From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Jzy8c-0001P3-Sc for qemu-devel@nongnu.org; Sat, 24 May 2008 14:06:38 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Jzy8b-0001Ny-JM for qemu-devel@nongnu.org; Sat, 24 May 2008 14:06:38 -0400 Received: from [199.232.76.173] (port=34287 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Jzy8b-0001Np-FE for qemu-devel@nongnu.org; Sat, 24 May 2008 14:06:37 -0400 Received: from savannah.gnu.org ([199.232.41.3]:48662 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Jzy8b-0007eo-1y for qemu-devel@nongnu.org; Sat, 24 May 2008 14:06:37 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1Jzy8a-0002aK-IM for qemu-devel@nongnu.org; Sat, 24 May 2008 18:06:36 +0000 Received: from blueswir1 by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1Jzy8a-0002aF-8J for qemu-devel@nongnu.org; Sat, 24 May 2008 18:06:36 +0000 MIME-Version: 1.0 Errors-To: blueswir1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Blue Swirl Message-Id: Date: Sat, 24 May 2008 18:06:36 +0000 Subject: [Qemu-devel] [4560] Use sethi and arith functions, fix comment Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Revision: 4560 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=4560 Author: blueswir1 Date: 2008-05-24 18:06:35 +0000 (Sat, 24 May 2008) Log Message: ----------- Use sethi and arith functions, fix comment Modified Paths: -------------- trunk/tcg/sparc/tcg-target.c Modified: trunk/tcg/sparc/tcg-target.c =================================================================== --- trunk/tcg/sparc/tcg-target.c 2008-05-24 16:41:17 UTC (rev 4559) +++ trunk/tcg/sparc/tcg-target.c 2008-05-24 18:06:35 UTC (rev 4560) @@ -243,12 +243,30 @@ #define STW (INSN_OP(3) | INSN_OP3(0x04)) #define STX (INSN_OP(3) | INSN_OP3(0x0e)) +static inline void tcg_out_arith(TCGContext *s, int rd, int rs1, int rs2, + int op) +{ + tcg_out32(s, op | INSN_RD(rd) | INSN_RS1(rs1) | + INSN_RS2(rs2)); +} + +static inline void tcg_out_arithi(TCGContext *s, int rd, int rs1, int offset, + int op) +{ + tcg_out32(s, op | INSN_RD(rd) | INSN_RS1(rs1) | + INSN_IMM13(offset)); +} + static inline void tcg_out_mov(TCGContext *s, int ret, int arg) { - tcg_out32(s, ARITH_OR | INSN_RD(ret) | INSN_RS1(arg) | - INSN_RS2(TCG_REG_G0)); + tcg_out_arith(s, ret, arg, TCG_REG_G0, ARITH_OR); } +static inline void tcg_out_sethi(TCGContext *s, int ret, uint32_t arg) +{ + tcg_out32(s, SETHI | INSN_RD(ret) | ((arg & 0xfffffc00) >> 10)); +} + static inline void tcg_out_movi(TCGContext *s, TCGType type, int ret, tcg_target_long arg) { @@ -260,7 +278,7 @@ tcg_out32(s, ARITH_OR | INSN_RD(ret) | INSN_RS1(TCG_REG_G0) | INSN_IMM13(arg)); else { - tcg_out32(s, SETHI | INSN_RD(ret) | ((arg & 0xfffffc00) >> 10)); + tcg_out_sethi(s, ret, arg); if (arg & 0x3ff) tcg_out32(s, ARITH_OR | INSN_RD(ret) | INSN_RS1(ret) | INSN_IMM13(arg & 0x3ff)); @@ -270,7 +288,7 @@ static inline void tcg_out_ld_raw(TCGContext *s, int ret, tcg_target_long arg) { - tcg_out32(s, SETHI | INSN_RD(ret) | (((uint32_t)arg & 0xfffffc00) >> 10)); + tcg_out_sethi(s, ret, arg); tcg_out32(s, LDUW | INSN_RD(ret) | INSN_RS1(ret) | INSN_IMM13(arg & 0x3ff)); } @@ -282,7 +300,7 @@ if (!check_fit_tl(arg, 32) && (arg & ~0xffffffff) != 0) fprintf(stderr, "unimplemented %s with offset %ld\n", __func__, arg); if (!check_fit_i32(arg, 13)) - tcg_out32(s, SETHI | INSN_RD(ret) | (((uint32_t)arg & 0xfffffc00) >> 10)); + tcg_out_sethi(s, ret, arg); tcg_out32(s, LDX | INSN_RD(ret) | INSN_RS1(ret) | INSN_IMM13(arg & 0x3ff)); #else @@ -320,20 +338,6 @@ tcg_out_ldst(s, arg, arg1, arg2, STX); } -static inline void tcg_out_arith(TCGContext *s, int rd, int rs1, int rs2, - int op) -{ - tcg_out32(s, op | INSN_RD(rd) | INSN_RS1(rs1) | - INSN_RS2(rs2)); -} - -static inline void tcg_out_arithi(TCGContext *s, int rd, int rs1, int offset, - int op) -{ - tcg_out32(s, op | INSN_RD(rd) | INSN_RS1(rs1) | - INSN_IMM13(offset)); -} - static inline void tcg_out_sety(TCGContext *s, tcg_target_long val) { if (val == 0 || val == -1) @@ -356,7 +360,7 @@ static inline void tcg_out_nop(TCGContext *s) { - tcg_out32(s, SETHI | INSN_RD(TCG_REG_G0) | 0); + tcg_out_sethi(s, TCG_REG_G0, 0); } static void tcg_out_branch(TCGContext *s, int opc, int label_index) @@ -392,7 +396,7 @@ int label_index) { if (const_arg2 && arg2 == 0) - /* orcc r, r, %g0 */ + /* orcc %g0, r, %g0 */ tcg_out_arith(s, TCG_REG_G0, TCG_REG_G0, arg1, ARITH_ORCC); else /* subcc r1, r2, %g0 */ @@ -780,8 +784,7 @@ case INDEX_op_goto_tb: if (s->tb_jmp_offset) { /* direct jump method */ - tcg_out32(s, SETHI | INSN_RD(TCG_REG_I5) | - ((args[0] & 0xffffe000) >> 10)); + tcg_out_sethi(s, TCG_REG_I5, args[0] & 0xffffe000); tcg_out32(s, JMPL | INSN_RD(TCG_REG_G0) | INSN_RS1(TCG_REG_I5) | INSN_IMM13((args[0] & 0x1fff))); s->tb_jmp_offset[args[0]] = s->code_ptr - s->code_buf;