LLVM API Documentation
00001 //===-- PPCTargetMachine.h - Define TargetMachine for PowerPC -----*- 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 PowerPC specific subclass of TargetMachine. 00011 // 00012 //===----------------------------------------------------------------------===// 00013 00014 #ifndef PPC_TARGETMACHINE_H 00015 #define PPC_TARGETMACHINE_H 00016 00017 #include "PPCFrameInfo.h" 00018 #include "PPCSubtarget.h" 00019 #include "PPCJITInfo.h" 00020 #include "PPCInstrInfo.h" 00021 #include "PPCISelLowering.h" 00022 #include "PPCMachOWriterInfo.h" 00023 #include "llvm/Target/TargetMachine.h" 00024 #include "llvm/Target/TargetData.h" 00025 00026 namespace llvm { 00027 class PassManager; 00028 class GlobalValue; 00029 00030 /// PPCTargetMachine - Common code between 32-bit and 64-bit PowerPC targets. 00031 /// 00032 class PPCTargetMachine : public LLVMTargetMachine { 00033 PPCSubtarget Subtarget; 00034 const TargetData DataLayout; // Calculates type size & alignment 00035 PPCInstrInfo InstrInfo; 00036 PPCFrameInfo FrameInfo; 00037 PPCJITInfo JITInfo; 00038 PPCTargetLowering TLInfo; 00039 InstrItineraryData InstrItins; 00040 PPCMachOWriterInfo MachOWriterInfo; 00041 00042 protected: 00043 virtual const TargetAsmInfo *createTargetAsmInfo() const; 00044 00045 // To avoid having target depend on the asmprinter stuff libraries, asmprinter 00046 // set this functions to ctor pointer at startup time if they are linked in. 00047 typedef FunctionPass *(*AsmPrinterCtorFn)(raw_ostream &o, 00048 PPCTargetMachine &tm); 00049 static AsmPrinterCtorFn AsmPrinterCtor; 00050 00051 public: 00052 PPCTargetMachine(const Module &M, const std::string &FS, bool is64Bit); 00053 00054 virtual const PPCInstrInfo *getInstrInfo() const { return &InstrInfo; } 00055 virtual const PPCFrameInfo *getFrameInfo() const { return &FrameInfo; } 00056 virtual PPCJITInfo *getJITInfo() { return &JITInfo; } 00057 virtual PPCTargetLowering *getTargetLowering() const { 00058 return const_cast<PPCTargetLowering*>(&TLInfo); 00059 } 00060 virtual const PPCRegisterInfo *getRegisterInfo() const { 00061 return &InstrInfo.getRegisterInfo(); 00062 } 00063 00064 virtual const TargetData *getTargetData() const { return &DataLayout; } 00065 virtual const PPCSubtarget *getSubtargetImpl() const { return &Subtarget; } 00066 virtual const InstrItineraryData getInstrItineraryData() const { 00067 return InstrItins; 00068 } 00069 virtual const PPCMachOWriterInfo *getMachOWriterInfo() const { 00070 return &MachOWriterInfo; 00071 } 00072 00073 static void registerAsmPrinter(AsmPrinterCtorFn F) { 00074 AsmPrinterCtor = F; 00075 } 00076 00077 // Pass Pipeline Configuration 00078 virtual bool addInstSelector(PassManagerBase &PM, bool Fast); 00079 virtual bool addPreEmitPass(PassManagerBase &PM, bool Fast); 00080 virtual bool addAssemblyEmitter(PassManagerBase &PM, bool Fast, 00081 raw_ostream &Out); 00082 virtual bool addCodeEmitter(PassManagerBase &PM, bool Fast, 00083 bool DumpAsm, MachineCodeEmitter &MCE); 00084 virtual bool addSimpleCodeEmitter(PassManagerBase &PM, bool Fast, 00085 bool DumpAsm, MachineCodeEmitter &MCE); 00086 virtual bool getEnableTailMergeDefault() const; 00087 }; 00088 00089 /// PPC32TargetMachine - PowerPC 32-bit target machine. 00090 /// 00091 class PPC32TargetMachine : public PPCTargetMachine { 00092 public: 00093 PPC32TargetMachine(const Module &M, const std::string &FS); 00094 00095 static unsigned getJITMatchQuality(); 00096 static unsigned getModuleMatchQuality(const Module &M); 00097 }; 00098 00099 /// PPC64TargetMachine - PowerPC 64-bit target machine. 00100 /// 00101 class PPC64TargetMachine : public PPCTargetMachine { 00102 public: 00103 PPC64TargetMachine(const Module &M, const std::string &FS); 00104 00105 static unsigned getJITMatchQuality(); 00106 static unsigned getModuleMatchQuality(const Module &M); 00107 }; 00108 00109 } // end namespace llvm 00110 00111 #endif