7705 Commits

Author SHA1 Message Date
Pietro Fezzardi 4b125fc6c8 CliftEmitC: emit trailing struct padding
The type emitter printed inter-field padding but never the padding
between the end of the last field and the declared size of the
struct.
Since every struct is emitted packed annotation, any struct with
trailing padding had a wrong sizeof in C.

This commit fixes the problem by always printing trailing padding in
structs, unless user have explicitly opted out setting `ExplicitPadding`
to off.
2026-06-15 17:28:22 +02:00
Alessandro Di Federico e4ba9ca989 Drop precedence-tests 2026-06-15 17:28:22 +02:00
Ivan Krysak 37c2cb12ed test-docs: use new pipeline 2026-06-15 17:28:22 +02:00
Ivan Krysak 17945bbe95 local_provider: improve an error message 2026-06-15 17:28:22 +02:00
Ivan Krysak 3aeb6c8b25 enum-field-access test: fix broken locations 2026-06-15 17:28:22 +02:00
Ivan Krysak 9418844aa3 Add a const serialization test 2026-06-15 17:28:22 +02:00
Lauri Vasama 15c5da73f2 Fix VoidType serialization 2026-06-15 17:28:22 +02:00
Ivan Krysak e02aa215fa makeNameAttr: soften the check
When de-serializing, MLIR pre-populates the value outside of our
control. As such, we cannot assert that it's always empty. So,
the least we can do is assert that value is the same.
2026-06-15 17:28:22 +02:00
Ivan Krysak 0d2ae728f3 makeNameAttr: better error message 2026-06-15 17:28:22 +02:00
Ivan Krysak a7820ae28b Simplify end-to-end c decompilation tests 2026-06-15 17:28:22 +02:00
Pietro Fezzardi ec5af3d5cb CliftImportModel: import symbol descriptive info
When importing descriptive info for a single function, the body walk
now intercepts clift::UseOp operations and follows the symbol
reference to find the target FunctionOp or GlobalVariableOp.

Before this commit, the per-function overload of importDescriptiveInfo
recorded the rename only for the current function (plus helpers and
globals at module level, but not via UseOp).

The deduplication logic makes it cheap and safe for a single FunctionOp
or GlobalVariableOp to be used in many UseOps without importing
descriptive info twice. The same holds if the FunctionOp is also visited
at module level and not just via UseOp, as is the case for
self-recursive functions.
2026-06-15 17:28:22 +02:00
Pietro Fezzardi 8fc5ff2c94 CliftImportModel: deduplicate recorded targets
This commit adds a set of module-level ops whose descriptive info has
already been recorded to SymbolRenamer, and short-circuit
recordFunctionOpName / recordGlobalVariableOpName when the same op
shows up again.

The set lives on SymbolRenamer (and not on the Importer) because a
single importDescriptiveInfo invocation may construct several Importer
instances: the per-function overload visits the current function with
one Importer, then each helper/global at module level with a fresh one,
and any callee reached through a clift::UseOp would similarly create
another. The deduplication logic must be shared across all of them so
that the same target is not recorded twice.

Behavior is unchanged for the current call sites (each module-level op
is visited at most once today); the deduplication logic prepares for
when the body walk will also reache sibling declarations through
clift::UseOp, which is necessary for importing descriptive info
properly.
2026-06-15 17:28:22 +02:00
Pietro Fezzardi 7aad574196 CliftImportModel: refactor visitGlobalVariableOp
Split visitFunctionOp into two parts:
1. a new recordGlobalVariableOpName helper, which records the name for
any GlobalVariableOp;
2 the existing visitGlobalVariableOp, that now delegates to the helper.

The helper exists so that, like recordFunctionOpName, it can be invoked
from contexts other than the top-level module walk, in particular, when
a clift::UseOp in a function body refers to a GlobalVariableOp.

Pure refactor: behavior is unchanged.
2026-06-15 17:28:22 +02:00
Pietro Fezzardi 98b0dd9380 CliftImportModel: refactor visitFunctionOp
Split visitFunctionOp into two parts:
1. a new recordFunctionOpName helper, which records the name for any
FunctionOp without touching the Importer's CurrentFunction state;
2. the existing visitFunctionOp, which keeps the CurrentFunction
lifecycle and now delegates the recording to the new helper.

This makes the recording reusable from contexts where mutating
CurrentFunction is not appropriate e.g. when reaching a callee
declaration from a body walk via a clift::UseOp, which will need in a
later commit.

