Misha Brukman | 5dfe3a9 | 2004-06-21 16:55:25 +0000 | [diff] [blame] | 1 | //===-- 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" |
| 15 | #include "llvm/IntrinsicLowering.h" |
| 16 | #include "llvm/Module.h" |
| 17 | #include "llvm/PassManager.h" |
| 18 | #include "llvm/Target/TargetMachineImpls.h" |
| 19 | #include "llvm/CodeGen/MachineFunction.h" |
| 20 | #include "llvm/CodeGen/Passes.h" |
| 21 | #include "llvm/Transforms/Scalar.h" |
| 22 | using namespace llvm; |
| 23 | |
| 24 | // allocatePowerPCTargetMachine - Allocate and return a subclass of |
| 25 | // TargetMachine that implements the PowerPC backend. |
| 26 | // |
| 27 | TargetMachine *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 |
| 35 | PowerPCTargetMachine::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 | /// |
| 44 | bool 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 | |
| 52 | // FIXME: The code generator does not properly handle functions with |
| 53 | // unreachable basic blocks. |
| 54 | PM.add(createCFGSimplificationPass()); |
| 55 | |
| 56 | // FIXME: Implement the switch instruction in the instruction selector! |
| 57 | PM.add(createLowerSwitchPass()); |
| 58 | |
| 59 | PM.add(createPPCSimpleInstructionSelector(*this)); |
| 60 | PM.add(createRegisterAllocator()); |
| 61 | PM.add(createPrologEpilogCodeInserter()); |
| 62 | PM.add(createPPCCodePrinterPass(Out, *this)); |
| 63 | PM.add(createMachineCodeDeleter()); |
| 64 | return false; |
| 65 | } |
| 66 | |
| 67 | /// addPassesToJITCompile - Add passes to the specified pass manager to |
| 68 | /// implement a fast dynamic compiler for this target. |
| 69 | /// |
| 70 | void PowerPCJITInfo::addPassesToJITCompile(FunctionPassManager &PM) { |
| 71 | // FIXME: Implement efficient support for garbage collection intrinsics. |
| 72 | PM.add(createLowerGCPass()); |
| 73 | |
| 74 | // FIXME: Implement the invoke/unwind instructions! |
| 75 | PM.add(createLowerInvokePass()); |
| 76 | |
| 77 | // FIXME: The code generator does not properly handle functions with |
| 78 | // unreachable basic blocks. |
| 79 | PM.add(createCFGSimplificationPass()); |
| 80 | |
| 81 | // FIXME: Implement the switch instruction in the instruction selector! |
| 82 | PM.add(createLowerSwitchPass()); |
| 83 | |
| 84 | PM.add(createPPCSimpleInstructionSelector(TM)); |
| 85 | PM.add(createRegisterAllocator()); |
| 86 | PM.add(createPrologEpilogCodeInserter()); |
| 87 | } |
| 88 | |