1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 19:12:56 +02:00

[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

llvm-svn: 204710
This commit is contained in:
Daniel Sanders 2014-03-25 10:57:07 +00:00
parent 8ca9daff27
commit 3b63d409c9
2 changed files with 12 additions and 3 deletions

View File

@ -985,8 +985,13 @@ bool MipsAsmParser::MatchAndEmitInstruction(
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(StringRef Name) {
.Case("s8", 30)
.Default(-1);
if ((CC != 0) && ((int)Options.getATRegNum() == CC))
Warning(getLexer().getLoc(), Twine("Used $") + Name + " with \".set at=$"
+ Name + "\"");
return CC;
}

View File

@ -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]