A method, device, medium and program product for compiling program code

By splitting and merging complex instructions into simplified instructions, the problem of low computer instruction execution efficiency is solved, resulting in more efficient computer system operation and a user-friendly development experience.

CN120653259BActive Publication Date: 2025-11-11SHANGHAI BIREN TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

In the prior art, due to hardware resource limitations, the use of complex instruction sets leads to low computer instruction execution efficiency, and there are deviations between the user-written program code and the preset instruction set, which affects the operating efficiency of the computer system.

Method used

By splitting complex instructions into simplified instructions and merging them during the compilation process, simplified instructions that match the simplified interface are generated. This optimization of the merging process reduces the number and complexity of instructions, thereby improving the execution efficiency of computer instructions.

Benefits of technology

It reduces instruction decoding and execution overhead, reduces programming errors and debugging time, and improves the operating efficiency of computer systems and user development efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120653259B_ABST
    Figure CN120653259B_ABST
Patent Text Reader

Abstract

This application relates to the field of computer technology and discloses a method, apparatus, medium, and program product for compiling program code. The method includes: reading program code to be compiled, the program code including a preset simplified interface, the simplified interface matching simplified instructions, and the simplified instructions being derived from complex instructions based on the functions of each instruction represented by the complex instructions; compiling the program code to convert the simplified interface in the program code into matching simplified instructions; for any converted simplified instruction, if there is an associated instruction related to the simplified instruction in the compilation result of the program code, merging the simplified instruction and the associated instruction, and executing the merged instruction. The technical solutions provided by one or more embodiments of this application can improve the execution efficiency of computer instructions, thereby improving the operating efficiency of computer systems.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a method, apparatus, medium and program product for compiling program code. Background Technology

[0002] With the rapid development of computer technology, due to limitations in hardware resources, complex instruction sets with multiple operation requirements are often used to reduce memory usage. However, this approach can lead to problems such as difficult-to-use interfaces and difficult-to-adapt instructions when developing software or hardware systems, resulting in significant logical overhead during the compilation of computer instructions and low execution efficiency.

[0003] Furthermore, in practical applications, the complexity of instructions used by the computer's internal compiler can easily lead to discrepancies between the user-written program code and the pre-defined complex instruction set, thus affecting the execution process of computer instructions and consequently resulting in lower operating efficiency of the computer system. Therefore, improving the operating efficiency of computer systems is an urgent problem to be solved. Summary of the Invention

[0004] This application provides a method, apparatus, medium, and program product for compiling program code, which can improve the execution efficiency of computer instructions and thus improve the operating efficiency of computer systems.

[0005] This application provides a method for compiling program code, the method comprising: reading program code to be compiled, the program code including a preset simplified interface, the simplified interface being matched with simplified instructions, the simplified instructions being derived from the complex instructions based on the functions of each instruction represented by the complex instructions; compiling the program code to convert the simplified interface in the program code into matching simplified instructions; for any converted simplified instruction, if there is an associated instruction related to the simplified instruction in the compilation result of the program code, merging the simplified instruction and the associated instruction, and executing the merged instruction.

[0006] In this embodiment, by optimizing and merging multiple simplified instructions matching the program code, fewer merged computer instructions are executed during compilation, thereby improving the operating efficiency of the computer system. Typically, complex instructions in related technologies include multiple desired behaviors. By parsing and compiling multiple simple instructions matching the program code, the simplified instructions can also perform the behaviors or functions of complex instructions. While ensuring instruction execution functionality, the compiler merges multiple simple instructions according to preset rules to execute fewer merged instructions, reducing instruction decoding and execution overhead during program execution, reducing the logical consumption of computer instructions, and improving the execution efficiency of computer instructions, thereby improving the operating efficiency of the computer system. Furthermore, compared to complex instructions, providing simplified interfaces that match the simplified instructions allows users to quickly adapt to different development scenarios and needs. The technical solution provided in this embodiment, by adopting simple instructions that match each simplified interface in the program code and optimizing and merging these simple instructions during compilation, can improve the execution efficiency of computer instructions, thereby improving the operating efficiency of the computer system.

[0007] In one implementation, the simplified instruction is obtained by splitting the complex instruction based on the various instruction functions represented by the complex instruction, including: identifying each instruction field in the complex instruction, and determining multiple instruction functions represented by the complex instruction based on the instruction fields; for any instruction function, obtaining a target instruction field from the complex instruction to implement the instruction function, and constructing a simplified instruction representing the instruction function based on the target instruction field.

[0008] In this embodiment, by breaking down the fields and functions of complex instructions and constructing a corresponding simplified instruction for each function, the complexity of computer instructions can be reduced, making it easier for users to use the simplified interface. At the same time, the simplified instructions reduce programming errors and debugging time caused by complex instructions, indirectly improving the operating efficiency of the computer system.

[0009] In one implementation, after constructing a simplified instruction characterizing the function of the instruction, the method further includes: generating a simplified interface that matches the simplified instruction, and establishing a compilation relationship between the simplified instruction and the matching simplified interface.

[0010] In this embodiment, based on breaking down complex instructions into multiple simplified instructions, a simplified interface matching the simplified instructions is further generated. This makes it easier for users to understand and use the simplified interface to implement the required functions, reducing programming errors and debugging time caused by complex instructions. At the same time, a compilation relationship between simplified instructions and simplified interfaces is established to ensure that the simplified interface can be correctly converted into the corresponding simplified instructions during the compilation process, avoiding additional logic consumption caused by instruction conversion errors and ensuring the operating efficiency of the computer system.

[0011] In one implementation, the various instruction functions represented by the complex instruction include a main instruction function and associated instruction functions; the associated instructions associated with the simplified instruction are determined as follows: it is determined whether the simplified instruction corresponds to the main instruction function represented by the complex instruction; if so, it is determined that the simplified instruction does not have any associated instructions; if not, the query path of the simplified instruction is determined according to the associated instruction function represented by the simplified instruction, and the associated instructions associated with the simplified instruction are queried in the compilation result of the program code according to the query path.

[0012] In this embodiment, by identifying and processing the main instruction function and related instruction functions in complex instructions, the associated related instructions of simplified instructions can be accurately determined. The matching and judgment mechanism between simplified instructions and instruction functions avoids unnecessary instruction lookups and merging, thereby improving the execution efficiency of computer instructions.

[0013] In one implementation, determining the query path of the simplified instruction based on the associated instruction function represented by the simplified instruction includes: identifying the logical execution order between the main instruction function and the associated instruction function represented by the simplified instruction; if the logical execution order is to execute the associated instruction function represented by the simplified instruction first and then execute the main instruction function, the path of forward query along the writing order of the program code is determined as the query path of the simplified instruction; if the logical execution order is to execute the main instruction function first and then execute the associated instruction function represented by the simplified instruction, the path of reverse query along the writing order of the program code is determined as the query path of the simplified instruction.

