40#define DEBUG_TYPE "asm-printer"
45 MSP430AsmPrinter(
TargetMachine &TM, std::unique_ptr<MCStreamer> Streamer)
48 StringRef getPassName()
const override {
return "MSP430 Assembly Printer"; }
54 bool PrefixHash =
true);
81void MSP430AsmPrinter::printOperand(
const MachineInstr *
MI,
int OpNum,
82 raw_ostream &O,
bool PrefixHash) {
83 const MachineOperand &MO =
MI->getOperand(OpNum);
104 PrintSymbolOperand(MO, O);
110void MSP430AsmPrinter::printSrcMemOperand(
const MachineInstr *
MI,
int OpNum,
112 const MachineOperand &
Base =
MI->getOperand(OpNum);
113 const MachineOperand &Disp =
MI->getOperand(OpNum+1);
118 if (Disp.
isImm() &&
Base.getReg() == MSP430::SR)
123 if (
Base.getReg() != MSP430::SR &&
Base.getReg() != MSP430::PC) {
132bool MSP430AsmPrinter::PrintAsmOperand(
const MachineInstr *
MI,
unsigned OpNo,
133 const char *ExtraCode, raw_ostream &O) {
135 if (ExtraCode && ExtraCode[0])
142bool MSP430AsmPrinter::PrintAsmMemoryOperand(
const MachineInstr *
MI,
144 const char *ExtraCode,
146 if (ExtraCode && ExtraCode[0]) {
149 printSrcMemOperand(
MI, OpNo, O);
154void MSP430AsmPrinter::emitInstruction(
const MachineInstr *
MI) {
155 MSP430_MC::verifyInstructionPredicates(
MI->getOpcode(),
156 getSubtargetInfo().getFeatureBits());
158 MSP430MCInstLower MCInstLowering(OutContext, *
this);
161 MCInstLowering.Lower(
MI, TmpInst);
162 EmitToStreamer(*OutStreamer, TmpInst);
165void MSP430AsmPrinter::EmitInterruptVectorSection(MachineFunction &ISR) {
166 MCSection *Cur = OutStreamer->getCurrentSectionOnly();
168 if (
F->getCallingConv() != CallingConv::MSP430_INTR) {
169 report_fatal_error(
"Functions with 'interrupt' attribute must have msp430_intrcc CC");
172 MCSection *
IV = OutStreamer->getContext().getELFSection(
173 "__interrupt_vector_" + IVIdx,
175 OutStreamer->switchSection(
IV);
178 OutStreamer->emitSymbolValue(FunctionSymbol, TM.getProgramPointerSize());
179 OutStreamer->switchSection(Cur);
182bool MSP430AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
185 EmitInterruptVectorSection(MF);
188 SetupMachineFunction(MF);
193char MSP430AsmPrinter::ID = 0;
196 "MSP430 Assembly Printer",
false,
false)
200LLVMInitializeMSP430AsmPrinter() {
206 MSP430AsmPrinter &
AsmPrinter =
static_cast<MSP430AsmPrinter &
>(
216 MSP430AsmPrinter &
AsmPrinter =
static_cast<MSP430AsmPrinter &
>(
227 MSP430AsmPrinter &
AsmPrinter =
static_cast<MSP430AsmPrinter &
>(
static const Function * getParent(const Value *V)
#define LLVM_EXTERNAL_VISIBILITY
This header defines various interfaces for pass management in LLVM.
This file declares the MachineConstantPool class which is an abstract constant pool to keep track of ...
ModuleAnalysisManager MAM
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
static bool printOperand(raw_ostream &OS, const SelectionDAG *G, const SDValue Value)
static const uint32_t IV[8]
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
This class is intended to be used as a driving class for all asm writers.
bool doInitialization(Module &M) override
Set up the AsmPrinter when we are working on a new module.
bool doFinalization(Module &M) override
Shut down the asmprinter.
bool runOnMachineFunction(MachineFunction &MF) override
Emit the specified function out to the OutStreamer.
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.
LLVM_ABI StringRef getValueAsString() const
Return the attribute's value as a string.
Attribute getFnAttribute(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind.
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
LLVM_ABI void print(raw_ostream &OS, const MCAsmInfo *MAI) const
print - Print the value to the stream OS.
PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM)
PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM)
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
static const char * getRegisterName(MCRegister Reg)
LLVM_ABI 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.
A Module instance is used to store all the information related to an LLVM module.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
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.
Pass manager infrastructure for declaring and invalidating analyses.
#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.
OuterAnalysisManagerProxy< ModuleAnalysisManager, MachineFunction > ModuleAnalysisManagerMachineFunctionProxy
Provide the ModuleAnalysisManager to Function proxy.
Target & getTheMSP430Target()
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
LLVM_ABI void setupModuleAsmPrinter(Module &M, ModuleAnalysisManager &MAM, AsmPrinter &AsmPrinter)
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
LLVM_ABI void setupMachineFunctionAsmPrinter(MachineFunctionAnalysisManager &MFAM, MachineFunction &MF, AsmPrinter &AsmPrinter)
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
RegisterAsmPrinter - Helper template for registering a target specific assembly printer,...