Commit Graph

3801 Commits

Author SHA1 Message Date
Ivan Krysak d3e22a2b05 CTokenEmitter: add #pragma once helper 2026-04-22 06:33:56 +00:00
Ivan Krysak 6d76908858 Introduce TypeDefinitionEmitter 2026-04-22 06:33:38 +00:00
Ivan Krysak d327cd3be5 emitCAttributes: introduce an array overload 2026-04-22 06:14:52 +00:00
Ivan Krysak c3b870beee CEmitter: make function prototype commentable
This wraps pieces of it (arguments and return value) into a commentable
region showing the UI where to direct the `"comment"` action.
2026-04-22 06:14:52 +00:00
Ivan Krysak 3e63412e8c CEmitter: make return value scope
This commit should be viewed in conjunction with the following one,
separating white-space only changes makes the next commit less noisy.
2026-04-22 06:14:52 +00:00
Ivan Krysak f69a0345b7 CTokenEmitter: introduce Commentable region 2026-04-22 06:14:52 +00:00
Ivan Krysak 9167153303 Only allow unit attributes on function operations 2026-04-22 06:14:52 +00:00
Ivan Krysak 58cff91c3b CTokenEmitter: allow identifiers in comments 2026-04-22 06:14:52 +00:00
Ivan Krysak 2f692a7265 Fix unnecessary _CAN_CONTAIN_CODE bug 2026-04-22 06:14:52 +00:00
Ivan Krysak f3df0e20b9 Minor improvements 2026-04-21 07:54:50 +00:00
Andrea Gussoni 8a87c034a8 EmitFieldAccesses: re-run on indirection
Re-run the emit-field-accesses if any replacement propagates a type
through an IndirectionOp. This is needed to discover new rewriting
opportunities enabled by the newly typed pointers.
2026-04-14 09:50:48 +02:00
Andrea Gussoni 0e63c46930 EmitFieldAccesses: propagate through indirection
After a replacement, check if the replaced value feeds into an
IndirectionOp. If the "rich" pre-bitcast value has a ptr<ptr<T>>
type, create a new typed IndirectionOp and insert a fixup bitcast
for existing non-lvalue uses. Lvalue uses (assign LHS) stay on the
old indirection to preserve type and lvalue constraints.

Returns true if propagation occurred, signaling the EFA driver to
rerun and discover new rewriting opportunities.
2026-04-14 09:50:48 +02:00
Andrea Gussoni e0a9f4f484 EmitFieldAccesses: ignore qualifiers on Types 2026-04-14 09:24:48 +02:00
Pietro Fezzardi e399f381ea CommonTypeMethods: add getters for function types 2026-04-10 15:27:24 +02:00
Pietro Fezzardi 762e3e9def Better RecursivelyDeleteTriviallyDeadInstructions 2026-04-10 15:27:24 +02:00
Pietro Fezzardi 74e3a6873e BeautifyGHAST: use mayHaveSideEffects() method 2026-04-10 15:27:24 +02:00
Pietro Fezzardi 6e3afe097b PromoteCSVs: drop unused Initializers member 2026-04-10 15:27:24 +02:00
Pietro Fezzardi 23bd3f6c46 ExitSSA: don't declare to preserve the CFG 2026-04-10 15:27:24 +02:00
Pietro Fezzardi cc441ccd5c ExitSSA: fix insertion point past PHIs
Before this commit, the insertion point for load instructions was being
set before a PHINode, causing the IR to temporarily fail verification.
The effect of this logic bug did not propagate outside the pass, because
all PHINodes are removed at the end of the pass, but it made debugging
harder.

This commit fixes the problem by always setting the insert point after
all the PHINodes.
2026-04-10 15:27:24 +02:00
Pietro Fezzardi 59f91dcfc0 MakeModelGEP: drop unnecessary includes 2026-04-10 15:27:24 +02:00
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