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/Transforms/Scalar.h"
24 // allocatePowerPCTargetMachine - Allocate and return a subclass of
25 // TargetMachine that implements the PowerPC backend.
27 TargetMachine *llvm::allocatePowerPCTargetMachine(const Module &M,
28 IntrinsicLowering *IL) {
29 return new PowerPCTargetMachine(M, IL);
32 /// PowerPCTargetMachine ctor - Create an ILP32 architecture model
34 /// FIXME: Should double alignment be 8 bytes? Then we get a PtrAl != DoubleAl
36 PowerPCTargetMachine::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) {
42 /// addPassesToEmitAssembly - Add passes to the specified pass manager
43 /// to implement a static compiler for this target.
45 bool PowerPCTargetMachine::addPassesToEmitAssembly(PassManager &PM,
47 // FIXME: Implement efficient support for garbage collection intrinsics.
48 PM.add(createLowerGCPass());
50 // FIXME: Implement the invoke/unwind instructions!
51 PM.add(createLowerInvokePass());
53 // FIXME: Implement the switch instruction in the instruction selector!
54 PM.add(createLowerSwitchPass());
56 PM.add(createLowerConstantExpressionsPass());
58 // Make sure that no unreachable blocks are instruction selected.
59 PM.add(createUnreachableBlockEliminationPass());
61 PM.add(createPPCSimpleInstructionSelector(*this));
64 PM.add(createMachineFunctionPrinterPass(&std::cerr));
66 PM.add(createRegisterAllocator());
69 PM.add(createMachineFunctionPrinterPass(&std::cerr));
71 PM.add(createPrologEpilogCodeInserter());
72 PM.add(createPPCCodePrinterPass(Out, *this));
73 PM.add(createMachineCodeDeleter());
77 /// addPassesToJITCompile - Add passes to the specified pass manager to
78 /// implement a fast dynamic compiler for this target.
80 void PowerPCJITInfo::addPassesToJITCompile(FunctionPassManager &PM) {
81 // FIXME: Implement efficient support for garbage collection intrinsics.
82 PM.add(createLowerGCPass());
84 // FIXME: Implement the invoke/unwind instructions!
85 PM.add(createLowerInvokePass());
87 // FIXME: Implement the switch instruction in the instruction selector!
88 PM.add(createLowerSwitchPass());
90 PM.add(createLowerConstantExpressionsPass());
92 // Make sure that no unreachable blocks are instruction selected.
93 PM.add(createUnreachableBlockEliminationPass());
95 PM.add(createPPCSimpleInstructionSelector(TM));
96 PM.add(createRegisterAllocator());
97 PM.add(createPrologEpilogCodeInserter());