1 // RUN: llvm-tblgen -gen-register-info -I %p/../../include -I %p/Common %s | FileCheck %s
3 include "llvm/Target/Target.td"
5 let Namespace = "MyTarget" in {
6 def R0 : Register<"r0">; // base class BaseA
7 def R1 : Register<"r1">; // base class BaseA
8 def R2 : Register<"r2">; // base class BaseC
9 def R3 : Register<"r3">; // base class BaseC
10 def R4 : Register<"r4">; // base class BaseB
11 def R5 : Register<"r5">; // base class BaseB
12 def R6 : Register<"r6">; // no base class
13 } // Namespace = "MyTarget"
16 // BaseA and BaseB are equal ordered so enumeration order determines base class for overlaps
17 def BaseA : RegisterClass<"MyTarget", [i32], 32, (sequence "R%u", 0, 3)> {
18 let BaseClassOrder = 1;
20 def BaseB : RegisterClass<"MyTarget", [i32], 32, (sequence "R%u", 3, 5)> {
21 let BaseClassOrder = 1;
24 // BaseC defined order overrides BaseA and BaseB
25 def BaseC : RegisterClass<"MyTarget", [i32], 32, (sequence "R%u", 2, 3)> {
26 let BaseClassOrder = 0;
29 def MyTarget : Target;
31 // CHECK: static const uint16_t Mapping[8] = {
32 // CHECK-NEXT: InvalidRegClassID, // NoRegister
33 // CHECK-NEXT: MyTarget::BaseARegClassID, // R0
34 // CHECK-NEXT: MyTarget::BaseARegClassID, // R1
35 // CHECK-NEXT: MyTarget::BaseCRegClassID, // R2
36 // CHECK-NEXT: MyTarget::BaseCRegClassID, // R3
37 // CHECK-NEXT: MyTarget::BaseBRegClassID, // R4
38 // CHECK-NEXT: MyTarget::BaseBRegClassID, // R5
39 // CHECK-NEXT: InvalidRegClassID, // R6