// $Id: DelocalizedReturnInstruction.java,v 1.3 1999/12/10 13:36:25 mpp Exp $

package IR2;

import java.util.*;

public class DelocalizedReturnInstruction extends DelocalizedInstruction {
  DelocalizedRValue result;

  public DelocalizedReturnInstruction(DelocalizedRValue val) {
    result = val;
  }
  
  public DelocalizedLValue destination() {
    return null;
  }

  public Enumeration lsources() {
    if (result instanceof DelocalizedLValue) {
      return new ShortEnumeration(result);
    } else {
      return new ShortEnumeration();
    }
  }

  public void generate_code(Codegen c){
    c.generate_return(result);
  }

  // Substitution. For swapping in a symbolic register
  public void substitute_rvalue(DelocalizedLValue oldlval, 
                                DelocalizedLValue newlval) {
    if (result.rproxy() == oldlval) result = (DelocalizedRValue)newlval;
  }


  /* Copy propagation */
  public boolean kills_copy(CopyInstruction copy) {
    return false;
  }
  public void substitute_copies(Hashtable map) {
    if (map.contains(result))
      result = (DelocalizedRValue) map.get(result);
  }
}
