Subzero: Provide a macro for iterating over instruction variables.
This makes it easier and less error-prone to implement the relatively common
pattern of looking at all the Variable operands contained within an instruction.
BUG= none
R=stichnot@chromium.org
Review URL: https://codereview.chromium.org/1323693002.
diff --git a/src/IceOperand.cpp b/src/IceOperand.cpp
index 32316ba..c10656f 100644
--- a/src/IceOperand.cpp
+++ b/src/IceOperand.cpp
@@ -18,6 +18,7 @@
#include "IceCfg.h"
#include "IceCfgNode.h"
#include "IceInst.h"
+#include "IceInstVarIter.h"
#include "IceTargetLowering.h" // dumping stack/frame pointer register
namespace Ice {
@@ -328,16 +329,11 @@
assert(DestNum < Metadata.size());
Metadata[DestNum].markDef(Kind, &I, Node);
}
- for (SizeT SrcNum = 0; SrcNum < I.getSrcSize(); ++SrcNum) {
- Operand *Src = I.getSrc(SrcNum);
- SizeT NumVars = Src->getNumVars();
- for (SizeT J = 0; J < NumVars; ++J) {
- const Variable *Var = Src->getVar(J);
- SizeT VarNum = Var->getIndex();
- assert(VarNum < Metadata.size());
- constexpr bool IsImplicit = false;
- Metadata[VarNum].markUse(Kind, &I, Node, IsImplicit);
- }
+ FOREACH_VAR_IN_INST(Var, I) {
+ SizeT VarNum = Var->getIndex();
+ assert(VarNum < Metadata.size());
+ constexpr bool IsImplicit = false;
+ Metadata[VarNum].markUse(Kind, &I, Node, IsImplicit);
}
}
}