39 #define DEBUG_TYPE "asm-printer" 44 MSP430AsmPrinter(
TargetMachine &
TM, std::unique_ptr<MCStreamer> Streamer)
47 StringRef getPassName()
const override {
return "MSP430 Assembly Printer"; }
54 void printSrcMemOperand(
const MachineInstr *MI,
int OpNum,
56 bool PrintAsmOperand(
const MachineInstr *MI,
unsigned OpNo,
58 bool PrintAsmMemoryOperand(
const MachineInstr *MI,
unsigned OpNo,
66 void MSP430AsmPrinter::PrintSymbolOperand(
const MachineOperand &MO,
70 O <<
'(' << Offset <<
'+';
87 if (!Modifier || strcmp(Modifier,
"nohash"))
99 if (!Modifier || strcmp(Modifier,
"nohash"))
101 PrintSymbolOperand(MO, O);
107 void MSP430AsmPrinter::printSrcMemOperand(
const MachineInstr *MI,
int OpNum,
120 if (Base.
getReg() != MSP430::SR && Base.
getReg() != MSP430::PC) {
129 bool MSP430AsmPrinter::PrintAsmOperand(
const MachineInstr *MI,
unsigned OpNo,
132 if (ExtraCode && ExtraCode[0])
139 bool MSP430AsmPrinter::PrintAsmMemoryOperand(
const MachineInstr *MI,
141 const char *ExtraCode,
143 if (ExtraCode && ExtraCode[0]) {
146 printSrcMemOperand(MI, OpNo, O);
151 void MSP430AsmPrinter::EmitInstruction(
const MachineInstr *MI) {
155 MCInstLowering.
Lower(MI, TmpInst);
156 EmitToStreamer(*OutStreamer, TmpInst);
159 void MSP430AsmPrinter::EmitInterruptVectorSection(
MachineFunction &ISR) {
160 MCSection *Cur = OutStreamer->getCurrentSectionOnly();
163 report_fatal_error(
"Functions with 'interrupt' attribute must have msp430_intrcc CC");
165 StringRef IVIdx =
F->getFnAttribute(
"interrupt").getValueAsString();
166 MCSection *IV = OutStreamer->getContext().getELFSection(
167 "__interrupt_vector_" + IVIdx,
169 OutStreamer->SwitchSection(IV);
171 const MCSymbol *FunctionSymbol = getSymbol(
F);
172 OutStreamer->EmitSymbolValue(FunctionSymbol,
TM.getProgramPointerSize());
173 OutStreamer->SwitchSection(Cur);
179 EmitInterruptVectorSection(MF);
182 SetupMachineFunction(MF);
Instances of this class represent a uniqued identifier for a section in the current translation unit...
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
Target & getTheMSP430Target()
MachineBasicBlock * getMBB() const
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
This class represents lattice values for constants.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
static const char * getRegisterName(unsigned RegNo)
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
MachineBasicBlock reference.
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
This file declares the MachineConstantPool class which is an abstract constant pool to keep track of ...
RegisterAsmPrinter - Helper template for registering a target specific assembly printer, for use in the target machine initialization function.
MSP430MCInstLower - This class is used to lower an MachineInstr into an MCInst.
Instances of this class represent a single low-level machine instruction.
Address of a global value.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
const GlobalValue * getGlobal() const
This class is intended to be used as a driving class for all asm writers.
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
MSP430_INTR - Calling convention used for MSP430 interrupt routines.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
MachineOperand class - Representation of each machine instruction operand.
Module.h This file contains the declarations for the Module class.
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeMSP430AsmPrinter()
virtual bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, const char *ExtraCode, raw_ostream &OS)
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant...
#define LLVM_EXTERNAL_VISIBILITY
const Function & getFunction() const
Return the LLVM function that this machine code represents.
void Lower(const MachineInstr *MI, MCInst &OutMI) const
Representation of each machine instruction.
static bool printOperand(raw_ostream &OS, const SelectionDAG *G, const SDValue Value)
int64_t getOffset() const
Return the offset from the symbol in this operand.
MCSymbol * getSymbol() const
Return the MCSymbol for this basic block.
This class implements an extremely fast bulk output stream that can only output to a stream...
Primary interface to the complete machine description for the target machine.
StringRef - Represent a constant reference to a string, i.e.
Register getReg() const
getReg - Returns the register number.
const MachineOperand & getOperand(unsigned i) const
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
void print(raw_ostream &OS, const MCAsmInfo *MAI) const
print - Print the value to the stream OS.