1b328973c439a56ccc5191910e81a30036e0475f
[oota-llvm.git] / lib / Target / CellSPU / SPUTargetMachine.h
1 //===-- SPUTargetMachine.h - Define TargetMachine for Cell SPU ----*- 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 CellSPU-specific subclass of TargetMachine.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef SPU_TARGETMACHINE_H
15 #define SPU_TARGETMACHINE_H
16
17 #include "SPUSubtarget.h"
18 #include "SPUInstrInfo.h"
19 #include "SPUISelLowering.h"
20 #include "SPUFrameInfo.h"
21 #include "llvm/Target/TargetMachine.h"
22 #include "llvm/Target/TargetData.h"
23
24 namespace llvm {
25 class PassManager;
26 class GlobalValue;
27 class TargetFrameInfo;
28
29 /// SPUTargetMachine
30 ///
31 class SPUTargetMachine : public LLVMTargetMachine {
32   SPUSubtarget        Subtarget;
33   const TargetData    DataLayout;
34   SPUInstrInfo        InstrInfo;
35   SPUFrameInfo        FrameInfo;
36   SPUTargetLowering   TLInfo;
37   InstrItineraryData  InstrItins;
38
39 protected:
40   virtual const TargetAsmInfo *createTargetAsmInfo() const;
41
42   // To avoid having target depend on the asmprinter stuff libraries, asmprinter
43   // set this functions to ctor pointer at startup time if they are linked in.
44   typedef FunctionPass *(*AsmPrinterCtorFn)(formatted_raw_ostream &o,
45                                             TargetMachine &tm,
46                                             bool verbose);
47   static AsmPrinterCtorFn AsmPrinterCtor;
48
49 public:
50   SPUTargetMachine(const Target &T, const Module &M, const std::string &FS);
51
52   /// Return the subtarget implementation object
53   virtual const SPUSubtarget     *getSubtargetImpl() const {
54     return &Subtarget;
55   }
56   virtual const SPUInstrInfo     *getInstrInfo() const {
57     return &InstrInfo;
58   }
59   virtual const SPUFrameInfo     *getFrameInfo() const {
60     return &FrameInfo;
61   }
62   /*!
63     \note Cell SPU does not support JIT today. It could support JIT at some
64     point.
65    */
66   virtual       TargetJITInfo    *getJITInfo() {
67     return NULL;
68   }
69   
70   //! Module match function
71   /*!
72     Module matching function called by TargetMachineRegistry().
73    */
74   static unsigned getModuleMatchQuality(const Module &M);
75
76   virtual       SPUTargetLowering *getTargetLowering() const { 
77    return const_cast<SPUTargetLowering*>(&TLInfo); 
78   }
79
80   virtual const SPURegisterInfo *getRegisterInfo() const {
81     return &InstrInfo.getRegisterInfo();
82   }
83   
84   virtual const TargetData *getTargetData() const {
85     return &DataLayout;
86   }
87
88   virtual const InstrItineraryData getInstrItineraryData() const {
89     return InstrItins;
90   }
91   
92   // Pass Pipeline Configuration
93   virtual bool addInstSelector(PassManagerBase &PM,
94                                CodeGenOpt::Level OptLevel);
95   virtual bool addAssemblyEmitter(PassManagerBase &PM,
96                                   CodeGenOpt::Level OptLevel,
97                                   bool Verbose, formatted_raw_ostream &Out);
98
99   static void registerAsmPrinter(AsmPrinterCtorFn F) {
100     AsmPrinterCtor = F;
101   }
102 };
103
104 } // end namespace llvm
105
106 #endif