Compare commits

..
Author SHA1 Message Date
maridogolpeador 67023d292b loader: add SHLD and SHRD, the double-precision shifts (#121)
Both engines refused SHLD and SHRD (0F A4/A5, 0F AC/AD) as illegal
instructions. They are now declared in the x86 registry and run on the
shared semantics for 16-, 32- and 64-bit register and memory
destinations, with the count in an 8-bit immediate or in CL.

- instructions.toml, x86_table.rs (generated), generate_x86.py,
  x86_decode.rs: the two operations and two operand encodings,
  rm_reg_imm and rm_reg_cl (ModRM destination, reg source, count).
- x86_exec.rs: the destination is shifted with the vacated bits filled
  from the source register. The count is masked to five bits (six for
  64-bit operands), a masked count of zero changes nothing, CF takes the
  last bit shifted out, ZF/SF/PF follow the result and OF is set only
  for a count of one. A 16-bit count above 16 is undefined in the SDM;
  the flags are kept and no test relies on the result.
- cpu_known_answers.rs: eight SDM-derived cases move from refused to
  verified.
- tests/x86: 72 assembled SHLD and SHRD instructions, with a
  bit-at-a-time reference in x86_integer.rs. A destination the
  reference marks undefined now skips the memory operand check too.
- docs/cpu/instruction-registry.md, CHANGELOG.md.

Nothing is lowered to ARM64.

Signed-off-by: maridogolpeador <354308468+maridogolpeador@users.noreply.github.com>
2026-11-24 20:47:45 -03:00
12 changed files with 400 additions and 929 deletions

No files matched your search

+1 -1
View File
@@ -29,7 +29,6 @@ remains unsupported.
- 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
- `dbt_bench` can compare two of its JSON documents when `XENORA_DBT_BENCH_COMPARE=<baseline.json>,<candidate.json>` is set (#114). It prints each median with its change and whether the change exceeds the larger recorded IQR, and lists changed DBT counters. It refuses, with exit status 1 and the differing field named, to compare runs from different CPUs, operating systems or architectures, with unknown host fields, or with different workloads, sample counts, debug assertions or build labels. A new optional `XENORA_DBT_BENCH_BUILD_LABEL` records build settings the benchmark cannot see, such as LTO. No benchmark runs in this mode.
- `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).
@@ -44,6 +43,7 @@ remains unsupported.
- Added MOVNTI, the SSE2 non-temporal store of a 32- or 64-bit general register to memory (part of #125). Both engines used to stop on it with an illegal-instruction exit. It is an ordinary store, as the other non-temporal stores already are; the register form and the 66 prefix stay rejected, and a destination that cannot be written faults without changing state. The SDM-derived case `movdqa_movaps_aligned_store_and_load` in `cpu_known_answers.rs`, which ends in a MOVNTI, moved from refused to verified, and `tests/x86/integer.txt` gains four assembled instructions checked by the text-only reference in `x86_integer.rs`. MASKMOVDQU stays rejected and SSE2 stays unreported by CPUID. Not compared with x86 hardware; awaiting independent review.
- Added MFENCE, LFENCE and SFENCE and documented the ordering of guest memory accesses (part of #199). Both engines used to stop on a fence with an illegal-instruction exit. Each engine runs one guest instruction at a time on one host thread and completes its loads and stores before the next, so accesses are already totally ordered and the fences change nothing; `docs/cpu/instruction-registry.md` states this and that it holds only while guest threads do not run on several host threads. Five single-thread cases in `cpu_known_answers.rs` and three assembled fixtures cover them, and the memory forms that share the opcode stay rejected. SSE2 is still not reported by CPUID because other SSE2 instructions are rejected; the refused SSE2 instruction that `cpu_features.rs` holds is now MASKMOVDQU. No multi-thread behaviour is established, and nothing was compared with x86 hardware; awaiting independent review.
- Added the accumulator short form of XCHG, opcodes 91 to 97 and 90 with REX.B, at 16, 32 and 64 bits (part of #118). Assemblers choose this form whenever one operand is the accumulator, and both engines used to stop on it with an illegal-instruction exit. A 16-bit exchange keeps the upper 48 bits of both registers, a 32-bit one clears both upper halves, and `49 90` exchanges RAX with R8 while plain `90` stays NOP. Both engines run the shared semantics; nothing is lowered to ARM64. Three SDM-derived cases already in `cpu_known_answers.rs` moved from refused to verified, and `tests/x86/integer.txt` gains 20 assembled instructions checked by the text-only reference in `x86_integer.rs`. F3 before this form, 16-bit PUSH and POP and LODSW stay rejected. Not compared with x86 hardware; awaiting independent review.
- Added SHLD and SHRD, the double-precision shifts (`0F A4`/`0F A5` and `0F AC`/`0F AD`), for 16-, 32- and 64-bit register and memory destinations with the count in an 8-bit immediate or in CL (part of #121). The count is masked to five bits (six for 64-bit operands); a masked count of zero changes nothing, the vacated bits are filled from the source register, CF receives the last bit shifted out of the destination, ZF, SF and PF follow the result, OF is set only for a count of one (a sign change) and AF is undefined. A 16-bit count above 16 leaves the result and flags undefined in the Intel SDM; Xenora keeps every flag and writes the bits of the 32-bit concatenation, and no test relies on that. The registry gained the operand encodings `rm_reg_imm` and `rm_reg_cl`. Both engines run the shared semantics; nothing is lowered to ARM64. Eight SDM-derived cases already in `cpu_known_answers.rs` moved from refused to verified, and `tests/x86/integer.txt` gains 72 assembled SHLD and SHRD instructions, checked by a bit-at-a-time reference in `x86_integer.rs` and by the faulting read-modify-write test. Not compared with x86 hardware; awaiting independent review.
- Added RCL and RCR, the rotates through the carry flag, for 8-, 16-, 32- and 64-bit register and memory operands with a count of one, CL or an immediate (part of #121). The count is masked to five bits (six for 64-bit operands) and then reduced modulo 9 or 17 for 8- and 16-bit operands; a masked count of zero changes nothing, CF receives the last bit rotated out, and OF is set only for a count of one. Both engines run the shared semantics; nothing is lowered to ARM64. Fourteen SDM-derived cases already in `cpu_known_answers.rs` moved from refused to verified, and its shift sweep now runs both instructions at every width, count and carry against its bit-loop model. `tests/x86/integer.txt` gains 80 assembled RCL and RCR instructions, checked by the single-step reference in `x86_integer.rs`. SHLD and SHRD stay rejected. Not compared with x86 hardware; awaiting independent review.
- Added four Wave32 gfx1030 VOP2 select and carry forms through the semantic registry. Conditional select, add with carry and both subtract orders with borrow use a per-lane VCC bit and have a guide-derived oracle that passes on both CPU interpreters and on native Metal (local Apple M5, API and shader validation); independent acceptance is pending. Part of #215.
- Added decoding and Metal shader translation for twelve Wave32 VOPC 16-bit integer compares (#215). The signed and unsigned forms compare the low 16 bits of each source and write the Wave32 VCC mask. CPU verification covers 1,572 compiler acceptance cases and 408 rejections from the guide-derived oracle, which also passes on native Metal (1,572 cases in 1,420 programs on a local Apple M5 under API and shader validation); acceptance is pending.
+3 -778
View File
@@ -5,14 +5,7 @@
//! Set `XENORA_DBT_BENCH_JSON=<path>` to also write the results as one JSON
//! document (format version 1). The text output does not change. Values the
//! benchmark cannot determine, such as the git revision outside a checkout,
//! are written as `null`. The benchmark cannot see build settings such as LTO,
//! so `XENORA_DBT_BENCH_BUILD_LABEL=<text>` records a label of your choosing
//! for them.
//!
//! Set `XENORA_DBT_BENCH_COMPARE=<baseline.json>,<candidate.json>` to compare
//! two such documents instead of running the benchmark. The comparison is
//! refused, with exit status 1, unless both runs used the same host, workload,
//! build settings and sample counts.
//! are written as `null`.
//!
//! The benchmark target disables Cargo's test harness. To run the percentile
//! unit tests, build with
@@ -161,7 +154,6 @@ struct RunInfo {
revision: Option<String>,
dirty: Option<bool>,
debug_assertions: bool,
build_label: Option<String>,
guest_code_bytes: usize,
warmup: usize,
}
@@ -195,7 +187,6 @@ fn run_info(guest_code_bytes: usize, warmup: usize) -> RunInfo {
dirty: command_output("git", &["status", "--porcelain", "--untracked-files=no"])
.map(|status| !status.is_empty()),
debug_assertions: cfg!(debug_assertions),
build_label: non_empty(std::env::var("XENORA_DBT_BENCH_BUILD_LABEL").ok()),
guest_code_bytes,
warmup,
}
@@ -283,10 +274,7 @@ fn json_document(
),
(
"build",
json_object(&[
("debug_assertions", info.debug_assertions.to_string()),
("label", json_option(info.build_label.as_ref(), string)),
]),
json_object(&[("debug_assertions", info.debug_assertions.to_string())]),
),
(
"workload",
@@ -331,471 +319,7 @@ fn json_document(
])
}
/// A parsed JSON value. Numbers keep their source text, so integers compare exactly.
#[derive(Clone, Debug, PartialEq)]
enum Json {
Null,
Bool(bool),
Number(String),
String(String),
Array(Vec<Json>),
Object(Vec<(String, Json)>),
}
impl Json {
/// The value at a dotted path such as `host.cpu`, if every step is an object key.
fn get(&self, path: &str) -> Option<&Json> {
path.split('.').try_fold(self, |value, key| match value {
Json::Object(fields) => fields.iter().find(|(k, _)| k == key).map(|(_, v)| v),
_ => None,
})
}
}
const MAX_JSON_DEPTH: usize = 32;
/// Reads one JSON document (RFC 8259) and rejects anything after it.
fn parse_json(text: &str) -> Result<Json, String> {
let mut reader = JsonReader {
bytes: text.as_bytes(),
pos: 0,
};
let value = reader.value(0)?;
reader.skip_whitespace();
if reader.pos != reader.bytes.len() {
return reader.error("unexpected data after the document");
}
Ok(value)
}
struct JsonReader<'a> {
bytes: &'a [u8],
pos: usize,
}
impl JsonReader<'_> {
fn error<T>(&self, what: &str) -> Result<T, String> {
Err(format!("{what} at byte {}", self.pos))
}
fn peek(&self) -> Option<u8> {
self.bytes.get(self.pos).copied()
}
fn skip_whitespace(&mut self) {
while matches!(self.peek(), Some(b' ' | b'\t' | b'\n' | b'\r')) {
self.pos += 1;
}
}
fn expect(&mut self, byte: u8) -> Result<(), String> {
if self.peek() == Some(byte) {
self.pos += 1;
Ok(())
} else {
self.error(&format!("expected '{}'", byte as char))
}
}
fn value(&mut self, depth: usize) -> Result<Json, String> {
if depth > MAX_JSON_DEPTH {
return self.error("nesting too deep");
}
self.skip_whitespace();
match self.peek() {
None => self.error("unexpected end of input"),
Some(b'n') => self.literal("null", Json::Null),
Some(b't') => self.literal("true", Json::Bool(true)),
Some(b'f') => self.literal("false", Json::Bool(false)),
Some(b'"') => Ok(Json::String(self.string()?)),
Some(b'[') => self.array(depth),
Some(b'{') => self.object(depth),
Some(b'-' | b'0'..=b'9') => self.number(),
Some(_) => self.error("unexpected character"),
}
}
fn literal(&mut self, word: &str, value: Json) -> Result<Json, String> {
if self.bytes[self.pos..].starts_with(word.as_bytes()) {
self.pos += word.len();
Ok(value)
} else {
self.error("invalid literal")
}
}
fn array(&mut self, depth: usize) -> Result<Json, String> {
self.expect(b'[')?;
let mut items = Vec::new();
self.skip_whitespace();
if self.peek() == Some(b']') {
self.pos += 1;
return Ok(Json::Array(items));
}
loop {
items.push(self.value(depth + 1)?);
self.skip_whitespace();
match self.peek() {
Some(b',') => self.pos += 1,
Some(b']') => {
self.pos += 1;
return Ok(Json::Array(items));
}
_ => return self.error("expected ',' or ']'"),
}
}
}
fn object(&mut self, depth: usize) -> Result<Json, String> {
self.expect(b'{')?;
let mut fields: Vec<(String, Json)> = Vec::new();
self.skip_whitespace();
if self.peek() == Some(b'}') {
self.pos += 1;
return Ok(Json::Object(fields));
}
loop {
self.skip_whitespace();
let key = self.string()?;
if fields.iter().any(|(k, _)| *k == key) {
return self.error(&format!("duplicate key `{key}`"));
}
self.skip_whitespace();
self.expect(b':')?;
let value = self.value(depth + 1)?;
fields.push((key, value));
self.skip_whitespace();
match self.peek() {
Some(b',') => self.pos += 1,
Some(b'}') => {
self.pos += 1;
return Ok(Json::Object(fields));
}
_ => return self.error("expected ',' or '}'"),
}
}
}
fn digits(&mut self) -> usize {
let start = self.pos;
while matches!(self.peek(), Some(b'0'..=b'9')) {
self.pos += 1;
}
self.pos - start
}
fn number(&mut self) -> Result<Json, String> {
let start = self.pos;
if self.peek() == Some(b'-') {
self.pos += 1;
}
match self.peek() {
Some(b'0') => self.pos += 1,
Some(b'1'..=b'9') => {
self.digits();
}
_ => return self.error("invalid number"),
}
if self.peek() == Some(b'.') {
self.pos += 1;
if self.digits() == 0 {
return self.error("invalid number");
}
}
if matches!(self.peek(), Some(b'e' | b'E')) {
self.pos += 1;
if matches!(self.peek(), Some(b'+' | b'-')) {
self.pos += 1;
}
if self.digits() == 0 {
return self.error("invalid number");
}
}
// Only ASCII digits and signs were consumed.
Ok(Json::Number(
String::from_utf8_lossy(&self.bytes[start..self.pos]).into_owned(),
))
}
fn hex4(&mut self) -> Result<u32, String> {
let digits = self.bytes.get(self.pos..self.pos + 4);
let value = digits
.and_then(|d| std::str::from_utf8(d).ok())
.and_then(|d| u32::from_str_radix(d, 16).ok());
match value {
Some(value) if digits.is_some_and(|d| d.iter().all(u8::is_ascii_hexdigit)) => {
self.pos += 4;
Ok(value)
}
_ => self.error("invalid \\u escape"),
}
}
fn unicode_escape(&mut self) -> Result<char, String> {
let first = self.hex4()?;
let code = match first {
0xD800..=0xDBFF => {
if !self.bytes[self.pos..].starts_with(b"\\u") {
return self.error("unpaired surrogate");
}
self.pos += 2;
let second = self.hex4()?;
if !(0xDC00..=0xDFFF).contains(&second) {
return self.error("unpaired surrogate");
}
0x10000 + ((first - 0xD800) << 10) + (second - 0xDC00)
}
0xDC00..=0xDFFF => return self.error("unpaired surrogate"),
code => code,
};
char::from_u32(code).map_or_else(|| self.error("invalid code point"), Ok)
}
fn string(&mut self) -> Result<String, String> {
self.expect(b'"')?;
let mut out = String::new();
loop {
// Copy the run up to the next quote, backslash or control byte. Those
// are ASCII, so the run never ends inside a multi-byte character.
let start = self.pos;
while matches!(self.peek(), Some(b) if b != b'"' && b != b'\\' && b >= 0x20) {
self.pos += 1;
}
match std::str::from_utf8(&self.bytes[start..self.pos]) {
Ok(run) => out.push_str(run),
Err(_) => return self.error("invalid UTF-8"),
}
match self.peek() {
Some(b'"') => {
self.pos += 1;
return Ok(out);
}
Some(b'\\') => {
self.pos += 1;
let escaped = self.peek();
self.pos += 1;
out.push(match escaped {
Some(b'"') => '"',
Some(b'\\') => '\\',
Some(b'/') => '/',
Some(b'b') => '\u{8}',
Some(b'f') => '\u{c}',
Some(b'n') => '\n',
Some(b'r') => '\r',
Some(b't') => '\t',
Some(b'u') => self.unicode_escape()?,
_ => {
self.pos -= 1;
return self.error("invalid escape");
}
});
}
Some(_) => return self.error("control character in string"),
None => return self.error("unterminated string"),
}
}
}
}
/// Fields that must be equal for two runs to be compared. A field listed in
/// `OPTIONAL_FIELDS` counts as `null` when a document does not have it.
const MATCHING_FIELDS: [&str; 15] = [
"format_version",
"benchmark",
"host.cpu",
"host.os",
"host.arch",
"build.debug_assertions",
"build.label",
"workload.name",
"workload.guest_instructions",
"workload.guest_code_bytes",
"workload.instruction_budget",
"workload.warmup_rounds",
"timings.interpreter.samples",
"timings.cold_dbt.samples",
"timings.warm_dbt.samples",
];
/// Older version 1 documents predate the build label.
const OPTIONAL_FIELDS: [&str; 1] = ["build.label"];
/// Host fields that must be known: two unknown CPUs are not the same CPU.
const KNOWN_FIELDS: [&str; 3] = ["host.cpu", "host.os", "host.arch"];
const SERIES: [(&str, &str); 3] = [
("interpreter", "Interpreter"),
("cold_dbt", "Cold DBT"),
("warm_dbt", "Warm DBT"),
];
const COUNTERS: [&str; 8] = [
"blocks_compiled",
"cache_hits",
"cache_misses",
"native_bytes_emitted",
"dbt_dispatches",
"instructions_executed",
"interpreter_fallbacks",
"service_calls",
];
fn field<'a>(doc: &'a Json, path: &str) -> Result<&'a Json, String> {
match doc.get(path) {
Some(value) => Ok(value),
None if OPTIONAL_FIELDS.contains(&path) => Ok(&Json::Null),
None => Err(format!("missing field `{path}`")),
}
}
fn integer(doc: &Json, path: &str) -> Result<u128, String> {
match field(doc, path)? {
Json::Number(text) => text
.parse()
.map_err(|_| format!("`{path}` is not a non-negative integer")),
_ => Err(format!("`{path}` is not a number")),
}
}
fn text(doc: &Json, path: &str) -> String {
match doc.get(path) {
Some(Json::String(value)) => value.clone(),
Some(Json::Bool(value)) => value.to_string(),
Some(Json::Number(value)) => value.clone(),
// The build label is optional, so its absence is not an unknown value.
_ if OPTIONAL_FIELDS.contains(&path) => "none".to_owned(),
_ => "unknown".to_owned(),
}
}
fn duration(ns: u128) -> Duration {
Duration::from_nanos(u64::try_from(ns).unwrap_or(u64::MAX))
}
fn change(before: u128, after: u128) -> String {
if before == 0 {
return "n/a".to_owned();
}
format!(
"{:+.2}%",
(after as f64 - before as f64) / before as f64 * 100.0
)
}
fn source(doc: &Json) -> String {
let dirty = match doc.get("source.dirty") {
Some(Json::Bool(true)) => " with local changes",
Some(Json::Bool(false)) => "",
_ => ", local changes unknown",
};
format!("{}{dirty}", text(doc, "source.revision"))
}
/// Compares two exported documents. Returns the report lines, or why the runs
/// cannot be compared.
fn compare_documents(baseline: &Json, candidate: &Json) -> Result<Vec<String>, String> {
for doc in [baseline, candidate] {
if field(doc, "format_version")? != &Json::Number("1".to_owned()) {
return Err("only format version 1 is supported".to_owned());
}
}
for path in KNOWN_FIELDS {
for (name, doc) in [("baseline", baseline), ("candidate", candidate)] {
if field(doc, path)? == &Json::Null {
return Err(format!(
"`{path}` is unknown in the {name}, so the hosts cannot be shown to match"
));
}
}
}
for path in MATCHING_FIELDS {
if field(baseline, path)? != field(candidate, path)? {
return Err(format!(
"`{path}` differs: baseline {}, candidate {}",
text(baseline, path),
text(candidate, path)
));
}
}
let mut lines = vec![
format!("Baseline: {}", source(baseline)),
format!("Candidate: {}", source(candidate)),
format!(
"Host: {}, {} {}; debug assertions {}; build label {}",
text(baseline, "host.cpu"),
text(baseline, "host.os"),
text(baseline, "host.arch"),
text(baseline, "build.debug_assertions"),
text(baseline, "build.label"),
),
];
if field(baseline, "host.os_version")? != field(candidate, "host.os_version")? {
lines.push(format!(
"Note: OS version differs: baseline {}, candidate {}",
text(baseline, "host.os_version"),
text(candidate, "host.os_version")
));
}
for (key, label) in SERIES {
let path = |stat: &str| format!("timings.{key}.{stat}");
let before = integer(baseline, &path("median_ns"))?;
let after = integer(candidate, &path("median_ns"))?;
let spread = integer(baseline, &path("iqr_ns"))?.max(integer(candidate, &path("iqr_ns"))?);
let verdict = if before.abs_diff(after) > spread {
"larger than"
} else {
"within"
};
lines.push(format!(
"{label}: median {:?} -> {:?} ({}), {verdict} the larger IQR {:?}",
duration(before),
duration(after),
change(before, after),
duration(spread)
));
}
let mut counters_changed = false;
for counter in COUNTERS {
let path = format!("cold_dbt_metrics.{counter}");
let (before, after) = (integer(baseline, &path)?, integer(candidate, &path)?);
if before != after {
counters_changed = true;
lines.push(format!(
"Cold DBT {counter}: {before} -> {after} ({})",
change(before, after)
));
}
}
if !counters_changed {
lines.push("Cold DBT counters are identical".to_owned());
}
Ok(lines)
}
fn compare_files(spec: &str) -> Result<Vec<String>, String> {
let (baseline, candidate) = spec
.split_once(',')
.ok_or("expected <baseline.json>,<candidate.json>")?;
let read = |path: &str| {
let text = std::fs::read_to_string(path).map_err(|e| format!("{path}: {e}"))?;
parse_json(&text).map_err(|e| format!("{path}: {e}"))
};
compare_documents(&read(baseline)?, &read(candidate)?)
}
fn main() {
if let Ok(spec) = std::env::var("XENORA_DBT_BENCH_COMPARE") {
match compare_files(&spec) {
Ok(lines) => lines.iter().for_each(|line| println!("{line}")),
Err(reason) => {
eprintln!("dbt_bench: cannot compare: {reason}");
std::process::exit(1);
}
}
return;
}
let sample_count = std::env::var("XENORA_DBT_BENCH_SAMPLES")
.map_or(101, |value| value.parse::<usize>().expect("sample count"));
assert!(sample_count > 0);
@@ -970,7 +494,6 @@ mod tests {
revision: Some("0123abcd".to_owned()),
dirty: Some(false),
debug_assertions: false,
build_label: Some("fat-lto".to_owned()),
guest_code_bytes: 40_011,
warmup: 10,
}
@@ -1005,7 +528,7 @@ mod tests {
r#"{{"format_version":1,"benchmark":"dbt_bench","unix_time":1700000000,"#,
r#""host":{{"cpu":"Test \"CPU\"\\1","os":"macos","os_version":null,"arch":"aarch64"}},"#,
r#""source":{{"revision":"0123abcd","dirty":false}},"#,
r#""build":{{"debug_assertions":false,"label":"fat-lto"}},"#,
r#""build":{{"debug_assertions":false}},"#,
r#""workload":{{"name":"add_rax_chain","guest_instructions":{},"guest_code_bytes":40011,"instruction_budget":20000,"warmup_rounds":10}},"#,
r#""timings":{{"interpreter":{},"cold_dbt":{},"warm_dbt":{}}},"#,
r#""cold_dbt_metrics":{{"blocks_compiled":626,"cache_hits":0,"cache_misses":626,"native_bytes_emitted":245168,"dbt_dispatches":626,"instructions_executed":10002,"interpreter_fallbacks":1,"service_calls":0}}}}"#,
@@ -1057,302 +580,4 @@ mod tests {
assert_eq!(s.iqr, Duration::from_micros(30));
assert_eq!(s.mips, INSTRUCTIONS as f64 / 25e-6 / 1e6);
}
// `cargo bench` builds this target with `--cfg test` but without `--test`,
// so this module is compiled with its #[test] functions removed and shared
// helpers look unused there.
#[allow(dead_code)]
fn comparable_document() -> super::Json {
super::parse_json(concat!(
r#"{"format_version":1,"benchmark":"dbt_bench","unix_time":1,"#,
r#""host":{"cpu":"Apple M5","os":"macos","os_version":"27.2.1","arch":"aarch64"},"#,
r#""source":{"revision":"aaaa","dirty":false},"#,
r#""build":{"debug_assertions":false,"label":null},"#,
r#""workload":{"name":"add_rax_chain","guest_instructions":10002,"guest_code_bytes":40011,"instruction_budget":20000,"warmup_rounds":10},"#,
r#""timings":{"#,
r#""interpreter":{"samples":101,"median_ns":900000,"min_ns":1,"max_ns":2,"p95_ns":1,"p99_ns":1,"iqr_ns":20000,"median_mips":11.1},"#,
r#""cold_dbt":{"samples":101,"median_ns":1100000,"min_ns":1,"max_ns":2,"p95_ns":1,"p99_ns":1,"iqr_ns":40000,"median_mips":9.1},"#,
r#""warm_dbt":{"samples":101,"median_ns":22000,"min_ns":1,"max_ns":2,"p95_ns":1,"p99_ns":1,"iqr_ns":500,"median_mips":454.6}},"#,
r#""cold_dbt_metrics":{"blocks_compiled":626,"cache_hits":0,"cache_misses":626,"native_bytes_emitted":245168,"dbt_dispatches":626,"instructions_executed":10002,"interpreter_fallbacks":0,"service_calls":0}}"#,
))
.expect("fixture parses")
}
/// Replaces the value at a dotted path, which must exist except for its last key.
#[allow(dead_code)]
fn set(doc: &mut super::Json, path: &str, value: super::Json) {
let (parent, key) = path.rsplit_once('.').map_or(("", path), |(p, k)| (p, k));
let mut node = doc;
for step in parent.split('.').filter(|s| !s.is_empty()) {
let super::Json::Object(fields) = node else {
panic!("{step} is not in an object")
};
node = &mut fields.iter_mut().find(|(k, _)| k == step).expect(step).1;
}
let super::Json::Object(fields) = node else {
panic!("{path} has no parent object")
};
match fields.iter_mut().find(|(k, _)| k == key) {
Some(entry) => entry.1 = value,
None => fields.push((key.to_owned(), value)),
}
}
#[test]
fn reader_accepts_json_values() {
use super::{Json, parse_json};
let doc = parse_json(
r#" { "a" : [1, -0.5, 2e3, 3E-2, true, false, null, {}, []], "s": "q\"b\\s\/n\n\té😀 Zażółć" } "#,
)
.unwrap();
assert_eq!(
doc.get("a"),
Some(&Json::Array(vec![
Json::Number("1".to_owned()),
Json::Number("-0.5".to_owned()),
Json::Number("2e3".to_owned()),
Json::Number("3E-2".to_owned()),
Json::Bool(true),
Json::Bool(false),
Json::Null,
Json::Object(vec![]),
Json::Array(vec![]),
]))
);
assert_eq!(
doc.get("s"),
Some(&Json::String("q\"b\\s/n\n\té😀 Zażółć".to_owned()))
);
assert_eq!(doc.get("a.b"), None);
assert_eq!(doc.get("missing"), None);
}
#[test]
fn reader_rejects_malformed_json() {
use super::parse_json;
let deep = "[".repeat(40) + &"]".repeat(40);
for bad in [
"",
"{",
r#"{"a":1,}"#,
r#"{"a" 1}"#,
r#"{"a":1,"a":2}"#,
"[1 2]",
"01",
"1.",
"-",
"1e",
"+1",
"tru",
r#""open"#,
"\"tab\tinside\"",
r#""\x""#,
r#""\u12g4""#,
r#""\u+123""#,
r#""\ud83d""#,
r#""\ude00""#,
r#""\ud83dA""#,
"{} {}",
deep.as_str(),
] {
assert!(parse_json(bad).is_err(), "accepted {bad:?}");
}
}
#[test]
fn exported_document_reads_back() {
use super::{DbtMetrics, Duration, Json, RunInfo, Summary, json_document, parse_json};
let summary = Summary {
samples: 7,
median: Duration::from_nanos(1_234_567),
min: Duration::from_nanos(1),
max: Duration::from_nanos(9),
p95: Duration::from_nanos(8),
p99: Duration::from_nanos(9),
iqr: Duration::from_nanos(3),
mips: 8.25,
};
let info = RunInfo {
unix_time: None,
cpu: Some("CPU \"x\" \\ \u{1}".to_owned()),
os: "macos",
os_version: None,
arch: "aarch64",
revision: None,
dirty: Some(true),
debug_assertions: true,
build_label: Some("é label".to_owned()),
guest_code_bytes: 5,
warmup: 2,
};
let metrics = DbtMetrics {
native_bytes_emitted: 42,
..DbtMetrics::default()
};
let doc = parse_json(&json_document(
&info, &summary, &summary, &summary, &metrics,
))
.unwrap();
let string = |s: &str| Some(Json::String(s.to_owned()));
assert_eq!(doc.get("host.cpu").cloned(), string("CPU \"x\" \\ \u{1}"));
assert_eq!(doc.get("build.label").cloned(), string("é label"));
assert_eq!(doc.get("host.os_version"), Some(&Json::Null));
assert_eq!(doc.get("source.dirty"), Some(&Json::Bool(true)));
assert_eq!(
doc.get("timings.cold_dbt.median_ns"),
Some(&Json::Number("1234567".to_owned()))
);
assert_eq!(
doc.get("cold_dbt_metrics.native_bytes_emitted"),
Some(&Json::Number("42".to_owned()))
);
}
#[test]
fn comparison_reports_changes_against_the_spread() {
use super::{Json, compare_documents};
let baseline = comparable_document();
let mut candidate = comparable_document();
set(
&mut candidate,
"source.revision",
Json::String("bbbb".to_owned()),
);
set(&mut candidate, "source.dirty", Json::Bool(true));
// 900 µs -> 846 µs is 54 µs, beyond the larger IQR of 20 µs.
set(
&mut candidate,
"timings.interpreter.median_ns",
Json::Number("846000".to_owned()),
);
// 1.1 ms -> 1.12 ms is 20 µs, within the larger IQR of 45 µs.
set(
&mut candidate,
"timings.cold_dbt.median_ns",
Json::Number("1120000".to_owned()),
);
set(
&mut candidate,
"timings.cold_dbt.iqr_ns",
Json::Number("45000".to_owned()),
);
set(
&mut candidate,
"cold_dbt_metrics.native_bytes_emitted",
Json::Number("290184".to_owned()),
);
set(
&mut candidate,
"host.os_version",
Json::String("27.3".to_owned()),
);
let lines = compare_documents(&baseline, &candidate).unwrap();
assert_eq!(
lines,
[
"Baseline: aaaa",
"Candidate: bbbb with local changes",
"Host: Apple M5, macos aarch64; debug assertions false; build label none",
"Note: OS version differs: baseline 27.2.1, candidate 27.3",
"Interpreter: median 900µs -> 846µs (-6.00%), larger than the larger IQR 20µs",
"Cold DBT: median 1.1ms -> 1.12ms (+1.82%), within the larger IQR 45µs",
"Warm DBT: median 22µs -> 22µs (+0.00%), within the larger IQR 500ns",
"Cold DBT native_bytes_emitted: 245168 -> 290184 (+18.36%)",
]
);
let same = compare_documents(&baseline, &baseline).unwrap();
assert_eq!(same.last().unwrap(), "Cold DBT counters are identical");
}
#[test]
fn comparison_rejects_every_mismatching_field() {
use super::{Json, compare_documents};
// Written out independently of MATCHING_FIELDS, so dropping a field
// there fails this test.
for path in [
"format_version",
"benchmark",
"host.cpu",
"host.os",
"host.arch",
"build.debug_assertions",
"build.label",
"workload.name",
"workload.guest_instructions",
"workload.guest_code_bytes",
"workload.instruction_budget",
"workload.warmup_rounds",
"timings.interpreter.samples",
"timings.cold_dbt.samples",
"timings.warm_dbt.samples",
] {
let mut candidate = comparable_document();
let other = match path {
"build.debug_assertions" => Json::Bool(true),
"build.label" => Json::String("fat-lto".to_owned()),
// A valid but different version is refused as unsupported first.
"format_version" => Json::Number("2".to_owned()),
p if p.contains("samples")
|| p.starts_with("workload.") && p != "workload.name" =>
{
Json::Number("7".to_owned())
}
_ => Json::String("other".to_owned()),
};
set(&mut candidate, path, other);
let error = compare_documents(&comparable_document(), &candidate).expect_err(path);
assert!(
error.contains(path) || path == "format_version" && error.contains("version"),
"{path}: {error}"
);
}
}
#[test]
fn comparison_needs_known_hosts_and_matching_labels() {
use super::{Json, compare_documents};
for path in ["host.cpu", "host.os", "host.arch"] {
let mut unknown = comparable_document();
set(&mut unknown, path, Json::Null);
let error = compare_documents(&unknown, &unknown).expect_err(path);
assert!(error.contains("unknown in the baseline"), "{error}");
}
// A document written before the label existed counts as having no label.
let mut old = comparable_document();
let Json::Object(fields) = &mut old else {
unreachable!()
};
let build = &mut fields.iter_mut().find(|(k, _)| k == "build").unwrap().1;
let Json::Object(build) = build else {
unreachable!()
};
build.retain(|(k, _)| k != "label");
assert!(compare_documents(&old, &comparable_document()).is_ok());
let mut labelled = comparable_document();
set(
&mut labelled,
"build.label",
Json::String("fat-lto".to_owned()),
);
assert!(compare_documents(&old, &labelled).is_err());
assert!(compare_documents(&labelled, &labelled).is_ok());
let mut missing = comparable_document();
let Json::Object(fields) = &mut missing else {
unreachable!()
};
fields.retain(|(k, _)| k != "workload");
let error = compare_documents(&comparable_document(), &missing).unwrap_err();
assert!(error.contains("missing field `workload.name`"), "{error}");
}
}
+3 -1
View File
@@ -50,6 +50,8 @@ ENCS = {
"rm_imm": ("RmImm", True, {"ib", "iz"}),
"rm_one": ("RmOne", True, {""}),
"rm_cl": ("RmCl", True, {""}),
"rm_reg_imm": ("RmRegImm", True, {"ub"}),
"rm_reg_cl": ("RmRegCl", True, {""}),
"acc_imm": ("AccImm", False, {"ib", "iz"}),
"op_reg": ("OpReg", False, {""}),
"op_reg_imm": ("OpRegImm", False, {"ib", "iv"}),
@@ -66,7 +68,7 @@ ENCS = {
"reg_xmm_imm": ("RegXmmImm", True, {"ub"}),
}
# Encodings whose ModRM operand is the destination, so LOCK can apply to it.
RM_DESTINATIONS = {"rm_reg", "rm", "rm_imm", "rm_one", "rm_cl"}
RM_DESTINATIONS = {"rm_reg", "rm", "rm_imm", "rm_one", "rm_cl", "rm_reg_imm", "rm_reg_cl"}
# Encodings whose ModRM operand is an XMM register or memory of the source width.
XMM_RM = {"xmm_rm", "rm_xmm", "xmm_rm_imm", "rm_imm_xmm", "reg_xmm", "reg_xmm_imm"}
# One-byte opcodes that are prefixes or the two-byte escape, never instructions.
+4
View File
@@ -76,6 +76,10 @@ pub enum Encoding {
RmImm,
RmOne,
RmCl,
/// `rm` from `rm` and `reg`, with an 8-bit count (SHLD, SHRD).
RmRegImm,
/// `rm` from `rm` and `reg`, with the count in CL (SHLD, SHRD).
RmRegCl,
AccImm,
OpReg,
OpRegImm,
+65
View File
@@ -296,6 +296,54 @@ fn shift(op: Op, value: u64, count: u64, size: u8, old: RFlags) -> Option<(u64,
Some((result, flags))
}
/// SHLD and SHRD (Intel SDM Vol. 2B, "SHLD" and "SHRD"): `dst` is shifted by
/// `count` and the vacated bits are filled from `src`, which is unchanged.
/// `None` means a masked count of zero, which changes neither the destination
/// nor the flags.
///
/// A count above the operand size is possible only for 16-bit operands and
/// leaves the result and flags undefined. Xenora then returns the bits the
/// 32-bit concatenation gives and keeps every flag; no test relies on that.
fn double_shift(
op: Op,
dst: u64,
src: u64,
count: u64,
size: u8,
old: RFlags,
) -> Option<(u64, RFlags)> {
let count = (count & if size == 8 { 0x3F } else { 0x1F }) as u32;
if count == 0 {
return None;
}
let bits = 8 * u32::from(size);
let (dst, src) = (u128::from(dst), u128::from(src));
// SHLD shifts `dst:src` left and keeps the high half; SHRD shifts
// `src:dst` right and keeps the low half. CF is the last bit shifted out
// of the destination.
let (result, cf) = if op == Op::Shld {
let pair = dst << bits | src;
let shifted = pair << count;
(shifted >> bits, pair >> (2 * bits - count) & 1 != 0)
} else {
let pair = src << bits | dst;
(pair >> count, pair >> (count - 1) & 1 != 0)
};
let result = result as u64 & mask(size);
let mut flags = old;
if count > bits {
return Some((result, flags));
}
flags.cf = cf;
result_flags(&mut flags, result, size);
// OF is defined only for a count of one: set when the sign changed.
if count == 1 {
let top = u128::from(sign_bit(size));
flags.of = (u128::from(result) & top != 0) != (dst & top != 0);
}
Some((result, flags))
}
fn push(cpu: &mut CpuState, memory: &mut GuestMemory, value: u64) -> Result<(), ExitReason> {
let sp = cpu.gpr[RSP]
.checked_sub(8)
@@ -448,6 +496,23 @@ pub fn execute(
if negative { mask(size) } else { 0 },
);
}
Op::Shld | Op::Shrd => {
let dst = read_rm(cpu, memory, insn)?;
let src = read_reg(cpu, insn.reg, size);
let count = match insn.encoding {
Encoding::RmRegCl => cpu.gpr[RCX] & 0xFF,
_ => insn.imm & 0xFF,
};
match double_shift(insn.op, dst, src, count, size, cpu.flags) {
Some((value, flags)) => {
write_rm(cpu, memory, insn, value)?;
cpu.flags = flags;
}
// As for the other shifts, a zero count still performs the
// write's permission check and the 32-bit zero-extension.
None => write_rm(cpu, memory, insn, dst)?,
}
}
Op::Rol | Op::Ror | Op::Rcl | Op::Rcr | Op::Shl | Op::Shr | Op::Sar => {
let (a, count) = operands(cpu, memory, insn)?;
match shift(insn.op, a, count, size, cpu.flags) {
+156 -134
View File
@@ -39,6 +39,8 @@ pub enum Op {
Shl,
Shr,
Sar,
Shld,
Shrd,
Mul,
Imul,
Imul2,
@@ -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::Shld, Op::Shrd, 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];
/// Lower-case mnemonic stem.
pub const fn name(self) -> &'static str {
@@ -251,6 +253,8 @@ impl Op {
Op::Shl => "shl",
Op::Shr => "shr",
Op::Sar => "sar",
Op::Shld => "shld",
Op::Shrd => "shrd",
Op::Mul => "mul",
Op::Imul => "imul",
Op::Imul2 => "imul2",
@@ -461,6 +465,8 @@ impl Op {
Op::Shl => 0,
Op::Shr => 0,
Op::Sar => 0,
Op::Shld => 0,
Op::Shrd => 0,
Op::Mul => 0,
Op::Imul => 0,
Op::Imul2 => 0,
@@ -671,6 +677,8 @@ impl Op {
Op::Shl => 0,
Op::Shr => 0,
Op::Sar => 0,
Op::Shld => 0,
Op::Shrd => 0,
Op::Mul => 9,
Op::Imul => 9,
Op::Imul2 => 9,
@@ -881,6 +889,8 @@ impl Op {
Op::Shl => 31,
Op::Shr => 31,
Op::Sar => 31,
Op::Shld => 31,
Op::Shrd => 31,
Op::Mul => 9,
Op::Imul => 9,
Op::Imul2 => 9,
@@ -1091,6 +1101,8 @@ impl Op {
Op::Shl => 32,
Op::Shr => 32,
Op::Sar => 32,
Op::Shld => 32,
Op::Shrd => 32,
Op::Mul => 54,
Op::Imul => 54,
Op::Imul2 => 54,
@@ -1301,6 +1313,8 @@ impl Op {
Op::Shl => false,
Op::Shr => false,
Op::Sar => false,
Op::Shld => false,
Op::Shrd => false,
Op::Mul => false,
Op::Imul => false,
Op::Imul2 => false,
@@ -1511,6 +1525,8 @@ impl Op {
Op::Shl => false,
Op::Shr => false,
Op::Sar => false,
Op::Shld => false,
Op::Shrd => false,
Op::Mul => false,
Op::Imul => false,
Op::Imul2 => false,
@@ -1721,6 +1737,8 @@ impl Op {
Op::Shl => false,
Op::Shr => false,
Op::Sar => false,
Op::Shld => false,
Op::Shrd => false,
Op::Mul => false,
Op::Imul => false,
Op::Imul2 => false,
@@ -1898,7 +1916,7 @@ impl Op {
}
}
pub static FORMS: [Form; 392] = [
pub static FORMS: [Form; 396] = [
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 },
@@ -1979,6 +1997,10 @@ pub static FORMS: [Form; 392] = [
Form { op: Op::Cmpxchg, encoding: Encoding::RmReg, size: OperandSize::Variable, immediate: Immediate::None, source: 0, has_modrm: true, memory_only: false, register_only: false, no_rex_b: false, unaligned: false, lockable: true },
Form { op: Op::Xadd, encoding: Encoding::RmReg, size: OperandSize::Byte, immediate: Immediate::None, source: 0, has_modrm: true, memory_only: false, register_only: false, no_rex_b: false, unaligned: false, lockable: true },
Form { op: Op::Xadd, encoding: Encoding::RmReg, size: OperandSize::Variable, immediate: Immediate::None, source: 0, has_modrm: true, memory_only: false, register_only: false, no_rex_b: false, unaligned: false, lockable: true },
Form { op: Op::Shld, encoding: Encoding::RmRegImm, size: OperandSize::Variable, immediate: Immediate::Byte, source: 0, has_modrm: true, memory_only: false, register_only: false, no_rex_b: false, unaligned: false, lockable: false },
Form { op: Op::Shld, encoding: Encoding::RmRegCl, 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::Shrd, encoding: Encoding::RmRegImm, size: OperandSize::Variable, immediate: Immediate::Byte, source: 0, has_modrm: true, memory_only: false, register_only: false, no_rex_b: false, unaligned: false, lockable: false },
Form { op: Op::Shrd, encoding: Encoding::RmRegCl, 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::Movaps, encoding: Encoding::XmmRm, size: OperandSize::Xmm, immediate: Immediate::None, source: 16, has_modrm: true, memory_only: false, register_only: false, no_rex_b: false, unaligned: false, lockable: false },
Form { op: Op::Movaps, encoding: Encoding::RmXmm, size: OperandSize::Xmm, immediate: Immediate::None, source: 16, has_modrm: true, memory_only: false, register_only: false, no_rex_b: false, unaligned: false, lockable: false },
Form { op: Op::Movaps, encoding: Encoding::XmmRm, size: OperandSize::Xmm, immediate: Immediate::None, source: 16, has_modrm: true, memory_only: false, register_only: false, no_rex_b: false, unaligned: false, lockable: false },
@@ -2295,47 +2317,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],
[268, 277, 286, 295, 304, 313, 322, 331],
[269, 278, 287, 296, 305, 314, 323, 332],
[270, 279, 288, 297, 306, 315, 324, 333],
[6, 65535, 65535, 65535, 65535, 65535, 65535, 65535],
[350, 351, 352, 353, 354, 355, 65535, 356],
[357, 358, 359, 360, 361, 362, 65535, 363],
[354, 355, 356, 357, 358, 359, 65535, 360],
[361, 362, 363, 364, 365, 366, 65535, 367],
[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],
[368, 369, 370, 371, 372, 373, 65535, 374],
[375, 376, 377, 378, 379, 380, 65535, 381],
[382, 383, 384, 385, 386, 387, 65535, 388],
[389, 390, 391, 392, 393, 394, 65535, 395],
[18, 65535, 338, 339, 340, 341, 342, 343],
[19, 65535, 344, 345, 346, 347, 348, 349],
[350, 351, 65535, 65535, 65535, 65535, 65535, 65535],
[352, 353, 48, 65535, 49, 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, 205, 206, 65535, 207, 208, 209],
[65535, 65535, 65535, 65535, 334, 335, 336, 337],
[65535, 65535, 177, 65535, 179, 65535, 181, 65535],
[65535, 65535, 183, 65535, 185, 65535, 187, 65535],
[65535, 65535, 189, 192, 65535, 65535, 191, 193],
];
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(262), Entry::Form(263), Entry::Form(264), Entry::Form(265),
Entry::Form(266), Entry::Form(267), Entry::Unsupported, Entry::Unsupported,
Entry::Form(271), Entry::Form(272), Entry::Form(273), Entry::Form(274),
Entry::Form(275), Entry::Form(276), Entry::Unsupported, Entry::Unsupported,
Entry::Form(280), Entry::Form(281), Entry::Form(282), Entry::Form(283),
Entry::Form(284), Entry::Form(285), Entry::Unsupported, Entry::Unsupported,
Entry::Form(289), Entry::Form(290), Entry::Form(291), Entry::Form(292),
Entry::Form(293), Entry::Form(294), Entry::Unsupported, Entry::Unsupported,
Entry::Form(298), Entry::Form(299), Entry::Form(300), Entry::Form(301),
Entry::Form(302), Entry::Form(303), Entry::Unsupported, Entry::Unsupported,
Entry::Form(307), Entry::Form(308), Entry::Form(309), Entry::Form(310),
Entry::Form(311), Entry::Form(312), Entry::Unsupported, Entry::Unsupported,
Entry::Form(316), Entry::Form(317), Entry::Form(318), Entry::Form(319),
Entry::Form(320), Entry::Form(321), Entry::Unsupported, Entry::Unsupported,
Entry::Form(325), Entry::Form(326), Entry::Form(327), Entry::Form(328),
Entry::Form(329), Entry::Form(330), Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
@@ -2391,14 +2413,14 @@ pub static TWO_BYTE: [Entry; 256] = [
Entry::Unsupported, Entry::Form(54), 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(88), Entry::Form(89), Entry::Form(108), Entry::Form(110),
Entry::Form(199), Entry::Form(201), Entry::Form(112), Entry::Form(114),
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(84), Entry::Form(85), Entry::Unsupported, Entry::Form(98),
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,
@@ -2407,10 +2429,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(116), Entry::Form(210), Entry::Unsupported, Entry::Unsupported,
Entry::Form(120), Entry::Form(123), Entry::Form(126), Entry::Form(129),
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,
@@ -2428,15 +2450,15 @@ 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::Unsupported, Entry::Unsupported, Entry::Form(55), Entry::Form(72),
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Form(80), Entry::Form(81), Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Form(73),
Entry::Unsupported, Entry::Unsupported, Entry::Group(17), Entry::Form(9),
Entry::Form(82), Entry::Form(83), 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(78), Entry::Form(79), Entry::Form(238), Entry::Form(97),
Entry::Unsupported, Entry::Unsupported, Entry::Form(197), 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::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
@@ -2458,14 +2480,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(90), Entry::Form(91), Entry::Form(109), Entry::Form(111),
Entry::Form(200), Entry::Form(202), Entry::Form(113), Entry::Form(115),
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::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(86), Entry::Form(87), Entry::Unsupported, Entry::Form(99),
Entry::Unsupported, Entry::Unsupported, Entry::Form(244), Entry::Form(245),
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,18 +2496,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(117), Entry::Form(211), Entry::Unsupported, Entry::Unsupported,
Entry::Form(121), Entry::Form(124), Entry::Form(127), Entry::Form(130),
Entry::Form(215), Entry::Form(219), Entry::Form(247), Entry::Form(251),
Entry::Form(223), Entry::Form(227), Entry::Form(231), Entry::Form(235),
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::Form(139), Entry::Form(140), Entry::Form(141), Entry::Form(142),
Entry::Form(143), Entry::Form(144), Entry::Form(106), Entry::Form(92),
Entry::Form(194), Entry::Group(19), Entry::Group(20), Entry::Group(21),
Entry::Form(145), Entry::Form(146), Entry::Form(147), 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::Form(107), 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,
@@ -2502,22 +2524,22 @@ 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::Unsupported, Entry::Unsupported, Entry::Form(235), Entry::Unsupported,
Entry::Form(199), Entry::Form(200), Entry::Form(194), Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Form(239), Entry::Unsupported,
Entry::Form(203), Entry::Form(204), Entry::Form(198), 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,
Entry::Unsupported, Entry::Form(176), Entry::Form(182), Entry::Form(188),
Entry::Form(148), Entry::Form(149), Entry::Form(105), Entry::Form(118),
Entry::Form(150), Entry::Form(151), Entry::Form(152), Entry::Form(119),
Entry::Form(153), Entry::Form(154), Entry::Form(155), Entry::Form(122),
Entry::Form(156), Entry::Form(178), Entry::Form(184), Entry::Form(157),
Entry::Form(158), Entry::Form(159), Entry::Form(253), Entry::Form(96),
Entry::Form(160), Entry::Form(161), Entry::Form(162), Entry::Form(125),
Entry::Form(163), Entry::Form(164), Entry::Form(165), Entry::Form(128),
Entry::Unsupported, Entry::Form(180), Entry::Form(186), Entry::Form(190),
Entry::Form(166), Entry::Form(167), Entry::Form(168), Entry::Unsupported,
Entry::Form(169), Entry::Form(170), Entry::Form(171), Entry::Form(172),
Entry::Form(173), Entry::Form(174), Entry::Form(175), Entry::Unsupported,
];
pub static TWO_BYTE_F3: [Entry; 256] = [
@@ -2525,14 +2547,14 @@ 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::Form(96), Entry::Form(97), 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(252), Entry::Unsupported,
Entry::Form(253), Entry::Form(254), Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Form(256), Entry::Unsupported,
Entry::Form(257), Entry::Form(258), Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
@@ -2541,18 +2563,18 @@ 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::Form(208), Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Form(212), 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::Form(216), Entry::Form(220), Entry::Form(248), Entry::Form(252),
Entry::Form(224), Entry::Form(228), Entry::Form(232), 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::Form(90),
Entry::Form(191), Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Form(94),
Entry::Form(195), Entry::Unsupported, Entry::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::Form(104), Entry::Form(95),
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
@@ -2569,7 +2591,7 @@ pub static TWO_BYTE_F3: [Entry; 256] = [
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::Form(240), Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
@@ -2578,7 +2600,7 @@ 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::Form(250), Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, 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,
@@ -2592,60 +2614,60 @@ 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::Form(98), Entry::Form(99), Entry::Unsupported, Entry::Unsupported,
Entry::Form(102), Entry::Form(103), Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::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(259), Entry::Unsupported,
Entry::Form(260), Entry::Form(261), Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::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(213), Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Form(217), Entry::Form(221), Entry::Form(249), Entry::Unsupported,
Entry::Form(225), Entry::Form(229), Entry::Form(233), Entry::Form(237),
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::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(196), Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::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(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, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::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(221), Entry::Form(225), Entry::Form(229), Entry::Form(233),
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::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::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::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(237), Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::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::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
Entry::Unsupported, Entry::Unsupported, Entry::Unsupported, Entry::Unsupported,
-8
View File
@@ -2774,14 +2774,6 @@ const UNSUPPORTED: &[(&str, usize)] = &[
("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),
("shld32_cl32_is_count_zero", 0),
("shld64_by63", 0),
("shrd32_by8", 0),
("shrd64_by1_sign_change", 0),
("shrd64_cl64_is_count_zero", 0),
];
// ---------------------------------------------------------------------------
+7
View File
@@ -59,6 +59,13 @@ def cases():
for count in ("1", "3", "7", "cl"):
out += [f"{op} {reg(3, bits)}, {count}", f"{op} {mem(bits)}, {count}"]
out += [f"{op} {reg(13, bits)}, {bits - 1}", f"{op} {reg(13, bits)}, 0"]
for op in ("shld", "shrd"):
for bits in (16, 32, 64):
for count in ("1", "3", "7", "cl"):
out += [f"{op} {reg(3, bits)}, {reg(9, bits)}, {count}",
f"{op} {mem(bits)}, {reg(2, bits)}, {count}"]
out += [f"{op} {reg(13, bits)}, {reg(0, bits)}, {bits - 1}", f"{op} {reg(13, bits)}, {reg(1, bits)}, 0",
f"{op} {reg(3, bits)}, {reg(3, bits)}, 5", f"{op} {reg(12, bits)}, {reg(10, bits)}, {bits}"]
for bits in (16, 32, 64):
out += [f"imul {reg(3, bits)}, {reg(9, bits)}", f"imul {reg(3, bits)}, {mem(bits)}",
f"imul {reg(8, bits)}, {reg(1, bits)}, -7", f"imul {reg(8, bits)}, {reg(1, bits)}, 0x1234",
+72
View File
@@ -747,6 +747,78 @@ d3 7c be 10 | sar dword ptr [rsi + 4*rdi + 16], cl
48 d3 7c be 10 | sar qword ptr [rsi + 4*rdi + 16], cl
49 c1 fd 3f | sar r13, 63
49 c1 fd 00 | sar r13, 0
66 44 0f a4 cb 01 | shld bx, r9w, 1
66 0f a4 54 be 10 01 | shld word ptr [rsi + 4*rdi + 16], dx, 1
66 44 0f a4 cb 03 | shld bx, r9w, 3
66 0f a4 54 be 10 03 | shld word ptr [rsi + 4*rdi + 16], dx, 3
66 44 0f a4 cb 07 | shld bx, r9w, 7
66 0f a4 54 be 10 07 | shld word ptr [rsi + 4*rdi + 16], dx, 7
66 44 0f a5 cb | shld bx, r9w, cl
66 0f a5 54 be 10 | shld word ptr [rsi + 4*rdi + 16], dx, cl
66 41 0f a4 c5 0f | shld r13w, ax, 15
66 41 0f a4 cd 00 | shld r13w, cx, 0
66 0f a4 db 05 | shld bx, bx, 5
66 45 0f a4 d4 10 | shld r12w, r10w, 16
44 0f a4 cb 01 | shld ebx, r9d, 1
0f a4 54 be 10 01 | shld dword ptr [rsi + 4*rdi + 16], edx, 1
44 0f a4 cb 03 | shld ebx, r9d, 3
0f a4 54 be 10 03 | shld dword ptr [rsi + 4*rdi + 16], edx, 3
44 0f a4 cb 07 | shld ebx, r9d, 7
0f a4 54 be 10 07 | shld dword ptr [rsi + 4*rdi + 16], edx, 7
44 0f a5 cb | shld ebx, r9d, cl
0f a5 54 be 10 | shld dword ptr [rsi + 4*rdi + 16], edx, cl
41 0f a4 c5 1f | shld r13d, eax, 31
41 0f a4 cd 00 | shld r13d, ecx, 0
0f a4 db 05 | shld ebx, ebx, 5
45 0f a4 d4 20 | shld r12d, r10d, 32
4c 0f a4 cb 01 | shld rbx, r9, 1
48 0f a4 54 be 10 01 | shld qword ptr [rsi + 4*rdi + 16], rdx, 1
4c 0f a4 cb 03 | shld rbx, r9, 3
48 0f a4 54 be 10 03 | shld qword ptr [rsi + 4*rdi + 16], rdx, 3
4c 0f a4 cb 07 | shld rbx, r9, 7
48 0f a4 54 be 10 07 | shld qword ptr [rsi + 4*rdi + 16], rdx, 7
4c 0f a5 cb | shld rbx, r9, cl
48 0f a5 54 be 10 | shld qword ptr [rsi + 4*rdi + 16], rdx, cl
49 0f a4 c5 3f | shld r13, rax, 63
49 0f a4 cd 00 | shld r13, rcx, 0
48 0f a4 db 05 | shld rbx, rbx, 5
4d 0f a4 d4 40 | shld r12, r10, 64
66 44 0f ac cb 01 | shrd bx, r9w, 1
66 0f ac 54 be 10 01 | shrd word ptr [rsi + 4*rdi + 16], dx, 1
66 44 0f ac cb 03 | shrd bx, r9w, 3
66 0f ac 54 be 10 03 | shrd word ptr [rsi + 4*rdi + 16], dx, 3
66 44 0f ac cb 07 | shrd bx, r9w, 7
66 0f ac 54 be 10 07 | shrd word ptr [rsi + 4*rdi + 16], dx, 7
66 44 0f ad cb | shrd bx, r9w, cl
66 0f ad 54 be 10 | shrd word ptr [rsi + 4*rdi + 16], dx, cl
66 41 0f ac c5 0f | shrd r13w, ax, 15
66 41 0f ac cd 00 | shrd r13w, cx, 0
66 0f ac db 05 | shrd bx, bx, 5
66 45 0f ac d4 10 | shrd r12w, r10w, 16
44 0f ac cb 01 | shrd ebx, r9d, 1
0f ac 54 be 10 01 | shrd dword ptr [rsi + 4*rdi + 16], edx, 1
44 0f ac cb 03 | shrd ebx, r9d, 3
0f ac 54 be 10 03 | shrd dword ptr [rsi + 4*rdi + 16], edx, 3
44 0f ac cb 07 | shrd ebx, r9d, 7
0f ac 54 be 10 07 | shrd dword ptr [rsi + 4*rdi + 16], edx, 7
44 0f ad cb | shrd ebx, r9d, cl
0f ad 54 be 10 | shrd dword ptr [rsi + 4*rdi + 16], edx, cl
41 0f ac c5 1f | shrd r13d, eax, 31
41 0f ac cd 00 | shrd r13d, ecx, 0
0f ac db 05 | shrd ebx, ebx, 5
45 0f ac d4 20 | shrd r12d, r10d, 32
4c 0f ac cb 01 | shrd rbx, r9, 1
48 0f ac 54 be 10 01 | shrd qword ptr [rsi + 4*rdi + 16], rdx, 1
4c 0f ac cb 03 | shrd rbx, r9, 3
48 0f ac 54 be 10 03 | shrd qword ptr [rsi + 4*rdi + 16], rdx, 3
4c 0f ac cb 07 | shrd rbx, r9, 7
48 0f ac 54 be 10 07 | shrd qword ptr [rsi + 4*rdi + 16], rdx, 7
4c 0f ad cb | shrd rbx, r9, cl
48 0f ad 54 be 10 | shrd qword ptr [rsi + 4*rdi + 16], rdx, cl
49 0f ac c5 3f | shrd r13, rax, 63
49 0f ac cd 00 | shrd r13, rcx, 0
48 0f ac db 05 | shrd rbx, rbx, 5
4d 0f ac d4 40 | shrd r12, r10, 64
66 41 0f af d9 | imul bx, r9w
66 0f af 5c be 10 | imul bx, word ptr [rsi + 4*rdi + 16]
66 44 6b c1 f9 | imul r8w, cx, -7
+54 -6
View File
@@ -274,7 +274,8 @@ struct Undefined {
of: bool,
pf: bool,
af: bool,
/// The destination itself is undefined (BSF/BSR of zero).
/// The destination itself is undefined (BSF/BSR of zero, or a 16-bit
/// SHLD/SHRD count above 16).
destination: bool,
}
@@ -450,6 +451,53 @@ fn reference(m: &mut Machine, text: &str) -> Outcome {
}
Outcome::Done(undefined)
}
"shld" | "shrd" => {
// Intel SDM Vol. 2B, SHLD and SHRD: the count is masked to 5 bits
// (6 for 64-bit operands); a count above the operand size leaves
// the destination and the flags undefined.
let count = read(m, places[2], 8) as u32 % if bits == 64 { 64 } else { 32 };
let start = read(m, places[0], bits);
let mut fill = read(m, places[1], bits);
if count > bits {
return Outcome::Done(Undefined {
cf: true,
zf: true,
sf: true,
of: true,
pf: true,
af: true,
destination: true,
});
}
let mut value = start;
let mut carry = m.flags.cf;
for _ in 0..count {
// One bit at a time: the bit leaving the destination goes to
// CF and the next bit of the source enters from the other end.
if name == "shld" {
carry = bit(value, bits - 1);
value = truncate(value * 2, bits) + u128::from(bit(fill, bits - 1));
fill = truncate(fill * 2, bits);
} else {
carry = bit(value, 0);
value = value / 2 + if bit(fill, 0) { 1u128 << (bits - 1) } else { 0 };
fill /= 2;
}
}
write(m, places[0], value);
let mut undefined = none;
if count != 0 {
m.flags.cf = carry;
set_result(&mut m.flags, value, bits);
undefined.af = true;
if count == 1 {
m.flags.of = bit(value, bits - 1) != bit(start, bits - 1);
} else {
undefined.of = true;
}
}
Outcome::Done(undefined)
}
"mul" | "imul" => {
let undefined = Undefined {
zf: true,
@@ -938,12 +986,12 @@ fn every_fixture_instruction_matches_the_reference_in_both_engines() {
assert_eq!(state.rip, ENTRY + case.code.len() as u64, "{text}");
if !undefined.destination {
assert_eq!(state.gpr, expected.gpr, "{text} from {cpu:x?}");
assert_eq!(
memory.read_u64(OPERAND).unwrap(),
expected.operand,
"{text} from {cpu:x?}"
);
}
assert_eq!(
memory.read_u64(OPERAND).unwrap(),
expected.operand,
"{text} from {cpu:x?}"
);
assert_eq!(
memory.read_u64(STACK_TOP - 8).unwrap(),
expected.pushed,
+34
View File
@@ -66,6 +66,8 @@ rcr = { reads = "cf", writes = "cf of", conditional = true, ref = "sdm RCL/RCR/R
shl = { writes = "cf zf sf of pf", undefined = "af", conditional = true, ref = "sdm SAL/SAR/SHL/SHR" }
shr = { writes = "cf zf sf of pf", undefined = "af", conditional = true, ref = "sdm SAL/SAR/SHL/SHR" }
sar = { writes = "cf zf sf of pf", undefined = "af", conditional = true, ref = "sdm SAL/SAR/SHL/SHR" }
shld = { writes = "cf zf sf of pf", undefined = "af", conditional = true, ref = "sdm SHLD" }
shrd = { writes = "cf zf sf of pf", undefined = "af", conditional = true, ref = "sdm SHRD" }
mul = { writes = "cf of", undefined = "zf sf pf af", ref = "sdm MUL" }
imul = { writes = "cf of", undefined = "zf sf pf af", ref = "sdm IMUL" }
imul2 = { writes = "cf of", undefined = "zf sf pf af", ref = "sdm IMUL" }
@@ -832,6 +834,38 @@ digits = { 0 = "inc", 1 = "dec" }
opcodes = [[0xC0, "b", "ib", "rm_imm"], [0xC1, "v", "ib", "rm_imm"], [0xD0, "b", "", "rm_one"], [0xD1, "v", "", "rm_one"], [0xD2, "b", "", "rm_cl"], [0xD3, "v", "", "rm_cl"]]
digits = { 0 = "rol", 1 = "ror", 2 = "rcl", 3 = "rcr", 4 = "shl", 5 = "shr", 7 = "sar" }
# Double-precision shifts: the ModRM operand is shifted and filled from the
# reg operand, by an 8-bit immediate or by CL.
[[form]]
op = "shld"
map = "0f"
opcode = 0xA4
enc = "rm_reg_imm"
size = "v"
imm = "ub"
[[form]]
op = "shld"
map = "0f"
opcode = 0xA5
enc = "rm_reg_cl"
size = "v"
[[form]]
op = "shrd"
map = "0f"
opcode = 0xAC
enc = "rm_reg_imm"
size = "v"
imm = "ub"
[[form]]
op = "shrd"
map = "0f"
opcode = 0xAD
enc = "rm_reg_cl"
size = "v"
# SSE and SSE2 moves and packed integer forms.
[[form]]
+1 -1
View File
@@ -104,4 +104,4 @@ A feature bit is set only when every instruction of that feature is implemented.
## Rejected on purpose
LOCK except as described above, F2 or F3 where it is neither PAUSE nor part of a declared form, F2 combined with F3, address-size overrides, an ignored segment override after FS or GS, 16-bit stack and branch forms, 16-bit BSWAP and MOVSXD, bit tests of memory by a register index, SHLD, SHRD, LODS, CMPS, SCAS, REPE and REPNE, MMX, the RCP and RSQRT approximations, SSE3 and later, VEX, CMPXCHG8B and CMPXCHG16B. The DBT also refuses raw SYSCALL.
LOCK except as described above, F2 or F3 where it is neither PAUSE nor part of a declared form, F2 combined with F3, address-size overrides, an ignored segment override after FS or GS, 16-bit stack and branch forms, 16-bit BSWAP and MOVSXD, bit tests of memory by a register index, LODS, CMPS, SCAS, REPE and REPNE, MMX, the RCP and RSQRT approximations, SSE3 and later, VEX, CMPXCHG8B and CMPXCHG16B. The DBT also refuses raw SYSCALL.