mirror of
https://github.com/MacosPorters/betterxen.git
synced 2026-11-26 22:50:44 +00:00
Compare commits
13
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
919f673cdf | ||
|
|
1c6bd25723 | ||
|
|
3b47c21bb0 | ||
|
|
9a62d86a89 | ||
|
|
4b32c532fe | ||
|
|
d2f77cdea3 | ||
|
|
a7fa8b0d65 | ||
|
|
2f28a5adbb | ||
|
|
788de1e83b | ||
|
|
1013746e17 | ||
|
|
9ddb708cdf | ||
|
|
6f1ac2a906 | ||
|
|
c95e175210 |
No files matched your search
@@ -10,6 +10,7 @@ Guest execution uses original, purpose-built test programs. Commercial Xbox game
|
||||
remains unsupported.
|
||||
|
||||
### Changed
|
||||
- The native ARM64 DBT now runs the 32- and 64-bit register and immediate forms of ADC and SBB itself instead of falling back to the shared interpreter (#195). The guest CF is moved into the host carry before ADCS or SBCS, inverted for SBB because SBCS subtracts NOT C while SBB subtracts CF. Memory forms and 8- and 16-bit forms still use the shared semantics. `tests/x86_carry_chain.rs` runs 256-bit add and subtract chains of 64- and 32-bit limbs, in one block and split one block per limb, against widening `u128`/`i128` reference arithmetic in both engines, plus immediate 128-bit increments and decrements and the `sbb reg, reg` carry mask. Locally verified on Apple M5 only.
|
||||
- Removed the temporary region-list allocation from each instruction-byte fetch while preserving lookup order, execute-permission checks and error behavior (part of #104).
|
||||
- Release and bench builds now use fat link-time optimization with one codegen unit (#116). On a local Apple M5, `dbt_bench` medians over five alternating runs dropped by about 6 % for the interpreter (903 to 845 µs) and about 9 % for cold DBT (1.155 to 1.046 ms), while warm DBT (cache hits) became about 2 % slower (21.83-22.08 to 22.29-22.54 µs over four further runs). The `xenora` binary shrank from 2.73 to 2.11 MB. A clean release build of the workspace takes about 14 s instead of 6 s. Debug and test builds are unchanged.
|
||||
- The ARM64 assembler loads 64-bit constants with the fewest MOVZ or MOVN plus MOVK instructions (#92). It no longer emits MOVK for zero halfwords and starts from MOVN when more halfwords are 0xFFFF than zero, so small negative values take one instruction instead of four. On Apple M5 the DBT benchmark emits 245,168 instead of 290,184 native bytes for its 626 blocks (-15.5%) and the 1,048 integer fixture instructions 128,724 instead of 145,732 (-11.7%); benchmark run times did not change measurably. New tests check the sequences against LLVM encodings and execute 1,056 of them on the host through the JIT.
|
||||
@@ -20,12 +21,15 @@ remains unsupported.
|
||||
- Moved gfx1030 `s_mov_b32` (SOP1) into the semantic registry, preserving its existing decode domain and shader output. The move operand rule retains explicit VCC and EXEC half destinations. Part of #215.
|
||||
- Moved the six hand-written gfx1030 VOP2 logical and shift forms (`v_and_b32`, `v_or_b32`, `v_xor_b32`, `v_lshlrev_b32`, `v_lshrrev_b32`, `v_ashrrev_i32`, AMD guide section 12.7) into the semantic registry under a new VGPR-only operand rule `vop2_vgpr2`, with no behaviour change: a sweep of 132,608 VOP2, VOP1 and SOP1 words decodes to the same text, length and error before and after, the MSL goldens are unchanged, and the runtime-region allowlist admits exactly the same six forms. The per-lane `VectorBinary` gained `And`, `Or`, `Xor` and the three shifts (count masked to S0[4:0]); 6 hand-written instruction variants and their decoder and lowering arms are gone (17 hand-written forms remain). Part of #215.
|
||||
- Added non-blocking Metal compute submission through `submit_words` and `wait`, with completion-aware resource retirement and a sixteen-dispatch in-flight limit. Synchronous calls keep their existing behavior. The benchmark reports the host submission split and compares synchronous and pipelined batches.
|
||||
- Reuse up to 16 native Metal compute pipelines per context for repeated shader source and entry points. Pending dispatches retain their pipelines through completion, including after eviction. Dispatch profiles report zero library and pipeline setup time when a cached pipeline is reused. Closes #132.
|
||||
- Extended the read-only RDNA2 planning CLI (`python3 -m qa rdna2`) with family/status filters, compact summaries, Codex-ready manifests under `artifacts/`, active-claim exclusion (family claims exclude those families; path-only claims block overlapping permitted files), coverage reconcile against `semantic_coverage` without inflating counts, and inventory diffs. Covered by `tests/qa/test_rdna2_plan.py`; planning only, no GPU production edits.
|
||||
|
||||
### Fixed
|
||||
- Made the native semantic-review timeout in `scripts/test-gpu.sh` configurable with `XENORA_SEMANTIC_TIMEOUT` and raised its default from 120 to 300 seconds, so cold Apple Silicon runs do not fail while the expanded Metal known-answer suite is still progressing.
|
||||
- Added a Python 3 fallback for `timeout` in `scripts/test-gpu.sh`, so the native Metal suite runs on stock macOS without GNU coreutils while preserving bounded execution and the usual timeout exit status.
|
||||
|
||||
### Added
|
||||
- LAHF and SAHF run in both engines, and guest CPUID reports them in leaf `8000_0001h`, ECX bit 0 (#387; Intel SDM Vol. 2A LAHF, Vol. 2B SAHF). The DBT runs them through the shared semantics. The four known answers from #155 that both engines refused are now verified, with twelve more cases, and the independent reference in `tests/x86_integer.rs` covers both instructions.
|
||||
- `dbt_bench` can also write its results as one JSON document when `XENORA_DBT_BENCH_JSON=<path>` is set (#112). The document records the host CPU, OS and architecture, the git revision and whether the tree had local changes, debug assertions, the workload and sample counts, the median, minimum, maximum, p95, p99, IQR and MIPS for the interpreter and for cold and warm DBT, and the cold DBT counters. Anything the benchmark cannot determine is `null`. The text output and the timed work are unchanged.
|
||||
- Added synthetic guest handle-lifetime regression tests (#205) for capacity reuse, stale handles, duplicate rights and lifetime, wrong object types, thread pseudo handles and failed-output nonmutation. Runtime behavior is unchanged; independent acceptance is pending.
|
||||
- Added a documented independent acceptance rule for promoting AMD RDNA2 desktop GPU (gfx1030) forms from local CPU and Metal results to `fixture verified`, including clean-commit evidence, reviewer independence, raw-log location, review-log summary, failure handling and status regeneration (#302).
|
||||
|
||||
@@ -309,7 +309,7 @@ These require a Metal-capable Apple Silicon Mac.
|
||||
scripts/test-gpu.sh
|
||||
```
|
||||
|
||||
The native test suite enables Metal API and shader validation and tests the supported compute, rendering and texture paths. The full semantic-review batch defaults to a 300-second timeout; set `XENORA_SEMANTIC_TIMEOUT` to raise or lower it for a slower or faster host.
|
||||
The native test suite enables Metal API and shader validation and tests the supported compute, rendering and texture paths. The full semantic-review batch defaults to a 300-second timeout; set `XENORA_SEMANTIC_TIMEOUT` to raise or lower it for a slower or faster host. On macOS, the script uses a Python 3 fallback when GNU `timeout` is unavailable.
|
||||
|
||||
### Verify guest execution
|
||||
|
||||
|
||||
@@ -430,6 +430,46 @@ impl Arm64Assembler {
|
||||
);
|
||||
}
|
||||
|
||||
/// ADCS (64-bit, flags updating): ADCS Xd, Xn, Xm computes Xn + Xm + C.
|
||||
pub fn adcs_reg_64(&mut self, xd: u8, xn: u8, xm: u8) {
|
||||
self.emit(
|
||||
0xba000000
|
||||
| ((xm as u32 & 0x1f) << 16)
|
||||
| ((xn as u32 & 0x1f) << 5)
|
||||
| (xd as u32 & 0x1f),
|
||||
);
|
||||
}
|
||||
|
||||
/// ADCS (32-bit, flags updating): ADCS Wd, Wn, Wm computes Wn + Wm + C.
|
||||
pub fn adcs_reg_32(&mut self, wd: u8, wn: u8, wm: u8) {
|
||||
self.emit(
|
||||
0x3a000000
|
||||
| ((wm as u32 & 0x1f) << 16)
|
||||
| ((wn as u32 & 0x1f) << 5)
|
||||
| (wd as u32 & 0x1f),
|
||||
);
|
||||
}
|
||||
|
||||
/// SBCS (64-bit, flags updating): SBCS Xd, Xn, Xm computes Xn - Xm - !C.
|
||||
pub fn sbcs_reg_64(&mut self, xd: u8, xn: u8, xm: u8) {
|
||||
self.emit(
|
||||
0xfa000000
|
||||
| ((xm as u32 & 0x1f) << 16)
|
||||
| ((xn as u32 & 0x1f) << 5)
|
||||
| (xd as u32 & 0x1f),
|
||||
);
|
||||
}
|
||||
|
||||
/// SBCS (32-bit, flags updating): SBCS Wd, Wn, Wm computes Wn - Wm - !C.
|
||||
pub fn sbcs_reg_32(&mut self, wd: u8, wn: u8, wm: u8) {
|
||||
self.emit(
|
||||
0x7a000000
|
||||
| ((wm as u32 & 0x1f) << 16)
|
||||
| ((wn as u32 & 0x1f) << 5)
|
||||
| (wd as u32 & 0x1f),
|
||||
);
|
||||
}
|
||||
|
||||
/// ADD (immediate, 64-bit): ADD Xd, Xn, #imm12
|
||||
pub fn add_imm_64(&mut self, xd: u8, xn: u8, imm12: u16) {
|
||||
self.emit(
|
||||
|
||||
@@ -130,6 +130,8 @@ impl CpuState {
|
||||
pub const CPUID_CMOV: u32 = 1 << 15;
|
||||
/// CPUID leaf 1, ECX: POPCNT.
|
||||
pub const CPUID_POPCNT: u32 = 1 << 23;
|
||||
/// CPUID leaf 0x8000_0001, ECX: LAHF and SAHF in 64-bit mode.
|
||||
pub const CPUID_LAHF_SAHF: u32 = 1;
|
||||
/// CPUID leaf 0x8000_0001, ECX: LZCNT.
|
||||
pub const CPUID_LZCNT: u32 = 1 << 5;
|
||||
/// CPUID leaf 0x8000_0001, EDX: 64-bit mode.
|
||||
@@ -150,7 +152,7 @@ pub fn cpuid(leaf: u32, _subleaf: u32) -> [u32; 4] {
|
||||
1 => [0, 0, CPUID_POPCNT, CPUID_CMOV],
|
||||
// Highest extended leaf.
|
||||
0x8000_0000 => [0x8000_0001, 0, 0, 0],
|
||||
0x8000_0001 => [0, 0, CPUID_LZCNT, CPUID_LONG_MODE],
|
||||
0x8000_0001 => [0, 0, CPUID_LAHF_SAHF | CPUID_LZCNT, CPUID_LONG_MODE],
|
||||
_ => [0; 4],
|
||||
}
|
||||
}
|
||||
|
||||
@@ -335,6 +335,9 @@ pub fn is_native(insn: &Insn) -> bool {
|
||||
let scanned = matches!(insn.size, 2 | 4 | 8);
|
||||
match insn.op {
|
||||
Op::Add | Op::Sub | Op::Cmp | Op::And | Op::Or | Op::Xor | Op::Test => wide,
|
||||
// Register and immediate forms only; a memory destination would have
|
||||
// to restore the guest carry again after the store helper call.
|
||||
Op::Adc | Op::Sbb => wide && insn.memory().is_none(),
|
||||
Op::Inc | Op::Dec | Op::Neg | Op::Not => wide,
|
||||
Op::Cmov => wide,
|
||||
Op::Bsf | Op::Bsr => scanned,
|
||||
@@ -587,9 +590,26 @@ impl Emitter<'_> {
|
||||
}
|
||||
|
||||
/// X11 = X9 op X10, setting host NZCV only for the arithmetic operations.
|
||||
/// ADC and SBB also read the guest CF and clobber X12 and X13.
|
||||
fn compute(&mut self, op: Op, wide: bool) {
|
||||
let asm = &mut *self.asm;
|
||||
if matches!(op, Op::Adc | Op::Sbb) {
|
||||
// ADCS adds the host C, so C must equal the guest CF. SBCS
|
||||
// subtracts NOT C, while x86 SBB subtracts the borrow CF, so there
|
||||
// C must be its inverse. A compare sets C when it does not borrow.
|
||||
asm.ldrb_uoff(X12, X19, CF);
|
||||
if op == Op::Adc {
|
||||
asm.load_imm_64(X13, 1);
|
||||
asm.cmp_reg_32(X12, X13); // C = CF >= 1
|
||||
} else {
|
||||
asm.cmp_reg_32(XZR, X12); // C = 0 >= CF
|
||||
}
|
||||
}
|
||||
match (op, wide) {
|
||||
(Op::Adc, true) => asm.adcs_reg_64(X11, X9, X10),
|
||||
(Op::Adc, false) => asm.adcs_reg_32(X11, X9, X10),
|
||||
(Op::Sbb, true) => asm.sbcs_reg_64(X11, X9, X10),
|
||||
(Op::Sbb, false) => asm.sbcs_reg_32(X11, X9, X10),
|
||||
(Op::Add | Op::Inc, true) => asm.adds_reg_64(X11, X9, X10),
|
||||
(Op::Add | Op::Inc, false) => asm.adds_reg_32(X11, X9, X10),
|
||||
(Op::And | Op::Test, true) => asm.ands_reg_64(X11, X9, X10),
|
||||
@@ -623,7 +643,7 @@ impl Emitter<'_> {
|
||||
match op {
|
||||
// INC and DEC leave CF unchanged.
|
||||
Op::Inc | Op::Dec => {}
|
||||
Op::Add => {
|
||||
Op::Add | Op::Adc => {
|
||||
asm.cset_32(X12, Condition::Cs);
|
||||
asm.strb_uoff(X12, X19, CF);
|
||||
}
|
||||
|
||||
@@ -651,6 +651,28 @@ pub fn execute(
|
||||
Op::Clc => cpu.flags.cf = false,
|
||||
Op::Stc => cpu.flags.cf = true,
|
||||
Op::Cmc => cpu.flags.cf = !cpu.flags.cf,
|
||||
// AH = SF:ZF:0:AF:0:PF:1:CF (Intel SDM Vol. 2A, LAHF).
|
||||
Op::Lahf => {
|
||||
let f = cpu.flags;
|
||||
let ah = u64::from(f.sf) << 7
|
||||
| u64::from(f.zf) << 6
|
||||
| u64::from(f.af) << 4
|
||||
| u64::from(f.pf) << 2
|
||||
| 1 << 1
|
||||
| u64::from(f.cf);
|
||||
cpu.gpr[RAX] = cpu.gpr[RAX] & !0xFF00 | ah << 8;
|
||||
}
|
||||
// SF, ZF, AF, PF and CF from AH bits 7, 6, 4, 2 and 0; OF is
|
||||
// unchanged (Intel SDM Vol. 2B, SAHF).
|
||||
Op::Sahf => {
|
||||
let ah = (cpu.gpr[RAX] >> 8) as u8;
|
||||
let flags = &mut cpu.flags;
|
||||
flags.sf = ah & 0x80 != 0;
|
||||
flags.zf = ah & 0x40 != 0;
|
||||
flags.af = ah & 0x10 != 0;
|
||||
flags.pf = ah & 0x04 != 0;
|
||||
flags.cf = ah & 0x01 != 0;
|
||||
}
|
||||
Op::Hlt => {
|
||||
cpu.rip = next;
|
||||
return Ok(Some(ExitReason::Halt));
|
||||
|
||||
+238
-218
@@ -68,6 +68,8 @@ pub enum Op {
|
||||
Clc,
|
||||
Stc,
|
||||
Cmc,
|
||||
Lahf,
|
||||
Sahf,
|
||||
Cpuid,
|
||||
Cld,
|
||||
Std,
|
||||
@@ -215,7 +217,7 @@ pub enum Op {
|
||||
}
|
||||
|
||||
impl Op {
|
||||
pub const ALL: &[Op] = &[Op::Add, Op::Or, Op::Adc, Op::Sbb, Op::And, Op::Sub, Op::Xor, Op::Cmp, Op::Test, Op::Inc, Op::Dec, Op::Neg, Op::Not, Op::Mov, Op::Movzx, Op::Movsx, Op::Movsxd, Op::Lea, Op::Xchg, Op::Xadd, Op::Cmpxchg, Op::Bswap, Op::Cwde, Op::Cdq, Op::Rol, Op::Ror, Op::Rcl, Op::Rcr, Op::Shl, Op::Shr, Op::Sar, Op::Mul, Op::Imul, Op::Imul2, Op::Div, Op::Idiv, Op::Cmov, Op::Setcc, Op::Bt, Op::Bts, Op::Btr, Op::Btc, Op::Bsf, Op::Bsr, Op::Popcnt, Op::Tzcnt, Op::Lzcnt, Op::Push, Op::Pop, Op::Leave, Op::Call, Op::Jmp, Op::Jcc, Op::Ret, Op::Nop, Op::Hlt, Op::Syscall, Op::Clc, Op::Stc, Op::Cmc, Op::Cpuid, Op::Cld, Op::Std, Op::Movs, Op::Stos, Op::Movaps, Op::Movups, Op::Movdqa, Op::Movdqu, Op::Movntdq, Op::Movnti, Op::Movntps, Op::Movss, Op::Movsd, Op::Movq, Op::Movd, Op::Movlps, Op::Movhps, Op::Movmskps, Op::Movmskpd, Op::Pmovmskb, Op::Pand, Op::Pandn, Op::Por, Op::Pxor, Op::Punpcklbw, Op::Punpcklwd, Op::Punpckldq, Op::Packsswb, Op::Pcmpgtb, Op::Pcmpgtw, Op::Pcmpgtd, Op::Packuswb, Op::Punpckhbw, Op::Punpckhwd, Op::Punpckhdq, Op::Packssdw, Op::Punpcklqdq, Op::Punpckhqdq, Op::Pcmpeqb, Op::Pcmpeqw, Op::Pcmpeqd, Op::Paddq, Op::Pmullw, Op::Psubusb, Op::Psubusw, Op::Pminub, Op::Paddusb, Op::Paddusw, Op::Pmaxub, Op::Pavgb, Op::Pavgw, Op::Pmulhuw, Op::Pmulhw, Op::Psubsb, Op::Psubsw, Op::Pminsw, Op::Paddsb, Op::Paddsw, Op::Pmaxsw, Op::Pmuludq, Op::Pmaddwd, Op::Psadbw, Op::Psubb, Op::Psubw, Op::Psubd, Op::Psubq, Op::Paddb, Op::Paddw, Op::Paddd, Op::Psrlw, Op::Psraw, Op::Psllw, Op::Psrld, Op::Psrad, Op::Pslld, Op::Psrlq, Op::Psllq, Op::Psrldq, Op::Pslldq, Op::Pshufd, Op::Pshufhw, Op::Pshuflw, Op::Shufps, Op::Shufpd, Op::Pinsrw, Op::Pextrw, Op::Ldmxcsr, Op::Lfence, Op::Mfence, Op::Sfence, Op::Stmxcsr, Op::Sqrtps, Op::Sqrtpd, Op::Sqrtss, Op::Sqrtsd, Op::Addps, Op::Addpd, Op::Addss, Op::Addsd, Op::Mulps, Op::Mulpd, Op::Mulss, Op::Mulsd, Op::Subps, Op::Subpd, Op::Subss, Op::Subsd, Op::Minps, Op::Minpd, Op::Minss, Op::Minsd, Op::Divps, Op::Divpd, Op::Divss, Op::Divsd, Op::Maxps, Op::Maxpd, Op::Maxss, Op::Maxsd, Op::Cmpps, Op::Cmppd, Op::Cmpss, Op::Cmpsd, Op::Ucomiss, Op::Comiss, Op::Ucomisd, Op::Comisd, Op::Cvtps2pd, Op::Cvtpd2ps, Op::Cvtss2sd, Op::Cvtsd2ss, Op::Cvtdq2ps, Op::Cvtps2dq, Op::Cvttps2dq, Op::Cvttpd2dq, Op::Cvtdq2pd, Op::Cvtpd2dq, Op::Cvtsi2ss, Op::Cvttss2si, Op::Cvtss2si, Op::Cvtsi2sd, Op::Cvttsd2si, Op::Cvtsd2si];
|
||||
pub const ALL: &[Op] = &[Op::Add, Op::Or, Op::Adc, Op::Sbb, Op::And, Op::Sub, Op::Xor, Op::Cmp, Op::Test, Op::Inc, Op::Dec, Op::Neg, Op::Not, Op::Mov, Op::Movzx, Op::Movsx, Op::Movsxd, Op::Lea, Op::Xchg, Op::Xadd, Op::Cmpxchg, Op::Bswap, Op::Cwde, Op::Cdq, Op::Rol, Op::Ror, Op::Rcl, Op::Rcr, Op::Shl, Op::Shr, Op::Sar, Op::Mul, Op::Imul, Op::Imul2, Op::Div, Op::Idiv, Op::Cmov, Op::Setcc, Op::Bt, Op::Bts, Op::Btr, Op::Btc, Op::Bsf, Op::Bsr, Op::Popcnt, Op::Tzcnt, Op::Lzcnt, Op::Push, Op::Pop, Op::Leave, Op::Call, Op::Jmp, Op::Jcc, Op::Ret, Op::Nop, Op::Hlt, Op::Syscall, Op::Clc, Op::Stc, Op::Cmc, Op::Lahf, Op::Sahf, Op::Cpuid, Op::Cld, Op::Std, Op::Movs, Op::Stos, Op::Movaps, Op::Movups, Op::Movdqa, Op::Movdqu, Op::Movntdq, Op::Movnti, Op::Movntps, Op::Movss, Op::Movsd, Op::Movq, Op::Movd, Op::Movlps, Op::Movhps, Op::Movmskps, Op::Movmskpd, Op::Pmovmskb, Op::Pand, Op::Pandn, Op::Por, Op::Pxor, Op::Punpcklbw, Op::Punpcklwd, Op::Punpckldq, Op::Packsswb, Op::Pcmpgtb, Op::Pcmpgtw, Op::Pcmpgtd, Op::Packuswb, Op::Punpckhbw, Op::Punpckhwd, Op::Punpckhdq, Op::Packssdw, Op::Punpcklqdq, Op::Punpckhqdq, Op::Pcmpeqb, Op::Pcmpeqw, Op::Pcmpeqd, Op::Paddq, Op::Pmullw, Op::Psubusb, Op::Psubusw, Op::Pminub, Op::Paddusb, Op::Paddusw, Op::Pmaxub, Op::Pavgb, Op::Pavgw, Op::Pmulhuw, Op::Pmulhw, Op::Psubsb, Op::Psubsw, Op::Pminsw, Op::Paddsb, Op::Paddsw, Op::Pmaxsw, Op::Pmuludq, Op::Pmaddwd, Op::Psadbw, Op::Psubb, Op::Psubw, Op::Psubd, Op::Psubq, Op::Paddb, Op::Paddw, Op::Paddd, Op::Psrlw, Op::Psraw, Op::Psllw, Op::Psrld, Op::Psrad, Op::Pslld, Op::Psrlq, Op::Psllq, Op::Psrldq, Op::Pslldq, Op::Pshufd, Op::Pshufhw, Op::Pshuflw, Op::Shufps, Op::Shufpd, Op::Pinsrw, Op::Pextrw, Op::Ldmxcsr, Op::Lfence, Op::Mfence, Op::Sfence, Op::Stmxcsr, Op::Sqrtps, Op::Sqrtpd, Op::Sqrtss, Op::Sqrtsd, Op::Addps, Op::Addpd, Op::Addss, Op::Addsd, Op::Mulps, Op::Mulpd, Op::Mulss, Op::Mulsd, Op::Subps, Op::Subpd, Op::Subss, Op::Subsd, Op::Minps, Op::Minpd, Op::Minss, Op::Minsd, Op::Divps, Op::Divpd, Op::Divss, Op::Divsd, Op::Maxps, Op::Maxpd, Op::Maxss, Op::Maxsd, Op::Cmpps, Op::Cmppd, Op::Cmpss, Op::Cmpsd, Op::Ucomiss, Op::Comiss, Op::Ucomisd, Op::Comisd, Op::Cvtps2pd, Op::Cvtpd2ps, Op::Cvtss2sd, Op::Cvtsd2ss, Op::Cvtdq2ps, Op::Cvtps2dq, Op::Cvttps2dq, Op::Cvttpd2dq, Op::Cvtdq2pd, Op::Cvtpd2dq, Op::Cvtsi2ss, Op::Cvttss2si, Op::Cvtss2si, Op::Cvtsi2sd, Op::Cvttsd2si, Op::Cvtsd2si];
|
||||
|
||||
/// Lower-case mnemonic stem.
|
||||
pub const fn name(self) -> &'static str {
|
||||
@@ -280,6 +282,8 @@ impl Op {
|
||||
Op::Clc => "clc",
|
||||
Op::Stc => "stc",
|
||||
Op::Cmc => "cmc",
|
||||
Op::Lahf => "lahf",
|
||||
Op::Sahf => "sahf",
|
||||
Op::Cpuid => "cpuid",
|
||||
Op::Cld => "cld",
|
||||
Op::Std => "std",
|
||||
@@ -490,6 +494,8 @@ impl Op {
|
||||
Op::Clc => 0,
|
||||
Op::Stc => 0,
|
||||
Op::Cmc => 1,
|
||||
Op::Lahf => 55,
|
||||
Op::Sahf => 0,
|
||||
Op::Cpuid => 0,
|
||||
Op::Cld => 0,
|
||||
Op::Std => 0,
|
||||
@@ -700,6 +706,8 @@ impl Op {
|
||||
Op::Clc => 1,
|
||||
Op::Stc => 1,
|
||||
Op::Cmc => 1,
|
||||
Op::Lahf => 0,
|
||||
Op::Sahf => 55,
|
||||
Op::Cpuid => 0,
|
||||
Op::Cld => 0,
|
||||
Op::Std => 0,
|
||||
@@ -910,6 +918,8 @@ impl Op {
|
||||
Op::Clc => 1,
|
||||
Op::Stc => 1,
|
||||
Op::Cmc => 1,
|
||||
Op::Lahf => 0,
|
||||
Op::Sahf => 55,
|
||||
Op::Cpuid => 0,
|
||||
Op::Cld => 0,
|
||||
Op::Std => 0,
|
||||
@@ -1120,6 +1130,8 @@ impl Op {
|
||||
Op::Clc => 0,
|
||||
Op::Stc => 0,
|
||||
Op::Cmc => 0,
|
||||
Op::Lahf => 0,
|
||||
Op::Sahf => 0,
|
||||
Op::Cpuid => 0,
|
||||
Op::Cld => 0,
|
||||
Op::Std => 0,
|
||||
@@ -1330,6 +1342,8 @@ impl Op {
|
||||
Op::Clc => false,
|
||||
Op::Stc => false,
|
||||
Op::Cmc => false,
|
||||
Op::Lahf => false,
|
||||
Op::Sahf => false,
|
||||
Op::Cpuid => false,
|
||||
Op::Cld => false,
|
||||
Op::Std => false,
|
||||
@@ -1540,6 +1554,8 @@ impl Op {
|
||||
Op::Clc => false,
|
||||
Op::Stc => false,
|
||||
Op::Cmc => false,
|
||||
Op::Lahf => false,
|
||||
Op::Sahf => false,
|
||||
Op::Cpuid => false,
|
||||
Op::Cld => false,
|
||||
Op::Std => false,
|
||||
@@ -1750,6 +1766,8 @@ impl Op {
|
||||
Op::Clc => false,
|
||||
Op::Stc => false,
|
||||
Op::Cmc => false,
|
||||
Op::Lahf => false,
|
||||
Op::Sahf => false,
|
||||
Op::Cpuid => false,
|
||||
Op::Cld => false,
|
||||
Op::Std => false,
|
||||
@@ -1898,7 +1916,7 @@ impl Op {
|
||||
}
|
||||
}
|
||||
|
||||
pub static FORMS: [Form; 392] = [
|
||||
pub static FORMS: [Form; 394] = [
|
||||
Form { op: Op::Movsxd, encoding: Encoding::RegRm, size: OperandSize::Wide, immediate: Immediate::None, source: 4, has_modrm: true, memory_only: false, register_only: false, no_rex_b: false, unaligned: false, lockable: false },
|
||||
Form { op: Op::Push, encoding: Encoding::OpReg, size: OperandSize::Quad, immediate: Immediate::None, source: 0, has_modrm: false, memory_only: false, register_only: false, no_rex_b: false, unaligned: false, lockable: false },
|
||||
Form { op: Op::Pop, encoding: Encoding::OpReg, size: OperandSize::Quad, immediate: Immediate::None, source: 0, has_modrm: false, memory_only: false, register_only: false, no_rex_b: false, unaligned: false, lockable: false },
|
||||
@@ -1937,6 +1955,8 @@ pub static FORMS: [Form; 392] = [
|
||||
Form { op: Op::Nop, encoding: Encoding::RmUnread, size: OperandSize::Variable, immediate: Immediate::None, source: 0, has_modrm: true, memory_only: false, register_only: false, no_rex_b: false, unaligned: false, lockable: false },
|
||||
Form { op: Op::Cwde, encoding: Encoding::None, size: OperandSize::Variable, immediate: Immediate::None, source: 0, has_modrm: false, memory_only: false, register_only: false, no_rex_b: false, unaligned: false, lockable: false },
|
||||
Form { op: Op::Cdq, encoding: Encoding::None, size: OperandSize::Variable, immediate: Immediate::None, source: 0, has_modrm: false, memory_only: false, register_only: false, no_rex_b: false, unaligned: false, lockable: false },
|
||||
Form { op: Op::Sahf, encoding: Encoding::None, size: OperandSize::None, immediate: Immediate::None, source: 0, has_modrm: false, memory_only: false, register_only: false, no_rex_b: false, unaligned: false, lockable: false },
|
||||
Form { op: Op::Lahf, encoding: Encoding::None, size: OperandSize::None, immediate: Immediate::None, source: 0, has_modrm: false, memory_only: false, register_only: false, no_rex_b: false, unaligned: false, lockable: false },
|
||||
Form { op: Op::Mov, encoding: Encoding::OpRegImm, size: OperandSize::Byte, immediate: Immediate::SignedByte, source: 0, has_modrm: false, memory_only: false, register_only: false, no_rex_b: false, unaligned: false, lockable: false },
|
||||
Form { op: Op::Mov, encoding: Encoding::OpRegImm, size: OperandSize::Variable, immediate: Immediate::Full, source: 0, has_modrm: false, memory_only: false, register_only: false, no_rex_b: false, unaligned: false, lockable: false },
|
||||
Form { op: Op::Mov, encoding: Encoding::RmImm, size: OperandSize::Byte, immediate: Immediate::SignedByte, source: 0, has_modrm: true, memory_only: false, register_only: false, no_rex_b: false, unaligned: false, lockable: false },
|
||||
@@ -2295,47 +2315,47 @@ pub static FORMS: [Form; 392] = [
|
||||
|
||||
/// Form per ModRM digit; 65535 marks an unsupported digit.
|
||||
pub static GROUPS: [[u16; 8]; 22] = [
|
||||
[264, 273, 282, 291, 300, 309, 318, 327],
|
||||
[265, 274, 283, 292, 301, 310, 319, 328],
|
||||
[266, 275, 284, 293, 302, 311, 320, 329],
|
||||
[267, 276, 285, 294, 303, 312, 321, 330],
|
||||
[268, 277, 286, 295, 304, 313, 322, 331],
|
||||
[6, 65535, 65535, 65535, 65535, 65535, 65535, 65535],
|
||||
[350, 351, 352, 353, 354, 355, 65535, 356],
|
||||
[357, 358, 359, 360, 361, 362, 65535, 363],
|
||||
[40, 65535, 65535, 65535, 65535, 65535, 65535, 65535],
|
||||
[41, 65535, 65535, 65535, 65535, 65535, 65535, 65535],
|
||||
[364, 365, 366, 367, 368, 369, 65535, 370],
|
||||
[371, 372, 373, 374, 375, 376, 65535, 377],
|
||||
[378, 379, 380, 381, 382, 383, 65535, 384],
|
||||
[385, 386, 387, 388, 389, 390, 65535, 391],
|
||||
[18, 65535, 334, 335, 336, 337, 338, 339],
|
||||
[19, 65535, 340, 341, 342, 343, 344, 345],
|
||||
[346, 347, 65535, 65535, 65535, 65535, 65535, 65535],
|
||||
[348, 349, 48, 65535, 49, 65535, 5, 65535],
|
||||
[352, 353, 354, 355, 356, 357, 65535, 358],
|
||||
[359, 360, 361, 362, 363, 364, 65535, 365],
|
||||
[42, 65535, 65535, 65535, 65535, 65535, 65535, 65535],
|
||||
[43, 65535, 65535, 65535, 65535, 65535, 65535, 65535],
|
||||
[366, 367, 368, 369, 370, 371, 65535, 372],
|
||||
[373, 374, 375, 376, 377, 378, 65535, 379],
|
||||
[380, 381, 382, 383, 384, 385, 65535, 386],
|
||||
[387, 388, 389, 390, 391, 392, 65535, 393],
|
||||
[18, 65535, 336, 337, 338, 339, 340, 341],
|
||||
[19, 65535, 342, 343, 344, 345, 346, 347],
|
||||
[348, 349, 65535, 65535, 65535, 65535, 65535, 65535],
|
||||
[350, 351, 50, 65535, 51, 65535, 5, 65535],
|
||||
[35, 65535, 65535, 65535, 65535, 65535, 65535, 65535],
|
||||
[65535, 65535, 201, 202, 65535, 203, 204, 205],
|
||||
[65535, 65535, 65535, 65535, 330, 331, 332, 333],
|
||||
[65535, 65535, 173, 65535, 175, 65535, 177, 65535],
|
||||
[65535, 65535, 179, 65535, 181, 65535, 183, 65535],
|
||||
[65535, 65535, 185, 188, 65535, 65535, 187, 189],
|
||||
[65535, 65535, 203, 204, 65535, 205, 206, 207],
|
||||
[65535, 65535, 65535, 65535, 332, 333, 334, 335],
|
||||
[65535, 65535, 175, 65535, 177, 65535, 179, 65535],
|
||||
[65535, 65535, 181, 65535, 183, 65535, 185, 65535],
|
||||
[65535, 65535, 187, 190, 65535, 65535, 189, 191],
|
||||
];
|
||||
|
||||
pub static ONE_BYTE: [Entry; 256] = [
|
||||
Entry::Form(258), Entry::Form(259), Entry::Form(260), Entry::Form(261),
|
||||
Entry::Form(262), Entry::Form(263), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(267), Entry::Form(268), Entry::Form(269), Entry::Form(270),
|
||||
Entry::Form(271), Entry::Form(272), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(276), Entry::Form(277), Entry::Form(278), Entry::Form(279),
|
||||
Entry::Form(280), Entry::Form(281), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(285), Entry::Form(286), Entry::Form(287), Entry::Form(288),
|
||||
Entry::Form(289), Entry::Form(290), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(294), Entry::Form(295), Entry::Form(296), Entry::Form(297),
|
||||
Entry::Form(298), Entry::Form(299), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(303), Entry::Form(304), Entry::Form(305), Entry::Form(306),
|
||||
Entry::Form(307), Entry::Form(308), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(312), Entry::Form(313), Entry::Form(314), Entry::Form(315),
|
||||
Entry::Form(316), Entry::Form(317), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(321), Entry::Form(322), Entry::Form(323), Entry::Form(324),
|
||||
Entry::Form(325), Entry::Form(326), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(260), Entry::Form(261), Entry::Form(262), Entry::Form(263),
|
||||
Entry::Form(264), Entry::Form(265), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(269), Entry::Form(270), Entry::Form(271), Entry::Form(272),
|
||||
Entry::Form(273), Entry::Form(274), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(278), Entry::Form(279), Entry::Form(280), Entry::Form(281),
|
||||
Entry::Form(282), Entry::Form(283), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(287), Entry::Form(288), Entry::Form(289), Entry::Form(290),
|
||||
Entry::Form(291), Entry::Form(292), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(296), Entry::Form(297), Entry::Form(298), Entry::Form(299),
|
||||
Entry::Form(300), Entry::Form(301), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(305), Entry::Form(306), Entry::Form(307), Entry::Form(308),
|
||||
Entry::Form(309), Entry::Form(310), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(314), Entry::Form(315), Entry::Form(316), Entry::Form(317),
|
||||
Entry::Form(318), Entry::Form(319), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(323), Entry::Form(324), Entry::Form(325), Entry::Form(326),
|
||||
Entry::Form(327), Entry::Form(328), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
@@ -2359,18 +2379,18 @@ pub static ONE_BYTE: [Entry; 256] = [
|
||||
Entry::Form(34), Entry::Form(22), Entry::Form(23), Entry::Form(24),
|
||||
Entry::Form(25), Entry::Form(26), Entry::Form(27), Entry::Form(28),
|
||||
Entry::Form(36), Entry::Form(37), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Form(38), Entry::Form(39),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(58), Entry::Form(59), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(16), Entry::Form(17), Entry::Form(60), Entry::Form(61),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(56), Entry::Form(57), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(16), Entry::Form(17), Entry::Form(58), Entry::Form(59),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(38), Entry::Form(38), Entry::Form(38), Entry::Form(38),
|
||||
Entry::Form(38), Entry::Form(38), Entry::Form(38), Entry::Form(38),
|
||||
Entry::Form(39), Entry::Form(39), Entry::Form(39), Entry::Form(39),
|
||||
Entry::Form(39), Entry::Form(39), Entry::Form(39), Entry::Form(39),
|
||||
Entry::Group(4), Entry::Group(5), Entry::Form(42), Entry::Form(43),
|
||||
Entry::Form(40), Entry::Form(40), Entry::Form(40), Entry::Form(40),
|
||||
Entry::Form(40), Entry::Form(40), Entry::Form(40), Entry::Form(40),
|
||||
Entry::Form(41), Entry::Form(41), Entry::Form(41), Entry::Form(41),
|
||||
Entry::Form(41), Entry::Form(41), Entry::Form(41), Entry::Form(41),
|
||||
Entry::Group(4), Entry::Group(5), Entry::Form(44), Entry::Form(45),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Group(6), Entry::Group(7),
|
||||
Entry::Unsupported, Entry::Form(44), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Form(46), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Group(8), Entry::Group(9), Entry::Group(10), Entry::Group(11),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
@@ -2378,27 +2398,27 @@ pub static ONE_BYTE: [Entry; 256] = [
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(45), Entry::Form(46), Entry::Unsupported, Entry::Form(47),
|
||||
Entry::Form(47), Entry::Form(48), Entry::Unsupported, Entry::Form(49),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(50), Entry::Form(51), Entry::Group(12), Entry::Group(13),
|
||||
Entry::Form(52), Entry::Form(53), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(60), Entry::Form(61), Entry::Group(14), Entry::Group(15),
|
||||
Entry::Form(52), Entry::Form(53), Entry::Group(12), Entry::Group(13),
|
||||
Entry::Form(54), Entry::Form(55), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(62), Entry::Form(63), Entry::Group(14), Entry::Group(15),
|
||||
];
|
||||
|
||||
pub static TWO_BYTE: [Entry; 256] = [
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Form(54), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Form(56), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(84), Entry::Form(85), Entry::Form(104), Entry::Form(106),
|
||||
Entry::Form(195), Entry::Form(197), Entry::Form(108), Entry::Form(110),
|
||||
Entry::Form(86), Entry::Form(87), Entry::Form(106), Entry::Form(108),
|
||||
Entry::Form(197), Entry::Form(199), Entry::Form(110), Entry::Form(112),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Group(16),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(80), Entry::Form(81), Entry::Unsupported, Entry::Form(94),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Form(238), Entry::Form(239),
|
||||
Entry::Form(82), Entry::Form(83), Entry::Unsupported, Entry::Form(96),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Form(240), Entry::Form(241),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
@@ -2407,10 +2427,10 @@ pub static TWO_BYTE: [Entry; 256] = [
|
||||
Entry::Form(12), Entry::Form(12), Entry::Form(12), Entry::Form(12),
|
||||
Entry::Form(12), Entry::Form(12), Entry::Form(12), Entry::Form(12),
|
||||
Entry::Form(12), Entry::Form(12), Entry::Form(12), Entry::Form(12),
|
||||
Entry::Form(112), Entry::Form(206), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(116), Entry::Form(119), Entry::Form(122), Entry::Form(125),
|
||||
Entry::Form(210), Entry::Form(214), Entry::Form(242), Entry::Form(246),
|
||||
Entry::Form(218), Entry::Form(222), Entry::Form(226), Entry::Form(230),
|
||||
Entry::Form(114), Entry::Form(208), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(118), Entry::Form(121), Entry::Form(124), Entry::Form(127),
|
||||
Entry::Form(212), Entry::Form(216), Entry::Form(244), Entry::Form(248),
|
||||
Entry::Form(220), Entry::Form(224), Entry::Form(228), Entry::Form(232),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
@@ -2427,18 +2447,18 @@ pub static TWO_BYTE: [Entry; 256] = [
|
||||
Entry::Form(13), Entry::Form(13), Entry::Form(13), Entry::Form(13),
|
||||
Entry::Form(13), Entry::Form(13), Entry::Form(13), Entry::Form(13),
|
||||
Entry::Form(13), Entry::Form(13), Entry::Form(13), Entry::Form(13),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Form(55), Entry::Form(72),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Form(57), Entry::Form(74),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Form(73),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Form(75),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Group(17), Entry::Form(9),
|
||||
Entry::Form(76), Entry::Form(77), Entry::Unsupported, Entry::Form(74),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Form(62), Entry::Form(63),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Group(18), Entry::Form(75),
|
||||
Entry::Form(67), Entry::Form(68), Entry::Form(64), Entry::Form(65),
|
||||
Entry::Form(78), Entry::Form(79), Entry::Form(234), Entry::Form(93),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Form(193), Entry::Unsupported,
|
||||
Entry::Form(66), Entry::Form(66), Entry::Form(66), Entry::Form(66),
|
||||
Entry::Form(66), Entry::Form(66), Entry::Form(66), Entry::Form(66),
|
||||
Entry::Form(78), Entry::Form(79), Entry::Unsupported, Entry::Form(76),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Form(64), Entry::Form(65),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Group(18), Entry::Form(77),
|
||||
Entry::Form(69), Entry::Form(70), Entry::Form(66), Entry::Form(67),
|
||||
Entry::Form(80), Entry::Form(81), Entry::Form(236), Entry::Form(95),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Form(195), Entry::Unsupported,
|
||||
Entry::Form(68), Entry::Form(68), Entry::Form(68), Entry::Form(68),
|
||||
Entry::Form(68), Entry::Form(68), Entry::Form(68), Entry::Form(68),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
@@ -2458,14 +2478,14 @@ pub static TWO_BYTE_66: [Entry; 256] = [
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(86), Entry::Form(87), Entry::Form(105), Entry::Form(107),
|
||||
Entry::Form(196), Entry::Form(198), Entry::Form(109), Entry::Form(111),
|
||||
Entry::Form(88), Entry::Form(89), Entry::Form(107), Entry::Form(109),
|
||||
Entry::Form(198), Entry::Form(200), Entry::Form(111), Entry::Form(113),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(82), Entry::Form(83), Entry::Unsupported, Entry::Form(95),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Form(240), Entry::Form(241),
|
||||
Entry::Form(84), Entry::Form(85), Entry::Unsupported, Entry::Form(97),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Form(242), Entry::Form(243),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
@@ -2474,152 +2494,18 @@ pub static TWO_BYTE_66: [Entry; 256] = [
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(113), Entry::Form(207), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(117), Entry::Form(120), Entry::Form(123), Entry::Form(126),
|
||||
Entry::Form(211), Entry::Form(215), Entry::Form(243), Entry::Form(247),
|
||||
Entry::Form(219), Entry::Form(223), Entry::Form(227), Entry::Form(231),
|
||||
Entry::Form(127), Entry::Form(128), Entry::Form(129), Entry::Form(130),
|
||||
Entry::Form(131), Entry::Form(132), Entry::Form(133), Entry::Form(134),
|
||||
Entry::Form(135), Entry::Form(136), Entry::Form(137), Entry::Form(138),
|
||||
Entry::Form(139), Entry::Form(140), Entry::Form(102), Entry::Form(88),
|
||||
Entry::Form(190), Entry::Group(19), Entry::Group(20), Entry::Group(21),
|
||||
Entry::Form(141), Entry::Form(142), Entry::Form(143), Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Form(103), Entry::Form(89),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Form(235), Entry::Unsupported,
|
||||
Entry::Form(199), Entry::Form(200), Entry::Form(194), Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Form(172), Entry::Form(178), Entry::Form(184),
|
||||
Entry::Form(144), Entry::Form(145), Entry::Form(101), Entry::Form(114),
|
||||
Entry::Form(146), Entry::Form(147), Entry::Form(148), Entry::Form(115),
|
||||
Entry::Form(149), Entry::Form(150), Entry::Form(151), Entry::Form(118),
|
||||
Entry::Form(152), Entry::Form(174), Entry::Form(180), Entry::Form(153),
|
||||
Entry::Form(154), Entry::Form(155), Entry::Form(249), Entry::Form(92),
|
||||
Entry::Form(156), Entry::Form(157), Entry::Form(158), Entry::Form(121),
|
||||
Entry::Form(159), Entry::Form(160), Entry::Form(161), Entry::Form(124),
|
||||
Entry::Unsupported, Entry::Form(176), Entry::Form(182), Entry::Form(186),
|
||||
Entry::Form(162), Entry::Form(163), Entry::Form(164), Entry::Unsupported,
|
||||
Entry::Form(165), Entry::Form(166), Entry::Form(167), Entry::Form(168),
|
||||
Entry::Form(169), Entry::Form(170), Entry::Form(171), Entry::Unsupported,
|
||||
];
|
||||
|
||||
pub static TWO_BYTE_F3: [Entry; 256] = [
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(96), Entry::Form(97), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Form(252), Entry::Unsupported,
|
||||
Entry::Form(253), Entry::Form(254), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Form(208), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(212), Entry::Form(216), Entry::Form(244), Entry::Form(248),
|
||||
Entry::Form(220), Entry::Form(224), Entry::Form(228), Entry::Form(232),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Form(90),
|
||||
Entry::Form(191), Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Form(100), Entry::Form(91),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(69), Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(70), Entry::Form(71), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Form(236), Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Form(250), Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
];
|
||||
|
||||
pub static TWO_BYTE_F2: [Entry; 256] = [
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(98), Entry::Form(99), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Form(255), Entry::Unsupported,
|
||||
Entry::Form(256), Entry::Form(257), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Form(209), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(213), Entry::Form(217), Entry::Form(245), Entry::Unsupported,
|
||||
Entry::Form(115), Entry::Form(209), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(119), Entry::Form(122), Entry::Form(125), Entry::Form(128),
|
||||
Entry::Form(213), Entry::Form(217), Entry::Form(245), Entry::Form(249),
|
||||
Entry::Form(221), Entry::Form(225), Entry::Form(229), Entry::Form(233),
|
||||
Entry::Form(129), Entry::Form(130), Entry::Form(131), Entry::Form(132),
|
||||
Entry::Form(133), Entry::Form(134), Entry::Form(135), Entry::Form(136),
|
||||
Entry::Form(137), Entry::Form(138), Entry::Form(139), Entry::Form(140),
|
||||
Entry::Form(141), Entry::Form(142), Entry::Form(104), Entry::Form(90),
|
||||
Entry::Form(192), Entry::Group(19), Entry::Group(20), Entry::Group(21),
|
||||
Entry::Form(143), Entry::Form(144), Entry::Form(145), Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(192), Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Form(105), Entry::Form(91),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
@@ -2637,6 +2523,36 @@ pub static TWO_BYTE_F2: [Entry; 256] = [
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Form(237), Entry::Unsupported,
|
||||
Entry::Form(201), Entry::Form(202), Entry::Form(196), Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Form(174), Entry::Form(180), Entry::Form(186),
|
||||
Entry::Form(146), Entry::Form(147), Entry::Form(103), Entry::Form(116),
|
||||
Entry::Form(148), Entry::Form(149), Entry::Form(150), Entry::Form(117),
|
||||
Entry::Form(151), Entry::Form(152), Entry::Form(153), Entry::Form(120),
|
||||
Entry::Form(154), Entry::Form(176), Entry::Form(182), Entry::Form(155),
|
||||
Entry::Form(156), Entry::Form(157), Entry::Form(251), Entry::Form(94),
|
||||
Entry::Form(158), Entry::Form(159), Entry::Form(160), Entry::Form(123),
|
||||
Entry::Form(161), Entry::Form(162), Entry::Form(163), Entry::Form(126),
|
||||
Entry::Unsupported, Entry::Form(178), Entry::Form(184), Entry::Form(188),
|
||||
Entry::Form(164), Entry::Form(165), Entry::Form(166), Entry::Unsupported,
|
||||
Entry::Form(167), Entry::Form(168), Entry::Form(169), Entry::Form(170),
|
||||
Entry::Form(171), Entry::Form(172), Entry::Form(173), Entry::Unsupported,
|
||||
];
|
||||
|
||||
pub static TWO_BYTE_F3: [Entry; 256] = [
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(98), Entry::Form(99), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Form(254), Entry::Unsupported,
|
||||
Entry::Form(255), Entry::Form(256), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
@@ -2645,7 +2561,111 @@ pub static TWO_BYTE_F2: [Entry; 256] = [
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Form(251), Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Form(210), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(214), Entry::Form(218), Entry::Form(246), Entry::Form(250),
|
||||
Entry::Form(222), Entry::Form(226), Entry::Form(230), Entry::Form(234),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Form(92),
|
||||
Entry::Form(193), Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Form(102), Entry::Form(93),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(71), Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(72), Entry::Form(73), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Form(238), Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Form(252), Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
];
|
||||
|
||||
pub static TWO_BYTE_F2: [Entry; 256] = [
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(100), Entry::Form(101), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Form(257), Entry::Unsupported,
|
||||
Entry::Form(258), Entry::Form(259), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Form(211), Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(215), Entry::Form(219), Entry::Form(247), Entry::Unsupported,
|
||||
Entry::Form(223), Entry::Form(227), Entry::Form(231), Entry::Form(235),
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Form(194), Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Form(239), Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Form(253), Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
|
||||
|
||||
@@ -164,3 +164,45 @@ fn vector_operations_match_llvm() {
|
||||
assert_eq!(assembler.instructions(), [*word], "{text}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn carry_arithmetic_matches_llvm() {
|
||||
// `llvm-mc -triple=aarch64-apple-macos -show-encoding`.
|
||||
let cases: &[(&str, Emit, u32)] = &[
|
||||
(
|
||||
"adcs x11, x9, x10",
|
||||
|a| a.adcs_reg_64(11, 9, 10),
|
||||
0xba0a012b,
|
||||
),
|
||||
(
|
||||
"adcs w11, w9, w10",
|
||||
|a| a.adcs_reg_32(11, 9, 10),
|
||||
0x3a0a012b,
|
||||
),
|
||||
(
|
||||
"adcs x0, x30, x17",
|
||||
|a| a.adcs_reg_64(0, 30, 17),
|
||||
0xba1103c0,
|
||||
),
|
||||
(
|
||||
"sbcs x11, x9, x10",
|
||||
|a| a.sbcs_reg_64(11, 9, 10),
|
||||
0xfa0a012b,
|
||||
),
|
||||
(
|
||||
"sbcs w11, w9, w10",
|
||||
|a| a.sbcs_reg_32(11, 9, 10),
|
||||
0x7a0a012b,
|
||||
),
|
||||
(
|
||||
"sbcs w0, w30, w17",
|
||||
|a| a.sbcs_reg_32(0, 30, 17),
|
||||
0x7a1103c0,
|
||||
),
|
||||
];
|
||||
for (text, emit, word) in cases {
|
||||
let mut assembler = Arm64Assembler::new();
|
||||
emit(&mut assembler);
|
||||
assert_eq!(assembler.instructions(), [*word], "{text}");
|
||||
}
|
||||
}
|
||||
@@ -13,8 +13,8 @@
|
||||
//! assembled with `clang -target x86_64-apple-macos` and read with `objdump`.
|
||||
|
||||
use xenora_loader::cpu::{
|
||||
CPUID_CMOV, CPUID_LONG_MODE, CPUID_LZCNT, CPUID_POPCNT, CpuState, ExitReason, Interpreter,
|
||||
RFlags, cpuid,
|
||||
CPUID_CMOV, CPUID_LAHF_SAHF, CPUID_LONG_MODE, CPUID_LZCNT, CPUID_POPCNT, CpuState, ExitReason,
|
||||
Interpreter, RFlags, cpuid,
|
||||
};
|
||||
use xenora_loader::dbt::DbtEngine;
|
||||
use xenora_loader::memory::{GuestMemory, MemoryPermissions};
|
||||
@@ -79,9 +79,9 @@ fn every_leaf_returns_its_documented_values() {
|
||||
(1, 0xFFFF_FFFF, [0, 0, 0x0080_0000, 0x0000_8000]),
|
||||
// Highest extended leaf.
|
||||
(0x8000_0000, 0, [0x8000_0001, 0, 0, 0]),
|
||||
// LZCNT is ECX bit 5 and long mode is EDX bit 29.
|
||||
(0x8000_0001, 0, [0, 0, 0x0000_0020, 0x2000_0000]),
|
||||
(0x8000_0001, 7, [0, 0, 0x0000_0020, 0x2000_0000]),
|
||||
// LAHF/SAHF is ECX bit 0, LZCNT ECX bit 5 and long mode EDX bit 29.
|
||||
(0x8000_0001, 0, [0, 0, 0x0000_0021, 0x2000_0000]),
|
||||
(0x8000_0001, 7, [0, 0, 0x0000_0021, 0x2000_0000]),
|
||||
// Everything else, above or between the highest leaves, is zeros.
|
||||
(2, 0, [0; 4]),
|
||||
(4, 0, [0; 4]),
|
||||
@@ -129,8 +129,14 @@ fn every_leaf_returns_its_documented_values() {
|
||||
.collect();
|
||||
assert_eq!(vendor, b"Xenora guest");
|
||||
assert_eq!(
|
||||
(CPUID_POPCNT, CPUID_CMOV, CPUID_LZCNT, CPUID_LONG_MODE),
|
||||
(1 << 23, 1 << 15, 1 << 5, 1 << 29)
|
||||
(
|
||||
CPUID_POPCNT,
|
||||
CPUID_CMOV,
|
||||
CPUID_LAHF_SAHF,
|
||||
CPUID_LZCNT,
|
||||
CPUID_LONG_MODE
|
||||
),
|
||||
(1 << 23, 1 << 15, 1, 1 << 5, 1 << 29)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -189,6 +195,10 @@ fn reported_features_have_all_their_instructions_in_the_fixtures() {
|
||||
decodable(&format!("{name} {high}, {}", memory(bits)));
|
||||
}
|
||||
}
|
||||
// LAHF and SAHF have one form each and no operands.
|
||||
assert_ne!(cpuid(0x8000_0001, 0)[ECX] & CPUID_LAHF_SAHF, 0);
|
||||
decodable("lahf");
|
||||
decodable("sahf");
|
||||
// Long mode: 64-bit operands and the registers only it has.
|
||||
assert_ne!(cpuid(0x8000_0001, 0)[EDX] & CPUID_LONG_MODE, 0);
|
||||
decodable("add r9, r12");
|
||||
@@ -232,7 +242,6 @@ fn unreported_features_each_have_an_instruction_that_is_refused() {
|
||||
("RDSEED", 7, EBX, 18, &[0x0F, 0xC7, 0xF8]), // rdseed eax
|
||||
("ADX", 7, EBX, 19, &[0x66, 0x0F, 0x38, 0xF6, 0xC1]), // adcx eax, ecx
|
||||
("SHA", 7, EBX, 29, &[0x0F, 0x38, 0xC9, 0xC1]), // sha1msg1 xmm0, xmm1
|
||||
("LAHF/SAHF", 0x8000_0001, ECX, 0, &[0x9F]), // lahf
|
||||
("PREFETCHW", 0x8000_0001, ECX, 8, &[0x0F, 0x0D, 0x0E]), // prefetchw [rsi]
|
||||
("SYSCALL/SYSRET", 0x8000_0001, EDX, 11, &[0x48, 0x0F, 0x07]), // sysretq
|
||||
("RDTSCP", 0x8000_0001, EDX, 27, &[0x0F, 0x01, 0xF9]), // rdtscp
|
||||
|
||||
@@ -598,6 +598,15 @@ const FLAG_MOVES: &str = r"
|
||||
SDM 2A LAHF
|
||||
lahf: rax=8877665544332211 f=CPASO => rax=8877665544339711 f=*
|
||||
lahf_zero: rax=8877665544332211 f=Z => rax=8877665544334211 f=*
|
||||
lahf_carry_only: rax=ffffffffffffffff f=C => rax=ffffffffffff03ff f=*
|
||||
lahf_parity_only: rax=ffffffffffffffff f=P => rax=ffffffffffff06ff f=*
|
||||
lahf_adjust_only: rax=ffffffffffffffff f=A => rax=ffffffffffff12ff f=*
|
||||
lahf_sign_only: rax=ffffffffffffffff f=S => rax=ffffffffffff82ff f=*
|
||||
lahf_does_not_store_of: rax=ffffffffffffffff f=O => rax=ffffffffffff02ff f=*
|
||||
@ rex.w lahf
|
||||
489f
|
||||
SDM 2A LAHF; 2A 2.2.1.2
|
||||
lahf_rex_w_changes_nothing: rax=ffffffffffffffff f=CO => rax=ffffffffffff03ff f=*
|
||||
@ sahf; lahf
|
||||
9e 9f
|
||||
SDM 2B SAHF
|
||||
@@ -606,6 +615,12 @@ sahf_ignores_bits_1_3_5: rax=ff00 f=O => rax=d700 f=CPAZSO
|
||||
9e
|
||||
SDM 2B SAHF
|
||||
sahf_clear_keeps_of: rax=2800 f=OC => f=cpazsO
|
||||
sahf_carry_only: rax=100 f=O => f=CpazsO
|
||||
sahf_parity_only: rax=400 f=O => f=cPazsO
|
||||
sahf_adjust_only: rax=1000 f=O => f=cpAzsO
|
||||
sahf_zero_only: rax=4000 f=O => f=cpaZsO
|
||||
sahf_sign_only: rax=8000 f=O => f=cpazSO
|
||||
sahf_reads_only_ah: rax=ffffffffffff00ff f=CPAZS => f=cpazso
|
||||
@ stc
|
||||
f9
|
||||
SDM 2B STC
|
||||
@@ -2722,8 +2737,6 @@ const UNSUPPORTED: &[(&str, usize)] = &[
|
||||
("insertps_zero_mask", 0),
|
||||
("jecxz_tests_low_32_bits", 1),
|
||||
("jrcxz_tests_all_64_bits", 1),
|
||||
("lahf", 0),
|
||||
("lahf_zero", 0),
|
||||
("lea64_addr32_truncates_effective_address", 0),
|
||||
("lock_btc_memory", 0),
|
||||
("lodsd_zero_extends", 1),
|
||||
@@ -2772,8 +2785,6 @@ const UNSUPPORTED: &[(&str, usize)] = &[
|
||||
("roundps_uses_mxcsr_rc", 0),
|
||||
("roundsd_suppress_precision", 0),
|
||||
("roundss_imm_modes", 0),
|
||||
("sahf_clear_keeps_of", 0),
|
||||
("sahf_ignores_bits_1_3_5", 0),
|
||||
("shld16_by16_takes_source", 0),
|
||||
("shld32_by1_sign_change", 0),
|
||||
("shld32_by4", 0),
|
||||
|
||||
@@ -95,8 +95,8 @@ def cases():
|
||||
out += [f"{op} ah, bl", f"{op} cl, dh", f"{op} {mem(8)}, ch"]
|
||||
out += ["mov ah, bl", "mov dl, ch", "mov bh, 0x21", "xchg ah, bl", "mov sil, dil",
|
||||
"movabs r15, 0x8877665544332211", "mov rcx, -2", "bswap ebx", "bswap r9",
|
||||
"cbw", "cwde", "cdqe", "cwd", "cdq", "cqo", "clc", "stc", "cmc", "nop", "cpuid",
|
||||
"nop dword ptr [rax + 8]", "pause", "lfence", "mfence", "sfence",
|
||||
"cbw", "cwde", "cdqe", "cwd", "cdq", "cqo", "clc", "stc", "cmc", "lahf", "sahf",
|
||||
"nop", "cpuid", "nop dword ptr [rax + 8]", "pause", "lfence", "mfence", "sfence",
|
||||
f"movnti {mem(32)}, ebx", f"movnti {mem(64)}, rbx",
|
||||
f"movnti {mem(32)}, r9d", f"movnti {mem(64)}, r14", "push r9", "push rbx", "push -5", "push 0x12345678",
|
||||
f"push {mem(64)}", "pop rbx", "pop r12", f"pop {mem(64)}", "leave"]
|
||||
|
||||
@@ -1113,6 +1113,8 @@ b7 21 | mov bh, 0x21
|
||||
f8 | clc
|
||||
f9 | stc
|
||||
f5 | cmc
|
||||
9f | lahf
|
||||
9e | sahf
|
||||
90 | nop
|
||||
0f a2 | cpuid
|
||||
0f 1f 40 08 | nop dword ptr [rax + 8]
|
||||
|
||||
@@ -0,0 +1,384 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
//! Multiword ADC and SBB carry chains through the interpreter and the native
|
||||
//! DBT.
|
||||
//!
|
||||
//! Encodings were assembled with LLVM (`llvm-mc -triple=x86_64`, Intel syntax).
|
||||
//! Expected values come from widening `u128` and `i128` arithmetic over the
|
||||
//! limbs, following the ADC and SBB operation sections of the Intel SDM Vol. 2:
|
||||
//! DEST = DEST + SRC + CF and DEST = DEST - (SRC + CF). They never read the
|
||||
//! production semantics. Both engines must also agree on the complete state,
|
||||
//! including PF and AF, which the reference does not model.
|
||||
|
||||
use xenora_loader::cpu::{CpuState, ExitReason, Interpreter};
|
||||
use xenora_loader::dbt::{DbtEngine, is_native};
|
||||
use xenora_loader::memory::{GuestMemory, MemoryPermissions};
|
||||
use xenora_loader::x86_decode::decode;
|
||||
use xenora_loader::x86_table::Op;
|
||||
|
||||
const ENTRY: u64 = 0x1000;
|
||||
/// `jmp +0`: ends the translated block, so the next instruction reads CF from
|
||||
/// the guest state stored by the previous block.
|
||||
const JMP: [u8; 2] = [0xEB, 0x00];
|
||||
const HLT: u8 = 0xF4;
|
||||
|
||||
/// Limb registers: A in RAX, RBX, RCX, RDX and B in R8 to R11.
|
||||
const A: [usize; 4] = [0, 3, 1, 2];
|
||||
const B: [usize; 4] = [8, 9, 10, 11];
|
||||
|
||||
// add rax, r8; adc rbx, r9; adc rcx, r10; adc rdx, r11 (and the SUB/SBB and
|
||||
// 32-bit equivalents).
|
||||
const ADD64: [&[u8]; 4] = [
|
||||
&[0x4C, 0x01, 0xC0],
|
||||
&[0x4C, 0x11, 0xCB],
|
||||
&[0x4C, 0x11, 0xD1],
|
||||
&[0x4C, 0x11, 0xDA],
|
||||
];
|
||||
const SUB64: [&[u8]; 4] = [
|
||||
&[0x4C, 0x29, 0xC0],
|
||||
&[0x4C, 0x19, 0xCB],
|
||||
&[0x4C, 0x19, 0xD1],
|
||||
&[0x4C, 0x19, 0xDA],
|
||||
];
|
||||
const ADD32: [&[u8]; 4] = [
|
||||
&[0x44, 0x01, 0xC0],
|
||||
&[0x44, 0x11, 0xCB],
|
||||
&[0x44, 0x11, 0xD1],
|
||||
&[0x44, 0x11, 0xDA],
|
||||
];
|
||||
const SUB32: [&[u8]; 4] = [
|
||||
&[0x44, 0x29, 0xC0],
|
||||
&[0x44, 0x19, 0xCB],
|
||||
&[0x44, 0x19, 0xD1],
|
||||
&[0x44, 0x19, 0xDA],
|
||||
];
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
||||
enum Chain {
|
||||
Add,
|
||||
Sub,
|
||||
}
|
||||
|
||||
/// Expected limbs and CF, ZF, SF, OF of the last limb.
|
||||
#[derive(PartialEq, Eq, Debug)]
|
||||
struct Expected {
|
||||
limbs: [u64; 4],
|
||||
cf: bool,
|
||||
zf: bool,
|
||||
sf: bool,
|
||||
of: bool,
|
||||
}
|
||||
|
||||
fn reference(chain: Chain, bits: u32, a: [u64; 4], b: [u64; 4]) -> Expected {
|
||||
let mask = if bits == 64 {
|
||||
u64::MAX
|
||||
} else {
|
||||
(1u64 << bits) - 1
|
||||
};
|
||||
let modulus = 1u128 << bits;
|
||||
let signed = |value: u64| -> i128 {
|
||||
let value = i128::from(value & mask);
|
||||
if value >= (1i128 << (bits - 1)) {
|
||||
value - (1i128 << bits)
|
||||
} else {
|
||||
value
|
||||
}
|
||||
};
|
||||
let mut limbs = [0; 4];
|
||||
let mut carry = 0u128;
|
||||
let mut of = false;
|
||||
for i in 0..4 {
|
||||
let (x, y) = (u128::from(a[i] & mask), u128::from(b[i] & mask));
|
||||
let wide = match chain {
|
||||
Chain::Add => x + y + carry,
|
||||
Chain::Sub => x + modulus - y - carry,
|
||||
};
|
||||
limbs[i] = (wide % modulus) as u64;
|
||||
let exact = match chain {
|
||||
Chain::Add => signed(a[i]) + signed(b[i]) + carry as i128,
|
||||
Chain::Sub => signed(a[i]) - signed(b[i]) - carry as i128,
|
||||
};
|
||||
of = exact != signed(limbs[i]);
|
||||
carry = match chain {
|
||||
Chain::Add => u128::from(wide >= modulus),
|
||||
Chain::Sub => u128::from(y + carry > x),
|
||||
};
|
||||
}
|
||||
Expected {
|
||||
limbs,
|
||||
cf: carry != 0,
|
||||
zf: limbs[3] == 0,
|
||||
sf: limbs[3] >> (bits - 1) & 1 != 0,
|
||||
of,
|
||||
}
|
||||
}
|
||||
|
||||
fn program(parts: &[&[u8]], split: bool) -> Vec<u8> {
|
||||
let mut code = Vec::new();
|
||||
for (i, part) in parts.iter().enumerate() {
|
||||
if split && i > 0 {
|
||||
code.extend_from_slice(&JMP);
|
||||
}
|
||||
code.extend_from_slice(part);
|
||||
}
|
||||
code.push(HLT);
|
||||
code
|
||||
}
|
||||
|
||||
fn load(code: &[u8], gpr: [u64; 16], cf: bool) -> (CpuState, GuestMemory) {
|
||||
let mut memory = GuestMemory::new();
|
||||
memory
|
||||
.map_region_with_data(ENTRY, code.len(), MemoryPermissions::READ_EXECUTE, code)
|
||||
.unwrap();
|
||||
let mut cpu = CpuState::new(ENTRY, 0);
|
||||
cpu.gpr = gpr;
|
||||
cpu.flags.cf = cf;
|
||||
(cpu, memory)
|
||||
}
|
||||
|
||||
/// Run `code` to its HLT in both engines, check they agree on the whole state
|
||||
/// and that the DBT never left native code, and return the final state.
|
||||
fn run_both(code: &[u8], gpr: [u64; 16], cf: bool, context: &str) -> CpuState {
|
||||
let (cpu, mut memory) = load(code, gpr, cf);
|
||||
let interpreted = Interpreter::new(cpu, &mut memory, 64).run();
|
||||
let (mut cpu, mut memory) = load(code, gpr, cf);
|
||||
let mut engine = DbtEngine::new(16 * 1024).unwrap();
|
||||
let translated = engine.run(&mut cpu, &mut memory, 64);
|
||||
assert_eq!(interpreted.exit_reason, ExitReason::Halt, "{context}");
|
||||
assert_eq!(translated.exit_reason, ExitReason::Halt, "{context}");
|
||||
assert_eq!(translated.final_state, interpreted.final_state, "{context}");
|
||||
assert_eq!(engine.metrics.interpreter_fallbacks, 0, "{context}");
|
||||
interpreted.final_state
|
||||
}
|
||||
|
||||
struct Random(u64);
|
||||
|
||||
impl Random {
|
||||
fn next(&mut self) -> u64 {
|
||||
self.0 ^= self.0 >> 12;
|
||||
self.0 ^= self.0 << 25;
|
||||
self.0 ^= self.0 >> 27;
|
||||
self.0.wrapping_mul(0x2545_F491_4F6C_DD1D)
|
||||
}
|
||||
}
|
||||
|
||||
/// Limb values at the carry and overflow boundaries of a `bits`-wide limb.
|
||||
fn edges(bits: u32) -> [u64; 6] {
|
||||
let max = if bits == 64 {
|
||||
u64::MAX
|
||||
} else {
|
||||
(1u64 << bits) - 1
|
||||
};
|
||||
let sign = 1u64 << (bits - 1);
|
||||
[0, 1, max - 1, max, sign, sign - 1]
|
||||
}
|
||||
|
||||
fn operand_sets(bits: u32) -> Vec<([u64; 4], [u64; 4])> {
|
||||
let edges = edges(bits);
|
||||
let mut sets = Vec::new();
|
||||
for &x in &edges {
|
||||
for &y in &edges {
|
||||
sets.push(([x; 4], [y; 4]));
|
||||
sets.push(([x, y, x, y], [y, x, y, x]));
|
||||
}
|
||||
}
|
||||
let mut random = Random(0x0195_ADC5_BB00_0001);
|
||||
for _ in 0..256 {
|
||||
let mut pick = || {
|
||||
let raw = random.next();
|
||||
if raw & 3 == 0 {
|
||||
edges[(raw >> 8) as usize % edges.len()] | raw & !edges[3]
|
||||
} else {
|
||||
raw
|
||||
}
|
||||
};
|
||||
let a = [pick(), pick(), pick(), pick()];
|
||||
let b = [pick(), pick(), pick(), pick()];
|
||||
sets.push((a, b));
|
||||
}
|
||||
sets
|
||||
}
|
||||
|
||||
fn check_chain(chain: Chain, bits: u32, parts: [&[u8]; 4]) {
|
||||
for part in &parts[1..] {
|
||||
let insn = decode(ENTRY, |address| {
|
||||
part.get((address - ENTRY) as usize).copied().ok_or(())
|
||||
})
|
||||
.unwrap();
|
||||
assert!(matches!(insn.op, Op::Adc | Op::Sbb));
|
||||
assert!(is_native(&insn), "{:?}", insn.op);
|
||||
}
|
||||
let mut random = Random(u64::from(bits) << 8 | chain as u64);
|
||||
for (a, b) in operand_sets(bits) {
|
||||
let expected = reference(chain, bits, a, b);
|
||||
for split in [false, true] {
|
||||
let code = program(&parts, split);
|
||||
let mut gpr: [u64; 16] = std::array::from_fn(|_| random.next());
|
||||
for i in 0..4 {
|
||||
gpr[A[i]] = a[i];
|
||||
gpr[B[i]] = b[i];
|
||||
}
|
||||
// The leading ADD or SUB must ignore the incoming carry.
|
||||
for cf in [false, true] {
|
||||
let context = format!("{chain:?}{bits} split={split} cf={cf} a={a:x?} b={b:x?}");
|
||||
let state = run_both(&code, gpr, cf, &context);
|
||||
let limbs = A.map(|index| state.gpr[index]);
|
||||
// A 32-bit destination clears bits 63:32.
|
||||
assert_eq!(limbs, expected.limbs, "{context}");
|
||||
assert_eq!(B.map(|index| state.gpr[index]), b, "{context}");
|
||||
let flags = (
|
||||
state.flags.cf,
|
||||
state.flags.zf,
|
||||
state.flags.sf,
|
||||
state.flags.of,
|
||||
);
|
||||
let wanted = (expected.cf, expected.zf, expected.sf, expected.of);
|
||||
assert_eq!(flags, wanted, "{context}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn reference_matches_native_wide_arithmetic() {
|
||||
// 128-bit sanity checks of the reference itself on the low two limbs.
|
||||
let cases = [
|
||||
(u128::MAX, 1u128),
|
||||
(0, 1),
|
||||
(1u128 << 64, 1),
|
||||
(0x8000_0000_0000_0000_0000_0000_0000_0000, 1),
|
||||
];
|
||||
for (x, y) in cases {
|
||||
let a = [x as u64, (x >> 64) as u64, 0, 0];
|
||||
let b = [y as u64, (y >> 64) as u64, 0, 0];
|
||||
let sum = reference(Chain::Add, 64, a, b);
|
||||
let expected = x.wrapping_add(y);
|
||||
assert_eq!(sum.limbs[0], expected as u64);
|
||||
assert_eq!(sum.limbs[1], (expected >> 64) as u64);
|
||||
let difference = reference(Chain::Sub, 64, a, b);
|
||||
let expected = x.wrapping_sub(y);
|
||||
assert_eq!(difference.limbs[0], expected as u64);
|
||||
assert_eq!(difference.limbs[1], (expected >> 64) as u64);
|
||||
// The upper limbs are zero, so the 256-bit borrow is the 128-bit one.
|
||||
assert_eq!(difference.cf, y > x);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn add_adc_chains_of_64_bit_limbs_carry_across_blocks() {
|
||||
check_chain(Chain::Add, 64, ADD64);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sub_sbb_chains_of_64_bit_limbs_borrow_across_blocks() {
|
||||
check_chain(Chain::Sub, 64, SUB64);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn add_adc_chains_of_32_bit_limbs_carry_across_blocks() {
|
||||
check_chain(Chain::Add, 32, ADD32);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sub_sbb_chains_of_32_bit_limbs_borrow_across_blocks() {
|
||||
check_chain(Chain::Sub, 32, SUB32);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn split_chains_run_one_block_per_limb() {
|
||||
let code = program(&ADD64, true);
|
||||
let (mut cpu, mut memory) = load(&code, [0; 16], false);
|
||||
let mut engine = DbtEngine::new(16 * 1024).unwrap();
|
||||
let result = engine.run(&mut cpu, &mut memory, 64);
|
||||
assert_eq!(result.exit_reason, ExitReason::Halt);
|
||||
assert_eq!(engine.metrics.blocks_compiled, 4);
|
||||
assert_eq!(engine.metrics.interpreter_fallbacks, 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn immediate_forms_increment_and_decrement_a_128_bit_value() {
|
||||
// add rax, 1; adc rbx, 0 and sub rax, 1; sbb rbx, 0.
|
||||
let increment: [&[u8]; 2] = [&[0x48, 0x83, 0xC0, 0x01], &[0x48, 0x83, 0xD3, 0x00]];
|
||||
let decrement: [&[u8]; 2] = [&[0x48, 0x83, 0xE8, 0x01], &[0x48, 0x83, 0xDB, 0x00]];
|
||||
let values = [
|
||||
0u128,
|
||||
1,
|
||||
u64::MAX as u128,
|
||||
1u128 << 64,
|
||||
u128::MAX,
|
||||
u128::MAX - 1,
|
||||
1u128 << 127,
|
||||
(1u128 << 127) - 1,
|
||||
];
|
||||
for value in values {
|
||||
for split in [false, true] {
|
||||
for (parts, expected, carry, overflow) in [
|
||||
(
|
||||
&increment,
|
||||
value.wrapping_add(1),
|
||||
value == u128::MAX,
|
||||
value == (1u128 << 127) - 1,
|
||||
),
|
||||
(
|
||||
&decrement,
|
||||
value.wrapping_sub(1),
|
||||
value == 0,
|
||||
value == 1u128 << 127,
|
||||
),
|
||||
] {
|
||||
let code = program(parts, split);
|
||||
let mut gpr = [0x5A5A_5A5A_5A5A_5A5A; 16];
|
||||
gpr[0] = value as u64;
|
||||
gpr[3] = (value >> 64) as u64;
|
||||
let context = format!("{value:#x} split={split} {:x?}", parts[0]);
|
||||
let state = run_both(&code, gpr, true, &context);
|
||||
assert_eq!(state.gpr[0], expected as u64, "{context}");
|
||||
assert_eq!(state.gpr[3], (expected >> 64) as u64, "{context}");
|
||||
assert_eq!(state.flags.cf, carry, "{context}");
|
||||
assert_eq!(state.flags.of, overflow, "{context}");
|
||||
assert_eq!(state.flags.zf, (expected >> 64) == 0, "{context}");
|
||||
assert_eq!(state.flags.sf, expected >> 127 != 0, "{context}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sbb_of_a_register_with_itself_materializes_the_carry_mask() {
|
||||
// sbb esi, esi and sbb rsi, rsi give -CF and borrow exactly when CF was
|
||||
// set; adc edi, 0 adds CF to 0x89ABCDEF without a carry out. The 32-bit
|
||||
// forms clear bits 63:32.
|
||||
// (code, destination register, value from CF, CF out from CF in)
|
||||
type Case = (&'static [u8], usize, fn(bool) -> u64, fn(bool) -> bool);
|
||||
let cases: [Case; 3] = [
|
||||
(
|
||||
&[0x19, 0xF6],
|
||||
6,
|
||||
|cf| if cf { 0xFFFF_FFFF } else { 0 },
|
||||
|cf| cf,
|
||||
),
|
||||
(
|
||||
&[0x48, 0x19, 0xF6],
|
||||
6,
|
||||
|cf| if cf { u64::MAX } else { 0 },
|
||||
|cf| cf,
|
||||
),
|
||||
(
|
||||
&[0x83, 0xD7, 0x00],
|
||||
7,
|
||||
|cf| u64::from(cf) + 0x89AB_CDEF,
|
||||
|_| false,
|
||||
),
|
||||
];
|
||||
for (code, register, value, carry) in cases {
|
||||
for cf in [false, true] {
|
||||
let mut gpr = [0x0123_4567_89AB_CDEF; 16];
|
||||
gpr[6] = 0xDEAD_BEEF_0000_0001;
|
||||
let program = [code, &[HLT]].concat();
|
||||
let context = format!("{code:x?} cf={cf}");
|
||||
let state = run_both(&program, gpr, cf, &context);
|
||||
assert_eq!(state.gpr[register], value(cf), "{context}");
|
||||
assert_eq!(state.flags.cf, carry(cf), "{context}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -328,6 +328,11 @@ fn reference(m: &mut Machine, text: &str) -> Outcome {
|
||||
bits,
|
||||
high: false,
|
||||
};
|
||||
let ah = Place::Reg {
|
||||
index: RAX,
|
||||
bits: 8,
|
||||
high: true,
|
||||
};
|
||||
|
||||
if let Some(code) = name.strip_prefix("cmov") {
|
||||
let value = read(
|
||||
@@ -739,18 +744,39 @@ fn reference(m: &mut Machine, text: &str) -> Outcome {
|
||||
m.flags.cf = !m.flags.cf;
|
||||
Outcome::Done(none)
|
||||
}
|
||||
// AH bits 7 to 0 are SF, ZF, 0, AF, 0, PF, 1 and CF; OF has no bit.
|
||||
"lahf" => {
|
||||
let f = m.flags;
|
||||
let bits = [f.cf, true, f.pf, false, f.af, false, f.zf, f.sf];
|
||||
let value = (0..8)
|
||||
.filter(|&index| bits[index])
|
||||
.map(|index| 1u128 << index)
|
||||
.sum();
|
||||
write(m, ah, value);
|
||||
Outcome::Done(none)
|
||||
}
|
||||
"sahf" => {
|
||||
let value = read(m, ah, 8);
|
||||
m.flags.cf = bit(value, 0);
|
||||
m.flags.pf = bit(value, 2);
|
||||
m.flags.af = bit(value, 4);
|
||||
m.flags.zf = bit(value, 6);
|
||||
m.flags.sf = bit(value, 7);
|
||||
Outcome::Done(none)
|
||||
}
|
||||
// The fences order memory accesses and compute nothing.
|
||||
"nop" | "pause" | "lfence" | "mfence" | "sfence" => Outcome::Done(none),
|
||||
"cpuid" => {
|
||||
// Xenora's guest CPUID contract, restated: the vendor "Xenora guest"
|
||||
// and the four features whose every instruction exists, CMOV and
|
||||
// POPCNT in leaf 1, LZCNT and long mode in leaf 0x8000_0001.
|
||||
// and the five features whose every instruction exists, CMOV and
|
||||
// POPCNT in leaf 1, LAHF/SAHF, LZCNT and long mode in leaf
|
||||
// 0x8000_0001.
|
||||
let word = |text: &[u8; 4]| u32::from_le_bytes(*text);
|
||||
let values = match m.gpr[RAX] as u32 {
|
||||
0 => [1, word(b"Xeno"), word(b"uest"), word(b"ra g")],
|
||||
1 => [0, 0, 1 << 23, 1 << 15],
|
||||
0x8000_0000 => [0x8000_0001, 0, 0, 0],
|
||||
0x8000_0001 => [0, 0, 1 << 5, 1 << 29],
|
||||
0x8000_0001 => [0, 0, 1 | 1 << 5, 1 << 29],
|
||||
_ => [0; 4],
|
||||
};
|
||||
// EAX, EBX, ECX and EDX, each zero-extended.
|
||||
|
||||
@@ -95,6 +95,10 @@ syscall = { terminator = true, ref = "sdm SYSCALL" }
|
||||
clc = { writes = "cf", ref = "sdm CLC" }
|
||||
stc = { writes = "cf", ref = "sdm STC" }
|
||||
cmc = { reads = "cf", writes = "cf", ref = "sdm CMC" }
|
||||
# AH holds SF, ZF, AF, PF and CF; valid in 64-bit mode when CPUID
|
||||
# 8000_0001h ECX bit 0 is set.
|
||||
lahf = { reads = "cf zf sf pf af", ref = "sdm LAHF" }
|
||||
sahf = { writes = "cf zf sf pf af", ref = "sdm SAHF" }
|
||||
cpuid = { ref = "sdm CPUID" }
|
||||
cld = { ref = "sdm CLD" }
|
||||
std = { ref = "sdm STD" }
|
||||
@@ -510,6 +514,18 @@ opcode = 0x99
|
||||
enc = "none"
|
||||
size = "v"
|
||||
|
||||
[[form]]
|
||||
op = "sahf"
|
||||
opcode = 0x9E
|
||||
enc = "none"
|
||||
size = "n"
|
||||
|
||||
[[form]]
|
||||
op = "lahf"
|
||||
opcode = 0x9F
|
||||
enc = "none"
|
||||
size = "n"
|
||||
|
||||
[[form]]
|
||||
op = "mov"
|
||||
opcode = 0xB0
|
||||
|
||||
+76
-27
@@ -1,4 +1,4 @@
|
||||
use std::collections::BTreeMap;
|
||||
use std::collections::{BTreeMap, VecDeque};
|
||||
use std::ffi::c_void;
|
||||
use std::fmt;
|
||||
use std::mem::size_of_val;
|
||||
@@ -37,6 +37,16 @@ const MAX_GROUPS: usize = 64;
|
||||
const MAX_GRID_WORDS: usize = MAX_GROUPS * MAX_THREADS_PER_GROUP;
|
||||
const MAX_SOURCE_BYTES: usize = 64 * 1024;
|
||||
const MAX_IN_FLIGHT: usize = 16;
|
||||
const MAX_CACHED_PIPELINES: usize = 16;
|
||||
|
||||
type ComputePipeline = Retained<ProtocolObject<dyn MTLComputePipelineState>>;
|
||||
|
||||
struct CachedPipeline {
|
||||
source: Box<str>,
|
||||
entry: Box<str>,
|
||||
shader_validation: bool,
|
||||
pipeline: ComputePipeline,
|
||||
}
|
||||
|
||||
const BC_READBACK: &str = r"
|
||||
#include <metal_stdlib>
|
||||
@@ -148,7 +158,9 @@ impl std::error::Error for MetalError {}
|
||||
/// measure a single submission and are not a benchmark distribution.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct RunProfile {
|
||||
/// Host library compilation time, or zero when reusing a compute pipeline.
|
||||
pub library_seconds: f64,
|
||||
/// Host pipeline creation time, or zero when reusing a compute pipeline.
|
||||
pub pipeline_seconds: f64,
|
||||
pub gpu_seconds: f64,
|
||||
/// Host wall time from the start of setup until wait observes completion.
|
||||
@@ -171,6 +183,8 @@ pub struct NativeCompute {
|
||||
device: Retained<ProtocolObject<dyn MTLDevice>>,
|
||||
queue: Retained<ProtocolObject<dyn MTLCommandQueue>>,
|
||||
submissions: Mutex<SubmissionTable>,
|
||||
// Least recently used first. In-flight submissions retain their own reference.
|
||||
compute_pipelines: Mutex<VecDeque<CachedPipeline>>,
|
||||
}
|
||||
|
||||
/// A submitted dispatch whose result can be collected by its issuing context.
|
||||
@@ -247,7 +261,7 @@ struct SubmissionEntry {
|
||||
/// Metal reports Completed or Error.
|
||||
struct InFlightResources {
|
||||
command: Retained<ProtocolObject<dyn MTLCommandBuffer>>,
|
||||
_pipeline: Retained<ProtocolObject<dyn MTLComputePipelineState>>,
|
||||
_pipeline: ComputePipeline,
|
||||
_input: Option<Retained<ProtocolObject<dyn MTLBuffer>>>,
|
||||
output: Retained<ProtocolObject<dyn MTLBuffer>>,
|
||||
_texture: Option<Retained<ProtocolObject<dyn MTLTexture>>>,
|
||||
@@ -348,6 +362,7 @@ impl NativeCompute {
|
||||
device,
|
||||
queue,
|
||||
submissions: Mutex::default(),
|
||||
compute_pipelines: Mutex::default(),
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -901,7 +916,7 @@ kernel void sample_rgba8(texture2d<float, access::sample> tex [[texture(0)]],
|
||||
self.run_profiled_words(source, entry, input, Some(width))
|
||||
}
|
||||
|
||||
/// Compile the kernel and report the smaller of the device and pipeline width limits.
|
||||
/// Find or compile the kernel and report the smaller of the device and pipeline width limits.
|
||||
///
|
||||
/// Input size and threadgroup count are checked separately at dispatch.
|
||||
///
|
||||
@@ -911,11 +926,7 @@ kernel void sample_rgba8(texture2d<float, access::sample> tex [[texture(0)]],
|
||||
pub fn max_group_width(&self, source: &str, entry: &str) -> Result<usize, MetalError> {
|
||||
validate_source(source, &[entry])?;
|
||||
autoreleasepool(|_| {
|
||||
let options = compile_options()?;
|
||||
let library = self.compile_library(source, &options)?;
|
||||
let function = find_function(&library, entry)?;
|
||||
let pipeline = self.compute_pipeline(&function)?;
|
||||
verify_shader_validation(&pipeline)?;
|
||||
let (pipeline, _, _) = self.prepare_compute_pipeline(source, entry)?;
|
||||
Ok(self.pipeline_group_width_limit(&pipeline))
|
||||
})
|
||||
}
|
||||
@@ -963,15 +974,8 @@ kernel void sample_rgba8(texture2d<float, access::sample> tex [[texture(0)]],
|
||||
host_start: Instant,
|
||||
) -> Result<Submission<'_>, MetalError> {
|
||||
self.submissions().check_capacity()?;
|
||||
let options = compile_options()?;
|
||||
let library_start = Instant::now();
|
||||
let library = self.compile_library(source, &options)?;
|
||||
let library_seconds = library_start.elapsed().as_secs_f64();
|
||||
let function = find_function(&library, entry)?;
|
||||
let pipeline_start = Instant::now();
|
||||
let pipeline = self.compute_pipeline(&function)?;
|
||||
let pipeline_seconds = pipeline_start.elapsed().as_secs_f64();
|
||||
verify_shader_validation(&pipeline)?;
|
||||
let (pipeline, library_seconds, pipeline_seconds) =
|
||||
self.prepare_compute_pipeline(source, entry)?;
|
||||
|
||||
let limit = self.pipeline_group_width_limit(&pipeline);
|
||||
let width = match group_width {
|
||||
@@ -1108,18 +1112,67 @@ kernel void sample_rgba8(texture2d<float, access::sample> tex [[texture(0)]],
|
||||
})
|
||||
}
|
||||
|
||||
fn compute_pipeline(
|
||||
fn prepare_compute_pipeline(
|
||||
&self,
|
||||
function: &ProtocolObject<dyn MTLFunction>,
|
||||
) -> Result<Retained<ProtocolObject<dyn MTLComputePipelineState>>, MetalError> {
|
||||
self.device
|
||||
.newComputePipelineStateWithFunction_error(function)
|
||||
source: &str,
|
||||
entry: &str,
|
||||
) -> Result<(ComputePipeline, f64, f64), MetalError> {
|
||||
let shader_validation = std::env::var("MTL_SHADER_VALIDATION").as_deref() == Ok("1");
|
||||
// Device identity is fixed by this context. All misses use the same
|
||||
// compile options (safe math, precise functions, default language,
|
||||
// no macros) and unspecialized functions. Any configurable options
|
||||
// must become part of the key before they are used here.
|
||||
let mut cache = self
|
||||
.compute_pipelines
|
||||
.lock()
|
||||
.unwrap_or_else(PoisonError::into_inner);
|
||||
if let Some(index) = cache.iter().position(|cached| {
|
||||
cached.source.as_ref() == source
|
||||
&& cached.entry.as_ref() == entry
|
||||
&& cached.shader_validation == shader_validation
|
||||
}) {
|
||||
let cached = cache.remove(index).expect("position in the locked cache");
|
||||
let pipeline = cached.pipeline.clone();
|
||||
cache.push_back(cached);
|
||||
return Ok((pipeline, 0.0, 0.0));
|
||||
}
|
||||
|
||||
// Serialize cache misses in this context so concurrent requests for
|
||||
// one key share the same build. The submission table is unlocked here.
|
||||
let options = compile_options()?;
|
||||
let library_start = Instant::now();
|
||||
let library = self.compile_library(source, &options)?;
|
||||
let library_seconds = library_start.elapsed().as_secs_f64();
|
||||
let function = find_function(&library, entry)?;
|
||||
let pipeline_start = Instant::now();
|
||||
let pipeline = self
|
||||
.device
|
||||
.newComputePipelineStateWithFunction_error(&function)
|
||||
.map_err(|error| {
|
||||
MetalError::new(
|
||||
"newComputePipelineStateWithFunction",
|
||||
error.localizedDescription().to_string(),
|
||||
)
|
||||
})
|
||||
})?;
|
||||
let pipeline_seconds = pipeline_start.elapsed().as_secs_f64();
|
||||
if shader_validation {
|
||||
verify_shader_validation(&pipeline)?;
|
||||
}
|
||||
|
||||
// Bound owned key text to 1 MiB. A valid oversized key can run
|
||||
// uncached, so this budget does not alter source or entry validation.
|
||||
if entry.len() <= MAX_SOURCE_BYTES.saturating_sub(source.len()) {
|
||||
if cache.len() == MAX_CACHED_PIPELINES {
|
||||
cache.pop_front();
|
||||
}
|
||||
cache.push_back(CachedPipeline {
|
||||
source: source.into(),
|
||||
entry: entry.into(),
|
||||
shader_validation,
|
||||
pipeline: pipeline.clone(),
|
||||
});
|
||||
}
|
||||
Ok((pipeline, library_seconds, pipeline_seconds))
|
||||
}
|
||||
|
||||
fn pipeline_group_width_limit(
|
||||
@@ -1232,10 +1285,6 @@ fn check_command_status(
|
||||
fn verify_shader_validation(
|
||||
pipeline: &ProtocolObject<dyn MTLComputePipelineState>,
|
||||
) -> Result<(), MetalError> {
|
||||
if std::env::var("MTL_SHADER_VALIDATION").as_deref() != Ok("1") {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
if !pipeline.respondsToSelector(sel!(shaderValidation)) {
|
||||
return Err(MetalError::new(
|
||||
"shaderValidation",
|
||||
|
||||
@@ -356,6 +356,131 @@ fn multiple_submissions() {
|
||||
assert_eq!(second, [5, 5, 1, 5]);
|
||||
}
|
||||
|
||||
fn pipeline_was_reused(profile: &xenora_metal::RunProfile) -> bool {
|
||||
profile.library_seconds == 0.0 && profile.pipeline_seconds == 0.0
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn compute_pipeline_cache_distinguishes_source_entry_and_context() {
|
||||
let context = context();
|
||||
let source = fixture("output[id] = input[id] + 1u;");
|
||||
let second_entry =
|
||||
fixture("output[id] = input[id] * 2u;").replace("void fixture(", "void other(");
|
||||
let source = format!("{source}\n{second_entry}");
|
||||
let changed = source.replace("input[id] + 1u", "input[id] - 1u");
|
||||
let input = [0, 11, u32::MAX];
|
||||
|
||||
for (msl, entry, expected) in [
|
||||
(source.as_str(), "fixture", [1, 12, 0]),
|
||||
(source.as_str(), "other", [0, 22, u32::MAX - 1]),
|
||||
(changed.as_str(), "fixture", [u32::MAX, 10, u32::MAX - 1]),
|
||||
] {
|
||||
let cold = native(context.run_words_profiled(msl, entry, &input));
|
||||
let warm = native(context.run_words_profiled(msl, entry, &input));
|
||||
assert!(!pipeline_was_reused(&cold), "{entry}");
|
||||
assert!(pipeline_was_reused(&warm), "{entry}");
|
||||
assert_eq!(cold.output, expected, "{entry}");
|
||||
assert_eq!(warm.output, expected, "{entry}");
|
||||
}
|
||||
let separate = native(NativeCompute::new());
|
||||
let fresh = native(separate.run_words_profiled(&source, "fixture", &input));
|
||||
assert!(!pipeline_was_reused(&fresh));
|
||||
assert_eq!(fresh.output, [1, 12, 0]);
|
||||
|
||||
for _ in 0..2 {
|
||||
for (msl, entry, operation) in [
|
||||
(source.as_str(), "missing", "newFunctionWithName"),
|
||||
("not valid MSL", "fixture", "newLibraryWithSource"),
|
||||
] {
|
||||
let error = context
|
||||
.run_words_profiled(msl, entry, &input)
|
||||
.expect_err("invalid pipeline must still fail after warming the cache");
|
||||
assert_eq!(error.operation, operation);
|
||||
}
|
||||
}
|
||||
let error = context
|
||||
.run_words_with_group_width(&source, "fixture", &input, 0)
|
||||
.expect_err("cached pipeline must still check dispatch width");
|
||||
assert_eq!(error.operation, "threadgroup width");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn compute_pipeline_cache_bounds_key_bytes_without_rejecting_maximum_source() {
|
||||
const SOURCE_LIMIT: usize = 64 * 1024;
|
||||
let context = context();
|
||||
let mut source = fixture("output[id] = input[id] ^ 1u;");
|
||||
source.push_str("\n// ");
|
||||
source.push_str(&" ".repeat(SOURCE_LIMIT - source.len()));
|
||||
|
||||
for _ in 0..2 {
|
||||
let profile = native(context.run_words_profiled(&source, "fixture", &[8]));
|
||||
assert_eq!(profile.output, [9]);
|
||||
assert!(!pipeline_was_reused(&profile));
|
||||
}
|
||||
source.push(' ');
|
||||
let error = context
|
||||
.run_words_profiled(&source, "fixture", &[8])
|
||||
.expect_err("source above 64 KiB must fail before pipeline lookup");
|
||||
assert_eq!(error.operation, "source bounds");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn compute_pipeline_cache_evicts_oldest_unused_key_and_keeps_pending_work_alive() {
|
||||
let context = context();
|
||||
// Seventeen entries in one source fit in Metal's input limit and exceed
|
||||
// Xenora's 16-pipeline cache. Each kernel writes a distinct result.
|
||||
let source: String = (0..=16)
|
||||
.map(|id| {
|
||||
fixture(&format!("output[id] = input[id] + {id}u;"))
|
||||
.replace("void fixture(", &format!("void entry{id}("))
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
.join("\n");
|
||||
native(context.max_group_width(&source, "entry0"));
|
||||
let (pending, gate) = native(context.submit_words_gated(&source, "entry1", &[7]));
|
||||
for id in 2..16 {
|
||||
native(context.max_group_width(&source, &format!("entry{id}")));
|
||||
}
|
||||
native(context.max_group_width(&source, "entry0"));
|
||||
native(context.max_group_width(&source, "entry16"));
|
||||
gate.open();
|
||||
let finished = native(context.wait(pending));
|
||||
assert_eq!(finished.output, [8]);
|
||||
|
||||
let recent = native(context.run_words_profiled(&source, "entry0", &[29]));
|
||||
assert!(pipeline_was_reused(&recent));
|
||||
assert_eq!(recent.output, [29]);
|
||||
let rebuilt = native(context.run_words_profiled(&source, "entry1", &[17]));
|
||||
assert!(!pipeline_was_reused(&rebuilt));
|
||||
assert_eq!(rebuilt.output, [18]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn simultaneous_compute_submissions_share_one_pipeline_build() {
|
||||
let context = context();
|
||||
let source = fixture("output[id] = input[id] ^ 5u;");
|
||||
let start = std::sync::Barrier::new(4);
|
||||
std::thread::scope(|scope| {
|
||||
let workers: Vec<_> = (0..4)
|
||||
.map(|input| {
|
||||
let (context, source, start) = (&context, &source, &start);
|
||||
scope.spawn(move || {
|
||||
start.wait();
|
||||
let token = native(context.submit_words(source, "fixture", &[input]));
|
||||
let result = native(context.wait(token));
|
||||
assert_eq!(result.output, [input ^ 5]);
|
||||
usize::from(!pipeline_was_reused(&result))
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
let builds: usize = workers
|
||||
.into_iter()
|
||||
.map(|worker| worker.join().unwrap())
|
||||
.sum();
|
||||
assert_eq!(builds, 1);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn errors_propagate() {
|
||||
let context = context();
|
||||
@@ -413,3 +538,52 @@ kernel void fixture(device const uint *input [[buffer(0)]],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "manual GPU timing run"]
|
||||
fn compute_pipeline_reuse_benchmark() {
|
||||
const WARMUPS: usize = 10;
|
||||
const SAMPLES: usize = 101;
|
||||
let warm_context = context();
|
||||
let device = warm_context.device_name();
|
||||
let source = fixture("output[id] = input[id] * 7u + 3u;");
|
||||
let input = mixing_input(131);
|
||||
let expected: Vec<_> = input
|
||||
.iter()
|
||||
.map(|word| word.wrapping_mul(7).wrapping_add(3))
|
||||
.collect();
|
||||
let mut timings = [[[0.0; SAMPLES]; 4]; 2];
|
||||
|
||||
for round in 0..WARMUPS + SAMPLES {
|
||||
let cold_context = context();
|
||||
// Alternate order so neither measurement always follows the other.
|
||||
let contexts = [&cold_context, &warm_context];
|
||||
for index in [round % 2, (round + 1) % 2] {
|
||||
let profile = native(contexts[index].run_words_profiled(&source, "fixture", &input));
|
||||
assert_eq!(profile.output, expected, "context={index} round={round}");
|
||||
if round >= WARMUPS {
|
||||
for (samples, seconds) in timings[index].iter_mut().zip([
|
||||
profile.library_seconds,
|
||||
profile.pipeline_seconds,
|
||||
profile.host_seconds,
|
||||
profile.gpu_seconds,
|
||||
]) {
|
||||
samples[round - WARMUPS] = seconds;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (label, [mut library, mut pipeline, mut host, mut gpu]) in
|
||||
["fresh context", "repeated context"]
|
||||
.into_iter()
|
||||
.zip(timings)
|
||||
{
|
||||
println!(
|
||||
"device={device} {label} samples={SAMPLES} library_us[{}] pipeline_us[{}] host_us[{}] gpu_us[{}]",
|
||||
timing_summary(&mut library),
|
||||
timing_summary(&mut pipeline),
|
||||
timing_summary(&mut host),
|
||||
timing_summary(&mut gpu),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -89,12 +89,12 @@ CPUID (`0F A2`) returns a fixed table that never reads the host. It describes a
|
||||
| 0 | 1, the highest basic leaf | `Xeno` | `uest` | `ra g` |
|
||||
| 1 | 0 | 0 | POPCNT (bit 23) | CMOV (bit 15) |
|
||||
| 0x8000_0000 | 0x8000_0001, the highest extended leaf | 0 | 0 | 0 |
|
||||
| 0x8000_0001 | 0 | 0 | LZCNT (bit 5) | long mode (bit 29) |
|
||||
| 0x8000_0001 | 0 | 0 | LAHF/SAHF (bit 0), LZCNT (bit 5) | long mode (bit 29) |
|
||||
| any other | 0 | 0 | 0 | 0 |
|
||||
|
||||
A feature bit is set only when every instruction of that feature is implemented. That is stricter than "some of it works", and it has consequences:
|
||||
|
||||
- SSE and SSE2 are not reported, although most of their instructions exist, because parts are still rejected: RSQRTPS and MASKMOVDQU, for example. BMI1 is not reported although TZCNT exists, because ANDN does not. The x87 FPU, MMX, FXSAVE, CMPXCHG8B, the time-stamp counter, LAHF and SYSRET are absent too.
|
||||
- SSE and SSE2 are not reported, although most of their instructions exist, because parts are still rejected: RSQRTPS and MASKMOVDQU, for example. BMI1 is not reported although TZCNT exists, because ANDN does not. The x87 FPU, MMX, FXSAVE, CMPXCHG8B, the time-stamp counter and SYSRET are absent too.
|
||||
- The table is therefore truthful about Xenora, not plausible as hardware: every real 64-bit processor reports the FPU and SSE2. A guest that tests a bit before using a feature avoids it; a guest that assumes SSE2 because it runs in 64-bit mode still gets every form that exists and an illegal-instruction exit for one that does not.
|
||||
- A leaf that is not listed returns zeros, whatever the subleaf. Intel processors answer a leaf above the highest basic one with that leaf's data instead; software is expected to read the highest leaf first.
|
||||
|
||||
|
||||
@@ -13,6 +13,43 @@ export CARGO_BUILD_JOBS=${CARGO_BUILD_JOBS:-4}
|
||||
# allow slower hosts to raise it without editing the script.
|
||||
export XENORA_SEMANTIC_TIMEOUT=${XENORA_SEMANTIC_TIMEOUT:-300s}
|
||||
|
||||
# macOS does not ship GNU timeout. Python 3 is already a project requirement,
|
||||
# so use a small POSIX-compatible fallback rather than making coreutils a
|
||||
# prerequisite for the native suite.
|
||||
if ! command -v timeout >/dev/null 2>&1; then
|
||||
timeout() {
|
||||
duration=$1
|
||||
shift
|
||||
python3 - "$duration" "$@" <<'PY'
|
||||
import os
|
||||
import re
|
||||
import signal
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
text = sys.argv[1]
|
||||
match = re.fullmatch(r"(\d+(?:\.\d+)?)([smh]?)", text)
|
||||
if match is None:
|
||||
print(f"timeout: invalid duration {text!r}", file=sys.stderr)
|
||||
raise SystemExit(2)
|
||||
seconds = float(match.group(1)) * {"": 1, "s": 1, "m": 60, "h": 3600}[match.group(2)]
|
||||
try:
|
||||
process = subprocess.Popen(sys.argv[2:], start_new_session=True)
|
||||
except FileNotFoundError as error:
|
||||
print(f"timeout: {error}", file=sys.stderr)
|
||||
raise SystemExit(127)
|
||||
try:
|
||||
code = process.wait(timeout=seconds)
|
||||
except subprocess.TimeoutExpired:
|
||||
os.killpg(process.pid, signal.SIGKILL)
|
||||
process.wait()
|
||||
print(f"timeout: command exceeded {seconds:g} seconds", file=sys.stderr)
|
||||
raise SystemExit(124)
|
||||
raise SystemExit(code)
|
||||
PY
|
||||
}
|
||||
fi
|
||||
|
||||
cargo test --locked -p xenora-metal --features gpu-tests --test native_compute --no-run
|
||||
timeout 30s cargo test --locked -p xenora-metal --features gpu-tests --test native_compute -- \
|
||||
--nocapture --test-threads=1
|
||||
|
||||
Reference in new issue
Block a user