[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


================
@@ -383,8 +427,17 @@ void CodeEmitterGen::emitInstructionBaseValues(
     if (const RecordVal *RV = R->getValue("EncodingInfos")) {
       if (auto *DI = dyn_cast_or_null<DefInit>(RV->getValue())) {
         EncodingInfoByHwMode EBM(DI->getDef(), HWM);
-        if (EBM.hasMode(HwMode))
+        if (EBM.hasMode(HwMode)) {
           EncodingDef = EBM.get(HwMode);
+        } else {
+          // If this Instr dosen't have this HwMode, just choose
+          // the encoding from the first HwMode. Otherwise, the encoding
+          // info would be empty.
----------------
nvjle wrote:

As mentioned in the comments regarding the lit test corresponding to this code, it is unclear to me why we would want to arbitrarily choose to assign an unused entry to the encoding for a different mode. Originally the value would ultimately end up zero, which seems to make more sense to me.

But even if this is kept, the comment is a bit garbled.

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


More information about the llvm-commits mailing list