OSDN Git Service

[MIPS GlobalISel] narrowScalar G_CONSTANT
authorPetar Avramovic <Petar.Avramovic@rt-rk.com>
Fri, 9 Nov 2018 14:21:16 +0000 (14:21 +0000)
committerPetar Avramovic <Petar.Avramovic@rt-rk.com>
Fri, 9 Nov 2018 14:21:16 +0000 (14:21 +0000)
Legalize s64 G_CONSTANT using narrowScalar on MIPS 32.

Differential Revision: https://reviews.llvm.org/D54255

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@346495 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/Mips/MipsLegalizerInfo.cpp

index 02701f3..6a8688f 100644 (file)
@@ -41,8 +41,7 @@ MipsLegalizerInfo::MipsLegalizerInfo(const MipsSubtarget &ST) {
 
   getActionDefinitionsBuilder(G_CONSTANT)
       .legalFor({s32})
-      .minScalar(0, s32)
-      .customFor({s64});
+      .clampScalar(0, s32, s32);
 
   getActionDefinitionsBuilder(G_GEP)
       .legalFor({{p0, s32}});
@@ -93,27 +92,6 @@ bool MipsLegalizerInfo::legalizeCustom(MachineInstr &MI,
     MI.eraseFromParent();
     break;
   }
-  case G_CONSTANT: {
-
-    unsigned Size = MRI.getType(MI.getOperand(0).getReg()).getSizeInBits();
-    const LLT sHalf = LLT::scalar(Size / 2);
-
-    const APInt &CImmValue = MI.getOperand(1).getCImm()->getValue();
-
-    unsigned ResLow = MRI.createGenericVirtualRegister(sHalf);
-    unsigned ResHigh = MRI.createGenericVirtualRegister(sHalf);
-    MIRBuilder.buildConstant(
-        ResLow, *ConstantInt::get(MI.getMF()->getFunction().getContext(),
-                                  CImmValue.trunc(Size / 2)));
-    MIRBuilder.buildConstant(
-        ResHigh, *ConstantInt::get(MI.getMF()->getFunction().getContext(),
-                                   CImmValue.lshr(Size / 2).trunc(Size / 2)));
-
-    MIRBuilder.buildMerge(MI.getOperand(0).getReg(), {ResLow, ResHigh});
-
-    MI.eraseFromParent();
-    break;
-  }
   default:
     return false;
   }