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