Commit c5631f487d5d3e328ca537be169d47d33e0fdf81

Authored by edgar_igl
1 parent 7dcfb089

CRIS: Avoid using cpu_T[0] for testing condition codes.

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5547 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 41 additions and 44 deletions
target-cris/translate.c
@@ -973,7 +973,7 @@ static int arith_cc(DisasContext *dc) @@ -973,7 +973,7 @@ static int arith_cc(DisasContext *dc)
973 return 0; 973 return 0;
974 } 974 }
975 975
976 -static void gen_tst_cc (DisasContext *dc, int cond) 976 +static void gen_tst_cc (DisasContext *dc, TCGv cc, int cond)
977 { 977 {
978 int arith_opt, move_opt; 978 int arith_opt, move_opt;
979 979
@@ -996,46 +996,46 @@ static void gen_tst_cc (DisasContext *dc, int cond) @@ -996,46 +996,46 @@ static void gen_tst_cc (DisasContext *dc, int cond)
996 non-zero otherwise T0 should be zero. */ 996 non-zero otherwise T0 should be zero. */
997 int l1; 997 int l1;
998 l1 = gen_new_label(); 998 l1 = gen_new_label();
999 - tcg_gen_movi_tl(cpu_T[0], 0); 999 + tcg_gen_movi_tl(cc, 0);
1000 tcg_gen_brcondi_tl(TCG_COND_NE, cc_result, 1000 tcg_gen_brcondi_tl(TCG_COND_NE, cc_result,
1001 0, l1); 1001 0, l1);
1002 - tcg_gen_movi_tl(cpu_T[0], 1); 1002 + tcg_gen_movi_tl(cc, 1);
1003 gen_set_label(l1); 1003 gen_set_label(l1);
1004 } 1004 }
1005 else { 1005 else {
1006 cris_evaluate_flags(dc); 1006 cris_evaluate_flags(dc);
1007 - tcg_gen_andi_tl(cpu_T[0], 1007 + tcg_gen_andi_tl(cc,
1008 cpu_PR[PR_CCS], Z_FLAG); 1008 cpu_PR[PR_CCS], Z_FLAG);
1009 } 1009 }
1010 break; 1010 break;
1011 case CC_NE: 1011 case CC_NE:
1012 if (arith_opt || move_opt) 1012 if (arith_opt || move_opt)
1013 - tcg_gen_mov_tl(cpu_T[0], cc_result); 1013 + tcg_gen_mov_tl(cc, cc_result);
1014 else { 1014 else {
1015 cris_evaluate_flags(dc); 1015 cris_evaluate_flags(dc);
1016 - tcg_gen_xori_tl(cpu_T[0], cpu_PR[PR_CCS], 1016 + tcg_gen_xori_tl(cc, cpu_PR[PR_CCS],
1017 Z_FLAG); 1017 Z_FLAG);
1018 - tcg_gen_andi_tl(cpu_T[0], cpu_T[0], Z_FLAG); 1018 + tcg_gen_andi_tl(cc, cc, Z_FLAG);
1019 } 1019 }
1020 break; 1020 break;
1021 case CC_CS: 1021 case CC_CS:
1022 cris_evaluate_flags(dc); 1022 cris_evaluate_flags(dc);
1023 - tcg_gen_andi_tl(cpu_T[0], cpu_PR[PR_CCS], C_FLAG); 1023 + tcg_gen_andi_tl(cc, cpu_PR[PR_CCS], C_FLAG);
1024 break; 1024 break;
1025 case CC_CC: 1025 case CC_CC:
1026 cris_evaluate_flags(dc); 1026 cris_evaluate_flags(dc);
1027 - tcg_gen_xori_tl(cpu_T[0], cpu_PR[PR_CCS], C_FLAG);  
1028 - tcg_gen_andi_tl(cpu_T[0], cpu_T[0], C_FLAG); 1027 + tcg_gen_xori_tl(cc, cpu_PR[PR_CCS], C_FLAG);
  1028 + tcg_gen_andi_tl(cc, cc, C_FLAG);
