Auto-registrate target
[oota-llvm.git] / lib / Target / PowerPC / PowerPCTargetMachine.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/Target/TargetMachineImpls.h"
18 #include "llvm/Target/TargetMachineRegistry.h"
19 #include "llvm/CodeGen/MachineFunction.h"
20 #include "llvm/CodeGen/Passes.h"
21 using namespace llvm;
22
23 namespace {
24   // Register the target.
25   RegisterTarget<PowerPCTargetMachine> X("powerpc", "PowerPC (experimental)");
26 }
27
28 // allocatePowerPCTargetMachine - Allocate and return a subclass of 
29 // TargetMachine that implements the PowerPC backend.
30 //
31 TargetMachine *llvm::allocatePowerPCTargetMachine(const Module &M,
32                                                   IntrinsicLowering *IL) {
33   return new PowerPCTargetMachine(M, IL);
34 }
35
36 /// PowerPCTargetMachine ctor - Create an ILP32 architecture model
37 ///
38 PowerPCTargetMachine::PowerPCTargetMachine(const Module &M,
39                                            IntrinsicLowering *IL)
40   : TargetMachine("PowerPC", IL, true, 4, 4, 4, 4, 4),
41     FrameInfo(TargetFrameInfo::StackGrowsDown, 8, -4), JITInfo(*this) {
42 }
43
44 /// addPassesToEmitAssembly - Add passes to the specified pass manager
45 /// to implement a static compiler for this target.
46 ///
47 bool PowerPCTargetMachine::addPassesToEmitAssembly(PassManager &PM,
48                                                std::ostream &Out) {
49   // <insert instruction selector passes here>
50   PM.add(createRegisterAllocator());
51   PM.add(createPrologEpilogCodeInserter());
52   // <insert assembly code output passes here>
53   PM.add(createMachineCodeDeleter());
54   return true; // change to `return false' when this actually works.
55 }
56
57 /// addPassesToJITCompile - Add passes to the specified pass manager to
58 /// implement a fast dynamic compiler for this target.
59 ///
60 void PowerPCJITInfo::addPassesToJITCompile(FunctionPassManager &PM) {
61   // <insert instruction selector passes here>
62   PM.add(createRegisterAllocator());
63   PM.add(createPrologEpilogCodeInserter());
64 }
65