@@ -1140,6 +1140,15 @@ 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 ( ) {
1145
+ exists ( SourceVariable sv , IRBlock bb , int i , UseImpl use |
1146
+ ssaDefReachesRead ( sv , this , bb , i ) and
1147
+ use .hasIndexInBlock ( bb , i , sv ) and
1148
+ result = use .getNode ( )
1149
+ )
1150
+ }
1151
+
1143
1152
/**
1144
1153
* INTERNAL: Do not use.
1145
1154
*/
@@ -1172,4 +1181,54 @@ class Definition extends SsaImpl::Definition {
1172
1181
Type getUnspecifiedType ( ) { result = this .getUnderlyingType ( ) .getUnspecifiedType ( ) }
1173
1182
}
1174
1183
1184
+ /**
1185
+ * An SSA definition that corresponds to an explicit definition.
1186
+ */
1187
+ class ExplicitDefinition extends Definition , SsaImpl:: WriteDefinition {
1188
+ DefImpl def ;
1189
+
1190
+ ExplicitDefinition ( ) {
1191
+ exists ( IRBlock bb , int i , SourceVariable sv |
1192
+ this .definesAt ( sv , bb , i ) and
1193
+ def .hasIndexInBlock ( sv , bb , i )
1194
+ )
1195
+ }
1196
+
1197
+ /**
1198
+ * Gets the `Node` computing the value that is written by this SSA definition.
1199
+ */
1200
+ Node getAssignedValue ( ) { result .asInstruction ( ) = def .getValue ( ) .asInstruction ( ) }
1201
+ }
1202
+
1203
+ /**
1204
+ * An explicit SSA definition that writes an indirect value to a pointer.
1205
+ *
1206
+ * For example in:
1207
+ * ```cpp
1208
+ * int x = 42; // (1)
1209
+ * int* p = &x; // (2)
1210
+ * ```
1211
+ * There are three `ExplicitDefinition`:
1212
+ * 1. A `DirectExplicitDefinition` at (1) which writes `42` to the SSA variable
1213
+ * corresponding to `x`.
1214
+ * 2. A `DirectExplicitDefinition` at (2) which writes `&x` to the SSA variable
1215
+ * corresponding to `p`.
1216
+ * 3. A `IndirectExplicitDefinition` at (2) which writes `*&x` (i.e., `x`) to
1217
+ * the SSA vairable corresponding to `*p`.
1218
+ */
1219
+ class IndirectExplicitDefinition extends ExplicitDefinition {
1220
+ IndirectExplicitDefinition ( ) { this .getIndirectionIndex ( ) > 0 }
1221
+ }
1222
+
1223
+ /**
1224
+ * An SSA definition that corresponds to an explicit definition.
1225
+ *
1226
+ * Unlike `ExplicitDefinition` this class does not include indirect
1227
+ * explicit definition. See `IndirectExplicitDefinition` if you want to include
1228
+ * those.
1229
+ */
1230
+ class DirectExplicitDefinition extends ExplicitDefinition {
1231
+ DirectExplicitDefinition ( ) { this .getIndirectionIndex ( ) = 0 }
1232
+ }
1233
+
1175
1234
import SsaCached
0 commit comments