1 /* 2 * Copyright 2002 Sun Microsystems, Inc. All Rights Reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 * CA 95054 USA or visit www.sun.com if you need additional information or 21 * have any questions. 22 * 23 */ 24 25 package sun.jvm.hotspot.asm.sparc; 26 27 import sun.jvm.hotspot.asm.*; 28 29 public class SPARCStoreInstruction extends SPARCMemoryInstruction 30 implements StoreInstruction { 31 final protected SPARCRegister register2; // used by double word store instructions 32 final protected Register[] storeSources; 33 34 public SPARCStoreInstruction(String name, int opcode, SPARCRegisterIndirectAddress address, SPARCRegister register, int dataType) { 35 super(name, opcode, address, register, dataType); 36 if (opcode == STD || opcode == STDA) { 37 storeSources = new Register[2]; 38 storeSources[0] = register; 39 int nextRegNum = (register.getNumber() + 1) % SPARCRegisters.NUM_REGISTERS; 40 register2 = SPARCRegisters.getRegister(nextRegNum); 41 storeSources[1] = register2; 42 } else { 43 storeSources = new Register[1]; 44 storeSources[0] = register; 45 register2 = null; 46 } 47 } 48 49 private String defaultInitDescription(StringBuffer buf) { 50 buf.append(getName()); 51 buf.append(spaces); 52 buf.append(register.toString()); 53 buf.append(comma); 54 buf.append(address.toString()); 55 return buf.toString(); 56 } 57 58 protected String getDescription() { 59 StringBuffer buf = new StringBuffer(); 60 if (register == SPARCRegisters.G0) { 61 switch (opcode) { 62 case ST: 63 buf.append("clr"); 64 break; 65 case STH: 66 buf.append("clrh"); 67 break; 68 case STB: 69 buf.append("clrb"); 70 break; 71 default: 72 return defaultInitDescription(buf); 73 } 74 buf.append(spaces); 75 buf.append(address.toString()); 76 return buf.toString(); 77 } else { 78 return defaultInitDescription(buf); 79 } 80 } 81 82 public int getDataType() { 83 return dataType; 84 } 85 86 public Address getStoreDestination() { 87 return address; 88 } 89 90 public Register[] getStoreSources() { 91 return storeSources; 92 } 93 94 public boolean isStore() { 95 return true; 96 } 97 }