23 Commits

Author SHA1 Message Date
Timm Baeder
a5d9ba6625
[clang][bytecode] Error on bitcasts to bool that aren't 0 or 1 (#149996)
This is also what the current interpreter does.
2025-07-22 14:23:01 +02:00
Timm Baeder
767a203a9e
[clang][bytecode] Fix discarded LValueToRValueBitCasts (#140034)
We handle discarding fine, but we used to ignore all discarded cast
expressions. Handle bitcasts differently.
2025-05-15 13:17:29 +02:00
Timm Baeder
56fd46edb3
[clang][bytecode] Remove a bitcast nullptr_t special case (#120188)
We still need to check the input pointer, so let this go through
BitCastPrim.
2024-12-17 13:23:14 +01:00
Timm Baeder
0fb06172f1
[clang][bytecode] Check vector element types for eligibility (#119385)
Like we do in ExprConstant.cpp.
2024-12-10 17:56:48 +01:00
Timm Baeder
2f9cd43a73
[clang][bytecode] Check primitive bit casts for indeterminate bits (#118954)
Record bits ranges of initialized bits and check them in
allInitialized().
2024-12-06 15:50:59 +01:00
Timm Baeder
b6217f67a4
[clang][bytecode] Fix bitcasting from null pointers (#116999) 2024-12-05 13:13:59 +01:00
Timm Baeder
7aec6dc477
[clang][bytecode] Initialize bases when bitcasting (#117179)
Base pointers do not get passed to the callback, so initialize them when iterating bases.
2024-12-04 16:49:03 +01:00
Timm Bäder
12ca72ba7f Reapply "[clang][bytecode] Handle bitcasts involving bitfields (#116843)"
This reverts commit 54db16221c92eb52efbea90ad5b5d2a1d00cda3e.

Check for existence of __SIZOEF_INT128__ so we don't run those
tests on targets that don't have int128.
2024-12-04 11:53:37 +01:00
Timm Bäder
54db16221c Revert "[clang][bytecode] Handle bitcasts involving bitfields (#116843)"
This reverts commit 4b5e7fa4de54e00df007ae5e2675393fd046aa59.

This breaks builders:
https://lab.llvm.org/buildbot/#/builders/154/builds/8464

I guess some more testing on 32 bit hosts is needed.
2024-12-04 11:43:43 +01:00
Timm Baeder
4b5e7fa4de
[clang][bytecode] Handle bitcasts involving bitfields (#116843)
Copy the data one bit at a time, leaving optimizations for future work.
Adds a BitcastBuffer that takes care of pushing the bits in the right
order.
2024-12-04 11:25:04 +01:00
Timm Baeder
1425fa915d
[clang][bytecode] Check FromPtr in BitCastPtr (#117142) 2024-11-21 13:21:00 +01:00
Timm Baeder
476b208e01
[clang][bytecode] Fix ToType/FromType diagnostic ordering (#116988)
We need to check the ToType first, then the FromType. Additionally,
remove qualifiers from the parent type of the field we're emitting a
note for.
2024-11-21 07:54:38 +01:00
Oleksandr T.
b63b0101ca
[Clang] enhance diagnostic message for __builtin_bit_cast size mismatch (#115940)
Fixes #115870
2024-11-13 09:11:36 -05:00
Timm Baeder
1b3da362c5
[clang][bytecode] Fix bitcasting packed bool vectors (#114937)
This is a special case we need to handle. We don't do bitcasting _into_
such vectors yet though.
2024-11-05 11:43:09 +01:00
Timm Baeder
5f84b332ec
[clang][bytecode] Fix discarding __builtin_bit_cast calls (#114926)
Optionally prepare storage for the result and do the bitcast anyway, to
get the right diagnostic output.
2024-11-05 11:05:23 +01:00
Timm Baeder
2f13fbfcd1
[clang][bytecode] Support bitcasting into float fields (#114825) 2024-11-05 05:52:03 +01:00
Timm Baeder
2588b8be56
[clang][bytecode] Implement bitcasts to composite types (#114776)
Only fixed-size, non-bitfield integral fields for now.
2024-11-04 15:10:10 +01:00
Timm Baeder
5b32c5954b
[clang][bytecode] Implement bitcasts to floating-point values (#114485) (#114712)
This time I tested on big-endian hosts.
2024-11-03 19:42:26 +01:00
Timm Baeder
88823d08ab
[clang][bytecode][NFC] Switch BitcastBuffer to SmallVector (#114677)
This is a little easier to work with since we are guaranteed that the
item type of the vector is byte sized and not something else.
2024-11-03 11:16:59 +01:00
Timm Bäder
c2a892f49a Revert "[clang][bytecode] Implement bitcasts to floating-point values (#114485)"
This reverts commit c752efbdcc1ebd81f879633d6b798248064e2ae2.

This broke bots:
 - https://lab.llvm.org/buildbot/#/builders/13/builds/3268
 - https://lab.llvm.org/buildbot/#/builders/42/builds/1718
2024-11-02 01:54:38 +01:00
Timm Baeder
c752efbdcc
[clang][bytecode] Implement bitcasts to floating-point values (#114485) 2024-11-01 14:58:19 +01:00
Timm Baeder
1e19f0f9d9
[clang][bytecode] Implement IntegralAP bitcasting (#114471)
Only for full-byte bitwidths for now.
2024-11-01 09:15:05 +01:00
Timm Baeder
ef2a104c94
[clang][bytecode] Start implementing __builtin_bit_cast (#112126)
This is a subset of #68288, with hopefully narrower scope. It does not
support bitcasting to non-integral types yet.
Bitfields are supported, but only if they result in a full byte-sized
final buffer. It does not support casting from null-pointers yet or
casting from indeterminate bits.


The tests are from #68288 and partially from #74775.

The `BitcastBuffer` struct is currently always working in single bits,
but I plan to (try to) optimize this for the common full-byte case.
2024-10-31 18:09:40 +01:00