LLVM API Documentation
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 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 protected: 00042 virtual const TargetAsmInfo *createTargetAsmInfo() const; 00043 00044 // To avoid having target depend on the asmprinter stuff libraries, asmprinter 00045 // set this functions to ctor pointer at startup time if they are linked in. 00046 typedef FunctionPass *(*AsmPrinterCtorFn)(raw_ostream &o, 00047 X86TargetMachine &tm); 00048 static AsmPrinterCtorFn AsmPrinterCtor; 00049 00050 public: 00051 X86TargetMachine(const Module &M, const std::string &FS, bool is64Bit); 00052 00053 virtual const X86InstrInfo *getInstrInfo() const { return &InstrInfo; } 00054 virtual const TargetFrameInfo *getFrameInfo() const { return &FrameInfo; } 00055 virtual X86JITInfo *getJITInfo() { return &JITInfo; } 00056 virtual const X86Subtarget *getSubtargetImpl() const{ return &Subtarget; } 00057 virtual X86TargetLowering *getTargetLowering() const { 00058 return const_cast<X86TargetLowering*>(&TLInfo); 00059 } 00060 virtual const X86RegisterInfo *getRegisterInfo() const { 00061 return &InstrInfo.getRegisterInfo(); 00062 } 00063 virtual const TargetData *getTargetData() const { return &DataLayout; } 00064 virtual const X86ELFWriterInfo *getELFWriterInfo() const { 00065 return Subtarget.isTargetELF() ? &ELFWriterInfo : 0; 00066 } 00067 00068 static unsigned getModuleMatchQuality(const Module &M); 00069 static unsigned getJITMatchQuality(); 00070 00071 static void registerAsmPrinter(AsmPrinterCtorFn F) { 00072 AsmPrinterCtor = F; 00073 } 00074 00075 // Set up the pass pipeline. 00076 virtual bool addInstSelector(PassManagerBase &PM, bool Fast); 00077 virtual bool addPreRegAlloc(PassManagerBase &PM, bool Fast); 00078 virtual bool addPostRegAlloc(PassManagerBase &PM, bool Fast); 00079 virtual bool addAssemblyEmitter(PassManagerBase &PM, bool Fast, 00080 raw_ostream &Out); 00081 virtual bool addCodeEmitter(PassManagerBase &PM, bool Fast, 00082 bool DumpAsm, MachineCodeEmitter &MCE); 00083 virtual bool addSimpleCodeEmitter(PassManagerBase &PM, bool Fast, 00084 bool DumpAsm, MachineCodeEmitter &MCE); 00085 00086 // symbolicAddressesAreRIPRel - Return true if symbolic addresses are 00087 // RIP-relative on this machine, taking into consideration the relocation 00088 // model and subtarget. RIP-relative addresses cannot have a separate 00089 // base or index register. 00090 bool symbolicAddressesAreRIPRel() const; 00091 }; 00092 00093 /// X86_32TargetMachine - X86 32-bit target machine. 00094 /// 00095 class X86_32TargetMachine : public X86TargetMachine { 00096 public: 00097 X86_32TargetMachine(const Module &M, const std::string &FS); 00098 00099 static unsigned getJITMatchQuality(); 00100 static unsigned getModuleMatchQuality(const Module &M); 00101 }; 00102 00103 /// X86_64TargetMachine - X86 64-bit target machine. 00104 /// 00105 class X86_64TargetMachine : public X86TargetMachine { 00106 public: 00107 X86_64TargetMachine(const Module &M, const std::string &FS); 00108 00109 static unsigned getJITMatchQuality(); 00110 static unsigned getModuleMatchQuality(const Module &M); 00111 }; 00112 00113 } // End llvm namespace 00114 00115 #endif
This web site is hosted by the Computer Science Department at the University of Illinois at Urbana-Champaign.