hotspot/agent/src/share/classes/sun/jvm/hotspot/asm/sparc/RegisterDecoder.java
changeset 13905 12e9215f3daa
parent 13904 173d83d9c9d7
parent 13903 eebf638312d2
child 13907 52873e4bbeaa
equal deleted inserted replaced
13904:173d83d9c9d7 13905:12e9215f3daa
     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.RTLDataTypes;
       
    28 
       
    29 class RegisterDecoder implements /* imports */ RTLDataTypes {
       
    30     // refer to page 40 - section 5.1.4.1 - Floating-point Register Number Encoding
       
    31     private static SPARCFloatRegister decodeDouble(int num) {
       
    32         // 6 bit double precision registers are encoded in 5 bits as
       
    33         // b<4> b<3> b<2> b<1> b<5>.
       
    34 
       
    35         boolean lsb = (0x1 & num) != 0;
       
    36         if (lsb)
       
    37             num |= 0x20;  // 10000b
       
    38 
       
    39         if ((num % 2) != 0)
       
    40             return null;
       
    41 
       
    42         return SPARCFloatRegisters.getRegister(num);
       
    43     }
       
    44 
       
    45     private static SPARCFloatRegister decodeQuad(int num) {
       
    46         // 6 bit quad precision registers are encoded in 5 bits as
       
    47         // b<4> b<3> b<2> 0 b<5>
       
    48 
       
    49         boolean lsb = (0x1 & num) != 0;
       
    50         if (lsb)
       
    51             num |= 0x20; // 10000b
       
    52 
       
    53         if ((num % 4) != 0)
       
    54             return null;
       
    55 
       
    56         return SPARCFloatRegisters.getRegister(num);
       
    57     }
       
    58 
       
    59     static SPARCRegister decode(int dataType, int regNum) {
       
    60         regNum &= 0x1F; // mask out all but lsb 5 bits
       
    61         SPARCRegister result = null;
       
    62         switch (dataType) {
       
    63             case RTLDT_FL_SINGLE:
       
    64                 result = SPARCFloatRegisters.getRegister(regNum);
       
    65                 break;
       
    66 
       
    67             case RTLDT_FL_DOUBLE:
       
    68                 result = decodeDouble(regNum);
       
    69                 break;
       
    70 
       
    71             case RTLDT_FL_QUAD:
       
    72                 result = decodeQuad(regNum);
       
    73                 break;
       
    74 
       
    75             case RTLDT_UNKNOWN:
       
    76                 result = null;
       
    77                 break;
       
    78 
       
    79             default: // some integer register
       
    80                 result = SPARCRegisters.getRegister(regNum);
       
    81                 break;
       
    82         }
       
    83         return result;
       
    84     }
       
    85 }