96 Commits

Author SHA1 Message Date
Ivan Krysak 1609bbe745 Restore the separate enum declaration node 2026-06-16 18:43:45 +02:00
Ivan Krysak 42a045a2b5 CliftEmitC: fix the header filtering direction 2026-06-15 17:32:35 +02:00
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
Ivan Krysak 2a2854c020 CliftEmitC: always emit opaque types in headers 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 a8056e8cee UnconfiguredNB: ensure binary lives long enough 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 c4104388ea CliftEmitC: expose emitTypes 2026-06-15 17:28:22 +02:00
Ivan Krysak eb5c6938ef CliftEmitC: expose emitCommonIncludes 2026-06-15 17:28:22 +02:00
Ivan Krysak ee5534c0ee Introduce single type emission helper 2026-06-15 17:28:22 +02:00
Ivan Krysak c36e7b3bee emitHelperHeader: emit opaque types 2026-06-15 17:28:22 +02:00
Ivan Krysak fbf875d498 CliftEmitC: make type size collector more generic 2026-06-15 17:28:22 +02:00
Ivan Krysak 06a68a806e CliftEmitC: prevent empty structs 2026-06-15 17:28:22 +02:00
Ivan Krysak 531fb0b439 emitTypeAndGlobalHeader: emit opaque types 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 ea785998ec Minor improvements 2026-06-15 11:47:41 +02:00
Alessandro Di Federico 8973f6e55c CliftEmitC: drop assert in emitUndefExpression 2026-06-11 17:39:52 +02:00
Pietro Fezzardi 76b10703b1 TypeDependencyGraph: rename Mode to ModelMode 2026-06-03 16:33:15 +02:00
Lauri Vasama b078f2c809 Fix C label output around hidden statements 2026-05-25 09:00:41 +02:00
Lauri Vasama 5c9a7b4207 Fix C output around hidden casts
```
// before
(var_0.x)[1];

// after
var_0.x[1];
```
2026-05-25 09:00:41 +02:00
Lauri Vasama 3064653e37 Add StatementOpInterface::getBlockArgumentVariable
Translates a mlir::BlockArgument to an mlir::Value more directly
representing the entity or expression to which the block argument
refers, or null if not applicable for the statement in question.
2026-05-25 09:00:41 +02:00
Lauri Vasama 5d3e3f73d9 Add clift.require operation 2026-05-13 15:32:34 +02:00
Pietro Fezzardi 9e3c059d3f CBackend: finish cleanup of array bitcast, assign
This commit completes the piecewise revert of
a546be1386, now that it's no longer
needed.
2026-05-13 15:32:27 +02:00
Pietro Fezzardi 58e95d330f Drop assign_array macro
The macro is no longer necessary: the code now ensures we never
need to assign anything to an array, which would be ill-advised
nevertheless given that array-typed rvalues in C immediately
decay to pointers.
2026-05-08 11:37:10 +02:00
Pietro Fezzardi 85a9780d28 Drop bit_cast_to_array macro
The macro is no longer necessary: the code now ensures we never
need to bitcast anything to an array, which would be ill-advised
nevertheless given that array-typed rvalues in C immediately
decay to pointers.
2026-05-08 11:37:10 +02:00
Pietro Fezzardi a546be1386 CBackend: emit array assignments
Teach CliftToCEmitter how to emit assignments and bitcasts whose
target type is an array, by emitting calls to the new
assign_array and bit_cast_to_array macros. The shape of the call
encodes the element type and the number of elements, which is what
the macros need to expand correctly.
2026-05-08 11:37:10 +02:00
Lauri Vasama 15df286a6f Implement clift.implicit support in the backend 2026-05-04 10:49:06 +03:00
Lauri Vasama 04fe27b8e9 Migrate Clift users to CDataModel 2026-05-04 10:49:03 +03:00
Lauri Vasama be564f8944 Migrate isIntegerType users to unwrapped_isa 2026-04-30 15:09:16 +03:00
Lauri Vasama 1c768919d6 Streamline header emission implementation 2026-04-30 15:09:16 +03:00
Lauri Vasama c56742770b Use const ArrayRef in emitHelperHeader 2026-04-30 15:09:16 +03:00
Lauri Vasama b30b4feec9 Remove MLIRContext from TypeDefinitionEmitter API 2026-04-30 15:09:16 +03: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 71845dcbbb CliftEmitC: stop using mlir::clift namespace 2026-04-22 08:19:47 +00:00
Ivan Krysak 3de5b009e7 Clift: introduce simple passes for header tests 2026-04-22 08:19:29 +00:00
Ivan Krysak 681df85f5d EmitCPass: separate boilerplate for easier reuse 2026-04-22 08:19:28 +00:00
Ivan Krysak d9acaadfac CBackendPass.cpp -> CEmissionPasses.cpp 2026-04-22 08:19:28 +00:00
Ivan Krysak 7edc4b3da6 CEmitter: emit function type attributes 2026-04-22 08:19:28 +00:00
Ivan Krysak 481f8dba31 CEmitter: emit function comment with prototype 2026-04-22 08:19:27 +00:00
Ivan Krysak 74fa16dd13 Introduce helper header emitter 2026-04-22 08:19:25 +00:00
Ivan Krysak 7ab3d590e0 Introduce type and global header emitter 2026-04-22 08:18:52 +00:00
Ivan Krysak 405eebcbd1 TypeDefinitionEmitter: emit comments 2026-04-22 06:33:56 +00:00
Ivan Krysak 3bd8879948 CEmitter: Introduce doxygen emission helpers 2026-04-22 06:33:56 +00:00
Ivan Krysak 6d76908858 Introduce TypeDefinitionEmitter 2026-04-22 06:33:38 +00:00