@@ -269,6 +269,7 @@ class asm_data
269269 // m_file replaced with a 32-bit index into a thread_local intern table.
270270 uint32_t m_file_idx;
271271 int m_annotation_index = -1 ;
272+ bool m_is_save_restore = false ; // True if this instruction is from save/restore routine
272273
273274public:
274275 asm_data () = default ;
@@ -282,17 +283,18 @@ class asm_data
282283 */
283284 asm_data (operation op, operation_type optype,
284285 code_section sec, offset_type size, uint32_t pgnum,
285- uint32_t ln, uint32_t file_idx)
286+ uint32_t ln, uint32_t file_idx, bool is_save_restore = false )
286287 :m_op(std::move(op)), m_optype(optype), m_section(sec), m_size(size),
287288 m_pagenum (pgnum), m_linenumber(ln),
288- m_file_idx(file_idx) {}
289+ m_file_idx(file_idx), m_is_save_restore(is_save_restore) {}
289290
290291 // Rule of Zero: implicit copy/move keeps insert_col_asmdata / vector growth cheap.
291292
292293 HEADER_ACCESS_GET_SET (code_section, section);
293294 HEADER_ACCESS_GET_SET (offset_type, size);
294295 HEADER_ACCESS_GET_SET (pageid_type, pagenum);
295296 HEADER_ACCESS_GET_SET (uint32_t , linenumber);
297+
296298 const std::string& get_file () const { return detail::lookup_filename (m_file_idx); }
297299 uint32_t get_file_idx () const { return m_file_idx; }
298300 // Qualify the operation's own name as a label-map key (e.g. "0:start_job").
@@ -322,6 +324,7 @@ class asm_data
322324 return n + ' ' + a;
323325 }
324326
327+ HEADER_ACCESS_GET_SET (bool , is_save_restore);
325328 bool isLabel () const { return m_optype == operation_type::label; }
326329 bool isOpcode () const { return m_optype == operation_type::op; }
327330 bool isAnnotation () const { return m_optype == operation_type::annotation; }
@@ -478,6 +481,7 @@ class asm_parser: public std::enable_shared_from_this<asm_parser>
478481 std::map<int , std::vector<std::string>> m_preempt_hintmaps; // group -> vector of hintmap_labels (multiple PREEMPT opcodes per group)
479482 std::map<std::string, std::pair<std::string, std::string>> m_hintmap_labels; // hintmap_label -> (save_label, restore_label)
480483 std::set<int > m_preempt_without_hintmap; // groups that have PREEMPT opcodes without hintmaps
484+ bool m_is_save_restore_routine = false ; // True when parsing save/restore routine files
481485
482486 // One unique scratchpad region: all hintmap labels that share the same scratchbase+size
483487 struct hintmap_group_entry {
@@ -557,6 +561,20 @@ class asm_parser: public std::enable_shared_from_this<asm_parser>
557561
558562 bool is_multi_column_mode () const { return m_preempt_labels.size () > 1 ; }
559563
564+ // Check if currently parsing save/restore routine
565+ bool is_save_restore_routine () const { return m_is_save_restore_routine; }
566+ void set_save_restore_routine (bool val) { m_is_save_restore_routine = val; }
567+
568+ // Check if we should skip setpad for this target in save/restore routine
569+ bool should_skip_setpad_in_save_restore () const {
570+ return m_is_save_restore_routine;
571+ }
572+
573+ // Check if we should use scratch-pad section for save/restore APPLY_OFFSET_57
574+ // bool should_use_scratchpad_section_for_save_restore() const {
575+ // return m_is_save_restore_routine;
576+ // }
577+
560578 // Record preempt label for current group (called when PREEMPT opcode is hit)
561579 // Label naming: save_N / restore_N where N = index (group/2 + 1)
562580 // group 0 -> save_1, group 2 -> save_2, group 4 -> save_3
0 commit comments