• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===------- 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/MachineBasicBlock.h"
17 #include "llvm/CodeGen/MachineFunctionPass.h"
18 #include "llvm/CodeGen/Passes.h"
19 
20 #include "Sparc.h"
21 #include "SparcSubtarget.h"
22 
23 namespace llvm {
24 class LLVM_LIBRARY_VISIBILITY LEONMachineFunctionPass
25     : public MachineFunctionPass {
26 protected:
27   const SparcSubtarget *Subtarget;
28   const int LAST_OPERAND = -1;
29 
30   // this vector holds free registers that we allocate in groups for some of the
31   // LEON passes
32   std::vector<int> UsedRegisters;
33 
34 protected:
35   LEONMachineFunctionPass(TargetMachine &tm, char &ID);
36   LEONMachineFunctionPass(char &ID);
37 
38   int GetRegIndexForOperand(MachineInstr &MI, int OperandIndex);
clearUsedRegisterList()39   void clearUsedRegisterList() { UsedRegisters.clear(); }
40 
markRegisterUsed(int registerIndex)41   void markRegisterUsed(int registerIndex) {
42     UsedRegisters.push_back(registerIndex);
43   }
44   int getUnusedFPRegister(MachineRegisterInfo &MRI);
45 };
46 
47 class LLVM_LIBRARY_VISIBILITY ReplaceSDIV : public LEONMachineFunctionPass {
48 public:
49   static char ID;
50 
51   ReplaceSDIV();
52   ReplaceSDIV(TargetMachine &tm);
53   bool runOnMachineFunction(MachineFunction &MF) override;
54 
getPassName()55   const char *getPassName() const override {
56     return "ReplaceSDIV: Erratum Fix LBR25:  do not emit SDIV, but emit SDIVCC "
57            "instead";
58   }
59 };
60 
61 class LLVM_LIBRARY_VISIBILITY FixCALL : public LEONMachineFunctionPass {
62 public:
63   static char ID;
64 
65   FixCALL(TargetMachine &tm);
66   bool runOnMachineFunction(MachineFunction &MF) override;
67 
getPassName()68   const char *getPassName() const override {
69     return "FixCALL: Erratum Fix LBR26: restrict the size of the immediate "
70            "operand of the CALL instruction to 20 bits";
71   }
72 };
73 
74 class LLVM_LIBRARY_VISIBILITY IgnoreZeroFlag : public LEONMachineFunctionPass {
75 public:
76   static char ID;
77 
78   IgnoreZeroFlag(TargetMachine &tm);
79   bool runOnMachineFunction(MachineFunction &MF) override;
80 
getPassName()81   const char *getPassName() const override {
82     return "IgnoreZeroFlag: Erratum Fix LBR28: do not rely on the zero bit "
83            "flag on a divide overflow for SDIVCC and UDIVCC";
84   }
85 };
86 
87 class LLVM_LIBRARY_VISIBILITY InsertNOPDoublePrecision
88     : public LEONMachineFunctionPass {
89 public:
90   static char ID;
91 
92   InsertNOPDoublePrecision(TargetMachine &tm);
93   bool runOnMachineFunction(MachineFunction &MF) override;
94 
getPassName()95   const char *getPassName() const override {
96     return "InsertNOPDoublePrecision: Erratum Fix LBR30: insert a NOP before "
97            "the double precision floating point instruction";
98   }
99 };
100 
101 class LLVM_LIBRARY_VISIBILITY FixFSMULD : public LEONMachineFunctionPass {
102 public:
103   static char ID;
104 
105   FixFSMULD(TargetMachine &tm);
106   bool runOnMachineFunction(MachineFunction &MF) override;
107 
getPassName()108   const char *getPassName() const override {
109     return "FixFSMULD: Erratum Fix LBR31: do not select FSMULD";
110   }
111 };
112 
113 class LLVM_LIBRARY_VISIBILITY ReplaceFMULS : public LEONMachineFunctionPass {
114 public:
115   static char ID;
116 
117   ReplaceFMULS(TargetMachine &tm);
118   bool runOnMachineFunction(MachineFunction &MF) override;
119 
getPassName()120   const char *getPassName() const override {
121     return "ReplaceFMULS: Erratum Fix LBR32: replace FMULS instruction with a "
122            "routine using conversions/double precision operations to replace "
123            "FMULS";
124   }
125 };
126 
127 class LLVM_LIBRARY_VISIBILITY PreventRoundChange
128     : public LEONMachineFunctionPass {
129 public:
130   static char ID;
131 
132   PreventRoundChange(TargetMachine &tm);
133   bool runOnMachineFunction(MachineFunction &MF) override;
134 
getPassName()135   const char *getPassName() const override {
136     return "PreventRoundChange: Erratum Fix LBR33: prevent any rounding mode "
137            "change request: use only the round-to-nearest rounding mode";
138   }
139 };
140 
141 class LLVM_LIBRARY_VISIBILITY FixAllFDIVSQRT : public LEONMachineFunctionPass {
142 public:
143   static char ID;
144 
145   FixAllFDIVSQRT(TargetMachine &tm);
146   bool runOnMachineFunction(MachineFunction &MF) override;
147 
getPassName()148   const char *getPassName() const override {
149     return "FixAllFDIVSQRT: Erratum Fix LBR34: fix FDIVS/FDIVD/FSQRTS/FSQRTD "
150            "instructions with NOPs and floating-point store";
151   }
152 };
153 
154 class LLVM_LIBRARY_VISIBILITY InsertNOPLoad : public LEONMachineFunctionPass {
155 public:
156   static char ID;
157 
158   InsertNOPLoad(TargetMachine &tm);
159   bool runOnMachineFunction(MachineFunction &MF) override;
160 
getPassName()161   const char *getPassName() const override {
162     return "InsertNOPLoad: insert a NOP instruction after "
163            "every single-cycle load instruction when the next instruction is "
164            "another load/store instruction";
165   }
166 };
167 
168 class LLVM_LIBRARY_VISIBILITY FlushCacheLineSWAP
169     : public LEONMachineFunctionPass {
170 public:
171   static char ID;
172 
173   FlushCacheLineSWAP(TargetMachine &tm);
174   bool runOnMachineFunction(MachineFunction &MF) override;
175 
getPassName()176   const char *getPassName() const override {
177     return "FlushCacheLineSWAP: Erratum Fix LBR36: flush cache line containing "
178            "the lock before performing any of the atomic instructions SWAP and "
179            "LDSTUB";
180   }
181 };
182 
183 class LLVM_LIBRARY_VISIBILITY InsertNOPsLoadStore
184     : public LEONMachineFunctionPass {
185 public:
186   static char ID;
187 
188   InsertNOPsLoadStore(TargetMachine &tm);
189   bool runOnMachineFunction(MachineFunction &MF) override;
190 
getPassName()191   const char *getPassName() const override {
192     return "InsertNOPsLoadStore: Erratum Fix LBR37: insert NOPs between "
193            "single-precision loads and the store, so the number of "
194            "instructions between is 4";
195   }
196 };
197 } // namespace lllvm
198 
199 #endif // LLVM_LIB_TARGET_SPARC_LEON_PASSES_H
200