Index: lib/Target/Mips/AsmParser/MipsAsmParser.cpp =================================================================== --- lib/Target/Mips/AsmParser/MipsAsmParser.cpp +++ lib/Target/Mips/AsmParser/MipsAsmParser.cpp @@ -271,8 +271,6 @@ unsigned getGPR(int RegNo); - int getATReg(SMLoc Loc); - bool processInstruction(MCInst &Inst, SMLoc IDLoc, SmallVectorImpl &Instructions); @@ -431,6 +429,10 @@ /// Warn if RegNo is the current assembler temporary. void warnIfAssemblerTemporary(int RegNo, SMLoc Loc); + + /// Error if AT is set to $0 (i.e. is unavailable). + /// This should be used in pseudo-instruction expansions which need AT. + bool isATAvailable(SMLoc IDLoc); }; } @@ -2047,11 +2049,12 @@ if (isLoad && IsGPR && (BaseRegNum != RegOpNum)) TmpRegNum = RegOpNum; else { - int AT = getATReg(IDLoc); - // At this point we need AT to perform the expansions and we exit if it is - // not available. - if (!AT) + // At this point we need AT to perform the expansions. + // If it is not available, an error is given and then we exit. + if (!isATAvailable(IDLoc)) return; + + unsigned AT = AssemblerOptions.back()->getATRegNum(); TmpRegNum = getReg( (isGP64bit()) ? Mips::GPR64RegClassID : Mips::GPR32RegClassID, AT); } @@ -2200,6 +2203,16 @@ llvm_unreachable("Implement any new match types added!"); } +bool MipsAsmParser::isATAvailable(SMLoc IDLoc) { + // If AT is not available, give an error. + if (AssemblerOptions.back()->getATRegNum() == 0) { + reportParseError( + IDLoc, "pseudo-instruction requires $at, which is not available"); + return false; + } + return true; +} + void MipsAsmParser::warnIfAssemblerTemporary(int RegIndex, SMLoc Loc) { if ((RegIndex != 0) && ((int)AssemblerOptions.back()->getATRegNum() == RegIndex)) { @@ -2382,14 +2395,6 @@ return CC; } -int MipsAsmParser::getATReg(SMLoc Loc) { - int AT = AssemblerOptions.back()->getATRegNum(); - if (AT == 0) - reportParseError(Loc, - "pseudo-instruction requires $at, which is not available"); - return AT; -} - unsigned MipsAsmParser::getReg(int RC, int RegNo) { return *(getContext().getRegisterInfo()->getRegClass(RC).begin() + RegNo); }