Browse Source

Merge remote-tracking branch 'upstream/master' into integration

Tex Riddell 8 years ago
parent
commit
2d3ce8ef22

+ 6 - 6
lib/HLSL/HLOperationLowerExtension.cpp

@@ -176,6 +176,9 @@ enum {
 // size.
 static unsigned GetReplicatedVectorSize(llvm::CallInst *CI) {
   unsigned commonVectorSize = NO_COMMON_VECTOR_SIZE;
+  Type *RetTy = CI->getType();
+  if (RetTy->isVectorTy())
+    commonVectorSize = RetTy->getVectorNumElements();
   for (unsigned i = 0; i < CI->getNumArgOperands(); ++i) {
     Type *Ty = CI->getArgOperand(i)->getType();
     if (Ty->isVectorTy()) {
@@ -199,15 +202,12 @@ class ReplicatedFunctionTypeTranslator : public FunctionTypeTranslator {
 
     // Result should be vector or void.
     Type *RetTy = CI->getType();
+    if (!RetTy->isVoidTy() && !RetTy->isVectorTy())
+      return nullptr;
+
     if (RetTy->isVectorTy()) {
-      if (RetTy->getVectorNumElements() != commonVectorSize)
-        return nullptr;
       RetTy = RetTy->getVectorElementType();
     }
-    else {
-      if (!RetTy->isVoidTy())
-        return nullptr;
-    }
 
     return RetTy;
   }

+ 0 - 51
tools/clang/INSTALL.txt

@@ -1,51 +0,0 @@
-Copyright (C) Microsoft Corporation. All rights reserved.
-Licensed under the MIT license. See COPYRIGHT in the project root for full licence information.
-//===----------------------------------------------------------------------===//
-// Clang Installation Instructions
-//===----------------------------------------------------------------------===//
-
-These instructions describe how to build and install Clang.
-
-//===----------------------------------------------------------------------===//
-// Step 1: Organization
-//===----------------------------------------------------------------------===//
-
-Clang is designed to be built as part of an LLVM build. Assuming that the LLVM
-source code is located at $LLVM_SRC_ROOT, then the clang source code should be
-installed as:
-
-  $LLVM_SRC_ROOT/tools/clang
-
-The directory is not required to be called clang, but doing so will allow the
-LLVM build system to automatically recognize it and build it along with LLVM.
-
-//===----------------------------------------------------------------------===//
-// Step 2: Configure and Build LLVM
-//===----------------------------------------------------------------------===//
-
-Configure and build your copy of LLVM (see $LLVM_SRC_ROOT/GettingStarted.html
-for more information).
-
-Assuming you installed clang at $LLVM_SRC_ROOT/tools/clang then Clang will
-automatically be built with LLVM. Otherwise, run 'make' in the Clang source
-directory to build Clang.
-
-//===----------------------------------------------------------------------===//
-// Step 3: (Optional) Verify Your Build
-//===----------------------------------------------------------------------===//
-
-It is a good idea to run the Clang tests to make sure your build works
-correctly. From inside the Clang build directory, run 'make test' to run the
-tests.
-
-//===----------------------------------------------------------------------===//
-// Step 4: Install Clang
-//===----------------------------------------------------------------------===//
-
-From inside the Clang build directory, run 'make install' to install the Clang
-compiler and header files into the prefix directory selected when LLVM was
-configured.
-
-The Clang compiler is available as 'clang' and 'clang++'. It supports a gcc like command line
-interface. See the man page for clang (installed into $prefix/share/man/man1)
-for more information.

+ 6 - 8
tools/clang/lib/Sema/SemaHLSL.cpp

@@ -1475,15 +1475,13 @@ static void AddHLSLIntrinsicAttr(FunctionDecl *FD, ASTContext &context,
                               LPCSTR tableName, LPCSTR lowering,
                               const HLSL_INTRINSIC *pIntrinsic) {
   unsigned opcode = (unsigned)pIntrinsic->Op;
-  if (HasUnsignedOpcode(opcode)) {
+  if (HasUnsignedOpcode(opcode) && IsBuiltinTable(tableName)) {
     QualType Ty = FD->getReturnType();
-    if (IsBuiltinTable(tableName)) {
-      IntrinsicOp intrinOp = static_cast<IntrinsicOp>(pIntrinsic->Op);
-      if (pIntrinsic->iOverloadParamIndex != -1) {
-        const FunctionProtoType *FT =
-            FD->getFunctionType()->getAs<FunctionProtoType>();
-        Ty = FT->getParamType(pIntrinsic->iOverloadParamIndex);
-      }
+    IntrinsicOp intrinOp = static_cast<IntrinsicOp>(pIntrinsic->Op);
+    if (pIntrinsic->iOverloadParamIndex != -1) {
+      const FunctionProtoType *FT =
+          FD->getFunctionType()->getAs<FunctionProtoType>();
+      Ty = FT->getParamType(pIntrinsic->iOverloadParamIndex);
     }
 
     // TODO: refine the code for getting element type

+ 1 - 1
tools/clang/unittests/HLSL/ExecutionTest.cpp

@@ -267,7 +267,7 @@ public:
   }
 
   bool CreateDevice(_COM_Outptr_ ID3D12Device **ppDevice) {
-    const D3D_FEATURE_LEVEL FeatureLevelRequired = D3D_FEATURE_LEVEL_12_1;
+    const D3D_FEATURE_LEVEL FeatureLevelRequired = D3D_FEATURE_LEVEL_11_0;
     CComPtr<IDXGIFactory4> factory;
     CComPtr<ID3D12Device> pDevice;
 

+ 55 - 0
tools/clang/unittests/HLSL/ExtensionTest.cpp

@@ -14,6 +14,7 @@
 #include "dxc/Support/microcom.h"
 #include "dxc/dxcapi.internal.h"
 #include "dxc/HLSL/HLOperationLowerExtension.h"
+#include "dxc/HlslIntrinsicOp.h"
 
 ///////////////////////////////////////////////////////////////////////////////
 // Support for test intrinsics.
@@ -78,6 +79,17 @@ static const HLSL_INTRINSIC_ARGUMENT TestFnPack4[] = {
   { "value", AR_QUAL_IN, 1, LITEMPLATE_VECTOR, 1, LICOMPTYPE_FLOAT, 1, 3},
 };
 
+// float<2> = test_rand()
+static const HLSL_INTRINSIC_ARGUMENT TestRand[] = {
+  { "test_rand", AR_QUAL_OUT, 0, LITEMPLATE_SCALAR, 0, LICOMPTYPE_FLOAT, 1, 2 },
+};
+
+// uint = test_rand(uint x)
+static const HLSL_INTRINSIC_ARGUMENT TestUnsigned[] = {
+  { "test_unsigned", AR_QUAL_OUT, 0, LITEMPLATE_SCALAR, 0, LICOMPTYPE_UINT, 1, 1 },
+  { "x", AR_QUAL_IN, 1, LITEMPLATE_VECTOR, 1, LICOMPTYPE_UINT, 1, 1},
+};
+
 struct Intrinsic {
   LPCWSTR hlslName;
   const char *dxilName;
@@ -101,6 +113,10 @@ Intrinsic Intrinsics[] = {
   {L"test_pack_2",  "test_pack_2.$o",  "p", {  8, false, true, -1, countof(TestFnPack2), TestFnPack2}},
   {L"test_pack_3",  "test_pack_3.$o",  "p", {  9, false, true, -1, countof(TestFnPack3), TestFnPack3}},
   {L"test_pack_4",  "test_pack_4.$o",  "p", { 10, false, true, -1, countof(TestFnPack4), TestFnPack4}},
+  {L"test_rand",    "test_rand",       "r", { 11, false, false,-1, countof(TestRand), TestRand}},
+  // Make this intrinsic have the same opcode as an hlsl intrinsic with an unsigned
+  // counterpart for testing purposes.
+  {L"test_unsigned","test_unsigned",   "n", { static_cast<unsigned>(hlsl::IntrinsicOp::IOP_min), false, true, -1, countof(TestUnsigned), TestUnsigned}},
 };
 
 class TestIntrinsicTable : public IDxcIntrinsicTable {
@@ -294,6 +310,8 @@ public:
   TEST_METHOD(CustomIntrinsicName);
   TEST_METHOD(NoLowering);
   TEST_METHOD(PackedLowering);
+  TEST_METHOD(ReplicateLoweringWhenOnlyVectorIsResult);
+  TEST_METHOD(UnsignedOpcodeIsUnchanged);
 };
 
 TEST_F(ExtensionTest, DefineWhenRegisteredThenPreserved) {
@@ -536,3 +554,40 @@ TEST_F(ExtensionTest, PackedLowering) {
     disassembly.npos !=
     disassembly.find("call { float, float } @test_pack_4.float(i32 10, { float, float, float }"));
 }
+
+TEST_F(ExtensionTest, ReplicateLoweringWhenOnlyVectorIsResult) {
+  Compiler c(m_dllSupport);
+  c.RegisterIntrinsicTable(new TestIntrinsicTable());
+  c.Compile(
+    "float2 main(float2 v1 : V1, float2 v2 : V2, float3 v3 : V3) : SV_Target {\n"
+    "  return test_rand();\n"
+    "}\n",
+    { L"/Vd" }, {}
+  );
+  std::string disassembly = c.Disassemble();
+
+  // - replicate strategy works for vector results
+  VERIFY_IS_TRUE(
+    disassembly.npos !=
+    disassembly.find("call float @test_rand(i32 11)"));
+}
+
+TEST_F(ExtensionTest, UnsignedOpcodeIsUnchanged) {
+  Compiler c(m_dllSupport);
+  c.RegisterIntrinsicTable(new TestIntrinsicTable());
+  c.Compile(
+    "uint main(uint v1 : V1) : SV_Target {\n"
+    "  return test_unsigned(v1);\n"
+    "}\n",
+    { L"/Vd" }, {}
+  );
+  std::string disassembly = c.Disassemble();
+
+  // - opcode is unchanged when it matches an hlsl intrinsic with
+  //   an unsigned version.
+  // Note that 113 is the current opcode for IOP_min. If that opcode
+  // changes the test will need to be updated to reflect the new opcode.
+  VERIFY_IS_TRUE(
+    disassembly.npos !=
+    disassembly.find("call i32 @test_unsigned(i32 113, "));
+}

+ 1 - 1
tools/clang/unittests/HLSL/ValidationTest.cpp

@@ -975,7 +975,7 @@ TEST_F(ValidationTest, MultiDimArray) {
                           "%1 = alloca [4 x float]",
                           "%1 = alloca [4 x float]\n"
                           "  %md = alloca [2 x [4 x float]]",
-                          "Array Type only allow one dimension");
+                          "Only one dimension allowed for array type");
 }
 
 TEST_F(ValidationTest, WhenWaveAffectsGradientThenFail) {

+ 1 - 1
utils/hct/hctshortcut.js

@@ -8,7 +8,7 @@
 ///////////////////////////////////////////////////////////////////////////////
 
 //
-// Use this script to createa shortcut on your desktop that will set up the
+// Use this script to create a shortcut on your desktop that will set up the
 // right console environment.
 //
 

+ 2 - 2
utils/hct/hctstart.cmd

@@ -5,9 +5,9 @@ if "%1"=="-?" goto :showhelp
 if "%1"=="-help" goto :showhelp
 if "%1"=="--help" goto :showhelp
 
-rem Default build arch is x86
+rem Default build arch is x64
 if "%BUILD_ARCH%"=="" (
-  set BUILD_ARCH=Win32
+  set BUILD_ARCH=x64
 )
 
 if "%1"=="-x86" (