66 Commits

Author SHA1 Message Date
yronglin
b294951e39
[clang][bytecode] Fix the handling of address of a vector (#106558)
The PR https://github.com/llvm/llvm-project/pull/105996 broke taking the
address of a vector:

**compound-literal.c**
```C
typedef int v4i32 __attribute((vector_size(16)));
v4i32 *y = &(v4i32){1,2,3,4};
```
That because the current interpreter handle vector unary operator as a
fallback when the generic code path fail. but the new interpreter was
not. we need to handle `UO_AddrOf` in
`Compiler<Emitter>::VisitVectorUnaryOperator`.

Signed-off-by: yronglin <yronglin777@gmail.com>
2024-08-30 17:34:00 +08:00
yronglin
ee0d706338
[clang][bytecode] Implement constexpr vector unary operators +, -, ~, ! (#105996)
Implement constexpr vector unary operators +, -, ~ and ! .

- Follow the current constant interpreter. All of our boolean operations
on vector types should be '-1' for the 'truth' type.
- Move the following functions from `Sema` to `ASTContext`, because we
used it in new interpreter.
```C++
QualType GetSignedVectorType(QualType V);
QualType GetSignedSizelessVectorType(QualType V);
```

---------

Signed-off-by: yronglin <yronglin777@gmail.com>
2024-08-29 06:10:30 +08:00
Timm Baeder
2f144ac5a1
[clang][bytecode][NFC] Remove containsErrors check from visitInitializer (#105811) 2024-08-23 14:28:52 +02:00
Timm Baeder
7b4b85b75d
[clang][bytecode] Reject void InitListExpr differently (#105802)
This reverts c79d1fa540390f6e37e1ea326153559eeadd0de6 and
125aa10b3d645bd26523a1bc321bb2e6b1cf04e1

Instead, use the previous approach but allow void-typed InitListExprs
with 0 initializers.
2024-08-23 11:56:42 +02:00
Timm Baeder
38b8e54682
[clang][bytecode][NFC] Remove containsErrors() check from delegate (#105804)
This check was removed a while ago from visit(), remove it from
delegate() as well.
2024-08-23 11:55:30 +02:00
Timm Baeder
b9c4c4ccf9
[clang][bytecode] Fix 'if consteval' in non-constant contexts (#104707)
The previous code made this a compile-time decision but it's not.
2024-08-22 19:06:09 +02:00
Timm Baeder
db94852b9b
[clang][bytecode] Allow adding offsets to function pointers (#105641)
Convert them to Pointers, do the offset calculation and then convert
them back to function pointers.
2024-08-22 15:23:50 +02:00
Timm Baeder
125aa10b3d
[clang][bytecode] Fix void unary * operators (#105640)
Discard the subexpr.
2024-08-22 14:05:17 +02:00
Timm Baeder
c79d1fa540
[clang][bytecode] Don't discard all void-typed expressions (#105625)
For void-types InitListExprs, we need to diagnose them as invalid. But
only if we are _not_ discarding.
2024-08-22 09:51:16 +02:00
Timm Baeder
a14c730990
[clang][bytecode] Fix diagnostic in final ltor cast (#105292)
Don't diagnose volatile reads but diagnose a few other accesses earlier.
2024-08-21 08:08:32 +02:00
Timm Baeder
c99347a9f5
[clang][bytecode] Fix discarding CompoundLiteralExprs (#104909) 2024-08-20 12:41:13 +02:00
Timm Baeder
ba7dadf0e9
[clang][bytecode] Fix initializing base casts (#104901)
Use delegate() there. To fix a follow-up problem, abort when a cast ends
up on a valid Pointer that isn't a base class.
2024-08-20 11:44:30 +02:00
Timm Baeder
ca148b2150
[clang][bytecode] Support ObjC blocks (#104551)
I started out by adding a new pointer type for blocks, and I was fully
prepared to compile their AST to bytecode and later call them.

... then I found out that the current interpreter doesn't support
calling blocks at all. So we reuse `Function` to support sources other
than `FunctionDecl`s and classify `BlockPointerType` as `PT_FnPtr`.
2024-08-20 06:08:53 +02:00
Timm Baeder
d27278a835
[clang][bytecode] Discard NullToPointer cast SubExpr (#104782)
So we still properly abort if they fail.
2024-08-19 17:51:27 +02:00
Timm Bäder
d082f1f37d [clang][bytecode] Only booleans can be inverted
No need to have the Inv() function be templated.
2024-08-18 16:02:32 +02:00
Timm Baeder
a07aba5d44
[clang] Rename all AST/Interp stuff to AST/ByteCode (#104552)
"Interp" clashes with the clang interpreter and people often confuse
this.
2024-08-16 17:13:12 +02:00