1 //===-- SparcTargetMachine.cpp - Define TargetMachine for Sparc -----------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // 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-f128:128:128"),
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 the target triple is something non-sparc, we don't match.
44 if (!TT.empty()) return 0;
46 if (M.getEndianness() == Module::BigEndian &&
47 M.getPointerSize() == Module::Pointer32)
49 return 20; // BE/32 ==> Prefer sparc on sparc
51 return 5; // BE/32 ==> Prefer ppc elsewhere
53 else if (M.getEndianness() != Module::AnyEndianness ||
54 M.getPointerSize() != Module::AnyPointerSize)
55 return 0; // Match for some other target
57 #if defined(__sparc__)
64 bool SparcTargetMachine::addInstSelector(PassManagerBase &PM, bool Fast) {
65 PM.add(createSparcISelDag(*this));
69 /// addPreEmitPass - This pass may be implemented by targets that want to run
70 /// passes immediately before machine code is emitted. This should return
71 /// true if -print-machineinstrs should print out the code after the passes.
72 bool SparcTargetMachine::addPreEmitPass(PassManagerBase &PM, bool Fast) {
73 PM.add(createSparcFPMoverPass(*this));
74 PM.add(createSparcDelaySlotFillerPass(*this));
78 bool SparcTargetMachine::addAssemblyEmitter(PassManagerBase &PM, bool Fast,
80 // Output assembly language.
81 PM.add(createSparcCodePrinterPass(Out, *this));