Skip to content
This repository was archived by the owner on Apr 23, 2021. It is now read-only.

Commit e2fabe9

Browse files
Mahesh Ravishankartensorflower-gardener
authored andcommitted
Add a convenient operation build method for spirv::SelectOp
The SelectOp always has the same result type as its true/false value. Add a builder method that uses the operand type to get the result type. PiperOrigin-RevId: 277217978
1 parent c42cb08 commit e2fabe9

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

include/mlir/Dialect/SPIRV/SPIRVLogicalOps.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -858,6 +858,10 @@ def SPV_SelectOp : SPV_Op<"Select", [NoSideEffect]> {
858858
let results = (outs
859859
SPV_SelectType:$result
860860
);
861+
862+
let builders = [OpBuilder<[{Builder *builder, OperationState &state,
863+
Value *cond, Value *trueValue,
864+
Value *falseValue}]>];
861865
}
862866

863867
// -----

lib/Dialect/SPIRV/SPIRVOps.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1844,6 +1844,11 @@ static LogicalResult verify(spirv::ReturnValueOp retValOp) {
18441844
// spv.Select
18451845
//===----------------------------------------------------------------------===//
18461846

1847+
void spirv::SelectOp::build(Builder *builder, OperationState &state,
1848+
Value *cond, Value *trueValue, Value *falseValue) {
1849+
build(builder, state, trueValue->getType(), cond, trueValue, falseValue);
1850+
}
1851+
18471852
static ParseResult parseSelectOp(OpAsmParser &parser, OperationState &state) {
18481853
OpAsmParser::OperandType condition;
18491854
SmallVector<OpAsmParser::OperandType, 2> operands;

0 commit comments

Comments
 (0)