================
@@ -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))
+    storageSize = arTy.getSize() * 8;
+  else if (auto intTy = mlir::dyn_cast<cir::IntType>(storageType))
+    storageSize = intTy.getWidth();
+  else
+    llvm_unreachable(
+        "Either ArrayType or IntType expected for bitfields storage");
+
+  mlir::IntegerType intType = mlir::IntegerType::get(context, storageSize);
----------------
andykaylor wrote:

I don't like having `intType` here right after `intTy` above, but if we don't 
need to handle arrays that should go away.

https://github.com/llvm/llvm-project/pull/145971
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to