Chris Dewhurst | 4f7cac3 | 2016-05-23 10:56:36 +0000 | [diff] [blame] | 1 | //===------- LeonPasses.h - Define passes specific to LEON ----------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // |
| 11 | //===----------------------------------------------------------------------===// |
| 12 | |
| 13 | #ifndef LLVM_LIB_TARGET_SPARC_LEON_PASSES_H |
| 14 | #define LLVM_LIB_TARGET_SPARC_LEON_PASSES_H |
| 15 | |
| 16 | #include "llvm/CodeGen/Passes.h" |
| 17 | #include "llvm/CodeGen/MachineFunctionPass.h" |
| 18 | #include "llvm/CodeGen/MachineBasicBlock.h" |
| 19 | |
| 20 | #include "Sparc.h" |
| 21 | #include "SparcSubtarget.h" |
| 22 | |
Benjamin Kramer | 797fb96 | 2016-05-27 10:06:27 +0000 | [diff] [blame] | 23 | namespace llvm { |
| 24 | class LLVM_LIBRARY_VISIBILITY LEONMachineFunctionPass |
| 25 | : public MachineFunctionPass { |
Chris Dewhurst | 4f7cac3 | 2016-05-23 10:56:36 +0000 | [diff] [blame] | 26 | protected: |
| 27 | const SparcSubtarget *Subtarget; |
Chris Dewhurst | 0c1e002 | 2016-06-19 11:03:28 +0000 | [diff] [blame^] | 28 | const int LAST_OPERAND = -1; |
| 29 | |
| 30 | //this vector holds free registers that we allocate in groups for some of the LEON passes |
| 31 | std::vector <int> UsedRegisters; |
Chris Dewhurst | 4f7cac3 | 2016-05-23 10:56:36 +0000 | [diff] [blame] | 32 | |
| 33 | protected: |
| 34 | LEONMachineFunctionPass(TargetMachine &tm, char& ID); |
| 35 | LEONMachineFunctionPass(char& ID); |
Chris Dewhurst | 0c1e002 | 2016-06-19 11:03:28 +0000 | [diff] [blame^] | 36 | |
| 37 | int GetRegIndexForOperand(MachineInstr& MI, int OperandIndex); |
| 38 | void clearUsedRegisterList(); |
| 39 | void markRegisterUsed(int registerIndex); |
| 40 | int getUnusedFPRegister(MachineRegisterInfo& MRI); |
Chris Dewhurst | 4f7cac3 | 2016-05-23 10:56:36 +0000 | [diff] [blame] | 41 | }; |
| 42 | |
Benjamin Kramer | 797fb96 | 2016-05-27 10:06:27 +0000 | [diff] [blame] | 43 | class LLVM_LIBRARY_VISIBILITY InsertNOPLoad : public LEONMachineFunctionPass { |
Chris Dewhurst | 4f7cac3 | 2016-05-23 10:56:36 +0000 | [diff] [blame] | 44 | public: |
| 45 | static char ID; |
| 46 | |
| 47 | InsertNOPLoad(TargetMachine &tm); |
| 48 | bool runOnMachineFunction(MachineFunction& MF) override; |
| 49 | |
| 50 | const char *getPassName() const override { |
| 51 | return "InsertNOPLoad: Erratum Fix LBR35: insert a NOP instruction after every single-cycle load instruction when the next instruction is another load/store instruction"; |
| 52 | } |
| 53 | }; |
Chris Dewhurst | 0c1e002 | 2016-06-19 11:03:28 +0000 | [diff] [blame^] | 54 | |
| 55 | class LLVM_LIBRARY_VISIBILITY FixFSMULD : public LEONMachineFunctionPass { |
| 56 | public: |
| 57 | static char ID; |
| 58 | |
| 59 | FixFSMULD(TargetMachine &tm); |
| 60 | bool runOnMachineFunction(MachineFunction& MF) override; |
| 61 | |
| 62 | const char *getPassName() const override { |
| 63 | return "FixFSMULD: Erratum Fix LBR31: do not select FSMULD"; |
| 64 | } |
| 65 | }; |
| 66 | |
| 67 | class LLVM_LIBRARY_VISIBILITY ReplaceFMULS : public LEONMachineFunctionPass { |
| 68 | public: |
| 69 | static char ID; |
| 70 | |
| 71 | ReplaceFMULS(TargetMachine &tm); |
| 72 | bool runOnMachineFunction(MachineFunction& MF) override; |
| 73 | |
| 74 | const char *getPassName() const override { |
| 75 | return "ReplaceFMULS: Erratum Fix LBR32: replace FMULS instruction with a routine using conversions/double precision operations to replace FMULS"; |
| 76 | } |
| 77 | }; |
| 78 | |
| 79 | class LLVM_LIBRARY_VISIBILITY FixAllFDIVSQRT : public LEONMachineFunctionPass { |
| 80 | public: |
| 81 | static char ID; |
| 82 | |
| 83 | FixAllFDIVSQRT(TargetMachine &tm); |
| 84 | bool runOnMachineFunction(MachineFunction& MF) override; |
| 85 | |
| 86 | const char *getPassName() const override { |
| 87 | return "FixAllFDIVSQRT: Erratum Fix LBR34: fix FDIVS/FDIVD/FSQRTS/FSQRTD instructions with NOPs and floating-point store"; |
| 88 | } |
| 89 | }; |
Benjamin Kramer | 797fb96 | 2016-05-27 10:06:27 +0000 | [diff] [blame] | 90 | } // namespace llvm |
Chris Dewhurst | 4f7cac3 | 2016-05-23 10:56:36 +0000 | [diff] [blame] | 91 | |
| 92 | #endif |