[libclc] [libclc] Create an internal 'clc' builtins library (PR #109985)

2024-10-29 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck updated https://github.com/llvm/llvm-project/pull/109985 >From ba6a7682bfedb4249f26ed5e2af98499d884538d Mon Sep 17 00:00:00 2001 From: Fraser Cormack Date: Mon, 23 Sep 2024 12:54:02 +0100 Subject: [PATCH 1/2] [libclc] Split off library build system into helpers T

[libclc] 183b38e - [libclc] Split off library build system into helpers

2024-10-29 Thread Fraser Cormack via cfe-commits
Author: Fraser Cormack Date: 2024-10-29T13:09:56Z New Revision: 183b38eb2261164fdfd6b7deac002edf27a39fe7 URL: https://github.com/llvm/llvm-project/commit/183b38eb2261164fdfd6b7deac002edf27a39fe7 DIFF: https://github.com/llvm/llvm-project/commit/183b38eb2261164fdfd6b7deac002edf27a39fe7.diff LOG

[libclc] b2bdd8b - [libclc] Create an internal 'clc' builtins library

2024-10-29 Thread Fraser Cormack via cfe-commits
Author: Fraser Cormack Date: 2024-10-29T13:09:56Z New Revision: b2bdd8bd39e90bfe3c66f6d5600468570a77ede6 URL: https://github.com/llvm/llvm-project/commit/b2bdd8bd39e90bfe3c66f6d5600468570a77ede6 DIFF: https://github.com/llvm/llvm-project/commit/b2bdd8bd39e90bfe3c66f6d5600468570a77ede6.diff LOG

[libclc] [libclc] Create an internal 'clc' builtins library (PR #109985)

2024-10-29 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck closed https://github.com/llvm/llvm-project/pull/109985 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[libclc] [libclc] Create an internal 'clc' builtins library (PR #109985)

2024-10-29 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck updated https://github.com/llvm/llvm-project/pull/109985 >From 183b38eb2261164fdfd6b7deac002edf27a39fe7 Mon Sep 17 00:00:00 2001 From: Fraser Cormack Date: Mon, 23 Sep 2024 12:54:02 +0100 Subject: [PATCH 1/2] [libclc] Split off library build system into helpers T

[libclc] [libclc] Create an internal 'clc' builtins library (PR #109985)

2024-10-22 Thread Fraser Cormack via cfe-commits
frasercrmck wrote: ping https://github.com/llvm/llvm-project/pull/109985 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[libclc] f1888e4 - [libclc] Add some include guards and format a file

2024-11-04 Thread Fraser Cormack via cfe-commits
Author: Fraser Cormack Date: 2024-11-04T10:37:11Z New Revision: f1888e4029ec2bf657a072518dcc1c9b461559be URL: https://github.com/llvm/llvm-project/commit/f1888e4029ec2bf657a072518dcc1c9b461559be DIFF: https://github.com/llvm/llvm-project/commit/f1888e4029ec2bf657a072518dcc1c9b461559be.diff LOG

[libclc] [libclc] Move ceil/fabs/floor/rint/trunc to CLC library (PR #114774)

2024-11-04 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck created https://github.com/llvm/llvm-project/pull/114774 These functions are all mapped to LLVM intrinsics. The clspv and spirv targets don't declare or define any of these CLC functions, and instead map these to their corresponding OpenCL symbols. >From 8dd4fb4

[libclc] b4ef43f - [libclc] Format clc_fma.cl. NFC

2024-11-04 Thread Fraser Cormack via cfe-commits
Author: Fraser Cormack Date: 2024-11-04T11:55:42Z New Revision: b4ef43fc75dfeea76d4d968553858b2820420e58 URL: https://github.com/llvm/llvm-project/commit/b4ef43fc75dfeea76d4d968553858b2820420e58 DIFF: https://github.com/llvm/llvm-project/commit/b4ef43fc75dfeea76d4d968553858b2820420e58.diff LOG

[libclc] [libclc] Move clcmacro.h to CLC library. NFC (PR #114845)

2024-11-04 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck created https://github.com/llvm/llvm-project/pull/114845 None >From e2ac0ddbd762774282e878e043bac0edbbe75407 Mon Sep 17 00:00:00 2001 From: Fraser Cormack Date: Mon, 4 Nov 2024 14:35:59 + Subject: [PATCH] [libclc] Move clcmacro.h to CLC library. NFC --- lib

[libclc] [libclc] Move clcmacro.h to CLC library. NFC (PR #114845)

2024-11-04 Thread Fraser Cormack via cfe-commits
frasercrmck wrote: Sorry for the noise, but this felt too big to just push. It should hopefully minimize diffs in upcoming patches. https://github.com/llvm/llvm-project/pull/114845 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.

[libclc] e28d7f7 - [libclc] Format clc_tan.cl. NFC

2024-11-04 Thread Fraser Cormack via cfe-commits
Author: Fraser Cormack Date: 2024-11-04T10:52:46Z New Revision: e28d7f713471cf33908a0fe5223f480dfd9b06f0 URL: https://github.com/llvm/llvm-project/commit/e28d7f713471cf33908a0fe5223f480dfd9b06f0 DIFF: https://github.com/llvm/llvm-project/commit/e28d7f713471cf33908a0fe5223f480dfd9b06f0.diff LOG

[libclc] [libclc] Move ceil/fabs/floor/rint/trunc to CLC library (PR #114774)

2024-11-04 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck updated https://github.com/llvm/llvm-project/pull/114774 >From 625b491279f81dc9b55e80bf422d0e15f44f02bb Mon Sep 17 00:00:00 2001 From: Fraser Cormack Date: Thu, 31 Oct 2024 13:11:00 + Subject: [PATCH] [libclc] Move ceil/fabs/floor/rint/trunc to CLC library Th

[libclc] [libclc] Move ceil/fabs/floor/rint/trunc to CLC library (PR #114774)

2024-11-04 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck closed https://github.com/llvm/llvm-project/pull/114774 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[libclc] [libclc] Move min/max/clamp into the CLC builtins library (PR #114386)

2024-10-31 Thread Fraser Cormack via cfe-commits
frasercrmck wrote: CC @rjodinchr, I hope this method of dealing with clspv works for you. https://github.com/llvm/llvm-project/pull/114386 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commi

[libclc] [libclc] Move min/max/clamp into the CLC builtins library (PR #114386)

2024-10-31 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck updated https://github.com/llvm/llvm-project/pull/114386 >From 045a64caab8d99c29e6b0abbdcdc19f84a55b820 Mon Sep 17 00:00:00 2001 From: Fraser Cormack Date: Thu, 26 Sep 2024 08:57:15 +0100 Subject: [PATCH] [libclc] Move min/max/clamp into the CLC builtins library

[libclc] [libclc] Move min/max/clamp into the CLC builtins library (PR #114386)

2024-10-31 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck created https://github.com/llvm/llvm-project/pull/114386 These functions are "shared" between integer and floating-point types, hence the directory name. They are used in several CLC internal functions such as __clc_ldexp. Note that clspv and spirv targets don't

[libclc] [libclc] Move min/max/clamp into the CLC builtins library (PR #114386)

2024-10-31 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck updated https://github.com/llvm/llvm-project/pull/114386 >From c0e8cf9ec8a3ce75b62afdcbb6383af16c2f3539 Mon Sep 17 00:00:00 2001 From: Fraser Cormack Date: Thu, 26 Sep 2024 08:57:15 +0100 Subject: [PATCH] [libclc] Move min/max/clamp into the CLC builtins library

[libclc] fba9f05 - [libclc] Format clc_ldexp.cl and clc_hypot.cl. NFC

2024-10-31 Thread Fraser Cormack via cfe-commits
Author: Fraser Cormack Date: 2024-10-31T10:18:29Z New Revision: fba9f05ff7b36f9cbb5835d79f659290dadecaad URL: https://github.com/llvm/llvm-project/commit/fba9f05ff7b36f9cbb5835d79f659290dadecaad DIFF: https://github.com/llvm/llvm-project/commit/fba9f05ff7b36f9cbb5835d79f659290dadecaad.diff LOG

[libclc] [libclc] Move min/max/clamp into the CLC builtins library (PR #114386)

2024-10-31 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck updated https://github.com/llvm/llvm-project/pull/114386 >From 0465b89a7b624b8015e27efdbaf948c4aadd0e94 Mon Sep 17 00:00:00 2001 From: Fraser Cormack Date: Thu, 26 Sep 2024 08:57:15 +0100 Subject: [PATCH] [libclc] Move min/max/clamp into the CLC builtins library

[libclc] [libclc] Move sign to the CLC builtins library (PR #115699)

2024-11-11 Thread Fraser Cormack via cfe-commits
frasercrmck wrote: > So is the sign function currently implemented in the OpenCL headers? The sign function for SPIR-V/Mesa is currently implemented by libclc [here](https://github.com/llvm/llvm-project/blob/main/libclc/generic/lib/common/sign.cl). With this change, `sign` now calls `__clc_sig

[libclc] [libclc] Move sign to the CLC builtins library (PR #115699)

2024-11-11 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck edited https://github.com/llvm/llvm-project/pull/115699 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[libclc] [libclc] Move sign to the CLC builtins library (PR #115699)

2024-11-11 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck created https://github.com/llvm/llvm-project/pull/115699 This patch necessitates some changes to how CLSPV and SPIR-V targets are built. This is the first patch in this series in which an OpenCL function declaration has been called from the CLC library for these

[libclc] [libclc] Move sign to the CLC builtins library (PR #115699)

2024-11-11 Thread Fraser Cormack via cfe-commits
frasercrmck wrote: CC @tstellar @fooishbar who might be able to account for the Mesa/SPIR-V target? https://github.com/llvm/llvm-project/pull/115699 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo

[libclc] [libclc] Move sign to the CLC builtins library (PR #115699)

2024-11-11 Thread Fraser Cormack via cfe-commits
frasercrmck wrote: > > So is the sign function currently implemented in the OpenCL headers? > > The sign function for SPIR-V/Mesa is currently implemented by libclc > [here](https://github.com/llvm/llvm-project/blob/main/libclc/generic/lib/common/sign.cl). > With this change, `sign` now calls

[libclc] [libclc] Create aliases with custom_command (PR #115885)

2024-11-13 Thread Fraser Cormack via cfe-commits
@@ -355,11 +355,13 @@ function(add_libclc_builtin_set) install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${obj_suffix} DESTINATION "${CMAKE_INSTALL_DATADIR}/clc" ) foreach( a ${ARG_ALIASES} ) set( alias_suffix "${a}-${ARG_TRIPLE}.bc" ) -add_custom_target( ${alias_suffix}

[libclc] Reland "[libclc] Create aliases with custom_command (#115885)" (PR #116025)

2024-11-13 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck closed https://github.com/llvm/llvm-project/pull/116025 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[libclc] [libclc] Create aliases with custom_command (PR #115885)

2024-11-13 Thread Fraser Cormack via cfe-commits
frasercrmck wrote: Relanded in #116025. https://github.com/llvm/llvm-project/pull/115885 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[libclc] [libclc] Move sign to the CLC builtins library (PR #115699)

2024-11-12 Thread Fraser Cormack via cfe-commits
@@ -0,0 +1,38 @@ +#include +#include +#include + +#define CLC_SIGN(TYPE, F) \ + _CLC_DEF _CLC_OVERLOAD TYPE __clc_sign(TYPE x) { \ +if (__clc_isnan(x)) {

[libclc] Reland "[libclc] Create aliases with custom_command (#115885)" (PR #116025)

2024-11-13 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck created https://github.com/llvm/llvm-project/pull/116025 This relands commit 2c980310f67c13dd89c8702d40abeab47a4a2b4b after fixing an issue. >From beb58052420070d392f97bfba6af6af818df9a16 Mon Sep 17 00:00:00 2001 From: Fraser Cormack Date: Wed, 13 Nov 2024 10:38

[libclc] [libclc] Move min/max/clamp into the CLC builtins library (PR #114386)

2024-10-31 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck reopened https://github.com/llvm/llvm-project/pull/114386 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[libclc] [libclc] Move min/max/clamp into the CLC builtins library (PR #114386)

2024-10-31 Thread Fraser Cormack via cfe-commits
frasercrmck wrote: > Moving them seems fine but these should probably just be deleted. __clc_min > is equivalent to __builtin_elementwise_min etc. > > I see there's a __builtin_hlsl_elementwise_clamp, but given the language > prefix it may be more abusive https://github.com/llvm/llvm-projec

[libclc] [libclc] Move min/max/clamp into the CLC builtins library (PR #114386)

2024-10-31 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck closed https://github.com/llvm/llvm-project/pull/114386 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[libclc] [libclc] Move min/max/clamp into the CLC builtins library (PR #114386)

2024-10-31 Thread Fraser Cormack via cfe-commits
@@ -0,0 +1,11 @@ +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_max(__CLC_GENTYPE a, + __CLC_GENTYPE b) { + return (a > b ? a : b); +} + +#ifndef __CLC_SCALAR +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_max(__CLC_GENTYPE a, +

[libclc] [libclc] Move sign to the CLC builtins library (PR #115699)

2024-11-12 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck updated https://github.com/llvm/llvm-project/pull/115699 >From 47512ee4162318160964f1af132be90bed67c90c Mon Sep 17 00:00:00 2001 From: Fraser Cormack Date: Thu, 7 Nov 2024 12:40:56 + Subject: [PATCH 1/2] [libclc] Move sign to the CLC builtins library This pat

[libclc] [libclc] Move sign to the CLC builtins library (PR #115699)

2024-11-12 Thread Fraser Cormack via cfe-commits
@@ -0,0 +1,38 @@ +#include +#include +#include + +#define CLC_SIGN(TYPE, F) \ + _CLC_DEF _CLC_OVERLOAD TYPE __clc_sign(TYPE x) { \ +if (__clc_isnan(x)) {

[libclc] [libclc] Use builtin_convertvector to convert between vector types (PR #115865)

2024-11-12 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck created https://github.com/llvm/llvm-project/pull/115865 This keeps values in vectors, rather than scalarizing them and then reconstituting the vector. The builtin is identical to performing a C-style cast on each element, which is what we were doing by recursive

[libclc] [libclc] Move sign to the CLC builtins library (PR #115699)

2024-11-12 Thread Fraser Cormack via cfe-commits
@@ -322,22 +322,26 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} ) if ( ARCH STREQUAL spirv OR ARCH STREQUAL spirv64 ) set( build_flags -O0 -finline-hint-functions -DCLC_SPIRV ) - set( opt_flags ) + set( clc_opt_flags ) + # Inline CLC functions into OpenCL

[libclc] [libclc] Avoid using undefined vector3 components (PR #115857)

2024-11-12 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck created https://github.com/llvm/llvm-project/pull/115857 Using '.hi' on a vector3 is technically allowed by the spec and is treated as a 4-element vector with an "undefined" w component. However, it's more undef/poison code for the compiler to process and remove.

[libclc] [libclc] Use builtin_convertvector to convert between vector types (PR #115865)

2024-11-12 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck closed https://github.com/llvm/llvm-project/pull/115865 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[libclc] [libclc] Fix installation w/ ENABLE_RUNTIME_SUBNORMAL (PR #109926)

2024-09-26 Thread Fraser Cormack via cfe-commits
@@ -221,8 +221,10 @@ if( ENABLE_RUNTIME_SUBNORMAL ) TARGET ${file} INPUTS ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/${file}.ll ) -install( FILES $ ARCHIVE - DESTINATION "${CMAKE_INSTALL_DATADIR}/clc" ) +install( + FILES ${CMAKE_CURRENT_BINARY_D

[libclc] [libclc] Fix installation w/ ENABLE_RUNTIME_SUBNORMAL (PR #109926)

2024-09-26 Thread Fraser Cormack via cfe-commits
@@ -221,8 +221,10 @@ if( ENABLE_RUNTIME_SUBNORMAL ) TARGET ${file} INPUTS ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/${file}.ll ) -install( FILES $ ARCHIVE - DESTINATION "${CMAKE_INSTALL_DATADIR}/clc" ) +install( + FILES ${CMAKE_CURRENT_BINARY_D

[libclc] [libclc] Fix installation w/ ENABLE_RUNTIME_SUBNORMAL (PR #109926)

2024-09-26 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck edited https://github.com/llvm/llvm-project/pull/109926 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[libclc] [libclc] Fix installation w/ ENABLE_RUNTIME_SUBNORMAL (PR #109926)

2024-09-26 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck edited https://github.com/llvm/llvm-project/pull/109926 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[libclc] [libclc] Fix installation w/ ENABLE_RUNTIME_SUBNORMAL (PR #109926)

2024-09-26 Thread Fraser Cormack via cfe-commits
@@ -221,8 +221,10 @@ if( ENABLE_RUNTIME_SUBNORMAL ) TARGET ${file} INPUTS ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/${file}.ll ) -install( FILES $ ARCHIVE - DESTINATION "${CMAKE_INSTALL_DATADIR}/clc" ) +install( + FILES ${CMAKE_CURRENT_BINARY_D

[libclc] [libclc] Fix installation w/ ENABLE_RUNTIME_SUBNORMAL (PR #109926)

2024-09-26 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck updated https://github.com/llvm/llvm-project/pull/109926 >From 567ea02fda22989a5af89746dbc5ed6eac0a43d9 Mon Sep 17 00:00:00 2001 From: Fraser Cormack Date: Wed, 25 Sep 2024 09:18:10 +0100 Subject: [PATCH] [libclc] Fix installation w/ ENABLE_RUNTIME_SUBNORMAL The

[libclc] [libclc] use default paths with find_program when possible (PR #105969)

2024-09-24 Thread Fraser Cormack via cfe-commits
frasercrmck wrote: > > Nixpkgs has no intention of moving away from standalone builds. > > I encourage you to acquire that intention. IMO libclc should not support the > standalone build, and this should be version locked to the exact compiler > commit. It's compiler data, not a real library

[libclc] [libclc] Create an internal 'clc' builtins library (PR #109985)

2024-09-26 Thread Fraser Cormack via cfe-commits
frasercrmck wrote: CC @rjodinchr. I realise now that this idea may prove problematic for `clspv`/`clspv64` targets. If this idea were to taken further, things like OpenCL `minmag` would call `__clc_minmag` which would call `__clc_fabs` (e.g.), but I notice `fabs` is not implemented in `clspv*`

[libclc] [llvm] [libclc] Refactor build system to allow in-tree builds (PR #87622)

2024-09-25 Thread Fraser Cormack via cfe-commits
@@ -167,12 +181,14 @@ install( FILES ${CMAKE_CURRENT_BINARY_DIR}/libclc.pc DESTINATION "${CMAKE_INSTAL install( DIRECTORY generic/include/clc DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" ) if( ENABLE_RUNTIME_SUBNORMAL ) - add_library( subnormal_use_default STATIC -generic/

[libclc] [libclc] Fix installation w/ ENABLE_RUNTIME_SUBNORMAL (PR #109926)

2024-09-25 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck created https://github.com/llvm/llvm-project/pull/109926 The ARCHIVE artifact kind is not valid for install(FILES ...). Additionally, install wasn't resolving the target's TARGET_FILE properly and was trying to find it in the top-level build directory, rather tha

[libclc] [libclc] Fix installation w/ ENABLE_RUNTIME_SUBNORMAL (PR #109926)

2024-09-25 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck edited https://github.com/llvm/llvm-project/pull/109926 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[libclc] [libclc] Fix installation w/ ENABLE_RUNTIME_SUBNORMAL (PR #109926)

2024-09-25 Thread Fraser Cormack via cfe-commits
frasercrmck wrote: Thanks to @aaronpuchert for pointing this out in #87622. https://github.com/llvm/llvm-project/pull/109926 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[libclc] [llvm] [libclc] Refactor build system to allow in-tree builds (PR #87622)

2024-09-25 Thread Fraser Cormack via cfe-commits
@@ -167,12 +181,14 @@ install( FILES ${CMAKE_CURRENT_BINARY_DIR}/libclc.pc DESTINATION "${CMAKE_INSTAL install( DIRECTORY generic/include/clc DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" ) if( ENABLE_RUNTIME_SUBNORMAL ) - add_library( subnormal_use_default STATIC -generic/

[libclc] [libclc] Create an internal 'clc' builtins library (PR #109985)

2024-09-25 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck created https://github.com/llvm/llvm-project/pull/109985 Some libclc builtins currently use internal builtins prefixed with '__clc_' for various reasons, e.g., to avoid naming clashes. This commit formalizes this concept by starting to isolate the definitions of t

[libclc] [libclc] Create an internal 'clc' builtins library (PR #109985)

2024-09-25 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck updated https://github.com/llvm/llvm-project/pull/109985 >From b01eadcda29e2df283c978901ea9616ebebd44aa Mon Sep 17 00:00:00 2001 From: Fraser Cormack Date: Mon, 23 Sep 2024 12:54:02 +0100 Subject: [PATCH 1/2] [libclc] Split off library build system into helpers T

[libclc] [libclc] Move relational functions to the CLC library (PR #115171)

2024-11-06 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck closed https://github.com/llvm/llvm-project/pull/115171 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[libclc] 6ca50a2 - [libclc] Correct use of CLC macro on two definitions

2024-11-07 Thread Fraser Cormack via cfe-commits
Author: Fraser Cormack Date: 2024-11-07T17:47:52Z New Revision: 6ca50a2593641f45b5310d907e6323f5eb367dfa URL: https://github.com/llvm/llvm-project/commit/6ca50a2593641f45b5310d907e6323f5eb367dfa DIFF: https://github.com/llvm/llvm-project/commit/6ca50a2593641f45b5310d907e6323f5eb367dfa.diff LOG

[libclc] [libclc] Move sign to the CLC builtins library (PR #115699)

2024-11-25 Thread Fraser Cormack via cfe-commits
@@ -0,0 +1,38 @@ +#include +#include +#include + +#define CLC_SIGN(TYPE, F) \ + _CLC_DEF _CLC_OVERLOAD TYPE __clc_sign(TYPE x) { \ +if (__clc_isnan(x)) {

[libclc] [libclc] Move several integer functions to CLC library (PR #116786)

2024-11-19 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck created https://github.com/llvm/llvm-project/pull/116786 This commit moves over the OpenCL clz, hadd, mad24, mad_hi, mul24, mul_hi, popcount, rhadd, and upsample builtins to the CLC library. There are no changes to any target's CLC libraries. The OpenCL mad_hi b

[libclc] [libclc] Move sign to the CLC builtins library (PR #115699)

2024-11-20 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck updated https://github.com/llvm/llvm-project/pull/115699 >From 0a9bcdc5fb9da8ada6d2580026f498f282ca7cf7 Mon Sep 17 00:00:00 2001 From: Fraser Cormack Date: Thu, 7 Nov 2024 12:40:56 + Subject: [PATCH] [libclc] Move sign to the CLC builtins library This patch n

[libclc] [libclc] Move sign to the CLC builtins library (PR #115699)

2024-11-20 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck edited https://github.com/llvm/llvm-project/pull/115699 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[libclc] [libclc] Move sign to the CLC builtins library (PR #115699)

2024-11-20 Thread Fraser Cormack via cfe-commits
@@ -322,22 +322,26 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} ) if ( ARCH STREQUAL spirv OR ARCH STREQUAL spirv64 ) set( build_flags -O0 -finline-hint-functions -DCLC_SPIRV ) - set( opt_flags ) + set( clc_opt_flags ) + # Inline CLC functions into OpenCL

[libclc] [libclc] Move sign to the CLC builtins library (PR #115699)

2024-11-20 Thread Fraser Cormack via cfe-commits
@@ -322,22 +322,26 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} ) if ( ARCH STREQUAL spirv OR ARCH STREQUAL spirv64 ) set( build_flags -O0 -finline-hint-functions -DCLC_SPIRV ) - set( opt_flags ) + set( clc_opt_flags ) + # Inline CLC functions into OpenCL

[libclc] [libclc] Move several integer functions to CLC library (PR #116786)

2024-11-19 Thread Fraser Cormack via cfe-commits
@@ -0,0 +1,44 @@ +#include +#include +#include + +_CLC_OVERLOAD _CLC_DEF char __clc_clz(char x) { + return __clc_clz((ushort)(uchar)x) - 8; +} + +_CLC_OVERLOAD _CLC_DEF uchar __clc_clz(uchar x) { + return __clc_clz((ushort)x) - 8; +} + +_CLC_OVERLOAD _CLC_DEF short __clc_clz(

[libclc] [libclc] Move several integer functions to CLC library (PR #116786)

2024-11-19 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck edited https://github.com/llvm/llvm-project/pull/116786 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[libclc] [libclc] Move several integer functions to CLC library (PR #116786)

2024-11-25 Thread Fraser Cormack via cfe-commits
@@ -0,0 +1,21 @@ +#ifndef __CLC_INTEGER_CLC_CLZ_H__ +#define __CLC_INTEGER_CLC_CLZ_H__ + +#if defined(CLC_CLSPV) || defined(CLC_SPIRV) +// clspv and spir-v targets provide their own OpenCL-compatible clz +#define __clc_clz clz frasercrmck wrote: Oh right, I thoug

[libclc] [libcxx] [llvm] [openmp] [polly] [llvm] Move sub-project lead maintainers into their own Maintainers.md files (PR #118309)

2024-12-03 Thread Fraser Cormack via cfe-commits
frasercrmck wrote: > For libclc maybe @tstellar -> @frasercrmck (or maybe both). I'm not opposed to this if people think it suitable. But having someone from Red Hat or AMD as co-maintainer(s) makes sense to me, as it's a project used (downstream) by several different groups. https://github.

[libclc] [libclc] Move several integer functions to CLC library (PR #116786)

2024-12-05 Thread Fraser Cormack via cfe-commits
@@ -0,0 +1,21 @@ +#ifndef __CLC_INTEGER_CLC_CLZ_H__ +#define __CLC_INTEGER_CLC_CLZ_H__ + +#if defined(CLC_CLSPV) || defined(CLC_SPIRV) +// clspv and spir-v targets provide their own OpenCL-compatible clz +#define __clc_clz clz frasercrmck wrote: > > I'm not sure

[libclc] [libclc] Move several integer functions to CLC library (PR #116786)

2024-12-05 Thread Fraser Cormack via cfe-commits
@@ -0,0 +1,21 @@ +#ifndef __CLC_INTEGER_CLC_CLZ_H__ +#define __CLC_INTEGER_CLC_CLZ_H__ + +#if defined(CLC_CLSPV) || defined(CLC_SPIRV) +// clspv and spir-v targets provide their own OpenCL-compatible clz +#define __clc_clz clz frasercrmck wrote: > On the `clspv`

[libclc] [libclc] Move several integer functions to CLC library (PR #116786)

2024-12-04 Thread Fraser Cormack via cfe-commits
@@ -0,0 +1,44 @@ +#include +#include +#include + +_CLC_OVERLOAD _CLC_DEF char __clc_clz(char x) { + return __clc_clz((ushort)(uchar)x) - 8; +} + +_CLC_OVERLOAD _CLC_DEF uchar __clc_clz(uchar x) { + return __clc_clz((ushort)x) - 8; +} + +_CLC_OVERLOAD _CLC_DEF short __clc_clz(

[libclc] [libclc] Add missing includes to CLC headers (PR #118654)

2024-12-04 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck created https://github.com/llvm/llvm-project/pull/118654 There's no automatic way of checking these headers are self-contained. Instead of including these common files many times across the whole codebase, we can include them in the generic `gentype.inc` and `flo

[libclc] [libclc] Move several integer functions to CLC library (PR #116786)

2024-12-04 Thread Fraser Cormack via cfe-commits
@@ -0,0 +1,21 @@ +#ifndef __CLC_INTEGER_CLC_CLZ_H__ +#define __CLC_INTEGER_CLC_CLZ_H__ + +#if defined(CLC_CLSPV) || defined(CLC_SPIRV) +// clspv and spir-v targets provide their own OpenCL-compatible clz +#define __clc_clz clz frasercrmck wrote: > > The clspv/spi

[libclc] [libclc] Move several integer functions to CLC library (PR #116786)

2024-12-04 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck edited https://github.com/llvm/llvm-project/pull/116786 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[libclc] [libclc] Move several integer functions to CLC library (PR #116786)

2024-12-09 Thread Fraser Cormack via cfe-commits
@@ -0,0 +1,21 @@ +#ifndef __CLC_INTEGER_CLC_CLZ_H__ +#define __CLC_INTEGER_CLC_CLZ_H__ + +#if defined(CLC_CLSPV) || defined(CLC_SPIRV) +// clspv and spir-v targets provide their own OpenCL-compatible clz +#define __clc_clz clz frasercrmck wrote: > > In this conte

[clang] [clang] Restrict use of scalar types in vector builtins (PR #119423)

2025-01-06 Thread Fraser Cormack via cfe-commits
@@ -14585,11 +14585,18 @@ void Sema::CheckAddressOfPackedMember(Expr *rhs) { _2, _3, _4)); } +static ExprResult UsualUnaryConversionsNoPromoteInt(Sema &S, Expr *E) { + // Don't promote integer types + if (QualType Ty = E->getType(); S.getASTContext().is

[clang] [clang] Restrict use of scalar types in vector builtins (PR #119423)

2025-01-06 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck updated https://github.com/llvm/llvm-project/pull/119423 >From 3f007d702922db63e128e3c0f72dff2f600e0879 Mon Sep 17 00:00:00 2001 From: Fraser Cormack Date: Tue, 10 Dec 2024 17:41:07 + Subject: [PATCH 1/5] [clang] Fix sub-integer __builtin_elementwise_(add|sub

[clang] [clang] Restrict use of scalar types in vector builtins (PR #119423)

2025-01-06 Thread Fraser Cormack via cfe-commits
frasercrmck wrote: > Would be good to also update the documentation for the builtins the clarify > the behavior. I've added some words to that effect. Is that what you had in mind? https://github.com/llvm/llvm-project/pull/119423 ___ cfe-commits mail

[clang] [clang] Restrict use of scalar types in vector builtins (PR #119423)

2025-01-06 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck updated https://github.com/llvm/llvm-project/pull/119423 >From 3f007d702922db63e128e3c0f72dff2f600e0879 Mon Sep 17 00:00:00 2001 From: Fraser Cormack Date: Tue, 10 Dec 2024 17:41:07 + Subject: [PATCH 1/4] [clang] Fix sub-integer __builtin_elementwise_(add|sub

[clang] [clang] Restrict use of scalar types in vector builtins (PR #119423)

2025-01-06 Thread Fraser Cormack via cfe-commits
@@ -14585,11 +14585,18 @@ void Sema::CheckAddressOfPackedMember(Expr *rhs) { _2, _3, _4)); } +static ExprResult UsualUnaryConversionsNoPromoteInt(Sema &S, Expr *E) { + // Don't promote integer types + if (QualType Ty = E->getType(); S.getASTContext().is

[clang] [clang] Restrict use of scalar types in vector builtins (PR #119423)

2025-01-06 Thread Fraser Cormack via cfe-commits
@@ -68,15 +66,18 @@ void test_builtin_elementwise_add_sat(float f1, float f2, double d1, double d2, long long int i2, si8 vi1, si8 vi2, unsigned u1, unsigned u2, u4 vu1, u4 vu2,

[clang] [clang] Restrict use of scalar types in vector builtins (PR #119423)

2025-01-06 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck edited https://github.com/llvm/llvm-project/pull/119423 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Restrict use of scalar types in vector builtins (PR #119423)

2025-01-06 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck updated https://github.com/llvm/llvm-project/pull/119423 >From 3f007d702922db63e128e3c0f72dff2f600e0879 Mon Sep 17 00:00:00 2001 From: Fraser Cormack Date: Tue, 10 Dec 2024 17:41:07 + Subject: [PATCH 1/6] [clang] Fix sub-integer __builtin_elementwise_(add|sub

[clang] [clang] Restrict use of scalar types in vector builtins (PR #119423)

2025-01-06 Thread Fraser Cormack via cfe-commits
@@ -649,7 +649,9 @@ Unless specified otherwise operation(±0) = ±0 and operation(±infinity) = ±in The integer elementwise intrinsics, including ``__builtin_elementwise_popcount``, ``__builtin_elementwise_bitreverse``, ``__builtin_elementwise_add_sat``, -``__builtin_elementwis

[clang] [clang] Restrict use of scalar types in vector builtins (PR #119423)

2025-01-07 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck updated https://github.com/llvm/llvm-project/pull/119423 >From 3f007d702922db63e128e3c0f72dff2f600e0879 Mon Sep 17 00:00:00 2001 From: Fraser Cormack Date: Tue, 10 Dec 2024 17:41:07 + Subject: [PATCH 1/7] [clang] Fix sub-integer __builtin_elementwise_(add|sub

[clang] [clang] Restrict use of scalar types in vector builtins (PR #119423)

2025-01-07 Thread Fraser Cormack via cfe-commits
@@ -14585,11 +14585,18 @@ void Sema::CheckAddressOfPackedMember(Expr *rhs) { _2, _3, _4)); } +static ExprResult UsualUnaryConversionsNoPromoteInt(Sema &S, Expr *E) { + // Don't promote integer types + if (QualType Ty = E->getType(); S.getASTContext().is

[clang] [clang] Restrict use of scalar types in vector builtins (PR #119423)

2025-01-07 Thread Fraser Cormack via cfe-commits
@@ -14604,57 +14611,63 @@ bool Sema::PrepareBuiltinElementwiseMathOneArgCall(CallExpr *TheCall) { } bool Sema::BuiltinElementwiseMath(CallExpr *TheCall, bool FPOnly) { - QualType Res; - if (BuiltinVectorMath(TheCall, Res, FPOnly)) -return true; - TheCall->setType(Res);

[libclc] [libclc] Move mad_sat to CLC; optimize for vector types (PR #125517)

2025-02-03 Thread Fraser Cormack via cfe-commits
@@ -0,0 +1,119 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define __CLC_CONVERT_TY(X, TY) __builtin_convertvector(X, TY) + +// Macro for defining mad_sat variants for char/uchar/short/ushort +// FIXME: Once using __clc_

[libclc] [libclc] Move mad_sat to CLC; optimize for vector types (PR #125517)

2025-02-03 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck created https://github.com/llvm/llvm-project/pull/125517 This commit moves the mad_sat builtin to the CLC library. It also optimizes it for vector types by avoiding scalarization. To help do this it transforms the previous control-flow code into vector select cod

[libclc] [libclc] Move mad_sat to CLC; optimize for vector types (PR #125517)

2025-02-03 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck updated https://github.com/llvm/llvm-project/pull/125517 >From 1404e1c7b4f133458751048b3f73800b90f98584 Mon Sep 17 00:00:00 2001 From: Fraser Cormack Date: Wed, 29 Jan 2025 13:46:26 + Subject: [PATCH] [libclc] Move mad_sat to CLC; optimize for vector This com

[libclc] [libclc] Move mad_sat to CLC; optimize for vector types (PR #125517)

2025-02-03 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck updated https://github.com/llvm/llvm-project/pull/125517 >From 1404e1c7b4f133458751048b3f73800b90f98584 Mon Sep 17 00:00:00 2001 From: Fraser Cormack Date: Wed, 29 Jan 2025 13:46:26 + Subject: [PATCH 1/2] [libclc] Move mad_sat to CLC; optimize for vector This

[libclc] [libclc] Move mad_sat to CLC; optimize for vector types (PR #125517)

2025-02-03 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck closed https://github.com/llvm/llvm-project/pull/125517 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[libclc] [libclc] Move rotate to CLC library; optimize (PR #125713)

2025-02-04 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck created https://github.com/llvm/llvm-project/pull/125713 This commit moves the rotate builtin to the CLC library. It also optimizes rotate(x, n) to generate the @llvm.fshl(x, x, n) intrinsic directly, for both scalar and vector types. The previous implementation

[libclc] [libclc] Move rotate to CLC library; optimize (PR #125713)

2025-02-04 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck edited https://github.com/llvm/llvm-project/pull/125713 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[libclc] [libclc] Move rotate to CLC library; optimize (PR #125713)

2025-02-04 Thread Fraser Cormack via cfe-commits
frasercrmck wrote: CC @rjodinchr - you might not need to custom replace rotate yourselves in clspv after this PR? https://github.com/llvm/llvm-project/pull/125713 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/m

[libclc] [libclc] Move rotate to CLC library; optimize (PR #125713)

2025-02-05 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck closed https://github.com/llvm/llvm-project/pull/125713 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Improve diagnostics for vector builtins (PR #125673)

2025-02-04 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck created https://github.com/llvm/llvm-project/pull/125673 This commit improves the diagnostics for vector (elementwise) builtins in a couple of ways. It primarily provides more precise type-checking diagnostics for builtins with specific type requirements. Previo

[libclc] [libclc] Move fma to the CLC library (PR #126052)

2025-02-06 Thread Fraser Cormack via cfe-commits
https://github.com/frasercrmck created https://github.com/llvm/llvm-project/pull/126052 This builtin is a little more involved than others as targets deal with fma in various different ways. Fundamentally, the CLC __clc_fma builtin compiles to __builtin_elementwise_fma, which compiles to the @l

[libclc] [libclc] Move fma to the CLC library (PR #126052)

2025-02-06 Thread Fraser Cormack via cfe-commits
frasercrmck wrote: FYI @rjodinchr this breaks downstream clspv testing. ``` # | declare !kernel_arg_name !7 float @llvm.fma.f32(float, float, float) #2 # | Unsupported llvm intrinsic # | UNREACHABLE executed at /clspv/lib/SPIRVProducerPass.cpp:2390! ``` I was wondering if clspv should be transl

[clang] [clang] Improve diagnostics for vector builtins (PR #125673)

2025-02-05 Thread Fraser Cormack via cfe-commits
@@ -2393,8 +2395,10 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { if (CheckVectorElementCallArgs(&SemaRef, TheCall)) return true; if (SemaRef.BuiltinElementwiseTernaryMath( -TheCall, /*CheckForFloatArgs*/ -

[libclc] d4144ca - [libclc][NFC] Clang-format two files

2025-02-06 Thread Fraser Cormack via cfe-commits
Author: Fraser Cormack Date: 2025-02-06T09:04:27Z New Revision: d4144ca27da174da3f8e7e3472e788b4246fd04e URL: https://github.com/llvm/llvm-project/commit/d4144ca27da174da3f8e7e3472e788b4246fd04e DIFF: https://github.com/llvm/llvm-project/commit/d4144ca27da174da3f8e7e3472e788b4246fd04e.diff LOG

<    1   2   3   4   5   6   >