[clang] [HLSL] standardize builtin unit tests (PR #83340)

2024-02-28 Thread Greg Roth via cfe-commits
pow2clk wrote: Do we have the suggestions that this is responding to written down somewhere? I think it would be useful to have those guidelines for anyone who might want to contribute HLSL tests. At any rate, I'd like to know the ones that this is in response to. https://github.com/llvm/llv

[clang] [clang][sema] consolidate diags for incompatible_vector_* (PR #83609)

2024-03-01 Thread Greg Roth via cfe-commits
@@ -5218,15 +5218,15 @@ bool CheckVectorElementCallArgs(Sema *S, CallExpr *TheCall) { // Note: type promotion is intended to be handeled via the intrinsics // and not the builtin itself. S->Diag(TheCall->getBeginLoc(), -diag::err_vec_bu

[clang] [clang][sema] consolidate diags for incompatible_vector_* (PR #83609)

2024-03-01 Thread Greg Roth via cfe-commits
https://github.com/pow2clk edited https://github.com/llvm/llvm-project/pull/83609 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][sema] consolidate diags for incompatible_vector_* (PR #83609)

2024-03-01 Thread Greg Roth via cfe-commits
https://github.com/pow2clk commented: Just some nitpicks. I also find it much harder to rereview a change when a force push has gone through. I don't know how things are done around here, but if it can be avoided, I prefer it. https://github.com/llvm/llvm-project/pull/83609 ___

[clang] [clang][sema] consolidate diags for incompatible_vector_* (PR #83609)

2024-03-01 Thread Greg Roth via cfe-commits
@@ -22,7 +22,7 @@ float test_dot_vector_size_mismatch(float3 p0, float2 p1) { float test_dot_builtin_vector_size_mismatch(float3 p0, float2 p1) { return __builtin_hlsl_dot(p0, p1); - // expected-error@-1 {{all arguments to '__builtin_hlsl_dot' must have vectors of the same

[clang] [clang][sema] consolidate diags for incompatible_vector_* (PR #83609)

2024-03-01 Thread Greg Roth via cfe-commits
@@ -5241,8 +5241,8 @@ bool CheckVectorElementCallArgs(Sema *S, CallExpr *TheCall) { // Note: if we get here one of the args is a scalar which // requires a VectorSplat on Arg0 or Arg1 - S->Diag(BuiltinLoc, diag::err_vec_builtin_non_vector_all) - << TheCall->getDirec

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

2024-09-04 Thread Greg Roth via cfe-commits
@@ -414,9 +414,20 @@ void CGHLSLRuntime::emitEntryFunction(const FunctionDecl *FD, void CGHLSLRuntime::setHLSLFunctionAttributes(const FunctionDecl *FD, llvm::Function *Fn) { - if (FD->isInExportDeclContext()) { -const String

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

2024-09-04 Thread Greg Roth via cfe-commits
https://github.com/pow3clk commented: On my laptop account. I assure you it's who you think it is. https://github.com/llvm/llvm-project/pull/106588 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/

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

2024-09-04 Thread Greg Roth via cfe-commits
https://github.com/pow3clk edited https://github.com/llvm/llvm-project/pull/106588 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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

2024-09-04 Thread Greg Roth via cfe-commits
@@ -290,8 +290,6 @@ struct BuiltinTypeDeclBuilder { SourceLocation())); MethodDecl->setLexicalDeclContext(Record); MethodDecl->setAccess(AccessSpecifier::AS_public); -MethodDecl->addAttr(AlwaysInlineAttr::CreateImplicit(

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

2024-09-04 Thread Greg Roth via cfe-commits
https://github.com/pow2clk updated https://github.com/llvm/llvm-project/pull/106588 >From 12253818bd47aa8c324f6222586965f356b11c90 Mon Sep 17 00:00:00 2001 From: Greg Roth Date: Wed, 24 Jul 2024 16:49:19 -0600 Subject: [PATCH 1/3] [HLSL] set alwaysinline on HLSL functions HLSL inlines all its

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

2024-09-04 Thread Greg Roth via cfe-commits
https://github.com/pow2clk updated https://github.com/llvm/llvm-project/pull/106588 >From 12253818bd47aa8c324f6222586965f356b11c90 Mon Sep 17 00:00:00 2001 From: Greg Roth Date: Wed, 24 Jul 2024 16:49:19 -0600 Subject: [PATCH 1/4] [HLSL] set alwaysinline on HLSL functions HLSL inlines all its

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

2024-09-05 Thread Greg Roth via cfe-commits
https://github.com/pow3clk edited https://github.com/llvm/llvm-project/pull/106588 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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

2024-09-09 Thread Greg Roth via cfe-commits
https://github.com/pow2clk commented: Thanks Damyan! https://github.com/llvm/llvm-project/pull/106588 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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

2024-09-09 Thread Greg Roth via cfe-commits
https://github.com/pow2clk edited https://github.com/llvm/llvm-project/pull/106588 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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

2024-09-09 Thread Greg Roth via cfe-commits
@@ -0,0 +1,114 @@ +// RUN: %clang_cc1 -x hlsl -triple dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes -o - | FileCheck %s --check-prefixes=CHECK,NOINLINE +// RUN: %clang_cc1 -x hlsl -triple dxil-pc-shadermodel6.3-library %s -emit-llvm -O0 -o - | FileCheck %s

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

2024-09-09 Thread Greg Roth via cfe-commits
@@ -1239,9 +1239,9 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy, if (getLangOpts().OpenMP && CurCodeDecl) CGM.getOpenMPRuntime().emitFunctionProlog(*this, CurCodeDecl); - if (FD && getLangOpts().HLSL) { + if (getLangOpts().HLSL) { // Handl

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

2024-09-09 Thread Greg Roth via cfe-commits
@@ -2474,7 +2474,9 @@ void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D, // If we don't have a declaration to control inlining, the function isn't // explicitly marked as alwaysinline for semantic reasons, and inlining is // disabled, mark th

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

2024-09-09 Thread Greg Roth via cfe-commits
https://github.com/pow2clk updated https://github.com/llvm/llvm-project/pull/106588 >From 12253818bd47aa8c324f6222586965f356b11c90 Mon Sep 17 00:00:00 2001 From: Greg Roth Date: Wed, 24 Jul 2024 16:49:19 -0600 Subject: [PATCH 1/6] [HLSL] set alwaysinline on HLSL functions HLSL inlines all its

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

2024-09-09 Thread Greg Roth via cfe-commits
https://github.com/pow2clk updated https://github.com/llvm/llvm-project/pull/106588 >From 12253818bd47aa8c324f6222586965f356b11c90 Mon Sep 17 00:00:00 2001 From: Greg Roth Date: Wed, 24 Jul 2024 16:49:19 -0600 Subject: [PATCH 1/7] [HLSL] set alwaysinline on HLSL functions HLSL inlines all its

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

2024-09-09 Thread Greg Roth via cfe-commits
@@ -2471,11 +2471,14 @@ void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D, B.addAttribute(llvm::Attribute::StackProtectReq); if (!D) { +// HLSL functions must always be inlined +if (getLangOpts().HLSL && !F->hasFnAttribute("hlsl.shader"))

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

2024-09-09 Thread Greg Roth via cfe-commits
https://github.com/pow2clk updated https://github.com/llvm/llvm-project/pull/106588 >From 12253818bd47aa8c324f6222586965f356b11c90 Mon Sep 17 00:00:00 2001 From: Greg Roth Date: Wed, 24 Jul 2024 16:49:19 -0600 Subject: [PATCH 1/8] [HLSL] set alwaysinline on HLSL functions HLSL inlines all its

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

2024-09-10 Thread Greg Roth via cfe-commits
@@ -2471,11 +2471,14 @@ void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D, B.addAttribute(llvm::Attribute::StackProtectReq); if (!D) { +// HLSL functions must always be inlined +if (getLangOpts().HLSL && !F->hasFnAttribute("hlsl.shader"))

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

2024-09-10 Thread Greg Roth via cfe-commits
https://github.com/pow2clk updated https://github.com/llvm/llvm-project/pull/106588 >From 12253818bd47aa8c324f6222586965f356b11c90 Mon Sep 17 00:00:00 2001 From: Greg Roth Date: Wed, 24 Jul 2024 16:49:19 -0600 Subject: [PATCH 1/9] [HLSL] set alwaysinline on HLSL functions HLSL inlines all its

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

2024-09-10 Thread Greg Roth via cfe-commits
https://github.com/pow2clk updated https://github.com/llvm/llvm-project/pull/106588 >From 12253818bd47aa8c324f6222586965f356b11c90 Mon Sep 17 00:00:00 2001 From: Greg Roth Date: Wed, 24 Jul 2024 16:49:19 -0600 Subject: [PATCH 01/10] [HLSL] set alwaysinline on HLSL functions HLSL inlines all it

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

2024-09-11 Thread Greg Roth via cfe-commits
https://github.com/pow2clk updated https://github.com/llvm/llvm-project/pull/106588 >From 12253818bd47aa8c324f6222586965f356b11c90 Mon Sep 17 00:00:00 2001 From: Greg Roth Date: Wed, 24 Jul 2024 16:49:19 -0600 Subject: [PATCH 01/11] [HLSL] set alwaysinline on HLSL functions HLSL inlines all it

[clang] [llvm] [HLSL][DXIL][SPIRV] Create llvm dot intrinsic and use for HLSL (PR #102872)

2024-08-12 Thread Greg Roth via cfe-commits
https://github.com/pow2clk created https://github.com/llvm/llvm-project/pull/102872 Per https://discourse.llvm.org/t/rfc-all-the-math-intrinsics/78294 `dot` should be an LLVM intrinsic. This adds the llvm intrinsics and updates HLSL builtin codegen to emit them. Removed some stale comments that

[clang] [llvm] [HLSL][DXIL][SPIRV] Create llvm dot intrinsic and use for HLSL (PR #102872)

2024-08-12 Thread Greg Roth via cfe-commits
https://github.com/pow2clk commented: The three commits are independently committable, but this is the grouping @farzonl and I agreed on. Reviewing them individually still might make this easier: 1. Create llvm dot intrinsic (6fde4bc98d0156024cf7acc27e2e986b9bec3993) 2. Update DX intrinsic ex

[clang] [llvm] [HLSL][DXIL][SPIRV] Create llvm dot intrinsic and use for HLSL (PR #102872)

2024-08-12 Thread Greg Roth via cfe-commits
https://github.com/pow2clk edited https://github.com/llvm/llvm-project/pull/102872 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [HLSL][DXIL][SPIRV] Create llvm dot intrinsic and use for HLSL (PR #102872)

2024-08-12 Thread Greg Roth via cfe-commits
@@ -18528,37 +18520,38 @@ Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned BuiltinID, Value *Op1 = EmitScalarExpr(E->getArg(1)); llvm::Type *T0 = Op0->getType(); llvm::Type *T1 = Op1->getType(); + +// If the arguments are scalars, just emit a multiply

[clang] [llvm] [HLSL][DXIL][SPIRV] Create llvm dot intrinsic and use for HLSL (PR #102872)

2024-08-12 Thread Greg Roth via cfe-commits
@@ -659,7 +659,7 @@ def Dot3 : DXILOp<55, dot3> { def Dot4 : DXILOp<56, dot4> { let Doc = "dot product of two float vectors Dot(a,b) = a[0]*b[0] + ... + " -"a[n]*b[n] where n is between 0 and 3"; +"a[n]*b[n] where n is 0 to 3 inclusive"; ---

[clang] [llvm] [HLSL][DXIL][SPIRV] Create llvm dot intrinsic and use for HLSL (PR #102872)

2024-08-12 Thread Greg Roth via cfe-commits
@@ -7,155 +7,155 @@ // RUN: -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF #ifdef __HLSL_ENABLE_16_BIT -// NATIVE_HALF: %dx.dot = mul i16 %0, %1 -// NATIVE_HALF: ret i16 %dx.dot +// NATIVE_HALF: %dot = mul i16 %0, %1 +// NATIVE_HALF: ret i16 %dot int16_t test_dot_short(

[clang] [llvm] [HLSL][DXIL][SPIRV] Create llvm dot intrinsic and use for HLSL (PR #102872)

2024-08-12 Thread Greg Roth via cfe-commits
@@ -380,6 +383,20 @@ bool SPIRVInstructionSelector::spvSelect(Register ResVReg, MIB.addImm(V); return MIB.constrainAllUses(TII, TRI, RBI); } + + case TargetOpcode::G_FDOTPROD: { +MachineBasicBlock &BB = *I.getParent(); +return BuildMI(BB, I, I.getDebugLoc()

[clang] [llvm] [HLSL][DXIL][SPIRV] Create llvm dot intrinsic and use for HLSL (PR #102872)

2024-08-12 Thread Greg Roth via cfe-commits
@@ -1057,6 +1057,27 @@ def G_FTANH : GenericInstruction { let hasSideEffects = false; } +/// Floating point vector dot product +def G_FDOTPROD : GenericInstruction { + let OutOperandList = (outs type0:$dst); + let InOperandList = (ins type0:$src1, type0:$src2); + let hasS

[clang] [llvm] [HLSL][DXIL][SPIRV] Create llvm dot intrinsic and use for HLSL (PR #102872)

2024-08-12 Thread Greg Roth via cfe-commits
https://github.com/pow2clk updated https://github.com/llvm/llvm-project/pull/102872 >From 6fde4bc98d0156024cf7acc27e2e986b9bec3993 Mon Sep 17 00:00:00 2001 From: Greg Roth Date: Fri, 2 Aug 2024 20:10:04 -0600 Subject: [PATCH 1/3] Create llvm dot intrinsic Per https://discourse.llvm.org/t/rfc-a

[clang] [llvm] [HLSL][DXIL][SPIRV] Create llvm dot intrinsic and use for HLSL (PR #102872)

2024-08-12 Thread Greg Roth via cfe-commits
@@ -1366,6 +1383,67 @@ bool SPIRVInstructionSelector::selectRsqrt(Register ResVReg, .constrainAllUses(TII, TRI, RBI); } +// Since there is no integer dot implementation, expand by piecewise multiplying pow2clk wrote: Those are fairly recent SPIRV exte

[clang] [llvm] [HLSL][DXIL][SPIRV] Create llvm dot intrinsic and use for HLSL (PR #102872)

2024-08-12 Thread Greg Roth via cfe-commits
@@ -18470,22 +18470,14 @@ llvm::Value *CodeGenFunction::EmitScalarOrConstFoldImmArg(unsigned ICEArguments, return Arg; } -Intrinsic::ID getDotProductIntrinsic(QualType QT, int elementCount) { - if (QT->hasFloatingRepresentation()) { -switch (elementCount) { -case 2

[clang] [llvm] [HLSL][DXIL][SPIRV] Create llvm dot intrinsic and use for HLSL (PR #102872)

2024-08-12 Thread Greg Roth via cfe-commits
@@ -1045,6 +1045,15 @@ let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrWillReturn] in { def int_nearbyint : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>; def int_round : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>; def int_roun

[clang] [llvm] [HLSL][DXIL][SPIRV] Create llvm dot intrinsic and use for HLSL (PR #102872)

2024-08-12 Thread Greg Roth via cfe-commits
https://github.com/pow2clk updated https://github.com/llvm/llvm-project/pull/102872 >From 6fde4bc98d0156024cf7acc27e2e986b9bec3993 Mon Sep 17 00:00:00 2001 From: Greg Roth Date: Fri, 2 Aug 2024 20:10:04 -0600 Subject: [PATCH 1/4] Create llvm dot intrinsic Per https://discourse.llvm.org/t/rfc-a

[clang] [llvm] [HLSL][DXIL][SPIRV] Create llvm dot intrinsic and use for HLSL (PR #102872)

2024-08-16 Thread Greg Roth via cfe-commits
https://github.com/pow2clk updated https://github.com/llvm/llvm-project/pull/102872 >From 6fde4bc98d0156024cf7acc27e2e986b9bec3993 Mon Sep 17 00:00:00 2001 From: Greg Roth Date: Fri, 2 Aug 2024 20:10:04 -0600 Subject: [PATCH 1/6] Create llvm dot intrinsic Per https://discourse.llvm.org/t/rfc-a

[clang] Correct confusing header in HLSLDocs (PR #100017)

2024-07-22 Thread Greg Roth via cfe-commits
https://github.com/pow2clk updated https://github.com/llvm/llvm-project/pull/100017 >From f325499de6336807b0d56696356a3e11c7a26ac3 Mon Sep 17 00:00:00 2001 From: Greg Roth Date: Mon, 22 Jul 2024 17:39:47 -0600 Subject: [PATCH 1/2] Correct confusing header in HLSLDocs Because AvailabilityDiagno

[clang] Correct confusing headers in HLSLDocs (PR #100017)

2024-07-22 Thread Greg Roth via cfe-commits
https://github.com/pow2clk edited https://github.com/llvm/llvm-project/pull/100017 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] (DRAFT) Another way to implement #92071: [HLSL] Default linkage of HLSL function should be internal (PR #95331)

2024-07-24 Thread Greg Roth via cfe-commits
@@ -353,6 +353,23 @@ llvm::Value *CGHLSLRuntime::emitInputSemantic(IRBuilder<> &B, return nullptr; } +void CGHLSLRuntime::emitFunctionProlog(const FunctionDecl *FD, + llvm::Function *Fn) { + if (!FD || !Fn) +return; + + if (FD->ha

[clang] [HLSL] (DRAFT) Another way to implement #92071: [HLSL] Default linkage of HLSL function should be internal (PR #95331)

2024-07-25 Thread Greg Roth via cfe-commits
@@ -119,3 +119,16 @@ behavior between Clang and DXC. Some examples include: diagnostic notifying the user of the conversion rather than silently altering precision relative to the other overloads (as FXC does) or generating code that will fail validation (as DXC does). +

[clang] [HLSL] (DRAFT) Another way to implement #92071: [HLSL] Default linkage of HLSL function should be internal (PR #95331)

2024-07-25 Thread Greg Roth via cfe-commits
https://github.com/pow2clk edited https://github.com/llvm/llvm-project/pull/95331 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] (DRAFT) Another way to implement #92071: [HLSL] Default linkage of HLSL function should be internal (PR #95331)

2024-07-25 Thread Greg Roth via cfe-commits
https://github.com/pow2clk commented: Linking functions as internal should mean that they won't be included in the final output if they don't have any calls. A test that verifies that behavior would be useful. Even if they are called, a test that verifies that they have the "internal" attribu

[clang] [HLSL] (DRAFT) Another way to implement #92071: [HLSL] Default linkage of HLSL function should be internal (PR #95331)

2024-07-25 Thread Greg Roth via cfe-commits
@@ -12363,6 +12363,11 @@ bool ASTContext::DeclMustBeEmitted(const Decl *D) { if (D->hasAttr() || D->hasAttr()) return true; + // HLSL entry functiona are required. pow2clk wrote: ```suggestion // HLSL entry functions are required. ``` typo https://g

[clang] [HLSL] (DRAFT) Another way to implement #92071: [HLSL] Default linkage of HLSL function should be internal (PR #95331)

2024-07-25 Thread Greg Roth via cfe-commits
@@ -158,7 +158,8 @@ def FunctionTmpl def HLSLEntry : SubsetSubjectisExternallyVisible() && !isa(S)}], + [{S->getDeclContext()->getRedeclContext()->isFileContext() && +S->getStorageClass() != SC_Static}], pow2clk wrote

[clang] [HLSL] (DRAFT) Another way to implement #92071: [HLSL] Default linkage of HLSL function should be internal (PR #95331)

2024-07-25 Thread Greg Roth via cfe-commits
@@ -119,3 +119,16 @@ behavior between Clang and DXC. Some examples include: diagnostic notifying the user of the conversion rather than silently altering precision relative to the other overloads (as FXC does) or generating code that will fail validation (as DXC does). +

[clang] Correct confusing header in HLSLDocs (PR #100017)

2024-07-22 Thread Greg Roth via cfe-commits
https://github.com/pow2clk created https://github.com/llvm/llvm-project/pull/100017 Because AvailabilityDiagnostics.rst mistakenly overlined the "Examples" section, it was included in the generated HLSLDocs page. By demoting it to a subheader, it shouldn't show up as a top-level HLSLDocs page.

[clang] Correct confusing header in HLSLDocs (PR #100017)

2024-07-22 Thread Greg Roth via cfe-commits
pow2clk wrote: See https://clang.llvm.org/docs/HLSL/HLSLDocs.html to see the effect https://github.com/llvm/llvm-project/pull/100017 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Implement '__builtin_hlsl_is_intangible' type trait (PR #104544)

2024-08-26 Thread Greg Roth via cfe-commits
https://github.com/pow2clk commented: Looks good overall. I have some areas where I still feel confused though https://github.com/llvm/llvm-project/pull/104544 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailm

[clang] [HLSL] Implement '__builtin_hlsl_is_intangible' type trait (PR #104544)

2024-08-26 Thread Greg Roth via cfe-commits
@@ -1154,3 +1156,70 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { } return false; } + +static bool calculateIsIntangibleType(QualType Ty) { + Ty = Ty->getCanonicalTypeUnqualified(); + if (Ty->isBuiltinType()) +return Ty->isHLSLSp

[clang] [HLSL] Implement '__builtin_hlsl_is_intangible' type trait (PR #104544)

2024-08-26 Thread Greg Roth via cfe-commits
@@ -1154,3 +1156,70 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { } return false; } + +static bool calculateIsIntangibleType(QualType Ty) { + Ty = Ty->getCanonicalTypeUnqualified(); + if (Ty->isBuiltinType()) +return Ty->isHLSLSp

[clang] [HLSL] Implement '__builtin_hlsl_is_intangible' type trait (PR #104544)

2024-08-26 Thread Greg Roth via cfe-commits
@@ -1154,3 +1156,70 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { } return false; } + +static bool calculateIsIntangibleType(QualType Ty) { + Ty = Ty->getCanonicalTypeUnqualified(); + if (Ty->isBuiltinType()) +return Ty->isHLSLSp

[clang] [HLSL] Implement '__builtin_hlsl_is_intangible' type trait (PR #104544)

2024-08-26 Thread Greg Roth via cfe-commits
https://github.com/pow2clk edited https://github.com/llvm/llvm-project/pull/104544 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Implement '__builtin_hlsl_is_intangible' type trait (PR #104544)

2024-08-26 Thread Greg Roth via cfe-commits
@@ -1154,3 +1156,70 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { } return false; } + +static bool calculateIsIntangibleType(QualType Ty) { + Ty = Ty->getCanonicalTypeUnqualified(); + if (Ty->isBuiltinType()) +return Ty->isHLSLSp

[clang] [HLSL] Implement '__builtin_hlsl_is_intangible' type trait (PR #104544)

2024-08-26 Thread Greg Roth via cfe-commits
@@ -5683,6 +5685,14 @@ static bool EvaluateUnaryTypeTrait(Sema &Self, TypeTrait UTT, return true; return false; } + case UTT_IsIntangibleType: +if (!T->isVoidType() && !T->isIncompleteArrayType()) + if (Self.RequireCompleteType(TInfo->getTypeLoc().getBe

[clang] [HLSL] Implement '__builtin_hlsl_is_intangible' type trait (PR #104544)

2024-08-26 Thread Greg Roth via cfe-commits
@@ -1154,3 +1156,70 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { } return false; } + +static bool calculateIsIntangibleType(QualType Ty) { + Ty = Ty->getCanonicalTypeUnqualified(); + if (Ty->isBuiltinType()) +return Ty->isHLSLSp

[clang] [HLSL] Implement '__builtin_hlsl_is_intangible' type trait (PR #104544)

2024-08-26 Thread Greg Roth via cfe-commits
@@ -1154,3 +1156,70 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { } return false; } + +static bool calculateIsIntangibleType(QualType Ty) { + Ty = Ty->getCanonicalTypeUnqualified(); + if (Ty->isBuiltinType()) +return Ty->isHLSLSp

[clang] [llvm] Tentative fix for not removing newly internal functions (PR #106146)

2024-08-26 Thread Greg Roth via cfe-commits
https://github.com/pow2clk created https://github.com/llvm/llvm-project/pull/106146 Functions are not removed even when made internal by DXILFinalizeLinkage The removal code is called from alwaysinliner and globalopt, which are invoked too early to remove functions made internal by this pass.

[clang] [llvm] Tentative fix for not removing newly internal functions (PR #106146)

2024-08-26 Thread Greg Roth via cfe-commits
https://github.com/pow2clk updated https://github.com/llvm/llvm-project/pull/106146 >From 6cf9e802a47860279fc793cb07ac3f4850826cb3 Mon Sep 17 00:00:00 2001 From: Greg Roth Date: Sun, 25 Aug 2024 12:00:03 -0600 Subject: [PATCH] Tentative fix for not removing newly internal functions Functions a

[clang] [llvm] Tentative fix for not removing newly internal functions (PR #106146)

2024-08-26 Thread Greg Roth via cfe-commits
pow2clk wrote: I'd like to add a test that verifies this removal of used functions that get alwaysinlined, but that requires the inlining fix for #89282 https://github.com/llvm/llvm-project/pull/106146 ___ cfe-commits mailing list cfe-commits@lists.l

[clang] [llvm] Tentative fix for not removing newly internal functions (PR #106146)

2024-08-26 Thread Greg Roth via cfe-commits
@@ -18,19 +18,20 @@ using namespace llvm; static bool finalizeLinkage(Module &M) { - SmallPtrSet EntriesAndExports; + SmallPtrSet Funcs; // Find all entry points and export functions for (Function &EF : M.functions()) { -if (!EF.hasFnAttribute("hlsl.shader") && !

[clang] [llvm] Tentative fix for not removing newly internal functions (PR #106146)

2024-08-26 Thread Greg Roth via cfe-commits
https://github.com/pow2clk updated https://github.com/llvm/llvm-project/pull/106146 >From e0d9fa7a87ee18b23cda29381afadeb0b8d23ce8 Mon Sep 17 00:00:00 2001 From: Greg Roth Date: Sun, 25 Aug 2024 12:00:03 -0600 Subject: [PATCH] Tentative fix for not removing newly internal functions Functions a

[clang] [DXIL] Don't generate per-variable guards for DirectX (PR #106096)

2024-08-27 Thread Greg Roth via cfe-commits
@@ -0,0 +1,37 @@ +// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -emit-llvm -o - -disable-llvm-passes %s | FileCheck %s + +// Verify that no per variable _Init_thread instructions are emitted for non-trivial static locals +// These would normally be emitted by the Mic

[clang] [DXIL] Don't generate per-variable guards for DirectX (PR #106096)

2024-08-27 Thread Greg Roth via cfe-commits
@@ -0,0 +1,37 @@ +// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -emit-llvm -o - -disable-llvm-passes %s | FileCheck %s + +// Verify that no per variable _Init_thread instructions are emitted for non-trivial static locals +// These would normally be emitted by the Mic

[clang] [DXIL] Don't generate per-variable guards for DirectX (PR #106096)

2024-08-27 Thread Greg Roth via cfe-commits
https://github.com/pow2clk updated https://github.com/llvm/llvm-project/pull/106096 >From a7242d7183b9a65c7e205c80f3a2bfe3866fcfb7 Mon Sep 17 00:00:00 2001 From: Greg Roth Date: Fri, 23 Aug 2024 16:00:01 -0600 Subject: [PATCH 1/2] [DXIL] Don't generate per-variable guards for DirectX Thread in

[clang] [llvm] [HLSL] Implement '__builtin_hlsl_is_intangible' type trait (PR #104544)

2024-08-27 Thread Greg Roth via cfe-commits
https://github.com/pow3clk approved this pull request. One more question, but it looks good to me! https://github.com/llvm/llvm-project/pull/104544 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/

[clang] [llvm] [HLSL] Implement '__builtin_hlsl_is_intangible' type trait (PR #104544)

2024-08-27 Thread Greg Roth via cfe-commits
@@ -5695,6 +5696,15 @@ static bool EvaluateUnaryTypeTrait(Sema &Self, TypeTrait UTT, return true; return false; } + case UTT_IsIntangibleType: +assert(Self.getLangOpts().HLSL && "intangible types are HLSL-only feature"); +if (!T->isVoidType() && !T->isI

[clang] [llvm] [HLSL] Implement '__builtin_hlsl_is_intangible' type trait (PR #104544)

2024-08-27 Thread Greg Roth via cfe-commits
https://github.com/pow3clk edited https://github.com/llvm/llvm-project/pull/104544 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [HLSL] Implement '__builtin_hlsl_is_intangible' type trait (PR #104544)

2024-08-27 Thread Greg Roth via cfe-commits
https://github.com/pow2clk approved this pull request. Oops. I approved on my underprivileged laptop account 😳 https://github.com/llvm/llvm-project/pull/104544 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailm

[clang] [HLSL] Apply NoRecurse attrib to all HLSL functions (PR #105907)

2024-08-28 Thread Greg Roth via cfe-commits
@@ -1064,13 +1064,17 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy, // OpenCL C 2.0 v2.2-11 s6.9.i: // Recursion is not supported. // + // HLSL + // Recursion is not supported. + // // SYCL v1.2.1 s3.10: // kernels cannot inclu

[clang] [HLSL] Apply NoRecurse attrib to all HLSL functions (PR #105907)

2024-08-28 Thread Greg Roth via cfe-commits
@@ -0,0 +1,93 @@ +// RUN: %clang_cc1 -x hlsl -triple dxil-pc-shadermodel6.3-library -finclude-default-header %s -emit-llvm -disable-llvm-passes -o - | FileCheck %s +// RUN: %clang_cc1 -x hlsl -triple dxil-pc-shadermodel6.0-compute -finclude-default-header %s -emit-llvm -disabl

[clang] [DXIL] Don't generate per-variable guards for DirectX (PR #106096)

2024-08-28 Thread Greg Roth via cfe-commits
@@ -94,6 +94,13 @@ class LLVM_LIBRARY_VISIBILITY DirectXTargetInfo : public TargetInfo { BuiltinVaListKind getBuiltinVaListKind() const override { return TargetInfo::VoidPtrBuiltinVaList; } + + void adjust(DiagnosticsEngine &Diags, LangOptions &Opts) override { --

[clang] [DXIL] Don't generate per-variable guards for DirectX (PR #106096)

2024-08-28 Thread Greg Roth via cfe-commits
@@ -94,6 +94,13 @@ class LLVM_LIBRARY_VISIBILITY DirectXTargetInfo : public TargetInfo { BuiltinVaListKind getBuiltinVaListKind() const override { return TargetInfo::VoidPtrBuiltinVaList; } + + void adjust(DiagnosticsEngine &Diags, LangOptions &Opts) override { --

[clang] [DXIL] Don't generate per-variable guards for DirectX (PR #106096)

2024-08-28 Thread Greg Roth via cfe-commits
https://github.com/pow2clk closed https://github.com/llvm/llvm-project/pull/106096 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Apply NoRecurse attrib to all HLSL functions (PR #105907)

2024-08-29 Thread Greg Roth via cfe-commits
https://github.com/pow2clk closed https://github.com/llvm/llvm-project/pull/105907 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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

2024-08-29 Thread Greg Roth via cfe-commits
https://github.com/pow2clk created https://github.com/llvm/llvm-project/pull/106588 HLSL inlines all its functions by default. This uses the alwaysinline attribute to force that in the corresponding pass for user functions by default and overrides the default noinline of some implicit function

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

2024-08-29 Thread Greg Roth via cfe-commits
https://github.com/pow2clk updated https://github.com/llvm/llvm-project/pull/106588 >From 12253818bd47aa8c324f6222586965f356b11c90 Mon Sep 17 00:00:00 2001 From: Greg Roth Date: Wed, 24 Jul 2024 16:49:19 -0600 Subject: [PATCH 1/2] [HLSL] set alwaysinline on HLSL functions HLSL inlines all its

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

2024-09-03 Thread Greg Roth via cfe-commits
@@ -414,9 +414,20 @@ void CGHLSLRuntime::emitEntryFunction(const FunctionDecl *FD, void CGHLSLRuntime::setHLSLFunctionAttributes(const FunctionDecl *FD, llvm::Function *Fn) { - if (FD->isInExportDeclContext()) { -const String

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

2024-09-03 Thread Greg Roth via cfe-commits
@@ -290,8 +290,6 @@ struct BuiltinTypeDeclBuilder { SourceLocation())); MethodDecl->setLexicalDeclContext(Record); MethodDecl->setAccess(AccessSpecifier::AS_public); -MethodDecl->addAttr(AlwaysInlineAttr::CreateImplicit(

[clang] [llvm] [HLSL][DXIL][SPIRV] Create llvm dot intrinsic and use for HLSL (PR #102872)

2024-08-16 Thread Greg Roth via cfe-commits
https://github.com/pow2clk closed https://github.com/llvm/llvm-project/pull/102872 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [HLSL][DXIL][SPIRV] Create llvm dot intrinsic and use for HLSL (PR #102872)

2024-08-16 Thread Greg Roth via cfe-commits
pow2clk wrote: Closing in light of the above. A new PR will capture the DXIL and SPIRV-specific work https://github.com/llvm/llvm-project/pull/102872 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listin

[clang] [llvm] Add SPIRV generation for HLSL dot (PR #104656)

2024-08-16 Thread Greg Roth via cfe-commits
https://github.com/pow2clk created https://github.com/llvm/llvm-project/pull/104656 This adds the SPIRV fdot, sdot, and udot intrinsics and allows them to be created at codegen depending on the target architecture. This required moving some of the DXIL-specific choices to DXIL instruction expa

[clang] [llvm] [HLSL][SPIRV]Add SPIRV generation for HLSL dot (PR #104656)

2024-08-16 Thread Greg Roth via cfe-commits
https://github.com/pow2clk edited https://github.com/llvm/llvm-project/pull/104656 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [HLSL][DXIL][SPIRV] Create llvm dot intrinsic and use for HLSL (PR #102872)

2024-08-16 Thread Greg Roth via cfe-commits
pow2clk wrote: Here's the new PR for anyone who wants to keep following along in its altered state: #104656 https://github.com/llvm/llvm-project/pull/102872 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman

[clang] [llvm] [HLSL][SPIRV]Add SPIRV generation for HLSL dot (PR #104656)

2024-08-16 Thread Greg Roth via cfe-commits
https://github.com/pow2clk updated https://github.com/llvm/llvm-project/pull/104656 >From 9aff63478b76f042c05b7ae3dd1a2c099dc615de Mon Sep 17 00:00:00 2001 From: Greg Roth Date: Fri, 2 Aug 2024 20:10:04 -0600 Subject: [PATCH 1/2] Add SPIRV generation for HLSL dot This adds the SPIRV fdot, sdot

[clang] [llvm] [HLSL][SPIRV]Add SPIRV generation for HLSL dot (PR #104656)

2024-08-19 Thread Greg Roth via cfe-commits
@@ -2157,6 +2221,16 @@ bool SPIRVInstructionSelector::selectIntrinsic(Register ResVReg, break; case Intrinsic::spv_thread_id: return selectSpvThreadId(ResVReg, ResType, I); + case Intrinsic::spv_fdot: +return BuildMI(BB, I, I.getDebugLoc(), TII.get(SPIRV::OpDot)

[clang] [llvm] [HLSL][SPIRV]Add SPIRV generation for HLSL dot (PR #104656)

2024-08-19 Thread Greg Roth via cfe-commits
@@ -68,28 +69,65 @@ static Value *expandAbs(CallInst *Orig) { "dx.max"); } -static Value *expandIntegerDot(CallInst *Orig, Intrinsic::ID DotIntrinsic) { +// Create DXIL dot intrinsics for floating point dot operations +static Value *expandFloat

[clang] [llvm] [HLSL][SPIRV]Add SPIRV generation for HLSL dot (PR #104656)

2024-08-19 Thread Greg Roth via cfe-commits
https://github.com/pow2clk updated https://github.com/llvm/llvm-project/pull/104656 >From 9aff63478b76f042c05b7ae3dd1a2c099dc615de Mon Sep 17 00:00:00 2001 From: Greg Roth Date: Fri, 2 Aug 2024 20:10:04 -0600 Subject: [PATCH 1/4] Add SPIRV generation for HLSL dot This adds the SPIRV fdot, sdot

[clang] [llvm] [HLSL][SPIRV]Add SPIRV generation for HLSL dot (PR #104656)

2024-08-19 Thread Greg Roth via cfe-commits
pow2clk wrote: > could you fixup normalize to use the fdot expansion? > > https://github.com/llvm/llvm-project/blob/9cf27a4d8b1da0e7b51eacb9fb6096155c294d3f/llvm/lib/Target/DirectX/DXILIntrinsicExpansion.cpp#L278-L289 It makes the signature a bit unusual, but it works! https://github.com/llvm/

[clang] [llvm] [HLSL][SPIRV]Add SPIRV generation for HLSL dot (PR #104656)

2024-08-19 Thread Greg Roth via cfe-commits
@@ -2157,6 +2221,16 @@ bool SPIRVInstructionSelector::selectIntrinsic(Register ResVReg, break; case Intrinsic::spv_thread_id: return selectSpvThreadId(ResVReg, ResType, I); + case Intrinsic::spv_fdot: +return BuildMI(BB, I, I.getDebugLoc(), TII.get(SPIRV::OpDot)

[clang] [llvm] [HLSL][SPIRV]Add SPIRV generation for HLSL dot (PR #104656)

2024-08-19 Thread Greg Roth via cfe-commits
@@ -1446,6 +1449,67 @@ bool SPIRVInstructionSelector::selectRsqrt(Register ResVReg, .constrainAllUses(TII, TRI, RBI); } +// Since there is no integer dot implementation, expand by piecewise multiplying pow2clk wrote: Done https://github.com/llvm/llvm

[clang] [llvm] [HLSL][SPIRV]Add SPIRV generation for HLSL dot (PR #104656)

2024-08-19 Thread Greg Roth via cfe-commits
@@ -68,28 +69,65 @@ static Value *expandAbs(CallInst *Orig) { "dx.max"); } -static Value *expandIntegerDot(CallInst *Orig, Intrinsic::ID DotIntrinsic) { +// Create DXIL dot intrinsics for floating point dot operations +static Value *expandFloat

[clang] [llvm] [HLSL][SPIRV]Add SPIRV generation for HLSL dot (PR #104656)

2024-08-19 Thread Greg Roth via cfe-commits
@@ -7,155 +7,155 @@ // RUN: -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF #ifdef __HLSL_ENABLE_16_BIT -// NATIVE_HALF: %dx.dot = mul i16 %0, %1 -// NATIVE_HALF: ret i16 %dx.dot +// NATIVE_HALF: %hlsl.dot = mul i16 %0, %1 +// NATIVE_HALF: ret i16 %hlsl.dot int16_t test_

[clang] [llvm] [HLSL][SPIRV]Add SPIRV generation for HLSL dot (PR #104656)

2024-08-19 Thread Greg Roth via cfe-commits
@@ -1,161 +1,172 @@ // 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: --check-pr

[clang] [llvm] [HLSL][SPIRV]Add SPIRV generation for HLSL dot (PR #104656)

2024-08-19 Thread Greg Roth via cfe-commits
@@ -1,161 +1,172 @@ // 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: --check-pr

[clang] [llvm] [HLSL][SPIRV]Add SPIRV generation for HLSL dot (PR #104656)

2024-08-19 Thread Greg Roth via cfe-commits
https://github.com/pow2clk updated https://github.com/llvm/llvm-project/pull/104656 >From 9aff63478b76f042c05b7ae3dd1a2c099dc615de Mon Sep 17 00:00:00 2001 From: Greg Roth Date: Fri, 2 Aug 2024 20:10:04 -0600 Subject: [PATCH 1/5] Add SPIRV generation for HLSL dot This adds the SPIRV fdot, sdot

[clang] [llvm] [HLSL][SPIRV]Add SPIRV generation for HLSL dot (PR #104656)

2024-08-19 Thread Greg Roth via cfe-commits
https://github.com/pow2clk updated https://github.com/llvm/llvm-project/pull/104656 >From 9aff63478b76f042c05b7ae3dd1a2c099dc615de Mon Sep 17 00:00:00 2001 From: Greg Roth Date: Fri, 2 Aug 2024 20:10:04 -0600 Subject: [PATCH 1/6] Add SPIRV generation for HLSL dot This adds the SPIRV fdot, sdot

  1   2   3   >