39#define DEBUG_TYPE "asm-printer"
44 MSP430AsmPrinter(
TargetMachine &TM, std::unique_ptr<MCStreamer> Streamer)
78void MSP430AsmPrinter::printOperand(
const MachineInstr *
MI,
int OpNum,
87 if (!Modifier || strcmp(Modifier,
"nohash"))
99 if (!Modifier || strcmp(Modifier,
"nohash"))
101 PrintSymbolOperand(MO, O);
107void MSP430AsmPrinter::printSrcMemOperand(
const MachineInstr *
MI,
int OpNum,
115 if (Disp.
isImm() &&
Base.getReg() == MSP430::SR)
120 if (
Base.getReg() != MSP430::SR &&
Base.getReg() != MSP430::PC) {
129bool MSP430AsmPrinter::PrintAsmOperand(
const MachineInstr *
MI,
unsigned OpNo,
132 if (ExtraCode && ExtraCode[0])
139bool MSP430AsmPrinter::PrintAsmMemoryOperand(
const MachineInstr *
MI,
141 const char *ExtraCode,
143 if (ExtraCode && ExtraCode[0]) {
146 printSrcMemOperand(
MI, OpNo, O);
152 MSP430_MC::verifyInstructionPredicates(
MI->getOpcode(),
153 getSubtargetInfo().getFeatureBits());
158 MCInstLowering.Lower(
MI, TmpInst);
159 EmitToStreamer(*OutStreamer, TmpInst);
162void MSP430AsmPrinter::EmitInterruptVectorSection(
MachineFunction &ISR) {
163 MCSection *Cur = OutStreamer->getCurrentSectionOnly();
166 report_fatal_error(
"Functions with 'interrupt' attribute must have msp430_intrcc CC");
168 StringRef IVIdx =
F->getFnAttribute(
"interrupt").getValueAsString();
169 MCSection *
IV = OutStreamer->getContext().getELFSection(
170 "__interrupt_vector_" + IVIdx,
172 OutStreamer->switchSection(
IV);
175 OutStreamer->emitSymbolValue(FunctionSymbol,
TM.getProgramPointerSize());
176 OutStreamer->switchSection(Cur);
182 EmitInterruptVectorSection(MF);
185 SetupMachineFunction(MF);
#define LLVM_EXTERNAL_VISIBILITY
This file contains the declarations for the subclasses of Constant, which represent the different fla...
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeMSP430AsmPrinter()
This file declares the MachineConstantPool class which is an abstract constant pool to keep track of ...
Module.h This file contains the declarations for the Module class.
static bool printOperand(raw_ostream &OS, const SelectionDAG *G, const SDValue Value)
static const uint32_t IV[8]
This class is intended to be used as a driving class for all asm writers.
virtual void emitInstruction(const MachineInstr *)
Targets should implement this to emit instructions.
virtual void PrintSymbolOperand(const MachineOperand &MO, raw_ostream &OS)
Print the MachineOperand as a symbol.
bool runOnMachineFunction(MachineFunction &MF) override
Emit the specified function out to the OutStreamer.
virtual bool PrintAsmMemoryOperand(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 as...
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.
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
Instances of this class represent a single low-level machine instruction.
Instances of this class represent a uniqued identifier for a section in the current translation unit.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
void print(raw_ostream &OS, const MCAsmInfo *MAI) const
print - Print the value to the stream OS.
static const char * getRegisterName(MCRegister Reg)
MSP430MCInstLower - This class is used to lower an MachineInstr into an MCInst.
MCSymbol * getSymbol() const
Return the MCSymbol for this basic block.
Function & getFunction()
Return the LLVM function that this machine code represents.
Representation of each machine instruction.
MachineOperand class - Representation of each machine instruction operand.
const GlobalValue * getGlobal() const
MachineBasicBlock * getMBB() const
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
Register getReg() const
getReg - Returns the register number.
@ MO_Immediate
Immediate operand.
@ MO_GlobalAddress
Address of a global value.
@ MO_MachineBasicBlock
MachineBasicBlock reference.
@ MO_Register
Register operand.
int64_t getOffset() const
Return the offset from the symbol in this operand.
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
StringRef - Represent a constant reference to a string, i.e.
Primary interface to the complete machine description for the target machine.
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.
@ MSP430_INTR
Used for MSP430 interrupt routines.
This is an optimization pass for GlobalISel generic memory operations.
Target & getTheMSP430Target()
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
RegisterAsmPrinter - Helper template for registering a target specific assembly printer,...