mirror of
https://github.com/yuzu-emu/sirit.git
synced 2024-12-23 00:25:34 +00:00
Add support for self-referencing phi nodes
This commit is contained in:
parent
9a08dab7ee
commit
f6a7130486
|
@ -90,6 +90,9 @@ public:
|
||||||
/// Generate a new id for forward declarations
|
/// Generate a new id for forward declarations
|
||||||
[[nodiscard]] Id ForwardDeclarationId();
|
[[nodiscard]] Id ForwardDeclarationId();
|
||||||
|
|
||||||
|
/// Returns the current generator id, useful for self-referencing phi nodes
|
||||||
|
[[nodiscard]] Id CurrentId() const noexcept;
|
||||||
|
|
||||||
/// Assign a new id and return the old one, useful for defining forward declarations
|
/// Assign a new id and return the old one, useful for defining forward declarations
|
||||||
Id ExchangeCurrentId(Id new_current_id);
|
Id ExchangeCurrentId(Id new_current_id);
|
||||||
|
|
||||||
|
|
|
@ -99,6 +99,10 @@ Id Module::ForwardDeclarationId() {
|
||||||
return Id{++bound};
|
return Id{++bound};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Id Module::CurrentId() const noexcept {
|
||||||
|
return Id{bound + 1};
|
||||||
|
}
|
||||||
|
|
||||||
Id Module::ExchangeCurrentId(Id new_current_id) {
|
Id Module::ExchangeCurrentId(Id new_current_id) {
|
||||||
const std::uint32_t old_id = std::exchange(bound, new_current_id.value - 1);
|
const std::uint32_t old_id = std::exchange(bound, new_current_id.value - 1);
|
||||||
return Id{old_id + 1};
|
return Id{old_id + 1};
|
||||||
|
|
Loading…
Reference in a new issue