aboutsummaryrefslogtreecommitdiff
path: root/src/lj_asm.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lj_asm.c')
-rw-r--r--src/lj_asm.c32
1 files changed, 19 insertions, 13 deletions
diff --git a/src/lj_asm.c b/src/lj_asm.c
index e847b8c9..6ff32940 100644
--- a/src/lj_asm.c
+++ b/src/lj_asm.c
@@ -1070,23 +1070,26 @@ static void asm_bufput(ASMState *as, IRIns *ir)
1070 GCstr *s = ir_kstr(irs); 1070 GCstr *s = ir_kstr(irs);
1071 if (s->len == 1) { /* Optimize put of single-char string constant. */ 1071 if (s->len == 1) { /* Optimize put of single-char string constant. */
1072 kchar = strdata(s)[0]; 1072 kchar = strdata(s)[0];
1073 ci = &lj_ir_callinfo[IRCALL_lj_buf_putchar];
1074 args[1] = ASMREF_TMP1; /* int, truncated to char */ 1073 args[1] = ASMREF_TMP1; /* int, truncated to char */
1074 ci = &lj_ir_callinfo[IRCALL_lj_buf_putchar];
1075 } 1075 }
1076 } else if (mayfuse(as, ir->op2) && ra_noreg(irs->r)) { 1076 } else if (mayfuse(as, ir->op2) && ra_noreg(irs->r)) {
1077 if (irs->o == IR_TOSTR) { /* Fuse number to string conversions. */ 1077 if (irs->o == IR_TOSTR) { /* Fuse number to string conversions. */
1078 if (LJ_SOFTFP ? (irs+1)->o == IR_HIOP : irt_isnum(IR(irs->op1)->t)) { 1078 if (irs->op2 == IRTOSTR_NUM) {
1079 ci = &lj_ir_callinfo[IRCALL_lj_buf_putnum];
1080 args[1] = ASMREF_TMP1; /* TValue * */ 1079 args[1] = ASMREF_TMP1; /* TValue * */
1080 ci = &lj_ir_callinfo[IRCALL_lj_buf_putnum];
1081 } else { 1081 } else {
1082 lua_assert(irt_isinteger(IR(irs->op1)->t)); 1082 lua_assert(irt_isinteger(IR(irs->op1)->t));
1083 ci = &lj_ir_callinfo[IRCALL_lj_buf_putint];
1084 args[1] = irs->op1; /* int */ 1083 args[1] = irs->op1; /* int */
1084 if (irs->op2 == IRTOSTR_INT)
1085 ci = &lj_ir_callinfo[IRCALL_lj_buf_putint];
1086 else
1087 ci = &lj_ir_callinfo[IRCALL_lj_buf_putchar];
1085 } 1088 }
1086 } else if (irs->o == IR_SNEW) { /* Fuse string allocation. */ 1089 } else if (irs->o == IR_SNEW) { /* Fuse string allocation. */
1087 ci = &lj_ir_callinfo[IRCALL_lj_buf_putmem];
1088 args[1] = irs->op1; /* const void * */ 1090 args[1] = irs->op1; /* const void * */
1089 args[2] = irs->op2; /* MSize */ 1091 args[2] = irs->op2; /* MSize */
1092 ci = &lj_ir_callinfo[IRCALL_lj_buf_putmem];
1090 } 1093 }
1091 } 1094 }
1092 asm_setupresult(as, ir, ci); /* SBuf * */ 1095 asm_setupresult(as, ir, ci); /* SBuf * */
@@ -1114,21 +1117,24 @@ static void asm_bufstr(ASMState *as, IRIns *ir)
1114 1117
1115static void asm_tostr(ASMState *as, IRIns *ir) 1118static void asm_tostr(ASMState *as, IRIns *ir)
1116{ 1119{
1120 const CCallInfo *ci;
1117 IRRef args[2]; 1121 IRRef args[2];
1118 args[0] = ASMREF_L; 1122 args[0] = ASMREF_L;
1119 as->gcsteps++; 1123 as->gcsteps++;
1120 if (irt_isnum(IR(ir->op1)->t) || (LJ_SOFTFP && (ir+1)->o == IR_HIOP)) { 1124 if (ir->op2 == IRTOSTR_NUM) {
1121 const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_str_fromnum];
1122 args[1] = ASMREF_TMP1; /* const lua_Number * */ 1125 args[1] = ASMREF_TMP1; /* const lua_Number * */
1123 asm_setupresult(as, ir, ci); /* GCstr * */ 1126 ci = &lj_ir_callinfo[IRCALL_lj_str_fromnum];
1124 asm_gencall(as, ci, args);
1125 asm_tvptr(as, ra_releasetmp(as, ASMREF_TMP1), ir->op1);
1126 } else { 1127 } else {
1127 const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_str_fromint];
1128 args[1] = ir->op1; /* int32_t k */ 1128 args[1] = ir->op1; /* int32_t k */
1129 asm_setupresult(as, ir, ci); /* GCstr * */ 1129 if (ir->op2 == IRTOSTR_INT)
1130 asm_gencall(as, ci, args); 1130 ci = &lj_ir_callinfo[IRCALL_lj_str_fromint];
1131 else
1132 ci = &lj_ir_callinfo[IRCALL_lj_str_fromchar];
1131 } 1133 }
1134 asm_setupresult(as, ir, ci); /* GCstr * */
1135 asm_gencall(as, ci, args);
1136 if (ir->op2 == IRTOSTR_NUM)
1137 asm_tvptr(as, ra_releasetmp(as, ASMREF_TMP1), ir->op1);
1132} 1138}
1133 1139
1134#if LJ_32 && LJ_HASFFI && !LJ_SOFTFP && !LJ_TARGET_X86 1140#if LJ_32 && LJ_HASFFI && !LJ_SOFTFP && !LJ_TARGET_X86