Wrap long line
[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   PM.add(createPPCSimpleInstructionSelector(*this));
59
60   if (PrintMachineCode)
61     PM.add(createMachineFunctionPrinterPass(&std::cerr));
62
63   PM.add(createRegisterAllocator());
64
65   if (PrintMachineCode)
66     PM.add(createMachineFunctionPrinterPass(&std::cerr));
67
68   PM.add(createPrologEpilogCodeInserter());
69   PM.add(createPPCCodePrinterPass(Out, *this));
70   PM.add(createMachineCodeDeleter());
71   return false;
72 }
73
74 /// addPassesToJITCompile - Add passes to the specified pass manager to
75 /// implement a fast dynamic compiler for this target.
76 ///
77 void PowerPCJITInfo::addPassesToJITCompile(FunctionPassManager &PM) {
78   // FIXME: Implement efficient support for garbage collection intrinsics.
79   PM.add(createLowerGCPass());
80
81   // FIXME: Implement the invoke/unwind instructions!
82   PM.add(createLowerInvokePass());
83
84   // FIXME: Implement the switch instruction in the instruction selector!
85   PM.add(createLowerSwitchPass());
86
87   PM.add(createLowerConstantExpressionsPass());
88
89   PM.add(createPPCSimpleInstructionSelector(TM));
90   PM.add(createRegisterAllocator());
91   PM.add(createPrologEpilogCodeInserter());
92 }
93