* ========== Copyright Header Begin ==========================================
* OpenSPARC T2 Processor File: SS_Opcode.h
* Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
* The above named program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License version 2 as published by the Free Software Foundation.
* The above named program is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
* You should have received a copy of the GNU General Public
* License along with this work; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
* ========== Copyright Header End ============================================
bool operator==( const SS_Opcode
& o
) { return opc
== o
.opc
; }
bool operator!=( const SS_Opcode
& o
) { return opc
!= o
.opc
; }
SS_Opcode
& operator=( uint32_t o
) { opc
= o
; return *this; }
uint32_t operator()() { return opc
; }
void set ( uint32_t o
) { opc
= o
; }
uint32_t get() { return opc
; }
uint_t
get_op() { return (opc
>> 30) & 3; }
uint_t
get_op2() { return (opc
>> 22) & 0x7; }
uint_t
get_op2cc() { return (opc
>> 20) & 0x1f; }
uint_t
get_op3() { return (opc
>> 19) & 0x3f; }
uint_t
get_opf() { return (opc
>> 5) & 0x1ff; }
uint_t
get_i() { return (opc
>> 13) & 1; }
uint_t
get_a() { return (opc
>> 29) & 1; }
uint_t
get_cond() { return (opc
>> 25) & 0xf; }
uint_t
get_fcn() { return (opc
>> 25) & 0x1f; }
uint_t
get_cc() { return (opc
>> 20) & 3; }
uint_t
get_x() { return (opc
>> 12) & 1; }
uint_t
get_ccr() { return (opc
>> 11) & 3; }
int_t
get_rs1() { return (opc
>> 14) & 0x1f; }
int_t
get_rs2() { return opc
& 0x1f; }
int_t
get_rd() { return (opc
>> 25) & 0x1f; }
int_t
get_rs1_irf() { return (opc
>> 11) & 0xf8; }
int_t
get_rs2_irf() { return (opc
<< 3) & 0xf8; }
int_t
get_rd_irf() { return (opc
>> 22) & 0xf8; }
int_t
get_p() { return (opc
>> 19) & 1; }
return ((opc
>> 12) & 0x7c) ^ 0x4;
return (opc
>> 12) & 0x7c;
return ((opc
<< 2) & 0x7c) ^ 0x4;
return (opc
<< 2) & 0x7c;
return ((opc
>> 7) & 0x7c) ^ 0x4;
return (opc
>> 7) & 0x7c;
return ((opc
>> 23) & 0x7c) ^ 0x4;
return (opc
>> 23) & 0x7c;
int_t
get_rs1_drf() { return (((opc
) >> 7) & 0x80) | (((opc
) >> 12) & 0x78); }
int_t
get_rs2_drf() { return (((opc
) << 7) & 0x80) | (((opc
) << 2) & 0x78); }
int_t
get_rs3_drf() { return (((opc
) >> 2) & 0x80) | (((opc
) >> 7) & 0x78); }
int_t
get_rd_drf() { return (((opc
) >> 18) & 0x80) | (((opc
) >> 23) & 0x78); }
int64_t get_simm10() { return (int64_t(opc
) << 54) >> 54; }
int64_t get_simm11() { return (int64_t(opc
) << 53) >> 53; }
int64_t get_simm13() { return (int64_t(opc
) << 51) >> 51; }
uint64_t get_imm3() { return opc
& 0x7; }
uint64_t get_imm5() { return opc
& 0x1f; }
uint64_t get_imm6() { return opc
& 0x3f; }
uint64_t get_imm7() { return opc
& 0x7f; }
uint64_t get_imm8() { return opc
& 0xff; }
uint64_t get_imm16() { return ((opc
>> 6) & 0xc000) | (opc
& 0x3fff); }
uint64_t get_imm22() { return opc
<< 10; }
uint32_t get_imm_asi() { return (opc
>> 5) & 0xff; }
int64_t get_disp16() { return int64_t(((uint64_t(opc
)>>20)<<62)|((uint64_t(opc
)<<50)>>2)) >> 46; }
int64_t get_disp19() { return (int64_t(opc
) << 45) >> 43; }
int64_t get_disp22() { return (int64_t(opc
) << 42) >> 40; }
int64_t get_disp30() { return (int64_t(opc
) << 34) >> 32; }
// is_zero_<to>_<from>() returns true when bits <from> to <to> (inclusive) are
// zero. False is returned otherwise. The methods are used in decoding.
bool is_zero_29_25() { return 0 == ((opc
>> 25) & 0x1f); }
bool is_zero_18_0() { return 0 == (opc
& 0x7ffff); }
bool is_zero_18_14() { return 0 == ((opc
>> 14) & 0x1f); }
bool is_zero_18_18() { return 0 == (opc
& 0x40000); }
bool is_zero_13_0() { return 0 == (opc
& 0x3fff); }
bool is_zero_12_8() { return 0 == ((opc
>> 8) & 0x1f); }
bool is_zero_12_7() { return 0 == ((opc
>> 7) & 0x3f); }
bool is_zero_12_5() { return 0 == ((opc
>> 5) & 0xff); }
bool is_zero_11_7() { return 0 == (opc
& 0xf80); }
bool is_zero_11_6() { return 0 == (opc
& 0xfc0); }
bool is_zero_11_5() { return 0 == (opc
& 0xfe0); }
bool is_zero_10_8() { return 0 == (opc
& 0x700); }
bool is_zero_10_5() { return 0 == (opc
& 0x7e0); }
bool is_zero_9_5() { return 0 == (opc
& 0x3e0); }
bool is_zero_4_0() { return 0 == (opc
& 0x1f); }
bool is_zero_4_3() { return 0 == (opc
& 0x18); }
void set_rs1( uint32_t v
) { opc
= (opc
& ~(0x1f << 14)) | ((v
& 0x1f) << 14); }
void set_rs2( uint32_t v
) { opc
= (opc
& ~ 0x1f ) | ( v
& 0x1f ); }
void set_rd ( uint32_t v
) { opc
= (opc
& ~(0x1f << 25)) | ((v
& 0x1f) << 25); }
void set_imm( uint32_t v
) { opc
= (opc
& ~0x3fff) | (v
& 0x3fff); }