MipsTargetMachine.h revision 194612
1//===-- MipsTargetMachine.h - Define TargetMachine for Mips -00--*- 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 Mips specific subclass of TargetMachine.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef MIPSTARGETMACHINE_H
15#define MIPSTARGETMACHINE_H
16
17#include "MipsSubtarget.h"
18#include "MipsInstrInfo.h"
19#include "MipsISelLowering.h"
20#include "llvm/Target/TargetMachine.h"
21#include "llvm/Target/TargetData.h"
22#include "llvm/Target/TargetFrameInfo.h"
23
24namespace llvm {
25  class raw_ostream;
26
27  class MipsTargetMachine : public LLVMTargetMachine {
28    MipsSubtarget       Subtarget;
29    const TargetData    DataLayout; // Calculates type size & alignment
30    MipsInstrInfo       InstrInfo;
31    TargetFrameInfo     FrameInfo;
32    MipsTargetLowering  TLInfo;
33
34  protected:
35    virtual const TargetAsmInfo *createTargetAsmInfo() const;
36  protected:
37    // To avoid having target depend on the asmprinter stuff libraries,
38    // asmprinter set this functions to ctor pointer at startup time if they are
39    // linked in.
40    typedef FunctionPass *(*AsmPrinterCtorFn)(raw_ostream &o,
41                                              MipsTargetMachine &tm,
42                                              CodeGenOpt::Level OptLevel,
43                                              bool verbose);
44    static AsmPrinterCtorFn AsmPrinterCtor;
45
46  public:
47    MipsTargetMachine(const Module &M, const std::string &FS, bool isLittle);
48
49    static void registerAsmPrinter(AsmPrinterCtorFn F) {
50      AsmPrinterCtor = F;
51    }
52
53    virtual const MipsInstrInfo   *getInstrInfo()     const
54    { return &InstrInfo; }
55    virtual const TargetFrameInfo *getFrameInfo()     const
56    { return &FrameInfo; }
57    virtual const MipsSubtarget   *getSubtargetImpl() const
58    { return &Subtarget; }
59    virtual const TargetData      *getTargetData()    const
60    { return &DataLayout;}
61
62    virtual const MipsRegisterInfo *getRegisterInfo()  const {
63      return &InstrInfo.getRegisterInfo();
64    }
65
66    virtual MipsTargetLowering   *getTargetLowering() const {
67      return const_cast<MipsTargetLowering*>(&TLInfo);
68    }
69
70    static unsigned getModuleMatchQuality(const Module &M);
71
72    // Pass Pipeline Configuration
73    virtual bool addInstSelector(PassManagerBase &PM,
74                                 CodeGenOpt::Level OptLevel);
75    virtual bool addPreEmitPass(PassManagerBase &PM,
76                                CodeGenOpt::Level OptLevel);
77    virtual bool addAssemblyEmitter(PassManagerBase &PM,
78                                    CodeGenOpt::Level OptLevel,
79                                    bool Verbose, raw_ostream &Out);
80  };
81
82/// MipselTargetMachine - Mipsel target machine.
83///
84class MipselTargetMachine : public MipsTargetMachine {
85public:
86  MipselTargetMachine(const Module &M, const std::string &FS);
87
88  static unsigned getModuleMatchQuality(const Module &M);
89};
90
91} // End llvm namespace
92
93#endif
94