[0014] In this implementation, by identifying the logical execution order between the main instruction function and the associated instruction function of the simplified instruction, the efficiency and accuracy of associated instruction lookup are improved. The lookup path is dynamically determined based on the logical execution order, flexibly selecting forward or reverse lookup, allowing the compiler to adapt to different instruction combinations and logical execution orders. This mechanism of dynamically adjusting the lookup direction enables the compiler to more efficiently find associated instructions for instruction merging, simplifying the matching and processing logic of computer instructions. It achieves flexibility, automation, and efficiency in instruction merging, thereby improving the execution efficiency of computer instructions and ultimately enhancing the operating efficiency of the computer system.

[0015] In one implementation, querying the compilation results of the program code for an associated instruction related to the simplified instruction according to the query path includes: determining the field matching rule corresponding to the simplified instruction, and querying the compilation results of the program code for another instruction that matches the field matching rule and is closest to the simplified instruction according to the query path, and determining the other instruction as an associated instruction related to the simplified instruction.

[0016] In this embodiment, by determining the field matching rules corresponding to simplified instructions, it is possible to accurately identify the relevant instructions that meet the requirements. Furthermore, a matching method based on specific fields is proposed, ensuring the accuracy and relevance of the query, avoiding the logical overhead caused by unnecessary instruction merging, thereby improving the execution efficiency of computer instructions and ultimately enhancing the operating efficiency of the computer system.

[0017] In one implementation, the other instruction conforming to the field matching rule includes: the other instruction containing the target instruction field represented by the field matching rule; or the other instruction containing the target instruction field represented by the field matching rule, but not containing the configuration field carried in the simplified instruction.

[0018] In this implementation, flexible matching conditions and precise field checks enhance the flexibility and accuracy of instruction matching. By checking whether another instruction contains the target instruction field represented by the field matching rules, accurate identification of associated instructions is ensured. Furthermore, checking whether another instruction contains configuration fields from a simplified instruction ensures the correctness and consistency of the merged instructions, thereby avoiding configuration conflicts and ensuring the execution efficiency of computer instructions and the operating efficiency of the computer system.

[0019] In one embodiment, merging the simplified instruction and the associated instruction includes: updating the status of a portion of the instruction fields in the simplified instruction according to the instruction functions represented by the simplified instruction and the associated instruction, and determining the updated instruction as the merged instruction, wherein the merged instruction simultaneously possesses the instruction functions represented by the simplified instruction and the associated instruction; deleting the original simplified instruction and the associated instruction, and replacing the original simplified instruction and the associated instruction with the merged instruction.

[0020] In this embodiment, instruction merging and replacement are performed by updating the state based on the instruction functions represented by the simplified instructions and associated instructions. This ensures that the merged instructions are functionally complete and reduces the number of instructions while reducing the logical processing of instruction merging. It further reduces the overhead of instruction decoding and execution during compilation, reduces the logical consumption of computer instructions, and further improves the execution efficiency of computer instructions, thereby improving the operating efficiency of the computer system.

[0021] In one embodiment, after merging the simplified instruction and the associated instruction, the method further includes: if the merged instruction does not correspond to the main instruction function represented by the complex instruction, continuing to query the associated instructions associated with the merged instruction in the compilation result of the program code, and continuing to merge the merged instruction with the associated instruction.

[0022] This embodiment proposes a solution to the situation where the merged instruction does not correspond to the function of the main instruction represented by the complex instruction. After merging the simplified instruction and the associated instruction, the compiler further checks whether the merged instruction corresponds to the function of the main instruction of the complex instruction. If they do not correspond, it continues to query other associated instructions related to the merged instruction, ensuring the functional correctness of the merged computer instruction, avoiding additional logical resource consumption caused by instruction execution errors, and thus ensuring the execution efficiency of the computer instruction and the operating efficiency of the computer system.

[0023] In one implementation, replacing the original simplified instruction and associated instruction with the merged instruction includes: if the deleted associated instruction contains an instruction representing the function of the main instruction, replacing the merged instruction with the original position of the instruction representing the function of the main instruction.

[0024] In this embodiment, when the deleted associated instructions include instructions representing the function of the main instruction, the merged instructions are replaced with the original instructions representing the function of the main instruction, ensuring the correctness and consistency of the program logic. This replacement method preserves the semantics and execution order of the original instructions, avoids logical errors caused by changes in instruction position, optimizes the instruction execution flow, and thus ensures the execution efficiency of computer instructions and the operating efficiency of the computer system.

[0025] In one embodiment, the method further includes: if there is no associated instruction related to the simplified instruction in the compilation result of the program code, executing the simplified instruction.

[0026] In this embodiment, when there is no associated instruction related to the simplified instruction in the compilation result, the simplified instruction is executed directly without instruction merging, which ensures the functional integrity of the program, avoids unnecessary queries and processing when the associated instruction cannot be found, reduces compilation time and resource consumption, and thus ensures the execution efficiency of computer instructions and the operating efficiency of the computer system.

[0027] This application also provides a program code compilation apparatus, the apparatus comprising: a code reading unit for reading program code to be compiled, the program code including a preset simplified interface, the simplified interface matching a simplified instruction, the simplified instruction being derived from the complex instruction based on the instruction functions represented by the complex instruction; an instruction conversion unit for compiling the program code to convert the simplified interface in the program code into a matching simplified instruction; and a merge execution unit for, for any converted simplified instruction, if there is an associated instruction in the compilation result of the program code related to the simplified instruction, merging the simplified instruction and the associated instruction, and executing the merged instruction.

[0028] This application also provides an electronic device, comprising: a memory storing computer instructions; and at least one processor for executing the computer instructions in the memory to execute a program code compilation method according to the above embodiments.

[0029] This application also provides a computer-readable storage medium storing computer instructions thereon, which, when executed by a processor, cause the processor to perform a program code compilation method according to the above embodiments.

[0030] This application also provides a computer program product, including computer instructions, which, when executed by a processor, cause the processor to execute a program code compilation method described in the above embodiments. Attached Figure Description

[0031] To more clearly illustrate the technical solutions in the specific embodiments of this application or the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0032] Figure 1 A flowchart illustrating the steps of a program code compilation method provided in one embodiment of this application;

[0033] Figure 2(a) is a schematic diagram of a simplified interface and simplified instruction conversion instructions provided in an embodiment of this application;

[0034] Figure 2(b) is a schematic diagram of instructions before merging in an embodiment of this application;

[0035] Figure 2(c) is a schematic diagram of a simplified instruction merging provided in an embodiment of this application;

[0036] Figure 3 A schematic diagram of the structure of a program code compilation device provided in one embodiment of this application;

[0037] Figure 4 This is a schematic diagram of the structure of an electronic device provided in one embodiment of this application. Detailed Implementation

[0038] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0039] Furthermore, the use of terms such as "first," "second," etc., in this application is for descriptive purposes only and should not be construed as indicating or implying their relative importance or implicitly specifying the number of technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of embodiments in this application, unless otherwise stated, "multiple" means two or more. Additionally, the use of "based on" or "according to" implies openness and inclusiveness, because processes, steps, calculations, or other actions "based on" or "according to" one or more of the stated conditions or values ​​may in practice be based on additional conditions or beyond the stated values.

