Commit 26cc915cff2adeabff44ca8b779de3a54fec0171

Authored by blueswir1
1 parent 77fcd093

Use sethi and arith functions, fix comment

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4560 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 26 additions and 23 deletions
tcg/sparc/tcg-target.c
@@ -243,10 +243,28 @@ static inline int tcg_target_const_match(tcg_target_long val, @@ -243,10 +243,28 @@ static inline int tcg_target_const_match(tcg_target_long val,
243 #define STW (INSN_OP(3) | INSN_OP3(0x04)) 243 #define STW (INSN_OP(3) | INSN_OP3(0x04))
244 #define STX (INSN_OP(3) | INSN_OP3(0x0e)) 244 #define STX (INSN_OP(3) | INSN_OP3(0x0e))
245 245
  246 +static inline void tcg_out_arith(TCGContext *s, int rd, int rs1, int rs2,
  247 + int op)
  248 +{
  249 + tcg_out32(s, op | INSN_RD(rd) | INSN_RS1(rs1) |
  250 + INSN_RS2(rs2));
  251 +}
  252 +
  253 +static inline void tcg_out_arithi(TCGContext *s, int rd, int rs1, int offset,
  254 + int op)
  255 +{
  256 + tcg_out32(s, op | INSN_RD(rd) | INSN_RS1(rs1) |
  257 + INSN_IMM13(offset));
  258 +}
  259 +
246 static inline void tcg_out_mov(TCGContext *s, int ret, int arg) 260 static inline void tcg_out_mov(TCGContext *s, int ret, int arg)
247 { 261 {
248 - tcg_out32(s, ARITH_OR | INSN_RD(ret) | INSN_RS1(arg) |  
249 - INSN_RS2(TCG_REG_G0)); 262 + tcg_out_arith(s, ret, arg, TCG_REG_G0, ARITH_OR);
  263 +}
  264 +
  265 +static inline void tcg_out_sethi(TCGContext *s, int ret, uint32_t arg)
  266 +{
  267 + tcg_out32(s, SETHI | INSN_RD(ret) | ((arg & 0xfffffc00) >> 10));
250 } 268 }
251 269
252 static inline void tcg_out_movi(TCGContext *s, TCGType type, 270 static inline void tcg_out_movi(TCGContext *s, TCGType type,
@@ -260,7 +278,7 @@ static inline void tcg_out_movi(TCGContext *s, TCGType type, @@ -260,7 +278,7 @@ static inline void tcg_out_movi(TCGContext *s, TCGType type,
260 tcg_out32(s, ARITH_OR | INSN_RD(ret) | INSN_RS1(TCG_REG_G0) | 278 tcg_out32(s, ARITH_OR | INSN_RD(ret) | INSN_RS1(TCG_REG_G0) |
261 INSN_IMM13(arg)); 279 INSN_IMM13(arg));
262 else { 280 else {
263 - tcg_out32(s, SETHI | INSN_RD(ret) | ((arg & 0xfffffc00) >> 10)); 281 + tcg_out_sethi(s, ret, arg);
264 if (arg & 0x3ff) 282 if (arg & 0x3ff)
265 tcg_out32(s, ARITH_OR | INSN_RD(ret) | INSN_RS1(ret) | 283 tcg_out32(s, ARITH_OR | INSN_RD(ret) | INSN_RS1(ret) |
266 INSN_IMM13(arg & 0x3ff)); 284 INSN_IMM13(arg & 0x3ff));
@@ -270,7 +288,7 @@ static inline void tcg_out_movi(TCGContext *s, TCGType type, @@ -270,7 +288,7 @@ static inline void tcg_out_movi(TCGContext *s, TCGType type,
270 static inline void tcg_out_ld_raw(TCGContext *s, int ret, 288 static inline void tcg_out_ld_raw(TCGContext *s, int ret,
271 tcg_target_long arg) 289 tcg_target_long arg)
272 { 290 {
273 - tcg_out32(s, SETHI | INSN_RD(ret) | (((uint32_t)arg & 0xfffffc00) >> 10)); 291 + tcg_out_sethi(s, ret, arg);
274 tcg_out32(s, LDUW | INSN_RD(ret) | INSN_RS1(ret) | 292 tcg_out32(s, LDUW | INSN_RD(ret) | INSN_RS1(ret) |
275 INSN_IMM13(arg & 0x3ff)); 293 INSN_IMM13(arg & 0x3ff));
276 } 294 }
@@ -282,7 +300,7 @@ static inline void tcg_out_ld_ptr(TCGContext *s, int ret, @@ -282,7 +300,7 @@ static inline void tcg_out_ld_ptr(TCGContext *s, int ret,
282 if (!check_fit_tl(arg, 32) && (arg & ~0xffffffff) != 0) 300 if (!check_fit_tl(arg, 32) && (arg & ~0xffffffff) != 0)
283 fprintf(stderr, "unimplemented %s with offset %ld\n", __func__, arg); 301 fprintf(stderr, "unimplemented %s with offset %ld\n", __func__, arg);
284 if (!check_fit_i32(arg, 13)) 302 if (!check_fit_i32(arg, 13))
285 - tcg_out32(s, SETHI | INSN_RD(ret) | (((uint32_t)arg & 0xfffffc00) >> 10)); 303 + tcg_out_sethi(s, ret, arg);
286 tcg_out32(s, LDX | INSN_RD(ret) | INSN_RS1(ret) | 304 tcg_out32(s, LDX | INSN_RD(ret) | INSN_RS1(ret) |
287 INSN_IMM13(arg & 0x3ff)); 305 INSN_IMM13(arg & 0x3ff));
288 #else 306 #else
@@ -320,20 +338,6 @@ static inline void tcg_out_st(TCGContext *s, TCGType type, int arg, @@ -320,20 +338,6 @@ static inline void tcg_out_st(TCGContext *s, TCGType type, int arg,
320 tcg_out_ldst(s, arg, arg1, arg2, STX); 338 tcg_out_ldst(s, arg, arg1, arg2, STX);
321 } 339 }
322 340
323 -static inline void tcg_out_arith(TCGContext *s, int rd, int rs1, int rs2,  
324 - int op)  
325 -{  
326 - tcg_out32(s, op | INSN_RD(rd) | INSN_RS1(rs1) |  
327 - INSN_RS2(rs2));  
328 -}  
329 -  
330 -static inline void tcg_out_arithi(TCGContext *s, int rd, int rs1, int offset,  
331 - int op)  
332 -{  
333 - tcg_out32(s, op | INSN_RD(rd) | INSN_RS1(rs1) |  
334 - INSN_IMM13(offset));  
335 -}  
336 -  
337 static inline void tcg_out_sety(TCGContext *s, tcg_target_long val) 341 static inline void tcg_out_sety(TCGContext *s, tcg_target_long val)
338 { 342 {
339 if (val == 0 || val == -1) 343 if (val == 0 || val == -1)
@@ -356,7 +360,7 @@ static inline void tcg_out_addi(TCGContext *s, int reg, tcg_target_long val) @@ -356,7 +360,7 @@ static inline void tcg_out_addi(TCGContext *s, int reg, tcg_target_long val)
356 360
357 static inline void tcg_out_nop(TCGContext *s) 361 static inline void tcg_out_nop(TCGContext *s)
358 { 362 {
359 - tcg_out32(s, SETHI | INSN_RD(TCG_REG_G0) | 0); 363 + tcg_out_sethi(s, TCG_REG_G0, 0);
360 } 364 }
361 365
362 static void tcg_out_branch(TCGContext *s, int opc, int label_index) 366 static void tcg_out_branch(TCGContext *s, int opc, int label_index)
@@ -392,7 +396,7 @@ static void tcg_out_brcond(TCGContext *s, int cond, @@ -392,7 +396,7 @@ static void tcg_out_brcond(TCGContext *s, int cond,
392 int label_index) 396 int label_index)
393 { 397 {
394 if (const_arg2 && arg2 == 0) 398 if (const_arg2 && arg2 == 0)
395 - /* orcc r, r, %g0 */ 399 + /* orcc %g0, r, %g0 */
396 tcg_out_arith(s, TCG_REG_G0, TCG_REG_G0, arg1, ARITH_ORCC); 400 tcg_out_arith(s, TCG_REG_G0, TCG_REG_G0, arg1, ARITH_ORCC);
397 else 401 else
398 /* subcc r1, r2, %g0 */ 402 /* subcc r1, r2, %g0 */
@@ -780,8 +784,7 @@ static inline void tcg_out_op(TCGContext *s, int opc, const TCGArg *args, @@ -780,8 +784,7 @@ static inline void tcg_out_op(TCGContext *s, int opc, const TCGArg *args,
780 case INDEX_op_goto_tb: 784 case INDEX_op_goto_tb:
781 if (s->tb_jmp_offset) { 785 if (s->tb_jmp_offset) {
782 /* direct jump method */ 786 /* direct jump method */
783 - tcg_out32(s, SETHI | INSN_RD(TCG_REG_I5) |  
784 - ((args[0] & 0xffffe000) >> 10)); 787 + tcg_out_sethi(s, TCG_REG_I5, args[0] & 0xffffe000);
785 tcg_out32(s, JMPL | INSN_RD(TCG_REG_G0) | INSN_RS1(TCG_REG_I5) | 788 tcg_out32(s, JMPL | INSN_RD(TCG_REG_G0) | INSN_RS1(TCG_REG_I5) |
786 INSN_IMM13((args[0] & 0x1fff))); 789 INSN_IMM13((args[0] & 0x1fff)));
787 s->tb_jmp_offset[args[0]] = s->code_ptr - s->code_buf; 790 s->tb_jmp_offset[args[0]] = s->code_ptr - s->code_buf;