blob: 1b3d9a7a32f907155f72b5b3040154a5a36d3df8 [file] [log] [blame]
Chris Dewhurst4f7cac32016-05-23 10:56:36 +00001//===------- 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 Dewhurst4f7cac32016-05-23 10:56:36 +000016#include "llvm/CodeGen/MachineBasicBlock.h"
Chris Dewhurst2bad85c2016-06-27 14:19:19 +000017#include "llvm/CodeGen/MachineFunctionPass.h"
18#include "llvm/CodeGen/Passes.h"
Chris Dewhurst4f7cac32016-05-23 10:56:36 +000019
20#include "Sparc.h"
21#include "SparcSubtarget.h"
22
Benjamin Kramer797fb962016-05-27 10:06:27 +000023namespace llvm {
24class LLVM_LIBRARY_VISIBILITY LEONMachineFunctionPass
25 : public MachineFunctionPass {
Chris Dewhurst4f7cac32016-05-23 10:56:36 +000026protected:
27 const SparcSubtarget *Subtarget;
Chris Dewhurst0c1e0022016-06-19 11:03:28 +000028 const int LAST_OPERAND = -1;
29
Chris Dewhurst2bad85c2016-06-27 14:19:19 +000030 // this vector holds free registers that we allocate in groups for some of the
31 // LEON passes
32 std::vector<int> UsedRegisters;
Chris Dewhurst4f7cac32016-05-23 10:56:36 +000033
34protected:
Chris Dewhurst2bad85c2016-06-27 14:19:19 +000035 LEONMachineFunctionPass(char &ID);
Chris Dewhurst0c1e0022016-06-19 11:03:28 +000036
Chris Dewhurst2bad85c2016-06-27 14:19:19 +000037 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 Dewhurst4f7cac32016-05-23 10:56:36 +000044};
45
James Y Knight2cc9da92016-08-12 14:48:09 +000046class LLVM_LIBRARY_VISIBILITY InsertNOPLoad : public LEONMachineFunctionPass {
Chris Dewhurst4f7cac32016-05-23 10:56:36 +000047public:
48 static char ID;
49
Francis Visoiu Mistrih8b617642017-05-18 17:21:13 +000050 InsertNOPLoad();
Chris Dewhurst2bad85c2016-06-27 14:19:19 +000051 bool runOnMachineFunction(MachineFunction &MF) override;
Chris Dewhurst4f7cac32016-05-23 10:56:36 +000052
Mehdi Amini117296c2016-10-01 02:56:57 +000053 StringRef getPassName() const override {
James Y Knight2cc9da92016-08-12 14:48:09 +000054 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 Dewhurst4f7cac32016-05-23 10:56:36 +000057 }
58};
Chris Dewhurst0c1e0022016-06-19 11:03:28 +000059
Chris Dewhurst2c3cdd62016-10-19 14:01:06 +000060class LLVM_LIBRARY_VISIBILITY DetectRoundChange
61 : public LEONMachineFunctionPass {
62public:
63 static char ID;
64
Francis Visoiu Mistrih8b617642017-05-18 17:21:13 +000065 DetectRoundChange();
Chris Dewhurst2c3cdd62016-10-19 14:01:06 +000066 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 Dewhurst0c1e0022016-06-19 11:03:28 +000074class LLVM_LIBRARY_VISIBILITY FixAllFDIVSQRT : public LEONMachineFunctionPass {
75public:
76 static char ID;
77
Francis Visoiu Mistrih8b617642017-05-18 17:21:13 +000078 FixAllFDIVSQRT();
Chris Dewhurst2bad85c2016-06-27 14:19:19 +000079 bool runOnMachineFunction(MachineFunction &MF) override;
Chris Dewhurst0c1e0022016-06-19 11:03:28 +000080
Mehdi Amini117296c2016-10-01 02:56:57 +000081 StringRef getPassName() const override {
James Y Knight2cc9da92016-08-12 14:48:09 +000082 return "FixAllFDIVSQRT: Erratum Fix LBR34: fix FDIVS/FDIVD/FSQRTS/FSQRTD "
Chris Dewhurst2bad85c2016-06-27 14:19:19 +000083 "instructions with NOPs and floating-point store";
Chris Dewhurst0c1e0022016-06-19 11:03:28 +000084 }
85};
James Y Knight2cc9da92016-08-12 14:48:09 +000086} // namespace llvm
Chris Dewhurst4f7cac32016-05-23 10:56:36 +000087
Chris Dewhurst5047f242016-06-27 14:35:07 +000088#endif // LLVM_LIB_TARGET_SPARC_LEON_PASSES_H