Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 1 | //===-- SPUTargetMachine.h - Define TargetMachine for Cell SPU ----*- C++ -*-=// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 4ee451d | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 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; |
Anton Korobeynikov | e494b9e | 2009-06-19 19:36:55 +0000 | [diff] [blame] | 38 | |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 39 | protected: |
| 40 | virtual const TargetAsmInfo *createTargetAsmInfo() const; |
Anton Korobeynikov | e494b9e | 2009-06-19 19:36:55 +0000 | [diff] [blame] | 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)(raw_ostream &o, |
| 45 | SPUTargetMachine &tm, |
| 46 | CodeGenOpt::Level OptLevel, |
| 47 | bool verbose); |
| 48 | static AsmPrinterCtorFn AsmPrinterCtor; |
| 49 | |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 50 | public: |
| 51 | SPUTargetMachine(const Module &M, const std::string &FS); |
| 52 | |
| 53 | /// Return the subtarget implementation object |
| 54 | virtual const SPUSubtarget *getSubtargetImpl() const { |
| 55 | return &Subtarget; |
| 56 | } |
| 57 | virtual const SPUInstrInfo *getInstrInfo() const { |
| 58 | return &InstrInfo; |
| 59 | } |
Dan Gohman | c9f5f3f | 2008-05-14 01:58:56 +0000 | [diff] [blame] | 60 | virtual const SPUFrameInfo *getFrameInfo() const { |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 61 | return &FrameInfo; |
| 62 | } |
| 63 | /*! |
| 64 | \note Cell SPU does not support JIT today. It could support JIT at some |
| 65 | point. |
| 66 | */ |
| 67 | virtual TargetJITInfo *getJITInfo() { |
| 68 | return NULL; |
| 69 | } |
| 70 | |
| 71 | //! Module match function |
| 72 | /*! |
| 73 | Module matching function called by TargetMachineRegistry(). |
| 74 | */ |
| 75 | static unsigned getModuleMatchQuality(const Module &M); |
| 76 | |
| 77 | virtual SPUTargetLowering *getTargetLowering() const { |
| 78 | return const_cast<SPUTargetLowering*>(&TLInfo); |
| 79 | } |
| 80 | |
Dan Gohman | c9f5f3f | 2008-05-14 01:58:56 +0000 | [diff] [blame] | 81 | virtual const SPURegisterInfo *getRegisterInfo() const { |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 82 | return &InstrInfo.getRegisterInfo(); |
| 83 | } |
| 84 | |
| 85 | virtual const TargetData *getTargetData() const { |
| 86 | return &DataLayout; |
| 87 | } |
| 88 | |
Anton Korobeynikov | e494b9e | 2009-06-19 19:36:55 +0000 | [diff] [blame] | 89 | virtual const InstrItineraryData getInstrItineraryData() const { |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 90 | return InstrItins; |
| 91 | } |
| 92 | |
| 93 | // Pass Pipeline Configuration |
Bill Wendling | 98a366d | 2009-04-29 23:29:43 +0000 | [diff] [blame] | 94 | virtual bool addInstSelector(PassManagerBase &PM, |
| 95 | CodeGenOpt::Level OptLevel); |
| 96 | virtual bool addAssemblyEmitter(PassManagerBase &PM, |
| 97 | CodeGenOpt::Level OptLevel, |
Bill Wendling | be8cc2a | 2009-04-29 00:15:41 +0000 | [diff] [blame] | 98 | bool Verbose, raw_ostream &Out); |
Anton Korobeynikov | e494b9e | 2009-06-19 19:36:55 +0000 | [diff] [blame] | 99 | |
| 100 | static void registerAsmPrinter(AsmPrinterCtorFn F) { |
| 101 | AsmPrinterCtor = F; |
| 102 | } |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 103 | }; |
| 104 | |
| 105 | } // end namespace llvm |
| 106 | |
| 107 | #endif |