Skip to content
Merged
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
2 changes: 2 additions & 0 deletions src/cpp/preprocessor/aie2ps/aie2ps_preprocessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,14 @@ class aie2ps_preprocessor: public preprocessor
auto& coldata = parser->get_col_asmdata(col);
for (auto label : parser->getLabelsforcol(col))
{
log_debug() << "[" << col << "]: Processing label: " << label << " Relative page index: " << relative_page_index<< std::endl;
// create state
std::vector<std::shared_ptr<asm_data>> data = coldata.get_label_asmdata(label);
std::shared_ptr<assembler_state> state = create_assembler_state(m_isa, data, scratchpad, label_page_index, ctrlpkt_id_map, optimize, true);
// create pages
pager(PAGE_SIZE).pagify(*state, col, pages, relative_page_index);
label_page_index[get_pagelabel(label)] = relative_page_index;
log_debug() << "num pages: " << pages.size() - relative_page_index << std::endl;
relative_page_index = static_cast<uint32_t>(pages.size());
}

Expand Down
6 changes: 3 additions & 3 deletions src/cpp/preprocessor/asm/asm_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ insert_col_asmdata(std::shared_ptr<asm_data> data)
if (m_col.find(m_current_col) == m_col.end())
m_col[m_current_col] = col_data();

auto& label_data = m_col[m_current_col].get_label_data();
if (label_data.find(m_current_label) == label_data.end())
label_data[m_current_label] = section_asmdata();
auto& cdata = m_col[m_current_col];
cdata.ensure_label(m_current_label);
auto& label_data = cdata.get_label_data();

if (get_data_state())
label_data[m_current_label].data.emplace_back(data);
Expand Down
20 changes: 14 additions & 6 deletions src/cpp/preprocessor/asm/asm_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,8 @@ class annotation_type

class col_data
{
// First time a label scope receives asm_data; map iteration order is order of insertion.
Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

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

The comment says “map iteration order is order of insertion”, but std::map iterates in key-sorted order, not insertion order. This is misleading now that insertion order is actually tracked in m_label_insertion_order; update the comment to reflect that the vector preserves insertion order while the map remains sorted by key.

Suggested change
// First time a label scope receives asm_data; map iteration order is order of insertion.
// Tracks the first time a label scope receives asm_data, preserving insertion order.
// Label data itself is stored in m_label_data, whose std::map iteration remains key-sorted.

Copilot uses AI. Check for mistakes.
std::vector<std::string> m_label_insertion_order;
std::map<std::string, section_asmdata> m_label_data;
std::map<std::string, uint32_t> m_labelpageindex;
std::map<std::string, std::shared_ptr<scratchpad_info>> m_scratchpads;
Expand All @@ -363,6 +365,16 @@ class col_data
uint32_t m_preempt_count = 0;
public:

void ensure_label(const std::string& label)
{
if (m_label_data.find(label) == m_label_data.end()) {
m_label_data[label] = section_asmdata();
m_label_insertion_order.push_back(label);
}
}

const std::vector<std::string>& get_label_insertion_order() const { return m_label_insertion_order; }

std::vector<std::shared_ptr<asm_data>> get_label_asmdata(const std::string& label)
{
std::vector<std::shared_ptr<asm_data>> result(m_label_data[label].text);
Expand Down Expand Up @@ -675,13 +687,9 @@ class asm_parser: public std::enable_shared_from_this<asm_parser>

std::map<std::string, uint32_t>& getcollabelpageindex(int col) { return m_col[col].get_labelpageindex(); }

std::vector<std::string> getLabelsforcol(uint32_t col)
const std::vector<std::string>& getLabelsforcol(uint32_t col)
{
std::vector<std::string> keys;
for (const auto& pair : m_col[col].get_label_data()) {
keys.push_back(pair.first);
}
return keys;
return m_col[col].get_label_insertion_order();
}

void insert_scratchpad(std::string& name, offset_type size, std::vector<char>& content);
Expand Down
2 changes: 1 addition & 1 deletion test/aie4-ctrlcode/1col_preempt/gold.md5
Original file line number Diff line number Diff line change
@@ -1 +1 @@
96b00cbda9f5061f2cfef83b22c2e01d
58f4172515858e1c790a38aab7bfa6b9
Loading