Parallel compiler compiling method and system supporting multiple operating systems
By generating and transforming abstract syntax tree (AST) to support the parallel compiler compilation method of multi-operating systems, the flexibility and portability of existing compilers in a multi-operating system environment is solved, and efficient multi-core processors are realized Parallel compilation and cross-platform compatibility.
Patent Information
- Application Number
- CN202411584312.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-07
- Publication Date
- 2025-02-14
AI Technical Summary
Existing parallel compilers are often optimized for specific operating systems or hardware platforms, lack flexibility and portability, cannot take full advantage of the parallelism of multi-core processors, and are difficult to run in multiple operating system environments.
A parallel compiler compilation method that supports multiple operating systems is proposed. By obtaining parallel compilation files and parameters, a AST tree is generated, traversing and transforming the main function node, combining parallel compilation parameters to generate the AST tree node of the corresponding operating system interface, and then combining them. Insert the AST tree to realize parallel compilation of multiple operating systems.
It realizes efficient compilation of parallel programs in multiple operating system environments, makes full use of the parallel advantages of multi-core processors, reduces development and maintenance costs, simplifies the compilation process, and improves compilation efficiency.
Smart Images

Figure CN119440538A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the field of electronic information technology applications and relates to a parallel compiler compiling method and system supporting multiple operating systems. Background Art
[0002] A parallel compiler is a special compiler that can generate code that can be executed in parallel to fully utilize the computing power of modern multi-core processors. Its core purpose is to improve the program execution efficiency of multi-core processors. With the development of embedded system chips, multi-core integrated architecture has become a standard configuration for integrated circuit design. By integrating multiple processor cores on a single chip, the computing power has been significantly improved. However, the efficient application of multi-core processors is not easy, especially in terms of how to balance task allocation, reduce communication overhead and optimize resource usage.
[0003] The existing high-performance dual-core processor LSP0201RH is compatible with the instruction set architecture of PowerPC. It is becoming increasingly complex and integrated. It needs to adapt to multiple chip upper-layer software to meet product compatibility. However, this will increase the investment in application development. At the same time, it is difficult to give full play to the parallel advantages of multi-core processors, and it is also necessary to reduce the application development burden of developers from serial code to parallel code. In high-tech fields such as aerospace, programs often need to run in multiple hardware and software environments, including bare metal environments, embedded Linux environments, and real-time operating systems such as FreeRTOS environments. The differences in these environments have led to major challenges in parallel program porting and compatibility.
[0004] However, traditional parallel compilers are usually optimized for specific operating systems or hardware platforms, lack flexibility and portability, and are unable to fully utilize their performance and support compilers for multiple operating systems and ensure that users can convert serial code into parallel programs in a very easy-to-use way. Summary of the invention
[0005] The purpose of the present invention is to solve the problems in the prior art and to provide a parallel compiler compiling method and system supporting multiple operating systems.
[0006] In order to achieve the above object, the present invention adopts the following technical solutions: The present invention proposes a parallel compiler compiling method supporting multiple operating systems, comprising: Get parallel compilation files and parallel compilation parameters; Perform AST tree changes on the parallel compiled file to obtain the AST tree, and traverse the AST tree to find the main function node; Transform the main function node and generate the AST tree node corresponding to the operating system interface in combination with the parallel compilation parameters; Insert AST tree nodes into the AST tree to perform node transformation operations to achieve parallel compilation of multiple operating systems.
[0007] Preferably, the parallel compilation parameters are obtained, specifically: By adding OPTION(rtos) to the option_t enumeration and OPTNAME(rtos) to the optnames array, the getopts() function is used to identify the command line parameters of the program call, and the rtosmode parameter is changed according to the command line parameters. The compilation mode of the operating system is obtained according to the rtosmode parameter.
[0008] Preferably, when the rtosmode parameter is true, a compilation mode of a real-time operating system is generated; when the rtosmode parameter is false, a compilation mode of a Linux operating system is generated.
[0009] Preferably, the parallel compilation file is subjected to AST tree changes to obtain an AST tree, and the AST tree is traversed to find the main function node, specifically: Through the ast_xform() function, the complete AST tree corresponding to the parallel compilation file is obtained, and the main function node is obtained by traversing the AST tree structure.
[0010] Preferably, the main function node is transformed and the AST tree node corresponding to the operating system interface is generated in combination with the parallel compilation parameters, specifically: The main function node is transformed according to the main function node conversion function append_new_main(), and then different main function node structures are generated in combination with different parallel compilation parameters, that is, the AST tree node is obtained.
[0011] Preferably, the inserting of the AST tree node into the AST tree to perform a node transformation operation is specifically as follows: Generate a new main function node through the BlockList function, add the new main function node to the AST tree, configure the corresponding parent node relationship, and complete the transformation operation through the chain data structure.
[0012] The present invention proposes a parallel compiler compiling system supporting multiple operating systems, comprising: A system configuration module, wherein the system configuration module is used to obtain parallel compilation files and parallel compilation parameters; A node search module, which is used to perform AST tree changes on the parallel compilation file to obtain an AST tree, and traverse the AST tree to search for a main function node; A node acquisition module, which is used to transform the main function node and generate an AST tree node corresponding to the operating system interface in combination with the parallel compilation parameters; A node transformation module is used to insert AST tree nodes into the AST tree to perform node transformation operations, thereby realizing parallel compilation of multiple operating systems.
[0013] Preferably, the parallel compilation parameters are obtained, specifically: By adding OPTION(rtos) to the option_t enumeration and OPTNAME(rtos) to the optnames array, the getopts() function is used to identify the command line parameters of the program call, and the rtosmode parameter is changed according to the command line parameters. The compilation mode of the operating system is obtained according to the rtosmode parameter.
[0014] A terminal device comprises a memory, a processor and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of a parallel compiler compiling method supporting multiple operating systems are implemented.
[0015] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of a parallel compiler compiling method supporting multiple operating systems.
[0016] Compared with the prior art, the present invention has the following beneficial effects: The invention proposes a parallel compiler compiling method supporting multiple operating systems. By obtaining parallel compilation files, the advantages of multi-processor or multi-core systems can be fully utilized, and multiple compilation tasks can be processed simultaneously, greatly shortening the compilation time. Parallel compilation can significantly improve the compilation speed of large files, especially for complex software projects, can accelerate the development cycle and improve development efficiency. The main function node is transformed and the AST tree node corresponding to the operating system interface is generated in combination with the parallel compilation parameters, and then inserted into the AST tree for node transformation operation, so that the compiled file can generate corresponding compiled code according to different operating systems. This method breaks the barriers between different operating systems, and developers do not need to write and maintain different versions of code for each operating system separately, reducing development and maintenance costs. The method allows adjustment according to different parallel compilation parameters to adapt to various compilation requirements. Whether it is for a specific hardware configuration or a specific performance requirement, the best compilation effect can be achieved by adjusting the parameters. At the same time, the operation of the AST tree also provides great flexibility, and a customized compilation process can be performed according to different requirements. Therefore, the method proposed by the invention can solve the adaptation problem of parallel files in different operating environments.
[0017] The invention proposes a parallel compiler compiling system supporting multiple operating systems, which realizes the parallel compilation of multiple operating systems by dividing the system into a system configuration module, a node search module, a node acquisition module and a node transformation module. The modularization concept is adopted to make each module independent of each other, which is convenient for unified management of each module. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.
[0019] Figure 1 This is a flow chart of the parallel compiler compiling method supporting multiple operating systems of the present invention.
[0020] Figure 2 The parallel program compilation flow chart of the present invention.
[0021] Figure 3 The figure is a flowchart of the compiler front end of the present invention.
[0022] Figure 4 The parallel program compilation flow chart of the present invention.
[0023] Figure 5 A diagram of the parallel compiler compilation system supporting multiple operating systems according to the present invention.
[0024] Figure 6 The figure is a schematic structural diagram of an electronic device of the present invention. DETAILED DESCRIPTION
[0025] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.
[0026] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention claimed for protection, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0027] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.
[0028] In the description of the embodiments of the present invention, it should be noted that if the terms "upper", "lower", "horizontal", "inner", etc. indicate an orientation or positional relationship based on the orientation or positional relationship shown in the drawings, or the orientation or positional relationship in which the product of the invention is usually placed when in use, it is only for the convenience of describing the present invention and simplifying the description, and does not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the present invention. In addition, the terms "first", "second", etc. are only used to distinguish the description, and cannot be understood as indicating or implying relative importance.
[0029] In addition, if the term "horizontal" appears, it does not mean that the component must be absolutely horizontal, but can be slightly tilted. For example, "horizontal" only means that its direction is more horizontal than "vertical", which does not mean that the structure must be completely horizontal, but can be slightly tilted.
[0030] In the description of the embodiments of the present invention, it is also necessary to explain that, unless otherwise clearly specified and limited, the terms "set", "install", "connect", and "connect" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, or it can be the internal connection of two components. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0031] The present invention is further described in detail below in conjunction with the accompanying drawings: Example 1 The present invention proposes a parallel compiler compiling method supporting multiple operating systems, such as Figure 1 and Figure 4 As shown, the following steps are included: S1. Obtain parallel compilation files and parallel compilation parameters; Get the parallel compilation parameters, specifically: By adding OPTION(rtos) to the option_t enumeration and OPTNAME(rtos) to the optnames array, the getopts() function is used to identify the command line parameters of the file call, and the rtosmode parameter is changed according to the command line parameters. The compilation mode of the operating system is obtained according to the rtosmode parameter.
[0032] When the rtosmode parameter is true, the compilation mode of the real-time operating system is generated; when the rtosmode parameter is false, the compilation mode of the Linux operating system is generated.
[0033] S2, change the AST tree of the parallel compiled file to obtain the AST tree, and traverse the AST tree to find the main function node; The parallel compilation file is subjected to AST tree changes to obtain an AST tree, and the AST tree is traversed to find the main function node, specifically: Through the ast_xform() function, the complete AST tree corresponding to the parallel compiler is obtained, and the main function node is obtained by traversing the AST tree structure.
[0034] S3, transform the main function node, and generate an AST tree node corresponding to the operating system interface in combination with the parallel compilation parameters; The main function node is transformed and the AST tree node corresponding to the operating system interface is generated in combination with the parallel compilation parameters, specifically: The main function node is transformed according to the main function node conversion function append_new_main(), and then different main function node structures are generated in combination with different parallel compilation parameters, that is, the AST tree node is obtained.
[0035] S4. Insert the AST tree node into the AST tree to perform node transformation operations to achieve parallel compilation of multiple operating systems.
[0036] The operation of inserting the AST tree node into the AST tree for node transformation is specifically as follows: Generate a new main function node through the BlockList function, add the new main function node to the AST tree, configure the corresponding parent node relationship, and complete the transformation operation through the chain data structure.
[0037] The following is a detailed description of this method: The present invention provides VCCi front-end compiler software for the LSP0201RH processor hardware platform. The compiler supports the OpenMP parallel compilation standard and can generate parallel programs adapted to different operating system environments according to the user's choice. The OpenMP parallel compilation standard uses #pragma to compile directive statements to guide the compiler to compile parallel code. The VCCi compiler adopts a multi-stage compilation process, including components such as a precompiler, a compiler front end, a runtime library, a system compiler, and a linker. The compilation flow chart is as follows: Figure 2 The compiler front end ants-fe receives and analyzes the source code, generates an intermediate representation (IR), and then controls the compiler output according to the --rtos option specified by the user.
[0038] like Figure 3 The front-end workflow of the compiler is based on the source compiler to implement parallel compiler front-end software across multiple operating systems. The source code is analyzed lexically and the syntax analysis process forms an intermediate representation abstract syntax tree (AST). Then, the AST tree is reassembled through AST transformation, and then the new AST tree is output through the target code generation process to form a new C language code (converting the guidance statement into a runtime library interface program). The front-end workflow of the compiler has the following specific steps: 1) Lexical analysis, the first step of the compiler, decomposes the source code into a series of lexical units (Tokens), such as keywords, identifiers, constants, operators, etc. Because the keywords in the OpenMP directives overlap with the keywords in the C language, they need to be identified in this step.
[0039] 2) Syntax analysis and semantic analysis. Based on lexical analysis, the syntax analyzer combines lexical units into grammatical structures, such as expressions and statements, according to the syntax rules of the programming language, and constructs an abstract syntax tree (AST). In this step, it is necessary to build a complete abstract syntax tree according to the rules of OpenMP / C program syntax, classify ordinary C language code and OpenMP program code, and generate different AST tree nodes respectively. It mainly completes the creation of the AST tree and the analysis of the parent-child relationship of the nodes. This syntax tree will correspond one-to-one with the source code.
[0040] 3) AST transformation. In this part, the AST tree is traversed multiple times, and the nodes of the tree are cut, spliced, and transformed into the form defined by the "runtime library". Usually these forms use a unified API interface. At this stage, different main function nodes will be generated according to different configuration parameters, that is, the type of operating system used, such as --rtos for real-time embedded operating system.
[0041] 4) Code generator, because the parallel compiler front-end software is mainly responsible for compiling the OpenMP parallel program into a C language program without compilation directive statements. From a formal point of view, the output of AST is actually the inverse process of syntax analysis. Therefore, it is also necessary to re-traverse the transformed AST tree structure according to the configured operating system type parameters and restore its nodes to character text, that is, to distinguish C language programs with different operating system interfaces.
[0042] Based on the AST tree transformation function, the present invention traverses the entire AST, and then classifies all AST tree nodes according to the node type, generates the corresponding AST node main function according to different user configuration options, and adds it to the AST tree of the corresponding category, and finally generates a module according to the target code of the AST tree, and outputs the AST tree into the corresponding target code according to the new structural organization form. In the present invention, the output code is a C language code without OpenMP directive statements, which uses all the operation interfaces provided in the runtime library. The specific implementation process is as follows: 1) Get configuration parameters. By adding OPTION(rtos) in the option_t enumeration and OPTNAME(rtos) in the optnames array, we can enrich the identification variables of program parameters. Then, we can modify the getopts() function. The getopts() function mainly identifies the command line parameters of the program call and changes the value of the corresponding control variable according to the parameter, so that the subsequent program can perform corresponding operations according to the variable. Here, we use the rtosmode parameter to indicate whether to automatically generate the compilation process of the real-time operating system. When rtosmode is true, the compilation mode of the real-time operating system is generated; when rtosmode is false, the compilation mode of the Linux operating system is generated. 2) Traverse the AST tree: Use the ast_xform() function to obtain the complete AST tree corresponding to the source code, and then find the main function node of the transformation by traversing the tree structure.
[0043] 3) Add and implement the main function node conversion function append_new_main(): This step is mainly to achieve the generation of different main function node structures according to different configuration parameters. In this step, you need to first determine the value of the rtosmode parameter. When using the real-time embedded operating system mode, the generated main function will have the characteristics of the real-time operating system, and the main function of the parallel program will be packaged into a task. Through the task creation function of the corresponding real-time embedded operating system, the memory management function of the embedded real-time operating system is added.
[0044] 4) Add the tree structure, add the generated new main node to the AST tree through the BlockList function, configure the corresponding parent node relationship, and complete it through the chain data structure operation.
[0045] 5) Compile and generate the executable file of the compiler front-end software. This step is to form a new compiler front-end software so that it can run in the system. When running in the system, the corresponding compilation parameter option (--rtos) needs to be used.
[0046] 6) Run the compiler front-end software and obtain the results: This step is to run the compiler front-end software and pass in the operating system type parameter to compile the parallel program into a C language program with the corresponding operating system interface.
[0047] Therefore, the parallel compiler front-end software of the present invention adopts source-to-source compilation technology, can receive and process the original parallel program source code, and automatically generate parallel program code adapted to different operating system environments according to predefined configuration parameters. Through this automated source code conversion process, the compiler front-end software ensures the efficient operation of parallel programs on different target operating systems, while maintaining the portability and consistency of the code. In addition, the compiler front-end software of the present invention is optimized specifically for domestic self-developed processors, enhancing the running compatibility of parallel programs thereon. Through intelligent code generation and adjustment mechanisms, this software significantly improves the performance of parallel programs on processors, and reduces the workload of developers on program transplantation and optimization. In summary, the main purpose of the parallel compiler front-end software of the present invention is to achieve cross-platform compatibility of parallel programs, reduce the difficulty of transplantation of parallel programs, and improve the operating efficiency on domestic self-developed processors, thereby promoting the application and development of parallel computing technology in key fields such as aerospace. The present invention is applied to the 0201-PPC processor platform, supports embedded real-time operating systems and Linux operating systems as well as bare metal mode, completes the compilation of parallel programs through the front-end software, compiles the compilation guidance statements of parallel programs into API interfaces supported by the runtime library, and realizes cross-platform compatibility of parallel programs.
[0048] Example 2 The present invention proposes a parallel compiler compiling system supporting multiple operating systems, such as Figure 5 As shown, it includes a system configuration module, a node search module, a node acquisition module and a node transformation module; The system configuration module is used to obtain parallel compilation files and parallel compilation parameters; Get the parallel compilation parameters, specifically: By adding OPTION(rtos) to the option_t enumeration and OPTNAME(rtos) to the optnames array, the getopts() function is used to identify the command line parameters of the program call, and the rtosmode parameter is changed according to the command line parameters. The compilation mode of the operating system is obtained according to the rtosmode parameter.
[0049] When the rtosmode parameter is true, the compilation mode of the real-time operating system is generated; when the rtosmode parameter is false, the compilation mode of the Linux operating system is generated.
[0050] The node search module is used to perform AST tree changes on the parallel compiled file to obtain an AST tree, and traverse the AST tree to search for the main function node; The parallel compilation file is subjected to AST tree changes to obtain an AST tree, and the AST tree is traversed to find the main function node, specifically: Through the ast_xform() function, the complete AST tree corresponding to the parallel compilation file is obtained, and the main function node is obtained by traversing the AST tree structure.
[0051] The node acquisition module is used to transform the main function node and generate an AST tree node corresponding to the operating system interface in combination with the parallel compilation parameters; The main function node is transformed and the AST tree node corresponding to the operating system interface is generated in combination with the parallel compilation parameters, specifically: The main function node is transformed according to the main function node conversion function append_new_main(), and then different main function node structures are generated in combination with different parallel compilation parameters, that is, the AST tree node is obtained.
[0052] The node transformation module is used to insert AST tree nodes into the AST tree to perform node transformation operations, thereby realizing parallel compilation of multiple operating systems.
[0053] The operation of inserting the AST tree node into the AST tree for node transformation is specifically as follows: Generate a new main function node through the BlockList function, add the new main function node to the AST tree, configure the corresponding parent node relationship, and complete the transformation operation through the chain data structure.
[0054] Example 3 See also Figure 6 As shown, the present invention also provides an electronic device 100 that supports a parallel compiler compilation method for multiple operating systems; the electronic device 100 includes a memory 101, at least one processor 102, a computer program 103 stored in the memory 101 and executable on the at least one processor 102, and at least one communication bus 104.
[0055] The memory 101 can be used to store the computer program 103, and the processor 102 implements the steps of the parallel compiler compiling method supporting multiple operating systems described in Example 1 by running or executing the computer program stored in the memory 101 and calling the data stored in the memory 101. The memory 101 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data (such as audio data) created according to the use of the electronic device 100, etc. In addition, the memory 101 can include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), at least one disk storage device, a flash memory device, or other non-volatile solid-state storage devices.
[0056] The at least one processor 102 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The processor 102 may be a microprocessor or any conventional processor, etc. The processor 102 is the control center of the electronic device 100, and uses various interfaces and lines to connect various parts of the entire electronic device 100.
[0057] The memory 101 in the electronic device 100 stores a plurality of instructions to implement a parallel compiler compiling method supporting multiple operating systems, and the processor 102 can execute the plurality of instructions to implement: Get parallel compilation files and parallel compilation parameters; Perform AST tree changes on the parallel compiled file to obtain the AST tree, and traverse the AST tree to find the main function node; Transform the main function node and generate the AST tree node corresponding to the operating system interface in combination with the parallel compilation parameters; Insert AST tree nodes into the AST tree to perform node transformation operations to achieve parallel compilation of multiple operating systems.
[0058] Example 4 If the module / unit integrated in the electronic device 100 is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present invention implements all or part of the process in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device that can carry the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory and read-only memory (ROM, Read-Only Memory).
[0059] It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0060] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0061] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0062] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0063] 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, ordinary technicians in the relevant field should understand that the specific implementation methods of the present invention can still be modified or replaced by equivalents. Any modification or equivalent replacement that does not depart from the spirit and scope of the present invention should be covered within the scope of protection of the claims of the present invention.
Claims
1. A parallel compiler compiling method supporting multiple operating systems, characterized in that: include: Get parallel compilation files and parallel compilation parameters; Perform AST tree changes on the parallel compiled file to obtain the AST tree, and traverse the AST tree to find the main function node; Transform the main function node and generate the AST tree node corresponding to the operating system interface in combination with the parallel compilation parameters; Insert AST tree nodes into the AST tree to perform node transformation operations to achieve parallel compilation of multiple operating systems.
2. The parallel compiler compiling method supporting multiple operating systems according to claim 1, characterized in that: Get the parallel compilation parameters, specifically: By adding OPTION(rtos) to the option_t enumeration and OPTNAME(rtos) to the optnames array, the getopts() function is used to identify the command line parameters of the program call, and the rtosmode parameter is changed according to the command line parameters. The compilation mode of the operating system is obtained according to the rtosmode parameter.
3. The parallel compiler compiling method supporting multiple operating systems according to claim 2, characterized in that: When the rtosmode parameter is true, the compilation mode of the real-time operating system is generated; when the rtosmode parameter is false, the compilation mode of the Linux operating system is generated.
4. The parallel compiler compiling method supporting multiple operating systems according to claim 1, characterized in that: The parallel compilation file is subjected to AST tree changes to obtain an AST tree, and the AST tree is traversed to find the main function node, specifically: Through the ast_xform() function, the complete AST tree corresponding to the parallel compilation file is obtained, and the main function node is obtained by traversing the AST tree structure.
5. The parallel compiler compiling method supporting multiple operating systems according to claim 1, characterized in that: The main function node is transformed and the AST tree node corresponding to the operating system interface is generated in combination with the parallel compilation parameters, specifically: The main function node is transformed according to the main function node conversion function append_new_main(), and then different main function node structures are generated in combination with different parallel compilation parameters, that is, the AST tree node is obtained.
6. The parallel compiler compiling method supporting multiple operating systems according to claim 1, characterized in that: The operation of inserting the AST tree node into the AST tree for node transformation is specifically as follows: Generate a new main function node through the BlockList function, add the new main function node to the AST tree, configure the corresponding parent node relationship, and complete the transformation operation through the chain data structure.
7. A parallel compiler compiling system supporting multiple operating systems, characterized in that: include: A system configuration module, wherein the system configuration module is used to obtain parallel compilation files and parallel compilation parameters; A node search module, which is used to perform AST tree changes on the parallel compilation file to obtain an AST tree, and traverse the AST tree to search for a main function node; A node acquisition module, which is used to transform the main function node and generate an AST tree node corresponding to the operating system interface in combination with the parallel compilation parameters; A node transformation module is used to insert AST tree nodes into the AST tree to perform node transformation operations, thereby realizing parallel compilation of multiple operating systems.
8. The parallel compiler compiling system supporting multiple operating systems according to claim 7, characterized in that: Get the parallel compilation parameters, specifically: By adding OPTION(rtos) to the option_t enumeration and OPTNAME(rtos) to the optnames array, the getopts() function is used to identify the command line parameters of the program call, and the rtosmode parameter is changed according to the command line parameters. The compilation mode of the operating system is obtained according to the rtosmode parameter.
9. A terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the parallel compiler compiling method supporting multiple operating systems as claimed in any one of claims 1 to 6 are implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the parallel compiler compiling method supporting multiple operating systems as claimed in any one of claims 1 to 6 are implemented.
Citation Information
Cited By
Parallel compiling method based on intermediate representation
CN122363705A