[llvm] r365106 - [PowerPC] Support constraint code "ww"

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 3 21:44:42 PDT 2019


Author: maskray
Date: Wed Jul  3 21:44:42 2019
New Revision: 365106

URL: http://llvm.org/viewvc/llvm-project?rev=365106&view=rev
Log:
[PowerPC] Support constraint code "ww"

Summary:
"ww" and "ws" are both constraint codes for VSX vector registers that
hold scalar double data. "ww" is preferred for float while "ws" is
preferred for double.

Reviewed By: jsji

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

Modified:
    llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp
    llvm/trunk/test/CodeGen/PowerPC/inlineasm-vsx-reg.ll
    llvm/trunk/test/CodeGen/PowerPC/vec-asm-disabled.ll

Modified: llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp?rev=365106&r1=365105&r2=365106&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp Wed Jul  3 21:44:42 2019
@@ -13962,7 +13962,7 @@ PPCTargetLowering::getConstraintType(Str
     return C_RegisterClass;
   } else if (Constraint == "wa" || Constraint == "wd" ||
              Constraint == "wf" || Constraint == "ws" ||
-             Constraint == "wi") {
+             Constraint == "wi" || Constraint == "ww") {
     return C_RegisterClass; // VSX registers.
   }
   return TargetLowering::getConstraintType(Constraint);
@@ -13990,10 +13990,12 @@ PPCTargetLowering::getSingleConstraintMa
             StringRef(constraint) == "wf") &&
            type->isVectorTy())
     return CW_Register;
-  else if (StringRef(constraint) == "ws" && type->isDoubleTy())
-    return CW_Register;
   else if (StringRef(constraint) == "wi" && type->isIntegerTy(64))
     return CW_Register; // just hold 64-bit integers data.
+  else if (StringRef(constraint) == "ws" && type->isDoubleTy())
+    return CW_Register;
+  else if (StringRef(constraint) == "ww" && type->isFloatTy())
+    return CW_Register;
 
   switch (*constraint) {
   default:
@@ -14079,7 +14081,7 @@ PPCTargetLowering::getRegForInlineAsmCon
              Constraint == "wf" || Constraint == "wi") &&
              Subtarget.hasVSX()) {
     return std::make_pair(0U, &PPC::VSRCRegClass);
-  } else if (Constraint == "ws" && Subtarget.hasVSX()) {
+  } else if ((Constraint == "ws" || Constraint == "ww") && Subtarget.hasVSX()) {
     if (VT == MVT::f32 && Subtarget.hasP8Vector())
       return std::make_pair(0U, &PPC::VSSRCRegClass);
     else

Modified: llvm/trunk/test/CodeGen/PowerPC/inlineasm-vsx-reg.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/inlineasm-vsx-reg.ll?rev=365106&r1=365105&r2=365106&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/PowerPC/inlineasm-vsx-reg.ll (original)
+++ llvm/trunk/test/CodeGen/PowerPC/inlineasm-vsx-reg.ll Wed Jul  3 21:44:42 2019
@@ -38,3 +38,12 @@ define double @test() {
 ; CHECK: mtvsrd v2, r1
 ; CHECK: #NO_APP
 }
+
+define float @test_ww(float %x, float %y) {
+  %1 = tail call float asm "xsmaxdp ${0:x}, ${1:x}, ${2:x}", "=^ww,^ww,^ww"(float %x, float %y)
+  ret float %1
+; CHECK-LABEL: test_ww:
+; CHECK: #APP
+; CHECK: xsmaxdp f1, f1, f2
+; CHECK: #NO_APP
+}

Modified: llvm/trunk/test/CodeGen/PowerPC/vec-asm-disabled.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/vec-asm-disabled.ll?rev=365106&r1=365105&r2=365106&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/PowerPC/vec-asm-disabled.ll (original)
+++ llvm/trunk/test/CodeGen/PowerPC/vec-asm-disabled.ll Wed Jul  3 21:44:42 2019
@@ -19,5 +19,17 @@ entry:
 ; CHECK: error: couldn't allocate output register for constraint 'wi'
 }
 
+define float @test_ww(float %x, float %y) #0 {
+  %1 = tail call float asm "xsmaxdp ${0:x},${1:x},${2:x}", "=^ww,^ww,^ww"(float %x, float %y) #0
+  ret float %1
+; CHECK: error: couldn't allocate output register for constraint 'ww'
+}
+
+define double @test_ws(double %x, double %y) #0 {
+  %1 = tail call double asm "xsmaxdp ${0:x},${1:x},${2:x}", "=^ws,^ws,^ws"(double %x, double %y) #0
+  ret double %1
+; CHECK: error: couldn't allocate output register for constraint 'ws'
+}
+
 attributes #0 = { nounwind "target-features"="-vsx" }
 




More information about the llvm-commits mailing list