001 /*
002 * This file is part of the Jikes RVM project (http://jikesrvm.org).
003 *
004 * This file is licensed to You under the Common Public License (CPL);
005 * You may not use this file except in compliance with the License. You
006 * may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/cpl1.0.php
009 *
010 * See the COPYRIGHT.txt file distributed with this work for information
011 * regarding copyright ownership.
012 */
013 package org.jikesrvm.compilers.opt.ir.operand;
014
015 import org.jikesrvm.compilers.opt.ir.BasicBlock;
016
017 /**
018 * Represents a basic block (used in LABEL and BBEND instructions)
019 *
020 * @see Operand
021 */
022 public final class BasicBlockOperand extends Operand {
023
024 /**
025 * The basic block
026 */
027 public BasicBlock block;
028
029 /**
030 * Construct a new basic block operand with the given block.
031 *
032 * @param b the basic block
033 */
034 public BasicBlockOperand(BasicBlock b) {
035 block = b;
036 }
037
038 /**
039 * Return a new operand that is semantically equivalent to <code>this</code>.
040 *
041 * @return a copy of <code>this</code>
042 */
043 public Operand copy() {
044 return new BasicBlockOperand(block);
045 }
046
047 /**
048 * Are two operands semantically equivalent?
049 *
050 * @param op other operand
051 * @return <code>true</code> if <code>this</code> and <code>op</code>
052 * are semantically equivalent or <code>false</code>
053 * if they are not.
054 */
055 public boolean similar(Operand op) {
056 return (op instanceof BasicBlockOperand) && (block == ((BasicBlockOperand) op).block);
057 }
058
059 /**
060 * Returns the string representation of this operand.
061 *
062 * @return a string representation of this operand.
063 */
064 public String toString() {
065 return block.toString();
066 }
067 }