Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CIR][CIRGen] Add CIRGen for binary fp2fp builtin operations #616

Merged
merged 3 commits into from
May 30, 2024

Conversation

Lancern
Copy link
Member

@Lancern Lancern commented May 19, 2024

This PR adds the following operations for the builtin binary fp2fp functions:

  • cir.copysign for __builtin_copysign;
  • cir.fmax for __builtin_fmax;
  • cir.fmin for __builtin_fmin;
  • cir.fmod for __builtin_fmod;
  • cir.pow for __builtin_pow.

This PR also includes CIRGen support for these new operations.

@bcardosolopes
Copy link
Member

Awesome! Please also add LLVM lowering support, thanks!

This patch adds the following operations for the builtin binary fp2fp functions:

  - `cir.copysign` for `__builtin_copysign`;
  - `cir.fmax` for `__builtin_fmax`;
  - `cir.fmin` for `__builtin_fmin`;
  - `cir.fmod` for `__builtin_fmod`;
  - `cir.pow` for `__builtin_pow`.

This patch also includes CIRGen support for these new operations.
@Lancern
Copy link
Member Author

Lancern commented May 29, 2024

Please also add LLVM lowering support

Added. Also rebased onto the latest main.

Copy link
Member

@bcardosolopes bcardosolopes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there, few nits!

