blob: 7132e5de6d5d3cd5de69546da8b56484b94ec0e7 [file] [log] [blame]
Brian Gaekeca78f492004-01-21 21:13:19 +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"
Brian Gaeke03f84a92004-02-02 19:06:36 +000014#include "PowerPC.h"
Brian Gaekeca78f492004-01-21 21:13:19 +000015#include "llvm/Module.h"
16#include "llvm/PassManager.h"
17#include "llvm/Target/TargetMachineImpls.h"
Chris Lattnerd36c9702004-07-11 02:48:49 +000018#include "llvm/Target/TargetMachineRegistry.h"
Brian Gaekeca78f492004-01-21 21:13:19 +000019#include "llvm/CodeGen/MachineFunction.h"
20#include "llvm/CodeGen/Passes.h"
Chris Lattner9a89f372004-02-28 19:53:18 +000021using namespace llvm;
Brian Gaekeca78f492004-01-21 21:13:19 +000022
Chris Lattnerd36c9702004-07-11 02:48:49 +000023namespace {
24 // Register the target.
25 RegisterTarget<PowerPCTargetMachine> X("powerpc", "PowerPC (experimental)");
26}
27
Brian Gaekeca78f492004-01-21 21:13:19 +000028// allocatePowerPCTargetMachine - Allocate and return a subclass of
29// TargetMachine that implements the PowerPC backend.
30//
Chris Lattner9a89f372004-02-28 19:53:18 +000031TargetMachine *llvm::allocatePowerPCTargetMachine(const Module &M,
32 IntrinsicLowering *IL) {
Brian Gaekeca78f492004-01-21 21:13:19 +000033 return new PowerPCTargetMachine(M, IL);
34}
35
36/// PowerPCTargetMachine ctor - Create an ILP32 architecture model
37///
38PowerPCTargetMachine::PowerPCTargetMachine(const Module &M,
39 IntrinsicLowering *IL)
40 : TargetMachine("PowerPC", IL, true, 4, 4, 4, 4, 4),
Chris Lattner32305f72004-06-10 06:19:25 +000041 FrameInfo(TargetFrameInfo::StackGrowsDown, 8, -4), JITInfo(*this) {
Brian Gaekeca78f492004-01-21 21:13:19 +000042}
43
Brian Gaeke03f84a92004-02-02 19:06:36 +000044/// addPassesToEmitAssembly - Add passes to the specified pass manager
45/// to implement a static compiler for this target.
46///
Brian Gaekeca78f492004-01-21 21:13:19 +000047bool PowerPCTargetMachine::addPassesToEmitAssembly(PassManager &PM,
48 std::ostream &Out) {
Brian Gaeke03f84a92004-02-02 19:06:36 +000049 // <insert instruction selector passes here>
50 PM.add(createRegisterAllocator());
51 PM.add(createPrologEpilogCodeInserter());
52 // <insert assembly code output passes here>
Alkis Evlogimenosc81efdc2004-02-15 00:03:15 +000053 PM.add(createMachineCodeDeleter());
Brian Gaeke03f84a92004-02-02 19:06:36 +000054 return true; // change to `return false' when this actually works.
Brian Gaekeca78f492004-01-21 21:13:19 +000055}
56
57/// addPassesToJITCompile - Add passes to the specified pass manager to
Brian Gaeke7b0cd6d2004-01-23 06:35:43 +000058/// implement a fast dynamic compiler for this target.
Brian Gaekeca78f492004-01-21 21:13:19 +000059///
Brian Gaeke7b0cd6d2004-01-23 06:35:43 +000060void PowerPCJITInfo::addPassesToJITCompile(FunctionPassManager &PM) {
Brian Gaeke03f84a92004-02-02 19:06:36 +000061 // <insert instruction selector passes here>
62 PM.add(createRegisterAllocator());
63 PM.add(createPrologEpilogCodeInserter());
Brian Gaekeca78f492004-01-21 21:13:19 +000064}
65