2006-02-05 06:50:24 +01:00
|
|
|
//===-- SparcTargetMachine.cpp - Define TargetMachine for Sparc -----------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 21:36:04 +01:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2006-02-05 06:50:24 +01:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2006-09-08 01:39:26 +02:00
|
|
|
#include "SparcTargetAsmInfo.h"
|
2006-02-05 06:50:24 +01:00
|
|
|
#include "SparcTargetMachine.h"
|
|
|
|
#include "Sparc.h"
|
|
|
|
#include "llvm/Module.h"
|
|
|
|
#include "llvm/PassManager.h"
|
|
|
|
#include "llvm/Target/TargetMachineRegistry.h"
|
|
|
|
using namespace llvm;
|
|
|
|
|
2008-05-13 02:00:25 +02:00
|
|
|
// Register the target.
|
2009-07-15 19:27:11 +02:00
|
|
|
static RegisterTarget<SparcTargetMachine> X("sparc", "SPARC");
|
2006-02-05 06:50:24 +01:00
|
|
|
|
2009-06-19 17:48:10 +02:00
|
|
|
// No assembler printer by default
|
|
|
|
SparcTargetMachine::AsmPrinterCtorFn SparcTargetMachine::AsmPrinterCtor = 0;
|
|
|
|
|
|
|
|
|
2009-06-24 01:59:40 +02:00
|
|
|
// Force static initialization.
|
|
|
|
extern "C" void LLVMInitializeSparcTarget() { }
|
2009-06-16 22:12:29 +02:00
|
|
|
|
2006-09-08 01:39:26 +02:00
|
|
|
const TargetAsmInfo *SparcTargetMachine::createTargetAsmInfo() const {
|
2008-08-07 11:51:25 +02:00
|
|
|
// FIXME: Handle Solaris subtarget someday :)
|
|
|
|
return new SparcELFTargetAsmInfo(*this);
|
2006-09-08 01:39:26 +02:00
|
|
|
}
|
|
|
|
|
2006-02-05 06:50:24 +01:00
|
|
|
/// SparcTargetMachine ctor - Create an ILP32 architecture model
|
|
|
|
///
|
2009-07-15 19:27:11 +02:00
|
|
|
SparcTargetMachine::SparcTargetMachine(const Module &M, const std::string &FS)
|
|
|
|
: DataLayout("E-p:32:32-f128:128:128"),
|
2008-10-03 18:55:19 +02:00
|
|
|
Subtarget(M, FS), TLInfo(*this), InstrInfo(Subtarget),
|
2006-02-05 06:50:24 +01:00
|
|
|
FrameInfo(TargetFrameInfo::StackGrowsDown, 8, 0) {
|
|
|
|
}
|
|
|
|
|
2009-07-15 19:27:11 +02:00
|
|
|
unsigned SparcTargetMachine::getModuleMatchQuality(const Module &M) {
|
|
|
|
std::string TT = M.getTargetTriple();
|
|
|
|
if (TT.size() >= 6 && std::string(TT.begin(), TT.begin()+6) == "sparc-")
|
|
|
|
return 20;
|
|
|
|
|
|
|
|
// If the target triple is something non-sparc, we don't match.
|
|
|
|
if (!TT.empty()) return 0;
|
|
|
|
|
|
|
|
if (M.getEndianness() == Module::BigEndian &&
|
|
|
|
M.getPointerSize() == Module::Pointer32)
|
|
|
|
#ifdef __sparc__
|
|
|
|
return 20; // BE/32 ==> Prefer sparc on sparc
|
|
|
|
#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
|
|
|
|
|
|
|
|
#if defined(__sparc__)
|
|
|
|
return 10;
|
|
|
|
#else
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2009-04-29 02:15:41 +02:00
|
|
|
bool SparcTargetMachine::addInstSelector(PassManagerBase &PM,
|
2009-04-30 01:29:43 +02:00
|
|
|
CodeGenOpt::Level OptLevel) {
|
2006-02-05 06:50:24 +01:00
|
|
|
PM.add(createSparcISelDag(*this));
|
2006-09-04 06:14:57 +02:00
|
|
|
return false;
|
|
|
|
}
|
2006-02-05 06:50:24 +01:00
|
|
|
|
2006-09-04 06:14:57 +02: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-30 01:29:43 +02:00
|
|
|
bool SparcTargetMachine::addPreEmitPass(PassManagerBase &PM,
|
|
|
|
CodeGenOpt::Level OptLevel){
|
2006-02-05 06:50:24 +01:00
|
|
|
PM.add(createSparcFPMoverPass(*this));
|
|
|
|
PM.add(createSparcDelaySlotFillerPass(*this));
|
2006-09-04 06:14:57 +02:00
|
|
|
return true;
|
|
|
|
}
|
2006-02-05 06:50:24 +01:00
|
|
|
|
2009-04-29 02:15:41 +02:00
|
|
|
bool SparcTargetMachine::addAssemblyEmitter(PassManagerBase &PM,
|
2009-04-30 01:29:43 +02:00
|
|
|
CodeGenOpt::Level OptLevel,
|
2009-04-29 02:15:41 +02:00
|
|
|
bool Verbose,
|
2009-07-14 22:18:05 +02:00
|
|
|
formatted_raw_ostream &Out) {
|
2006-02-05 06:50:24 +01:00
|
|
|
// Output assembly language.
|
2009-06-19 17:48:10 +02:00
|
|
|
assert(AsmPrinterCtor && "AsmPrinter was not linked in");
|
|
|
|
if (AsmPrinterCtor)
|
2009-07-01 03:48:54 +02:00
|
|
|
PM.add(AsmPrinterCtor(Out, *this, Verbose));
|
2006-02-05 06:50:24 +01:00
|
|
|
return false;
|
|
|
|
}
|