[clang] [CIR] Upstream get_bitfield operation to load bit-field members from structs (PR #145971)

Andy Kaylor via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 27 16:56:02 PDT 2025


================
@@ -2244,6 +2245,54 @@ mlir::LogicalResult CIRToLLVMComplexImagOpLowering::matchAndRewrite(
   return mlir::success();
 }
 
+mlir::LogicalResult CIRToLLVMGetBitfieldOpLowering::matchAndRewrite(
+    cir::GetBitfieldOp op, OpAdaptor adaptor,
+    mlir::ConversionPatternRewriter &rewriter) const {
+
+  mlir::OpBuilder::InsertionGuard guard(rewriter);
+  rewriter.setInsertionPoint(op);
+
+  cir::BitfieldInfoAttr info = op.getBitfieldInfo();
+  uint64_t size = info.getSize();
+  uint64_t offset = info.getOffset();
+  mlir::Type storageType = info.getStorageType();
+  mlir::MLIRContext *context = storageType.getContext();
+  unsigned storageSize = 0;
+
+  if (auto arTy = mlir::dyn_cast<cir::ArrayType>(storageType))
----------------
andykaylor wrote:

Can this still happen? I thought after your recent change to align with classic codegen we wouldn't generate arrays anymore.

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


More information about the cfe-commits mailing list