[llvm] r204710 - [mips] Fix assembler temporary expansion and add associated warnings about the use of $at.
Daniel Sanders
daniel.sanders at imgtec.com
Tue Mar 25 03:57:07 PDT 2014
Author: dsanders
Date: Tue Mar 25 05:57:07 2014
New Revision: 204710
URL: http://llvm.org/viewvc/llvm-project?rev=204710&view=rev
Log:
[mips] Fix assembler temporary expansion and add associated warnings about the use of $at.
Summary:
The assembler temporary is normally $at ($1) but can be reassigned using
'.set at=$reg'. Regardless of which register is nominated as the assembler
temporary, $at remains $1 when written by the user.
Adds warnings under the following conditions:
* The register nominated as the assembler temporary is used by the user.
* '.set noat' is in effect and $at is used by the user.
Both of these only work for named registers. I have a follow up commit that makes it work for numeric registers as well.
XFAIL set-at-directive.s since it incorrectly tests that $at is redefined by
'.set at=$reg'. Testcases will follow in a separate commit.
Patch by David Chisnall
His work was sponsored by: DARPA, AFRL
Differential Revision: http://llvm-reviews.chandlerc.com/D3167
Modified:
llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
llvm/trunk/test/MC/Mips/set-at-directive.s
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=204710&r1=204709&r2=204710&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp (original)
+++ llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp Tue Mar 25 05:57:07 2014
@@ -985,8 +985,13 @@ bool MipsAsmParser::MatchAndEmitInstruct
int MipsAsmParser::matchCPURegisterName(StringRef Name) {
int CC;
- if (Name == "at")
- return getATReg();
+ if (Name == "at") {
+ // If noat is set then the at register is 0, otherwise it's defined as a
+ // specific register. Warn if the assembler is free to use it.
+ if (Options.getATRegNum() != 0)
+ Warning(getLexer().getLoc(), "Used $at without \".set noat\"");
+ return 1;
+ }
CC = StringSwitch<unsigned>(Name)
.Case("zero", 0)
@@ -1039,6 +1044,10 @@ int MipsAsmParser::matchCPURegisterName(
.Case("s8", 30)
.Default(-1);
+ if ((CC != 0) && ((int)Options.getATRegNum() == CC))
+ Warning(getLexer().getLoc(), Twine("Used $") + Name + " with \".set at=$"
+ + Name + "\"");
+
return CC;
}
Modified: llvm/trunk/test/MC/Mips/set-at-directive.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Mips/set-at-directive.s?rev=204710&r1=204709&r2=204710&view=diff
==============================================================================
--- llvm/trunk/test/MC/Mips/set-at-directive.s (original)
+++ llvm/trunk/test/MC/Mips/set-at-directive.s Tue Mar 25 05:57:07 2014
@@ -2,7 +2,7 @@
# RUN: FileCheck %s
# Check that the assembler can handle the documented syntax
# for ".set at" and set the correct value.
-
+# XFAIL:
.text
foo:
# CHECK: jr $1 # encoding: [0x08,0x00,0x20,0x00]
More information about the llvm-commits
mailing list