@@ -10,79 +10,20 @@ private import Imports::MemoryAccessKind
1010private import Imports:: IRType
1111private import Imports:: Overlap
1212private import Imports:: OperandTag
13-
14- cached
15- private newtype TOperand =
16- TRegisterOperand ( Instruction useInstr , RegisterOperandTag tag , Instruction defInstr ) {
17- defInstr = Construction:: getRegisterOperandDefinition ( useInstr , tag ) and
18- not Construction:: isInCycle ( useInstr ) and
19- strictcount ( Construction:: getRegisterOperandDefinition ( useInstr , tag ) ) = 1
20- } or
21- TNonPhiMemoryOperand ( Instruction useInstr , MemoryOperandTag tag ) {
22- useInstr .getOpcode ( ) .hasOperand ( tag )
23- } or
24- TPhiOperand (
25- PhiInstruction useInstr , Instruction defInstr , IRBlock predecessorBlock , Overlap overlap
26- ) {
27- defInstr = Construction:: getPhiOperandDefinition ( useInstr , predecessorBlock , overlap )
28- }
29-
30- /**
31- * Base class for all register operands. This is a placeholder for the IPA union type that we will
32- * eventually use for this purpose.
33- */
34- private class RegisterOperandBase extends TRegisterOperand {
35- /** Gets a textual representation of this element. */
36- abstract string toString ( ) ;
37- }
38-
39- /**
40- * Returns the register operand with the specified parameters.
41- */
42- private RegisterOperandBase registerOperand (
43- Instruction useInstr , RegisterOperandTag tag , Instruction defInstr
44- ) {
45- result = TRegisterOperand ( useInstr , tag , defInstr )
46- }
47-
48- /**
49- * Base class for all non-Phi memory operands. This is a placeholder for the IPA union type that we
50- * will eventually use for this purpose.
51- */
52- private class NonPhiMemoryOperandBase extends TNonPhiMemoryOperand {
53- /** Gets a textual representation of this element. */
54- abstract string toString ( ) ;
55- }
56-
57- /**
58- * Returns the non-Phi memory operand with the specified parameters.
59- */
60- private NonPhiMemoryOperandBase nonPhiMemoryOperand ( Instruction useInstr , MemoryOperandTag tag ) {
61- result = TNonPhiMemoryOperand ( useInstr , tag )
62- }
13+ private import Imports:: TOperand
14+ private import internal.OperandInternal
6315
6416/**
65- * Base class for all Phi operands. This is a placeholder for the IPA union type that we will
66- * eventually use for this purpose .
17+ * An operand of an `Instruction` in this stage of the IR. Implemented as a union of the branches
18+ * of `TOperand` that are used in this stage .
6719 */
68- private class PhiOperandBase extends TPhiOperand {
69- abstract string toString ( ) ;
70- }
71-
72- /**
73- * Returns the Phi operand with the specified parameters.
74- */
75- private PhiOperandBase phiOperand (
76- Instruction useInstr , Instruction defInstr , IRBlock predecessorBlock , Overlap overlap
77- ) {
78- result = TPhiOperand ( useInstr , defInstr , predecessorBlock , overlap )
79- }
20+ private class TStageOperand = TRegisterOperand or TNonSSAMemoryOperand or TPhiOperand or TChiOperand ;
8021
8122/**
8223 * An operand of an `Instruction`. The operand represents a use of the result of one instruction
8324 * (the defining instruction) in another instruction (the use instruction)
8425 */
85- class Operand extends TOperand {
26+ class Operand extends TStageOperand {
8627 /** Gets a textual representation of this element. */
8728 string toString ( ) { result = "Operand" }
8829
@@ -239,8 +180,9 @@ class Operand extends TOperand {
239180 */
240181class MemoryOperand extends Operand {
241182 MemoryOperand ( ) {
242- this instanceof NonPhiMemoryOperandBase or
243- this instanceof PhiOperandBase
183+ this instanceof TNonSSAMemoryOperand or
184+ this instanceof TPhiOperand or
185+ this instanceof TChiOperand
244186 }
245187
246188 /**
@@ -278,7 +220,8 @@ class NonPhiOperand extends Operand {
278220
279221 NonPhiOperand ( ) {
280222 this = registerOperand ( useInstr , tag , _) or
281- this = nonPhiMemoryOperand ( useInstr , tag )
223+ this = nonSSAMemoryOperand ( useInstr , tag ) or
224+ this = chiOperand ( useInstr , tag )
282225 }
283226
284227 final override Instruction getUse ( ) { result = useInstr }
@@ -298,7 +241,7 @@ class NonPhiOperand extends Operand {
298241/**
299242 * An operand that consumes a register (non-memory) result.
300243 */
301- class RegisterOperand extends NonPhiOperand , RegisterOperandBase {
244+ class RegisterOperand extends NonPhiOperand , TRegisterOperand {
302245 override RegisterOperandTag tag ;
303246 Instruction defInstr ;
304247
@@ -317,10 +260,14 @@ class RegisterOperand extends NonPhiOperand, RegisterOperandBase {
317260/**
318261 * A memory operand other than the operand of a `Phi` instruction.
319262 */
320- class NonPhiMemoryOperand extends NonPhiOperand , MemoryOperand , NonPhiMemoryOperandBase {
263+ class NonPhiMemoryOperand extends NonPhiOperand , MemoryOperand {
321264 override MemoryOperandTag tag ;
322265
323- NonPhiMemoryOperand ( ) { this = nonPhiMemoryOperand ( useInstr , tag ) }
266+ NonPhiMemoryOperand ( ) {
267+ this = nonSSAMemoryOperand ( useInstr , tag )
268+ or
269+ this = chiOperand ( useInstr , tag )
270+ }
324271
325272 final override string toString ( ) { result = tag .toString ( ) }
326273
@@ -462,7 +409,7 @@ class SideEffectOperand extends TypedOperand {
462409/**
463410 * An operand of a `PhiInstruction`.
464411 */
465- class PhiInputOperand extends MemoryOperand , PhiOperandBase {
412+ class PhiInputOperand extends MemoryOperand , TPhiOperand {
466413 PhiInstruction useInstr ;
467414 Instruction defInstr ;
468415 IRBlock predecessorBlock ;
0 commit comments