A method and device for interrupt control based on function call graph

By obtaining the function call diagram of the interrupt processing function, accurately identify the registers actually used by the interrupt service routine, and generate corresponding register usage information, solving unnecessary register storage problems in the hardware mechanism, and improving the efficiency and response speed of interrupt processing.

CN120295841BActive Publication Date: 2025-08-12ZHONGZHI QIXIN (SHANGHAI) TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510771853.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-06-11
Publication Date
2025-08-12
Estimated Expiration
2045-06-11

AI Technical Summary

Technical Problem

In the interrupt processing process in the prior art, since the hardware mechanism can only use the method of saving the complete register state, unnecessary time overhead is caused, which reduces the interrupt processing efficiency.

Method used

By obtaining the function call diagram of the interrupt processing function, accurately identify the registers actually used by the interrupt service routine, generate corresponding register usage information, and delete unnecessary save and recovery instructions during the compilation process to optimize register management.

Benefits of technology

Improves the efficiency and response speed of interrupt processing, and reduces unnecessary register storage and recovery operations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120295841B_ABST
    Figure CN120295841B_ABST
Patent Text Reader

Abstract

The present invention provides an interrupt control method and device based on a function call graph. The method includes: obtaining an interrupt handling function, and a compiler generating a function call graph corresponding to the interrupt handling function; if the currently compiled function belongs to a function in the function call graph, generating usage information for each caller-save register assigned to the function; when the interrupt handling function is a function written in a high-level language, the compiler sets corresponding usage information for each allocated first caller-save register and each allocated first callee-save register; when the interrupt handling function is a function written in a low-level language, the compiler updates the usage information based on the second caller-save register and the second callee-save register used in each instruction of the function; and updating the register usage information of the function. The interrupt control method and device provided by the present invention improve the efficiency of interrupt handling by accurately identifying the registers actually used by the interrupt service routine.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the technical field of interrupt processing, and in particular to an interrupt control method and device based on a function call graph. Background Art

[0002] During interrupt processing, the processor must save its current operating state to designated registers or storage space and restore this state after the interrupt returns to ensure continuity before and after the interrupt. This state, known as the interrupt context, generally includes key information such as the processor's control status registers, general-purpose registers, and floating-point registers. The time required to save and restore the interrupt context is a key technical factor affecting the system's interrupt response speed.

[0003] Conventional technology typically implements automatic context switching through hardware-supported mechanisms. However, when an interrupt is triggered, the hardware can only manage context by saving the entire register state. This means that even if some general-purpose registers are not used during the current interrupt processing, they are unnecessarily saved and restored, resulting in additional time overhead and reducing overall interrupt processing efficiency.

[0004] Therefore, it is necessary to provide an interrupt control method and device based on a function call graph to effectively solve the above problems. Summary of the Invention

[0005] The present invention provides an interrupt control method and device based on a function call graph, which improves the efficiency and response speed of interrupt processing by accurately identifying the registers actually used by the interrupt service routine.

[0006] An embodiment of the present invention provides an interrupt control method based on a function call graph, comprising:

[0007] Obtaining an interrupt handling function, and the compiler generating a function call graph corresponding to the interrupt handling function;

[0008] If the currently compiled function belongs to a function in the function call graph, generating usage information for each caller-saved register allocated to the function;

[0009] If the currently compiled function does not belong to the functions in the function call graph, normal compilation is performed;

[0010] When the interrupt handling function is a function written in a high-level language, the compiler sets corresponding usage information for each allocated first caller-save register and each allocated first callee-save register; and at the same time, the compiler does not generate instructions for saving and restoring the first caller-save register and the first callee-save register when generating code;

[0011] When the interrupt handling function is a function written in a low-level language, the compiler updates usage information according to the second caller-saved register and the second callee-saved register used in each instruction of the function; and at the same time, if there are instructions for saving and restoring the second caller-saved register and the second callee-saved register in the code, the instructions are deleted;

[0012] Updates register usage information for a function.

[0013] Preferably, the register usage information of the update function includes:

[0014] If the function call graph is empty, the function does not call other functions and there is no need to update the register usage information;

[0015] If the function call graph is not empty, a depth-first traversal is performed on each function in the function call graph, and caller-saved register information of the child function is merged into the parent function.

[0016] Preferably, the step of merging the caller-saved register information of the child function into the parent function comprises:

