blob: a544e322fcb0fd927aaca1ce2b2cb1e60dec0ea8 [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(TargetMachine &tm, char &ID);
36 LEONMachineFunctionPass(char &ID);
Chris Dewhurst0c1e0022016-06-19 11:03:28 +000037
Chris Dewhurst2bad85c2016-06-27 14:19:19 +000038 int GetRegIndexForOperand(MachineInstr &MI, int OperandIndex);
39 void clearUsedRegisterList() { UsedRegisters.clear(); }
40
41 void markRegisterUsed(int registerIndex) {
42 UsedRegisters.push_back(registerIndex);
43 }
44 int getUnusedFPRegister(MachineRegisterInfo &MRI);
Chris Dewhurst4f7cac32016-05-23 10:56:36 +000045};
46
James Y Knight2cc9da92016-08-12 14:48:09 +000047class LLVM_LIBRARY_VISIBILITY InsertNOPLoad : public LEONMachineFunctionPass {
Chris Dewhurst4f7cac32016-05-23 10:56:36 +000048public:
49 static char ID;
50
James Y Knight2cc9da92016-08-12 14:48:09 +000051 InsertNOPLoad(TargetMachine &tm);
Chris Dewhurst2bad85c2016-06-27 14:19:19 +000052 bool runOnMachineFunction(MachineFunction &MF) override;
Chris Dewhurst4f7cac32016-05-23 10:56:36 +000053
54 const char *getPassName() const override {
James Y Knight2cc9da92016-08-12 14:48:09 +000055 return "InsertNOPLoad: Erratum Fix LBR35: insert a NOP instruction after "
56 "every single-cycle load instruction when the next instruction is "
57 "another load/store instruction";
Chris Dewhurst4f7cac32016-05-23 10:56:36 +000058 }
59};
Chris Dewhurst0c1e0022016-06-19 11:03:28 +000060
61class LLVM_LIBRARY_VISIBILITY FixFSMULD : public LEONMachineFunctionPass {
62public:
63 static char ID;
64
65 FixFSMULD(TargetMachine &tm);
Chris Dewhurst2bad85c2016-06-27 14:19:19 +000066 bool runOnMachineFunction(MachineFunction &MF) override;
Chris Dewhurst0c1e0022016-06-19 11:03:28 +000067
68 const char *getPassName() const override {
James Y Knight2cc9da92016-08-12 14:48:09 +000069 return "FixFSMULD: Erratum Fix LBR31: do not select FSMULD";
Chris Dewhurst0c1e0022016-06-19 11:03:28 +000070 }
71};
72
73class LLVM_LIBRARY_VISIBILITY ReplaceFMULS : public LEONMachineFunctionPass {
74public:
75 static char ID;
76
77 ReplaceFMULS(TargetMachine &tm);
Chris Dewhurst2bad85c2016-06-27 14:19:19 +000078 bool runOnMachineFunction(MachineFunction &MF) override;
Chris Dewhurst0c1e0022016-06-19 11:03:28 +000079
80 const char *getPassName() const override {
James Y Knight2cc9da92016-08-12 14:48:09 +000081 return "ReplaceFMULS: Erratum Fix LBR32: replace FMULS instruction with a "
Chris Dewhurst2bad85c2016-06-27 14:19:19 +000082 "routine using conversions/double precision operations to replace "
83 "FMULS";
Chris Dewhurst0c1e0022016-06-19 11:03:28 +000084 }
85};
86
87class LLVM_LIBRARY_VISIBILITY FixAllFDIVSQRT : public LEONMachineFunctionPass {
88public:
89 static char ID;
90
91 FixAllFDIVSQRT(TargetMachine &tm);
Chris Dewhurst2bad85c2016-06-27 14:19:19 +000092 bool runOnMachineFunction(MachineFunction &MF) override;
Chris Dewhurst0c1e0022016-06-19 11:03:28 +000093
94 const char *getPassName() const override {
James Y Knight2cc9da92016-08-12 14:48:09 +000095 return "FixAllFDIVSQRT: Erratum Fix LBR34: fix FDIVS/FDIVD/FSQRTS/FSQRTD "
Chris Dewhurst2bad85c2016-06-27 14:19:19 +000096 "instructions with NOPs and floating-point store";
Chris Dewhurst0c1e0022016-06-19 11:03:28 +000097 }
98};
James Y Knight2cc9da92016-08-12 14:48:09 +000099} // namespace llvm
Chris Dewhurst4f7cac32016-05-23 10:56:36 +0000100
Chris Dewhurst5047f242016-06-27 14:35:07 +0000101#endif // LLVM_LIB_TARGET_SPARC_LEON_PASSES_H