1 pnkfelix 1.1.2.1 // InstrMOVE.java, created Mon Aug  2 23:19:01 1999 by pnkfelix
 2 pnkfelix 1.1.2.1 // Copyright (C) 1999 Felix S. Klock II <pnkfelix@mit.edu>
 3 pnkfelix 1.1.2.1 // Licensed under the terms of the GNU GPL; see COPYING for details.
 4 pnkfelix 1.1.2.1 package harpoon.IR.Assem;
 5 pnkfelix 1.1.2.1 
 6 pnkfelix 1.1.2.1 import harpoon.ClassFile.HCodeElement;
 7 pnkfelix 1.1.2.1 import harpoon.Temp.Temp;
 8 cananian 1.1.2.3 import harpoon.Temp.TempMap;
 9 pnkfelix 1.1.2.1 
10 pnkfelix 1.1.2.4 import harpoon.Util.Util;
11 pnkfelix 1.1.2.4 
12 pnkfelix 1.1.2.1 /**
13 pnkfelix 1.1.2.1  * <code>InstrMOVE</code> represents a copying of a set of source
14 pnkfelix 1.1.2.1  * <code>Temp</code>s to a set of destination <code>Temp</code>s.
15 pnkfelix 1.1.2.1  * This instruction is being specialized to allow for easier detection
16 pnkfelix 1.1.2.1  * of MOVEs which could guide optimizations (either in eliminating the
17 pnkfelix 1.1.2.1  * MOVE in question or in choosing which register a given
18 pnkfelix 1.1.2.1  * <code>Temp</code> would be best assigned to.
19 pnkfelix 1.1.2.1  * 
20 pnkfelix 1.1.2.1  * Note that <code>InstrMOVE</code>s at the lowest level represents
21 pnkfelix 1.1.2.1  * the movement of data from register to register, <B>not</B> to
22 pnkfelix 1.1.2.1  * memory (use <code>InstrMEM</code> for that).  However, prior to
23 pnkfelix 1.1.2.1  * register allocation it is legal for <code>InstrMOVE</code>s to have
24 pnkfelix 1.1.2.1  * non-register <code>Temp</code>s as their source or destination; the
25 pnkfelix 1.1.2.1  * instruction will simply be replaced later in the compilation with
26 pnkfelix 1.1.2.1  * either a new backend legal <code>InstrMOVE</code> or
27 pnkfelix 1.1.2.1  * <code>InstrMEM</code>.
28 pnkfelix 1.1.2.1  * 
29 pnkfelix 1.1.2.1  * @author  Felix S. Klock II <pnkfelix@mit.edu>
30 cananian 1.4      * @version $Id: InstrMOVE.java,v 1.4 2002/04/10 03:04:29 cananian Exp $ 
31 pnkfelix 1.1.2.1  */
32 pnkfelix 1.1.2.1 public class InstrMOVE extends Instr {
33 pnkfelix 1.1.2.1     
34 pnkfelix 1.1.2.1     /** Creates a <code>InstrMOVE</code>. */
35 pnkfelix 1.1.2.1     public InstrMOVE(InstrFactory inf, HCodeElement codeSrc, 
36 pnkfelix 1.1.2.1                      String assem, Temp[] dst, Temp[] tempSrc) {
37 pnkfelix 1.1.2.1         super(inf, codeSrc, assem, dst, tempSrc);
38 cananian 1.3.2.1         assert dst.length == 1 : "can only have one dest";
39 cananian 1.3.2.1         assert tempSrc.length == 1 : "can only have one src";
40 pnkfelix 1.1.2.1     }
41 pnkfelix 1.1.2.1     
42 pnkfelix 1.1.2.1     /** Accept a visitor */
43 pnkfelix 1.1.2.2     public void accept(InstrVisitor v) { v.visit(this); }
44 cananian 1.1.2.3 
45 cananian 1.1.2.3     public Instr rename(InstrFactory inf, TempMap defMap, TempMap useMap) {
46 cananian 1.1.2.3         return new InstrMOVE(inf, this, getAssem(),
47 cananian 1.1.2.3                              map(defMap,def()), map(useMap,use()));
48 pnkfelix 1.1.2.6     }
49 pnkfelix 1.1.2.6 
50 pnkfelix 1.1.2.6     public Instr cloneMutateAssem(InstrFactory inf, String newAssem) {
51 pnkfelix 1.1.2.6         return new InstrMOVE(inf, this, newAssem, def(), use());
52 cananian 1.1.2.3     }
53 pnkfelix 1.1.2.5 
54 pnkfelix 1.1.2.5     public boolean isMove() { return true; }
55 cananian 1.2     }