gallium/swr: use ElementCount type arguments for getSplat()
authorJan Zielinski <jan.zielinski@intel.com>
Fri, 13 Mar 2020 19:00:39 +0000 (20:00 +0100)
committerJan Zielinski <jan.zielinski@intel.com>
Fri, 13 Mar 2020 17:56:13 +0000 (17:56 +0000)
Reviewed-by: Alok Hota <alok.hota@intel.com>
In LLVM11, ConstantVector::getSplat() function definition
has changed and the first function argument has now ElementCount type.

Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4188>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4188>

src/gallium/drivers/swr/rasterizer/jitter/builder_misc.cpp
src/gallium/drivers/swr/rasterizer/jitter/builder_misc.h
src/gallium/drivers/swr/rasterizer/jitter/functionpasses/lower_x86.cpp
src/gallium/drivers/swr/rasterizer/jitter/jit_pch.hpp

index 96175692259bf221089daf56fb713c978712931d..4b844e3684ff23353b51a3fd5d7d8b3ee80f98c4 100644 (file)
@@ -172,52 +172,92 @@ namespace SwrJit
 
     Value* Builder::VIMMED1(uint64_t i)
     {
+#if LLVM_VERSION_MAJOR > 10
+        return ConstantVector::getSplat(ElementCount(mVWidth, false), cast<ConstantInt>(C(i)));
+#else
         return ConstantVector::getSplat(mVWidth, cast<ConstantInt>(C(i)));
+#endif
     }
 
     Value* Builder::VIMMED1_16(uint64_t i)
     {
+#if LLVM_VERSION_MAJOR > 10
+        return ConstantVector::getSplat(ElementCount(mVWidth16, false), cast<ConstantInt>(C(i)));
+#else
         return ConstantVector::getSplat(mVWidth16, cast<ConstantInt>(C(i)));
+#endif
     }
 
     Value* Builder::VIMMED1(int i)
     {
+#if LLVM_VERSION_MAJOR > 10
+        return ConstantVector::getSplat(ElementCount(mVWidth, false), cast<ConstantInt>(C(i)));
+#else
         return ConstantVector::getSplat(mVWidth, cast<ConstantInt>(C(i)));
+#endif
     }
 
     Value* Builder::VIMMED1_16(int i)
     {
+#if LLVM_VERSION_MAJOR > 10
+        return ConstantVector::getSplat(ElementCount(mVWidth16, false), cast<ConstantInt>(C(i)));
+#else
         return ConstantVector::getSplat(mVWidth16, cast<ConstantInt>(C(i)));
+#endif
     }
 
     Value* Builder::VIMMED1(uint32_t i)
     {
+#if LLVM_VERSION_MAJOR > 10
+        return ConstantVector::getSplat(ElementCount(mVWidth, false), cast<ConstantInt>(C(i)));
+#else
         return ConstantVector::getSplat(mVWidth, cast<ConstantInt>(C(i)));
+#endif
     }
 
     Value* Builder::VIMMED1_16(uint32_t i)
     {
+#if LLVM_VERSION_MAJOR > 10
+        return ConstantVector::getSplat(ElementCount(mVWidth16, false), cast<ConstantInt>(C(i)));
+#else
         return ConstantVector::getSplat(mVWidth16, cast<ConstantInt>(C(i)));
+#endif
     }
 
     Value* Builder::VIMMED1(float i)
     {
+#if LLVM_VERSION_MAJOR > 10
+        return ConstantVector::getSplat(ElementCount(mVWidth, false), cast<ConstantFP>(C(i)));
+#else
         return ConstantVector::getSplat(mVWidth, cast<ConstantFP>(C(i)));
+#endif
     }
 
     Value* Builder::VIMMED1_16(float i)
     {
+#if LLVM_VERSION_MAJOR > 10
+        return ConstantVector::getSplat(ElementCount(mVWidth16, false), cast<ConstantFP>(C(i)));
+#else
         return ConstantVector::getSplat(mVWidth16, cast<ConstantFP>(C(i)));
+#endif
     }
 
     Value* Builder::VIMMED1(bool i)
     {
+#if LLVM_VERSION_MAJOR > 10
+        return ConstantVector::getSplat(ElementCount(mVWidth, false), cast<ConstantInt>(C(i)));
+#else
         return ConstantVector::getSplat(mVWidth, cast<ConstantInt>(C(i)));
+#endif
     }
 
     Value* Builder::VIMMED1_16(bool i)
     {
+#if LLVM_VERSION_MAJOR > 10
+        return ConstantVector::getSplat(ElementCount(mVWidth16, false), cast<ConstantInt>(C(i)));
+#else
         return ConstantVector::getSplat(mVWidth16, cast<ConstantInt>(C(i)));
+#endif
     }
 
     Value* Builder::VUNDEF_IPTR() { return UndefValue::get(VectorType::get(mInt32PtrTy, mVWidth)); }
index 242c98c9353a4a95acad91355b8669d3b2d31411..616c73b254aee399efa5e0bff10a04910e1151ac 100644 (file)
  ******************************************************************************/
 #pragma once
 
-#if LLVM_VERSION_MAJOR > 10
-    typedef llvm::Align AlignType;
-#else
-    typedef unsigned AlignType;
-#endif
-
 Constant* C(bool i);
 Constant* C(char i);
 Constant* C(uint8_t i);
index 3c728084afe1d650853de5e30ae6fd957ffa2911..f6c09600d99486d05087f8f28f1fbea9a90c389e 100644 (file)
@@ -48,12 +48,6 @@ namespace SwrJit
 {
     using namespace llvm;
 
-#if LLVM_VERSION_MAJOR > 10
-    typedef unsigned IntrinsicID;
-#else
-    typedef Intrinsic::ID IntrinsicID;
-#endif
-
     enum TargetArch
     {
         AVX    = 0,
@@ -512,10 +506,10 @@ namespace SwrJit
         auto     vi1Mask     = pCallInst->getArgOperand(3);
         auto     i8Scale     = pCallInst->getArgOperand(4);
 
-        pBase             = B->POINTER_CAST(pBase, PointerType::get(B->mInt8Ty, 0));
-        uint32_t numElem  = vSrc->getType()->getVectorNumElements();
-        auto     i32Scale = B->Z_EXT(i8Scale, B->mInt32Ty);
-        auto     srcTy    = vSrc->getType()->getVectorElementType();
+        pBase              = B->POINTER_CAST(pBase, PointerType::get(B->mInt8Ty, 0));
+        uint32_t numElem   = vSrc->getType()->getVectorNumElements();
+        auto     i32Scale  = B->Z_EXT(i8Scale, B->mInt32Ty);
+        auto     srcTy     = vSrc->getType()->getVectorElementType();
         Value*   v32Gather = nullptr;
         if (arch == AVX)
         {
@@ -526,7 +520,11 @@ namespace SwrJit
             B->STORE(vSrc, pTmp);
 
             v32Gather        = UndefValue::get(vSrc->getType());
+#if LLVM_VERSION_MAJOR > 10
+            auto vi32Scale   = ConstantVector::getSplat(ElementCount(numElem, false), cast<ConstantInt>(i32Scale));
+#else
             auto vi32Scale   = ConstantVector::getSplat(numElem, cast<ConstantInt>(i32Scale));
+#endif
             auto vi32Offsets = B->MUL(vi32Indices, vi32Scale);
 
             for (uint32_t i = 0; i < numElem; ++i)
index 6b9a6b3375fb1797a9c429591089557d25cea882..1bdba9d9acdd81b6b53e427f772f4ff1eaaf799d 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (C) 2017-2018 Intel Corporation.   All Rights Reserved.
+ * Copyright (C) 2017-2020 Intel Corporation.   All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -142,6 +142,14 @@ static inline llvm::AttributeSet GetFuncAttribSet(llvm::LLVMContext&       ctx,
 #pragma pop_macro("DEBUG")
 #endif
 
+#if LLVM_VERSION_MAJOR > 10
+    typedef unsigned            IntrinsicID;
+    typedef llvm::Align         AlignType;
+#else
+    typedef llvm::Intrinsic::ID IntrinsicID;
+    typedef unsigned            AlignType;
+#endif
+
 #include <deque>
 #include <list>
 #include <unordered_map>