37#define DEBUG_TYPE "ve-asmprinter"
46 explicit VEAsmPrinter(
TargetMachine &TM, std::unique_ptr<MCStreamer> Streamer)
166 emitBinary(OutStreamer, VE::ANDrm, RS1, Imm, RD, STI);
178 emitANDrm(OutStreamer, RD, M032, RD, STI);
182void VEAsmPrinter::lowerGETGOTAndEmitMCInsts(
const MachineInstr *
MI,
185 OutContext.getOrCreateSymbol(
Twine(
"_GLOBAL_OFFSET_TABLE_"));
190 if (!isPositionIndependent()) {
192 switch (
TM.getCodeModel()) {
215 emitLEAzii(*OutStreamer, cim24, loImm, MCRegOP, STI);
217 emitANDrm(*OutStreamer, MCRegOP, M032, MCRegOP, STI);
218 emitSIC(*OutStreamer, RegPLT, STI);
221 emitLEASLrri(*OutStreamer, RegGOT, RegPLT, hiImm, MCRegOP, STI);
224void VEAsmPrinter::lowerGETFunPLTAndEmitMCInsts(
const MachineInstr *
MI,
231 switch (
Addr.getType()) {
242 AddrSym = GetExternalSymbolSymbol(
Addr.getSymbolName());
245 AddrSym = getSymbol(
Addr.getGlobal());
249 if (!isPositionIndependent()) {
263 emitLEAzii(*OutStreamer, cim24, loImm, MCRegOP, STI);
265 emitANDrm(*OutStreamer, MCRegOP, M032, MCRegOP, STI);
266 emitSIC(*OutStreamer, RegPLT, STI);
269 emitLEASLrri(*OutStreamer, MCRegOP, RegPLT, hiImm, MCRegOP, STI);
272void VEAsmPrinter::lowerGETTLSAddrAndEmitMCInsts(
const MachineInstr *
MI,
277 switch (
Addr.getType()) {
288 AddrSym = GetExternalSymbolSymbol(
Addr.getSymbolName());
291 AddrSym = getSymbol(
Addr.getGlobal());
298 MCSymbol *GetTLSLabel = OutContext.getOrCreateSymbol(
Twine(
"__tls_get_addr"));
311 emitLEAzii(*OutStreamer, cim24, loImm, RegS0, STI);
313 emitANDrm(*OutStreamer, RegS0, M032, RegS0, STI);
314 emitSIC(*OutStreamer, RegLR, STI);
317 emitLEASLrri(*OutStreamer, RegS0, RegLR, hiImm, RegS0, STI);
321 emitLEAzii(*OutStreamer, ci8, loImm2, RegS12, STI);
322 emitANDrm(*OutStreamer, RegS12, M032, RegS12, STI);
325 emitLEASLrri(*OutStreamer, RegS12, RegLR, hiImm2, RegS12, STI);
326 emitBSIC(*OutStreamer, RegLR, RegS12, STI);
330 VE_MC::verifyInstructionPredicates(
MI->getOpcode(),
331 getSubtargetInfo().getFeatureBits());
333 switch (
MI->getOpcode()) {
336 case TargetOpcode::DBG_VALUE:
340 lowerGETGOTAndEmitMCInsts(
MI, getSubtargetInfo());
343 lowerGETFunPLTAndEmitMCInsts(
MI, getSubtargetInfo());
346 lowerGETTLSAddrAndEmitMCInsts(
MI, getSubtargetInfo());
355 EmitToStreamer(*OutStreamer, TmpInst);
356 }
while ((++
I != E) &&
I->isInsideBundle());
376bool VEAsmPrinter::PrintAsmOperand(
const MachineInstr *
MI,
unsigned OpNo,
378 if (ExtraCode && ExtraCode[0]) {
379 if (ExtraCode[1] != 0)
382 switch (ExtraCode[0]) {
397bool VEAsmPrinter::PrintAsmMemoryOperand(
const MachineInstr *
MI,
unsigned OpNo,
398 const char *ExtraCode,
400 if (ExtraCode && ExtraCode[0])
403 if (
MI->getOperand(OpNo+1).isImm() &&
404 MI->getOperand(OpNo+1).getImm() == 0) {
409 if (
MI->getOperand(OpNo).isImm() &&
410 MI->getOperand(OpNo).getImm() == 0) {
411 if (
MI->getOperand(OpNo+1).isImm() &&
412 MI->getOperand(OpNo+1).getImm() == 0) {
#define LLVM_EXTERNAL_VISIBILITY
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
static std::string getRegisterName(const TargetRegisterInfo *TRI, Register Reg)
static bool printOperand(raw_ostream &OS, const SelectionDAG *G, const SDValue Value)
static MCOperand createGOTRelExprOp(VEMCExpr::VariantKind Kind, MCSymbol *GOTLabel, MCContext &OutContext)
static void emitSIC(MCStreamer &OutStreamer, MCOperand &RD, const MCSubtargetInfo &STI)
static void emitBinary(MCStreamer &OutStreamer, unsigned Opcode, MCOperand &RS1, MCOperand &Src2, MCOperand &RD, const MCSubtargetInfo &STI)
static void emitLEAzii(MCStreamer &OutStreamer, MCOperand &RS1, MCOperand &Imm, MCOperand &RD, const MCSubtargetInfo &STI)
static MCOperand createVEMCOperand(VEMCExpr::VariantKind Kind, MCSymbol *Sym, MCContext &OutContext)
static void emitLEASLzzi(MCStreamer &OutStreamer, MCOperand &Imm, MCOperand &RD, const MCSubtargetInfo &STI)
static void emitBSIC(MCStreamer &OutStreamer, MCOperand &R1, MCOperand &R2, const MCSubtargetInfo &STI)
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeVEAsmPrinter()
static void emitHiLo(MCStreamer &OutStreamer, MCSymbol *GOTSym, VEMCExpr::VariantKind HiKind, VEMCExpr::VariantKind LoKind, MCOperand &RD, MCContext &OutContext, const MCSubtargetInfo &STI)
static void emitLEAzzi(MCStreamer &OutStreamer, MCOperand &Imm, MCOperand &RD, const MCSubtargetInfo &STI)
static void emitANDrm(MCStreamer &OutStreamer, MCOperand &RS1, MCOperand &Imm, MCOperand &RD, const MCSubtargetInfo &STI)
static void emitLEASLrri(MCStreamer &OutStreamer, MCOperand &RS1, MCOperand &RS2, MCOperand &Imm, MCOperand &RD, const MCSubtargetInfo &STI)
This class is intended to be used as a driving class for all asm writers.
virtual void emitInstruction(const MachineInstr *)
Targets should implement this to emit instructions.
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...
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.
Context object for machine code objects.
Instances of this class represent a single low-level machine instruction.
void addOperand(const MCOperand Op)
void setOpcode(unsigned Op)
Instances of this class represent operands of the MCInst class.
static MCOperand createReg(unsigned Reg)
static MCOperand createExpr(const MCExpr *Val)
static MCOperand createImm(int64_t Val)
Wrapper class representing physical registers. Should be passed by value.
Streaming machine code generation interface.
virtual void emitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI)
Emit the given Instruction into the current section.
Generic base class for all target subtargets.
Represent a reference to a symbol from inside an expression.
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 ...
Instructions::const_iterator const_instr_iterator
Representation of each machine instruction.
MachineOperand class - Representation of each machine instruction operand.
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
Register getReg() const
getReg - Returns the register number.
@ MO_Immediate
Immediate operand.
@ MO_ConstantPoolIndex
Address of indexed Constant in Constant Pool.
@ MO_GlobalAddress
Address of a global value.
@ MO_MachineBasicBlock
MachineBasicBlock reference.
@ MO_Register
Register operand.
@ MO_ExternalSymbol
Name of external global symbol.
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
StringRef - Represent a constant reference to a string, i.e.
std::string lower() const
Primary interface to the complete machine description for the target machine.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
static const char * getRegisterName(MCRegister Reg, unsigned AltIdx=VE::NoRegAltName)
static const VEMCExpr * create(VariantKind Kind, const MCExpr *Expr, MCContext &Ctx)
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.
This is an optimization pass for GlobalISel generic memory operations.
void LowerVEMachineInstrToMCInst(const MachineInstr *MI, MCInst &OutMI, AsmPrinter &AP)
Target & getTheVETarget()
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
unsigned M0(unsigned Val)
RegisterAsmPrinter - Helper template for registering a target specific assembly printer,...