001 /*
002 * This file is part of the Jikes RVM project (http://jikesrvm.org).
003 *
004 * This file is licensed to You under the Eclipse Public License (EPL);
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/eclipse-1.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.liveness;
014
015 import org.jikesrvm.VM;
016 import org.jikesrvm.classloader.TypeReference;
017 import org.jikesrvm.compilers.opt.ir.Register;
018 import org.jikesrvm.compilers.opt.ir.operand.RegisterOperand;
019
020 /*
021 *
022 * A simple class that holds an element in a LiveSet.
023 */
024 final class LiveSetElement {
025
026 /**
027 * The register operand, i.e., the data
028 */
029 private RegisterOperand regOp;
030
031 /**
032 * The next field
033 */
034 private LiveSetElement next;
035
036 /**
037 * Construct an {@link LiveSetElement}.
038 *
039 * @param register An {@link RegisterOperand}
040 */
041 LiveSetElement(RegisterOperand register) {
042 regOp = register;
043 }
044
045 /**
046 * Returns the register operand associated with this element
047 * @return the register operand associated with this element
048 */
049 public RegisterOperand getRegisterOperand() {
050 return regOp;
051 }
052
053 /**
054 * Change the register operand. New operand must represent the same register
055 * This is done to promote something of WordType to ReferenceType for the purposes of GC mapping.
056 */
057 public void setRegisterOperand(RegisterOperand newRegOp) {
058 if (VM.VerifyAssertions) VM._assert(regOp.getRegister().number == newRegOp.getRegister().number);
059 regOp = newRegOp;
060 }
061
062 /**
063 * Returns the register associated with this element
064 * @return the register associated with this element
065 */
066 public Register getRegister() {
067 return regOp.getRegister();
068 }
069
070 /**
071 * Returns the register type associated with this element
072 * @return the register type associated with this element
073 */
074 public TypeReference getRegisterType() {
075 return regOp.getType();
076 }
077
078 /**
079 * Returns the next element on this list
080 * @return the next element on this list
081 */
082 public LiveSetElement getNext() {
083 return next;
084 }
085
086 /**
087 * Sets the next element field
088 * @param newNext the next element field
089 */
090 public void setNext(LiveSetElement newNext) {
091 next = newNext;
092 }
093
094 /**
095 * Returns a string version of this element
096 * @return a string version of this element
097 */
098 public String toString() {
099 StringBuilder buf = new StringBuilder("");
100 buf.append(regOp);
101 return buf.toString();
102 }
103 }