2006-02-05 05:50:24 +00:00
|
|
|
//===-- SparcTargetMachine.cpp - Define TargetMachine for Sparc -----------===//
|
2005-04-21 23:30:14 +00:00
|
|
|
//
|
2004-02-25 19:28:19 +00:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file was developed by the LLVM research group and is distributed under
|
|
|
|
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
2005-04-21 23:30:14 +00:00
|
|
|
//
|
2004-02-25 19:28:19 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
2005-04-21 23:30:14 +00:00
|
|
|
//
|
2004-02-25 19:28:19 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2006-09-07 23:39:26 +00:00
|
|
|
#include "SparcTargetAsmInfo.h"
|
2006-02-05 05:50:24 +00:00
|
|
|
#include "SparcTargetMachine.h"
|
|
|
|
#include "Sparc.h"
|
2004-02-25 19:28:19 +00:00
|
|
|
#include "llvm/Module.h"
|
|
|
|
#include "llvm/PassManager.h"
|
2004-07-11 02:48:49 +00:00
|
|
|
#include "llvm/Target/TargetMachineRegistry.h"
|
2004-02-28 19:52:49 +00:00
|
|
|
using namespace llvm;
|
2004-02-25 19:28:19 +00:00
|
|
|
|
2004-07-11 02:48:49 +00:00
|
|
|
namespace {
|
|
|
|
// Register the target.
|
2006-02-05 05:50:24 +00:00
|
|
|
RegisterTarget<SparcTargetMachine> X("sparc", " SPARC");
|
2004-07-11 02:48:49 +00:00
|
|
|
}
|
|
|
|
|
2006-09-07 23:39:26 +00:00
|
|
|
const TargetAsmInfo *SparcTargetMachine::createTargetAsmInfo() const {
|
|
|
|
return new SparcTargetAsmInfo(*this);
|
|
|
|
}
|
|
|
|
|
2006-02-05 05:50:24 +00:00
|
|
|
/// SparcTargetMachine ctor - Create an ILP32 architecture model
|
2004-02-25 19:28:19 +00:00
|
|
|
///
|
2006-03-23 05:43:16 +00:00
|
|
|
SparcTargetMachine::SparcTargetMachine(const Module &M, const std::string &FS)
|
2006-09-03 18:44:02 +00:00
|
|
|
: DataLayout("E-p:32:32"),
|
2006-02-04 06:58:46 +00:00
|
|
|
Subtarget(M, FS), InstrInfo(Subtarget),
|
2005-12-16 06:06:07 +00:00
|
|
|
FrameInfo(TargetFrameInfo::StackGrowsDown, 8, 0) {
|
2004-10-09 05:57:01 +00:00
|
|
|
}
|
|
|
|
|
2006-02-05 05:50:24 +00:00
|
|
|
unsigned SparcTargetMachine::getModuleMatchQuality(const Module &M) {
|
2004-12-12 17:40:28 +00:00
|
|
|
std::string TT = M.getTargetTriple();
|
|
|
|
if (TT.size() >= 6 && std::string(TT.begin(), TT.begin()+6) == "sparc-")
|
|
|
|
return 20;
|
2007-07-09 17:25:29 +00:00
|
|
|
|
|
|
|
// If the target triple is something non-sparc, we don't match.
|
|
|
|
if (!TT.empty()) return 0;
|
2004-12-12 17:40:28 +00:00
|
|
|
|
2004-10-09 05:57:01 +00:00
|
|
|
if (M.getEndianness() == Module::BigEndian &&
|
|
|
|
M.getPointerSize() == Module::Pointer32)
|
|
|
|
#ifdef __sparc__
|
2006-02-05 05:50:24 +00:00
|
|
|
return 20; // BE/32 ==> Prefer sparc on sparc
|
2004-10-09 05:57:01 +00:00
|
|
|
#else
|
|
|
|
return 5; // BE/32 ==> Prefer ppc elsewhere
|
|
|
|
#endif
|
|
|
|
else if (M.getEndianness() != Module::AnyEndianness ||
|
|
|
|
M.getPointerSize() != Module::AnyPointerSize)
|
|
|
|
return 0; // Match for some other target
|
|
|
|
|
2005-12-16 06:06:07 +00:00
|
|
|
return 0;
|
2004-10-09 05:57:01 +00:00
|
|
|
}
|
|
|
|
|
2006-09-04 04:14:57 +00:00
|
|
|
bool SparcTargetMachine::addInstSelector(FunctionPassManager &PM, bool Fast) {
|
2006-02-05 05:50:24 +00:00
|
|
|
PM.add(createSparcISelDag(*this));
|
2006-09-04 04:14:57 +00:00
|
|
|
return false;
|
|
|
|
}
|
2004-02-29 00:27:00 +00:00
|
|
|
|
2006-09-04 04:14:57 +00:00
|
|
|
/// addPreEmitPass - This pass may be implemented by targets that want to run
|
|
|
|
/// passes immediately before machine code is emitted. This should return
|
|
|
|
/// true if -print-machineinstrs should print out the code after the passes.
|
|
|
|
bool SparcTargetMachine::addPreEmitPass(FunctionPassManager &PM, bool Fast) {
|
2006-02-05 05:50:24 +00:00
|
|
|
PM.add(createSparcFPMoverPass(*this));
|
|
|
|
PM.add(createSparcDelaySlotFillerPass(*this));
|
2006-09-04 04:14:57 +00:00
|
|
|
return true;
|
|
|
|
}
|
2004-04-06 23:21:24 +00:00
|
|
|
|
2006-09-04 04:14:57 +00:00
|
|
|
bool SparcTargetMachine::addAssemblyEmitter(FunctionPassManager &PM, bool Fast,
|
|
|
|
std::ostream &Out) {
|
2004-03-04 19:22:16 +00:00
|
|
|
// Output assembly language.
|
2006-02-05 05:50:24 +00:00
|
|
|
PM.add(createSparcCodePrinterPass(Out, *this));
|
2004-02-28 20:21:45 +00:00
|
|
|
return false;
|
2004-02-25 19:28:19 +00:00
|
|
|
}
|