35#define DEBUG_TYPE "ve-asmprinter"
44 explicit VEAsmPrinter(
TargetMachine &TM, std::unique_ptr<MCStreamer> Streamer)
165 emitBinary(OutStreamer, VE::ANDrm, RS1, Imm, RD, STI);
176 emitANDrm(OutStreamer, RD, M032, RD, STI);
180void VEAsmPrinter::lowerGETGOTAndEmitMCInsts(
const MachineInstr *
MI,
183 OutContext.getOrCreateSymbol(
Twine(
"_GLOBAL_OFFSET_TABLE_"));
188 if (!isPositionIndependent()) {
190 switch (
TM.getCodeModel()) {
212 emitLEAzii(*OutStreamer, cim24, loImm, MCRegOP, STI);
214 emitANDrm(*OutStreamer, MCRegOP, M032, MCRegOP, STI);
215 emitSIC(*OutStreamer, RegPLT, STI);
217 emitLEASLrri(*OutStreamer, RegGOT, RegPLT, hiImm, MCRegOP, STI);
220void VEAsmPrinter::lowerGETFunPLTAndEmitMCInsts(
const MachineInstr *
MI,
227 switch (
Addr.getType()) {
238 AddrSym = GetExternalSymbolSymbol(
Addr.getSymbolName());
241 AddrSym = getSymbol(
Addr.getGlobal());
245 if (!isPositionIndependent()) {
258 emitLEAzii(*OutStreamer, cim24, loImm, MCRegOP, STI);
260 emitANDrm(*OutStreamer, MCRegOP, M032, MCRegOP, STI);
261 emitSIC(*OutStreamer, RegPLT, STI);
263 emitLEASLrri(*OutStreamer, MCRegOP, RegPLT, hiImm, MCRegOP, STI);
266void VEAsmPrinter::lowerGETTLSAddrAndEmitMCInsts(
const MachineInstr *
MI,
271 switch (
Addr.getType()) {
282 AddrSym = GetExternalSymbolSymbol(
Addr.getSymbolName());
285 AddrSym = getSymbol(
Addr.getGlobal());
292 MCSymbol *GetTLSLabel = OutContext.getOrCreateSymbol(
Twine(
"__tls_get_addr"));
304 emitLEAzii(*OutStreamer, cim24, loImm, RegS0, STI);
306 emitANDrm(*OutStreamer, RegS0, M032, RegS0, STI);
307 emitSIC(*OutStreamer, RegLR, STI);
309 emitLEASLrri(*OutStreamer, RegS0, RegLR, hiImm, RegS0, STI);
313 emitLEAzii(*OutStreamer, ci8, loImm2, RegS12, STI);
314 emitANDrm(*OutStreamer, RegS12, M032, RegS12, STI);
317 emitLEASLrri(*OutStreamer, RegS12, RegLR, hiImm2, RegS12, STI);
318 emitBSIC(*OutStreamer, RegLR, RegS12, STI);
322 VE_MC::verifyInstructionPredicates(
MI->getOpcode(),
323 getSubtargetInfo().getFeatureBits());
325 switch (
MI->getOpcode()) {
328 case TargetOpcode::DBG_VALUE:
332 lowerGETGOTAndEmitMCInsts(
MI, getSubtargetInfo());
335 lowerGETFunPLTAndEmitMCInsts(
MI, getSubtargetInfo());
338 lowerGETTLSAddrAndEmitMCInsts(
MI, getSubtargetInfo());
347 EmitToStreamer(*OutStreamer, TmpInst);
348 }
while ((++
I != E) &&
I->isInsideBundle());
368bool VEAsmPrinter::PrintAsmOperand(
const MachineInstr *
MI,
unsigned OpNo,
370 if (ExtraCode && ExtraCode[0]) {
371 if (ExtraCode[1] != 0)
374 switch (ExtraCode[0]) {
389bool VEAsmPrinter::PrintAsmMemoryOperand(
const MachineInstr *
MI,
unsigned OpNo,
390 const char *ExtraCode,
392 if (ExtraCode && ExtraCode[0])
395 if (
MI->getOperand(OpNo+1).isImm() &&
396 MI->getOperand(OpNo+1).getImm() == 0) {
401 if (
MI->getOperand(OpNo).isImm() &&
402 MI->getOperand(OpNo).getImm() == 0) {
403 if (
MI->getOperand(OpNo+1).isImm() &&
404 MI->getOperand(OpNo+1).getImm() == 0) {
417char VEAsmPrinter::ID = 0;
#define LLVM_EXTERNAL_VISIBILITY
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
static std::string getRegisterName(const TargetRegisterInfo *TRI, Register Reg)
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
static bool printOperand(raw_ostream &OS, const SelectionDAG *G, const SDValue Value)
static void emitSIC(MCStreamer &OutStreamer, MCOperand &RD, const MCSubtargetInfo &STI)
static void emitHiLo(MCStreamer &OutStreamer, MCSymbol *GOTSym, VE::Specifier HiKind, VE::Specifier LoKind, MCOperand &RD, MCContext &OutContext, 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 void emitLEASLzzi(MCStreamer &OutStreamer, MCOperand &Imm, MCOperand &RD, const MCSubtargetInfo &STI)
static MCOperand createGOTRelExprOp(VE::Specifier Kind, MCSymbol *GOTLabel, MCContext &OutContext)
static void emitBSIC(MCStreamer &OutStreamer, MCOperand &R1, MCOperand &R2, const MCSubtargetInfo &STI)
static MCOperand createVEMCOperand(VE::Specifier Kind, MCSymbol *Sym, MCContext &OutContext)
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.
static const MCSpecifierExpr * create(const MCExpr *Expr, Spec S, MCContext &Ctx, SMLoc Loc=SMLoc())
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, SMLoc Loc=SMLoc())
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.
LLVM_ABI 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)
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.
void LowerVEMachineInstrToMCInst(const MachineInstr *MI, MCInst &OutMI, AsmPrinter &AP)
Target & getTheVETarget()
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
unsigned M0(unsigned Val)
RegisterAsmPrinter - Helper template for registering a target specific assembly printer,...