File tree Expand file tree Collapse file tree 10 files changed +47
-24
lines changed
cpp/ql/src/semmle/code/cpp/ir/implementation
csharp/ql/src/experimental/ir/implementation Expand file tree Collapse file tree 10 files changed +47
-24
lines changed Original file line number Diff line number Diff line change @@ -297,7 +297,8 @@ class Instruction extends Construction::TStageInstruction {
297
297
/**
298
298
* Gets the opcode that specifies the operation performed by this instruction.
299
299
*/
300
- final Opcode getOpcode ( ) { result = Construction:: getInstructionOpcode ( this ) }
300
+ pragma [ inline]
301
+ final Opcode getOpcode ( ) { Construction:: getInstructionOpcode ( result , this ) }
301
302
302
303
/**
303
304
* Gets all direct uses of the result of this instruction. The result can be
Original file line number Diff line number Diff line change @@ -338,15 +338,21 @@ private module Cached {
338
338
instr = unreachedInstruction ( _) and result = Language:: getVoidType ( )
339
339
}
340
340
341
+ /**
342
+ * Holds if `opcode` is the opcode that specifies the operation performed by `instr`.
343
+ *
344
+ * The parameters are ordered such that they produce a clean join (with no need for reordering)
345
+ * in the characteristic predicates of the `Instruction` subclasses.
346
+ */
341
347
cached
342
- Opcode getInstructionOpcode ( Instruction instr ) {
343
- result = getOldInstruction ( instr ) .getOpcode ( )
348
+ predicate getInstructionOpcode ( Opcode opcode , Instruction instr ) {
349
+ opcode = getOldInstruction ( instr ) .getOpcode ( )
344
350
or
345
- instr = phiInstruction ( _, _) and result instanceof Opcode:: Phi
351
+ instr = phiInstruction ( _, _) and opcode instanceof Opcode:: Phi
346
352
or
347
- instr = chiInstruction ( _) and result instanceof Opcode:: Chi
353
+ instr = chiInstruction ( _) and opcode instanceof Opcode:: Chi
348
354
or
349
- instr = unreachedInstruction ( _) and result instanceof Opcode:: Unreached
355
+ instr = unreachedInstruction ( _) and opcode instanceof Opcode:: Unreached
350
356
}
351
357
352
358
cached
Original file line number Diff line number Diff line change @@ -297,7 +297,8 @@ class Instruction extends Construction::TStageInstruction {
297
297
/**
298
298
* Gets the opcode that specifies the operation performed by this instruction.
299
299
*/
300
- final Opcode getOpcode ( ) { result = Construction:: getInstructionOpcode ( this ) }
300
+ pragma [ inline]
301
+ final Opcode getOpcode ( ) { Construction:: getInstructionOpcode ( result , this ) }
301
302
302
303
/**
303
304
* Gets all direct uses of the result of this instruction. The result can be
Original file line number Diff line number Diff line change @@ -360,8 +360,8 @@ CppType getInstructionResultType(TStageInstruction instr) {
360
360
getInstructionTranslatedElement ( instr ) .hasInstruction ( _, getInstructionTag ( instr ) , result )
361
361
}
362
362
363
- Opcode getInstructionOpcode ( TStageInstruction instr ) {
364
- getInstructionTranslatedElement ( instr ) .hasInstruction ( result , getInstructionTag ( instr ) , _)
363
+ predicate getInstructionOpcode ( Opcode opcode , TStageInstruction instr ) {
364
+ getInstructionTranslatedElement ( instr ) .hasInstruction ( opcode , getInstructionTag ( instr ) , _)
365
365
}
366
366
367
367
IRFunctionBase getInstructionEnclosingIRFunction ( TStageInstruction instr ) {
Original file line number Diff line number Diff line change @@ -297,7 +297,8 @@ class Instruction extends Construction::TStageInstruction {
297
297
/**
298
298
* Gets the opcode that specifies the operation performed by this instruction.
299
299
*/
300
- final Opcode getOpcode ( ) { result = Construction:: getInstructionOpcode ( this ) }
300
+ pragma [ inline]
301
+ final Opcode getOpcode ( ) { Construction:: getInstructionOpcode ( result , this ) }
301
302
302
303
/**
303
304
* Gets all direct uses of the result of this instruction. The result can be
Original file line number Diff line number Diff line change @@ -338,15 +338,21 @@ private module Cached {
338
338
instr = unreachedInstruction ( _) and result = Language:: getVoidType ( )
339
339
}
340
340
341
+ /**
342
+ * Holds if `opcode` is the opcode that specifies the operation performed by `instr`.
343
+ *
344
+ * The parameters are ordered such that they produce a clean join (with no need for reordering)
345
+ * in the characteristic predicates of the `Instruction` subclasses.
346
+ */
341
347
cached
342
- Opcode getInstructionOpcode ( Instruction instr ) {
343
- result = getOldInstruction ( instr ) .getOpcode ( )
348
+ predicate getInstructionOpcode ( Opcode opcode , Instruction instr ) {
349
+ opcode = getOldInstruction ( instr ) .getOpcode ( )
344
350
or
345
- instr = phiInstruction ( _, _) and result instanceof Opcode:: Phi
351
+ instr = phiInstruction ( _, _) and opcode instanceof Opcode:: Phi
346
352
or
347
- instr = chiInstruction ( _) and result instanceof Opcode:: Chi
353
+ instr = chiInstruction ( _) and opcode instanceof Opcode:: Chi
348
354
or
349
- instr = unreachedInstruction ( _) and result instanceof Opcode:: Unreached
355
+ instr = unreachedInstruction ( _) and opcode instanceof Opcode:: Unreached
350
356
}
351
357
352
358
cached
Original file line number Diff line number Diff line change @@ -297,7 +297,8 @@ class Instruction extends Construction::TStageInstruction {
297
297
/**
298
298
* Gets the opcode that specifies the operation performed by this instruction.
299
299
*/
300
- final Opcode getOpcode ( ) { result = Construction:: getInstructionOpcode ( this ) }
300
+ pragma [ inline]
301
+ final Opcode getOpcode ( ) { Construction:: getInstructionOpcode ( result , this ) }
301
302
302
303
/**
303
304
* Gets all direct uses of the result of this instruction. The result can be
Original file line number Diff line number Diff line change @@ -165,10 +165,10 @@ import Cached
165
165
cached
166
166
private module Cached {
167
167
cached
168
- Opcode getInstructionOpcode ( TRawInstruction instr ) {
168
+ predicate getInstructionOpcode ( Opcode opcode , TRawInstruction instr ) {
169
169
exists ( TranslatedElement element , InstructionTag tag |
170
170
instructionOrigin ( instr , element , tag ) and
171
- element .hasInstruction ( result , tag , _)
171
+ element .hasInstruction ( opcode , tag , _)
172
172
)
173
173
}
174
174
Original file line number Diff line number Diff line change @@ -297,7 +297,8 @@ class Instruction extends Construction::TStageInstruction {
297
297
/**
298
298
* Gets the opcode that specifies the operation performed by this instruction.
299
299
*/
300
- final Opcode getOpcode ( ) { result = Construction:: getInstructionOpcode ( this ) }
300
+ pragma [ inline]
301
+ final Opcode getOpcode ( ) { Construction:: getInstructionOpcode ( result , this ) }
301
302
302
303
/**
303
304
* Gets all direct uses of the result of this instruction. The result can be
Original file line number Diff line number Diff line change @@ -338,15 +338,21 @@ private module Cached {
338
338
instr = unreachedInstruction ( _) and result = Language:: getVoidType ( )
339
339
}
340
340
341
+ /**
342
+ * Holds if `opcode` is the opcode that specifies the operation performed by `instr`.
343
+ *
344
+ * The parameters are ordered such that they produce a clean join (with no need for reordering)
345
+ * in the characteristic predicates of the `Instruction` subclasses.
346
+ */
341
347
cached
342
- Opcode getInstructionOpcode ( Instruction instr ) {
343
- result = getOldInstruction ( instr ) .getOpcode ( )
348
+ predicate getInstructionOpcode ( Opcode opcode , Instruction instr ) {
349
+ opcode = getOldInstruction ( instr ) .getOpcode ( )
344
350
or
345
- instr = phiInstruction ( _, _) and result instanceof Opcode:: Phi
351
+ instr = phiInstruction ( _, _) and opcode instanceof Opcode:: Phi
346
352
or
347
- instr = chiInstruction ( _) and result instanceof Opcode:: Chi
353
+ instr = chiInstruction ( _) and opcode instanceof Opcode:: Chi
348
354
or
349
- instr = unreachedInstruction ( _) and result instanceof Opcode:: Unreached
355
+ instr = unreachedInstruction ( _) and opcode instanceof Opcode:: Unreached
350
356
}
351
357
352
358
cached
You can’t perform that action at this time.
0 commit comments