[0017] If the function in the function call graph is a function with source code, if its register usage information already completely includes the caller-save register usage information of all sub-functions, then no update is required; if the function in the function call graph does not call other functions, then its register usage information is marked as complete; if the function in the function call graph has one or more sub-functions, then the register usage information of the one or more sub-functions is recursively updated, and the caller-save register usage information of the one or more sub-functions is incorporated into the register usage information of the function in the function call graph; if the function in the function call graph already includes the caller-save register usage information of all sub-functions, then the register usage information of the function in the function call graph is marked as complete;

[0018] If the function in the function call graph is a function with only binary code, if the instruction is a function call, the called function is identified and this step is recursively executed; if the instruction uses the caller-save register, the caller-save register usage information is updated.

[0019] Preferably, the register usage information of the interrupt processing function is recorded in a bit mask manner, 1 indicates that the register of the interrupt processing function is used, and 0 indicates that the register of the interrupt processing function is not used.

[0020] Preferably, the method further comprises:

[0021] When the interrupt processing function is registered, register usage information corresponding to the interrupt processing function is synchronously registered. The processor reads the register usage information when the interrupt is triggered and determines the register set to be saved according to the register usage information.

[0022] Preferably, when the processor responds to the interrupt handling function and is ready to jump to the interrupt service routine, the processor reads the register usage information corresponding to the interrupt number;

[0023] Determine whether the register is in an unrestored state based on the register usage information of the corresponding interrupt number. If the register recovery has not been completed for the previous interrupt, confirm the unsaved registers required for the current interrupt, and the processor automatically saves the unsaved registers; if the register recovery has been completed for the previous interrupt, the processor automatically saves the registers marked as used in the register usage information.

[0024] Preferably, before the interrupt handling function is about to return, the processor determines whether to restore the register immediately according to the current interrupt status;

[0025] If the current interrupt status indicates that there is a new interrupt processing request, the register restoration operation is not performed, the current context is marked as unrestored, the current interrupt process is exited, and the new interrupt service routine is executed;

[0026] If the current interrupt status is that there is no new interrupt processing request, all registers saved in the current context are restored and the interrupt processing function is exited normally.

[0027] Preferably, a dedicated register is provided for storing a register usage information table, the register usage information table including an index basis and table entry content, the index basis including an interrupt number ID, and the table entry content including register usage information corresponding to the interrupt number ID.

[0028] Preferably, the reading of the table entry content includes:

[0029] Calculate the address according to the interrupt number ID: base address + ID × information item size;

[0030] Read the corresponding register usage information from the address.

[0031] An embodiment of the present invention further provides an interrupt control device based on a function call graph, comprising:

[0032] A function call graph generation module is used to obtain an interrupt handling function, and the compiler generates a function call graph corresponding to the interrupt handling function;

[0033] a register usage information generating module, configured to generate usage information for each caller-saved register allocated to a function if the currently compiled function belongs to a function in the function call graph;

[0034] a first usage information setting module configured to, when the interrupt handling function is a function written in a high-level language, cause the compiler to set corresponding usage information for each allocated first caller-save register and each allocated first callee-save register; and, at the same time, not generate instructions for saving and restoring the first caller-save register and the first callee-save register when generating code;

[0035] a second usage information setting module configured to, when the interrupt handling function is a function written in a low-level language, cause the compiler to update usage information based on the second caller-save register and the second callee-save register used in each instruction of the function; and, if an instruction for saving and restoring the second caller-save register and the second callee-save register exists in the code, delete the instruction;

[0036] The register usage information update module is used to update the register usage information of the function.

[0037] Compared with the prior art, the technical solution of the embodiment of the present invention has the following beneficial effects:

[0038] An embodiment of the present invention provides an interrupt control method and device based on a function call graph. The method includes: obtaining an interrupt handling function, and a compiler generating a function call graph corresponding to the interrupt handling function; if the currently compiled function belongs to a function in the function call graph, generating usage information for each caller-saved register assigned to the function; when the interrupt handling function is written in a high-level language, the compiler sets corresponding usage information for each allocated first caller-saved register and each allocated first callee-saved register; and when generating code, the compiler does not generate instructions for saving and restoring the first caller-saved register and the first callee-saved register; when the interrupt handling function is written in a low-level language, the compiler updates the usage information based on the second caller-saved register and the second callee-saved register used in each instruction of the function; and if there is an instruction in the code to save and restore the second caller-saved register and the second callee-saved register, deleting the instruction; updating the register usage information of the function, and improving the efficiency and response speed of interrupt handling by accurately identifying the registers actually used by the interrupt service routine;

