[PATCH] [mips] [IAS] Refactor the function which checks for the availability of AT. NFC.

Toma Tabacu toma.tabacu at imgtec.com
Fri Mar 20 03:54:22 PDT 2015


Remove other WIP from this patch.


http://reviews.llvm.org/D8478

Files:
  lib/Target/Mips/AsmParser/MipsAsmParser.cpp

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<MCInst> &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);
 }

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8478.22339.patch
Type: text/x-patch
Size: 2306 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150320/d749be11/attachment.bin>


More information about the llvm-commits mailing list