LLVM API Documentation
00001 //===-- XCoreTargetMachine.cpp - Define TargetMachine for XCore -----------===// 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 // 00011 //===----------------------------------------------------------------------===// 00012 00013 #include "XCoreTargetMachine.h" 00014 #include "XCore.h" 00015 #include "llvm/CodeGen/Passes.h" 00016 #include "llvm/IR/Module.h" 00017 #include "llvm/PassManager.h" 00018 #include "llvm/Support/TargetRegistry.h" 00019 using namespace llvm; 00020 00021 /// XCoreTargetMachine ctor - Create an ILP32 architecture model 00022 /// 00023 XCoreTargetMachine::XCoreTargetMachine(const Target &T, StringRef TT, 00024 StringRef CPU, StringRef FS, 00025 const TargetOptions &Options, 00026 Reloc::Model RM, CodeModel::Model CM, 00027 CodeGenOpt::Level OL) 00028 : LLVMTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL), 00029 Subtarget(TT, CPU, FS, *this) { 00030 initAsmInfo(); 00031 } 00032 00033 namespace { 00034 /// XCore Code Generator Pass Configuration Options. 00035 class XCorePassConfig : public TargetPassConfig { 00036 public: 00037 XCorePassConfig(XCoreTargetMachine *TM, PassManagerBase &PM) 00038 : TargetPassConfig(TM, PM) {} 00039 00040 XCoreTargetMachine &getXCoreTargetMachine() const { 00041 return getTM<XCoreTargetMachine>(); 00042 } 00043 00044 bool addPreISel() override; 00045 bool addInstSelector() override; 00046 bool addPreEmitPass() override; 00047 }; 00048 } // namespace 00049 00050 TargetPassConfig *XCoreTargetMachine::createPassConfig(PassManagerBase &PM) { 00051 return new XCorePassConfig(this, PM); 00052 } 00053 00054 bool XCorePassConfig::addPreISel() { 00055 addPass(createXCoreLowerThreadLocalPass()); 00056 return false; 00057 } 00058 00059 bool XCorePassConfig::addInstSelector() { 00060 addPass(createXCoreISelDag(getXCoreTargetMachine(), getOptLevel())); 00061 return false; 00062 } 00063 00064 bool XCorePassConfig::addPreEmitPass() { 00065 addPass(createXCoreFrameToArgsOffsetEliminationPass()); 00066 return false; 00067 } 00068 00069 // Force static initialization. 00070 extern "C" void LLVMInitializeXCoreTarget() { 00071 RegisterTargetMachine<XCoreTargetMachine> X(TheXCoreTarget); 00072 } 00073 00074 void XCoreTargetMachine::addAnalysisPasses(PassManagerBase &PM) { 00075 // Add first the target-independent BasicTTI pass, then our XCore pass. This 00076 // allows the XCore pass to delegate to the target independent layer when 00077 // appropriate. 00078 PM.add(createBasicTargetTransformInfoPass(this)); 00079 PM.add(createXCoreTargetTransformInfoPass(this)); 00080 }