1 //===------- LeonPasses.h - Define passes specific to LEON ----------------===//
3 // 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
7 //===----------------------------------------------------------------------===//
10 //===----------------------------------------------------------------------===//
12 #ifndef LLVM_LIB_TARGET_SPARC_LEON_PASSES_H
13 #define LLVM_LIB_TARGET_SPARC_LEON_PASSES_H
15 #include "llvm/CodeGen/MachineBasicBlock.h"
16 #include "llvm/CodeGen/MachineFunctionPass.h"
17 #include "llvm/CodeGen/Passes.h"
20 #include "SparcSubtarget.h"
23 class LLVM_LIBRARY_VISIBILITY LEONMachineFunctionPass
24 : public MachineFunctionPass
{
26 const SparcSubtarget
*Subtarget
;
27 const int LAST_OPERAND
= -1;
29 // this vector holds free registers that we allocate in groups for some of the
31 std::vector
<int> UsedRegisters
;
34 LEONMachineFunctionPass(char &ID
);
36 int GetRegIndexForOperand(MachineInstr
&MI
, int OperandIndex
);
37 void clearUsedRegisterList() { UsedRegisters
.clear(); }
39 void markRegisterUsed(int registerIndex
) {
40 UsedRegisters
.push_back(registerIndex
);
42 int getUnusedFPRegister(MachineRegisterInfo
&MRI
);
45 class LLVM_LIBRARY_VISIBILITY InsertNOPLoad
: public LEONMachineFunctionPass
{
50 bool runOnMachineFunction(MachineFunction
&MF
) override
;
52 StringRef
getPassName() const override
{
53 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";
59 class LLVM_LIBRARY_VISIBILITY DetectRoundChange
60 : public LEONMachineFunctionPass
{
65 bool runOnMachineFunction(MachineFunction
&MF
) override
;
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";
73 class LLVM_LIBRARY_VISIBILITY FixAllFDIVSQRT
: public LEONMachineFunctionPass
{
78 bool runOnMachineFunction(MachineFunction
&MF
) override
;
80 StringRef
getPassName() const override
{
81 return "FixAllFDIVSQRT: Erratum Fix LBR34: fix FDIVS/FDIVD/FSQRTS/FSQRTD "
82 "instructions with NOPs and floating-point store";
87 #endif // LLVM_LIB_TARGET_SPARC_LEON_PASSES_H