Crosslinking method, device, electronic device and program
Patent Information
- Application Number
- JP2023554384
- Authority / Receiving Office
- JP · JP
- Patent Type
- Patents
- Current Assignee / Owner
- Filing Date
- 2022-08-17
- Publication Date
- 2025-02-26
- Estimated Expiration
- 2042-08-17
Smart Images

Figure 0007636574000001 
Figure 0007636574000002 
Figure 0007636574000003
Abstract
Description
[Technical field]
[0001] The present application relates to the field of computer technology, and in particular to a cross-linking method, device, electronic device and storage medium. [Background technology]
[0002] Compiling and linking is the process of converting a high-level language program (source code) into a program that can be executed on hardware (executable code or machine code), and mainly includes two steps: compiling and linking. Compiling converts high-level language source code into intermediate code (object files). Linking combines object files and called library files (containing library functions) to create the final executable code.
[0003] For example, depending on the number of bits of the address length, compilers include 64-bit compilers and 32-bit compilers. When a compiler supports multiple hardware platforms and multiple programming languages, a complex situation occurs in which some programs are created by 32-bit front ends and some programs are created by 64-bit front ends. Specifically, if a 64-bit executable program is required but the library functions are created by a 32-bit compiler, when cross-linking, the traditional linker cannot ensure the accuracy of the machine code created in this case, so the workers are forced to upgrade all library functions to 64 bits. For this reason, all compilers that create library functions must be upgraded to 64 bits, which places a heavy burden on the workers. The traditional compile-link method cannot achieve cross-linking of programs with different bit numbers without upgrading the library functions. Summary of the Invention [Problem to be solved by the invention]
[0004] An object of the embodiments of the present application is to provide a cross-linking method, device, electronic device, and storage medium that can achieve cross-linking of programs with different numbers of address bits. [Means for solving the problem]
[0005] The present application is realized as follows.
[0006] In a first aspect, an embodiment of the present application provides a cross-linking method, which includes the steps of: modifying a register address in a first operation instruction of a library function when the register address in the first operation instruction is in a pre-created mapping table; and linking the modified first operation instruction to a main program, the mapping table including a mapping relationship between a destination register address of the main program and a register address of the library function, the destination register address of the main program is raised to a first address bit number, the register address in the operation instruction of the library function is a second address bit number, the first address bit number is greater than the second address bit number, and the register address in the modified first operation instruction is the destination register address of the corresponding main program in the mapping table.
[0007] In the embodiment of the present application, before linking the operation instruction of the library function to the main program, a pre-created mapping table is searched, and if the register address in the first operation instruction is in the pre-created mapping table, the register address in the first operation instruction is changed (i.e., increased to the first address bit number) according to the mapping relationship in the mapping table, and the changed first operation instruction is linked to the main program. This ensures the accuracy and uniformity of the address bit number when linking the library function to the main program. In this way, there is no need for the workers to upgrade all the compilers that create the library functions to the first address bit number, which reduces the burden on the workers and accelerates the development of subsequent projects.
[0008] In the technical solution according to the above first aspect, in some possible manners, before scanning all instructions in the library function, the method further includes a step of renaming a register corresponding to the library function, so as to assign a value to each register in the library function with one instruction each.
[0009] In the embodiment of the present application, before scanning all instructions in the library function, the registers corresponding to the library function are first renamed so that each register in the library function is assigned a value by one instruction respectively, which prevents confusion when increasing the number of bits of the register later and affects the linking of the library function.
[0010] In the technical solution according to the above first aspect, in some possible manners, when an address manipulation instruction of a library function is in a pre-created mapping table, before modifying a register address in the address manipulation instruction of the library function, the method further includes the steps of scanning all instructions in the library function to identify the first operation instruction which is an address manipulation instruction, and matching the register address in the first operation instruction with the mapping table.
[0011] In the embodiment of the present application, first, all instructions of the library function are scanned, and only if the instruction is an address manipulation instruction, an operation of matching with the mapping table is performed, thereby improving link efficiency.
[0012] In the technical solution according to the above first aspect, in some possible manners, before scanning all instructions in the library function, the method further includes the steps of: obtaining a parameter transfer instruction of the main program, which includes a destination register address for providing input parameters to the called library function, which is a second address bit number, and a source register address; raising the destination register address to a first address bit number and associating it with a register address of the called library function, which is the address of its own input parameter; and building the mapping table based on the destination register address with the raised bit number and the register address of the called library function.
[0013] In the embodiment of the present application, instead of constructing a mapping table including the mapping relationship of all register addresses, the bit number of the parameter register address is changed according to the parameter transmission command of the main program to dynamically create a desired mapping table, thereby improving link efficiency.
[0014] In the technical solution according to the above first aspect, in some possible manners, before obtaining the parameter transmission command of the main program, the method further includes the steps of compiling a source code of a main program having a first address bit number into the main program by a compiler having a first address bit number, and compiling a source code of a library function having a second address bit number into the library function by a compiler having a second address bit number.
[0015] In an embodiment of the present application, the source code of the main program can be compiled using a compiler with a first number of address bits, and the source code of the library functions can be compiled using a compiler with a second number of address bits. This eliminates the need for workers to upgrade all compilers used to create library functions to the first number of address bits, reducing the burden on workers and accelerating the development of subsequent projects.
[0016] In the technical solution according to the above first aspect, in some possible manners, when a register address in the mapping table and a register address not in the mapping table exist in the first operation instruction, the method further includes the steps of: increasing a destination register of a main program corresponding to the register address not in the mapping table to a first address bit number by sign extension, and updating the mapping table; and modifying the register address in the first operation instruction according to the updated mapping table.
[0017] In an embodiment of the present application, when a first operation instruction contains a register address in the mapping table and a register address not in the mapping table, the destination register of the main program corresponding to the register address not in the mapping table is sign-extended to the first address bit number, and the mapping table is updated, thereby realizing the update of the mapping table in the process of linking a library function, and ensuring the accuracy and uniformity of the address bit number when linking a library function to a main program.
[0018] In the technical solution according to the first aspect, in some possible manners, the first operation instruction includes any one of a load instruction, a store instruction, and an arithmetic instruction.
[0019] In a second aspect, an embodiment of the present application provides a cross-link device, which includes: a processing module for modifying a register address in a first operation instruction of a library function when the register address in the first operation instruction is in a pre-created mapping table; and a link module for linking the modified first operation instruction to a main program, the mapping table including a mapping relationship between a destination register address of the main program and a register address of the library function, the destination register address of the main program is raised to a first address bit number, the register address in the operation instruction of the library function is a second address bit number, and the register address in the modified first operation instruction is the destination register address of the corresponding main program in the mapping table.
[0020] In the technical solution according to the above second aspect, in some possible manners, the apparatus further includes a renaming module for renaming a register corresponding to the library function, so as to assign a value to each register in the library function with one instruction each before scanning all instructions in the library function.
[0021] In the technical solution according to the above second aspect, in some possible manners, the device further includes a matching module: when an address manipulation instruction of a library function is in a pre-created mapping table, before modifying a register address in the address manipulation instruction of the library function, scans all instructions in the library function, identifies the first operation instruction which is an address manipulation instruction, and matches the register address in the first operation instruction with the mapping table.
[0022] In the technical solution according to the above second aspect, in some possible manners, the apparatus further includes a construction module for obtaining a parameter transfer instruction of the main program, which includes a destination register address and a source register address for providing input parameters to the called library function, which is a second address bit number, before scanning all instructions in the library function, increasing the destination register address to a first address bit number, and associating the destination register address with a register address of the called library function, which is the address of its own input parameter, and constructing the mapping table based on the increased destination register address and the register address of the called library function.
[0023] In the technical solution according to the above second aspect, in some possible manners, the apparatus further includes a compilation module that compiles a source code of a main program having a first address bit number into the main program by a compiler having a first address bit number, and compiles a source code of a library function having a second address bit number into the library function by a compiler having a second address bit number before obtaining a parameter transmission command of the main program.
[0024] In the technical solution according to the above second aspect, in some possible manners, the device further includes an update module for, when a register address in the mapping table and a register address not in the mapping table exist in the first operation instruction, increasing a destination register of a main program corresponding to the register address not in the mapping table to a first address bit number by sign extension, updating the mapping table, and changing the register address in the first operation instruction according to the updated mapping table.
[0025] In the technical solution according to the second aspect, in some possible manners, the first operation instruction includes one of a load instruction, a store instruction, and a calculation instruction.
[0026] In a third aspect, an embodiment of the present application provides an electronic device, the electronic device including a processor and a memory coupled to the processor and storing a program that, when called by the processor, causes the processor to perform the embodiment of the first aspect above and / or a method according to some possible manners related to the embodiment of the first aspect above.
[0027] In a fourth aspect, an embodiment of the present application provides a computer readable storage medium storing a computer program which, when executed by a processor, causes the embodiment of the first aspect above to perform the method according to any of several possible ways associated with the embodiment of the first aspect above. [Brief description of the drawings]
[0028] In order to more clearly describe the technical solutions of the embodiments of the present application, the drawings necessary for describing the embodiments of the present application are briefly described below. The following drawings only show some embodiments of the present application and do not limit the scope. Those skilled in the art can obtain other related drawings based on these drawings without using inventive ability.
[0029] [Figure 1] FIG. 1 is a block diagram of a module of an electronic device according to an embodiment of the present application. [Diagram 2] FIG. 2 is a flow chart of a cross-linking method according to an embodiment of the present application. [Diagram 3] FIG. 3 is a flow chart of cross-linking according to an embodiment of the present application. [Figure 4] FIG. 4 is a block diagram of a module of a cross-link device according to an embodiment of the present application. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS
[0030] Hereinafter, the technical solutions according to the embodiments of the present application will be described with reference to the drawings of the embodiments of the present application.
[0031] Referring to FIG. 1, FIG. 1 is a schematic structural block diagram of an electronic device 100 using a cross-link method and device according to an embodiment of the present application. In the embodiment of the present application, the electronic device 100 may be a terminal or a server. The terminal may be, but is not limited to, a personal computer (PC), a smartphone, a tablet, a personal digital assistant (PDA), a mobile internet device (MID), etc. The server may be, but is not limited to, a network server, a database server, a cloud server, or a server integration device consisting of multiple sub-servers, etc. Of course, the above-listed devices are merely for easily understanding the embodiment of the present application, and do not limit the present embodiment.
[0032] The electronic device 100 may include a processor 110 and a memory 120 .
[0033] The processor 110 is electrically connected directly or indirectly to the memory 120 for data transmission and communication. For example, these elements may be electrically connected to each other via one or more communication buses or signal lines. The cross-link device includes at least one software module that can be stored in the memory 120 as software or embedded in the operating system (OS) of the electronic device 100 as firmware. The processor 110 executes executable modules, such as software function modules and computer programs, included in the cross-link device and stored in the memory 120, to realize the cross-link method. The processor 110 can execute a computer program upon receiving an execution instruction.
[0034] In the embodiment of the present application, the processor 110 is a graphics processing unit (GPU). A compiler arranged in the graphics processing unit supports high-level languages for shading such as GLSL (OpenGL Shading Language) and HLSL (High Level Shader Language), as well as general-purpose high-level languages for calculation such as OpenCL (Open Computing Language) and CUDA (Compute Unified Device Architecture, a platform for parallel computing), and also supports binary intermediate code representation such as DXIL and SPIR-V.
[0035] Of course, the processor 110 may be an integrated circuit chip having signal processing capabilities. The processor 110 may be a general-purpose processor such as a central processing unit (CPU), a digital signal processor (DSP), an application specific integrated circuit (ASIC), a discrete gate or transistor logic device, or a discrete hardware component, and may implement or execute each method, step, and logic block diagram disclosed in the embodiments of the present application. The general-purpose processor may be a microprocessor or any conventional processor, etc.
[0036] Memory 120 may be, but is not limited to, Random Access Memory (RAM), Read Only Memory (ROM), Programmable Read-Only Memory (PROM), Erasable Programmable Read-Only Memory (EPROM), and Electrically Erasable Programmable Read-Only Memory (EEPROM). Memory 120 stores programs that are executed by processor 110 upon receiving an execution instruction.
[0037] In addition, the structure shown in Fig. 1 is merely exemplary, and the electronic device 100 according to the embodiment of the present application may have fewer or more components than those shown in Fig. 1, or may have a different configuration than those shown in Fig. 1. Note that each component shown in Fig. 1 can be realized by software, hardware, or a combination thereof.
[0038] Fig. 2 is a flow chart of a cross-linking method according to an embodiment of the present application, and as shown in Fig. 2, the method is used in the electronic device 100 shown in Fig. 1. The cross-linking method according to the embodiment of the present application includes steps S101 to S102, but is not limited to the order shown in Fig. 2 and below.
[0039] Step S101: If the register address in the first operation instruction of the library function is in the mapping table created in advance, the register address in the first operation instruction is changed.
[0040] The mapping table includes a mapping relationship between a destination register address of the main program and a register address of the library function. The destination register address of the main program is raised to a first address bit number, and the register address in the operation instruction of the library function is a second address bit number. The changed register address in the first operation instruction is the destination register address of the corresponding main program in the mapping table.
[0041] Also, the first address bit number is larger than the second address bit number, the first address bit number is specified by the source code of the main program, and the second address bit number is specified by the address bit number of the source code of the library function. For example, if the source code of the main program is 64 bits, the first address bit number is 64 bits, and if the source code of the library function is 32 bits, the second address bit number is 32 bits. Of course, in other embodiments, the first address bit number may be 32 bits and the second address bit number may be 16 bits, or the first address bit number may be 128 bits and the second address bit number may be 64 bits, or the first address number may be 64 bits and the second address bit number may be 16 bits, and is not limited in this application. For ease of understanding, in the following examples, the first address bit number is 64 bits and the second address bit number is 32 bits.
[0042] The above "in the mapping table" can be understood to mean that the register address in the first operation instruction of the library function is the same as any one of the register addresses in the mapping table.
[0043] In one embodiment, before step S101, the method further includes the steps of scanning all instructions in the library function, identifying a first operation instruction which is an address operation instruction, and matching a register address in the first operation instruction with a mapping table.
[0044] The first operation instruction includes any one of a load instruction, a store instruction, and an arithmetic instruction.
[0045] The arithmetic instructions include, but are not limited to, an addition instruction (add), a subtraction instruction (sub), a multiplication instruction (mul), and a division instruction (div).
[0046] In the embodiment of the present application, first, all instructions in the library function are scanned, and only if the instruction is an address manipulation instruction, a matching operation with the mapping table is performed, thereby improving link efficiency.
[0047] Of course, the first instruction may be any instruction in the library function, and is not limited in this application.
[0048] Optionally, before performing the operation of scanning all instructions in the library function, the method further comprises the step of renaming registers corresponding to the library function such that each register in the library function is assigned a value with a respective instruction.
[0049] As an example, it is as follows:
[0050] 001:uadd uint32 temp(1079),uint32 temp(1067),uint32 temp(1069); ... 007:uadd uint32 temp(1079),uint32 temp(1068),10.
[0051] Among them, 001 and 007 represent two addition instructions in the library function. uint32 represents a 32-bit integer type, and temp(*) represents a register. For example, temp(1079) represents the 1079th register. In both instructions 001 and 007, a value is assigned to temp(1079) once. When increasing the number of bits in a register later, some instructions need to increase the register to 64 bits, while other instructions (for example, instructions other than address manipulation instructions) do not need to increase the register. In order to avoid confusion, temp(1079) can be renamed to a new unused register temp(1267). Then, the above instruction becomes as follows.
[0052] 001:uadd uint32 temp(1079),uint32 temp(1067),uint32 temp(1069) ... 007:uadd uint32 temp(1267),uint32 temp(1068),10
[0053] Therefore, in the embodiment of the present application, before scanning all the instructions in the library function, the registers corresponding to the library function are first renamed so that each register in the library function is assigned a value by one instruction, thereby preventing confusion when increasing the number of bits of the register later.
[0054] Optionally, before performing the operation of scanning all instructions in the above library function, the method includes the steps of obtaining a parameter transfer instruction of the main program, boosting a destination register address in the parameter transfer instruction to a first address bit number and associating it with a register address of the called library function, and building a mapping table based on the boosted destination register address and the register address of the called library function.
[0055] The parameter transfer command includes a destination register address and a source register address.
[0056] The destination register address is originally the second address bit number. The destination register address is the address for providing the input parameters to the called library function. The called library function's register address is the address of the called library function's own input parameters.
[0057] As an example, it is as follows:
[0058] movparam uint32 temp(66) uint64 temp(34)
[0059] The above instruction is a parameter transfer instruction of the main program. uint64 represents a 64-bit integer type. This instruction means to assign the value of register 34 to register 66. temp(34) is the source register address, and the operand of temp(34) is the source operand. temp(66) is the destination register address, and the operand of temp(66) is the destination operand. temp(66) is the address to provide the input parameter to the called library function.
[0060] Since the main program is 64-bit, we now modify the destination operand of the instruction, raising it to 64-bit. The modified instruction is:
[0061] movparam uint64 temp(66) uint64 temp(34)
[0062] Therefore, the destination register address temp(66) is increased from 32 bits to 64 bits.
[0063] Illustratively, the register address of the called library function corresponding to the address of this input parameter is uint32 temp(1067). That is, uint32 temp(1067) is both the register address of the called library function and the address of the input parameter of the called library function itself.
[0064] Then, the destination register address with the boosted number of bits is associated with the register address of the called library function to build a mapping table.
[0065] In the mapping table, the mapping relationship between the destination register address with the increased bit count and the register address of the called library function is as follows:
[0066] uint32 temp(1067) <―> uint64 temp(66)
[0067] Furthermore, if the instructions in the main program are instructions other than address manipulation instructions, they may be linked using a normal linking method.
[0068] In the embodiment of the present application, instead of constructing a mapping table including the mapping relationship of all register addresses, the bit number of the parameter register address is changed according to the parameter transmission command of the main program to dynamically create a desired mapping table, thereby improving link efficiency.
[0069] Optionally, before obtaining the parameter transmission instruction of the main program, the method further includes compiling, by a compiler with a first address bit number, a source code of the main program with the first address bit number into a main program, and compiling, by a compiler with a second address bit number, a source code of a library function with the second address bit number into a library function.
[0070] For example, a 64-bit compiler may compile a 64-bit main program source code into a main program, and a 32-bit compiler may compile a 32-bit library function source code into a library function.
[0071] In addition, the main program and the library functions in the above embodiment are both middle level intermediate codes. Before linking, the source code needs to be compiled by a compiler. In the embodiment of the present application, the source code of the main program can be compiled by a compiler with a first address bit number, and the source code of the library functions can be compiled by a compiler with a second address bit number, so that the workers do not need to upgrade all the compilers that create the library functions to the first address bit number.
[0072] The table is constructed in advance, and after identifying the first operation instruction of the library function, the register address in the first operation instruction is matched with the mapping table. Hereinafter, a specific example will be described. The first operation instruction is a load instruction as follows:
[0073] load float32 temp(1079),uint32 temp(1067),0
[0074] Searching the mapping table, uint32 temp(1067) is mapped to uint64 temp(66) in the main program, and the bit length of temp(66) in the main program is increased to 64 bits. In this case, it means that this operation instruction needs to be increased to 64 bits when linked to the main program. Now, change the first operation instruction, and the changed first operation instruction is as follows:
[0075] load float32 temp(1079),uint64 temp(66),0.
[0076] In one embodiment, if a register address in the mapping table and a register address not in the mapping table are present in the first operation instruction, the method further includes: sign-extending a destination register of the main program corresponding to the register address not in the mapping table to a first address bit number, and updating the mapping table; and modifying the register address in the first operation instruction based on the updated mapping table.
[0077] Specifically, when there are multiple register addresses in the first operation instruction, some of the register addresses may be in the mapping table and the other register addresses may not be in the mapping table. In order to unify the address bit number, only the destination registers of the main program corresponding to the other register addresses are increased to the first address bit number, and the mapping table is updated. Finally, the register addresses in the first operation instruction are changed according to the updated mapping table.
[0078] The code extension method is well known in the art, and therefore will not be described here.
[0079] Hereinafter, a specific example will be described. The first operation instruction is an add instruction as follows.
[0080] uadd uint32 temp(1079),uint32 temp(1067),uint32 temp(1069)
[0081] Search the mapping table and find that uint32 temp(1067) is in the mapping table and corresponds to uint64 temp(66) in the main program, but uint32 temp(1079) and uint32 temp(1069) are not in the mapping table. Therefore, to unify the number of address bits, increase the destination registers in the main program that correspond to uint32 temp(1079) and uint32 temp(1069) to 64 bits and update the mapping table.
[0082] The updated mapping table includes the following mapping relationships:
[0083] uint32 temp(1067) <―> uint64 temp(66) uint32 temp(1079) <―> uint64 temp(78) uint32 temp(1069) <―> uint64 temp(69)
[0084] Finally, the register address in the first operation instruction is modified based on the updated mapping table. The modified first operation instruction is as follows:
[0085] uadd uint64 temp(78),uint64 temp(66),uint64 temp(69)
[0086] In an embodiment of the present application, when a first operation instruction contains a register address in the mapping table and a register address not in the mapping table, the destination register of the main program corresponding to the register address not in the mapping table is sign-extended to the first address bit number, and the mapping table is updated. In this way, the mapping table can be updated in the process of linking a library function, and the accuracy and uniformity of the address bit number can be ensured when linking a library function to a main program.
[0087] In other embodiments, the number of bits may be increased according to the mapping relationship of the codes in the symbol table, and the present application is not limited thereto.
[0088] Step S102: The modified first operation instruction is linked to the main program.
[0089] Finally, the modified first operational instructions are linked into a main program which then undergoes machine-independent and machine-dependent optimizations to produce executable code, or machine code.
[0090] The above-mentioned cross-linking method will be described below with reference to a specific example. As shown in FIG. 3, the electronic device first obtains the source code of a 64-bit main program and the source code of a 32-bit library function, and then compiles them. That is, the source code of the 64-bit main program is compiled into a main program by a 64-bit compiler, and the source code of the 32-bit library function is compiled into a library function by a 32-bit compiler. Then, the main program and the library function are linked. First, a parameter transmission command of the main program is obtained. The parameter transmission command includes a destination register address and a source register address. The destination register address is 32 bits and is an address for providing an input parameter to the called library function. The destination register address is raised to 64 bits and associated with the register address of the called library function. The register address of the called library function is the address of the input parameter of the called library function itself. A mapping table is constructed based on the destination register address with the raised number of bits and the register address of the called library function. Then, the register corresponding to the library function is renamed so that a value is assigned to each register in the library function by one instruction. Then, scan all instructions in the library function to identify a first operation instruction which is an address operation instruction, and match the register address in the first operation instruction with the mapping table. If the register address in the first operation instruction of the library function is in the mapping table created in advance, modify the register address in the first operation instruction. The modified register address in the first operation instruction is the destination register address of the corresponding main program in the mapping table. Finally, link the modified first operation instruction with the main program to obtain an executable code.
[0091] As described above, in the embodiment of the present application, before linking the operation instruction of the library function to the main program, a previously prepared mapping table is searched, and if the register address in the first operation instruction is in the previously prepared mapping table, the register address in the first operation instruction is changed (i.e., increased to the first address bit number) according to the mapping relationship in the mapping table, and the changed first operation instruction is linked to the main program. This ensures the accuracy and uniformity of the address bit number when linking the library function to the main program. In this way, there is no need for the worker to upgrade all the compilers that create the library functions to the first address bit number, which reduces the burden on the workers and accelerates the development of subsequent projects.
[0092] Based on the same inventive idea, an embodiment of the present application further provides a cross-link apparatus 200 , which includes a processing module 210 and a link module 220 , as shown in FIG.
[0093] The processing module 210 modifies a register address in a first operation instruction of a library function when the register address in the first operation instruction is in a pre-created mapping table, the mapping table includes a mapping relationship between a destination register address of the main program and a register address of the library function, the destination register address of the main program is increased to a first address bit number, the register address in the operation instruction of the library function is a second address bit number, the first address bit number is greater than the second address bit number, and the modified register address in the first operation instruction is the destination register address of the corresponding main program in the mapping table.
[0094] The link module 220 links the modified first operating instruction to the main program.
[0095] Optionally, the apparatus further includes a matching module.
[0096] When an address manipulation instruction of a library function is in a pre-created mapping table, a matching module scans all instructions in the library function, identifies the first operation instruction which is an address manipulation instruction, and matches the register address in the first operation instruction with the mapping table before changing the register address in the address manipulation instruction of the library function.
[0097] Optionally, the apparatus further comprises a renaming module.
[0098] The renaming module renames registers corresponding to the library functions such that each register in the library function is assigned a value by one instruction before scanning all instructions in the library function.
[0099] Optionally, the apparatus further comprises a construction module.
[0100] Before scanning all instructions in the library function, the construction module obtains a parameter transfer instruction of the main program, boosts a destination register address to a first address bit number and associates it with a register address of a called library function, and constructs the mapping table based on the boosted destination register address and the register address of the called library function, the parameter transfer instruction includes the destination register address of a second address bit number and a source register address, the destination register address is an address for providing an input parameter to the called library function, and the register address of the called library function is an address of the input parameter of the called library function itself.
[0101] Optionally, the apparatus further includes a compilation module.
[0102] Before obtaining a parameter transmission command of the main program, the compilation module compiles a source code of a main program having a first address bit number into the main program using a compiler having a first address bit number, and compiles a source code of a library function having a second address bit number into the library function using a compiler having a second address bit number.
[0103] Optionally, the apparatus further includes an update module.
[0104] When a register address in the mapping table and a register address not in the mapping table are present in the first operation instruction, the update module increases a destination register of the main program corresponding to the register address not in the mapping table to a first address bit number by sign extension, updates the mapping table, and changes the register address in the first operation instruction based on the updated mapping table.
[0105] It should be noted that for the operation processes of the above-described system, device, and unit, those skilled in the art can refer to the corresponding processes in the above-described method embodiments, so for convenience and brevity, the description thereof will be omitted here.
[0106] Based on the same inventive idea, an embodiment of the present application further provides a computer-readable storage medium storing a computer program, which when executed, performs the method according to the above embodiment.
[0107] The storage medium may be any available medium accessible by a computer, or a data storage device formed by integrating one or more available media, such as a server, a data center, etc. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a magnetic tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid state drive (SSD)).
[0108] In the embodiments according to the present application, the described apparatus and method can be realized in other ways. The above-described apparatus embodiments are merely exemplary. For example, the division of the above units is merely a logical functional division, and may be another division in actual implementation. For example, multiple units or components may be combined or integrated into another system, or some features may be omitted or not implemented. In addition, the shown or discussed mutual couplings or direct couplings or communication connections may be indirect couplings or communication connections through some interfaces, devices or units, and may be electrical, mechanical or other types of connections.
[0109] In addition, the units described as separate parts may or may not be physically separate. The components shown as units may or may not be physical units, i.e., they may be located in the same location or distributed among multiple network units. Some or all of the units can be selected according to actual requirements to achieve the purpose of the proposed embodiment.
[0110] Each functional module according to each embodiment of the present application may be an independent part formed by integration, or each module may be a stand-alone module, or may be an independent part formed by integration of two or more modules.
[0111] As used herein, relational terms such as first and second, etc. may be used only to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual relationship or order between such entities or actions.
[0112] The above is merely an embodiment of the present application, and does not limit the scope of protection of the present application. Those skilled in the art may make improvements or modifications to the present application. Any modifications, equivalent replacements or improvements made without departing from the spirit of the present application belong to the scope of protection of the present application. [Explanation of symbols]
[0113] 100...Electronic equipment 110…Processor 120…Memory 200…Crosslinking device 210... Processing module 220...Link module
Claims
1. A processor-implemented cross-linking method, comprising: The steps executed by the processor include: changing a register address in a first operation instruction of a library function when the register address in the first operation instruction is in a mapping table created in advance; and linking the modified first operating instructions into a main program; The mapping table includes a mapping relationship between a destination register address of the main program and a register address of the library function, the destination register address of the main program is increased to a first address bit number, the register address in an operation instruction of the library function is a second address bit number, the first address bit number is greater than the second address bit number, and the register address in the changed first operation instruction is the destination register address of the main program corresponding to the destination register address in the mapping table. A crosslinking method comprising the steps of:
2. before scanning all instructions in said library function, The method further includes a step of renaming registers corresponding to the library functions so that each register in the library functions is assigned a value with a single instruction.
2. The cross-linking method according to claim 1 .
3. When an address manipulation instruction of a library function is in the previously created mapping table, before changing a register address in the address manipulation instruction of the library function, scanning all instructions in the library function to identify the first manipulation instruction being an address manipulation instruction; and matching a register address in the first operation instruction with the mapping table.
2. The cross-linking method according to claim 1 .
4. before scanning all instructions in said library function, obtaining a parameter transfer instruction of the main program, the parameter transfer instruction including a destination register address and a source register address for providing input parameters to the called library function, the destination register address being a second number of address bits; raising the destination register address to a first number of address bits and associating it with a register address of the called library function that is the address of its own input parameter; and constructing the mapping table based on the boosted destination register address and the register address of the called library function.
4. The cross-linking method according to claim 3.
5. before obtaining a parameter transmission command of the main program; compiling, by a compiler with a first number of address bits, a source code of a main program with the first number of address bits into the main program; and compiling, by a compiler for the second number of address bits, a source code of a library function having the second number of address bits into the library function.
5. The cross-linking method according to claim 4.
6. If a register address in the mapping table and a register address not in the mapping table are present in the first operation instruction, updating the mapping table by sign-extending a destination register of the main program corresponding to a register address not found in the mapping table to a first address bit number; and modifying a register address in the first operation instruction based on the updated mapping table.
2. The cross-linking method according to claim 1 .
7. 7. The cross-link method according to claim 1, wherein the first operation command includes any one of a load command, a store command, and an arithmetic command.
8. a processing module for changing a register address in a first operation instruction of a library function when the register address in the first operation instruction is in a mapping table created in advance; a link module for linking the modified first operating instructions to a main program; The mapping table includes a mapping relationship between a destination register address of the main program and a register address of the library function, the destination register address of the main program is increased to a first address bit number, the register address in an operation instruction of the library function is a second address bit number, the first address bit number is greater than the second address bit number, and the register address in the changed first operation instruction is the destination register address of the main program corresponding to the destination register address in the mapping table. A cross-linking device comprising:
9. The method further includes a renaming module for renaming a register corresponding to the library function such that each register in the library function is assigned a value by one instruction before scanning all instructions in the library function.
9. A cross-link device according to claim 8.
10. and a matching module for scanning all instructions in the library function, identifying the first operation instruction which is an address manipulation instruction, and matching the register address in the first operation instruction with the mapping table before modifying a register address in the address manipulation instruction of the library function when the address manipulation instruction of the library function is in the pre-created mapping table.
9. A cross-link device according to claim 8.
11. and a construction module for obtaining a parameter transfer instruction of the main program, the parameter transfer instruction including a destination register address and a source register address for providing an input parameter to a called library function, the destination register address being a second number of address bits, before scanning all instructions in the library function, and for raising the destination register address to a first number of address bits and associating the destination register address with a register address of the called library function, the register address being the address of its own input parameter, and for constructing the mapping table based on the raised destination register address and the register address of the called library function.
11. A cross-link device according to claim 10.
12. The method further includes a compilation module for compiling a source code of a main program having a first address bit number into the main program by a compiler having a first address bit number and compiling a source code of a library function having a second address bit number into the library function by a compiler having a second address bit number before obtaining a parameter transmission command of the main program.
12. A cross-link device according to claim 11.
13. and an update module for, when a register address in the mapping table and a register address not in the mapping table are present in the first operation instruction, increasing a destination register of a main program corresponding to the register address not in the mapping table to a first address bit number by sign extension, updating the mapping table, and changing the register address in the first operation instruction based on the updated mapping table.
9. A cross-link device according to claim 8.
14. 14. The cross link device according to claim 8, wherein the first operation command includes any one of a load command, a store command, and an arithmetic command.
15. A processor; a memory connected to said processor and storing a program for causing said processor to carry out the method according to any one of claims 1 to 6.
1. An electronic device comprising:
16. A processor; a memory coupled to said processor and storing a program for causing said processor to carry out the method of claim 7.
1. An electronic device comprising:
17. The cross-linking method according to any one of claims 1 to 6 is performed by the processor. A program characterized by:
18. The cross-linking method according to claim 7 is performed by the processor. A program characterized by:
Citation Information
Patent Citations
Shared library system and method of building the system
CN1577268A
Information processor
JP1994019717A