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