1 //===-- SPUTargetMachine.cpp - Define TargetMachine for Cell SPU ----------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // Top-level implementation for the Cell SPU target.
12 //===----------------------------------------------------------------------===//
15 #include "SPUTargetMachine.h"
16 #include "llvm/PassManager.h"
17 #include "llvm/CodeGen/RegAllocRegistry.h"
18 #include "llvm/CodeGen/SchedulerRegistry.h"
19 #include "llvm/Support/DynamicLibrary.h"
20 #include "llvm/Support/TargetRegistry.h"
24 extern "C" void LLVMInitializeCellSPUTarget() {
25 // Register the target.
26 RegisterTargetMachine<SPUTargetMachine> X(TheCellSPUTarget);
29 const std::pair<unsigned, int> *
30 SPUFrameLowering::getCalleeSaveSpillSlots(unsigned &NumEntries) const {
35 SPUTargetMachine::SPUTargetMachine(const Target &T, StringRef TT,
36 StringRef CPU, StringRef FS,
37 const TargetOptions &Options,
38 Reloc::Model RM, CodeModel::Model CM,
40 : LLVMTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL),
41 Subtarget(TT, CPU, FS),
42 DataLayout(Subtarget.getTargetDataString()),
44 FrameLowering(Subtarget),
47 InstrItins(Subtarget.getInstrItineraryData()) {
50 //===----------------------------------------------------------------------===//
51 // Pass Pipeline Configuration
52 //===----------------------------------------------------------------------===//
54 bool SPUTargetMachine::addInstSelector(PassManagerBase &PM) {
55 // Install an instruction selector.
56 PM.add(createSPUISelDag(*this));
60 // passes to run just before printing the assembly
61 bool SPUTargetMachine::
62 addPreEmitPass(PassManagerBase &PM) {
63 // load the TCE instruction scheduler, if available via
65 typedef llvm::FunctionPass* (*BuilderFunc)(const char*);
66 BuilderFunc schedulerCreator =
67 (BuilderFunc)(intptr_t)sys::DynamicLibrary::SearchForAddressOfSymbol(
68 "createTCESchedulerPass");
69 if (schedulerCreator != NULL)
70 PM.add(schedulerCreator("cellspu"));
72 //align instructions with nops/lnops for dual issue
73 PM.add(createSPUNopFillerPass(*this));