blob: 16326431356c907c313601e4c2a4a15fd37aa5d7 [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"
Chris Lattner68905bb2004-07-11 04:17:58 +000020#include "llvm/Target/TargetOptions.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/// PowerPCTargetMachine ctor - Create an ILP32 architecture model
32///
Misha Brukmanf233a842004-07-01 21:27:59 +000033/// FIXME: Should double alignment be 8 bytes? Then we get a PtrAl != DoubleAl
34/// abort
Misha Brukman5dfe3a92004-06-21 16:55:25 +000035PowerPCTargetMachine::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
Chris Lattnerfab96f02004-07-02 05:48:42 +000057 // Make sure that no unreachable blocks are instruction selected.
58 PM.add(createUnreachableBlockEliminationPass());
59
Misha Brukman5dfe3a92004-06-21 16:55:25 +000060 PM.add(createPPCSimpleInstructionSelector(*this));
Misha Brukman75afe1f2004-06-24 23:55:01 +000061
62 if (PrintMachineCode)
63 PM.add(createMachineFunctionPrinterPass(&std::cerr));
64
Misha Brukman5dfe3a92004-06-21 16:55:25 +000065 PM.add(createRegisterAllocator());
Misha Brukman34fa8712004-06-25 19:57:47 +000066
67 if (PrintMachineCode)
68 PM.add(createMachineFunctionPrinterPass(&std::cerr));
69
Misha Brukman5dfe3a92004-06-21 16:55:25 +000070 PM.add(createPrologEpilogCodeInserter());
71 PM.add(createPPCCodePrinterPass(Out, *this));
72 PM.add(createMachineCodeDeleter());
73 return false;
74}
75
76/// addPassesToJITCompile - Add passes to the specified pass manager to
77/// implement a fast dynamic compiler for this target.
78///
79void PowerPCJITInfo::addPassesToJITCompile(FunctionPassManager &PM) {
80 // FIXME: Implement efficient support for garbage collection intrinsics.
81 PM.add(createLowerGCPass());
82
83 // FIXME: Implement the invoke/unwind instructions!
84 PM.add(createLowerInvokePass());
85
Misha Brukman5dfe3a92004-06-21 16:55:25 +000086 // FIXME: Implement the switch instruction in the instruction selector!
87 PM.add(createLowerSwitchPass());
88
Misha Brukman60f35812004-06-29 23:33:20 +000089 PM.add(createLowerConstantExpressionsPass());
90
Chris Lattnerfab96f02004-07-02 05:48:42 +000091 // Make sure that no unreachable blocks are instruction selected.
92 PM.add(createUnreachableBlockEliminationPass());
93
Misha Brukman5dfe3a92004-06-21 16:55:25 +000094 PM.add(createPPCSimpleInstructionSelector(TM));
95 PM.add(createRegisterAllocator());
96 PM.add(createPrologEpilogCodeInserter());
97}
98