#
1ac3665e |
| 29-Jan-2025 |
Fraser Cormack <fraser@codeplay.com> |
[clang] Restrict the use of scalar types in vector builtins (#119423)
This commit restricts the use of scalar types in vector math builtins,
particularly the `__builtin_elementwise_*` builtins.
[clang] Restrict the use of scalar types in vector builtins (#119423)
This commit restricts the use of scalar types in vector math builtins,
particularly the `__builtin_elementwise_*` builtins.
Previously, small scalar integer types would be promoted to `int`, as
per the usual conversions. This would silently do the wrong thing for
certain operations, such as `add_sat`, `popcount`, `bitreverse`, and
others. Similarly, since unsigned integer types were promoted to `int`,
something like `add_sat(unsigned char, unsigned char)` would perform a
*signed* operation.
With this patch, promotable scalar integer types are not promoted to
int, and are kept intact. If any of the types differ in the binary and
ternary builtins, an error is issued. Similarly an error is issued if
builtins are supplied integer types of different signs. Mixing enums of
different types in binary/ternary builtins now consistently raises an
error in all language modes.
This brings the behaviour surrounding scalar types more in line with
that of vector types. No change is made to vector types, which are both
not promoted and whose element types must match.
Fixes #84047.
RFC:
https://discourse.llvm.org/t/rfc-change-behaviour-of-elementwise-builtins-on-scalar-integer-types/83725
show more ...
|
Revision tags: llvmorg-21-init, llvmorg-19.1.7, llvmorg-19.1.6, llvmorg-19.1.5, llvmorg-19.1.4, llvmorg-19.1.3, llvmorg-19.1.2 |
|
#
9440420f |
| 01-Oct-2024 |
Francis Visoiu Mistrih <890283+francisvm@users.noreply.github.com> |
[Clang] Add __builtin_(elementwise|reduce)_(max|min)imum (#110198)
We have the LLVM intrinsics, and we're missing the clang builtins to be
used directly in code that needs to make the distinction i
[Clang] Add __builtin_(elementwise|reduce)_(max|min)imum (#110198)
We have the LLVM intrinsics, and we're missing the clang builtins to be
used directly in code that needs to make the distinction in NaN
semantics.
show more ...
|
#
b70d3278 |
| 01-Oct-2024 |
Tex Riddell <texr@microsoft.com> |
[HLSL][clang] Add elementwise builtin for atan2 (p3) (#110187)
This change is part of this proposal:
https://discourse.llvm.org/t/rfc-all-the-math-intrinsics/78294
- Add HLSL frontend for atan2
[HLSL][clang] Add elementwise builtin for atan2 (p3) (#110187)
This change is part of this proposal:
https://discourse.llvm.org/t/rfc-all-the-math-intrinsics/78294
- Add HLSL frontend for atan2
- Add clang Builtin, map to new llvm.atan2
- SemaChecking restrict to floating point and 2 args
- SemaHLSL restrict to float or half.
- Add to clang ReleaseNotes.rst and LanguageExtensions.rst
- Add half-float-only-errors2.hlsl for 2 arg intrinsics, and update half-float-only-errors.hlsl with scalar case for consistency
- Remove fmod-errors.hlsl and pow-errors.hlsl now covered in half-float-only-errors2.hlsl
Part 3 for Implement the atan2 HLSL Function #70096.
show more ...
|
Revision tags: llvmorg-19.1.1 |
|
#
5d08f325 |
| 27-Sep-2024 |
Zhengxing li <unixhaha@gmail.com> |
[HLSL] Implementation of the elementwise fmod builtin (#108849)
This change add the elementwise fmod builtin to support HLSL function
'fmod' in clang for #99118
Builtins.td - add the f
[HLSL] Implementation of the elementwise fmod builtin (#108849)
This change add the elementwise fmod builtin to support HLSL function
'fmod' in clang for #99118
Builtins.td - add the fmod builtin
CGBuiltin.cpp - lower the builtin to llvm FRem instruction
hlsl_intrinsics.h - add the fmod api
SemaChecking.cpp - add type checks for builtin
SemaHLSL.cpp - add HLSL type checks for builtin
clang/docs/LanguageExtensions.rst - add the builtin in *Elementwise
Builtins*
clang/docs/ReleaseNotes.rst - announce the builtin
show more ...
|
#
67518a44 |
| 18-Sep-2024 |
Sarah Spall <sarahspall@microsoft.com> |
[HLSL] Implement elementwise popcount (#108121)
Add new elementwise popcount builtin to support HLSL function
'countbits'.
elementwise popcount only accepts integer types.
Add hlsl intrinsic 'cou
[HLSL] Implement elementwise popcount (#108121)
Add new elementwise popcount builtin to support HLSL function
'countbits'.
elementwise popcount only accepts integer types.
Add hlsl intrinsic 'countbits'
Closes #99094
show more ...
|
Revision tags: llvmorg-19.1.0 |
|
#
d32982b6 |
| 11-Sep-2024 |
Sarah Spall <spall@users.noreply.github.com> |
[HLSL] fix elementwise bitreverse test (#108128)
The test called 'ceil' instead of 'bitreverse', which I assume was a
copy paste leftover.
|
Revision tags: llvmorg-19.1.0-rc4, llvmorg-19.1.0-rc3, llvmorg-19.1.0-rc2, llvmorg-19.1.0-rc1, llvmorg-20-init |
|
#
f73ac218 |
| 23-Jun-2024 |
Farzon Lotfi <1802579+farzonl@users.noreply.github.com> |
[HLSL][clang] Add elementwise builtins for trig intrinsics (#95999)
This change is part of this proposal:
https://discourse.llvm.org/t/rfc-all-the-math-intrinsics/78294
This is part 3 of 4 PRs.
[HLSL][clang] Add elementwise builtins for trig intrinsics (#95999)
This change is part of this proposal:
https://discourse.llvm.org/t/rfc-all-the-math-intrinsics/78294
This is part 3 of 4 PRs. It sets the ground work for using the
intrinsics in HLSL.
Add HLSL frontend apis for `acos`, `asin`, `atan`, `cosh`, `sinh`, and
`tanh`
https://github.com/llvm/llvm-project/issues/70079
https://github.com/llvm/llvm-project/issues/70080
https://github.com/llvm/llvm-project/issues/70081
https://github.com/llvm/llvm-project/issues/70083
https://github.com/llvm/llvm-project/issues/70084
https://github.com/llvm/llvm-project/issues/95966
show more ...
|
Revision tags: llvmorg-18.1.8, llvmorg-18.1.7, llvmorg-18.1.6 |
|
#
31b45a9d |
| 08-May-2024 |
Farzon Lotfi <1802579+farzonl@users.noreply.github.com> |
[clang][hlsl] Add tan intrinsic part 1 (#90276)
This change is an implementation of #87367's investigation on supporting
IEEE math operations as intrinsics.
Which was discussed in this RFC:
https
[clang][hlsl] Add tan intrinsic part 1 (#90276)
This change is an implementation of #87367's investigation on supporting
IEEE math operations as intrinsics.
Which was discussed in this RFC:
https://discourse.llvm.org/t/rfc-all-the-math-intrinsics/78294
If you want an overarching view of how this will all connect see:
https://github.com/llvm/llvm-project/pull/90088
Changes:
- `clang/docs/LanguageExtensions.rst` - Document the new elementwise tan
builtin.
- `clang/include/clang/Basic/Builtins.td` - Implement the tan builtin.
- `clang/lib/CodeGen/CGBuiltin.cpp` - invoke the tan intrinsic on uses
of the builtin
- `clang/lib/Headers/hlsl/hlsl_intrinsics.h` - Associate the tan builtin
with the equivalent hlsl apis
- `clang/lib/Sema/SemaChecking.cpp` - Add generic sema checks as well as
HLSL specifc sema checks to the tan builtin
- `llvm/include/llvm/IR/Intrinsics.td` - Create the tan intrinsic
- `llvm/docs/LangRef.rst` - Document the tan intrinsic
show more ...
|
Revision tags: llvmorg-18.1.5, llvmorg-18.1.4, llvmorg-18.1.3, llvmorg-18.1.2, llvmorg-18.1.1, llvmorg-18.1.0, llvmorg-18.1.0-rc4 |
|
#
8c2ae42b |
| 27-Feb-2024 |
Kupa-Martin <84517188+Kupa-Martin@users.noreply.github.com> |
[Clang][Sema] Fix missing warning when comparing mismatched enums in … (#81418)
…C mode
Factored logic from `CheckImplicitConversion` into new methods
`Expr::getEnumConstantDecl` and `Expr::getE
[Clang][Sema] Fix missing warning when comparing mismatched enums in … (#81418)
…C mode
Factored logic from `CheckImplicitConversion` into new methods
`Expr::getEnumConstantDecl` and `Expr::getEnumCoercedType` for use in
`checkEnumArithmeticConversions`.
Fix #29217
show more ...
|
Revision tags: llvmorg-18.1.0-rc3, llvmorg-18.1.0-rc2, llvmorg-18.1.0-rc1, llvmorg-19-init, llvmorg-17.0.6, llvmorg-17.0.5, llvmorg-17.0.4, llvmorg-17.0.3, llvmorg-17.0.2, llvmorg-17.0.1, llvmorg-17.0.0, llvmorg-17.0.0-rc4, llvmorg-17.0.0-rc3, llvmorg-17.0.0-rc2 |
|
#
9e3d9c9e |
| 31-Jul-2023 |
Matt Arsenault <Matthew.Arsenault@amd.com> |
clang: Add __builtin_elementwise_sqrt
This will be used in the opencl builtin headers to provide direct intrinsic access with proper !fpmath metadata.
https://reviews.llvm.org/D156737
|
#
57f879cd |
| 31-Jul-2023 |
Joshua Batista <jbatista@microsoft.com> |
clang: Add elementwise bitreverse builtin
Add codegen for llvm bitreverse elementwise builtin The bitreverse elementwise builtin is necessary for HLSL codegen. Tests were added to make sure that the
clang: Add elementwise bitreverse builtin
Add codegen for llvm bitreverse elementwise builtin The bitreverse elementwise builtin is necessary for HLSL codegen. Tests were added to make sure that the expected errors are encountered when these functions are given inputs of incompatible types, or too many inputs. The new builtin is restricted to integer types only.
Reviewed By: arsenm
Differential Revision: https://reviews.llvm.org/D156357
show more ...
|
Revision tags: llvmorg-17.0.0-rc1, llvmorg-18-init |
|
#
3a98e731 |
| 24-Jul-2023 |
Joshua Batista <jbatista@microsoft.com> |
clang: Add elementwise pow builtin
Add codegen for llvm pow elementwise builtin The pow elementwise builtin is necessary for HLSL codegen. Tests were added to make sure that the expected errors are
clang: Add elementwise pow builtin
Add codegen for llvm pow elementwise builtin The pow elementwise builtin is necessary for HLSL codegen. Tests were added to make sure that the expected errors are encountered when these functions are given inputs of incompatible types, or too many inputs. The new builtin is restricted to floating point types only.
Reviewed By: arsenm
Differential Revision: https://reviews.llvm.org/D153310
show more ...
|
#
9d84f8dc |
| 18-Jun-2023 |
Matt Arsenault <Matthew.Arsenault@amd.com> |
clang: Add __builtin_elementwise_rint and nearbyint
These are basically the same thing and only differ for strictfp, so add both for future proofing. Note all the elementwise functions are currently
clang: Add __builtin_elementwise_rint and nearbyint
These are basically the same thing and only differ for strictfp, so add both for future proofing. Note all the elementwise functions are currently broken for strictfp, and use non-constrained ops. Add a test that demonstrates this, but doesn't attempt to fix it.
show more ...
|
Revision tags: llvmorg-16.0.6, llvmorg-16.0.5, llvmorg-16.0.4, llvmorg-16.0.3, llvmorg-16.0.2, llvmorg-16.0.1, llvmorg-16.0.0, llvmorg-16.0.0-rc4, llvmorg-16.0.0-rc3, llvmorg-16.0.0-rc2, llvmorg-16.0.0-rc1, llvmorg-17-init, llvmorg-15.0.7 |
|
#
2a488b44 |
| 05-Jan-2023 |
Matt Arsenault <Matthew.Arsenault@amd.com> |
clang: Add __builtin_elementwise_round
|
#
4c82050c |
| 09-Mar-2023 |
Joshua Batista <jbatista@microsoft.com> |
Add codegen for llvm exp/exp2 elementwise builtins
Add codegen for llvm exp/exp2 elementwise builtin The exp/exp2 elementwise builtins are necessary for HLSL codegen. Tests were added to make sure t
Add codegen for llvm exp/exp2 elementwise builtins
Add codegen for llvm exp/exp2 elementwise builtin The exp/exp2 elementwise builtins are necessary for HLSL codegen. Tests were added to make sure that the expected errors are encountered when these functions are given inputs of incompatible types. The new builtins are restricted to floating point types only.
Reviewed By: fhahn
Differential Revision: https://reviews.llvm.org/D145270
show more ...
|
#
8709bcac |
| 08-Dec-2022 |
Matt Arsenault <Matthew.Arsenault@amd.com> |
clang: Add __builtin_elementwise_fma
I didn't understand why the other builtins have promotion logic, or how it would apply for a ternary operation. Implicit conversions are evil to begin with, an
clang: Add __builtin_elementwise_fma
I didn't understand why the other builtins have promotion logic, or how it would apply for a ternary operation. Implicit conversions are evil to begin with, and even more so when the purpose is to get an exact IR intrinsic. This checks all the arguments have the same type.
show more ...
|
#
836249b1 |
| 07-Feb-2023 |
Joshua Batista <jbatista@microsoft.com> |
Add codegen for llvm log2/log10 elementwise builtins
Add codegen for llvm log2 / log10 elementwise builtin The log2/log10 elementwise builtin is necessary for HLSL codegen. Tests were added to make
Add codegen for llvm log2/log10 elementwise builtins
Add codegen for llvm log2 / log10 elementwise builtin The log2/log10 elementwise builtin is necessary for HLSL codegen. Tests were added to make sure that the expected errors are encountered when these functions are given inputs of incompatible types. The new builtins are restricted to floating point types only.
Reviewed By: fhahn
Differential Revision: https://reviews.llvm.org/D143207
show more ...
|
#
26eb7082 |
| 02-Feb-2023 |
Joshua Batista <jbatista@microsoft.com> |
Add builtin_elementwise_log
Add codegen for llvm log elementwise builtin The log elementwise builtin is necessary for HLSL codegen. Tests were added to make sure that the expected errors are encount
Add builtin_elementwise_log
Add codegen for llvm log elementwise builtin The log elementwise builtin is necessary for HLSL codegen. Tests were added to make sure that the expected errors are encountered when these functions are given inputs of incompatible types. The new builtin is restricted to floating point types only.
Reviewed By: beanz
Differential Revision: https://reviews.llvm.org/D140489
show more ...
|
#
2ad4c3c8 |
| 23-Dec-2022 |
Matt Arsenault <Matthew.Arsenault@amd.com> |
clang: Fix handling of __builtin_elementwise_copysign
I realized the handling of copysign made no sense at all. Only the type of the first operand should really matter, and it should not perform a c
clang: Fix handling of __builtin_elementwise_copysign
I realized the handling of copysign made no sense at all. Only the type of the first operand should really matter, and it should not perform a conversion between them.
Also fixes misleading errors and producing broken IR for integers.
We could accept different FP types for the sign argument, if the intrinsic permitted different types like the DAG node. As it is we would need to insert a cast, which could have other effects (like trapping on snan) which should not happen for a copysign.
show more ...
|
#
437346ab |
| 08-Dec-2022 |
Matt Arsenault <Matthew.Arsenault@amd.com> |
clang: Add __builtin_elementwise canonicalize and copysign
Just copy paste from the other functions. I also need fma, but the current code seems to assume 1 or 2 arguments.
|
Revision tags: llvmorg-15.0.6, llvmorg-15.0.5 |
|
#
a5d14f75 |
| 11-Nov-2022 |
Joshua Batista <jbatista@microsoft.com> |
Add builtin_elementwise_sin and builtin_elementwise_cos
Add codegen for llvm cos and sin elementwise builtins The sin and cos elementwise builtins are necessary for HLSL codegen. Tests were added to
Add builtin_elementwise_sin and builtin_elementwise_cos
Add codegen for llvm cos and sin elementwise builtins The sin and cos elementwise builtins are necessary for HLSL codegen. Tests were added to make sure that the expected errors are encountered when these functions are given inputs of incompatible types. The new builtins are restricted to floating point types only.
Reviewed By: craig.topper, fhahn
Differential Revision: https://reviews.llvm.org/D135011
show more ...
|
Revision tags: llvmorg-15.0.4, llvmorg-15.0.3, working, llvmorg-15.0.2, llvmorg-15.0.1, llvmorg-15.0.0, llvmorg-15.0.0-rc3, llvmorg-15.0.0-rc2, llvmorg-15.0.0-rc1, llvmorg-16-init, llvmorg-14.0.6, llvmorg-14.0.5, llvmorg-14.0.4, llvmorg-14.0.3, llvmorg-14.0.2, llvmorg-14.0.1, llvmorg-14.0.0, llvmorg-14.0.0-rc4, llvmorg-14.0.0-rc3, llvmorg-14.0.0-rc2, llvmorg-14.0.0-rc1 |
|
#
c00db971 |
| 08-Feb-2022 |
Simon Pilgrim <llvm-dev@redking.me.uk> |
[Clang] Add elementwise saturated add/sub builtins
This patch implements `__builtin_elementwise_add_sat` and `__builtin_elementwise_sub_sat` builtins.
These map to the add/sub saturated math intrin
[Clang] Add elementwise saturated add/sub builtins
This patch implements `__builtin_elementwise_add_sat` and `__builtin_elementwise_sub_sat` builtins.
These map to the add/sub saturated math intrinsics described here: https://llvm.org/docs/LangRef.html#saturation-arithmetic-intrinsics
With this in place we should then be able to replace the x86 SSE adds/subs intrinsics with these generic variants - it looks like other targets should be able to use these as well (arm/aarch64/webassembly all have similar examples in cgbuiltin).
Differential Revision: https://reviews.llvm.org/D117898
show more ...
|
Revision tags: llvmorg-15-init |
|
#
9d75ee1c |
| 28-Jan-2022 |
Simon Pilgrim <llvm-dev@redking.me.uk> |
[Sema] Add signed/unsigned integer mismatch tests for min/max elementwise builtins
As suggested on D117898
Differential Revision: https://reviews.llvm.org/D118464
|
Revision tags: llvmorg-13.0.1, llvmorg-13.0.1-rc3, llvmorg-13.0.1-rc2 |
|
#
b2ed9f3f |
| 07-Jan-2022 |
Jun Zhang <jun@junz.org> |
[Clang] Implement the rest of __builtin_elementwise_* functions.
The patch implement the rest of __builtin_elementwise_* functions specified in D111529, including: * __builtin_elementwise_floor * __
[Clang] Implement the rest of __builtin_elementwise_* functions.
The patch implement the rest of __builtin_elementwise_* functions specified in D111529, including: * __builtin_elementwise_floor * __builtin_elementwise_roundeven * __builtin_elementwise_trunc
Signed-off-by: Jun <jun@junz.org>
Reviewed By: fhahn
Differential Revision: https://reviews.llvm.org/D115429
show more ...
|
#
8680f951 |
| 08-Dec-2021 |
Jun Zhang <jun@junz.org> |
Add __builtin_elementwise_ceil
This patch implements one of the missing builtin functions specified in https://reviews.llvm.org/D111529.
|