2016-05-23 18:56:36 +08:00
|
|
|
//===------- LeonPasses.h - Define passes specific to LEON ----------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_LIB_TARGET_SPARC_LEON_PASSES_H
|
|
|
|
#define LLVM_LIB_TARGET_SPARC_LEON_PASSES_H
|
|
|
|
|
|
|
|
#include "llvm/CodeGen/MachineBasicBlock.h"
|
2016-06-27 22:19:19 +08:00
|
|
|
#include "llvm/CodeGen/MachineFunctionPass.h"
|
|
|
|
#include "llvm/CodeGen/Passes.h"
|
2016-05-23 18:56:36 +08:00
|
|
|
|
|
|
|
#include "Sparc.h"
|
|
|
|
#include "SparcSubtarget.h"
|
|
|
|
|
2016-05-27 18:06:27 +08:00
|
|
|
namespace llvm {
|
|
|
|
class LLVM_LIBRARY_VISIBILITY LEONMachineFunctionPass
|
|
|
|
: public MachineFunctionPass {
|
2016-05-23 18:56:36 +08:00
|
|
|
protected:
|
|
|
|
const SparcSubtarget *Subtarget;
|
2016-06-19 19:03:28 +08:00
|
|
|
const int LAST_OPERAND = -1;
|
|
|
|
|
2016-06-27 22:19:19 +08:00
|
|
|
// this vector holds free registers that we allocate in groups for some of the
|
|
|
|
// LEON passes
|
|
|
|
std::vector<int> UsedRegisters;
|
2016-05-23 18:56:36 +08:00
|
|
|
|
|
|
|
protected:
|
2016-06-27 22:19:19 +08:00
|
|
|
LEONMachineFunctionPass(char &ID);
|
|
|
|
|
|
|
|
int GetRegIndexForOperand(MachineInstr &MI, int OperandIndex);
|
|
|
|
void clearUsedRegisterList() { UsedRegisters.clear(); }
|
2016-06-19 19:03:28 +08:00
|
|
|
|
2016-06-27 22:19:19 +08:00
|
|
|
void markRegisterUsed(int registerIndex) {
|
|
|
|
UsedRegisters.push_back(registerIndex);
|
|
|
|
}
|
|
|
|
int getUnusedFPRegister(MachineRegisterInfo &MRI);
|
2016-05-23 18:56:36 +08:00
|
|
|
};
|
|
|
|
|
2016-08-12 22:48:09 +08:00
|
|
|
class LLVM_LIBRARY_VISIBILITY InsertNOPLoad : public LEONMachineFunctionPass {
|
2016-07-08 23:33:56 +08:00
|
|
|
public:
|
|
|
|
static char ID;
|
|
|
|
|
2017-05-19 01:21:13 +08:00
|
|
|
InsertNOPLoad();
|
2016-07-08 23:33:56 +08:00
|
|
|
bool runOnMachineFunction(MachineFunction &MF) override;
|
|
|
|
|
2016-10-01 10:56:57 +08:00
|
|
|
StringRef getPassName() const override {
|
2016-08-12 22:48:09 +08:00
|
|
|
return "InsertNOPLoad: Erratum Fix LBR35: insert a NOP instruction after "
|
|
|
|
"every single-cycle load instruction when the next instruction is "
|
|
|
|
"another load/store instruction";
|
2016-05-23 18:56:36 +08:00
|
|
|
}
|
|
|
|
};
|
2016-06-19 19:03:28 +08:00
|
|
|
|
2016-10-19 22:01:06 +08:00
|
|
|
class LLVM_LIBRARY_VISIBILITY DetectRoundChange
|
|
|
|
: public LEONMachineFunctionPass {
|
|
|
|
public:
|
|
|
|
static char ID;
|
|
|
|
|
2017-05-19 01:21:13 +08:00
|
|
|
DetectRoundChange();
|
2016-10-19 22:01:06 +08:00
|
|
|
bool runOnMachineFunction(MachineFunction &MF) override;
|
|
|
|
|
|
|
|
StringRef getPassName() const override {
|
|
|
|
return "DetectRoundChange: Leon erratum detection: detect any rounding "
|
|
|
|
"mode change request: use only the round-to-nearest rounding mode";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-06-19 19:03:28 +08:00
|
|
|
class LLVM_LIBRARY_VISIBILITY FixAllFDIVSQRT : public LEONMachineFunctionPass {
|
|
|
|
public:
|
|
|
|
static char ID;
|
|
|
|
|
2017-05-19 01:21:13 +08:00
|
|
|
FixAllFDIVSQRT();
|
2016-06-27 22:19:19 +08:00
|
|
|
bool runOnMachineFunction(MachineFunction &MF) override;
|
2016-06-19 19:03:28 +08:00
|
|
|
|
2016-10-01 10:56:57 +08:00
|
|
|
StringRef getPassName() const override {
|
2016-08-12 22:48:09 +08:00
|
|
|
return "FixAllFDIVSQRT: Erratum Fix LBR34: fix FDIVS/FDIVD/FSQRTS/FSQRTD "
|
2016-06-27 22:19:19 +08:00
|
|
|
"instructions with NOPs and floating-point store";
|
2016-06-19 19:03:28 +08:00
|
|
|
}
|
|
|
|
};
|
2016-08-12 22:48:09 +08:00
|
|
|
} // namespace llvm
|
2016-05-23 18:56:36 +08:00
|
|
|
|
2016-06-27 22:35:07 +08:00
|
|
|
#endif // LLVM_LIB_TARGET_SPARC_LEON_PASSES_H
|