[llvm] r293798 - [mips] Parse the 'bopt' and 'nobopt' directives in IAS.

Simon Dardis via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 1 10:50:24 PST 2017


Author: sdardis
Date: Wed Feb  1 12:50:24 2017
New Revision: 293798

URL: http://llvm.org/viewvc/llvm-project?rev=293798&view=rev
Log:
[mips] Parse the 'bopt' and 'nobopt' directives in IAS.

The GAS assembler supports the ".set bopt" directive but according
to the sources it doesn't do anything. It's supposed to optimize
branches by filling the delay slot of a branch with it's target.

This patch teaches the MIPS asm parser to accept both and warn in
the case of 'bopt' that the bopt directive is unsupported.

This resolves PR/31841.

Thanks to Sean Bruno for reporting the issue!


Added:
    llvm/trunk/test/MC/Mips/bopt-directive.s
Modified:
    llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp

Modified: llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp?rev=293798&r1=293797&r2=293798&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp (original)
+++ llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp Wed Feb  1 12:50:24 2017
@@ -6030,6 +6030,14 @@ bool MipsAsmParser::parseDirectiveSet()
     return parseSetAtDirective();
   } else if (Tok.getString() == "arch") {
     return parseSetArchDirective();
+  } else if (Tok.getString() == "bopt") {
+    Warning(Tok.getLoc(), "'bopt' feature is unsupported");
+    getParser().Lex();
+    return false;
+  } else if (Tok.getString() == "nobopt") {
+    // We're already running in nobopt mode, so nothing to do.
+    getParser().Lex();
+    return false;
   } else if (Tok.getString() == "fp") {
     return parseSetFpDirective();
   } else if (Tok.getString() == "oddspreg") {

Added: llvm/trunk/test/MC/Mips/bopt-directive.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Mips/bopt-directive.s?rev=293798&view=auto
==============================================================================
--- llvm/trunk/test/MC/Mips/bopt-directive.s (added)
+++ llvm/trunk/test/MC/Mips/bopt-directive.s Wed Feb  1 12:50:24 2017
@@ -0,0 +1,16 @@
+# RUN: llvm-mc -arch=mips -mcpu=mips32 %s 2>&1 | FileCheck %s
+
+# We don't support the bopt option in the integrated assembler. Given it's
+# single pass nature, it would be quite difficult to implement currently.
+
+# Ensure we parse the bopt & nobopt directives and warn in the bopt case.
+
+# CHECK: warning: 'bopt' feature is unsupported
+# CHECK: nop
+.text
+f:
+.set bopt
+g:
+.set nobopt
+nop
+




More information about the llvm-commits mailing list