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-11-15 22:36:30 +01:00
|
|
|
/// SparcTargetMachineModule - Note that this is used on hosts that
|
|
|
|
/// cannot link in a library unless there are references into the
|
|
|
|
/// library. In particular, it seems that it is not possible to get
|
|
|
|
/// things to work on Win32 without this. Though it is unused, do not
|
|
|
|
/// remove it.
|
|
|
|
extern "C" int SparcTargetMachineModule;
|
|
|
|
int SparcTargetMachineModule = 0;
|
|
|
|
|
2008-05-13 02:00:25 +02:00
|
|
|
// Register the target.
|
2008-10-14 22:25:08 +02:00
|
|
|
static RegisterTarget<SparcTargetMachine> X("sparc", "SPARC");
|
2006-02-05 06:50:24 +01: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
|
|
|
|
///
|
2006-03-23 06:43:16 +01:00
|
|
|
SparcTargetMachine::SparcTargetMachine(const Module &M, const std::string &FS)
|
2007-08-03 22:20:50 +02:00
|
|
|
: 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) {
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2007-07-09 19:25:29 +02:00
|
|
|
|
|
|
|
// If the target triple is something non-sparc, we don't match.
|
|
|
|
if (!TT.empty()) return 0;
|
2006-02-05 06:50:24 +01:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2007-07-11 18:32:10 +02:00
|
|
|
#if defined(__sparc__)
|
|
|
|
return 10;
|
|
|
|
#else
|
2006-02-05 06:50:24 +01:00
|
|
|
return 0;
|
2007-07-11 18:32:10 +02:00
|
|
|
#endif
|
2006-02-05 06:50:24 +01:00
|
|
|
}
|
|
|
|
|
2009-04-29 02:15:41 +02:00
|
|
|
bool SparcTargetMachine::addInstSelector(PassManagerBase &PM,
|
|
|
|
unsigned 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-29 02:15:41 +02:00
|
|
|
bool SparcTargetMachine::addPreEmitPass(PassManagerBase &PM, unsigned 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,
|
|
|
|
unsigned OptLevel,
|
|
|
|
bool Verbose,
|
|
|
|
raw_ostream &Out) {
|
2006-02-05 06:50:24 +01:00
|
|
|
// Output assembly language.
|
2009-04-29 02:15:41 +02:00
|
|
|
PM.add(createSparcCodePrinterPass(Out, *this, OptLevel, Verbose));
|
2006-02-05 06:50:24 +01:00
|
|
|
return false;
|
|
|
|
}
|