Compare commits

..

1 Commits

Author SHA1 Message Date
lizzie c454e30249 2026-09-06 20:58:56
Signed-off-by: lizzie <lizzie@eden-emu.dev>
2026-09-06 20:58:56 +00:00
7 changed files with 44 additions and 59 deletions
+2 -11
View File
@@ -39,16 +39,8 @@ Block::iterator Block::PrependNewInst(iterator insertion_point, Opcode opcode, s
// just pool it!!! - reason why there is an inline buffer is because many small blocks are created
// with few instructions due to subpar optimisations on other passes... plus branch-heavy code will
// hugely benefit from the coherency of faster allocations...
IR::Inst* inst;
if (inlined_inst.size() < inlined_inst.max_size()) {
inlined_inst.emplace_back(opcode);
inst = &inlined_inst[inlined_inst.size() - 1];
} else {
if (pooled_inst.empty() || pooled_inst.back().size() == pooled_inst.back().max_size())
pooled_inst.emplace_back();
pooled_inst.back().emplace_back(opcode);
inst = &pooled_inst.back()[pooled_inst.back().size() - 1];
}
inlined_inst.emplace_back(opcode);
auto* inst = &inlined_inst[inlined_inst.size() - 1];
DEBUG_ASSERT(args.size() == inst->NumArgs());
std::for_each(args.begin(), args.end(), [&inst, index = size_t(0)](const auto& arg) mutable {
inst->SetArg(index, arg);
@@ -61,7 +53,6 @@ void Block::Reset(LocationDescriptor location_) noexcept {
mcl::intrusive_list<IR::Inst> tmp = {};
instructions.swap(tmp);
inlined_inst.clear();
pooled_inst.clear();
cond_failed.reset();
location = location_;
end_location = location_;
+2 -4
View File
@@ -142,11 +142,9 @@ public:
}
/// "Hot cache" for small blocks so we don't call global allocator
boost::container::static_vector<Inst, 30> inlined_inst;
boost::container::static_vector<Inst, 4096> inlined_inst = {};
/// List of instructions in this block.
instruction_list_type instructions;
/// "Long/far" memory pool
boost::container::stable_vector<boost::container::static_vector<Inst, 32>> pooled_inst;
/// Block to execute next if `cond` did not pass.
std::optional<LocationDescriptor> cond_failed = {};
/// Description of the starting location of this block
@@ -162,7 +160,7 @@ public:
/// Number of cycles this block takes to execute.
size_t cycle_count = 0;
};
static_assert(sizeof(Block) == 4096);
//static_assert(sizeof(Block) == 4096);
/// Returns a string representation of the contents of block. Intended for debugging.
std::string DumpBlock(const IR::Block& block) noexcept;
+2
View File
@@ -321,6 +321,8 @@ static void RunTestInstance(Dynarmic::A32::Jit& jit,
uni_env.PadCodeMem();
jit_env.modified_memory.clear();
uni_env.modified_memory.clear();
jit_env.interrupts.clear();
uni_env.interrupts.clear();
jit.Regs() = regs;
jit.ExtRegs() = vecs;
@@ -176,6 +176,8 @@ static void RunTestInstance(Dynarmic::A64::Jit& jit, A64Unicorn& uni, A64TestEnv
uni_env.code_mem_start_address = instructions_start;
jit_env.modified_memory.clear();
uni_env.modified_memory.clear();
jit_env.interrupts.clear();
uni_env.interrupts.clear();
const u64 initial_sp = RandInt<u64>(0x30'0000'0000, 0x40'0000'0000) * 4;
+10 -4
View File
@@ -282,17 +282,20 @@ int main(int argc, char** argv) {
return 1;
}
const char* const hex_instruction = [s = argv[2]] {
if (strlen(s) > 2 && s[0] == '0' && s[1] == 'x')
return s + 2;
return s;
const char* const hex_instruction = [argv] {
if (strlen(argv[2]) > 2 && argv[2][0] == '0' && argv[2][1] == 'x') {
return argv[2] + 2;
}
return argv[2];
}();
if (strlen(hex_instruction) > 8) {
fmt::print("hex string too long\n");
return 1;
}
const u32 instruction = strtol(hex_instruction, nullptr, 16);
if (strcmp(argv[1], "a32") == 0) {
PrintA32Instruction(instruction);
} else if (strcmp(argv[1], "a64") == 0) {
@@ -303,11 +306,13 @@ int main(int argc, char** argv) {
fmt::print("Invalid mode: {}\nValid values: a32, a64, thumb\n", argv[1]);
return 1;
}
if (argc == 4) {
if (strcmp(argv[3], "-exec") != 0) {
fmt::print("Invalid option {}\n", argv[3]);
return 1;
}
if (strcmp(argv[1], "a32") == 0) {
ExecuteA32Instruction(instruction);
} else {
@@ -315,5 +320,6 @@ int main(int argc, char** argv) {
return 1;
}
}
return 0;
}
+24 -40
View File
@@ -354,8 +354,6 @@ u32 GenRandomA64Inst(u64 pc, bool is_last_inst) {
"MSR_reg",
"MSR_imm",
"MRS",
// generates F16
"FCADD_vec",
};
for (const auto& [fn, bitstring] : list) {
@@ -442,6 +440,7 @@ void RunTestInstance(Dynarmic::A32::Jit& jit,
std::copy(instructions.begin(), instructions.end(), jit_env.code_mem.begin() + num_words);
jit_env.PadCodeMem();
jit_env.modified_memory.clear();
jit_env.interrupts.clear();
jit.Regs() = regs;
jit.ExtRegs() = vecs;
@@ -511,6 +510,7 @@ void RunTestInstance(Dynarmic::A64::Jit& jit,
jit_env.code_mem.emplace_back(0x14000000); // B .
jit_env.code_mem_start_address = start_address;
jit_env.modified_memory.clear();
jit_env.interrupts.clear();
jit.SetRegisters(regs);
jit.SetVectors(vecs);
@@ -536,52 +536,36 @@ void RunTestInstance(Dynarmic::A64::Jit& jit,
fmt::print("initial_regs:");
for (u64 i : regs)
fmt::print(" {:016x}", i);
fmt::print(
"\n"
"initial_vecs:"
);
fmt::print("\n");
fmt::print("initial_vecs:");
for (auto i : vecs)
fmt::print(" {:016x}:{:016x}", i[0], i[1]);
fmt::print(
"\n"
"initial_sp: {:016x}\n"
"initial_pstate: {:08x}\n"
"initial_fpcr: {:08x}\n"
"final_regs:"
, initial_sp
, pstate
, fpcr
);
fmt::print("\n");
fmt::print("initial_sp: {:016x}\n", initial_sp);
fmt::print("initial_pstate: {:08x}\n", pstate);
fmt::print("initial_fpcr: {:08x}\n", fpcr);
fmt::print("final_regs:");
for (u64 i : jit.GetRegisters())
fmt::print(" {:016x}", i);
fmt::print(
"\n"
"final_vecs:"
);
fmt::print("\n");
fmt::print("final_vecs:");
for (auto i : jit.GetVectors())
fmt::print(" {:016x}:{:016x}", i[0], i[1]);
fmt::print(
"\n"
"final_sp: {:016x}\n"
"final_pc: {:016x}\n"
"final_pstate: {:08x}\n"
"final_fpcr: {:08x}\n"
"final_qc : {}\n"
"mod_mem:"
, jit.GetSP()
, jit.GetPC()
, jit.GetPstate()
, jit.GetFpcr()
, FP::FPSR{jit.GetFpsr()}.QC()
);
fmt::print("\n");
fmt::print("final_sp: {:016x}\n", jit.GetSP());
fmt::print("final_pc: {:016x}\n", jit.GetPC());
fmt::print("final_pstate: {:08x}\n", jit.GetPstate());
fmt::print("final_fpcr: {:08x}\n", jit.GetFpcr());
fmt::print("final_qc : {}\n", FP::FPSR{jit.GetFpsr()}.QC());
fmt::print("mod_mem:");
for (auto [addr, value] : jit_env.modified_memory)
fmt::print(" {:08x}:{:02x}", addr, value);
fmt::print(
"\n"
"===\n"
"{}"
, jit.Disassemble()
);
fmt::print("\n");
fmt::print("interrupts:\n");
for (const auto& i : jit_env.interrupts)
std::puts(i.c_str());
fmt::print("===\n");
fmt::print("{}", jit.Disassemble());
}
}
+2
View File
@@ -99,6 +99,7 @@ void RunTestInstance(Dynarmic::A32::Jit& jit,
std::copy(instructions.begin(), instructions.end(), jit_env.code_mem.begin() + num_words);
jit_env.PadCodeMem();
jit_env.modified_memory.clear();
jit_env.interrupts.clear();
jit.Regs() = regs;
jit.ExtRegs() = vecs;
@@ -191,6 +192,7 @@ void RunTestInstance(A64::Jit& jit,
jit_env.code_mem.emplace_back(0x14000000); // B .
jit_env.code_mem_start_address = start_address;
jit_env.modified_memory.clear();
jit_env.interrupts.clear();
jit.SetRegisters(regs);
jit.SetVectors(vecs);