[mlir][llvmir] Added extra builders for CallInstrinsicOp (#111664)

Extra builders for CallIntrinsicOp.
This is inspired by the comment from @antiagainst from
[here](https://github.com/llvm/llvm-project/pull/108933#issuecomment-2392751569).
This commit is contained in:
Finlay
2024-10-10 08:58:37 +01:00
committed by GitHub
parent 4dadf42c1a
commit 741ad3ab8e
2 changed files with 37 additions and 0 deletions

View File

@@ -1947,6 +1947,13 @@ def LLVM_CallIntrinsicOp
attr-dict
}];
let builders = [
OpBuilder<(ins "StringAttr":$intrin, "ValueRange":$args)>,
OpBuilder<(ins "StringAttr":$intrin, "ValueRange":$args, "FastmathFlagsAttr":$fastMathFlags)>,
OpBuilder<(ins "Type": $resultType, "StringAttr":$intrin, "ValueRange":$args)>,
OpBuilder<(ins "TypeRange": $resultTypes, "StringAttr":$intrin, "ValueRange":$args, "FastmathFlagsAttr":$fastMathFlags)>
];
let hasVerifier = 1;
}

View File

@@ -3328,6 +3328,36 @@ LogicalResult CallIntrinsicOp::verify() {
return success();
}
void CallIntrinsicOp::build(OpBuilder &builder, OperationState &state,
mlir::StringAttr intrin, mlir::ValueRange args) {
build(builder, state, /*resultTypes=*/TypeRange{}, intrin, args,
FastmathFlagsAttr{},
/*op_bundle_operands=*/{});
}
void CallIntrinsicOp::build(OpBuilder &builder, OperationState &state,
mlir::StringAttr intrin, mlir::ValueRange args,
mlir::LLVM::FastmathFlagsAttr fastMathFlags) {
build(builder, state, /*resultTypes=*/TypeRange{}, intrin, args,
fastMathFlags,
/*op_bundle_operands=*/{});
}
void CallIntrinsicOp::build(OpBuilder &builder, OperationState &state,
mlir::Type resultType, mlir::StringAttr intrin,
mlir::ValueRange args) {
build(builder, state, {resultType}, intrin, args, FastmathFlagsAttr{},
/*op_bundle_operands=*/{});
}
void CallIntrinsicOp::build(OpBuilder &builder, OperationState &state,
mlir::TypeRange resultTypes,
mlir::StringAttr intrin, mlir::ValueRange args,
mlir::LLVM::FastmathFlagsAttr fastMathFlags) {
build(builder, state, resultTypes, intrin, args, fastMathFlags,
/*op_bundle_operands=*/{});
}
//===----------------------------------------------------------------------===//
// OpAsmDialectInterface
//===----------------------------------------------------------------------===//