LLVM API Documentation
00001 //===-- SPUTargetMachine.cpp - Define TargetMachine for Cell SPU ----------===// 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 // Top-level implementation for the Cell SPU target. 00011 // 00012 //===----------------------------------------------------------------------===// 00013 00014 #include "SPU.h" 00015 #include "SPURegisterNames.h" 00016 #include "SPUTargetAsmInfo.h" 00017 #include "SPUTargetMachine.h" 00018 #include "llvm/Module.h" 00019 #include "llvm/PassManager.h" 00020 #include "llvm/Target/TargetMachineRegistry.h" 00021 #include "llvm/CodeGen/RegAllocRegistry.h" 00022 #include "llvm/CodeGen/SchedulerRegistry.h" 00023 00024 using namespace llvm; 00025 00026 /// CellSPUTargetMachineModule - Note that this is used on hosts that 00027 /// cannot link in a library unless there are references into the 00028 /// library. In particular, it seems that it is not possible to get 00029 /// things to work on Win32 without this. Though it is unused, do not 00030 /// remove it. 00031 extern "C" int CellSPUTargetMachineModule; 00032 int CellSPUTargetMachineModule = 0; 00033 00034 namespace { 00035 // Register the targets 00036 RegisterTarget<SPUTargetMachine> 00037 CELLSPU("cellspu", "STI CBEA Cell SPU [experimental]"); 00038 } 00039 00040 const std::pair<unsigned, int> * 00041 SPUFrameInfo::getCalleeSaveSpillSlots(unsigned &NumEntries) const { 00042 NumEntries = 1; 00043 return &LR[0]; 00044 } 00045 00046 const TargetAsmInfo * 00047 SPUTargetMachine::createTargetAsmInfo() const 00048 { 00049 return new SPULinuxTargetAsmInfo(*this); 00050 } 00051 00052 unsigned 00053 SPUTargetMachine::getModuleMatchQuality(const Module &M) 00054 { 00055 // We strongly match "spu-*" or "cellspu-*". 00056 std::string TT = M.getTargetTriple(); 00057 if ((TT.size() == 3 && std::string(TT.begin(), TT.begin()+3) == "spu") 00058 || (TT.size() == 7 && std::string(TT.begin(), TT.begin()+7) == "cellspu") 00059 || (TT.size() >= 4 && std::string(TT.begin(), TT.begin()+4) == "spu-") 00060 || (TT.size() >= 8 && std::string(TT.begin(), TT.begin()+8) == "cellspu-")) 00061 return 20; 00062 00063 return 0; // No match at all... 00064 } 00065 00066 SPUTargetMachine::SPUTargetMachine(const Module &M, const std::string &FS) 00067 : Subtarget(*this, M, FS), 00068 DataLayout(Subtarget.getTargetDataString()), 00069 InstrInfo(*this), 00070 FrameInfo(*this), 00071 TLInfo(*this), 00072 InstrItins(Subtarget.getInstrItineraryData()) 00073 { 00074 // For the time being, use static relocations, since there's really no 00075 // support for PIC yet. 00076 setRelocationModel(Reloc::Static); 00077 } 00078 00079 //===----------------------------------------------------------------------===// 00080 // Pass Pipeline Configuration 00081 //===----------------------------------------------------------------------===// 00082 00083 bool 00084 SPUTargetMachine::addInstSelector(PassManagerBase &PM, bool Fast) 00085 { 00086 // Install an instruction selector. 00087 PM.add(createSPUISelDag(*this)); 00088 return false; 00089 } 00090 00091 bool SPUTargetMachine::addAssemblyEmitter(PassManagerBase &PM, bool Fast, 00092 raw_ostream &Out) { 00093 PM.add(createSPUAsmPrinterPass(Out, *this)); 00094 return false; 00095 }