[0039] Furthermore, if the function call graph is empty, the function does not call other functions and there is no need to update the register usage information; if the function call graph is not empty, a depth-first traversal is performed on each function in the function call graph, and the register information saved by the caller of the child function is merged into the parent function, thereby effectively updating the register usage information of the function;

[0040] Furthermore, if the function in the function call graph is a function with source code, if its register usage information already completely includes the caller-save register usage information of all sub-functions, no update is required; if the function in the function call graph does not call other functions, its register usage information is marked as complete; if the function in the function call graph has one or more sub-functions, the register usage information of the one or more sub-functions is recursively updated, and the caller-save register usage information of the one or more sub-functions is incorporated into the register usage information of the function in the function call graph; if the function in the function call graph already includes the caller-save register usage information of all sub-functions, the register usage information of the function in the function call graph is marked as complete; if the function in the function call graph is a function with only binary code, if the instruction is a function call, the called function is identified and this step is recursively executed; if the instruction uses the caller-save register, the caller-save register usage information is updated, so that different function update strategies are adopted for different situations of functions with source code and functions with only binary code. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] To more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention, not all embodiments. Those skilled in the art can also derive other drawings based on these drawings without inventive effort.

[0042] Figure 1 A schematic flow chart of an interrupt control method based on a function call graph provided by one embodiment of the present invention;

[0043] Figure 2 A schematic diagram of a function call graph of an interrupt control method based on a function call graph provided by one embodiment of the present invention;

[0044] Figure 3 A schematic flow chart of an interrupt control method based on a function call graph provided in accordance with another embodiment of the present invention;

[0045] Figure 4A schematic diagram of a module of an interrupt control device based on a function call graph provided by one embodiment of the present invention. DETAILED DESCRIPTION

[0046] To make the objectives, technical solutions, and advantages of the embodiments of the present invention more clear, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts shall fall within the scope of protection of the present invention.

[0047] The technical solution of the present invention is described in detail below with reference to specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.

[0048] Based on the problems existing in the prior art, an embodiment of the present invention provides an interrupt control method and device based on a function call graph, which improves the efficiency and response speed of interrupt processing by accurately identifying the registers actually used by the interrupt service routine.

[0049] Figure 1 A flow chart of an interrupt control method based on a function call graph is provided for one embodiment of the present invention. Figure 1 , an embodiment of the present invention provides an interrupt control method based on a function call graph, comprising:

[0050] Step S101: obtaining an interrupt handling function, and the compiler generating a function call graph corresponding to the interrupt handling function;

[0051] Step S102: if the currently compiled function belongs to a function in the function call graph, generating usage information for each caller-saved register allocated to the function;

[0052] Step S103: If the currently compiled function does not belong to the functions in the function call graph, then normal compilation is performed;

[0053] Step S104: When the interrupt handling function is a function written in a high-level language, the compiler sets corresponding usage information for each allocated first caller-saved register and each allocated first callee-saved register; and at the same time, the compiler does not generate instructions for saving and restoring the first caller-saved register and the first callee-saved register when generating code.

[0054] Step S105: When the interrupt handling function is a function written in a low-level language, the compiler updates usage information based on the second caller-save register and the second callee-save register used in each instruction of the function; and if there are instructions for saving and restoring the second caller-save register and the second callee-save register in the code, the instructions are deleted;

[0055] Step S106: Update the register usage information of the function.

[0056] Specifically, the compiler analyzes the general registers and floating-point registers actually used by each interrupt handler and generates register usage information. Each register usage information has a unique symbolic name that corresponds to the corresponding interrupt handler function for subsequent software calls.

[0057] In step S104, since the compiler does not generate instructions for saving and restoring the first caller-save register and the first callee-save register when generating code, unnecessary register save and restore operations are avoided. The function written in a high-level language may be, for example, a function written in C language.

[0058] In step S105, if there are instructions in the code to save and restore the second caller-save register and the second callee-save register, the instructions are deleted to avoid repeated saving. The function written in a low-level language can be, for example, a function written in assembly language.

[0059] For example, the compiler analyzes register usage information of the interrupt handling function, which may include interrupt handling function 0, interrupt handling function 1...interrupt handling function n-1, and accordingly generates register usage information 0, register usage information 1...register usage information n-1.

[0060] Figure 2 A schematic diagram of a function call graph of an interrupt control method based on a function call graph is provided for an embodiment of the present invention. Figure 2 The register usage information for the interrupt handling function includes: ISR, A1_U, A2_U, and A3. The caller-save register usage information A1_U for function A1 includes: A1, B1_U, and B2. The caller-save register usage information B1_U for function B1 includes: B1 and C1. The caller-save register usage information for function C1 includes: the caller-save register C1 used by the self-contained function itself.

