diff options
author | Daniel Sanders <daniel.sanders@imgtec.com> | 2014-03-25 11:16:03 +0000 |
---|---|---|
committer | Daniel Sanders <daniel.sanders@imgtec.com> | 2014-03-25 11:16:03 +0000 |
commit | b1d7e53a2630d3a51f3c7242655ccc1235c9f88b (patch) | |
tree | e31b3017e635d1149a8adb68275297a87fe4415a /llvm/lib | |
parent | e231ae9e3a5b293a16aecd281e13f8d59b4d1393 (diff) | |
download | bcm5719-llvm-b1d7e53a2630d3a51f3c7242655ccc1235c9f88b.tar.gz bcm5719-llvm-b1d7e53a2630d3a51f3c7242655ccc1235c9f88b.zip |
[mips] Correct testcase for .set at=$reg and emit the new warnings for numeric registers too.
Summary:
Remove the XFAIL added in my previous commit and correct the test such that
it correctly tests the expansion of the assembler temporary.
Also added a test to check that $at is always $1 when written by the
user.
Corrected the new assembler temporary warnings so that they are emitted for
numeric registers too.
Differential Revision: http://llvm-reviews.chandlerc.com/D3169
llvm-svn: 204711
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp b/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp index 0a6aee4bcee..74e19c5be33 100644 --- a/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp +++ b/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp @@ -250,6 +250,9 @@ class MipsAsmParser : public MCTargetAsmParser { int getATReg(); + // Warn if RegNo is the current assembler temporary. + void warnIfAssemblerTemporary(int RegNo); + bool processInstruction(MCInst &Inst, SMLoc IDLoc, SmallVectorImpl<MCInst> &Instructions); @@ -982,19 +985,23 @@ bool MipsAsmParser::MatchAndEmitInstruction( return true; } -int MipsAsmParser::matchCPURegisterName(StringRef Name) { - int CC; - - 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) +void MipsAsmParser::warnIfAssemblerTemporary(int RegNo) { + if ((RegNo != 0) && ((int)Options.getATRegNum() == RegNo)) { + if (RegNo == 1) Warning(getLexer().getLoc(), "Used $at without \".set noat\""); - return 1; + else + Warning(getLexer().getLoc(), Twine("Used $") + Twine(RegNo) + + " with \".set at=$" + Twine(RegNo) + + "\""); } +} + +int MipsAsmParser::matchCPURegisterName(StringRef Name) { + int CC; CC = StringSwitch<unsigned>(Name) .Case("zero", 0) + .Case("at", 1) .Case("a0", 4) .Case("a1", 5) .Case("a2", 6) @@ -1044,9 +1051,7 @@ 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 + "\""); + warnIfAssemblerTemporary(CC); return CC; } @@ -1199,6 +1204,9 @@ int MipsAsmParser::matchRegisterByNumber(unsigned RegNum, unsigned RegClass) { getContext().getRegisterInfo()->getRegClass(RegClass).getNumRegs()) return -1; + if (RegClass == Mips::GPR32RegClassID || RegClass == Mips::GPR64RegClassID) + warnIfAssemblerTemporary(RegNum); + return getReg(RegClass, RegNum); } |