Return operand_range instead for generated variadic operands accessor.

PiperOrigin-RevId: 239959381
This commit is contained in:
Jacques Pienaar 2019-03-23 10:36:55 -07:00 committed by jpienaar
parent 39fa23feca
commit b236041b93
2 changed files with 7 additions and 9 deletions

View File

@ -32,7 +32,7 @@ def NS_AOp : Op<"a_op", [NoSideEffect]> {
// CHECK: public:
// CHECK: static StringRef getOperationName();
// CHECK: Value *a();
// CHECK: SmallVector<Value *, 4> b();
// CHECK: Instruction::operand_range b();
// CHECK: Value *r();
// CHECK: APInt attr1();
// CHECK: Optional< APFloat > attr2();

View File

@ -485,14 +485,12 @@ void OpEmitter::genNamedOperandGetters() {
} else {
assert(i + 1 == e && "only the last operand can be variadic");
const char *const code1 =
R"( assert(getInstruction()->getNumOperands() >= {0});
SmallVector<Value *, 4> operands(
std::next(getInstruction()->operand_begin(), {0}),
getInstruction()->operand_end());
return operands;)";
auto &m = opClass.newMethod("SmallVector<Value *, 4>", operand.name);
m.body() << formatv(code1, i);
const char *const code = R"(
assert(getInstruction()->getNumOperands() >= {0});
return {std::next(operand_begin(), {0}), operand_end()};
)";
auto &m = opClass.newMethod("Instruction::operand_range", operand.name);
m.body() << formatv(code, i);
}
}
}