39 Commits

Author SHA1 Message Date
Timm Baeder
d9671bba3e
[clang][Interp] Implement __builtin_ffs (#72988) 2023-12-12 15:59:39 +01:00
Timm Baeder
43e6aec145
[clang][Interp] Implement __builtin_rotate{right,left} (#72984) 2023-12-12 10:48:00 +01:00
Timm Baeder
d5e2cbd01a
[clang][Interp] Implement builtin_expect (#69713) 2023-12-08 14:46:25 +01:00
Timm Baeder
965d301dff
[clang][Interp] Implement __builtin_classify_type (#71972)
This adds some infrastructure for unevaluated builtin calls, and uses the implementation from ExprConstant.cpp
2023-11-17 16:13:23 +01:00
Timm Baeder
3defe8facc
[clang][Interp] Implement __builtin_bitreverse (#71687)
Since the return value of this function is slightly more involved than
the void/bool/int/size_t return values we've seen so far, also refactor
this.
2023-11-17 08:29:13 +01:00
Timm Baeder
bffa8e1d1a
[clang][Interp] Implement __builtin_clrsb (#72243) 2023-11-16 07:30:54 +01:00
Timm Baeder
0f8c51a523
[clang][Interp] Implement __builtin_parity (#71662) 2023-11-16 06:24:04 +01:00
Serge Pavlov
fc7198b799
[clang] Additional FP classification functions (#69041)
C language standard defined library functions `iszero`, `issignaling`
and `issubnormal`, which did not have counterparts among clang builtin
functions. This change adds new functions:

    __builtin_iszero
    __builtin_issubnormal
    __builtin_issignaling

They provide builtin implementation for the missing standard functions.

Pull request: https://github.com/llvm/llvm-project/pull/69041
2023-11-01 12:10:54 +07:00
Timm Baeder
7f677fe310
[clang][Interp] Add explicit dummy descriptors (#68888)
Instead of (ab)using incomplete array types for this, add a 'Dummy' bit
to Descriptor. We need to be able to differentiate between the two when
adding an offset.
2023-10-26 15:15:25 +02:00
Timm Baeder
26d9f851cf
[clang][Interp] Add basic support for _BitInt (#68069)
Make sure we pass the expected bitwidth around when casting to
IntAP/IntAPS.

This makes it easier to test the `IntegralAP` code for different bit
widths than 128.
2023-10-11 08:53:21 +02:00
Timm Baeder
9aedb60c70
[clang][Interp] Implement __builtin_popcount() (#67929) 2023-10-02 17:14:31 +02:00
Timm Baeder
512739ebbb
[clang][Interp] Three-way comparisons (#65901) 2023-09-29 09:41:58 +02:00
Timm Bäder
87461d6696 [clang][Interp] Implement __builtin_offsetof
Differential Revision: https://reviews.llvm.org/D156400
2023-09-11 12:03:47 +02:00
Timm Bäder
673ef8ceae Re-land "[clang][Interp] Make sure we push integers of the correct size"
This also re-reverts the commit implementing __builtin_strlen.

I was unable to reproduce the msan issue with an msan-enabled build (for
infrastructure reasons), but I think fixing the target-dependent int
sizes in the implementation of __builtin_fpclassify should work.
2023-08-18 10:25:54 +02:00
Vitaly Buka
e03686f4a3 Revert "[clang][Interp] Make sure we push integers of the correct size"
Revert "[clang][Interp] Implement __builtin_strlen"

Fails Msan. Details in https://reviews.llvm.org/D155568

This reverts commit d425720aed48fd2c058a126ac961576d48c9732b.
This reverts commit 91af0d0a669880918eda2d2bd2d6185b2903a402.
2023-08-17 18:12:02 -07:00
Timm Bäder
d425720aed [clang][Interp] Implement __builtin_strlen
Differential Revision: https://reviews.llvm.org/D156042
2023-08-17 13:10:46 +02:00
Timm Bäder
91af0d0a66 [clang][Interp] Make sure we push integers of the correct size
Integers might not be 32 bits wide, so check the TargetInfo for their
size.

Differential Revision: https://reviews.llvm.org/D155568
2023-08-17 10:36:06 +02:00
Timm Bäder
8a25145058 [clang][Interp] Pass CallExpr to builtin functions
For some builtins, we need to do quite a bit of type checking ourselves,
so pass the call expression along. This way we can inspect arguments,
expected return value, etc.

Differential Revision: https://reviews.llvm.org/D155545
2023-08-17 10:20:58 +02:00
Timm Bäder
89e44e33ed [clang][Interp] Implement __builtin_fmax
Differential Revision: https://reviews.llvm.org/D155401
2023-08-01 17:45:24 +02:00
Timm Bäder
1684406e63 [clang][Interp] Implement __builtin_fabs()
Differential Revision: https://reviews.llvm.org/D155400
2023-08-01 16:32:29 +02:00
Timm Bäder
5821351343 [clang][Interp] Implement __builtin_fpclassify
Differential Revision: https://reviews.llvm.org/D155394
2023-08-01 16:02:15 +02:00
Timm Bäder
6ba4b21334 [clang][Interp] Implement __builtin_isfpclass 2023-08-01 15:25:22 +02:00
Timm Bäder
d37f1e9965 [clang][Interp] Implement __builtin_isnormal
Differential Revision: https://reviews.llvm.org/D155374
2023-07-31 09:14:16 +02:00
Timm Bäder
f444f39686 [clang][Interp] Implement __builtin_isfinite
Differential Revision: https://reviews.llvm.org/D155372
2023-07-31 09:12:32 +02:00
Timm Bäder
72450a7793 [clang][Interp] Implement __builtin_isinf
Differential Revision: https://reviews.llvm.org/D155371
2023-07-31 08:49:22 +02:00
Timm Bäder
ff80fc0ea2 [clang][Interp] Implement __builtin_isnan()
The previous version was using llvm::reverse(CallExpr::arguments()),
which causes problems when clang is compiled with GCC.

Differential Revision: https://reviews.llvm.org/D155369
2023-07-29 10:48:10 +02:00
Timm Bäder
9016514c6b Revert "[clang][Interp] Implement __builtin_isnan()"
This reverts commit 8ad9dcb3869394e3a4ecb01631646237074723fe.

This breaks builders:
https://lab.llvm.org/buildbot/#/builders/139/builds/46363/steps/6/logs/FAIL__Clang__constant-builtins-fmin_cpp

Revert while I figure out what's going wrong.
2023-07-28 20:59:38 +02:00
Timm Bäder
8ad9dcb386 [clang][Interp] Implement __builtin_isnan()
Differential Revision: https://reviews.llvm.org/D155369
2023-07-28 20:49:45 +02:00
Timm Bäder
c14c34de45 [clang][Interp] Implement __builtin_fmin
Differential Revision: https://reviews.llvm.org/D155546
2023-07-28 20:18:57 +02:00
Timm Bäder
57ca62d5d3 [clang][Interp] Implement __builtin_copysign
Differential Revision: https://reviews.llvm.org/D155368
2023-07-28 10:55:34 +02:00
Timm Bäder
b395e91f2e [clang][Interp] Implement __builtin_inf() etc.
Differential Revision: https://reviews.llvm.org/D155367
2023-07-28 10:50:13 +02:00
Timm Bäder
c2273e33bd [clang][Interp] Implement __builtin_nan family
Differential Revision: https://reviews.llvm.org/D155356
2023-07-28 10:28:55 +02:00
Timm Bäder
e9eb8362f0 [clang][Interp][NFC] Add an assertion 2023-07-26 11:50:07 +02:00
Timm Bäder
d913aa6971 [clang][Interp][NFC] Make a local function static 2023-07-26 11:50:07 +02:00
Timm Bäder
ae667f03d3 [clang][Interp][NFC] Take a const InterpFrame* in InterpBuiltin.cpp 2023-07-26 10:06:26 +02:00
Timm Bäder
8a4bbeb916 [clang][Interp] Remove args from called functions in more cases
When calling functions in the checkingPotentialConstantExpression mode,
we cannot have arguments (including This + RVO pointers) for the
toplevel callee, but the functions called from within can work just
fine, or at least we succeed in pushing their arguments on the stack, so
we must also succeed in removing them again.

Differential Revision: https://reviews.llvm.org/D150358
2023-07-26 08:47:54 +02:00
Timm Bäder
eaadbcd5e0 [clang][Interp] Implement __builtin_strcmp
Make our Function class keep a list of parameter offsets so we can
simply get a parameter by index when evaluating builtin functions.

Differential Revision: https://reviews.llvm.org/D149816
2023-07-20 15:46:04 +02:00
Timm Bäder
760136ff13 [clang][Interp] Implement __builtin_assume
Just ignore it.

As part of this, move the Ret and RetVoid implementation to Interp.h, so
they can be shared with InterpBuiltin.cpp.

Differential Revision: https://reviews.llvm.org/D141193
2023-01-27 07:54:37 +01:00
Timm Bäder
a7a4463acb [clang][Interp] Start implementing builtin functions
Differential Revision: https://reviews.llvm.org/D137487
2023-01-25 14:08:03 +01:00