[0040] In contemporary software development, with the rapid development of hardware technology and significant improvements in hardware performance, complex instruction sets (CIS) are often employed to reduce memory usage and instruction overhead due to hardware resource limitations. A CIS consists of multiple pre-defined complex instructions, each containing multiple desired combinations of options. A computer can execute a single complex instruction to complete multiple functional steps. By using complex instructions to reduce the total number of instructions in a program, memory usage and instruction overhead can be reduced.

[0041] For example, consider the complex instruction 'cp.[on / off].[wait_buffer_ready / nowait_buffer_ready].[post_data_ready / nopost_data_ready]&config.priority&config.readonly' representing a copy operation. Here, the 'cp' field indicates that the copy operation is performed; the 'on / off' field controls whether the copy operation is executed; the 'wait_buffer_ready / nowait_buffer_ready' field indicates whether to wait for the buffer ready semaphore; the 'post_data_ready / nopost_data_ready' field determines whether to send the data ready semaphore; the 'config.priority' field configures the priority of the instruction execution; and the 'config.readonly' field configures whether the instruction execution is read-only. Thus, it can be seen that through different combinations of options, various complex instructions expressing different copy behaviors and related control methods can be implemented.

[0042] However, this approach of trading complex instruction sets for memory space often results in significant computational overhead in practical applications. Because each complex instruction is logically intricate, it can lead to difficulties in interface usability and instruction compatibility during software or hardware system development. This necessitates substantial additional effort in instruction compatibility handling, resulting in significant computational overhead and lower execution efficiency. Furthermore, since the user's actual instruction requirements may deviate from the functionality of the complex instruction set, when the compiler attempts to match the user code with the complex instruction set, it can easily lead to the triggering of erroneous complex instructions. This deviation directly interferes with the execution process of computer instructions, thus affecting the overall system performance and causing lower operating efficiency.

[0043] In view of the above, this application provides one or more embodiments of a program code compilation method, device, medium, and program product, which can solve the above problems, overcome the limitations of complex instruction sets, reduce the number and complexity of instructions by matching and merging multiple simple instructions with different functions, improve the execution efficiency of computer instructions, and thus improve the operating efficiency of computer systems.

[0044] Please see Figure 1 One embodiment of this application provides a method for compiling program code, which may include the following steps:

[0045] S1: Read the program code to be compiled, which includes a preset simplified interface. The simplified interface matches the simplified instructions, which are derived from the complex instructions based on the functions of each instruction represented by the complex instructions.

[0046] S3: Compile the program code to convert the simplified interface in the program code into matching simplified instructions.

[0047] S5: For any simplified instruction obtained from the conversion, if there is an associated instruction related to the simplified instruction in the compilation result of the program code, the simplified instruction and the associated instruction are merged, and the merged instruction is executed.

[0048] The compilation method of the above program code can be used by the processor to perform data processing tasks, such as image processing and signal processing. The processor can be any one of GPU (Graphics Processing Unit), TPU (Tensor Processing Unit), NPU (Neural Network Processing Unit), DPU (Deep Learning Processing Unit), APU (Accelerated Processing Unit), and GPGPU (General-Purpose Graphics Processing Unit).

[0049] Taking image data processing as an example, the compilation method of the above program code can represent an optimized execution method for image processing tasks. The program code contains the source code of a data processing algorithm. It converts simplified interfaces representing different steps of the data processing task into simplified instructions, and then merges these simplified instructions to execute the merged instructions. Image processing typically involves multiple steps, such as image filtering and image scaling. By merging related simplified instructions, the processor's instruction cycle can be reduced, thereby accelerating the processor's image processing efficiency, which is particularly suitable for scenarios requiring the processing of large amounts of image data.

[0050] The above program code is a set of instructions written by the user in a certain programming language to control the computer to complete specific tasks. By compiling the program code according to the above compilation method, the computer automatically determines and merges the simplified instructions that match the program code, reducing the processor's instruction cycle, which speeds up the processor's data processing efficiency and thus improves the computer system's operating efficiency when completing different data processing tasks.

[0051] It should be noted that the image data processing example described above is merely a scenario example provided in the specification and is not intended to limit the present invention. Any modifications, equivalent substitutions, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

[0052] Specifically, the program code includes pre-defined simplified interfaces. These simplified interfaces provide easy-to-use interface functions or operation interfaces to facilitate user programming. The simplified instructions can be understood as fine-grained instructions broken down from complex instructions, with each simplified instruction representing a specific function within the complex instruction. Users can call the simplified interfaces to use the simplified instructions during compilation, quickly implementing the corresponding functions of complex instructions. By replacing complex instructions with simple ones, the overhead of instruction decoding and execution during program execution can be reduced, decreasing the logical consumption of computer instructions. Simultaneously, since users only need to call the simplified interfaces when writing program code, without having to write complex instructions themselves, the difficulty and complexity of programming are reduced, allowing users to avoid directly handling the low-level details of instructions, thus improving development efficiency and user experience.

[0053] In this implementation, matching simplified interfaces with simplified instructions helps improve the compiler's processing speed and efficiency. Since the compiler needs to convert simplified interfaces in program code into specific instructions to generate an executable program, matching simplified interfaces with simplified instructions ensures that code written by the user using the simplified interface can be accurately mapped to the corresponding simplified instructions to achieve the intended function. During compilation, the compiler can quickly convert simplified interfaces into corresponding simplified instructions based on predefined matching relationships, improving the execution efficiency of computer instructions and thus improving the operating efficiency of the computer system.

[0054] Optionally, a mapping relationship between simplified interfaces and simplified instructions can be established. Based on this mapping relationship, the simplified instructions matching the simplified interface can be determined. Specifically, a mapping mechanism can be established at the underlying implementation level of the simplified interface to convert interface calls into specific instructions. When a user calls the simplified interface, the mapping mechanism within the simplified interface will convert it into the corresponding simplified instruction according to the mapping relationship. Optionally, the matching relationship between simplified interfaces and simplified instructions can be defined through a preset mapping table or configuration file. Optionally, the matching relationship between simplified interfaces and simplified instructions can also be defined based on pattern matching or function signatures.

[0055] In this embodiment, the functions of each instruction represented by a complex instruction are broken down, and a simple instruction is created based on any one of the instruction functions. Specifically, the function of a complex instruction can be determined through the information of each field of the complex instruction. The complex instruction typically contains multiple fields, each representing a different function or parameter. First, the functional fields of the complex instruction are identified. Based on the identified functional fields, the complex instruction is broken down into multiple individual instructions. For example, a complex instruction may simultaneously perform multiple functions such as data transmission, arithmetic operations, or state setting. A complex instruction containing data transmission and arithmetic operations is broken down into a data transmission instruction and an arithmetic operation instruction as simplified instructions. For each simplified instruction, the fields related to its specific function are retained, and other unnecessary fields are deleted. Optionally, the structure of the complex instruction can also be analyzed to break down its different components into independent simple instructions. Generally, the different components of a complex instruction represent different instruction functions.

