History

riscv: Fix tcctest.c

this is it! With this tcctest.c works, as well as compiling TCC with itself. abitest.c doesn't yet work due to known problems, all the rest does. There are still warnings during linking.

Michael Matz committed 7 years ago

Commit e9c2a191 parent 509f5611 file · +21 −5Browse files

Unified · Split

riscv64-gen.c+21−5
@@ -184,7 +184,7 @@ ST_FUNC void load(int r, SValue *sv) · 183 unmodified lines
184184 sv->c.i = 0;
185185 } else {
186186 if (((unsigned)fc + (1 << 11)) >> 12)
187− tcc_error("unimp: large addend for global address");
187+ tcc_error("unimp: large addend for global address (0x%llx)", sv->c.i);
188188 greloca(cur_text_section, sv->sym, ind,
189189 R_RISCV_GOT_HI20, 0);
190190 doload = 1;
@@ -233,7 +233,7 @@ ST_FUNC void load(int r, SValue *sv) · 42 unmodified lines
233233 sv->c.i = 0;
234234 } else {
235235 if (((unsigned)fc + (1 << 11)) >> 12)
236− tcc_error("unimp: large addend for global address");
236+ tcc_error("unimp: large addend for global address (0x%llx)", sv->c.i);
237237 greloca(cur_text_section, sv->sym, ind,
238238 R_RISCV_GOT_HI20, 0);
239239 doload = 1;
@@ -383,7 +383,7 @@ ST_FUNC void store(int r, SValue *sv) · 143 unmodified lines
383383 sv->c.i = 0;
384384 } else {
385385 if (((unsigned)fc + (1 << 11)) >> 12)
386− tcc_error("unimp: large addend for global address");
386+ tcc_error("unimp: large addend for global address (0x%llx)", sv->c.i);
387387 greloca(cur_text_section, sv->sym, ind,
388388 R_RISCV_GOT_HI20, 0);
389389 doload = 1;
@@ -569,6 +569,7 @@ ST_FUNC void gfunc_call(int nb_args) · 179 unmodified lines
569569 }
570570 }
571571 vrotb(nb_args + 1);
572+ save_regs(nb_args + 1);
572573 gcall_or_jmp(1);
573574 vtop -= nb_args + 1;
574575 if (stack_adj + tempspace)
@@ -1081,9 +1082,24 @@ ST_FUNC void gen_cvt_ftof(int dt) · 506 unmodified lines
10811082 int func = (dt == VT_LDOUBLE) ?
10821083 (st == VT_FLOAT ? TOK___extendsftf2 : TOK___extenddftf2) :
10831084 (dt == VT_FLOAT ? TOK___trunctfsf2 : TOK___trunctfdf2);
1085+ /* We can't use gfunc_call, as func_old_type works like vararg
1086+ functions, and on riscv unnamed float args are passed like
1087+ integers. But we really need them in the float argument registers
1088+ for extendsftf2/extenddftf2. So, do it explicitely. */
1089+ save_regs(1);
1090+ if (dt == VT_LDOUBLE)
1091+ gv(RC_F(0));
1092+ else {
1093+ gv(RC_R(0));
1094+ assert(vtop->r2 < 7);
1095+ if (vtop->r2 != 1 + vtop->r) {
1096+ EI(0x13, 0, ireg(vtop->r) + 1, ireg(vtop->r2), 0); // mv Ra+1, RR2
1097+ vtop->r2 = 1 + vtop->r;
1098+ }
1099+ }
10841100 vpush_global_sym(&func_old_type, func);
1085− vrott(2);
1086− gfunc_call(1);
1101+ gcall_or_jmp(1);
1102+ vtop -= 2;
10871103 vpushi(0);
10881104 vtop->type.t = dt;
10891105 if (dt == VT_LDOUBLE)