[0061] In some embodiments, the register usage information of the update function includes:

[0062] If the function call graph is empty, the function does not call other functions and there is no need to update the register usage information;

[0063] If the function call graph is not empty, a depth-first traversal is performed on each function in the function call graph, and caller-saved register information of the child function is merged into the parent function.

[0064] In some embodiments, merging the caller-saved register information of the child function into the parent function includes:

[0065] If the function in the function call graph is a function with source code, if its register usage information already completely includes the caller-save register usage information of all sub-functions, then no update is required; if the function in the function call graph does not call other functions, then its register usage information is marked as complete; if the function in the function call graph has one or more sub-functions, then the register usage information of the one or more sub-functions is recursively updated, and the caller-save register usage information of the one or more sub-functions is incorporated into the register usage information of the function in the function call graph; if the function in the function call graph already includes the caller-save register usage information of all sub-functions, then the register usage information of the function in the function call graph is marked as complete;

[0066] If the function in the function call graph is a function with only binary code, if the instruction is a function call, the called function is identified and this step is recursively executed; if the instruction uses the caller-save register, the caller-save register usage information is updated.

[0067] In some embodiments, register usage information for the interrupt handler function is recorded using a bit mask, with one bit representing the usage status of each register. For example, a 1 indicates that the register for the interrupt handler function is in use, and a 0 indicates that the register for the interrupt handler function is not in use. For example, for 32 registers, a 32-bit (4-byte) bit mask data can be used to represent them.

[0068] In some embodiments, the method further comprises:

[0069] When the interrupt processing function is registered, register usage information corresponding to the interrupt processing function is synchronously registered. The processor reads the register usage information when the interrupt is triggered and determines the register set to be saved according to the register usage information.

[0070] In some embodiments, when the processor responds to the interrupt handling function and is about to jump to the interrupt service routine (ISR), the processor reads the register usage information corresponding to the interrupt number;

[0071] Determine whether the register is in an unrestored state based on the register usage information of the corresponding interrupt number. If the register recovery has not been completed for the previous interrupt, confirm the unsaved registers required for the current interrupt, and the processor automatically saves the unsaved registers; if the register recovery has been completed for the previous interrupt, the processor automatically saves the registers marked as used in the register usage information.

[0072] In some embodiments, before the interrupt handling function is about to return, the processor determines whether to restore the register immediately based on the current interrupt status;

[0073] If the current interrupt status indicates that there is a new interrupt processing request, the register restoration operation is not performed, the current context is marked as unrestored, the current interrupt process is exited, and the new interrupt service routine is executed;

[0074] If the current interrupt status is that there is no new interrupt processing request, all registers saved in the current context are restored and the interrupt processing function is exited normally.

[0075] In some embodiments, a dedicated register is set to store a register usage information table, the register usage information table including an index basis and table entry content, the index basis including an interrupt number ID, and the table entry content including register usage information corresponding to the interrupt number ID.

[0076] For example, register usage information 0, register usage information 1, ..., register usage information n-1 are all stored in the register usage information table.

[0077] In some embodiments, the reading of the entry content includes:

[0078] Calculate the address according to the interrupt number ID: base address + ID × information item size;

[0079] Read the corresponding register usage information from the address.

[0080] Figure 3 A flow chart of an interrupt control method based on a function call graph is provided for another embodiment of the present invention. Figure 3 , an embodiment of the present invention provides an interrupt control method based on a function call graph, comprising:

[0081] Step S301: obtaining an interrupt handling function, and the compiler generating a function call graph corresponding to the interrupt handling function;

[0082] Step S302: if the currently compiled function belongs to a function in the function call graph, generating usage information for each caller-save register allocated to the function;

[0083] Step S303: If the currently compiled function does not belong to the function in the function call graph, then normal compilation is performed;

[0084] Step S304: When the interrupt handling function is a function written in a high-level language, the compiler sets corresponding usage information for each allocated first caller-save register and each allocated first callee-save register; and at the same time, the compiler does not generate instructions for saving and restoring the first caller-save register and the first callee-save register when generating code.

[0085] Step S305: When the interrupt handling function is a function written in a low-level language, the compiler updates usage information based on the second caller-save register and the second callee-save register used in each instruction of the function; and if there are instructions in the code for saving and restoring the second caller-save register and the second callee-save register, the instructions are deleted;

