Skip to content

Commit

Permalink
Merge pull request #16339 from MathiasVP/one-less-stage
Browse files Browse the repository at this point in the history
C++: Remove a stage by properly caching `getResultIRType`
  • Loading branch information
MathiasVP authored Apr 26, 2024
2 parents 6147a38 + 70e9c48 commit c9ce642
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,7 @@ class Instruction extends Construction::TStageInstruction {
* Gets the type of the result produced by this instruction. If the instruction does not produce
* a result, its result type will be `IRVoidType`.
*/
cached
final IRType getResultIRType() { result = this.getResultLanguageType().getIRType() }
final IRType getResultIRType() { result = Construction::getInstructionResultIRType(this) }

/**
* Gets the type of the result produced by this instruction. If the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,11 @@ private module Cached {
instr = unreachedInstruction(_) and result = Language::getVoidType()
}

cached
IRType getInstructionResultIRType(Instruction instr) {
result = instr.getResultLanguageType().getIRType()
}

/**
* Holds if `opcode` is the opcode that specifies the operation performed by `instr`.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,7 @@ class Instruction extends Construction::TStageInstruction {
* Gets the type of the result produced by this instruction. If the instruction does not produce
* a result, its result type will be `IRVoidType`.
*/
cached
final IRType getResultIRType() { result = this.getResultLanguageType().getIRType() }
final IRType getResultIRType() { result = Construction::getInstructionResultIRType(this) }

/**
* Gets the type of the result produced by this instruction. If the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,10 @@ CppType getInstructionResultType(TStageInstruction instr) {
result = getVoidType()
}

IRType getInstructionResultIRType(Instruction instr) {
result = instr.getResultLanguageType().getIRType()
}

predicate getInstructionOpcode(Opcode opcode, TStageInstruction instr) {
getInstructionTranslatedElement(instr).hasInstruction(opcode, getInstructionTag(instr), _)
or
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,7 @@ class Instruction extends Construction::TStageInstruction {
* Gets the type of the result produced by this instruction. If the instruction does not produce
* a result, its result type will be `IRVoidType`.
*/
cached
final IRType getResultIRType() { result = this.getResultLanguageType().getIRType() }
final IRType getResultIRType() { result = Construction::getInstructionResultIRType(this) }

/**
* Gets the type of the result produced by this instruction. If the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,11 @@ private module Cached {
instr = unreachedInstruction(_) and result = Language::getVoidType()
}

cached
IRType getInstructionResultIRType(Instruction instr) {
result = instr.getResultLanguageType().getIRType()
}

/**
* Holds if `opcode` is the opcode that specifies the operation performed by `instr`.
*
Expand Down

0 comments on commit c9ce642

Please sign in to comment.