Skip to content

Commit 23803bb

Browse files
philmdtaylorsimpson
authored andcommitted
target/hexagon: Use tcg_constant_*
Replace uses of tcg_const_* with the allocate and free close together. Inspired-by: Richard Henderson <[email protected]> Reviewed-by: Richard Henderson <[email protected]> Reviewed-by: Taylor Simpson <[email protected]> Signed-off-by: Philippe Mathieu-Daudé <[email protected]> Message-Id: <[email protected]>
1 parent f844f74 commit 23803bb

File tree

5 files changed

+25
-53
lines changed

5 files changed

+25
-53
lines changed

target/hexagon/gen_tcg.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -684,9 +684,8 @@
684684
gen_helper_sfmin(RdV, cpu_env, RsV, RtV)
685685
#define fGEN_TCG_F2_sfclass(SHORTCODE) \
686686
do { \
687-
TCGv imm = tcg_const_tl(uiV); \
687+
TCGv imm = tcg_constant_tl(uiV); \
688688
gen_helper_sfclass(PdV, cpu_env, RsV, imm); \
689-
tcg_temp_free(imm); \
690689
} while (0)
691690
#define fGEN_TCG_F2_sffixupn(SHORTCODE) \
692691
gen_helper_sffixupn(RdV, cpu_env, RsV, RtV)
@@ -712,9 +711,8 @@
712711
gen_helper_dfcmpuo(PdV, cpu_env, RssV, RttV)
713712
#define fGEN_TCG_F2_dfclass(SHORTCODE) \
714713
do { \
715-
TCGv imm = tcg_const_tl(uiV); \
714+
TCGv imm = tcg_constant_tl(uiV); \
716715
gen_helper_dfclass(PdV, cpu_env, RssV, imm); \
717-
tcg_temp_free(imm); \
718716
} while (0)
719717
#define fGEN_TCG_F2_sfmpy(SHORTCODE) \
720718
gen_helper_sfmpy(RdV, cpu_env, RsV, RtV)

target/hexagon/gen_tcg_funcs.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ def gen_tcg_func(f, tag, regs, imms):
403403
if hex_common.need_part1(tag):
404404
f.write(" TCGv part1 = tcg_const_tl(insn->part1);\n")
405405
if hex_common.need_slot(tag):
406-
f.write(" TCGv slot = tcg_const_tl(insn->slot);\n")
406+
f.write(" TCGv slot = tcg_constant_tl(insn->slot);\n")
407407
f.write(" gen_helper_%s(" % (tag))
408408
i=0
409409
## If there is a scalar result, it is the return type
@@ -424,8 +424,6 @@ def gen_tcg_func(f, tag, regs, imms):
424424
if hex_common.need_slot(tag): f.write(", slot")
425425
if hex_common.need_part1(tag): f.write(", part1" )
426426
f.write(");\n")
427-
if hex_common.need_slot(tag):
428-
f.write(" tcg_temp_free(slot);\n")
429427
if hex_common.need_part1(tag):
430428
f.write(" tcg_temp_free(part1);\n")
431429
for immlett,bits,immshift in imms:

target/hexagon/genptr.c

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
static inline void gen_log_predicated_reg_write(int rnum, TCGv val, int slot)
3131
{
32-
TCGv zero = tcg_const_tl(0);
32+
TCGv zero = tcg_constant_tl(0);
3333
TCGv slot_mask = tcg_temp_new();
3434

3535
tcg_gen_andi_tl(slot_mask, hex_slot_cancelled, 1 << slot);
@@ -47,7 +47,6 @@ static inline void gen_log_predicated_reg_write(int rnum, TCGv val, int slot)
4747
tcg_gen_or_tl(hex_reg_written[rnum], hex_reg_written[rnum], slot_mask);
4848
}
4949

50-
tcg_temp_free(zero);
5150
tcg_temp_free(slot_mask);
5251
}
5352

