beanz created this revision.
beanz added reviewers: python3kgae, pow2clk, bob80905.
Herald added a subscriber: Anastasia.
Herald added a project: All.
beanz requested review of this revision.
Herald added a project: clang.

Should have done this from the start. Since all the injected AST types
are in the hlsl namespace we should also put the header-defined types
and functions in there too.

This updates the basic_types test to run once with the namespaced types
and once without, and adds using declarations or namespaces calls in
other tests.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D135973

Files:
  clang/lib/Headers/hlsl/hlsl_basic_types.h
  clang/lib/Headers/hlsl/hlsl_intrinsics.h
  clang/test/CodeGenHLSL/basic_types.hlsl
  clang/test/CodeGenHLSL/builtins/abs.hlsl
  clang/test/CodeGenHLSL/builtins/ceil.hlsl
  clang/test/CodeGenHLSL/builtins/sqrt.hlsl
  clang/test/SemaHLSL/Wave.hlsl
  clang/test/SemaHLSL/WaveBuiltinAvailability.hlsl

Index: clang/test/SemaHLSL/WaveBuiltinAvailability.hlsl
===================================================================
--- clang/test/SemaHLSL/WaveBuiltinAvailability.hlsl
+++ clang/test/SemaHLSL/WaveBuiltinAvailability.hlsl
@@ -5,5 +5,5 @@
     // expected-warning@#site {{'WaveActiveCountBits' is only available on HLSL ShaderModel 6.0 or newer}}
     // expected-note@hlsl/hlsl_intrinsics.h:* {{'WaveActiveCountBits' has been marked as being introduced in HLSL ShaderModel 6.0 here, but the deployment target is HLSL ShaderModel 5.0}}
     // expected-note@#site {{enclose 'WaveActiveCountBits' in a __builtin_available check to silence this warning}}
-    return WaveActiveCountBits(b); // #site
+    return hlsl::WaveActiveCountBits(b); // #site
 }
Index: clang/test/SemaHLSL/Wave.hlsl
===================================================================
--- clang/test/SemaHLSL/Wave.hlsl
+++ clang/test/SemaHLSL/Wave.hlsl
@@ -4,5 +4,5 @@
 
 // expected-no-diagnostics
 unsigned foo(bool b) {
-    return WaveActiveCountBits(b);
+    return hlsl::WaveActiveCountBits(b);
 }
Index: clang/test/CodeGenHLSL/builtins/sqrt.hlsl
===================================================================
--- clang/test/CodeGenHLSL/builtins/sqrt.hlsl
+++ clang/test/CodeGenHLSL/builtins/sqrt.hlsl
@@ -5,6 +5,8 @@
 // RUN:   dxil-pc-shadermodel6.2-library %s -emit-llvm -disable-llvm-passes \
 // RUN:   -o - | FileCheck %s --check-prefix=NO_HALF
 
+using hlsl::sqrt;
+
 double sqrt_d(double x)
 {
   return sqrt(x);
Index: clang/test/CodeGenHLSL/builtins/ceil.hlsl
===================================================================
--- clang/test/CodeGenHLSL/builtins/ceil.hlsl
+++ clang/test/CodeGenHLSL/builtins/ceil.hlsl
@@ -5,6 +5,8 @@
 // RUN:   dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
 // RUN:   -D__HLSL_ENABLE_16_BIT -o - | FileCheck %s --check-prefix=NO_HALF
 
+using hlsl::ceil;
+
 // CHECK: define noundef half @
 // CHECK: call half @llvm.ceil.f16(
 // NO_HALF: define noundef float @"?test_ceil_half@@YA$halff@$halff@@Z"(
Index: clang/test/CodeGenHLSL/builtins/abs.hlsl
===================================================================
--- clang/test/CodeGenHLSL/builtins/abs.hlsl
+++ clang/test/CodeGenHLSL/builtins/abs.hlsl
@@ -5,6 +5,7 @@
 // RUN:   dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
 // RUN:   -D__HLSL_ENABLE_16_BIT -o - | FileCheck %s --check-prefix=NO_HALF
 
+using hlsl::abs;
 
 // CHECK: define noundef signext i16 @
 // FIXME: int16_t is promoted to i32 now. Change to abs.i16 once it is fixed.
Index: clang/test/CodeGenHLSL/basic_types.hlsl
===================================================================
--- clang/test/CodeGenHLSL/basic_types.hlsl
+++ clang/test/CodeGenHLSL/basic_types.hlsl
@@ -1,6 +1,9 @@
 // RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \
 // RUN:   dxil-pc-shadermodel6.3-library %s -fnative-half-type \
 // RUN:   -emit-llvm -disable-llvm-passes -o - | FileCheck %s
+// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \
+// RUN:   dxil-pc-shadermodel6.3-library %s -fnative-half-type \
+// RUN:   -emit-llvm -disable-llvm-passes -o - -DNAMESPACED| FileCheck %s
 
 
 // CHECK:"?uint16_t_Val@@3GA" = global i16 0, align 2
@@ -36,7 +39,11 @@
 // CHECK:"?double3_Val@@3T?$__vector@N$02@__clang@@A" = global <3 x double> zeroinitializer, align 32
 // CHECK:"?double4_Val@@3T?$__vector@N$03@__clang@@A" = global <4 x double> zeroinitializer, align 32
 
+#ifdef NAMESPACED
+#define TYPE_DECL(T)  hlsl::T T##_Val
+#else
 #define TYPE_DECL(T)  T T##_Val
+#endif
 
 #ifdef __HLSL_ENABLE_16_BIT
 TYPE_DECL(uint16_t);
Index: clang/lib/Headers/hlsl/hlsl_intrinsics.h
===================================================================
--- clang/lib/Headers/hlsl/hlsl_intrinsics.h
+++ clang/lib/Headers/hlsl/hlsl_intrinsics.h
@@ -9,6 +9,8 @@
 #ifndef _HLSL_HLSL_INTRINSICS_H_
 #define _HLSL_HLSL_INTRINSICS_H_
 
+namespace hlsl {
+
 __attribute__((availability(shadermodel, introduced = 6.0)))
 __attribute__((clang_builtin_alias(__builtin_hlsl_wave_active_count_bits))) uint
 WaveActiveCountBits(bool bBit);
@@ -99,4 +101,6 @@
 __attribute__((clang_builtin_alias(__builtin_elementwise_ceil)))
 double4 ceil(double4);
 
+} // namespace hlsl
+
 #endif //_HLSL_HLSL_INTRINSICS_H_
Index: clang/lib/Headers/hlsl/hlsl_basic_types.h
===================================================================
--- clang/lib/Headers/hlsl/hlsl_basic_types.h
+++ clang/lib/Headers/hlsl/hlsl_basic_types.h
@@ -9,6 +9,7 @@
 #ifndef _HLSL_HLSL_BASIC_TYPES_H_
 #define _HLSL_HLSL_BASIC_TYPES_H_
 
+namespace hlsl {
 // built-in scalar data types:
 
 #ifdef __HLSL_ENABLE_16_BIT
@@ -61,4 +62,6 @@
 typedef vector<double, 3> double3;
 typedef vector<double, 4> double4;
 
+} // namespace hlsl
+
 #endif //_HLSL_HLSL_BASIC_TYPES_H_
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D135973: Move HLSL ... Chris Bieneman via Phabricator via cfe-commits

Reply via email to