Skip to content

Commit 5925588

Browse files
committed
Merge remote-tracking branch 'remotes/rth/tags/pull-tcg-20180502' into staging
Queued TCG patches # gpg: Signature made Wed 02 May 2018 18:43:33 BST # gpg: using RSA key 64DF38E8AF7E215F # gpg: Good signature from "Richard Henderson <[email protected]>" # Primary key fingerprint: 7A48 1E78 868B 4DB6 A85A 05C0 64DF 38E8 AF7E 215F * remotes/rth/tags/pull-tcg-20180502: tcg: workaround branch instruction overflow in tcg_out_qemu_ld/st tcg: Improve TCGv_ptr support tcg: Allow wider vectors for cmp and mul tcg/arm: Fix memory barrier encoding tcg: Document INDEX_mul[us]h_* Signed-off-by: Peter Maydell <[email protected]>
2 parents 98bae9c + 6001f77 commit 5925588

File tree

8 files changed

+150
-106
lines changed

8 files changed

+150
-106
lines changed

target/hppa/translate.c

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,7 @@
151151
#define tcg_gen_qemu_ld_reg tcg_gen_qemu_ld_i64
152152
#define tcg_gen_qemu_st_reg tcg_gen_qemu_st_i64
153153
#define tcg_gen_atomic_xchg_reg tcg_gen_atomic_xchg_i64
154-
#if UINTPTR_MAX == UINT32_MAX
155-
# define tcg_gen_trunc_reg_ptr(p, r) \
156-
tcg_gen_trunc_i64_i32(TCGV_PTR_TO_NAT(p), r)
157-
#else
158-
# define tcg_gen_trunc_reg_ptr(p, r) \
159-
tcg_gen_mov_i64(TCGV_PTR_TO_NAT(p), r)
160-
#endif
154+
#define tcg_gen_trunc_reg_ptr tcg_gen_trunc_i64_ptr
161155
#else
162156
#define TCGv_reg TCGv_i32
163157
#define tcg_temp_new tcg_temp_new_i32
@@ -251,13 +245,7 @@
251245
#define tcg_gen_qemu_ld_reg tcg_gen_qemu_ld_i32
252246
#define tcg_gen_qemu_st_reg tcg_gen_qemu_st_i32
253247
#define tcg_gen_atomic_xchg_reg tcg_gen_atomic_xchg_i32
254-
#if UINTPTR_MAX == UINT32_MAX
255-
# define tcg_gen_trunc_reg_ptr(p, r) \
256-
tcg_gen_mov_i32(TCGV_PTR_TO_NAT(p), r)
257-
#else
258-
# define tcg_gen_trunc_reg_ptr(p, r) \
259-
tcg_gen_extu_i32_i64(TCGV_PTR_TO_NAT(p), r)
260-
#endif
248+
#define tcg_gen_trunc_reg_ptr tcg_gen_ext_i32_ptr
261249
#endif /* TARGET_REGISTER_BITS */
262250

