ARM JIT should observe -relocation-model command line option.
[oota-llvm.git] / lib / Target / ARM / ARMTargetMachine.h
1 //===-- ARMTargetMachine.h - Define TargetMachine for ARM -------*- 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 // This file declares the ARM specific subclass of TargetMachine.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef ARMTARGETMACHINE_H
15 #define ARMTARGETMACHINE_H
16
17 #include "llvm/Target/TargetMachine.h"
18 #include "llvm/Target/TargetData.h"
19 #include "llvm/Target/TargetFrameInfo.h"
20 #include "ARMInstrInfo.h"
21 #include "ARMFrameInfo.h"
22 #include "ARMJITInfo.h"
23 #include "ARMSubtarget.h"
24 #include "ARMISelLowering.h"
25
26 namespace llvm {
27
28 class Module;
29
30 class ARMTargetMachine : public LLVMTargetMachine {
31   ARMSubtarget      Subtarget;
32   const TargetData  DataLayout;       // Calculates type size & alignment
33   ARMInstrInfo      InstrInfo;
34   ARMFrameInfo      FrameInfo;
35   ARMJITInfo        JITInfo;
36   ARMTargetLowering TLInfo;
37   Reloc::Model      DefRelocModel;    // Reloc model before it's overridden.
38
39 protected:
40   // To avoid having target depend on the asmprinter stuff libraries, asmprinter
41   // set this functions to ctor pointer at startup time if they are linked in.
42   typedef FunctionPass *(*AsmPrinterCtorFn)(raw_ostream &o,
43                                             ARMTargetMachine &tm);
44   static AsmPrinterCtorFn AsmPrinterCtor;
45
46 public:
47   ARMTargetMachine(const Module &M, const std::string &FS, bool isThumb = false);
48
49   virtual const ARMInstrInfo     *getInstrInfo() const { return &InstrInfo; }
50   virtual const ARMFrameInfo     *getFrameInfo() const { return &FrameInfo; }
51   virtual       ARMJITInfo       *getJITInfo()         { return &JITInfo; }
52   virtual const ARMRegisterInfo  *getRegisterInfo() const {
53     return &InstrInfo.getRegisterInfo();
54   }
55   virtual const TargetData       *getTargetData() const { return &DataLayout; }
56   virtual const ARMSubtarget  *getSubtargetImpl() const { return &Subtarget; }
57   virtual       ARMTargetLowering *getTargetLowering() const {
58     return const_cast<ARMTargetLowering*>(&TLInfo);
59   }
60
61   static void registerAsmPrinter(AsmPrinterCtorFn F) {
62     AsmPrinterCtor = F;
63   }
64
65   static unsigned getModuleMatchQuality(const Module &M);
66   static unsigned getJITMatchQuality();
67
68   virtual const TargetAsmInfo *createTargetAsmInfo() const;
69
70   // Pass Pipeline Configuration
71   virtual bool addInstSelector(PassManagerBase &PM, bool Fast);
72   virtual bool addPreEmitPass(PassManagerBase &PM, bool Fast);
73   virtual bool addAssemblyEmitter(PassManagerBase &PM, bool Fast,
74                                   raw_ostream &Out);
75   virtual bool addCodeEmitter(PassManagerBase &PM, bool Fast,
76                               bool DumpAsm, MachineCodeEmitter &MCE);
77   virtual bool addSimpleCodeEmitter(PassManagerBase &PM, bool Fast,
78                                     bool DumpAsm, MachineCodeEmitter &MCE);
79 };
80
81 /// ThumbTargetMachine - Thumb target machine.
82 ///
83 class ThumbTargetMachine : public ARMTargetMachine {
84 public:
85   ThumbTargetMachine(const Module &M, const std::string &FS);
86
87   static unsigned getJITMatchQuality();
88   static unsigned getModuleMatchQuality(const Module &M);
89 };
90
91 } // end namespace llvm
92
93 #endif