blob: 18f525d1c8ce792145097420cbb5f366b5fd07e0 [file] [log] [blame]
Scott Michel564427e2007-12-05 01:24:05 +00001//===-- SPUTargetMachine.h - Define TargetMachine for Cell SPU ----*- C++ -*-=//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Scott Michel564427e2007-12-05 01:24:05 +00007//
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
24namespace llvm {
25class PassManager;
26class GlobalValue;
27class TargetFrameInfo;
28
29/// SPUTargetMachine
30///
31class SPUTargetMachine : public LLVMTargetMachine {
32 SPUSubtarget Subtarget;
33 const TargetData DataLayout;
34 SPUInstrInfo InstrInfo;
35 SPUFrameInfo FrameInfo;
36 SPUTargetLowering TLInfo;
37 InstrItineraryData InstrItins;
Anton Korobeynikove494b9e2009-06-19 19:36:55 +000038
Scott Michel564427e2007-12-05 01:24:05 +000039protected:
40 virtual const TargetAsmInfo *createTargetAsmInfo() const;
Anton Korobeynikove494b9e2009-06-19 19:36:55 +000041
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.
David Greene71847812009-07-14 20:18:05 +000044 typedef FunctionPass *(*AsmPrinterCtorFn)(formatted_raw_ostream &o,
Daniel Dunbar51b198a2009-07-15 20:24:03 +000045 TargetMachine &tm,
Anton Korobeynikove494b9e2009-06-19 19:36:55 +000046 bool verbose);
47 static AsmPrinterCtorFn AsmPrinterCtor;
48
Scott Michel564427e2007-12-05 01:24:05 +000049public:
Daniel Dunbar51b198a2009-07-15 20:24:03 +000050 SPUTargetMachine(const Target &T, const Module &M, const std::string &FS);
Scott Michel564427e2007-12-05 01:24:05 +000051
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 }
Dan Gohmanc9f5f3f2008-05-14 01:58:56 +000059 virtual const SPUFrameInfo *getFrameInfo() const {
Scott Michel564427e2007-12-05 01:24:05 +000060 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 }
Scott Michel564427e2007-12-05 01:24:05 +000069
70 virtual SPUTargetLowering *getTargetLowering() const {
71 return const_cast<SPUTargetLowering*>(&TLInfo);
72 }
73
Dan Gohmanc9f5f3f2008-05-14 01:58:56 +000074 virtual const SPURegisterInfo *getRegisterInfo() const {
Scott Michel564427e2007-12-05 01:24:05 +000075 return &InstrInfo.getRegisterInfo();
76 }
77
78 virtual const TargetData *getTargetData() const {
79 return &DataLayout;
80 }
81
Anton Korobeynikove494b9e2009-06-19 19:36:55 +000082 virtual const InstrItineraryData getInstrItineraryData() const {
Scott Michel564427e2007-12-05 01:24:05 +000083 return InstrItins;
84 }
85
86 // Pass Pipeline Configuration
Bill Wendling98a366d2009-04-29 23:29:43 +000087 virtual bool addInstSelector(PassManagerBase &PM,
88 CodeGenOpt::Level OptLevel);
89 virtual bool addAssemblyEmitter(PassManagerBase &PM,
90 CodeGenOpt::Level OptLevel,
David Greene71847812009-07-14 20:18:05 +000091 bool Verbose, formatted_raw_ostream &Out);
Anton Korobeynikove494b9e2009-06-19 19:36:55 +000092
93 static void registerAsmPrinter(AsmPrinterCtorFn F) {
94 AsmPrinterCtor = F;
95 }
Scott Michel564427e2007-12-05 01:24:05 +000096};
97
98} // end namespace llvm
99
100#endif