LLVM: lib/Target/CSKY/MCTargetDesc/CSKYInstPrinter.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
29
30using namespace llvm;
31
32#define DEBUG_TYPE "csky-asm-printer"
33
34
35#define PRINT_ALIAS_INSTR
36#include "CSKYGenAsmWriter.inc"
37
40 cl::desc("Disable the emission of assembler pseudo instructions"),
42
45 cl::desc("Print architectural register names rather than the "
46 "ABI names (such as r14 instead of sp)"),
48
49
50
51
52
53
55 if (Opt == "no-aliases") {
57 return true;
58 }
59 if (Opt == "numeric") {
61 return true;
62 }
63 if (Opt == "debug") {
65 return true;
66 }
67 if (Opt == "abi-names") {
68 ABIRegNames = true;
69 return true;
70 }
71
72 return false;
73}
74
84
87 O << getRegisterName(Reg, ABIRegNames ? CSKY::ABIRegAltName
88 : CSKY::NoRegAltName);
89 else
91}
92
99
102 const MCOperand &MO = MI->getOperand(OpNo);
103
104 if (MO.isReg()) {
105 unsigned Reg = MO.getReg();
106 bool useABIName = false;
108 useABIName = ABIRegNames;
109 else
111
112 if (Reg == CSKY::C)
113 O << "";
114 else if (STI.hasFeature(CSKY::FeatureJAVA)) {
115 if (Reg == CSKY::R23)
116 O << (useABIName ? "fp" : "r23");
117 else if (Reg == CSKY::R24)
118 O << (useABIName ? "top" : "r24");
119 else if (Reg == CSKY::R25)
120 O << (useABIName ? "bsp" : "r25");
121 else
123 } else
125
126 return;
127 }
128
129 if (MO.isImm()) {
130 uint64_t TSFlags = MII.get(MI->getOpcode()).TSFlags;
131
135 else
137 return;
138 }
139
140 assert(MO.isExpr() && "Unknown operand kind in printOperand");
142}
143
147 const MCOperand &MO = MI->getOperand(OpNo);
148
149 O << "[";
152 else
154 O << "]";
155}
156
160 const MCOperand &MO = MI->getOperand(OpNo);
161
162 if (MO.isImm()) {
165 Target &= 0xfffffffc;
167 } else {
169 }
170 return;
171 }
172
173 assert(MO.isExpr() && "Unknown operand kind in printConstpool");
174
175 O << "[";
177 O << "]";
178}
179
181 unsigned OpNo,
184 const MCOperand &MO = MI->getOperand(OpNo);
185 if (!MO.isImm()) {
187 }
188
191 Target &= 0xffffffff;
193 } else {
195 }
196}
197
200 auto V = MI->getOperand(OpNo).getImm();
201
203
204 if ((V >> 3) & 0x1)
205 O << LS << "ee";
206 if ((V >> 2) & 0x1)
207 O << LS << "ie";
208 if ((V >> 1) & 0x1)
209 O << LS << "fe";
210 if ((V >> 0) & 0x1)
211 O << LS << "af";
212}
213
221
225 auto V = MI->getOperand(OpNum).getImm();
227
228 if (V & 0xf) {
229 O << LS;
231 auto Offset = (V & 0xf) - 1;
233 O << "-";
235 }
236 }
237
238 if ((V >> 4) & 0x1) {
239 O << LS;
241 }
242
243 if ((V >> 5) & 0x7) {
244 O << LS;
246
247 auto Offset = ((V >> 5) & 0x7) - 1;
248
250 O << "-";
252 }
253 }
254
255 if ((V >> 8) & 0x1) {
256 O << LS;
258 }
259}
260
263 : CSKY::ABIRegAltName);
264}
265
268 const MCOperand &MO = MI->getOperand(OpNo);
270
272}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static cl::opt< bool > NoAliases("csky-no-aliases", cl::desc("Disable the emission of assembler pseudo instructions"), cl::init(false), cl::Hidden)
static cl::opt< bool > ArchRegNames("csky-arch-reg-names", cl::desc("Print architectural register names rather than the " "ABI names (such as r14 instead of sp)"), cl::init(false), cl::Hidden)
void printInst(const MCInst *MI, uint64_t Address, StringRef Annot, const MCSubtargetInfo &STI, raw_ostream &O) override
Print the specified MCInst to the specified raw_ostream.
Definition CSKYInstPrinter.cpp:75
void printRegisterSeq(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, raw_ostream &O)
Definition CSKYInstPrinter.cpp:214
void printFPRRegName(raw_ostream &O, unsigned RegNo) const
Definition CSKYInstPrinter.cpp:93
static const char * getRegisterName(MCRegister Reg)
Definition CSKYInstPrinter.cpp:261
void printDataSymbol(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, raw_ostream &O)
Definition CSKYInstPrinter.cpp:144
bool applyTargetSpecificCLOption(StringRef Opt) override
Customize the printer according to a command line option.
Definition CSKYInstPrinter.cpp:54
void printOperand(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, raw_ostream &O)
Definition CSKYInstPrinter.cpp:100
void printPSRFlag(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, raw_ostream &O)
Definition CSKYInstPrinter.cpp:198
void printCSKYSymbolOperand(const MCInst *MI, uint64_t Address, unsigned OpNo, const MCSubtargetInfo &STI, raw_ostream &O)
Definition CSKYInstPrinter.cpp:180
void printFPR(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, raw_ostream &O)
Definition CSKYInstPrinter.cpp:266
void printConstpool(const MCInst *MI, uint64_t Address, unsigned OpNo, const MCSubtargetInfo &STI, raw_ostream &O)
Definition CSKYInstPrinter.cpp:157
bool printAliasInstr(const MCInst *MI, uint64_t Address, const MCSubtargetInfo &STI, raw_ostream &O)
void printRegisterList(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, raw_ostream &O)
Definition CSKYInstPrinter.cpp:222
void printInstruction(const MCInst *MI, uint64_t Address, const MCSubtargetInfo &STI, raw_ostream &O)
void printRegName(raw_ostream &O, MCRegister Reg) override
Print the assembler register name.
Definition CSKYInstPrinter.cpp:85
A helper class to return the specified delimiter string after the first invocation of operator String...
format_object< int64_t > formatHex(int64_t Value) const
void printAnnotation(raw_ostream &OS, StringRef Annot)
Utility function for printing annotations.
bool PrintBranchImmAsAddress
If true, a branch immediate (e.g.
Instances of this class represent a single low-level machine instruction.
Instances of this class represent operands of the MCInst class.
MCRegister getReg() const
Returns the register number.
const MCExpr * getExpr() const
Wrapper class representing physical registers. Should be passed by value.
Generic base class for all target subtargets.
bool hasFeature(unsigned Feature) const
StringRef - Represent a constant reference to a string, i.e.
This class implements an extremely fast bulk output stream that can only output to a stream.
initializer< Ty > init(const Ty &Val)
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI bool DebugFlag
This boolean is set to true if the '-debug' command line option is specified.