步骤A:isa+toml 新增 RS_OFF 形态(LOAD_PTR/STORE_PTR,0010 前缀 op=8/9)+ 强校验放行 + isa_test roundtrip

This commit is contained in:
2026-08-27 09:13:38 +08:00
parent 92e91350cc
commit 68261cd78b
8 changed files with 71 additions and 6 deletions
+19
View File
@@ -128,6 +128,11 @@ static bool test_fields() {
enc_slot_off(buf, static_cast<uint8_t>(isa::Op::LOAD_OFF), 3, 1, 9, -12);
CHECK(slot32_of(buf) == 9);
CHECK(off32_hi_of(buf) == -12);
// RS_OFF0010 op=8/9rd@2、rs1@3、off@87..56
enc_rs_off(buf, static_cast<uint8_t>(isa::Op::LOAD_PTR), 3, 5, 1, -12);
CHECK(rd_of(buf) == 5);
CHECK(rs1_of(buf) == 1);
CHECK(off32_hi_of(buf) == -12);
// RET
enc_ret(buf);
CHECK(op_of(buf) == static_cast<uint8_t>(isa::Op::RET));
@@ -197,6 +202,20 @@ static bool test_disasm() {
enc_slot_off(buf, static_cast<uint8_t>(isa::Op::LOAD_OFF), 3, 2, 8, 16);
isa::disasm(buf, 16, out, sizeof out);
CHECK(std::strcmp(out, "LOAD_OFF.I16 r2, s8, 16") == 0);
// RS_OFFLOAD_PTR/STORE_PTR
enc_rs_off(buf, static_cast<uint8_t>(isa::Op::LOAD_PTR), 3, 2, 1, 16);
isa::disasm(buf, 16, out, sizeof out);
CHECK(std::strcmp(out, "LOAD_PTR.I16 r2, r1, 16") == 0);
enc_rs_off(buf, static_cast<uint8_t>(isa::Op::STORE_PTR), 9, 9, 1, -4);
isa::disasm(buf, 16, out, sizeof out);
CHECK(std::strcmp(out, "STORE_PTR.F64 r9, r1, -4") == 0);
// decode 回读(encode 路径)
{
isa::Decoded d = isa::decode(buf, 16);
isa::encode(d, buf);
isa::disasm(buf, 16, out, sizeof out);
CHECK(std::strcmp(out, "STORE_PTR.F64 r9, r1, -4") == 0);
}
// 未知(010110 预留区)
buf[0] = 0x58;
isa::disasm(buf, 8, out, sizeof out);
+1 -1
View File
@@ -132,7 +132,7 @@ static bool test_positive() {
CHECK(cfg.find_type("DT") != nullptr && cfg.find_type("DT")->func == 6);
CHECK(cfg.find_type("NOPE") == nullptr);
CHECK(cfg.ops().size() == 72);
CHECK(cfg.ops().size() == 74);
const compiler::ConfigOp* move = cfg.find_op("MOVE");
CHECK(move != nullptr && move->prefix == "11" && move->op == 0 && move->fmt == "RR" &&
move->func_mode == "width" && move->params.size() == 2);