fixed data + instruction cache callbacks (w/ tests)
This commit is contained in:
parent
77621a8448
commit
6d4333c78e
3 changed files with 31 additions and 3 deletions
|
@ -647,13 +647,13 @@ void A64EmitX64::EmitA64ExceptionRaised(A64EmitContext& ctx, IR::Inst* inst) {
|
|||
|
||||
void A64EmitX64::EmitA64DataCacheOperationRaised(A64EmitContext& ctx, IR::Inst* inst) {
|
||||
auto args = ctx.reg_alloc.GetArgumentInfo(inst);
|
||||
ctx.reg_alloc.HostCall(nullptr, args[0], args[1]);
|
||||
ctx.reg_alloc.HostCall(nullptr, {}, args[0], args[1]);
|
||||
Devirtualize<&A64::UserCallbacks::DataCacheOperationRaised>(conf.callbacks).EmitCall(code);
|
||||
}
|
||||
|
||||
void A64EmitX64::EmitA64InstructionCacheOperationRaised(A64EmitContext& ctx, IR::Inst* inst) {
|
||||
auto args = ctx.reg_alloc.GetArgumentInfo(inst);
|
||||
ctx.reg_alloc.HostCall(nullptr, args[0], args[1]);
|
||||
ctx.reg_alloc.HostCall(nullptr, {}, args[0], args[1]);
|
||||
Devirtualize<&A64::UserCallbacks::InstructionCacheOperationRaised>(conf.callbacks).EmitCall(code);
|
||||
}
|
||||
|
||||
|
|
|
@ -634,3 +634,31 @@ TEST_CASE("A64: Optimization failure when folding ADD", "[a64]") {
|
|||
REQUIRE(jit.GetPstate() == 0x20000000);
|
||||
REQUIRE(jit.GetVector(30) == Vector{0xf7f6f5f4, 0});
|
||||
}
|
||||
|
||||
TEST_CASE("A64: Cache Maintenance Instructions", "[a64]") {
|
||||
class CacheMaintenanceTestEnv final : public A64TestEnv {
|
||||
void InstructionCacheOperationRaised(A64::InstructionCacheOperation op, VAddr value) override {
|
||||
REQUIRE(op == A64::InstructionCacheOperation::InvalidateByVAToPoU);
|
||||
REQUIRE(value == 0xcafed00d);
|
||||
}
|
||||
void DataCacheOperationRaised(A64::DataCacheOperation op, VAddr value) override {
|
||||
REQUIRE(op == A64::DataCacheOperation::InvalidateByVAToPoC);
|
||||
REQUIRE(value == 0xcafebabe);
|
||||
}
|
||||
};
|
||||
|
||||
CacheMaintenanceTestEnv env;
|
||||
A64::UserConfig conf{&env};
|
||||
conf.hook_data_cache_operations = true;
|
||||
A64::Jit jit{conf};
|
||||
|
||||
jit.SetRegister(0, 0xcafed00d);
|
||||
jit.SetRegister(1, 0xcafebabe);
|
||||
|
||||
env.code_mem.emplace_back(0xd50b7520); // ic ivau, x0
|
||||
env.code_mem.emplace_back(0xd5087621); // dc ivac, x1
|
||||
env.code_mem.emplace_back(0x14000000); // B .
|
||||
|
||||
env.ticks_left = 3;
|
||||
jit.Run();
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
using Vector = Dynarmic::A64::Vector;
|
||||
|
||||
class A64TestEnv final : public Dynarmic::A64::UserCallbacks {
|
||||
class A64TestEnv : public Dynarmic::A64::UserCallbacks {
|
||||
public:
|
||||
u64 ticks_left = 0;
|
||||
|
||||
|
|
Loading…
Reference in a new issue