LLVM API Documentation

X86TargetMachine.h

Go to the documentation of this file.
00001 //===-- X86TargetMachine.h - Define TargetMachine for the X86 ---*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file declares the X86 specific subclass of TargetMachine.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 #ifndef X86TARGETMACHINE_H
00015 #define X86TARGETMACHINE_H
00016 
00017 #include "llvm/Target/TargetMachine.h"
00018 #include "llvm/Target/TargetData.h"
00019 #include "llvm/Target/TargetFrameInfo.h"
00020 #include "X86.h"
00021 #include "X86ELFWriterInfo.h"
00022 #include "X86InstrInfo.h"
00023 #include "X86JITInfo.h"
00024 #include "X86Subtarget.h"
00025 #include "X86ISelLowering.h"
00026 
00027 namespace llvm {
00028   
00029 class formatted_raw_ostream;
00030 
00031 class X86TargetMachine : public LLVMTargetMachine {
00032   X86Subtarget      Subtarget;
00033   const TargetData  DataLayout; // Calculates type size & alignment
00034   TargetFrameInfo   FrameInfo;
00035   X86InstrInfo      InstrInfo;
00036   X86JITInfo        JITInfo;
00037   X86TargetLowering TLInfo;
00038   X86ELFWriterInfo  ELFWriterInfo;
00039   Reloc::Model      DefRelocModel; // Reloc model before it's overridden.
00040 
00041 public:
00042   X86TargetMachine(const Target &T, const std::string &TT, 
00043                    const std::string &FS, bool is64Bit);
00044 
00045   virtual const X86InstrInfo     *getInstrInfo() const { return &InstrInfo; }
00046   virtual const TargetFrameInfo  *getFrameInfo() const { return &FrameInfo; }
00047   virtual       X86JITInfo       *getJITInfo()         { return &JITInfo; }
00048   virtual const X86Subtarget     *getSubtargetImpl() const{ return &Subtarget; }
00049   virtual       X86TargetLowering *getTargetLowering() const { 
00050     return const_cast<X86TargetLowering*>(&TLInfo); 
00051   }
00052   virtual const X86RegisterInfo  *getRegisterInfo() const {
00053     return &InstrInfo.getRegisterInfo();
00054   }
00055   virtual const TargetData       *getTargetData() const { return &DataLayout; }
00056   virtual const X86ELFWriterInfo *getELFWriterInfo() const {
00057     return Subtarget.isTargetELF() ? &ELFWriterInfo : 0;
00058   }
00059 
00060   // Set up the pass pipeline.
00061   virtual bool addInstSelector(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
00062   virtual bool addPreRegAlloc(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
00063   virtual bool addPostRegAlloc(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
00064   virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel,
00065                               MachineCodeEmitter &MCE);
00066   virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel,
00067                               JITCodeEmitter &JCE);
00068   virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel,
00069                               ObjectCodeEmitter &OCE);
00070   virtual bool addSimpleCodeEmitter(PassManagerBase &PM,
00071                                     CodeGenOpt::Level OptLevel,
00072                                     MachineCodeEmitter &MCE);
00073   virtual bool addSimpleCodeEmitter(PassManagerBase &PM,
00074                                     CodeGenOpt::Level OptLevel,
00075                                     JITCodeEmitter &JCE);
00076   virtual bool addSimpleCodeEmitter(PassManagerBase &PM,
00077                                     CodeGenOpt::Level OptLevel,
00078                                     ObjectCodeEmitter &OCE);
00079 };
00080 
00081 /// X86_32TargetMachine - X86 32-bit target machine.
00082 ///
00083 class X86_32TargetMachine : public X86TargetMachine {
00084 public:
00085   X86_32TargetMachine(const Target &T, const std::string &M,
00086                       const std::string &FS);
00087 };
00088 
00089 /// X86_64TargetMachine - X86 64-bit target machine.
00090 ///
00091 class X86_64TargetMachine : public X86TargetMachine {
00092 public:
00093   X86_64TargetMachine(const Target &T, const std::string &TT,
00094                       const std::string &FS);
00095 };
00096 
00097 } // End llvm namespace
00098 
00099 #endif