[0056] In this embodiment, simplified interfaces in the program code are converted into matching simplified instructions. Optionally, a mapping relationship between simplified interfaces and simplified instructions can be preset in the compiler's configuration file or internal data structure, and each simplified interface can be directly mapped to its corresponding simplified instruction based on the direct call mapping relationship. Optionally, the compiler can perform semantic analysis on the program code to understand the intent and context of the simplified interfaces, and then generate corresponding simplified instructions based on the semantic information.

[0057] In this embodiment, during compilation, the computer's compiler merges the simplified instructions that have been converted. Specifically, for each simplified instruction, the compiler checks the compiled code to see if there are other simplified instructions associated with the current simplified instruction. These associated simplified instructions are then designated as related instructions to identify those logically closely related to the current simplified instruction and capable of being merged for execution. Further, after merging the simplified instruction with its associated instructions, a new instruction is generated to replace the original two or more instructions. For example, the merged instruction may be able to complete multiple operations at once, reducing the processor's switching time between different instructions. This reduces the number of instructions, lowers the control flow overhead during program execution, improves the execution efficiency of computer instructions, and thus improves the operating efficiency of the computer system. Optionally, adjacent instructions can be merged based on the execution order and flow of the simplified instruction and its associated instructions in the program. Optionally, a predefined template can be used to match multiple instructions and replace them with a composite instruction.

[0058] In this embodiment, by optimizing and merging multiple simplified instructions matching the program code, fewer merged computer instructions are executed during compilation, thereby improving the operating efficiency of the computer system. Typically, complex instructions in related technologies include multiple desired behaviors. By parsing and compiling multiple simple instructions matching the program code, the simplified instructions can also perform the behaviors or functions of complex instructions. While ensuring instruction execution functionality, the compiler merges multiple simple instructions according to preset rules to execute fewer merged instructions, reducing instruction decoding and execution overhead during program execution, reducing the logical consumption of computer instructions, and improving the execution efficiency of computer instructions, thereby improving the operating efficiency of the computer system. Furthermore, compared to complex instructions, providing simplified interfaces that match the simplified instructions allows users to quickly adapt to different development scenarios and needs. The technical solution provided in this embodiment, by adopting simple instructions that match each simplified interface in the program code and optimizing and merging these simple instructions during compilation, can improve the execution efficiency of computer instructions, thereby improving the operating efficiency of the computer system.

[0059] In one implementation, the simplified instructions are derived from complex instructions by decomposing the various instruction functions represented by the complex instructions. Specifically, a complex instruction typically has multiple instruction fields, which represent certain specific information or parameters of the complex instruction. Each instruction field has its own instruction function, providing various information required for instruction execution, while the instruction function is the result of interpreting and executing this information. By identifying the various instruction fields in the complex instruction, and determining the multiple instruction functions represented by the complex instruction based on these instruction fields, further, for any instruction function, a target instruction field for implementing the current instruction function is obtained from the complex instruction, and a simplified instruction representing the current instruction function is constructed based on the target instruction field.

[0060] In one embodiment, for a complex instruction 'cp.[on / off].[wait_buffer_ready / nowait_buffer_ready].[post_data_ready / nopost_data_ready]&config.priority&config.readonly' used for a copy (data replication) operation, the complex instruction has multiple instruction fields including a body field (cp), an execution decision field (on, off), a buffer ready field (wait_buffer_ready / nowait_buffer_ready), a data ready field (post_data_ready / nopost_data_ready), a priority configuration field (config.priority), and a read-only configuration field (config.readonly). These different instruction fields represent different instruction functions: 'copy_data' is responsible for performing the core data replication function of the operation; 'copy_wait_buffer_ready' is responsible for waiting for the buffer to be ready; 'copy_post_data_ready' is responsible for sending the data ready signal; 'config.priority' is responsible for the instruction execution priority; and 'config.readonly' is responsible for configuring whether the instruction is read-only.

[0061] Furthermore, based on different target instruction fields, several simplified instructions are constructed to represent different instruction functions: 'cp.on.nowait_buffer_ready.nopost_data_ready' indicates that the copy operation is performed without waiting for the bufferready signal or sending the data ready signal. 'cp.off.wait_buffer_ready.nopost_data_ready' indicates that the copy operation is not performed, but the buffer ready signal is waited for. 'cp.off.nowait_buffer_ready.post_data_ready' indicates that the copy operation is not performed, and the buffer ready signal is not waited for, but the data ready signal is sent. 'cp.off.nowait_buffer_ready.nopost_data_ready&config.priority' indicates that the copy operation is not performed, the buffer ready signal is not waited for, and the data ready signal is not sent, but the priority of the copy operation is set. 'cp.off.nowait_buffer_ready.nopost_data_ready&config.readonly' means that the copy operation is not performed, the buffer ready signal is not waited for, and the data ready signal is not sent, but the read-only attribute of the copy operation is set.

[0062] In this embodiment, by breaking down the fields and functions of complex instructions, a simplified instruction is constructed for each function, so that each simplified instruction corresponds to a specific behavior or function. This approach reduces the complexity of computer instructions, making it easier for users to use the simplified interface. At the same time, the simplified instructions reduce programming errors and debugging time caused by complex instructions, indirectly improving the operating efficiency of the computer system.

[0063] In one implementation, to facilitate the use of simplified instructions by developers, an easy-to-use simplified interface is provided for user invocation. Specifically, after constructing the simplified instructions representing the function of the instructions, the function of the simplified instructions is analyzed to generate a simplified interface that matches the simplified instructions, and a compilation relationship is established between the simplified instructions and the matching simplified interfaces. During compilation, the compiler performs semantic analysis on the program code, identifies calls to the simplified interfaces, and determines the matching simplified instructions. This facilitates the use of simplified interfaces to achieve project requirements while avoiding program security risks caused by direct exposure of simplified instructions, as the simplified instructions are not directly provided to users. It should be noted that the design of the interface should follow the specifications and conventions of the programming language, and ensure that the parameters and return values ​​of the interface accurately reflect the functional requirements of the instructions.

[0064] For example, there exists a simplified instruction for setting data transfer priority, requiring the generation of a matching simplified interface and the establishment of a compilation relationship. First, a simplified interface named 'void set_copy_priority()' is designed to set the data transfer priority. During compilation, the compiler recognizes the simplified interface 'set_copy_priority()' and converts it into the matching simplified instruction 'cp.off.nowait_buffer_ready.nopost_data_ready&config.priority'.

[0065] In this embodiment, based on breaking down complex instructions into multiple simplified instructions, a simplified interface matching the simplified instructions is further generated. This makes it easier for users to understand and use the simplified interface to implement the required functions, reducing programming errors and debugging time caused by complex instructions. At the same time, a compilation relationship between simplified instructions and simplified interfaces is established to ensure that the simplified interface can be correctly converted into the corresponding simplified instructions during the compilation process, avoiding additional logic consumption caused by instruction conversion errors and ensuring the operating efficiency of the computer system.

