LLVM: lib/Target/ARC/MCTargetDesc/ARCInstPrinter.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
23
24using namespace llvm;
25
26#define DEBUG_TYPE "asm-printer"
27
28#include "ARCGenAsmWriter.inc"
29
30template
32 LLVM_DEBUG(dbgs() << "Unknown condition code passed: " << cc << "\n");
33 return "{unknown-cc}";
34}
35
37 switch (BRCC) {
39 return "eq";
41 return "ne";
43 return "lt";
45 return "ge";
47 return "lo";
49 return "hs";
50 }
52}
53
55 switch (CC) {
57 return "eq";
59 return "ne";
61 return "p";
63 return "n";
65 return "hs";
67 return "lo";
69 return "gt";
71 return "ge";
73 return "vs";
75 return "vc";
77 return "lt";
79 return "le";
81 return "hi";
83 return "ls";
85 return "pnz";
87 return "al";
89 return "nz";
91 return "z";
92 }
94}
95
99
106
111
113 OS << "0x";
115 return;
116 }
117
121 assert(SRE && CE && "Binary expression must be sym+const.");
122 Offset = CE->getValue();
123 } else {
125 assert(SRE && "Unexpected MCExpr type.");
126 }
128
129
130 OS << '@';
132
135 OS << '+';
137 }
138}
139
140void ARCInstPrinter::printOperand(const MCInst *MI, unsigned OpNum,
142 const MCOperand &Op = MI->getOperand(OpNum);
143 if (Op.isReg()) {
145 return;
146 }
147
148 if (Op.isImm()) {
150 return;
151 }
152
153 assert(Op.isExpr() && "unknown operand kind in printOperand");
155}
156
157void ARCInstPrinter::printMemOperandRI(const MCInst *MI, unsigned OpNum,
159 const MCOperand &base = MI->getOperand(OpNum);
160 const MCOperand &offset = MI->getOperand(OpNum + 1);
161 assert(base.isReg() && "Base should be register.");
162 assert(offset.isImm() && "Offset should be immediate.");
164 O << "," << offset.getImm();
165}
166
167void ARCInstPrinter::printPredicateOperand(const MCInst *MI, unsigned OpNum,
169
170 const MCOperand &Op = MI->getOperand(OpNum);
171 assert(Op.isImm() && "Predicate operand is immediate.");
173}
174
175void ARCInstPrinter::printBRCCPredicateOperand(const MCInst *MI, unsigned OpNum,
177 const MCOperand &Op = MI->getOperand(OpNum);
178 assert(Op.isImm() && "Predicate operand is immediate.");
180}
181
186
187void ARCInstPrinter::printU6ShiftedBy(unsigned ShiftBy, const MCInst *MI,
189 const MCOperand &MO = MI->getOperand(OpNum);
190 if (MO.isImm()) {
192 unsigned Value2 = Value >> ShiftBy;
193 if (Value2 > 0x3F || (Value2 << ShiftBy != Value)) {
194 errs() << "!!! Instruction has out-of-range U6 immediate operand:\n"
195 << " Opcode is " << MI->getOpcode() << "; operand value is "
197 if (ShiftBy)
198 errs() << " scaled by " << (1 << ShiftBy) << "\n";
199 assert(false && "instruction has wrong format");
200 }
201 }
202 printOperand(MI, OpNum, O);
203}
204
206 printU6ShiftedBy(0, MI, OpNum, O);
207}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static const char * BadConditionCode(T cc)
Definition ARCInstPrinter.cpp:31
static void printExpr(const MCExpr *Expr, const MCAsmInfo *MAI, raw_ostream &OS)
Definition ARCInstPrinter.cpp:107
static const char * ARCBRCondCodeToString(ARCCC::BRCondCode BRCC)
Definition ARCInstPrinter.cpp:36
static const char * ARCCondCodeToString(ARCCC::CondCode CC)
Definition ARCInstPrinter.cpp:54
This file contains the declaration of the ARCInstPrinter class, which is used to print ARC MCInst to ...
void printCCOperand(const MCInst *MI, int OpNum, raw_ostream &O)
Definition ARCInstPrinter.cpp:182
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 ARCInstPrinter.cpp:100
static const char * getRegisterName(MCRegister Reg)
void printRegName(raw_ostream &OS, MCRegister Reg) override
Print the assembler register name.
Definition ARCInstPrinter.cpp:96
void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &O)
void printU6(const MCInst *MI, int OpNum, raw_ostream &O)
Definition ARCInstPrinter.cpp:205
This class is intended to be used as a base class for asm properties and features specific to the tar...
Base class for the full range of assembler expressions which are needed for parsing.
void printAnnotation(raw_ostream &OS, StringRef Annot)
Utility function for printing annotations.
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.
Wrapper class representing physical registers. Should be passed by value.
Generic base class for all target subtargets.
Represent a reference to a symbol from inside an expression.
const MCSymbol & getSymbol() const
uint16_t getSpecifier() const
LLVM_ABI void print(raw_ostream &OS, const MCAsmInfo *MAI) const
print - Print the value to the stream OS.
StringRef - Represent a constant reference to a string, i.e.
LLVM_ABI std::string lower() const
LLVM Value Representation.
This class implements an extremely fast bulk output stream that can only output to a stream.
raw_ostream & write_hex(unsigned long long N)
Output N in hexadecimal, without any prefix or padding.
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast - Return the argument parameter cast to the specified type.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
LLVM_ABI raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
DWARFExpression::Operation Op