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 | |
Chris Dewhurst | 4f7cac3 | 2016-05-23 10:56:36 +0000 | [diff] [blame] | 16 | #include "llvm/CodeGen/MachineBasicBlock.h" |
Chris Dewhurst | 2bad85c | 2016-06-27 14:19:19 +0000 | [diff] [blame] | 17 | #include "llvm/CodeGen/MachineFunctionPass.h" |
| 18 | #include "llvm/CodeGen/Passes.h" |
Chris Dewhurst | 4f7cac3 | 2016-05-23 10:56:36 +0000 | [diff] [blame] | 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 | |
Chris Dewhurst | 2bad85c | 2016-06-27 14:19:19 +0000 | [diff] [blame] | 30 | // this vector holds free registers that we allocate in groups for some of the |
| 31 | // LEON passes |
| 32 | std::vector<int> UsedRegisters; |
Chris Dewhurst | 4f7cac3 | 2016-05-23 10:56:36 +0000 | [diff] [blame] | 33 | |
| 34 | protected: |
Chris Dewhurst | 2bad85c | 2016-06-27 14:19:19 +0000 | [diff] [blame] | 35 | LEONMachineFunctionPass(char &ID); |
Chris Dewhurst | 0c1e002 | 2016-06-19 11:03:28 +0000 | [diff] [blame] | 36 | |
Chris Dewhurst | 2bad85c | 2016-06-27 14:19:19 +0000 | [diff] [blame] | 37 | int GetRegIndexForOperand(MachineInstr &MI, int OperandIndex); |
| 38 | void clearUsedRegisterList() { UsedRegisters.clear(); } |
| 39 | |
| 40 | void markRegisterUsed(int registerIndex) { |
| 41 | UsedRegisters.push_back(registerIndex); |
| 42 | } |
| 43 | int getUnusedFPRegister(MachineRegisterInfo &MRI); |
Chris Dewhurst | 4f7cac3 | 2016-05-23 10:56:36 +0000 | [diff] [blame] | 44 | }; |
| 45 | |
James Y Knight | 2cc9da9 | 2016-08-12 14:48:09 +0000 | [diff] [blame] | 46 | class LLVM_LIBRARY_VISIBILITY InsertNOPLoad : public LEONMachineFunctionPass { |
Chris Dewhurst | 4f7cac3 | 2016-05-23 10:56:36 +0000 | [diff] [blame] | 47 | public: |
| 48 | static char ID; |
| 49 | |
Francis Visoiu Mistrih | 8b61764 | 2017-05-18 17:21:13 +0000 | [diff] [blame] | 50 | InsertNOPLoad(); |
Chris Dewhurst | 2bad85c | 2016-06-27 14:19:19 +0000 | [diff] [blame] | 51 | bool runOnMachineFunction(MachineFunction &MF) override; |
Chris Dewhurst | 4f7cac3 | 2016-05-23 10:56:36 +0000 | [diff] [blame] | 52 | |
Mehdi Amini | 117296c | 2016-10-01 02:56:57 +0000 | [diff] [blame] | 53 | StringRef getPassName() const override { |
James Y Knight | 2cc9da9 | 2016-08-12 14:48:09 +0000 | [diff] [blame] | 54 | return "InsertNOPLoad: Erratum Fix LBR35: insert a NOP instruction after " |
| 55 | "every single-cycle load instruction when the next instruction is " |
| 56 | "another load/store instruction"; |
Chris Dewhurst | 4f7cac3 | 2016-05-23 10:56:36 +0000 | [diff] [blame] | 57 | } |
| 58 | }; |
Chris Dewhurst | 0c1e002 | 2016-06-19 11:03:28 +0000 | [diff] [blame] | 59 | |
Chris Dewhurst | 2c3cdd6 | 2016-10-19 14:01:06 +0000 | [diff] [blame] | 60 | class LLVM_LIBRARY_VISIBILITY DetectRoundChange |
| 61 | : public LEONMachineFunctionPass { |
| 62 | public: |
| 63 | static char ID; |
| 64 | |
Francis Visoiu Mistrih | 8b61764 | 2017-05-18 17:21:13 +0000 | [diff] [blame] | 65 | DetectRoundChange(); |
Chris Dewhurst | 2c3cdd6 | 2016-10-19 14:01:06 +0000 | [diff] [blame] | 66 | bool runOnMachineFunction(MachineFunction &MF) override; |
| 67 | |
| 68 | StringRef getPassName() const override { |
| 69 | return "DetectRoundChange: Leon erratum detection: detect any rounding " |
| 70 | "mode change request: use only the round-to-nearest rounding mode"; |
| 71 | } |
| 72 | }; |
| 73 | |
Chris Dewhurst | 0c1e002 | 2016-06-19 11:03:28 +0000 | [diff] [blame] | 74 | class LLVM_LIBRARY_VISIBILITY FixAllFDIVSQRT : public LEONMachineFunctionPass { |
| 75 | public: |
| 76 | static char ID; |
| 77 | |
Francis Visoiu Mistrih | 8b61764 | 2017-05-18 17:21:13 +0000 | [diff] [blame] | 78 | FixAllFDIVSQRT(); |
Chris Dewhurst | 2bad85c | 2016-06-27 14:19:19 +0000 | [diff] [blame] | 79 | bool runOnMachineFunction(MachineFunction &MF) override; |
Chris Dewhurst | 0c1e002 | 2016-06-19 11:03:28 +0000 | [diff] [blame] | 80 | |
Mehdi Amini | 117296c | 2016-10-01 02:56:57 +0000 | [diff] [blame] | 81 | StringRef getPassName() const override { |
James Y Knight | 2cc9da9 | 2016-08-12 14:48:09 +0000 | [diff] [blame] | 82 | return "FixAllFDIVSQRT: Erratum Fix LBR34: fix FDIVS/FDIVD/FSQRTS/FSQRTD " |
Chris Dewhurst | 2bad85c | 2016-06-27 14:19:19 +0000 | [diff] [blame] | 83 | "instructions with NOPs and floating-point store"; |
Chris Dewhurst | 0c1e002 | 2016-06-19 11:03:28 +0000 | [diff] [blame] | 84 | } |
| 85 | }; |
James Y Knight | 2cc9da9 | 2016-08-12 14:48:09 +0000 | [diff] [blame] | 86 | } // namespace llvm |
Chris Dewhurst | 4f7cac3 | 2016-05-23 10:56:36 +0000 | [diff] [blame] | 87 | |
Chris Dewhurst | 5047f24 | 2016-06-27 14:35:07 +0000 | [diff] [blame] | 88 | #endif // LLVM_LIB_TARGET_SPARC_LEON_PASSES_H |