blob: 04117d3c059a4fb1f72bfdca4bc56c3222ce8576 [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
Misha Brukman5dfe3a92004-06-21 16:55:25 +000058 PM.add(createPPCSimpleInstructionSelector(*this));
Misha Brukman75afe1f2004-06-24 23:55:01 +000059
60 if (PrintMachineCode)
61 PM.add(createMachineFunctionPrinterPass(&std::cerr));
62
Misha Brukman5dfe3a92004-06-21 16:55:25 +000063 PM.add(createRegisterAllocator());
Misha Brukman34fa8712004-06-25 19:57:47 +000064
65 if (PrintMachineCode)
66 PM.add(createMachineFunctionPrinterPass(&std::cerr));
67
Misha Brukman5dfe3a92004-06-21 16:55:25 +000068 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///
77void 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
Misha Brukman5dfe3a92004-06-21 16:55:25 +000084 // FIXME: Implement the switch instruction in the instruction selector!
85 PM.add(createLowerSwitchPass());
86
Misha Brukman60f35812004-06-29 23:33:20 +000087 PM.add(createLowerConstantExpressionsPass());
88
Misha Brukman5dfe3a92004-06-21 16:55:25 +000089 PM.add(createPPCSimpleInstructionSelector(TM));
90 PM.add(createRegisterAllocator());
91 PM.add(createPrologEpilogCodeInserter());
92}
93