C++: Address review comments

This commit is contained in:
Jeroen Ketema
2023-02-09 11:56:40 +01:00
parent 20ce4cdf91
commit e4c211df2d
2 changed files with 25 additions and 15 deletions

View File

@@ -49,11 +49,7 @@ class Node0Impl extends TIRDataFlowNode0 {
DataFlowType getType() { none() } // overridden in subclasses DataFlowType getType() { none() } // overridden in subclasses
/** Gets the instruction corresponding to this node, if any. */ /** Gets the instruction corresponding to this node, if any. */
Instruction asInstruction() { Instruction asInstruction() { result = this.(InstructionNode0).getInstruction() }
result = this.(InstructionNode0).getInstruction()
or
result = Ssa::getIRRepresentationOfOperand(this.(SingleUseOperandNode0).getOperand())
}
/** Gets the operands corresponding to this node, if any. */ /** Gets the operands corresponding to this node, if any. */
Operand asOperand() { result = this.(OperandNode0).getOperand() } Operand asOperand() { result = this.(OperandNode0).getOperand() }
@@ -78,11 +74,9 @@ class Node0Impl extends TIRDataFlowNode0 {
/** /**
* An instruction, viewed as a node in a data flow graph. * An instruction, viewed as a node in a data flow graph.
*/ */
class InstructionNode0 extends Node0Impl, TInstructionNode0 { abstract class InstructionNode0 extends Node0Impl {
Instruction instr; Instruction instr;
InstructionNode0() { this = TInstructionNode0(instr) }
/** Gets the instruction corresponding to this node. */ /** Gets the instruction corresponding to this node. */
Instruction getInstruction() { result = instr } Instruction getInstruction() { result = instr }
@@ -101,6 +95,25 @@ class InstructionNode0 extends Node0Impl, TInstructionNode0 {
} }
} }
/**
* An instruction without an operand that is used only once, viewed as a node in a data flow graph.
*/
private class InstructionInstructionNode0 extends InstructionNode0, TInstructionNode0 {
InstructionInstructionNode0() { this = TInstructionNode0(instr) }
}
/**
* An instruction with an operand that is used only once, viewed as a node in a data flow graph.
*/
private class SingleUseOperandInstructionNode0 extends InstructionNode0, TSingleUseOperandNode0 {
SingleUseOperandInstructionNode0() {
exists(Operand op |
this = TSingleUseOperandNode0(op) and
instr = Ssa::getIRRepresentationOfOperand(op)
)
}
}
/** /**
* An operand, viewed as a node in a data flow graph. * An operand, viewed as a node in a data flow graph.
*/ */
@@ -124,14 +137,14 @@ abstract class OperandNode0 extends Node0Impl {
/** /**
* An operand that is used multiple times, viewed as a node in a data flow graph. * An operand that is used multiple times, viewed as a node in a data flow graph.
*/ */
class MultipleUseOperandNode0 extends OperandNode0, TMultipleUseOperandNode0 { private class MultipleUseOperandNode0 extends OperandNode0, TMultipleUseOperandNode0 {
MultipleUseOperandNode0() { this = TMultipleUseOperandNode0(op) } MultipleUseOperandNode0() { this = TMultipleUseOperandNode0(op) }
} }
/** /**
* An operand that is used only once, viewed as a node in a data flow graph. * An operand that is used only once, viewed as a node in a data flow graph.
*/ */
class SingleUseOperandNode0 extends OperandNode0, TSingleUseOperandNode0 { private class SingleUseOperandNode0 extends OperandNode0, TSingleUseOperandNode0 {
SingleUseOperandNode0() { this = TSingleUseOperandNode0(op) } SingleUseOperandNode0() { this = TSingleUseOperandNode0(op) }
} }

View File

@@ -383,13 +383,10 @@ private class Node0 extends Node, TNode0 {
* An instruction, viewed as a node in a data flow graph. * An instruction, viewed as a node in a data flow graph.
*/ */
class InstructionNode extends Node0 { class InstructionNode extends Node0 {
override InstructionNode0 node;
Instruction instr; Instruction instr;
InstructionNode() { InstructionNode() { instr = node.getInstruction() }
node.(InstructionNode0).getInstruction() = instr
or
Ssa::getIRRepresentationOfOperand(node.(SingleUseOperandNode0).getOperand()) = instr
}
/** Gets the instruction corresponding to this node. */ /** Gets the instruction corresponding to this node. */
Instruction getInstruction() { result = instr } Instruction getInstruction() { result = instr }