[0066] In one implementation, the various instruction functions represented by the complex instruction above include a main instruction function and associated instruction functions; the associated instructions associated with the simplified instruction are determined as follows: it is determined whether the simplified instruction corresponds to the main instruction function represented by the complex instruction; if so, it is determined that the simplified instruction does not have any associated instructions; if not, the query path of the simplified instruction is determined according to the associated instruction function represented by the simplified instruction, and the associated instructions associated with the simplified instruction are queried in the compilation result of the program code according to the query path.

[0067] The aforementioned main instruction function can be understood as the core and primary operational function of a complex instruction. It is typically a mandatory part of a complex instruction or the function that best reflects the instruction's main purpose. The aforementioned associated instruction function refers to other auxiliary or related functions within a complex instruction besides the main instruction function. The aforementioned associated instructions refer to other instructions that are functionally related to a particular instruction. It should be noted that this association may be because they jointly complete different parts of a task, or because they have a certain order and logical relationship in their execution flow. The aforementioned query path can be understood as the path or order for finding associated instructions in the compiled program code, which can be a forward or reverse query along the order in which the program code was written.

[0068] For example, taking a complex instruction for a copy operation as an example, the simplified instruction corresponding to 'cp.[on / off].[wait_buffer_ready / nowait_buffer_ready].[post_data_ready / nopost_data_ready]&config.priority&config.readonly' can include 'cp.on.nowait_buffer_ready.nopost_data_ready' and 'cp.off.wait_buffer_ready.nopost_data_ready', indicating that the copy operation is not performed, but the buffer ready signal is waited for. In the above complex instruction, 'cp.[on / off]' represents the data copy function, which is the main instruction function of the copy operation. The simplified instruction matching the above main instruction function is 'cp.on.nowait_buffer_ready.nopost_data_ready', which indicates that only the copy operation is performed. This simplified instruction does not need to look up the associated instruction. Among the complex instructions mentioned above, the instruction functions represented by the cache-ready field 'wait_buffer_ready', the data-ready field 'post_data_ready', the priority configuration field 'config.priority', and the read-only configuration field 'config.readonly' are associated instruction functions. Simplified instructions that contain the above associated instruction functions need to be queried to see if there are associated instructions related to the simplified instruction.

[0069] For example, the simplified instruction 'cp.off.wait_buffer_ready.nopost_data_ready' represents the instruction function 'wait_buffer_ready', which is an associated instruction function. It is necessary to query whether there are associated instructions related to this simplified instruction. Following the query path of the current simplified instruction, the compiler looks up associated instructions in the compiled program code, and then merges the current simplified instruction with its associated instructions. It should be noted that the instruction function of the aforementioned associated instructions can be either the main instruction function or an associated instruction function.

[0070] In this embodiment, by identifying and processing the main instruction function and related instruction functions in complex instructions, the associated related instructions of simplified instructions can be accurately determined. The matching and judgment mechanism between simplified instructions and instruction functions avoids unnecessary instruction lookups and merging, thereby improving the execution efficiency of computer instructions.

[0071] In one implementation, determining the query path of the simplified instruction based on the associated instruction function represented by the simplified instruction includes: identifying the logical execution order between the main instruction function and the associated instruction function represented by the simplified instruction; if the logical execution order is to execute the associated instruction function represented by the simplified instruction first and then execute the main instruction function, the path of forward query along the writing order of the program code is determined as the query path of the simplified instruction; if the logical execution order is to execute the main instruction function first and then execute the associated instruction function represented by the simplified instruction, the path of reverse query along the writing order of the program code is determined as the query path of the simplified instruction.

[0072] In this embodiment, the query path for the simplified instruction is determined based on the logical execution order among the associated instruction functions represented by the simplified instruction. The aforementioned logical execution order can be understood as the order in which instructions are executed in a program, determining the program's behavior and the flow of function implementation. Performing the aforementioned forward query means that if logically the associated instruction function needs to be executed first, then following the order of the program code, starting from the current simplified instruction's position, the search proceeds backwards for the relevant main instruction. Performing the aforementioned reverse query means that if logically the main instruction function needs to be executed first, then following the order of the program code, starting from the current simplified instruction's position, the search proceeds backwards for the relevant main instruction.

[0073] For example, the instruction 'cp.off.wait_buffer_ready.nopost_data_ready' corresponds to the wait buffer readiness function (associated instruction function) of the copy operation. Based on the logical execution order, if it's necessary to wait for the buffer to be ready before data copying, the query path might be a forward query downwards along the order of the program code, searching for the associated instruction 'cp.on.nowait_buffer_ready.nopost_data_ready'. If it's necessary to copy data first and then wait for the buffer to be ready, the query path might be a reverse query upwards along the order of the program code, searching for the associated instruction 'cp.on.nowait_buffer_ready.nopost_data_ready'. By understanding the logical relationship between instruction functions, the query direction can be effectively determined, optimizing the efficiency and accuracy of instruction merging.

[0074] In this implementation, by identifying the logical execution order between the main instruction function and the associated instruction function of the simplified instruction, the efficiency and accuracy of associated instruction lookup are improved. The lookup path is dynamically determined based on the logical execution order, flexibly selecting forward or reverse lookup, allowing the compiler to adapt to different instruction combinations and logical execution orders. This mechanism of dynamically adjusting the lookup direction enables the compiler to more efficiently find associated instructions for instruction merging, simplifying the matching and processing logic of computer instructions. It achieves flexibility, automation, and efficiency in instruction merging, thereby improving the execution efficiency of computer instructions and ultimately enhancing the operating efficiency of the computer system.

[0075] In one implementation, the associated instructions related to the simplified instruction are queried in the compilation results of the program code according to the query path. Specifically, a field matching rule corresponding to the simplified instruction is determined, and according to the query path, another instruction that matches the field matching rule and is closest to the simplified instruction is queried in the compilation results of the program code. This other instruction is then identified as the associated instruction related to the simplified instruction. The aforementioned field matching rule is used to determine whether instructions match, and is typically constructed based on the opposite of specific fields representing the instruction's function and execution status fields. The aforementioned field matching rule can include execution status fields and instruction function fields, such as 'on.nowait_buffer_ready' and 'on.nopost_data_ready'.

[0076] For example, for the simplified instruction 'cp.off.wait_buffer_ready.nopost_data_ready', its instruction function field is 'wait_buffer_ready', therefore the field matching rule for this simplified instruction is 'on.nowait_buffer_ready'. For example, if there is a sequence of instructions like 'cp.on.nowait_buffer_ready.nopost_data_ready'; 'cp.off.nowaitbuffer_ready.post_data_ready', after the compiler finds the second instruction, it searches upwards for the nearest instruction that contains the 'on.nopost_data_ready' field, i.e., the first instruction. The first instruction is then identified as the associated instruction with the second instruction.

[0077] In this embodiment, by determining the field matching rules corresponding to simplified instructions, it is possible to accurately identify the relevant instructions that meet the requirements. Furthermore, a matching method based on specific fields is proposed, ensuring the accuracy and relevance of the query, avoiding the logical overhead caused by unnecessary instruction merging, thereby improving the execution efficiency of computer instructions and ultimately enhancing the operating efficiency of the computer system.

