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);
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);
96void 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;
144 CSKY_MC::verifyInstructionPredicates(
MI->getOpcode(),
154 if (InConstantPool &&
MI->getOpcode() != CSKY::CONSTPOOL_ENTRY) {
155 InConstantPool =
false;
158 if (
MI->getOpcode() == CSKY::PseudoTLSLA32)
159 return expandTLSLA(
MI);
161 if (
MI->getOpcode() == CSKY::CONSTPOOL_ENTRY)
162 return emitCustomConstantPool(
MI);
165 MCInstLowering.
Lower(
MI, TmpInst);
202 cast<CSKYConstantPoolConstant>(CCPV)->getBlockAddress();
205 const GlobalValue *GV = cast<CSKYConstantPoolConstant>(CCPV)->getGV();
210 }
else if (CCPV->
isJT()) {
211 signed JTI = cast<CSKYConstantPoolJT>(CCPV)->getJTI();
214 const Constant *
C = cast<CSKYConstantPoolConstant>(CCPV)->getConstantPool();
218 StringRef Sym = cast<CSKYConstantPoolSymbol>(CCPV)->getSymbol();
250void CSKYAsmPrinter::emitAttributes() {
272 if (ExtraCode && ExtraCode[0]) {
273 if (ExtraCode[1] != 0)
276 switch (ExtraCode[0]) {
292 if (MO.
getReg() == CSKY::C)
312 unsigned OpNo,
const char *ExtraCode,
static MCSymbolRefExpr::VariantKind getModifierVariantKind(ARMCP::ARMCPModifier Modifier)
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeCSKYAsmPrinter()
#define LLVM_EXTERNAL_VISIBILITY
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
This file declares the MachineConstantPool class which is an abstract constant pool to keep track of ...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
This class is intended to be used as a driving class for all asm writers.
MCSymbol * getSymbol(const GlobalValue *GV) const
void EmitToStreamer(MCStreamer &S, const MCInst &Inst)
TargetMachine & TM
Target machine description.
virtual MCSymbol * GetCPISymbol(unsigned CPID) const
Return the symbol for the specified constant pool entry.
virtual void PrintSymbolOperand(const MachineOperand &MO, raw_ostream &OS)
Print the MachineOperand as a symbol.
const MCAsmInfo * MAI
Target Asm Printer information.
MachineFunction * MF
The current machine function.
MCSymbol * GetJTISymbol(unsigned JTID, bool isLinkerPrivate=false) const
Return the symbol for the specified jump table entry.
unsigned getFunctionNumber() const
Return a unique ID for the current function.
void emitGlobalConstant(const DataLayout &DL, const Constant *CV, AliasMapTy *AliasList=nullptr)
EmitGlobalConstant - Print a general LLVM constant to the .s file.
MCContext & OutContext
This is the context for the output file that we are streaming.
MCSymbol * GetExternalSymbolSymbol(Twine Sym) const
Return the MCSymbol for the specified ExternalSymbol.
bool runOnMachineFunction(MachineFunction &MF) override
Emit the specified function out to the OutStreamer.
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...
MCSymbol * GetBlockAddressSymbol(const BlockAddress *BA) const
Return the MCSymbol used to satisfy BlockAddress uses of the specified basic block.
const DataLayout & getDataLayout() const
Return information about data layout.
const MCSubtargetInfo & getSubtargetInfo() const
Return information about subtarget.
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.
The address of a basic block.
void emitFunctionBodyEnd() override
Targets can override this to emit stuff after the last basic block in the function.
void EmitToStreamer(MCStreamer &S, const MCInst &Inst)
CSKYAsmPrinter(TargetMachine &TM, std::unique_ptr< MCStreamer > Streamer)
bool lowerPseudoInstExpansion(const MachineInstr *MI, MCInst &Inst)
tblgen'erated driver function for lowering simple MI->MC pseudo instructions.
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.
void emitMachineConstantPoolValue(MachineConstantPoolValue *MCPV) override
bool runOnMachineFunction(MachineFunction &MF) override
Emit the specified function out to the OutStreamer.
void emitEndOfAsmFile(Module &M) override
This virtual method can be overridden by targets that want to emit something at the end of their file...
void emitInstruction(const MachineInstr *MI) override
Targets should implement this to emit instructions.
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 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...
CSKYConstantPoolValue - CSKY specific constantpool value.
bool isMachineBasicBlock() const
bool isGlobalValue() const
unsigned getLabelID() const
unsigned getPCAdjustment() const
bool mustAddCurrentAddress() const
bool isBlockAddress() const
CSKYCP::CSKYCPModifier getModifier() const
static const char * getRegisterName(MCRegister Reg)
static const CSKYMCExpr * create(const MCExpr *Expr, VariantKind Kind, MCContext &Ctx)
void Lower(const MachineInstr *MI, MCInst &OutMI) const
virtual void emitTargetAttributes(const MCSubtargetInfo &STI)
virtual void finishAttributeSection()
This is an important base class in LLVM.
TypeSize getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
StringRef getPrivateGlobalPrefix() const
static const MCBinaryExpr * createSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
MCSymbol * createTempSymbol()
Create a temporary symbol with a unique name.
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
Base class for the full range of assembler expressions which are needed for parsing.
Instances of this class represent a single low-level machine instruction.
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode.
Streaming machine code generation interface.
Generic base class for all target subtargets.
void setFeatureBits(const FeatureBitset &FeatureBits_)
const FeatureBitset & getFeatureBits() const
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
MCSymbol * getSymbol() const
Return the MCSymbol for this basic block.
This class is a data container for one entry in a MachineConstantPool.
bool isMachineConstantPoolEntry() const
isMachineConstantPoolEntry - Return true if the MachineConstantPoolEntry is indeed a target specific ...
union llvm::MachineConstantPoolEntry::@204 Val
The constant itself.
MachineConstantPoolValue * MachineCPVal
const Constant * ConstVal
Abstract base class for all machine specific constantpool value subclasses.
const std::vector< MachineConstantPoolEntry > & getConstants() const
unsigned getConstantPoolIndex(const Constant *C, Align Alignment)
getConstantPoolIndex - Create a new entry in the constant pool or return an existing one.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
const DataLayout & getDataLayout() const
Return the DataLayout attached to the Module associated to this MF.
MachineConstantPool * getConstantPool()
getConstantPool - Return the constant pool object for the current function.
const MachineInstrBuilder & add(const MachineOperand &MO) const
const MachineInstrBuilder & addSym(MCSymbol *Sym, unsigned char TargetFlags=0) const
Representation of each machine instruction.
MachineOperand class - Representation of each machine instruction operand.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
const BlockAddress * getBlockAddress() const
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_BlockAddress
Address of a basic block.
@ MO_Register
Register operand.
A Module instance is used to store all the information related to an LLVM module.
StringRef - Represent a constant reference to a string, i.e.
Primary interface to the complete machine description for the target machine.
const Triple & getTargetTriple() const
const MCSubtargetInfo * getMCSubtargetInfo() const
StringRef getTargetFeatureString() const
StringRef getTargetCPU() const
virtual const TargetInstrInfo * getInstrInfo() const
Triple - Helper class for working with autoconf configuration names.
bool isOSBinFormatELF() const
Tests whether the OS uses the ELF binary format.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
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.
@ C
The default llvm calling convention, compatible with C.
This is an optimization pass for GlobalISel generic memory operations.
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
Target & getTheCSKYTarget()
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Implement std::hash so that hash_code can be used in STL containers.
This struct is a compact representation of a valid (non-zero power of two) alignment.
RegisterAsmPrinter - Helper template for registering a target specific assembly printer,...