LLVM API Documentation
00001 //===-- SparcTargetMachine.cpp - Define TargetMachine for Sparc -----------===// 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 "SparcTargetAsmInfo.h" 00014 #include "SparcTargetMachine.h" 00015 #include "Sparc.h" 00016 #include "llvm/Module.h" 00017 #include "llvm/PassManager.h" 00018 #include "llvm/Target/TargetMachineRegistry.h" 00019 using namespace llvm; 00020 00021 /// SparcTargetMachineModule - Note that this is used on hosts that 00022 /// cannot link in a library unless there are references into the 00023 /// library. In particular, it seems that it is not possible to get 00024 /// things to work on Win32 without this. Though it is unused, do not 00025 /// remove it. 00026 extern "C" int SparcTargetMachineModule; 00027 int SparcTargetMachineModule = 0; 00028 00029 // Register the target. 00030 static RegisterTarget<SparcTargetMachine> X("sparc", "SPARC"); 00031 00032 const TargetAsmInfo *SparcTargetMachine::createTargetAsmInfo() const { 00033 // FIXME: Handle Solaris subtarget someday :) 00034 return new SparcELFTargetAsmInfo(*this); 00035 } 00036 00037 /// SparcTargetMachine ctor - Create an ILP32 architecture model 00038 /// 00039 SparcTargetMachine::SparcTargetMachine(const Module &M, const std::string &FS) 00040 : DataLayout("E-p:32:32-f128:128:128"), 00041 Subtarget(M, FS), TLInfo(*this), InstrInfo(Subtarget), 00042 FrameInfo(TargetFrameInfo::StackGrowsDown, 8, 0) { 00043 } 00044 00045 unsigned SparcTargetMachine::getModuleMatchQuality(const Module &M) { 00046 std::string TT = M.getTargetTriple(); 00047 if (TT.size() >= 6 && std::string(TT.begin(), TT.begin()+6) == "sparc-") 00048 return 20; 00049 00050 // If the target triple is something non-sparc, we don't match. 00051 if (!TT.empty()) return 0; 00052 00053 if (M.getEndianness() == Module::BigEndian && 00054 M.getPointerSize() == Module::Pointer32) 00055 #ifdef __sparc__ 00056 return 20; // BE/32 ==> Prefer sparc on sparc 00057 #else 00058 return 5; // BE/32 ==> Prefer ppc elsewhere 00059 #endif 00060 else if (M.getEndianness() != Module::AnyEndianness || 00061 M.getPointerSize() != Module::AnyPointerSize) 00062 return 0; // Match for some other target 00063 00064 #if defined(__sparc__) 00065 return 10; 00066 #else 00067 return 0; 00068 #endif 00069 } 00070 00071 bool SparcTargetMachine::addInstSelector(PassManagerBase &PM, bool Fast) { 00072 PM.add(createSparcISelDag(*this)); 00073 return false; 00074 } 00075 00076 /// addPreEmitPass - This pass may be implemented by targets that want to run 00077 /// passes immediately before machine code is emitted. This should return 00078 /// true if -print-machineinstrs should print out the code after the passes. 00079 bool SparcTargetMachine::addPreEmitPass(PassManagerBase &PM, bool Fast) { 00080 PM.add(createSparcFPMoverPass(*this)); 00081 PM.add(createSparcDelaySlotFillerPass(*this)); 00082 return true; 00083 } 00084 00085 bool SparcTargetMachine::addAssemblyEmitter(PassManagerBase &PM, bool Fast, 00086 raw_ostream &Out) { 00087 // Output assembly language. 00088 PM.add(createSparcCodePrinterPass(Out, *this)); 00089 return false; 00090 }
This web site is hosted by the Computer Science Department at the University of Illinois at Urbana-Champaign.