37#define DEBUG_TYPE "ve-asmprinter"
49 StringRef getPassName()
const override {
return "VE Assembly Printer"; }
178 emitANDrm(OutStreamer, RD, M032, RD, STI);
182void VEAsmPrinter::lowerGETGOTAndEmitMCInsts(
const MachineInstr *
MI,
185 OutContext.getOrCreateSymbol(Twine(
"_GLOBAL_OFFSET_TABLE_"));
187 const MachineOperand &MO =
MI->getOperand(0);
190 if (!isPositionIndependent()) {
192 switch (TM.getCodeModel()) {
214 emitLEAzii(*OutStreamer, cim24, loImm, MCRegOP, STI);
216 emitANDrm(*OutStreamer, MCRegOP, M032, MCRegOP, STI);
217 emitSIC(*OutStreamer, RegPLT, STI);
219 emitLEASLrri(*OutStreamer, RegGOT, RegPLT, hiImm, MCRegOP, STI);
222void VEAsmPrinter::lowerGETFunPLTAndEmitMCInsts(
const MachineInstr *
MI,
223 const MCSubtargetInfo &STI) {
224 const MachineOperand &MO =
MI->getOperand(0);
226 const MachineOperand &Addr =
MI->getOperand(1);
247 if (!isPositionIndependent()) {
260 emitLEAzii(*OutStreamer, cim24, loImm, MCRegOP, STI);
262 emitANDrm(*OutStreamer, MCRegOP, M032, MCRegOP, STI);
263 emitSIC(*OutStreamer, RegPLT, STI);
265 emitLEASLrri(*OutStreamer, MCRegOP, RegPLT, hiImm, MCRegOP, STI);
268void VEAsmPrinter::lowerGETTLSAddrAndEmitMCInsts(
const MachineInstr *
MI,
269 const MCSubtargetInfo &STI) {
270 const MachineOperand &Addr =
MI->getOperand(0);
294 MCSymbol *GetTLSLabel = OutContext.getOrCreateSymbol(Twine(
"__tls_get_addr"));
306 emitLEAzii(*OutStreamer, cim24, loImm, RegS0, STI);
308 emitANDrm(*OutStreamer, RegS0, M032, RegS0, STI);
309 emitSIC(*OutStreamer, RegLR, STI);
311 emitLEASLrri(*OutStreamer, RegS0, RegLR, hiImm, RegS0, STI);
315 emitLEAzii(*OutStreamer, ci8, loImm2, RegS12, STI);
316 emitANDrm(*OutStreamer, RegS12, M032, RegS12, STI);
319 emitLEASLrri(*OutStreamer, RegS12, RegLR, hiImm2, RegS12, STI);
320 emitBSIC(*OutStreamer, RegLR, RegS12, STI);
323void VEAsmPrinter::emitInstruction(
const MachineInstr *
MI) {
324 VE_MC::verifyInstructionPredicates(
MI->getOpcode(),
325 getSubtargetInfo().getFeatureBits());
327 switch (
MI->getOpcode()) {
330 case TargetOpcode::DBG_VALUE:
334 lowerGETGOTAndEmitMCInsts(
MI, getSubtargetInfo());
337 lowerGETFunPLTAndEmitMCInsts(
MI, getSubtargetInfo());
340 lowerGETTLSAddrAndEmitMCInsts(
MI, getSubtargetInfo());
349 EmitToStreamer(*OutStreamer, TmpInst);
350 }
while ((++
I !=
E) &&
I->isInsideBundle());
353void VEAsmPrinter::printOperand(
const MachineInstr *
MI,
int OpNum,
355 const MachineOperand &MO =
MI->getOperand(OpNum);
370bool VEAsmPrinter::PrintAsmOperand(
const MachineInstr *
MI,
unsigned OpNo,
371 const char *ExtraCode, raw_ostream &O) {
372 if (ExtraCode && ExtraCode[0]) {
373 if (ExtraCode[1] != 0)
376 switch (ExtraCode[0]) {
391bool VEAsmPrinter::PrintAsmMemoryOperand(
const MachineInstr *
MI,
unsigned OpNo,
392 const char *ExtraCode,
394 if (ExtraCode && ExtraCode[0])
397 if (
MI->getOperand(OpNo+1).isImm() &&
398 MI->getOperand(OpNo+1).getImm() == 0) {
403 if (
MI->getOperand(OpNo).isImm() &&
404 MI->getOperand(OpNo).getImm() == 0) {
405 if (
MI->getOperand(OpNo+1).isImm() &&
406 MI->getOperand(OpNo+1).getImm() == 0) {
419char VEAsmPrinter::ID = 0;
431 VEAsmPrinter &
AsmPrinter =
static_cast<VEAsmPrinter &
>(
440 VEAsmPrinter &
AsmPrinter =
static_cast<VEAsmPrinter &
>(
451 VEAsmPrinter &
AsmPrinter =
static_cast<VEAsmPrinter &
>(
static const Function * getParent(const Value *V)
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define LLVM_EXTERNAL_VISIBILITY
static std::string getRegisterName(const TargetRegisterInfo *TRI, Register Reg)
ModuleAnalysisManager MAM
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
static bool printOperand(raw_ostream &OS, const SelectionDAG *G, const SDValue Value)
static void emitHiLo(MCStreamer &OutStreamer, MCSymbol *GOTSym, uint16_t HiKind, uint16_t LoKind, MCOperand &RD, MCContext &OutContext, const MCSubtargetInfo &STI)
std::unique_ptr< MCStreamer > && Streamer
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)
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
This class is intended to be used as a driving class for all asm writers.
bool doInitialization(Module &M) override
Set up the AsmPrinter when we are working on a new module.
bool doFinalization(Module &M) override
Shut down the asmprinter.
bool runOnMachineFunction(MachineFunction &MF) override
Emit the specified function out to the OutStreamer.
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
Function & getFunction()
Return the LLVM function that this machine code represents.
Representation of each machine instruction.
const GlobalValue * getGlobal() const
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
const char * getSymbolName() const
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.
A Module instance is used to store all the information related to an LLVM module.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Represent a constant reference to a string, i.e.
Primary interface to the complete machine description for the target machine.
PreservedAnalyses run(Module &M, ModuleAnalysisManager &MFAM)
PreservedAnalyses run(Module &M, ModuleAnalysisManager &MFAM)
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
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.
This is an optimization pass for GlobalISel generic memory operations.
OuterAnalysisManagerProxy< ModuleAnalysisManager, MachineFunction > ModuleAnalysisManagerMachineFunctionProxy
Provide the ModuleAnalysisManager to Function proxy.
void LowerVEMachineInstrToMCInst(const MachineInstr *MI, MCInst &OutMI, AsmPrinter &AP)
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
Target & getTheVETarget()
LLVM_ABI void setupModuleAsmPrinter(Module &M, ModuleAnalysisManager &MAM, AsmPrinter &AsmPrinter)
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
unsigned M0(unsigned Val)
LLVM_ABI void setupMachineFunctionAsmPrinter(MachineFunctionAnalysisManager &MFAM, MachineFunction &MF, AsmPrinter &AsmPrinter)
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
RegisterAsmPrinter - Helper template for registering a target specific assembly printer,...