[clang] [CIR] Upstream minimal builtin function call support (PR #142981)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 9 09:21:26 PDT 2025
================
@@ -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
More information about the cfe-commits
mailing list