Switch all uses of LLVM_OVERRIDE to just use 'override' directly.
[oota-llvm.git] / lib / Target / ARM / ARMAsmPrinter.h
1 //===-- ARMAsmPrinter.h - ARM implementation of AsmPrinter ------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef ARMASMPRINTER_H
11 #define ARMASMPRINTER_H
12
13 #include "ARM.h"
14 #include "ARMTargetMachine.h"
15 #include "llvm/CodeGen/AsmPrinter.h"
16 #include "llvm/Support/Compiler.h"
17
18 namespace llvm {
19
20 class MCOperand;
21
22 namespace ARM {
23   enum DW_ISA {
24     DW_ISA_ARM_thumb = 1,
25     DW_ISA_ARM_arm = 2
26   };
27 }
28
29 class LLVM_LIBRARY_VISIBILITY ARMAsmPrinter : public AsmPrinter {
30
31   /// Subtarget - Keep a pointer to the ARMSubtarget around so that we can
32   /// make the right decision when printing asm code for different targets.
33   const ARMSubtarget *Subtarget;
34
35   /// AFI - Keep a pointer to ARMFunctionInfo for the current
36   /// MachineFunction.
37   ARMFunctionInfo *AFI;
38
39   /// MCP - Keep a pointer to constantpool entries of the current
40   /// MachineFunction.
41   const MachineConstantPool *MCP;
42
43   /// InConstantPool - Maintain state when emitting a sequence of constant
44   /// pool entries so we can properly mark them as data regions.
45   bool InConstantPool;
46 public:
47   explicit ARMAsmPrinter(TargetMachine &TM, MCStreamer &Streamer)
48     : AsmPrinter(TM, Streamer), AFI(NULL), MCP(NULL), InConstantPool(false) {
49       Subtarget = &TM.getSubtarget<ARMSubtarget>();
50     }
51
52   virtual const char *getPassName() const override {
53     return "ARM Assembly / Object Emitter";
54   }
55
56   void printOperand(const MachineInstr *MI, int OpNum, raw_ostream &O,
57                     const char *Modifier = 0);
58
59   virtual bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNum,
60                                unsigned AsmVariant, const char *ExtraCode,
61                                raw_ostream &O) override;
62   virtual bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNum,
63                                      unsigned AsmVariant, const char *ExtraCode,
64                                      raw_ostream &O) override;
65
66   virtual void emitInlineAsmEnd(const MCSubtargetInfo &StartInfo,
67                                 const MCSubtargetInfo *EndInfo) const override;
68
69   void EmitJumpTable(const MachineInstr *MI);
70   void EmitJump2Table(const MachineInstr *MI);
71   virtual void EmitInstruction(const MachineInstr *MI) override;
72   virtual bool runOnMachineFunction(MachineFunction &F) override;
73
74   virtual void EmitConstantPool() override {
75     // we emit constant pools customly!
76   }
77   virtual void EmitFunctionBodyEnd() override;
78   virtual void EmitFunctionEntryLabel() override;
79   virtual void EmitStartOfAsmFile(Module &M) override;
80   virtual void EmitEndOfAsmFile(Module &M) override;
81   virtual void EmitXXStructor(const Constant *CV) override;
82
83   // lowerOperand - Convert a MachineOperand into the equivalent MCOperand.
84   bool lowerOperand(const MachineOperand &MO, MCOperand &MCOp);
85
86 private:
87   // Helpers for EmitStartOfAsmFile() and EmitEndOfAsmFile()
88   void emitAttributes();
89
90   // Generic helper used to emit e.g. ARMv5 mul pseudos
91   void EmitPatchedInstruction(const MachineInstr *MI, unsigned TargetOpc);
92
93   void EmitUnwindingInstruction(const MachineInstr *MI);
94
95   // emitPseudoExpansionLowering - tblgen'erated.
96   bool emitPseudoExpansionLowering(MCStreamer &OutStreamer,
97                                    const MachineInstr *MI);
98
99 public:
100   virtual unsigned getISAEncoding() override {
101     // ARM/Darwin adds ISA to the DWARF info for each function.
102     if (!Subtarget->isTargetMachO())
103       return 0;
104     return Subtarget->isThumb() ?
105       ARM::DW_ISA_ARM_thumb : ARM::DW_ISA_ARM_arm;
106   }
107
108 private:
109   MCOperand GetSymbolRef(const MachineOperand &MO, const MCSymbol *Symbol);
110   MCSymbol *GetARMJTIPICJumpTableLabel2(unsigned uid, unsigned uid2) const;
111
112   MCSymbol *GetARMSJLJEHLabel() const;
113
114   MCSymbol *GetARMGVSymbol(const GlobalValue *GV, unsigned char TargetFlags);
115
116 public:
117   /// EmitMachineConstantPoolValue - Print a machine constantpool value to
118   /// the .s file.
119   virtual void
120     EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV) override;
121 };
122 } // end namespace llvm
123
124 #endif