035c31e7de430fe10c6ca0be409c61a9d1705193
[oota-llvm.git] / lib / Target / PowerPC / PPCTargetMachine.cpp
1 //===-- PowerPCTargetMachine.cpp - Define TargetMachine for PowerPC -------===//
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 "PowerPCTargetMachine.h"
14 #include "PowerPC.h"
15 #include "llvm/Module.h"
16 #include "llvm/PassManager.h"
17 #include "llvm/CodeGen/IntrinsicLowering.h"
18 #include "llvm/CodeGen/MachineFunction.h"
19 #include "llvm/CodeGen/Passes.h"
20 #include "llvm/Target/TargetMachineImpls.h"
21 #include "llvm/Transforms/Scalar.h"
22 using namespace llvm;
23
24 // allocatePowerPCTargetMachine - Allocate and return a subclass of 
25 // TargetMachine that implements the PowerPC backend.
26 //
27 TargetMachine *llvm::allocatePowerPCTargetMachine(const Module &M,
28                                                   IntrinsicLowering *IL) {
29   return new PowerPCTargetMachine(M, IL);
30 }
31
32 /// PowerPCTargetMachine ctor - Create an ILP32 architecture model
33 ///
34 /// FIXME: Should double alignment be 8 bytes?  Then we get a PtrAl != DoubleAl
35 /// abort
36 PowerPCTargetMachine::PowerPCTargetMachine(const Module &M,
37                                            IntrinsicLowering *IL)
38   : TargetMachine("PowerPC", IL, false, 4, 4, 4, 4, 4, 4, 4, 4),
39     FrameInfo(TargetFrameInfo::StackGrowsDown, 16, -4), JITInfo(*this) {
40 }
41
42 /// addPassesToEmitAssembly - Add passes to the specified pass manager
43 /// to implement a static compiler for this target.
44 ///
45 bool PowerPCTargetMachine::addPassesToEmitAssembly(PassManager &PM,
46                                                std::ostream &Out) {
47   // FIXME: Implement efficient support for garbage collection intrinsics.
48   PM.add(createLowerGCPass());
49
50   // FIXME: Implement the invoke/unwind instructions!
51   PM.add(createLowerInvokePass());
52
53   // FIXME: Implement the switch instruction in the instruction selector!
54   PM.add(createLowerSwitchPass());
55
56   PM.add(createLowerConstantExpressionsPass());
57
58   // Make sure that no unreachable blocks are instruction selected.
59   PM.add(createUnreachableBlockEliminationPass());
60
61   PM.add(createPPCSimpleInstructionSelector(*this));
62
63   if (PrintMachineCode)
64     PM.add(createMachineFunctionPrinterPass(&std::cerr));
65
66   PM.add(createRegisterAllocator());
67
68   if (PrintMachineCode)
69     PM.add(createMachineFunctionPrinterPass(&std::cerr));
70
71   PM.add(createPrologEpilogCodeInserter());
72   PM.add(createPPCCodePrinterPass(Out, *this));
73   PM.add(createMachineCodeDeleter());
74   return false;
75 }
76
77 /// addPassesToJITCompile - Add passes to the specified pass manager to
78 /// implement a fast dynamic compiler for this target.
79 ///
80 void PowerPCJITInfo::addPassesToJITCompile(FunctionPassManager &PM) {
81   // FIXME: Implement efficient support for garbage collection intrinsics.
82   PM.add(createLowerGCPass());
83
84   // FIXME: Implement the invoke/unwind instructions!
85   PM.add(createLowerInvokePass());
86
87   // FIXME: Implement the switch instruction in the instruction selector!
88   PM.add(createLowerSwitchPass());
89
90   PM.add(createLowerConstantExpressionsPass());
91
92   // Make sure that no unreachable blocks are instruction selected.
93   PM.add(createUnreachableBlockEliminationPass());
94
95   PM.add(createPPCSimpleInstructionSelector(TM));
96   PM.add(createRegisterAllocator());
97   PM.add(createPrologEpilogCodeInserter());
98 }
99