LLVM: lib/Target/MSP430/MCTargetDesc/MSP430InstPrinter.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
20using namespace llvm;
21
22#define DEBUG_TYPE "asm-printer"
23
24
25#define PRINT_ALIAS_INSTR
26#include "MSP430GenAsmWriter.inc"
27
31
39
40void MSP430InstPrinter::printPCRelImmOperand(const MCInst *MI, unsigned OpNo,
43 if (Op.isImm()) {
44 int64_t Imm = Op.getImm() * 2 + 2;
45 O << "$";
46 if (Imm >= 0)
47 O << '+';
48 O << Imm;
49 } else {
50 assert(Op.isExpr() && "unknown pcrel immediate operand");
52 }
53}
54
55void MSP430InstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
57 const MCOperand &Op = MI->getOperand(OpNo);
58 if (Op.isReg()) {
60 } else if (Op.isImm()) {
62 } else {
63 assert(Op.isExpr() && "unknown operand kind in printOperand");
64 O << '#';
65 MAI.printExpr(O, *Op.getExpr());
66 }
67}
68
69void MSP430InstPrinter::printSrcMemOperand(const MCInst *MI, unsigned OpNo,
71 const MCOperand &Base = MI->getOperand(OpNo);
72 const MCOperand &Disp = MI->getOperand(OpNo+1);
73
74
75
76
77
78
79
80
81
82 if (Base.getReg() == MSP430::SR)
83 O << '&';
84
87 else {
88 assert(Disp.isImm() && "Expected immediate in displacement field");
90 }
91
92
93 if ((Base.getReg() != MSP430::SR) &&
94 (Base.getReg() != MSP430::PC))
96}
97
98void MSP430InstPrinter::printIndRegOperand(const MCInst *MI, unsigned OpNo,
100 const MCOperand &Base = MI->getOperand(OpNo);
102}
103
104void MSP430InstPrinter::printPostIndRegOperand(const MCInst *MI, unsigned OpNo,
106 const MCOperand &Base = MI->getOperand(OpNo);
108}
109
110void MSP430InstPrinter::printCCOperand(const MCInst *MI, unsigned OpNo,
112 unsigned CC = MI->getOperand(OpNo).getImm();
113
114 switch (CC) {
115 default:
118 O << "eq";
119 break;
121 O << "ne";
122 break;
124 O << "hs";
125 break;
127 O << "lo";
128 break;
130 O << "ge";
131 break;
133 O << 'l';
134 break;
136 O << 'n';
137 break;
138 }
139}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
void printExpr(raw_ostream &, const MCExpr &) const
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.
const MCExpr * getExpr() const
Wrapper class representing physical registers. Should be passed by value.
Generic base class for all target subtargets.
static const char * getRegisterName(MCRegister Reg)
void printRegName(raw_ostream &O, MCRegister Reg) override
Print the assembler register name.
Definition MSP430InstPrinter.cpp:28
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 MSP430InstPrinter.cpp:32
void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &O)
bool printAliasInstr(const MCInst *MI, uint64_t Address, raw_ostream &O)
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