blob: 035c31e7de430fe10c6ca0be409c61a9d1705193 [file] [log] [blame]
Misha Brukman5dfe3a92004-06-21 16:55:25 +00001//===-- 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"
Misha Brukman5dfe3a92004-06-21 16:55:25 +000015#include "llvm/Module.h"
16#include "llvm/PassManager.h"
Misha Brukman8c9f5202004-06-21 18:30:31 +000017#include "llvm/CodeGen/IntrinsicLowering.h"
Misha Brukman5dfe3a92004-06-21 16:55:25 +000018#include "llvm/CodeGen/MachineFunction.h"
19#include "llvm/CodeGen/Passes.h"
Misha Brukman8c9f5202004-06-21 18:30:31 +000020#include "llvm/Target/TargetMachineImpls.h"
Misha Brukman5dfe3a92004-06-21 16:55:25 +000021#include "llvm/Transforms/Scalar.h"
22using namespace llvm;
23
24// allocatePowerPCTargetMachine - Allocate and return a subclass of
25// TargetMachine that implements the PowerPC backend.
26//
27TargetMachine *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///
Misha Brukmanf233a842004-07-01 21:27:59 +000034/// FIXME: Should double alignment be 8 bytes? Then we get a PtrAl != DoubleAl
35/// abort
Misha Brukman5dfe3a92004-06-21 16:55:25 +000036PowerPCTargetMachine::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///
45bool 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
Misha Brukman5dfe3a92004-06-21 16:55:25 +000053 // FIXME: Implement the switch instruction in the instruction selector!
54 PM.add(createLowerSwitchPass());
55
Misha Brukman60f35812004-06-29 23:33:20 +000056 PM.add(createLowerConstantExpressionsPass());
57
Chris Lattnerfab96f02004-07-02 05:48:42 +000058 // Make sure that no unreachable blocks are instruction selected.
59 PM.add(createUnreachableBlockEliminationPass());
60
Misha Brukman5dfe3a92004-06-21 16:55:25 +000061 PM.add(createPPCSimpleInstructionSelector(*this));
Misha Brukman75afe1f2004-06-24 23:55:01 +000062
63 if (PrintMachineCode)
64 PM.add(createMachineFunctionPrinterPass(&std::cerr));
65
Misha Brukman5dfe3a92004-06-21 16:55:25 +000066 PM.add(createRegisterAllocator());
Misha Brukman34fa8712004-06-25 19:57:47 +000067
68 if (PrintMachineCode)
69 PM.add(createMachineFunctionPrinterPass(&std::cerr));
70
Misha Brukman5dfe3a92004-06-21 16:55:25 +000071 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///
80void 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
Misha Brukman5dfe3a92004-06-21 16:55:25 +000087 // FIXME: Implement the switch instruction in the instruction selector!
88 PM.add(createLowerSwitchPass());
89
Misha Brukman60f35812004-06-29 23:33:20 +000090 PM.add(createLowerConstantExpressionsPass());
91
Chris Lattnerfab96f02004-07-02 05:48:42 +000092 // Make sure that no unreachable blocks are instruction selected.
93 PM.add(createUnreachableBlockEliminationPass());
94
Misha Brukman5dfe3a92004-06-21 16:55:25 +000095 PM.add(createPPCSimpleInstructionSelector(TM));
96 PM.add(createRegisterAllocator());
97 PM.add(createPrologEpilogCodeInserter());
98}
99