Commit Graph

705 Commits

Author SHA1 Message Date
Lauri Vasama 3ca3653333 Convert Clift type handles to use locations 2025-03-24 09:27:57 +02:00
Lauri Vasama e9c329e51d Rename Clift unique handle to handle 2025-03-24 09:26:43 +02:00
Lauri Vasama 5479a5de88 Add special handling of aggregate initializers 2025-03-24 09:26:43 +02:00
Lauri Vasama 2f64025dc9 Fix Clift backend double negation emission 2025-03-24 09:26:43 +02:00
Lauri Vasama 5f475739ef Rename reinterpret, add convert cast 2025-03-24 09:26:43 +02:00
Lauri Vasama f884642f59 Overhaul clift.struct, clift.union assembly syntax
Old syntax:
```
	unique_handle = "/model-type/1",
	name = "my_struct",
	size = 2,
	fields = [
		<
			offset = 0
			name = "",
			type = !t
		>,
		<
			offset = 1,
			name = "my_field",
			type = !t
		>
	]
>

	unique_handle = "/model-type/1",
	name = "my_union",
	fields = [
		<
			offset = 0,
			name = "",
			type = !t
		>,
		<
			offset = 0,
			name = "my_field",
			type = !t
		>
	]
>
```

New syntax:
```
	"/model-type/1" as "my_struct" : size(1) {
		offset(0) : !t,
		offset(1) as "my_field" : !t
	}
>

	"/model-type/1" as "my_union" : {
		!t,
		"my_field" : !t
	}
>
```
2025-03-24 09:26:43 +02:00
Lauri Vasama 5bd481ae5a Overhaul clift.function assembly syntax
Old syntax:
```
        unique_handle = "/model-type/1",
        name = "my_function",
        return_type = !t,
        argument_types = [
                !t
        ]
>
```

New syntax:
```
        "/model-type/1" as "my_function" : !t(!t)
>
```

* Rename clift.function mnemonic to clift.func.
2025-03-24 09:26:43 +02:00
Lauri Vasama 281bf283e2 Overhaul clift.typedef assembly syntax
Old syntax:
```
	unique_handle = "/model-type/1",
	name = "my_typedef",
	underlying_type = !t
>
```

New syntax:
```
	"/model-type/1" as "my_typedef" : !t
>
```
2025-03-24 09:26:43 +02:00
Lauri Vasama ea78766f10 Overhaul clift.enum assembly syntax
Old syntax:
```
	unique_handle = "/model-type/1",
	name = "my_enum",
	underlying_type = !t,
	fields = [
		<
			name = "my_enumerator",
			raw_value = 42
		>
	]
>
```

New syntax:
```
	"/model-type/1" as "my_enum" : !t {
		42 as "my_enumerator"
	}
>
```
2025-03-24 09:26:43 +02:00
Lauri Vasama 8482bcbf90 Overhaul clift.defined assembly syntax
Old syntax:
```
!clift.defined<#t>
!clift.defined<is_const = true, #t>
```

New syntax:
```
!clift.defined<#t>
!clift.defined<const #t>
```
2025-03-24 09:26:43 +02:00
Lauri Vasama 64fc21e9dd Overhaul clift.pointer assembly syntax
Old syntax:
```
!clift.pointer<pointer_size = 8, pointee_type = !t>
!clift.pointer<is_const = true, pointer_size = 8, pointee_type = !t>
```

New syntax:
```
!clift.ptr<8 to !t>
!clift.ptr<const 8 to !t>
```
2025-03-24 09:26:43 +02:00
Lauri Vasama 872b157774 Overhaul clift.array assembly syntax
Old syntax:
```
!clift.array<elements_count = 42, element_type = !t>
```

New syntax:
```
!clift.array<42 x !t>
```
2025-03-24 09:26:43 +02:00
Lauri Vasama eaf1bf35aa Overhaul clift.primitive assembly syntax
Old syntax:
```
!clift.primitive<SignedKind 8>
!clift.primitive<is_const = true, SignedKind 8>
```

