1 //===-- PowerPCTargetMachine.cpp - Define TargetMachine for PowerPC -------===//
3 // The LLVM Compiler Infrastructure
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.
8 //===----------------------------------------------------------------------===//
11 //===----------------------------------------------------------------------===//
13 #include "PowerPCTargetMachine.h"
15 #include "llvm/Module.h"
16 #include "llvm/PassManager.h"
17 #include "llvm/CodeGen/IntrinsicLowering.h"
18 #include "llvm/CodeGen/MachineFunction.h"
19 #include "llvm/CodeGen/Passes.h"
20 #include "llvm/Target/TargetMachineImpls.h"
21 #include "llvm/Target/TargetMachineRegistry.h"
22 #include "llvm/Transforms/Scalar.h"
27 // Register the target.
28 RegisterTarget<PowerPCTargetMachine> X("powerpc", " PowerPC (experimental)");
31 // allocatePowerPCTargetMachine - Allocate and return a subclass of
32 // TargetMachine that implements the PowerPC backend.
34 TargetMachine *llvm::allocatePowerPCTargetMachine(const Module &M,
35 IntrinsicLowering *IL) {
36 return new PowerPCTargetMachine(M, IL);
39 /// PowerPCTargetMachine ctor - Create an ILP32 architecture model
41 /// FIXME: Should double alignment be 8 bytes? Then we get a PtrAl != DoubleAl
43 PowerPCTargetMachine::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) {
49 /// addPassesToEmitAssembly - Add passes to the specified pass manager
50 /// to implement a static compiler for this target.
52 bool PowerPCTargetMachine::addPassesToEmitAssembly(PassManager &PM,
54 // FIXME: Implement efficient support for garbage collection intrinsics.
55 PM.add(createLowerGCPass());
57 // FIXME: Implement the invoke/unwind instructions!
58 PM.add(createLowerInvokePass());
60 // FIXME: Implement the switch instruction in the instruction selector!
61 PM.add(createLowerSwitchPass());
63 PM.add(createLowerConstantExpressionsPass());
65 // Make sure that no unreachable blocks are instruction selected.
66 PM.add(createUnreachableBlockEliminationPass());
68 PM.add(createPPCSimpleInstructionSelector(*this));
71 PM.add(createMachineFunctionPrinterPass(&std::cerr));
73 PM.add(createRegisterAllocator());
76 PM.add(createMachineFunctionPrinterPass(&std::cerr));
78 PM.add(createPrologEpilogCodeInserter());
79 PM.add(createPPCCodePrinterPass(Out, *this));
80 PM.add(createMachineCodeDeleter());
84 /// addPassesToJITCompile - Add passes to the specified pass manager to
85 /// implement a fast dynamic compiler for this target.
87 void PowerPCJITInfo::addPassesToJITCompile(FunctionPassManager &PM) {
88 // FIXME: Implement efficient support for garbage collection intrinsics.
89 PM.add(createLowerGCPass());
91 // FIXME: Implement the invoke/unwind instructions!
92 PM.add(createLowerInvokePass());
94 // FIXME: Implement the switch instruction in the instruction selector!
95 PM.add(createLowerSwitchPass());
97 PM.add(createLowerConstantExpressionsPass());
99 // Make sure that no unreachable blocks are instruction selected.
100 PM.add(createUnreachableBlockEliminationPass());
102 PM.add(createPPCSimpleInstructionSelector(TM));
103 PM.add(createRegisterAllocator());
104 PM.add(createPrologEpilogCodeInserter());