protected final int FITS(OPT_Operand op, int numBits, int trueCost, int falseCost) {
   if (op.isIntConstant() && OPT_Bits.fits(IV(op), numBits)) {
     return trueCost;
   } else if (op.isAddressConstant() && OPT_Bits.fits(AV(op), numBits)) {
     return trueCost;
   } else {
     return falseCost;
   }
 }
Exemple #2
0
  /**
   * Build a BURS Tree for each OPT_Instruction. 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.
   *
   * @param s The instruction for which a tree must be built
   */
  private OPT_BURS_TreeNode buildTree(OPT_Instruction s) {

    OPT_BURS_TreeNode root = new OPT_BURS_TreeNode(new OPT_DepGraphNode(s));
    OPT_BURS_TreeNode cur = root;
    for (OPT_OperandEnumeration uses = s.getUses(); uses.hasMoreElements(); ) {
      OPT_Operand op = uses.next();
      if (op == null) continue;

      op.clear();
      // Set child = OPT_BURS_TreeNode for operand op
      OPT_BURS_TreeNode child;
      if (op instanceof OPT_RegisterOperand) {
        if (op.asRegister().register.isValidation()) continue;
        child = Register;
      } else if (op instanceof OPT_IntConstantOperand) {
        child = new OPT_BURS_IntConstantTreeNode(((OPT_IntConstantOperand) op).value);
      } else if (op instanceof OPT_LongConstantOperand) {
        child = LongConstant;
      } else if (op instanceof OPT_AddressConstantOperand) {
        child = AddressConstant;
      } else if (op instanceof OPT_BranchOperand && s.isCall()) {
        child = BranchTarget;
        // -#if RVM_WITH_OSR
      } else if (op instanceof OPT_InlinedOsrTypeInfoOperand && s.isYieldPoint()) {
        child = NullTreeNode;
        // -#endif
      } else {
        continue;
      }

      // Attach child as child of cur_parent in correct position
      if (cur.child1 == null) {
        cur.child1 = child;
      } else if (cur.child2 == null) {
        cur.child2 = child;
      } else {
        // Create auxiliary node so as to represent
        // a instruction with arity > 2 in a binary tree.
        OPT_BURS_TreeNode child1 = cur.child2;
        OPT_BURS_TreeNode aux = new OPT_BURS_TreeNode(OTHER_OPERAND_opcode);
        cur.child2 = aux;
        cur = aux;
        cur.child1 = child1;
        cur.child2 = child;
      }
    }

    // patch for calls & return
    switch (s.getOpcode()) {
      case CALL_opcode:
      case SYSCALL_opcode:
        // -#if RVM_WITH_OSR
      case YIELDPOINT_OSR_opcode:
        // -#endif
        if (cur.child2 == null) cur.child2 = NullTreeNode;
        // fall through
      case RETURN_opcode:
        if (cur.child1 == null) cur.child1 = NullTreeNode;
    }
    return root;
  }