LLVM API Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SparcTargetMachine.cpp
Go to the documentation of this file.
1 //===-- SparcTargetMachine.cpp - Define TargetMachine for Sparc -----------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "SparcTargetMachine.h"
14 #include "Sparc.h"
15 #include "llvm/CodeGen/Passes.h"
16 #include "llvm/PassManager.h"
18 using namespace llvm;
19 
20 extern "C" void LLVMInitializeSparcTarget() {
21  // Register the target.
24 }
25 
26 /// SparcTargetMachine ctor - Create an ILP32 architecture model
27 ///
29  StringRef CPU, StringRef FS,
30  const TargetOptions &Options,
33  bool is64bit)
34  : LLVMTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL),
35  Subtarget(TT, CPU, FS, is64bit),
36  DL(Subtarget.getDataLayout()),
37  InstrInfo(Subtarget),
38  TLInfo(*this), TSInfo(*this),
39  FrameLowering(Subtarget) {
40  initAsmInfo();
41 }
42 
43 namespace {
44 /// Sparc Code Generator Pass Configuration Options.
45 class SparcPassConfig : public TargetPassConfig {
46 public:
47  SparcPassConfig(SparcTargetMachine *TM, PassManagerBase &PM)
48  : TargetPassConfig(TM, PM) {}
49 
50  SparcTargetMachine &getSparcTargetMachine() const {
51  return getTM<SparcTargetMachine>();
52  }
53 
54  virtual bool addInstSelector();
55  virtual bool addPreEmitPass();
56 };
57 } // namespace
58 
60  return new SparcPassConfig(this, PM);
61 }
62 
63 bool SparcPassConfig::addInstSelector() {
64  addPass(createSparcISelDag(getSparcTargetMachine()));
65  return false;
66 }
67 
68 bool SparcTargetMachine::addCodeEmitter(PassManagerBase &PM,
69  JITCodeEmitter &JCE) {
70  // Machine code emitter pass for Sparc.
71  PM.add(createSparcJITCodeEmitterPass(*this, JCE));
72  return false;
73 }
74 
75 /// addPreEmitPass - This pass may be implemented by targets that want to run
76 /// passes immediately before machine code is emitted. This should return
77 /// true if -print-machineinstrs should print out the code after the passes.
78 bool SparcPassConfig::addPreEmitPass(){
79  addPass(createSparcDelaySlotFillerPass(getSparcTargetMachine()));
80  return true;
81 }
82 
83 void SparcV8TargetMachine::anchor() { }
84 
86  StringRef TT, StringRef CPU,
87  StringRef FS,
88  const TargetOptions &Options,
92  : SparcTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL, false) {
93 }
94 
95 void SparcV9TargetMachine::anchor() { }
96 
98  StringRef TT, StringRef CPU,
99  StringRef FS,
100  const TargetOptions &Options,
102  CodeModel::Model CM,
104  : SparcTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL, true) {
105 }
SparcTargetMachine(const Target &T, StringRef TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Reloc::Model RM, CodeModel::Model CM, CodeGenOpt::Level OL, bool is64bit)
FunctionPass * createSparcDelaySlotFillerPass(TargetMachine &TM)
void LLVMInitializeSparcTarget()
FunctionPass * createSparcJITCodeEmitterPass(SparcTargetMachine &TM, JITCodeEmitter &JCE)
SparcV8TargetMachine(const Target &T, StringRef TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Reloc::Model RM, CodeModel::Model CM, CodeGenOpt::Level OL)
Target TheSparcTarget
#define false
Definition: ConvertUTF.c:64
#define true
Definition: ConvertUTF.c:65
SparcV9TargetMachine(const Target &T, StringRef TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Reloc::Model RM, CodeModel::Model CM, CodeGenOpt::Level OL)
virtual TargetPassConfig * createPassConfig(PassManagerBase &PM)
FunctionPass * createSparcISelDag(SparcTargetMachine &TM)
Target TheSparcV9Target
virtual bool addCodeEmitter(PassManagerBase &PM, JITCodeEmitter &JCE)
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml","ocaml 3.10-compatible collector")
static RegisterPass< NVPTXAllocaHoisting > X("alloca-hoisting","Hoisting alloca instructions in non-entry ""blocks to the entry block")