apply make format

This commit is contained in:
Nikolai Kumar 2026-06-08 21:18:38 -05:00
parent c9ec8730a9
commit ccff993489
3 changed files with 16 additions and 18 deletions

View File

@ -141,9 +141,9 @@ private:
std::size_t trimElementBitRange(int elem, int bitLsb, int bitMsb) { std::size_t trimElementBitRange(int elem, int bitLsb, int bitMsb) {
auto it = std::lower_bound(m_entries.begin(), m_entries.end(), elem, auto it = std::lower_bound(m_entries.begin(), m_entries.end(), elem,
[](const Entry& e, int idx) {return e.m_msb <idx; }); [](const Entry& e, int idx) { return e.m_msb < idx; });
while(it != m_entries.end() && it->m_lsb <= elem) { while (it != m_entries.end() && it->m_lsb <= elem) {
if(it->m_elemWidth == 0 || it->m_bitMsb < bitLsb || it ->m_bitLsb > bitMsb) { if (it->m_elemWidth == 0 || it->m_bitMsb < bitLsb || it->m_bitLsb > bitMsb) {
++it; ++it;
continue; continue;
} }
@ -166,7 +166,7 @@ private:
it = m_entries.erase(it); it = m_entries.erase(it);
} }
auto ins = std::lower_bound(m_entries.begin(), m_entries.end(), elem, auto ins = std::lower_bound(m_entries.begin(), m_entries.end(), elem,
[](const Entry& e, int idx) {return e.m_msb < idx; }); [](const Entry& e, int idx) { return e.m_msb < idx; });
while (ins != m_entries.end() && ins->m_lsb <= elem while (ins != m_entries.end() && ins->m_lsb <= elem
&& (ins->m_elemWidth == 0 || ins->m_bitLsb <= bitLsb)) { && (ins->m_elemWidth == 0 || ins->m_bitLsb <= bitLsb)) {
++ins; ++ins;
@ -238,15 +238,15 @@ private:
template <typename Elem> template <typename Elem>
static typename std::enable_if<!VlIsVlWide<Elem>::value, Elem>::type static typename std::enable_if<!VlIsVlWide<Elem>::value, Elem>::type
blendElem(Elem cur, const Entry& e) { blendElem(Elem cur, const Entry& e) {
if(e.m_elemWidth == 0) return *static_cast<const Elem*>(e.m_rhsDatap); if (e.m_elemWidth == 0) return *static_cast<const Elem*>(e.m_rhsDatap);
const Entry bitEntry{e.m_bitLsb, e.m_bitMsb, e.m_rhsLsb, e.m_rhsDatap, 0, 0, 0}; const Entry bitEntry{e.m_bitLsb, e.m_bitMsb, e.m_rhsLsb, e.m_rhsDatap, 0, 0, 0};
return applyEntry(cur, bitEntry); return applyEntry(cur, bitEntry);
} }
template <typename Elem> template <typename Elem>
static typename std::enable_if<VlIsVlWide<Elem>::value, Elem>::type static typename std::enable_if<VlIsVlWide<Elem>::value, Elem>::type blendElem(Elem cur,
blendElem(Elem cur, const Entry& e) { const Entry& e) {
if(e.m_elemWidth == 0) return *static_cast<const Elem*>(e.m_rhsDatap); if (e.m_elemWidth == 0) return *static_cast<const Elem*>(e.m_rhsDatap);
Elem res = cur; Elem res = cur;
const Entry bitEntry{e.m_bitLsb, e.m_bitMsb, e.m_rhsLsb, e.m_rhsDatap, 0, 0, 0}; const Entry bitEntry{e.m_bitLsb, e.m_bitMsb, e.m_rhsLsb, e.m_rhsDatap, 0, 0, 0};
applyEntry(res, bitEntry, e.m_bitLsb, e.m_bitMsb, 0); applyEntry(res, bitEntry, e.m_bitLsb, e.m_bitMsb, 0);
@ -293,7 +293,7 @@ public:
for (int idx = startIdx; idx <= endIdx; idx++) { for (int idx = startIdx; idx <= endIdx; idx++) {
const std::size_t uidx = static_cast<std::size_t>(idx); const std::size_t uidx = static_cast<std::size_t>(idx);
Elem& dst = VlForceArrayIndexer<T>::elem(result, uidx); Elem& dst = VlForceArrayIndexer<T>::elem(result, uidx);
if(entry.m_elemWidth == 0){ if (entry.m_elemWidth == 0) {
const Elem* const rhsBasep = static_cast<const Elem*>(entry.m_rhsDatap); const Elem* const rhsBasep = static_cast<const Elem*>(entry.m_rhsDatap);
const int rhsIndex = idx - entry.m_rhsLsb; const int rhsIndex = idx - entry.m_rhsLsb;
dst = rhsBasep[rhsIndex]; dst = rhsBasep[rhsIndex];
@ -366,7 +366,6 @@ public:
const std::size_t at = trimElementBitRange(lsb, bitLsb, bitMsb); const std::size_t at = trimElementBitRange(lsb, bitLsb, bitMsb);
m_entries.insert(m_entries.begin() + at, m_entries.insert(m_entries.begin() + at,
Entry{lsb, msb, rhsLsb, rhsDatap, bitLsb, bitMsb, elemWidth}); Entry{lsb, msb, rhsLsb, rhsDatap, bitLsb, bitMsb, elemWidth});
} }
void release(int lsb, int msb) { void release(int lsb, int msb) {

View File

@ -1095,8 +1095,8 @@ class ForceConvertVisitor final : public VNVisitor {
const AstSel* const selLhsp = VN_CAST(lhsp, Sel); const AstSel* const selLhsp = VN_CAST(lhsp, Sel);
const bool arrayBitSel const bool arrayBitSel
= info.m_hasArraySel && selLhsp && ForceState::getArraySelInfo(lhsp).m_hasBitSel = info.m_hasArraySel && selLhsp && ForceState::getArraySelInfo(lhsp).m_hasBitSel
&& ForceState::isBitwiseDType(selLhsp->fromp()) && ForceState::isBitwiseDType(selLhsp->fromp())
&& (info.m_padMsb - info.m_padLsb + 1) < selLhsp->fromp()->width(); && (info.m_padMsb - info.m_padLsb + 1) < selLhsp->fromp()->width();
AstNodeExpr* const rhsDatap = ForceState::buildRhsDataExpr(flp, info); AstNodeExpr* const rhsDatap = ForceState::buildRhsDataExpr(flp, info);
AstCExpr* const rhsAddrp = new AstCExpr{flp}; AstCExpr* const rhsAddrp = new AstCExpr{flp};
rhsAddrp->add("&("); rhsAddrp->add("&(");
@ -1108,7 +1108,7 @@ class ForceConvertVisitor final : public VNVisitor {
addForceCallp->addPinsp(ForceState::makeConst32(flp, info.m_rangeMsb)); addForceCallp->addPinsp(ForceState::makeConst32(flp, info.m_rangeMsb));
addForceCallp->addPinsp(rhsAddrp); addForceCallp->addPinsp(rhsAddrp);
addForceCallp->addPinsp( addForceCallp->addPinsp(
ForceState::makeConst32(flp, arrayBitSel ? info.m_padLsb : info.m_rangeLsb)); ForceState::makeConst32(flp, arrayBitSel ? info.m_padLsb : info.m_rangeLsb));
if (arrayBitSel) { if (arrayBitSel) {
addForceCallp->addPinsp(ForceState::makeConst32(flp, info.m_padLsb)); addForceCallp->addPinsp(ForceState::makeConst32(flp, info.m_padLsb));
addForceCallp->addPinsp(ForceState::makeConst32(flp, info.m_padMsb)); addForceCallp->addPinsp(ForceState::makeConst32(flp, info.m_padMsb));
@ -1153,12 +1153,11 @@ class ForceConvertVisitor final : public VNVisitor {
const ForceState::ForceRangeInfo rangeInfo const ForceState::ForceRangeInfo rangeInfo
= m_state.getForceRangeInfo(lhsp, releasedVarp, false); = m_state.getForceRangeInfo(lhsp, releasedVarp, false);
const AstSel* const selLhsp = VN_CAST(lhsp, Sel); const AstSel* const selLhsp = VN_CAST(lhsp, Sel);
const bool arrayBitSel const bool arrayBitSel
= rangeInfo.m_hasArraySel && selLhsp && rangeInfo.m_arrayInfo.m_hasBitSel = rangeInfo.m_hasArraySel && selLhsp && rangeInfo.m_arrayInfo.m_hasBitSel
&& ForceState::isBitwiseDType(selLhsp->fromp()) && ForceState::isBitwiseDType(selLhsp->fromp())
&& (rangeInfo.m_padMsb - rangeInfo.m_padLsb + 1) < selLhsp->fromp()->width(); && (rangeInfo.m_padMsb - rangeInfo.m_padLsb + 1) < selLhsp->fromp()->width();
AstCMethodHard* const releaseCallp = new AstCMethodHard{ AstCMethodHard* const releaseCallp = new AstCMethodHard{
flp, new AstVarRef{flp, varInfo->m_forceVecVscp, VAccess::WRITE}, flp, new AstVarRef{flp, varInfo->m_forceVecVscp, VAccess::WRITE},
VCMethod::FORCE_RELEASE, ForceState::makeConst32(flp, rangeInfo.m_rangeLsb)}; VCMethod::FORCE_RELEASE, ForceState::makeConst32(flp, rangeInfo.m_rangeLsb)};

0
test_regress/t/t_force_unpacked_bitsel.py Normal file → Executable file
View File