[0078] In one implementation, the other instruction conforming to the field matching rule includes: the other instruction containing the target instruction field represented by the field matching rule; or the other instruction containing the target instruction field represented by the field matching rule, but not containing the configuration field carried in the simplified instruction.

[0079] For example, for the simplified instruction 'cp.off.nowait_buffer_ready.post_data_ready', search upwards for the nearest target instruction field 'on.nopost_data_ready'. For example, for the simplified instruction 'cp.off.nowait_buffer_ready.nopost_data_ready&config.priority' which has the configuration field 'config.priority', search downwards for the simplified instruction that does not have 'config.priority' configured, i.e., 'cp.off.nowait_buffer_ready.nopost_data_ready', and use that instruction as the associated instruction.

[0080] In this implementation, flexible matching conditions and precise field checks enhance the flexibility and accuracy of instruction matching. By checking whether another instruction contains the target instruction field represented by the field matching rules, accurate identification of associated instructions is ensured. Furthermore, checking whether another instruction contains configuration fields from a simplified instruction ensures the correctness and consistency of the merged instructions, thereby avoiding configuration conflicts and ensuring the execution efficiency of computer instructions and the operating efficiency of the computer system.

[0081] In one implementation, merging the simplified instruction and the associated instruction includes: updating the status of some instruction fields in the simplified instruction according to the instruction functions represented by the simplified instruction and the associated instruction, and determining the updated instruction as the merged instruction. The merged instruction possesses the instruction functions represented by both the simplified instruction and the associated instruction; deleting the original simplified instruction and the associated instruction, and replacing the original simplified instruction and the associated instruction with the merged instruction.

[0082] The aforementioned instruction fields can be understood as execution decision fields used to characterize whether a control operation is executed. For example, the 'on / off' field in 'cp.[on / off]…'. When the above execution decision field is 'on', it means that the copy operation is actually executed. When the above execution decision field is 'off', it means that the copy operation is not executed, but other related behaviors will still be executed normally.

[0083] For example, suppose there is the following instruction sequence in the code segment: 'cp.off.wait_buffer_ready.nopost_data_ready' 'cp.on.nowait_buffer_ready.nopost_data_ready'. The compiler will find that the first instruction is 'cp.off.wait_buffer_ready.nopost_data_ready', treat it as a simplified instruction, and then search downwards for the nearest simplified instruction containing the field 'on.nowait_buffer_ready', which is the second instruction, and treat it as an associated instruction. After finding it, the 'on' field of the simplified instruction is changed to the 'off' field, which is equivalent to merging the simplified instruction and the associated instruction into 'cp.on.wait_buffer_ready.nopost_data_ready', and deleting the original two instructions, thus completing the instruction merging optimization.

[0084] In this embodiment, instruction merging and replacement are performed by updating the state based on the instruction functions represented by the simplified instructions and associated instructions. This ensures that the merged instructions are functionally complete and reduces the number of instructions while reducing the logical processing of instruction merging. It further reduces the overhead of instruction decoding and execution during compilation, reduces the logical consumption of computer instructions, and further improves the execution efficiency of computer instructions, thereby improving the operating efficiency of the computer system.

[0085] In one embodiment, after merging the simplified instruction and the associated instruction, the method further includes: if the merged instruction does not correspond to the main instruction function represented by the complex instruction, continuing to query the associated instructions associated with the merged instruction in the compilation result of the program code, and continuing to merge the merged instruction with the associated instruction.

[0086] In this embodiment, the merged instruction can continue to query other related instructions and be merged again. Specifically, when there are other related instructions in the merged instruction, it can be merged again with other related instructions according to the functions of each instruction. For example, the simplified instruction 'cp.on.wait_buffer_ready.nopost_data_ready' after merging, after searching upwards, finds the related instruction 'cp.off.nowait_buffer_ready.post_data_ready', and merges it again to obtain the instruction 'cp.on.wait_buffer_ready.post_data_ready'.

[0087] This embodiment also proposes a solution for the situation where the merged instruction does not correspond to the function of the main instruction represented by the complex instruction. After merging the simplified instruction and the associated instruction, the compiler further checks whether the merged instruction corresponds to the function of the main instruction of the complex instruction. If they do not correspond, it continues to query other associated instructions related to the merged instruction, ensuring the functional correctness of the merged computer instruction, avoiding additional logical resource consumption caused by instruction execution errors, and thus ensuring the execution efficiency of the computer instruction and the operating efficiency of the computer system.

[0088] In one implementation, replacing the original simplified instructions and associated instructions with the merged instructions includes: if the deleted associated instructions contain instructions representing the function of the main instruction, replacing the merged instructions with the original position of the instructions representing the function of the main instruction. That is, even after multiple mergings of simplified instructions, as long as one of the merged associated instructions contains a simplified instruction representing the function of the main instruction, the merged instructions are replaced with the original position of the associated instructions representing the function of the main instruction, and the other merged simplified instructions are deleted.

[0089] In this embodiment, when the deleted associated instructions include instructions representing the function of the main instruction, the merged instructions are replaced with the original instructions representing the function of the main instruction, ensuring the correctness and consistency of the program logic. This replacement method preserves the semantics and execution order of the original instructions, avoids logical errors caused by changes in instruction position, optimizes the instruction execution flow, and thus ensures the execution efficiency of computer instructions and the operating efficiency of the computer system.

[0090] In one implementation, if there is no associated instruction related to the simplified instruction in the compiled program code, the compiler directly executes the simplified instruction without merging the instructions.

[0091] In this embodiment, when there is no associated instruction related to the simplified instruction in the compilation result, the simplified instruction is executed directly without instruction merging, which ensures the functional integrity of the program, avoids unnecessary queries and processing when the associated instruction cannot be found, reduces compilation time and resource consumption, and thus ensures the execution efficiency of computer instructions and the operating efficiency of the computer system.

[0092] In a specific embodiment, a corresponding simplified interface is designed for each simplified instruction as shown in Table 1 below, so that users can achieve the corresponding behavior by calling these simplified interfaces.

[0093] Table 1: Simplified instructions and corresponding simplified interfaces

[0094]

[0095] In Table 1 above, calling the simplified interface 'voidcopy_data()' indicates performing a copy operation without waiting for or sending a buffer ready signal. Calling the simplified interface 'voidcopy_wait_buffer_ready()' indicates not performing a copy operation but waiting for a buffer ready signal. Calling the simplified interface 'voidcopy_post_data_ready()' indicates not performing a copy operation, not waiting for a buffer ready signal, but sending a data ready signal. Calling the simplified interface 'voidset_copy_priority()' indicates not performing a copy operation, not waiting for a buffer ready signal, not sending a data ready signal, and setting the priority of the copy operation. Calling the simplified interface 'voidset_copy_readonly()' indicates not performing a copy operation, not waiting for a buffer ready signal, not sending a data ready signal, and setting the read-only attribute of the copy operation.

