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
|
|
|
|
//
|
2007-12-29 20:36:04 +00:00
|
|
|
// This file 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
|
|
|
|
2008-05-13 00:00:25 +00:00
|
|
|
// Register the target.
|
2008-10-14 20:25:08 +00:00
|
|
|
static RegisterTarget<SparcTargetMachine> X("sparc", "SPARC");
|
2004-07-11 02:48:49 +00:00
|
|
|
|
2009-06-19 15:48:10 +00:00
|
|
|
// No assembler printer by default
|
|
|
|
SparcTargetMachine::AsmPrinterCtorFn SparcTargetMachine::AsmPrinterCtor = 0;
|
|
|
|
|
|
|
|
|
2009-06-23 23:59:40 +00:00
|
|
|
// Force static initialization.
|
|
|
|
extern "C" void LLVMInitializeSparcTarget() { }
|
2009-06-16 20:12:29 +00:00
|
|
|
|
2006-09-07 23:39:26 +00:00
|
|
|
const TargetAsmInfo *SparcTargetMachine::createTargetAsmInfo() const {
|
2008-08-07 09:51:25 +00:00
|
|
|
// FIXME: Handle Solaris subtarget someday :)
|
|
|
|
return new SparcELFTargetAsmInfo(*this);
|
2006-09-07 23:39:26 +00:00
|
|
|
}
|
|
|
|
|
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)
|
2007-08-03 20:20:50 +00:00
|
|
|
: DataLayout("E-p:32:32-f128:128:128"),
|
2008-10-03 16:55:19 +00:00
|
|
|
Subtarget(M, FS), TLInfo(*this), 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
|
|
|
|
|
2007-07-11 16:32:10 +00:00
|
|
|
#if defined(__sparc__)
|
|
|
|
return 10;
|
|
|
|
#else
|
2005-12-16 06:06:07 +00:00
|
|
|
return 0;
|
2007-07-11 16:32:10 +00:00
|
|
|
#endif
|
2004-10-09 05:57:01 +00:00
|
|
|
}
|
|
|
|
|
2009-04-29 00:15:41 +00:00
|
|
|
bool SparcTargetMachine::addInstSelector(PassManagerBase &PM,
|
2009-04-29 23:29:43 +00:00
|
|
|
CodeGenOpt::Level OptLevel) {
|
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.
|
2009-04-29 23:29:43 +00:00
|
|
|
bool SparcTargetMachine::addPreEmitPass(PassManagerBase &PM,
|
|
|
|
CodeGenOpt::Level OptLevel){
|
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
|
|
|
|
2009-04-29 00:15:41 +00:00
|
|
|
bool SparcTargetMachine::addAssemblyEmitter(PassManagerBase &PM,
|
2009-04-29 23:29:43 +00:00
|
|
|
CodeGenOpt::Level OptLevel,
|
2009-04-29 00:15:41 +00:00
|
|
|
bool Verbose,
|
|
|
|
raw_ostream &Out) {
|
2004-03-04 19:22:16 +00:00
|
|
|
// Output assembly language.
|
2009-06-19 15:48:10 +00:00
|
|
|
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
|
|
|
|
if (AsmPrinterCtor)
|
2009-07-01 01:48:54 +00:00
|
|
|
PM.add(AsmPrinterCtor(Out, *this, Verbose));
|
2004-02-28 20:21:45 +00:00
|
|
|
return false;
|
2004-02-25 19:28:19 +00:00
|
|
|
}
|