263251
typedef struct DisasCond {

tcg/README

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,14 @@ double-word product T0. The later is returned in two single-word outputs.
431431

432432
Similar to mulu2, except the two inputs T1 and T2 are signed.
433433

434+
* mulsh_i32/i64 t0, t1, t2
435+
* muluh_i32/i64 t0, t1, t2
436+
437+
Provide the high part of a signed or unsigned multiply, respectively.
438+
If mulu2/muls2 are not provided by the backend, the tcg-op generator
439+
can obtain the same results can be obtained by emitting a pair of
440+
opcodes, mul+muluh/mulsh.
441+
434442
********* Memory Barrier support
435443

436444
* mb <$arg>

tcg/arm/tcg-target.inc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ typedef enum {
159159
INSN_STRD_IMM = 0x004000f0,
160160
INSN_STRD_REG = 0x000000f0,
161161

162-
INSN_DMB_ISH = 0x5bf07ff5,
163-
INSN_DMB_MCR = 0xba0f07ee,
162+
INSN_DMB_ISH = 0xf57ff05b,
163+
INSN_DMB_MCR = 0xee070fba,
164164

165165
/* Architected nop introduced in v6k. */
166166
/* ??? This is an MSR (imm) 0,0,0 insn. Anyone know if this

tcg/tcg-ldst.inc.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ typedef struct TCGLabelQemuLdst {
3030
TCGReg datahi_reg; /* reg index for high word to be loaded or stored */
3131
tcg_insn_unit *raddr; /* gen code addr of the next IR of qemu_ld/st IR */
3232
tcg_insn_unit *label_ptr[2]; /* label pointers to be updated */
33-
struct TCGLabelQemuLdst *next;
33+
QSIMPLEQ_ENTRY(TCGLabelQemuLdst) next;
3434
} TCGLabelQemuLdst;
3535

3636

@@ -46,7 +46,7 @@ static bool tcg_out_ldst_finalize(TCGContext *s)
4646
TCGLabelQemuLdst *lb;
4747

4848
/* qemu_ld/st slow paths */
49-
for (lb = s->ldst_labels; lb != NULL; lb = lb->next) {
49+
QSIMPLEQ_FOREACH(lb, &s->ldst_labels, next) {
5050
if (lb->is_ld) {
5151
tcg_out_qemu_ld_slow_path(s, lb);
5252
} else {
@@ -72,7 +72,7 @@ static inline TCGLabelQemuLdst *new_ldst_label(TCGContext *s)
7272
{
7373
TCGLabelQemuLdst *l = tcg_malloc(sizeof(*l));
7474

75-
l->next = s->ldst_labels;
76-
s->ldst_labels = l;
75+
QSIMPLEQ_INSERT_TAIL(&s->ldst_labels, l, next);
76+
7777
return l;
7878
}

tcg/tcg-op-vec.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,8 @@ void tcg_gen_cmp_vec(TCGCond cond, unsigned vece,
355355
TCGType type = rt->base_type;
356356
int can;
357357

358-
tcg_debug_assert(at->base_type == type);
359-
tcg_debug_assert(bt->base_type == type);
358+
tcg_debug_assert(at->base_type >= type);
359+
tcg_debug_assert(bt->base_type >= type);
360360
can = tcg_can_emit_vec_op(INDEX_op_cmp_vec, type, vece);
361361
if (can > 0) {
362362
vec_gen_4(INDEX_op_cmp_vec, type, vece, ri, ai, bi, cond);
@@ -377,8 +377,8 @@ void tcg_gen_mul_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b)
377377
TCGType type = rt->base_type;
378378
int can;
379379

380-
tcg_debug_assert(at->base_type == type);
381-
tcg_debug_assert(bt->base_type == type);
380+
tcg_debug_assert(at->base_type >= type);
381+
tcg_debug_assert(bt->base_type >= type);
382382
can = tcg_can_emit_vec_op(INDEX_op_mul_vec, type, vece);
383383
if (can > 0) {
384384
vec_gen_3(INDEX_op_mul_vec, type, vece, ri, ai, bi);

tcg/tcg-op.h

Lines changed: 70 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,25 +1137,74 @@ void tcg_gen_stl_vec(TCGv_vec r, TCGv_ptr base, TCGArg offset, TCGType t);
11371137
#endif
11381138

11391139
#if UINTPTR_MAX == UINT32_MAX
1140-
# define tcg_gen_ld_ptr(R, A, O) \
1141-
tcg_gen_ld_i32(TCGV_PTR_TO_NAT(R), (A), (O))
1142-
# define tcg_gen_discard_ptr(A) \
1143-
tcg_gen_discard_i32(TCGV_PTR_TO_NAT(A))
1144-
# define tcg_gen_add_ptr(R, A, B) \
1145-
tcg_gen_add_i32(TCGV_PTR_TO_NAT(R), TCGV_PTR_TO_NAT(A), TCGV_PTR_TO_NAT(B))
1146-
# define tcg_gen_addi_ptr(R, A, B) \
1147-
tcg_gen_addi_i32(TCGV_PTR_TO_NAT(R), TCGV_PTR_TO_NAT(A), (B))
1148-
# define tcg_gen_ext_i32_ptr(R, A) \
1149-
tcg_gen_mov_i32(TCGV_PTR_TO_NAT(R), (A))
1140+
# define PTR i32
1141+
# define NAT TCGv_i32
11501142
#else
1151-
# define tcg_gen_ld_ptr(R, A, O) \
1152-
tcg_gen_ld_i64(TCGV_PTR_TO_NAT(R), (A), (O))
1153-
# define tcg_gen_discard_ptr(A) \
1154-
tcg_gen_discard_i64(TCGV_PTR_TO_NAT(A))
1155-
# define tcg_gen_add_ptr(R, A, B) \
1156-
tcg_gen_add_i64(TCGV_PTR_TO_NAT(R), TCGV_PTR_TO_NAT(A), TCGV_PTR_TO_NAT(B))
1157-
# define tcg_gen_addi_ptr(R, A, B) \
1158-
tcg_gen_addi_i64(TCGV_PTR_TO_NAT(R), TCGV_PTR_TO_NAT(A), (B))
1159-
# define tcg_gen_ext_i32_ptr(R, A) \
1160-
tcg_gen_ext_i32_i64(TCGV_PTR_TO_NAT(R), (A))
1161-
#endif /* UINTPTR_MAX == UINT32_MAX */
1143+
# define PTR i64
1144+
# define NAT TCGv_i64
1145+
#endif
1146+
1147+
static inline void tcg_gen_ld_ptr(TCGv_ptr r, TCGv_ptr a, intptr_t o)
1148+
{
1149+
glue(tcg_gen_ld_,PTR)((NAT)r, a, o);
1150+
}
1151+
1152+
static inline void tcg_gen_discard_ptr(TCGv_ptr a)
1153+
{
1154+
glue(tcg_gen_discard_,PTR)((NAT)a);
1155+
}
1156+
1157+
static inline void tcg_gen_add_ptr(TCGv_ptr r, TCGv_ptr a, TCGv_ptr b)
1158+
{
1159+
glue(tcg_gen_add_,PTR)((NAT)r, (NAT)a, (NAT)b);
1160+
}
1161+
1162+
static inline void tcg_gen_addi_ptr(TCGv_ptr r, TCGv_ptr a, intptr_t b)
1163+
{
1164+
glue(tcg_gen_addi_,PTR)((NAT)r, (NAT)a, b);
1165+
}
1166+
1167+
static inline void tcg_gen_brcondi_ptr(TCGCond cond, TCGv_ptr a,
1168+
intptr_t b, TCGLabel *label)
1169+
{
1170+
glue(tcg_gen_brcondi_,PTR)(cond, (NAT)a, b, label);
1171+
}
1172+
1173+
static inline void tcg_gen_ext_i32_ptr(TCGv_ptr r, TCGv_i32 a)
1174+
{
1175+
#if UINTPTR_MAX == UINT32_MAX
1176+
tcg_gen_mov_i32((NAT)r, a);
1177+
#else
1178+
tcg_gen_ext_i32_i64((NAT)r, a);
1179+
#endif
1180+
}
1181+
1182+
static inline void tcg_gen_trunc_i64_ptr(TCGv_ptr r, TCGv_i64 a)
1183+
{
1184+
#if UINTPTR_MAX == UINT32_MAX
1185+
tcg_gen_extrl_i64_i32((NAT)r, a);
1186+
#else
1187+
tcg_gen_mov_i64((NAT)r, a);
1188+
#endif
1189+
}
1190+
1191+
static inline void tcg_gen_extu_ptr_i64(TCGv_i64 r, TCGv_ptr a)
1192+
{
1193+
#if UINTPTR_MAX == UINT32_MAX
1194+
tcg_gen_extu_i32_i64(r, (NAT)a);
1195+
#else
1196+
tcg_gen_mov_i64(r, (NAT)a);
1197+
#endif
1198+
}
1199+
1200+
static inline void tcg_gen_trunc_ptr_i32(TCGv_i32 r, TCGv_ptr a)
1201+
{
1202+
#if UINTPTR_MAX == UINT32_MAX
1203+
tcg_gen_mov_i32(r, (NAT)a);
1204+
#else
1205+
tcg_gen_extrl_i64_i32(r, (NAT)a);
1206+
#endif
1207+
}
1208+
1209+
#undef PTR
1210+
#undef NAT

tcg/tcg.c

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -980,7 +980,7 @@ TCGTemp *tcg_global_mem_new_internal(TCGType type, TCGv_ptr base,
980980
return ts;
981981
}
982982

983-
static TCGTemp *tcg_temp_new_internal(TCGType type, int temp_local)
983+
TCGTemp *tcg_temp_new_internal(TCGType type, bool temp_local)
984984
{
985985
TCGContext *s = tcg_ctx;
986986
TCGTemp *ts;
@@ -1025,18 +1025,6 @@ static TCGTemp *tcg_temp_new_internal(TCGType type, int temp_local)
10251025
return ts;
10261026
}
10271027

1028-
TCGv_i32 tcg_temp_new_internal_i32(int temp_local)
1029-
{
1030-
TCGTemp *t = tcg_temp_new_internal(TCG_TYPE_I32, temp_local);
1031-
return temp_tcgv_i32(t);
1032-
}
1033-
1034-
TCGv_i64 tcg_temp_new_internal_i64(int temp_local)
1035-
{
1036-
TCGTemp *t = tcg_temp_new_internal(TCG_TYPE_I64, temp_local);
1037-
return temp_tcgv_i64(t);
1038-
}
1039-
10401028
TCGv_vec tcg_temp_new_vec(TCGType type)
10411029
{
10421030
TCGTemp *t;
@@ -1072,7 +1060,7 @@ TCGv_vec tcg_temp_new_vec_matching(TCGv_vec match)
10721060
return temp_tcgv_vec(t);
10731061
}
10741062

1075-
static void tcg_temp_free_internal(TCGTemp *ts)
1063+
void tcg_temp_free_internal(TCGTemp *ts)
10761064
{
10771065
TCGContext *s = tcg_ctx;
10781066
int k, idx;
@@ -1093,21 +1081,6 @@ static void tcg_temp_free_internal(TCGTemp *ts)
10931081
set_bit(idx, s->free_temps[k].l);
10941082
}
10951083

1096-
void tcg_temp_free_i32(TCGv_i32 arg)
1097-
{
1098-
tcg_temp_free_internal(tcgv_i32_temp(arg));
1099-
}
1100-
1101-
void tcg_temp_free_i64(TCGv_i64 arg)
1102-
{
1103-
tcg_temp_free_internal(tcgv_i64_temp(arg));
1104-
}
1105-
1106-
void tcg_temp_free_vec(TCGv_vec arg)
1107-
{
1108-
tcg_temp_free_internal(tcgv_vec_temp(arg));
1109-
}
1110-
11111084
TCGv_i32 tcg_const_i32(int32_t val)
11121085
{
11131086
TCGv_i32 t0;
@@ -3324,7 +3297,7 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb)
33243297
s->code_ptr = tb->tc.ptr;
33253298

33263299
#ifdef TCG_TARGET_NEED_LDST_LABELS
3327-
s->ldst_labels = NULL;
3300+
QSIMPLEQ_INIT(&s->ldst_labels);
33283301
#endif
33293302
#ifdef TCG_TARGET_NEED_POOL_LABELS
33303303
s->pool_labels = NULL;

0 commit comments

Comments
 (0)