[0096] In a specific embodiment, in order to improve the execution efficiency and performance of the code and reduce the number and complexity of instructions, the compiler will look for instructions that can be merged in the same code segment and merge multiple simplified instructions back into the more complex instructions originally designed by the hardware according to the optimization rules shown in Table 2, thereby reducing the number of instructions and improving execution efficiency.

[0097] Table 2: Instruction Queue and Corresponding Merge Instructions

[0098]

[0099] In Table 2 above, in the first instruction queue, since the simplified instruction represents the function of the main instruction, its associated instructions are no longer queried. In the second instruction queue, for the simplified instruction 'cp.off.wait_buffer_ready.nopost_data_ready', the nearest associated instruction containing the 'on.nowait_buffer_ready' field is queried downwards. The simplified instruction itself is deleted, and it is merged with the found instruction to form a new instruction 'cp.on.wait_buffer_ready.nopost_data_ready'. Since the found associated instruction is the simplified instruction 'cp.on.nowait_buffer_ready.nopost_data_ready' representing the function of the main instruction, the merged instruction is placed in the position of the original associated instruction.

[0100] In Table 2 above, in the third instruction queue, for the simplified instruction 'cp.off.nowait_buffer_ready.post_data_ready', the nearest related instruction that includes the 'on.nopost_data_ready' field is queried upwards. The simplified instruction itself is deleted and merged with the found instruction to form a new instruction 'cp.on.nowait_buffer_ready.post_data_ready'.

[0101] In Table 2 above, in the fourth instruction queue, for the simplified instruction 'cp.off.nowait_buffer_ready.nopost_data_ready&config.priority', the nearest related instruction that does not include the 'config.priority' field is searched downwards. The simplified instruction itself is deleted and merged with the found instruction to form a new instruction 'cp.off.nowait_buffer_ready.nopost_data_ready&config.priority'.

[0102] In Table 2 above, in the fifth instruction queue, for the simplified instruction 'cp.off.nowait_buffer_ready.nopost_data_ready&config.priority', the nearest related instruction that does not include the 'config.priority' field is searched downwards. The simplified instruction itself is deleted and merged with the found instruction to form a new instruction 'cp.off.nowait_buffer_ready.nopost_data_ready&config.priority'.

[0103] In a specific embodiment, please refer to Figure 2(a). The left box of Figure 2(a) shows a portion of the program code input by the user, which includes multiple simplified interfaces. During the compilation process, the computer converts any simplified interface into a simplified instruction in the corresponding line in the right box. Further, please refer to Figure 2(b). The converted simplified instructions are merged. The three instructions marked in red in Figure 2(b) can be merged into one instruction marked in red in Figure 2(c), and the three instructions marked in green in Figure 2(b) can be merged into one instruction marked in green in Figure 2(c). Specifically, the compiler merges the second and third instructions, and then merges the resulting instruction 'cp.on.wait_buffer_ready.nopost_data_ready' with the first instruction to obtain a new merged instruction 'cp.on.wait_buffer_ready.nopost_data_ready&config.priority'. When the compiler reads the fifth instruction, it merges the fifth instruction with the sixth instruction, and then merges the resulting instruction 'cp.on.nowait_buffer_ready.post_data_ready' with the fourth instruction to obtain a new merged instruction 'cp.on.nowait_buffer_ready.post_data_ready&config.readonly'. The seventh instruction is not merged, resulting in the three final merged instructions shown in Figure 2(c). The compiler then executes these three instructions.

[0104] Please see Figure 3 This application also provides a program code compilation apparatus, the apparatus comprising:

[0105] The code reading unit 100 is used to read the program code to be compiled. The program code includes a preset simplified interface. The simplified interface matches the simplified instructions. The simplified instructions are obtained by decomposing the complex instructions based on the functions of each instruction represented by the complex instructions.

[0106] The instruction conversion unit 200 is used to compile the program code to convert the simplified interface in the program code into matching simplified instructions;

[0107] The merging execution unit 300 is used to merge the simplified instruction and the associated instruction in the compilation result of the program code if there is an associated instruction related to the simplified instruction, and then execute the merged instruction.

[0108] in,

[0109] The code reading unit 100 is specifically used to identify each instruction field in a complex instruction, and determine multiple instruction functions represented by the complex instruction based on the instruction fields. For any instruction function, it obtains the target instruction field used to implement the instruction function from the complex instruction, and constructs a simplified instruction representing the instruction function based on the target instruction field.

[0110] The instruction conversion unit 200 is specifically used to generate a simplified interface that matches the simplified instruction, establish a compilation relationship between the simplified instruction and the matching simplified interface, and convert the simplified interface in the program code into a matching simplified instruction according to the compilation relationship.

[0111] The merging execution unit 300 is specifically used to determine the query path of the simplified instruction based on the associated instruction function represented by the simplified instruction, and to determine the field matching rule corresponding to the simplified instruction. According to the query path, it queries the compilation result of the program code for another instruction that matches the field matching rule and is closest to the simplified instruction, and determines the other instruction as the associated instruction associated with the simplified instruction.

[0112] Further functional descriptions of the above modules and units are the same as those in the corresponding embodiments described above, and will not be repeated here.

[0113] This application also provides an electronic device, comprising: a memory storing computer instructions; and at least one processor for executing the computer instructions in the memory to execute a program code compilation method according to the above embodiments.

[0114] This application also provides a computer-readable storage medium storing computer instructions thereon, which, when executed by a processor, cause the processor to perform a program code compilation method according to the above embodiments.

[0115] This application also provides a computer program product, including computer instructions, which, when executed by a processor, cause the processor to execute a program code compilation method described in the above embodiments.

[0116] Please see Figure 4 , Figure 4 This is a schematic diagram of the structure of an electronic device provided in an optional embodiment of the present invention, such as... Figure 4As shown, the electronic device includes one or more processors 10, memory 20, and interfaces for connecting the components, including high-speed interfaces and low-speed interfaces. The components communicate with each other via different buses and can be mounted on a common motherboard or otherwise as required. The processors can process instructions executed within the electronic device, including instructions stored in or on memory to display graphical information of a GUI on external input / output devices (such as display devices coupled to the interfaces). In some alternative implementations, multiple processors and / or multiple buses can be used with multiple memories and multiple memory modules, if desired. Similarly, multiple electronic devices can be connected, each providing some of the necessary operations (e.g., as a server array, a group of blade servers, or a multiprocessor system). Figure 4 Take a processor 10 as an example.

[0117] Processor 10 may be a central processing unit, a network processor, or a combination thereof. Processor 10 may further include a hardware chip. The hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The programmable logic device may be a complex programmable logic device (CAMP), a field-programmable gate array (FPGA), a general-purpose array logic (GDA), or any combination thereof.

[0118] The memory 20 stores instructions executable by at least one processor 10 to cause the at least one processor 10 to perform the method shown in the above embodiments.

[0119] The memory 20 may include a program storage area and a data storage area. The program storage area may store the operating system and applications required for at least one function; the data storage area may store data created based on the use of the electronic device. Furthermore, the memory 20 may include high-speed random access memory and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some alternative embodiments, the memory 20 may optionally include memory remotely located relative to the processor 10, and these remote memories may be connected to the electronic device via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.

