Commit Graph

169 Commits

Author SHA1 Message Date
Ivan Krysak 290d2e2c57 ptml::CTypeBuilder: rename into ModelCBuilder 2025-07-23 11:38:53 +02:00
Ivan Krysak 742bda05ba New backend: adopt new variable and label tagging 2025-07-23 11:38:51 +02:00
Ivan Krysak c7c61dbc04 New backend: drop leading _ in variable names 2025-07-23 11:38:51 +02:00
Lauri Vasama 780e774b20 Add Clift legalization pipe 2025-07-17 16:45:03 +02:00
Lauri Vasama 4e17287cfc Add LLVM-to-Clift import 2025-07-17 16:45:03 +02:00
Lauri Vasama b9ce0a87df Add Clift model verification 2025-07-17 16:45:03 +02:00
Lauri Vasama abc842a87e Change undef expression emission
```
// Old output:
/* undef */ (T){0}

// New output:
undef_T()
```

This matches the output emitted by the old backend.
2025-07-17 16:45:03 +02:00
Lauri Vasama fa184b9212 Add Clift backend support for pointer sizes 2025-07-17 16:45:03 +02:00
Lauri Vasama eb4e96dcdf Fix Clift backend names emission
This commit fixes name emission for different kinds of entities such as
artificial RFT return type structs and helper function return types.
2025-07-17 16:45:03 +02:00
Lauri Vasama 183f045616 Fix CliftAttributes abort message 2025-07-17 16:45:03 +02:00
Lauri Vasama 237d246665 Factor out the default C target implementation
This commit also adds size 16 -> extended integer kind mapping.

While we are hardcoding this for now, some maintenance (as above) is
needed, so it's best to hardcode it only in one place and share that
definition.
2025-07-17 16:45:03 +02:00
Lauri Vasama 8411dd4361 Fix emission of labels before declarations
A semicolon is needed after a label if it precedes a declaration.
2025-07-17 16:45:03 +02:00
Lauri Vasama 3b58a5bf4e Fix StackArgumentsType to Clift import
The stack argument was previously imported as a pointer.
2025-07-17 16:45:03 +02:00
Lauri Vasama d14365220b Fix DefinedType uniqueness verification
T and const T were detected as distinct types.
2025-07-17 16:45:03 +02:00
Lauri Vasama 50a96527cd Add PtrAdd/PtrSub operand helpers 2025-07-17 16:45:03 +02:00
Lauri Vasama fc682383e9 Implement Clift bytecode
Fixes bytecode emission of class types with very large trees of members.
See the new unit test: union-with-large-tree.mlir .
2025-07-17 16:45:03 +02:00
Lauri Vasama 936c0106e4 Add truncate/extend between pointers 2025-07-17 16:45:03 +02:00
Lauri Vasama d2e83b30a1 Add clift::getPointerType 2025-07-17 16:45:03 +02:00
Lauri Vasama 50c3c8f95a Fix Clift union recursion parsing issue 2025-07-17 16:45:03 +02:00
Lauri Vasama 4bf1d8fe99 Remove Clift backend transform and model option 2025-06-04 15:13:47 +02:00
Lauri Vasama d21325ef55 Remove model dependency in CliftTypes.cpp 2025-06-04 15:13:47 +02:00
Lauri Vasama 13b554d64a Remove unused include in CliftOps.cpp 2025-06-04 15:13:47 +02:00
Lauri Vasama cc94e2d290 Constrain returnable types 2025-06-04 15:13:47 +02:00
Lauri Vasama 047511b1ed Remove Clift break and continue ops 2025-06-04 15:13:47 +02:00
Lauri Vasama 3e065cb23d Remove local and label names 2025-06-04 15:13:47 +02:00
Lauri Vasama a0ec1305f1 Move ReturnOp type verification to FunctionOp 2025-06-04 15:13:47 +02:00
Lauri Vasama f0091e699f Remove clift::ModuleOp
A new dialect attribute is instead used to verify mlir::ModuleOp:

