56 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
Lauri Vasama aa48a01400 Fix overwriting of names in Clift type import 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 77affee259 importType: provide a error-less overload 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 8f29c5e77c Clift: type list attribute should be clift.types 2026-06-15 17:28:22 +02:00
Ivan Krysak 57bbb7b962 Do not propagate model unnecessarily 2026-06-15 17:28:22 +02:00
Ivan Krysak 32b89d86f9 Clifter: Factor makeOpaqueStruct out 2026-06-15 17:28:22 +02:00
Ivan Krysak 6ff6b8d699 CliftImportModel: ensure DataModel is set 2026-06-15 11:47:41 +02:00
Ivan Krysak d22bd1cc58 CliftImportModel: introduce more bulk importers 2026-06-15 11:47:41 +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 f13748583b verifyAgainstModel: check forbidden attributes 2026-04-22 08:19:35 +00:00
Ivan Krysak 8387f8ce17 verifyAgainstModel: check for unknown attributes 2026-04-22 08:19:34 +00:00
Ivan Krysak e4770db1f1 verifyAgainstModel: function type attributes 2026-04-22 08:19:34 +00:00
Ivan Krysak 52f41c4c44 verifyAgainstModel: check struct attributes 2026-04-22 08:19:33 +00:00
Ivan Krysak d66c54321c verifyAgainstModel: check function attributes 2026-04-22 08:19:32 +00:00
Ivan Krysak 9675b2d3c9 verifyAgainstModel: greatly improve RFT checks 2026-04-22 08:19:32 +00:00
Ivan Krysak e693cdbd53 model-verify-clift -> verify-against-model 2026-04-22 08:19:30 +00:00
Ivan Krysak ce7e5a3917 CliftModelVerify: improve error message wording 2026-04-22 08:19:30 +00:00
Ivan Krysak 40a5c76e81 CliftModelVerify: factor error creation out
This heavily improves readability of the messages themselves.
2026-04-22 08:19:29 +00:00
Ivan Krysak b46c54308a Remove unused logic that slipped through 2026-04-22 08:19:29 +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
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 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 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 de0e59b188 Move FunctionOp arg attr verify to model verify 2026-04-08 11:12:41 +03: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 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 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 b632772cbb ImportModel: import function attributes 2026-03-27 08:12:51 +00:00
Ivan Krysak 00f05cac7a ImportModel: introduce importSegmentDeclaration 2026-03-27 08:12:17 +00:00
Ivan Krysak 8f89984f36 ImportModel: introduce importFunctionDeclaration 2026-03-27 08:11:11 +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 c30f309f5e Clift: introduce getMutableComment 2026-03-27 08:09:09 +00:00
Ivan Krysak aa53ba5d0b ImportDescriptiveInfo: import argument attributes 2026-03-27 08:04:40 +00:00
Ivan Krysak 58257d5520 ImportModel: import _ABI 2026-03-27 08:04:10 +00:00
Ivan Krysak 105f15266b ImportModel: import _CAN_CONTAIN_CODE 2026-03-27 07:19:27 +00:00
Ivan Krysak 7f66f25253 mlir::clift::ClassAttr: add attribute support 2026-03-27 07:19:27 +00:00
Ivan Krysak 928bcdb118 mlir::clift::FunctionType: add attribute support 2026-03-27 07:19:27 +00:00
Lauri Vasama ad6f6df04e Improve function arg/result attribute interface 2026-03-27 07:18:49 +00:00