LLVM: lib/Target/Mips/MipsMulMulBugPass.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
29
30#define DEBUG_TYPE "mips-vr4300-mulmul-fix"
31
32using namespace llvm;
33
34namespace {
35
37public:
39
40 StringRef getPassName() const override { return "Mips VR4300 mulmul bugfix"; }
41
44 }
45
47
48 static char ID;
49
50private:
52};
53
54}
55
56INITIALIZE_PASS(MipsMulMulBugFix, "mips-vr4300-mulmul-fix",
57 "Mips VR4300 mulmul bugfix", false, false)
58
59char MipsMulMulBugFix::ID = 0;
60
61bool MipsMulMulBugFix::runOnMachineFunction(MachineFunction &MF) {
63 *static_cast<const MipsInstrInfo *>(MF.getSubtarget().getInstrInfo());
64
66
67 for (auto &MBB : MF)
69
71}
72
74 switch (MI.getOpcode()) {
75 case Mips::FMUL_S:
76 case Mips::FMUL_D:
77 case Mips::FMUL_D32:
78 case Mips::FMUL_D64:
79 return true;
80 default:
81 return false;
82 }
83}
84
86 if (MI.isBranch() || MI.isIndirectBranch() || MI.isCall())
87 return true;
88
89 switch (MI.getOpcode()) {
90 case Mips::MUL:
91 case Mips::FMUL_S:
92 case Mips::FMUL_D:
93 case Mips::FMUL_D32:
94 case Mips::FMUL_D64:
95 case Mips::MULT:
96 case Mips::MULTu:
97 case Mips::DMULT:
98 case Mips::DMULTu:
99 return true;
100 default:
101 return false;
102 }
103}
104
108
110
111
114 MII != E; MII = NextMII) {
115
117
118
119
122
123 const MCInstrDesc &NewMCID = MipsII.get(Mips::NOP);
126 }
127 }
128
130}
131
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static bool isSecondMulOrBranch(const MachineInstr &MI)
Definition MipsMulMulBugPass.cpp:85
static bool isFirstMul(const MachineInstr &MI)
Definition MipsMulMulBugPass.cpp:73
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
FunctionPass class - This class is used to implement most global optimizations.
instr_iterator instr_begin()
Instructions::iterator instr_iterator
instr_iterator instr_end()
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
Properties which a MachineFunction may have at a given point in time.
Representation of each machine instruction.
StringRef - Represent a constant reference to a string, i.e.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
MipsII - This namespace holds all of the target specific flags that instruction info tracks.
This is an optimization pass for GlobalISel generic memory operations.
IterT next_nodbg(IterT It, IterT End, bool SkipPseudoOp=true)
Increment It, then continue incrementing it while it points to a debug instruction.
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
FunctionPass * createMipsMulMulBugPass()
Definition MipsMulMulBugPass.cpp:132