34#define DEBUG_TYPE "ve-asmprinter"
43 explicit VEAsmPrinter(
TargetMachine &TM, std::unique_ptr<MCStreamer> Streamer)
163 emitBinary(OutStreamer, VE::ANDrm, RS1, Imm, RD, STI);
175 emitANDrm(OutStreamer, RD, M032, RD, STI);
179void VEAsmPrinter::lowerGETGOTAndEmitMCInsts(
const MachineInstr *
MI,
182 OutContext.getOrCreateSymbol(
Twine(
"_GLOBAL_OFFSET_TABLE_"));
187 if (!isPositionIndependent()) {
189 switch (
TM.getCodeModel()) {
212 emitLEAzii(*OutStreamer, cim24, loImm, MCRegOP, STI);
214 emitANDrm(*OutStreamer, MCRegOP, M032, MCRegOP, STI);
215 emitSIC(*OutStreamer, RegPLT, STI);
218 emitLEASLrri(*OutStreamer, RegGOT, RegPLT, hiImm, MCRegOP, STI);
221void VEAsmPrinter::lowerGETFunPLTAndEmitMCInsts(
const MachineInstr *
MI,
228 switch (
Addr.getType()) {
239 AddrSym = GetExternalSymbolSymbol(
Addr.getSymbolName());
242 AddrSym = getSymbol(
Addr.getGlobal());
246 if (!isPositionIndependent()) {
260 emitLEAzii(*OutStreamer, cim24, loImm, MCRegOP, STI);
262 emitANDrm(*OutStreamer, MCRegOP, M032, MCRegOP, STI);
263 emitSIC(*OutStreamer, RegPLT, STI);
266 emitLEASLrri(*OutStreamer, MCRegOP, RegPLT, hiImm, MCRegOP, STI);
269void VEAsmPrinter::lowerGETTLSAddrAndEmitMCInsts(
const MachineInstr *
MI,
274 switch (
Addr.getType()) {
285 AddrSym = GetExternalSymbolSymbol(
Addr.getSymbolName());
288 AddrSym = getSymbol(
Addr.getGlobal());
295 MCSymbol *GetTLSLabel = OutContext.getOrCreateSymbol(
Twine(
"__tls_get_addr"));
308 emitLEAzii(*OutStreamer, cim24, loImm, RegS0, STI);
310 emitANDrm(*OutStreamer, RegS0, M032, RegS0, STI);
311 emitSIC(*OutStreamer, RegLR, STI);
314 emitLEASLrri(*OutStreamer, RegS0, RegLR, hiImm, RegS0, STI);
318 emitLEAzii(*OutStreamer, ci8, loImm2, RegS12, STI);
319 emitANDrm(*OutStreamer, RegS12, M032, RegS12, STI);
322 emitLEASLrri(*OutStreamer, RegS12, RegLR, hiImm2, RegS12, STI);
323 emitBSIC(*OutStreamer, RegLR, RegS12, STI);
327 VE_MC::verifyInstructionPredicates(
MI->getOpcode(),
328 getSubtargetInfo().getFeatureBits());
330 switch (
MI->getOpcode()) {
333 case TargetOpcode::DBG_VALUE:
337 lowerGETGOTAndEmitMCInsts(
MI, getSubtargetInfo());
340 lowerGETFunPLTAndEmitMCInsts(
MI, getSubtargetInfo());
343 lowerGETTLSAddrAndEmitMCInsts(
MI, getSubtargetInfo());
352 EmitToStreamer(*OutStreamer, TmpInst);
353 }
while ((++
I != E) &&
I->isInsideBundle());
373bool VEAsmPrinter::PrintAsmOperand(
const MachineInstr *
MI,
unsigned OpNo,
375 if (ExtraCode && ExtraCode[0]) {
376 if (ExtraCode[1] != 0)
379 switch (ExtraCode[0]) {
394bool VEAsmPrinter::PrintAsmMemoryOperand(
const MachineInstr *
MI,
unsigned OpNo,
395 const char *ExtraCode,
397 if (ExtraCode && ExtraCode[0])
400 if (
MI->getOperand(OpNo+1).isImm() &&
401 MI->getOperand(OpNo+1).getImm() == 0) {
406 if (
MI->getOperand(OpNo).isImm() &&
407 MI->getOperand(OpNo).getImm() == 0) {
408 if (
MI->getOperand(OpNo+1).isImm() &&
409 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 createExpr(const MCExpr *Val)
static MCOperand createReg(MCRegister Reg)
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,...