C++: Replace TRawInstruction() calls

Replace most direct calls to `TRawInstruction()` with calls to `getInstructionTranslatedElement()` and `getInstructionTag()`, matching existing practice. One tiny RA diff in an inconsequential join order in `getInstructionVariable`.
This commit is contained in:
Dave Bartolomeo
2020-06-17 10:52:32 -04:00
parent c1016743a5
commit 687d6d2643

View File

@@ -71,7 +71,8 @@ module Raw {
cached
TIRVariable getInstructionVariable(Instruction instruction) {
exists(TranslatedElement element, InstructionTag tag |
instruction = TRawInstruction(element, tag) and
element = getInstructionTranslatedElement(instruction) and
tag = getInstructionTag(instruction) and
(
result = element.getInstructionVariable(tag) or
result.(IRStringLiteral).getAST() = element.getInstructionStringLiteral(tag)
@@ -81,10 +82,9 @@ module Raw {
cached
Field getInstructionField(Instruction instruction) {
exists(TranslatedElement element, InstructionTag tag |
instruction = TRawInstruction(element, tag) and
result = element.getInstructionField(tag)
)
result =
getInstructionTranslatedElement(instruction)
.getInstructionField(getInstructionTag(instruction))
}
cached
@@ -103,10 +103,9 @@ module Raw {
cached
int getInstructionIndex(Instruction instruction) {
exists(TranslatedElement element, InstructionTag tag |
instruction = TRawInstruction(element, tag) and
result = element.getInstructionIndex(tag)
)
result =
getInstructionTranslatedElement(instruction)
.getInstructionIndex(getInstructionTag(instruction))
}
cached
@@ -131,10 +130,9 @@ module Raw {
cached
int getInstructionElementSize(Instruction instruction) {
exists(TranslatedElement element, InstructionTag tag |
instruction = TRawInstruction(element, tag) and
result = element.getInstructionElementSize(tag)
)
result =
getInstructionTranslatedElement(instruction)
.getInstructionElementSize(getInstructionTag(instruction))
}
cached
@@ -345,17 +343,11 @@ Locatable getInstructionAST(TStageInstruction instr) {
}
CppType getInstructionResultType(TStageInstruction instr) {
exists(TranslatedElement element, InstructionTag tag |
instr = TRawInstruction(element, tag) and
element.hasInstruction(_, tag, result)
)
getInstructionTranslatedElement(instr).hasInstruction(_, getInstructionTag(instr), result)
}
Opcode getInstructionOpcode(TStageInstruction instr) {
exists(TranslatedElement element, InstructionTag tag |
instr = TRawInstruction(element, tag) and
element.hasInstruction(result, tag, _)
)
getInstructionTranslatedElement(instr).hasInstruction(result, getInstructionTag(instr), _)
}
IRFunctionBase getInstructionEnclosingIRFunction(TStageInstruction instr) {
@@ -363,10 +355,9 @@ IRFunctionBase getInstructionEnclosingIRFunction(TStageInstruction instr) {
}
Instruction getPrimaryInstructionForSideEffect(SideEffectInstruction instruction) {
exists(TranslatedElement element, InstructionTag tag |
instruction = TRawInstruction(element, tag) and
result = element.getPrimaryInstructionForSideEffect(tag)
)
result =
getInstructionTranslatedElement(instruction)
.getPrimaryInstructionForSideEffect(getInstructionTag(instruction))
}
import CachedForDebugging