X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FTarget%2FARM%2FARMAsmPrinter.h;h=e475ae43a6d3c0a6e47b5c04d0f47dc023feafec;hb=579cebfb15c5f80cc8bbc7d51da9f7827424125a;hp=76a43d4cb856de32b839a8e97edb561c5239d247;hpb=4d7286083537833880901953d29786cf831affc4;p=oota-llvm.git diff --git a/lib/Target/ARM/ARMAsmPrinter.h b/lib/Target/ARM/ARMAsmPrinter.h index 76a43d4cb85..e475ae43a6d 100644 --- a/lib/Target/ARM/ARMAsmPrinter.h +++ b/lib/Target/ARM/ARMAsmPrinter.h @@ -1,4 +1,4 @@ -//===-- ARMAsmPrinter.h - Print machine code to an ARM .s file ------------===// +//===-- ARMAsmPrinter.h - ARM implementation of AsmPrinter ------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -6,21 +6,22 @@ // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// -// -// ARM Assembly printer class. -// -//===----------------------------------------------------------------------===// -#ifndef ARMASMPRINTER_H -#define ARMASMPRINTER_H +#ifndef LLVM_LIB_TARGET_ARM_ARMASMPRINTER_H +#define LLVM_LIB_TARGET_ARM_ARMASMPRINTER_H -#include "ARM.h" -#include "ARMTargetMachine.h" +#include "ARMSubtarget.h" #include "llvm/CodeGen/AsmPrinter.h" -#include "llvm/Support/Compiler.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, @@ -42,68 +43,90 @@ class LLVM_LIBRARY_VISIBILITY ARMAsmPrinter : public AsmPrinter { /// MachineFunction. const MachineConstantPool *MCP; + /// InConstantPool - Maintain state when emitting a sequence of constant + /// pool entries so we can properly mark them as data regions. + bool InConstantPool; + + /// ThumbIndirectPads - These maintain a per-function list of jump pad + /// labels used for ARMv4t thumb code to make register indirect calls. + SmallVector, 4> ThumbIndirectPads; + public: - explicit ARMAsmPrinter(TargetMachine &TM, MCStreamer &Streamer) - : AsmPrinter(TM, Streamer), AFI(NULL), MCP(NULL) { - Subtarget = &TM.getSubtarget(); - } + explicit ARMAsmPrinter(TargetMachine &TM, + std::unique_ptr Streamer); - virtual const char *getPassName() const { - return "ARM Assembly Printer"; + const char *getPassName() const override { + return "ARM Assembly / Object Emitter"; } void printOperand(const MachineInstr *MI, int OpNum, raw_ostream &O, - const char *Modifier = 0); + const char *Modifier = nullptr); - virtual bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNum, - unsigned AsmVariant, const char *ExtraCode, - raw_ostream &O); - virtual bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNum, - unsigned AsmVariant, - const char *ExtraCode, raw_ostream &O); + bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNum, + unsigned AsmVariant, const char *ExtraCode, + raw_ostream &O) override; + bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNum, + unsigned AsmVariant, const char *ExtraCode, + raw_ostream &O) override; + + void emitInlineAsmEnd(const MCSubtargetInfo &StartInfo, + const MCSubtargetInfo *EndInfo) const override; void EmitJumpTable(const MachineInstr *MI); void EmitJump2Table(const MachineInstr *MI); - virtual void EmitInstruction(const MachineInstr *MI); - bool runOnMachineFunction(MachineFunction &F); + void EmitInstruction(const MachineInstr *MI) override; + bool runOnMachineFunction(MachineFunction &F) override; - virtual void EmitConstantPool() {} // we emit constant pools customly! - virtual void EmitFunctionEntryLabel(); - void EmitStartOfAsmFile(Module &M); - void EmitEndOfAsmFile(Module &M); + void EmitConstantPool() override { + // we emit constant pools customly! + } + void EmitFunctionBodyEnd() override; + void EmitFunctionEntryLabel() override; + void EmitStartOfAsmFile(Module &M) override; + void EmitEndOfAsmFile(Module &M) override; + void EmitXXStructor(const Constant *CV) override; + + // lowerOperand - Convert a MachineOperand into the equivalent MCOperand. + bool lowerOperand(const MachineOperand &MO, MCOperand &MCOp); private: // Helpers for EmitStartOfAsmFile() and EmitEndOfAsmFile() void emitAttributes(); - // Helper for ELF .o only - void emitARMAttributeSection(); - // Generic helper used to emit e.g. ARMv5 mul pseudos void EmitPatchedInstruction(const MachineInstr *MI, unsigned TargetOpc); -public: - void PrintDebugValueComment(const MachineInstr *MI, raw_ostream &OS); + void EmitUnwindingInstruction(const MachineInstr *MI); - MachineLocation getDebugValueLocation(const MachineInstr *MI) const; + // emitPseudoExpansionLowering - tblgen'erated. + bool emitPseudoExpansionLowering(MCStreamer &OutStreamer, + const MachineInstr *MI); - virtual unsigned getISAEncoding() { +public: + unsigned getISAEncoding() override { // ARM/Darwin adds ISA to the DWARF info for each function. - if (!Subtarget->isTargetDarwin()) + Triple TT(TM.getTargetTriple()); + if (!TT.isOSBinFormatMachO()) return 0; - return Subtarget->isThumb() ? - llvm::ARM::DW_ISA_ARM_thumb : llvm::ARM::DW_ISA_ARM_arm; + bool isThumb = TT.getArch() == Triple::thumb || + TT.getArch() == Triple::thumbeb || + TT.getSubArch() == Triple::ARMSubArch_v7m || + TT.getSubArch() == Triple::ARMSubArch_v6m; + return isThumb ? ARM::DW_ISA_ARM_thumb : ARM::DW_ISA_ARM_arm; } - MCSymbol *GetARMSetPICJumpTableLabel2(unsigned uid, unsigned uid2, - const MachineBasicBlock *MBB) const; +private: + MCOperand GetSymbolRef(const MachineOperand &MO, const MCSymbol *Symbol); MCSymbol *GetARMJTIPICJumpTableLabel2(unsigned uid, unsigned uid2) const; - MCSymbol *GetARMSJLJEHLabel(void) const; + MCSymbol *GetARMSJLJEHLabel() const; + + MCSymbol *GetARMGVSymbol(const GlobalValue *GV, unsigned char TargetFlags); +public: /// EmitMachineConstantPoolValue - Print a machine constantpool value to /// the .s file. - virtual void EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV); + void EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV) override; }; } // end namespace llvm