1029 break; 1029 break;
1030 case CC_VS: 1030 case CC_VS:
1031 cris_evaluate_flags(dc); 1031 cris_evaluate_flags(dc);
1032 - tcg_gen_andi_tl(cpu_T[0], cpu_PR[PR_CCS], V_FLAG); 1032 + tcg_gen_andi_tl(cc, cpu_PR[PR_CCS], V_FLAG);
1033 break; 1033 break;
1034 case CC_VC: 1034 case CC_VC:
1035 cris_evaluate_flags(dc); 1035 cris_evaluate_flags(dc);
1036 - tcg_gen_xori_tl(cpu_T[0], cpu_PR[PR_CCS], 1036 + tcg_gen_xori_tl(cc, cpu_PR[PR_CCS],
1037 V_FLAG); 1037 V_FLAG);
1038 - tcg_gen_andi_tl(cpu_T[0], cpu_T[0], V_FLAG); 1038 + tcg_gen_andi_tl(cc, cc, V_FLAG);
1039 break; 1039 break;
1040 case CC_PL: 1040 case CC_PL:
1041 if (arith_opt || move_opt) { 1041 if (arith_opt || move_opt) {
@@ -1046,13 +1046,13 @@ static void gen_tst_cc (DisasContext *dc, int cond) @@ -1046,13 +1046,13 @@ static void gen_tst_cc (DisasContext *dc, int cond)
1046 else if (dc->cc_size == 2) 1046 else if (dc->cc_size == 2)
1047 bits = 15; 1047 bits = 15;
1048 1048
1049 - tcg_gen_shri_tl(cpu_T[0], cc_result, bits);  
1050 - tcg_gen_xori_tl(cpu_T[0], cpu_T[0], 1); 1049 + tcg_gen_shri_tl(cc, cc_result, bits);
  1050 + tcg_gen_xori_tl(cc, cc, 1);
1051 } else { 1051 } else {
1052 cris_evaluate_flags(dc); 1052 cris_evaluate_flags(dc);
1053 - tcg_gen_xori_tl(cpu_T[0], cpu_PR[PR_CCS], 1053 + tcg_gen_xori_tl(cc, cpu_PR[PR_CCS],
1054 N_FLAG); 1054 N_FLAG);
1055 - tcg_gen_andi_tl(cpu_T[0], cpu_T[0], N_FLAG); 1055 + tcg_gen_andi_tl(cc, cc, N_FLAG);
1056 } 1056 }
1057 break; 1057 break;
1058 case CC_MI: 1058 case CC_MI:
@@ -1064,17 +1064,17 @@ static void gen_tst_cc (DisasContext *dc, int cond) @@ -1064,17 +1064,17 @@ static void gen_tst_cc (DisasContext *dc, int cond)
1064 else if (dc->cc_size == 2) 1064 else if (dc->cc_size == 2)
1065 bits = 15; 1065 bits = 15;
1066 1066
1067 - tcg_gen_shri_tl(cpu_T[0], cc_result, 31); 1067 + tcg_gen_shri_tl(cc, cc_result, 31);
1068 } 1068 }
1069 else { 1069 else {
1070 cris_evaluate_flags(dc); 1070 cris_evaluate_flags(dc);
1071 - tcg_gen_andi_tl(cpu_T[0], cpu_PR[PR_CCS], 1071 + tcg_gen_andi_tl(cc, cpu_PR[PR_CCS],
1072 N_FLAG); 1072 N_FLAG);
1073 } 1073 }
1074 break; 1074 break;
1075 case CC_LS: 1075 case CC_LS:
1076 cris_evaluate_flags(dc); 1076 cris_evaluate_flags(dc);
1077 - tcg_gen_andi_tl(cpu_T[0], cpu_PR[PR_CCS], 1077 + tcg_gen_andi_tl(cc, cpu_PR[PR_CCS],
1078 C_FLAG | Z_FLAG); 1078 C_FLAG | Z_FLAG);
1079 break; 1079 break;
1080 case CC_HI: 1080 case CC_HI:
@@ -1086,9 +1086,9 @@ static void gen_tst_cc (DisasContext *dc, int cond) @@ -1086,9 +1086,9 @@ static void gen_tst_cc (DisasContext *dc, int cond)
1086 tcg_gen_xori_tl(tmp, cpu_PR[PR_CCS], 1086 tcg_gen_xori_tl(tmp, cpu_PR[PR_CCS],
1087 C_FLAG | Z_FLAG); 1087 C_FLAG | Z_FLAG);
1088 /* Overlay the C flag on top of the Z. */ 1088 /* Overlay the C flag on top of the Z. */
1089 - tcg_gen_shli_tl(cpu_T[0], tmp, 2);  
1090 - tcg_gen_and_tl(cpu_T[0], tmp, cpu_T[0]);  
1091 - tcg_gen_andi_tl(cpu_T[0], cpu_T[0], Z_FLAG); 1089 + tcg_gen_shli_tl(cc, tmp, 2);
  1090 + tcg_gen_and_tl(cc, tmp, cc);
  1091 + tcg_gen_andi_tl(cc, cc, Z_FLAG);
