llvm-project
llvm-project copied to clipboard
[RISCV]Add support for resolving encoding conflicts among vendor specific CSRs
This patch adds the framework for resolving encoding conflicts among CSRs.
Specifically, this patch adds a support for emitting a new lookup function for the primary key which return a pair of iterators pointing to first and last value hence giving a range of values which satisfies the query.
While printing the CSR name during objdump, iterate over the range and print the name of only that CSR which satisifes the feature requirement of subtarget.
Below is the signature of the new function that will be emitted for primary key:
llvm::iterator_range<const SysReg *>
lookupSysRegByEncoding(uint16_t Encoding) {
SysReg Key;
Key.Encoding = Encoding;
auto Table = ArrayRef(SysRegsList);
auto It = std::equal_range(Table.begin(), Table.end(), Key,
[](const SysReg &LHS, const SysReg &RHS) {
if (LHS.Encoding < RHS.Encoding)
return true;
if (LHS.Encoding > RHS.Encoding)
return false;
return false;
});
return llvm::make_range(It.first, It.second);
}