1 //===-- SparcV8TargetMachine.cpp - Define TargetMachine for SparcV8 -------===//
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 "SparcV8TargetMachine.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"
22 // allocateSparcV8TargetMachine - Allocate and return a subclass of
23 // TargetMachine that implements the SparcV8 backend.
25 TargetMachine *llvm::allocateSparcV8TargetMachine(const Module &M,
26 IntrinsicLowering *IL) {
27 return new SparcV8TargetMachine(M, IL);
30 /// SparcV8TargetMachine ctor - Create an ILP32 architecture model
32 SparcV8TargetMachine::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) {
38 /// addPassesToEmitAssembly - Add passes to the specified pass manager
39 /// to implement a static compiler for this target.
41 bool SparcV8TargetMachine::addPassesToEmitAssembly(PassManager &PM,
43 PM.add(createSparcV8SimpleInstructionSelector(*this));
45 // Print machine instructions as they were initially generated.
47 PM.add(createMachineFunctionPrinterPass(&std::cerr));
49 PM.add(createRegisterAllocator());
50 PM.add(createPrologEpilogCodeInserter());
52 // Print machine instructions after register allocation and prolog/epilog
55 PM.add(createMachineFunctionPrinterPass(&std::cerr));
57 PM.add(createSparcV8DelaySlotFillerPass(*this));
59 // Print machine instructions after filling delay slots.
61 PM.add(createMachineFunctionPrinterPass(&std::cerr));
63 // Output assembly language.
64 PM.add(createSparcV8CodePrinterPass(Out, *this));
66 // Delete the MachineInstrs we generated, since they're no longer needed.
67 PM.add(createMachineCodeDeleter());
71 /// addPassesToJITCompile - Add passes to the specified pass manager to
72 /// implement a fast dynamic compiler for this target.
74 void SparcV8JITInfo::addPassesToJITCompile(FunctionPassManager &PM) {
75 PM.add(createSparcV8SimpleInstructionSelector(TM));
77 // Print machine instructions as they were initially generated.
79 PM.add(createMachineFunctionPrinterPass(&std::cerr));
81 PM.add(createRegisterAllocator());
82 PM.add(createPrologEpilogCodeInserter());
84 // Print machine instructions after register allocation and prolog/epilog
87 PM.add(createMachineFunctionPrinterPass(&std::cerr));
89 PM.add(createSparcV8DelaySlotFillerPass(TM));
91 // Print machine instructions after filling delay slots.
93 PM.add(createMachineFunctionPrinterPass(&std::cerr));