Index: lib/Target/Mips/AsmParser/MipsAsmParser.cpp =================================================================== --- lib/Target/Mips/AsmParser/MipsAsmParser.cpp +++ lib/Target/Mips/AsmParser/MipsAsmParser.cpp @@ -265,8 +265,6 @@ unsigned getGPR(int RegNo); - int getATReg(SMLoc Loc); - bool processInstruction(MCInst &Inst, SMLoc IDLoc, SmallVectorImpl &Instructions); @@ -425,6 +423,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); }; } @@ -2041,11 +2043,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); } @@ -2194,6 +2197,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)) { @@ -2384,14 +2397,6 @@ return true; } -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); }