blob: 798f63407e378c5fb59893db4364c640f351dde9 [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
16#include "llvm/CodeGen/Passes.h"
17#include "llvm/CodeGen/MachineFunctionPass.h"
18#include "llvm/CodeGen/MachineBasicBlock.h"
19
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
30 //this vector holds free registers that we allocate in groups for some of the LEON passes
31 std::vector <int> UsedRegisters;
Chris Dewhurst4f7cac32016-05-23 10:56:36 +000032
33protected:
34 LEONMachineFunctionPass(TargetMachine &tm, char& ID);
35 LEONMachineFunctionPass(char& ID);
Chris Dewhurst0c1e0022016-06-19 11:03:28 +000036
37 int GetRegIndexForOperand(MachineInstr& MI, int OperandIndex);
38 void clearUsedRegisterList();
39 void markRegisterUsed(int registerIndex);
40 int getUnusedFPRegister(MachineRegisterInfo& MRI);
Chris Dewhurst4f7cac32016-05-23 10:56:36 +000041};
42
Benjamin Kramer797fb962016-05-27 10:06:27 +000043class LLVM_LIBRARY_VISIBILITY InsertNOPLoad : public LEONMachineFunctionPass {
Chris Dewhurst4f7cac32016-05-23 10:56:36 +000044public:
45 static char ID;
46
47 InsertNOPLoad(TargetMachine &tm);
48 bool runOnMachineFunction(MachineFunction& MF) override;
49
50 const char *getPassName() const override {
51 return "InsertNOPLoad: Erratum Fix LBR35: insert a NOP instruction after every single-cycle load instruction when the next instruction is another load/store instruction";
52 }
53};
Chris Dewhurst0c1e0022016-06-19 11:03:28 +000054
55class LLVM_LIBRARY_VISIBILITY FixFSMULD : public LEONMachineFunctionPass {
56public:
57 static char ID;
58
59 FixFSMULD(TargetMachine &tm);
60 bool runOnMachineFunction(MachineFunction& MF) override;
61
62 const char *getPassName() const override {
63 return "FixFSMULD: Erratum Fix LBR31: do not select FSMULD";
64 }
65};
66
67class LLVM_LIBRARY_VISIBILITY ReplaceFMULS : public LEONMachineFunctionPass {
68public:
69 static char ID;
70
71 ReplaceFMULS(TargetMachine &tm);
72 bool runOnMachineFunction(MachineFunction& MF) override;
73
74 const char *getPassName() const override {
75 return "ReplaceFMULS: Erratum Fix LBR32: replace FMULS instruction with a routine using conversions/double precision operations to replace FMULS";
76 }
77};
78
79class LLVM_LIBRARY_VISIBILITY FixAllFDIVSQRT : public LEONMachineFunctionPass {
80public:
81 static char ID;
82
83 FixAllFDIVSQRT(TargetMachine &tm);
84 bool runOnMachineFunction(MachineFunction& MF) override;
85
86 const char *getPassName() const override {
87 return "FixAllFDIVSQRT: Erratum Fix LBR34: fix FDIVS/FDIVD/FSQRTS/FSQRTD instructions with NOPs and floating-point store";
88 }
89};
Benjamin Kramer797fb962016-05-27 10:06:27 +000090} // namespace llvm
Chris Dewhurst4f7cac32016-05-23 10:56:36 +000091
92#endif