Skip to content

Commit 5c7a696

Browse files
authored
[ARM] Migrate from SearchableTable to GenericTable. NFC (#121840)
SearchableTable is the legacy version that does not appear to be well documented. Not sure if the plan was to delete it eventually. The enum from SearchableTable does not appear to be used so I did not add a GenericEnum. MClassSysReg assigned EnumValueField 3 times, but rather than creating 3 enums, this overwrites the previous assignment. We can eventually use the PrimaryKey feature of GenericTable to remove one of the SearchIndex declarations. This will sort the generated table by the primary key and remove the separately generated indexing table to reduce .rodata size. This patch is just the mechanical migration. The size savings will be done in follow ups.
1 parent afa8aee commit 5c7a696

File tree

3 files changed

+45
-14
lines changed

3 files changed

+45
-14
lines changed

llvm/lib/Target/ARM/ARMSystemRegister.td

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,13 @@ class MClassSysReg<bits<1> UniqMask1,
1919
bits<1> UniqMask2,
2020
bits<1> UniqMask3,
2121
bits<12> Enc12,
22-
string name> : SearchableTable {
23-
let SearchableFields = ["Name", "M1Encoding12", "M2M3Encoding8", "Encoding"];
22+
string name> {
2423
string Name;
2524
bits<13> M1Encoding12;
2625
bits<10> M2M3Encoding8;
2726
bits<12> Encoding;
2827

2928
let Name = name;
30-
let EnumValueField = "M1Encoding12";
31-
let EnumValueField = "M2M3Encoding8";
32-
let EnumValueField = "Encoding";
3329

3430
let M1Encoding12{12} = UniqMask1;
3531
let M1Encoding12{11-00} = Enc12;
@@ -41,6 +37,27 @@ class MClassSysReg<bits<1> UniqMask1,
4137
code Requires = [{ {} }];
4238
}
4339

40+
def MClassSysRegsList : GenericTable {
41+
let FilterClass = "MClassSysReg";
42+
let Fields = ["Name", "M1Encoding12", "M2M3Encoding8", "Encoding",
43+
"Requires"];
44+
}
45+
46+
def lookupMClassSysRegByName : SearchIndex {
47+
let Table = MClassSysRegsList;
48+
let Key = ["Name"];
49+
}
50+
51+
def lookupMClassSysRegByM1Encoding12 : SearchIndex {
52+
let Table = MClassSysRegsList;
53+
let Key = ["M1Encoding12"];
54+
}
55+
56+
def lookupMClassSysRegByM2M3Encoding8 : SearchIndex {
57+
let Table = MClassSysRegsList;
58+
let Key = ["M2M3Encoding8"];
59+
}
60+
4461
// [|i|e|x]apsr_nzcvq has alias [|i|e|x]apsr.
4562
// Mask1 Mask2 Mask3 Enc12, Name
4663
let Requires = [{ {ARM::FeatureDSP} }] in {
@@ -127,15 +144,29 @@ def : MClassSysReg<0, 0, 1, 0x8a7, "pac_key_u_3_ns">;
127144

128145
// Banked Registers
129146
//
130-
class BankedReg<string name, bits<8> enc>
131-
: SearchableTable {
147+
class BankedReg<string name, bits<8> enc> {
132148
string Name;
133149
bits<8> Encoding;
134150
let Name = name;
135151
let Encoding = enc;
136-
let SearchableFields = ["Name", "Encoding"];
137152
}
138153

154+
def BankedRegsList : GenericTable {
155+
let FilterClass = "BankedReg";
156+
let Fields = ["Name", "Encoding"];
157+
}
158+
159+
def lookupBankedRegByName : SearchIndex {
160+
let Table = BankedRegsList;
161+
let Key = ["Name"];
162+
}
163+
164+
def lookupBankedRegByEncoding : SearchIndex {
165+
let Table = BankedRegsList;
166+
let Key = ["Encoding"];
167+
}
168+
169+
139170
// The values here come from B9.2.3 of the ARM ARM, where bits 4-0 are SysM
140171
// and bit 5 is R.
141172
def : BankedReg<"r8_usr", 0x00>;

llvm/lib/Target/ARM/Utils/ARMBaseInfo.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@ const MClassSysReg *lookupMClassSysRegBy8bitSYSmValue(unsigned SYSm) {
6262
return ARMSysReg::lookupMClassSysRegByM2M3Encoding8((1<<8)|(SYSm & 0xFF));
6363
}
6464

65-
#define GET_MCLASSSYSREG_IMPL
65+
#define GET_MClassSysRegsList_IMPL
6666
#include "ARMGenSystemRegister.inc"
6767

6868
} // end namespace ARMSysReg
6969

7070
namespace ARMBankedReg {
71-
#define GET_BANKEDREG_IMPL
71+
#define GET_BankedRegsList_IMPL
7272
#include "ARMGenSystemRegister.inc"
7373
} // end namespce ARMSysReg
7474
} // end namespace llvm

llvm/lib/Target/ARM/Utils/ARMBaseInfo.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,8 @@ namespace ARMSysReg {
206206
}
207207
};
208208

209-
#define GET_MCLASSSYSREG_DECL
210-
#include "ARMGenSystemRegister.inc"
209+
#define GET_MClassSysRegsList_DECL
210+
#include "ARMGenSystemRegister.inc"
211211

212212
// lookup system register using 12-bit SYSm value.
213213
// Note: the search is uniqued using M1 mask
@@ -228,8 +228,8 @@ namespace ARMBankedReg {
228228
const char *Name;
229229
uint16_t Encoding;
230230
};
231-
#define GET_BANKEDREG_DECL
232-
#include "ARMGenSystemRegister.inc"
231+
#define GET_BankedRegsList_DECL
232+
#include "ARMGenSystemRegister.inc"
233233
} // end namespace ARMBankedReg
234234

235235
} // end namespace llvm

0 commit comments

Comments
 (0)