#ifndef LLVM_LIB_TARGET_ARM_ARMASMPRINTER_H
#define LLVM_LIB_TARGET_ARM_ARMASMPRINTER_H
#include "ARMSubtarget.h"
#include "llvm/CodeGen/AsmPrinter.h"
#include "llvm/Target/TargetMachine.h"
namespace llvm {
class ARMFunctionInfo;
class MCOperand;
class MachineConstantPool;
class MachineOperand;
class MCSymbol;
namespace ARM {
enum DW_ISA {
DW_ISA_ARM_thumb = 1,
DW_ISA_ARM_arm = 2
};
}
class LLVM_LIBRARY_VISIBILITY ARMAsmPrinter : public AsmPrinter {
const ARMSubtarget *Subtarget;
ARMFunctionInfo *AFI;
const MachineConstantPool *MCP;
bool InConstantPool;
SmallVector<std::pair<unsigned, MCSymbol*>, 4> ThumbIndirectPads;
int OptimizationGoals;
SmallPtrSet<const GlobalVariable*,2> PromotedGlobals;
SmallPtrSet<const GlobalVariable*,2> EmittedPromotedGlobalLabels;
public:
explicit ARMAsmPrinter(TargetMachine &TM,
std::unique_ptr<MCStreamer> Streamer);
StringRef getPassName() const override {
return "ARM Assembly Printer";
}
void printOperand(const MachineInstr *MI, int OpNum, raw_ostream &O);
void PrintSymbolOperand(const MachineOperand &MO, raw_ostream &O) override;
bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNum,
const char *ExtraCode, raw_ostream &O) override;
bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNum,
const char *ExtraCode, raw_ostream &O) override;
void emitInlineAsmEnd(const MCSubtargetInfo &StartInfo,
const MCSubtargetInfo *EndInfo) const override;
void emitJumpTableAddrs(const MachineInstr *MI);
void emitJumpTableInsts(const MachineInstr *MI);
void emitJumpTableTBInst(const MachineInstr *MI, unsigned OffsetWidth);
void emitInstruction(const MachineInstr *MI) override;
bool runOnMachineFunction(MachineFunction &F) override;
void emitConstantPool() override {
}
void emitFunctionBodyEnd() override;
void emitFunctionEntryLabel() override;
void emitStartOfAsmFile(Module &M) override;
void emitEndOfAsmFile(Module &M) override;
void emitXXStructor(const DataLayout &DL, const Constant *CV) override;
void emitGlobalVariable(const GlobalVariable *GV) override;
MCSymbol *GetCPISymbol(unsigned CPID) const override;
bool lowerOperand(const MachineOperand &MO, MCOperand &MCOp);
public:
void LowerPATCHABLE_FUNCTION_ENTER(const MachineInstr &MI);
void LowerPATCHABLE_FUNCTION_EXIT(const MachineInstr &MI);
void LowerPATCHABLE_TAIL_CALL(const MachineInstr &MI);
private:
void EmitSled(const MachineInstr &MI, SledKind Kind);
void emitAttributes();
void EmitPatchedInstruction(const MachineInstr *MI, unsigned TargetOpc);
void EmitUnwindingInstruction(const MachineInstr *MI);
bool emitPseudoExpansionLowering(MCStreamer &OutStreamer,
const MachineInstr *MI);
public:
unsigned getISAEncoding() override {
const Triple &TT = TM.getTargetTriple();
if (!TT.isOSBinFormatMachO())
return 0;
bool isThumb = TT.isThumb() ||
TT.getSubArch() == Triple::ARMSubArch_v7m ||
TT.getSubArch() == Triple::ARMSubArch_v6m;
return isThumb ? ARM::DW_ISA_ARM_thumb : ARM::DW_ISA_ARM_arm;
}
private:
MCOperand GetSymbolRef(const MachineOperand &MO, const MCSymbol *Symbol);
MCSymbol *GetARMJTIPICJumpTableLabel(unsigned uid) const;
MCSymbol *GetARMGVSymbol(const GlobalValue *GV, unsigned char TargetFlags);
public:
void emitMachineConstantPoolValue(MachineConstantPoolValue *MCPV) override;
};
}
#endif