mirror of
https://github.com/github/codeql.git
synced 2026-04-30 19:26:02 +02:00
Merge pull request #5829 from MathiasVP/reorder-get-instruction-opcode
C++: Reorder getInstructionOpcode
This commit is contained in:
@@ -297,7 +297,8 @@ class Instruction extends Construction::TStageInstruction {
|
||||
/**
|
||||
* Gets the opcode that specifies the operation performed by this instruction.
|
||||
*/
|
||||
final Opcode getOpcode() { result = Construction::getInstructionOpcode(this) }
|
||||
pragma[inline]
|
||||
final Opcode getOpcode() { Construction::getInstructionOpcode(result, this) }
|
||||
|
||||
/**
|
||||
* Gets all direct uses of the result of this instruction. The result can be
|
||||
|
||||
@@ -338,15 +338,21 @@ private module Cached {
|
||||
instr = unreachedInstruction(_) and result = Language::getVoidType()
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if `opcode` is the opcode that specifies the operation performed by `instr`.
|
||||
*
|
||||
* The parameters are ordered such that they produce a clean join (with no need for reordering)
|
||||
* in the characteristic predicates of the `Instruction` subclasses.
|
||||
*/
|
||||
cached
|
||||
Opcode getInstructionOpcode(Instruction instr) {
|
||||
result = getOldInstruction(instr).getOpcode()
|
||||
predicate getInstructionOpcode(Opcode opcode, Instruction instr) {
|
||||
opcode = getOldInstruction(instr).getOpcode()
|
||||
or
|
||||
instr = phiInstruction(_, _) and result instanceof Opcode::Phi
|
||||
instr = phiInstruction(_, _) and opcode instanceof Opcode::Phi
|
||||
or
|
||||
instr = chiInstruction(_) and result instanceof Opcode::Chi
|
||||
instr = chiInstruction(_) and opcode instanceof Opcode::Chi
|
||||
or
|
||||
instr = unreachedInstruction(_) and result instanceof Opcode::Unreached
|
||||
instr = unreachedInstruction(_) and opcode instanceof Opcode::Unreached
|
||||
}
|
||||
|
||||
cached
|
||||
|
||||
@@ -297,7 +297,8 @@ class Instruction extends Construction::TStageInstruction {
|
||||
/**
|
||||
* Gets the opcode that specifies the operation performed by this instruction.
|
||||
*/
|
||||
final Opcode getOpcode() { result = Construction::getInstructionOpcode(this) }
|
||||
pragma[inline]
|
||||
final Opcode getOpcode() { Construction::getInstructionOpcode(result, this) }
|
||||
|
||||
/**
|
||||
* Gets all direct uses of the result of this instruction. The result can be
|
||||
|
||||
@@ -360,8 +360,8 @@ CppType getInstructionResultType(TStageInstruction instr) {
|
||||
getInstructionTranslatedElement(instr).hasInstruction(_, getInstructionTag(instr), result)
|
||||
}
|
||||
|
||||
Opcode getInstructionOpcode(TStageInstruction instr) {
|
||||
getInstructionTranslatedElement(instr).hasInstruction(result, getInstructionTag(instr), _)
|
||||
predicate getInstructionOpcode(Opcode opcode, TStageInstruction instr) {
|
||||
getInstructionTranslatedElement(instr).hasInstruction(opcode, getInstructionTag(instr), _)
|
||||
}
|
||||
|
||||
IRFunctionBase getInstructionEnclosingIRFunction(TStageInstruction instr) {
|
||||
|
||||
@@ -297,7 +297,8 @@ class Instruction extends Construction::TStageInstruction {
|
||||
/**
|
||||
* Gets the opcode that specifies the operation performed by this instruction.
|
||||
*/
|
||||
final Opcode getOpcode() { result = Construction::getInstructionOpcode(this) }
|
||||
pragma[inline]
|
||||
final Opcode getOpcode() { Construction::getInstructionOpcode(result, this) }
|
||||
|
||||
/**
|
||||
* Gets all direct uses of the result of this instruction. The result can be
|
||||
|
||||
@@ -338,15 +338,21 @@ private module Cached {
|
||||
instr = unreachedInstruction(_) and result = Language::getVoidType()
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if `opcode` is the opcode that specifies the operation performed by `instr`.
|
||||
*
|
||||
* The parameters are ordered such that they produce a clean join (with no need for reordering)
|
||||
* in the characteristic predicates of the `Instruction` subclasses.
|
||||
*/
|
||||
cached
|
||||
Opcode getInstructionOpcode(Instruction instr) {
|
||||
result = getOldInstruction(instr).getOpcode()
|
||||
predicate getInstructionOpcode(Opcode opcode, Instruction instr) {
|
||||
opcode = getOldInstruction(instr).getOpcode()
|
||||
or
|
||||
instr = phiInstruction(_, _) and result instanceof Opcode::Phi
|
||||
instr = phiInstruction(_, _) and opcode instanceof Opcode::Phi
|
||||
or
|
||||
instr = chiInstruction(_) and result instanceof Opcode::Chi
|
||||
instr = chiInstruction(_) and opcode instanceof Opcode::Chi
|
||||
or
|
||||
instr = unreachedInstruction(_) and result instanceof Opcode::Unreached
|
||||
instr = unreachedInstruction(_) and opcode instanceof Opcode::Unreached
|
||||
}
|
||||
|
||||
cached
|
||||
|
||||
@@ -297,7 +297,8 @@ class Instruction extends Construction::TStageInstruction {
|
||||
/**
|
||||
* Gets the opcode that specifies the operation performed by this instruction.
|
||||
*/
|
||||
final Opcode getOpcode() { result = Construction::getInstructionOpcode(this) }
|
||||
pragma[inline]
|
||||
final Opcode getOpcode() { Construction::getInstructionOpcode(result, this) }
|
||||
|
||||
/**
|
||||
* Gets all direct uses of the result of this instruction. The result can be
|
||||
|
||||
@@ -165,10 +165,10 @@ import Cached
|
||||
cached
|
||||
private module Cached {
|
||||
cached
|
||||
Opcode getInstructionOpcode(TRawInstruction instr) {
|
||||
predicate getInstructionOpcode(Opcode opcode, TRawInstruction instr) {
|
||||
exists(TranslatedElement element, InstructionTag tag |
|
||||
instructionOrigin(instr, element, tag) and
|
||||
element.hasInstruction(result, tag, _)
|
||||
element.hasInstruction(opcode, tag, _)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -297,7 +297,8 @@ class Instruction extends Construction::TStageInstruction {
|
||||
/**
|
||||
* Gets the opcode that specifies the operation performed by this instruction.
|
||||
*/
|
||||
final Opcode getOpcode() { result = Construction::getInstructionOpcode(this) }
|
||||
pragma[inline]
|
||||
final Opcode getOpcode() { Construction::getInstructionOpcode(result, this) }
|
||||
|
||||
/**
|
||||
* Gets all direct uses of the result of this instruction. The result can be
|
||||
|
||||
@@ -338,15 +338,21 @@ private module Cached {
|
||||
instr = unreachedInstruction(_) and result = Language::getVoidType()
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if `opcode` is the opcode that specifies the operation performed by `instr`.
|
||||
*
|
||||
* The parameters are ordered such that they produce a clean join (with no need for reordering)
|
||||
* in the characteristic predicates of the `Instruction` subclasses.
|
||||
*/
|
||||
cached
|
||||
Opcode getInstructionOpcode(Instruction instr) {
|
||||
result = getOldInstruction(instr).getOpcode()
|
||||
predicate getInstructionOpcode(Opcode opcode, Instruction instr) {
|
||||
opcode = getOldInstruction(instr).getOpcode()
|
||||
or
|
||||
instr = phiInstruction(_, _) and result instanceof Opcode::Phi
|
||||
instr = phiInstruction(_, _) and opcode instanceof Opcode::Phi
|
||||
or
|
||||
instr = chiInstruction(_) and result instanceof Opcode::Chi
|
||||
instr = chiInstruction(_) and opcode instanceof Opcode::Chi
|
||||
or
|
||||
instr = unreachedInstruction(_) and result instanceof Opcode::Unreached
|
||||
instr = unreachedInstruction(_) and opcode instanceof Opcode::Unreached
|
||||
}
|
||||
|
||||
cached
|
||||
|
||||
Reference in New Issue
Block a user