Commit Graph

17 Commits

Author SHA1 Message Date
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
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
Pietro Fezzardi 2f692127f9 OpaqueType: model verification and name import
Teach Clift's verify-against-model and ImportDescriptiveInfo
visitors about types whose handle has the OpaqueType rank: the
verifier rejects non-struct types with such handles, and the name
importer fills in the type's mutable name with
NameBuilder::opaqueTypeName based on the wrapped byte size.
2026-05-08 11:37:10 +02:00
Lauri Vasama 90e5dfd4c9 Pass MLIRContext by address
Passing by address is more conventional. This is what MLIR does most of
the time, and it avoids dereferences and addressofs everywhere.
2026-04-30 15:09:16 +03:00
Lauri Vasama a338194eb7 Move namespace mlir::clift out of namespace mlir 2026-04-27 12:48:24 +03: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 e250657c0b ImportDescriptiveInfo: import return value comment 2026-03-27 08:10:41 +00:00
Ivan Krysak d6edb20142 ImportDescriptiveInfo: import comments 2026-03-27 08:10:10 +00:00
Ivan Krysak aa53ba5d0b ImportDescriptiveInfo: import argument attributes 2026-03-27 08:04:40 +00:00
Lauri Vasama ad6f6df04e Improve function arg/result attribute interface 2026-03-27 07:18:49 +00:00
Ivan Krysak 92fd9188d5 ImportDescriptiveInfo: improve an error message 2026-03-27 07:18:49 +00:00
Ivan Krysak 53a476e9ee importNames -> importDescriptiveInfo
This opens up the possibility of importing more than just names.
2026-03-26 16:28:48 +00:00