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 "SPUTargetMachine.h"
|
2012-03-17 18:46:09 +00:00
|
|
|
#include "SPU.h"
|
2007-12-05 01:24:05 +00:00
|
|
|
#include "llvm/PassManager.h"
|
2008-12-10 00:15:19 +00:00
|
|
|
#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;
|
|
|
|
|
2012-02-03 05:12:41 +00:00
|
|
|
extern "C" void LLVMInitializeCellSPUTarget() {
|
2009-07-25 06:49:55 +00:00
|
|
|
// 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
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2012-02-03 05:12:41 +00:00
|
|
|
namespace {
|
|
|
|
/// SPU Code Generator Pass Configuration Options.
|
|
|
|
class SPUPassConfig : public TargetPassConfig {
|
|
|
|
public:
|
2012-02-04 02:56:59 +00:00
|
|
|
SPUPassConfig(SPUTargetMachine *TM, PassManagerBase &PM)
|
|
|
|
: TargetPassConfig(TM, PM) {}
|
2012-02-03 05:12:41 +00:00
|
|
|
|
|
|
|
SPUTargetMachine &getSPUTargetMachine() const {
|
|
|
|
return getTM<SPUTargetMachine>();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool addInstSelector();
|
|
|
|
virtual bool addPreEmitPass();
|
|
|
|
};
|
|
|
|
} // namespace
|
|
|
|
|
2012-02-04 02:56:59 +00:00
|
|
|
TargetPassConfig *SPUTargetMachine::createPassConfig(PassManagerBase &PM) {
|
|
|
|
return new SPUPassConfig(this, PM);
|
2012-02-03 05:12:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool SPUPassConfig::addInstSelector() {
|
2007-12-05 01:24:05 +00:00
|
|
|
// Install an instruction selector.
|
2012-07-02 19:48:31 +00:00
|
|
|
addPass(createSPUISelDag(getSPUTargetMachine()));
|
2007-12-05 01:24:05 +00:00
|
|
|
return false;
|
|
|
|
}
|
2011-01-11 09:07:54 +00:00
|
|
|
|
|
|
|
// passes to run just before printing the assembly
|
2012-02-03 05:12:41 +00:00
|
|
|
bool SPUPassConfig::addPreEmitPass() {
|
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)
|
2012-07-02 19:48:31 +00:00
|
|
|
addPass(schedulerCreator("cellspu"));
|
2011-08-19 10:50:24 +00:00
|
|
|
|
2011-01-11 09:07:54 +00:00
|
|
|
//align instructions with nops/lnops for dual issue
|
2012-07-02 19:48:31 +00:00
|
|
|
addPass(createSPUNopFillerPass(getSPUTargetMachine()));
|
2011-01-11 09:07:54 +00:00
|
|
|
return true;
|
|
|
|
}
|