mirror of
https://github.com/copy/v86.git
synced 2025-12-31 04:23:15 +00:00
switch to rust 2021, fix imports
This commit is contained in:
parent
d04046d958
commit
2996c087fd
28 changed files with 358 additions and 326 deletions
|
|
@ -133,15 +133,15 @@ function gen_instruction_body(encodings, size)
|
|||
|
||||
if(has_66.length) {
|
||||
const body = gen_instruction_body_after_prefix(has_66, size);
|
||||
if_blocks.push({ condition: "cpu.prefixes & ::prefix::PREFIX_66 != 0", body, });
|
||||
if_blocks.push({ condition: "cpu.prefixes & prefix::PREFIX_66 != 0", body, });
|
||||
}
|
||||
if(has_F2.length) {
|
||||
const body = gen_instruction_body_after_prefix(has_F2, size);
|
||||
if_blocks.push({ condition: "cpu.prefixes & ::prefix::PREFIX_F2 != 0", body, });
|
||||
if_blocks.push({ condition: "cpu.prefixes & prefix::PREFIX_F2 != 0", body, });
|
||||
}
|
||||
if(has_F3.length) {
|
||||
const body = gen_instruction_body_after_prefix(has_F3, size);
|
||||
if_blocks.push({ condition: "cpu.prefixes & ::prefix::PREFIX_F3 != 0", body, });
|
||||
if_blocks.push({ condition: "cpu.prefixes & prefix::PREFIX_F3 != 0", body, });
|
||||
}
|
||||
|
||||
const else_block = {
|
||||
|
|
@ -199,7 +199,7 @@ function gen_instruction_body_after_prefix(encodings, size)
|
|||
|
||||
default_case: {
|
||||
body: [
|
||||
"analysis.ty = ::analysis::AnalysisType::BlockBoundary;",
|
||||
"analysis.ty = analysis::AnalysisType::BlockBoundary;",
|
||||
"analysis.no_next_instruction = true;",
|
||||
],
|
||||
}
|
||||
|
|
@ -218,14 +218,14 @@ function gen_instruction_body_after_fixed_g(encoding, size)
|
|||
const instruction_postfix = [];
|
||||
|
||||
if(encoding.custom_sti) {
|
||||
instruction_postfix.push("analysis.ty = ::analysis::AnalysisType::STI;");
|
||||
instruction_postfix.push("analysis.ty = analysis::AnalysisType::STI;");
|
||||
}
|
||||
else if(
|
||||
encoding.block_boundary &&
|
||||
// jump_offset_imm: Is a block boundary, but gets a different type (Jump) below
|
||||
!encoding.jump_offset_imm || (!encoding.custom && encoding.e))
|
||||
{
|
||||
instruction_postfix.push("analysis.ty = ::analysis::AnalysisType::BlockBoundary;");
|
||||
instruction_postfix.push("analysis.ty = analysis::AnalysisType::BlockBoundary;");
|
||||
}
|
||||
|
||||
if(encoding.no_next_instruction)
|
||||
|
|
@ -239,7 +239,7 @@ function gen_instruction_body_after_fixed_g(encoding, size)
|
|||
|
||||
if(encoding.prefix)
|
||||
{
|
||||
const instruction_name = "::analysis::" + make_instruction_name(encoding, size) + "_analyze";
|
||||
const instruction_name = "analysis::" + make_instruction_name(encoding, size) + "_analyze";
|
||||
const args = ["cpu", "analysis"];
|
||||
|
||||
assert(!imm_read);
|
||||
|
|
@ -259,14 +259,14 @@ function gen_instruction_body_after_fixed_g(encoding, size)
|
|||
if(encoding.mem_ud)
|
||||
{
|
||||
mem_postfix.push(
|
||||
"analysis.ty = ::analysis::AnalysisType::BlockBoundary;"
|
||||
"analysis.ty = analysis::AnalysisType::BlockBoundary;"
|
||||
);
|
||||
}
|
||||
|
||||
if(encoding.reg_ud)
|
||||
{
|
||||
reg_postfix.push(
|
||||
"analysis.ty = ::analysis::AnalysisType::BlockBoundary;"
|
||||
"analysis.ty = analysis::AnalysisType::BlockBoundary;"
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -287,7 +287,7 @@ function gen_instruction_body_after_fixed_g(encoding, size)
|
|||
if_blocks: [{
|
||||
condition: "modrm_byte < 0xC0",
|
||||
body: [].concat(
|
||||
gen_call("::analysis::modrm_analyze", ["cpu", "modrm_byte"]),
|
||||
gen_call("analysis::modrm_analyze", ["cpu", "modrm_byte"]),
|
||||
mem_postfix,
|
||||
),
|
||||
}],
|
||||
|
|
@ -320,11 +320,11 @@ function gen_instruction_body_after_fixed_g(encoding, size)
|
|||
(encoding.opcode & ~0x3) === 0xE0
|
||||
);
|
||||
const condition_index = encoding.opcode & 0xFF;
|
||||
body.push(`analysis.ty = ::analysis::AnalysisType::Jump { offset: jump_offset as i32, condition: Some(0x${hex(condition_index, 2)}), is_32: cpu.osize_32() };`);
|
||||
body.push(`analysis.ty = analysis::AnalysisType::Jump { offset: jump_offset as i32, condition: Some(0x${hex(condition_index, 2)}), is_32: cpu.osize_32() };`);
|
||||
}
|
||||
else
|
||||
{
|
||||
body.push(`analysis.ty = ::analysis::AnalysisType::Jump { offset: jump_offset as i32, condition: None, is_32: cpu.osize_32() };`);
|
||||
body.push(`analysis.ty = analysis::AnalysisType::Jump { offset: jump_offset as i32, condition: None, is_32: cpu.osize_32() };`);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -415,7 +415,10 @@ function gen_table()
|
|||
{
|
||||
const code = [
|
||||
"#[cfg_attr(rustfmt, rustfmt_skip)]",
|
||||
"pub fn analyzer(opcode: u32, cpu: &mut ::cpu_context::CpuContext, analysis: &mut ::analysis::Analysis) {",
|
||||
"use crate::analysis;",
|
||||
"use crate::prefix;",
|
||||
"use crate::cpu_context;",
|
||||
"pub fn analyzer(opcode: u32, cpu: &mut cpu_context::CpuContext, analysis: &mut analysis::Analysis) {",
|
||||
table,
|
||||
"}",
|
||||
];
|
||||
|
|
@ -472,7 +475,10 @@ function gen_table()
|
|||
const code = [
|
||||
"#![allow(unused)]",
|
||||
"#[cfg_attr(rustfmt, rustfmt_skip)]",
|
||||
"pub fn analyzer(opcode: u32, cpu: &mut ::cpu_context::CpuContext, analysis: &mut ::analysis::Analysis) {",
|
||||
"use crate::analysis;",
|
||||
"use crate::prefix;",
|
||||
"use crate::cpu_context;",
|
||||
"pub fn analyzer(opcode: u32, cpu: &mut cpu_context::CpuContext, analysis: &mut analysis::Analysis) {",
|
||||
table0f,
|
||||
"}"
|
||||
];
|
||||
|
|
|
|||
|
|
@ -139,18 +139,18 @@ function gen_instruction_body(encodings, size)
|
|||
|
||||
if(has_66.length) {
|
||||
const body = gen_instruction_body_after_prefix(has_66, size);
|
||||
if_blocks.push({ condition: "prefixes_ & ::prefix::PREFIX_66 != 0", body, });
|
||||
if_blocks.push({ condition: "prefixes_ & prefix::PREFIX_66 != 0", body, });
|
||||
}
|
||||
if(has_F2.length) {
|
||||
const body = gen_instruction_body_after_prefix(has_F2, size);
|
||||
if_blocks.push({ condition: "prefixes_ & ::prefix::PREFIX_F2 != 0", body, });
|
||||
if_blocks.push({ condition: "prefixes_ & prefix::PREFIX_F2 != 0", body, });
|
||||
}
|
||||
if(has_F3.length) {
|
||||
const body = gen_instruction_body_after_prefix(has_F3, size);
|
||||
if_blocks.push({ condition: "prefixes_ & ::prefix::PREFIX_F3 != 0", body, });
|
||||
if_blocks.push({ condition: "prefixes_ & prefix::PREFIX_F3 != 0", body, });
|
||||
}
|
||||
|
||||
const check_prefixes = encoding.sse ? "(::prefix::PREFIX_66 | ::prefix::PREFIX_F2 | ::prefix::PREFIX_F3)" : "(::prefix::PREFIX_F2 | ::prefix::PREFIX_F3)";
|
||||
const check_prefixes = encoding.sse ? "(prefix::PREFIX_66 | prefix::PREFIX_F2 | prefix::PREFIX_F3)" : "(prefix::PREFIX_F2 | prefix::PREFIX_F3)";
|
||||
|
||||
const else_block = {
|
||||
body: [].concat(
|
||||
|
|
@ -408,11 +408,12 @@ function gen_table()
|
|||
const code = [
|
||||
"#![cfg_attr(rustfmt, rustfmt_skip)]",
|
||||
|
||||
"use cpu::cpu::{after_block_boundary, modrm_resolve};",
|
||||
"use cpu::cpu::{read_imm8, read_imm8s, read_imm16, read_imm32s, read_moffs};",
|
||||
"use cpu::cpu::{task_switch_test, trigger_ud, DEBUG};",
|
||||
"use cpu::instructions;",
|
||||
"use cpu::global_pointers::{instruction_pointer, prefixes};",
|
||||
"use crate::cpu::cpu::{after_block_boundary, modrm_resolve};",
|
||||
"use crate::cpu::cpu::{read_imm8, read_imm8s, read_imm16, read_imm32s, read_moffs};",
|
||||
"use crate::cpu::cpu::{task_switch_test, trigger_ud, DEBUG};",
|
||||
"use crate::cpu::instructions;",
|
||||
"use crate::cpu::global_pointers::{instruction_pointer, prefixes};",
|
||||
"use crate::prefix;",
|
||||
|
||||
"pub unsafe fn run(opcode: u32) {",
|
||||
table,
|
||||
|
|
@ -471,12 +472,13 @@ function gen_table()
|
|||
const code = [
|
||||
"#![cfg_attr(rustfmt, rustfmt_skip)]",
|
||||
|
||||
"use cpu::cpu::{after_block_boundary, modrm_resolve};",
|
||||
"use cpu::cpu::{read_imm8, read_imm16, read_imm32s};",
|
||||
"use cpu::cpu::{task_switch_test, task_switch_test_mmx, trigger_ud};",
|
||||
"use cpu::cpu::DEBUG;",
|
||||
"use cpu::instructions_0f;",
|
||||
"use cpu::global_pointers::{instruction_pointer, prefixes};",
|
||||
"use crate::cpu::cpu::{after_block_boundary, modrm_resolve};",
|
||||
"use crate::cpu::cpu::{read_imm8, read_imm16, read_imm32s};",
|
||||
"use crate::cpu::cpu::{task_switch_test, task_switch_test_mmx, trigger_ud};",
|
||||
"use crate::cpu::cpu::DEBUG;",
|
||||
"use crate::cpu::instructions_0f;",
|
||||
"use crate::cpu::global_pointers::{instruction_pointer, prefixes};",
|
||||
"use crate::prefix;",
|
||||
|
||||
"pub unsafe fn run(opcode: u32) {",
|
||||
table0f,
|
||||
|
|
|
|||
|
|
@ -133,15 +133,15 @@ function gen_instruction_body(encodings, size)
|
|||
|
||||
if(has_66.length) {
|
||||
const body = gen_instruction_body_after_prefix(has_66, size);
|
||||
if_blocks.push({ condition: "ctx.cpu.prefixes & ::prefix::PREFIX_66 != 0", body, });
|
||||
if_blocks.push({ condition: "ctx.cpu.prefixes & prefix::PREFIX_66 != 0", body, });
|
||||
}
|
||||
if(has_F2.length) {
|
||||
const body = gen_instruction_body_after_prefix(has_F2, size);
|
||||
if_blocks.push({ condition: "ctx.cpu.prefixes & ::prefix::PREFIX_F2 != 0", body, });
|
||||
if_blocks.push({ condition: "ctx.cpu.prefixes & prefix::PREFIX_F2 != 0", body, });
|
||||
}
|
||||
if(has_F3.length) {
|
||||
const body = gen_instruction_body_after_prefix(has_F3, size);
|
||||
if_blocks.push({ condition: "ctx.cpu.prefixes & ::prefix::PREFIX_F3 != 0", body, });
|
||||
if_blocks.push({ condition: "ctx.cpu.prefixes & prefix::PREFIX_F3 != 0", body, });
|
||||
}
|
||||
|
||||
const else_block = {
|
||||
|
|
@ -199,8 +199,8 @@ function gen_instruction_body_after_prefix(encodings, size)
|
|||
|
||||
default_case: {
|
||||
body: [].concat(
|
||||
gen_call(`::codegen::gen_trigger_ud`, ["ctx"]),
|
||||
"*instr_flags |= ::jit::JIT_INSTR_BLOCK_BOUNDARY_FLAG;"
|
||||
gen_call(`codegen::gen_trigger_ud`, ["ctx"]),
|
||||
"*instr_flags |= jit::JIT_INSTR_BLOCK_BOUNDARY_FLAG;"
|
||||
),
|
||||
}
|
||||
},
|
||||
|
|
@ -218,7 +218,7 @@ function gen_instruction_body_after_fixed_g(encoding, size)
|
|||
|
||||
if(encoding.block_boundary || (!encoding.custom && encoding.e))
|
||||
{
|
||||
instruction_postfix.push("*instr_flags |= ::jit::JIT_INSTR_BLOCK_BOUNDARY_FLAG;");
|
||||
instruction_postfix.push("*instr_flags |= jit::JIT_INSTR_BLOCK_BOUNDARY_FLAG;");
|
||||
}
|
||||
|
||||
const instruction_prefix = [];
|
||||
|
|
@ -226,7 +226,7 @@ function gen_instruction_body_after_fixed_g(encoding, size)
|
|||
if(encoding.task_switch_test || encoding.sse)
|
||||
{
|
||||
instruction_prefix.push(
|
||||
gen_call(encoding.sse ? "::codegen::gen_task_switch_test_mmx" : "::codegen::gen_task_switch_test", ["ctx"])
|
||||
gen_call(encoding.sse ? "codegen::gen_task_switch_test_mmx" : "codegen::gen_task_switch_test", ["ctx"])
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -247,10 +247,10 @@ function gen_instruction_body_after_fixed_g(encoding, size)
|
|||
else
|
||||
{
|
||||
instruction_prefix.push(
|
||||
gen_call("::codegen::gen_move_registers_from_locals_to_memory", ["ctx"])
|
||||
gen_call("codegen::gen_move_registers_from_locals_to_memory", ["ctx"])
|
||||
);
|
||||
instruction_postfix.push(
|
||||
gen_call("::codegen::gen_move_registers_from_memory_to_locals", ["ctx"])
|
||||
gen_call("codegen::gen_move_registers_from_memory_to_locals", ["ctx"])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -263,14 +263,14 @@ function gen_instruction_body_after_fixed_g(encoding, size)
|
|||
if(encoding.mem_ud)
|
||||
{
|
||||
mem_postfix.push(
|
||||
"*instr_flags |= ::jit::JIT_INSTR_BLOCK_BOUNDARY_FLAG;"
|
||||
"*instr_flags |= jit::JIT_INSTR_BLOCK_BOUNDARY_FLAG;"
|
||||
);
|
||||
}
|
||||
|
||||
if(encoding.reg_ud)
|
||||
{
|
||||
reg_postfix.push(
|
||||
"*instr_flags |= ::jit::JIT_INSTR_BLOCK_BOUNDARY_FLAG;"
|
||||
"*instr_flags |= jit::JIT_INSTR_BLOCK_BOUNDARY_FLAG;"
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -284,7 +284,7 @@ function gen_instruction_body_after_fixed_g(encoding, size)
|
|||
|
||||
return [].concat(
|
||||
instruction_prefix,
|
||||
gen_call(`::codegen::gen_fn${args.length - 2}_const`, args),
|
||||
gen_call(`codegen::gen_fn${args.length - 2}_const`, args),
|
||||
reg_postfix,
|
||||
instruction_postfix
|
||||
);
|
||||
|
|
@ -313,16 +313,16 @@ function gen_instruction_body_after_fixed_g(encoding, size)
|
|||
if_blocks: [{
|
||||
condition: "modrm_byte < 0xC0",
|
||||
body: [].concat(
|
||||
"let addr = ::modrm::decode(ctx.cpu, modrm_byte);",
|
||||
"let addr = modrm::decode(ctx.cpu, modrm_byte);",
|
||||
imm_read_bindings,
|
||||
gen_call(`::jit_instructions::${instruction_name}_mem_jit`, mem_args),
|
||||
gen_call(`jit_instructions::${instruction_name}_mem_jit`, mem_args),
|
||||
mem_postfix
|
||||
),
|
||||
}],
|
||||
else_block: {
|
||||
body: [].concat(
|
||||
imm_read_bindings,
|
||||
gen_call(`::jit_instructions::${instruction_name}_reg_jit`, reg_args),
|
||||
gen_call(`jit_instructions::${instruction_name}_reg_jit`, reg_args),
|
||||
reg_postfix
|
||||
),
|
||||
},
|
||||
|
|
@ -354,17 +354,17 @@ function gen_instruction_body_after_fixed_g(encoding, size)
|
|||
if_blocks: [{
|
||||
condition: "modrm_byte < 0xC0",
|
||||
body: [].concat(
|
||||
"let addr = ::modrm::decode(ctx.cpu, modrm_byte);",
|
||||
gen_call(`::codegen::gen_modrm_resolve`, ["ctx", "addr"]),
|
||||
"let addr = modrm::decode(ctx.cpu, modrm_byte);",
|
||||
gen_call(`codegen::gen_modrm_resolve`, ["ctx", "addr"]),
|
||||
imm_read_bindings,
|
||||
gen_call(`::codegen::gen_modrm_fn${mem_args.length - 2}`, mem_args),
|
||||
gen_call(`codegen::gen_modrm_fn${mem_args.length - 2}`, mem_args),
|
||||
mem_postfix
|
||||
),
|
||||
}],
|
||||
else_block: {
|
||||
body: [].concat(
|
||||
imm_read_bindings,
|
||||
gen_call(`::codegen::gen_fn${reg_args.length - 2}_const`, reg_args),
|
||||
gen_call(`codegen::gen_fn${reg_args.length - 2}_const`, reg_args),
|
||||
reg_postfix
|
||||
),
|
||||
},
|
||||
|
|
@ -392,7 +392,7 @@ function gen_instruction_body_after_fixed_g(encoding, size)
|
|||
return [].concat(
|
||||
instruction_prefix,
|
||||
imm_read_bindings,
|
||||
gen_call(`::jit_instructions::${instruction_name}_jit`, args),
|
||||
gen_call(`jit_instructions::${instruction_name}_jit`, args),
|
||||
instruction_postfix
|
||||
);
|
||||
}
|
||||
|
|
@ -423,7 +423,7 @@ function gen_instruction_body_after_fixed_g(encoding, size)
|
|||
return [].concat(
|
||||
instruction_prefix,
|
||||
imm_read_bindings,
|
||||
gen_call(`::codegen::gen_fn${args.length - 2}_const`, args),
|
||||
gen_call(`codegen::gen_fn${args.length - 2}_const`, args),
|
||||
instruction_postfix
|
||||
);
|
||||
}
|
||||
|
|
@ -493,7 +493,14 @@ function gen_table()
|
|||
{
|
||||
const code = [
|
||||
"#[cfg_attr(rustfmt, rustfmt_skip)]",
|
||||
"pub fn jit(opcode: u32, ctx: &mut ::jit::JitContext, instr_flags: &mut u32) {",
|
||||
|
||||
"use crate::prefix;",
|
||||
"use crate::jit;",
|
||||
"use crate::jit_instructions;",
|
||||
"use crate::modrm;",
|
||||
"use crate::codegen;",
|
||||
|
||||
"pub fn jit(opcode: u32, ctx: &mut jit::JitContext, instr_flags: &mut u32) {",
|
||||
table,
|
||||
"}",
|
||||
];
|
||||
|
|
@ -549,7 +556,14 @@ function gen_table()
|
|||
{
|
||||
const code = [
|
||||
"#[cfg_attr(rustfmt, rustfmt_skip)]",
|
||||
"pub fn jit(opcode: u32, ctx: &mut ::jit::JitContext, instr_flags: &mut u32) {",
|
||||
|
||||
"use crate::prefix;",
|
||||
"use crate::jit;",
|
||||
"use crate::jit_instructions;",
|
||||
"use crate::modrm;",
|
||||
"use crate::codegen;",
|
||||
|
||||
"pub fn jit(opcode: u32, ctx: &mut jit::JitContext, instr_flags: &mut u32) {",
|
||||
table0f,
|
||||
"}",
|
||||
];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue