SparcTargetMachine.cpp revision f05522974b3c1b9dc2644831364e19d5132e751b
1//===-- SparcTargetMachine.cpp - Define TargetMachine for Sparc -----------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9// 10// 11//===----------------------------------------------------------------------===// 12 13#include "SparcTargetAsmInfo.h" 14#include "SparcTargetMachine.h" 15#include "Sparc.h" 16#include "llvm/Module.h" 17#include "llvm/PassManager.h" 18#include "llvm/Target/TargetMachineRegistry.h" 19using namespace llvm; 20 21// Register the target. 22extern Target TheSparcTarget; 23static RegisterTarget<SparcTargetMachine> X(TheSparcTarget, "sparc", "SPARC"); 24 25// Force static initialization. 26extern "C" void LLVMInitializeSparcTarget() { } 27 28const TargetAsmInfo *SparcTargetMachine::createTargetAsmInfo() const { 29 // FIXME: Handle Solaris subtarget someday :) 30 return new SparcELFTargetAsmInfo(*this); 31} 32 33/// SparcTargetMachine ctor - Create an ILP32 architecture model 34/// 35SparcTargetMachine::SparcTargetMachine(const Target &T, const Module &M, 36 const std::string &FS) 37 : LLVMTargetMachine(T), 38 DataLayout("E-p:32:32-f128:128:128"), 39 Subtarget(M, FS), TLInfo(*this), InstrInfo(Subtarget), 40 FrameInfo(TargetFrameInfo::StackGrowsDown, 8, 0) { 41} 42 43bool SparcTargetMachine::addInstSelector(PassManagerBase &PM, 44 CodeGenOpt::Level OptLevel) { 45 PM.add(createSparcISelDag(*this)); 46 return false; 47} 48 49/// addPreEmitPass - This pass may be implemented by targets that want to run 50/// passes immediately before machine code is emitted. This should return 51/// true if -print-machineinstrs should print out the code after the passes. 52bool SparcTargetMachine::addPreEmitPass(PassManagerBase &PM, 53 CodeGenOpt::Level OptLevel){ 54 PM.add(createSparcFPMoverPass(*this)); 55 PM.add(createSparcDelaySlotFillerPass(*this)); 56 return true; 57} 58 59bool SparcTargetMachine::addAssemblyEmitter(PassManagerBase &PM, 60 CodeGenOpt::Level OptLevel, 61 bool Verbose, 62 formatted_raw_ostream &Out) { 63 FunctionPass *Printer = getTarget().createAsmPrinter(Out, *this, Verbose); 64 if (!Printer) 65 llvm_report_error("unable to create assembly printer"); 66 PM.add(Printer); 67 return false; 68} 69