Brian Gaeke | e785e53 | 2004-02-25 19:28:19 +0000 | [diff] [blame] | 1 | //===-- 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 Lattner | 8d8a6bc | 2004-02-28 19:52:49 +0000 | [diff] [blame] | 20 | using namespace llvm; |
Brian Gaeke | e785e53 | 2004-02-25 19:28:19 +0000 | [diff] [blame] | 21 | |
| 22 | // allocateSparcV8TargetMachine - Allocate and return a subclass of |
| 23 | // TargetMachine that implements the SparcV8 backend. |
| 24 | // |
Chris Lattner | 8d8a6bc | 2004-02-28 19:52:49 +0000 | [diff] [blame] | 25 | TargetMachine *llvm::allocateSparcV8TargetMachine(const Module &M, |
| 26 | IntrinsicLowering *IL) { |
Brian Gaeke | e785e53 | 2004-02-25 19:28:19 +0000 | [diff] [blame] | 27 | return new SparcV8TargetMachine(M, IL); |
| 28 | } |
| 29 | |
| 30 | /// SparcV8TargetMachine ctor - Create an ILP32 architecture model |
| 31 | /// |
| 32 | SparcV8TargetMachine::SparcV8TargetMachine(const Module &M, |
| 33 | IntrinsicLowering *IL) |
| 34 | : TargetMachine("SparcV8", IL, true, 4, 4, 4, 4, 4), |
Brian Gaeke | ef8e48a | 2004-04-13 18:28:37 +0000 | [diff] [blame] | 35 | FrameInfo(TargetFrameInfo::StackGrowsDown, 8, 0), JITInfo(*this) { |
Brian Gaeke | e785e53 | 2004-02-25 19:28:19 +0000 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | /// addPassesToEmitAssembly - Add passes to the specified pass manager |
| 39 | /// to implement a static compiler for this target. |
| 40 | /// |
| 41 | bool SparcV8TargetMachine::addPassesToEmitAssembly(PassManager &PM, |
| 42 | std::ostream &Out) { |
Chris Lattner | 1c809c5 | 2004-02-29 00:27:00 +0000 | [diff] [blame] | 43 | PM.add(createSparcV8SimpleInstructionSelector(*this)); |
| 44 | |
Brian Gaeke | 7a3ae1f | 2004-03-04 19:22:16 +0000 | [diff] [blame] | 45 | // Print machine instructions as they were initially generated. |
| 46 | if (PrintMachineCode) |
| 47 | PM.add(createMachineFunctionPrinterPass(&std::cerr)); |
Chris Lattner | 1c809c5 | 2004-02-29 00:27:00 +0000 | [diff] [blame] | 48 | |
Brian Gaeke | e785e53 | 2004-02-25 19:28:19 +0000 | [diff] [blame] | 49 | PM.add(createRegisterAllocator()); |
| 50 | PM.add(createPrologEpilogCodeInserter()); |
Chris Lattner | 1c809c5 | 2004-02-29 00:27:00 +0000 | [diff] [blame] | 51 | |
Brian Gaeke | 7a3ae1f | 2004-03-04 19:22:16 +0000 | [diff] [blame] | 52 | // Print machine instructions after register allocation and prolog/epilog |
| 53 | // insertion. |
| 54 | if (PrintMachineCode) |
| 55 | PM.add(createMachineFunctionPrinterPass(&std::cerr)); |
Chris Lattner | 1c809c5 | 2004-02-29 00:27:00 +0000 | [diff] [blame] | 56 | |
Brian Gaeke | 86a8790 | 2004-04-06 23:21:24 +0000 | [diff] [blame] | 57 | PM.add(createSparcV8DelaySlotFillerPass(*this)); |
| 58 | |
| 59 | // Print machine instructions after filling delay slots. |
| 60 | if (PrintMachineCode) |
| 61 | PM.add(createMachineFunctionPrinterPass(&std::cerr)); |
| 62 | |
Brian Gaeke | 7a3ae1f | 2004-03-04 19:22:16 +0000 | [diff] [blame] | 63 | // Output assembly language. |
Brian Gaeke | 4acfd03 | 2004-03-04 06:00:41 +0000 | [diff] [blame] | 64 | PM.add(createSparcV8CodePrinterPass(Out, *this)); |
| 65 | |
Brian Gaeke | 7a3ae1f | 2004-03-04 19:22:16 +0000 | [diff] [blame] | 66 | // Delete the MachineInstrs we generated, since they're no longer needed. |
Brian Gaeke | e785e53 | 2004-02-25 19:28:19 +0000 | [diff] [blame] | 67 | PM.add(createMachineCodeDeleter()); |
Chris Lattner | 9ff6ba1 | 2004-02-28 20:21:45 +0000 | [diff] [blame] | 68 | return false; |
Brian Gaeke | e785e53 | 2004-02-25 19:28:19 +0000 | [diff] [blame] | 69 | } |
| 70 | |
| 71 | /// addPassesToJITCompile - Add passes to the specified pass manager to |
| 72 | /// implement a fast dynamic compiler for this target. |
| 73 | /// |
| 74 | void SparcV8JITInfo::addPassesToJITCompile(FunctionPassManager &PM) { |
Brian Gaeke | 86a8790 | 2004-04-06 23:21:24 +0000 | [diff] [blame] | 75 | PM.add(createSparcV8SimpleInstructionSelector(TM)); |
| 76 | |
| 77 | // Print machine instructions as they were initially generated. |
| 78 | if (PrintMachineCode) |
| 79 | PM.add(createMachineFunctionPrinterPass(&std::cerr)); |
| 80 | |
Brian Gaeke | e785e53 | 2004-02-25 19:28:19 +0000 | [diff] [blame] | 81 | PM.add(createRegisterAllocator()); |
| 82 | PM.add(createPrologEpilogCodeInserter()); |
Brian Gaeke | 86a8790 | 2004-04-06 23:21:24 +0000 | [diff] [blame] | 83 | |
| 84 | // Print machine instructions after register allocation and prolog/epilog |
| 85 | // insertion. |
| 86 | if (PrintMachineCode) |
| 87 | PM.add(createMachineFunctionPrinterPass(&std::cerr)); |
| 88 | |
| 89 | PM.add(createSparcV8DelaySlotFillerPass(TM)); |
| 90 | |
| 91 | // Print machine instructions after filling delay slots. |
| 92 | if (PrintMachineCode) |
| 93 | PM.add(createMachineFunctionPrinterPass(&std::cerr)); |
Brian Gaeke | e785e53 | 2004-02-25 19:28:19 +0000 | [diff] [blame] | 94 | } |