[go: up one dir, main page]

CN111857816B - Register allocation method, device, electronic equipment and computer storage medium - Google Patents

Register allocation method, device, electronic equipment and computer storage medium Download PDF

Info

Publication number
CN111857816B
CN111857816B CN201910339025.7A CN201910339025A CN111857816B CN 111857816 B CN111857816 B CN 111857816B CN 201910339025 A CN201910339025 A CN 201910339025A CN 111857816 B CN111857816 B CN 111857816B
Authority
CN
China
Prior art keywords
register
information
calling
calling convention
registers
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910339025.7A
Other languages
Chinese (zh)
Other versions
CN111857816A (en
Inventor
林作健
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Alibaba Group Holding Ltd
Original Assignee
Alibaba Group Holding Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Alibaba Group Holding Ltd filed Critical Alibaba Group Holding Ltd
Priority to CN201910339025.7A priority Critical patent/CN111857816B/en
Publication of CN111857816A publication Critical patent/CN111857816A/en
Application granted granted Critical
Publication of CN111857816B publication Critical patent/CN111857816B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/30098Register arrangements

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Devices For Executing Special Programs (AREA)

Abstract

The embodiment of the invention provides a register allocation method, a device, electronic equipment and a computer storage medium, wherein the register allocation method comprises the following steps: acquiring target functions to be called and information of a calling convention according to information of a calling instance, wherein the calling convention comprises definition information of all available registers in current equipment; acquiring information of a register used by the target function according to the information of the calling convention; and allocating a register for the call instance according to the information of the register so as to carry out parameter transfer of the target function through the register. According to the embodiment of the invention, the transfer cost of the register parameters is effectively reduced, and the code compiling efficiency is improved.

Description

Register allocation method, device, electronic equipment and computer storage medium
Technical Field
The embodiment of the invention relates to the technical field of computers, in particular to a register allocation method, a register allocation device, electronic equipment and a computer storage medium.
Background
Register allocation is a method of increasing the execution speed of a program by allocating program variables to registers as much as possible. In an actual compiler, in order to improve the squeezing performance as much as possible, the allocation efficiency of the compiler is optimized by adopting various different modes.
Taking LLVM as an example, LLVM is a framework system of a framework compiler (compiler) for optimizing a compiling time (com-time), a link-time (link-time), a run-time (run-time), and an idle-time (idle-time) of a program written in an arbitrary programming language, and for compatibility with existing scripts. Also, LLVM provides language independent intermediate code, so that intermediate code can be generated from different language codes, thereby enabling the interconnection of different languages through LLVM. In LLVM, function parameters are defined by ABI (Application Binary Interface ) to pass in specified physical registers, LLVM is represented by copies between physical and virtual registers before and after function call. The register allocator attempts to allocate virtual registers to the same physical registers so that copies can be eliminated. However, in the current LLVM, there is no explicit calling convention (Calling Conventions, CC) for transferring register parameters, and in practical applications, if a certain register is to be used, a programmer needs to set an additional calling convention for the register to be used, for example, define a calling convention of v8r0r3CC, so as to specifically handle the r0 and r3 parameter transferring situations. If the register r4r5 is needed for transferring parameters, a programmer is needed to define a calling convention for r4 and r 5.
Therefore, the transfer cost of register parameters in the LLVM is greatly increased, and the compiling efficiency of the LLVM is reduced.
Disclosure of Invention
Accordingly, embodiments of the present invention provide a register allocation scheme to at least partially solve the above-mentioned problems.
According to a first aspect of an embodiment of the present invention, there is provided a register allocation method, including: acquiring target functions to be called and information of a calling convention according to information of a calling instance, wherein the calling convention comprises definition information of all available registers in current equipment; acquiring information of a register used by the target function according to the information of the calling convention; and allocating a register for the call instance according to the information of the register so as to carry out parameter transfer of the target function through the register.
According to a second aspect of an embodiment of the present invention, there is provided a register allocation apparatus including: the first acquisition module is used for acquiring an objective function to be called and information of a calling convention according to information of a calling instance, wherein the calling convention comprises definition information of all available registers in current equipment; the second acquisition module is used for acquiring the information of the register used by the target function according to the information of the calling convention; and the allocation module is used for allocating a register for the call example according to the information of the register so as to transfer the parameters of the target function through the register.
According to a third aspect of an embodiment of the present invention, there is provided an electronic apparatus including: the device comprises a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface complete communication with each other through the communication bus; the memory is configured to store at least one executable instruction, where the executable instruction causes the processor to perform operations corresponding to the register allocation method according to the first aspect.
According to a fourth aspect of embodiments of the present invention, there is provided a computer storage medium having stored thereon a computer program which, when executed by a processor, implements the register allocation method as described in the first aspect.
According to the register allocation scheme provided by the embodiment of the invention, when the register is required to be allocated for the target function to be called, the register is carried in the information of the calling instance according to the preset calling convention, so that the information of the calling instance is analyzed according to the calling convention, the information of the register is obtained, and the register is allocated accordingly to transfer the parameters of the target function. The calling convention comprises definition information of all available registers in the current device, namely, the calling convention can find corresponding positions and processes in the calling convention for all available registers of the current device, and special calling conventions are not required to be additionally set for the used registers when corresponding register parameter transfer is carried out each time. The method can be used on the current equipment for a long time by one-time setting, effectively reduces the transfer cost of register parameters, and improves the code compiling efficiency.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings that are required in the embodiments or the description of the prior art will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments described in the embodiments of the present invention, and other drawings may be obtained according to these drawings for a person having ordinary skill in the art.
FIG. 1 is a flowchart showing steps of a register allocation method according to a first embodiment of the present invention;
FIG. 2 is a flowchart illustrating a register allocation method according to a second embodiment of the present invention;
FIG. 3 is a block diagram showing a register allocation apparatus according to a third embodiment of the present invention;
FIG. 4 is a block diagram showing a register allocation apparatus according to a fourth embodiment of the present invention;
fig. 5 is a schematic structural diagram of an electronic device according to a fifth embodiment of the present invention.
Detailed Description
In order to better understand the technical solutions in the embodiments of the present invention, the following description will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only some embodiments of the present invention, not all embodiments. All other embodiments, which are derived by a person skilled in the art based on the embodiments of the present invention, shall fall within the scope of protection of the embodiments of the present invention.
The implementation of the embodiments of the present invention will be further described below with reference to the accompanying drawings.
Example 1
Referring to fig. 1, a flowchart of steps of a register allocation method according to a first embodiment of the present invention is shown.
The register allocation method of the present embodiment includes the steps of:
Step S102: and acquiring the target function to be called and the information of the calling convention according to the information of the calling instance.
In the embodiment of the invention, the calling convention adopted is different from the conventional calling convention required for the specific used register, and the calling convention in the embodiment of the invention comprises definition information of all available registers in the current equipment. The definition information includes, but is not limited to: indication information (e.g., identification information or pointer information, etc.) of each available register, location information (which may also be considered sequence information) of each available register, specific handling information for registers and/or parameters in the calling convention, etc. For example, the current device has 5 available registers (e.g., r0-r 4), then the calling convention format may be such as: xxxcc: the format of the objective functions r0, r1, r2, r3, r4 to be called.
The person skilled in the art may set what registers are available according to actual needs, and in one possible manner, registers other than the reserved registers may be set as available registers.
The call instance is an instance (instance) of a call, e.g., the LLVM's function, call, and reflection may all have a choice calling convention specifying a call. In practical applications, according to the functions, the call and the reflection, the specific call functions, call points, reflection call and the like which are correspondingly generated can be regarded as call instances.
The information of the calling instance carries parameters to be transferred and calling convention information, wherein the calling convention information can be indicated in any appropriate mode, such as a calling convention name or identifier.
Step S104: and acquiring the information of the register used by the target function according to the information of the calling convention.
As previously described, the calling convention includes definition information for all available registers in the current device. Thus, register information may be obtained from the values in the calling convention corresponding to the respective registers.
For example, still at xxxcc: the formats of the objective functions r0, r1, r2, r3, r4 to be called are exemplified, if xxxcc: f1, undef, undef, r2, r3, undef, the registers used by the objective function to be called include r2 and r3.
Step S106: and allocating a register for the call instance according to the information of the register so as to carry out parameter transfer of the target function through the register.
After the register used by the objective function is determined according to the information of the register, the register can be allocated for the call instance according to the current application, such as the current register allocation algorithm in a code generator or a compiler, or by a register allocator responsible for performing the register allocation, so as to perform parameter transfer of the objective function.
According to the method and the device, when a register is required to be allocated for the target function to be called, the register is carried in information of a calling instance according to a preset calling convention, the information of the calling instance is analyzed according to the calling convention, the information of the register is obtained, and then the register is allocated accordingly to transfer parameters of the target function. The calling convention comprises definition information of all available registers in the current device, namely, the calling convention can find corresponding positions and processes in the calling convention for all available registers of the current device, and special calling conventions are not required to be additionally set for the used registers when corresponding register parameter transfer is carried out each time. The method can be used on the current equipment for a long time by one-time setting, effectively reduces the transfer cost of register parameters, and improves the code compiling efficiency.
The register allocation method of the present embodiment may be performed by any suitable electronic device having data processing capabilities, including, but not limited to: servers, mobile terminals (such as mobile phones, PADs, etc.), and PCs, etc.
Example two
Referring to fig. 2, a flowchart illustrating steps of a register allocation method according to a second embodiment of the present invention is shown.
In this embodiment, LLVM is taken as a user of the register allocation method, and a calling convention set for a V8 engine is taken as an example to describe a register allocation scheme in the embodiment of the present invention.
Based on this, the register allocation method of the present embodiment includes the steps of:
step S202: a calling convention is generated.
The step may include: acquiring information of other registers except a reserved register in the current equipment; setting parameter indication information and parameter position information in calling convention for the other registers; and generating calling convention according to the parameter indication information and the parameter position information. The format may be as follows xxxcc: the objective functions to be called, r0, r1, r2, r3, r4. In a specific example of LLVM, one can, for example @ name_call, i32 1,i32 0,i64 addrspace (1)% obj, i32 0, i32 5, i 32-1 … …
Compilers typically use registers in three groups as needed: registers may be allocated, reserved, and zero. Wherein the allocable registers are registers for allocating variables (source and temporary variables); the reserved registers are special registers reserved by the system for special tasks, such as stack pointer registers, display registers and the like; the zero register is a very short life register used to make "shortcuts". The allocatable registers can only be applied by calling the subroutines; the reserved register is special during the whole running period of the target code, so that the reserved register cannot participate in allocation or short work; the zero-use register is a short-lived register, so that the zero-use register cannot participate in allocation, and the system can be used on an on-demand basis, unlike a special reserved register. Thus, other registers in the current device than the reserved registers may be considered allocatable registers, i.e., available registers in embodiments of the present invention.
After the information of the available registers in the current device is obtained, the parameter indication information and the parameter position information in the calling convention can be set for the current device. The parameter indication information is used for marking a register, such as a register name or a register identifier; the parameter position information is used to indicate the sequential position of the respective registers. In addition, each call contract has certain functions, e.g., the call contract "ccc" is a call contract that matches targets to the C language, which supports variable length parameter function calls and can tolerate some mismatch between declarations and implementations of the function. Similarly, one skilled in the art may set the calling convention to perform corresponding register allocation and processing of parameters in the convention, such as information of registers and information of parameters transferred using registers.
In one possible manner, the generating the calling convention according to the parameter indication information and the parameter location information may include: performing register allocation processing setting on the other registers, and indicating the other registers not to perform data storage processing in a register allocation stage through the register allocation processing setting; and generating the calling convention according to the parameter indication information, the parameter position information and the register allocation processing setting. In the calling convention, it is specified that during the register allocation phase, no value is saved to the register, the compiler will save all active values to the stack to find the safe point from the stack space conveniently, and since only the register allocator is handling this work, no conflict with the safe point generation module will be incurred.
Of course, in practical application, other contents may be contracted in the calling convention.
In particular to setting a calling convention for the V8 engine in LLVM, in one possible approach, a calling convention V8cc may be defined, with references defined as all registers except the reserved registers, and the registers used by the V8 engine include r0-r11. And (5) transferring undefined values to the places without the parameters. In addition, defining such calling conventions does not save any value to registers during the register allocation phase, the compiler will save all active values to the stack to find a safe point from stack space conveniently, and no conflict will be incurred since only the register allocator is handling this work.
Through the step, the setting and the generation of the calling convention are realized, and the calling convention can be used for a long time after being generated.
Step S204: and acquiring information of the calling instance, and acquiring the target function to be called and the information of the calling convention according to the information of the calling instance.
The calling convention comprises definition information of all available registers in the current equipment.
If the calling instance uses the calling convention in step S202, the objective function to be called and the information of the calling convention may be obtained from the information of the calling instance.
For example, if references to r0 and r3 are required, it may be obtained from the information of the call instance: LLVM IR call v8cc function p1 (r 0, undef, r3, undef … undef). Wherein, "function p1" is the target function to be called, and v8cc is the calling convention information.
Step S206: and acquiring the information of the register used by the target function to be called according to the information of the calling convention.
In one possible manner, the information of the register used by the target function to be called may be obtained according to the parameter indication information and the parameter location information agreed by the calling convention. In this way, the information of the register can be determined efficiently and quickly.
As previously described, the registers used by the V8 engine include r0-r11, corresponding call contract argument forms such as: v8cc of objective functions to be called, r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10. On the other hand, according to "LLVM IR: call v8cc function p1 (r 0, undef, r3, undef … undef)", it can be determined that the registers used for the references are r0 and r3. The COPY node may then be generated by SelctionDAG, with the parameters used by COPp 1 going to r0 and r3.
Step S208: and allocating a register for the calling example according to the information of the register so as to carry out parameter transfer of the target function through the register.
After the information of the register is obtained, a corresponding register can be allocated for the calling instance to carry out parameter transfer.
If the register allocation process setting is also set in the calling convention, this step may optionally be implemented as: and allocating registers for the calling examples according to the information of the registers and the register allocation processing setting, and storing all the active values in the calling examples into stacks corresponding to the calling examples. So that only the register allocator is saving the value of the recovery security point and will not conflict with the security point generation module.
After all the activity values in the calling instance are saved in the stack corresponding to the calling instance, further optionally, the security point of the calling instance can be obtained from the stack; and according to the security point, processing operation of calling an instance is carried out. Wherein, the processing operation of the calling instance is implemented according to the calling convention and the specific code setting of the calling instance, such as code conversion or generation, etc., which is not limited by the embodiment of the invention.
In LLVM, through the above procedure, LLVM IR can easily implement transfer and allocation of registers, without additional calling conventions, and also makes code generation easier and more efficient. In addition, under the scene that garbage collection and a security point are needed, one call can cover a plurality of traditional calls, and the method is simple and easy to operate in engineering. In addition, only the register allocator saves and restores the value of the security point, and the value cannot conflict with the security point generation module.
It can be seen that, through this embodiment, when a register is required to be allocated to a target function to be called, the register is carried in information of a calling instance according to a preset calling convention, so that the information of the calling instance is parsed according to the calling convention, the information of the register is obtained therefrom, and then the register is allocated accordingly to transfer parameters of the target function. The calling convention comprises definition information of all available registers in the current device, namely, the calling convention can find corresponding positions and processes in the calling convention for all available registers of the current device, and special calling conventions are not required to be additionally set for the used registers when corresponding register parameter transfer is carried out each time. The method can be used on the current equipment for a long time by one-time setting, effectively reduces the transfer cost of register parameters, and improves the code compiling efficiency.
The register allocation method of the present embodiment may be performed by any suitable electronic device having data processing capabilities, including, but not limited to: servers, mobile terminals (such as mobile phones, PADs, etc.), and PCs, etc.
Example III
Referring to fig. 3, a block diagram of a register allocation apparatus according to a third embodiment of the present invention is shown.
The register allocation apparatus of the present embodiment includes: the first obtaining module 302 is configured to obtain, according to information of a calling instance, information of a target function to be called and calling conventions, where the calling conventions include definition information of all available registers in a current device; a second obtaining module 304, configured to obtain, according to the information of the calling convention, information of a register used by the target function to be called; and the allocation module 306 is configured to allocate a register for the call instance according to the information of the register, so as to transfer parameters of the objective function to be called through the register.
The register allocation device in this embodiment is configured to implement the corresponding register allocation method in the foregoing multiple method embodiments, and has the beneficial effects of the corresponding method embodiments, which are not described herein again. In addition, the functional implementation of each module in the register allocation apparatus of this embodiment may refer to the description of the corresponding portion in the foregoing method embodiment, which is not repeated herein.
Example IV
Referring to fig. 4, a block diagram of a register allocation apparatus according to a fourth embodiment of the present invention is shown.
The register allocation apparatus of the present embodiment includes: a first obtaining module 402, configured to obtain, according to information of a calling instance, information of an objective function to be called and calling conventions, where the calling conventions include definition information of all available registers in a current device; a second obtaining module 404, configured to obtain, according to the information of the calling convention, information of a register used by the target function to be called; and the allocation module 406 is configured to allocate a register for the call instance according to the information of the register, so as to perform parameter transfer of the objective function to be called through the register.
Optionally, the register allocation apparatus of the present embodiment further includes: a generating module 408 for generating the calling convention by: acquiring information of other registers except a reserved register in the current equipment; setting parameter indication information and parameter position information in calling convention for the other registers; and generating the calling convention according to the parameter indication information and the parameter position information.
Optionally, the generating module 408 generates the call schedule according to the parameter indication information and the parameter location information: performing register allocation processing setting on the other registers, and indicating the other registers not to perform data storage processing in a register allocation stage through the register allocation processing setting; and generating the calling convention according to the parameter indication information, the parameter position information and the register allocation processing setting.
Optionally, the allocating module 406 is configured to allocate a register for the call instance according to the information of the register and the register allocation processing setting, and store all the active values in the call instance to a stack corresponding to the call instance.
Optionally, the register allocation apparatus of the present embodiment further includes: a processing module 410, configured to obtain a security point of the call instance from the stack; and carrying out processing operation of the calling example according to the security point.
Optionally, the second obtaining module 404 is configured to obtain, according to the parameter indication information and the parameter location information agreed by the calling convention, information of a register used by the objective function to be called.
Alternatively, the register allocation apparatus of the present embodiment is applied to LLVM, and the calling convention is V8 engine calling convention.
The register allocation device in this embodiment is configured to implement the corresponding register allocation method in the foregoing multiple method embodiments, and has the beneficial effects of the corresponding method embodiments, which are not described herein again. In addition, the functional implementation of each module in the register allocation apparatus of this embodiment may refer to the description of the corresponding portion in the foregoing method embodiment, which is not repeated herein.
Example five
Referring to fig. 5, a schematic structural diagram of an electronic device according to a fifth embodiment of the present invention is shown, and the specific embodiment of the present invention is not limited to the specific implementation of the electronic device.
As shown in fig. 5, the electronic device may include: a processor 502, a communication interface (Communications Interface) 504, a memory 506, and a communication bus 508.
Wherein:
processor 502, communication interface 504, and memory 506 communicate with each other via communication bus 508.
A communication interface 504 for communicating with other electronic devices or servers.
The processor 502 is configured to execute the program 510, and may specifically perform relevant steps in the above-described embodiment of the register allocation method.
In particular, program 510 may include program code including computer-operating instructions.
Processor 52 may be a central processing unit CPU, or an Application-specific integrated Circuit ASIC (Application SPECIFIC INTEGRATED Circuit), or one or more integrated circuits configured to implement embodiments of the present invention. The one or more processors comprised by the smart device may be the same type of processor, such as one or more CPUs; but may also be different types of processors such as one or more CPUs and one or more ASICs.
A memory 506 for storing a program 510. Memory 506 may comprise high-speed RAM memory or may also include non-volatile memory (non-volatile memory), such as at least one disk memory.
The program 510 may be specifically operable to cause the processor 502 to: acquiring target functions to be called and information of a calling convention according to information of a calling instance, wherein the calling convention comprises definition information of all available registers in current equipment; acquiring information of a register used by the target function to be called according to the information of the calling convention; and allocating a register for the calling example according to the information of the register so as to transfer the parameters of the target function to be called through the register.
In an alternative embodiment, program 510 is further configured to cause processor 502 to generate the calling convention by: acquiring information of other registers except a reserved register in the current equipment; setting parameter indication information and parameter position information in calling convention for the other registers; and generating the calling convention according to the parameter indication information and the parameter position information.
In an alternative embodiment, the program 510 is further configured to cause the processor 502 to perform a register allocation process setting for the other register when the call constraint is generated according to the parameter indication information and the parameter location information, where the register allocation process setting indicates that the other register does not perform a data saving process in a register allocation stage; and generating the calling convention according to the parameter indication information, the parameter position information and the register allocation processing setting.
In an alternative embodiment, the program 510 is further configured to, when allocating a register to the call instance according to the register information, allocate a register to the call instance according to the register information and the register allocation processing setting, and save all the activity values in the call instance to a stack corresponding to the call instance.
In an alternative embodiment, program 510 is further configured to cause processor 502 to obtain a secure point of the call instance from the stack; and carrying out processing operation of the calling example according to the security point.
In an alternative embodiment, the program 510 is further configured to, when obtaining the information of the register used by the target function to be called according to the information of the calling convention, obtain the information of the register used by the target function to be called according to the parameter indication information and the parameter location information agreed by the calling convention.
In an alternative implementation, the electronic device of this embodiment is applied to LLVM, and the calling convention is V8 engine calling convention.
The specific implementation of each step in the procedure 510 may refer to the corresponding step and corresponding description in the unit in the above embodiment of the register allocation method, which is not repeated herein. It will be clear to those skilled in the art that, for convenience and brevity of description, specific working procedures of the apparatus and modules described above may refer to corresponding procedure descriptions in the foregoing method embodiments, which are not repeated herein.
Through the electronic equipment of the embodiment, when the register is required to be allocated for the target function to be called, the register is carried in the information of the calling instance according to the preset calling convention, so that the information of the calling instance is analyzed according to the calling convention, the information of the register is obtained, and the register is allocated accordingly to transfer the parameters of the target function to be called. The calling convention comprises definition information of all available registers in the current device, namely, the calling convention can find corresponding positions and processes in the calling convention for all available registers of the current device, and special calling conventions are not required to be additionally set for the used registers when corresponding register parameter transfer is carried out each time. The method can be used on the current equipment for a long time by one-time setting, effectively reduces the transfer cost of register parameters, and improves the code compiling efficiency.
It should be noted that, according to implementation requirements, each component/step described in the embodiments of the present invention may be split into more components/steps, or two or more components/steps or part of operations of the components/steps may be combined into new components/steps, so as to achieve the objects of the embodiments of the present invention.
The above-described methods according to embodiments of the present invention may be implemented in hardware, firmware, or as software or computer code storable in a recording medium such as a CD ROM, RAM, floppy disk, hard disk, or magneto-optical disk, or as computer code originally stored in a remote recording medium or a non-transitory machine-readable medium and to be stored in a local recording medium downloaded through a network, so that the methods described herein may be stored on such software processes on a recording medium using a general purpose computer, special purpose processor, or programmable or special purpose hardware such as an ASIC or FPGA. It is understood that a computer, processor, microprocessor controller, or programmable hardware includes a memory component (e.g., RAM, ROM, flash memory, etc.) that can store or receive software or computer code that, when accessed and executed by the computer, processor, or hardware, implements the register allocation methods described herein. Further, when the general-purpose computer accesses code for implementing the register allocation method shown herein, execution of the code converts the general-purpose computer into a special-purpose computer for executing the register allocation method shown herein.
Those of ordinary skill in the art will appreciate that the elements and method steps of the examples described in connection with the embodiments disclosed herein can be implemented as electronic hardware, or as a combination of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the embodiments of the present invention.
The above embodiments are only for illustrating the embodiments of the present invention, but not for limiting the embodiments of the present invention, and various changes and modifications may be made by one skilled in the relevant art without departing from the spirit and scope of the embodiments of the present invention, so that all equivalent technical solutions also fall within the scope of the embodiments of the present invention, and the scope of the embodiments of the present invention should be defined by the claims.

Claims (12)

1. A register allocation method, comprising:
According to the information of the calling instance, obtaining the information of the target function to be called and the calling convention, wherein the calling convention comprises the definition information of all available registers in the current equipment, and the calling convention is generated by the following modes: acquiring information of other registers except a reserved register in the current equipment; setting parameter indication information and parameter position information in calling convention for the other registers; generating the calling convention according to the parameter indication information and the parameter position information, wherein the calling convention comprises the following steps: performing register allocation processing setting on the other registers, and indicating the other registers not to perform data storage processing in a register allocation stage through the register allocation processing setting; generating the calling convention according to the parameter indication information, the parameter position information and the register allocation processing setting;
Acquiring information of a register used by the target function according to the information of the calling convention;
And allocating a register for the call instance according to the information of the register so as to carry out parameter transfer of the target function through the register.
2. The method of claim 1, wherein the allocating a register for the call instance according to the information of the register comprises:
and allocating registers for the call examples according to the information of the registers and the register allocation processing setting, and storing all the active values in the call examples into stacks corresponding to the call examples.
3. The method of claim 2, wherein the method further comprises:
acquiring a security point of the calling instance from the stack;
and carrying out processing operation of the calling example according to the security point.
4. The method of claim 1, wherein the obtaining information of a register used by the objective function according to the information of the calling convention comprises:
and acquiring information of a register used by the target function according to the parameter indication information and the parameter position information agreed by the calling agreement.
5. The method of any of claims 1-4, wherein the method is applied to LLVM and the calling convention is a V8 engine calling convention.
6. A register allocation apparatus comprising:
The first acquisition module is used for acquiring an objective function to be called and information of a calling convention according to information of a calling instance, wherein the calling convention comprises definition information of all available registers in current equipment;
The generating module is used for generating the calling convention by the following modes: acquiring information of other registers except a reserved register in the current equipment; setting parameter indication information and parameter position information in calling convention for the other registers; generating the calling convention according to the parameter indication information and the parameter position information, wherein the calling convention comprises the following steps: performing register allocation processing setting on the other registers, and indicating the other registers not to perform data storage processing in a register allocation stage through the register allocation processing setting; generating the calling convention according to the parameter indication information, the parameter position information and the register allocation processing setting;
The second acquisition module is used for acquiring the information of the register used by the target function according to the information of the calling convention;
And the allocation module is used for allocating a register for the call example according to the information of the register so as to transfer the parameters of the target function through the register.
7. The apparatus of claim 6, wherein the allocation module is configured to allocate a register for the call instance according to the information of the register and the register allocation processing setting, and store all activity values in the call instance to a stack corresponding to the call instance.
8. The apparatus of claim 7, wherein the apparatus further comprises:
the processing module is used for acquiring the security point of the calling instance from the stack; and carrying out processing operation of the calling example according to the security point.
9. The apparatus of claim 6, wherein the second obtaining module is configured to obtain information of a register used by the objective function according to the parameter indication information and the parameter location information agreed by the calling convention.
10. The apparatus of any of claims 6-9, wherein the apparatus is applied to an LLVM, the calling convention is a V8 engine calling convention.
11. An electronic device, comprising: the device comprises a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface complete communication with each other through the communication bus;
The memory is configured to store at least one executable instruction, where the executable instruction causes the processor to perform operations corresponding to the register allocation method according to any one of claims 1-5.
12. A computer storage medium having stored thereon a computer program which when executed by a processor implements a register allocation method as claimed in any one of claims 1 to 5.
CN201910339025.7A 2019-04-25 2019-04-25 Register allocation method, device, electronic equipment and computer storage medium Active CN111857816B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910339025.7A CN111857816B (en) 2019-04-25 2019-04-25 Register allocation method, device, electronic equipment and computer storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910339025.7A CN111857816B (en) 2019-04-25 2019-04-25 Register allocation method, device, electronic equipment and computer storage medium

Publications (2)

Publication Number Publication Date
CN111857816A CN111857816A (en) 2020-10-30
CN111857816B true CN111857816B (en) 2024-05-10

Family

ID=72952425

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910339025.7A Active CN111857816B (en) 2019-04-25 2019-04-25 Register allocation method, device, electronic equipment and computer storage medium

Country Status (1)

Country Link
CN (1) CN111857816B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114661296B (en) * 2022-03-28 2022-12-09 优视科技有限公司 Program code compiling method, program code compiling device, electronic equipment and storage medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103853532A (en) * 2012-11-29 2014-06-11 国际商业机器公司 Method and device for calling function
CN105190534A (en) * 2013-03-14 2015-12-23 国际商业机器公司 Instruction for performing pseudorandom number seed operation

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP3956112B2 (en) * 2002-06-12 2007-08-08 インターナショナル・ビジネス・マシーンズ・コーポレーション Compiler, register allocation device, program, recording medium, compilation method, and register allocation method
US9864518B2 (en) * 2014-11-10 2018-01-09 International Business Machines Corporation Assigning home memory addresses to function call parameters

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103853532A (en) * 2012-11-29 2014-06-11 国际商业机器公司 Method and device for calling function
CN105190534A (en) * 2013-03-14 2015-12-23 国际商业机器公司 Instruction for performing pseudorandom number seed operation

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
基于LLVM架构的NiosⅡ后端快速移植;任胜兵等;计算机应用与软件;20111231;第28卷(第12期);22-25、50 *

Also Published As

Publication number Publication date
CN111857816A (en) 2020-10-30

Similar Documents

Publication Publication Date Title
CN107943469B (en) Intelligent contract issuing method and device
CN107992344B (en) Coroutine implementation method and coroutine implementation device
CN109739508B (en) Source code compiling method, device, system and storage medium
CN110659031B (en) Application compilation method, device, electronic device and storage medium
CN110928548B (en) Data processing method and device
CN113407362A (en) SOMEIP communication intermediate layer implementation method and system based on SOA architecture of vehicle-mounted Android system
WO2013192104A2 (en) Optimized execution of dynamic languages
CN106960140A (en) Virtual machine instructions obscure method and device, virtual machine protection system
CN105893105A (en) Compiling system and method for multiple compiling platforms
CN114327477A (en) Intelligent contract execution method and device, electronic device and storage medium
JP4042527B2 (en) Method for generating calling convention conversion processing
CN118409758B (en) Method, apparatus, medium and program product for compiling a kernel function
CN109614772A (en) Code conversion method and device based on application installation package file
CN109828796B (en) Plug-in calling method and device based on microkernel architecture
CN119669036A (en) Program debugging method, device, electronic device and storage medium
CN111857816B (en) Register allocation method, device, electronic equipment and computer storage medium
CN113031954A (en) Code compiling method and device, electronic equipment, storage medium and heterogeneous system
CN111045746B (en) Code extension methods and frameworks
CN106484375A (en) A kind of instruction block loading method, Softswitch and system
CN110990018B (en) Compiling method and compiling system of embedded system
CN110377367B (en) Component configuration method and device, electronic terminal and computer readable storage medium
US20170003907A1 (en) Compilation apparatus and compilation method
CN116909681A (en) Generation method, device, electronic equipment and storage medium of data processing component
CN113326048B (en) Floating point number calculation precision processing method, system, medium and device
CN111857678B (en) Code generation method, device, electronic equipment and computer storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant