Skip to content

Commit 82cb989

Browse files
committed
[Test] Indicate insts with vals.
If a value is defined by an instruction, it's often more convenient to specify the instruction by the value.
1 parent 8417f51 commit 82cb989

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

include/swift/SIL/ParseTestSpecification.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,15 @@ struct Arguments {
186186
}
187187
Operand *takeOperand() { return takeInstance<OperandArgument>("operand"); }
188188
SILInstruction *takeInstruction() {
189-
return takeInstance<InstructionArgument>("instruction");
189+
auto argument = takeArgument();
190+
if (isa<ValueArgument>(argument)) {
191+
auto value = cast<ValueArgument>(argument).getValue();
192+
auto *definingInstruction = value.getDefiningInstruction();
193+
assert(definingInstruction &&
194+
"selected instruction via argument value!?");
195+
return definingInstruction;
196+
}
197+
return getInstance<InstructionArgument>("instruction", argument);
190198
}
191199
SILArgument *takeBlockArgument() {
192200
return takeInstance<BlockArgumentArgument>("block argument");

0 commit comments

Comments
 (0)