spirv: Add support for self-referencing phi nodes
This commit is contained in:
parent
e87a502da2
commit
7496bbf758
@ -217,11 +217,18 @@ Id EmitPhi(EmitContext& ctx, IR::Inst* inst) {
|
|||||||
IR::Inst* const arg_inst{arg.Inst()};
|
IR::Inst* const arg_inst{arg.Inst()};
|
||||||
def = arg_inst->Definition<Id>();
|
def = arg_inst->Definition<Id>();
|
||||||
if (!Sirit::ValidId(def)) {
|
if (!Sirit::ValidId(def)) {
|
||||||
// If it hasn't been defined, get a forward declaration
|
if (arg_inst == inst) {
|
||||||
|
// This is a self referencing phi node
|
||||||
|
def = ctx.CurrentId();
|
||||||
|
// Self-referencing definition will be set by the caller
|
||||||
|
} else {
|
||||||
|
// If it hasn't been defined and it's not a self reference,
|
||||||
|
// get a forward declaration
|
||||||
def = ctx.ForwardDeclarationId();
|
def = ctx.ForwardDeclarationId();
|
||||||
arg_inst->SetDefinition<Id>(def);
|
arg_inst->SetDefinition<Id>(def);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
IR::Block* const phi_block{inst->PhiBlock(index)};
|
IR::Block* const phi_block{inst->PhiBlock(index)};
|
||||||
operands.push_back(def);
|
operands.push_back(def);
|
||||||
operands.push_back(phi_block->Definition<Id>());
|
operands.push_back(phi_block->Definition<Id>());
|
||||||
|
Loading…
Reference in New Issue
Block a user