Skip to content

Commit

Permalink
Address more PR feedback
Browse files Browse the repository at this point in the history
Signed-off-by: Dave Thaler <[email protected]>
  • Loading branch information
dthaler committed Mar 14, 2024
1 parent 9d7101e commit e96578f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
11 changes: 2 additions & 9 deletions src/asm_parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,18 +191,11 @@ Instruction parse_instruction(const std::string& line, const std::map<std::strin
.is_load = false,
};
}
if (regex_match(text, m, regex("lock " DEREF PAREN(REG PLUSMINUS IMM) " " ATOMICOP " " REG))) {
if (regex_match(text, m, regex("lock " DEREF PAREN(REG PLUSMINUS IMM) " " ATOMICOP " " REG "( fetch)?"))) {
Atomic::Op op = str_to_atomicop.at(m[5]);
return Atomic{
.op = op,
.fetch = (op == Atomic::Op::XCHG || op == Atomic::Op::CMPXCHG),
.access = deref(m[1], m[2], m[3], m[4]),
.valreg = reg(m[6])};
}
if (regex_match(text, m, regex("lock " DEREF PAREN(REG PLUSMINUS IMM) " " ATOMICOP " " REG " fetch"))) {
return Atomic{
.op = str_to_atomicop.at(m[5]),
.fetch = true,
.fetch = m[7].matched || op == Atomic::Op::XCHG || op == Atomic::Op::CMPXCHG,
.access = deref(m[1], m[2], m[3], m[4]),
.valreg = reg(m[6])};
}
Expand Down
2 changes: 1 addition & 1 deletion src/asm_syntax.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ struct Atomic {
};

Op op;
bool fetch;
bool fetch{};
Deref access;
Reg valreg;
constexpr bool operator==(const Atomic&) const = default;
Expand Down
6 changes: 6 additions & 0 deletions src/test/test_marshal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,13 @@ TEST_CASE("disasm_marshal", "[disasm][marshal]") {
compare_marshal_unmarshal(Atomic{.op = Atomic::Op::AND, .fetch = true, .access = access, .valreg = Reg{1}});
compare_marshal_unmarshal(Atomic{.op = Atomic::Op::XOR, .fetch = false, .access = access, .valreg = Reg{1}});
compare_marshal_unmarshal(Atomic{.op = Atomic::Op::XOR, .fetch = true, .access = access, .valreg = Reg{1}});
check_marshal_unmarshal_fail(
Atomic{.op = Atomic::Op::XCHG, .fetch = false, .access = access, .valreg = Reg{1}},
"0: unsupported immediate\n");
compare_marshal_unmarshal(Atomic{.op = Atomic::Op::XCHG, .fetch = true, .access = access, .valreg = Reg{1}});
check_marshal_unmarshal_fail(
Atomic{.op = Atomic::Op::CMPXCHG, .fetch = false, .access = access, .valreg = Reg{1}},
"0: unsupported immediate\n");
compare_marshal_unmarshal(Atomic{.op = Atomic::Op::CMPXCHG, .fetch = true, .access = access, .valreg = Reg{1}});
}
}
Expand Down

0 comments on commit e96578f

Please sign in to comment.