1092 1092
1093 tcg_temp_free(tmp); 1093 tcg_temp_free(tmp);
1094 } 1094 }
@@ -1096,19 +1096,19 @@ static void gen_tst_cc (DisasContext *dc, int cond) @@ -1096,19 +1096,19 @@ static void gen_tst_cc (DisasContext *dc, int cond)
1096 case CC_GE: 1096 case CC_GE:
1097 cris_evaluate_flags(dc); 1097 cris_evaluate_flags(dc);
1098 /* Overlay the V flag on top of the N. */ 1098 /* Overlay the V flag on top of the N. */
1099 - tcg_gen_shli_tl(cpu_T[0], cpu_PR[PR_CCS], 2);  
1100 - tcg_gen_xor_tl(cpu_T[0],  
1101 - cpu_PR[PR_CCS], cpu_T[0]);  
1102 - tcg_gen_andi_tl(cpu_T[0], cpu_T[0], N_FLAG);  
1103 - tcg_gen_xori_tl(cpu_T[0], cpu_T[0], N_FLAG); 1099 + tcg_gen_shli_tl(cc, cpu_PR[PR_CCS], 2);
  1100 + tcg_gen_xor_tl(cc,
  1101 + cpu_PR[PR_CCS], cc);
  1102 + tcg_gen_andi_tl(cc, cc, N_FLAG);
  1103 + tcg_gen_xori_tl(cc, cc, N_FLAG);
1104 break; 1104 break;
1105 case CC_LT: 1105 case CC_LT:
1106 cris_evaluate_flags(dc); 1106 cris_evaluate_flags(dc);
1107 /* Overlay the V flag on top of the N. */ 1107 /* Overlay the V flag on top of the N. */
1108 - tcg_gen_shli_tl(cpu_T[0], cpu_PR[PR_CCS], 2);  
1109 - tcg_gen_xor_tl(cpu_T[0],  
1110 - cpu_PR[PR_CCS], cpu_T[0]);  
1111 - tcg_gen_andi_tl(cpu_T[0], cpu_T[0], N_FLAG); 1108 + tcg_gen_shli_tl(cc, cpu_PR[PR_CCS], 2);
  1109 + tcg_gen_xor_tl(cc,
  1110 + cpu_PR[PR_CCS], cc);
  1111 + tcg_gen_andi_tl(cc, cc, N_FLAG);
1112 break; 1112 break;
1113 case CC_GT: 1113 case CC_GT:
1114 cris_evaluate_flags(dc); 1114 cris_evaluate_flags(dc);
@@ -1127,8 +1127,8 @@ static void gen_tst_cc (DisasContext *dc, int cond) @@ -1127,8 +1127,8 @@ static void gen_tst_cc (DisasContext *dc, int cond)
1127 1127
1128 tcg_gen_xor_tl(n, n, cpu_PR[PR_CCS]); 1128 tcg_gen_xor_tl(n, n, cpu_PR[PR_CCS]);
1129 tcg_gen_xori_tl(n, n, 2); 1129 tcg_gen_xori_tl(n, n, 2);
1130 - tcg_gen_and_tl(cpu_T[0], z, n);  
1131 - tcg_gen_andi_tl(cpu_T[0], cpu_T[0], 2); 1130 + tcg_gen_and_tl(cc, z, n);
  1131 + tcg_gen_andi_tl(cc, cc, 2);
