[clang] [HLSL] Add __is_scalarized_layout_compatible (PR #102227)

2024-08-06 Thread Chris B via cfe-commits
https://github.com/llvm-beanz created https://github.com/llvm/llvm-project/pull/102227 HLSL tends to rely pretty aggressively on scalarization occuring in the complier, which allows for some relaxed language behaviors when types are fully sclarized to equivalent scalar representations. This c

[clang] [llvm] [clang][HLSL] Add WaveIsFirstLane() intrinsic (PR #103299)

2024-08-19 Thread Chris B via cfe-commits
@@ -18660,6 +18660,10 @@ case Builtin::BI__builtin_hlsl_elementwise_isinf: { llvm::FunctionType::get(IntTy, {}, false), "__hlsl_wave_get_lane_index", {}, false, true)); } + case Builtin::BI__builtin_hlsl_wave_is_first_lane: { +Intrinsic::ID ID = CGM.getH

[clang] [HLSL] Add __is_scalarized_layout_compatible (PR #102227)

2024-08-19 Thread Chris B via cfe-commits
@@ -1142,3 +1142,85 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { } return false; } + +static void BuildFlattenedTypeList(QualType BaseTy, + llvm::SmallVectorImpl &List) { + llvm::SmallVector WorkList

[clang] [HLSL] Allow truncation to scalar (PR #104844)

2024-08-19 Thread Chris B via cfe-commits
https://github.com/llvm-beanz created https://github.com/llvm/llvm-project/pull/104844 HLSL allows implicit conversions to truncate vectors to scalar pr-values. These conversions are scored as vector truncations and should warn appropriately. This change allows forming a truncation cast to a p

[clang] [HLSL] Add __builtin_hlsl_is_scalarized_layout_compatible (PR #102227)

2024-08-19 Thread Chris B via cfe-commits
https://github.com/llvm-beanz edited https://github.com/llvm/llvm-project/pull/102227 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Implement output parameter (PR #101083)

2024-08-19 Thread Chris B via cfe-commits
https://github.com/llvm-beanz updated https://github.com/llvm/llvm-project/pull/101083 >From e8ec3e24e0061714b5dc440b1b92086965809483 Mon Sep 17 00:00:00 2001 From: Chris Bieneman Date: Mon, 29 Jul 2024 16:05:11 -0500 Subject: [PATCH 01/10] [HLSL] Implement output parameter HLSL output paramet

[clang] [HLSL] Add __builtin_hlsl_is_scalarized_layout_compatible (PR #102227)

2024-08-26 Thread Chris B via cfe-commits
https://github.com/llvm-beanz closed https://github.com/llvm/llvm-project/pull/102227 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Rework implicit conversion sequences (PR #96011)

2024-06-24 Thread Chris B via cfe-commits
https://github.com/llvm-beanz updated https://github.com/llvm/llvm-project/pull/96011 >From 0baa7ec1ded4fa093092d491eaa2c803b736742b Mon Sep 17 00:00:00 2001 From: Chris Bieneman Date: Tue, 18 Jun 2024 20:25:57 -0500 Subject: [PATCH 1/3] [HLSL] Rework implicit conversion sequences This PR rewo

[clang] [clang][NFC] Move more things out of `SemaChecking.cpp` (PR #96641)

2024-06-26 Thread Chris B via cfe-commits
https://github.com/llvm-beanz approved this pull request. HLSL changes look good to me. https://github.com/llvm/llvm-project/pull/96641 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [ParserHLSL] Attempt to parse HLSL annotations on Field Decls. (PR #96346)

2024-06-26 Thread Chris B via cfe-commits
@@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -o - %s -verify + +// expected-no-diagnostics + +struct MyBitFields { +unsigned int field1 : 3; // 3 bits for field1 +unsigned int field2 : 4; // 4 bits for field2 +int field3 : 5;

[clang] [ParserHLSL] Attempt to parse HLSL annotations on Field Decls. (PR #96346)

2024-06-26 Thread Chris B via cfe-commits
@@ -0,0 +1,30 @@ +// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -o - %s -verify + +// previously, this test would result in an error shown below on the line that +// declares variable a in struct Eg9: +// error: use of undeclared identifier +// 'SV_Dispat

[clang] [ParserHLSL] Attempt to parse HLSL annotations on Field Decls. (PR #96346)

2024-06-26 Thread Chris B via cfe-commits
@@ -0,0 +1,30 @@ +// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -o - %s -verify + +// previously, this test would result in an error shown below on the line that +// declares variable a in struct Eg9: +// error: use of undeclared identifier +// 'SV_Dispat

[clang] [HLSL] Implement `export` keyword (PR #96823)

2024-06-27 Thread Chris B via cfe-commits
llvm-beanz wrote: > The grammer looks exactly the same with modules. May it be compatible with > modules? The grammar is the same (although HLSL only supports the `export` keyword in a subset of the places C++ does), but the behavior isn't the same. We may look to shift HLSL's behavior to mat

[clang] [HLSL] Allow truncation to scalar (PR #104844)

2024-09-11 Thread Chris B via cfe-commits
https://github.com/llvm-beanz closed https://github.com/llvm/llvm-project/pull/104844 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Adding `asuint` implementation to hlsl (PR #107292)

2024-09-12 Thread Chris B via cfe-commits
@@ -0,0 +1,42 @@ +//===- hlsl_intrinsics.h - HLSL definitions for intrinsics --===// +// +// 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

[clang] [HLSL] Allow narrowing in initialization lists (PR #108035)

2024-09-12 Thread Chris B via cfe-commits
llvm-beanz wrote: > Can we test this? It is tested. The modified test case adds a run line with `-std=hlsl202x` which fails without this change due to narrowing conversion in an initializer list. https://github.com/llvm/llvm-project/pull/108035 ___ c

[clang] [HLSL] Allow narrowing in initialization lists (PR #108035)

2024-09-12 Thread Chris B via cfe-commits
llvm-beanz wrote: > looks fine. Curious, why is this extra RUN: line added? Doesn't the other one > already contain the same parameters `-ast-dump -o - %s | FileCheck %s` ? > > RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -ast-dump -o - %s | > FileCheck %s The diff is a bit awkward

[clang] [HLSL] Allow narrowing in initialization lists (PR #108035)

2024-09-12 Thread Chris B via cfe-commits
https://github.com/llvm-beanz closed https://github.com/llvm/llvm-project/pull/108035 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Add HLSL 202y language mode (PR #108437)

2024-09-12 Thread Chris B via cfe-commits
https://github.com/llvm-beanz created https://github.com/llvm/llvm-project/pull/108437 This change adds a new HLSL 202y language mode. Currently HLSL 202y is planned to add `auto` and `constexpr`. This change updates extension diagnostics to state that lambadas are a "clang HLSL" extension (s

[clang] [HLSL] Fix move assignment of `this` (PR #108445)

2024-09-12 Thread Chris B via cfe-commits
https://github.com/llvm-beanz created https://github.com/llvm/llvm-project/pull/108445 Under HLSL 202x+ move assignment can occur and when targeting `this` move assignment was generating some really odd errors. This corrects the errors by properly generating the `this` object reference for HLS

[clang] [HLSL] set alwaysinline on HLSL functions (PR #106588)

2024-09-12 Thread Chris B via cfe-commits
@@ -2502,9 +2505,16 @@ void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D, ShouldAddOptNone &= !D->hasAttr(); ShouldAddOptNone &= !D->hasAttr(); - // Add optnone, but do so only if the function isn't always_inline. - if ((ShouldAddOptNone || D->has

[clang] [HLSL] set alwaysinline on HLSL functions (PR #106588)

2024-09-12 Thread Chris B via cfe-commits
@@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -emit-llvm-only %s -verify llvm-beanz wrote: We should not need to emit IR to test a warning. This should work with `-fsyntax-only` or without the `-emit-llvm-only` flag. https://githu

[clang] [HLSL] generate hlsl.wavesize attribute (PR #107176)

2024-09-12 Thread Chris B via cfe-commits
https://github.com/llvm-beanz approved this pull request. https://github.com/llvm/llvm-project/pull/107176 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Adding `asuint` implementation to hlsl (PR #107292)

2024-09-12 Thread Chris B via cfe-commits
@@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -emit-llvm-only -disable-llvm-passes -verify -verify-ignore-unexpected llvm-beanz wrote: what messages are seen but not expected? https:/

[clang] [HLSL] Add HLSL 202y language mode (PR #108437)

2024-09-12 Thread Chris B via cfe-commits
@@ -12397,6 +12397,9 @@ def warn_attr_min_eq_max: Warning< def err_hlsl_attribute_number_arguments_insufficient_shader_model: Error< "attribute %0 with %1 arguments requires shader model %2 or greater">; +def ext_hlsl_auto_type_specifier : ExtWarn< llvm-bea

[clang] [HLSL] Add HLSL 202y language mode (PR #108437)

2024-09-12 Thread Chris B via cfe-commits
@@ -12397,6 +12397,9 @@ def warn_attr_min_eq_max: Warning< def err_hlsl_attribute_number_arguments_insufficient_shader_model: Error< "attribute %0 with %1 arguments requires shader model %2 or greater">; +def ext_hlsl_auto_type_specifier : ExtWarn< + "'auto' type specifier

[clang] [HLSL] Add HLSL 202y language mode (PR #108437)

2024-09-13 Thread Chris B via cfe-commits
https://github.com/llvm-beanz updated https://github.com/llvm/llvm-project/pull/108437 >From 34cc492bad3f1b2b4cae7eb4dc5cbd4b219a8944 Mon Sep 17 00:00:00 2001 From: Chris Bieneman Date: Tue, 10 Sep 2024 10:24:08 -0500 Subject: [PATCH 1/2] [HLSL] Add HLSL 202y language mode This change adds a n

[clang] [HLSL] Fix move assignment of `this` (PR #108445)

2024-09-13 Thread Chris B via cfe-commits
https://github.com/llvm-beanz updated https://github.com/llvm/llvm-project/pull/108445 >From a5be65fa3b763659dda7fd9ab2fda9ca9dae4391 Mon Sep 17 00:00:00 2001 From: Chris Bieneman Date: Thu, 12 Sep 2024 12:06:02 -0500 Subject: [PATCH 1/2] [HLSL] Fix move assignment of `this` Under HLSL 202x+ m

[clang] [HLSL] Fix move assignment of `this` (PR #108445)

2024-09-13 Thread Chris B via cfe-commits
https://github.com/llvm-beanz closed https://github.com/llvm/llvm-project/pull/108445 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Vector Usual Arithmetic Conversions (PR #108659)

2024-09-13 Thread Chris B via cfe-commits
https://github.com/llvm-beanz created https://github.com/llvm/llvm-project/pull/108659 HLSL has a different set of usual arithmetic conversions for vector types to resolve a common type for binary operator expressions. This PR implements the current spec proposal from: https://github.com/micr

[clang] [HLSL] Align all language modes on 202x (PR #108662)

2024-09-13 Thread Chris B via cfe-commits
https://github.com/llvm-beanz created https://github.com/llvm/llvm-project/pull/108662 As captured in issue #108044, HLSL 202x is the target language mode for conformance for Clang. Earlier language modes will be a best effort and prioritized after 2020x. To make this easier and reduce our tes

[clang] Implementing `asfloat` using `bit_cast` (PR #108686)

2024-09-14 Thread Chris B via cfe-commits
@@ -361,6 +361,23 @@ bool any(double3); _HLSL_BUILTIN_ALIAS(__builtin_hlsl_any) bool any(double4); +//===--===// +// asfloat builtins +//===-

[clang] [HLSL] Align language modes on 202x as default (PR #108662)

2024-09-16 Thread Chris B via cfe-commits
https://github.com/llvm-beanz edited https://github.com/llvm/llvm-project/pull/108662 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Align language modes on 202x as default (PR #108662)

2024-09-16 Thread Chris B via cfe-commits
@@ -12,7 +12,7 @@ // HALF: #define __HLSL_ENABLE_16_BIT 1 // NOHALF-NOT: __HLSL_ENABLE_16_BIT -// CHECK: #define __HLSL_VERSION 2021 +// CHECK: #define __HLSL_VERSION 2028 llvm-beanz wrote: 202x doesn't have a year yet, so to make it big and far out I gave it

[clang] [HLSL] Align language modes on 202x as default (PR #108662)

2024-09-16 Thread Chris B via cfe-commits
@@ -12,7 +12,7 @@ // HALF: #define __HLSL_ENABLE_16_BIT 1 // NOHALF-NOT: __HLSL_ENABLE_16_BIT -// CHECK: #define __HLSL_VERSION 2021 +// CHECK: #define __HLSL_VERSION 2028 llvm-beanz wrote: Yea. Subject to revision once we have an actual year. https://github

[clang] [HLSL] Align language modes on 202x as default (PR #108662)

2024-09-16 Thread Chris B via cfe-commits
@@ -37,7 +37,7 @@ _Static_assert(is_same<__decltype(4294967296), int64_t>::value, "4294967296 is i // Clang emits a warning that it is interpreting it as unsigned because that is // not conforming to the C standard. -// expected-warning@+1{{integer literal is too large to be

[clang] [HLSL] Align language modes on 202x as default (PR #108662)

2024-09-16 Thread Chris B via cfe-commits
https://github.com/llvm-beanz closed https://github.com/llvm/llvm-project/pull/108662 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Warn about incomplete language support (PR #108894)

2024-09-16 Thread Chris B via cfe-commits
https://github.com/llvm-beanz created https://github.com/llvm/llvm-project/pull/108894 This adds a warning about incomplete language mode support before HLSL 202x. This is the last change in the sequence to fix and make HLSL 202x the default mode for Clang (#108044). Fixes #108044 >From 0b5

[clang] [HLSL] Make casting functions constexpr (PR #108902)

2024-09-16 Thread Chris B via cfe-commits
https://github.com/llvm-beanz created https://github.com/llvm/llvm-project/pull/108902 This marks the `bit_cast` helper as `constexpr` and allows the casts implemented with it to also be `constexpr`. This is largely not a functional change, but it enables using the casts in expressions that ne

[clang] [HLSL] Make casting functions constexpr (PR #108902)

2024-09-16 Thread Chris B via cfe-commits
https://github.com/llvm-beanz updated https://github.com/llvm/llvm-project/pull/108902 >From 9deebd707410a6ad8474f615a97c943937ceeb34 Mon Sep 17 00:00:00 2001 From: Chris Bieneman Date: Mon, 16 Sep 2024 18:21:38 -0500 Subject: [PATCH 1/2] [HLSL] Make casting functions constexpr This marks the

[clang] [HLSL] Make HLSLAttributedResourceType canonical and add code paths to convert HLSL types to DirectX target types (PR #110327)

2024-10-08 Thread Chris B via cfe-commits
https://github.com/llvm-beanz edited https://github.com/llvm/llvm-project/pull/110327 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Make HLSLAttributedResourceType canonical and add code paths to convert HLSL types to DirectX target types (PR #110327)

2024-10-08 Thread Chris B via cfe-commits
@@ -32,6 +32,7 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringExtras.h" #include "llvm/Support/CRC.h" +#include "llvm/Support/DXILABI.h" llvm-beanz wrote: Do we need this include? https://github.com/llvm/llvm-project/pull/110327 ___

[clang] [HLSL] Make HLSLAttributedResourceType canonical and add code paths to convert HLSL types to DirectX target types (PR #110327)

2024-10-08 Thread Chris B via cfe-commits
@@ -3437,6 +3437,9 @@ static void encodeTypeForFunctionPointerAuth(const ASTContext &Ctx, OS << II->getLength() << II->getName(); return; } + case Type::HLSLAttributedResource: llvm-beanz wrote: This should maybe be higher up with the "should never

[clang] [HLSL] Make HLSLAttributedResourceType canonical and add code paths to convert HLSL types to DirectX target types (PR #110327)

2024-10-08 Thread Chris B via cfe-commits
@@ -3943,6 +3943,9 @@ void ItaniumRTTIBuilder::BuildVTablePointer(const Type *Ty) { // abi::__pointer_to_member_type_info. VTableName = "_ZTVN10__cxxabiv129__pointer_to_member_type_infoE"; break; + + case Type::HLSLAttributedResource: +llvm_unreachable("not ye

[clang] [HLSL] Make HLSLAttributedResourceType canonical and add code paths to convert HLSL types to DirectX target types (PR #110327)

2024-10-08 Thread Chris B via cfe-commits
@@ -4205,6 +4208,9 @@ llvm::Constant *ItaniumRTTIBuilder::BuildTypeInfo( case Type::Atomic: // No fields, at least for the moment. break; + + case Type::HLSLAttributedResource: +llvm_unreachable("not yet implemented"); llvm-beanz wrote: This too

[clang] [HLSL] Make HLSLAttributedResourceType canonical and add code paths to convert HLSL types to DirectX target types (PR #110327)

2024-10-08 Thread Chris B via cfe-commits
https://github.com/llvm-beanz commented: A few (mostly small) comments https://github.com/llvm/llvm-project/pull/110327 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Make HLSLAttributedResourceType canonical and add code paths to convert HLSL types to DirectX target types (PR #110327)

2024-10-08 Thread Chris B via cfe-commits
@@ -13672,6 +13690,9 @@ static QualType getCommonNonSugarTypeNode(ASTContext &Ctx, const Type *X, TX->getDepth(), TX->getIndex(), TX->isParameterPack(), getCommonDecl(TX->getDecl(), TY->getDecl())); } + case Type::HLSLAttributedResource: { l

[clang] [HLSL] Make HLSLAttributedResourceType canonical and add code paths to convert HLSL types to DirectX target types (PR #110327)

2024-10-08 Thread Chris B via cfe-commits
@@ -29,19 +29,40 @@ class DirectXTargetCodeGenInfo : public TargetCodeGenInfo { llvm::Type *DirectXTargetCodeGenInfo::getHLSLType(CodeGenModule &CGM, const Type *Ty) const { - auto *BuiltinTy = dyn_cast(Ty); - if (!BuiltinTy

[clang] [llvm] [HLSL] Implement `WaveReadLaneAt` intrinsic (PR #111010)

2024-10-08 Thread Chris B via cfe-commits
@@ -0,0 +1,26 @@ +// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -emit-llvm-only -disable-llvm-passes -verify -verify-ignore-unexpected llvm-beanz wrote: I'm always suspicious when I see `verify-ignore-u

[clang] [llvm] [HLSL] Implement `WaveReadLaneAt` intrinsic (PR #111010)

2024-10-08 Thread Chris B via cfe-commits
@@ -87,6 +87,7 @@ class CGHLSLRuntime { GENERATE_HLSL_INTRINSIC_FUNCTION(SDot, sdot) GENERATE_HLSL_INTRINSIC_FUNCTION(UDot, udot) GENERATE_HLSL_INTRINSIC_FUNCTION(WaveIsFirstLane, wave_is_first_lane) + GENERATE_HLSL_INTRINSIC_FUNCTION(WaveReadLaneAt, waveReadLaneAt)

[clang] [llvm] [HLSL] Implement `WaveReadLaneAt` intrinsic (PR #111010)

2024-10-08 Thread Chris B via cfe-commits
@@ -18835,6 +18835,24 @@ case Builtin::BI__builtin_hlsl_elementwise_isinf: { Intrinsic::ID ID = CGM.getHLSLRuntime().getWaveIsFirstLaneIntrinsic(); return EmitRuntimeCall(Intrinsic::getDeclaration(&CGM.getModule(), ID)); } + case Builtin::BI__builtin_hlsl_wave_read_l

[clang] [HLSL] get inout/out ABI for array parameters working (PR #111047)

2024-10-07 Thread Chris B via cfe-commits
@@ -2249,6 +2235,25 @@ static bool IsStandardConversion(Sema &S, Expr* From, QualType ToType, SCS.setAllToTypes(ToType); return true; + } else if (argIsLValue && !FromType->canDecayToPointerType() && + S.Context.getCanonicalType(FromType) != S.Context.Ove

[clang] [llvm] Adding splitdouble HLSL function (PR #109331)

2024-10-08 Thread Chris B via cfe-commits
@@ -18901,6 +18901,150 @@ case Builtin::BI__builtin_hlsl_elementwise_isinf: { CGM.getHLSLRuntime().getRadiansIntrinsic(), ArrayRef{Op0}, nullptr, "hlsl.radians"); } + // This should only be called when targeting DXIL + case Builtin::BI__builtin_hlsl_splitdou

[clang] [llvm] Adding splitdouble HLSL function (PR #109331)

2024-10-08 Thread Chris B via cfe-commits
@@ -18901,6 +18901,150 @@ case Builtin::BI__builtin_hlsl_elementwise_isinf: { CGM.getHLSLRuntime().getRadiansIntrinsic(), ArrayRef{Op0}, nullptr, "hlsl.radians"); } + // This should only be called when targeting DXIL + case Builtin::BI__builtin_hlsl_splitdou

[clang] [llvm] Adding splitdouble HLSL function (PR #109331)

2024-10-08 Thread Chris B via cfe-commits
https://github.com/llvm-beanz commented: I've got a lot of style nits here. In general it is nice to break up changes into smaller changes where you can. One obvious split in this PR would have been to put the DirectX backend changes in first in a separate PR. Smaller PRs are easier to review

[clang] [llvm] Adding splitdouble HLSL function (PR #109331)

2024-10-08 Thread Chris B via cfe-commits
@@ -18901,6 +18901,150 @@ case Builtin::BI__builtin_hlsl_elementwise_isinf: { CGM.getHLSLRuntime().getRadiansIntrinsic(), ArrayRef{Op0}, nullptr, "hlsl.radians"); } + // This should only be called when targeting DXIL + case Builtin::BI__builtin_hlsl_splitdou

[clang] [llvm] Adding splitdouble HLSL function (PR #109331)

2024-10-08 Thread Chris B via cfe-commits
@@ -1992,6 +2001,37 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { return true; break; } + case Builtin::BI__builtin_hlsl_splitdouble: { +if (SemaRef.checkArgCount(TheCall, 3)) + return true; + +Expr *Op0 = TheCall

[clang] [llvm] Adding splitdouble HLSL function (PR #109331)

2024-10-08 Thread Chris B via cfe-commits
@@ -1992,6 +2001,37 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { return true; break; } + case Builtin::BI__builtin_hlsl_splitdouble: { +if (SemaRef.checkArgCount(TheCall, 3)) + return true; + +Expr *Op0 = TheCall

[clang] [llvm] Adding splitdouble HLSL function (PR #109331)

2024-10-08 Thread Chris B via cfe-commits
@@ -4681,6 +4681,11 @@ void CallArg::copyInto(CodeGenFunction &CGF, Address Addr) const { IsUsed = true; } +void CodeGenFunction::EmitWritebacks(CodeGenFunction &CGF, + const CallArgList &args) { + emitWritebacks(CGF, args);

[clang] [llvm] Adding splitdouble HLSL function (PR #109331)

2024-10-08 Thread Chris B via cfe-commits
@@ -5148,6 +5151,9 @@ class CodeGenFunction : public CodeGenTypeCache { SourceLocation ArgLoc, AbstractCallee AC, unsigned ParmNum); + /// EmitWriteback - Emit callbacks for function. + void EmitWritebacks(CodeGenFunction

[clang] [llvm] Adding splitdouble HLSL function (PR #109331)

2024-10-08 Thread Chris B via cfe-commits
@@ -18901,6 +18901,150 @@ case Builtin::BI__builtin_hlsl_elementwise_isinf: { CGM.getHLSLRuntime().getRadiansIntrinsic(), ArrayRef{Op0}, nullptr, "hlsl.radians"); } + // This should only be called when targeting DXIL + case Builtin::BI__builtin_hlsl_splitdou

[clang] [llvm] Adding splitdouble HLSL function (PR #109331)

2024-10-08 Thread Chris B via cfe-commits
@@ -18901,6 +18901,150 @@ case Builtin::BI__builtin_hlsl_elementwise_isinf: { CGM.getHLSLRuntime().getRadiansIntrinsic(), ArrayRef{Op0}, nullptr, "hlsl.radians"); } + // This should only be called when targeting DXIL + case Builtin::BI__builtin_hlsl_splitdou

[clang] [llvm] Adding splitdouble HLSL function (PR #109331)

2024-10-08 Thread Chris B via cfe-commits
@@ -18901,6 +18901,150 @@ case Builtin::BI__builtin_hlsl_elementwise_isinf: { CGM.getHLSLRuntime().getRadiansIntrinsic(), ArrayRef{Op0}, nullptr, "hlsl.radians"); } + // This should only be called when targeting DXIL + case Builtin::BI__builtin_hlsl_splitdou

[clang] [llvm] Adding splitdouble HLSL function (PR #109331)

2024-10-08 Thread Chris B via cfe-commits
@@ -18901,6 +18901,150 @@ case Builtin::BI__builtin_hlsl_elementwise_isinf: { CGM.getHLSLRuntime().getRadiansIntrinsic(), ArrayRef{Op0}, nullptr, "hlsl.radians"); } + // This should only be called when targeting DXIL + case Builtin::BI__builtin_hlsl_splitdou

[clang] [llvm] Adding splitdouble HLSL function (PR #109331)

2024-10-08 Thread Chris B via cfe-commits
@@ -18901,6 +18901,150 @@ case Builtin::BI__builtin_hlsl_elementwise_isinf: { CGM.getHLSLRuntime().getRadiansIntrinsic(), ArrayRef{Op0}, nullptr, "hlsl.radians"); } + // This should only be called when targeting DXIL + case Builtin::BI__builtin_hlsl_splitdou

[clang] [llvm] Adding splitdouble HLSL function (PR #109331)

2024-10-08 Thread Chris B via cfe-commits
@@ -18901,6 +18901,150 @@ case Builtin::BI__builtin_hlsl_elementwise_isinf: { CGM.getHLSLRuntime().getRadiansIntrinsic(), ArrayRef{Op0}, nullptr, "hlsl.radians"); } + // This should only be called when targeting DXIL + case Builtin::BI__builtin_hlsl_splitdou

[clang] Enable matrices in HLSL (PR #111415)

2024-10-10 Thread Chris B via cfe-commits
@@ -17,12 +17,12 @@ void add(sx10x10_t a, sx5x10_t b, sx10x5_t c) { // expected-error@-1 {{assigning to 'sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))') from incompatible type 'sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))')}} a = b + &c; - //

[clang] [llvm] [HLSL] Implement `WaveReadLaneAt` intrinsic (PR #111010)

2024-10-08 Thread Chris B via cfe-commits
@@ -87,6 +87,7 @@ class CGHLSLRuntime { GENERATE_HLSL_INTRINSIC_FUNCTION(SDot, sdot) GENERATE_HLSL_INTRINSIC_FUNCTION(UDot, udot) GENERATE_HLSL_INTRINSIC_FUNCTION(WaveIsFirstLane, wave_is_first_lane) + GENERATE_HLSL_INTRINSIC_FUNCTION(WaveReadLaneAt, waveReadLaneAt)

[clang] [llvm] [HLSL] Implement `WaveReadLaneAt` intrinsic (PR #111010)

2024-10-08 Thread Chris B via cfe-commits
@@ -87,6 +87,7 @@ class CGHLSLRuntime { GENERATE_HLSL_INTRINSIC_FUNCTION(SDot, sdot) GENERATE_HLSL_INTRINSIC_FUNCTION(UDot, udot) GENERATE_HLSL_INTRINSIC_FUNCTION(WaveIsFirstLane, wave_is_first_lane) + GENERATE_HLSL_INTRINSIC_FUNCTION(WaveReadLaneAt, waveReadLaneAt)

[clang] Enable matrices in HLSL (PR #111415)

2024-10-07 Thread Chris B via cfe-commits
@@ -852,34 +852,50 @@ void TypePrinter::printExtVectorAfter(const ExtVectorType *T, raw_ostream &OS) { void TypePrinter::printConstantMatrixBefore(const ConstantMatrixType *T, raw_ostream &OS) { + if (Policy.UseHLSLTypes) +OS <

[clang] [HLSL] get inout/out ABI for array parameters working (PR #111047)

2024-10-07 Thread Chris B via cfe-commits
@@ -4690,8 +4690,9 @@ void CodeGenFunction::EmitCallArg(CallArgList &args, const Expr *E, return emitWritebackArg(*this, args, CRE); } - assert(type->isReferenceType() == E->isGLValue() && - "reference binding to unmaterialized r-value!"); + assert(type->isArr

[clang] [HLSL] get inout/out ABI for array parameters working (PR #111047)

2024-10-07 Thread Chris B via cfe-commits
@@ -5811,9 +5811,12 @@ LValue CodeGenFunction::EmitBinaryOperatorLValue(const BinaryOperator *E) { // This function implements trivial copy assignment for HLSL's // assignable constant arrays. LValue CodeGenFunction::EmitHLSLArrayAssignLValue(const BinaryOperator *E) { - LVal

[clang] [llvm] [HLSL] Implement `WaveReadLaneAt` intrinsic (PR #111010)

2024-10-07 Thread Chris B via cfe-commits
@@ -1956,6 +1956,26 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { return true; break; } + case Builtin::BI__builtin_hlsl_wave_read_lane_at: { +if (SemaRef.checkArgCount(TheCall, 2)) + return true; + +// Ensure ind

[clang] [llvm] [HLSL] Implement `WaveReadLaneAt` intrinsic (PR #111010)

2024-10-07 Thread Chris B via cfe-commits
@@ -2015,6 +2015,13 @@ _HLSL_AVAILABILITY(shadermodel, 6.0) _HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_is_first_lane) __attribute__((convergent)) bool WaveIsFirstLane(); +// \brief Returns the value of the expression for the given lane index within +// the specified wave. +templa

[clang] [llvm] [HLSL] Implement `WaveReadLaneAt` intrinsic (PR #111010)

2024-10-07 Thread Chris B via cfe-commits
@@ -18835,6 +18835,24 @@ case Builtin::BI__builtin_hlsl_elementwise_isinf: { Intrinsic::ID ID = CGM.getHLSLRuntime().getWaveIsFirstLaneIntrinsic(); return EmitRuntimeCall(Intrinsic::getDeclaration(&CGM.getModule(), ID)); } + case Builtin::BI__builtin_hlsl_wave_read_l

[clang] [HLSL] get inout/out ABI for array parameters working (PR #111047)

2024-10-07 Thread Chris B via cfe-commits
@@ -3830,6 +3830,16 @@ QualType ASTContext::getDecayedType(QualType T) const { return getDecayedType(T, Decayed); } +QualType ASTContext::getConstantArrayFromArrayParameterType(QualType Ty) const { + if (Ty->isConstantArrayType() && !Ty->isArrayParameterType()) +return

[clang] [llvm] [HLSL] Implement `WaveReadLaneAt` intrinsic (PR #111010)

2024-10-07 Thread Chris B via cfe-commits
@@ -2015,6 +2015,13 @@ _HLSL_AVAILABILITY(shadermodel, 6.0) _HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_is_first_lane) __attribute__((convergent)) bool WaveIsFirstLane(); +// \brief Returns the value of the expression for the given lane index within +// the specified wave. +templa

[clang] [HLSL] Add implicit resource element type concepts to AST (PR #112600)

2024-10-17 Thread Chris B via cfe-commits
@@ -483,10 +555,106 @@ static BuiltinTypeDeclBuilder setupBufferType(CXXRecordDecl *Decl, Sema &S, .addDefaultHandleConstructor(S, RC); } +BinaryOperator *getSizeOfLEQ16Expr(clang::ASTContext &context, + SourceLocation NameLoc, +

[clang] [HLSL] Add implicit resource element type concepts to AST (PR #112600)

2024-10-17 Thread Chris B via cfe-commits
@@ -323,30 +324,101 @@ struct TemplateParameterListBuilder { S.Context, Builder.Record->getDeclContext(), SourceLocation(), SourceLocation(), /* TemplateDepth */ 0, Position, &S.Context.Idents.get(Name, tok::TokenKind::identifier), -/* Typename *

[clang] [llvm] [HLSL] Implement `WaveReadLaneAt` intrinsic (PR #111010)

2024-10-10 Thread Chris B via cfe-commits
https://github.com/llvm-beanz edited https://github.com/llvm/llvm-project/pull/111010 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [HLSL] Implement `WaveReadLaneAt` intrinsic (PR #111010)

2024-10-10 Thread Chris B via cfe-commits
@@ -1956,6 +1956,26 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { return true; break; } + case Builtin::BI__builtin_hlsl_wave_read_lane_at: { +if (SemaRef.checkArgCount(TheCall, 2)) + return true; + +// Ensure ind

[clang] Enable matrices in HLSL (PR #111415)

2024-10-10 Thread Chris B via cfe-commits
@@ -1381,7 +1381,7 @@ void ASTContext::InitBuiltinTypes(const TargetInfo &Target, if (LangOpts.OpenACC && !LangOpts.OpenMP) { InitBuiltinType(ArraySectionTy, BuiltinType::ArraySection); } - if (LangOpts.MatrixTypes) + if (LangOpts.MatrixTypes || LangOpts.HLSL) --

[clang] [llvm] [HLSL] Implement `WaveReadLaneAt` intrinsic (PR #111010)

2024-10-10 Thread Chris B via cfe-commits
https://github.com/llvm-beanz commented: One small nit, but otherwise looks good. https://github.com/llvm/llvm-project/pull/111010 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [HLSL] Implement `WaveReadLaneAt` intrinsic (PR #111010)

2024-10-10 Thread Chris B via cfe-commits
@@ -87,6 +87,7 @@ class CGHLSLRuntime { GENERATE_HLSL_INTRINSIC_FUNCTION(SDot, sdot) GENERATE_HLSL_INTRINSIC_FUNCTION(UDot, udot) GENERATE_HLSL_INTRINSIC_FUNCTION(WaveIsFirstLane, wave_is_first_lane) + GENERATE_HLSL_INTRINSIC_FUNCTION(WaveReadLaneAt, wave_readlaneat) ---

[clang] [llvm] [HLSL] Add `Increment`/`DecrementCounter` methods to structured buffers (PR #114148)

2024-11-01 Thread Chris B via cfe-commits
@@ -359,6 +356,176 @@ struct TemplateParameterListBuilder { return Builder; } }; + +// Builder for methods of builtin types. Allows adding methods to builtin types +// using the builder pattern like this: +// +// BuiltinTypeMethodBuilder(Sema, RecordBuilder, "MethodName

[clang] [llvm] [HLSL] Add `Increment`/`DecrementCounter` methods to structured buffers (PR #114148)

2024-11-01 Thread Chris B via cfe-commits
@@ -359,6 +356,176 @@ struct TemplateParameterListBuilder { return Builder; } }; + +// Builder for methods of builtin types. Allows adding methods to builtin types +// using the builder pattern like this: +// +// BuiltinTypeMethodBuilder(Sema, RecordBuilder, "MethodName

[clang] [HLSL] add IsTypedResourceElementCompatible type trait (PR #114864)

2024-11-05 Thread Chris B via cfe-commits
@@ -2163,6 +2163,50 @@ static void BuildFlattenedTypeList(QualType BaseTy, } } +bool SemaHLSL::IsTypedResourceElementCompatible(clang::QualType QT) { + if (QT.isNull()) +return false; + + // check if the outer type was an array type + if (QT->isArrayType()) +retur

[clang] [HLSL][NFC] Cleanup - removed unused function, includes and param, fix typos (PR #113649)

2024-11-05 Thread Chris B via cfe-commits
@@ -15,7 +15,7 @@ // EMPTY-NEXT: CXXRecordDecl 0x{{[0-9A-Fa-f]+}} <> implicit class RWBuffer // EMPTY-NEXT: FinalAttr 0x{{[0-9A-Fa-f]+}} <> Implicit final -// There should be no more occurrances of RWBuffer +// There should be no more occurrences of RWBuffer

[clang] [llvm] [HLSL] Add `Increment`/`DecrementCounter` methods to structured buffers (PR #114148)

2024-11-05 Thread Chris B via cfe-commits
@@ -354,27 +345,230 @@ struct TemplateParameterListBuilder { Params.clear(); QualType T = Builder.Template->getInjectedClassNameSpecialization(); -T = S.Context.getInjectedClassNameType(Builder.Record, T); +T = AST.getInjectedClassNameType(Builder.Record, T);

[clang] [llvm] [HLSL] Add `Increment`/`DecrementCounter` methods to structured buffers (PR #114148)

2024-11-05 Thread Chris B via cfe-commits
@@ -354,27 +345,230 @@ struct TemplateParameterListBuilder { Params.clear(); QualType T = Builder.Template->getInjectedClassNameSpecialization(); -T = S.Context.getInjectedClassNameType(Builder.Record, T); +T = AST.getInjectedClassNameType(Builder.Record, T);

[clang] [llvm] [HLSL] Add `Increment`/`DecrementCounter` methods to structured buffers (PR #114148)

2024-11-05 Thread Chris B via cfe-commits
https://github.com/llvm-beanz approved this pull request. A couple small comment take or leave, but looks good. https://github.com/llvm/llvm-project/pull/114148 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mail

[clang] [llvm] [HLSL] Add `Increment`/`DecrementCounter` methods to structured buffers (PR #114148)

2024-11-05 Thread Chris B via cfe-commits
@@ -4846,7 +4846,6 @@ def HLSLSaturate : LangBuiltin<"HLSL_LANG"> { let Prototype = "void(...)"; } - llvm-beanz wrote: nit: looks like an unrelated change from a merge conflict. https://github.com/llvm/llvm-project/pull/114148 _

[clang] [llvm] [HLSL] Add `Increment`/`DecrementCounter` methods to structured buffers (PR #114148)

2024-11-05 Thread Chris B via cfe-commits
https://github.com/llvm-beanz edited https://github.com/llvm/llvm-project/pull/114148 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Add implicit resource element type concepts to AST (PR #112600)

2024-11-04 Thread Chris B via cfe-commits
@@ -483,10 +581,102 @@ static BuiltinTypeDeclBuilder setupBufferType(CXXRecordDecl *Decl, Sema &S, .addDefaultHandleConstructor(S, RC); } +BinaryOperator *constructSizeOfLEQ16Expr(ASTContext &Context, + SourceLocation NameLoc, +

[clang] [HLSL] Add implicit resource element type concepts to AST (PR #112600)

2024-11-04 Thread Chris B via cfe-commits
@@ -483,10 +581,102 @@ static BuiltinTypeDeclBuilder setupBufferType(CXXRecordDecl *Decl, Sema &S, .addDefaultHandleConstructor(S, RC); } +BinaryOperator *constructSizeOfLEQ16Expr(ASTContext &Context, + SourceLocation NameLoc, +

[clang] [HLSL] Add implicit resource element type concepts to AST (PR #112600)

2024-11-04 Thread Chris B via cfe-commits
https://github.com/llvm-beanz commented: Mostly looking good to me. A few small comments. https://github.com/llvm/llvm-project/pull/112600 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commi

[clang] [HLSL] Add implicit resource element type concepts to AST (PR #112600)

2024-11-04 Thread Chris B via cfe-commits
https://github.com/llvm-beanz edited https://github.com/llvm/llvm-project/pull/112600 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Add implicit resource element type concepts to AST (PR #112600)

2024-11-04 Thread Chris B via cfe-commits
@@ -483,10 +581,102 @@ static BuiltinTypeDeclBuilder setupBufferType(CXXRecordDecl *Decl, Sema &S, .addDefaultHandleConstructor(S, RC); } +BinaryOperator *constructSizeOfLEQ16Expr(ASTContext &Context, + SourceLocation NameLoc, +

[clang] [HLSL] get inout/out ABI for array parameters working (PR #111047)

2024-11-04 Thread Chris B via cfe-commits
@@ -0,0 +1,134 @@ +// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -disable-llvm-passes -emit-llvm -finclude-default-header -o - %s | FileCheck %s + +// CHECK-LABEL: increment +void increment(inout int Arr[2]) { + for (int I = 0; I < 2; I++) +Arr[0] += 2; +} + +//

[clang] Enable matrices in HLSL (PR #111415)

2024-11-04 Thread Chris B via cfe-commits
@@ -1,7 +1,5 @@ // RUN: %clang_cc1 -O0 -fenable-matrix -triple x86_64-apple-darwin %s -emit-llvm -disable-llvm-passes -o - -std=c++11 | FileCheck --check-prefixes=CHECK,NOOPT %s // RUN: %clang_cc1 -O1 -fenable-matrix -triple x86_64-apple-darwin %s -emit-llvm -disable-llvm-pas

<    1   2   3   4   5   6   7   8   9   10   >