Overhaul my earlier submission due to feedback. It's a large patch, but most of
[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                                             bool fast);
45   static AsmPrinterCtorFn AsmPrinterCtor;
46
47 public:
48   ARMTargetMachine(const Module &M, const std::string &FS, bool isThumb = false);
49
50   virtual const ARMInstrInfo     *getInstrInfo() const { return &InstrInfo; }
51   virtual const ARMFrameInfo     *getFrameInfo() const { return &FrameInfo; }
52   virtual       ARMJITInfo       *getJITInfo()         { return &JITInfo; }
53   virtual const ARMRegisterInfo  *getRegisterInfo() const {
54     return &InstrInfo.getRegisterInfo();
55   }
56   virtual const TargetData       *getTargetData() const { return &DataLayout; }
57   virtual const ARMSubtarget  *getSubtargetImpl() const { return &Subtarget; }
58   virtual       ARMTargetLowering *getTargetLowering() const {
59     return const_cast<ARMTargetLowering*>(&TLInfo);
60   }
61
62   static void registerAsmPrinter(AsmPrinterCtorFn F) {
63     AsmPrinterCtor = F;
64   }
65
66   static unsigned getModuleMatchQuality(const Module &M);
67   static unsigned getJITMatchQuality();
68
69   virtual const TargetAsmInfo *createTargetAsmInfo() const;
70
71   // Pass Pipeline Configuration
72   virtual bool addInstSelector(PassManagerBase &PM, bool Fast);
73   virtual bool addPreEmitPass(PassManagerBase &PM, bool Fast);
74   virtual bool addAssemblyEmitter(PassManagerBase &PM, bool Fast,
75                                   raw_ostream &Out);
76   virtual bool addCodeEmitter(PassManagerBase &PM, bool Fast,
77                               bool DumpAsm, MachineCodeEmitter &MCE);
78   virtual bool addSimpleCodeEmitter(PassManagerBase &PM, bool Fast,
79                                     bool DumpAsm, MachineCodeEmitter &MCE);
80 };
81
82 /// ThumbTargetMachine - Thumb target machine.
83 ///
84 class ThumbTargetMachine : public ARMTargetMachine {
85 public:
86   ThumbTargetMachine(const Module &M, const std::string &FS);
87
88   static unsigned getJITMatchQuality();
89   static unsigned getModuleMatchQuality(const Module &M);
90 };
91
92 } // end namespace llvm
93
94 #endif