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
This commit is contained in:
Mahesh Ravishankar 2019-10-28 23:03:54 -07:00 committed by A. Unique TensorFlower
parent ca2538e9a7
commit 61225d678e
2 changed files with 9 additions and 0 deletions

View File

@ -858,6 +858,10 @@ def SPV_SelectOp : SPV_Op<"Select", [NoSideEffect]> {
let results = (outs
SPV_SelectType:$result
);
let builders = [OpBuilder<[{Builder *builder, OperationState &state,
Value *cond, Value *trueValue,
Value *falseValue}]>];
}
// -----

View File

@ -1844,6 +1844,11 @@ static LogicalResult verify(spirv::ReturnValueOp retValOp) {
// spv.Select
//===----------------------------------------------------------------------===//
void spirv::SelectOp::build(Builder *builder, OperationState &state,
Value *cond, Value *trueValue, Value *falseValue) {
build(builder, state, trueValue->getType(), cond, trueValue, falseValue);
}
static ParseResult parseSelectOp(OpAsmParser &parser, OperationState &state) {
OpAsmParser::OperandType condition;
SmallVector<OpAsmParser::OperandType, 2> operands;