blob: d2a3cf218859a942a228e72f78bbd906bc0333ab (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
using ARMeilleure.Translation;
using static ARMeilleure.IntermediateRepresentation.Operand.Factory;
namespace ARMeilleure.IntermediateRepresentation
{
readonly struct PhiOperation
{
private readonly Operation _operation;
public PhiOperation(Operation operation)
{
_operation = operation;
}
public int SourcesCount => _operation.SourcesCount / 2;
public BasicBlock GetBlock(ControlFlowGraph cfg, int index)
{
return cfg.PostOrderBlocks[cfg.PostOrderMap[_operation.GetSource(index * 2).AsInt32()]];
}
public void SetBlock(int index, BasicBlock block)
{
_operation.SetSource(index * 2, Const(block.Index));
}
public Operand GetSource(int index)
{
return _operation.GetSource(index * 2 + 1);
}
public void SetSource(int index, Operand operand)
{
_operation.SetSource(index * 2 + 1, operand);
}
}
}
|