]> granicus.if.org Git - llvm/commitdiff
[mips] Parse the 'bopt' and 'nobopt' directives in IAS.
authorSimon Dardis <simon.dardis@imgtec.com>
Wed, 1 Feb 2017 18:50:24 +0000 (18:50 +0000)
committerSimon Dardis <simon.dardis@imgtec.com>
Wed, 1 Feb 2017 18:50:24 +0000 (18:50 +0000)
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!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293798 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/Mips/AsmParser/MipsAsmParser.cpp
test/MC/Mips/bopt-directive.s [new file with mode: 0644]

index 504a4983036b5d5ccd3b331d0d69160f7998cd2f..015e6adad5ce4d3b667cee0ee46e2422888e84cf 100644 (file)
@@ -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") {
diff --git a/test/MC/Mips/bopt-directive.s b/test/MC/Mips/bopt-directive.s
new file mode 100644 (file)
index 0000000..63e2a05
--- /dev/null
@@ -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
+