Commit Graph

7644 Commits

Author SHA1 Message Date
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
Ivan Krysak 7214a75379 Precedence test: drop 2026-06-15 17:28:22 +02:00
Ivan Krysak d1f9987523 dual-case test: drop 2026-06-15 17:28:22 +02:00
Ivan Krysak c87513cb37 segments-and-sections test: drop 2026-06-15 17:28:22 +02:00
Ivan Krysak 45d8be8a0f pretty-ints test: drop 2026-06-15 17:28:22 +02:00
Ivan Krysak 277e646d19 linked-lists test: adjust for the new backend 2026-06-15 17:28:22 +02:00
Ivan Krysak 6a4c12c68a New pipeline: add more debugging artifacts 2026-06-15 17:28:22 +02:00
Ivan Krysak c1ed293c7a New pipeline: adopt new backend 2026-06-15 17:28:22 +02:00
Ivan Krysak 5ddde903c5 emit-c-as-directory: move to new backend 2026-06-15 17:28:22 +02:00
Ivan Krysak 14ea4b6cd7 emit-c-as-single-file: move to new backend 2026-06-15 17:28:22 +02:00
Ivan Krysak 190405a77b Rename decompile-to-X pipes to emit-c-as-X
Note that the artifact names were intentionally left untouched.
2026-06-15 17:28:22 +02:00
Ivan Krysak 4381f86f31 emit-c: expose options 2026-06-15 17:28:22 +02:00