1 //===------- LeonPasses.h - Define passes specific to LEON ----------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_LIB_TARGET_SPARC_LEON_PASSES_H
14 #define LLVM_LIB_TARGET_SPARC_LEON_PASSES_H
16 #include "llvm/CodeGen/MachineBasicBlock.h"
17 #include "llvm/CodeGen/MachineFunctionPass.h"
18 #include "llvm/CodeGen/Passes.h"
21 #include "SparcSubtarget.h"
24 class LLVM_LIBRARY_VISIBILITY LEONMachineFunctionPass
25 : public MachineFunctionPass {
27 const SparcSubtarget *Subtarget;
28 const int LAST_OPERAND = -1;
30 // this vector holds free registers that we allocate in groups for some of the
32 std::vector<int> UsedRegisters;
35 LEONMachineFunctionPass(TargetMachine &tm, char &ID);
36 LEONMachineFunctionPass(char &ID);
38 int GetRegIndexForOperand(MachineInstr &MI, int OperandIndex);
39 void clearUsedRegisterList() { UsedRegisters.clear(); }
41 void markRegisterUsed(int registerIndex) {
42 UsedRegisters.push_back(registerIndex);
44 int getUnusedFPRegister(MachineRegisterInfo &MRI);
47 class LLVM_LIBRARY_VISIBILITY InsertNOPLoad : public LEONMachineFunctionPass {
51 InsertNOPLoad(TargetMachine &tm);
52 bool runOnMachineFunction(MachineFunction &MF) override;
54 StringRef getPassName() const override {
55 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";
61 class LLVM_LIBRARY_VISIBILITY FixFSMULD : public LEONMachineFunctionPass {
65 FixFSMULD(TargetMachine &tm);
66 bool runOnMachineFunction(MachineFunction &MF) override;
68 StringRef getPassName() const override {
69 return "FixFSMULD: Erratum Fix LBR31: do not select FSMULD";
73 class LLVM_LIBRARY_VISIBILITY ReplaceFMULS : public LEONMachineFunctionPass {
77 ReplaceFMULS(TargetMachine &tm);
78 bool runOnMachineFunction(MachineFunction &MF) override;
80 StringRef getPassName() const override {
81 return "ReplaceFMULS: Erratum Fix LBR32: replace FMULS instruction with a "
82 "routine using conversions/double precision operations to replace "
87 class LLVM_LIBRARY_VISIBILITY DetectRoundChange
88 : public LEONMachineFunctionPass {
92 DetectRoundChange(TargetMachine &tm);
93 bool runOnMachineFunction(MachineFunction &MF) override;
95 StringRef getPassName() const override {
96 return "DetectRoundChange: Leon erratum detection: detect any rounding "
97 "mode change request: use only the round-to-nearest rounding mode";
101 class LLVM_LIBRARY_VISIBILITY FixAllFDIVSQRT : public LEONMachineFunctionPass {
105 FixAllFDIVSQRT(TargetMachine &tm);
106 bool runOnMachineFunction(MachineFunction &MF) override;
108 StringRef getPassName() const override {
109 return "FixAllFDIVSQRT: Erratum Fix LBR34: fix FDIVS/FDIVD/FSQRTS/FSQRTD "
110 "instructions with NOPs and floating-point store";
115 #endif // LLVM_LIB_TARGET_SPARC_LEON_PASSES_H