diff options
| author | Chris Dewhurst <chris.dewhurst@lero.ie> | 2016-10-19 14:01:06 +0000 |
|---|---|---|
| committer | Chris Dewhurst <chris.dewhurst@lero.ie> | 2016-10-19 14:01:06 +0000 |
| commit | 2c3cdd66d27e046547315e9a1480c6ae32ad2bde (patch) | |
| tree | b33eeae1d262463cefc66fe5d9c96c10e1b168b5 /llvm/lib/Target/Sparc/LeonPasses.cpp | |
| parent | 13b6a10e7b01f57089e38b081de7de60e8eb22d2 (diff) | |
| download | bcm5719-llvm-2c3cdd66d27e046547315e9a1480c6ae32ad2bde.tar.gz bcm5719-llvm-2c3cdd66d27e046547315e9a1480c6ae32ad2bde.zip | |
[Sparc][LEON] Detects an erratum on UT699 LEON 3 processors involving rounding mode changes and issues an appropriate user error message.
Differential Revision: https://reviews.llvm.org/D24665
llvm-svn: 284591
Diffstat (limited to 'llvm/lib/Target/Sparc/LeonPasses.cpp')
| -rw-r--r-- | llvm/lib/Target/Sparc/LeonPasses.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/llvm/lib/Target/Sparc/LeonPasses.cpp b/llvm/lib/Target/Sparc/LeonPasses.cpp index 46ae9ccc783..0acc2875daa 100644 --- a/llvm/lib/Target/Sparc/LeonPasses.cpp +++ b/llvm/lib/Target/Sparc/LeonPasses.cpp @@ -16,6 +16,7 @@ #include "llvm/CodeGen/MachineInstr.h" #include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/CodeGen/MachineRegisterInfo.h" +#include "llvm/IR/DiagnosticInfo.h" #include "llvm/IR/LLVMContext.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; @@ -274,6 +275,50 @@ bool ReplaceFMULS::runOnMachineFunction(MachineFunction &MF) { return Modified; } + +//***************************************************************************** +//**** DetectRoundChange pass +//***************************************************************************** +// To prevent any explicit change of the default rounding mode, this pass +// detects any call of the fesetround function. +// A warning is generated to ensure the user knows this has happened. +// +// Detects an erratum in UT699 LEON 3 processor + +char DetectRoundChange::ID = 0; + +DetectRoundChange::DetectRoundChange(TargetMachine &tm) + : LEONMachineFunctionPass(tm, ID) {} + +bool DetectRoundChange::runOnMachineFunction(MachineFunction &MF) { + Subtarget = &MF.getSubtarget<SparcSubtarget>(); + + bool Modified = false; + for (auto MFI = MF.begin(), E = MF.end(); MFI != E; ++MFI) { + MachineBasicBlock &MBB = *MFI; + for (auto MBBI = MBB.begin(), E = MBB.end(); MBBI != E; ++MBBI) { + MachineInstr &MI = *MBBI; + unsigned Opcode = MI.getOpcode(); + if (Opcode == SP::CALL && MI.getNumOperands() > 0) { + MachineOperand &MO = MI.getOperand(0); + + if (MO.isGlobal()) { + StringRef FuncName = MO.getGlobal()->getName(); + if (FuncName.compare_lower("fesetround") == 0) { + errs() << "Error: You are using the detectroundchange " + "option to detect rounding changes that will " + "cause LEON errata. The only way to fix this " + "is to remove the call to fesetround from " + "the source code.\n"; + } + } + } + } + } + + return Modified; +} + //***************************************************************************** //**** FixAllFDIVSQRT pass //***************************************************************************** |

