Skip to content

Commit

Permalink
Make exegesis conversion script use appropriate register class (#37)
Browse files Browse the repository at this point in the history
This patch fixes the register class that the BHive to Exegesis
conversion script uses. Currently it is only pulling in registers that
don't have a REX encoding, which doesn't even include R9-R15. This patch
fixes that behavior by using the more generic LLVM 64-bit GPR Register
class, but specifically looking at registers that don't require a REX2
encoding, as there is no hardware in the wild yet that supports APX.
  • Loading branch information
boomanaiden154 authored Feb 5, 2024
1 parent 7d528cc commit f782e79
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions gematria/datasets/convert_bhive_to_llvm_exegesis_input.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,25 +80,24 @@ int main(int argc, char* argv[]) {

// Iterate through all general purpose registers and vector registers
// and add them to the register definitions.
// TODO(9Temptest): Change GR64_NOREXRegClassID to GR64_NOREX2RegClassID when
// the LLVM version is bumped to avoid including the new APX GPRs (r16-r31)
// that have recently been added to LLVM.
for (unsigned i = 0;
i < reg_info.getRegClass(llvm::X86::GR64_NOREXRegClassID).getNumRegs();
++i) {
llvm::StringRef reg_name = reg_info.getName(
reg_info.getRegClass(llvm::X86::GR64_NOREXRegClassID).getRegister(i));
const auto& gr64_register_class =
reg_info.getRegClass(llvm::X86::GR64_NOREX2RegClassID);
for (unsigned i = 0; i < gr64_register_class.getNumRegs(); ++i) {
if (gr64_register_class.getRegister(i) == llvm::X86::RIP) continue;
llvm::StringRef reg_name =
reg_info.getName(gr64_register_class.getRegister(i));
register_defs_lines += llvm::Twine(kRegDefPrefix)
.concat(reg_name)
.concat(" ")
.concat(initial_reg_val_str)
.concat("\n")
.str();
}
for (unsigned i = 0;
i < reg_info.getRegClass(llvm::X86::VR128RegClassID).getNumRegs(); ++i) {
llvm::StringRef reg_name = reg_info.getName(
reg_info.getRegClass(llvm::X86::VR128RegClassID).getRegister(i));
const auto& vr128_register_class =
reg_info.getRegClass(llvm::X86::VR128RegClassID);
for (unsigned i = 0; i < vr128_register_class.getNumRegs(); ++i) {
llvm::StringRef reg_name =
reg_info.getName(vr128_register_class.getRegister(i));
register_defs_lines += llvm::Twine(kRegDefPrefix)
.concat(reg_name)
.concat(" ")
Expand Down

0 comments on commit f782e79

Please sign in to comment.