Go to the documentation of this file.
34 #define DEBUG_TYPE "csky-asm-printer"
37 "Number of C-SKY Compressed instructions emitted");
40 std::unique_ptr<llvm::MCStreamer> Streamer)
57 #define GEN_COMPRESS_INSTR
58 #include "CSKYGenCompressInstEmitter.inc"
61 bool Res = compressInst(CInst, Inst, *Subtarget,
OutStreamer->getContext());
63 ++CSKYNumInstrsCompressed;
69 #include "CSKYGenMCPseudoLowering.inc"
76 "_" +
Twine(
MI->getOperand(3).getImm()));
81 .
add(
MI->getOperand(0))
82 .
add(
MI->getOperand(2));
84 MCInstLowering.
Lower(Instr, LRWInst);
88 .
add(
MI->getOperand(1))
91 MCInstLowering.
Lower(Instr, GRSInst);
96 void CSKYAsmPrinter::emitCustomConstantPool(
const MachineInstr *
MI) {
103 unsigned LabelId = (unsigned)
MI->getOperand(0).getImm();
104 unsigned CPIdx = (unsigned)
MI->getOperand(1).getIndex();
107 if (!InConstantPool) {
109 InConstantPool =
true;
127 InConstantPool =
false;
149 if (InConstantPool &&
MI->getOpcode() != CSKY::CONSTPOOL_ENTRY) {
150 InConstantPool =
false;
153 if (
MI->getOpcode() == CSKY::PseudoTLSLA32)
154 return expandTLSLA(
MI);
156 if (
MI->getOpcode() == CSKY::CONSTPOOL_ENTRY)
157 return emitCustomConstantPool(
MI);
160 MCInstLowering.
Lower(
MI, TmpInst);
197 cast<CSKYConstantPoolConstant>(CCPV)->getBlockAddress();
200 const GlobalValue *GV = cast<CSKYConstantPoolConstant>(CCPV)->getGV();
205 }
else if (CCPV->
isJT()) {
206 signed JTI = cast<CSKYConstantPoolJT>(CCPV)->getJTI();
210 StringRef Sym = cast<CSKYConstantPoolSymbol>(CCPV)->getSymbol();
242 void CSKYAsmPrinter::emitAttributes() {
264 if (ExtraCode && ExtraCode[0]) {
265 if (ExtraCode[1] != 0)
268 switch (ExtraCode[0]) {
304 unsigned OpNo,
const char *ExtraCode,
bool isMachineBasicBlock() const
@ MO_BlockAddress
Address of a basic block.
@ 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
void emitFunctionBodyEnd() override
Targets can override this to emit stuff after the last basic block in the function.
const MachineInstrBuilder & add(const MachineOperand &MO) const
virtual const TargetInstrInfo * getInstrInfo() const
MachineConstantPoolValue * MachineCPVal
const MCAsmInfo * MAI
Target Asm Printer information.
StringRef getPrivateGlobalPrefix() const
void emitGlobalConstant(const DataLayout &DL, const Constant *CV)
Print a general LLVM constant to the .s file.
bool emitPseudoExpansionLowering(MCStreamer &OutStreamer, const MachineInstr *MI)
tblgen'erated driver function for lowering simple MI->MC pseudo instructions.
const BlockAddress * getBlockAddress() const
union llvm::MachineConstantPoolEntry::@188 Val
The constant itself.
Triple - Helper class for working with autoconf configuration names.
Abstract base class for all machine specific constantpool value subclasses.
virtual void PrintSymbolOperand(const MachineOperand &MO, raw_ostream &OS)
Print the MachineOperand as a symbol.
static const CSKYMCExpr * create(const MCExpr *Expr, VariantKind Kind, MCContext &Ctx)
void setFeatureBits(const FeatureBitset &FeatureBits_)
Instances of this class represent a single low-level machine instruction.
bool isGlobalValue() const
@ MO_Register
Register operand.
void EmitToStreamer(MCStreamer &S, const MCInst &Inst)
Target & getTheCSKYTarget()
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeCSKYAsmPrinter()
MCSymbol * getSymbol() const
Return the MCSymbol for this basic block.
Streaming machine code generation interface.
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
bool isOSBinFormatELF() const
Tests whether the OS uses the ELF binary format.
bool isBlockAddress() const
@ MO_GlobalAddress
Address of a global value.
CSKYAsmPrinter(TargetMachine &TM, std::unique_ptr< MCStreamer > Streamer)
std::unique_ptr< MCStreamer > OutStreamer
This is the MCStreamer object for the file we are generating.
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...
(vector float) vec_cmpeq(*A, *B) C
const HexagonInstrInfo * TII
bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, const char *ExtraCode, raw_ostream &OS) override
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant.
MachineOperand class - Representation of each machine instruction operand.
const FeatureBitset & getFeatureBits() const
bool mustAddCurrentAddress() const
STATISTIC(NumFunctions, "Total number of functions")
This class implements an extremely fast bulk output stream that can only output to a stream.
void print(raw_ostream &OS, const MCAsmInfo *MAI) const
print - Print the value to the stream OS.
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
void EmitToStreamer(MCStreamer &S, const MCInst &Inst)
void emitStartOfAsmFile(Module &M) override
This virtual method can be overridden by targets that want to emit something at the start of their fi...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
void Lower(const MachineInstr *MI, MCInst &OutMI) const
unsigned getLabelID() const
virtual MCSymbol * GetCPISymbol(unsigned CPID) const
Return the symbol for the specified constant pool entry.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
Representation of each machine instruction.
#define LLVM_EXTERNAL_VISIBILITY
const MCSubtargetInfo * getMCSubtargetInfo() const
MCSymbol * GetBlockAddressSymbol(const BlockAddress *BA) const
Return the MCSymbol used to satisfy BlockAddress uses of the specified basic block.
CSKYConstantPoolValue - CSKY specific constantpool value.
void emitInstruction(const MachineInstr *MI) override
Targets should implement this to emit instructions.
static const char * getRegisterName(unsigned RegNo)
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
MachineConstantPool * getConstantPool()
getConstantPool - Return the constant pool object for the current function.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool isMachineConstantPoolEntry() const
isMachineConstantPoolEntry - Return true if the MachineConstantPoolEntry is indeed a target specific ...
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.
CSKYCP::CSKYCPModifier getModifier() const
static const MCBinaryExpr * createSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
MachineFunction * MF
The current machine function.
MCContext & OutContext
This is the context for the output file that we are streaming.
void emitMachineConstantPoolValue(MachineConstantPoolValue *MCPV) override
Register getReg() const
getReg - Returns the register number.
A Module instance is used to store all the information related to an LLVM module.
void emitEndOfAsmFile(Module &M) override
This virtual method can be overridden by targets that want to emit something at the end of their file...
bool runOnMachineFunction(MachineFunction &MF) override
Emit the specified function out to the OutStreamer.
The address of a basic block.
MCSymbol * GetExternalSymbolSymbol(StringRef Sym) const
Return the MCSymbol for the specified ExternalSymbol.
StringRef - Represent a constant reference to a string, i.e.
Analysis the ScalarEvolution expression for r is this
MCSymbol * GetJTISymbol(unsigned JTID, bool isLinkerPrivate=false) const
Return the symbol for the specified jump table entry.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo, const char *ExtraCode, raw_ostream &OS) override
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant as...
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
StringRef getTargetFeatureString() const
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
MCSymbol * createTempSymbol()
Create a temporary symbol with a unique name.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
This class is a data container for one entry in a MachineConstantPool.
const std::vector< MachineConstantPoolEntry > & getConstants() const
bool runOnMachineFunction(MachineFunction &MF) override
Emit the specified function out to the OutStreamer.
unsigned getPCAdjustment() const
This class is intended to be used as a driving class for all asm writers.
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
static CSKYMCExpr::VariantKind getModifierVariantKind(CSKYCP::CSKYCPModifier Modifier)
const MachineInstrBuilder & addSym(MCSymbol *Sym, unsigned char TargetFlags=0) const
StringRef getTargetCPU() const
virtual void finishAttributeSection()
TargetMachine & TM
Target machine description.
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
const Triple & getTargetTriple() const
const DataLayout & getDataLayout() const
Return the DataLayout attached to the Module associated to this MF.
const DataLayout & getDataLayout() const
Return information about data layout.
const char LLVMTargetMachineRef TM
RegisterAsmPrinter - Helper template for registering a target specific assembly printer,...
Generic base class for all target subtargets.
unsigned getFunctionNumber() const
Return a unique ID for the current function.
const Constant * ConstVal
Base class for the full range of assembler expressions which are needed for parsing.
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.
virtual void emitTargetAttributes(const MCSubtargetInfo &STI)
TypeSize getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...