[llvm] r249580 - [mips][FastISel] Simple refactoring of MipsFastISel::emitLogicalOP(). NFC.

Vasileios Kalintiris via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 7 11:14:25 PDT 2015


Author: vkalintiris
Date: Wed Oct  7 13:14:24 2015
New Revision: 249580

URL: http://llvm.org/viewvc/llvm-project?rev=249580&view=rev
Log:
[mips][FastISel] Simple refactoring of MipsFastISel::emitLogicalOP(). NFC.

Modified:
    llvm/trunk/lib/Target/Mips/MipsFastISel.cpp

Modified: llvm/trunk/lib/Target/Mips/MipsFastISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsFastISel.cpp?rev=249580&r1=249579&r2=249580&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/MipsFastISel.cpp (original)
+++ llvm/trunk/lib/Target/Mips/MipsFastISel.cpp Wed Oct  7 13:14:24 2015
@@ -236,32 +236,36 @@ unsigned MipsFastISel::emitLogicalOp(uns
     std::swap(LHS, RHS);
 
   unsigned Opc;
-  if (ISDOpc == ISD::AND) {
-    Opc = Mips::AND;
-  } else if (ISDOpc == ISD::OR) {
-    Opc = Mips::OR;
-  } else if (ISDOpc == ISD::XOR) {
-    Opc = Mips::XOR;
-  } else
+  switch (ISDOpc) {
+    case ISD::AND:
+      Opc = Mips::AND;
+      break;
+    case ISD::OR:
+      Opc = Mips::OR;
+      break;
+    case ISD::XOR:
+      Opc = Mips::XOR;
+      break;
+    default:
     llvm_unreachable("unexpected opcode");
+  }
 
   unsigned LHSReg = getRegForValue(LHS);
-  unsigned ResultReg = createResultReg(&Mips::GPR32RegClass);
-  if (!ResultReg)
-    return 0;
-
-  unsigned RHSReg;
   if (!LHSReg)
     return 0;
 
+  unsigned RHSReg;
   if (const auto *C = dyn_cast<ConstantInt>(RHS))
     RHSReg = materializeInt(C, MVT::i32);
   else
     RHSReg = getRegForValue(RHS);
-
   if (!RHSReg)
     return 0;
 
+  unsigned ResultReg = createResultReg(&Mips::GPR32RegClass);
+  if (!ResultReg)
+    return 0;
+
   emitInst(Opc, ResultReg).addReg(LHSReg).addReg(RHSReg);
   return ResultReg;
 }




More information about the llvm-commits mailing list