Allow LocalVariable
to be assigned more than once (#2288)
* Allow `LocalVariable` to be assigned more than once This allows us to write flow controls like loops and if-elses with LocalVariables participating in phi nodes. * Add `GetLocalNumber` to operand
This commit is contained in:
parent
212e472c9f
commit
c805542b29
6 changed files with 47 additions and 16 deletions
|
@ -45,7 +45,7 @@ namespace ARMeilleure.Translation
|
|||
public static void Construct(ControlFlowGraph cfg)
|
||||
{
|
||||
var globalDefs = new DefMap[cfg.Blocks.Count];
|
||||
var localDefs = new Operand[RegisterConsts.TotalCount];
|
||||
var localDefs = new Operand[cfg.LocalsCount + RegisterConsts.TotalCount];
|
||||
|
||||
var dfPhiBlocks = new Queue<BasicBlock>();
|
||||
|
||||
|
@ -264,6 +264,12 @@ namespace ARMeilleure.Translation
|
|||
|
||||
return true;
|
||||
}
|
||||
else if (operand is { Kind: OperandKind.LocalVariable } && operand.GetLocalNumber() > 0)
|
||||
{
|
||||
result = RegisterConsts.TotalCount + operand.GetLocalNumber() - 1;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
result = -1;
|
||||
|
||||
|
@ -274,7 +280,7 @@ namespace ARMeilleure.Translation
|
|||
{
|
||||
if (!TryGetId(operand, out int key))
|
||||
{
|
||||
Debug.Fail("OperandKind must be Register.");
|
||||
Debug.Fail("OperandKind must be Register or a numbered LocalVariable.");
|
||||
}
|
||||
|
||||
return key;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue