Revision ba225198 tcg/sparc/tcg-target.c
b/tcg/sparc/tcg-target.c | ||
---|---|---|
285 | 285 |
INSN_IMM13(offset)); |
286 | 286 |
} |
287 | 287 |
|
288 |
static void tcg_out_arithc(TCGContext *s, int rd, int rs1, |
|
289 |
int val2, int val2const, int op) |
|
290 |
{ |
|
291 |
tcg_out32(s, op | INSN_RD(rd) | INSN_RS1(rs1) |
|
292 |
| (val2const ? INSN_IMM13(val2) : INSN_RS2(val2))); |
|
293 |
} |
|
294 |
|
|
288 | 295 |
static inline void tcg_out_mov(TCGContext *s, int ret, int arg) |
289 | 296 |
{ |
290 | 297 |
tcg_out_arith(s, ret, arg, TCG_REG_G0, ARITH_OR); |
... | ... | |
481 | 488 |
|
482 | 489 |
static void tcg_out_cmp(TCGContext *s, TCGArg c1, TCGArg c2, int c2const) |
483 | 490 |
{ |
484 |
if (c2const) |
|
485 |
tcg_out_arithi(s, TCG_REG_G0, c1, c2, ARITH_SUBCC); |
|
486 |
else |
|
487 |
tcg_out_arith(s, TCG_REG_G0, c1, c2, ARITH_SUBCC); |
|
491 |
tcg_out_arithc(s, TCG_REG_G0, c1, c2, c2const, ARITH_SUBCC); |
|
488 | 492 |
} |
489 | 493 |
|
490 | 494 |
static void tcg_out_brcond_i32(TCGContext *s, int cond, |
... | ... | |
1036 | 1040 |
|
1037 | 1041 |
#if TCG_TARGET_REG_BITS == 64 |
1038 | 1042 |
#define OP_32_64(x) \ |
1039 |
glue(glue(case INDEX_op_, x), _i32:) \
|
|
1040 |
glue(glue(case INDEX_op_, x), _i64:)
|
|
1043 |
glue(glue(case INDEX_op_, x), _i32): \
|
|
1044 |
glue(glue(case INDEX_op_, x), _i64) |
|
1041 | 1045 |
#else |
1042 | 1046 |
#define OP_32_64(x) \ |
1043 |
glue(glue(case INDEX_op_, x), _i32:)
|
|
1047 |
glue(glue(case INDEX_op_, x), _i32) |
|
1044 | 1048 |
#endif |
1045 |
OP_32_64(ld8u);
|
|
1049 |
OP_32_64(ld8u):
|
|
1046 | 1050 |
tcg_out_ldst(s, args[0], args[1], args[2], LDUB); |
1047 | 1051 |
break; |
1048 |
OP_32_64(ld8s);
|
|
1052 |
OP_32_64(ld8s):
|
|
1049 | 1053 |
tcg_out_ldst(s, args[0], args[1], args[2], LDSB); |
1050 | 1054 |
break; |
1051 |
OP_32_64(ld16u);
|
|
1055 |
OP_32_64(ld16u):
|
|
1052 | 1056 |
tcg_out_ldst(s, args[0], args[1], args[2], LDUH); |
1053 | 1057 |
break; |
1054 |
OP_32_64(ld16s);
|
|
1058 |
OP_32_64(ld16s):
|
|
1055 | 1059 |
tcg_out_ldst(s, args[0], args[1], args[2], LDSH); |
1056 | 1060 |
break; |
1057 | 1061 |
case INDEX_op_ld_i32: |
... | ... | |
1060 | 1064 |
#endif |
1061 | 1065 |
tcg_out_ldst(s, args[0], args[1], args[2], LDUW); |
1062 | 1066 |
break; |
1063 |
OP_32_64(st8);
|
|
1067 |
OP_32_64(st8):
|
|
1064 | 1068 |
tcg_out_ldst(s, args[0], args[1], args[2], STB); |
1065 | 1069 |
break; |
1066 |
OP_32_64(st16);
|
|
1070 |
OP_32_64(st16):
|
|
1067 | 1071 |
tcg_out_ldst(s, args[0], args[1], args[2], STH); |
1068 | 1072 |
break; |
1069 | 1073 |
case INDEX_op_st_i32: |
... | ... | |
1072 | 1076 |
#endif |
1073 | 1077 |
tcg_out_ldst(s, args[0], args[1], args[2], STW); |
1074 | 1078 |
break; |
1075 |
OP_32_64(add);
|
|
1079 |
OP_32_64(add):
|
|
1076 | 1080 |
c = ARITH_ADD; |
1077 |
goto gen_arith32;
|
|
1078 |
OP_32_64(sub);
|
|
1081 |
goto gen_arith; |
|
1082 |
OP_32_64(sub):
|
|
1079 | 1083 |
c = ARITH_SUB; |
1080 |
goto gen_arith32;
|
|
1081 |
OP_32_64(and);
|
|
1084 |
goto gen_arith; |
|
1085 |
OP_32_64(and):
|
|
1082 | 1086 |
c = ARITH_AND; |
1083 |
goto gen_arith32;
|
|
1084 |
OP_32_64(or);
|
|
1087 |
goto gen_arith; |
|
1088 |
OP_32_64(or):
|
|
1085 | 1089 |
c = ARITH_OR; |
1086 |
goto gen_arith32;
|
|
1087 |
OP_32_64(xor);
|
|
1090 |
goto gen_arith; |
|
1091 |
OP_32_64(xor):
|
|
1088 | 1092 |
c = ARITH_XOR; |
1089 |
goto gen_arith32;
|
|
1093 |
goto gen_arith; |
|
1090 | 1094 |
case INDEX_op_shl_i32: |
1091 | 1095 |
c = SHIFT_SLL; |
1092 |
goto gen_arith32;
|
|
1096 |
goto gen_arith; |
|
1093 | 1097 |
case INDEX_op_shr_i32: |
1094 | 1098 |
c = SHIFT_SRL; |
1095 |
goto gen_arith32;
|
|
1099 |
goto gen_arith; |
|
1096 | 1100 |
case INDEX_op_sar_i32: |
1097 | 1101 |
c = SHIFT_SRA; |
1098 |
goto gen_arith32;
|
|
1102 |
goto gen_arith; |
|
1099 | 1103 |
case INDEX_op_mul_i32: |
1100 | 1104 |
c = ARITH_UMUL; |
1101 |
goto gen_arith32;
|
|
1105 |
goto gen_arith; |
|
1102 | 1106 |
case INDEX_op_div2_i32: |
1103 | 1107 |
#if defined(__sparc_v9__) || defined(__sparc_v8plus__) |
1104 | 1108 |
c = ARITH_SDIVX; |
1105 |
goto gen_arith32;
|
|
1109 |
goto gen_arith; |
|
1106 | 1110 |
#else |
1107 | 1111 |
tcg_out_sety(s, 0); |
1108 | 1112 |
c = ARITH_SDIV; |
1109 |
goto gen_arith32;
|
|
1113 |
goto gen_arith; |
|
1110 | 1114 |
#endif |
1111 | 1115 |
case INDEX_op_divu2_i32: |
1112 | 1116 |
#if defined(__sparc_v9__) || defined(__sparc_v8plus__) |
1113 | 1117 |
c = ARITH_UDIVX; |
1114 |
goto gen_arith32;
|
|
1118 |
goto gen_arith; |
|
1115 | 1119 |
#else |
1116 | 1120 |
tcg_out_sety(s, 0); |
1117 | 1121 |
c = ARITH_UDIV; |
1118 |
goto gen_arith32;
|
|
1122 |
goto gen_arith; |
|
1119 | 1123 |
#endif |
1120 | 1124 |
|
1121 | 1125 |
case INDEX_op_brcond_i32: |
... | ... | |
1173 | 1177 |
break; |
1174 | 1178 |
case INDEX_op_shl_i64: |
1175 | 1179 |
c = SHIFT_SLLX; |
1176 |
goto gen_arith32;
|
|
1180 |
goto gen_arith; |
|
1177 | 1181 |
case INDEX_op_shr_i64: |
1178 | 1182 |
c = SHIFT_SRLX; |
1179 |
goto gen_arith32;
|
|
1183 |
goto gen_arith; |
|
1180 | 1184 |
case INDEX_op_sar_i64: |
1181 | 1185 |
c = SHIFT_SRAX; |
1182 |
goto gen_arith32;
|
|
1186 |
goto gen_arith; |
|
1183 | 1187 |
case INDEX_op_mul_i64: |
1184 | 1188 |
c = ARITH_MULX; |
1185 |
goto gen_arith32;
|
|
1189 |
goto gen_arith; |
|
1186 | 1190 |
case INDEX_op_div2_i64: |
1187 | 1191 |
c = ARITH_SDIVX; |
1188 |
goto gen_arith32;
|
|
1192 |
goto gen_arith; |
|
1189 | 1193 |
case INDEX_op_divu2_i64: |
1190 | 1194 |
c = ARITH_UDIVX; |
1191 |
goto gen_arith32;
|
|
1195 |
goto gen_arith; |
|
1192 | 1196 |
|
1193 | 1197 |
case INDEX_op_brcond_i64: |
1194 | 1198 |
tcg_out_brcond_i64(s, args[2], args[0], args[1], const_args[1], |
... | ... | |
1202 | 1206 |
break; |
1203 | 1207 |
|
1204 | 1208 |
#endif |
1205 |
gen_arith32: |
|
1206 |
if (const_args[2]) { |
|
1207 |
tcg_out_arithi(s, args[0], args[1], args[2], c); |
|
1208 |
} else { |
|
1209 |
tcg_out_arith(s, args[0], args[1], args[2], c); |
|
1210 |
} |
|
1209 |
gen_arith: |
|
1210 |
tcg_out_arithc(s, args[0], args[1], args[2], const_args[2], c); |
|
1211 | 1211 |
break; |
1212 | 1212 |
|
1213 | 1213 |
default: |
Also available in: Unified diff