@@ -1140,12 +1140,33 @@ class Definition extends SsaImpl::Definition {
1140
1140
not result instanceof PhiNode
1141
1141
}
1142
1142
1143
- /** Gets a `Node ` that represents a use of this definition. */
1144
- Node getAUse ( ) {
1143
+ /** Gets an `Operand ` that represents a use of this definition. */
1144
+ Operand getAUse ( ) {
1145
1145
exists ( SourceVariable sv , IRBlock bb , int i , UseImpl use |
1146
1146
ssaDefReachesRead ( sv , this , bb , i ) and
1147
1147
use .hasIndexInBlock ( bb , i , sv ) and
1148
- result = use .getNode ( )
1148
+ result = use .getNode ( ) .asOperand ( )
1149
+ )
1150
+ }
1151
+
1152
+ /**
1153
+ * Gets an `Operand` that represents an indirect use of this definition.
1154
+ *
1155
+ * The use is indirect because the operand represents a pointer that points
1156
+ * to the value written by this definition. For example in:
1157
+ * ```cpp
1158
+ * 1. int x = 42;
1159
+ * 2. int* p = &x;
1160
+ * ```
1161
+ * There is an `ExplicitDefinition` corresponding to `x = 42` on line 1 and
1162
+ * the definition has an indirect use on line 2 because `&x` points to the
1163
+ * value that was defined by the definition.
1164
+ */
1165
+ Operand getAnIndirectUse ( int indirectionIndex ) {
1166
+ exists ( SourceVariable sv , IRBlock bb , int i , UseImpl use |
1167
+ ssaDefReachesRead ( sv , this , bb , i ) and
1168
+ use .hasIndexInBlock ( bb , i , sv ) and
1169
+ result = use .getNode ( ) .asIndirectOperand ( indirectionIndex )
1149
1170
)
1150
1171
}
1151
1172
@@ -1195,9 +1216,18 @@ class ExplicitDefinition extends Definition, SsaImpl::WriteDefinition {
1195
1216
}
1196
1217
1197
1218
/**
1198
- * Gets the `Node` computing the value that is written by this SSA definition.
1219
+ * Gets the `Instruction` computing the value that is written to the
1220
+ * associated SSA variable by this SSA definition.
1221
+ *
1222
+ * If `this.getIndirectionIndex() = 0` (i.e., if `this` is an instance of
1223
+ * `DirectExplicitDefinition`) then the SSA variable is present in the source
1224
+ * code.
1225
+ * However, if `this.getIndirectionIndex() > 0` (i.e., if `this` is an
1226
+ * instance of `IndirectExplicitDefinition`) then the SSA variable associated
1227
+ * with this definition represents the memory pointed to by a variable in the
1228
+ * source code.
1199
1229
*/
1200
- Node getAssignedValue ( ) { result . asInstruction ( ) = def .getValue ( ) .asInstruction ( ) }
1230
+ Instruction getAssignedInstruction ( ) { result = def .getValue ( ) .asInstruction ( ) }
1201
1231
}
1202
1232
1203
1233
/**
0 commit comments