Lines Matching refs:env

170 addInstr(ISelEnv *env, s390_insn *insn)
172 addHInstr(env->code, insn);
193 lookupIRTemp(ISelEnv *env, IRTemp tmp)
195 vassert(tmp < env->n_vregmap);
196 vassert(env->vregmap[tmp] != INVALID_HREG);
198 return env->vregmap[tmp];
204 lookupIRTemp128(HReg *hi, HReg *lo, ISelEnv *env, IRTemp tmp)
206 vassert(tmp < env->n_vregmap);
207 vassert(env->vregmapHI[tmp] != INVALID_HREG);
209 *lo = env->vregmap[tmp];
210 *hi = env->vregmapHI[tmp];
216 newVRegI(ISelEnv *env)
218 HReg reg = mkHReg(env->vreg_ctr, HRcInt64, True /* virtual */ );
219 env->vreg_ctr++;
227 newVRegF(ISelEnv *env)
229 HReg reg = mkHReg(env->vreg_ctr, HRcFlt64, True /* virtual */ );
231 env->vreg_ctr++;
288 s390_isel_amode_wrk(ISelEnv *env, IRExpr *expr)
307 return s390_amode_b12((Int)value, s390_isel_int_expr(env, arg1));
312 return s390_amode_b20((Int)value, s390_isel_int_expr(env, arg1));
319 return s390_amode_b12(0, s390_isel_int_expr(env, expr));
324 s390_isel_amode(ISelEnv *env, IRExpr *expr)
329 vassert(typeOfIRExpr(env->type_env, expr) == Ity_I64);
331 am = s390_isel_amode_wrk(env, expr);
452 doHelperCall(ISelEnv *env, Bool passBBP, IRExpr *guard,
475 IRType type = typeOfIRExpr(env->type_env, args[i]);
491 tmpregs[argreg] = newVRegI(env);
492 addInstr(env, s390_insn_move(sizeof(ULong), tmpregs[argreg],
499 tmpregs[argreg] = s390_isel_int_expr(env, args[i]);
511 cc = s390_isel_cc(env, guard);
522 addInstr(env, s390_insn_move(size, finalreg, tmpregs[i]));
528 addInstr(env, s390_insn_helper_call(cc, (Addr64)target, n_args,
570 convert_s390_fpcc_to_vex(ISelEnv *env, HReg cc_s390)
574 cc0 = newVRegI(env);
575 addInstr(env, s390_insn_move(4, cc0, cc_s390));
576 addInstr(env, s390_insn_alu(4, S390_ALU_AND, cc0, s390_opnd_imm(1)));
578 cc1 = newVRegI(env);
579 addInstr(env, s390_insn_move(4, cc1, cc_s390));
580 addInstr(env, s390_insn_alu(4, S390_ALU_RSH, cc1, s390_opnd_imm(1)));
582 b2 = newVRegI(env);
583 addInstr(env, s390_insn_move(4, b2, cc0));
584 addInstr(env, s390_insn_alu(4, S390_ALU_AND, b2, s390_opnd_reg(cc1)));
585 addInstr(env, s390_insn_alu(4, S390_ALU_LSH, b2, s390_opnd_imm(2)));
587 b6 = newVRegI(env);
588 addInstr(env, s390_insn_move(4, b6, cc0));
589 addInstr(env, s390_insn_alu(4, S390_ALU_SUB, b6, s390_opnd_reg(cc1)));
590 addInstr(env, s390_insn_alu(4, S390_ALU_ADD, b6, s390_opnd_imm(1)));
591 addInstr(env, s390_insn_alu(4, S390_ALU_AND, b6, s390_opnd_imm(1)));
592 addInstr(env, s390_insn_alu(4, S390_ALU_LSH, b6, s390_opnd_imm(6)));
594 cc_vex = newVRegI(env);
595 addInstr(env, s390_insn_move(4, cc_vex, cc0));
596 addInstr(env, s390_insn_alu(4, S390_ALU_OR, cc_vex, s390_opnd_reg(b2)));
597 addInstr(env, s390_insn_alu(4, S390_ALU_OR, cc_vex, s390_opnd_reg(b6)));
607 s390_isel_int128_expr_wrk(HReg *dst_hi, HReg *dst_lo, ISelEnv *env,
610 IRType ty = typeOfIRExpr(env->type_env, expr);
621 lookupIRTemp128(dst_hi, dst_lo, env, expr->Iex.RdTmp.tmp);
648 *dst_hi = s390_isel_int_expr(env, arg1);
649 *dst_lo = s390_isel_int_expr(env, arg2);
656 h1 = s390_isel_int_expr(env, arg1); /* Process 1st operand */
657 op2 = s390_isel_int_expr_RMI(env, arg2); /* Process 2nd operand */
664 addInstr(env, s390_insn_move(8, r11, h1));
667 addInstr(env, s390_insn_divs(8, r10, r11, op2));
673 *dst_hi = newVRegI(env);
674 *dst_lo = newVRegI(env);
675 addInstr(env, s390_insn_move(8, *dst_hi, r10));
676 addInstr(env, s390_insn_move(8, *dst_lo, r11));
689 h1 = s390_isel_int_expr(env, arg1); /* Process 1st operand */
690 op2 = s390_isel_int_expr_RMI(env, arg2); /* Process 2nd operand */
697 addInstr(env, s390_insn_move(8, r11, h1));
700 addInstr(env, s390_insn_mul(8, r10, r11, op2, is_signed_multiply));
704 *dst_hi = newVRegI(env);
705 *dst_lo = newVRegI(env);
706 addInstr(env, s390_insn_move(8, *dst_hi, r10));
707 addInstr(env, s390_insn_move(8, *dst_lo, r11));
715 s390_isel_int128_expr(&hi, &lo, env, arg1);
716 op2 = s390_isel_int_expr_RMI(env, arg2); /* Process 2nd operand */
724 addInstr(env, s390_insn_move(8, r10, hi));
725 addInstr(env, s390_insn_move(8, r11, lo));
728 addInstr(env, s390_insn_div(8, r10, r11, op2, is_signed_divide));
734 *dst_hi = newVRegI(env);
735 *dst_lo = newVRegI(env);
736 addInstr(env, s390_insn_move(8, *dst_hi, r10));
737 addInstr(env, s390_insn_move(8, *dst_lo, r11));
751 s390_isel_int128_expr(HReg *dst_hi, HReg *dst_lo, ISelEnv *env, IRExpr *expr)
753 s390_isel_int128_expr_wrk(dst_hi, dst_lo, env, expr);
784 s390_isel_int_expr_wrk(ISelEnv *env, IRExpr *expr)
786 IRType ty = typeOfIRExpr(env->type_env, expr);
799 return lookupIRTemp(env, expr->Iex.RdTmp.tmp);
803 HReg dst = newVRegI(env);
804 s390_amode *am = s390_isel_amode(env, expr->Iex.Load.addr);
809 addInstr(env, s390_insn_load(size, dst, am));
845 h1 = s390_isel_int_expr(env, arg1); /* Process 1st operand */
846 op2 = s390_isel_int_expr_RMI(env, arg2); /* Process 2nd operand */
853 addInstr(env, s390_insn_move(arg_size, r11, h1));
856 addInstr(env, s390_insn_mul(arg_size, r10, r11, op2, is_signed_multiply));
860 res = newVRegI(env);
861 addInstr(env, s390_insn_move(arg_size, res, r10));
863 addInstr(env, s390_insn_alu(size, S390_ALU_LSH, res, value));
865 addInstr(env, s390_insn_alu(size, S390_ALU_AND, r11, value));
867 addInstr(env, s390_insn_alu(size, S390_ALU_OR, res, opnd));
882 h1 = s390_isel_int_expr(env, arg1); /* Process 1st operand */
883 op2 = s390_isel_int_expr_RMI(env, arg2); /* Process 2nd operand */
891 addInstr(env, s390_insn_move(8, r10, h1));
892 addInstr(env, s390_insn_move(8, r11, h1));
894 addInstr(env, s390_insn_alu(8, S390_ALU_RSH, r10, value));
897 addInstr(env, s390_insn_div(4, r10, r11, op2, is_signed_divide));
903 res = newVRegI(env);
904 addInstr(env, s390_insn_move(8, res, r10));
906 addInstr(env, s390_insn_alu(8, S390_ALU_LSH, res, value));
908 addInstr(env, s390_insn_alu(8, S390_ALU_AND, r11, value));
910 addInstr(env, s390_insn_alu(8, S390_ALU_OR, res, opnd));
924 res = newVRegI(env);
925 h1 = s390_isel_float_expr(env, arg2); /* Process operand */
928 addInstr(env, s390_insn_bfp_unop(size, bfpop, res, h1, rounding_mode));
936 res = newVRegI(env);
937 s390_isel_float128_expr(&op_hi, &op_lo, env, arg2); /* operand */
944 addInstr(env, s390_insn_move(8, f13, op_hi));
945 addInstr(env, s390_insn_move(8, f15, op_lo));
948 addInstr(env, s390_insn_bfp128_convert_from(size, bfpop, res, f13, f15,
959 res = newVRegI(env);
960 h1 = s390_isel_int_expr(env, arg1); /* Process 1st operand */
961 h2 = s390_isel_int_expr(env, arg2); /* Process 2nd operand */
963 addInstr(env, s390_insn_move(arg_size, res, h1));
965 addInstr(env, s390_insn_alu(size, S390_ALU_LSH, res, value));
967 addInstr(env, s390_insn_alu(size, S390_ALU_AND, h2, value));
969 addInstr(env, s390_insn_alu(size, S390_ALU_OR, res, opnd));
975 res = newVRegI(env);
976 h1 = s390_isel_int_expr(env, arg1);
977 op2 = s390_isel_int_expr_RMI(env, arg2);
979 addInstr(env, s390_insn_move(size, res, h1));
980 addInstr(env, s390_insn_compare(size, res, op2, False /* signed */));
981 addInstr(env, s390_insn_cond_move(size, S390_CC_L, res, op2));
989 h1 = s390_isel_float_expr(env, arg1);
990 h2 = s390_isel_float_expr(env, arg2);
991 cc_s390 = newVRegI(env);
995 addInstr(env, s390_insn_bfp_compare(size, cc_s390, h1, h2));
997 return convert_s390_fpcc_to_vex(env, cc_s390);
1003 s390_isel_float128_expr(&op1_hi, &op1_lo, env, arg1); /* 1st operand */
1004 s390_isel_float128_expr(&op2_hi, &op2_lo, env, arg2); /* 2nd operand */
1005 cc_s390 = newVRegI(env);
1014 addInstr(env, s390_insn_move(8, f12, op1_hi));
1015 addInstr(env, s390_insn_move(8, f14, op1_lo));
1018 addInstr(env, s390_insn_move(8, f13, op2_hi));
1019 addInstr(env, s390_insn_move(8, f15, op2_lo));
1021 res = newVRegI(env);
1022 addInstr(env, s390_insn_bfp128_compare(16, cc_s390, f12, f14, f13, f15));
1024 return convert_s390_fpcc_to_vex(env, cc_s390);
1093 res = newVRegI(env);
1094 op2 = s390_isel_int_expr_RMI(env, arg2); /* Process 2nd operand */
1096 addInstr(env, insn);
1105 h1 = s390_isel_int_expr(env, arg1); /* Process 1st operand */
1106 op2 = s390_isel_int_expr_RMI(env, arg2); /* Process 2nd operand */
1107 res = newVRegI(env);
1108 addInstr(env, s390_insn_move(size, res, h1));
1111 addInstr(env, insn);
1140 h1 = s390_isel_int_expr(env, arg->Iex.Binop.arg1); /* 1st opnd */
1141 opnd = s390_isel_int_expr_RMI(env, arg->Iex.Binop.arg2); /* 2nd opnd */
1142 dst = newVRegI(env); /* Result goes into a new register */
1143 addInstr(env, s390_insn_move(size, dst, h1));
1144 addInstr(env, s390_insn_alu(size, S390_ALU_MUL, dst, opnd));
1150 dst = newVRegI(env);
1151 h1 = s390_isel_float_expr(env, arg); /* Process the operand */
1152 addInstr(env, s390_insn_move(size, dst, h1));
1158 if (typeOfIRExpr(env->type_env, arg) == Ity_I1) {
1159 s390_cc_t cond = s390_isel_cc(env, arg);
1160 dst = newVRegI(env); /* Result goes into a new register */
1161 addInstr(env, s390_insn_cc2bool(dst, cond));
1168 addInstr(env, s390_insn_alu(4, S390_ALU_AND, dst, mask));
1174 addInstr(env, s390_insn_alu(8, S390_ALU_AND, dst, mask));
1181 addInstr(env, s390_insn_alu(4, S390_ALU_LSH, dst, shift));
1182 addInstr(env, s390_insn_alu(4, S390_ALU_RSHA, dst, shift));
1187 addInstr(env, s390_insn_alu(8, S390_ALU_LSH, dst, shift));
1188 addInstr(env, s390_insn_alu(8, S390_ALU_RSHA, dst, shift));
1203 s390_isel_int128_expr(&dst_hi, &dst_lo, env, arg);
1210 s390_isel_int128_expr(&dst_hi, &dst_lo, env, arg);
1214 dst = newVRegI(env); /* Result goes into a new register */
1215 opnd = s390_isel_int_expr_RMI(env, arg); /* Process the operand */
1261 addInstr(env, s390_opnd_copy(8, dst, opnd));
1267 addInstr(env, s390_opnd_copy(4, dst, opnd));
1273 addInstr(env, s390_opnd_copy(2, dst, opnd));
1284 addInstr(env, s390_opnd_copy(size, dst, opnd));
1292 addInstr(env, s390_insn_unop(size, S390_NEGATE, dst, opnd));
1300 addInstr(env, s390_insn_unop(size, S390_NEGATE, dst, opnd));
1301 addInstr(env, s390_insn_alu(size, S390_ALU_OR, dst, opnd));
1303 addInstr(env, s390_insn_alu(size, S390_ALU_RSHA, dst, shift));
1317 addInstr(env, s390_insn_clz(8, r10, r11, opnd));
1318 addInstr(env, s390_insn_move(8, dst, r10));
1326 addInstr(env, insn);
1333 HReg dst = newVRegI(env);
1340 addInstr(env, s390_insn_load(size, dst, am));
1351 HReg dst = newVRegI(env);
1353 doHelperCall(env, False, NULL, expr->Iex.CCall.cee,
1364 HReg dst = newVRegI(env);
1376 addInstr(env, s390_insn_load_immediate(size, dst, value));
1389 dst = newVRegI(env);
1390 r0 = s390_isel_int_expr_RMI(env, expr->Iex.Mux0X.expr0);
1391 rX = s390_isel_int_expr(env, expr->Iex.Mux0X.exprX);
1392 size = sizeofIRType(typeOfIRExpr(env->type_env, expr->Iex.Mux0X.exprX));
1395 s390_cc_t cc = s390_isel_cc(env, cond_expr->Iex.Unop.arg);
1397 addInstr(env, s390_insn_move(size, dst, rX));
1398 addInstr(env, s390_insn_cond_move(size, s390_cc_invert(cc), dst, r0));
1403 addInstr(env, s390_insn_move(size, dst, rX));
1406 cond = s390_isel_int_expr_RMI(env, cond_expr);
1409 tmp = newVRegI(env);
1410 addInstr(env, s390_insn_load_immediate(4, tmp, 0xFF));
1411 addInstr(env, s390_insn_alu(4, S390_ALU_AND, tmp, cond));
1415 addInstr(env, s390_insn_compare(4, tmp, zero, 0 /* signed */));
1418 size = sizeofIRType(typeOfIRExpr(env->type_env, expr->Iex.Mux0X.expr0));
1419 addInstr(env, s390_insn_cond_move(size, S390_CC_E, dst, r0));
1436 s390_isel_int_expr(ISelEnv *env, IRExpr *expr)
1438 HReg dst = s390_isel_int_expr_wrk(env, expr);
1449 s390_isel_int_expr_RMI(ISelEnv *env, IRExpr *expr)
1451 IRType ty = typeOfIRExpr(env->type_env, expr);
1459 dst.variant.am = s390_isel_amode(env, expr->Iex.Load.addr);
1482 dst.variant.reg = s390_isel_int_expr(env, expr);
1493 s390_isel_float128_expr_wrk(HReg *dst_hi, HReg *dst_lo, ISelEnv *env,
1496 IRType ty = typeOfIRExpr(env->type_env, expr);
1502 lookupIRTemp128(dst_hi, dst_lo, env, expr->Iex.RdTmp.tmp);
1509 lookupIRTemp128(dst_hi, dst_lo, env, expr->Iex.RdTmp.tmp);
1523 am_hi = s390_isel_amode(env, addr_hi);
1524 am_lo = s390_isel_amode(env, addr_lo);
1526 *dst_hi = newVRegF(env);
1527 *dst_lo = newVRegF(env);
1528 addInstr(env, s390_insn_load(8, *dst_hi, am_hi));
1529 addInstr(env, s390_insn_load(8, *dst_hi, am_lo));
1554 s390_isel_float128_expr(&op1_hi, &op1_lo, env, left); /* 1st operand */
1555 s390_isel_float128_expr(&op2_hi, &op2_lo, env, right); /* 2nd operand */
1564 addInstr(env, s390_insn_move(8, f12, op1_hi));
1565 addInstr(env, s390_insn_move(8, f14, op1_lo));
1568 addInstr(env, s390_insn_move(8, f13, op2_hi));
1569 addInstr(env, s390_insn_move(8, f15, op2_lo));
1581 addInstr(env, s390_insn_bfp128_binop(16, bfpop, f12, f14, f13,
1585 *dst_hi = newVRegF(env);
1586 *dst_lo = newVRegF(env);
1587 addInstr(env, s390_insn_move(8, *dst_hi, f12));
1588 addInstr(env, s390_insn_move(8, *dst_lo, f14));
1607 s390_isel_float128_expr(&op_hi, &op_lo, env, expr->Iex.Binop.arg2);
1610 addInstr(env, s390_insn_move(8, f13, op_hi));
1611 addInstr(env, s390_insn_move(8, f15, op_lo));
1616 addInstr(env, s390_insn_bfp128_unop(16, bfpop, f12, f14, f13, f15,
1620 *dst_hi = newVRegF(env);
1621 *dst_lo = newVRegF(env);
1622 addInstr(env, s390_insn_move(8, *dst_hi, f12));
1623 addInstr(env, s390_insn_move(8, *dst_lo, f14));
1627 *dst_hi = s390_isel_float_expr(env, expr->Iex.Binop.arg1);
1628 *dst_lo = s390_isel_float_expr(env, expr->Iex.Binop.arg2);
1661 s390_isel_float128_expr(&op_hi, &op_lo, env, left);
1664 addInstr(env, s390_insn_move(8, f13, op_hi));
1665 addInstr(env, s390_insn_move(8, f15, op_lo));
1668 addInstr(env, s390_insn_bfp128_unop(16, bfpop, f12, f14, f13, f15,
1673 op = s390_isel_float_expr(env, left);
1674 addInstr(env, s390_insn_bfp128_convert_to(16, bfpop, f12, f14,
1679 op = s390_isel_int_expr(env, left);
1680 addInstr(env, s390_insn_bfp128_convert_to(16, bfpop, f12, f14,
1686 *dst_hi = newVRegF(env);
1687 *dst_lo = newVRegF(env);
1688 addInstr(env, s390_insn_move(8, *dst_hi, f12));
1689 addInstr(env, s390_insn_move(8, *dst_lo, f14));
1707 s390_isel_float128_expr(HReg *dst_hi, HReg *dst_lo, ISelEnv *env, IRExpr *expr)
1709 s390_isel_float128_expr_wrk(dst_hi, dst_lo, env, expr);
1724 s390_isel_float_expr_wrk(ISelEnv *env, IRExpr *expr)
1726 IRType ty = typeOfIRExpr(env->type_env, expr);
1736 return lookupIRTemp(env, expr->Iex.RdTmp.tmp);
1740 HReg dst = newVRegF(env);
1741 s390_amode *am = s390_isel_amode(env, expr->Iex.Load.addr);
1746 addInstr(env, s390_insn_load(size, dst, am));
1753 HReg dst = newVRegF(env);
1756 addInstr(env, s390_insn_load(size, dst, am));
1767 HReg dst = newVRegF(env);
1779 addInstr(env, s390_insn_load_immediate(size, dst, value));
1790 op1 = s390_isel_float_expr(env, expr->Iex.Qop.details->arg2);
1791 op2 = s390_isel_float_expr(env, expr->Iex.Qop.details->arg3);
1792 op3 = s390_isel_float_expr(env, expr->Iex.Qop.details->arg4);
1793 dst = newVRegF(env);
1794 addInstr(env, s390_insn_move(size, dst, op1));
1807 addInstr(env, s390_insn_bfp_triop(size, bfpop, dst, op2, op3,
1822 h1 = s390_isel_float_expr(env, left); /* Process 1st operand */
1823 op2 = s390_isel_float_expr(env, right); /* Process 2nd operand */
1824 dst = newVRegF(env);
1825 addInstr(env, s390_insn_move(size, dst, h1));
1841 addInstr(env, s390_insn_bfp_binop(size, bfpop, dst, op2, rounding_mode));
1883 s390_isel_float128_expr(&op_hi, &op_lo, env, expr->Iex.Binop.arg2);
1892 addInstr(env, s390_insn_move(8, f13, op_hi));
1893 addInstr(env, s390_insn_move(8, f15, op_lo));
1895 dst = newVRegF(env);
1896 addInstr(env, s390_insn_bfp128_unop(16, bfpop, f12, f14, f13, f15,
1900 addInstr(env, s390_insn_move(8, dst, f12));
1907 h1 = s390_isel_int_expr(env, left);
1909 h1 = s390_isel_float_expr(env, left);
1912 dst = newVRegF(env);
1914 addInstr(env, s390_insn_bfp_unop(size, bfpop, dst, h1, rounding_mode));
1929 s390_isel_float128_expr(&dst_hi, &dst_lo, env, left);
1934 dst = newVRegF(env);
1935 h1 = s390_isel_int_expr(env, left); /* Process the operand */
1936 addInstr(env, s390_insn_move(size, dst, h1));
1961 h1 = s390_isel_int_expr(env, left);
1963 h1 = s390_isel_float_expr(env, left->Iex.Unop.arg);
1965 h1 = s390_isel_float_expr(env, left);
1967 dst = newVRegF(env);
1969 addInstr(env, s390_insn_bfp_unop(size, bfpop, dst, h1, rounding_mode));
1985 s390_isel_float_expr(ISelEnv *env, IRExpr *expr)
1987 HReg dst = s390_isel_float_expr_wrk(env, expr);
2003 s390_isel_cc(ISelEnv *env, IRExpr *cond)
2007 vassert(typeOfIRExpr(env->type_env, cond) == Ity_I1);
2021 HReg reg = lookupIRTemp(env, tmp);
2024 if (typeOfIRTemp(env->type_env, tmp) == Ity_I1)
2027 size = sizeofIRType(typeOfIRTemp(env->type_env, tmp));
2028 addInstr(env, s390_insn_test(size, s390_opnd_reg(reg)));
2039 return s390_cc_invert(s390_isel_cc(env, arg));
2044 HReg dst = newVRegI(env);
2045 HReg h1 = s390_isel_int_expr(env, arg);
2047 size = sizeofIRType(typeOfIRExpr(env->type_env, arg));
2049 addInstr(env, s390_insn_move(size, dst, h1));
2050 addInstr(env, s390_insn_alu(size, S390_ALU_AND, dst, s390_opnd_imm(1)));
2051 addInstr(env, s390_insn_test(size, s390_opnd_reg(dst)));
2063 dst = newVRegI(env);
2064 src = s390_isel_int_expr_RMI(env, arg);
2065 addInstr(env, s390_insn_unop(4, op, dst, src));
2066 addInstr(env, s390_insn_test(4, s390_opnd_reg(dst)));
2074 src = s390_isel_int_expr_RMI(env, arg);
2075 size = sizeofIRType(typeOfIRExpr(env->type_env, arg));
2076 addInstr(env, s390_insn_test(size, src));
2091 size = sizeofIRType(typeOfIRExpr(env->type_env, arg1));
2124 op1 = s390_isel_int_expr_RMI(env, arg1);
2125 reg1 = newVRegI(env);
2126 addInstr(env, s390_insn_unop(4, op, reg1, op1));
2128 op2 = s390_isel_int_expr_RMI(env, arg2);
2129 reg2 = newVRegI(env);
2130 addInstr(env, s390_insn_unop(4, op, reg2, op2)); /* zero extend */
2133 addInstr(env, s390_insn_compare(4, reg1, op2, False));
2158 op1 = s390_isel_int_expr(env, arg1);
2159 op2 = s390_isel_int_expr_RMI(env, arg2);
2161 addInstr(env, s390_insn_compare(size, op1, op2, False));
2173 op1 = s390_isel_int_expr(env, arg1);
2174 op2 = s390_isel_int_expr_RMI(env, arg2);
2176 addInstr(env, s390_insn_compare(size, op1, op2, True));
2189 op1 = s390_isel_int_expr(env, arg1);
2190 op2 = s390_isel_int_expr_RMI(env, arg2);
2192 addInstr(env, s390_insn_compare(size, op1, op2, False));
2214 s390_isel_stmt(ISelEnv *env, IRStmt *stmt)
2226 IRType tyd = typeOfIRExpr(env->type_env, stmt->Ist.Store.data);
2232 am = s390_isel_amode(env, stmt->Ist.Store.addr);
2239 src = s390_isel_int_expr(env, stmt->Ist.Store.data);
2244 src = s390_isel_float_expr(env, stmt->Ist.Store.data);
2255 addInstr(env, s390_insn_store(sizeofIRType(tyd), am, src));
2261 IRType tyd = typeOfIRExpr(env->type_env, stmt->Ist.Put.data);
2288 if (env->first_IA_assignment) {
2289 env->first_IA_assignment = False;
2296 env->old_value_valid[guest_reg] = False;
2306 old_value = env->old_value[guest_reg];
2308 env->old_value[guest_reg] = new_value;
2310 Bool old_value_is_valid = env->old_value_valid[guest_reg];
2311 env->old_value_valid[guest_reg] = True;
2324 addInstr(env, s390_insn_gzero(sizeofIRType(tyd), offset));
2335 addInstr(env, s390_insn_gadd(sizeofIRType(tyd), offset,
2348 addInstr(env, s390_insn_load_immediate(4, r0,
2350 addInstr(env, s390_insn_store(4, gam, r0));
2364 src = s390_isel_int_expr(env, stmt->Ist.Put.data);
2369 src = s390_isel_float_expr(env, stmt->Ist.Put.data);
2380 addInstr(env, s390_insn_store(sizeofIRType(tyd), am, src));
2387 IRType tyd = typeOfIRTemp(env->type_env, tmp);
2394 s390_isel_int128_expr(&res_hi, &res_lo, env, stmt->Ist.WrTmp.data);
2395 lookupIRTemp128(&dst_hi, &dst_lo, env, tmp);
2397 addInstr(env, s390_insn_move(8, dst_hi, res_hi));
2398 addInstr(env, s390_insn_move(8, dst_lo, res_lo));
2406 src = s390_isel_int_expr(env, stmt->Ist.WrTmp.data);
2407 dst = lookupIRTemp(env, tmp);
2411 s390_cc_t cond = s390_isel_cc(env, stmt->Ist.WrTmp.data);
2412 dst = lookupIRTemp(env, tmp);
2413 addInstr(env, s390_insn_cc2bool(dst, cond));
2419 src = s390_isel_float_expr(env, stmt->Ist.WrTmp.data);
2420 dst = lookupIRTemp(env, tmp);
2426 s390_isel_float128_expr(&res_hi, &res_lo, env, stmt->Ist.WrTmp.data);
2427 lookupIRTemp128(&dst_hi, &dst_lo, env, tmp);
2429 addInstr(env, s390_insn_move(8, dst_hi, res_hi));
2430 addInstr(env, s390_insn_move(8, dst_lo, res_lo));
2438 addInstr(env, s390_insn_move(sizeofIRType(tyd), dst, src));
2459 env->old_value_valid[guest_reg] = False;
2471 doHelperCall(env, passBBP, d->guard, d->cee, d->args, dst);
2475 retty = typeOfIRTemp(env->type_env, d->tmp);
2479 dst = lookupIRTemp(env, d->tmp);
2480 doHelperCall(env, passBBP, d->guard, d->cee, d->args, dst);
2489 s390_amode *op2 = s390_isel_amode(env, cas->addr);
2490 HReg op3 = s390_isel_int_expr(env, cas->dataLo); /* new value */
2491 HReg op1 = s390_isel_int_expr(env, cas->expdLo); /* expected value */
2492 HReg old = lookupIRTemp(env, cas->oldLo);
2494 if (typeOfIRTemp(env->type_env, cas->oldLo) == Ity_I32) {
2495 addInstr(env, s390_insn_cas(4, op1, op2, op3, old));
2497 addInstr(env, s390_insn_cas(8, op1, op2, op3, old));
2502 s390_amode *op2 = s390_isel_amode(env, cas->addr);
2504 HReg op3_high = s390_isel_int_expr(env, cas->dataHi); /* new value */
2505 HReg op3_low = s390_isel_int_expr(env, cas->dataLo); /* new value */
2506 HReg op1_high = s390_isel_int_expr(env, cas->expdHi); /* expected value */
2507 HReg op1_low = s390_isel_int_expr(env, cas->expdLo); /* expected value */
2508 HReg old_low = lookupIRTemp(env, cas->oldLo);
2509 HReg old_high = lookupIRTemp(env, cas->oldHi);
2515 addInstr(env, s390_insn_move(8, r8, op1_high));
2516 addInstr(env, s390_insn_move(8, r9, op1_low));
2522 addInstr(env, s390_insn_move(8, r10, op3_high));
2523 addInstr(env, s390_insn_move(8, r11, op3_low));
2528 if (typeOfIRTemp(env->type_env, cas->oldLo) == Ity_I32) {
2529 addInstr(env, s390_insn_cdas(4, r8, r9, op2, r10, r11,
2532 addInstr(env, s390_insn_cdas(8, r8, r9, op2, r10, r11,
2535 addInstr(env, s390_insn_move(8, op1_high, r8));
2536 addInstr(env, s390_insn_move(8, op1_low, r9));
2537 addInstr(env, s390_insn_move(8, op3_high, r10));
2538 addInstr(env, s390_insn_move(8, op3_low, r11));
2552 cond = s390_isel_cc(env, stmt->Ist.Exit.guard);
2556 if (env->chaining_allowed) {
2561 = ((Addr64)stmt->Ist.Exit.dst->Ico.U64) > env->max_ga;
2563 addInstr(env, s390_insn_xdirect(cond, stmt->Ist.Exit.dst->Ico.U64,
2569 HReg dst = s390_isel_int_expr(env,
2571 addInstr(env, s390_insn_xassisted(cond, dst, guest_IA, Ijk_Boring));
2585 HReg dst = s390_isel_int_expr(env, IRExpr_Const(stmt->Ist.Exit.dst));
2586 addInstr(env, s390_insn_xassisted(cond, dst, guest_IA,
2602 addInstr(env, s390_insn_mfence());
2632 iselNext(ISelEnv *env, IRExpr *next, IRJumpKind jk, int offsIP)
2650 if (env->chaining_allowed) {
2655 = ((Addr64)cdst->Ico.U64) > env->max_ga;
2657 addInstr(env, s390_insn_xdirect(S390_CC_ALWAYS, cdst->Ico.U64,
2663 HReg dst = s390_isel_int_expr(env, next);
2664 addInstr(env, s390_insn_xassisted(S390_CC_ALWAYS, dst, guest_IA,
2676 HReg dst = s390_isel_int_expr(env, next);
2677 if (env->chaining_allowed) {
2678 addInstr(env, s390_insn_xindir(S390_CC_ALWAYS, dst, guest_IA));
2680 addInstr(env, s390_insn_xassisted(S390_CC_ALWAYS, dst, guest_IA,
2698 HReg dst = s390_isel_int_expr(env, next);
2699 addInstr(env, s390_insn_xassisted(S390_CC_ALWAYS, dst, guest_IA, jk));
2726 ISelEnv *env;
2736 env = LibVEX_Alloc(sizeof(ISelEnv));
2737 env->vreg_ctr = 0;
2740 env->code = newHInstrArray();
2742 /* Copy BB's type env. */
2743 env->type_env = bb->tyenv;
2746 env->first_IA_assignment = True;
2748 env->old_value[i] = 0; /* just something to have a defined value */
2749 env->old_value_valid[i] = False;
2758 env->n_vregmap = bb->tyenv->types_used;
2759 env->vregmap = LibVEX_Alloc(env->n_vregmap * sizeof(HReg));
2760 env->vregmapHI = LibVEX_Alloc(env->n_vregmap * sizeof(HReg));
2763 env->hwcaps = hwcaps_host;
2765 env->max_ga = max_ga;
2766 env->chaining_allowed = chaining_allowed;
2771 for (i = 0; i < env->n_vregmap; i++) {
2806 env->vregmap[i] = hreg;
2807 env->vregmapHI[i] = hregHI;
2809 env->vreg_ctr = j;
2815 addInstr(env, s390_insn_evcheck(counter, fail_addr));
2822 addInstr(env, s390_insn_profinc());
2828 s390_isel_stmt(env, bb->stmts[i]);
2830 iselNext(env, bb->next, bb->jumpkind, bb->offsIP);
2833 env->code->n_vregs = env->vreg_ctr;
2835 return env->code;