Commit 9bf3eb2ca542dd9306cb2e72fc68e02ba3e56e2e
1 parent
2a0ab998
target-mips: optimize movc*()
Optimize code generation in gen_movc*(): - Temp variables are valid up to and *including* the brcond instruction. Use them instead of temp local variables. - Avoid using temporary variables to transfer values. - Access fpu_fcr31 directly in gen_movcf_ps(). Signed-off-by: Aurelien Jarno <aurelien@aurel32.net> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5683 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
33 additions
and
48 deletions
target-mips/translate.c
... | ... | @@ -5930,8 +5930,7 @@ static void gen_movci (DisasContext *ctx, int rd, int rs, int cc, int tf) |
5930 | 5930 | uint32_t ccbit; |
5931 | 5931 | TCGCond cond; |
5932 | 5932 | TCGv t0 = tcg_temp_local_new(TCG_TYPE_TL); |
5933 | - TCGv t1 = tcg_temp_local_new(TCG_TYPE_TL); | |
5934 | - TCGv r_tmp = tcg_temp_local_new(TCG_TYPE_I32); | |
5933 | + TCGv r_tmp = tcg_temp_new(TCG_TYPE_I32); | |
5935 | 5934 | |
5936 | 5935 | if (cc) |
5937 | 5936 | ccbit = 1 << (24 + cc); |
... | ... | @@ -5943,14 +5942,9 @@ static void gen_movci (DisasContext *ctx, int rd, int rs, int cc, int tf) |
5943 | 5942 | cond = TCG_COND_NE; |
5944 | 5943 | |
5945 | 5944 | gen_load_gpr(t0, rd); |
5946 | - gen_load_gpr(t1, rs); | |
5947 | 5945 | tcg_gen_andi_i32(r_tmp, fpu_fcr31, ccbit); |
5948 | 5946 | tcg_gen_brcondi_i32(cond, r_tmp, 0, l1); |
5949 | - tcg_temp_free(r_tmp); | |
5950 | - | |
5951 | - tcg_gen_mov_tl(t0, t1); | |
5952 | - tcg_temp_free(t1); | |
5953 | - | |
5947 | + gen_load_gpr(t0, rs); | |
5954 | 5948 | gen_set_label(l1); |
5955 | 5949 | gen_store_gpr(t0, rd); |
5956 | 5950 | tcg_temp_free(t0); |
... | ... | @@ -5960,9 +5954,8 @@ static inline void gen_movcf_s (int fs, int fd, int cc, int tf) |
5960 | 5954 | { |
5961 | 5955 | uint32_t ccbit; |
5962 | 5956 | int cond; |
5963 | - TCGv r_tmp1 = tcg_temp_local_new(TCG_TYPE_I32); | |
5957 | + TCGv r_tmp1 = tcg_temp_new(TCG_TYPE_I32); | |
5964 | 5958 | TCGv fp0 = tcg_temp_local_new(TCG_TYPE_I32); |
5965 | - TCGv fp1 = tcg_temp_local_new(TCG_TYPE_I32); | |
5966 | 5959 | int l1 = gen_new_label(); |
5967 | 5960 | |
5968 | 5961 | if (cc) |
... | ... | @@ -5975,25 +5968,21 @@ static inline void gen_movcf_s (int fs, int fd, int cc, int tf) |
5975 | 5968 | else |
5976 | 5969 | cond = TCG_COND_NE; |
5977 | 5970 | |
5978 | - gen_load_fpr32(fp0, fs); | |
5979 | - gen_load_fpr32(fp1, fd); | |
5971 | + gen_load_fpr32(fp0, fd); | |
5980 | 5972 | tcg_gen_andi_i32(r_tmp1, fpu_fcr31, ccbit); |
5981 | 5973 | tcg_gen_brcondi_i32(cond, r_tmp1, 0, l1); |
5982 | - tcg_gen_mov_i32(fp1, fp0); | |
5983 | - tcg_temp_free(fp0); | |
5974 | + gen_load_fpr32(fp0, fs); | |
5984 | 5975 | gen_set_label(l1); |
5985 | - tcg_temp_free(r_tmp1); | |
5986 | - gen_store_fpr32(fp1, fd); | |
5987 | - tcg_temp_free(fp1); | |
5976 | + gen_store_fpr32(fp0, fd); | |
5977 | + tcg_temp_free(fp0); | |
5988 | 5978 | } |
5989 | 5979 | |
5990 | 5980 | static inline void gen_movcf_d (DisasContext *ctx, int fs, int fd, int cc, int tf) |
5991 | 5981 | { |
5992 | 5982 | uint32_t ccbit; |
5993 | 5983 | int cond; |
5994 | - TCGv r_tmp1 = tcg_temp_local_new(TCG_TYPE_I32); | |
5984 | + TCGv r_tmp1 = tcg_temp_new(TCG_TYPE_I32); | |
5995 | 5985 | TCGv fp0 = tcg_temp_local_new(TCG_TYPE_I64); |
5996 | - TCGv fp1 = tcg_temp_local_new(TCG_TYPE_I64); | |
5997 | 5986 | int l1 = gen_new_label(); |
5998 | 5987 | |
5999 | 5988 | if (cc) |
... | ... | @@ -6006,57 +5995,53 @@ static inline void gen_movcf_d (DisasContext *ctx, int fs, int fd, int cc, int t |
6006 | 5995 | else |
6007 | 5996 | cond = TCG_COND_NE; |
6008 | 5997 | |
6009 | - gen_load_fpr64(ctx, fp0, fs); | |
6010 | - gen_load_fpr64(ctx, fp1, fd); | |
5998 | + gen_load_fpr64(ctx, fp0, fd); | |
6011 | 5999 | tcg_gen_andi_i32(r_tmp1, fpu_fcr31, ccbit); |
6012 | 6000 | tcg_gen_brcondi_i32(cond, r_tmp1, 0, l1); |
6013 | - tcg_gen_mov_i64(fp1, fp0); | |
6014 | - tcg_temp_free(fp0); | |
6001 | + gen_load_fpr64(ctx, fp0, fs); | |
6015 | 6002 | gen_set_label(l1); |
6016 | - tcg_temp_free(r_tmp1); | |
6017 | - gen_store_fpr64(ctx, fp1, fd); | |
6018 | - tcg_temp_free(fp1); | |
6003 | + gen_store_fpr64(ctx, fp0, fd); | |
6004 | + tcg_temp_free(fp0); | |
6019 | 6005 | } |
6020 | 6006 | |
6021 | 6007 | static inline void gen_movcf_ps (int fs, int fd, int cc, int tf) |
6022 | 6008 | { |
6009 | + uint32_t ccbit1, ccbit2; | |
6023 | 6010 | int cond; |
6024 | 6011 | TCGv r_tmp1 = tcg_temp_local_new(TCG_TYPE_I32); |
6025 | - TCGv r_tmp2 = tcg_temp_local_new(TCG_TYPE_I32); | |
6026 | 6012 | TCGv fp0 = tcg_temp_local_new(TCG_TYPE_I32); |
6027 | - TCGv fph0 = tcg_temp_local_new(TCG_TYPE_I32); | |
6028 | - TCGv fp1 = tcg_temp_local_new(TCG_TYPE_I32); | |
6029 | - TCGv fph1 = tcg_temp_local_new(TCG_TYPE_I32); | |
6030 | 6013 | int l1 = gen_new_label(); |
6031 | 6014 | int l2 = gen_new_label(); |
6032 | 6015 | |
6016 | + if (cc) { | |
6017 | + ccbit1 = 1 << (24 + cc); | |
6018 | + ccbit2 = 1 << (25 + cc); | |
6019 | + } else { | |
6020 | + ccbit1 = 1 << 23; | |
6021 | + ccbit2 = 1 << 25; | |
6022 | + } | |
6023 | + | |
6033 | 6024 | if (tf) |
6034 | 6025 | cond = TCG_COND_EQ; |
6035 | 6026 | else |
6036 | 6027 | cond = TCG_COND_NE; |
6037 | 6028 | |
6029 | + gen_load_fpr32(fp0, fd); | |
6030 | + tcg_gen_andi_i32(r_tmp1, fpu_fcr31, ccbit1); | |
6031 | + tcg_gen_brcondi_i32(cond, r_tmp1, 0, l1); | |
6038 | 6032 | gen_load_fpr32(fp0, fs); |
6039 | - gen_load_fpr32h(fph0, fs); | |
6040 | - gen_load_fpr32(fp1, fd); | |
6041 | - gen_load_fpr32h(fph1, fd); | |
6042 | - get_fp_cond(r_tmp1); | |
6043 | - tcg_gen_shri_i32(r_tmp1, r_tmp1, cc); | |
6044 | - tcg_gen_andi_i32(r_tmp2, r_tmp1, 0x1); | |
6045 | - tcg_gen_brcondi_i32(cond, r_tmp2, 0, l1); | |
6046 | - tcg_gen_mov_i32(fp1, fp0); | |
6047 | - tcg_temp_free(fp0); | |
6048 | 6033 | gen_set_label(l1); |
6049 | - tcg_gen_andi_i32(r_tmp2, r_tmp1, 0x2); | |
6050 | - tcg_gen_brcondi_i32(cond, r_tmp2, 0, l2); | |
6051 | - tcg_gen_mov_i32(fph1, fph0); | |
6052 | - tcg_temp_free(fph0); | |
6034 | + gen_store_fpr32(fp0, fd); | |
6035 | + | |
6036 | + gen_load_fpr32h(fp0, fd); | |
6037 | + tcg_gen_andi_i32(r_tmp1, fpu_fcr31, ccbit2); | |
6038 | + tcg_gen_brcondi_i32(cond, r_tmp1, 0, l2); | |
6039 | + gen_load_fpr32h(fp0, fs); | |
6053 | 6040 | gen_set_label(l2); |
6041 | + gen_store_fpr32h(fp0, fd); | |
6042 | + | |
6054 | 6043 | tcg_temp_free(r_tmp1); |
6055 | - tcg_temp_free(r_tmp2); | |
6056 | - gen_store_fpr32(fp1, fd); | |
6057 | - gen_store_fpr32h(fph1, fd); | |
6058 | - tcg_temp_free(fp1); | |
6059 | - tcg_temp_free(fph1); | |
6044 | + tcg_temp_free(fp0); | |
6060 | 6045 | } |
6061 | 6046 | |
6062 | 6047 | ... | ... |