blob: 6593fcd58de08b02a694bb6da67154199eed6b4a [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"
Chris Lattnerd36c9702004-07-11 02:48:49 +000021#include "llvm/Target/TargetMachineRegistry.h"
Misha Brukman5dfe3a92004-06-21 16:55:25 +000022#include "llvm/Transforms/Scalar.h"
Chris Lattnerd36c9702004-07-11 02:48:49 +000023#include <iostream>
Misha Brukman5dfe3a92004-06-21 16:55:25 +000024using namespace llvm;
25
Chris Lattnerd36c9702004-07-11 02:48:49 +000026namespace {
27 // Register the target.
Chris Lattner71d24aa2004-07-11 03:27:42 +000028 RegisterTarget<PowerPCTargetMachine> X("powerpc", " PowerPC (experimental)");
Chris Lattnerd36c9702004-07-11 02:48:49 +000029}
30
Misha Brukman5dfe3a92004-06-21 16:55:25 +000031// allocatePowerPCTargetMachine - Allocate and return a subclass of
32// TargetMachine that implements the PowerPC backend.
33//
34TargetMachine *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///
Misha Brukmanf233a842004-07-01 21:27:59 +000041/// FIXME: Should double alignment be 8 bytes? Then we get a PtrAl != DoubleAl
42/// abort
Misha Brukman5dfe3a92004-06-21 16:55:25 +000043PowerPCTargetMachine::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///
52bool 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
Misha Brukman5dfe3a92004-06-21 16:55:25 +000060 // FIXME: Implement the switch instruction in the instruction selector!
61 PM.add(createLowerSwitchPass());
62
Misha Brukman60f35812004-06-29 23:33:20 +000063 PM.add(createLowerConstantExpressionsPass());
64
Chris Lattnerfab96f02004-07-02 05:48:42 +000065 // Make sure that no unreachable blocks are instruction selected.
66 PM.add(createUnreachableBlockEliminationPass());
67
Misha Brukman5dfe3a92004-06-21 16:55:25 +000068 PM.add(createPPCSimpleInstructionSelector(*this));
Misha Brukman75afe1f2004-06-24 23:55:01 +000069
70 if (PrintMachineCode)
71 PM.add(createMachineFunctionPrinterPass(&std::cerr));
72
Misha Brukman5dfe3a92004-06-21 16:55:25 +000073 PM.add(createRegisterAllocator());
Misha Brukman34fa8712004-06-25 19:57:47 +000074
75 if (PrintMachineCode)
76 PM.add(createMachineFunctionPrinterPass(&std::cerr));
77
Misha Brukman5dfe3a92004-06-21 16:55:25 +000078 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///
87void 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
Misha Brukman5dfe3a92004-06-21 16:55:25 +000094 // FIXME: Implement the switch instruction in the instruction selector!
95 PM.add(createLowerSwitchPass());
96
Misha Brukman60f35812004-06-29 23:33:20 +000097 PM.add(createLowerConstantExpressionsPass());
98
Chris Lattnerfab96f02004-07-02 05:48:42 +000099 // Make sure that no unreachable blocks are instruction selected.
100 PM.add(createUnreachableBlockEliminationPass());
101
Misha Brukman5dfe3a92004-06-21 16:55:25 +0000102 PM.add(createPPCSimpleInstructionSelector(TM));
103 PM.add(createRegisterAllocator());
104 PM.add(createPrologEpilogCodeInserter());
105}
106