82 Commits

Author SHA1 Message Date
Amr Hesham
2de5a17e9c
[CIR] Upstream FPToFP Builtin CeilOp (#166052)
Upstream the FPToFP Builtin CeilOp
2025-11-03 18:08:27 +00:00
Andres-Salamanca
4448ff453d
[CIR] Emit CIR builtins: coroAlloc, coroBegin, and coroSize (#164180)
This PR adds support for emitting the builtins coroAlloc, coroBegin, and
coroSize.
2025-10-24 17:55:29 -05:00
Shawn K
3107c2fe94
[CIR] Upstream handling for __builtin_prefetch (#164387)
Fix #163886
2025-10-23 20:28:35 +08:00
Jakub Kuderski
9a2e825c13
[clang][CIR][mlir] Migrate to free create functions. NFC. (#164656)
See
https://discourse.llvm.org/t/psa-opty-create-now-with-100-more-tab-complete/87339.

I plan to make these deprecated in
https://github.com/llvm/llvm-project/pull/164649.
2025-10-22 14:30:19 -04:00
Andy Kaylor
e1ee75f217
[CIR][NFC] Add infrastructure for handling X86 builtins (#164465)
This adds the infrastructure for handling x86-specific builtin calls. It
does not add any actual handling, just the code structure and a large
switch statement containing all of the builtins that will eventually
need to be handled. Target-specific builtins for other targets will be
added later.
2025-10-21 13:16:04 -07:00
Andy Kaylor
99f02ea177
[CIR][NFC] Improve the output for missing builtin calls (#163884)
This improves the diagnostic emitted when `errorNYI` is called for
missing builtin calls so that the builtin being called is displayed in
the diagnostic.
2025-10-16 17:39:16 -07:00
Andres-Salamanca
16f5a85fb6
[CIR] Initial support for emitting coroutine body (#161616)
This PR adds new `FuncOp` attributes (`coroutine` and `builtin`) and
begins the implementation of the `emitCoroutineBody` function. Feature
markers were also added for guidance in future PRs.
2025-10-03 13:56:53 -05:00
Amr Hesham
cf9576d940
[CIR] Upstream FPToFPBuiltin CosOp (#158342)
Upstream support for FPToFPBuiltin CosOp
2025-09-13 11:02:30 +02:00
Amr Hesham
5437d90bb7
[CIR] Upstream FPToFPBuiltin ATanOp (#157496)
Upstream support for FPToFPBuiltin ATanOp
2025-09-11 18:01:12 +02:00
Amr Hesham
e5102e2931
[CIR] Upstream FPToFPBuiltin ASinOp (#157350)
Upstream support for FPToFPBuiltin ASinOp
2025-09-10 17:47:06 +02:00
Morris Hafner
6b4803fd48
[CIR] Add support for __builtin_alloca (#157116)
This patch adds support for the alloca builtin and extends AllocaOp with
a dynamic size argument.
2025-09-09 15:47:17 +02:00
Amr Hesham
1b130e3fc0
[CIR] Upstream FPToFPBuiltin ACosOp (#156356)
Upstream support for FPToFPBuiltin ACosOp
2025-09-03 18:13:36 +02:00
Morris Hafner
3b9664840b
[CIR] Implement__builtin_va_arg (#153834)
Part of https://github.com/llvm/llvm-project/issues/153286.
Depends on https://github.com/llvm/llvm-project/pull/153819.

This patch adds support for __builtin_va_arg by adding the cir.va.arg
operator. Unlike the incubator it doesn't depend on any target specific
lowering (yet) but maps to llvm.va_arg.
2025-08-20 12:52:11 +02:00
Sirui Mu
10d193bf5e
[CIR][NFC] Fix regression by #153819 (#154346)
This patch fixes a regression introduced by #153819. The evaluation
order of the arguments to `emitVAStart` is unspecified, but the test
requires the arguments to be evaluated in left-to-right order.

It's a bit strange that the pre-merge checks did not catch this. The
tests failed on my local machine, which runs Fedora 42 with gcc 15.2.1 .
2025-08-19 23:32:02 +08:00
Morris Hafner
b44e47a68f
[CIR] Upstream __builtin_va_start and __builtin_va_end (#153819)
Part of #153286
2025-08-19 09:16:11 +02:00
Morris Hafner
df0e9f3a2d
[CIR] Implement __builtin_return_address and __builtin_frame_address (#153698)
This adds ReturnAddrOp and FrameAddrOp that represent
__builtin_return_address and __builtin_frame_address and the respective
lowering to LLVM parts.

---------

Co-authored-by: Andy Kaylor <akaylor@nvidia.com>
2025-08-16 00:47:04 +02:00
Amr Hesham
dc84f3aea8
[CIR] Upstream builtin FAbs op (#151750)
Upstreaming FAbsOp as a prerequisite for upstreaming ComplexDivOp
2025-08-13 17:57:06 +02:00
Sirui Mu
b2cdd80411
[CIR] Add support for __builtin_assume_aligned (#152152)
This patch upstreams CIRGen and LLVM lowering support for the
`__builtin_assume_aligned` builtin function.
2025-08-10 12:25:45 +08:00
Sirui Mu
13600c72ce
[CIR] Add CIRGen for cir.unreachable and cir.trap (#151363) 2025-08-05 18:52:02 +08:00
Sirui Mu
1249ab9a03
[CIR] Add bit ffs operation (#150997)
This patch adds the `cir.ffs` operation which corresponds to the
`__builtin_ffs` family of builtin functions.

This operation was not included in the previous PRs because the call to
`__builtin_ffs` would be transformed into a library call to `ffs`. At
the time of authoring this patch, this behavior has been changed and now
we can properly lower calls to `__builtin_ffs` to `cir.ffs`.
2025-07-29 20:45:13 +08:00
Sirui Mu
3371b9111f
[CIR] Add assume_separate_storage operation (#149696)
This patch adds the `cir.assume_separate_storage` operation for the
`__builtin_assume_separate_storage` builtin function.
2025-07-21 22:21:44 +08:00
Amr Hesham
84d65e9d19
[CIR] Upstream builtin_conj for ComplexType (#149170)
This change adds support for builtin_conj for ComplexType

https://github.com/llvm/llvm-project/issues/141365
2025-07-17 18:00:32 +02:00
Sirui Mu
8519143a9f
[CIR] Add rotate operation (#148426)
This patch adds `cir.rotate` operation for the `__builtin_rotateleft`
and `__builtin_rotateright` families of builtin calls.
2025-07-17 00:41:28 +08:00
Sirui Mu
265fb3605d
[CIR] Add bit reverse and byte reverse operations (#147200)
This patch adds support for the following two builtin functions:

- `__builtin_bswap`, represented by the `cir.byte_swap` operation.
- `__builtin_bitreverse`, represented by the `cir.bit.reverse`
operation.
2025-07-12 12:15:36 +08:00
Amr Hesham
54ec5217a0
[CIR] Upstream __builtin_cimag for ComplexType (#147808)
Upstream __builtin_cimag support for ComplexType

https://github.com/llvm/llvm-project/issues/141365
2025-07-10 18:19:24 +02:00
Amr Hesham
ddfc13c191
[CIR] Upstream __builtin_creal for ComplexType (#146927)
Upstream `__builtin_creal` support for ComplexType

https://github.com/llvm/llvm-project/issues/141365
2025-07-09 18:28:00 +02:00
Sirui Mu
4b9f622ca9
[CIR] Bit manipulation builtin functions (#146529)
This patch adds CIR support for the following families of bit
manipulation builtin functions:

- `__builtin_clrsb`, represented by the `cir.bit.clrsb` operation
- `__builtin_ctz`, represented by the `cir.bit.clz` operation
- `__builtin_clz`, represented by the `cir.bit.ctz` operation
- `__builtin_parity`, represented by the `cir.bit.parity` operation
- `__builtin_popcount`, represented by the `cir.bit.popcnt` operation

The `__builtin_ffs` builtin function is not included in this patch
because the current CIRGen would emit it as a library call to `@ffs`.
2025-07-03 23:08:49 +08:00
Sirui Mu
9291ad1c96
[CIR] Add support for __builtin_expect (#144726)
This patch adds support for the `__builtin_expect` and
`__builtin_expect_with_probability` builtin functions.
2025-06-24 10:17:12 -07:00
Amr Hesham
4dca4459a3
[CIR] Upstream ComplexType builtin_complex (#144225)
This change adds support for builtin_complex

https://github.com/llvm/llvm-project/issues/141365
2025-06-18 23:09:48 +02:00
Sirui Mu
8e157fdbb7
[CIR] Add support for __builtin_assume (#144376)
This patch adds support for the `__builtin_assume` builtin function.
2025-06-18 17:10:29 +08:00
Morris Hafner
4bcf9732c7
[CIR] Add Support For Library Builtins (#143984)
This patch upstreams support for builtins that map to a standard library
function. Examples would be abort() and printf().

It also fixes a minor issue with the errorNYI for all remaining
unimplemented builtins using the mlir::Location instead of the clang AST
SourceLocation.
2025-06-16 23:03:49 +01:00
Morris Hafner
8e4f0d8614
[CIR] Upstream minimal builtin function call support (#142981)
This patch adds all bits required to implement builtin function calls to
ClangIR. It doesn't actually implement any of the builtins except those
that fold to a constant ahead of CodeGen
(`__builtin_is_constant_evaluated()` being one example).
2025-06-11 18:24:46 +02:00