2007-12-05 01:24:05 +00:00
|
|
|
//===-- SPUTargetMachine.cpp - Define TargetMachine for Cell SPU ----------===//
|
|
|
|
//
|
|
|
|
// 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.
|
2007-12-05 01:24:05 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// Top-level implementation for the Cell SPU target.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "SPU.h"
|
|
|
|
#include "SPUTargetMachine.h"
|
|
|
|
#include "llvm/PassManager.h"
|
2008-12-10 00:15:19 +00:00
|
|
|
#include "llvm/CodeGen/RegAllocRegistry.h"
|
|
|
|
#include "llvm/CodeGen/SchedulerRegistry.h"
|
2011-08-19 10:50:24 +00:00
|
|
|
#include "llvm/Support/DynamicLibrary.h"
|
2011-08-24 18:08:43 +00:00
|
|
|
#include "llvm/Support/TargetRegistry.h"
|
2007-12-05 01:24:05 +00:00
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
2009-07-25 06:49:55 +00:00
|
|
|
extern "C" void LLVMInitializeCellSPUTarget() {
|
|
|
|
// Register the target.
|
|
|
|
RegisterTargetMachine<SPUTargetMachine> X(TheCellSPUTarget);
|
2007-12-05 01:24:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const std::pair<unsigned, int> *
|
2011-01-10 12:39:04 +00:00
|
|
|
SPUFrameLowering::getCalleeSaveSpillSlots(unsigned &NumEntries) const {
|
2007-12-05 01:24:05 +00:00
|
|
|
NumEntries = 1;
|
|
|
|
return &LR[0];
|
|
|
|
}
|
|
|
|
|
2011-07-19 06:37:02 +00:00
|
|
|
SPUTargetMachine::SPUTargetMachine(const Target &T, StringRef TT,
|
2011-07-20 07:51:56 +00:00
|
|
|
StringRef CPU, StringRef FS,
|
2011-12-02 22:16:29 +00:00
|
|
|
const TargetOptions &Options,
|
2011-11-16 08:38:26 +00:00
|
|
|
Reloc::Model RM, CodeModel::Model CM,
|
|
|
|
CodeGenOpt::Level OL)
|
2011-12-02 22:16:29 +00:00
|
|
|
: LLVMTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL),
|
2011-06-30 01:53:36 +00:00
|
|
|
Subtarget(TT, CPU, FS),
|
2007-12-05 01:24:05 +00:00
|
|
|
DataLayout(Subtarget.getTargetDataString()),
|
|
|
|
InstrInfo(*this),
|
2011-01-10 12:39:04 +00:00
|
|
|
FrameLowering(Subtarget),
|
2007-12-05 01:24:05 +00:00
|
|
|
TLInfo(*this),
|
2010-05-11 17:31:57 +00:00
|
|
|
TSInfo(*this),
|
2009-08-02 04:44:33 +00:00
|
|
|
InstrItins(Subtarget.getInstrItineraryData()) {
|
2007-12-05 01:24:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Pass Pipeline Configuration
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2011-11-16 08:38:26 +00:00
|
|
|
bool SPUTargetMachine::addInstSelector(PassManagerBase &PM) {
|
2007-12-05 01:24:05 +00:00
|
|
|
// Install an instruction selector.
|
|
|
|
PM.add(createSPUISelDag(*this));
|
|
|
|
return false;
|
|
|
|
}
|
2011-01-11 09:07:54 +00:00
|
|
|
|
|
|
|
// passes to run just before printing the assembly
|
|
|
|
bool SPUTargetMachine::
|
2011-11-16 08:38:26 +00:00
|
|
|
addPreEmitPass(PassManagerBase &PM) {
|
2011-08-19 10:50:24 +00:00
|
|
|
// load the TCE instruction scheduler, if available via
|
|
|
|
// loaded plugins
|
|
|
|
typedef llvm::FunctionPass* (*BuilderFunc)(const char*);
|
2011-08-20 02:22:42 +00:00
|
|
|
BuilderFunc schedulerCreator =
|
|
|
|
(BuilderFunc)(intptr_t)sys::DynamicLibrary::SearchForAddressOfSymbol(
|
2011-08-19 10:50:24 +00:00
|
|
|
"createTCESchedulerPass");
|
|
|
|
if (schedulerCreator != NULL)
|
|
|
|
PM.add(schedulerCreator("cellspu"));
|
|
|
|
|
2011-01-11 09:07:54 +00:00
|
|
|
//align instructions with nops/lnops for dual issue
|
|
|
|
PM.add(createSPUNopFillerPass(*this));
|
|
|
|
return true;
|
|
|
|
}
|