File: AllowDuplicateRegisterNames.td

package info (click to toggle)
swiftlang 6.2.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,856,264 kB
  • sloc: cpp: 9,995,718; ansic: 2,234,019; asm: 1,092,167; python: 313,940; objc: 82,726; f90: 80,126; lisp: 38,373; pascal: 25,580; sh: 20,378; ml: 5,058; perl: 4,751; makefile: 4,725; awk: 3,535; javascript: 3,018; xml: 918; fortran: 664; cs: 573; ruby: 396
file content (86 lines) | stat: -rw-r--r-- 2,627 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// RUN: llvm-tblgen -gen-asm-matcher -I %p/../../include %s | FileCheck %s

// Check that MatchRegisterName and MatchRegisterAltName are generated
// correctly when multiple registers are defined with the same name and
// AllowDuplicateRegisterNames is set.

include "llvm/Target/Target.td"

def ArchInstrInfo : InstrInfo;

def ArchAsmParser : AsmParser {
  let AllowDuplicateRegisterNames = 1;
  let ShouldEmitMatchRegisterAltName = 1;
}

def Arch : Target {
  let InstructionSet = ArchInstrInfo;
  let AssemblyParsers = [ArchAsmParser];
}

let Namespace = "Arch" in {
class ArchReg<string n, list <string> alt, list <RegAltNameIndex> altidx>
    : Register<n> {
  let AltNames = alt;
  let RegAltNameIndices = altidx;
}

def ABIRegAltName : RegAltNameIndex;

foreach i = 0...3 in {
  def R#i#_32 : ArchReg<"r"#i, ["x"#i], [ABIRegAltName]>;
  def R#i#_64 : ArchReg<"r"#i, ["x"#i], [ABIRegAltName]>;
}
} // Namespace = "Arch"

def GPR32 : RegisterClass<"Arch", [i32], 32, (add
    (sequence "R%u_32", 0, 3)
)>;

def GPR64 : RegisterClass<"Arch", [i64], 64, (add
    (sequence "R%u_64", 0, 3)
)>;

// CHECK: static MCRegister MatchRegisterName(StringRef Name) {
// CHECK:   switch (Name.size()) {
// CHECK:   default: break;
// CHECK:   case 2:  // 8 strings to match.
// CHECK:     if (Name[0] != 'r')
// CHECK:       break;
// CHECK:     switch (Name[1]) {
// CHECK:     default: break;
// CHECK:     case '0':  // 2 strings to match.
// CHECK:       return Arch::R0_32;  // "r0"
// CHECK:     case '1':  // 2 strings to match.
// CHECK:       return Arch::R1_32;  // "r1"
// CHECK:     case '2':  // 2 strings to match.
// CHECK:       return Arch::R2_32;  // "r2"
// CHECK:     case '3':  // 2 strings to match.
// CHECK:       return Arch::R3_32;  // "r3"
// CHECK:     }
// CHECK:     break;
// CHECK:   }
// CHECK:   return Arch::NoRegister;
// CHECK: }

// CHECK: static MCRegister MatchRegisterAltName(StringRef Name) {
// CHECK:   switch (Name.size()) {
// CHECK:   default: break;
// CHECK:   case 2:  // 8 strings to match.
// CHECK:     if (Name[0] != 'x')
// CHECK:       break;
// CHECK:     switch (Name[1]) {
// CHECK:     default: break;
// CHECK:     case '0':  // 2 strings to match.
// CHECK:       return Arch::R0_32;  // "x0"
// CHECK:     case '1':  // 2 strings to match.
// CHECK:       return Arch::R1_32;  // "x1"
// CHECK:     case '2':  // 2 strings to match.
// CHECK:       return Arch::R2_32;  // "x2"
// CHECK:     case '3':  // 2 strings to match.
// CHECK:       return Arch::R3_32;  // "x3"
// CHECK:     }
// CHECK:     break;
// CHECK:   }
// CHECK:   return Arch::NoRegister;
// CHECK: }