33 #define DEBUG_TYPE "avr-asm-printer"
41 std::unique_ptr<MCStreamer> Streamer)
42 :
AsmPrinter(TM, std::move(Streamer)), MRI(*TM.getMCRegisterInfo()) { }
47 const char *Modifier = 0);
50 unsigned AsmVariant,
const char *ExtraCode,
54 unsigned AsmVariant,
const char *ExtraCode,
89 unsigned AsmVariant,
const char *ExtraCode,
95 if (Error && ExtraCode && ExtraCode[0]) {
96 if (ExtraCode[1] != 0)
99 if (ExtraCode[0] >=
'A' && ExtraCode[0] <=
'Z') {
102 assert(RegOp.
isReg() &&
"Operand must be a register when you're"
103 "using 'A'..'Z' operand extracodes.");
106 unsigned ByteNumber = ExtraCode[0] -
'A';
115 unsigned BytesPerReg = TRI.getMinimalPhysRegClass(Reg)->getSize();
116 assert(BytesPerReg <= 2 &&
"Only 8 and 16 bit regs are supported.");
118 unsigned RegIdx = ByteNumber / BytesPerReg;
119 assert(RegIdx < NumOpRegs &&
"Multibyte index out of range.");
123 if (BytesPerReg == 2) {
124 Reg = TRI.getSubReg(Reg, ByteNumber % BytesPerReg ? AVR::sub_hi
139 unsigned OpNum,
unsigned AsmVariant,
140 const char *ExtraCode,
142 if (ExtraCode && ExtraCode[0]) {
148 assert(MO.
isReg() &&
"Unexpected inline asm memory operand");
155 "Wrong register class for memory operand.");
164 if (NumOpRegs == 2) {
void EmitInstruction(const MachineInstr *MI) override
Targets should implement this to emit instructions.
const GlobalValue * getGlobal() const
std::unique_ptr< MCStreamer > OutStreamer
This is the MCStreamer object for the file we are generating.
MCSymbol * getSymbol(const GlobalValue *GV) const
MachineBasicBlock * getMBB() const
bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNum, unsigned AsmVariant, const char *ExtraCode, raw_ostream &O) override
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant as...
MCContext & OutContext
This is the context for the output file that we are streaming.
const MachineFunction * MF
The current machine function.
MachineBasicBlock reference.
const char * getSymbolName() const
Target & getTheAVRTarget()
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
Name of external global symbol.
Reg
All possible values of the reg field in the ModR/M byte.
Instances of this class represent a single low-level machine instruction.
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
void printOperand(const MachineInstr *MI, unsigned OpNo, raw_ostream &O, const char *Modifier=0)
void LLVMInitializeAVRAsmPrinter()
Address of a global value.
Lowers MachineInstr objects into MCInst objects.
const MachineOperand & getOperand(unsigned i) const
virtual bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, unsigned AsmVariant, const char *ExtraCode, raw_ostream &OS)
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant...
AVRAsmPrinter(TargetMachine &TM, std::unique_ptr< MCStreamer > Streamer)
TargetMachine & TM
Target machine description.
This class is intended to be used as a driving class for all asm writers.
static unsigned getNumOperandRegisters(unsigned Flag)
getNumOperandRegisters - Extract the number of registers field from the inline asm operand flag...
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang","erlang-compatible garbage collector")
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
MCSymbol * getSymbol() const
Return the MCSymbol for this basic block.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
void lowerInstruction(const MachineInstr &MI, MCInst &OutMI) const
Lowers a MachineInstr into a MCInst.
MachineOperand class - Representation of each machine instruction operand.
void EmitToStreamer(MCStreamer &S, const MCInst &Inst)
An AVR assembly code printer.
bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNum, unsigned AsmVariant, const char *ExtraCode, raw_ostream &O) override
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant...
A specific AVR target MCU.
Representation of each machine instruction.
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
static const char * getPrettyRegisterName(unsigned RegNo, MCRegisterInfo const &MRI)
StringRef getPassName() const override
getPassName - Return a nice clean name for a pass.
unsigned getReg() const
getReg - Returns the register number.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
RegisterAsmPrinter - Helper template for registering a target specific assembly printer, for use in the target machine initialization function.
Lightweight error class with error context and mandatory checking.
const AVRRegisterInfo * getRegisterInfo() const override
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.
MCSymbol * GetExternalSymbolSymbol(StringRef Sym) const
Return the MCSymbol for the specified ExternalSymbol.