c4c8e6c1d985824a7598cf2b2966eb14bf25dcdc
[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   InstrItineraryData  InstrItins;
38   Reloc::Model        DefRelocModel;    // Reloc model before it's overridden.
39
40 protected:
41   // To avoid having target depend on the asmprinter stuff libraries, asmprinter
42   // set this functions to ctor pointer at startup time if they are linked in.
43   typedef FunctionPass *(*AsmPrinterCtorFn)(raw_ostream &o,
44                                             ARMTargetMachine &tm,
45                                             CodeGenOpt::Level OptLevel,
46                                             bool verbose);
47   static AsmPrinterCtorFn AsmPrinterCtor;
48
49 public:
50   ARMTargetMachine(const Module &M, const std::string &FS, bool isThumb = false);
51
52   virtual const ARMInstrInfo     *getInstrInfo() const { return &InstrInfo; }
53   virtual const ARMFrameInfo     *getFrameInfo() const { return &FrameInfo; }
54   virtual       ARMJITInfo       *getJITInfo()         { return &JITInfo; }
55   virtual const ARMRegisterInfo  *getRegisterInfo() const {
56     return &InstrInfo.getRegisterInfo();
57   }
58   virtual const TargetData       *getTargetData() const { return &DataLayout; }
59   virtual const ARMSubtarget  *getSubtargetImpl() const { return &Subtarget; }
60   virtual       ARMTargetLowering *getTargetLowering() const {
61     return const_cast<ARMTargetLowering*>(&TLInfo);
62   }
63   virtual const InstrItineraryData getInstrItineraryData() const {  
64     return InstrItins;
65   }
66
67   static void registerAsmPrinter(AsmPrinterCtorFn F) {
68     AsmPrinterCtor = F;
69   }
70
71   static unsigned getModuleMatchQuality(const Module &M);
72   static unsigned getJITMatchQuality();
73
74   virtual const TargetAsmInfo *createTargetAsmInfo() const;
75
76   // Pass Pipeline Configuration
77   virtual bool addInstSelector(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
78   virtual bool addPreRegAlloc(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
79   virtual bool addPreEmitPass(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
80   virtual bool addAssemblyEmitter(PassManagerBase &PM,
81                                   CodeGenOpt::Level OptLevel,
82                                   bool Verbose, raw_ostream &Out);
83   virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel,
84                               bool DumpAsm, MachineCodeEmitter &MCE);
85   virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel,
86                               bool DumpAsm, JITCodeEmitter &MCE);
87   virtual bool addSimpleCodeEmitter(PassManagerBase &PM,
88                                     CodeGenOpt::Level OptLevel,
89                                     bool DumpAsm,
90                                     MachineCodeEmitter &MCE);
91   virtual bool addSimpleCodeEmitter(PassManagerBase &PM,
92                                     CodeGenOpt::Level OptLevel,
93                                     bool DumpAsm,
94                                     JITCodeEmitter &MCE);
95 };
96
97 /// ThumbTargetMachine - Thumb target machine.
98 ///
99 class ThumbTargetMachine : public ARMTargetMachine {
100 public:
101   ThumbTargetMachine(const Module &M, const std::string &FS);
102
103   static unsigned getJITMatchQuality();
104   static unsigned getModuleMatchQuality(const Module &M);
105 };
106
107 } // end namespace llvm
108
109 #endif