blob: ad60cb6e1a6eaf007a77d7cd2bb292b255b9c8f2 [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///
34/// FIXME: Should double alignment be 8 bytes? Then we get a PtrAl != DoubleAl abort
35PowerPCTargetMachine::PowerPCTargetMachine(const Module &M,
36 IntrinsicLowering *IL)
37 : TargetMachine("PowerPC", IL, false, 4, 4, 4, 4, 4, 4, 4, 4),
38 FrameInfo(TargetFrameInfo::StackGrowsDown, 16, -4), JITInfo(*this) {
39}
40
41/// addPassesToEmitAssembly - Add passes to the specified pass manager
42/// to implement a static compiler for this target.
43///
44bool PowerPCTargetMachine::addPassesToEmitAssembly(PassManager &PM,
45 std::ostream &Out) {
46 // FIXME: Implement efficient support for garbage collection intrinsics.
47 PM.add(createLowerGCPass());
48
49 // FIXME: Implement the invoke/unwind instructions!
50 PM.add(createLowerInvokePass());
51
Misha Brukman5dfe3a92004-06-21 16:55:25 +000052 // FIXME: Implement the switch instruction in the instruction selector!
53 PM.add(createLowerSwitchPass());
54
Misha Brukman60f35812004-06-29 23:33:20 +000055 PM.add(createLowerConstantExpressionsPass());
56
Misha Brukman5dfe3a92004-06-21 16:55:25 +000057 PM.add(createPPCSimpleInstructionSelector(*this));
Misha Brukman75afe1f2004-06-24 23:55:01 +000058
59 if (PrintMachineCode)
60 PM.add(createMachineFunctionPrinterPass(&std::cerr));
61
Misha Brukman5dfe3a92004-06-21 16:55:25 +000062 PM.add(createRegisterAllocator());
Misha Brukman34fa8712004-06-25 19:57:47 +000063
64 if (PrintMachineCode)
65 PM.add(createMachineFunctionPrinterPass(&std::cerr));
66
Misha Brukman5dfe3a92004-06-21 16:55:25 +000067 PM.add(createPrologEpilogCodeInserter());
68 PM.add(createPPCCodePrinterPass(Out, *this));
69 PM.add(createMachineCodeDeleter());
70 return false;
71}
72
73/// addPassesToJITCompile - Add passes to the specified pass manager to
74/// implement a fast dynamic compiler for this target.
75///
76void PowerPCJITInfo::addPassesToJITCompile(FunctionPassManager &PM) {
77 // FIXME: Implement efficient support for garbage collection intrinsics.
78 PM.add(createLowerGCPass());
79
80 // FIXME: Implement the invoke/unwind instructions!
81 PM.add(createLowerInvokePass());
82
Misha Brukman5dfe3a92004-06-21 16:55:25 +000083 // FIXME: Implement the switch instruction in the instruction selector!
84 PM.add(createLowerSwitchPass());
85
Misha Brukman60f35812004-06-29 23:33:20 +000086 PM.add(createLowerConstantExpressionsPass());
87
Misha Brukman5dfe3a92004-06-21 16:55:25 +000088 PM.add(createPPCSimpleInstructionSelector(TM));
89 PM.add(createRegisterAllocator());
90 PM.add(createPrologEpilogCodeInserter());
91}
92