LLVM API Documentation
00001 //===-- ARMTargetMachine.h - Define TargetMachine for ARM -------*- 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 ARM specific subclass of TargetMachine. 00011 // 00012 //===----------------------------------------------------------------------===// 00013 00014 #ifndef ARMTARGETMACHINE_H 00015 #define ARMTARGETMACHINE_H 00016 00017 #include "llvm/Target/TargetMachine.h" 00018 #include "llvm/Target/TargetData.h" 00019 #include "ARMInstrInfo.h" 00020 #include "ARMFrameInfo.h" 00021 #include "ARMJITInfo.h" 00022 #include "ARMSubtarget.h" 00023 #include "ARMISelLowering.h" 00024 #include "Thumb1InstrInfo.h" 00025 #include "Thumb2InstrInfo.h" 00026 00027 namespace llvm { 00028 00029 class ARMBaseTargetMachine : public LLVMTargetMachine { 00030 protected: 00031 ARMSubtarget Subtarget; 00032 00033 private: 00034 ARMFrameInfo FrameInfo; 00035 ARMJITInfo JITInfo; 00036 InstrItineraryData InstrItins; 00037 Reloc::Model DefRelocModel; // Reloc model before it's overridden. 00038 00039 public: 00040 ARMBaseTargetMachine(const Target &T, const std::string &TT, 00041 const std::string &FS, bool isThumb); 00042 00043 virtual const ARMFrameInfo *getFrameInfo() const { return &FrameInfo; } 00044 virtual ARMJITInfo *getJITInfo() { return &JITInfo; } 00045 virtual const ARMSubtarget *getSubtargetImpl() const { return &Subtarget; } 00046 virtual const InstrItineraryData getInstrItineraryData() const { 00047 return InstrItins; 00048 } 00049 00050 // Pass Pipeline Configuration 00051 virtual bool addInstSelector(PassManagerBase &PM, CodeGenOpt::Level OptLevel); 00052 virtual bool addPreRegAlloc(PassManagerBase &PM, CodeGenOpt::Level OptLevel); 00053 virtual bool addPreEmitPass(PassManagerBase &PM, CodeGenOpt::Level OptLevel); 00054 virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel, 00055 MachineCodeEmitter &MCE); 00056 virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel, 00057 JITCodeEmitter &MCE); 00058 virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel, 00059 ObjectCodeEmitter &OCE); 00060 virtual bool addSimpleCodeEmitter(PassManagerBase &PM, 00061 CodeGenOpt::Level OptLevel, 00062 MachineCodeEmitter &MCE); 00063 virtual bool addSimpleCodeEmitter(PassManagerBase &PM, 00064 CodeGenOpt::Level OptLevel, 00065 JITCodeEmitter &MCE); 00066 virtual bool addSimpleCodeEmitter(PassManagerBase &PM, 00067 CodeGenOpt::Level OptLevel, 00068 ObjectCodeEmitter &OCE); 00069 }; 00070 00071 /// ARMTargetMachine - ARM target machine. 00072 /// 00073 class ARMTargetMachine : public ARMBaseTargetMachine { 00074 ARMInstrInfo InstrInfo; 00075 const TargetData DataLayout; // Calculates type size & alignment 00076 ARMTargetLowering TLInfo; 00077 public: 00078 ARMTargetMachine(const Target &T, const std::string &TT, 00079 const std::string &FS); 00080 00081 virtual const ARMRegisterInfo *getRegisterInfo() const { 00082 return &InstrInfo.getRegisterInfo(); 00083 } 00084 00085 virtual ARMTargetLowering *getTargetLowering() const { 00086 return const_cast<ARMTargetLowering*>(&TLInfo); 00087 } 00088 00089 virtual const ARMInstrInfo *getInstrInfo() const { return &InstrInfo; } 00090 virtual const TargetData *getTargetData() const { return &DataLayout; } 00091 }; 00092 00093 /// ThumbTargetMachine - Thumb target machine. 00094 /// Due to the way architectures are handled, this represents both 00095 /// Thumb-1 and Thumb-2. 00096 /// 00097 class ThumbTargetMachine : public ARMBaseTargetMachine { 00098 ARMBaseInstrInfo *InstrInfo; // either Thumb1InstrInfo or Thumb2InstrInfo 00099 const TargetData DataLayout; // Calculates type size & alignment 00100 ARMTargetLowering TLInfo; 00101 public: 00102 ThumbTargetMachine(const Target &T, const std::string &TT, 00103 const std::string &FS); 00104 00105 /// returns either Thumb1RegisterInfo of Thumb2RegisterInfo 00106 virtual const ARMBaseRegisterInfo *getRegisterInfo() const { 00107 return &InstrInfo->getRegisterInfo(); 00108 } 00109 00110 virtual ARMTargetLowering *getTargetLowering() const { 00111 return const_cast<ARMTargetLowering*>(&TLInfo); 00112 } 00113 00114 /// returns either Thumb1InstrInfo or Thumb2InstrInfo 00115 virtual const ARMBaseInstrInfo *getInstrInfo() const { return InstrInfo; } 00116 virtual const TargetData *getTargetData() const { return &DataLayout; } 00117 }; 00118 00119 } // end namespace llvm 00120 00121 #endif