diff options
| author | Mike Pall <mike> | 2015-04-12 01:25:14 +0200 |
|---|---|---|
| committer | Mike Pall <mike> | 2015-04-12 01:25:14 +0200 |
| commit | b2a5cc82338aad90ca16fced8631ac1a634949e9 (patch) | |
| tree | 2d1f358e6890228481c3c1200b76511b53b3b91c | |
| parent | dec4acca9a2e06b565415d7be44506baa0a0fee0 (diff) | |
| download | luajit-b2a5cc82338aad90ca16fced8631ac1a634949e9.tar.gz luajit-b2a5cc82338aad90ca16fced8631ac1a634949e9.tar.bz2 luajit-b2a5cc82338aad90ca16fced8631ac1a634949e9.zip | |
DynASM/PPC: Add support for parameterized shifts/masks.
| -rw-r--r-- | dynasm/dasm_ppc.h | 11 | ||||
| -rw-r--r-- | dynasm/dasm_ppc.lua | 9 |
2 files changed, 14 insertions, 6 deletions
diff --git a/dynasm/dasm_ppc.h b/dynasm/dasm_ppc.h index 2ded2580..332c64dc 100644 --- a/dynasm/dasm_ppc.h +++ b/dynasm/dasm_ppc.h | |||
| @@ -21,7 +21,7 @@ enum { | |||
| 21 | /* The following actions need a buffer position. */ | 21 | /* The following actions need a buffer position. */ |
| 22 | DASM_ALIGN, DASM_REL_LG, DASM_LABEL_LG, | 22 | DASM_ALIGN, DASM_REL_LG, DASM_LABEL_LG, |
| 23 | /* The following actions also have an argument. */ | 23 | /* The following actions also have an argument. */ |
| 24 | DASM_REL_PC, DASM_LABEL_PC, DASM_IMM, | 24 | DASM_REL_PC, DASM_LABEL_PC, DASM_IMM, DASM_IMMSH, |
| 25 | DASM__MAX | 25 | DASM__MAX |
| 26 | }; | 26 | }; |
| 27 | 27 | ||
| @@ -244,6 +244,10 @@ void dasm_put(Dst_DECL, int start, ...) | |||
| 244 | #endif | 244 | #endif |
| 245 | b[pos++] = n; | 245 | b[pos++] = n; |
| 246 | break; | 246 | break; |
| 247 | case DASM_IMMSH: | ||
| 248 | CK((n >> 6) == 0, RANGE_I); | ||
| 249 | b[pos++] = n; | ||
| 250 | break; | ||
| 247 | } | 251 | } |
| 248 | } | 252 | } |
| 249 | } | 253 | } |
| @@ -299,7 +303,7 @@ int dasm_link(Dst_DECL, size_t *szp) | |||
| 299 | case DASM_ALIGN: ofs -= (b[pos++] + ofs) & (ins & 255); break; | 303 | case DASM_ALIGN: ofs -= (b[pos++] + ofs) & (ins & 255); break; |
| 300 | case DASM_REL_LG: case DASM_REL_PC: pos++; break; | 304 | case DASM_REL_LG: case DASM_REL_PC: pos++; break; |
| 301 | case DASM_LABEL_LG: case DASM_LABEL_PC: b[pos++] += ofs; break; | 305 | case DASM_LABEL_LG: case DASM_LABEL_PC: b[pos++] += ofs; break; |
| 302 | case DASM_IMM: pos++; break; | 306 | case DASM_IMM: case DASM_IMMSH: pos++; break; |
| 303 | } | 307 | } |
| 304 | } | 308 | } |
| 305 | stop: (void)0; | 309 | stop: (void)0; |
| @@ -366,6 +370,9 @@ int dasm_encode(Dst_DECL, void *buffer) | |||
| 366 | case DASM_IMM: | 370 | case DASM_IMM: |
| 367 | cp[-1] |= (n & ((1<<((ins>>5)&31))-1)) << (ins&31); | 371 | cp[-1] |= (n & ((1<<((ins>>5)&31))-1)) << (ins&31); |
| 368 | break; | 372 | break; |
| 373 | case DASM_IMMSH: | ||
| 374 | cp[-1] |= (ins & 1) ? ((n&31)<<11)|((n&32)>>4) : ((n&31)<<6)|(n&32); | ||
| 375 | break; | ||
| 369 | default: *cp++ = ins; break; | 376 | default: *cp++ = ins; break; |
| 370 | } | 377 | } |
| 371 | } | 378 | } |
diff --git a/dynasm/dasm_ppc.lua b/dynasm/dasm_ppc.lua index 37447072..784223df 100644 --- a/dynasm/dasm_ppc.lua +++ b/dynasm/dasm_ppc.lua | |||
| @@ -41,7 +41,7 @@ local wline, werror, wfatal, wwarn | |||
| 41 | local action_names = { | 41 | local action_names = { |
| 42 | "STOP", "SECTION", "ESC", "REL_EXT", | 42 | "STOP", "SECTION", "ESC", "REL_EXT", |
| 43 | "ALIGN", "REL_LG", "LABEL_LG", | 43 | "ALIGN", "REL_LG", "LABEL_LG", |
| 44 | "REL_PC", "LABEL_PC", "IMM", | 44 | "REL_PC", "LABEL_PC", "IMM", "IMMSH" |
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | -- Maximum number of section buffer positions for dasm_put(). | 47 | -- Maximum number of section buffer positions for dasm_put(). |
| @@ -1482,8 +1482,8 @@ local function parse_shiftmask(imm, isshift) | |||
| 1482 | local n = tonumber(imm) | 1482 | local n = tonumber(imm) |
| 1483 | if n then | 1483 | if n then |
| 1484 | if shr(n, 6) == 0 then | 1484 | if shr(n, 6) == 0 then |
| 1485 | local lsb = band(imm, 31) | 1485 | local lsb = band(n, 31) |
| 1486 | local msb = imm - lsb | 1486 | local msb = n - lsb |
| 1487 | return isshift and (shl(lsb, 11)+shr(msb, 4)) or (shl(lsb, 6)+msb) | 1487 | return isshift and (shl(lsb, 11)+shr(msb, 4)) or (shl(lsb, 6)+msb) |
| 1488 | end | 1488 | end |
| 1489 | werror("out of range immediate `"..imm.."'") | 1489 | werror("out of range immediate `"..imm.."'") |
| @@ -1491,7 +1491,8 @@ local function parse_shiftmask(imm, isshift) | |||
| 1491 | match(imm, "^([%w_]+):(r[1-3]?[0-9])$") then | 1491 | match(imm, "^([%w_]+):(r[1-3]?[0-9])$") then |
| 1492 | werror("expected immediate operand, got register") | 1492 | werror("expected immediate operand, got register") |
| 1493 | else | 1493 | else |
| 1494 | werror("NYI: parameterized 64 bit shift/mask") | 1494 | waction("IMMSH", isshift and 1 or 0, imm) |
| 1495 | return 0; | ||
| 1495 | end | 1496 | end |
| 1496 | end | 1497 | end |
| 1497 | 1498 | ||
