WO2022073197A1 - 汇编指令的资源分析方法、装置和存储介质 - Google Patents
汇编指令的资源分析方法、装置和存储介质 Download PDFInfo
- Publication number
- WO2022073197A1 WO2022073197A1 PCT/CN2020/119997 CN2020119997W WO2022073197A1 WO 2022073197 A1 WO2022073197 A1 WO 2022073197A1 CN 2020119997 W CN2020119997 W CN 2020119997W WO 2022073197 A1 WO2022073197 A1 WO 2022073197A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- instruction
- assembly
- information
- resource
- resources
- 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.)
- Ceased
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/30—Arrangements for executing machine instructions, e.g. instruction decode
- G06F9/30145—Instruction analysis, e.g. decoding, instruction word fields
Definitions
- Embodiments of the present invention relate to the technical field of data processing, and in particular, to a resource analysis method, device and storage medium for assembly instructions.
- the embodiments of the present invention provide a resource analysis method, device and storage medium for an assembly instruction, so as to solve the problem in the prior art that because the instruction writer cannot clearly understand the data resources occupied by the assembly instruction, which is not conducive to the The problem of ensuring the correctness of assembly instructions.
- a first aspect of the embodiments of the present invention provides a resource analysis method for an assembly instruction, including:
- the assembly information includes at least one assembly instruction
- instruction resource information corresponding to each assembly instruction in the assembly information is determined.
- a second aspect of the embodiments of the present invention provides a resource analysis device for an assembly instruction, including:
- a processor for running a computer program stored in the memory to achieve:
- the assembly information includes at least one assembly instruction
- instruction resource information corresponding to each assembly instruction in the assembly information is determined.
- a third aspect of the embodiments of the present invention provides a computer-readable storage medium, where program instructions are stored in the computer-readable storage medium, and the program instructions are used to implement the resource analysis method for an assembly instruction described in the first aspect.
- the resource analysis method, device, and storage medium for assembly instructions provided by the embodiments of the present invention can analyze and identify instruction resource information of assembly instructions, obtain instruction resource information corresponding to each assembly instruction, and then facilitate the instruction writers.
- the data resources occupied by the assembly instructions can be clearly understood through the instruction resource information, which is beneficial to improve the accuracy and quality of writing the assembly instructions.
- FIG. 1 is a schematic flowchart of a resource analysis method for an assembly instruction provided by an embodiment of the present invention
- FIG. 2 is a schematic flowchart of obtaining compilation information to be analyzed provided by an embodiment of the present invention
- FIG. 3 is a schematic flowchart of determining available resources corresponding to the compilation information provided by an embodiment of the present invention
- FIG. 4 is a schematic flowchart of determining an instruction type corresponding to each assembly instruction provided by an embodiment of the present invention
- FIG. 5 is a schematic flowchart of determining instruction resource information corresponding to each assembly instruction in the assembly information based on the available resources and instruction types provided by an embodiment of the present invention
- FIG. 6 is a schematic flowchart of determining instruction resource information corresponding to each assembly instruction in the assembly information based on the usable resources and instruction types provided by another embodiment of the present invention
- FIG. 7 is a schematic flowchart of obtaining an association relationship corresponding to each assembly instruction in the assembly information provided by an embodiment of the present invention.
- FIG. 8 is a schematic flowchart of determining instruction resource information corresponding to each assembly instruction in the assembly information based on the association relationship, available resources, and instruction types provided by an embodiment of the present invention
- FIG. 9 is a schematic flowchart of determining instruction resource information corresponding to each assembly instruction in the assembly information based on the association relationship, available resources, and instruction type provided by another embodiment of the present invention.
- FIG. 10 is a schematic structural diagram of an apparatus for analyzing a resource of an assembly instruction according to an embodiment of the present invention.
- FIG. 1 is a schematic flowchart of a resource analysis method for an assembly instruction provided by an embodiment of the present invention; with reference to FIG. 1 , the present embodiment provides a resource analysis method for an assembly instruction, wherein the execution body of the method may be It is a resource analysis device for assembling instructions. It can be understood that the resource analysis device can be implemented as software or a combination of software and hardware. The resource analysis method can be applied to a code writing system or a code optimization system. In the above application scenario , which can effectively improve the quality and efficiency of compiling instructions for instruction writing operations with high computational density.
- the method may include:
- Step S101 Obtain assembly information to be analyzed, where the assembly information includes at least one assembly instruction.
- Step S102 Determine the available resources corresponding to the assembly information and the instruction type corresponding to each assembly instruction.
- Step S103 Determine instruction resource information corresponding to each assembly instruction in the assembly information based on available resources and instruction types.
- Step S101 Obtain assembly information to be analyzed, where the assembly information includes at least one assembly instruction.
- the assembly information to be analyzed may refer to an assembly instruction set that needs to be analyzed for resources, and the assembly information may include at least one assembly instruction.
- the specific acquisition method of the compilation information to be analyzed is not limited.
- An achievable method is: the compilation information is stored in a preset area, and the compilation to be analyzed can be acquired by accessing the preset area. information.
- the resource analysis device is provided with a display module for the user to input assembly instructions, and the display module can display a display interface for interacting with the user, and then real-time detection of the user's response to the display The information entered in the interface is used to obtain the assembly information to be analyzed.
- other methods may also be used to obtain the compilation information to be analyzed, as long as the accuracy and reliability of the acquisition of the compilation information can be ensured, which will not be repeated here.
- Step S102 Determine the available resources corresponding to the assembly information and the instruction type corresponding to each assembly instruction.
- the above-mentioned available resources may include at least the following: One: the number of registers that can be used, the length of the registers that can be used, the start and stop bits of the registers that can be used, and the registers that can run at the same time.
- this embodiment does not limit the specific way of determining the usable resources.
- An implementable way is to pre-configure the mapping relationship between different types of chips and usable resources, and after obtaining the assembly information, The chip type corresponding to the assembly information can be determined, and the available resources corresponding to the assembly information can be determined based on the chip type and the above-mentioned mapping relationship.
- this embodiment does not limit the specific manner of determining the instruction type corresponding to the assembly instruction.
- An achievable manner is: pre-configuring a plurality of mapping relationships between standard instruction frameworks and standard instruction types. After reaching the assembly instructions included in the assembly information, the standard instruction frame corresponding to the above assembly instruction can be determined, and then the standard instruction type corresponding to the standard instruction frame is determined as the instruction type corresponding to the assembly instruction.
- another achievable way is: after obtaining the assembly instructions included in the assembly information, the assembly instruction structure and keywords corresponding to each assembly instruction can be obtained; The instruction type corresponding to the assembly information.
- Step S103 Determine instruction resource information corresponding to each assembly instruction in the assembly information based on available resources and instruction types.
- the usable resources and the instruction type may be analyzed and processed to determine the available resources and the instruction type corresponding to each assembly instruction in the assembly information.
- Instruction resource information the instruction resource information may include at least one of the following: the number of registers, the length of each register, the start bit and the end bit of each register when it is used. Wherein, the start bit and the end bit of each register in use respectively refer to which instruction the register starts to be occupied, and which instruction can be occupied again after the execution of the instruction.
- this embodiment does not limit the specific determination method for determining the instruction resource information corresponding to each assembly instruction in the assembly information.
- An achievable method is: according to the hiring rules, using the control flow graph of the compilation principle to analyze the current The assembly instruction code that needs to be analyzed. Further, according to the entered resources, the correlation between assembly instructions is analyzed. Through the correlation between the assembly instructions and the existing control flow graph, determine the resource occupation of each assembly instruction, so as to obtain the occupied and unoccupied resources of each assembly instruction and the usable resources of the assembly instruction to be written in the future. . For the existing program, the assembly code can be read better by this method, which is convenient for the programmer to optimize the assembly. .
- the method in this embodiment may further include: displaying the instruction resource information corresponding to each assembly instruction.
- the instruction resource information corresponding to each assembly instruction may be show.
- displaying the instruction resource information corresponding to each assembly instruction may include: acquiring a display mode for displaying the instruction resource information; based on the display mode, displaying the instruction resource information corresponding to each assembly instruction Display, so that the assembly instruction and instruction resource information form an assembly file.
- a display mode for displaying the instruction resource information is preset, and the display mode may include at least one of the following: displaying the instruction resource information at a preset position of the assembly instruction, displaying the instruction resource information The information is displayed by means of comments, and the instruction resource information is displayed by means of highlighting (for example, by color, font shape, and font size).
- a display mode for displaying the instruction resource information can be acquired, and then the instruction resource corresponding to each assembly instruction can be displayed in the acquired display mode. information is displayed. Further, when displaying the assembly instruction and the instruction resource information, the assembly instruction and the instruction resource information can be formed into an assembly file, and can also be compiled in the interface provided by the analysis system of this embodiment and displayed in real time. Users can choose the two methods by themselves, so as to facilitate users to view the instruction resource information in a unified manner, and further improve the practicability, flexibility and reliability of the method.
- the above-mentioned instruction resource information may include custom resources located on the chip, and may support vectorized operations on resources, which not only expands the scope of use of the method, but also helps to improve the practicability of the method .
- the resource analysis method for an assembly instruction obtains the assembly information to be analyzed, and then determines the available resources corresponding to the assembly information and the instruction type corresponding to each assembly instruction, and based on the available resources and the instruction type to determine the instruction resource information corresponding to each assembly instruction in the assembly information, thereby effectively realizing the analysis and identification of the instruction resource information of the assembly instruction, obtaining the instruction resource information corresponding to each assembly instruction, and then It is convenient for the instruction writers to clearly understand the data resources occupied by the assembly instructions through the instruction resource information, which is conducive to improving the accuracy and quality of the compilation instructions, further improving the practicability of the method, and is conducive to the promotion of the market. with application.
- Fig. 2 is the schematic flow chart of obtaining the compilation information to be analyzed provided by the embodiment of the present invention. On the basis of the above-mentioned embodiment, continue to refer to Fig.
- the example provides an implementation manner of acquiring assembly information. Specifically, acquiring the assembly information to be analyzed in this embodiment may include:
- Step S201 Obtain an information assembly specification for analyzing and processing the assembly information.
- Step S202 Obtain the compilation information to be analyzed based on the information compilation specification.
- the resource attributes corresponding to the main keywords are shown in the following table:
- the input resource table/output resource table in the above table may include an on-chip storage unit, and the on-chip storage unit may include a vector storage unit and a scalar storage unit. It can be understood that the vector storage unit is used to store vector data, and the scalar storage unit Used to store scalar data. For the assembly instruction corresponding to the above "cfg_func", the specific function corresponding to the current instruction can be determined by the specific keyword included in the instruction.
- the information assembly specification may include: for a text document (eg, a txt format document) used to form assembly information, each attribute information in the text document may be marked with symbols " ⁇ " and ">” Labels, attribute information equivalents can be separated by the symbol "
- the configured information compilation specifications can be stored in the preset area.
- Information compilation specification for the analysis and processing of information After the information assembly specification is obtained, the assembly information to be analyzed can be obtained based on the information assembly specification, thereby effectively realizing that when writing assembly information for various types of chips, it is possible to obtain information that meets the information assembly specification and can pass
- the resource analysis device accurately analyzes and processes the compiled information, thereby effectively ensuring the accuracy and reliability of the acquisition of the compiled information.
- the lengths of the above-mentioned input resources and output resources may be in bits, and there is no upper limit on the lengths (for example, the lengths may be 2 64 bits).
- the running time occupied by each assembly instruction can be obtained. Specifically, the running time occupied by the assembly instruction can be determined through an abstract unit time (cycle), The above-mentioned abstract unit time can be understood as the minimum instruction execution unit time corresponding to all assembly instructions in the resource analysis device.
- the assembly information to be analyzed can be accurately obtained based on the above information assembly specification.
- a vector addition for a platform could be:
- an addition assembly instruction on the movidus platform can be:
- vau corresponds to the module attribute
- add corresponds to the name attribute
- vr corresponds to the output attribute
- vr,vr corresponds to the input attribute
- 128 corresponds to the output length attribute
- 128,128 corresponds to Enter the length attribute
- pocs corresponds to the function attribute
- "3" corresponds to the delay attribute; in this way, the assembly information that satisfies the validity of the numerical value can be accurately obtained, thereby effectively ensuring the accuracy and reliability of the assembly information acquisition.
- FIG. 3 is a schematic flowchart of determining available resources corresponding to compilation information provided by an embodiment of the present invention; on the basis of the foregoing embodiment, continuing to refer to FIG. 3 , the determination in this embodiment corresponds to compilation information
- the available resources can include:
- Step S301 Obtain chip feature information corresponding to the assembly information.
- Step S302 Determine available resources corresponding to the assembly information based on the chip feature information.
- the assembly information may be analyzed and processed to determine chip feature information corresponding to the assembly information, where the chip feature information may include at least one of the following: chip type and chip architecture.
- the instruction writer when the instruction writer writes assembly information for a certain chip, he can first determine the chip feature information corresponding to the chip, and the chip feature information can be stored in a preset area. Chip feature information corresponding to the assembly information can be obtained by accessing the preset area, so as to perform the writing operation of the assembly information based on the chip feature information.
- the available resources corresponding to the assembly information can be determined by using the pre-configured mapping relationship between the chip feature information and the available resources, thereby effectively ensuring the accurate determination of the available resources. Reliability, which further improves the quality and efficiency of resource analysis of assembly instructions in assembly information based on available resources.
- FIG. 4 is a schematic flowchart of determining an instruction type corresponding to each assembly instruction provided by an embodiment of the present invention; on the basis of the above embodiment, with continued reference to FIG. 4 , this embodiment provides a The accuracy and reliability of determining, specifically, determining the instruction type corresponding to each assembly instruction in this embodiment may include:
- Step S401 Obtain an instruction type identifier corresponding to each assembly instruction.
- Step S402 Determine the instruction type corresponding to the assembly instruction based on the instruction type identifier.
- each assembly instruction in the assembly information can be analyzed and processed to obtain the instruction type identifier corresponding to each assembly instruction.
- the instruction type corresponding to the assembly instruction It can include any one of the following: storage class instructions, jump class instructions, and operation processing instructions.
- the storage class instruction is used to implement the storage operation on data, that is, any instruction with any storage (for example: writing to a preset memory) function can be marked as a storage class instruction; the jump class instruction is used to implement function jumping.
- the transfer operation that is, the instruction with any jump function is marked as a jump instruction; and then for the assembly instruction, the instruction that is not of the above two functional types is marked as an operation processing instruction.
- the instruction type corresponding to the assembly instruction can be determined based on the instruction type identifier. Specifically, the mapping relationship between different standard instruction types and the standard type identifier is pre-stored. After the instruction type identifier is acquired After that, the instruction type identifier can be analyzed and matched with the standard type identifier, and then the target standard type identifier corresponding to the assembly instruction can be determined, and the standard instruction type corresponding to the target standard type identifier can be determined as the instruction type corresponding to the assembly instruction. . Of course, other methods may also be used to determine the instruction type corresponding to the assembly instruction based on the instruction type identifier, as long as the accuracy and reliability of determining the instruction type corresponding to the assembly instruction can be ensured.
- FIG. 5 is a schematic flowchart of determining instruction resource information corresponding to each assembly instruction in the assembly information based on available resources and instruction types according to an embodiment of the present invention; on the basis of the above embodiment, continue to refer to FIG. 5 As shown, this embodiment provides an implementation method for determining instruction resource information. Specifically, in this embodiment, based on available resources and instruction types, determining instruction resource information corresponding to each assembly instruction in the assembly information can be include:
- Step S501 Determine resource limitation information corresponding to the assembly instruction according to the instruction type.
- Step S502 Determine instruction resource information corresponding to each assembly instruction in the assembly information based on available resources and resource limitation information.
- the instruction type can be analyzed and processed to determine the resource limitation information corresponding to the assembly instruction, and the resource limitation information may include resource upper limit information, resource lower limit information, etc. It can be understood that, Different instruction types may correspond to different resource limit information.
- the instruction resource information corresponding to each assembly instruction in the assembly information can be determined based on the usable resources and the resource limitation information. All the resource information that the corresponding chip can support, and the resource limit information is the resource limit information that needs to be met when each assembly instruction runs.
- the resource range corresponding to the restriction information is a part of the resource range corresponding to the usable resource.
- the available resources (for example, the number of registers) corresponding to the assembly information are 100.
- the resource limitation information corresponding to an assembly instruction located in the assembly information is 2 to 10, that is, the minimum resource limitation information corresponding to the above assembly instruction is 2, and the resource maximum limitation information is 10.
- the instruction resource information corresponding to each assembly instruction in the assembly information can be determined based on the specific application scenarios and application requirements, based on the available resources and resource limitation information.
- the instruction resource corresponding to each assembly instruction can be The information is determined to be any resource information in the resource scope corresponding to the resource limitation information.
- the total resource of the instruction resource information corresponding to all the assembly instructions in the assembly information should be smaller than the resource scope corresponding to the available resources to ensure that the Assembly instructions perform accurate resource analysis operations.
- the resource limitation information corresponding to the assembly instruction is determined according to the instruction type, and then the instruction resource information corresponding to each assembly instruction in the assembly information is determined based on the available resources and the resource limitation information.
- the accuracy and reliability of the determination of the instruction resource information also ensures that the instruction resource information can be supported by the corresponding chip, which further improves the quality and efficiency of the resource analysis for the assembly instruction.
- FIG. 6 is a schematic flowchart of determining instruction resource information corresponding to each assembly instruction in the assembly information based on available resources and instruction types according to another embodiment of the present invention; on the basis of the above embodiment, continue to refer to the accompanying drawings As shown in 6, this embodiment provides another implementation manner of determining the instruction resource information. Specifically, in this embodiment, the instruction resource corresponding to each assembly instruction in the assembly information is determined based on the available resources and the instruction type. Information can include:
- Step S601 Obtain an association relationship corresponding to each assembly instruction in the assembly information.
- an association relationship may exist between the assembly instruction and other assembly instructions, and the association relationship may include an input-output relationship.
- each assembly instruction in the assembly information can be analyzed and processed to obtain the association corresponding to each assembly instruction relation.
- the compilation information can be input into the resource analysis device, and the resource analysis device can identify the resource dependency and usage in the current compilation information based on preset data processing rules.
- obtaining the association relationship corresponding to each assembly instruction in the assembly information in this embodiment may include:
- Step S6011 Obtain a control flow graph corresponding to the assembly information, where the control flow graph includes an instruction node corresponding to each assembly instruction.
- Step S6012 Identify the input-output relationship corresponding to each instruction node in the control flow graph.
- Step S6013 Determine the input-output relationship corresponding to each instruction node in the control flow graph as an association relationship corresponding to each assembly instruction in the assembly information.
- each instruction node After obtaining the assembly information, you can count the multiple assembly instructions included in the assembly information, the writing order corresponding to the multiple assembly instructions, and the input parameters and output parameters corresponding to each assembly instruction, and then use each assembly instruction as An instruction node obtains a control flow graph corresponding to the assembly information based on the writing sequence corresponding to the above-mentioned multiple assembly instructions, and the input parameters and output parameters corresponding to each assembly instruction. After the control flow graph is obtained, each instruction node in the control flow graph can be analyzed and identified, so that the input and output relationship corresponding to each instruction node can be obtained, and then the corresponding input and output relationship of each instruction node can be obtained. The input-output relationship is determined as an association relationship corresponding to each assembly instruction in the assembly information, which effectively improves the accuracy and reliability of acquiring the association relationship corresponding to each assembly instruction in the assembly information.
- Step S602 Determine instruction resource information corresponding to each assembly instruction in the assembly information based on the association relationship, available resources and instruction types.
- usable resources and instruction types After obtaining the association relationship, usable resources and instruction types, the above-mentioned association relationship, usable resources and instruction types can be analyzed and processed to determine the instruction resource information corresponding to each assembly instruction in the assembly information.
- determining the instruction resource information corresponding to each assembly instruction in the assembly information may include:
- Step S6021 Determine the multiplexed register resources included in any two assembly instructions according to the association relationship and the instruction type.
- Step S6022 Determine the instruction resource information corresponding to the assembly instruction based on the available resources, the instruction type and the multiplexed register resource, where the instruction resource information includes the multiplexed register resource.
- the instruction resource information corresponding to the two assembly instructions may be independent of each other or there may be multiplexed data resources. Therefore, in order to accurately identify the instruction resource information corresponding to each assembly instruction, after obtaining the association relationship and the instruction type, the register resource corresponding to the assembly instruction can be analyzed and processed based on the association relationship and the instruction type. To determine the multiplexed register resources included in any two assembly instructions.
- the assembly information includes assembly instruction a and assembly instruction b
- the instruction type of assembly instruction a can be a storage class instruction, and assembly instruction a is used to store the resources in register b3 into register a1;
- the instruction type is an operation processing instruction (for example, a summation operation instruction), and the assembly instruction b is used to sum the resources in the register b1 and the resources in the register b2 to obtain the resources in the register b3.
- the association between assembly instruction b and assembly instruction a is that the output information of assembly instruction b is the input information of assembly instruction a.
- the multiplexed register resources (register b3 ) included in the assembly instruction a and the assembly instruction b can be determined.
- the arm instruction as the assembly instruction in the assembly information as an example, there are two arm instructions as follows, the first instruction is: Vadd q1, q2, q3; the second instruction is: Vsub q5, q1, q4.
- the first arm instruction is a summation operation instruction
- q1 corresponds to the target register
- q2 and q3 correspond to the input register
- the second arm instruction is a subtraction instruction
- q5 corresponds to the target register
- q1 and q4 correspond to the input register.
- the usable resources, instruction types and multiplexed register resources can be analyzed and processed to determine the instruction resource information corresponding to the assembly instruction.
- the instruction resource corresponding to the instruction information The information may include multiplexed register resources, thereby effectively ensuring the quality and efficiency of determining the instruction resource information corresponding to each assembly instruction in the assembly information.
- the method in this embodiment may further include: generating first prompt information corresponding to the assembly instructions based on the multiplexed register resources.
- the first hint information corresponding to the assembly instruction may be generated based on the multiplexed register resource.
- the first prompt information can be displayed. In this way, the first prompt information corresponding to the assembly instruction is displayed, so that the user can obtain the assembly instruction information with the multiplexed register resource in time through the displayed first prompt information, which is conducive to improving the ability to write the assembly information. Accurate and reliable.
- determining the instruction resource information corresponding to each assembly instruction in the assembly information may include:
- Step S6023 Determine the register resources released in the assembly instruction according to the association relationship and the instruction type.
- Step S6024 Determine the instruction resource information corresponding to the assembly instruction based on the available resources, the instruction type and the released register resources, and the instruction resource information includes the released register resources.
- the register resources released in the assembly instruction can be determined according to the association relationship and the instruction type.
- the assembly information includes assembly instruction A and assembly instruction B, and the instruction types of assembly instruction A and assembly instruction B may both be operation processing instructions (for example, summation operation instructions).
- assembly instruction A is used to implement The resources in register A1 and the resources in register B1 are summed to obtain the resources in register C1; the assembly instruction B is used to realize the summation between the resources in register A2 and the resources in register B2, and the resources in register C2 are obtained resources within.
- the running time interval between the above assembly instruction A and assembly instruction B is relatively long, for example: assembly instruction A runs before assembly instruction B, then, when assembly instruction B runs, the register resources corresponding to assembly instruction A The release can be performed after the above-mentioned running time interval, and at this time, the register resources released by the assembly instruction A can be obtained.
- the usable resources, instruction types and released register resources can be analyzed and processed to determine the instruction resource information corresponding to the assembly instruction.
- the instruction resource information at this time may include the released register resources, thereby effectively ensuring the quality and efficiency of determining the instruction resource information corresponding to each assembly instruction in the assembly information.
- the method further includes: generating second hint information corresponding to the assembly instruction based on the released register resources.
- the second prompt information when writing assembly instructions, in order to improve the accuracy and reliability of writing assembly information and improve the utilization of data resources, after determining the register resources released by the assembly instructions, generate and compile instructions based on the released register resources.
- the second prompt information in order to enable the user to know the register resources released in the assembly instruction in time, the second prompt information may be displayed.
- the second prompt information can be displayed at the upper end, the lower end, the side end of the assembly instruction or in the form of comments/annotations, so that the user can obtain the registers released by the assembly instruction in time through the displayed second prompt information.
- resources which is conducive to improving the accuracy and reliability of compiling the compilation information, and at the same time ensuring high utilization of resources.
- the method in this embodiment may further include: based on the available resources and the instruction type, determining Unused resource information corresponding to assembly information.
- the available resources and the instruction type can be used to determine the corresponding assembly information. of unused resources.
- the instruction resource information set corresponding to all assembly instructions in the assembly information can be counted based on the instruction type corresponding to each assembly instruction, and then the unusable resources corresponding to the assembly information can be determined based on the available resources and the instruction resource information set.
- the unused resource may be the difference between the available resource and the instruction resource information set.
- the method in this embodiment may further include: generating third prompt information corresponding to the compilation information based on the unused resource information.
- a third prompt message corresponding to the assembly information can be generated based on the unused resource information .
- the third prompt information can be displayed, and the third prompt information can be displayed on the upper end, the lower end, the side end of the assembly instruction or in the form of comments/comments. The information is displayed, so that the user can obtain the unused resource information corresponding to the compilation information in time through the displayed third prompt information, which is beneficial to improve the utilization rate of data resources and further improve the accuracy and reliability of the method.
- the method in this embodiment may further include: acquiring an assembly instruction without an associated relationship, and assembling the assembly instruction without an associated relationship The instructions are marked, so that the error rate existing in the compilation of the assembly information can be effectively avoided, the accuracy of the compilation of the assembly information can be improved, and the development efficiency of the assembly information can be further improved.
- FIG. 10 is a schematic structural diagram of a resource analysis device for an assembly instruction provided by an embodiment of the present invention; with reference to FIG. 10 , the present embodiment provides a resource analysis device for an assembly instruction, and the resource analysis device for an assembly instruction may A resource analysis method for executing the assembly instruction corresponding to FIG. 1 above.
- the resource analysis device can be an electronic device with the ability to analyze assembly instructions, such as computers, servers, cloud servers, electronic terminals, etc., or it can be a computer chip or integrated circuit with the ability to analyze assembly instructions, such as a central processing unit.
- CPU Central Processing Unit
- DSP Digital Signal Processor
- ASIC Application Specific Integrated Circuit
- FPGA off-the-shelf programmable gate array
- the resource analysis device for the assembly instruction may include:
- the processor 11 is used for running the computer program stored in the memory 12 to realize:
- the assembly information to be analyzed includes at least one assembly instruction
- instruction resource information corresponding to each assembly instruction in the assembly information is determined.
- the structure of the resource analysis apparatus for assembly instructions may further include a communication interface 13, which is used to implement communication between the resource analysis apparatus for assembly instructions and other devices or communication networks.
- the usable resources include at least one of the following: the number of usable registers, the length of usable registers, the start bit and the end bit of usable registers when they are in use, and registers that can be run simultaneously.
- the instruction resource information includes at least one of the following: the number of registers, the length of each register, the start bit and the end bit of each register when it is used.
- the processor 11 when acquiring the compilation information to be analyzed, is configured to: acquire an information compilation specification for analyzing and processing the compilation information; and acquire the compilation information to be analyzed based on the information compilation specification.
- the processor 11 when determining the available resources corresponding to the assembly information, is configured to: obtain chip feature information corresponding to the assembly information; and determine the available resources corresponding to the assembly information based on the chip feature information .
- the chip feature information includes at least one of the following: chip type, chip architecture.
- the processor 11 when determining the instruction type corresponding to each assembly instruction, is configured to: obtain an instruction type identifier corresponding to each assembly instruction; determine the instruction type corresponding to the assembly instruction based on the instruction type identifier Instruction type.
- the instruction type corresponding to the assembly instruction includes any one of the following: a storage class instruction, a jump class instruction, and an operation processing instruction.
- the processor 11 when determining the instruction resource information corresponding to each assembly instruction in the assembly information based on the available resources and the instruction type, is configured to: determine the resource limitation information corresponding to the assembly instruction according to the instruction type ; Determine the instruction resource information corresponding to each assembly instruction in the assembly information based on the available resources and resource limit information.
- the processor 11 when determining the instruction resource information corresponding to each assembly instruction in the assembly information based on the available resources and the instruction type, is configured to: obtain an association corresponding to each assembly instruction in the assembly information Relationship; based on the association relationship, available resources and instruction types, determine the instruction resource information corresponding to each assembly instruction in the assembly information.
- the processor 11 when obtaining the association relationship corresponding to each assembly instruction in the assembly information, is configured to: obtain a control flow graph corresponding to the assembly information, where the control flow graph includes a control flow graph corresponding to each assembly instruction. Corresponding instruction node; identify the input-output relationship corresponding to each instruction node in the control flow graph; determine the input-output relationship corresponding to each instruction node in the control flow graph as corresponding to each assembly instruction in the assembly information. corresponding relationship.
- the processor 11 when determining the instruction resource information corresponding to each assembly instruction in the assembly information based on the association relationship, available resources and instruction type, is configured to: determine any two according to the association relationship and the instruction type. Multiplexed register resources included in each assembly instruction; based on available resources, instruction types and multiplexed register resources, determine the instruction resource information corresponding to the assembly instruction, and the instruction resource information includes multiplexed register resources.
- the processor 11 is configured to: generate first hint information corresponding to the assembly instructions based on the multiplexed register resources.
- the processor 11 when determining the instruction resource information corresponding to each assembly instruction in the assembly information based on the association relationship, available resources and instruction type, is configured to: determine the assembly instruction according to the association relationship and the instruction type Register resources released in ; based on available resources, instruction types and released register resources, determine the instruction resource information corresponding to the assembly instruction, and the instruction resource information includes the released register resources.
- the processor 11 is configured to: generate second hint information corresponding to the assembly instruction based on the released register resources.
- the processor 11 is configured to: based on the available resources and the instruction type, determine the available resources corresponding to the assembly information of unused resource information.
- the processor 11 is configured to: generate third prompt information corresponding to the assembly information based on the unused resource information.
- the processor 11 is configured to: display the instruction resource information corresponding to each assembly instruction.
- the processor 11 when displaying the instruction resource information corresponding to each assembly instruction, is configured to: obtain a display mode for displaying the instruction resource information; The instruction resource information corresponding to the instruction is displayed, so that the assembly instruction and the instruction resource information form an assembly file.
- the resource analysis device of the assembly instruction shown in FIG. 10 can execute the method of the embodiment shown in FIG. 1-FIG. 9.
- FIG. 1-FIG. 9 For the part not described in detail in this embodiment, please refer to the related description of the embodiment shown in FIG. 1-FIG. 9.
- the execution process and technical effect of the technical solution refer to the descriptions in the embodiments shown in FIG. 1 to FIG. 9 , which will not be repeated here.
- an embodiment of the present invention provides a storage medium, where the storage medium is a computer-readable storage medium, and program instructions are stored in the computer-readable storage medium, and the program instructions are used to implement the above-mentioned embodiments shown in FIG. 1 to FIG. 9 .
- the disclosed resource analysis device and method for assembly instructions may be implemented in other manners.
- the above-described embodiments of the resource analysis apparatus for assembly instructions are only illustrative.
- the division of the modules or units is only a logical function division. In actual implementation, there may be other division methods, such as multiple divisions. Individual units or components may be combined or may be integrated into another system, or some features may be omitted, or not implemented.
- the shown or discussed mutual coupling or direct coupling or communication connection may be through some interfaces, and the indirect coupling or communication connection of the remote control device or unit may be in electrical, mechanical or other forms.
- the units described as separate components may or may not be physically separated, and components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution in this embodiment.
- each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically alone, or two or more units may be integrated into one unit.
- the above-mentioned integrated units may be implemented in the form of hardware, or may be implemented in the form of software functional units.
- the integrated unit if implemented in the form of a software functional unit and sold or used as an independent product, may be stored in a computer-readable storage medium.
- the technical solution of the present invention is essentially or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium , including several instructions for causing a computer processor (processor) to perform all or part of the steps of the methods described in the various embodiments of the present invention.
- the aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read_Only Memory, ROM), random access memory (Random Access Memory, RAM), magnetic disk or optical disk and other media that can store program codes.
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Debugging And Monitoring (AREA)
Abstract
本发明实施例提供一种汇编指令的资源分析方法、装置和存储介质,其中方法包括:获取待分析的汇编信息,所述汇编信息中包括至少一个汇编指令;确定与所述汇编信息相对应的可使用资源、以及与每个汇编指令相对应的指令类型;基于所述可使用资源和指令类型,确定与所述汇编信息中每个汇编指令相对应的指令资源信息。本发明实施例提供的技术方案,可以实现对汇编指令的指令资源信息进行分析识别,获得与每个汇编指令相对应的指令资源信息,而后便于使得指令编写人员通过指令资源信息清楚地了解到汇编指令所占用的数据资源情况,有利于提高对汇编指令进行撰写的准确性和质量。
Description
本发明实施例涉及数据处理技术领域,尤其涉及一种汇编指令的资源分析方法、装置和存储介质。
在芯片开发的过程中,往往需要编写大量的汇编指令,在汇编指令运行时,大量的汇编指令往往会占用较多的数据资源。然而,由于汇编指令并没有在芯片上实际运行,因此,指令编写人员无法清楚地了解到汇编指令所占用的数据资源情况,这样不利于保证汇编指令撰写的正确性。
发明内容
本发明实施例提供了一种汇编指令的资源分析方法、装置和存储介质,用以解决现有技术中存在的由于指令编写人员无法清楚地了解到汇编指令所占用的数据资源情况,从而不利于保证汇编指令撰写的正确性的问题。
本发明实施例第一方面提供了一种汇编指令的资源分析方法,包括:
获取待分析的汇编信息,所述汇编信息中包括至少一个汇编指令;
确定与所述汇编信息相对应的可使用资源、以及与每个汇编指令相对应的指令类型;
基于所述可使用资源和指令类型,确定与所述汇编信息中每个汇编指令相对应的指令资源信息。
本发明实施例第二方面提供了一种汇编指令的资源分析装置,包括:
存储器,用于存储计算机程序;
处理器,用于运行所述存储器中存储的计算机程序以实现:
获取待分析的汇编信息,所述汇编信息中包括至少一个汇编指令;
确定与所述汇编信息相对应的可使用资源、以及与每个汇编指令相对应的指令类型;
基于所述可使用资源和指令类型,确定与所述汇编信息中每个汇编指令 相对应的指令资源信息。
本发明实施例第三方面提供了一种计算机可读存储介质,所述计算机可读存储介质中存储有程序指令,所述程序指令用于实现第一方面所述的汇编指令的资源分析方法。
本发明实施例提供的汇编指令的资源分析方法、装置和存储介质,可以实现对汇编指令的指令资源信息进行分析识别,获得与每个汇编指令相对应的指令资源信息,而后便于使得指令编写人员通过指令资源信息清楚地了解到汇编指令所占用的数据资源情况,有利于提高对汇编指令进行撰写的准确性和质量。
此处所说明的附图用来提供对本发明的进一步理解,构成本发明的一部分,本发明的示意性实施例及其说明用于解释本发明,并不构成对本发明的不当限定。在附图中:
图1为本发明实施例提供的一种汇编指令的资源分析方法的流程示意图;
图2为本发明实施例提供的获取待分析的汇编信息的流程示意图;
图3为本发明实施例提供的确定与所述汇编信息相对应的可使用资源的流程示意图;
图4为本发明实施例提供的确定与每个汇编指令相对应的指令类型的流程示意图;
图5为本发明一实施例提供的基于所述可使用资源和指令类型,确定与所述汇编信息中每个汇编指令相对应的指令资源信息的流程示意图;
图6为本发明另一实施例提供的基于所述可使用资源和指令类型,确定与所述汇编信息中每个汇编指令相对应的指令资源信息的流程示意图;
图7为本发明实施例提供的获取与所述汇编信息中每个汇编指令相对应的关联关系的流程示意图;
图8为本发明一实施例提供的基于所述关联关系、可使用资源和指令类型,确定与所述汇编信息中每个汇编指令相对应的指令资源信息的流程示意图;
图9为本发明另一实施例提供的基于所述关联关系、可使用资源和指令类型,确定与所述汇编信息中每个汇编指令相对应的指令资源信息的流程示意图;
图10为本发明实施例提供的一种汇编指令的资源分析装置的结构示意图。
为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。
除非另有定义,本文所使用的所有的技术和科学术语与属于本发明的技术领域的技术人员通常理解的含义相同。本文中在本发明的说明书中所使用的术语只是为了描述具体的实施例的目的,不是旨在于限制本发明。
下面结合附图,对本发明的一些实施方式作详细说明。在各实施例之间不冲突的情况下,下述的实施例及实施例中的特征可以相互组合。
图1为本发明实施例提供的一种汇编指令的资源分析方法的流程示意图;参考附图1所示,本实施例提供了一种汇编指令的资源分析方法,其中,该方法的执行主体可以为汇编指令的资源分析装置,可以理解的是,该资源分析装置可以实现为软件、或者软件和硬件的组合,该资源分析方法可以应用于代码编写系统或者代码优化系统,在上述的应用场景中,针对计算密度较高的指令编写操作,可以有效地提高汇编指令的撰写质量和效率。
具体的,该方法可以包括:
步骤S101:获取待分析的汇编信息,汇编信息中包括至少一个汇编指令。
步骤S102:确定与汇编信息相对应的可使用资源、以及与每个汇编指令相对应的指令类型。
步骤S103:基于可使用资源和指令类型,确定与汇编信息中每个汇编指令相对应的指令资源信息。
下面对上述各个步骤的具体实现过程和实现效果进行详细说明:
步骤S101:获取待分析的汇编信息,汇编信息中包括至少一个汇编指令。
其中,待分析的汇编信息可以是指需要进行资源分析的汇编指令集合,该汇编信息中可以包括至少一个汇编指令。
另外,本实施例中对于待分析的汇编信息的具体获取方式不做限定,一种可实现的方式为:汇编信息存储在预设区域中,通过访问预设区域即可获 取到待分析的汇编信息。或者,又一种可实现的方式为:资源分析装置上设置有用于供用户输入汇编指令的显示模块,该显示模块上可以显示有用于与用户进行交互的显示界面,而后通过实时检测用户针对显示界面所输入的信息来获取待分析的汇编信息。当然的,也可以采用其他的方式来获取待分析的汇编信息,只要能够保证对汇编信息进行获取的准确可靠性即可,在此不再赘述。
步骤S102:确定与汇编信息相对应的可使用资源、以及与每个汇编指令相对应的指令类型。
对于汇编信息而言,不同类型的芯片可以支持不同的汇编信息,而不同类型的芯片可以对应有不同的使用资源。因此,为了能够对汇编信息进行准确地资源分析操作,在获取到汇编信息之后,可以对汇编信息进行分析处理,以确定与汇编信息相对应的可使用资源,上述的可使用资源可以包括以下至少之一:可使用的寄存器个数、可使用寄存器的长度、可使用寄存器在使用时的起始位和终止位、可同时运行的寄存器。
具体的,本实施例对于可使用资源的具体确定方式不做限定,一种可实现的方式为,预先配置有不同类型的芯片与可使用资源之间的映射关系,在获取到汇编信息之后,可以确定与汇编信息相对应的芯片类型,基于芯片类型和上述的映射关系来确定与汇编信息相对应的可使用资源。
另外,本实施例对于与汇编指令相对应的指令类型的具体确定方式不做限定,一种可实现的方式为:预先配置有多个标准指令框架与标准指令类型之间的映射关系,在获取到汇编信息中所包括的汇编指令之后,可以确定与上述汇编指令相对应的标准指令框架,而后将标准指令框架所对应的标准指令类型确定为与汇编指令相对应的指令类型。或者,另一种可实现的方式为:在获取到汇编信息中所包括的汇编指令之后,可以获取与每个汇编指令相对应的汇编指令结构和关键字;基于汇编指令结构和关键字来确定与汇编信息相对应的指令类型。
当然的,也可以采用其他的方式来确定与汇编信息相对应的可使用资源、以及与每个汇编指令相对应的指令类型,只要能够保证对可使用资源和指令类型进行确定的准确可靠性即可中,在此不再赘述。
步骤S103:基于可使用资源和指令类型,确定与汇编信息中每个汇编指令相对应的指令资源信息。
在确定与汇编信息相对应的可使用资源、以及与每个汇编指令相对应的指令类型之后,可以对可使用资源和指令类型进行分析处理,以确定与汇编信息中每个汇编指令相对应的指令资源信息,该指令资源信息可以包括以下至少之一:寄存器个数、每个寄存器的长度、每个寄存器在使用时的起始位和终止位。其中,每个寄存器在使用时的起始位和终止位分别是指寄存器从哪个指令开始被占用,在哪条指令执行后可以被再次占用。
其中,本实施例对于确定与汇编信息中每个汇编指令相对应的指令资源信息的具体确定方式不做限定,一种可实现的方式为:根据录用规则,利用编译原理的控制流图分析当前需要被分析的汇编指令代码。进一步,根据录入的资源,分析汇编指令间的相关性。通过汇编指令间的相关性和已有的控制流图,判断每条汇编指令对资源的占用情况,从而得到每条汇编指令已占用和未占用的资源和未来要编写的汇编指令的可使用资源。对于已有程序,通过该方法能较好地读取汇编代码,方便程序员优化汇编。。当然的,也可以采用其他的方式来确定与汇编信息中每个汇编指令相对应的指令资源信息,只要能够保证对与汇编信息中每个汇编指令相对应的指令资源信息进行确定的准确可靠性即可中,在此不再赘述。
在一些实例中,在确定与汇编信息中每个汇编指令相对应的指令资源信息之后,本实施例中的方法还可以包括:对与每个汇编指令相对应的指令资源信息进行显示。
其中,在获取到与每个汇编指令相对应的指令资源信息之后,为了能够使得用户清楚地获知到汇编指令所对应的指令资源信息,则可以对与每个汇编指令相对应的指令资源信息进行显示。具体的,对与每个汇编指令相对应的指令资源信息进行显示可以包括:获取用于对指令资源信息进行显示的显示方式;基于显示方式,对与每个汇编指令相对应的指令资源信息进行显示,以使汇编指令与指令资源信息形成一汇编文件。
对于资源分析装置而言,预先设置有用于对指令资源信息进行显示的显示方式,该显示方式可以包括以下至少之一:将指令资源信息通过在汇编指令的预设位置处进行显示、将指令资源信息通过注释的方式进行显示、将指令资源信息通过突出显示的方式(例如:通过颜色、字体形状、字体大小)进行显示。
在获取到与每个汇编指令相对应的指令资源信息之后,则可以获取用于 对指令资源信息进行显示的显示方式,而后则可以通过所获取的显示方式对每个汇编指令相对应的指令资源信息进行显示。进一步的,在对汇编指令和指令资源信息进行显示时,可以使汇编指令与指令资源信息形成一个汇编文件,也可以在本实施方式的分析系统提供的界面中进行编写并进行实时显示。两种方法用户可以自己选择,从而方便用户对指令资源信息进行统一查看,进一步提高了该方法的实用性和灵活可靠性。
在一些实例中,上述的指令资源信息中可以包括位于芯片上的自定义资源,并可以支持对资源的向量化操作,这样不仅可以扩大该方法的使用范围,并且有利于提高该方法的实用性。
本实施例中提供的汇编指令的资源分析方法,通过获取待分析的汇编信息,而后确定与汇编信息相对应的可使用资源、以及与每个汇编指令相对应的指令类型,并基于可使用资源和指令类型来确定与汇编信息中每个汇编指令相对应的指令资源信息,从而有效地实现了对汇编指令的指令资源信息进行分析识别,获得与每个汇编指令相对应的指令资源信息,而后便于使得指令编写人员通过指令资源信息清楚地了解到汇编指令所占用的数据资源情况,有利于提高对汇编指令进行撰写的准确性和质量,进一步提高了该方法的实用性,有利于市场的推广与应用。
图2为本发明实施例提供的获取待分析的汇编信息的流程示意图;在上述实施例的基础上,继续参考附图2所示,为了能够保证对汇编信息进行分析识别的准确性,本实施例提供了对汇编信息进行获取的一种实现方式,具体的,本实施例中的获取待分析的汇编信息可以包括:
步骤S201:获取用于对汇编信息进行分析处理的信息汇编规范。
步骤S202:基于信息汇编规范,获取待分析的汇编信息。
对于汇编信息中的汇编指令而言,其主要由关键字以及关键字所对应的资源属性所组成,其中,主要关键字所对应的资源属性如下表所示:
| module | 当前指令属于哪个模块 |
| Instrcname | 当前指令指令名 |
| dst_list | 当前指令输出资源表(有序) |
| src_list | 当前指令输入资源表(有序) |
| dst_stlen_list | 当前指令每个寄存器内输入起始和长度(有序,单位bit) |
| src_stlen_list | 当前指令每个寄存器内输出起始和长度(有序,单位bit) |
| cfg_func | 当前指令是读写跳转还是运算 |
| dst_cycl_list | 当前指令每个输出寄存器需要多少个cycle后才有效 |
| end_sign | 一条指令结束,默认是换行符”\n” |
| cmt_signl | 指令中用于注释的标识符 |
其中,上述表格中的输入资源表/输出资源表可以包括片上存储单元,而片上存储单元可以包括向量存储单元和标量存储单元,可以理解的是,向量存储单元用于存储向量数据,标量存储单元用于存储标量数据。上述的“cfg_func”所对应的汇编指令,可以通过该条指令中所包括的具体关键字来确定当前指令所对应的具体功能,例如,在关键字为“jump”时,则可以将“cfg_func”所对应的汇编指令确定为跳转指令;在关键字为“rdwr”时,则可以将“cfg_func”所对应的汇编指令确定为读写指令;在关键字为“pocs”时,则可以将“cfg_func”所对应的汇编指令确定为运算指令。
基于上述的主要关键字所对应的资源属性,用户可以撰写能够实现相应功能的汇编指令,为了能够提高对汇编指令进行撰写的质量和效率,同时也保证汇编指令进行资源分析的质量和效率,可以预先配置有与汇编信息相对应的信息汇编规范,该信息汇编规范中包括在对汇编指令进行撰写时、汇编指令所需要满足的汇编撰写规则和要求。举例来说,该信息汇编规范可以包括:对于用于形成汇编信息的文本文档(例如:txt格式文档)而言,可以将文本文档中的每个属性信息以符号“<”和“>”进行标注,属性信息等价可以用符号“|”进行分隔,标量寄存器可以用“sr”进行标识,向量寄存器可以用“vr”进行标识,立即数可以用“im”进行标识等等。
另外,为了能够准确地获取到信息汇编规则,在对信息汇编规则配置完毕之后,可以将所配置的信息汇编规范存储在预设区域中,因此,通过访问预设区域可以获取到用于对汇编信息进行分析处理的信息汇编规范。在获取到信息汇编规范之后,可以基于信息汇编规范来获取待分析的汇编信息,从而有效地实现了在针对各种类型的芯片撰写汇编信息时,均可以获取到满足信息汇编规范、且能够通过资源分析装置进行准确分析处理的汇编信息,从而有效地保证了对汇编信息进行获取的准确可靠性。
在另一些实例中,为了能够提高资源分析装置的兼容性,在获取待分析的汇编信息时,上述的输入资源和输出资源的长度可以以bit为单位,并且长度无上限(例如:长度可以为2
64bit)。另外,为了能够保证对汇编信息进行 编写的质量和准确率,可以获取每个汇编指令所占用的运行时间,具体的,可以通过一个抽象单位时间(cycle)来确定汇编指令所占用的运行时间,上述的抽象单位时间可以理解为资源分析装置中的所有汇编指令所对于应的最小的指令运行单位时间。
在信息汇编规范为“模块+名字+输出+输入+输出长度+输入长度+功能+延迟”时,则可以基于上述的信息汇编规范准确地获取待分析的汇编信息。举例来说,某个平台的一条向量加法可以为:
<xxx><vadd><sr|vr|us><sr|vr|us|im,sr|vr|us|ime><256><256|64,128><pocs><3>。
其中,“xxx”对应于模块属性,“vadd”对应于名字属性,“sr|vr|us”对应于输出属性,“sr|vr|us|im和sr|vr|us|ime”对应于输入属性,“256”对应于输出长度属性,“256|64,128”对应于输入长度属性,“pocs”对应于功能属性,“3”对应于延迟属性。
再例如,movidus平台的一条加法汇编指令可以为:
<vau><add><vr><vr,vr><128><128,128><pocs><3>。
其中,“vau”对应于模块属性,“add”对应于名字属性,“vr”对应于输出属性,“vr,vr”对应于输入属性,“128”对应于输出长度属性,“128,128”对应于输入长度属性,“pocs”对应于功能属性,“3”对应于延迟属性;这样可以准确地获取到满足数值生效的汇编信息,从而有效地保证了对汇编信息进行获取的准确可靠性。
图3为本发明实施例提供的确定与汇编信息相对应的可使用资源的流程示意图;在上述实施例的基础上,继续参考附图3所示,本实施例中的确定与汇编信息相对应的可使用资源可以包括:
步骤S301:获取与汇编信息相对应的芯片特征信息。
步骤S302:基于芯片特征信息,确定与汇编信息相对应的可使用资源。
其中,由于不同类型的芯片可以支持不同的汇编信息,而不同类型的芯片可以对应有不同的可使用资源,因此,为了能够保证对于汇编信息相对应的可使用资源进行确定的准确可靠性,在获取到汇编信息之后,可以对汇编信息进行分析处理,以确定与汇编信息相对应的芯片特征信息,该芯片特征信息可以包括以下至少之一:芯片类型、芯片架构。
具体的,在指令编写人员针对某一芯片撰写汇编信息时,可以先确定芯 片所对应的芯片特征信息,该芯片特征信息可以存储在预设区域中,之后,在进行汇编信息的撰写操作时,可以通过访问预设区域获取与汇编信息相对应的芯片特征信息,以便基于芯片特征信息来进行汇编信息的撰写操作。
在获取到芯片特征信息之后,可以利用预先配置的芯片特征信息与可使用资源之间的映射关系来确定与汇编信息相对应的可使用资源,从而有效地保证了对可使用资源进行确定的准确可靠性,进一步提高了基于可使用资源对汇编信息中汇编指令进行资源分析的质量和效率。
图4为本发明实施例提供的确定与每个汇编指令相对应的指令类型的流程示意图;在上述实施例的基础上,继续参考附图4所示,本实施例提供了一种对指令类型进行确定的准确可靠性,具体的,本实施例中的确定与每个汇编指令相对应的指令类型可以包括:
步骤S401:获取与每个汇编指令相对应的指令类型标识。
步骤S402:基于指令类型标识,确定与汇编指令相对应的指令类型。
其中,在获取到汇编信息之后,可以对汇编信息中的每个汇编指令进行分析处理,以获取与每个汇编指令相对应的指令类型标识,在一些实例中,与汇编指令相对应的指令类型可以包括以下任意之一:存储类指令、跳转类指令、运算处理指令。具体的,存储类指令用于实现对数据的存储操作,即针对有任何存储(例如:写入到预设存储器)功能的指令均可以标记为存储类指令;跳转类指令用于实现功能跳转操作,即针对有任何跳转功能的指令标记为跳转类指令;而后针对汇编指令,将不是以上两个功能类型的指令标记为运算处理指令。
在获取到指令类型标识之后,可以基于指令类型标识来确定与汇编指令相对应的指令类型,具体的,预先存储有不同的标准指令类型与标准类型标识之前的映射关系,在获取到指令类型标识之后,可以将指令类型标识与标准类型标识进行分析匹配,而后确定与汇编指令相对应的目标标准类型标识,并将目标标准类型标识所对应的标准指令类型确定为与汇编指令相对应的指令类型。当然的,也可以采用其他的方式来实现基于指令类型标识确定与汇编指令相对应的指令类型,只要能够保证对与汇编指令相对应的指令类型进行确定的准确可靠性。
图5为本发明一实施例提供的基于可使用资源和指令类型,确定与汇编信息中每个汇编指令相对应的指令资源信息的流程示意图;在上述实施例的基 础上,继续参考附图5所示,本实施例提供了一种确定指令资源信息的实现方式,具体的,本实施例中的基于可使用资源和指令类型,确定与汇编信息中每个汇编指令相对应的指令资源信息可以包括:
步骤S501:根据指令类型确定与汇编指令相对应的资源限制信息。
步骤S502:基于可使用资源和资源限制信息,确定与汇编信息中每个汇编指令相对应的指令资源信息。
其中,在获取到指令类型之后,可以对指令类型进行分析处理,以确定与汇编指令相对应的资源限制信息,该资源限制信息可以包括资源上限信息、资源下限信息等等,可以理解的是,不同指令类型可以对应有不同的资源限制信息。
在获取到可使用资源和资源限制信息之后,即可基于可使用资源和资源限制信息来确定与汇编信息中每个汇编指令相对应的指令资源信息,简单来说,可使用资源是汇编信息所对应的芯片可支持的所有资源信息,资源限制信息为每条汇编指令运行时需要满足的资源限制信息,可以理解的是,可使用资源所对应的范围大于资源限制信息所对应的范围,且资源限制信息所对应的资源范围是可使用资源所对应的资源范围中的一部分。
举例来说,汇编信息所对应的可使用资源(例如:寄存器个数)为100,在对汇编信息进行分析处理时,可以获取到位于汇编信息中的一条汇编指令所对应的资源限制信息(例如:寄存器个数)为2至10,即上述汇编指令所对应的资源最小限制信息为2,资源最大限制信息为10。而后可以基于具体的应用场景和应用需求,基于可使用资源和资源限制信息来确定与汇编信息中每个汇编指令相对应的指令资源信息,具体的,可以将每个汇编指令所对应的指令资源信息确定为资源限制信息所对应的资源范围中的任意一个资源信息,另外,汇编信息中所有的汇编指令所对应的指令资源信息的资源总和要小于可使用资源所对应的资源范围,以保证对汇编指令进行准确地资源分析操作。
本实施例中,根据指令类型确定与汇编指令相对应的资源限制信息,而后基于可使用资源和资源限制信息,确定与汇编信息中每个汇编指令相对应的指令资源信息,这样不仅保证了对指令资源信息进行确定的准确可靠性,并还保证了指令资源信息可以得到对应芯片的支持,进一步提高了对汇编指令进行资源分析的质量和效率。
图6为本发明另一实施例提供的基于可使用资源和指令类型,确定与汇编 信息中每个汇编指令相对应的指令资源信息的流程示意图;在上述实施例的基础上,继续参考附图6所示,本实施例提供了另一种确定指令资源信息的实现方式,具体的,本实施例中的基于可使用资源和指令类型,确定与汇编信息中每个汇编指令相对应的指令资源信息可以包括:
步骤S601:获取与汇编信息中每个汇编指令相对应的关联关系。
其中,对汇编信息中的任意一条汇编指令而言,该汇编指令可以与其他汇编指令之间存在关联关系,该关联关系可以包括输入输出关系。为了能够准确地识别出与每个汇编指令相对应的指令资源信息,在获取到汇编信息之后,可以对与汇编信息中每个汇编指令进行分析处理,以获取与每个汇编指令相对应的关联关系。
具体的,在获取到汇编信息之后,可以将汇编信息输入至资源分析装置中,该资源分析装置可以基于预设的数据处理规则来识别当前汇编信息中的资源依赖情况以及使用情况。在一些实例中,参考附图7所示,本实施例中的获取与汇编信息中每个汇编指令相对应的关联关系可以包括:
步骤S6011:获取与汇编信息相对应的控制流图,控制流图中包括与每个汇编指令相对应的指令节点。
步骤S6012:识别与控制流图中每个指令节点相对应的输入输出关系。
步骤S6013:将与控制流图中每个指令节点相对应的输入输出关系,确定为与汇编信息中每个汇编指令相对应的关联关系。
在获取到汇编信息之后,可以统计汇编信息中所包括的多个汇编指令、多个汇编指令所对应的撰写顺序以及每个汇编指令所对应的输入参数和输出参数,而后将每个汇编指令作为一个指令节点,基于上述多个汇编指令所对应的撰写顺序、每个汇编指令所对应的输入参数和输出参数来获得与汇编信息相对应的控制流图。在获取到控制流图之后,可以对控制流图中的每个指令节点进行分析识别,从而可以获取到与每个指令节点相对应的输入输出关系,而后可以将与每个指令节点所对应的输入输出关系确定为与汇编信息中每个汇编指令相对应的关联关系,这样有效地提高了对与汇编信息中每个汇编指令相对应的关联关系进行获取的准确可靠性。
步骤S602:基于关联关系、可使用资源和指令类型,确定与汇编信息中每个汇编指令相对应的指令资源信息。
在获取到关联关系、可使用资源和指令类型之后,可以对上述的关联关 系、可使用资源和指令类型进行分析处理,以确定与汇编信息中每个汇编指令相对应的指令资源信息。
在一些实例中,参考附图8所示,基于关联关系、可使用资源和指令类型,确定与汇编信息中每个汇编指令相对应的指令资源信息可以包括:
步骤S6021:根据关联关系和指令类型,确定任意两个汇编指令中所包括的复用寄存器资源。
步骤S6022:基于可使用资源、指令类型和复用寄存器资源,确定与汇编指令相对应的指令资源信息,指令资源信息中包括复用寄存器资源。
其中,对于汇编信息中存在关联关系的任意两个汇编指令而言,两个汇编指令所对应的指令资源信息可以相互独立或者存在复用的数据资源。因此,为了能够准确地识别出与每个汇编指令相对应的指令资源信息,在获取到关联关系和指令类型之后,则可以基于关联关系和指令类型对汇编指令所对应的寄存器资源进行分析处理,以确定任意两个汇编指令中所包括的复用寄存器资源。
举例来说,汇编信息中包括汇编指令a和汇编指令b,汇编指令a的指令类型可以为存储类指令,汇编指令a用于实现将寄存器b3内的资源存储至寄存器a1中;汇编指令b的指令类型为运算处理指令(例如:求和运算指令),汇编指令b用于对寄存器b1内的资源与寄存器b2内的资源之间进行求和,获得寄存器b3内的资源。由上述陈述内容可知,汇编指令b与汇编指令a之间的关联关系为汇编指令b的输出信息为汇编指令a的输入信息,通过上述汇编指令a和汇编指令b之间的关联关系和指令类型,即可确定汇编指令a和汇编指令b所包括的复用寄存器资源(寄存器b3)。
以arm指令作为汇编信息中的汇编指令为例进行说明,现有以下两条arm指令,指令一为:Vadd q1,q2,q3;指令二为:Vsub q5,q1,q4。
其中,arm指令一是求和运算指令,q1对应于目标寄存器,q2和q3对应于输入寄存器。arm指令二是减法运算指令,q5对应于目标寄存器,q1和q4对应于输入寄存器。通过对上述两条arm指令所对应的寄存器资源进行比较可知,arm指令二的输入寄存器依赖于arm指令一的目标寄存器,因此,arm指令一与arm指令二之间存在关联关系,且存在复用寄存器资源q1。
在获取到复用寄存器资源之后,则可以对可使用资源、指令类型和复用寄存器资源进行分析处理,以确定与汇编指令相对应的指令资源信息,此时, 与指令信息相对应的指令资源信息中可以包括复用的寄存器资源,从而有效地保证了对与汇编信息中每个汇编指令相对应的指令资源信息进行确定的质量和效率。
在一些实例中,在确定任意两个汇编指令中所包括的复用寄存器资源之后,本实施例中的方法还可以包括:基于复用寄存器资源,生成与汇编指令相对应的第一提示信息。
在对汇编指令进行撰写时,为了方便不同的数据处理平台对汇编信息进行识别,同时提高对汇编信息进行撰写的准确可靠性,在确定任意两个汇编指令中所包括的复用寄存器资源之后,则可以基于复用寄存器资源来生成与汇编指令相对应的第一提示信息。并且,为了能够使得用户及时了解到汇编指令中所包括的复用寄存器资源的情况,可以对第一提示信息进行显示,具体的,可以在汇编指令的上端、下端、侧端或者以批注/注释的方式对与汇编指令相对应的第一提示信息进行显示,从而使得用户通过所显示的第一提示信息及时获取到存在复用寄存器资源的汇编指令信息,这样有利于提高对汇编信息进行撰写的准确可靠性。
在另一些实例中,参考附图9所示,基于关联关系、可使用资源和指令类型,确定与汇编信息中每个汇编指令相对应的指令资源信息可以包括:
步骤S6023:根据关联关系和指令类型,确定汇编指令中所释放的寄存器资源。
步骤S6024:基于可使用资源、指令类型和释放的寄存器资源,确定与汇编指令相对应的指令资源信息,指令资源信息中包括释放的寄存器资源。
其中,对于汇编信息中的每个汇编指令而言,在汇编信息中的汇编指令运行完毕之后,可以释放汇编指令所对应的指令资源信息中的部分资源或者全部资源,而所释放的资源信息可以供其他汇编指令进行使用。此时,为了能够保证汇编指令进行撰写的质量,同时提高对所释放的资源信息进行使用的利用率,则可以根据关联关系和指令类型来确定汇编指令中所释放的寄存器资源。
举例来说,汇编信息中包括汇编指令A和汇编指令B,汇编指令A和汇编指令B的指令类型可以均为运算处理指令(例如:求和运算指令),具体的,汇编指令A用于实现寄存器A1内的资源与寄存器B1内的资源之间进行求和,获得寄存器C1内的资源;汇编指令B用于实现寄存器A2内的资源与寄存器B2内的资 源之间进行求和,获得寄存器C2内的资源。
在上述汇编指令A与汇编指令B之间的运行时间间隔较长时,例如:汇编指令A先于汇编指令B进行运行,那么,在汇编指令B进行运行时,汇编指令A所对应的寄存器资源可以在上述的运行时间间隔之后进行释放,此时则可以获取到汇编指令A所释放的寄存器资源。
在获取到释放的寄存器资源之后,则可以对可使用资源、指令类型和释放的寄存器资源进行分析处理,以确定与汇编指令相对应的指令资源信息,此时的指令资源信息中可以包括释放的寄存器资源,从而有效地保证了对与汇编信息中每个汇编指令相对应的指令资源信息进行确定的质量和效率。
在一些实例中,在确定汇编指令中所释放的寄存器资源之后,方法还包括:基于释放的寄存器资源,生成与汇编指令相对应的第二提示信息。
在对汇编指令进行撰写时,为了能够提高对汇编信息进行撰写的准确可靠性,同时提高数据资源的利用率,可以在确定汇编指令所释放的寄存器资源之后,基于释放的寄存器资源生成与汇编指令相对应的第二提示信息,为了能够使得用户及时了解到汇编指令中所释放的寄存器资源,可以对第二提示信息进行显示。具体的,可以在汇编指令的上端、下端、侧端或者以批注/注释的方式对第二提示信息进行显示,从而实现了用户通过所显示的第二提示信息及时获取到汇编指令所释放的寄存器资源,这样有利于提高对汇编信息进行撰写的准确可靠性,同时保证了资源的高利用率。
在一些实例中,在确定与汇编信息相对应的可使用资源、以及与每个汇编指令相对应的指令类型之后,本实施例中的方法还可以包括:基于可使用资源和指令类型,确定与汇编信息相对应的未使用资源信息。
其中,为了保证数据资源的高利用率,在确定与汇编信息相对应的可使用资源以及与每个汇编指令相对应的指令类型之后,可以基于可使用资源和指令类型来确定与汇编信息相对应的未使用资源。具体的,可以基于每个汇编指令相对应的指令类型来统计汇编信息中所有汇编指令所对应的指令资源信息集合,后可以基于可使用资源和指令资源信息集合来确定与汇编信息相对应的未使用资源,该未使用资源可以为可使用资源与指令资源信息集合的差值。
当然的,也可以采用其他的方式来确定与汇编信息相对应的未使用资源信息,只要能够保证对与汇编信息相对应的未使用资源信息进行确定的准确 可靠性即可,在此不再赘述。
在一些实例中,在确定与汇编信息相对应的未使用资源信息之后,本实施例中的方法还可以包括:基于未使用资源信息,生成与汇编信息相对应的第三提示信息。
在对汇编指令进行撰写时,为了能够提高数据资源的利用率,在确定与汇编信息相对应的未使用资源信息之后,则可以基于未使用资源信息,生成与汇编信息相对应的第三提示信息。为了能够使得用户及时了解到与汇编信息相对应的未使用资源信息,可以对第三提示信息进行显示,并且可以在汇编指令的上端、下端、侧端或者以批注/注释的方式对第三提示信息进行显示,从而使得用户可以通过所显示的第三提示信息及时获取到汇编信息相对应的未使用资源信息,这样有利于提高数据资源的利用率,进一步提高了该方法使用的准确可靠性。
在另一些实例中,在确定与汇编信息中每个汇编指令相对应的指令资源信息之后,本实施例中的方法还可以包括:获取未存在关联关系的汇编指令,对不存在关联关系的汇编指令进行标记,从而可以有效地避免汇编信息进行撰写时所存在的错误率,同时便于提高对汇编信息进行撰写的准确性,进一步提高了汇编信息的开发效率。
图10为本发明实施例提供的一种汇编指令的资源分析装置的结构示意图;参考附图10所示,本实施例提供了一种汇编指令的资源分析装置,该汇编指令的资源分析装置可以用于执行上述图1所对应的汇编指令的资源分析方法。具体实现时,该资源分析装置可以是具有汇编指令分析能力的电子设备,如电脑、服务器、云端服务器、电子终端等设备,也可以是具有汇编指令分析能力的计算机芯片或者集成电路,例如中央处理单元(Central Processing Unit,CPU)、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)或者现成可编程门阵列(Field-Programmable Gate Array,FPGA)等。
具体的,该汇编指令的资源分析装置可以包括:
存储器12,用于存储计算机程序;
处理器11,用于运行存储器12中存储的计算机程序以实现:
获取待分析的汇编信息,汇编信息中包括至少一个汇编指令;
确定与汇编信息相对应的可使用资源、以及与每个汇编指令相对应的指 令类型;
基于可使用资源和指令类型,确定与汇编信息中每个汇编指令相对应的指令资源信息。
此外,汇编指令的资源分析装置的结构中还可以包括通信接口13,用于实现汇编指令的资源分析装置与其他设备或通信网络通信。
在一些实例中,可使用资源包括以下至少之一:可使用的寄存器个数、可使用寄存器的长度、可使用寄存器在使用时的起始位和终止位、可同时运行的寄存器。
在一些实例中,指令资源信息包括以下至少之一:寄存器个数、每个寄存器的长度、每个寄存器在使用时的起始位和终止位。
在一些实例中,在获取待分析的汇编信息时,处理器11用于:获取用于对汇编信息进行分析处理的信息汇编规范;基于信息汇编规范,获取待分析的汇编信息。
在一些实例中,在确定与汇编信息相对应的可使用资源时,处理器11用于:获取与汇编信息相对应的芯片特征信息;基于芯片特征信息,确定与汇编信息相对应的可使用资源。
在一些实例中,芯片特征信息包括以下至少之一:芯片类型、芯片架构。
在一些实例中,在确定与每个汇编指令相对应的指令类型时,处理器11用于:获取与每个汇编指令相对应的指令类型标识;基于指令类型标识,确定与汇编指令相对应的指令类型。
在一些实例中,与汇编指令相对应的指令类型包括以下任意之一:存储类指令、跳转类指令、运算处理指令。
在一些实例中,在基于可使用资源和指令类型,确定与汇编信息中每个汇编指令相对应的指令资源信息时,处理器11用于:根据指令类型确定与汇编指令相对应的资源限制信息;基于可使用资源和资源限制信息,确定与汇编信息中每个汇编指令相对应的指令资源信息。
在一些实例中,在基于可使用资源和指令类型,确定与汇编信息中每个汇编指令相对应的指令资源信息时,处理器11用于:获取与汇编信息中每个汇编指令相对应的关联关系;基于关联关系、可使用资源和指令类型,确定与汇编信息中每个汇编指令相对应的指令资源信息。
在一些实例中,在获取与汇编信息中每个汇编指令相对应的关联关系时, 处理器11用于:获取与汇编信息相对应的控制流图,控制流图中包括与每个汇编指令相对应的指令节点;识别与控制流图中每个指令节点相对应的输入输出关系;将与控制流图中每个指令节点相对应的输入输出关系,确定为与汇编信息中每个汇编指令相对应的关联关系。
在一些实例中,在基于关联关系、可使用资源和指令类型,确定与汇编信息中每个汇编指令相对应的指令资源信息时,处理器11用于:根据关联关系和指令类型,确定任意两个汇编指令中所包括的复用寄存器资源;基于可使用资源、指令类型和复用寄存器资源,确定与汇编指令相对应的指令资源信息,指令资源信息中包括复用寄存器资源。
在一些实例中,在确定任意两个汇编指令中所包括的复用寄存器资源之后,处理器11用于:基于复用寄存器资源,生成与汇编指令相对应的第一提示信息。
在一些实例中,在基于关联关系、可使用资源和指令类型,确定与汇编信息中每个汇编指令相对应的指令资源信息时,处理器11用于:根据关联关系和指令类型,确定汇编指令中所释放的寄存器资源;基于可使用资源、指令类型和释放的寄存器资源,确定与汇编指令相对应的指令资源信息,指令资源信息中包括释放的寄存器资源。
在一些实例中,在确定汇编指令中所释放的寄存器资源之后,处理器11用于:基于释放的寄存器资源,生成与汇编指令相对应的第二提示信息。
在一些实例中,在确定与汇编信息相对应的可使用资源、以及与每个汇编指令相对应的指令类型之后,处理器11用于:基于可使用资源和指令类型,确定与汇编信息相对应的未使用资源信息。
在一些实例中,在确定与汇编信息相对应的未使用资源信息之后,处理器11用于:基于未使用资源信息,生成与汇编信息相对应的第三提示信息。
在一些实例中,在确定与汇编信息中每个汇编指令相对应的指令资源信息之后,处理器11用于:对与每个汇编指令相对应的指令资源信息进行显示。
在一些实例中,在对与每个汇编指令相对应的指令资源信息进行显示时,处理器11用于:获取用于对指令资源信息进行显示的显示方式;基于显示方式,对与每个汇编指令相对应的指令资源信息进行显示,以使汇编指令与指令资源信息形成一汇编文件。
图10所示汇编指令的资源分析装置可以执行图1-图9所示实施例的方法, 本实施例未详细描述的部分,可参考对图1-图9所示实施例的相关说明。该技术方案的执行过程和技术效果参见图1-图9所示实施例中的描述,在此不再赘述。
另外,本发明实施例提供了一种存储介质,该存储介质为计算机可读存储介质,该计算机可读存储介质中存储有程序指令,程序指令用于实现上述图1-图9所示实施例中的汇编指令的资源分析方法。
以上各个实施例中的技术方案、技术特征在与本相冲突的情况下均可以单独,或者进行组合,只要未超出本领域技术人员的认知范围,均属于本发明保护范围内的等同实施例。
在本发明所提供的几个实施例中,应该理解到,所揭露的汇编指令的资源分析装置和方法,可以通过其它的方式实现。例如,以上所描述的汇编指令的资源分析装置实施例仅仅是示意性的,例如,所述模块或单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,遥控装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。
另外,在本发明各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。
所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得计算机处理器(processor)执行本发明 各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(Read_Only Memory,ROM)、随机存取存储器(Random Access Memory,RAM)、磁盘或者光盘等各种可以存储程序代码的介质。
以上所述仅为本发明的实施例,并非因此限制本发明的专利范围,凡是利用本发明说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本发明的专利保护范围内。
最后应说明的是:以上各实施例仅用以说明本发明的技术方案,而非对其限制;尽管参照前述各实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分或者全部技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例技术方案的范围。
Claims (39)
- 一种汇编指令的资源分析方法,其特征在于,包括:获取待分析的汇编信息,所述汇编信息中包括至少一个汇编指令;确定与所述汇编信息相对应的可使用资源、以及与每个汇编指令相对应的指令类型;基于所述可使用资源和指令类型,确定与所述汇编信息中每个汇编指令相对应的指令资源信息。
- 根据权利要求1所述的方法,其特征在于,所述可使用资源包括以下至少之一:可使用的寄存器个数、可使用寄存器的长度、可使用寄存器在使用时的起始位和终止位、可同时运行的寄存器。
- 根据权利要求1所述的方法,其特征在于,所述指令资源信息包括以下至少之一:寄存器个数、每个寄存器的长度、每个寄存器在使用时的起始位和终止位。
- 根据权利要求1所述的方法,其特征在于,获取待分析的汇编信息,包括:获取用于对所述汇编信息进行分析处理的信息汇编规范;基于所述信息汇编规范,获取待分析的汇编信息。
- 根据权利要求1所述的方法,其特征在于,确定与所述汇编信息相对应的可使用资源,包括:获取与所述汇编信息相对应的芯片特征信息;基于所述芯片特征信息,确定与所述汇编信息相对应的可使用资源。
- 根据权利要求5所述的方法,其特征在于,所述芯片特征信息包括以下至少之一:芯片类型、芯片架构。
- 根据权利要求1所述的方法,其特征在于,确定与每个汇编指令相对应的指令类型,包括:获取与每个汇编指令相对应的指令类型标识;基于所述指令类型标识,确定与所述汇编指令相对应的指令类型。
- 根据权利要求7所述的方法,其特征在于,与所述汇编指令相对应的指令类型包括以下任意之一:存储类指令、跳转类指令、运算处理指令。
- 根据权利要求1所述的方法,其特征在于,基于所述可使用资源和指令类型,确定与所述汇编信息中每个汇编指令相对应的指令资源信息,包括:根据所述指令类型确定与所述汇编指令相对应的资源限制信息;基于所述可使用资源和资源限制信息,确定与所述汇编信息中每个汇编指令相对应的指令资源信息。
- 根据权利要求1所述的方法,其特征在于,基于所述可使用资源和指令类型,确定与所述汇编信息中每个汇编指令相对应的指令资源信息,包括:获取与所述汇编信息中每个汇编指令相对应的关联关系;基于所述关联关系、可使用资源和指令类型,确定与所述汇编信息中每个汇编指令相对应的指令资源信息。
- 根据权利要求10所述的方法,其特征在于,获取与所述汇编信息中每个汇编指令相对应的关联关系,包括:获取与所述汇编信息相对应的控制流图,所述控制流图中包括与每个汇编指令相对应的指令节点;识别与所述控制流图中每个指令节点相对应的输入输出关系;将与所述控制流图中每个指令节点相对应的输入输出关系,确定为与所述汇编信息中每个汇编指令相对应的关联关系。
- 根据权利要求10所述的方法,其特征在于,基于所述关联关系、可使用资源和指令类型,确定与所述汇编信息中每个汇编指令相对应的指令资源信息,包括:根据所述关联关系和指令类型,确定任意两个所述汇编指令中所包括的复用寄存器资源;基于所述可使用资源、指令类型和复用寄存器资源,确定与所述汇编指令相对应的指令资源信息,所述指令资源信息中包括复用寄存器资源。
- 根据权利要求12所述的方法,其特征在于,在确定任意两个所述汇编指令中所包括的复用寄存器资源之后,所述方法还包括:基于所述复用寄存器资源,生成与所述汇编指令相对应的第一提示信息。
- 根据权利要求10所述的方法,其特征在于,基于所述关联关系、可使用资源和指令类型,确定与所述汇编信息中每个汇编指令相对应的指令资源信息,包括:根据所述关联关系和指令类型,确定所述汇编指令中所释放的寄存器资源;基于所述可使用资源、指令类型和释放的寄存器资源,确定与所述汇编 指令相对应的指令资源信息,所述指令资源信息中包括释放的寄存器资源。
- 根据权利要求14所述的方法,其特征在于,在确定所述汇编指令中所释放的寄存器资源之后,所述方法还包括:基于释放的寄存器资源,生成与所述汇编指令相对应的第二提示信息。
- 根据权利要求1-15中任意一项所述的方法,其特征在于,在确定与所述汇编信息相对应的可使用资源、以及与每个汇编指令相对应的指令类型之后,所述方法还包括:基于所述可使用资源和指令类型,确定与所述汇编信息相对应的未使用资源信息。
- 根据权利要求16所述的方法,其特征在于,在确定与所述汇编信息相对应的未使用资源信息之后,所述方法还包括:基于所述未使用资源信息,生成与所述汇编信息相对应的第三提示信息。
- 根据权利要求1-15中任意一项所述的方法,其特征在于,在确定与所述汇编信息中每个汇编指令相对应的指令资源信息之后,所述方法还包括:对与每个汇编指令相对应的指令资源信息进行显示。
- 根据权利要求18所述的方法,其特征在于,对与每个汇编指令相对应的指令资源信息进行显示,包括:获取用于对指令资源信息进行显示的显示方式;基于所述显示方式,对与每个汇编指令相对应的指令资源信息进行显示,以使所述汇编指令与所述指令资源信息形成一汇编文件。
- 一种汇编指令的资源分析装置,其特征在于,包括:存储器,用于存储计算机程序;处理器,用于运行所述存储器中存储的计算机程序以实现:获取待分析的汇编信息,所述汇编信息中包括至少一个汇编指令;确定与所述汇编信息相对应的可使用资源、以及与每个汇编指令相对应的指令类型;基于所述可使用资源和指令类型,确定与所述汇编信息中每个汇编指令相对应的指令资源信息。
- 根据权利要求20所述的装置,其特征在于,所述可使用资源包括以下至少之一:可使用的寄存器个数、可使用寄存器的长度、可使用寄存器在使用时的起始位和终止位、可同时运行的寄存器。
- 根据权利要求20所述的装置,其特征在于,所述指令资源信息包括以下至少之一:寄存器个数、每个寄存器的长度、每个寄存器在使用时的起始位和终止位。
- 根据权利要求20所述的装置,其特征在于,在获取待分析的汇编信息时,所述处理器用于:获取用于对所述汇编信息进行分析处理的信息汇编规范;基于所述信息汇编规范,获取待分析的汇编信息。
- 根据权利要求20所述的装置,其特征在于,在确定与所述汇编信息相对应的可使用资源时,所述处理器用于:获取与所述汇编信息相对应的芯片特征信息;基于所述芯片特征信息,确定与所述汇编信息相对应的可使用资源。
- 根据权利要求24所述的装置,其特征在于,所述芯片特征信息包括以下至少之一:芯片类型、芯片架构。
- 根据权利要求20所述的装置,其特征在于,在确定与每个汇编指令相对应的指令类型时,所述处理器用于:获取与每个汇编指令相对应的指令类型标识;基于所述指令类型标识,确定与所述汇编指令相对应的指令类型。
- 根据权利要求26所述的装置,其特征在于,与所述汇编指令相对应的指令类型包括以下任意之一:存储类指令、跳转类指令、运算处理指令。
- 根据权利要求20所述的装置,其特征在于,在基于所述可使用资源和指令类型,确定与所述汇编信息中每个汇编指令相对应的指令资源信息时,所述处理器用于:根据所述指令类型确定与所述汇编指令相对应的资源限制信息;基于所述可使用资源和资源限制信息,确定与所述汇编信息中每个汇编指令相对应的指令资源信息。
- 根据权利要求20所述的装置,其特征在于,在基于所述可使用资源和指令类型,确定与所述汇编信息中每个汇编指令相对应的指令资源信息时,所述处理器用于:获取与所述汇编信息中每个汇编指令相对应的关联关系;基于所述关联关系、可使用资源和指令类型,确定与所述汇编信息中每个汇编指令相对应的指令资源信息。
- 根据权利要求29所述的装置,其特征在于,在获取与所述汇编信息中每个汇编指令相对应的关联关系时,所述处理器用于:获取与所述汇编信息相对应的控制流图,所述控制流图中包括与每个汇编指令相对应的指令节点;识别与所述控制流图中每个指令节点相对应的输入输出关系;将与所述控制流图中每个指令节点相对应的输入输出关系,确定为与所述汇编信息中每个汇编指令相对应的关联关系。
- 根据权利要求29所述的装置,其特征在于,在基于所述关联关系、可使用资源和指令类型,确定与所述汇编信息中每个汇编指令相对应的指令资源信息时,所述处理器用于:根据所述关联关系和指令类型,确定任意两个所述汇编指令中所包括的复用寄存器资源;基于所述可使用资源、指令类型和复用寄存器资源,确定与所述汇编指令相对应的指令资源信息,所述指令资源信息中包括复用寄存器资源。
- 根据权利要求31所述的装置,其特征在于,在确定任意两个所述汇编指令中所包括的复用寄存器资源之后,所述处理器用于:基于所述复用寄存器资源,生成与所述汇编指令相对应的第一提示信息。
- 根据权利要求29所述的装置,其特征在于,在基于所述关联关系、可使用资源和指令类型,确定与所述汇编信息中每个汇编指令相对应的指令资源信息时,所述处理器用于:根据所述关联关系和指令类型,确定所述汇编指令中所释放的寄存器资源;基于所述可使用资源、指令类型和释放的寄存器资源,确定与所述汇编指令相对应的指令资源信息,所述指令资源信息中包括释放的寄存器资源。
- 根据权利要求33所述的装置,其特征在于,在确定所述汇编指令中所释放的寄存器资源之后,所述处理器用于:基于释放的寄存器资源,生成与所述汇编指令相对应的第二提示信息。
- 根据权利要求20-34中任意一项所述的装置,其特征在于,在确定与所述汇编信息相对应的可使用资源、以及与每个汇编指令相对应的指令类型之后,所述处理器用于:基于所述可使用资源和指令类型,确定与所述汇编信息相对应的未使用 资源信息。
- 根据权利要求35所述的装置,其特征在于,在确定与所述汇编信息相对应的未使用资源信息之后,所述处理器用于:基于所述未使用资源信息,生成与所述汇编信息相对应的第三提示信息。
- 根据权利要求20-34中任意一项所述的装置,其特征在于,在确定与所述汇编信息中每个汇编指令相对应的指令资源信息之后,所述处理器用于:对与每个汇编指令相对应的指令资源信息进行显示。
- 根据权利要求37所述的装置,其特征在于,在对与每个汇编指令相对应的指令资源信息进行显示时,所述处理器用于:获取用于对指令资源信息进行显示的显示方式;基于所述显示方式,对与每个汇编指令相对应的指令资源信息进行显示,以使所述汇编指令与所述指令资源信息形成一汇编文件。
- 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质中存储有程序指令,所述程序指令用于实现权利要求1-19中任意一项所述的汇编指令的资源分析方法。
Priority Applications (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202080007999.6A CN113302587A (zh) | 2020-10-09 | 2020-10-09 | 汇编指令的资源分析方法、装置和存储介质 |
| PCT/CN2020/119997 WO2022073197A1 (zh) | 2020-10-09 | 2020-10-09 | 汇编指令的资源分析方法、装置和存储介质 |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| PCT/CN2020/119997 WO2022073197A1 (zh) | 2020-10-09 | 2020-10-09 | 汇编指令的资源分析方法、装置和存储介质 |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2022073197A1 true WO2022073197A1 (zh) | 2022-04-14 |
Family
ID=77318793
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2020/119997 Ceased WO2022073197A1 (zh) | 2020-10-09 | 2020-10-09 | 汇编指令的资源分析方法、装置和存储介质 |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN113302587A (zh) |
| WO (1) | WO2022073197A1 (zh) |
Families Citing this family (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN119105799A (zh) * | 2023-06-08 | 2024-12-10 | 中兴通讯股份有限公司 | 代码分析方法、电子设备、计算机可读介质 |
Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN102693147A (zh) * | 2012-06-13 | 2012-09-26 | 上海第二工业大学 | 计算机汇编语言的辅助分析装置及分析方法 |
| CN103645930A (zh) * | 2013-12-18 | 2014-03-19 | 中国科学院声学研究所 | 汇编级跨文件调度框架的构建方法 |
| JP2015197821A (ja) * | 2014-04-01 | 2015-11-09 | 株式会社日立製作所 | アセンブリコード変換装置およびその変換方法 |
| CN109491918A (zh) * | 2018-11-22 | 2019-03-19 | 中国人民解放军战略支援部队信息工程大学 | 一种汇编冗余指令的检测方法及装置 |
-
2020
- 2020-10-09 CN CN202080007999.6A patent/CN113302587A/zh active Pending
- 2020-10-09 WO PCT/CN2020/119997 patent/WO2022073197A1/zh not_active Ceased
Patent Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN102693147A (zh) * | 2012-06-13 | 2012-09-26 | 上海第二工业大学 | 计算机汇编语言的辅助分析装置及分析方法 |
| CN103645930A (zh) * | 2013-12-18 | 2014-03-19 | 中国科学院声学研究所 | 汇编级跨文件调度框架的构建方法 |
| JP2015197821A (ja) * | 2014-04-01 | 2015-11-09 | 株式会社日立製作所 | アセンブリコード変換装置およびその変換方法 |
| CN109491918A (zh) * | 2018-11-22 | 2019-03-19 | 中国人民解放军战略支援部队信息工程大学 | 一种汇编冗余指令的检测方法及装置 |
Also Published As
| Publication number | Publication date |
|---|---|
| CN113302587A (zh) | 2021-08-24 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN111428462B (zh) | 通讯协议模板构建的方法及终端设备 | |
| CN107274186A (zh) | 在区块链中获得智能合约接口的方法和设备 | |
| CN102541521B (zh) | 基于结构化查询语言的操作指令自动生成装置及方法 | |
| CN110688111A (zh) | 业务流程的配置方法、装置、服务器和存储介质 | |
| JP2014081922A (ja) | ライセンス調整のための方法、システム、プログラム、および記録媒体 | |
| CN110955409B (zh) | 在云平台上创建资源的方法和装置 | |
| CN113626102A (zh) | 一种数据处理方法、装置、电子设备及存储介质 | |
| CN109815141B (zh) | 一种测试方法和装置 | |
| CN111767217A (zh) | Js单元测试案例生成方法及装置 | |
| CN116028062A (zh) | 目标代码的生成方法、npu指令的显示方法及装置 | |
| WO2024152665A1 (zh) | 代码构建方法、装置、计算机设备及存储介质 | |
| CN115794641A (zh) | 基于业务流程的造数方法、装置、设备及存储介质 | |
| CN110737431A (zh) | 软件开发方法、开发平台、终端设备及存储介质 | |
| US9064042B2 (en) | Instrumenting computer program code by merging template and target code methods | |
| CN114546384A (zh) | 页面展示系统、方法、可读存储介质及电子设备 | |
| CN111444161B (zh) | 数据处理方法、装置、电子设备及存储介质 | |
| CN113302587A (zh) | 汇编指令的资源分析方法、装置和存储介质 | |
| CN114048415A (zh) | 表单生成方法及装置、电子设备和计算机可读存储介质 | |
| CN110825438B (zh) | 用于模拟人工智能芯片的数据处理的方法和装置 | |
| CN117912623A (zh) | 基于领域描述语言推理的专病库数据要素提取方法及系统 | |
| CN118012938A (zh) | 一种数据处理方法、装置及电子设备、存储介质 | |
| CN116028427A (zh) | 参数的配置系统、方法及存储介质 | |
| CN110489121B (zh) | 一种皮肤包文件的生成方法及系统 | |
| CN115328494A (zh) | 代码生成方法、装置、设备及介质 | |
| CN115098075A (zh) | 一种多系统集成方法、装置、电子设备及介质 |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 20956512 Country of ref document: EP Kind code of ref document: A1 |
|
| NENP | Non-entry into the national phase |
Ref country code: DE |
|
| 122 | Ep: pct application non-entry in european phase |
Ref document number: 20956512 Country of ref document: EP Kind code of ref document: A1 |