[0120] The memory 20 may include volatile memory, such as random access memory; the memory may also include non-volatile memory, such as flash memory, hard disk or solid-state drive; the memory 20 may also include a combination of the above types of memory.

[0121] The electronic device also includes a communication interface 30 for communicating with other devices or communication networks.

[0122] This invention also provides a computer-readable storage medium. The methods described above according to embodiments of the invention can be implemented in hardware or firmware, or implemented as computer code that can be recorded on a storage medium, or implemented as computer code downloaded via a network and originally stored on a remote storage medium or a non-transitory machine-readable storage medium and then stored on a local storage medium. Thus, the methods described herein can be processed by software stored on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. The storage medium can be a magnetic disk, optical disk, read-only memory, random access memory, flash memory, hard disk, or solid-state drive, etc.; further, the storage medium can also include combinations of the above types of memory. It is understood that computers, processors, microprocessor controllers, or programmable hardware include storage components capable of storing or receiving software or computer code, which, when accessed and executed by the computer, processor, or hardware, implements the methods shown in the above embodiments.

[0123] A portion of this invention can be applied as a computer program product, such as computer program instructions, which, when executed by a computer, can invoke or provide the methods and / or technical solutions according to the invention through the operation of the computer. Those skilled in the art will understand that the forms in which computer program instructions exist in a computer-readable medium include, but are not limited to, source files, executable files, installation package files, etc. Correspondingly, the ways in which computer program instructions are executed by a computer include, but are not limited to: the computer directly executing the instructions, or the computer compiling the instructions and then executing the corresponding compiled program, or the computer reading and executing the instructions, or the computer reading and installing the instructions and then executing the corresponding installed program. Here, the computer-readable medium can be any available computer-readable storage medium or communication medium accessible to a computer.

[0124] This application is described with reference to flowchart illustrations and / or block diagrams of methods and systems according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0125] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0126] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0127] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0128] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the device embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions of the method embodiments.

[0129] The above description is merely an embodiment of this application and is not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.

[0130] Although embodiments of this application have been described in conjunction with the accompanying drawings, those skilled in the art can make various modifications and variations without departing from the spirit and scope of this application, and such modifications and variations all fall within the scope defined by the appended claims.

Claims

1. A method for compiling program code, characterized in that, The method includes: The program code to be compiled is read, which includes a preset simplified interface. The simplified interface matches the simplified instructions, which are derived from the complex instructions based on the functions of each instruction represented by the complex instructions. Compile the program code to convert the simplified interface in the program code into matching simplified instructions; For any simplified instruction obtained from the conversion, if there is an associated instruction related to the simplified instruction in the compilation result of the program code, the simplified instruction and the associated instruction are merged, and the merged instruction is executed; wherein, the various instruction functions represented by the complex instruction include the main instruction function and the associated instruction function, and the associated instruction related to the simplified instruction is queried in the compilation result of the program code only when the simplified instruction does not correspond to the main instruction function represented by the complex instruction.

2. The method according to claim 1, characterized in that, The simplified instructions are derived from the complex instructions by decomposing the individual instruction functions represented by the complex instructions, including: Identify each instruction field in a complex instruction, and determine multiple instruction functions represented by the complex instruction based on the instruction fields; For any instruction function, a target instruction field for implementing the instruction function is obtained from the complex instruction, and a simplified instruction representing the instruction function is constructed based on the target instruction field.

3. The method according to claim 2, characterized in that, After constructing a simplified instruction representing the function of the instruction, the method further includes: Generate a simplified interface that matches the simplified instruction, and establish a compilation relationship between the simplified instruction and the matching simplified interface.

4. The method according to claim 1, characterized in that, The associated instructions to which the simplified instructions are attached are determined as follows: Determine whether the simplified instruction corresponds to the main instruction function represented by the complex instruction; if so, determine that the simplified instruction does not have any associated instructions. If not, determine the query path of the simplified instruction based on the associated instruction function represented by the simplified instruction, and query the associated instructions related to the simplified instruction in the compilation result of the program code according to the query path.

5. The method according to claim 4, characterized in that, Based on the associated instruction function represented by the simplified instruction, the query path of the simplified instruction is determined as follows: Identify the logical execution order between the main instruction function and the associated instruction function represented by the simplified instruction; If the logical execution order is to first execute the associated instruction function represented by the simplified instruction and then execute the main instruction function, the path of forward query along the writing order of the program code will be determined as the query path of the simplified instruction; If the logical execution order is to execute the main instruction function first and then the associated instruction function represented by the simplified instruction, the path of reverse lookup along the writing order of the program code will be determined as the lookup path of the simplified instruction.

6. The method according to claim 4 or 5, characterized in that, According to the query path, the associated instructions related to the simplified instructions in the compilation results of the program code include: Determine the field matching rule corresponding to the simplified instruction, and according to the query path, query the compilation result of the program code for another instruction that matches the field matching rule and is closest to the simplified instruction, and determine the other instruction as the associated instruction related to the simplified instruction.

7. The method according to claim 6, characterized in that, The other instruction that conforms to the field matching rule includes: The other instruction includes the target instruction field characterized by the field matching rule; or, The other instruction includes the target instruction field characterized by the field matching rule, but does not include the configuration field carried in the simplified instruction.

8. The method according to claim 1, characterized in that, Merging the simplified instructions and the associated instructions includes: Based on the instruction functions represented by the simplified instruction and the associated instruction, a portion of the instruction fields in the simplified instruction are updated in state, and the updated instruction is determined as the merged instruction, wherein the merged instruction simultaneously possesses the instruction functions represented by the simplified instruction and the associated instruction. Delete the original simplified instructions and associated instructions, and replace the original simplified instructions and associated instructions with the instructions obtained by merging.

9. The method according to claim 1 or 8, characterized in that, After merging the simplified instructions and the associated instructions, the method further includes: If the merged instruction does not correspond to the main instruction function represented by the complex instruction, the compiler continues to query the associated instructions related to the merged instruction in the compilation result of the program code, and then merges the merged instruction with the associated instructions.

10. The method according to claim 8, characterized in that, Replacing the original simplified instructions and associated instructions with the instructions obtained from the merger includes: If the deleted associated instructions contain instructions that characterize the function of the main instructions, the merged instructions will replace the original positions of the instructions that characterize the function of the main instructions.

11. The method according to claim 1, characterized in that, The method further includes: If no associated instruction is found in the compilation result of the program code, the simplified instruction is executed.

12. An electronic device, characterized in that, include: Memory, which stores computer instructions; At least one processor is configured to execute the computer instructions in the memory to perform the method according to any one of claims 1-11.

13. A computer-readable storage medium having computer instructions stored thereon, characterized in that, When executed by a processor, the computer instructions cause the processor to perform the method according to any one of claims 1-11.

14. A computer program product comprising computer instructions, characterized in that, When executed by a processor, the computer instructions cause the processor to perform the method according to any one of claims 1-11.

Citation Information

Patent Citations

  • Compilation optimization method and device, compiler, compiling equipment, medium and program

    CN119025123A