Skip to content

Commit

Permalink
[ARM] Migrate from SearchableTable to GenericTable. NFC (llvm#121840)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
topperc authored Jan 7, 2025
1 parent afa8aee commit 5c7a696
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 14 deletions.
47 changes: 39 additions & 8 deletions llvm/lib/Target/ARM/ARMSystemRegister.td
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,13 @@ class MClassSysReg<bits<1> UniqMask1,
bits<1> UniqMask2,
bits<1> UniqMask3,
bits<12> Enc12,
string name> : SearchableTable {
let SearchableFields = ["Name", "M1Encoding12", "M2M3Encoding8", "Encoding"];
string name> {
string Name;
bits<13> M1Encoding12;
bits<10> M2M3Encoding8;
bits<12> Encoding;

let Name = name;
let EnumValueField = "M1Encoding12";
let EnumValueField = "M2M3Encoding8";
let EnumValueField = "Encoding";

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

def MClassSysRegsList : GenericTable {
let FilterClass = "MClassSysReg";
let Fields = ["Name", "M1Encoding12", "M2M3Encoding8", "Encoding",
"Requires"];
}

def lookupMClassSysRegByName : SearchIndex {
let Table = MClassSysRegsList;
let Key = ["Name"];
}

def lookupMClassSysRegByM1Encoding12 : SearchIndex {
let Table = MClassSysRegsList;
let Key = ["M1Encoding12"];
}

def lookupMClassSysRegByM2M3Encoding8 : SearchIndex {
let Table = MClassSysRegsList;
let Key = ["M2M3Encoding8"];
}

// [|i|e|x]apsr_nzcvq has alias [|i|e|x]apsr.
// Mask1 Mask2 Mask3 Enc12, Name
let Requires = [{ {ARM::FeatureDSP} }] in {
Expand Down Expand Up @@ -127,15 +144,29 @@ def : MClassSysReg<0, 0, 1, 0x8a7, "pac_key_u_3_ns">;

// Banked Registers
//
class BankedReg<string name, bits<8> enc>
: SearchableTable {
class BankedReg<string name, bits<8> enc> {
string Name;
bits<8> Encoding;
let Name = name;
let Encoding = enc;
let SearchableFields = ["Name", "Encoding"];
}

def BankedRegsList : GenericTable {
let FilterClass = "BankedReg";
let Fields = ["Name", "Encoding"];
}

def lookupBankedRegByName : SearchIndex {
let Table = BankedRegsList;
let Key = ["Name"];
}

def lookupBankedRegByEncoding : SearchIndex {
let Table = BankedRegsList;
let Key = ["Encoding"];
}


// The values here come from B9.2.3 of the ARM ARM, where bits 4-0 are SysM
// and bit 5 is R.
def : BankedReg<"r8_usr", 0x00>;
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Target/ARM/Utils/ARMBaseInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ const MClassSysReg *lookupMClassSysRegBy8bitSYSmValue(unsigned SYSm) {
return ARMSysReg::lookupMClassSysRegByM2M3Encoding8((1<<8)|(SYSm & 0xFF));
}

#define GET_MCLASSSYSREG_IMPL
#define GET_MClassSysRegsList_IMPL
#include "ARMGenSystemRegister.inc"

} // end namespace ARMSysReg

namespace ARMBankedReg {
#define GET_BANKEDREG_IMPL
#define GET_BankedRegsList_IMPL
#include "ARMGenSystemRegister.inc"
} // end namespce ARMSysReg
} // end namespace llvm
8 changes: 4 additions & 4 deletions llvm/lib/Target/ARM/Utils/ARMBaseInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ namespace ARMSysReg {
}
};

#define GET_MCLASSSYSREG_DECL
#include "ARMGenSystemRegister.inc"
#define GET_MClassSysRegsList_DECL
#include "ARMGenSystemRegister.inc"

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

} // end namespace llvm
Expand Down

0 comments on commit 5c7a696

Please sign in to comment.