blob: 9bc4569a12984ac72248f4e8fdb37677e7429ddf [file] [log] [blame]
Chris Dewhurst4f7cac32016-05-23 10:56:36 +00001//===------- LeonPasses.h - Define passes specific to LEON ----------------===//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// 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 Dewhurst4f7cac32016-05-23 10:56:36 +00006//
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 Dewhurst2bad85c2016-06-27 14:19:19 +000015#include "llvm/CodeGen/MachineFunctionPass.h"
Chris Dewhurst4f7cac32016-05-23 10:56:36 +000016
Benjamin Kramer797fb962016-05-27 10:06:27 +000017namespace llvm {
Simon Pilgrimdfc33302020-09-07 17:09:42 +010018class SparcSubtarget;
19
Benjamin Kramer797fb962016-05-27 10:06:27 +000020class LLVM_LIBRARY_VISIBILITY LEONMachineFunctionPass
21 : public MachineFunctionPass {
Chris Dewhurst4f7cac32016-05-23 10:56:36 +000022protected:
Simon Pilgrimb3be8592019-11-13 14:15:17 +000023 const SparcSubtarget *Subtarget = nullptr;
Chris Dewhurst0c1e0022016-06-19 11:03:28 +000024 const int LAST_OPERAND = -1;
25
Chris Dewhurst2bad85c2016-06-27 14:19:19 +000026 // this vector holds free registers that we allocate in groups for some of the
27 // LEON passes
28 std::vector<int> UsedRegisters;
Chris Dewhurst4f7cac32016-05-23 10:56:36 +000029
30protected:
Chris Dewhurst2bad85c2016-06-27 14:19:19 +000031 LEONMachineFunctionPass(char &ID);
Chris Dewhurst0c1e0022016-06-19 11:03:28 +000032
Chris Dewhurst2bad85c2016-06-27 14:19:19 +000033 void clearUsedRegisterList() { UsedRegisters.clear(); }
34
35 void markRegisterUsed(int registerIndex) {
36 UsedRegisters.push_back(registerIndex);
37 }
Chris Dewhurst4f7cac32016-05-23 10:56:36 +000038};
39
James Y Knight2cc9da92016-08-12 14:48:09 +000040class LLVM_LIBRARY_VISIBILITY InsertNOPLoad : public LEONMachineFunctionPass {
Chris Dewhurst4f7cac32016-05-23 10:56:36 +000041public:
42 static char ID;
43
Francis Visoiu Mistrih8b617642017-05-18 17:21:13 +000044 InsertNOPLoad();
Chris Dewhurst2bad85c2016-06-27 14:19:19 +000045 bool runOnMachineFunction(MachineFunction &MF) override;
Chris Dewhurst4f7cac32016-05-23 10:56:36 +000046
Mehdi Amini117296c2016-10-01 02:56:57 +000047 StringRef getPassName() const override {
James Y Knight2cc9da92016-08-12 14:48:09 +000048 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 Dewhurst4f7cac32016-05-23 10:56:36 +000051 }
52};
Chris Dewhurst0c1e0022016-06-19 11:03:28 +000053
Chris Dewhurst2c3cdd62016-10-19 14:01:06 +000054class LLVM_LIBRARY_VISIBILITY DetectRoundChange
55 : public LEONMachineFunctionPass {
56public:
57 static char ID;
58
Francis Visoiu Mistrih8b617642017-05-18 17:21:13 +000059 DetectRoundChange();
Chris Dewhurst2c3cdd62016-10-19 14:01:06 +000060 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 Dewhurst0c1e0022016-06-19 11:03:28 +000068class LLVM_LIBRARY_VISIBILITY FixAllFDIVSQRT : public LEONMachineFunctionPass {
69public:
70 static char ID;
71
Francis Visoiu Mistrih8b617642017-05-18 17:21:13 +000072 FixAllFDIVSQRT();
Chris Dewhurst2bad85c2016-06-27 14:19:19 +000073 bool runOnMachineFunction(MachineFunction &MF) override;
Chris Dewhurst0c1e0022016-06-19 11:03:28 +000074
Mehdi Amini117296c2016-10-01 02:56:57 +000075 StringRef getPassName() const override {
James Y Knight2cc9da92016-08-12 14:48:09 +000076 return "FixAllFDIVSQRT: Erratum Fix LBR34: fix FDIVS/FDIVD/FSQRTS/FSQRTD "
Chris Dewhurst2bad85c2016-06-27 14:19:19 +000077 "instructions with NOPs and floating-point store";
Chris Dewhurst0c1e0022016-06-19 11:03:28 +000078 }
79};
James Y Knight2cc9da92016-08-12 14:48:09 +000080} // namespace llvm
Chris Dewhurst4f7cac32016-05-23 10:56:36 +000081
Chris Dewhurst5047f242016-06-27 14:35:07 +000082#endif // LLVM_LIB_TARGET_SPARC_LEON_PASSES_H