<div dir="ltr"><div dir="ltr"><div dir="ltr"><div>First off, awesome project! I love it. Comments inline...</div><div><br></div>On Tue, Nov 6, 2018 at 5:59 PM Dan Ravensloft via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr">The MIPS R5900 core that powers the PlayStation 2's CPU has a hardware bug that affects very short loops of 6 or less instructions where the processor may fail to branch under "special conditions" (don't you love vague hardware manuals?)<div><br></div><div>The obvious solution is to pad the loop with NOPs so that it is bigger than 6 instructions long.</div><div><br></div><div>However, I have a few questions to ask about this.</div><div><br></div><div>First, where would I go about adding a pass that detects and works around this hardware bug? Presumably it would have to go as a pass after instruction selection, but I'm unfamiliar with LLVM internals in this case.</div></div></blockquote><div><br></div><div>Check out a similar pass in the X86 backend: llvm/lib/Target/X86/X86PadShortFunction.cpp</div><div><br></div><div>You'll likely need to use MachineLoopInfo to find the loops. </div><div> </div><div>-Cameron </div></div></div></div></div>