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 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) {
41 /// addPassesToEmitAssembly - Add passes to the specified pass manager
42 /// to implement a static compiler for this target.
44 bool PowerPCTargetMachine::addPassesToEmitAssembly(PassManager &PM,
46 // FIXME: Implement efficient support for garbage collection intrinsics.
47 PM.add(createLowerGCPass());
49 // FIXME: Implement the invoke/unwind instructions!
50 PM.add(createLowerInvokePass());
52 // FIXME: The code generator does not properly handle functions with
53 // unreachable basic blocks.
54 PM.add(createCFGSimplificationPass());
56 // FIXME: Implement the switch instruction in the instruction selector!
57 PM.add(createLowerSwitchPass());
59 PM.add(createPPCSimpleInstructionSelector(*this));
62 PM.add(createMachineFunctionPrinterPass(&std::cerr));
64 PM.add(createRegisterAllocator());
67 PM.add(createMachineFunctionPrinterPass(&std::cerr));
69 PM.add(createPrologEpilogCodeInserter());
70 PM.add(createPPCCodePrinterPass(Out, *this));
71 PM.add(createMachineCodeDeleter());
75 /// addPassesToJITCompile - Add passes to the specified pass manager to
76 /// implement a fast dynamic compiler for this target.
78 void PowerPCJITInfo::addPassesToJITCompile(FunctionPassManager &PM) {
79 // FIXME: Implement efficient support for garbage collection intrinsics.
80 PM.add(createLowerGCPass());
82 // FIXME: Implement the invoke/unwind instructions!
83 PM.add(createLowerInvokePass());
85 // FIXME: The code generator does not properly handle functions with
86 // unreachable basic blocks.
87 PM.add(createCFGSimplificationPass());
89 // FIXME: Implement the switch instruction in the instruction selector!
90 PM.add(createLowerSwitchPass());
92 PM.add(createPPCSimpleInstructionSelector(TM));
93 PM.add(createRegisterAllocator());
94 PM.add(createPrologEpilogCodeInserter());