Pure refactor: behavior is unchanged.
2026-06-15 17:28:22 +02:00
Lauri Vasama aa48a01400 Fix overwriting of names in Clift type import 2026-06-15 17:28:22 +02:00
Ivan Krysak 2a2854c020 CliftEmitC: always emit opaque types in headers 2026-06-15 17:28:22 +02:00
Ivan Krysak 6d86e8ca71 CliftAttributes: improve mutation error message 2026-06-15 17:28:22 +02:00
Ivan Krysak f13a63ba97 Comment tests: make robust to new attributes 2026-06-15 17:28:22 +02:00
Ivan Krysak cdf22d56a5 Comment tests: restore the segment test 2026-06-15 17:28:22 +02:00
Ivan Krysak ce9918a0c6 Clifter: do not load dialect in the pipe
Container already takes care of that.
2026-06-15 17:28:22 +02:00
Ivan Krysak f8e13b8c96 TypeDependencyGraph: skip opaque types 2026-06-15 17:28:22 +02:00
Ivan Krysak a83521d337 Ensure no duplicate opaque types in headers 2026-06-15 17:28:22 +02:00
Ivan Krysak 5cd3556765 emit-single-type-definition: add a TODO 2026-06-15 17:28:22 +02:00
Ivan Krysak 3a6ed1e7eb CliftContainer: accept owning module references 2026-06-15 17:28:22 +02:00
Ivan Krysak a8056e8cee UnconfiguredNB: ensure binary lives long enough 2026-06-15 17:28:22 +02:00
Ivan Krysak b383c9a111 Pipebox: improve an error message 2026-06-15 17:28:22 +02:00
Ivan Krysak 77affee259 importType: provide a error-less overload 2026-06-15 17:28:22 +02:00
Ivan Krysak 686dc0877a hasModuleAttr -> isCliftModule 2026-06-15 17:28:22 +02:00
Alessandro Di Federico 7d03759672 Drop test_pointer_array_emission 2026-06-15 17:28:22 +02:00
Ivan Krysak ffc367f584 Pipebox: reorder containers and pipes 2026-06-15 17:28:22 +02:00
Ivan Krysak b0bc3eb2d8 Pipebox: streamline registration
Having manual indexing leads to having to touch all the following
entries when one is removed. It also makes adding new ones to
the middle of the list really awkward.

Instead of manual indexing, use a simple macro to come up with
the instance name on the fly.
2026-06-15 17:28:22 +02:00
Ivan Krysak 93e9b41769 EnforceABI: drop an unused class declaration 2026-06-15 17:28:22 +02:00
Ivan Krysak 53b868e48f PTML: drop unused interfaces 2026-06-15 17:28:22 +02:00
Ivan Krysak 81190634df ABI: drop unused interfaces 2026-06-15 17:28:22 +02:00
Ivan Krysak 529b36a91c ADT: drop unused interfaces 2026-06-15 17:28:22 +02:00
Ivan Krysak 0c9d83dd4d CliftImportModel: import artificial field comments 2026-06-15 17:28:22 +02:00
Ivan Krysak c03d582ba4 ArtificialStruct name: use name builder helper 2026-06-15 17:28:22 +02:00
Ivan Krysak 771d01f107 CliftEmitC: mark typedefs as commentable 2026-06-15 17:28:22 +02:00
Ivan Krysak c01a553d23 CliftEmitC: mark segments as commentable 2026-06-15 17:28:22 +02:00
Ivan Krysak ff53337edb CEmitter: fix sub-comment commands
Before this fix, triggering "comment" action *between* other parts,
for example, between arguments, would trigger it on the function
itself.

That behavior was confusing, so comment action is not allowed there
anymore.
2026-06-15 17:28:22 +02:00
Ivan Krysak 129e636796 CEmitter: ensure every prototype is commentable 2026-06-15 17:28:22 +02:00
Ivan Krysak ae17e8987a Fix extra commentability on prototype return value 2026-06-15 17:28:22 +02:00
Ivan Krysak 381c834cce HeaderToModel: add TODOs 2026-06-15 17:28:22 +02:00
Ivan Krysak dddd0e7d90 License: update copyright year 2026-06-15 17:28:22 +02:00
Ivan Krysak 087ca2ff8c Update forgotten license headers 2026-06-15 17:28:22 +02:00
Ivan Krysak b18bb7e0d5 ImportFromC: handle always_inline and noreturn 2026-06-15 17:28:22 +02:00
Ivan Krysak 8cd3248175 abi::...::Layout: function-type-layout logger 2026-06-15 17:28:22 +02:00
Ivan Krysak 0d0d455b19 abi::FunctionType::Layout: move yaml traits higher 2026-06-15 17:28:22 +02:00
Ivan Krysak cabbe4d6e6 Tests: use new header pipes 2026-06-15 17:28:22 +02:00
Ivan Krysak 8f29c5e77c Clift: type list attribute should be clift.types 2026-06-15 17:28:22 +02:00