32bit signed constants larger than 0x7ffff800 were handled wrongly.
Unified · Split
| @@ -189,7 +189,7 @@ ST_FUNC void load(int r, SValue *sv) · 188 unmodified lines | |||
| 189 | tcc_error("unimp: load(non-local lval)"); | 189 | tcc_error("unimp: load(non-local lval)"); |
| 190 | } | 190 | } |
| 191 | } else if (v == VT_CONST) { | 191 | } else if (v == VT_CONST) { |
| 192 | int rb = 0; | 192 | int rb = 0, do32bit = 8; |
| 193 | assert(!is_float(sv->type.t) && is_ireg(r)); | 193 | assert(!is_float(sv->type.t) && is_ireg(r)); |
| 194 | if (fr & VT_SYM) { | 194 | if (fr & VT_SYM) { |
| 195 | static Sym label; | 195 | static Sym label; |
| @@ -207,6 +207,7 @@ ST_FUNC void load(int r, SValue *sv) · 11 unmodified lines | |||
| 207 | rb = rr; | 207 | rb = rr; |
| 208 | fc = 0; | 208 | fc = 0; |
| 209 | sv->c.i = 0; | 209 | sv->c.i = 0; |
| 210 | do32bit = 0; | ||
| 210 | } | 211 | } |
| 211 | if (is_float(sv->type.t)) | 212 | if (is_float(sv->type.t)) |
| 212 | tcc_error("unimp: load(float)"); | 213 | tcc_error("unimp: load(float)"); |
| @@ -224,10 +225,11 @@ ST_FUNC void load(int r, SValue *sv) · 11 unmodified lines | |||
| 224 | EI(0x13, 1, rr, rr, 8); // slli RR, RR, 8 | 225 | EI(0x13, 1, rr, rr, 8); // slli RR, RR, 8 |
| 225 | fc = (pi & 0x3ff) | (-((int)(pi & 0x200))); | 226 | fc = (pi & 0x3ff) | (-((int)(pi & 0x200))); |
| 226 | rb = rr; | 227 | rb = rr; |
| 228 | do32bit = 0; | ||
| 227 | } | 229 | } |
| 228 | if (((unsigned)fc + (1 << 11)) >> 12) | 230 | if (((unsigned)fc + (1 << 11)) >> 12) |
| 229 | o(0x37 | (rr << 7) | ((0x800 + fc) & 0xfffff000)), rb = rr; //lui RR, upper(fc) | 231 | o(0x37 | (rr << 7) | ((0x800 + fc) & 0xfffff000)), rb = rr; //lui RR, upper(fc) |
| 230 | EI(0x13, 0, rr, rb, fc << 20 >> 20); // addi R, x0|R, FC | 232 | EI(0x13 | do32bit, 0, rr, rb, fc << 20 >> 20); // addi[w] R, x0|R, FC |
| 231 | } else if (v == VT_LOCAL) { | 233 | } else if (v == VT_LOCAL) { |
| 232 | assert(is_ireg(r)); | 234 | assert(is_ireg(r)); |
| 233 | if (((unsigned)fc + (1 << 11)) >> 12) | 235 | if (((unsigned)fc + (1 << 11)) >> 12) |