Chris Dewhurst | 4f7cac3 | 2016-05-23 10:56:36 +0000 | [diff] [blame] | 1 | //===------- LeonPasses.h - Define passes specific to LEON ----------------===// |
| 2 | // |
Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
Chris Dewhurst | 4f7cac3 | 2016-05-23 10:56:36 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | // |
| 9 | // |
| 10 | //===----------------------------------------------------------------------===// |
| 11 | |
| 12 | #ifndef LLVM_LIB_TARGET_SPARC_LEON_PASSES_H |
| 13 | #define LLVM_LIB_TARGET_SPARC_LEON_PASSES_H |
| 14 | |
Chris Dewhurst | 2bad85c | 2016-06-27 14:19:19 +0000 | [diff] [blame] | 15 | #include "llvm/CodeGen/MachineFunctionPass.h" |
Chris Dewhurst | 4f7cac3 | 2016-05-23 10:56:36 +0000 | [diff] [blame] | 16 | |
Benjamin Kramer | 797fb96 | 2016-05-27 10:06:27 +0000 | [diff] [blame] | 17 | namespace llvm { |
Simon Pilgrim | dfc3330 | 2020-09-07 17:09:42 +0100 | [diff] [blame] | 18 | class SparcSubtarget; |
| 19 | |
Benjamin Kramer | 797fb96 | 2016-05-27 10:06:27 +0000 | [diff] [blame] | 20 | class LLVM_LIBRARY_VISIBILITY LEONMachineFunctionPass |
| 21 | : public MachineFunctionPass { |
Chris Dewhurst | 4f7cac3 | 2016-05-23 10:56:36 +0000 | [diff] [blame] | 22 | protected: |
Simon Pilgrim | b3be859 | 2019-11-13 14:15:17 +0000 | [diff] [blame] | 23 | const SparcSubtarget *Subtarget = nullptr; |
Chris Dewhurst | 0c1e002 | 2016-06-19 11:03:28 +0000 | [diff] [blame] | 24 | const int LAST_OPERAND = -1; |
| 25 | |
Chris Dewhurst | 2bad85c | 2016-06-27 14:19:19 +0000 | [diff] [blame] | 26 | // this vector holds free registers that we allocate in groups for some of the |
| 27 | // LEON passes |
| 28 | std::vector<int> UsedRegisters; |
Chris Dewhurst | 4f7cac3 | 2016-05-23 10:56:36 +0000 | [diff] [blame] | 29 | |
| 30 | protected: |
Chris Dewhurst | 2bad85c | 2016-06-27 14:19:19 +0000 | [diff] [blame] | 31 | LEONMachineFunctionPass(char &ID); |
Chris Dewhurst | 0c1e002 | 2016-06-19 11:03:28 +0000 | [diff] [blame] | 32 | |
Chris Dewhurst | 2bad85c | 2016-06-27 14:19:19 +0000 | [diff] [blame] | 33 | void clearUsedRegisterList() { UsedRegisters.clear(); } |
| 34 | |
| 35 | void markRegisterUsed(int registerIndex) { |
| 36 | UsedRegisters.push_back(registerIndex); |
| 37 | } |
Chris Dewhurst | 4f7cac3 | 2016-05-23 10:56:36 +0000 | [diff] [blame] | 38 | }; |
| 39 | |
James Y Knight | 2cc9da9 | 2016-08-12 14:48:09 +0000 | [diff] [blame] | 40 | class LLVM_LIBRARY_VISIBILITY InsertNOPLoad : public LEONMachineFunctionPass { |
Chris Dewhurst | 4f7cac3 | 2016-05-23 10:56:36 +0000 | [diff] [blame] | 41 | public: |
| 42 | static char ID; |
| 43 | |
Francis Visoiu Mistrih | 8b61764 | 2017-05-18 17:21:13 +0000 | [diff] [blame] | 44 | InsertNOPLoad(); |
Chris Dewhurst | 2bad85c | 2016-06-27 14:19:19 +0000 | [diff] [blame] | 45 | bool runOnMachineFunction(MachineFunction &MF) override; |
Chris Dewhurst | 4f7cac3 | 2016-05-23 10:56:36 +0000 | [diff] [blame] | 46 | |
Mehdi Amini | 117296c | 2016-10-01 02:56:57 +0000 | [diff] [blame] | 47 | StringRef getPassName() const override { |
James Y Knight | 2cc9da9 | 2016-08-12 14:48:09 +0000 | [diff] [blame] | 48 | return "InsertNOPLoad: Erratum Fix LBR35: insert a NOP instruction after " |
| 49 | "every single-cycle load instruction when the next instruction is " |
| 50 | "another load/store instruction"; |
Chris Dewhurst | 4f7cac3 | 2016-05-23 10:56:36 +0000 | [diff] [blame] | 51 | } |
| 52 | }; |
Chris Dewhurst | 0c1e002 | 2016-06-19 11:03:28 +0000 | [diff] [blame] | 53 | |
Chris Dewhurst | 2c3cdd6 | 2016-10-19 14:01:06 +0000 | [diff] [blame] | 54 | class LLVM_LIBRARY_VISIBILITY DetectRoundChange |
| 55 | : public LEONMachineFunctionPass { |
| 56 | public: |
| 57 | static char ID; |
| 58 | |
Francis Visoiu Mistrih | 8b61764 | 2017-05-18 17:21:13 +0000 | [diff] [blame] | 59 | DetectRoundChange(); |
Chris Dewhurst | 2c3cdd6 | 2016-10-19 14:01:06 +0000 | [diff] [blame] | 60 | bool runOnMachineFunction(MachineFunction &MF) override; |
| 61 | |
| 62 | StringRef getPassName() const override { |
| 63 | return "DetectRoundChange: Leon erratum detection: detect any rounding " |
| 64 | "mode change request: use only the round-to-nearest rounding mode"; |
| 65 | } |
| 66 | }; |
| 67 | |
Chris Dewhurst | 0c1e002 | 2016-06-19 11:03:28 +0000 | [diff] [blame] | 68 | class LLVM_LIBRARY_VISIBILITY FixAllFDIVSQRT : public LEONMachineFunctionPass { |
| 69 | public: |
| 70 | static char ID; |
| 71 | |
Francis Visoiu Mistrih | 8b61764 | 2017-05-18 17:21:13 +0000 | [diff] [blame] | 72 | FixAllFDIVSQRT(); |
Chris Dewhurst | 2bad85c | 2016-06-27 14:19:19 +0000 | [diff] [blame] | 73 | bool runOnMachineFunction(MachineFunction &MF) override; |
Chris Dewhurst | 0c1e002 | 2016-06-19 11:03:28 +0000 | [diff] [blame] | 74 | |
Mehdi Amini | 117296c | 2016-10-01 02:56:57 +0000 | [diff] [blame] | 75 | StringRef getPassName() const override { |
James Y Knight | 2cc9da9 | 2016-08-12 14:48:09 +0000 | [diff] [blame] | 76 | return "FixAllFDIVSQRT: Erratum Fix LBR34: fix FDIVS/FDIVD/FSQRTS/FSQRTD " |
Chris Dewhurst | 2bad85c | 2016-06-27 14:19:19 +0000 | [diff] [blame] | 77 | "instructions with NOPs and floating-point store"; |
Chris Dewhurst | 0c1e002 | 2016-06-19 11:03:28 +0000 | [diff] [blame] | 78 | } |
| 79 | }; |
James Y Knight | 2cc9da9 | 2016-08-12 14:48:09 +0000 | [diff] [blame] | 80 | } // namespace llvm |
Chris Dewhurst | 4f7cac3 | 2016-05-23 10:56:36 +0000 | [diff] [blame] | 81 | |
Chris Dewhurst | 5047f24 | 2016-06-27 14:35:07 +0000 | [diff] [blame] | 82 | #endif // LLVM_LIB_TARGET_SPARC_LEON_PASSES_H |