@@ -63,7 +62,7 @@ static inline void gen_log_reg_write(int rnum, TCGv val)
6362
static void gen_log_predicated_reg_write_pair(int rnum, TCGv_i64 val, int slot)
6463
{
6564
TCGv val32 = tcg_temp_new();
66-
TCGv zero = tcg_const_tl(0);
65+
TCGv zero = tcg_constant_tl(0);
6766
TCGv slot_mask = tcg_temp_new();
6867

6968
tcg_gen_andi_tl(slot_mask, hex_slot_cancelled, 1 << slot);
@@ -92,7 +91,6 @@ static void gen_log_predicated_reg_write_pair(int rnum, TCGv_i64 val, int slot)
9291
}
9392

9493
tcg_temp_free(val32);
95-
tcg_temp_free(zero);
9694
tcg_temp_free(slot_mask);
9795
}
9896

@@ -181,9 +179,8 @@ static inline void gen_read_ctrl_reg_pair(DisasContext *ctx, const int reg_num,
181179
tcg_gen_concat_i32_i64(dest, p3_0, hex_gpr[reg_num + 1]);
182180
tcg_temp_free(p3_0);
183181
} else if (reg_num == HEX_REG_PC - 1) {
184-
TCGv pc = tcg_const_tl(ctx->base.pc_next);
182+
TCGv pc = tcg_constant_tl(ctx->base.pc_next);
185183
tcg_gen_concat_i32_i64(dest, hex_gpr[reg_num], pc);
186-
tcg_temp_free(pc);
187184
} else if (reg_num == HEX_REG_QEMU_PKT_CNT) {
188185
TCGv pkt_cnt = tcg_temp_new();
189186
TCGv insn_cnt = tcg_temp_new();
@@ -331,15 +328,13 @@ static inline void gen_store_conditional4(DisasContext *ctx,
331328

332329
tcg_gen_brcond_tl(TCG_COND_NE, vaddr, hex_llsc_addr, fail);
333330

334-
one = tcg_const_tl(0xff);
335-
zero = tcg_const_tl(0);
331+
one = tcg_constant_tl(0xff);
332+
zero = tcg_constant_tl(0);
336333
tmp = tcg_temp_new();
337334
tcg_gen_atomic_cmpxchg_tl(tmp, hex_llsc_addr, hex_llsc_val, src,
338335
ctx->mem_idx, MO_32);
339336
tcg_gen_movcond_tl(TCG_COND_EQ, pred, tmp, hex_llsc_val,
340337
one, zero);
341-
tcg_temp_free(one);
342-
tcg_temp_free(zero);
343338
tcg_temp_free(tmp);
344339
tcg_gen_br(done);
345340

@@ -359,16 +354,14 @@ static inline void gen_store_conditional8(DisasContext *ctx,
359354

360355
tcg_gen_brcond_tl(TCG_COND_NE, vaddr, hex_llsc_addr, fail);
361356

362-
one = tcg_const_i64(0xff);
363-
zero = tcg_const_i64(0);
357+
one = tcg_constant_i64(0xff);
358+
zero = tcg_constant_i64(0);
364359
tmp = tcg_temp_new_i64();
365360
tcg_gen_atomic_cmpxchg_i64(tmp, hex_llsc_addr, hex_llsc_val_i64, src,
366361
ctx->mem_idx, MO_64);
367362
tcg_gen_movcond_i64(TCG_COND_EQ, tmp, tmp, hex_llsc_val_i64,
368363
one, zero);
369364
tcg_gen_extrl_i64_i32(pred, tmp);
370-
tcg_temp_free_i64(one);
371-
tcg_temp_free_i64(zero);
372365
tcg_temp_free_i64(tmp);
373366
tcg_gen_br(done);
374367

@@ -396,9 +389,8 @@ static inline void gen_store1(TCGv_env cpu_env, TCGv vaddr, TCGv src,
396389
static inline void gen_store1i(TCGv_env cpu_env, TCGv vaddr, int32_t src,
397390
DisasContext *ctx, int slot)
398391
{
399-
TCGv tmp = tcg_const_tl(src);
392+
TCGv tmp = tcg_constant_tl(src);
400393
gen_store1(cpu_env, vaddr, tmp, ctx, slot);
401-
tcg_temp_free(tmp);
402394
}
403395

404396
static inline void gen_store2(TCGv_env cpu_env, TCGv vaddr, TCGv src,
@@ -411,9 +403,8 @@ static inline void gen_store2(TCGv_env cpu_env, TCGv vaddr, TCGv src,
411403
static inline void gen_store2i(TCGv_env cpu_env, TCGv vaddr, int32_t src,
412404
DisasContext *ctx, int slot)
413405
{
414-
TCGv tmp = tcg_const_tl(src);
406+
TCGv tmp = tcg_constant_tl(src);
415407
gen_store2(cpu_env, vaddr, tmp, ctx, slot);
416-
tcg_temp_free(tmp);
417408
}
418409

419410
static inline void gen_store4(TCGv_env cpu_env, TCGv vaddr, TCGv src,
@@ -426,9 +417,8 @@ static inline void gen_store4(TCGv_env cpu_env, TCGv vaddr, TCGv src,
426417
static inline void gen_store4i(TCGv_env cpu_env, TCGv vaddr, int32_t src,
427418
DisasContext *ctx, int slot)
428419
{
429-
TCGv tmp = tcg_const_tl(src);
420+
TCGv tmp = tcg_constant_tl(src);
430421
gen_store4(cpu_env, vaddr, tmp, ctx, slot);
431-
tcg_temp_free(tmp);
432422
}
433423

434424
static inline void gen_store8(TCGv_env cpu_env, TCGv vaddr, TCGv_i64 src,
@@ -443,18 +433,15 @@ static inline void gen_store8(TCGv_env cpu_env, TCGv vaddr, TCGv_i64 src,
443433
static inline void gen_store8i(TCGv_env cpu_env, TCGv vaddr, int64_t src,
444434
DisasContext *ctx, int slot)
445435
{
446-
TCGv_i64 tmp = tcg_const_i64(src);
436+
TCGv_i64 tmp = tcg_constant_i64(src);
447437
gen_store8(cpu_env, vaddr, tmp, ctx, slot);
448-
tcg_temp_free_i64(tmp);
449438
}
450439

451440
static TCGv gen_8bitsof(TCGv result, TCGv value)
452441
{
453-
TCGv zero = tcg_const_tl(0);
454-
TCGv ones = tcg_const_tl(0xff);
442+
TCGv zero = tcg_constant_tl(0);
443+
TCGv ones = tcg_constant_tl(0xff);
455444
tcg_gen_movcond_tl(TCG_COND_NE, result, value, zero, ones, zero);
456-
tcg_temp_free(zero);
457-
tcg_temp_free(ones);
458445

459446
return result;
460447
}

target/hexagon/macros.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,14 +189,13 @@ static inline void gen_pred_cancel(TCGv pred, int slot_num)
189189
{
190190
TCGv slot_mask = tcg_const_tl(1 << slot_num);
191191
TCGv tmp = tcg_temp_new();
192-
TCGv zero = tcg_const_tl(0);
192+
TCGv zero = tcg_constant_tl(0);
193193
tcg_gen_or_tl(slot_mask, hex_slot_cancelled, slot_mask);
194194
tcg_gen_andi_tl(tmp, pred, 1);
195195
tcg_gen_movcond_tl(TCG_COND_EQ, hex_slot_cancelled, tmp, zero,
196196
slot_mask, hex_slot_cancelled);
197197
tcg_temp_free(slot_mask);
198198
tcg_temp_free(tmp);
199-
tcg_temp_free(zero);
200199
}
201200
#define PRED_LOAD_CANCEL(PRED, EA) \
202201
gen_pred_cancel(PRED, insn->is_endloop ? 4 : insn->slot)

target/hexagon/translate.c

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@ static const char * const hexagon_prednames[] = {
5454

5555
static void gen_exception_raw(int excp)
5656
{
57-
TCGv_i32 helper_tmp = tcg_const_i32(excp);
58-
gen_helper_raise_exception(cpu_env, helper_tmp);
59-
tcg_temp_free_i32(helper_tmp);
57+
gen_helper_raise_exception(cpu_env, tcg_constant_i32(excp));
6058
}
6159

6260
static void gen_exec_counters(DisasContext *ctx)
@@ -288,7 +286,7 @@ static void gen_pred_writes(DisasContext *ctx, Packet *pkt)
288286
* write of the predicates.
289287
*/
290288
if (pkt->pkt_has_endloop) {
291-
TCGv zero = tcg_const_tl(0);
289+
TCGv zero = tcg_constant_tl(0);
292290
TCGv pred_written = tcg_temp_new();
293291
for (i = 0; i < ctx->preg_log_idx; i++) {
294292
int pred_num = ctx->preg_log[i];
@@ -299,7 +297,6 @@ static void gen_pred_writes(DisasContext *ctx, Packet *pkt)
299297
hex_new_pred_value[pred_num],
300298
hex_pred[pred_num]);
301299
}
302-
tcg_temp_free(zero);
303300
tcg_temp_free(pred_written);
304301
} else {
305302
for (i = 0; i < ctx->preg_log_idx; i++) {
@@ -317,11 +314,9 @@ static void gen_pred_writes(DisasContext *ctx, Packet *pkt)
317314
static void gen_check_store_width(DisasContext *ctx, int slot_num)
318315
{
319316
if (HEX_DEBUG) {
320-
TCGv slot = tcg_const_tl(slot_num);
321-
TCGv check = tcg_const_tl(ctx->store_width[slot_num]);
317+
TCGv slot = tcg_constant_tl(slot_num);
318+
TCGv check = tcg_constant_tl(ctx->store_width[slot_num]);
322319
gen_helper_debug_check_store_width(cpu_env, slot, check);
323-
tcg_temp_free(slot);
324-
tcg_temp_free(check);
325320
}
326321
}
327322

@@ -403,9 +398,8 @@ void process_store(DisasContext *ctx, Packet *pkt, int slot_num)
403398
* TCG generation time, we'll use a helper to
404399
* avoid branching based on the width at runtime.
405400
*/
406-
TCGv slot = tcg_const_tl(slot_num);
401+
TCGv slot = tcg_constant_tl(slot_num);
407402
gen_helper_commit_store(cpu_env, slot);
408-
tcg_temp_free(slot);
409403
}
410404
}
411405
tcg_temp_free(address);
@@ -436,7 +430,7 @@ static void process_dczeroa(DisasContext *ctx, Packet *pkt)
436430
if (pkt->pkt_has_dczeroa) {
437431
/* Store 32 bytes of zero starting at (addr & ~0x1f) */
438432
TCGv addr = tcg_temp_new();
439-
TCGv_i64 zero = tcg_const_i64(0);
433+
TCGv_i64 zero = tcg_constant_i64(0);
440434

441435
tcg_gen_andi_tl(addr, hex_dczero_addr, ~0x1f);
442436
tcg_gen_qemu_st64(zero, addr, ctx->mem_idx);
@@ -448,7 +442,6 @@ static void process_dczeroa(DisasContext *ctx, Packet *pkt)
448442
tcg_gen_qemu_st64(zero, addr, ctx->mem_idx);
449443

450444
tcg_temp_free(addr);
451-
tcg_temp_free_i64(zero);
452445
}
453446
}
454447

@@ -510,15 +503,12 @@ static void gen_commit_packet(DisasContext *ctx, Packet *pkt)
510503
update_exec_counters(ctx, pkt);
511504
if (HEX_DEBUG) {
512505
TCGv has_st0 =
513-
tcg_const_tl(pkt->pkt_has_store_s0 && !pkt->pkt_has_dczeroa);
506+
tcg_constant_tl(pkt->pkt_has_store_s0 && !pkt->pkt_has_dczeroa);
514507
TCGv has_st1 =
515-
tcg_const_tl(pkt->pkt_has_store_s1 && !pkt->pkt_has_dczeroa);
508+
tcg_constant_tl(pkt->pkt_has_store_s1 && !pkt->pkt_has_dczeroa);
516509

517510
/* Handy place to set a breakpoint at the end of execution */
518511
gen_helper_debug_commit_end(cpu_env, has_st0, has_st1);
519-
520-
tcg_temp_free(has_st0);
521-
tcg_temp_free(has_st1);
522512
}
523513

524514
if (pkt->pkt_has_cof) {

0 commit comments

Comments
 (0)