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"
21 // Register the target.
22 static RegisterTarget<SparcTargetMachine> X("sparc", " SPARC");
24 const TargetAsmInfo *SparcTargetMachine::createTargetAsmInfo() const {
25 return new SparcTargetAsmInfo(*this);
28 /// SparcTargetMachine ctor - Create an ILP32 architecture model
30 SparcTargetMachine::SparcTargetMachine(const Module &M, const std::string &FS)
31 : DataLayout("E-p:32:32-f128:128:128"),
32 Subtarget(M, FS), InstrInfo(Subtarget),
33 FrameInfo(TargetFrameInfo::StackGrowsDown, 8, 0) {
36 unsigned SparcTargetMachine::getModuleMatchQuality(const Module &M) {
37 std::string TT = M.getTargetTriple();
38 if (TT.size() >= 6 && std::string(TT.begin(), TT.begin()+6) == "sparc-")
41 // If the target triple is something non-sparc, we don't match.
42 if (!TT.empty()) return 0;
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
55 #if defined(__sparc__)
62 bool SparcTargetMachine::addInstSelector(PassManagerBase &PM, bool Fast) {
63 PM.add(createSparcISelDag(*this));
67 /// addPreEmitPass - This pass may be implemented by targets that want to run
68 /// passes immediately before machine code is emitted. This should return
69 /// true if -print-machineinstrs should print out the code after the passes.
70 bool SparcTargetMachine::addPreEmitPass(PassManagerBase &PM, bool Fast) {
71 PM.add(createSparcFPMoverPass(*this));
72 PM.add(createSparcDelaySlotFillerPass(*this));
76 bool SparcTargetMachine::addAssemblyEmitter(PassManagerBase &PM, bool Fast,
78 // Output assembly language.
79 PM.add(createSparcCodePrinterPass(Out, *this));