2168 Commits

Author SHA1 Message Date
Rahul Joshi
fa789dffb1
[NFC] Rename Intrinsic::getDeclaration to getOrInsertDeclaration (#111752)
Rename the function to reflect its correct behavior and to be consistent
with `Module::getOrInsertFunction`. This is also in preparation of
adding a new `Intrinsic::getDeclaration` that will have behavior similar
to `Module::getFunction` (i.e, just lookup, no creation).
2024-10-11 05:26:03 -07:00
Finn Plummer
2647505027
[HLSL] Implement the degrees intrinsic (#111209)
- add degrees builtin
    - link degrees api in hlsl_intrinsics.h
    - add degrees intrinsic to IntrinsicsDirectX.td
    - add degrees intrinsic to IntrinsicsSPIRV.td
- add lowering from clang builtin to dx/spv intrinsics in CGBuiltin.cpp
    - add semantic checks to SemaHLSL.cpp
- add expansion of directx intrinsic to llvm fmul for DirectX in
DXILIntrinsicExpansion.cpp
    - add mapping to spir-v intrinsic in SPIRVInstructionSelector.cpp

    - add test coverage:
- degrees.hlsl -> check hlsl lowering to dx/spv degrees intrinsics
- degrees-errors.hlsl/half-float-only-errors -> check semantic warnings
- hlsl-intrinsics/degrees.ll -> check lowering of spir-v degrees
intrinsic to SPIR-V backend
- DirectX/degrees.ll -> check expansion and scalarization of directx
degrees intrinsic to fmul
      
Resolves #99104
2024-10-10 16:34:26 -07:00
Finn Plummer
d36cef0b17
[HLSL][DXIL] Implement WaveGetLaneIndex Intrinsic (#111576)
- add additional lowering for directx backend in CGBuiltin.cpp
    - add directx intrinsic to IntrinsicsDirectX.td
    - add semantic check of arguments in SemaHLSL.cpp
    - add mapping to DXIL op in DXIL.td

    - add testing of semantics in WaveGetLaneIndex-errors.hlsl
    - add testing of dxil lowering in WaveGetLaneIndex.ll
  
Resolves #70105
2024-10-10 11:44:44 -07:00
Tim Gymnich
99608f114f
[clang][HLSL] Add sign intrinsic part 4 (#108396)
- Add handling for unsigned integers to hlsl_elementwise_sign
- Use `select` instead of adding dx and spirv intrinsics for unsigned
integers as [discussed previously
](https://github.com/llvm/llvm-project/pull/101988#discussion_r1736779424)

fixes #70078

### Related PRs
- https://github.com/llvm/llvm-project/pull/101987
- https://github.com/llvm/llvm-project/pull/101988
- https://github.com/llvm/llvm-project/pull/101989

cc @farzonl @pow2clk @bob80905 @bogner @llvm-beanz
2024-10-10 05:18:15 -04:00
Adam Yang
9df94e2791
[clang][HLSL] Add radians intrinsic (#110802)
partially fixes #99151

### Changes
* Implemented `radians` clang builtin
* Linked `radians` clang builtin with `hlsl_intrinsics.h`
* Added sema checks for `radians` to `CheckHLSLBuiltinFunctionCall` in
`SemaChecking.cpp`
* Add codegen for `radians` to `EmitHLSLBuiltinExpr` in `CGBuiltin.cpp`
* Add codegen tests to `clang/test/CodeGenHLSL/builtins/radians.hlsl`
* Add sema tests to `clang/test/SemaHLSL/BuiltIns/radians-errors.hlsl`

### Related PRs
* [[DXIL] Add radians intrinsic
#110616](https://github.com/llvm/llvm-project/pull/110616)
* [[SPIRV] Add radians intrinsic
#110800](https://github.com/llvm/llvm-project/pull/110800)
2024-10-04 18:34:46 -04:00
Kazu Hirata
36929955f5 [CodeGen] Fix warnings
This patch fixes:

  clang/lib/CodeGen/CGBuiltin.cpp:18677:11: error: unused variable
  'XVecTy1' [-Werror,-Wunused-variable]

  clang/lib/CodeGen/CGBuiltin.cpp:18678:11: error: unused variable
  'XVecTy2' [-Werror,-Wunused-variable]
2024-10-03 10:47:26 -07:00
Joshua Batista
c098435eaa
Add cross builtins and cross HLSL function to DirectX and SPIR-V backend (#109180)
This PR adds the step intrinsic and an HLSL function that uses it.
The SPIRV backend is also implemented.

Used https://github.com/llvm/llvm-project/pull/106471 as a reference.
Fixes https://github.com/llvm/llvm-project/issues/99095
2024-10-03 10:24:09 -07:00
Francis Visoiu Mistrih
9440420f63
[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.
2024-10-01 15:39:23 -07:00
Tex Riddell
b70d32789c
[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.
2024-10-01 14:41:43 -07:00
realqhc
00128a20ee
[RISCV] Implement Clang Builtins for XCValu Extension in CV32E40P (#100684)
This commit adds the Clang Builtins, C API header and relevant tests for
XCValu extension.

Spec:
https://github.com/openhwgroup/core-v-sw/blob/master/specifications/corev-builtin-spec.md

Contributor: @melonedo, @PaoloS02
2024-10-01 11:22:02 +10:00
Zhengxing li
5d08f3256b
[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
2024-09-27 17:26:06 -04:00
Lukacma
c511cc099a
[AArch64] Implement NEON vscale intrinsics (#100347)
This patch implements following intrinsics:

```
float16x4_t vscale_f16(float16x4_t vn, int16x4_t vm)	
float16x8_t vscaleq_f16(float16x8_t vn, int16x8_t vm)
float32x2_t vscale_f32(float32x2_t vn, int32x2_t vm)
float32x4_t vscaleq_f32(float32x4_t vn, int32x4_t vm)
float64x2_t vscaleq_f64(float64x2_t vn, int64x2_t vm)
```

as defined in https://github.com/ARM-software/acle/pull/323

Co-authored-by: Hassnaa Hamdi <hassnaa.hamdi@arm.com>
2024-09-26 16:39:18 +01:00
Paul Walker
0c31ea5a09
[Clang][SME2] Use tuple result of SME builtins directly. (#109423)
I missed a codepath during PR108008 so SME2/SVE2p1 builtins are
converting their struct return type into a large vector, which is
causing unnecessary casting via memory.
2024-09-25 11:19:05 +01:00
Benjamin Maxwell
53907ed508
[clang][codegen] Don't mark "int" TBAA on FP libcalls with indirect args (#108853)
On some targets, an FP libcall with argument types such as long double
will be lowered to pass arguments indirectly via pointers. When this is
the case we should not mark the libcall with "int" TBAA as it may lead
to incorrect optimizations.

Currently, this can be seen for long doubles on x86_64-w64-mingw32. The
`load x86_fp80` after the call is (incorrectly) marked with "int" TBAA
(overwriting the previous metadata for "long double").

Nothing seems to break due to this currently as the metadata is being
incorrectly placed on the load and not the call. But if the metadata
is moved to the call (which this patch ensures), LLVM will optimize out
the setup for the arguments.
2024-09-25 09:50:55 +01:00
Yingwei Zheng
d8f555d625
[UBSan] Diagnose assumption violation (#104741)
This patch extends [D34590](https://reviews.llvm.org/D34590) to check
assumption violations.

---------

Co-authored-by: Vitaly Buka <vitalybuka@google.com>
2024-09-25 13:59:10 +08:00
Congcong Cai
eca5949031
[codegen][NFC] add static mark for internal usage variable and function (#109431)
Detect by clang-tidy misc-use-internal-linkage
2024-09-24 07:25:07 +08:00
Lei Huang
62f3eae466
[PowerPC] Fix incorrect store alignment for __builtin_vsx_build_pair() (#108606)
Fixes #107229
2024-09-23 13:30:59 -04:00
Nikita Popov
ecb98f9fed [IRBuilder] Remove uses of CreateGlobalStringPtr() (NFC)
Since the migration to opaque pointers, CreateGlobalStringPtr()
is the same as CreateGlobalString(). Normalize to the latter.
2024-09-23 16:30:50 +02:00
Simon Pilgrim
f8f0a266e0
[clang][wasm] Replace the target integer sub saturate intrinsics with the equivalent generic __builtin_elementwise_sub_sat intrinsics (#109405)
Remove the Intrinsic::wasm_sub_sat_signed/wasm_sub_sat_unsigned entries
and just use sub_sat_s/sub_sat_u directly
2024-09-22 10:12:41 +01:00
Simon Pilgrim
2c90eb990a
[clang][wasm] Replace the target integer add saturate intrinsics with the equivalent generic __builtin_elementwise_add_sat intrinsics (#109269)
Noticed while working on #109160

I've left out the sub_sat intrinsics for now - not sure about the history behind them using Intrinsic::wasm_sub_sat_* instead of Intrinsic::*sub_sat
2024-09-20 11:49:31 +01:00
Simon Pilgrim
e5717fb61d
[clang][wasm] Replace the target iminmax intrinsics with the equivalent generic __builtin_elementwise_min/max intrinsics (#109259)
Noticed while working on #109160
2024-09-20 11:48:57 +01:00
Simon Pilgrim
0013f94b24
[clang][powerpc][wasm][systemz][x86] Replace target vector popcount intrinsics with __builtin_elementwise_popcount (#109160)
Now that we have the C/C++ `__builtin_elementwise_popcount` intrinsic (#108121) - remove custom target intrinsics that just immediately map to Intrinsic::ctpop and use the generic intrinsic directly.
2024-09-19 12:40:36 +01:00
Sarah Spall
67518a44fe
[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
2024-09-18 08:19:52 -07:00
Martin Storsjö
f710612584 Revert "[clang][codegen] Fix possible crash when setting TBAA metadata on FP math libcalls (#108575)"
This reverts commit a56ca1a0fb248c6f38b5841323a74673748f43ea.

This commit broke code generation for x86 mingw targets, with regards
to long double math functions - see
https://github.com/llvm/llvm-project/pull/108575#issuecomment-2352574978
for details.
2024-09-16 13:51:16 +03:00
Benjamin Maxwell
a56ca1a0fb
[clang][codegen] Fix possible crash when setting TBAA metadata on FP math libcalls (#108575)
There's currently no code path that can reach this crash, but:

```
Instruction *Inst = cast<llvm::Instruction>(Call.getScalarVal());
```

fails if the call returns `void`. This could happen if a builtin for
something like `void sincos(double, double*, double*)` is added to
clang.

Instead, use the `llvm::CallBase` returned from `EmitCall()` to set the
TBAA metadata, which should exist no matter the return type.
2024-09-15 13:41:26 +01:00
Paul Walker
992a64aad3
[Clang][SVE] Change LLVM representation of ACLE tuple types to be struct based. (#108008)
This implements our original design now that LLVM is comfortable with
structs and arrays of scalable vector types. All SVE ACLE intrinsics
already use struct types so the effect of this change is purely the
types used for alloca and function parameters.
    
There should be no C/C++ user visible change with this patch.
2024-09-13 12:45:21 +01:00
Joshua Batista
2d47a0baba
Add step builtins and step HLSL function to DirectX and SPIR-V backend (#106471)
This PR adds the step intrinsic and an HLSL function that uses it.
The SPIRV backend is also implemented.

Used https://github.com/llvm/llvm-project/pull/102683 as a reference.
Fixes https://github.com/llvm/llvm-project/issues/99157
2024-09-12 10:26:38 -07:00
Tim Gymnich
dce50397b5
[clang][HLSL] Add sign intrinsic part 3 (#101989)
partially fixes #70078

### Changes
- Implemented `sign` clang builtin
- Linked `sign` clang builtin with `hlsl_intrinsics.h`
- Added sema checks for `sign` to `CheckHLSLBuiltinFunctionCall` in
`SemaChecking.cpp`
- Add codegen for `sign` to `EmitHLSLBuiltinExpr` in `CGBuiltin.cpp`
- Add codegen tests to `clang/test/CodeGenHLSL/builtins/sign.hlsl`
- Add sema tests to `clang/test/SemaHLSL/BuiltIns/sign-errors.hlsl`

### Related PRs
- https://github.com/llvm/llvm-project/pull/101987
- https://github.com/llvm/llvm-project/pull/101988

### Discussion
- Should there be a `usign` intrinsic that handles the unsigned cases?
2024-09-09 23:35:45 -04:00
Sarah Spall
0f349b7a9c
[HLSL] Implement support for HLSL intrinsic - select (#107129)
Implement support for HLSL intrinsic select.
This would close issue #75377
2024-09-09 11:07:20 -07:00
Momchil Velikov
cf8fb4320f
[AArch64] Implement NEON vamin/vamax intrinsics (#99041)
This patch implements the intrinsics of the form

    floatNxM_t vamin[q]_fN(floatNxM_t vn, floatNxM_t vm);
    floatNxM_t vamax[q]_fN(floatNxM_t vn, floatNxM_t vm);

as defined in https://github.com/ARM-software/acle/pull/324

---------

Co-authored-by: Hassnaa Hamdi <hassnaa.hamdi@arm.com>
2024-09-09 13:34:41 +01:00
Stanislav Mekhanoshin
bd840a4004
[AMDGPU] Add target intrinsic for s_prefetch_data (#107133) 2024-09-05 15:14:31 -07:00
Mital Ashok
2a07509c8d
[Clang] Add __builtin_is_within_lifetime to implement P2641R4's std::is_within_lifetime (#91895)
[P2641R4](https://wg21.link/P2641R4)

This new builtin function is declared `consteval`. Support for
`-fexperimental-new-constant-interpreter` will be added in a later
patch.

---------

Co-authored-by: cor3ntin <corentinjabot@gmail.com>
2024-09-05 14:42:59 +02:00
Lukacma
3e948eb3e8
[AArch64][NEON] Add intrinsics for LUTI (#96883)
This patch adds intrinsics for NEON LUTI2 and LUTI4 instructions as
specified in the [ACLE
proposal](https://github.com/ARM-software/acle/pull/324)
2024-09-04 10:39:59 +01:00
Nathan Gauër
afb6dafc6b
[clang][HLSL] Add WaveIsFirstLane() intrinsic (#103299)
This commits add the WaveIsFirstLane() hlsl intrinsinc. This intrinsic
uses the convergence intrinsincs for the SPIR-V backend. On the DXIL
side, I'm not sure what the strategy is for convergence, so I
implemented that like in DXC: a normal builtin function.

Signed-off-by: Nathan Gauër <brioche@google.com>
2024-09-04 11:27:03 +02:00
Freddy Ye
83ad644afa
[X86][AVX10.2] Support AVX10.2-BF16 new instructions. (#101603)
Ref.: https://cdrdv2.intel.com/v1/dl/getContent/828965
2024-09-04 08:13:24 +08:00
Brandon Wu
239127d731
[llvm][RISCV] Support RISCV vector tuple type in llvm IR (#97992)
Summary:
This patch proposes new llvm types for RISCV vector tuples represented
as `TargetExtType` which contains both `LMUL` and `NF`(num_fields)
information and keep it all the way down to `selectionDAG` to match the
corresponding `MVT`(support in the following patch).

Detail:
Currently we have built-in C types for RISCV vector tuple type, e.g.
`vint32m1x2_t`, however it's is represented as structure of scalable
vector types, i.e. `{<vscale x 2 x i32>, <vscale x 2 x i32>}`. It loses
the information for num_fields(NF) as struct is flattened during
`selectionDAG`, thus it makes it not possible to handle inline assembly
of vector tuple type, it also makes the calling convention of vector
tuple types handing not strait forward and hard to realize the
allocation code, i.e. `RVVArgDispatcher`.

The llvm IR for the example above is then represented as
`target("riscv.vector.tuple", <vscale x 8 x i8>, 2)` in which the first
type parameter is the equivalent size scalable vecotr of i8 element
type, the following integer parameter is the `NF` of the tuple.

The new RISCV specific vector insert/extract intrinsics are also added
as `llvm.riscv.vector.insert` and `llvm.riscv.vector.extract` to handle
tuple type subvector insertion/extraction since the generic ones only
operates on `VectorType` but not `TargetExtType`.

There are total of 32 llvm types added for each `VREGS * NF <= 8`, where
`VREGS` is the vector registers needed for each `LMUL` and `NF` is
num_fields.
The name of types are:
```
target("riscv.vector.tuple", <vscale x 1 x i8>, 2)  // LMUL = mf8, NF = 2
target("riscv.vector.tuple", <vscale x 1 x i8>, 3)  // LMUL = mf8, NF = 3
target("riscv.vector.tuple", <vscale x 1 x i8>, 4)  // LMUL = mf8, NF = 4
target("riscv.vector.tuple", <vscale x 1 x i8>, 5)  // LMUL = mf8, NF = 5
target("riscv.vector.tuple", <vscale x 1 x i8>, 6)  // LMUL = mf8, NF = 6
target("riscv.vector.tuple", <vscale x 1 x i8>, 7)  // LMUL = mf8, NF = 7
target("riscv.vector.tuple", <vscale x 1 x i8>, 8)  // LMUL = mf8, NF = 8
target("riscv.vector.tuple", <vscale x 2 x i8>, 2)  // LMUL = mf4, NF = 2
target("riscv.vector.tuple", <vscale x 2 x i8>, 3)  // LMUL = mf4, NF = 3
target("riscv.vector.tuple", <vscale x 2 x i8>, 4)  // LMUL = mf4, NF = 4
target("riscv.vector.tuple", <vscale x 2 x i8>, 5)  // LMUL = mf4, NF = 5
target("riscv.vector.tuple", <vscale x 2 x i8>, 6)  // LMUL = mf4, NF = 6
target("riscv.vector.tuple", <vscale x 2 x i8>, 7)  // LMUL = mf4, NF = 7
target("riscv.vector.tuple", <vscale x 2 x i8>, 8)  // LMUL = mf4, NF = 8
target("riscv.vector.tuple", <vscale x 4 x i8>, 2)  // LMUL = mf2, NF = 2
target("riscv.vector.tuple", <vscale x 4 x i8>, 3)  // LMUL = mf2, NF = 3
target("riscv.vector.tuple", <vscale x 4 x i8>, 4)  // LMUL = mf2, NF = 4
target("riscv.vector.tuple", <vscale x 4 x i8>, 5)  // LMUL = mf2, NF = 5
target("riscv.vector.tuple", <vscale x 4 x i8>, 6)  // LMUL = mf2, NF = 6
target("riscv.vector.tuple", <vscale x 4 x i8>, 7)  // LMUL = mf2, NF = 7
target("riscv.vector.tuple", <vscale x 4 x i8>, 8)  // LMUL = mf2, NF = 8
target("riscv.vector.tuple", <vscale x 8 x i8>, 2)  // LMUL = m1, NF = 2
target("riscv.vector.tuple", <vscale x 8 x i8>, 3)  // LMUL = m1, NF = 3
target("riscv.vector.tuple", <vscale x 8 x i8>, 4)  // LMUL = m1, NF = 4
target("riscv.vector.tuple", <vscale x 8 x i8>, 5)  // LMUL = m1, NF = 5
target("riscv.vector.tuple", <vscale x 8 x i8>, 6)  // LMUL = m1, NF = 6
target("riscv.vector.tuple", <vscale x 8 x i8>, 7)  // LMUL = m1, NF = 7
target("riscv.vector.tuple", <vscale x 8 x i8>, 8)  // LMUL = m1, NF = 8
target("riscv.vector.tuple", <vscale x 16 x i8>, 2) // LMUL = m2, NF = 2
target("riscv.vector.tuple", <vscale x 16 x i8>, 3) // LMUL = m2, NF = 3
target("riscv.vector.tuple", <vscale x 16 x i8>, 4) // LMUL = m2, NF = 4
target("riscv.vector.tuple", <vscale x 32 x i8>, 2) // LMUL = m4, NF = 2
```

RFC:
https://discourse.llvm.org/t/rfc-support-riscv-vector-tuple-type-in-llvm/80005
2024-08-31 18:59:47 +08:00
Brendan Dahl
5703d8572f
[WebAssembly] Add intrinsics to wasm_simd128.h for all FP16 instructions (#106465)
Getting this to work required a few additional changes:
- Add builtins for any instructions that can't be done with plain C
currently.
- Add support for the saturating version of fp_to_<s,i>_I16x8. Other
vector sizes supported this already.
- Support bitcast of f16x8 to v128. Needed to return a __f16x8 as
v128_t.
2024-08-30 08:42:37 -07:00
Denis.G
2d1fba67c5
[NVPTX] Support __usAtomicCAS builtin (#99646)
Supported `__usAtomicCAS` builtin originally defined in
`/usr/local/cuda/inlcude/crt/sm_70_rt.hpp`

---------

Co-authored-by: Denis Gerasimov <Denis.Gerasimov@baikalelectronics.ru>
Co-authored-by: Gonzalo Brito Gadeschi <gonzalob@nvidia.com>
Co-authored-by: Denis.Gerasimov <dengzmm@gmail.com>
2024-08-28 12:01:35 -07:00
Greg Roth
319c7a42ba
[HLSL][SPIRV]Add SPIRV generation for HLSL dot (#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
expansion out of codegen and providing it with at a more generic fdot
intrinsic as well.

Removed some stale comments that gave the obsolete impression that type
conversions should be expected to match overloads.

The SPIRV intrinsic handling involves generating multiply and add
operations for integers and the existing OpDot operation for floating
point.

New tests for generating SPIRV float and integer dot intrinsics are
added as well as expanding HLSL tests to include SPIRV generation

Used new dot product intrinsic generation to implement normalize() in SPIRV

Incidentally changed existing dot intrinsic definitions to use
DefaultAttrsIntrinsic to match the newly added inrinsics

Fixes #88056
2024-08-22 11:13:52 -07:00
Piyou Chen
126b56a234
[RISCV] Make EmitRISCVCpuSupports accept multiple features (#104917)
This patch creates an additional EmitRISCVCpuSupports function to handle
situations with multiple features. It also modifies the original
EmitRISCVCpuSupports function to invoke the new one.
2024-08-21 16:46:59 +08:00
Matt Arsenault
93e0f312c2
clang/AMDGPU: Emit atomicrmw for flat/global atomic min/max f64 builtins (#96876) 2024-08-20 23:24:15 +04:00
Matt Arsenault
5822cc271b
clang/AMDGPU: Emit atomicrmw for global/flat fadd v2bf16 builtins (#96875) 2024-08-20 23:20:03 +04:00
Matt Arsenault
0a22655f31
clang/AMDGPU: Emit atomicrmw from flat_atomic_{f32|f64} builtins (#96874) 2024-08-20 23:15:55 +04:00
Matt Arsenault
ce132a58b8
clang/AMDGPU: Emit atomicrmw from {global|flat}_atomic_fadd_v2f16 builtins (#96873) 2024-08-20 23:01:15 +04:00
S. Bharadwaj Yadavalli
6a38e19c92
[HLSL] Implement support for HLSL intrinsic - saturate (#104619)
Implement support for HLSL intrinsic saturate.
Implement DXIL codegen for the intrinsic saturate by lowering it to DXIL
Op dx.saturate.
Implement SPIRV codegen by transforming saturate(x) to clamp(x, 0.0f,
1.0f).

Add tests for DXIL and SPIRV CodeGen.
2024-08-20 12:46:33 -04:00
Matt Arsenault
b5e63cc533
clang/AMDGPU: Emit atomicrmw for __builtin_amdgcn_global_atomic_fadd_{f32|f64} (#96872)
Need to emit syncscope and new metadata to get the native instruction,
most of the time.
2024-08-15 22:59:24 +04:00
Bill Wendling
94b8b11ac3
[Clang][NFC] Move FindCountedByField into FieldDecl (#104235)
FindCountedByField can be used in more places than CodeGen. Move it into
FieldDecl to avoid layering issues.
2024-08-15 05:27:19 +00:00
Piyou Chen
c4206f1ff1
[RISCV][compiler-rt] Update __init_riscv_feature_bits prototype (#101472)
This patch add `void* PlatformArgs` parameter to
`__init_riscv_feature_bits`. `PlatformArgs` allows the platform to
provide pre-computed data and access it without extra effort. For
example, Linux could pass the vDSO object to avoid an extra system call.

```
__init_riscv_feature_bits()

->

__init_riscv_feature_bits(void *PlatformArgs)
```
2024-08-14 17:30:53 +08:00
Joshua Batista
1b2d11de93
Add normalize builtins and normalize HLSL function to DirectX and SPIR-V backend (#102683)
This PR adds the normalize intrinsic and an HLSL function that uses it.
The SPIRV backend is also implemented.

Used https://github.com/llvm/llvm-project/pull/101256 as a reference,
along with https://github.com/llvm/llvm-project/pull/102243
Fixes https://github.com/llvm/llvm-project/issues/99139
2024-08-13 15:15:19 -07:00
Jessica Clarke
e91e0f5289
[CodeGen][NFCI] Don't re-implement parts of ASTContext::getIntWidth (#101765)
ASTContext::getIntWidth returns 1 if isBooleanType(), and falls back on
getTypeSize in the default case, which itself just returns the Width
from getTypeInfo's returned struct, so can be used in all cases here,
not just for _BitInt types.
2024-08-09 22:52:08 +01:00