|
20 | 20 | #include <vector>
|
21 | 21 |
|
22 | 22 | namespace llvm {
|
23 |
| - class CodeGenInstruction; |
24 |
| - |
25 |
| - struct AsmWriterOperand { |
26 |
| - enum OpType { |
27 |
| - // Output this text surrounded by quotes to the asm. |
28 |
| - isLiteralTextOperand, |
29 |
| - // This is the name of a routine to call to print the operand. |
30 |
| - isMachineInstrOperand, |
31 |
| - // Output this text verbatim to the asm writer. It is code that |
32 |
| - // will output some text to the asm. |
33 |
| - isLiteralStatementOperand |
34 |
| - } OperandType; |
35 |
| - |
36 |
| - /// MiOpNo - For isMachineInstrOperand, this is the operand number of the |
37 |
| - /// machine instruction. |
38 |
| - unsigned MIOpNo = 0; |
39 |
| - |
40 |
| - /// Str - For isLiteralTextOperand, this IS the literal text. For |
41 |
| - /// isMachineInstrOperand, this is the PrinterMethodName for the operand.. |
42 |
| - /// For isLiteralStatementOperand, this is the code to insert verbatim |
43 |
| - /// into the asm writer. |
44 |
| - std::string Str; |
45 |
| - |
46 |
| - /// MiModifier - For isMachineInstrOperand, this is the modifier string for |
47 |
| - /// an operand, specified with syntax like ${opname:modifier}. |
48 |
| - std::string MiModifier; |
49 |
| - |
50 |
| - bool PCRel = false; |
51 |
| - |
52 |
| - // To make VS STL happy |
53 |
| - AsmWriterOperand(OpType op = isLiteralTextOperand):OperandType(op) {} |
54 |
| - |
55 |
| - AsmWriterOperand(const std::string &LitStr, |
56 |
| - OpType op = isLiteralTextOperand) |
57 |
| - : OperandType(op), Str(LitStr) {} |
58 |
| - |
59 |
| - AsmWriterOperand(const std::string &Printer, unsigned _MIOpNo, |
60 |
| - const std::string &Modifier, |
61 |
| - OpType op = isMachineInstrOperand, bool PCRel = false) |
62 |
| - : OperandType(op), MIOpNo(_MIOpNo), Str(Printer), MiModifier(Modifier), |
63 |
| - PCRel(PCRel) {} |
64 |
| - |
65 |
| - bool operator!=(const AsmWriterOperand &Other) const { |
66 |
| - if (OperandType != Other.OperandType || Str != Other.Str) return true; |
67 |
| - if (OperandType == isMachineInstrOperand) |
68 |
| - return MIOpNo != Other.MIOpNo || MiModifier != Other.MiModifier || |
69 |
| - PCRel != Other.PCRel; |
70 |
| - return false; |
71 |
| - } |
72 |
| - bool operator==(const AsmWriterOperand &Other) const { |
73 |
| - return !operator!=(Other); |
74 |
| - } |
75 |
| - |
76 |
| - /// getCode - Return the code that prints this operand. |
77 |
| - std::string getCode(bool PassSubtarget) const; |
78 |
| - }; |
79 |
| - |
80 |
| - class AsmWriterInst { |
81 |
| - public: |
82 |
| - std::vector<AsmWriterOperand> Operands; |
83 |
| - const CodeGenInstruction *CGI; |
84 |
| - unsigned CGIIndex; |
85 |
| - |
86 |
| - AsmWriterInst(const CodeGenInstruction &CGI, unsigned CGIIndex, |
87 |
| - unsigned Variant); |
88 |
| - |
89 |
| - /// MatchesAllButOneOp - If this instruction is exactly identical to the |
90 |
| - /// specified instruction except for one differing operand, return the |
91 |
| - /// differing operand number. Otherwise return ~0. |
92 |
| - unsigned MatchesAllButOneOp(const AsmWriterInst &Other) const; |
93 |
| - |
94 |
| - private: |
95 |
| - void AddLiteralString(const std::string &Str) { |
96 |
| - // If the last operand was already a literal text string, append this to |
97 |
| - // it, otherwise add a new operand. |
98 |
| - if (!Operands.empty() && |
99 |
| - Operands.back().OperandType == AsmWriterOperand::isLiteralTextOperand) |
100 |
| - Operands.back().Str.append(Str); |
101 |
| - else |
102 |
| - Operands.push_back(AsmWriterOperand(Str)); |
103 |
| - } |
104 |
| - }; |
105 |
| -} |
| 23 | +class CodeGenInstruction; |
| 24 | + |
| 25 | +struct AsmWriterOperand { |
| 26 | + enum OpType { |
| 27 | + // Output this text surrounded by quotes to the asm. |
| 28 | + isLiteralTextOperand, |
| 29 | + // This is the name of a routine to call to print the operand. |
| 30 | + isMachineInstrOperand, |
| 31 | + // Output this text verbatim to the asm writer. It is code that |
| 32 | + // will output some text to the asm. |
| 33 | + isLiteralStatementOperand |
| 34 | + } OperandType; |
| 35 | + |
| 36 | + /// MiOpNo - For isMachineInstrOperand, this is the operand number of the |
| 37 | + /// machine instruction. |
| 38 | + unsigned MIOpNo = 0; |
| 39 | + |
| 40 | + /// Str - For isLiteralTextOperand, this IS the literal text. For |
| 41 | + /// isMachineInstrOperand, this is the PrinterMethodName for the operand.. |
| 42 | + /// For isLiteralStatementOperand, this is the code to insert verbatim |
| 43 | + /// into the asm writer. |
| 44 | + std::string Str; |
| 45 | + |
| 46 | + /// MiModifier - For isMachineInstrOperand, this is the modifier string for |
| 47 | + /// an operand, specified with syntax like ${opname:modifier}. |
| 48 | + std::string MiModifier; |
| 49 | + |
| 50 | + bool PCRel = false; |
| 51 | + |
| 52 | + // To make VS STL happy |
| 53 | + AsmWriterOperand(OpType op = isLiteralTextOperand) : OperandType(op) {} |
| 54 | + |
| 55 | + AsmWriterOperand(const std::string &LitStr, OpType op = isLiteralTextOperand) |
| 56 | + : OperandType(op), Str(LitStr) {} |
| 57 | + |
| 58 | + AsmWriterOperand(const std::string &Printer, unsigned _MIOpNo, |
| 59 | + const std::string &Modifier, |
| 60 | + OpType op = isMachineInstrOperand, bool PCRel = false) |
| 61 | + : OperandType(op), MIOpNo(_MIOpNo), Str(Printer), MiModifier(Modifier), |
| 62 | + PCRel(PCRel) {} |
| 63 | + |
| 64 | + bool operator!=(const AsmWriterOperand &Other) const { |
| 65 | + if (OperandType != Other.OperandType || Str != Other.Str) |
| 66 | + return true; |
| 67 | + if (OperandType == isMachineInstrOperand) |
| 68 | + return MIOpNo != Other.MIOpNo || MiModifier != Other.MiModifier || |
| 69 | + PCRel != Other.PCRel; |
| 70 | + return false; |
| 71 | + } |
| 72 | + bool operator==(const AsmWriterOperand &Other) const { |
| 73 | + return !operator!=(Other); |
| 74 | + } |
| 75 | + |
| 76 | + /// getCode - Return the code that prints this operand. |
| 77 | + std::string getCode(bool PassSubtarget) const; |
| 78 | +}; |
| 79 | + |
| 80 | +class AsmWriterInst { |
| 81 | +public: |
| 82 | + std::vector<AsmWriterOperand> Operands; |
| 83 | + const CodeGenInstruction *CGI; |
| 84 | + unsigned CGIIndex; |
| 85 | + |
| 86 | + AsmWriterInst(const CodeGenInstruction &CGI, unsigned CGIIndex, |
| 87 | + unsigned Variant); |
| 88 | + |
| 89 | + /// MatchesAllButOneOp - If this instruction is exactly identical to the |
| 90 | + /// specified instruction except for one differing operand, return the |
| 91 | + /// differing operand number. Otherwise return ~0. |
| 92 | + unsigned MatchesAllButOneOp(const AsmWriterInst &Other) const; |
| 93 | + |
| 94 | +private: |
| 95 | + void AddLiteralString(const std::string &Str) { |
| 96 | + // If the last operand was already a literal text string, append this to |
| 97 | + // it, otherwise add a new operand. |
| 98 | + if (!Operands.empty() && |
| 99 | + Operands.back().OperandType == AsmWriterOperand::isLiteralTextOperand) |
| 100 | + Operands.back().Str.append(Str); |
| 101 | + else |
| 102 | + Operands.push_back(AsmWriterOperand(Str)); |
| 103 | + } |
| 104 | +}; |
| 105 | +} // namespace llvm |
106 | 106 |
|
107 | 107 | #endif
|
0 commit comments