aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Headers/hlsl
diff options
context:
space:
mode:
authorXiang Li <python3kgae@outlook.com>2022-05-05 15:31:22 -0700
committerXiang Li <python3kgae@outlook.com>2022-05-30 09:05:29 -0700
commite576280380d3f5221cfcc14e9fabeacc8506a43c (patch)
tree65bb7c9e6bdcc2e333e8c233f5db66366a5faf6f /clang/lib/Headers/hlsl
parentf8239eec8decd3459d4f638b98c4f582add31263 (diff)
downloadllvm-e576280380d3f5221cfcc14e9fabeacc8506a43c.zip
llvm-e576280380d3f5221cfcc14e9fabeacc8506a43c.tar.gz
llvm-e576280380d3f5221cfcc14e9fabeacc8506a43c.tar.bz2
[HLSL] Enable vector types for hlsl.
Vector types in hlsl is using clang ext_vector_type. Declaration of vector types is in builtin header hlsl.h. hlsl.h will be included by default for hlsl shader. Reviewed By: Anastasia Differential Revision: https://reviews.llvm.org/D125052
Diffstat (limited to 'clang/lib/Headers/hlsl')
-rw-r--r--clang/lib/Headers/hlsl/hlsl_basic_types.h64
1 files changed, 64 insertions, 0 deletions
diff --git a/clang/lib/Headers/hlsl/hlsl_basic_types.h b/clang/lib/Headers/hlsl/hlsl_basic_types.h
new file mode 100644
index 0000000..2069990
--- /dev/null
+++ b/clang/lib/Headers/hlsl/hlsl_basic_types.h
@@ -0,0 +1,64 @@
+//===----- hlsl_basic_types.h - HLSL definitions for basic types ----------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _HLSL_HLSL_BASIC_TYPES_H_
+#define _HLSL_HLSL_BASIC_TYPES_H_
+
+// built-in scalar data types:
+
+#ifdef __HLSL_ENABLE_16_BIT
+// 16-bit integer.
+typedef unsigned short uint16_t;
+typedef short int16_t;
+#endif
+
+// unsigned 32-bit integer.
+typedef unsigned int uint;
+
+// 64-bit integer.
+typedef unsigned long uint64_t;
+typedef long int64_t;
+
+// built-in vector data types:
+
+#ifdef __HLSL_ENABLE_16_BIT
+typedef int16_t int16_t2 __attribute__((ext_vector_type(2)));
+typedef int16_t int16_t3 __attribute__((ext_vector_type(3)));
+typedef int16_t int16_t4 __attribute__((ext_vector_type(4)));
+typedef uint16_t uint16_t2 __attribute__((ext_vector_type(2)));
+typedef uint16_t uint16_t3 __attribute__((ext_vector_type(3)));
+typedef uint16_t uint16_t4 __attribute__((ext_vector_type(4)));
+#endif
+
+typedef int int2 __attribute__((ext_vector_type(2)));
+typedef int int3 __attribute__((ext_vector_type(3)));
+typedef int int4 __attribute__((ext_vector_type(4)));
+typedef uint uint2 __attribute__((ext_vector_type(2)));
+typedef uint uint3 __attribute__((ext_vector_type(3)));
+typedef uint uint4 __attribute__((ext_vector_type(4)));
+typedef int64_t int64_t2 __attribute__((ext_vector_type(2)));
+typedef int64_t int64_t3 __attribute__((ext_vector_type(3)));
+typedef int64_t int64_t4 __attribute__((ext_vector_type(4)));
+typedef uint64_t uint64_t2 __attribute__((ext_vector_type(2)));
+typedef uint64_t uint64_t3 __attribute__((ext_vector_type(3)));
+typedef uint64_t uint64_t4 __attribute__((ext_vector_type(4)));
+
+#ifdef __HLSL_ENABLE_16_BIT
+typedef half half2 __attribute__((ext_vector_type(2)));
+typedef half half3 __attribute__((ext_vector_type(3)));
+typedef half half4 __attribute__((ext_vector_type(4)));
+#endif
+
+typedef float float2 __attribute__((ext_vector_type(2)));
+typedef float float3 __attribute__((ext_vector_type(3)));
+typedef float float4 __attribute__((ext_vector_type(4)));
+typedef double double2 __attribute__((ext_vector_type(2)));
+typedef double double3 __attribute__((ext_vector_type(3)));
+typedef double double4 __attribute__((ext_vector_type(4)));
+
+#endif //_HLSL_HLSL_BASIC_TYPES_H_