[llvm] [TableGen] Use bitwise operations to access HwMode ID. (PR #88377)

Jason Eckhardt via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 17 20:43:51 PDT 2024


================
@@ -290,11 +290,55 @@ CodeEmitterGen::getInstructionCases(Record *R, CodeGenTarget &Target) {
     if (auto *DI = dyn_cast_or_null<DefInit>(RV->getValue())) {
       const CodeGenHwModes &HWM = Target.getHwModes();
       EncodingInfoByHwMode EBM(DI->getDef(), HWM);
+      unsigned EncodingHwModesInBits = DefaultMode;
+      for (auto &[ModeId, Encoding] : EBM) {
+        // DefaultMode is 0, skip it.
+        if (ModeId != DefaultMode)
+          EncodingHwModesInBits |= (1 << (ModeId - 1));
+      }
+
+      // Get HwModes for this Instr by bitwise AND operations,
+      // and find the table to which this instr and hwmode belong.
----------------
nvjle wrote:

Nit: Be consistent in the prose-- we use `Instr` here and then `instr` there, and `HwModes` here vs `hwmode` there. And just say "mask" rather than the long-winded "by bitwise AND oeprations".

 I'd probably just write "Get the applicable hardware modes for this instruction by masking off the relevant bits."

https://github.com/llvm/llvm-project/pull/88377


More information about the llvm-commits mailing list