aboutsummaryrefslogtreecommitdiff
path: root/dynasm
diff options
context:
space:
mode:
authorMike Pall <mike>2018-01-29 13:19:30 +0100
committerMike Pall <mike>2018-01-29 13:19:30 +0100
commit0bf46e1edf94c43795b5e491efe682ab70974ce7 (patch)
tree5e96ce2da5161ebd49fb564fe5aa73805b3391b7 /dynasm
parent74c544d68c07bcd416225598cdf15f88e62fd457 (diff)
parentd4ee80342770d1281e2ce877f8ae8ab1d99e6528 (diff)
downloadluajit-0bf46e1edf94c43795b5e491efe682ab70974ce7.tar.gz
luajit-0bf46e1edf94c43795b5e491efe682ab70974ce7.tar.bz2
luajit-0bf46e1edf94c43795b5e491efe682ab70974ce7.zip
Merge branch 'master' into v2.1
Diffstat (limited to 'dynasm')
-rw-r--r--dynasm/dasm_arm.h2
-rw-r--r--dynasm/dasm_mips.h1
-rw-r--r--dynasm/dasm_ppc.h1
-rw-r--r--dynasm/dasm_x86.h18
4 files changed, 18 insertions, 4 deletions
diff --git a/dynasm/dasm_arm.h b/dynasm/dasm_arm.h
index a43f7c66..1d404ccd 100644
--- a/dynasm/dasm_arm.h
+++ b/dynasm/dasm_arm.h
@@ -254,6 +254,7 @@ void dasm_put(Dst_DECL, int start, ...)
254 case DASM_IMMV8: 254 case DASM_IMMV8:
255 CK((n & 3) == 0, RANGE_I); 255 CK((n & 3) == 0, RANGE_I);
256 n >>= 2; 256 n >>= 2;
257 /* fallthrough */
257 case DASM_IMML8: 258 case DASM_IMML8:
258 case DASM_IMML12: 259 case DASM_IMML12:
259 CK(n >= 0 ? ((n>>((ins>>5)&31)) == 0) : 260 CK(n >= 0 ? ((n>>((ins>>5)&31)) == 0) :
@@ -371,6 +372,7 @@ int dasm_encode(Dst_DECL, void *buffer)
371 break; 372 break;
372 case DASM_REL_LG: 373 case DASM_REL_LG:
373 CK(n >= 0, UNDEF_LG); 374 CK(n >= 0, UNDEF_LG);
375 /* fallthrough */
374 case DASM_REL_PC: 376 case DASM_REL_PC:
375 CK(n >= 0, UNDEF_PC); 377 CK(n >= 0, UNDEF_PC);
376 n = *DASM_POS2PTR(D, n) - (int)((char *)cp - base) - 4; 378 n = *DASM_POS2PTR(D, n) - (int)((char *)cp - base) - 4;
diff --git a/dynasm/dasm_mips.h b/dynasm/dasm_mips.h
index 4b49fd8c..71a835b2 100644
--- a/dynasm/dasm_mips.h
+++ b/dynasm/dasm_mips.h
@@ -350,6 +350,7 @@ int dasm_encode(Dst_DECL, void *buffer)
350 break; 350 break;
351 case DASM_REL_LG: 351 case DASM_REL_LG:
352 CK(n >= 0, UNDEF_LG); 352 CK(n >= 0, UNDEF_LG);
353 /* fallthrough */
353 case DASM_REL_PC: 354 case DASM_REL_PC:
354 CK(n >= 0, UNDEF_PC); 355 CK(n >= 0, UNDEF_PC);
355 n = *DASM_POS2PTR(D, n); 356 n = *DASM_POS2PTR(D, n);
diff --git a/dynasm/dasm_ppc.h b/dynasm/dasm_ppc.h
index 3a7ee9b0..83fc030a 100644
--- a/dynasm/dasm_ppc.h
+++ b/dynasm/dasm_ppc.h
@@ -354,6 +354,7 @@ int dasm_encode(Dst_DECL, void *buffer)
354 break; 354 break;
355 case DASM_REL_LG: 355 case DASM_REL_LG:
356 CK(n >= 0, UNDEF_LG); 356 CK(n >= 0, UNDEF_LG);
357 /* fallthrough */
357 case DASM_REL_PC: 358 case DASM_REL_PC:
358 CK(n >= 0, UNDEF_PC); 359 CK(n >= 0, UNDEF_PC);
359 n = *DASM_POS2PTR(D, n) - (int)((char *)cp - base); 360 n = *DASM_POS2PTR(D, n) - (int)((char *)cp - base);
diff --git a/dynasm/dasm_x86.h b/dynasm/dasm_x86.h
index f598da9a..dc14d883 100644
--- a/dynasm/dasm_x86.h
+++ b/dynasm/dasm_x86.h
@@ -194,12 +194,13 @@ void dasm_put(Dst_DECL, int start, ...)
194 switch (action) { 194 switch (action) {
195 case DASM_DISP: 195 case DASM_DISP:
196 if (n == 0) { if (mrm < 0) mrm = p[-2]; if ((mrm&7) != 5) break; } 196 if (n == 0) { if (mrm < 0) mrm = p[-2]; if ((mrm&7) != 5) break; }
197 case DASM_IMM_DB: if (((n+128)&-256) == 0) goto ob; 197 /* fallthrough */
198 case DASM_IMM_DB: if (((n+128)&-256) == 0) goto ob; /* fallthrough */
198 case DASM_REL_A: /* Assumes ptrdiff_t is int. !x64 */ 199 case DASM_REL_A: /* Assumes ptrdiff_t is int. !x64 */
199 case DASM_IMM_D: ofs += 4; break; 200 case DASM_IMM_D: ofs += 4; break;
200 case DASM_IMM_S: CK(((n+128)&-256) == 0, RANGE_I); goto ob; 201 case DASM_IMM_S: CK(((n+128)&-256) == 0, RANGE_I); goto ob;
201 case DASM_IMM_B: CK((n&-256) == 0, RANGE_I); ob: ofs++; break; 202 case DASM_IMM_B: CK((n&-256) == 0, RANGE_I); ob: ofs++; break;
202 case DASM_IMM_WB: if (((n+128)&-256) == 0) goto ob; 203 case DASM_IMM_WB: if (((n+128)&-256) == 0) goto ob; /* fallthrough */
203 case DASM_IMM_W: CK((n&-65536) == 0, RANGE_I); ofs += 2; break; 204 case DASM_IMM_W: CK((n&-65536) == 0, RANGE_I); ofs += 2; break;
204 case DASM_SPACE: p++; ofs += n; break; 205 case DASM_SPACE: p++; ofs += n; break;
205 case DASM_SETLABEL: b[pos-2] = -0x40000000; break; /* Neg. label ofs. */ 206 case DASM_SETLABEL: b[pos-2] = -0x40000000; break; /* Neg. label ofs. */
@@ -207,8 +208,8 @@ void dasm_put(Dst_DECL, int start, ...)
207 if (*p < 0x40 && p[1] == DASM_DISP) mrm = n; 208 if (*p < 0x40 && p[1] == DASM_DISP) mrm = n;
208 if (*p < 0x20 && (n&7) == 4) ofs++; 209 if (*p < 0x20 && (n&7) == 4) ofs++;
209 switch ((*p++ >> 3) & 3) { 210 switch ((*p++ >> 3) & 3) {
210 case 3: n |= b[pos-3]; 211 case 3: n |= b[pos-3]; /* fallthrough */
211 case 2: n |= b[pos-2]; 212 case 2: n |= b[pos-2]; /* fallthrough */
212 case 1: if (n <= 7) { b[pos-1] |= 0x10; ofs--; } 213 case 1: if (n <= 7) { b[pos-1] |= 0x10; ofs--; }
213 } 214 }
214 continue; 215 continue;
@@ -329,11 +330,14 @@ int dasm_link(Dst_DECL, size_t *szp)
329 pos += 2; 330 pos += 2;
330 break; 331 break;
331 } 332 }
333 /* fallthrough */
332 case DASM_SPACE: case DASM_IMM_LG: case DASM_VREG: p++; 334 case DASM_SPACE: case DASM_IMM_LG: case DASM_VREG: p++;
335 /* fallthrough */
333 case DASM_DISP: case DASM_IMM_S: case DASM_IMM_B: case DASM_IMM_W: 336 case DASM_DISP: case DASM_IMM_S: case DASM_IMM_B: case DASM_IMM_W:
334 case DASM_IMM_D: case DASM_IMM_WB: case DASM_IMM_DB: 337 case DASM_IMM_D: case DASM_IMM_WB: case DASM_IMM_DB:
335 case DASM_SETLABEL: case DASM_REL_A: case DASM_IMM_PC: pos++; break; 338 case DASM_SETLABEL: case DASM_REL_A: case DASM_IMM_PC: pos++; break;
336 case DASM_LABEL_LG: p++; 339 case DASM_LABEL_LG: p++;
340 /* fallthrough */
337 case DASM_LABEL_PC: b[pos++] += ofs; break; /* Fix label offset. */ 341 case DASM_LABEL_PC: b[pos++] += ofs; break; /* Fix label offset. */
338 case DASM_ALIGN: ofs -= (b[pos++]+ofs)&*p++; break; /* Adjust ofs. */ 342 case DASM_ALIGN: ofs -= (b[pos++]+ofs)&*p++; break; /* Adjust ofs. */
339 case DASM_EXTERN: p += 2; break; 343 case DASM_EXTERN: p += 2; break;
@@ -391,12 +395,15 @@ int dasm_encode(Dst_DECL, void *buffer)
391 if (mrm != 5) { mm[-1] -= 0x80; break; } } 395 if (mrm != 5) { mm[-1] -= 0x80; break; } }
392 if (((n+128) & -256) != 0) goto wd; else mm[-1] -= 0x40; 396 if (((n+128) & -256) != 0) goto wd; else mm[-1] -= 0x40;
393 } 397 }
398 /* fallthrough */
394 case DASM_IMM_S: case DASM_IMM_B: wb: dasmb(n); break; 399 case DASM_IMM_S: case DASM_IMM_B: wb: dasmb(n); break;
395 case DASM_IMM_DB: if (((n+128)&-256) == 0) { 400 case DASM_IMM_DB: if (((n+128)&-256) == 0) {
396 db: if (!mark) mark = cp; mark[-2] += 2; mark = NULL; goto wb; 401 db: if (!mark) mark = cp; mark[-2] += 2; mark = NULL; goto wb;
397 } else mark = NULL; 402 } else mark = NULL;
403 /* fallthrough */
398 case DASM_IMM_D: wd: dasmd(n); break; 404 case DASM_IMM_D: wd: dasmd(n); break;
399 case DASM_IMM_WB: if (((n+128)&-256) == 0) goto db; else mark = NULL; 405 case DASM_IMM_WB: if (((n+128)&-256) == 0) goto db; else mark = NULL;
406 /* fallthrough */
400 case DASM_IMM_W: dasmw(n); break; 407 case DASM_IMM_W: dasmw(n); break;
401 case DASM_VREG: { 408 case DASM_VREG: {
402 int t = *p++; 409 int t = *p++;
@@ -421,6 +428,7 @@ int dasm_encode(Dst_DECL, void *buffer)
421 } 428 }
422 case DASM_REL_LG: p++; if (n >= 0) goto rel_pc; 429 case DASM_REL_LG: p++; if (n >= 0) goto rel_pc;
423 b++; n = (int)(ptrdiff_t)D->globals[-n]; 430 b++; n = (int)(ptrdiff_t)D->globals[-n];
431 /* fallthrough */
424 case DASM_REL_A: rel_a: 432 case DASM_REL_A: rel_a:
425 n -= (unsigned int)(ptrdiff_t)(cp+4); goto wd; /* !x64 */ 433 n -= (unsigned int)(ptrdiff_t)(cp+4); goto wd; /* !x64 */
426 case DASM_REL_PC: rel_pc: { 434 case DASM_REL_PC: rel_pc: {
@@ -433,6 +441,7 @@ int dasm_encode(Dst_DECL, void *buffer)
433 } 441 }
434 case DASM_IMM_LG: 442 case DASM_IMM_LG:
435 p++; if (n < 0) { n = (int)(ptrdiff_t)D->globals[-n]; goto wd; } 443 p++; if (n < 0) { n = (int)(ptrdiff_t)D->globals[-n]; goto wd; }
444 /* fallthrough */
436 case DASM_IMM_PC: { 445 case DASM_IMM_PC: {
437 int *pb = DASM_POS2PTR(D, n); 446 int *pb = DASM_POS2PTR(D, n);
438 n = *pb < 0 ? pb[1] : (*pb + (int)(ptrdiff_t)base); 447 n = *pb < 0 ? pb[1] : (*pb + (int)(ptrdiff_t)base);
@@ -453,6 +462,7 @@ int dasm_encode(Dst_DECL, void *buffer)
453 case DASM_EXTERN: n = DASM_EXTERN(Dst, cp, p[1], *p); p += 2; goto wd; 462 case DASM_EXTERN: n = DASM_EXTERN(Dst, cp, p[1], *p); p += 2; goto wd;
454 case DASM_MARK: mark = cp; break; 463 case DASM_MARK: mark = cp; break;
455 case DASM_ESC: action = *p++; 464 case DASM_ESC: action = *p++;
465 /* fallthrough */
456 default: *cp++ = action; break; 466 default: *cp++ = action; break;
457 case DASM_SECTION: case DASM_STOP: goto stop; 467 case DASM_SECTION: case DASM_STOP: goto stop;
458 } 468 }