Add the Object Code Emitter class. Original patch by Aaron Gray, I did some
[oota-llvm.git] / lib / Target / Alpha / AlphaTargetMachine.h
1 //===-- AlphaTargetMachine.h - Define TargetMachine for Alpha ---*- 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 Alpha-specific subclass of TargetMachine.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef ALPHA_TARGETMACHINE_H
15 #define ALPHA_TARGETMACHINE_H
16
17 #include "llvm/Target/TargetMachine.h"
18 #include "llvm/Target/TargetData.h"
19 #include "llvm/Target/TargetFrameInfo.h"
20 #include "AlphaInstrInfo.h"
21 #include "AlphaJITInfo.h"
22 #include "AlphaISelLowering.h"
23 #include "AlphaSubtarget.h"
24
25 namespace llvm {
26
27 class GlobalValue;
28
29 class AlphaTargetMachine : public LLVMTargetMachine {
30   const TargetData DataLayout;       // Calculates type size & alignment
31   AlphaInstrInfo InstrInfo;
32   TargetFrameInfo FrameInfo;
33   AlphaJITInfo JITInfo;
34   AlphaSubtarget Subtarget;
35   AlphaTargetLowering TLInfo;
36
37 protected:
38   virtual const TargetAsmInfo *createTargetAsmInfo() const;
39
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                                             TargetMachine &tm,
44                                             bool verbose);
45   static AsmPrinterCtorFn AsmPrinterCtor;
46
47 public:
48   AlphaTargetMachine(const Module &M, const std::string &FS);
49
50   virtual const AlphaInstrInfo *getInstrInfo() const { return &InstrInfo; }
51   virtual const TargetFrameInfo  *getFrameInfo() const { return &FrameInfo; }
52   virtual const AlphaSubtarget   *getSubtargetImpl() const{ return &Subtarget; }
53   virtual const AlphaRegisterInfo *getRegisterInfo() const {
54     return &InstrInfo.getRegisterInfo();
55   }
56   virtual AlphaTargetLowering* getTargetLowering() const {
57     return const_cast<AlphaTargetLowering*>(&TLInfo);
58   }
59   virtual const TargetData       *getTargetData() const { return &DataLayout; }
60   virtual AlphaJITInfo* getJITInfo() {
61     return &JITInfo;
62   }
63
64   static unsigned getJITMatchQuality();
65   static unsigned getModuleMatchQuality(const Module &M);
66
67   // Pass Pipeline Configuration
68   virtual bool addInstSelector(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
69   virtual bool addPreEmitPass(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
70   virtual bool addAssemblyEmitter(PassManagerBase &PM,
71                                   CodeGenOpt::Level OptLevel,
72                                   bool Verbose, raw_ostream &Out);
73   virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel,
74                               bool DumpAsm, MachineCodeEmitter &MCE);
75   virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel,
76                               bool DumpAsm, JITCodeEmitter &JCE);
77   virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel,
78                               bool DumpAsm, ObjectCodeEmitter &JCE);
79   virtual bool addSimpleCodeEmitter(PassManagerBase &PM,
80                                     CodeGenOpt::Level OptLevel,
81                                     bool DumpAsm,
82                                     MachineCodeEmitter &MCE);
83   virtual bool addSimpleCodeEmitter(PassManagerBase &PM,
84                                     CodeGenOpt::Level OptLevel,
85                                     bool DumpAsm,
86                                     JITCodeEmitter &JCE);
87   virtual bool addSimpleCodeEmitter(PassManagerBase &PM,
88                                     CodeGenOpt::Level OptLevel,
89                                     bool DumpAsm,
90                                     ObjectCodeEmitter &OCE);
91
92   static void registerAsmPrinter(AsmPrinterCtorFn F) {
93     AsmPrinterCtor = F;
94   }
95 };
96
97 } // end namespace llvm
98
99 #endif