1 //===-- SparcTargetMachine.cpp - Define TargetMachine for Sparc -----------===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 //===----------------------------------------------------------------------===//
13 #include "SparcTargetAsmInfo.h"
14 #include "SparcTargetMachine.h"
16 #include "llvm/Module.h"
17 #include "llvm/PassManager.h"
18 #include "llvm/Target/TargetMachineRegistry.h"
22 // Register the target.
23 RegisterTarget<SparcTargetMachine> X("sparc", " SPARC");
26 const TargetAsmInfo *SparcTargetMachine::createTargetAsmInfo() const {
27 return new SparcTargetAsmInfo(*this);
30 /// SparcTargetMachine ctor - Create an ILP32 architecture model
32 SparcTargetMachine::SparcTargetMachine(const Module &M, const std::string &FS)
33 : DataLayout("E-p:32:32"),
34 Subtarget(M, FS), InstrInfo(Subtarget),
35 FrameInfo(TargetFrameInfo::StackGrowsDown, 8, 0) {
38 unsigned SparcTargetMachine::getModuleMatchQuality(const Module &M) {
39 std::string TT = M.getTargetTriple();
40 if (TT.size() >= 6 && std::string(TT.begin(), TT.begin()+6) == "sparc-")
43 if (M.getEndianness() == Module::BigEndian &&
44 M.getPointerSize() == Module::Pointer32)
46 return 20; // BE/32 ==> Prefer sparc on sparc
48 return 5; // BE/32 ==> Prefer ppc elsewhere
50 else if (M.getEndianness() != Module::AnyEndianness ||
51 M.getPointerSize() != Module::AnyPointerSize)
52 return 0; // Match for some other target
57 bool SparcTargetMachine::addInstSelector(FunctionPassManager &PM, bool Fast) {
58 PM.add(createSparcISelDag(*this));
62 /// addPreEmitPass - This pass may be implemented by targets that want to run
63 /// passes immediately before machine code is emitted. This should return
64 /// true if -print-machineinstrs should print out the code after the passes.
65 bool SparcTargetMachine::addPreEmitPass(FunctionPassManager &PM, bool Fast) {
66 PM.add(createSparcFPMoverPass(*this));
67 PM.add(createSparcDelaySlotFillerPass(*this));
71 bool SparcTargetMachine::addAssemblyEmitter(FunctionPassManager &PM, bool Fast,
73 // Output assembly language.
74 PM.add(createSparcCodePrinterPass(Out, *this));