1 //===-- SparcTargetMachine.cpp - Define TargetMachine for Sparc -----------===//
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 //===----------------------------------------------------------------------===//
11 //===----------------------------------------------------------------------===//
13 #include "SparcTargetMachine.h"
15 #include "llvm/PassManager.h"
16 #include "llvm/CodeGen/Passes.h"
17 #include "llvm/Support/TargetRegistry.h"
20 extern "C" void LLVMInitializeSparcTarget() {
21 // Register the target.
22 RegisterTargetMachine<SparcV8TargetMachine> X(TheSparcTarget);
23 RegisterTargetMachine<SparcV9TargetMachine> Y(TheSparcV9Target);
26 /// SparcTargetMachine ctor - Create an ILP32 architecture model
28 SparcTargetMachine::SparcTargetMachine(const Target &T, StringRef TT,
29 StringRef CPU, StringRef FS,
30 const TargetOptions &Options,
31 Reloc::Model RM, CodeModel::Model CM,
34 : LLVMTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL),
35 Subtarget(TT, CPU, FS, is64bit),
36 DataLayout(Subtarget.getDataLayout()),
38 TLInfo(*this), TSInfo(*this),
39 FrameLowering(Subtarget) {
43 /// Sparc Code Generator Pass Configuration Options.
44 class SparcPassConfig : public TargetPassConfig {
46 SparcPassConfig(SparcTargetMachine *TM, PassManagerBase &PM)
47 : TargetPassConfig(TM, PM) {}
49 SparcTargetMachine &getSparcTargetMachine() const {
50 return getTM<SparcTargetMachine>();
53 virtual bool addInstSelector();
54 virtual bool addPreEmitPass();
58 TargetPassConfig *SparcTargetMachine::createPassConfig(PassManagerBase &PM) {
59 return new SparcPassConfig(this, PM);
62 bool SparcPassConfig::addInstSelector() {
63 addPass(createSparcISelDag(getSparcTargetMachine()));
67 /// addPreEmitPass - This pass may be implemented by targets that want to run
68 /// passes immediately before machine code is emitted. This should return
69 /// true if -print-machineinstrs should print out the code after the passes.
70 bool SparcPassConfig::addPreEmitPass(){
71 addPass(createSparcFPMoverPass(getSparcTargetMachine()));
72 addPass(createSparcDelaySlotFillerPass(getSparcTargetMachine()));
76 void SparcV8TargetMachine::anchor() { }
78 SparcV8TargetMachine::SparcV8TargetMachine(const Target &T,
79 StringRef TT, StringRef CPU,
81 const TargetOptions &Options,
85 : SparcTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL, false) {
88 void SparcV9TargetMachine::anchor() { }
90 SparcV9TargetMachine::SparcV9TargetMachine(const Target &T,
91 StringRef TT, StringRef CPU,
93 const TargetOptions &Options,
97 : SparcTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL, true) {