[llvm] [IR] Implementation and lowering of bitinsert and bitextract (PR #200605)

Antonio Frighetto via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 16 04:22:17 PDT 2026


================
@@ -5636,6 +5644,41 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
       break;
     }
 
+    case bitc::FUNC_CODE_INST_BITINSERT: { // BITINSERT: [ty, opval, opval,
+                                           // opval]
+      unsigned OpNum = 0;
+      Value *Base, *Val, *Offset;
+      unsigned BaseTypeID, ValTypeID, OffsetTypeID;
+      if (getValueTypePair(Record, OpNum, NextValueNo, Base, BaseTypeID,
+                           CurBB) ||
+          getValueTypePair(Record, OpNum, NextValueNo, Val, ValTypeID, CurBB) ||
+          getValueTypePair(Record, OpNum, NextValueNo, Offset, OffsetTypeID,
+                           CurBB))
+        return error("Invalid bitinsert record");
+      I = BitInsertInst::Create(Base, Val, Offset);
+      ResTypeID = BaseTypeID;
+      InstructionList.push_back(I);
+      break;
+    }
+
+    case bitc::FUNC_CODE_INST_BITEXTRACT: { // BITEXTRACT: [ty, opval, opval]
+      unsigned OpNum = 0;
+      if (Record.empty())
+        return error("Record is empty for bitextract");
+      unsigned TypeID = Record[OpNum++];
+      Type *ResTy = getTypeByID(TypeID);
----------------
antoniofrighetto wrote:

```suggestion
      Type *ResTy = getTypeByID(TypeID);
      if (!ResTy)
        return error("Invalid bitextract result type");
```

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


More information about the llvm-commits mailing list