LLVM: lib/Target/AVR/MCTargetDesc/AVRInstPrinter.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
14
16
24
25#include
26
27#define DEBUG_TYPE "asm-printer"
28
29namespace llvm {
30
31
32#define PRINT_ALIAS_INSTR
33#include "AVRGenAsmWriter.inc"
34
38 unsigned Opcode = MI->getOpcode();
39
40
41
42
43 switch (Opcode) {
44 case AVR::LDRdPtr:
45 case AVR::LDRdPtrPi:
46 case AVR::LDRdPtrPd:
47 O << "\tld\t";
48 printOperand(MI, 0, O);
49 O << ", ";
50
51 if (Opcode == AVR::LDRdPtrPd)
52 O << '-';
53
54 printOperand(MI, 1, O);
55
56 if (Opcode == AVR::LDRdPtrPi)
57 O << '+';
58 break;
59 case AVR::STPtrRr:
60 O << "\tst\t";
61 printOperand(MI, 0, O);
62 O << ", ";
63 printOperand(MI, 1, O);
64 break;
65 case AVR::STPtrPiRr:
66 case AVR::STPtrPdRr:
67 O << "\tst\t";
68
69 if (Opcode == AVR::STPtrPdRr)
70 O << '-';
71
72 printOperand(MI, 1, O);
73
74 if (Opcode == AVR::STPtrPiRr)
75 O << '+';
76
77 O << ", ";
78 printOperand(MI, 2, O);
79 break;
80 default:
81 if (!printAliasInstr(MI, Address, O))
83
85 break;
86 }
87}
88
91
92
93 if (MRI.getNumSubRegIndices() > 0) {
95 Reg = (RegLo != AVR::NoRegister) ? RegLo : Reg;
96 }
97
98 return getRegisterName(Reg);
99}
100
101void AVRInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
105
106 if (Op.isReg()) {
107 bool isPtrReg = (MOI.RegClass == AVR::PTRREGSRegClassID) ||
108 (MOI.RegClass == AVR::PTRDISPREGSRegClassID) ||
109 (MOI.RegClass == AVR::ZREGRegClassID);
110
111 if (isPtrReg) {
113 } else {
115 }
116 } else if (Op.isImm()) {
118 } else {
119 assert(Op.isExpr() && "Unknown operand kind in printOperand");
120 MAI.printExpr(O, *Op.getExpr());
121 }
122}
123
124
125
126void AVRInstPrinter::printPCRelImm(const MCInst *MI, unsigned OpNo,
128 if (OpNo >= MI->size()) {
129
130
131
132
133
134 O << "";
135 return;
136 }
137
138 const MCOperand &Op = MI->getOperand(OpNo);
139
140 if (Op.isImm()) {
141 int64_t Imm = Op.getImm();
142 O << '.';
143
144
145
146 if (Imm >= 0)
147 O << '+';
148
150 } else {
151 assert(Op.isExpr() && "Unknown pcrel immediate operand");
152 MAI.printExpr(O, *Op.getExpr());
153 }
154}
155
156void AVRInstPrinter::printMemri(const MCInst *MI, unsigned OpNo,
158 assert(MI->getOperand(OpNo).isReg() &&
159 "Expected a register for the first operand");
160
161 const MCOperand &OffsetOp = MI->getOperand(OpNo + 1);
162
163
164 printOperand(MI, OpNo, O);
165
166
169
171 O << '+';
172
174 } else if (OffsetOp.isExpr()) {
176 } else {
178 }
179}
180
181}
unsigned const MachineRegisterInfo * MRI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
std::pair< Instruction::BinaryOps, Value * > OffsetOp
Find all possible pairs (BinOp, RHS) that BinOp V, RHS can be simplified.
static std::string getRegisterName(const TargetRegisterInfo *TRI, Register Reg)
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 AVRInstPrinter.cpp:35
static const char * getPrettyRegisterName(MCRegister Reg, MCRegisterInfo const &MRI)
Definition AVRInstPrinter.cpp:89
const MCRegisterInfo & MRI
void printAnnotation(raw_ostream &OS, StringRef Annot)
Utility function for printing annotations.
format_object< int64_t > formatImm(int64_t Value) const
Utility function to print immediates in decimal or hex.
Instances of this class represent a single low-level machine instruction.
unsigned getOpcode() const
ArrayRef< MCOperandInfo > operands() const
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode.
This holds information about one operand of a machine instruction, indicating the register class for ...
int16_t RegClass
This specifies the register class enumeration of the operand if the operand is a register.
Instances of this class represent operands of the MCInst class.
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
Wrapper class representing physical registers. Should be passed by value.
Generic base class for all target subtargets.
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.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.
DWARFExpression::Operation Op