@@ -0,0 +1,132 @@
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t.ll
// RUN: FileCheck --input-file=%t.ll %s -check-prefix=LLVM
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. I think it's best to have it all in one place, since it's the exact same functions. Just add these RUN lines in clang/test/CIR/CodeGen/builtin-floating-point.c and add the LLVM checks there. No need to add tests for things that pre-exist in that file, we can increment that in the future.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, LLVM lowering for the unary fp2fp builtins is not yet implemented. I'll make a PR for this later and we can add tests in that PR :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Looking fwd, I'm in general (unless there's a good reason not to) expecting new CIR stuff to come with LLVM support in the same PR. Just a heads up so you can make sure you can include that in newer PRs you create. If that potentially means bigger PRs, just do less CIR features in each of them.

clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp Show resolved Hide resolved
@bcardosolopes bcardosolopes merged commit cda4ef5 into llvm:main May 30, 2024
6 checks passed
@Lancern Lancern deleted the binary-fp2fp branch May 31, 2024 02:08
Lancern added a commit to Lancern/clangir that referenced this pull request Jun 8, 2024
LLVM lowering for the following operations is introduced in llvm#616 and llvm#651: cos,
exp, exp2, log, log10, log2, sin, sqrt, fmod, and pow. However, they are not
lowered to their corresponding LLVM intrinsics; instead they are transformed to
libc calls during lowering prepare. This does not match the upstream behavior.

This patch tries to correct this mistake.
Lancern added a commit to Lancern/clangir that referenced this pull request Jun 15, 2024
LLVM lowering for the following operations is introduced in llvm#616 and llvm#651: cos,
exp, exp2, log, log10, log2, sin, sqrt, fmod, and pow. However, they are not
lowered to their corresponding LLVM intrinsics; instead they are transformed to
libc calls during lowering prepare. This does not match the upstream behavior.

This patch tries to correct this mistake.
Lancern added a commit to Lancern/clangir that referenced this pull request Jun 24, 2024
LLVM lowering for the following operations is introduced in llvm#616 and llvm#651: cos,
exp, exp2, log, log10, log2, sin, sqrt, fmod, and pow. However, they are not
lowered to their corresponding LLVM intrinsics; instead they are transformed to
libc calls during lowering prepare. This does not match the upstream behavior.

This patch tries to correct this mistake.
Lancern added a commit to Lancern/clangir that referenced this pull request Jul 11, 2024
LLVM lowering for the following operations is introduced in llvm#616 and llvm#651: cos,
exp, exp2, log, log10, log2, sin, sqrt, fmod, and pow. However, they are not
lowered to their corresponding LLVM intrinsics; instead they are transformed to
libc calls during lowering prepare. This does not match the upstream behavior.

This patch tries to correct this mistake.
bcardosolopes pushed a commit that referenced this pull request Jul 11, 2024
LLVM lowering for the following operations is introduced in #616 and
#651: `cos`, `exp`, `exp2`, `log`, `log10`, `log2`, `sin`, `sqrt`,
`fmod`, and `pow`. However, they are not lowered to their corresponding
LLVM intrinsics; instead they are transformed to libc calls during
lowering prepare. This does not match the upstream behavior.

This PR tries to correct this mistake. It makes all CIR FP intrinsic ops
lower to their corresponding LLVM intrinsics (`fmod` is a special case
and it is lowered to the `frem` LLVM instruction).
bruteforceboy pushed a commit to bruteforceboy/clangir that referenced this pull request Oct 2, 2024
This PR adds the following operations for the builtin binary fp2fp
functions:

  - `cir.copysign` for `__builtin_copysign`;
  - `cir.fmax` for `__builtin_fmax`;
  - `cir.fmin` for `__builtin_fmin`;
  - `cir.fmod` for `__builtin_fmod`;
  - `cir.pow` for `__builtin_pow`.

This PR also includes CIRGen support for these new operations.
Hugobros3 pushed a commit to shady-gang/clangir that referenced this pull request Oct 2, 2024
This PR adds the following operations for the builtin binary fp2fp
functions:

  - `cir.copysign` for `__builtin_copysign`;
  - `cir.fmax` for `__builtin_fmax`;
  - `cir.fmin` for `__builtin_fmin`;
  - `cir.fmod` for `__builtin_fmod`;
  - `cir.pow` for `__builtin_pow`.

This PR also includes CIRGen support for these new operations.
Hugobros3 pushed a commit to shady-gang/clangir that referenced this pull request Oct 2, 2024
LLVM lowering for the following operations is introduced in llvm#616 and
llvm#651: `cos`, `exp`, `exp2`, `log`, `log10`, `log2`, `sin`, `sqrt`,
`fmod`, and `pow`. However, they are not lowered to their corresponding
LLVM intrinsics; instead they are transformed to libc calls during
lowering prepare. This does not match the upstream behavior.

This PR tries to correct this mistake. It makes all CIR FP intrinsic ops
lower to their corresponding LLVM intrinsics (`fmod` is a special case
and it is lowered to the `frem` LLVM instruction).
smeenai pushed a commit to smeenai/clangir that referenced this pull request Oct 9, 2024
This PR adds the following operations for the builtin binary fp2fp
functions:

  - `cir.copysign` for `__builtin_copysign`;
  - `cir.fmax` for `__builtin_fmax`;
  - `cir.fmin` for `__builtin_fmin`;
  - `cir.fmod` for `__builtin_fmod`;
  - `cir.pow` for `__builtin_pow`.

This PR also includes CIRGen support for these new operations.
smeenai pushed a commit to smeenai/clangir that referenced this pull request Oct 9, 2024
LLVM lowering for the following operations is introduced in llvm#616 and
llvm#651: `cos`, `exp`, `exp2`, `log`, `log10`, `log2`, `sin`, `sqrt`,
`fmod`, and `pow`. However, they are not lowered to their corresponding
LLVM intrinsics; instead they are transformed to libc calls during
lowering prepare. This does not match the upstream behavior.

This PR tries to correct this mistake. It makes all CIR FP intrinsic ops
lower to their corresponding LLVM intrinsics (`fmod` is a special case
and it is lowered to the `frem` LLVM instruction).
smeenai pushed a commit to smeenai/clangir that referenced this pull request Oct 9, 2024
LLVM lowering for the following operations is introduced in llvm#616 and
llvm#651: `cos`, `exp`, `exp2`, `log`, `log10`, `log2`, `sin`, `sqrt`,
`fmod`, and `pow`. However, they are not lowered to their corresponding
LLVM intrinsics; instead they are transformed to libc calls during
lowering prepare. This does not match the upstream behavior.

This PR tries to correct this mistake. It makes all CIR FP intrinsic ops
lower to their corresponding LLVM intrinsics (`fmod` is a special case
and it is lowered to the `frem` LLVM instruction).
keryell pushed a commit to keryell/clangir that referenced this pull request Oct 19, 2024
This PR adds the following operations for the builtin binary fp2fp
functions:

  - `cir.copysign` for `__builtin_copysign`;
  - `cir.fmax` for `__builtin_fmax`;
  - `cir.fmin` for `__builtin_fmin`;
  - `cir.fmod` for `__builtin_fmod`;
  - `cir.pow` for `__builtin_pow`.

This PR also includes CIRGen support for these new operations.
keryell pushed a commit to keryell/clangir that referenced this pull request Oct 19, 2024
LLVM lowering for the following operations is introduced in llvm#616 and
llvm#651: `cos`, `exp`, `exp2`, `log`, `log10`, `log2`, `sin`, `sqrt`,
`fmod`, and `pow`. However, they are not lowered to their corresponding
LLVM intrinsics; instead they are transformed to libc calls during
lowering prepare. This does not match the upstream behavior.

This PR tries to correct this mistake. It makes all CIR FP intrinsic ops
lower to their corresponding LLVM intrinsics (`fmod` is a special case
and it is lowered to the `frem` LLVM instruction).
lanza pushed a commit that referenced this pull request Nov 5, 2024
This PR adds the following operations for the builtin binary fp2fp
functions:

  - `cir.copysign` for `__builtin_copysign`;
  - `cir.fmax` for `__builtin_fmax`;
  - `cir.fmin` for `__builtin_fmin`;
  - `cir.fmod` for `__builtin_fmod`;
  - `cir.pow` for `__builtin_pow`.

This PR also includes CIRGen support for these new operations.
lanza pushed a commit that referenced this pull request Nov 5, 2024
LLVM lowering for the following operations is introduced in #616 and
#651: `cos`, `exp`, `exp2`, `log`, `log10`, `log2`, `sin`, `sqrt`,
`fmod`, and `pow`. However, they are not lowered to their corresponding
LLVM intrinsics; instead they are transformed to libc calls during
lowering prepare. This does not match the upstream behavior.

This PR tries to correct this mistake. It makes all CIR FP intrinsic ops
lower to their corresponding LLVM intrinsics (`fmod` is a special case
and it is lowered to the `frem` LLVM instruction).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants