11private import internal.ValueNumberingInternal
2- private import cpp
2+ private import internal.ValueNumberingImports
33private import IR
44
55/**
@@ -23,31 +23,31 @@ newtype TValueNumber =
2323 initializeParameterValueNumber ( _, irFunc , var )
2424 } or
2525 TInitializeThisValueNumber ( IRFunction irFunc ) { initializeThisValueNumber ( _, irFunc ) } or
26- TConstantValueNumber ( IRFunction irFunc , Type type , string value ) {
26+ TConstantValueNumber ( IRFunction irFunc , IRType type , string value ) {
2727 constantValueNumber ( _, irFunc , type , value )
2828 } or
29- TStringConstantValueNumber ( IRFunction irFunc , Type type , string value ) {
29+ TStringConstantValueNumber ( IRFunction irFunc , IRType type , string value ) {
3030 stringConstantValueNumber ( _, irFunc , type , value )
3131 } or
32- TFieldAddressValueNumber ( IRFunction irFunc , Field field , ValueNumber objectAddress ) {
32+ TFieldAddressValueNumber ( IRFunction irFunc , Language :: Field field , ValueNumber objectAddress ) {
3333 fieldAddressValueNumber ( _, irFunc , field , objectAddress )
3434 } or
3535 TBinaryValueNumber (
36- IRFunction irFunc , Opcode opcode , Type type , ValueNumber leftOperand , ValueNumber rightOperand
36+ IRFunction irFunc , Opcode opcode , IRType type , ValueNumber leftOperand , ValueNumber rightOperand
3737 ) {
3838 binaryValueNumber ( _, irFunc , opcode , type , leftOperand , rightOperand )
3939 } or
4040 TPointerArithmeticValueNumber (
41- IRFunction irFunc , Opcode opcode , Type type , int elementSize , ValueNumber leftOperand ,
41+ IRFunction irFunc , Opcode opcode , IRType type , int elementSize , ValueNumber leftOperand ,
4242 ValueNumber rightOperand
4343 ) {
4444 pointerArithmeticValueNumber ( _, irFunc , opcode , type , elementSize , leftOperand , rightOperand )
4545 } or
46- TUnaryValueNumber ( IRFunction irFunc , Opcode opcode , Type type , ValueNumber operand ) {
46+ TUnaryValueNumber ( IRFunction irFunc , Opcode opcode , IRType type , ValueNumber operand ) {
4747 unaryValueNumber ( _, irFunc , opcode , type , operand )
4848 } or
4949 TInheritanceConversionValueNumber (
50- IRFunction irFunc , Opcode opcode , Class baseClass , Class derivedClass , ValueNumber operand
50+ IRFunction irFunc , Opcode opcode , Language :: Class baseClass , Language :: Class derivedClass , ValueNumber operand
5151 ) {
5252 inheritanceConversionValueNumber ( _, irFunc , opcode , baseClass , derivedClass , operand )
5353 } or
@@ -59,7 +59,7 @@ newtype TValueNumber =
5959class ValueNumber extends TValueNumber {
6060 final string toString ( ) { result = getExampleInstruction ( ) .getResultId ( ) }
6161
62- final Location getLocation ( ) { result = getExampleInstruction ( ) .getLocation ( ) }
62+ final Language :: Location getLocation ( ) { result = getExampleInstruction ( ) .getLocation ( ) }
6363
6464 /**
6565 * Gets the instructions that have been assigned this value number. This will always produce at
@@ -150,67 +150,67 @@ private predicate initializeThisValueNumber(InitializeThisInstruction instr, IRF
150150}
151151
152152private predicate constantValueNumber (
153- ConstantInstruction instr , IRFunction irFunc , Type type , string value
153+ ConstantInstruction instr , IRFunction irFunc , IRType type , string value
154154) {
155155 instr .getEnclosingIRFunction ( ) = irFunc and
156- instr .getResultType ( ) = type and
156+ instr .getResultIRType ( ) = type and
157157 instr .getValue ( ) = value
158158}
159159
160160private predicate stringConstantValueNumber (
161- StringConstantInstruction instr , IRFunction irFunc , Type type , string value
161+ StringConstantInstruction instr , IRFunction irFunc , IRType type , string value
162162) {
163163 instr .getEnclosingIRFunction ( ) = irFunc and
164- instr .getResultType ( ) = type and
164+ instr .getResultIRType ( ) = type and
165165 instr .getValue ( ) .getValue ( ) = value
166166}
167167
168168private predicate fieldAddressValueNumber (
169- FieldAddressInstruction instr , IRFunction irFunc , Field field , ValueNumber objectAddress
169+ FieldAddressInstruction instr , IRFunction irFunc , Language :: Field field , ValueNumber objectAddress
170170) {
171171 instr .getEnclosingIRFunction ( ) = irFunc and
172172 instr .getField ( ) = field and
173173 valueNumber ( instr .getObjectAddress ( ) ) = objectAddress
174174}
175175
176176private predicate binaryValueNumber (
177- BinaryInstruction instr , IRFunction irFunc , Opcode opcode , Type type , ValueNumber leftOperand ,
177+ BinaryInstruction instr , IRFunction irFunc , Opcode opcode , IRType type , ValueNumber leftOperand ,
178178 ValueNumber rightOperand
179179) {
180180 instr .getEnclosingIRFunction ( ) = irFunc and
181181 not instr instanceof PointerArithmeticInstruction and
182182 instr .getOpcode ( ) = opcode and
183- instr .getResultType ( ) = type and
183+ instr .getResultIRType ( ) = type and
184184 valueNumber ( instr .getLeft ( ) ) = leftOperand and
185185 valueNumber ( instr .getRight ( ) ) = rightOperand
186186}
187187
188188private predicate pointerArithmeticValueNumber (
189- PointerArithmeticInstruction instr , IRFunction irFunc , Opcode opcode , Type type , int elementSize ,
189+ PointerArithmeticInstruction instr , IRFunction irFunc , Opcode opcode , IRType type , int elementSize ,
190190 ValueNumber leftOperand , ValueNumber rightOperand
191191) {
192192 instr .getEnclosingIRFunction ( ) = irFunc and
193193 instr .getOpcode ( ) = opcode and
194- instr .getResultType ( ) = type and
194+ instr .getResultIRType ( ) = type and
195195 instr .getElementSize ( ) = elementSize and
196196 valueNumber ( instr .getLeft ( ) ) = leftOperand and
197197 valueNumber ( instr .getRight ( ) ) = rightOperand
198198}
199199
200200private predicate unaryValueNumber (
201- UnaryInstruction instr , IRFunction irFunc , Opcode opcode , Type type , ValueNumber operand
201+ UnaryInstruction instr , IRFunction irFunc , Opcode opcode , IRType type , ValueNumber operand
202202) {
203203 instr .getEnclosingIRFunction ( ) = irFunc and
204204 not instr instanceof InheritanceConversionInstruction and
205205 not instr instanceof CopyInstruction and
206206 instr .getOpcode ( ) = opcode and
207- instr .getResultType ( ) = type and
207+ instr .getResultIRType ( ) = type and
208208 valueNumber ( instr .getUnary ( ) ) = operand
209209}
210210
211211private predicate inheritanceConversionValueNumber (
212- InheritanceConversionInstruction instr , IRFunction irFunc , Opcode opcode , Class baseClass ,
213- Class derivedClass , ValueNumber operand
212+ InheritanceConversionInstruction instr , IRFunction irFunc , Opcode opcode ,
213+ Language :: Class baseClass , Language :: Class derivedClass , ValueNumber operand
214214) {
215215 instr .getEnclosingIRFunction ( ) = irFunc and
216216 instr .getOpcode ( ) = opcode and
@@ -225,7 +225,7 @@ private predicate inheritanceConversionValueNumber(
225225 */
226226private predicate uniqueValueNumber ( Instruction instr , IRFunction irFunc ) {
227227 instr .getEnclosingIRFunction ( ) = irFunc and
228- not instr .getResultType ( ) instanceof VoidType and
228+ not instr .getResultIRType ( ) instanceof IRVoidType and
229229 not numberableInstruction ( instr )
230230}
231231
@@ -269,38 +269,39 @@ private ValueNumber nonUniqueValueNumber(Instruction instr) {
269269 initializeThisValueNumber ( instr , irFunc ) and
270270 result = TInitializeThisValueNumber ( irFunc )
271271 or
272- exists ( Type type , string value |
272+ exists ( IRType type , string value |
273273 constantValueNumber ( instr , irFunc , type , value ) and
274274 result = TConstantValueNumber ( irFunc , type , value )
275275 )
276276 or
277- exists ( Type type , string value |
277+ exists ( IRType type , string value |
278278 stringConstantValueNumber ( instr , irFunc , type , value ) and
279279 result = TStringConstantValueNumber ( irFunc , type , value )
280280 )
281281 or
282- exists ( Field field , ValueNumber objectAddress |
282+ exists ( Language :: Field field , ValueNumber objectAddress |
283283 fieldAddressValueNumber ( instr , irFunc , field , objectAddress ) and
284284 result = TFieldAddressValueNumber ( irFunc , field , objectAddress )
285285 )
286286 or
287- exists ( Opcode opcode , Type type , ValueNumber leftOperand , ValueNumber rightOperand |
287+ exists ( Opcode opcode , IRType type , ValueNumber leftOperand , ValueNumber rightOperand |
288288 binaryValueNumber ( instr , irFunc , opcode , type , leftOperand , rightOperand ) and
289289 result = TBinaryValueNumber ( irFunc , opcode , type , leftOperand , rightOperand )
290290 )
291291 or
292- exists ( Opcode opcode , Type type , ValueNumber operand |
292+ exists ( Opcode opcode , IRType type , ValueNumber operand |
293293 unaryValueNumber ( instr , irFunc , opcode , type , operand ) and
294294 result = TUnaryValueNumber ( irFunc , opcode , type , operand )
295295 )
296296 or
297- exists ( Opcode opcode , Class baseClass , Class derivedClass , ValueNumber operand |
297+ exists ( Opcode opcode , Language:: Class baseClass , Language:: Class derivedClass ,
298+ ValueNumber operand |
298299 inheritanceConversionValueNumber ( instr , irFunc , opcode , baseClass , derivedClass , operand ) and
299300 result = TInheritanceConversionValueNumber ( irFunc , opcode , baseClass , derivedClass , operand )
300301 )
301302 or
302303 exists (
303- Opcode opcode , Type type , int elementSize , ValueNumber leftOperand , ValueNumber rightOperand
304+ Opcode opcode , IRType type , int elementSize , ValueNumber leftOperand , ValueNumber rightOperand
304305 |
305306 pointerArithmeticValueNumber ( instr , irFunc , opcode , type , elementSize , leftOperand ,
306307 rightOperand ) and
0 commit comments