blob: 581c535ccb244d35b84ab6ed9c7ff24b9dbe15a1 [file] [log] [blame]
Brian Gaekee785e532004-02-25 19:28:19 +00001//===-- SparcV8TargetMachine.cpp - Define TargetMachine for SparcV8 -------===//
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 "SparcV8TargetMachine.h"
14#include "SparcV8.h"
15#include "llvm/Module.h"
16#include "llvm/PassManager.h"
17#include "llvm/Target/TargetMachineImpls.h"
18#include "llvm/CodeGen/MachineFunction.h"
19#include "llvm/CodeGen/Passes.h"
Chris Lattner8d8a6bc2004-02-28 19:52:49 +000020using namespace llvm;
Brian Gaekee785e532004-02-25 19:28:19 +000021
22// allocateSparcV8TargetMachine - Allocate and return a subclass of
23// TargetMachine that implements the SparcV8 backend.
24//
Chris Lattner8d8a6bc2004-02-28 19:52:49 +000025TargetMachine *llvm::allocateSparcV8TargetMachine(const Module &M,
26 IntrinsicLowering *IL) {
Brian Gaekee785e532004-02-25 19:28:19 +000027 return new SparcV8TargetMachine(M, IL);
28}
29
30/// SparcV8TargetMachine ctor - Create an ILP32 architecture model
31///
32SparcV8TargetMachine::SparcV8TargetMachine(const Module &M,
33 IntrinsicLowering *IL)
34 : TargetMachine("SparcV8", IL, true, 4, 4, 4, 4, 4),
35 FrameInfo(TargetFrameInfo::StackGrowsDown, 8, 4), JITInfo(*this) {
36}
37
38/// addPassesToEmitAssembly - Add passes to the specified pass manager
39/// to implement a static compiler for this target.
40///
41bool SparcV8TargetMachine::addPassesToEmitAssembly(PassManager &PM,
42 std::ostream &Out) {
Chris Lattner1c809c52004-02-29 00:27:00 +000043 PM.add(createSparcV8SimpleInstructionSelector(*this));
44
45 // Print machine instructions as they are created.
46 PM.add(createMachineFunctionPrinterPass(&std::cerr));
47
Brian Gaekee785e532004-02-25 19:28:19 +000048 PM.add(createRegisterAllocator());
49 PM.add(createPrologEpilogCodeInserter());
50 // <insert assembly code output passes here>
Chris Lattner1c809c52004-02-29 00:27:00 +000051
52 // This is not a correct asm writer by any means, but at least we see what we
53 // are producing.
54 PM.add(createMachineFunctionPrinterPass(&Out));
55
Brian Gaeke4acfd032004-03-04 06:00:41 +000056 PM.add(createSparcV8CodePrinterPass(Out, *this));
57
Brian Gaekee785e532004-02-25 19:28:19 +000058 PM.add(createMachineCodeDeleter());
Chris Lattner9ff6ba12004-02-28 20:21:45 +000059 return false;
Brian Gaekee785e532004-02-25 19:28:19 +000060}
61
62/// addPassesToJITCompile - Add passes to the specified pass manager to
63/// implement a fast dynamic compiler for this target.
64///
65void SparcV8JITInfo::addPassesToJITCompile(FunctionPassManager &PM) {
66 // <insert instruction selector passes here>
67 PM.add(createRegisterAllocator());
68 PM.add(createPrologEpilogCodeInserter());
69}