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

Alexis Engelke via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 16 07:13:03 PDT 2026


================
@@ -2630,6 +2630,57 @@ Type *ExtractValueInst::getIndexedType(Type *Agg,
   return Agg;
 }
 
+//===----------------------------------------------------------------------===//
+//                             BitInsert Class
+//===----------------------------------------------------------------------===//
+BitInsertInst::BitInsertInst(Value *Base, Value *Val, Value *Offset,
+                             const Twine &Name, InsertPosition InsertBef)
+    : Instruction(Base->getType(), BitInsert, AllocMarker, InsertBef) {
+  assert(isValidOperands(Base, Val, Offset) &&
+         "Invalid bitinsert instruction operands!");
+  Op<0>() = Base;
+  Op<1>() = Val;
+  Op<2>() = Offset;
+  setName(Name);
+}
+
+bool BitInsertInst::isValidOperands(const Value *Base, const Value *Val,
+                                    const Value *Offset) {
+  if (!Base->getType()->isByteTy())
+    return false;
+  if (!Val->getType()->isSingleValueType() || Val->getType()->isVectorTy() ||
+      Val->getType()->isTargetExtTy() || Val->getType()->isX86_AMXTy())
----------------
aengelke wrote:

At this point... spell out isFloatingPointTy, isIntegerTy, isPointerTy, isByteTy -- easier to understand.

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


More information about the llvm-commits mailing list