[clang] [HLSL] cbuffer: Create host layout struct and add resource handle to AST (PR #122820)

2025-01-16 Thread Chris B via cfe-commits
llvm-beanz wrote: > I was kind of hoping we might be able to generate the accesses off a handle > during codegen when the global is accessed. I'm not sure if that's possible > though. I'm concerned that this will be more complex to make work with the other CBV syntaxes. For example, the impli

[clang] [HLSL] Implement HLSL Flat casting (excluding splat cases) (PR #118842)

2025-01-16 Thread Chris B via cfe-commits
@@ -2412,6 +2412,102 @@ bool SemaHLSL::CheckCompatibleParameterABI(FunctionDecl *New, return HadError; } +// Generally follows PerformScalarCast, with cases reordered for +// clarity of what types are supported +bool SemaHLSL::CanPerformScalarCast(QualType SrcTy, QualType D

[clang] [HLSL] Implement HLSL intialization list support (PR #123141)

2025-01-16 Thread Chris B via cfe-commits
llvm-beanz wrote: A couple notes for myself: * I need to write some AST tests * Also need to write tests to cover bit fields and unions. https://github.com/llvm/llvm-project/pull/123141 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://li

[clang] [HLSL] Implement HLSL intialization list support (PR #123141)

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

[clang] [HLSL] Implement HLSL intialization list support (PR #123141)

2025-01-15 Thread Chris B via cfe-commits
https://github.com/llvm-beanz created https://github.com/llvm/llvm-project/pull/123141 This PR implements HLSL's initialization list behvaior as specified in the draft language specifcation under [*Decl.Init.Agg*](https://microsoft.github.io/hlsl-specs/specs/hlsl.html #Decl.Init.Agg). This be

[clang] [HLSL] Make bool in hlsl i32 (PR #122977)

2025-01-15 Thread Chris B via cfe-commits
https://github.com/llvm-beanz approved this pull request. https://github.com/llvm/llvm-project/pull/122977 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Implement HLSL Flat casting (excluding splat cases) (PR #118842)

2025-01-14 Thread Chris B via cfe-commits
@@ -2412,6 +2412,102 @@ bool SemaHLSL::CheckCompatibleParameterABI(FunctionDecl *New, return HadError; } +// Generally follows PerformScalarCast, with cases reordered for +// clarity of what types are supported +bool SemaHLSL::CanPerformScalarCast(QualType SrcTy, QualType D

[clang] [HLSL] Implement HLSL Flat casting (excluding splat cases) (PR #118842)

2025-01-14 Thread Chris B via cfe-commits
@@ -491,6 +491,81 @@ static bool isTrivialFiller(Expr *E) { return false; } +// emit a flat cast where the RHS is a scalar, including vector +static void EmitHLSLScalarFlatCast(CodeGenFunction &CGF, Address DestVal, + QualType DestTy, llvm::

[clang] [HLSL] Implement HLSL Flat casting (excluding splat cases) (PR #118842)

2025-01-14 Thread Chris B via cfe-commits
@@ -2752,7 +2787,17 @@ Value *ScalarExprEmitter::VisitCastExpr(CastExpr *CE) { llvm::Value *Zero = llvm::Constant::getNullValue(CGF.SizeTy); return Builder.CreateExtractElement(Vec, Zero, "cast.vtrunc"); } + case CK_HLSLAggregateCast: { +RValue RV = CGF.EmitAnyEx

[clang] [HLSL] Implement HLSL Flat casting (excluding splat cases) (PR #118842)

2025-01-14 Thread Chris B via cfe-commits
@@ -6358,3 +6359,89 @@ RValue CodeGenFunction::EmitPseudoObjectRValue(const PseudoObjectExpr *E, LValue CodeGenFunction::EmitPseudoObjectLValue(const PseudoObjectExpr *E) { return emitPseudoObjectExpr(*this, E, true, AggValueSlot::ignored()).LV; } + +void CodeGenFunction::Fl

[clang] [HLSL] Implement HLSL Flat casting (excluding splat cases) (PR #118842)

2025-01-14 Thread Chris B via cfe-commits
https://github.com/llvm-beanz commented: I want to spend a little more time going over the tests, but I had a few small comments. This seems to be mostly right from my initial review. https://github.com/llvm/llvm-project/pull/118842 ___ cfe-commits ma

[clang] [HLSL] Implement HLSL Flat casting (excluding splat cases) (PR #118842)

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

[clang] [SPIR-V] Add hlsl_private address space for HLSL/SPIR-V (PR #122103)

2025-01-14 Thread Chris B via cfe-commits
https://github.com/llvm-beanz commented: We talked about this yesterday in a call with @Keenuts and @s-perron. I think one of the problems we have with HLSL is that we haven't had explicit address space annotations except for `groupshared` in the past. We do need to do that in the future, but

[clang] [HLSL] Implement D3DCOLORtoUBYTE4 intrinsic (PR #122202)

2025-01-14 Thread Chris B via cfe-commits
https://github.com/llvm-beanz approved this pull request. https://github.com/llvm/llvm-project/pull/122202 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [HLSL] Implement elementwise firstbitlow builtin (PR #116858)

2025-01-14 Thread Chris B via cfe-commits
https://github.com/llvm-beanz approved this pull request. https://github.com/llvm/llvm-project/pull/116858 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] cbuffer: Create host layout struct and add resource handle to AST (PR #122820)

2025-01-14 Thread Chris B via cfe-commits
@@ -253,12 +257,253 @@ static void validatePackoffset(Sema &S, HLSLBufferDecl *BufDecl) { } } +// Returns true if the array has a zero size = if any of the dimensions is 0 +static bool isZeroSizedArray(const ConstantArrayType *CAT) { + while (CAT && !CAT->isZeroSize()) +

[clang] [HLSL] cbuffer: Create host layout struct and add resource handle to AST (PR #122820)

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

[clang] [HLSL] cbuffer: Create host layout struct and add resource handle to AST (PR #122820)

2025-01-14 Thread Chris B via cfe-commits
https://github.com/llvm-beanz commented: The one design question I have here is: should we be bothering to create a handle for the cbuffer in the frontend at all? My thought had been that we would instead emit the cbuffer member declarations as constant address space (2 for DXIL) declarations

[clang] [llvm] [HLSL] Reapply Move length support out of the DirectX Backend (#121611) (PR #122337)

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

[clang] [llvm] [HLSL] Reapply Move length support out of the DirectX Backend (#121611) (PR #122337)

2025-01-09 Thread Chris B via cfe-commits
llvm-beanz wrote: > No failures. We would need to have tests for all intrinsics that if its not > SM 6.2 or greater uses of half would error, but we never did that for any of > the other intrinsics so we should probably discuss what the test coverage > should be and apply it broadly. In pract

[clang] [HLSL] Make fast math the default for HLSL (PR #119820)

2025-01-08 Thread Chris B via cfe-commits
https://github.com/llvm-beanz approved this pull request. https://github.com/llvm/llvm-project/pull/119820 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [HLSL] Adding Flatten and Branch if attributes with test fixes (PR #122157)

2025-01-08 Thread Chris B via cfe-commits
https://github.com/llvm-beanz approved this pull request. https://github.com/llvm/llvm-project/pull/122157 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Deprecate order file instrumentation (PR #121514)

2025-01-08 Thread Chris B via cfe-commits
@@ -8010,15 +8010,19 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, } } - if (Args.hasArg(options::OPT_forder_file_instrumentation)) { - CmdArgs.push_back("-forder-file-instrumentation"); - // Enable order file instrumentation when ThinLTO is

[clang] [llvm] Revert #116331 & #121852 (PR #122105)

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

[clang] [llvm] Revert #116331 & #121852 (PR #122105)

2025-01-08 Thread Chris B via cfe-commits
https://github.com/llvm-beanz created https://github.com/llvm/llvm-project/pull/122105 #116331 introduced a regression in DXIL testing, and did not address all PR feedback before merging. @joaosaffran is looking at the regression tracked in #122052 and will re-land these changes with that fix

[clang] [llvm] [HLSL][SPIRV][DXIL] Implement `WaveActiveSum` intrinsic (PR #118580)

2025-01-07 Thread Chris B via cfe-commits
https://github.com/llvm-beanz approved this pull request. https://github.com/llvm/llvm-project/pull/118580 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [HLSL][RootSignature] Implement parsing of `RootFlags` (PR #121799)

2025-01-07 Thread Chris B via cfe-commits
llvm-beanz wrote: > I didn't implement the tokenizer because I found that the extra level of > abstraction to be redundant/not beneficial with the StringRef operations. I disagree, and generally string operations tend to muddy up and can lead to inefficiencies. > Looking at the DXC implementa

[clang] Deprecate order file instrumentation (PR #121514)

2025-01-07 Thread Chris B via cfe-commits
@@ -8010,15 +8010,19 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, } } - if (Args.hasArg(options::OPT_forder_file_instrumentation)) { - CmdArgs.push_back("-forder-file-instrumentation"); - // Enable order file instrumentation when ThinLTO is

[clang] [clang] add llvm abi support (PR #121123)

2025-01-06 Thread Chris B via cfe-commits
@@ -1531,7 +1531,7 @@ Compilation *Driver::BuildCompilation(ArrayRef ArgList) { // Check if the environment version is valid except wasm case. llvm::Triple Triple = TC.getTriple(); - if (!Triple.isWasm()) { + if (!Triple.isWasm() && Triple.getEnvironment() != llvm::Tripl

[clang] Deprecate order file instrumentation (PR #121514)

2025-01-06 Thread Chris B via cfe-commits
@@ -8010,15 +8010,19 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, } } - if (Args.hasArg(options::OPT_forder_file_instrumentation)) { - CmdArgs.push_back("-forder-file-instrumentation"); - // Enable order file instrumentation when ThinLTO is

[clang] [llvm] [HLSL] Move length support out of the DirectX Backend (PR #121611)

2025-01-06 Thread Chris B via cfe-commits
https://github.com/llvm-beanz approved this pull request. https://github.com/llvm/llvm-project/pull/121611 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [HLSL] Move length support out of the DirectX Backend (PR #121611)

2025-01-06 Thread Chris B via cfe-commits
https://github.com/llvm-beanz commented: I don't love the way you re-wrote clang/test/CodeGenHLSL/builtins/length.hlsl. I'm not a huge fan of the `update_cc_test_checks` workflow, and (as I commented elsewhere) I really don't like tests that depend on optimizations. I'm okay with removing the

[clang] [llvm] [HLSL] Move length support out of the DirectX Backend (PR #121611)

2025-01-06 Thread Chris B via cfe-commits
@@ -1,73 +1,151 @@ -// RUN: %clang_cc1 -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: --check-prefixes=CHECK,NATIVE_HALF -// RUN: %clang_cc1 -

[clang] [llvm] [HLSL][RootSignature] Implement parsing of `RootFlags` (PR #121799)

2025-01-06 Thread Chris B via cfe-commits
@@ -0,0 +1,139 @@ +#include "clang/Sema/ParseHLSLRootSignature.h" + +namespace llvm { +namespace hlsl { +namespace root_signature { + +// TODO: Hook up with Sema to properly report semantic/validation errors +bool Parser::ReportError() { return true; } + +bool Parser::ParseRootFla

[clang] [llvm] [HLSL][RootSignature] Implement parsing of `RootFlags` (PR #121799)

2025-01-06 Thread Chris B via cfe-commits
https://github.com/llvm-beanz commented: Is there a reason that you're just operating on a StringRef buffer instead of building out a proper tokenizer and parser? It seems to me like root signature parsing probably warrants full lexer and parser that operates on tokens rather than just section

[clang] [llvm] [HLSL][RootSignature] Implement parsing of `RootFlags` (PR #121799)

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

[clang] [HLSL] Fix debug info generation for RWBuffer types (PR #119041)

2025-01-06 Thread Chris B via cfe-commits
https://github.com/llvm-beanz approved this pull request. https://github.com/llvm/llvm-project/pull/119041 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [HLSL] Adding Flatten and Branch if attributes (PR #116331)

2025-01-06 Thread Chris B via cfe-commits
https://github.com/llvm-beanz approved this pull request. https://github.com/llvm/llvm-project/pull/116331 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clangd] Remove clangd's HasValue GMock matcher (PR #121309)

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

[clang] [clang-tools-extra] [clangd] Make clangd run `format::cleanupAroundReplacements()` for all code actions just as clang-tidy does (PR #118569)

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

[clang] Add `pragma clang scope [push|pop]` (PR #121025)

2024-12-23 Thread Chris B via cfe-commits
https://github.com/llvm-beanz created https://github.com/llvm/llvm-project/pull/121025 Have you ever had that horrible realization that some header you included defines a macro that matches a commonly used word that appears throughout your codebase? What kind of horrible person would define `m

[clang] [clang-tools-extra] [clangd] Make clangd run `format::cleanupAroundReplacements()` for all code actions just as clang-tidy does (PR #118569)

2024-12-22 Thread Chris B via cfe-commits
@@ -761,7 +762,37 @@ void StoreDiags::HandleDiagnostic(DiagnosticsEngine::Level DiagLevel, return false; if (!isInsideMainFile(FixIt.RemoveRange.getBegin(), SM)) return false; - Edits.push_back(toTextEdit(FixIt, SM, *LangOpts)); + + auto R = too

[clang] [clang-tools-extra] [clangd] Make clangd run `format::cleanupAroundReplacements()` for all code actions just as clang-tidy does (PR #118569)

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

[clang] [clang-tools-extra] [clangd] Make clangd run `format::cleanupAroundReplacements()` for all code actions just as clang-tidy does (PR #118569)

2024-12-22 Thread Chris B via cfe-commits
@@ -761,7 +762,37 @@ void StoreDiags::HandleDiagnostic(DiagnosticsEngine::Level DiagLevel, return false; if (!isInsideMainFile(FixIt.RemoveRange.getBegin(), SM)) return false; - Edits.push_back(toTextEdit(FixIt, SM, *LangOpts)); + + auto R = too

[clang] [clang-tools-extra] [clangd] Make clangd run `format::cleanupAroundReplacements()` for all code actions just as clang-tidy does (PR #118569)

2024-12-22 Thread Chris B via cfe-commits
@@ -761,7 +762,37 @@ void StoreDiags::HandleDiagnostic(DiagnosticsEngine::Level DiagLevel, return false; if (!isInsideMainFile(FixIt.RemoveRange.getBegin(), SM)) return false; - Edits.push_back(toTextEdit(FixIt, SM, *LangOpts)); + + auto R = too

[clang] [clang-tools-extra] [clangd] Make clangd run `format::cleanupAroundReplacements()` for all code actions just as clang-tidy does (PR #118569)

2024-12-22 Thread Chris B via cfe-commits
@@ -342,6 +342,20 @@ llvm::Error Replacements::add(const Replacement &R) { return llvm::Error::success(); } +llvm::Error Replacements::addOrMerge(const Replacement &R) { + auto Err = add(R); + if (Err) { llvm-beanz wrote: nit: You could rewrite this as: `

[clang] [clang-tools-extra] [clangd] Make clangd run `format::cleanupAroundReplacements()` for all code actions just as clang-tidy does (PR #118569)

2024-12-22 Thread Chris B via cfe-commits
@@ -149,26 +149,12 @@ class ErrorReporter { Repl.getLength(), Repl.getReplacementText()); auto &Entry = FileReplacements[R.getFilePath()]; Replacements &Replacements = Entry.Replaces; -llvm::Error Err = Rep

[clang] [clang-tools-extra] [clangd] Make clangd run `format::cleanupAroundReplacements()` for all code actions just as clang-tidy does (PR #118569)

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

[clang] [clang-tools-extra] [clangd] Make clangd run `format::cleanupAroundReplacements()` for all code actions just as clang-tidy does (PR #118569)

2024-12-22 Thread Chris B via cfe-commits
@@ -761,7 +762,37 @@ void StoreDiags::HandleDiagnostic(DiagnosticsEngine::Level DiagLevel, return false; if (!isInsideMainFile(FixIt.RemoveRange.getBegin(), SM)) return false; - Edits.push_back(toTextEdit(FixIt, SM, *LangOpts)); + + auto R = too

[clang] [clang-tools-extra] [clangd] Make clangd run `format::cleanupAroundReplacements()` for all code actions just as clang-tidy does (PR #118569)

2024-12-22 Thread Chris B via cfe-commits
https://github.com/llvm-beanz approved this pull request. This mostly looks good to me. I have a few style nits to use more idomatic patterns and conform better to LLVM coding standards. https://github.com/llvm/llvm-project/pull/118569 ___ cfe-commits

[clang-tools-extra] [clangd] Do not show `aParam` parameter hint for argument spelled `param` (PR #119162)

2024-12-22 Thread Chris B via cfe-commits
https://github.com/llvm-beanz commented: I think this gets really complicated really quickly. The `a` prefix for arguments seems like a coding style derived from Hungarian Notation, and I guess I could see an argument for having an option to disregard variable prefixes when matching the hints,

[clang] [HLSL] Codegen for `cbuffer` declarations without embedded arrays or structs (PR #119755)

2024-12-20 Thread Chris B via cfe-commits
@@ -890,6 +890,10 @@ CodeGenModule::EmitCXXGlobalInitFunc() { ModuleInits.push_back(Fn); } + if (getLangOpts().HLSL && getHLSLRuntime().needsResourceBindingInitFn()) { +CXXGlobalInits.push_back(getHLSLRuntime().createResourceBindingInitFn()); + } --

[clang] [HLSL] Codegen for `cbuffer` declarations without embedded arrays or structs (PR #119755)

2024-12-20 Thread Chris B via cfe-commits
@@ -164,18 +164,18 @@ Decl *SemaHLSL::ActOnStartBuffer(Scope *BufferScope, bool CBuffer, return Result; } -// Calculate the size of a legacy cbuffer type based on +// Calculate the size of a legacy cbuffer type in bytes based on // https://learn.microsoft.com/en-us/window

[clang] [HLSL] Codegen for `cbuffer` declarations without embedded arrays or structs (PR #119755)

2024-12-20 Thread Chris B via cfe-commits
@@ -54,78 +54,108 @@ void addDxilValVersion(StringRef ValVersionStr, llvm::Module &M) { auto *DXILValMD = M.getOrInsertNamedMetadata(DXILValKey); DXILValMD->addOperand(Val); } + void addDisableOptimizations(llvm::Module &M) { StringRef Key = "dx.disable_optimizations";

[clang] [HLSL] Codegen for `cbuffer` declarations without embedded arrays or structs (PR #119755)

2024-12-20 Thread Chris B via cfe-commits
@@ -54,78 +54,108 @@ void addDxilValVersion(StringRef ValVersionStr, llvm::Module &M) { auto *DXILValMD = M.getOrInsertNamedMetadata(DXILValKey); DXILValMD->addOperand(Val); } + void addDisableOptimizations(llvm::Module &M) { StringRef Key = "dx.disable_optimizations";

[clang] [HLSL] Codegen for `cbuffer` declarations without embedded arrays or structs (PR #119755)

2024-12-20 Thread Chris B via cfe-commits
@@ -54,78 +54,108 @@ void addDxilValVersion(StringRef ValVersionStr, llvm::Module &M) { auto *DXILValMD = M.getOrInsertNamedMetadata(DXILValKey); DXILValMD->addOperand(Val); } + void addDisableOptimizations(llvm::Module &M) { StringRef Key = "dx.disable_optimizations";

[clang] [HLSL] Codegen for `cbuffer` declarations without embedded arrays or structs (PR #119755)

2024-12-20 Thread Chris B via cfe-commits
https://github.com/llvm-beanz requested changes to this pull request. https://github.com/llvm/llvm-project/pull/119755 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Make fast math the default for HLSL (PR #119820)

2024-12-19 Thread Chris B via cfe-commits
llvm-beanz wrote: Quick sanity check question for @bogner: In DXC we apply the `fast` flag, which in LLVM 3.7 implies: `nnan ninf nsz arcp` and includes the modern interpretation of `reassoc` With this change we are applying: `reassoc nnan ninf nsz arcp afn` (no `fast` because its meaning is

[clang] [HLSL] Make fast math the default for HLSL (PR #119820)

2024-12-18 Thread Chris B via cfe-commits
llvm-beanz wrote: With how `RUN` lines tend to get copied from test to test, I think it is probably best to limit how many tests explicitly disable fast math otherwise they're likely to proliferate across future tests. https://github.com/llvm/llvm-project/pull/119820 __

[clang] [llvm] [DirectX][SPIRV] Consistent names for HLSL resource intrinsics (PR #120466)

2024-12-18 Thread Chris B via cfe-commits
@@ -208,37 +208,44 @@ Examples: .. code-block:: llvm - ; RWBuffer Buf : register(u5, space3) - %buf = call target("dx.TypedBuffer", <4 x float>, 1, 0, 0) - @llvm.dx.handle.fromBinding.tdx.TypedBuffer_f32_1_0( - i32 3, i32 5, i32 1, i32 0, i

[clang] [llvm] [DirectX][SPIRV] Consistent names for HLSL resource intrinsics (PR #120466)

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

[clang] [Clang] Add float type support to __builtin_reduce_add and __builtin_reduce_multipy (PR #120367)

2024-12-18 Thread Chris B via cfe-commits
@@ -12338,7 +12338,8 @@ def err_builtin_invalid_arg_type: Error < "a vector of integers|" "an unsigned integer|" "an 'int'|" - "a vector of floating points}1 (was %2)">; + "a vector of floating points|" + "a vector of integers or floating points}1 (was %2)">; -

[clang] [Clang] Add float type support to __builtin_reduce_add and __builtin_reduce_multipy (PR #120367)

2024-12-18 Thread Chris B via cfe-commits
@@ -1754,6 +1755,17 @@ static bool interp__builtin_vector_reduce(InterpState &S, CodePtr OpPC, PrimType ElemT = *S.getContext().classify(ElemType); unsigned NumElems = Arg.getNumElems(); + if (ElemType->isRealFloatingType()) { +if (ID != Builtin::BI__builtin_reduce_a

[clang] [llvm] [HLSL][SPIRV][DXIL] Implement `WaveActiveSum` intrinsic (PR #118580)

2024-12-17 Thread Chris B via cfe-commits
@@ -9272,6 +9272,8 @@ def err_typecheck_expect_scalar_or_vector : Error< "a vector of such type is required">; def err_typecheck_expect_any_scalar_or_vector : Error< "invalid operand of type %0 where a scalar or vector is required">; +def err_typecheck_expect_scalar_or_vect

[clang] [llvm] [HLSL] Implement elementwise firstbitlow builtin (PR #116858)

2024-12-17 Thread Chris B via cfe-commits
@@ -3139,136 +3151,269 @@ Register SPIRVInstructionSelector::buildPointerToResource( return AcReg; } -bool SPIRVInstructionSelector::selectFirstBitHigh16(Register ResVReg, -const SPIRVType *ResType, -

[clang] [llvm] [HLSL] Implement elementwise firstbitlow builtin (PR #116858)

2024-12-17 Thread Chris B via cfe-commits
@@ -3139,136 +3151,269 @@ Register SPIRVInstructionSelector::buildPointerToResource( return AcReg; } -bool SPIRVInstructionSelector::selectFirstBitHigh16(Register ResVReg, -const SPIRVType *ResType, -

[clang] [llvm] [HLSL] Implement elementwise firstbitlow builtin (PR #116858)

2024-12-17 Thread Chris B via cfe-commits
@@ -3139,136 +3151,269 @@ Register SPIRVInstructionSelector::buildPointerToResource( return AcReg; } -bool SPIRVInstructionSelector::selectFirstBitHigh16(Register ResVReg, -const SPIRVType *ResType, -

[clang] [llvm] [HLSL] Implement elementwise firstbitlow builtin (PR #116858)

2024-12-17 Thread Chris B via cfe-commits
@@ -3139,136 +3151,269 @@ Register SPIRVInstructionSelector::buildPointerToResource( return AcReg; } -bool SPIRVInstructionSelector::selectFirstBitHigh16(Register ResVReg, -const SPIRVType *ResType, -

[clang] [llvm] [HLSL] Implement elementwise firstbitlow builtin (PR #116858)

2024-12-17 Thread Chris B via cfe-commits
@@ -17,12 +17,10 @@ double test_int_builtin(double p0) { double2 test_int_builtin_2(double2 p0) { return __builtin_hlsl_elementwise_firstbithigh(p0); - // expected-error@-1 {{1st argument must be a vector of integers - // (was 'double2' (aka 'vector'))}} + // expected-err

[clang] [llvm] [HLSL] Adding Flatten and Branch if attributes (PR #116331)

2024-12-17 Thread Chris B via cfe-commits
@@ -1229,8 +1248,15 @@ FunctionPass *llvm::createSPIRVStructurizerPass() { PreservedAnalyses SPIRVStructurizerWrapper::run(Function &F, FunctionAnalysisManager &AF) { - FunctionPass *StructurizerPass = createSPIRVStructurizerPas

[clang] [llvm] [HLSL] Adding Flatten and Branch if attributes (PR #116331)

2024-12-17 Thread Chris B via cfe-commits
@@ -0,0 +1,48 @@ +// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple dxil-pc-shadermodel6.3-library %s -fnative-half-type -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple spirv-vulkan-library %s -fnative-half-type -emit-llvm -

[clang] [llvm] [HLSL] Adding Flatten and Branch if attributes (PR #116331)

2024-12-17 Thread Chris B via cfe-commits
@@ -0,0 +1,43 @@ +// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-compute -ast-dump %s | FileCheck %s + +// CHECK: FunctionDecl 0x{{[0-9A-Fa-f]+}} <{{.*}}> {{.*}} used branch 'int (int)' +// CHECK: AttributedStmt 0x{{[0-9A-Fa-f]+}} < +// CHECK-NEXT: -HLSLControlFlowHintAttr 0x

[clang] [llvm] [HLSL] Adding Flatten and Branch if attributes (PR #116331)

2024-12-17 Thread Chris B via cfe-commits
@@ -295,6 +296,39 @@ static MDTuple *emitTopLevelLibraryNode(Module &M, MDNode *RMD, return constructEntryMetadata(nullptr, nullptr, RMD, Properties, Ctx); } +// TODO: We might need to refactor this to be more generic, +// in case we need more metadata to be replaced. +stat

[clang] [llvm] [HLSL] Adding Flatten and Branch if attributes (PR #116331)

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

[clang] [llvm] [HLSL] Adding Flatten and Branch if attributes (PR #116331)

2024-12-17 Thread Chris B via cfe-commits
@@ -2776,19 +2788,23 @@ bool SPIRVInstructionSelector::selectIntrinsic(Register ResVReg, } return MIB.constrainAllUses(TII, TRI, RBI); } - case Intrinsic::spv_loop_merge: - case Intrinsic::spv_selection_merge: { -const auto Opcode = IID == Intrinsic::spv_select

[clang] [llvm] [HLSL] Adding Flatten and Branch if attributes (PR #116331)

2024-12-17 Thread Chris B via cfe-commits
@@ -2081,7 +2081,26 @@ void CodeGenFunction::EmitBranchOnBoolExpr( Weights = createProfileWeights(TrueCount, CurrentCount - TrueCount); } - Builder.CreateCondBr(CondV, TrueBlock, FalseBlock, Weights, Unpredictable); + auto *BrInst = Builder.CreateCondBr(CondV, TrueBloc

[clang] [llvm] [HLSL] Adding Flatten and Branch if attributes (PR #116331)

2024-12-17 Thread Chris B via cfe-commits
https://github.com/llvm-beanz requested changes to this pull request. Mostly minor nits, but the stuff in `SPIRVStructurizerWrapper::run` has to change before we land this. https://github.com/llvm/llvm-project/pull/116331 ___ cfe-commits mailing list

[clang] [HLSL] Move `_init_resource_bindings` to entry point functions (PR #119311)

2024-12-12 Thread Chris B via cfe-commits
llvm-beanz wrote: > You are correct @llvm-beanz, this change is not needed at all. Sorry for > wasting your time! Even a broken clock is right twice a day... me being the broken clock here 😄 It's never a waste to put something up to review if it helps us get to the right solution. https://gi

[clang] [NFC] Updating Debug Info generation for 'this' (PR #119445)

2024-12-12 Thread Chris B via cfe-commits
llvm-beanz wrote: > any chance you could A/B test this on a bootstrap of clang, for instance? To > help validate that this really is NFC/dead code? I did a little more archeology, and I'm actually struggling to find any point in the history where this change was required. The difference betwee

[clang] [clang-tools-extra] [clangd] Update clangDaemonTweaks to set symbol visibility macros (PR #112304)

2024-12-11 Thread Chris B via cfe-commits
llvm-beanz wrote: What is the case where an object library wouldn't need to act as `CLANG_IMPORT`? It seems to me like the object library needs to be built assuming that it is importing clang symbols unless it is one of the core clang components. https://github.com/llvm/llvm-project/pull/1123

[clang] [clang-tools-extra] [clangd] Update clangDaemonTweaks to set symbol visibility macros (PR #112304)

2024-12-11 Thread Chris B via cfe-commits
@@ -114,7 +114,7 @@ macro(add_clang_library name) if(TARGET "obj.${name}") target_compile_definitions("obj.${name}" PUBLIC CLANG_BUILD_STATIC) endif() - elseif(NOT ARG_SHARED AND NOT ARG_STATIC) + elseif(NOT ARG_SHARED AND NOT ARG_STATIC AND NOT ARG_CLANG_IMPORT

[clang] [NFC] Cleanup comments in HLSLExternalSemaSource.cpp (PR #119444)

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

[clang] [llvm] [HLSL][SPIRV][DXIL] Implement `WaveActiveSum` intrinsic (PR #118580)

2024-12-10 Thread Chris B via cfe-commits
@@ -9272,6 +9272,8 @@ def err_typecheck_expect_scalar_or_vector : Error< "a vector of such type is required">; def err_typecheck_expect_any_scalar_or_vector : Error< "invalid operand of type %0 where a scalar or vector is required">; +def err_typecheck_expect_scalar_or_vect

[clang] [HLSL] Move `_init_resource_bindings` to entry point functions (PR #119311)

2024-12-10 Thread Chris B via cfe-commits
llvm-beanz wrote: Is this the right solution, or should we be doing something to force the constructor function to be generated. I'm a little worried that we have one path for initializing some types of globals and a different approach for other globals. https://github.com/llvm/llvm-project/p

[clang] [llvm] [HLSL] Implement SV_GroupThreadId semantic (PR #117781)

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

[clang] [HLSL] Fix debug info generation for RWBuffer types (PR #119041)

2024-12-09 Thread Chris B via cfe-commits
@@ -2021,28 +2021,10 @@ llvm::DISubroutineType *CGDebugInfo::getOrCreateInstanceMethodType( // ThisPtr may be null if the member function has an explicit 'this' // parameter. if (!ThisPtr.isNull()) { -const CXXRecordDecl *RD = ThisPtr->getPointeeCXXRecordDecl(); -

[clang-tools-extra] [clangd] Consolidate two functions converting index to LSP locations (PR #117885)

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

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

2024-12-03 Thread Chris B via cfe-commits
@@ -5322,6 +5324,11 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo, IRCallArgs[FirstIRArg] = Val; break; } + } else if (I->getType()->isArrayParameterType()) { +// use the tmp created by the HLSLOutArgExpr +/

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

2024-12-03 Thread Chris B via cfe-commits
@@ -5322,6 +5324,11 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo, IRCallArgs[FirstIRArg] = Val; break; } + } else if (I->getType()->isArrayParameterType()) { +// use the tmp created by the HLSLOutArgExpr +/

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

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

[clang] [llvm] [HLSL] Adding Flatten and Branch if attributes (PR #116331)

2024-12-03 Thread Chris B via cfe-commits
@@ -2694,19 +2694,49 @@ bool SPIRVInstructionSelector::selectIntrinsic(Register ResVReg, } return MIB.constrainAllUses(TII, TRI, RBI); } - case Intrinsic::spv_loop_merge: - case Intrinsic::spv_selection_merge: { -const auto Opcode = IID == Intrinsic::spv_select

[clang] [llvm] [HLSL] Adding Flatten and Branch if attributes (PR #116331)

2024-12-03 Thread Chris B via cfe-commits
@@ -1206,6 +1202,21 @@ class SPIRVStructurizer : public FunctionPass { AU.addPreserved(); FunctionPass::getAnalysisUsage(AU); } + + void createOpSelectMerge(IRBuilder<> *Builder, BlockAddress *MergeAddress) { +Instruction *BBTerminatorInst = Builder->GetInsertBlo

[clang] [llvm] [HLSL] Adding Flatten and Branch if attributes (PR #116331)

2024-12-03 Thread Chris B via cfe-commits
@@ -300,6 +301,36 @@ static MDTuple *emitTopLevelLibraryNode(Module &M, MDNode *RMD, return constructEntryMetadata(nullptr, nullptr, RMD, Properties, Ctx); } +// TODO: We might need to refactor this to be more generic, +// in case we need more metadata to be replaced. +stat

[clang] [llvm] [HLSL] Adding Flatten and Branch if attributes (PR #116331)

2024-12-02 Thread Chris B via cfe-commits
@@ -2694,19 +2694,49 @@ bool SPIRVInstructionSelector::selectIntrinsic(Register ResVReg, } return MIB.constrainAllUses(TII, TRI, RBI); } - case Intrinsic::spv_loop_merge: - case Intrinsic::spv_selection_merge: { -const auto Opcode = IID == Intrinsic::spv_select

[clang] [llvm] [HLSL] Adding Flatten and Branch if attributes (PR #116331)

2024-12-02 Thread Chris B via cfe-commits
@@ -300,6 +301,36 @@ static MDTuple *emitTopLevelLibraryNode(Module &M, MDNode *RMD, return constructEntryMetadata(nullptr, nullptr, RMD, Properties, Ctx); } +// TODO: We might need to refactor this to be more generic, +// in case we need more metadata to be replaced. +stat

[clang] [llvm] [HLSL] Adding Flatten and Branch if attributes (PR #116331)

2024-12-02 Thread Chris B via cfe-commits
@@ -2076,7 +2076,28 @@ void CodeGenFunction::EmitBranchOnBoolExpr( Weights = createProfileWeights(TrueCount, CurrentCount - TrueCount); } - Builder.CreateCondBr(CondV, TrueBlock, FalseBlock, Weights, Unpredictable); + auto *BrInst = Builder.CreateCondBr(CondV, TrueBloc

[clang] [NFC][HLSL] Allow target intrinsic switching to optionally be set. (PR #117648)

2024-12-02 Thread Chris B via cfe-commits
@@ -30,22 +30,36 @@ #include #include +#define GENERATE_HLSL_INTRINSIC_FUNCTION_DEFAULT(FunctionName, \ + IntrinsicPostfix) \ + GENERATE_HLSL_INTRINSIC_FUNCTION(FunctionName, IntrinsicPostfix, 1,

[clang] [llvm] [HLSL] Implement RWBuffer::operator[] via __builtin_hlsl_resource_getpointer (PR #117017)

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

[clang-tools-extra] Rename CODE_OWNERS -> Maintainers (PR #114544)

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

[clang] [HLSL] Implement SV_GroupID semantic (PR #115911)

2024-11-22 Thread Chris B via cfe-commits
@@ -784,6 +785,17 @@ void SemaHLSL::handleSV_DispatchThreadIDAttr(Decl *D, const ParsedAttr &AL) { HLSLSV_DispatchThreadIDAttr(getASTContext(), AL)); } +void SemaHLSL::handleSV_GroupIDAttr(Decl *D, const ParsedAttr &AL) { + auto *VD = cast(D); + if (!isLega

  1   2   3   4   5   6   7   8   9   >