[0086] Step S306: Update the register usage information of the function;

[0087] Step S307: If the function call graph is empty, the function does not call other functions and there is no need to update the register usage information;

[0088] Step S308: If the function call graph is not empty, perform a depth-first traversal on each function in the function call graph, and merge the caller-saved register information of the child function into the parent function.

[0089] Figure 4 A schematic diagram of a module of an interrupt control device based on a function call graph is provided for an embodiment of the present invention. Figure 4 , an embodiment of the present invention provides an interrupt control device based on a function call graph, comprising:

[0090] A function call graph generation module 41 is used to obtain an interrupt handling function, and the compiler generates a function call graph corresponding to the interrupt handling function;

[0091] a register usage information generating module 42 for generating usage information for each caller-saved register allocated to a function if the currently compiled function belongs to a function in the function call graph;

[0092] a first usage information setting module 43 configured to, when the interrupt handling function is a function written in a high-level language, cause the compiler to set corresponding usage information for each allocated first caller-save register and each allocated first callee-save register; and, at the same time, not generate instructions for saving and restoring the first caller-save register and the first callee-save register when generating code;

[0093] a second usage information setting module 44 configured to, when the interrupt handling function is a function written in a low-level language, cause the compiler to update usage information based on the second caller-save register and the second callee-save register used in each instruction of the function; and, if an instruction for saving and restoring the second caller-save register and the second callee-save register exists in the code, delete the instruction;

[0094] The register usage information updating module 45 is configured to update the register usage information of a function.

[0095] In summary, the interrupt control method and apparatus based on a function call graph provided by an embodiment of the present invention include: obtaining an interrupt handling function, and a compiler generating a function call graph corresponding to the interrupt handling function; if the currently compiled function belongs to a function in the function call graph, generating usage information for each caller-saved register assigned to the function; when the interrupt handling function is a function written in a high-level language, the compiler sets corresponding usage information for each allocated first caller-saved register and each allocated first callee-saved register; and when generating code, the compiler does not generate instructions for saving and restoring the first caller-saved register and the first callee-saved register; when the interrupt handling function is a function written in a low-level language, the compiler updates the usage information based on the second caller-saved register and the second callee-saved register used in each instruction of the function; and if instructions for saving and restoring the second caller-saved register and the second callee-saved register exist in the code, deleting the instructions; updating the register usage information of the function, and improving the efficiency and response speed of interrupt handling by accurately identifying the registers actually used by the interrupt service routine;

[0096] Furthermore, if the function call graph is empty, the function does not call other functions and there is no need to update the register usage information; if the function call graph is not empty, a depth-first traversal is performed on each function in the function call graph, and the register information saved by the caller of the child function is merged into the parent function, thereby effectively updating the register usage information of the function;

[0097] Furthermore, if the function in the function call graph is a function with source code, if its register usage information already completely includes the caller-save register usage information of all sub-functions, no update is required; if the function in the function call graph does not call other functions, its register usage information is marked as complete; if the function in the function call graph has one or more sub-functions, the register usage information of the one or more sub-functions is recursively updated, and the caller-save register usage information of the one or more sub-functions is incorporated into the register usage information of the function in the function call graph; if the function in the function call graph already includes the caller-save register usage information of all sub-functions, the register usage information of the function in the function call graph is marked as complete; if the function in the function call graph is a function with only binary code, if the instruction is a function call, the called function is identified and this step is recursively executed; if the instruction uses the caller-save register, the caller-save register usage information is updated, so that different function update strategies are adopted for different situations of functions with source code and functions with only binary code.

[0098] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the above embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.

Claims

1. An interrupt control method based on a function call graph, characterized in that: The method comprises: Obtaining an interrupt handling function, and the compiler generating a function call graph corresponding to the interrupt handling function; If the currently compiled function belongs to a function in the function call graph, generating usage information for each caller-saved register allocated to the function; If the currently compiled function does not belong to the functions in the function call graph, normal compilation is performed; When the interrupt handling function is a function written in a high-level language, the compiler sets corresponding usage information for each allocated first caller-save register and each allocated first callee-save register; and at the same time, the compiler does not generate instructions for saving and restoring the first caller-save register and the first callee-save register when generating code; When the interrupt handling function is a function written in a low-level language, the compiler updates usage information according to the second caller-saved register and the second callee-saved register used in each instruction of the function; and at the same time, if there are instructions for saving and restoring the second caller-saved register and the second callee-saved register in the code, the instructions are deleted; Update the register usage information of the function; if the function call graph is empty, the function does not call other functions and there is no need to update the register usage information; if the function call graph is not empty, perform a depth-first traversal on each function in the function call graph and merge the register information saved by the caller of the child function into the parent function.