New syntax:
```
!clift.primitive<signed 8>
!clift.primitive<const signed 8>
```
2025-03-24 09:26:43 +02:00
Lauri Vasama e08a8e766b Set register set type name in Clift import 2025-03-24 09:26:43 +02:00
Lauri Vasama 20cb57a105 Fix redundant cast parentheses in Clift backend 2025-03-24 09:26:42 +02:00
Lauri Vasama 23b47f825e Add Clift AggregateOp 2025-03-24 09:17:38 +02:00
Lauri Vasama bf625c631a Improve Clift CallOp syntax 2025-03-24 09:17:36 +02:00
Lauri Vasama 1b63797640 Add Clift TernaryOp 2025-03-19 12:57:22 +02:00
Lauri Vasama 747a792f0f Add Clift pointer arithmetic ops 2025-03-19 12:57:22 +02:00
Lauri Vasama 66246218b7 Add Clift StringOp 2025-03-19 12:57:21 +02:00
Lauri Vasama 888d529d93 Fix Clift return type verification 2025-03-19 12:57:20 +02:00
Lauri Vasama 08c2c0a477 Remove ScalarTupleType
After converting type IDs to unique handles it was decided to remove
scalar tuple types in favour of generated structs with non-model unique
handles.
2025-03-19 12:57:18 +02:00
Lauri Vasama 386efffb2f Convert TypeDefinitionAttr ID to UniqueHandle 2025-03-19 12:57:17 +02:00
Lauri Vasama 86126db366 Fix Clift composite type verify on parsing 2025-03-19 12:57:17 +02:00
Andrea Gussoni 93f4a620dd DAGify: implement the DAGify pass
Implement the DAGify pass. This pass, using the results exposed by the
`GenericRegionInfo` analysis, transforms all the retreating edges of
each identified `GenericRegion`, processed in a bottom-up fashion, into
a `goto` edge on the `ScopeGraph`.
2025-03-11 12:26:36 +01:00
Andrea Gussoni 7c8d581271 ESE: fix unit test 2025-03-11 12:25:24 +01:00
Ivan Krysak 705e4a5955 auto [...] -> auto &&[...] 2025-02-13 13:10:51 +02:00
Ivan Krysak 5b8c03b89a Introduce unit tests for comment placement 2025-02-13 13:09:50 +02:00
Ivan Krysak 8841bc7144 Don't include model::NameBuilder from the binary 2025-02-13 13:09:50 +02:00
Ivan Krysak a93ffd3760 Rename UnusedStackArgumentBytes
Old name was `StackBytesAllocatedForRegisterArguments`.
2025-02-12 16:43:19 +02:00
Lauri Vasama 6343bfcb40 Add c-verify pass 2025-01-30 14:52:47 +02:00
Lauri Vasama b7047d3854 Remove Clift backend PTML tags unit test 2025-01-29 23:58:24 +01:00
Pietro Fezzardi 8114c19164 Replace WIP comment with TODO 2025-01-29 15:17:15 +01:00
Andrea Gussoni 684cbf649a ScopeGraph: implement Inverse<Scope<>>
Implement the `Inverse<Scope<...>>` `GraphTraits`. This are needed in
order to support the computation of the `PostDominatorTree` on a
`ScopeGraph`.

Add some `FileCheck` tests to test the dominator and postdominator trees
on the `ScopeGraph`.
2025-01-15 11:48:28 +01:00
Lauri Vasama 96312ce164 Add Clift C Backend LIT tests 2025-01-10 08:04:20 +02:00
Lauri Vasama db6b757c42 Remove duplicate C++ unit test 2025-01-10 08:03:20 +02:00
Lauri Vasama 8515ffffce Move Clift label C++ unit test to LIT 2025-01-10 08:03:20 +02:00
Lauri Vasama aaddafa15b Add check for conflicting local names in Clift 2025-01-10 08:03:20 +02:00
Lauri Vasama 4cedc22efb Merge access ops into AccessOp with indirect flag 2025-01-02 11:25:32 +02:00
Lauri Vasama fe2e70e885 Improve label and goto ops 2025-01-02 11:25:32 +02:00
Andrea Gussoni 26cf42eb12 ESE: Introduce the Enforce Single Exit pass
Introduce the Enforce Single Exit pass, whose task is to normalize a
generic `ScopeGraph`, which may have multiple exit blocks (and/or
infinite loop regions), in order to have a single `sink_block` as exit
block.

This is done by adding a new entry block, a `sink_block`, and some
`scope_closer` edges (which are visible only on the `ScopeGraph`) that
enforce the property.

This is done taking inspiration from how the internally the
`PostDominatorTree` pass construct the temporary graph on which the post
dominance information is computed on.

Some unit tests are added in order to verify that the pass works as
expected.
2024-12-18 10:51:40 +01:00
Andrea Gussoni fa69bd24e5 ScopeGraph: introduce the ScopeGraph
Introduce the `ScopeCloser` and `GotoTarget` annotations in the IR, and
the relative necessary machinery, needed to handle scope closer and goto
edges for the new backend.

A specialization of the `llvm::GraphTraits`, called `ScopeGraph`, that
is able to handle both the above mentioned annotations is provided.

For the `llvm::GraphTraits` implementation, we introduce the
`GeneratorIterator` class, which uses a coroutine to store the status of
the iteration.

A debug logger pass is added, so that we are able to test the
functionality with `FileCheck`.
2024-12-05 15:43:57 +01:00
Alessandro Di Federico 143c315196 Merge revng-c into revng 2024-11-21 10:50:55 +01:00
Ivan Krysak 64446d0453 Adopt name builder across the model users 2024-11-06 19:18:53 +02:00
Ivan Krysak 672ee5df50 Replace std::string_view with llvm::StringRef 2024-11-06 15:43:13 +02:00
Ivan Krysak a67ba96644 Adopt name builder across the model users 2024-11-06 15:43:13 +02:00
Ivan Krysak c101770c72 ModelTypeTests: pass the binary to the verifier 2024-11-06 15:42:44 +02:00
Alessandro Di Federico 4e670ac8e6 Either link revngcSupport or revngSupport 2024-11-04 15:09:56 +01:00
Lauri Vasama 2d2fe890fb Add Clift expression operations 2024-10-31 08:41:25 +01:00
Lauri Vasama e1b55fd5c3 Add custom assembly format for Clift FunctionOp 2024-10-31 08:41:25 +01:00