Commit Graph

3781 Commits

Author SHA1 Message Date
Giacomo Vercesi 90e8cce41e model: rework python mixin infrastructure
Rework the python mixin infrastructure for the model. Mixins are now
specified explicitly instead of using the `ast` module. The mixins are
loaded relative to the generated python file, this allows to have two
models: `revng.model` and `revng.project.model`. The latter is augmented
via mixins to have project-specific facilities such as `get_artifact`
and artifact accessors.
2026-04-10 11:45:12 +02:00
Lauri Vasama c18164c25d Simplify IndentingEmitter; make configurable 2026-04-09 18:37:46 +03:00
Lauri Vasama cacaa9fff1 Fix CTokenEmitter::CommentEmitter newlines 2026-04-09 18:37:46 +03:00
Lauri Vasama 553c740e2d Remove pointers to array in model type import
Pointers to array of T are now converted to pointers to T.
2026-04-08 12:32:18 +03:00
Lauri Vasama 8085a1e8e9 Improve integer literal emission 2026-04-08 12:31:45 +03:00
Lauri Vasama 4cadcafa2c Move operand constraints from C++ to tablegen 2026-04-08 12:30:31 +03:00
Lauri Vasama 0e7703e312 CBackend null pointer constant 2026-04-08 12:29:58 +03:00
Lauri Vasama d35e54627c Add Clift ValueType interface
Value types is the set of non-array object types. These types are
assignable, can be used as function parameters, and as return types
(along with void), and in other scenarios where the type must have usual
value-like behaviour with no weirdness (such as array decay).
2026-04-08 12:28:45 +03:00
Lauri Vasama 80731d1a10 Migrate users to new Clift type casts 2026-04-08 12:27:32 +03:00
Lauri Vasama fb3cdbdf38 Rename ValueType to AddressableType 2026-04-08 12:26:18 +03:00
Lauri Vasama 29c935ac90 Replace Clift type category helpers with casts 2026-04-08 12:25:04 +03:00
Lauri Vasama db2b57e867 Add Clift ObjectType type interface 2026-04-08 12:22:33 +03:00
Lauri Vasama 92ad229ff0 Move BytecodeClassAttr into a separate file 2026-04-08 12:21:16 +03:00
Lauri Vasama 9ba90e9b81 Replace ValueType with mlir::Type where applicable
`mlir::Type` is now used as the default C++ type for representing all
MLIR types, even when `ValueType` would be a valid constraint, unless
doing so provides a clear benefit in that specific context.
2026-04-08 12:20:00 +03:00
Lauri Vasama f9a4cb6384 Split up clift::dealias
* `unwrapTypedefs` matches `dealias(T, /*IgnoreQualifiers=*/true)`.
* `collapseTypedefs` matches `dealias(T)`.
2026-04-08 12:18:42 +03:00
Lauri Vasama be8351a17d Split up Clift PrimitiveType
* PrimitiveType is now an interface.
* VoidKind is now VoidType.
* FloatKind is now FloatType.
* The integer kinds are now IntegerType with IntegerKind.
2026-04-08 12:18:10 +03:00
Lauri Vasama a2be1b476a Split up Clift CastOp
* DecayOp - array or function to pointer decay. Not shown in C.
* BitCastOp - bit-preserving conversion. Emitted as bit_cast if
  necessary.
* ExtendOp - zero- or sign-extending conversion from any integer type to
  any wider integer type.
* TruncateOp - truncating conversion from any integer type to any
  narrower integer type.