2. The interrupt control method based on function call graph according to claim 1, characterized in that: The step of merging the caller-saved register information of the child function into the parent function includes: If the function in the function call graph is a function with source code, if its register usage information already completely includes the caller-save register usage information of all sub-functions, then no update is required; if the function in the function call graph does not call other functions, then its register usage information is marked as complete; if the function in the function call graph has one or more sub-functions, then the register usage information of the one or more sub-functions is recursively updated, and the caller-save register usage information of the one or more sub-functions is incorporated into the register usage information of the function in the function call graph; if the function in the function call graph already includes the caller-save register usage information of all sub-functions, then the register usage information of the function in the function call graph is marked as complete; If the function in the function call graph is a function with only binary code, if the instruction is a function call, the called function is identified and this step is recursively executed; if the instruction uses the caller-save register, the caller-save register usage information is updated.

3. The interrupt control method based on function call graph according to claim 1, characterized in that: The register usage information of the interrupt processing function is recorded in a bit mask manner, 1 indicates that the register of the interrupt processing function is used, and 0 indicates that the register of the interrupt processing function is not used.

4. The interrupt control method based on function call graph according to claim 1, characterized in that: The method further comprises: When the interrupt processing function is registered, register usage information corresponding to the interrupt processing function is synchronously registered. The processor reads the register usage information when the interrupt is triggered and determines the register set to be saved according to the register usage information.

5. The interrupt control method based on function call graph according to claim 1, characterized in that: When the processor responds to the interrupt handling function and is about to jump to the interrupt service routine, the processor reads the register usage information corresponding to the interrupt number; Determine whether the register is in an unrestored state based on the register usage information of the corresponding interrupt number. If the register recovery has not been completed for the previous interrupt, confirm the unsaved registers required for the current interrupt, and the processor automatically saves the unsaved registers; if the register recovery has been completed for the previous interrupt, the processor automatically saves the registers marked as used in the register usage information.

6. The interrupt control method based on function call graph according to claim 1, characterized in that: When the interrupt handling function is about to return, the processor determines whether to restore the registers immediately based on the current interrupt status; If the current interrupt status indicates that there is a new interrupt processing request, the register restoration operation is not performed, the current context is marked as unrestored, the current interrupt process is exited, and the new interrupt service routine is executed; If the current interrupt status is that there is no new interrupt processing request, all registers saved in the current context are restored and the interrupt processing function is exited normally.

7. The interrupt control method based on function call graph according to claim 1, characterized in that: A dedicated register is set to store a register usage information table, wherein the register usage information table includes an index basis and table item content, wherein the index basis includes an interrupt number ID, and the table item content includes register usage information corresponding to the interrupt number ID.

8. The interrupt control method based on function call graph according to claim 7, characterized in that: Reading the table entry content includes: Calculate the address according to the interrupt number ID: base address + ID × information item size; Read the corresponding register usage information from the address.

9. An interrupt control device based on a function call graph, characterized in that: The device comprises: A function call graph generation module is used to obtain an interrupt handling function, and the compiler generates a function call graph corresponding to the interrupt handling function; a register usage information generating module, configured to generate usage information for each caller-saved register allocated to a function if the currently compiled function belongs to a function in the function call graph; a first usage information setting module configured to, when the interrupt handling function is a function written in a high-level language, cause the compiler to set corresponding usage information for each allocated first caller-save register and each allocated first callee-save register; and, at the same time, not generate instructions for saving and restoring the first caller-save register and the first callee-save register when generating code; a second usage information setting module configured to, when the interrupt handling function is a function written in a low-level language, cause the compiler to update usage information based on the second caller-save register and the second callee-save register used in each instruction of the function; and, if an instruction for saving and restoring the second caller-save register and the second callee-save register exists in the code, delete the instruction; A register usage information update module is used to update the register usage information of a function; if the function call graph is empty, the function does not call other functions and there is no need to update the register usage information; if the function call graph is not empty, a depth-first traversal is performed on each function in the function call graph, and the register information saved by the caller of the child function is merged into the parent function.

Citation Information

Patent Citations

  • Interrupt processing method, electronic equipment and storage medium

    CN117407054A

  • Compiler capable of reducing interrupt handling in optimization and its optimization method

    CN1223402A