Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

triggers: implement {mcontrol,mcontrol6}.match = {not equal,not napot,not mask low,not mask high} #1348

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion riscv/triggers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,25 @@ bool mcontrol_common_t::simple_match(unsigned xlen, reg_t value) const {
reg_t mask = tdata2 >> (xlen/2);
return ((value >> (xlen/2)) & mask) == (tdata2 & mask);
}
case MATCH_NOT_EQUAL:
return value != tdata2;
case MATCH_NOT_NAPOT:
{
reg_t mask = ~((1 << (cto(tdata2)+1)) - 1);
return (value & mask) != (tdata2 & mask);
}
case MATCH_NOT_MASK_LOW:
{
reg_t mask = tdata2 >> (xlen/2);
return (value & mask) != (tdata2 & mask);
}
case MATCH_NOT_MASK_HIGH:
{
reg_t mask = tdata2 >> (xlen/2);
return ((value >> (xlen/2)) & mask) != (tdata2 & mask);
}
default: assert(false);
}
assert(0);
}

std::optional<match_result_t> mcontrol_common_t::detect_memory_access_match(processor_t * const proc, operation_t operation, reg_t address, std::optional<reg_t> data) noexcept {
Expand Down Expand Up @@ -245,6 +262,10 @@ mcontrol_common_t::match_t mcontrol_common_t::legalize_match(reg_t val) noexcept
case MATCH_LT:
case MATCH_MASK_LOW:
case MATCH_MASK_HIGH:
case MATCH_NOT_EQUAL:
case MATCH_NOT_NAPOT:
case MATCH_NOT_MASK_LOW:
case MATCH_NOT_MASK_HIGH:
return (match_t)val;
default:
return MATCH_EQUAL;
Expand Down
6 changes: 5 additions & 1 deletion riscv/triggers.h
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The encoding.h does not have MCONTROL_MATCH_NOT_EQUAL, MCONTROL_MATCH_NOT_NAPOT, MCONTROL_MATCH_NOT_MASK_LOW, MCONTROL_MATCH_NOT_MASK_HIGH. Without modifying encoding.h (or without including debug_defines.h), we must hardcode the values. However, that makes this part inconsistent. Should we also hardcode the values of MATCH_EQUAL, MATCH_NAPOT, MATCH_GE, MATCH_LT, MATCH_MASK_LOW, and MATCH_MASK_HIGH?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the problem with including debug_defines.h? That seems easier to maintain, etc. Are there macro name conflicts?

Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,11 @@ class mcontrol_common_t : public trigger_t {
MATCH_GE = MCONTROL_MATCH_GE,
MATCH_LT = MCONTROL_MATCH_LT,
MATCH_MASK_LOW = MCONTROL_MATCH_MASK_LOW,
MATCH_MASK_HIGH = MCONTROL_MATCH_MASK_HIGH
MATCH_MASK_HIGH = MCONTROL_MATCH_MASK_HIGH,
MATCH_NOT_EQUAL = 8,
MATCH_NOT_NAPOT = 9,
MATCH_NOT_MASK_LOW = 12,
MATCH_NOT_MASK_HIGH = 13
} match_t;

virtual bool get_dmode() const override { return dmode; }
Expand Down