Go to the documentation of this file.
37 #define DEBUG_TYPE "avr-asm-printer"
69 bool EmittedStructorSymbolAttrs =
false;
103 if (
Error && ExtraCode && ExtraCode[0]) {
104 if (ExtraCode[1] != 0)
107 if (ExtraCode[0] >=
'A' && ExtraCode[0] <=
'Z') {
110 assert(RegOp.
isReg() &&
"Operand must be a register when you're"
111 "using 'A'..'Z' operand extracodes.");
114 unsigned ByteNumber = ExtraCode[0] -
'A';
116 unsigned OpFlags =
MI->getOperand(OpNum - 1).getImm();
124 unsigned BytesPerReg =
TRI.getRegSizeInBits(*RC) / 8;
125 assert(BytesPerReg <= 2 &&
"Only 8 and 16 bit regs are supported.");
127 unsigned RegIdx = ByteNumber / BytesPerReg;
128 assert(RegIdx < NumOpRegs &&
"Multibyte index out of range.");
130 Reg =
MI->getOperand(OpNum + RegIdx).getReg();
132 if (BytesPerReg == 2) {
133 Reg =
TRI.getSubReg(
Reg, ByteNumber % BytesPerReg ? AVR::sub_hi
149 unsigned OpNum,
const char *ExtraCode,
151 if (ExtraCode && ExtraCode[0])
156 assert(MO.
isReg() &&
"Unexpected inline asm memory operand");
162 if (
MI->getOperand(OpNum).getReg() == AVR::R31R30) {
165 assert(
MI->getOperand(OpNum).getReg() == AVR::R29R28 &&
166 "Wrong register class for memory operand.");
172 unsigned OpFlags =
MI->getOperand(OpNum - 1).getImm();
175 if (NumOpRegs == 2) {
176 O <<
'+' <<
MI->getOperand(OpNum + 1).getImm();
193 if (
const GlobalValue *GV = dyn_cast<GlobalValue>(CV)) {
205 if (!EmittedStructorSymbolAttrs) {
207 " Emitting these undefined symbol references causes us to link the"
208 " libgcc code that runs our constructors/destructors");
209 OutStreamer->emitRawComment(
" This matches GCC's behavior");
217 EmittedStructorSymbolAttrs =
true;
230 " Declaring this symbol tells the CRT that it should");
232 "copy all variables from program memory to RAM on startup");
236 " Declaring this symbol tells the CRT that it should");
237 OutStreamer->emitRawComment(
"clear the zeroed data section on startup");
@ MO_Immediate
Immediate operand.
This is an optimization pass for GlobalISel generic memory operations.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
A parsed version of the target data layout string in and methods for querying it.
virtual void emitXXStructor(const DataLayout &DL, const Constant *CV)
Targets can override this to change how global constants that are part of a C++ static/global constru...
virtual const MCExpr * lowerConstant(const Constant *CV)
Lower the specified LLVM Constant to an MCExpr.
const MCContext & getContext() const
void emitInstruction(const MachineInstr *MI) override
Targets should implement this to emit instructions.
int getIORegEIND(void) const
const GlobalValue * getGlobal() const
Context object for machine code objects.
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
A generic AVR implementation.
Reg
All possible values of the reg field in the ModR/M byte.
bool doFinalization(Module &M) override
Shut down the asmprinter.
int getIORegSPH(void) const
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeAVRAsmPrinter()
bool doFinalization(Module &M) override
Shut down the asmprinter.
Instances of this class represent a single low-level machine instruction.
unsigned const TargetRegisterInfo * TRI
@ MO_Register
Register operand.
void EmitToStreamer(MCStreamer &S, const MCInst &Inst)
int getIORegRAMPZ(void) const
Get I/O register addresses.
MCSymbol * getSymbol() const
Return the MCSymbol for this basic block.
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
Lowers MachineInstr objects into MCInst objects.
@ MO_GlobalAddress
Address of a global value.
std::unique_ptr< MCStreamer > OutStreamer
This is the MCStreamer object for the file we are generating.
A specific AVR target MCU.
bool hasEIJMPCALL() const
const LLVMTargetMachine & getTarget() const
Target & getTheAVRTarget()
MachineOperand class - Representation of each machine instruction operand.
This class implements an extremely fast bulk output stream that can only output to a stream.
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
void emitStartOfAsmFile(Module &M) override
This virtual method can be overridden by targets that want to emit something at the start of their fi...
bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNum, const char *ExtraCode, raw_ostream &O) override
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant.
int getRegZeroIndex(void) const
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
static const AVRMCExpr * create(VariantKind Kind, const MCExpr *Expr, bool isNegated, MCContext &Ctx)
Creates an AVR machine code expression.
This is an important base class in LLVM.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
Representation of each machine instruction.
static const char * getPrettyRegisterName(unsigned RegNo, MCRegisterInfo const &MRI)
#define LLVM_EXTERNAL_VISIBILITY
void printOperand(const MachineInstr *MI, unsigned OpNo, raw_ostream &O)
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
const MCExpr * lowerConstant(const Constant *CV) override
Lower the specified LLVM Constant to an MCExpr.
bool hasSmallStack() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
MCSymbol * getSymbol(const GlobalValue *GV) const
Primary interface to the complete machine description for the target machine.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
MachineFunction * MF
The current machine function.
MCContext & OutContext
This is the context for the output file that we are streaming.
Register getReg() const
getReg - Returns the register number.
A Module instance is used to store all the information related to an LLVM module.
MCSymbol * GetExternalSymbolSymbol(StringRef Sym) const
Return the MCSymbol for the specified ExternalSymbol.
@ VK_AVR_PM
Corresponds to pm(), reference to program memory.
MachineBasicBlock * getMBB() const
StringRef - Represent a constant reference to a string, i.e.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ MO_MachineBasicBlock
MachineBasicBlock reference.
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
int getIORegSREG(void) const
StringRef getPassName() const override
getPassName - Return a nice clean name for a pass.
Wrapper class representing virtual and physical registers.
MachineModuleInfo * MMI
This is a pointer to the current MachineModuleInfo.
int getRegTmpIndex(void) const
Get GPR aliases.
Lightweight error class with error context and mandatory checking.
@ MO_ExternalSymbol
Name of external global symbol.
void emitXXStructor(const DataLayout &DL, const Constant *CV) override
Targets can override this to change how global constants that are part of a C++ static/global constru...
This class is intended to be used as a driving class for all asm writers.
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
@ MCSA_Global
.type _foo, @gnu_unique_object
AVRAsmPrinter(TargetMachine &TM, std::unique_ptr< MCStreamer > Streamer)
An AVR assembly code printer.
const AVRRegisterInfo * getRegisterInfo() const override
TargetMachine & TM
Target machine description.
bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNum, const char *ExtraCode, raw_ostream &O) override
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant as...
virtual const TargetSubtargetInfo * getSubtargetImpl(const Function &) const
Virtual method implemented by subclasses that returns a reference to that target's TargetSubtargetInf...
static unsigned getNumOperandRegisters(unsigned Flag)
getNumOperandRegisters - Extract the number of registers field from the inline asm operand flag.
const char * getSymbolName() const
RegisterAsmPrinter - Helper template for registering a target specific assembly printer,...
Base class for the full range of assembler expressions which are needed for parsing.
void lowerInstruction(const MachineInstr &MI, MCInst &OutMI) const
Lowers a MachineInstr into a MCInst.
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.
int getIORegSPL(void) const