Search in sources :

Example 6 with InlinedOsrTypeInfoOperand

use of org.jikesrvm.compilers.opt.ir.operand.InlinedOsrTypeInfoOperand in project JikesRVM by JikesRVM.

the class NormalBURS method buildTrees.

/**
 * Stage 1: Complete the expression trees and identify tree roots.
 * Complete BURS trees by adding leaf nodes as needed, and
 * creating tree edges by calling insertChild1() or insertChild2()
 * This step is also where we introduce intermediate tree nodes for
 * any LIR instruction that has > 2 "real" operands e.g., a CALL.
 * We also mark nodes that must be tree roots.
 *
 * @param dg  The dependence graph.
 */
private void buildTrees(DepGraph dg) {
    DepGraphNode bbNodes = (DepGraphNode) dg.firstNode();
    for (DepGraphNode n = bbNodes; n != null; n = (DepGraphNode) n.getNext()) {
        // Initialize n.treeNode
        AbstractBURS_TreeNode cur_parent = AbstractBURS_TreeNode.create(n);
        castNode(n).setCurrentParent(cur_parent);
        Instruction instr = n.instruction();
        // loop for USES of an instruction
        for (Enumeration<Operand> uses = instr.getUses(); uses.hasMoreElements(); ) {
            // Create tree edge for next use.
            Operand op = uses.nextElement();
            if (op == null)
                continue;
            // Set child = AbstractBURS_TreeNode for operand op
            AbstractBURS_TreeNode child;
            if (op instanceof RegisterOperand) {
                RegisterOperand regOp = (RegisterOperand) op;
                // ignore validation registers
                if (regOp.getRegister().isValidation())
                    continue;
                DepGraphEdge e = DepGraphEdge.findInputEdge(n, op);
                if (e == null) {
                    // operand is leaf
                    child = Register;
                } else {
                    child = castNode(e.fromNode()).getCurrentParent();
                }
            } else if (op instanceof IntConstantOperand) {
                child = new BURS_IntConstantTreeNode(((IntConstantOperand) op).value);
            } else if (op instanceof LongConstantOperand) {
                child = LongConstant;
            } else if (op instanceof AddressConstantOperand) {
                child = AddressConstant;
            } else if (op instanceof BranchOperand && instr.isCall()) {
                child = BranchTarget;
            } else if (op instanceof InlinedOsrTypeInfoOperand && instr.isYieldPoint()) {
                child = NullTreeNode;
            } else {
                continue;
            }
            // Attach child as child of cur_parent in correct position
            if (cur_parent.getChild1() == null) {
                cur_parent.setChild1(child);
            } else if (cur_parent.getChild2() == null) {
                cur_parent.setChild2(child);
            } else {
                // Create auxiliary node so as to represent
                // a instruction with arity > 2 in a binary tree.
                AbstractBURS_TreeNode child1 = cur_parent.getChild2();
                AbstractBURS_TreeNode aux = AbstractBURS_TreeNode.create(OTHER_OPERAND_opcode);
                cur_parent.setChild2(aux);
                cur_parent = aux;
                cur_parent.setChild1(child1);
                cur_parent.setChild2(child);
            }
        }
        // patch for calls & return
        switch(instr.getOpcode()) {
            case CALL_opcode:
            case SYSCALL_opcode:
            case YIELDPOINT_OSR_opcode:
                if (cur_parent.getChild2() == null) {
                    cur_parent.setChild2(NullTreeNode);
                }
            // fall through
            case RETURN_opcode:
                if (cur_parent.getChild1() == null) {
                    cur_parent.setChild1(NullTreeNode);
                }
        }
        if (mustBeTreeRoot(n)) {
            makeTreeRoot(castNode(n).getCurrentParent());
        }
    }
}
Also used : LongConstantOperand(org.jikesrvm.compilers.opt.ir.operand.LongConstantOperand) IntConstantOperand(org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand) AddressConstantOperand(org.jikesrvm.compilers.opt.ir.operand.AddressConstantOperand) InlinedOsrTypeInfoOperand(org.jikesrvm.compilers.opt.ir.operand.InlinedOsrTypeInfoOperand) LongConstantOperand(org.jikesrvm.compilers.opt.ir.operand.LongConstantOperand) BranchOperand(org.jikesrvm.compilers.opt.ir.operand.BranchOperand) RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) Operand(org.jikesrvm.compilers.opt.ir.operand.Operand) IntConstantOperand(org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand) AddressConstantOperand(org.jikesrvm.compilers.opt.ir.operand.AddressConstantOperand) DepGraphNode(org.jikesrvm.compilers.opt.depgraph.DepGraphNode) InlinedOsrTypeInfoOperand(org.jikesrvm.compilers.opt.ir.operand.InlinedOsrTypeInfoOperand) Instruction(org.jikesrvm.compilers.opt.ir.Instruction) RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) BranchOperand(org.jikesrvm.compilers.opt.ir.operand.BranchOperand) DepGraphEdge(org.jikesrvm.compilers.opt.depgraph.DepGraphEdge)

Aggregations

InlinedOsrTypeInfoOperand (org.jikesrvm.compilers.opt.ir.operand.InlinedOsrTypeInfoOperand)6 Operand (org.jikesrvm.compilers.opt.ir.operand.Operand)6 RegisterOperand (org.jikesrvm.compilers.opt.ir.operand.RegisterOperand)5 OsrPoint (org.jikesrvm.compilers.opt.ir.OsrPoint)4 BranchOperand (org.jikesrvm.compilers.opt.ir.operand.BranchOperand)4 IntConstantOperand (org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand)4 LongConstantOperand (org.jikesrvm.compilers.opt.ir.operand.LongConstantOperand)4 AddressConstantOperand (org.jikesrvm.compilers.opt.ir.operand.AddressConstantOperand)3 LinkedList (java.util.LinkedList)2 DepGraphNode (org.jikesrvm.compilers.opt.depgraph.DepGraphNode)2 Instruction (org.jikesrvm.compilers.opt.ir.Instruction)2 BranchProfileOperand (org.jikesrvm.compilers.opt.ir.operand.BranchProfileOperand)2 ConditionOperand (org.jikesrvm.compilers.opt.ir.operand.ConditionOperand)2 ConstantOperand (org.jikesrvm.compilers.opt.ir.operand.ConstantOperand)2 LocationOperand (org.jikesrvm.compilers.opt.ir.operand.LocationOperand)2 MethodOperand (org.jikesrvm.compilers.opt.ir.operand.MethodOperand)2 TrapCodeOperand (org.jikesrvm.compilers.opt.ir.operand.TrapCodeOperand)2 TrueGuardOperand (org.jikesrvm.compilers.opt.ir.operand.TrueGuardOperand)2 OptimizingCompilerException (org.jikesrvm.compilers.opt.OptimizingCompilerException)1 DepGraphEdge (org.jikesrvm.compilers.opt.depgraph.DepGraphEdge)1