Skip to content

Commit

Permalink
tcg: Move tcg_constant_* out of line
Browse files Browse the repository at this point in the history
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20231029210848.78234-10-richard.henderson@linaro.org>
  • Loading branch information
rth7680 committed Nov 6, 2023
1 parent 17b9fad commit 16edaee
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 26 deletions.
8 changes: 8 additions & 0 deletions include/tcg/tcg-op-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
#include "exec/helper-proto-common.h"
#include "exec/helper-gen-common.h"

TCGv_i32 tcg_constant_i32(int32_t val);
TCGv_i64 tcg_constant_i64(int64_t val);
TCGv_vec tcg_constant_vec(TCGType type, unsigned vece, int64_t val);
TCGv_vec tcg_constant_vec_matching(TCGv_vec match, unsigned vece, int64_t val);

/* Generic ops. */

void gen_set_label(TCGLabel *l);
Expand Down Expand Up @@ -459,6 +464,9 @@ void tcg_gen_stl_vec(TCGv_vec r, TCGv_ptr base, TCGArg offset, TCGType t);
# define NAT TCGv_i64
#endif

TCGv_ptr tcg_constant_ptr_int(intptr_t x);
#define tcg_constant_ptr(X) tcg_constant_ptr_int((intptr_t)(X))

static inline void tcg_gen_ld_ptr(TCGv_ptr r, TCGv_ptr a, intptr_t o)
{
glue(tcg_gen_ld_,PTR)((NAT)r, a, o);
Expand Down
26 changes: 0 additions & 26 deletions include/tcg/tcg.h
Original file line number Diff line number Diff line change
Expand Up @@ -934,32 +934,6 @@ void tcg_remove_ops_after(TCGOp *op);

void tcg_optimize(TCGContext *s);

/*
* Locate or create a read-only temporary that is a constant.
* This kind of temporary need not be freed, but for convenience
* will be silently ignored by tcg_temp_free_*.
*/
TCGTemp *tcg_constant_internal(TCGType type, int64_t val);

static inline TCGv_i32 tcg_constant_i32(int32_t val)
{
return temp_tcgv_i32(tcg_constant_internal(TCG_TYPE_I32, val));
}

static inline TCGv_i64 tcg_constant_i64(int64_t val)
{
return temp_tcgv_i64(tcg_constant_internal(TCG_TYPE_I64, val));
}

TCGv_vec tcg_constant_vec(TCGType type, unsigned vece, int64_t val);
TCGv_vec tcg_constant_vec_matching(TCGv_vec match, unsigned vece, int64_t val);

#if UINTPTR_MAX == UINT32_MAX
# define tcg_constant_ptr(x) ((TCGv_ptr)tcg_constant_i32((intptr_t)(x)))
#else
# define tcg_constant_ptr(x) ((TCGv_ptr)tcg_constant_i64((intptr_t)(x)))
#endif

TCGLabel *gen_new_label(void);

/**
Expand Down
7 changes: 7 additions & 0 deletions tcg/tcg-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ static inline TCGv_i64 TCGV128_HIGH(TCGv_i128 t)

bool tcg_target_has_memory_bswap(MemOp memop);

/*
* Locate or create a read-only temporary that is a constant.
* This kind of temporary need not be freed, but for convenience
* will be silently ignored by tcg_temp_free_*.
*/
TCGTemp *tcg_constant_internal(TCGType type, int64_t val);

void tcg_gen_op1(TCGOpcode, TCGArg);
void tcg_gen_op2(TCGOpcode, TCGArg, TCGArg);
void tcg_gen_op3(TCGOpcode, TCGArg, TCGArg, TCGArg);
Expand Down
15 changes: 15 additions & 0 deletions tcg/tcg.c
Original file line number Diff line number Diff line change
Expand Up @@ -1806,6 +1806,21 @@ TCGTemp *tcg_constant_internal(TCGType type, int64_t val)
return ts;
}

TCGv_i32 tcg_constant_i32(int32_t val)
{
return temp_tcgv_i32(tcg_constant_internal(TCG_TYPE_I32, val));
}

TCGv_i64 tcg_constant_i64(int64_t val)
{
return temp_tcgv_i64(tcg_constant_internal(TCG_TYPE_I64, val));
}

TCGv_ptr tcg_constant_ptr_int(intptr_t val)
{
return temp_tcgv_ptr(tcg_constant_internal(TCG_TYPE_PTR, val));
}

TCGv_vec tcg_constant_vec(TCGType type, unsigned vece, int64_t val)
{
val = dup_const(vece, val);
Expand Down

0 comments on commit 16edaee

Please sign in to comment.