1132 1132
1133 tcg_temp_free(n); 1133 tcg_temp_free(n);
1134 tcg_temp_free(z); 1134 tcg_temp_free(z);
@@ -1148,8 +1148,8 @@ static void gen_tst_cc (DisasContext *dc, int cond) @@ -1148,8 +1148,8 @@ static void gen_tst_cc (DisasContext *dc, int cond)
1148 tcg_gen_shri_tl(z, cpu_PR[PR_CCS], 1); 1148 tcg_gen_shri_tl(z, cpu_PR[PR_CCS], 1);
1149 1149
1150 tcg_gen_xor_tl(n, n, cpu_PR[PR_CCS]); 1150 tcg_gen_xor_tl(n, n, cpu_PR[PR_CCS]);
1151 - tcg_gen_or_tl(cpu_T[0], z, n);  
1152 - tcg_gen_andi_tl(cpu_T[0], cpu_T[0], 2); 1151 + tcg_gen_or_tl(cc, z, n);
  1152 + tcg_gen_andi_tl(cc, cc, 2);
1153 1153
1154 tcg_temp_free(n); 1154 tcg_temp_free(n);
1155 tcg_temp_free(z); 1155 tcg_temp_free(z);
@@ -1157,10 +1157,10 @@ static void gen_tst_cc (DisasContext *dc, int cond) @@ -1157,10 +1157,10 @@ static void gen_tst_cc (DisasContext *dc, int cond)
1157 break; 1157 break;
1158 case CC_P: 1158 case CC_P:
1159 cris_evaluate_flags(dc); 1159 cris_evaluate_flags(dc);
1160 - tcg_gen_andi_tl(cpu_T[0], cpu_PR[PR_CCS], P_FLAG); 1160 + tcg_gen_andi_tl(cc, cpu_PR[PR_CCS], P_FLAG);
1161 break; 1161 break;
1162 case CC_A: 1162 case CC_A:
1163 - tcg_gen_movi_tl(cpu_T[0], 1); 1163 + tcg_gen_movi_tl(cc, 1);
1164 break; 1164 break;
1165 default: 1165 default:
1166 BUG(); 1166 BUG();
@@ -1188,8 +1188,7 @@ static void cris_prepare_cc_branch (DisasContext *dc, @@ -1188,8 +1188,7 @@ static void cris_prepare_cc_branch (DisasContext *dc,
1188 if (cond != CC_A) 1188 if (cond != CC_A)
1189 { 1189 {
1190 dc->jmp = JMP_INDIRECT; 1190 dc->jmp = JMP_INDIRECT;
1191 - gen_tst_cc (dc, cond);  
1192 - tcg_gen_mov_tl(env_btaken, cpu_T[0]); 1191 + gen_tst_cc (dc, env_btaken, cond);
1193 tcg_gen_movi_tl(env_btarget, dc->jmp_pc); 1192 tcg_gen_movi_tl(env_btarget, dc->jmp_pc);
1194 } else { 1193 } else {
1195 /* Allow chaining. */ 1194 /* Allow chaining. */
@@ -1623,11 +1622,9 @@ static unsigned int dec_scc_r(DisasContext *dc) @@ -1623,11 +1622,9 @@ static unsigned int dec_scc_r(DisasContext *dc)
1623 { 1622 {
1624 int l1; 1623 int l1;
1625 1624
1626 - gen_tst_cc (dc, cond);  
1627 - 1625 + gen_tst_cc (dc, cpu_R[dc->op1], cond);
1628 l1 = gen_new_label(); 1626 l1 = gen_new_label();
1629 - tcg_gen_movi_tl(cpu_R[dc->op1], 0);  
1630 - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_T[0], 0, l1); 1627 + tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_R[dc->op1], 0, l1);
1631 tcg_gen_movi_tl(cpu_R[dc->op1], 1); 1628 tcg_gen_movi_tl(cpu_R[dc->op1], 1);
1632 gen_set_label(l1); 1629 gen_set_label(l1);
1633 } 1630 }