1b5b80abdbc9ece975f559c84ed251c9de328514
[oota-llvm.git] / lib / Target / Sparc / SparcTargetMachine.cpp
1 //===-- SparcV8TargetMachine.cpp - Define TargetMachine for SparcV8 -------===//
2 // 
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 // 
8 //===----------------------------------------------------------------------===//
9 // 
10 //
11 //===----------------------------------------------------------------------===//
12
13 #include "SparcV8TargetMachine.h"
14 #include "SparcV8.h"
15 #include "llvm/Module.h"
16 #include "llvm/PassManager.h"
17 #include "llvm/Target/TargetMachineImpls.h"
18 #include "llvm/CodeGen/MachineFunction.h"
19 #include "llvm/CodeGen/Passes.h"
20 using namespace llvm;
21
22 // allocateSparcV8TargetMachine - Allocate and return a subclass of 
23 // TargetMachine that implements the SparcV8 backend.
24 //
25 TargetMachine *llvm::allocateSparcV8TargetMachine(const Module &M,
26                                                   IntrinsicLowering *IL) {
27   return new SparcV8TargetMachine(M, IL);
28 }
29
30 /// SparcV8TargetMachine ctor - Create an ILP32 architecture model
31 ///
32 SparcV8TargetMachine::SparcV8TargetMachine(const Module &M,
33                                            IntrinsicLowering *IL)
34   : TargetMachine("SparcV8", IL, true, 4, 4, 4, 4, 4),
35     FrameInfo(TargetFrameInfo::StackGrowsDown, 8, 4), JITInfo(*this) {
36 }
37
38 /// addPassesToEmitAssembly - Add passes to the specified pass manager
39 /// to implement a static compiler for this target.
40 ///
41 bool SparcV8TargetMachine::addPassesToEmitAssembly(PassManager &PM,
42                                                std::ostream &Out) {
43   PM.add(createSparcV8SimpleInstructionSelector(*this));
44
45   // Print machine instructions as they were initially generated.
46   if (PrintMachineCode)
47     PM.add(createMachineFunctionPrinterPass(&std::cerr));
48
49   PM.add(createRegisterAllocator());
50   PM.add(createPrologEpilogCodeInserter());
51
52   // Print machine instructions after register allocation and prolog/epilog
53   // insertion.
54   if (PrintMachineCode)
55     PM.add(createMachineFunctionPrinterPass(&std::cerr));
56
57   // Output assembly language.
58   PM.add(createSparcV8CodePrinterPass(Out, *this));
59
60   // Delete the MachineInstrs we generated, since they're no longer needed.
61   PM.add(createMachineCodeDeleter());
62   return false;
63 }
64
65 /// addPassesToJITCompile - Add passes to the specified pass manager to
66 /// implement a fast dynamic compiler for this target.
67 ///
68 void SparcV8JITInfo::addPassesToJITCompile(FunctionPassManager &PM) {
69   // <insert instruction selector passes here>
70   PM.add(createRegisterAllocator());
71   PM.add(createPrologEpilogCodeInserter());
72 }