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
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204710
91177308-0d34-0410-b5e6-
96231b3b80d8
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)
.Case("s8", 30)
.Default(-1);
+ if ((CC != 0) && ((int)Options.getATRegNum() == CC))
+ Warning(getLexer().getLoc(), Twine("Used $") + Name + " with \".set at=$"
+ + Name + "\"");
+
return CC;
}
# 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]