X86TargetMachine.h revision 195340
143410Snewton//===-- X86TargetMachine.h - Define TargetMachine for the X86 ---*- C++ -*-===//
243410Snewton//
343410Snewton//                     The LLVM Compiler Infrastructure
443410Snewton//
543410Snewton// This file is distributed under the University of Illinois Open Source
643410Snewton// License. See LICENSE.TXT for details.
743410Snewton//
843410Snewton//===----------------------------------------------------------------------===//
943410Snewton//
1043410Snewton// This file declares the X86 specific subclass of TargetMachine.
1143410Snewton//
1243410Snewton//===----------------------------------------------------------------------===//
1343410Snewton
1443410Snewton#ifndef X86TARGETMACHINE_H
1543410Snewton#define X86TARGETMACHINE_H
1643410Snewton
1743410Snewton#include "llvm/Target/TargetMachine.h"
1843410Snewton#include "llvm/Target/TargetData.h"
1943410Snewton#include "llvm/Target/TargetFrameInfo.h"
2043410Snewton#include "X86.h"
2143410Snewton#include "X86ELFWriterInfo.h"
2243410Snewton#include "X86InstrInfo.h"
2343410Snewton#include "X86JITInfo.h"
2443410Snewton#include "X86Subtarget.h"
2543410Snewton#include "X86ISelLowering.h"
2643410Snewton
2743410Snewtonnamespace llvm {
2843410Snewton
2943410Snewtonclass raw_ostream;
3043410Snewton
3143410Snewtonclass X86TargetMachine : public LLVMTargetMachine {
3249263Snewton  X86Subtarget      Subtarget;
3350477Speter  const TargetData  DataLayout; // Calculates type size & alignment
3443410Snewton  TargetFrameInfo   FrameInfo;
3543410Snewton  X86InstrInfo      InstrInfo;
3643410Snewton  X86JITInfo        JITInfo;
3743410Snewton  X86TargetLowering TLInfo;
3843410Snewton  X86ELFWriterInfo  ELFWriterInfo;
3943410Snewton  Reloc::Model      DefRelocModel; // Reloc model before it's overridden.
4043410Snewton
4143410Snewtonprotected:
4243410Snewton  virtual const TargetAsmInfo *createTargetAsmInfo() const;
4343410Snewton
4443410Snewton  // To avoid having target depend on the asmprinter stuff libraries, asmprinter
4543410Snewton  // set this functions to ctor pointer at startup time if they are linked in.
4643410Snewton  typedef FunctionPass *(*AsmPrinterCtorFn)(raw_ostream &o,
4743410Snewton                                            X86TargetMachine &tm,
4843410Snewton                                            bool verbose);
4943410Snewton  static AsmPrinterCtorFn AsmPrinterCtor;
5043410Snewton
5143410Snewtonpublic:
5243410Snewton  X86TargetMachine(const Module &M, const std::string &FS, bool is64Bit);
5343410Snewton
5443410Snewton  virtual const X86InstrInfo     *getInstrInfo() const { return &InstrInfo; }
5543410Snewton  virtual const TargetFrameInfo  *getFrameInfo() const { return &FrameInfo; }
5643410Snewton  virtual       X86JITInfo       *getJITInfo()         { return &JITInfo; }
5765314Sobrien  virtual const X86Subtarget     *getSubtargetImpl() const{ return &Subtarget; }
5865314Sobrien  virtual       X86TargetLowering *getTargetLowering() const {
5965314Sobrien    return const_cast<X86TargetLowering*>(&TLInfo);
6065314Sobrien  }
6165314Sobrien  virtual const X86RegisterInfo  *getRegisterInfo() const {
6265314Sobrien    return &InstrInfo.getRegisterInfo();
6343410Snewton  }
6483366Sjulian  virtual const TargetData       *getTargetData() const { return &DataLayout; }
6583366Sjulian  virtual const X86ELFWriterInfo *getELFWriterInfo() const {
6643410Snewton    return Subtarget.isTargetELF() ? &ELFWriterInfo : 0;
6743410Snewton  }
6843410Snewton
6943410Snewton  static unsigned getModuleMatchQuality(const Module &M);
7043410Snewton  static unsigned getJITMatchQuality();
7143410Snewton
7243410Snewton  static void registerAsmPrinter(AsmPrinterCtorFn F) {
7343410Snewton    AsmPrinterCtor = F;
7460938Sjake  }
7543410Snewton
7643410Snewton  // Set up the pass pipeline.
7760938Sjake  virtual bool addInstSelector(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
7843410Snewton  virtual bool addPreRegAlloc(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
7943410Snewton  virtual bool addPostRegAlloc(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
8043410Snewton  virtual bool addAssemblyEmitter(PassManagerBase &PM,
8143410Snewton                                  CodeGenOpt::Level OptLevel,
8243410Snewton                                  bool Verbose, raw_ostream &Out);
8343410Snewton  virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel,
8443410Snewton                              bool DumpAsm, MachineCodeEmitter &MCE);
8543410Snewton  virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel,
8643410Snewton                              bool DumpAsm, JITCodeEmitter &JCE);
8743410Snewton  virtual bool addSimpleCodeEmitter(PassManagerBase &PM,
8843410Snewton                                    CodeGenOpt::Level OptLevel,
8943410Snewton                                    bool DumpAsm, MachineCodeEmitter &MCE);
9043410Snewton  virtual bool addSimpleCodeEmitter(PassManagerBase &PM,
9143410Snewton                                    CodeGenOpt::Level OptLevel,
9243410Snewton                                    bool DumpAsm, JITCodeEmitter &JCE);
9343410Snewton};
9443410Snewton
9543410Snewton/// X86_32TargetMachine - X86 32-bit target machine.
9643410Snewton///
9743410Snewtonclass X86_32TargetMachine : public X86TargetMachine {
9852114Snewtonpublic:
9952114Snewton  X86_32TargetMachine(const Module &M, const std::string &FS);
10052114Snewton
10143410Snewton  static unsigned getJITMatchQuality();
10272521Sjlemon  static unsigned getModuleMatchQuality(const Module &M);
10372521Sjlemon};
10443410Snewton
10543410Snewton/// X86_64TargetMachine - X86 64-bit target machine.
10643410Snewton///
10743410Snewtonclass X86_64TargetMachine : public X86TargetMachine {
10847625Sphkpublic:
10947625Sphk  X86_64TargetMachine(const Module &M, const std::string &FS);
11047625Sphk
11147625Sphk  static unsigned getJITMatchQuality();
11247625Sphk  static unsigned getModuleMatchQuality(const Module &M);
11347625Sphk};
11447625Sphk
11547625Sphk} // End llvm namespace
11647625Sphk
11747625Sphk#endif
11847625Sphk