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"
23 // Register the target.
24 RegisterTarget<SparcTargetMachine> X("sparc", " SPARC");
27 const TargetAsmInfo *SparcTargetMachine::createTargetAsmInfo() const {
28 return new SparcTargetAsmInfo(*this);
31 /// SparcTargetMachine ctor - Create an ILP32 architecture model
33 SparcTargetMachine::SparcTargetMachine(const Module &M, const std::string &FS)
34 : DataLayout("E-p:32:32"),
35 Subtarget(M, FS), InstrInfo(Subtarget),
36 FrameInfo(TargetFrameInfo::StackGrowsDown, 8, 0) {
39 unsigned SparcTargetMachine::getModuleMatchQuality(const Module &M) {
40 std::string TT = M.getTargetTriple();
41 if (TT.size() >= 6 && std::string(TT.begin(), TT.begin()+6) == "sparc-")
44 if (M.getEndianness() == Module::BigEndian &&
45 M.getPointerSize() == Module::Pointer32)
47 return 20; // BE/32 ==> Prefer sparc on sparc
49 return 5; // BE/32 ==> Prefer ppc elsewhere
51 else if (M.getEndianness() != Module::AnyEndianness ||
52 M.getPointerSize() != Module::AnyPointerSize)
53 return 0; // Match for some other target
58 bool SparcTargetMachine::addInstSelector(FunctionPassManager &PM, bool Fast) {
59 PM.add(createSparcISelDag(*this));
63 /// addPreEmitPass - This pass may be implemented by targets that want to run
64 /// passes immediately before machine code is emitted. This should return
65 /// true if -print-machineinstrs should print out the code after the passes.
66 bool SparcTargetMachine::addPreEmitPass(FunctionPassManager &PM, bool Fast) {
67 PM.add(createSparcFPMoverPass(*this));
68 PM.add(createSparcDelaySlotFillerPass(*this));
72 bool SparcTargetMachine::addAssemblyEmitter(FunctionPassManager &PM, bool Fast,
74 // Output assembly language.
75 PM.add(createSparcCodePrinterPass(Out, *this));