Exemplo n.º 1
0
        private static Operand FindDefOnPred(DefMap[] globalDefs, BasicBlock current, Operand operand)
        {
            BasicBlock previous;

            do
            {
                DefMap defMap = globalDefs[current.Index];

                Register reg = operand.GetRegister();

                if (defMap.TryGetOperand(reg, out Operand lastDef))
                {
                    return(lastDef);
                }

                if (defMap.HasPhi(reg))
                {
                    return(InsertPhi(globalDefs, current, operand));
                }

                previous = current;
                current  = current.ImmediateDominator;
            }while (previous != current);

            return(Undef());
        }
Exemplo n.º 2
0
        private static Definition FindDefinition(DefMap[] globalDefs, BasicBlock current, Register reg)
        {
            foreach (BasicBlock block in SelfAndImmediateDominators(current))
            {
                DefMap defMap = globalDefs[block.Index];

                if (defMap.TryGetOperand(reg, out Operand lastDef))
                {
                    return(new Definition(block, lastDef));
                }

                if (defMap.HasPhi(reg))
                {
                    return(new Definition(block, InsertPhi(globalDefs, block, reg)));
                }
            }

            return(new Definition(current, Undef()));
        }