Commit Graph

2939 Commits

Author SHA1 Message Date
Lauri Vasama c92f34b409 Add FunctionOp::getCliftReturnType 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 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
Giacomo Vercesi 79d20d343b FilePath: fix addExtension
When working with `stdin` and `stdout`, the `addExtension` function
should return std::nullopt, since concatenating files is undesirable.
This fixes a bug where the output of the `StringMap` container would
have the index file appended to it, rendering an invalid tar.
2025-06-27 17:12:18 +02:00
Andrea Gussoni a93b8b7044 RegionCFGTree: introduce soft failure
Soft fail for `inflate`.
2025-06-26 12:02:38 +02:00
Giacomo Vercesi d62b7b6b1a TTG: inline root type in schema
Move the root type inside the schema definition, as it is a property of
it and not of the generator.
2025-06-25 15:40:13 +02:00
Andrea Gussoni 82c66fd4ca BeautifyGHAST: early return failure handling 2025-06-23 12:00:59 +02:00
Andrea Gussoni 6a6db9e00f GenerateAST: introduce soft failure
Soft fail for `createSwitchTile`.
2025-06-23 12:00:59 +02:00
Andrea Gussoni a521b9d760 RegionCFGTree: introduce soft failure
Soft fail for `insertBulkNodes`.
2025-06-20 13:38:05 +02:00
Andrea Gussoni 7550753081 ASTTree: introduce soft failure
Soft fail for `copyASTNodesFrom`.
2025-06-20 10:29:04 +02:00
Andrea Gussoni e2c7404218 RegionCFGTree: introduce soft failure
Soft fail for `purgeIfTrivialDummy`.
2025-06-20 10:15:46 +02:00
Andrea Gussoni 12bf4e7db0 RestructureCFG: fail on unexpected dummy purge
When attempting to simplify away a dummy that simply connects a
Predecessor and a Successor, fail if Predecessor and Successor are
already connected.

In order to handle such failure, we need to decorate a lot of function
on the stack trace in order to be able to propagate the failure code.
2025-06-19 11:36:49 +02:00
Andrea Gussoni da31adc83c ASTTree: clear internal fields on constructor 2025-06-19 09:48:39 +02:00
Andrea Gussoni 333903e86e ScopeGraph: ScopeGraphBuilder const methods 2025-06-12 15:31:38 +02:00
Lauri Vasama 4bf1d8fe99 Remove Clift backend transform and model option 2025-06-04 15:13:47 +02:00
Lauri Vasama 7c9031bd98 Change MLIRContainer to focus on Clift, rename 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 fdbc7b57fb Add SwitchOp::getCaseRegions 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 51c4ed8201 Make Clift.td formatting more consistent 2025-06-04 15:13:47 +02:00
Lauri Vasama 206de51c69 Add API for helper PTML references by name
The Clift backend does not have access to any llvm::Function objects so
the helper C identifiers must be derived from the helper name alone.
2025-06-04 15:13:47 +02:00
Lauri Vasama 6f3c8ee418 Add PrimitiveType builder with default const=false 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 d17d23b8fc Add getHandle on GlobalOpInterface 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 c44df5d591 Improve CliftOpInterfaces formatting consistency 2025-06-04 15:13:47 +02:00
Lauri Vasama 957150915c Fix LocalVariableHelpers const correctness 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 460af9d7d4 Use full paths for Clift .td includes 2025-06-04 15:13:47 +02:00
Pietro Fezzardi df3b4758e4 Add initModeTypesConsideringUses
Before this commit, initModelTypes always looked at uses of each
instructions to see if its knowledge of the instruction's model type
could be improved.

This is useful in some cases, but it's detrimental when building model
casts, because this requires to see the exact type computed for an
instruction.

This commit introduces a new function initModeTypesConsideringUses,
which works like old initModelTypes, considering uses.
In this way we can make sure that uses are considered when necessary,
like when computing types to build new local variables, and ignored when
necessary, e.g. when building model casts.
2025-05-29 09:38:01 +02:00
Pietro Fezzardi e50bd12519 Drop unused printInlineDefinition 2025-05-29 09:31:26 +02:00
Pietro Fezzardi c66da0ab65 DependencyGraph: drop getDeclaration/getDefinition
These methods are now unused after the recent refactoring.
2025-05-29 09:31:26 +02:00
Pietro Fezzardi 0b977b85d6 DependencyGraph: add view() debug_function method
to open the graphviz visualization.
2025-05-29 09:31:26 +02:00
Pietro Fezzardi a71db5d243 DependencyGraph: refactor creation of nodes/edges 2025-05-28 17:11:57 +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 c4b637eaa4 DependencyGraph: hide all non-const methods
This commits wraps all the machinery that can mutate a DependencyGraph
inside the interval factory class DependencyGraph::Builder.
In this way, once a DependencyGraph is created, it cannot be mutated by
accident from outside.
This is important because mutating it from outside makes it easy to
break the consistency of internal maps.
This risk will only increase when supporting artificial struct wrapper
types, so we encapsulate this now to prevent issues in the future.
2025-05-28 17:11:49 +02:00
Pietro Fezzardi 2331f10282 DependencyGraph: add new factory method and class 2025-05-28 17:11:11 +02:00
Pietro Fezzardi 660cb89eb5 DepenencyGraph: introduce AssociatedNodes
This data structure is used to bind together a pair of pointers to
TypeDependencyNode, one referring to a declaration of a type and the
other referring to a definition of the same type.

The definition can be null if the type referred to is a type without an
explicit definition (e.g. typedefs), while it's never null for types
for which have forward declaration that is separate from the definition
(e.g. structs and unions).
2025-05-28 17:11:11 +02:00
Pietro Fezzardi a4d45d0788 Add abi::FunctionType::Layout::argumentTypes 2025-05-28 17:11:11 +02:00
Pietro Fezzardi 7aab7ba843 Add abi::FunctionType::Layout::returnValueTypes 2025-05-28 17:11:11 +02:00
Pietro Fezzardi e51fcfc01a DependencyGraph: add TypeNode helper methods 2025-05-28 17:11:11 +02:00
Pietro Fezzardi 28f180dcb8 Rename CTypeBuilder::printTypeDefinition
to printDefinition.
2025-05-28 17:11:11 +02:00
Pietro Fezzardi ec0c56abcc Rename CTypeBuilder::printTypeDeclaration
to printDeclaration.
2025-05-28 17:11:11 +02:00
Pietro Fezzardi 8c7a800de1 Rename CTypeBuilder::printForwardTypeDeclaration
to printForwardDeclaration.
2025-05-28 17:11:11 +02:00
Pietro Fezzardi f353af775e TypeNode: add entries for artificial wrappers
This commit adds two enum entries to TypeNode::Kind to represent forward
declarations and definitions of artificial struct wrappers, that are not
present in the model but that we're forced to print in C to overcome
its limitations in representing types.

At the moment, this is only going to be used for representing return
types of RawFunctionDefinitions whose Layout returns RegisterSet, which
can't be represented in C without a wrapper.
2025-05-28 17:11:11 +02:00