hotspot/agent/src/share/classes/sun/jvm/hotspot/asm/sparc/SPARCStoreInstruction.java
changeset 13911 e59cfb5f223b
parent 13910 aded5e617602
parent 13909 9b94bf4dcc0c
child 13912 3bd874584fc0
equal deleted inserted replaced
13910:aded5e617602 13911:e59cfb5f223b
     1 /*
       
     2  * Copyright (c) 2002, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    20  * or visit www.oracle.com if you need additional information or have any
       
    21  * 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 }