================
@@ -38,3 +38,25 @@ mlir::Value CIRGenBuilderTy::getArrayElement(mlir::Location
arrayLocBegin,
const mlir::Type flatPtrTy = basePtr.getType();
return create<cir::PtrStrideOp>(arrayLocEnd, flatPtrTy, basePtr, idx);
}
+
+cir::ConstantOp CIRGenBuilderTy::getConstInt(mlir::Location loc,
+ llvm::APSInt intVal) {
+ bool isSigned = intVal.isSigned();
+ unsigned width = intVal.getBitWidth();
+ cir::IntType t = isSigned ? getSIntNTy(width) : getUIntNTy(width);
+ return getConstInt(loc, t,
+ isSigned ? intVal.getSExtValue() : intVal.getZExtValue());
+}
+
+cir::ConstantOp CIRGenBuilderTy::getConstInt(mlir::Location loc,
+ llvm::APInt intVal) {
+ unsigned width = intVal.getBitWidth();
----------------
erichkeane wrote:
```suggestion
return getConstInt(loc, llvm::APSInt(intVal));
```
https://github.com/llvm/llvm-project/pull/142981
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits