Instruction dependency construction method, device, equipment and readable storage medium

By storing register numbers in the stack by type and generating instruction dependencies, the problem of cumbersome instruction dependency construction process is solved, and the construction efficiency and data processing flexibility are improved.

CN118642761BActive Publication Date: 2024-10-15BEIJING INSTITUTE OF OPEN SOURCE CHIP
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411116818.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-14
Publication Date
2024-10-15
Estimated Expiration
2044-08-14

AI Technical Summary

Technical Problem

In the existing technology, the instruction dependency construction process is cumbersome and requires registers of the same type to be searched one by one, resulting in high data processing pressure and low construction efficiency.

Method used

By obtaining multiple register numbers in the generated instructions, storing them into different types of register number stacks based on the register type information, obtaining the target register type of the instruction to be generated, determining the target register number stack, and generating the target register number based on the target register number. Generate instructions and build instruction dependencies.

Benefits of technology

It reduces the need to save all information of generated instructions, reduces data processing pressure, improves the efficiency of constructing instruction dependencies, and can quickly find and build dependencies based on register types.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118642761B_ABST
    Figure CN118642761B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention provides an instruction dependency construction method, device, equipment and readable storage medium, the method comprising: obtaining multiple register numbers in a generated instruction; each register number corresponds to register type information; different register numbers correspond to different generated instructions; based on the register type information corresponding to each register number, the multiple register numbers are stored in at least one register number stack respectively; the target register type of the instruction to be generated is obtained, and a target register number stack corresponding to the target register type is determined; based on the target register number in the target register number stack, the instruction to be generated is generated, so that the instruction to be generated and the generated instruction corresponding to the target register number form an instruction dependency. The present invention can improve the efficiency of instruction dependency construction.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to an instruction dependency construction method, device, electronic device and computer-readable storage medium. Background Art

[0002] When instructions are executed, they need to be based on a certain sequence, otherwise, after the instructions are executed, incorrect execution results will be generated. The execution order of instructions is called instruction dependency. In the process of generating instructions, it is necessary to build instruction dependencies between instructions based on registers of the same type.

[0003] At present, all instruction information of a fixed number of generated instructions is maintained. When constructing instruction dependencies between instructions to be generated and generated instructions, it is necessary to search for registers of the same type one by one in all instruction information of the saved generated instructions in order to construct dependencies, which is cumbersome. Summary of the invention

[0004] The embodiments of the present invention provide an instruction dependency construction method, device, electronic device and readable storage medium, which can solve the problem of complicated instruction dependency construction process in related technologies.

[0005] In order to solve the above problem, an embodiment of the present invention discloses an instruction dependency construction method, the method comprising:

[0006] Obtain multiple register numbers in the generated instructions; each register number corresponds to register type information; different register numbers correspond to different generated instructions;

[0007] Based on register type information corresponding to each register number, the plurality of register numbers are stored in at least one register number stack respectively;

[0008] Obtaining a target register type of the instruction to be generated, and determining a target register number stack corresponding to the target register type;

[0009] The to-be-generated instruction is generated based on the target register number in the target register number stack, so that the to-be-generated instruction and the generated instruction corresponding to the target register number form an instruction dependency; the instruction dependency indicates the instruction execution order.

[0010] Optionally, the method further includes:

[0011] Based on usage parameters corresponding to the register numbers, the register numbers in each register number stack are sorted to construct a register number sequence corresponding to each register number stack; the usage parameters represent usage of the register numbers when generating instructions;

[0012] The step of generating the instruction to be generated based on the target register number in the target register number stack comprises:

[0013] In the target register number sequence corresponding to the target register number stack, obtaining the register number corresponding to the minimum usage parameter as the target register number;

[0014] Based on the target register number, the to-be-generated instruction is generated.

[0015] Optionally, the usage parameter is instruction generation time, each register number has a corresponding counter, and the counter is used to record the instruction generation time;

[0016] Before the step of sorting the register numbers in each register number stack based on the usage parameters corresponding to the register numbers in each register number stack, the method further includes:

[0017] The instruction generation time of the generated instruction corresponding to the register number is obtained, and a counter corresponding to the register number is set according to the instruction generation time, so that the counter records the instruction generation time.

[0018] Optionally, the usage parameter is the number of times the register number is used, and each register number has a corresponding counter, and the counter is used to record the number of times it is used;

[0019] Before the step of sorting the register numbers in each register number stack based on the usage parameters corresponding to the register numbers in each register number stack, the method further includes:

[0020] Based on the register numbers in each register number stack, determining the number of times each register number is used in the generated instruction;

[0021] Based on the number of times each register number is used, a counter corresponding to each register number is set so that the counter records the number of times it is used.

[0022] Optionally, after the step of generating the instruction to be generated based on the target register number, the method further includes:

[0023] According to the instruction generation time of the instruction to be generated, the counter corresponding to the target register number is updated to update the position of the target register number in the target register number sequence.

[0024] Optionally, the register type information includes a data type and a location type;

[0025] The step of storing the plurality of register numbers into at least one register number stack respectively based on the register type information corresponding to each register number comprises:

[0026] Determine at least one candidate register number stack corresponding to the register number based on the data type in the register type information;

[0027] Based on the location type in the register type information, determining a target register number stack corresponding to the location type in the at least one candidate register number stack;

[0028] The register number is stored in the target register number stack.

[0029] Optionally, the number of the target register number stacks is at least two;

[0030] The updating of the counter corresponding to the target register number according to the instruction generation time of the instruction to be generated includes:

[0031] According to the instruction generation time of the instruction to be generated, the counters corresponding to the target register numbers in all target register number stacks are updated.

[0032] On the other hand, an embodiment of the present invention discloses an instruction dependency construction device, the device comprising:

[0033] A number acquisition module is used to acquire multiple register numbers in the generated instructions; each register number corresponds to register type information; different register numbers correspond to different generated instructions;

[0034] A number storage module, used for storing the plurality of register numbers into at least one register number stack respectively based on register type information corresponding to each register number;

[0035] A target determination module, used to obtain a target register type of the instruction to be generated, and determine a target register number stack corresponding to the target register type;

[0036] A generation and construction module is used to generate the instruction to be generated based on the target register number in the target register number stack, and to construct an instruction dependency between the instruction to be generated and the generated instruction corresponding to the target register number; the instruction dependency represents the execution order of the instructions.

[0037] Optionally, the device further comprises:

[0038] A register number sequence module, used for sorting the register numbers in each register number stack based on usage parameters corresponding to the register numbers, so as to construct a register number sequence corresponding to each register number stack; the usage parameters represent the usage of the register numbers when generating instructions;

[0039] Generate building blocks, including:

[0040] A minimum parameter submodule, used to obtain, in the target register number sequence corresponding to the target register number stack, a register number corresponding to a minimum usage parameter as a target register number;

[0041] The instruction generation submodule is used to generate the instruction to be generated based on the target register number.

[0042] Optionally, the usage parameter is instruction generation time, each register number has a corresponding counter, and the counter is used to record the instruction generation time;

[0043] The device also includes:

[0044] The generation time module is used to temporarily set a counter corresponding to the register number so that the counter records the instruction generation time.

[0045] Optionally, the usage parameter is the number of times the register number is used, and each register number has a corresponding counter, and the counter is used to record the number of times it is used;

[0046] The device also includes:

[0047] A frequency counting module, used for determining the number of times each register number is used in the generated instruction based on the register number in each register number stack;

[0048] The number recording module is used to set the counter corresponding to the register number in each number set based on the number of uses in the number set, so that the counter records the number of uses.

[0049] Optionally, the device further comprises:

[0050] An updating module is used to update the counter corresponding to the target register number according to the instruction generation time of the instruction to be generated, so as to update the position of the target register number in the target register number sequence.

[0051] Optionally, the register type information includes a data type and a location type;

[0052] Numbered storage module, including:

[0053] A data type submodule, configured to determine at least one candidate register number stack corresponding to the register number based on the data type in the register type information;

[0054] a location type submodule, configured to determine, based on the location type in the register type information, a target register number stack corresponding to the location type in the at least one candidate register number stack;

[0055] The number storing submodule is used to store the register number into the target register number stack.

[0056] Optionally, the number of the target register number stacks is at least two;

[0057] Update modules, including:

[0058] The updating submodule is used to update the counters corresponding to the target register numbers in all target register number stacks according to the instruction generation time of the instruction to be generated.

[0059] On the other hand, an embodiment of the present invention further discloses an electronic device, which includes a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other through the communication bus; the memory is used to store executable instructions, and the executable instructions enable the processor to execute the aforementioned instruction dependency construction method.

[0060] The embodiment of the present invention further discloses a readable storage medium. When the instructions in the readable storage medium are executed by a processor of an electronic device, the electronic device can execute the aforementioned instruction dependency construction method.

[0061] The embodiment of the present invention includes the following advantages: by obtaining multiple register numbers in the generated instructions; based on the register type information corresponding to each register number, the multiple register numbers are stored in at least one register number stack respectively; the target register type of the instruction to be generated is obtained, and the target register number stack corresponding to the target register type is determined; based on the target register number in the target register number stack, the instruction to be generated is generated, so that the instruction to be generated and the generated instruction corresponding to the target register number form an instruction dependency. The register number of the generated instruction can be saved, and all the instruction information of the generated instruction does not need to be saved, which reduces the pressure of data processing; and it is stored in different register number stacks, and the register number can be searched according to the type, which improves the efficiency of constructing instruction dependencies. BRIEF DESCRIPTION OF THE DRAWINGS

[0062] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.

[0063] Figure 1 It is a flow chart of steps of an instruction dependency construction method of the present invention;

[0064] Figure 2 is a flowchart of another instruction-dependent construction method of the present invention;

[0065] Figure 3 is a structural block diagram of an instruction dependency construction device provided by an example of the present invention;

[0066] Figure 4 It is a structural block diagram of an electronic device for instruction-dependent construction provided by an example of the present invention. DETAILED DESCRIPTION

[0067] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0068] The terms "first", "second", etc. in the specification and claims of the present invention are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable when appropriate, so that the embodiments of the present invention can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, the term "and / or" in the specification and claims is used to describe the association relationship of associated objects, indicating that three relationships can exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. In the embodiments of the present invention, the term "multiple" refers to two or more, and other quantifiers are similar.

[0069] During the verification process of the processor, it is necessary to build instruction dependencies. Because the order of instruction execution is fixed, if two instructions need to write to the same register, the result calculated by the second instruction can only be written after the previous instruction is executed and the value is written. Otherwise, the value saved in the register at the end of the instruction stream execution will be inaccurate. For example, two instructions: A: add x2, x3, x4 and B: add x2, x5, x6. If the value of the x3 register is 2, the value of the x4 register is 5, the value of the x5 register is 6, and the value of the x6 register is 7, the order of instruction execution is A first and then B. If B is executed before A, the final result saved in the x2 register is x3+x4=7, not x5+x6=13.

[0070] The x2 of instruction A and the x2 of instruction B form a write-after-write (WAW) dependency (it can also include other dependencies such as read-after-write and write-after-read), so during the out-of-order execution process, instruction B must wait until instruction A is executed, and cannot be executed before instruction A, otherwise the value of the x2 register will be incorrect. Instructions without dependencies can be executed out-of-order and are not subject to instruction dependencies.

[0071] Multiple generated instructions can form an instruction stream. The current instruction dependency construction is to store all the information of the most recently generated fixed number of instructions in the instruction stream, that is, define a window in the instruction stream, which includes a fixed number of instructions. Then, when it is necessary to build an instruction dependency, the corresponding type of register is searched in all the instruction information of the fixed number of instructions corresponding to the window. However, the problem is that on the one hand, the storage space increases and the instruction code is cumbersome. On the other hand, it is necessary to use a fixed window to search for instructions that can build dependencies one by one in the generated instruction stream (the register type of the instruction needs to be consistent with the register type of the instruction to be generated currently) before the dependency can be built. The query time is relatively long, and the dependency cannot be built quickly. In addition, the dependency range is limited. If there are only 20 instructions in the window, it is impossible to build a dependency with the instructions before these 20. If some types of register instructions do not appear frequently, they are likely not in this window, and the corresponding instructions cannot be found and the dependency cannot be built.

[0072] Method Embodiment

[0073] Reference Figure 1 , shows a flowchart of an embodiment of an instruction dependency construction method of the present invention, the method may specifically include the following steps:

[0074] Step 101, obtaining multiple register numbers in the generated instructions; each register number corresponds to register type information; different register numbers correspond to different generated instructions;

[0075] In an embodiment of the present invention, multiple register numbers in a generated instruction are obtained in an instruction stream, wherein each generated instruction corresponds to a different register number. For example, an instruction named "AND" includes register numbers "x25", "x25" and "x29", an instruction named "FSUB_D" includes register numbers "f27", "f7" and "f4", and an instruction named "VSRL_VI" includes register numbers "v26" and "v2".

[0076] Each register number carries register type information. In the instruction named "AND", the "x" in the register numbers "x25", "x25" and "x29" indicates integer type. In the instruction named "FSUB_D", the "f" in the register numbers "f27", "f7" and "f4" indicates floating point type. In the instruction named "VSRL_VI", the "v" in the register numbers "v26" and "v2" indicates vector type.

[0077] Step 102, based on register type information corresponding to each register number, storing the plurality of register numbers into at least one register number stack respectively;

[0078] In an embodiment of the present invention, each register number is stored in a different register number stack based on the register type information corresponding to each register number. A register number stack may be constructed based on each register type, and then the corresponding register number is stored. The register number stack may be implemented using a structure array, where the structure includes the register number of the register. Each column in the structure array may correspond to a type of register number stack, and multiple register numbers in the register number stack are arranged in sequence.

[0079] Step 103, obtaining a target register type of the instruction to be generated, and determining a target register number stack corresponding to the target register type;

[0080] In an embodiment of the present invention, to construct an instruction dependency, the target register type of the current instruction to be generated can be first obtained, and then the target register number stack corresponding to the target register type can be directly determined from the multiple register number stacks in the structure array. The target register type can refer to integer, floating point or vector type.

[0081] Step 104 , generating the instruction to be generated based on the target register number in the target register number stack, so that the instruction to be generated and the generated instruction corresponding to the target register number form an instruction dependency; the instruction dependency indicates the instruction execution order.

[0082] In an embodiment of the present invention, after determining the target register number stack, the target register number is determined in the target register number stack. The target register number can be selected in a random determination, i.e., a random dependency mode. Since the register numbers in the target register number stack all conform to the target register type of the instruction to be generated, any register number in the target register number stack can be used as the target register number. The target register number can also be selected based on other methods, such as using the register number corresponding to the middle position of the target register number stack as the target register number. For example, if there are 5 register numbers in the target register number stack, the third register number is used as the target register number. How to determine the target register number in the target register number stack is not specifically limited here.

[0083] Based on the target register number, the instruction to be generated is generated, and the target register number is also carried in the instruction to be generated, thereby forming an instruction dependency between the instruction to be generated and the generated instruction corresponding to the target register number.

[0084] In summary, the embodiments of the present invention include the following advantages: by obtaining multiple register numbers in the generated instructions; based on the register type information corresponding to each register number, the multiple register numbers are stored in at least one register number stack respectively; the target register type of the instruction to be generated is obtained, and the target register number stack corresponding to the target register type is determined; based on the target register number in the target register number stack, the instruction to be generated is generated, so that the instruction to be generated and the generated instruction corresponding to the target register number form an instruction dependency. The register number of the generated instruction can be saved, and all the instruction information of the generated instruction does not need to be saved, which reduces the pressure of data processing; and it is stored in different register number stacks, and the register number can be searched according to the type, which improves the efficiency of constructing instruction dependencies.

[0085] Since the present invention does not need to save all the information of all instructions like the original solution, the register number is only related to the position of the register and the type of the register. For example, for instructions in the dest position (destination register), it is only necessary to select and store them in the xd (integer), fd (floating point) or vd (vector) stack according to the register type. There is no need to retain additional useless information, which is convenient for storage and dependency construction.

[0086] Moreover, based on the register number storage method of the present invention, the constructed instruction stream can be made more complex. The original solution needs to maintain a window. For example, if the window is only 20, then the instruction can only build a dependency with one of the 20 instructions, and it is necessary to input the dependency distance (for example, if the dependency distance is 20, the first instruction of the 20 instructions is selected), and it cannot build a dependency with the instructions before 20, which has great limitations.

[0087] Reference Figure 2, shows a flowchart of another instruction dependency construction method embodiment of the present invention, the method may specifically include the following steps:

[0088] Step 201, obtaining multiple register numbers in the generated instructions; each register number corresponds to register type information; different register numbers correspond to different generated instructions;

[0089] Step 202, based on register type information corresponding to each register number, storing the plurality of register numbers into at least one register number stack respectively;

[0090] Step 203, obtaining a target register type of the instruction to be generated, and determining a target register number stack corresponding to the target register type;

[0091] Step 204 , generating the instruction to be generated based on the target register number in the target register number stack, so that the instruction to be generated and the generated instruction corresponding to the target register number form an instruction dependency; the instruction dependency indicates the instruction execution order.

[0092] The contents of the above steps 201-204 can refer to the above Figure 1 The embodiments are not described in detail here.

[0093] Optionally, the step of storing the multiple register numbers into at least one register number stack respectively based on the register type information corresponding to each register number includes:

[0094] Determine at least one candidate register number stack corresponding to the register number based on the data type in the register type information;

[0095] Based on the location type in the register type information, determining a target register number stack corresponding to the location type in the at least one candidate register number stack;

[0096] The register number is stored in the target register number stack.

[0097] In the disclosed embodiment, the corresponding register number stack is determined based on the register type information. Since each instruction actually includes multiple register numbers, the types of the multiple register numbers are the same. For example, in the "AND" instruction, the register numbers "x25", "x25" and "x29" are all integer registers. The register number stack corresponding to a specific type of register number can be further distinguished based on the position of the registers corresponding to different register numbers of the same type of register number in the generated instructions. For example, the first "x25" in the "AND" instruction is the destination register (dest) in the instruction, "x25" is the first source register (src), and "x29" is the second source register (src). The destination register is used to store the result of the instruction execution, and the source register is used to store the data required for the instruction execution. Table 1 below is a structure array including 16 generated instructions, as shown in Table 1:

[0098] Table 1

[0099]

[0100] In Table 1, name represents the instruction name, rd represents the destination register number of the instruction, rs1 represents the first source register number of the instruction, rs2 represents the second source register number of the instruction, and rs3 represents the third source register number of the instruction. Instruction numbers 0-15 represent 16 generated instructions, current_inst is the current instruction to be generated, the name of the instruction to be generated is "BGEU", and the "x" in x? indicates that the register used to generate the BGEU instruction is an integer register. For any type of register, it is also possible to distinguish the register according to its specific position in the generated instruction, for example, to distinguish it as a target register or the first and second source registers, to further classify the specific type of register. The classification of the register numbers of the above 16 instructions in the structure array can be shown in Table 2 below:

[0101] Table 2

[0102]

[0103] In Table 2, for the "x" integer register, it can be further divided into xd, xs1 and xs2 according to the position of the register number in the generated instruction, with a total of 3 register number stacks. Similarly, for the "f" integer register, it can be divided into fd, fs1, fs2 and fs3, with a total of 4 register number stacks, and for the "v" integer register, it can be divided into vd, vs1 and vs2, with a total of 3 register number stacks.

[0104] When storing the register numbers "x25", "x25" and "x29" in the "AND" instruction, the three candidate register number stacks xd, xs1 and xs2 can be determined first, and then since the first "x25" is the target register, it can be stored in the xd register number stack, and "x29" is the second source register, it can be stored in the xs2 register number stack. The remaining instructions are similar and will not be repeated here.

[0105] In the embodiment of the present disclosure, at least one candidate register number stack corresponding to the register number is determined based on the data type in the register type information; a target register number stack corresponding to the position type is determined in at least one candidate register number stack based on the position type in the register type information; and the register number is stored in the target register number stack. On the basis of the register type, the registers can be further differentiated and stored, thereby improving the precision of register number storage.

[0106] Optionally, the method further includes:

[0107] Step A1, sorting the register numbers in each register number stack based on usage parameters corresponding to the register numbers to construct a register number sequence corresponding to each register number stack; the usage parameters represent the usage of the register numbers when generating instructions;

[0108] The step 204 of generating the instruction to be generated based on the target register number in the target register number stack includes:

[0109] Step 2041, obtaining a register number corresponding to a minimum usage parameter in a target register number sequence corresponding to the target register number stack as a target register number;

[0110] Step 2042: Generate the instruction to be generated based on the target register number.

[0111] In the disclosed embodiment, each register number corresponds to a usage parameter, which may indicate the usage of the register number when generating instructions (such as usage time, number of times used, etc.). Usage refers to the action generated based on the register number when generating instructions.

[0112] Based on the size of the used parameters, multiple register numbers in each register number stack can be sorted, for example, from large to small or from small to large, to construct a register number sequence corresponding to each register number stack. For details, please refer to Table 2 above. The multiple columns of data in Table 2 (except the first column) are all register number sequences.

[0113] When determining the target register number in the target register number stack, the target register number may be selected according to the target register number sequence corresponding to the target register number stack, for example, the first, middle or last register number in the register number sequence may be selected. How to sort and how to select the target register number in the sequence are not specifically limited herein.

[0114] Optionally, the usage parameter is instruction generation time, each register number has a corresponding counter, and the counter is used to record the instruction generation time;

[0115] Before the step of sorting the register numbers in each register number stack based on the usage parameters corresponding to the register numbers in each register number stack, the method further includes:

[0116] The instruction generation time (timestamp) of the generated instruction corresponding to the register number is obtained, and a counter corresponding to the register number is set according to the instruction generation time, so that the counter records the instruction generation time.

[0117] In the disclosed embodiment, the usage parameter may specifically be the instruction generation time, and each register number has a corresponding counter, which is used to record the instruction generation time. It is understandable that the counter can also be implemented in a structure array. The use of the register number is the action of generating an instruction based on the register number when the instruction is generated. Then, the instruction generation time of the generated instruction corresponding to each register number can be directly obtained, which is the usage parameter of the register number. By setting the counter corresponding to the register number according to the instruction generation time, the counter records the instruction generation time.

[0118] Furthermore, the instruction generation time corresponding to each register number can be sorted, and the register number with an earlier instruction generation time can be stored at the bottom of the register stack. The later the instruction generation time of the register number, the higher the storage position in the register stack. It can be understood that the earlier the instruction generation time, the smaller the value in the counter of the corresponding register number. Selecting the register number corresponding to the minimum usage parameter in the register sequence obtained by sorting based on the instruction generation time means selecting the register number at the bottom of the register number stack for dependency construction. This selection method can be considered as the least recently used algorithm (LRU, Least Recently Used).

[0119] Optionally, the usage parameter is the number of times the register number is used, and each register number has a corresponding counter, and the counter is used to record the number of times it is used;

[0120] Before the step of sorting the register numbers in each register number stack based on the usage parameters corresponding to the register numbers in each register number stack, the method further includes:

[0121] Based on the register numbers in each register number stack, determining the number of times each register number is used in the generated instruction;

[0122] Based on the number of times each register number is used, a counter corresponding to each register number is set so that the counter records the number of times it is used.

[0123] In the disclosed embodiment, the usage parameter is the number of times the register number is used, and each register number has a corresponding counter, which is used to record the number of times it is used. The number of times a register number is used means that among several instructions that have been generated, some instructions have the same register number, and the number of these same register numbers is the number of times it is used. For example, among the 5 instructions that have been generated, 3 instructions include the register number "x25", and each instruction has 1 register number "x25", then the number of times the register number "x25" is used is 3.

[0124] It is understandable that for m identical register numbers, only one corresponding register number can be displayed in the register number stack, and then the value of the counter of this register number is set to m, which can indicate the number of times this register number is used. Based on the same process, the usage parameters of other register numbers in the register number stack are determined and sorted based on the number of times used.

[0125] Based on the register number sequence of usage times, the one at the bottom may be the one that is used the least. So when selecting the target register number, the register number that is used the least may be selected. This selection method can be considered as the least frequently used algorithm (LFU).

[0126] It is understandable that the logic of other page (cache) replacement algorithms may also be used to implement the register number sorting and target register number selection, such as random algorithms and first-in-first-out algorithms, which are not limited here.

[0127] Optionally, after the step of generating the instruction to be generated based on the target register number, the method further includes:

[0128] According to the instruction generation time of the instruction to be generated, the counter corresponding to the target register number is updated to update the position of the target register number in the target register number sequence.

[0129] In the disclosed embodiment, after the step of generating the instruction to be generated based on the target register number, the usage parameter of the target register number will change. When the usage parameter is the instruction generation time, the instruction generation time corresponding to the target register number is actually updated, because the current instruction to be generated is generated based on the target register number, so it is necessary to update the value in the counter corresponding to the target register number to the instruction generation time of the current instruction to be generated. Correspondingly, in the case of sorting based on the instruction generation time, the position of the target register number in the target register number sequence will also be updated accordingly.

[0130] In the implementation of the embodiment of the present disclosure, after the step of generating the instruction to be generated based on the target register number, the counter corresponding to the target register number is updated according to the instruction generation time of the instruction to be generated, so as to update the position of the target register number in the target register number sequence. In the process of instruction generation, the corresponding counter can be adjusted in real time and the register number sequence can be adjusted accordingly, so that the register number sequence can always reflect the current usage of each register number, which is convenient for the generation of the next instruction to be generated and the dependency construction, and improves the accuracy of the dependency construction.

[0131] Optionally, the number of the target register number stacks is at least two;

[0132] The updating of the counter corresponding to the target register number according to the instruction generation time of the instruction to be generated includes:

[0133] According to the instruction generation time of the instruction to be generated, the counters corresponding to the target register numbers in all target register number stacks are updated.

[0134] In the disclosed embodiment, the number of target register number stacks may be at least two. Referring to the BGEU instruction in Table 1, when generating the BGEU instruction, since the BGEU instruction includes the destination register "x?" and the first source register "x?", although both registers are integers, in the above-mentioned classified storage of registers, based on the destination register "x?", the corresponding register number may be searched in the xd register number stack (a stack for storing the destination register number) to construct the write-after-write dependency (WAW, Write After Write) of rd_rd. Since the first source register "x?" is used to store the data required for the execution of the instruction, and as far as the two register number stacks xs1 or xs2 are concerned, the register corresponding to any register number in each register number stack is a register for storing the data required for the execution of the instruction, then the first source register "x?" may be determined in any of the register number stacks xs1 or xs2 to construct the rs_rs dependency, and at this time the number of target register number stacks is two (xs1, xs2).

[0135] Then, when updating the counter corresponding to the target register number in the target register number stack according to the instruction generation time of the instruction to be generated, the counters of the target register numbers in the two target register number stacks need to be updated.

[0136] It can be understood that although there are two target register number stacks (xs1, xs2), when selecting a specific target register number, any register number in xs1 or xs2 or the register number corresponding to the minimum used parameter in the register number sequence is selected. Referring to Table 2, if the selected target register number is x29 in the xs2 register number stack, the counter corresponding to x29 in xs2 needs to be updated, and the corresponding x29 position will be at the top of xs2. However, the register number x29 does not exist in xs1, so the new register number x29 needs to be directly added to the top of xs1, as shown in Table 3 below:

[0137] Table 3

[0138]

[0139] Table 3 is an updated table based on Table 2. The tops of xs1 and xs2 in Table 3 are the updated x29 register numbers.

[0140] It should be noted that, for the sake of simplicity, the method embodiments are described as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.

[0141] Device Embodiment

[0142] Reference Figure 3 , shows a structural block diagram of an instruction dependency construction device of the present invention, the device 30 comprises:

[0143] The number acquisition module 301 is used to acquire multiple register numbers in the generated instructions; each register number corresponds to register type information; different register numbers correspond to different generated instructions;

[0144] A number storage module 302, configured to store the plurality of register numbers into at least one register number stack respectively based on register type information corresponding to each register number;

[0145] A target determination module 303 is used to obtain a target register type of the instruction to be generated and determine a target register number stack corresponding to the target register type;

[0146] The generation and construction module 304 is used to generate the instruction to be generated based on the target register number in the target register number stack, and to construct an instruction dependency between the instruction to be generated and the generated instruction corresponding to the target register number; the instruction dependency indicates the execution order of the instructions.

[0147] Optionally, the device further comprises:

[0148] A register number sequence module, used for sorting the register numbers in each register number stack based on usage parameters corresponding to the register numbers, so as to construct a register number sequence corresponding to each register number stack; the usage parameters represent the usage of the register numbers when generating instructions;

[0149] Generate building blocks, including:

[0150] A minimum parameter submodule, used to obtain, in the target register number sequence corresponding to the target register number stack, a register number corresponding to a minimum usage parameter as a target register number;

[0151] The instruction generation submodule is used to generate the instruction to be generated based on the target register number.

[0152] Optionally, the usage parameter is instruction generation time, each register number has a corresponding counter, and the counter is used to record the instruction generation time;

[0153] The device also includes:

[0154] The generation time module is used to temporarily set a counter corresponding to the register number so that the counter records the instruction generation time.

[0155] Optionally, the usage parameter is the number of times the register number is used, and each register number has a corresponding counter, and the counter is used to record the number of times it is used;

[0156] The device also includes:

[0157] A frequency counting module, used for determining the number of times each register number is used in the generated instruction based on the register number in each register number stack;

[0158] The number recording module is used to set the counter corresponding to the register number in each number set based on the number of uses in the number set, so that the counter records the number of uses.

[0159] Optionally, the device further comprises:

[0160] An updating module is used to update the counter corresponding to the target register number according to the instruction generation time of the instruction to be generated, so as to update the position of the target register number in the target register number sequence.

[0161] Optionally, the register type information includes a data type and a location type;

[0162] Numbered storage module, including:

[0163] A data type submodule, configured to determine at least one candidate register number stack corresponding to the register number based on the data type in the register type information;

[0164] a location type submodule, configured to determine, based on the location type in the register type information, a target register number stack corresponding to the location type in the at least one candidate register number stack;

[0165] The number storing submodule is used to store the register number into the target register number stack.

[0166] Optionally, the number of the target register number stacks is at least two;

[0167] Update modules, including:

[0168] The updating submodule is used to update the counters corresponding to the target register numbers in all target register number stacks according to the instruction generation time of the instruction to be generated.

[0169] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0170] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0171] Regarding the processor in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0172] Reference Figure 4 , is a structural block diagram of an electronic device for instruction-dependent construction provided by an embodiment of the present invention. Figure 4 As shown, the electronic device includes: a processor, a memory, a communication interface and a communication bus, and the processor, the memory and the communication interface communicate with each other through the communication bus; the memory is used to store executable instructions, and the executable instructions enable the processor to execute the instruction dependency construction method of the aforementioned embodiment.

[0173] The processor may be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array) or other editable devices, transistor logic devices, hardware components or any combination thereof. The processor may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor.

[0174] The communication bus may include a path for transmitting information between the memory and the communication interface. The communication bus may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The communication bus may be divided into an address bus, a data bus, and a control bus. For ease of representation, Figure 4 The fact that only one line is used in the diagram does not mean that there is only one bus or only one type of bus.

[0175] The memory can be a ROM (Read Only Memory) or other types of static storage devices that can store static information and instructions, a RAM (Random Access Memory) or other types of dynamic storage devices that can store information and instructions, or it can be an EEPROM (Electrically ErasableProgrammable Read Only Memory), a CD-ROM (Compact Disc Read Only Memory), a magnetic tape, a floppy disk, and an optical data storage device.

[0176] The embodiment of the present invention also provides a non-transitory computer-readable storage medium, when the instructions in the storage medium are executed by a processor of an electronic device (server or terminal), the processor can execute Figure 2 The instructions shown depend on the build method.

[0177] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0178] It will be appreciated by those skilled in the art that the embodiments of the present invention may be provided as methods, devices, or computer program products. Therefore, the embodiments of the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the embodiments of the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage) containing computer-usable program code.

[0179] The embodiments of the present invention are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0180] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing terminal device to operate in a predictable manner, so that the instructions stored in the computer readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0181] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0182] Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present invention.

[0183] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.

[0184] The above is a detailed introduction to an instruction dependency construction method, device, electronic device and readable storage medium provided by the present invention. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea; at the same time, for general technical personnel in this field, according to the idea of ​​the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.

Claims

1. A method for building command dependencies, It is characterized in that The method comprises: Obtain multiple register numbers in the generated instructions; each register number corresponds to register type information; different register numbers correspond to different generated instructions; Based on register type information corresponding to each register number, the plurality of register numbers are stored in at least one register number stack respectively; Obtaining a target register type of the instruction to be generated, and determining a target register number stack corresponding to the target register type; The to-be-generated instruction is generated based on the target register number in the target register number stack, so that the to-be-generated instruction and the generated instruction corresponding to the target register number form an instruction dependency; the instruction dependency indicates the instruction execution order.

2. The method according to claim 1, It is characterized in that The method further comprises: Based on usage parameters corresponding to the register numbers, the register numbers in each register number stack are sorted to construct a register number sequence corresponding to each register number stack; the usage parameters represent usage of the register numbers when generating instructions; The step of generating the instruction to be generated based on the target register number in the target register number stack comprises: In the target register number sequence corresponding to the target register number stack, obtaining the register number corresponding to the minimum usage parameter as the target register number; Based on the target register number, the to-be-generated instruction is generated.

3. The method according to claim 2, It is characterized in that The usage parameter is the instruction generation time, each register number has a corresponding counter, and the counter is used to record the instruction generation time; Before the step of sorting the register numbers in each register number stack based on the usage parameters corresponding to the register numbers in each register number stack, the method further includes: The instruction generation time of the generated instruction corresponding to the register number is obtained, and a counter corresponding to the register number is set according to the instruction generation time, so that the counter records the instruction generation time.

4. The method according to claim 2, It is characterized in that The usage parameter is the number of times the register number is used, and each register number has a corresponding counter, and the counter is used to record the number of times it is used; Before the step of sorting the register numbers in each register number stack based on the usage parameters corresponding to the register numbers in each register number stack, the method further includes: Based on the register numbers in each register number stack, determining the number of times each register number is used in the generated instruction; Based on the number of times each register number is used, a counter corresponding to each register number is set so that the counter records the number of times it is used.

5. The method according to claim 3, It is characterized in that After the step of generating the instruction to be generated based on the target register number, the method further includes: According to the instruction generation time of the instruction to be generated, the counter corresponding to the target register number is updated to update the position of the target register number in the target register number sequence.

6. The method according to claim 1, It is characterized in that The register type information includes a data type and a location type; The step of storing the plurality of register numbers into at least one register number stack respectively based on the register type information corresponding to each register number comprises: Determine at least one candidate register number stack corresponding to the register number based on the data type in the register type information; Based on the location type in the register type information, determining a target register number stack corresponding to the location type in the at least one candidate register number stack; The register number is stored in the target register number stack.

7. The method according to claim 5, It is characterized in that The number of the target register number stacks is at least two; The updating of the counter corresponding to the target register number according to the instruction generation time of the instruction to be generated includes: According to the instruction generation time of the instruction to be generated, the counters corresponding to the target register numbers in all target register number stacks are updated.

8. An instruction-dependent construction device, It is characterized in that The device comprises: A number acquisition module is used to acquire multiple register numbers in the generated instructions; each register number corresponds to register type information; different register numbers correspond to different generated instructions; A number storage module, used for storing the plurality of register numbers into at least one register number stack respectively based on register type information corresponding to each register number; A target determination module, used to obtain a target register type of the instruction to be generated, and determine a target register number stack corresponding to the target register type; A generation and construction module is used to generate the instruction to be generated based on the target register number in the target register number stack, and to construct an instruction dependency between the instruction to be generated and the generated instruction corresponding to the target register number; the instruction dependency represents the execution order of the instructions.

9. An electronic device, It is characterized in that The electronic device includes a processor, a memory, a communication interface and a communication bus, and the processor, the memory and the communication interface communicate with each other through the communication bus; the memory is used to store executable instructions, and the executable instructions enable the processor to execute the instruction dependency construction method as described in any one of claims 1 to 7.

10. A readable storage medium, It is characterized in that When the instructions in the readable storage medium are executed by a processor of an electronic device, the processor is enabled to execute the instruction-dependent construction method as described in any one of claims 1 to 7.