hotspot/agent/src/share/classes/sun/jvm/hotspot/asm/sparc/SPARCV9Disassembler.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 // Please refer to "The SPARC Architecture Manual - Version 9"
       
    30 
       
    31 public class SPARCV9Disassembler extends SPARCDisassembler
       
    32                     implements /* imports */ SPARCV9Opcodes {
       
    33     public SPARCV9Disassembler(long startPc, byte[] code, SPARCV9InstructionFactory factory) {
       
    34         super(startPc, code, factory);
       
    35     }
       
    36 
       
    37     public SPARCV9Disassembler(long startPc, byte[] code) {
       
    38         this(startPc, code, new SPARCV9InstructionFactoryImpl());
       
    39     }
       
    40 
       
    41     // decoders for format 2 instructions
       
    42     private static InstructionDecoder format2Decoders[] = {
       
    43         new UnimpDecoder(),
       
    44         new V9IntegerBranchDecoder(),
       
    45         new IntegerBranchDecoder(),
       
    46         new V9IntRegisterBranchDecoder(),
       
    47         new SethiDecoder(),
       
    48         new V9FloatBranchDecoder(),
       
    49         new FloatBranchDecoder(),
       
    50         illegalDecoder
       
    51     };
       
    52 
       
    53     protected InstructionDecoder getFormat2Decoder(int op2) {
       
    54         return format2Decoders[op2];
       
    55     }
       
    56 
       
    57     // op3 opcode table for op=3 (FORMAT_3) instructions - (memory instructions)
       
    58     // E.2 Tables - Page 275 - Table 33.
       
    59     private static final InstructionDecoder format3Decoders[][] = {
       
    60         {
       
    61           new LoadDecoder(LDUW, "ld" /* lduw */, RTLDT_UNSIGNED_WORD), new V9AlternateSpaceLoadDecoder(LDUWA, "lduwa", RTLDT_UNSIGNED_WORD),
       
    62           new LoadDecoder(LDF,"ld", RTLDT_FL_SINGLE),  new V9AlternateSpaceLoadDecoder(LDFA, "lda", RTLDT_FL_SINGLE)
       
    63         },
       
    64         {
       
    65           new LoadDecoder(LDUB, "ldub", RTLDT_UNSIGNED_BYTE),   new V9AlternateSpaceLoadDecoder(LDUBA, "lduba", RTLDT_UNSIGNED_BYTE),
       
    66           new V9SpecialLoadDecoder(LDFSR), illegalDecoder
       
    67         },
       
    68         {
       
    69           new LoadDecoder(LDUH, "lduh", RTLDT_UNSIGNED_HALF),  new V9AlternateSpaceLoadDecoder(LDUHA, "lduha", RTLDT_UNSIGNED_HALF),
       
    70           new LoadDecoder(LDQF, "ldq", RTLDT_FL_QUAD), new V9AlternateSpaceLoadDecoder(LDQFA, "ldqa", RTLDT_FL_QUAD)
       
    71         },
       
    72         {
       
    73           new LoadDecoder(LDD, "ldd", RTLDT_UNSIGNED_DWORD), new V9AlternateSpaceLoadDecoder(LDDA, "ldda", RTLDT_UNSIGNED_DWORD),
       
    74           new LoadDecoder(LDDF, "ldd", RTLDT_FL_DOUBLE), new LoadDecoder(LDDFA, "ldda", RTLDT_FL_DOUBLE)
       
    75         },
       
    76         {
       
    77           new StoreDecoder(STW, "st" /* stw, stuw, stsw */, RTLDT_UNSIGNED_WORD), new V9AlternateSpaceStoreDecoder(STWA, "stwa", RTLDT_UNSIGNED_WORD),
       
    78           new StoreDecoder(STF, "st", RTLDT_FL_SINGLE), new StoreDecoder(STFA, "st", RTLDT_FL_SINGLE),
       
    79         },
       
    80         {
       
    81           new StoreDecoder(STB, "stb", RTLDT_UNSIGNED_BYTE), new V9AlternateSpaceStoreDecoder(STBA, "stba", RTLDT_UNSIGNED_BYTE),
       
    82           new V9SpecialStoreDecoder(STFSR), illegalDecoder
       
    83         },
       
    84         {
       
    85           new StoreDecoder(STH, "sth", RTLDT_UNSIGNED_HALF), new V9AlternateSpaceStoreDecoder(STHA, "stha", RTLDT_UNSIGNED_HALF),
       
    86           new StoreDecoder(STQF, "stq", RTLDT_FL_QUAD), new V9AlternateSpaceStoreDecoder(STQFA, "stqa", RTLDT_FL_QUAD),
       
    87         },
       
    88         {
       
    89           new StoreDecoder(STD, "std", RTLDT_UNSIGNED_DWORD), new V9AlternateSpaceStoreDecoder(STDA, "stda", RTLDT_UNSIGNED_DWORD),
       
    90           new StoreDecoder(STDF, "std", RTLDT_FL_DOUBLE), new V9AlternateSpaceStoreDecoder(STDFA, "stda", RTLDT_FL_DOUBLE)
       
    91         },
       
    92         {
       
    93           new LoadDecoder(LDSW, "ldsw", RTLDT_SIGNED_WORD), new V9AlternateSpaceLoadDecoder(LDSWA, "ldswa", RTLDT_SIGNED_WORD),
       
    94           illegalDecoder, illegalDecoder
       
    95         },
       
    96         {
       
    97           new LoadDecoder(LDSB, "ldsb", RTLDT_SIGNED_BYTE), new V9AlternateSpaceLoadDecoder(LDSBA, "ldsba", RTLDT_UNSIGNED_BYTE),
       
    98           illegalDecoder, illegalDecoder
       
    99         },
       
   100         {
       
   101           new LoadDecoder(LDSH, "ldsh", RTLDT_SIGNED_HALF), new V9AlternateSpaceLoadDecoder(LDSHA, "ldsha", RTLDT_UNSIGNED_HALF),
       
   102           illegalDecoder, illegalDecoder
       
   103         },
       
   104         {
       
   105           new LoadDecoder(LDX, "ldx", RTLDT_UNSIGNED_DWORD), new V9AlternateSpaceLoadDecoder(LDXA, "ldxa", RTLDT_UNSIGNED_DWORD),
       
   106           illegalDecoder, illegalDecoder
       
   107         },
       
   108         {
       
   109           illegalDecoder, illegalDecoder,
       
   110           illegalDecoder, new V9CasDecoder(CASA, "casa", RTLDT_UNSIGNED_WORD)
       
   111         },
       
   112         {
       
   113           new LdstubDecoder(LDSTUB, "ldstub", RTLDT_UNSIGNED_BYTE), new V9AlternateSpaceLdstubDecoder(LDSTUBA, "ldstuba", RTLDT_UNSIGNED_BYTE),
       
   114           new V9PrefetchDecoder(), new V9AlternateSpacePrefetchDecoder()
       
   115         },
       
   116         {
       
   117           new StoreDecoder(STX, "stx", RTLDT_UNSIGNED_DWORD), new V9AlternateSpaceStoreDecoder(STXA, "stxa", RTLDT_UNSIGNED_DWORD),
       
   118           illegalDecoder, new V9CasDecoder(CASXA, "casxa", RTLDT_UNSIGNED_DWORD)
       
   119         },
       
   120         {
       
   121           new SwapDecoder(SWAP, "swap", RTLDT_UNSIGNED_WORD), new V9AlternateSpaceSwapDecoder(SWAPA, "swapa", RTLDT_UNSIGNED_WORD),
       
   122           illegalDecoder, illegalDecoder
       
   123         },
       
   124     };
       
   125 
       
   126     protected InstructionDecoder getFormat3Decoder(int row, int column) {
       
   127         return format3Decoders[row][column];
       
   128     }
       
   129 
       
   130     // op3 decoder table for op=2 (FORMAT_3A) instructions
       
   131     // E Opcode Maps - Page 274 - Table 32
       
   132 
       
   133     protected static final InstructionDecoder format3ADecoders[][] = {
       
   134         {
       
   135           new ArithmeticDecoder(ADD, "add", RTLOP_ADD), new ArithmeticDecoder(ADDcc, "addcc", RTLOP_ADD),
       
   136           new ArithmeticDecoder(TADDcc, "taddcc", RTLOP_ADD),  new V9WriteDecoder()
       
   137         },
       
   138         {
       
   139           new LogicDecoder(AND, "and", RTLOP_AND), new LogicDecoder(ANDcc, "andcc", RTLOP_AND),
       
   140           new ArithmeticDecoder(TSUBcc, "tsubcc", RTLOP_ADD),  new V9SavedRestoredDecoder()
       
   141         },
       
   142         {
       
   143           new LogicDecoder(OR, "or", RTLOP_OR), new LogicDecoder(ORcc, "orcc", RTLOP_OR),
       
   144           new ArithmeticDecoder(TADDccTV, "taddcctv", RTLOP_ADD),  new V9WrprDecoder()
       
   145         },
       
   146         {
       
   147           new LogicDecoder(XOR, "xor", RTLOP_XOR), new LogicDecoder(XORcc, "xorcc", RTLOP_XOR),
       
   148           new ArithmeticDecoder(TSUBccTV, "tsubcctv", RTLOP_SUB), illegalDecoder
       
   149         },
       
   150         {
       
   151           new ArithmeticDecoder(SUB, "sub", RTLOP_SUB),  new ArithmeticDecoder(SUBcc, "subcc", RTLOP_SUB),
       
   152           new ArithmeticDecoder(MULScc, "mulscc", RTLOP_SMUL), new V9FPop1Decoder()
       
   153         },
       
   154         {
       
   155           new LogicDecoder(ANDN, "andn", RTLOP_NAND), new LogicDecoder(ANDNcc, "andncc", RTLOP_NAND),
       
   156           new V9ShiftDecoder(SLL, "sll", RTLOP_SLL), new V9FPop2Decoder()
       
   157         },
       
   158         {
       
   159           new LogicDecoder(ORN, "orn", RTLOP_NOR), new LogicDecoder(ORNcc, "orncc", RTLOP_NOR),
       
   160           new V9ShiftDecoder(SRL, "srl", RTLOP_SRL), new CoprocessorDecoder(IMPDEP1)
       
   161         },
       
   162         {
       
   163           new LogicDecoder(XNOR, "xnor", RTLOP_XNOR), new LogicDecoder(XNORcc, "xnorcc", RTLOP_XNOR),
       
   164           new V9ShiftDecoder(SRA, "sra", RTLOP_SRA), new CoprocessorDecoder(IMPDEP2)
       
   165         },
       
   166         {
       
   167           new ArithmeticDecoder(ADDC, "addc", RTLOP_ADDC), new ArithmeticDecoder(ADDCcc, "addccc", RTLOP_ADDC),
       
   168           new V9ReadDecoder(), new JmplDecoder()
       
   169         },
       
   170         {
       
   171           new ArithmeticDecoder(MULX, "mulx", RTLOP_UMUL), illegalDecoder,
       
   172           illegalDecoder, new RettDecoder()
       
   173         },
       
   174         {
       
   175           new ArithmeticDecoder(UMUL, "umul", RTLOP_UMUL), new ArithmeticDecoder(UMULcc, "umulcc", RTLOP_UMUL),
       
   176           new V9RdprDecoder(), new TrapDecoder()
       
   177         },
       
   178         {
       
   179           new ArithmeticDecoder(SMUL, "smul", RTLOP_SMUL), new ArithmeticDecoder(SMULcc, "smulcc", RTLOP_SMUL),
       
   180           new V9FlushwDecoder(), new FlushDecoder()
       
   181         },
       
   182         {
       
   183           new ArithmeticDecoder(SUBC, "subc", RTLOP_SUBC), new ArithmeticDecoder(SUBCcc, "subccc", RTLOP_SUBC),
       
   184           new V9MOVccDecoder(), new SaveDecoder()
       
   185         },
       
   186         {
       
   187           new ArithmeticDecoder(UDIVX, "udivx", RTLOP_UDIV), illegalDecoder,
       
   188           new ArithmeticDecoder(SDIVX, "sdivx", RTLOP_SDIV), new RestoreDecoder()
       
   189         },
       
   190         {
       
   191           new ArithmeticDecoder(UDIV, "udiv", RTLOP_UDIV),  new ArithmeticDecoder(UDIVcc, "udivcc", RTLOP_UDIV),
       
   192           new V9PopcDecoder(), new V9DoneRetryDecoder()
       
   193         },
       
   194         {
       
   195           new ArithmeticDecoder(SDIV, "sdiv", RTLOP_SDIV), new ArithmeticDecoder(SDIVcc, "sdivcc", RTLOP_SDIV),
       
   196           new V9MOVrDecoder(), illegalDecoder
       
   197         }
       
   198     };
       
   199 
       
   200     protected InstructionDecoder getFormat3ADecoder(int row, int column) {
       
   201         return format3ADecoders[row][column];
       
   202     }
       
   203 }