```
module attributes {clift.module} {
}
```
2025-06-04 15:13:47 +02:00
Lauri Vasama a7eb86174b Add revng/Support/Identifier.h for id validation 2025-06-04 15:13:47 +02:00
Lauri Vasama d1dfbc4b01 Emit implicit switch breaks from Clift 2025-06-04 15:13:47 +02:00
Lauri Vasama 137bb6f95b Fix register set member access emission 2025-06-04 15:13:47 +02:00
Lauri Vasama f94b28b7e4 Add missing newline after if without else 2025-06-04 15:13:47 +02:00
Lauri Vasama a3ee0349a6 Inherit GlobalOpInterface from Symbol 2025-06-04 15:13:47 +02:00
Lauri Vasama 81dcea49e4 Fix printing of CallOp on function pointer 2025-06-04 15:13:47 +02:00
Lauri Vasama 7273b0d1a1 Fix getOnlyOperation Clift backend 2025-06-04 15:13:47 +02:00
Lauri Vasama 276e43d050 Fix brace elision around gotos 2025-06-04 15:13:47 +02:00
Lauri Vasama 2bc4cec399 Fix MakeLabelOp canonicalization 2025-06-04 15:13:47 +02:00
Lauri Vasama 336b18d937 Overhaul Clift type syntax
* Removed syntax for defined type attributes.
* Added !clift.const<T> and removed const syntax from types kinds.
* Some restructuring of class type internals.
2025-06-04 15:13:47 +02:00
Lauri Vasama 0313350b7f Minor Clift.cpp cleanup 2025-06-04 15:13:47 +02:00
Pietro Fezzardi ea3cbe4c1b Drop type inlining
Type inlining was a feature that allowed type definitions of
structs/unions/enums to be printed in C directly inside the definition
of another parent struct/union, if the inner type was only used once in
the parent type.

This kind of reasoning is inherently global: a type definition of the
subtype can be inlined in the parent type one only if *globally* the
subtype it isn't referred anywhere else.

This caused issues with type inlining inside definitions of stack types
in the body of functions. Indeed, for a given function, due to type
inlining, it was necessary to do global reasoning about what other types
could be inlined in the definition of the function's stack frame type.
This, in turn, had heavy consequences on invalidation, because any
change to any type (even if it wasn't referred in a given function's
body) was causing invalidation of all functions' bodies.

For this reason it was decided to drop the type inlining feature.
2025-05-28 17:11:56 +02:00
Pietro Fezzardi 28f180dcb8 Rename CTypeBuilder::printTypeDefinition
to printDefinition.
2025-05-28 17:11:11 +02:00
Ivan Krysak c7bba8c1b9 Prevent Support headers from depending on PTML 2025-05-08 15:42:01 +02:00
Ivan Krysak eac296a99f Standardize PTML tag emission in c backend 2025-05-08 15:42:00 +02:00
Ivan Krysak 79964eac74 Avoid ' misuse in error messages and comments 2025-04-17 16:41:21 +02:00
Ivan Krysak 57b5eb7f98 NameBuilder: allow different name checkers 2025-04-17 11:19:17 +03:00
Ivan Krysak dce5c1a02c NamingConfiguration: pull more prefixes inside
Unify additional values that used to be hardcoded in the old backend
under the same naming configuration root.
2025-04-17 11:19:17 +03:00
Ivan Krysak 645cf7fc2e NameBuilder: sunset deduplication
This reworks NameBuilder to ease the transition to the system where
the model will be guaranteed to never contain any name collisions, both
between user-specified names and the automatic ones.
2025-04-15 16:35:42 +03:00
Ivan Krysak 3edb6cbb9b Minor improvements 2025-04-15 16:35:42 +03:00
Lauri Vasama 3ca3653333 Convert Clift type handles to use locations 2025-03-24 09:27:57 +02:00
Lauri Vasama d6a2ee387e Add aliases for Clift types without handles 2025-03-24 09:26:43 +02:00
Lauri Vasama e9c329e51d Rename Clift unique handle to handle 2025-03-24 09:26:43 +02:00