[clang] [CIR] Upstream minimal builtin function call support (PR #142981)
Andy Kaylor via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 5 11:46:03 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();
+ auto 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) {
+ auto width = intVal.getBitWidth();
----------------
andykaylor wrote:
```suggestion
unsigned width = intVal.getBitWidth();
```
https://github.com/llvm/llvm-project/pull/142981
More information about the cfe-commits
mailing list