Skip to content

Commit 741ad3a

Browse files
authored
[mlir][llvmir] Added extra builders for CallInstrinsicOp (#111664)
Extra builders for CallIntrinsicOp. This is inspired by the comment from @antiagainst from [here](#108933 (comment)).
1 parent 4dadf42 commit 741ad3a

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1947,6 +1947,13 @@ def LLVM_CallIntrinsicOp
19471947
attr-dict
19481948
}];
19491949

1950+
let builders = [
1951+
OpBuilder<(ins "StringAttr":$intrin, "ValueRange":$args)>,
1952+
OpBuilder<(ins "StringAttr":$intrin, "ValueRange":$args, "FastmathFlagsAttr":$fastMathFlags)>,
1953+
OpBuilder<(ins "Type": $resultType, "StringAttr":$intrin, "ValueRange":$args)>,
1954+
OpBuilder<(ins "TypeRange": $resultTypes, "StringAttr":$intrin, "ValueRange":$args, "FastmathFlagsAttr":$fastMathFlags)>
1955+
];
1956+
19501957
let hasVerifier = 1;
19511958
}
19521959

mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3328,6 +3328,36 @@ LogicalResult CallIntrinsicOp::verify() {
33283328
return success();
33293329
}
33303330

3331+
void CallIntrinsicOp::build(OpBuilder &builder, OperationState &state,
3332+
mlir::StringAttr intrin, mlir::ValueRange args) {
3333+
build(builder, state, /*resultTypes=*/TypeRange{}, intrin, args,
3334+
FastmathFlagsAttr{},
3335+
/*op_bundle_operands=*/{});
3336+
}
3337+
3338+
void CallIntrinsicOp::build(OpBuilder &builder, OperationState &state,
3339+
mlir::StringAttr intrin, mlir::ValueRange args,
3340+
mlir::LLVM::FastmathFlagsAttr fastMathFlags) {
3341+
build(builder, state, /*resultTypes=*/TypeRange{}, intrin, args,
3342+
fastMathFlags,
3343+
/*op_bundle_operands=*/{});
3344+
}
3345+
3346+
void CallIntrinsicOp::build(OpBuilder &builder, OperationState &state,
3347+
mlir::Type resultType, mlir::StringAttr intrin,
3348+
mlir::ValueRange args) {
3349+
build(builder, state, {resultType}, intrin, args, FastmathFlagsAttr{},
3350+
/*op_bundle_operands=*/{});
3351+
}
3352+
3353+
void CallIntrinsicOp::build(OpBuilder &builder, OperationState &state,
3354+
mlir::TypeRange resultTypes,
3355+
mlir::StringAttr intrin, mlir::ValueRange args,
3356+
mlir::LLVM::FastmathFlagsAttr fastMathFlags) {
3357+
build(builder, state, resultTypes, intrin, args, fastMathFlags,
3358+
/*op_bundle_operands=*/{});
3359+
}
3360+
33313361
//===----------------------------------------------------------------------===//
33323362
// OpAsmDialectInterface
33333363
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)