blob: 154a2b467e16cf937c5afa8ca6da9fb4b68060b4 [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 Dewhurst4f7cac32016-05-23 10:56:36 +000015#include "llvm/CodeGen/MachineBasicBlock.h"
Chris Dewhurst2bad85c2016-06-27 14:19:19 +000016#include "llvm/CodeGen/MachineFunctionPass.h"
17#include "llvm/CodeGen/Passes.h"
Chris Dewhurst4f7cac32016-05-23 10:56:36 +000018
19#include "Sparc.h"
20#include "SparcSubtarget.h"
21
Benjamin Kramer797fb962016-05-27 10:06:27 +000022namespace llvm {
23class LLVM_LIBRARY_VISIBILITY LEONMachineFunctionPass
24 : public MachineFunctionPass {
Chris Dewhurst4f7cac32016-05-23 10:56:36 +000025protected:
26 const SparcSubtarget *Subtarget;
Chris Dewhurst0c1e0022016-06-19 11:03:28 +000027 const int LAST_OPERAND = -1;
28
Chris Dewhurst2bad85c2016-06-27 14:19:19 +000029 // this vector holds free registers that we allocate in groups for some of the
30 // LEON passes
31 std::vector<int> UsedRegisters;
Chris Dewhurst4f7cac32016-05-23 10:56:36 +000032
33protected:
Chris Dewhurst2bad85c2016-06-27 14:19:19 +000034 LEONMachineFunctionPass(char &ID);
Chris Dewhurst0c1e0022016-06-19 11:03:28 +000035
Chris Dewhurst2bad85c2016-06-27 14:19:19 +000036 int GetRegIndexForOperand(MachineInstr &MI, int OperandIndex);
37 void clearUsedRegisterList() { UsedRegisters.clear(); }
38
39 void markRegisterUsed(int registerIndex) {
40 UsedRegisters.push_back(registerIndex);
41 }
42 int getUnusedFPRegister(MachineRegisterInfo &MRI);
Chris Dewhurst4f7cac32016-05-23 10:56:36 +000043};
44
James Y Knight2cc9da92016-08-12 14:48:09 +000045class LLVM_LIBRARY_VISIBILITY InsertNOPLoad : public LEONMachineFunctionPass {
Chris Dewhurst4f7cac32016-05-23 10:56:36 +000046public:
47 static char ID;
48
Francis Visoiu Mistrih8b617642017-05-18 17:21:13 +000049 InsertNOPLoad();
Chris Dewhurst2bad85c2016-06-27 14:19:19 +000050 bool runOnMachineFunction(MachineFunction &MF) override;
Chris Dewhurst4f7cac32016-05-23 10:56:36 +000051
Mehdi Amini117296c2016-10-01 02:56:57 +000052 StringRef getPassName() const override {
James Y Knight2cc9da92016-08-12 14:48:09 +000053 return "InsertNOPLoad: Erratum Fix LBR35: insert a NOP instruction after "
54 "every single-cycle load instruction when the next instruction is "
55 "another load/store instruction";
Chris Dewhurst4f7cac32016-05-23 10:56:36 +000056 }
57};
Chris Dewhurst0c1e0022016-06-19 11:03:28 +000058
Chris Dewhurst2c3cdd62016-10-19 14:01:06 +000059class LLVM_LIBRARY_VISIBILITY DetectRoundChange
60 : public LEONMachineFunctionPass {
61public:
62 static char ID;
63
Francis Visoiu Mistrih8b617642017-05-18 17:21:13 +000064 DetectRoundChange();
Chris Dewhurst2c3cdd62016-10-19 14:01:06 +000065 bool runOnMachineFunction(MachineFunction &MF) override;
66
67 StringRef getPassName() const override {
68 return "DetectRoundChange: Leon erratum detection: detect any rounding "
69 "mode change request: use only the round-to-nearest rounding mode";
70 }
71};
72
Chris Dewhurst0c1e0022016-06-19 11:03:28 +000073class LLVM_LIBRARY_VISIBILITY FixAllFDIVSQRT : public LEONMachineFunctionPass {
74public:
75 static char ID;
76
Francis Visoiu Mistrih8b617642017-05-18 17:21:13 +000077 FixAllFDIVSQRT();
Chris Dewhurst2bad85c2016-06-27 14:19:19 +000078 bool runOnMachineFunction(MachineFunction &MF) override;
Chris Dewhurst0c1e0022016-06-19 11:03:28 +000079
Mehdi Amini117296c2016-10-01 02:56:57 +000080 StringRef getPassName() const override {
James Y Knight2cc9da92016-08-12 14:48:09 +000081 return "FixAllFDIVSQRT: Erratum Fix LBR34: fix FDIVS/FDIVD/FSQRTS/FSQRTD "
Chris Dewhurst2bad85c2016-06-27 14:19:19 +000082 "instructions with NOPs and floating-point store";
Chris Dewhurst0c1e0022016-06-19 11:03:28 +000083 }
84};
James Y Knight2cc9da92016-08-12 14:48:09 +000085} // namespace llvm
Chris Dewhurst4f7cac32016-05-23 10:56:36 +000086
Chris Dewhurst5047f242016-06-27 14:35:07 +000087#endif // LLVM_LIB_TARGET_SPARC_LEON_PASSES_H