* PtrResizeOp - resizes a pointer without changing its pointee type.
2026-04-08 12:11:54 +03:00
Lauri Vasama 89fd0ee909 Use getObjectSize in EmitFieldAccesses 2026-04-08 11:13:44 +03:00
Lauri Vasama 4cd4de4f83 Improve Clift type tablegen definitions 2026-04-08 11:12:41 +03:00
Lauri Vasama 82ae097c18 Improve Clift operation type constraints 2026-04-08 11:12:41 +03:00
Lauri Vasama 5198af8ba7 Improve Clift free function type property helpers 2026-04-08 11:12:41 +03:00
Lauri Vasama 7219a9f795 Improve clift::isCompleteType 2026-04-08 11:12:41 +03:00
Lauri Vasama 8e72ad8e48 Improve Clift module verification 2026-04-08 11:12:41 +03:00
Lauri Vasama a37f3195d9 Homogenize static assertions in primitive-types.h 2026-04-08 11:12:41 +03:00
Lauri Vasama b062b23ad6 Include stddef.h in primitive-types.h 2026-04-08 11:12:41 +03:00
Lauri Vasama c0ca9222ce Fix Clift immediate emission 2026-04-08 11:12:41 +03:00
Lauri Vasama 90658bbbed Change default C target size of long
Currently there is only a single default target used for all C emission.
However, the emitted code is actually compiled using multiple
implementations (32-bit and 64-bit targets), some of which use a 32-bit
wide long. This causes integer literals to be emitted with wrong sizes
on those targets. This change forces all 64-bit literals to be emitted
using long long, which is 64 bits wide in all relevant implementations.
2026-04-08 11:12:41 +03:00
Lauri Vasama 71f1fa128a Remove unnecessary function type verification 2026-04-08 11:12:41 +03:00
Lauri Vasama 4e4d3bab46 Remove namespace mlir using directives 2026-04-08 11:12:41 +03:00
Lauri Vasama c0b774369b Remove bad comment in CliftOpInterfaces.cpp 2026-04-08 11:12:41 +03:00
Lauri Vasama de0e59b188 Move FunctionOp arg attr verify to model verify 2026-04-08 11:12:41 +03:00
Giacomo Vercesi b40fec2270 Add LLMRename analysis to pypeline 2026-03-31 17:00:48 +02:00
Giacomo Vercesi 14d95a924d pypeline: rework fields in pipeline metadata
Rework which information is transmitted in the pipeline metadata,
avoiding redundancy and moving some information there instead of
returning it every time a request is made.
2026-03-31 17:00:48 +02:00
Andrea Gussoni fab35aaa24 EmitFieldAccesses: unwrap typedef in subscript
Use a `bitcast` to unwrap a `typedef` passed as `Pointer` operand to a
`subscript`, which requires it to be a raw `PointerType`.
2026-03-30 16:03:37 +02:00
Andrea Gussoni 82945de055 EmitFieldAccesses: support pointer as array
Introduce the support to decouple the `BaseType` from `BasePointer`
pointee type.

This enable us to wrap pointee typees into an implicit array. This
enables pointer arithmetic rewriting of `*(p + i)` as `p[i]`.
2026-03-30 16:03:37 +02:00
Ivan Krysak 1b689079d1 Clifter: enforce lambda captures 2026-03-27 14:11:04 +01:00
Lauri Vasama 9d58a4ab9d Clifter: make a warning louder and expand it 2026-03-27 14:10:17 +01:00
Ivan Krysak c354642902 Clifter: fix a newly introduced bug
This fixes the invalidation problem introduced by reading attributes
in the scope whose execution order depends on the function processing
order.
2026-03-27 12:27:26 +00:00
Ivan Krysak 6f02461948 Clift: fix missed getAttributes methods
They are now correctly named `getCAttributes`.
2026-03-27 12:27:16 +00:00
Ivan Krysak 1f5ca9f40e Clift: ensure _REG and _STACK are exclusive 2026-03-27 08:28:46 +00:00
Ivan Krysak 82e86cf167 Emit prototype attributes *before* the prototype 2026-03-27 08:27:52 +00:00
Ivan Krysak 5ca78e8897 emitCAttributes: improve spacing control 2026-03-27 08:27:23 +00:00
Ivan Krysak a03e944403 CEmitter: emit unit attributes 2026-03-27 08:26:55 +00:00
Ivan Krysak 378bfb650f CliftEmitC: Attributes -> CAttributes 2026-03-27 08:22:23 +00:00
Ivan Krysak de31315cd7 Model: rename Inline into AlwaysInline 2026-03-27 08:16:21 +00:00
Ivan Krysak 19741a32ab ImportModel: expose a high level type importer 2026-03-27 08:15:23 +00:00
Ivan Krysak 35fe2309c3 import-types: use clift.types as the attribute
Before this, `clift.test` was used
2026-03-27 08:14:53 +00:00
Ivan Krysak 756c097900 Import dynamic function prototype 2026-03-27 08:14:22 +00:00
Ivan Krysak cbfa009aa4 Factor function prototype importing out 2026-03-27 08:13:52 +00:00
Ivan Krysak 882fed11ad emitFunctionPrototype: simplify helper handling 2026-03-27 08:13:25 +00:00