WO2015096425A1 - Method and apparatus for preventing register conflict - Google Patents

Method and apparatus for preventing register conflict Download PDF

Info

Publication number
WO2015096425A1
WO2015096425A1 PCT/CN2014/080553 CN2014080553W WO2015096425A1 WO 2015096425 A1 WO2015096425 A1 WO 2015096425A1 CN 2014080553 W CN2014080553 W CN 2014080553W WO 2015096425 A1 WO2015096425 A1 WO 2015096425A1
Authority
WO
WIPO (PCT)
Prior art keywords
register
variable
life cycle
program
module
Prior art date
Application number
PCT/CN2014/080553
Other languages
French (fr)
Chinese (zh)
Inventor
姜海明
王治春
Original Assignee
中兴通讯股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Publication of WO2015096425A1 publication Critical patent/WO2015096425A1/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/38Concurrent instruction execution, e.g. pipeline or look ahead
    • G06F9/3824Operand accessing
    • G06F9/383Operand prefetching
    • G06F9/3832Value prediction for operands; operand history buffers
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/38Concurrent instruction execution, e.g. pipeline or look ahead
    • G06F9/3836Instruction issuing, e.g. dynamic instruction scheduling or out of order instruction execution

Definitions

  • the present invention relates to the field of computers, and in particular, to a method and apparatus for avoiding register conflicts. Background technique
  • embodiments of the present invention provide a method and apparatus for avoiding register conflicts.
  • An embodiment of the present invention provides a method for avoiding a register conflict, including: acquiring a life cycle of each variable in a register; detecting whether a life cycle of each variable in the register overlaps, and performing an alarm when the detection result is yes.
  • the step of obtaining the life cycle of each variable of the program in the register comprises: parsing the program with a regular expression to obtain a life cycle of each variable in the register.
  • the step of parsing a program by using a regular expression to obtain a life cycle of each variable in the register includes: parsing a program variable definition portion by using a regular expression, and acquiring each variable of the program and its register Definition; Use the regular expression to parse the program instruction line to obtain the life cycle of each variable; According to the variables of the program and its register definition, the life cycle of each variable in each register is counted.
  • the step of performing an alarm comprises: prompting an error by using a script to implement an alarm.
  • the method further comprises: outputting a life cycle of each variable in the register to the text file when the life cycles of the variables in the register do not overlap.
  • the embodiment of the invention further provides an apparatus for avoiding register conflict, comprising: an obtaining module, a detecting module and an alarm module; the obtaining module is configured to obtain a life cycle of each variable of the program in the register; and the detecting module is configured to detect the Whether the life cycle of each variable in the register overlaps, and sends a notification to the alarm module when the detection result is yes; the alarm module is configured to perform an alarm after receiving the notification sent by the detection module.
  • the obtaining module further includes a parsing module, wherein the parsing module parses the program by using a regular expression to obtain a life cycle of each variable in the register.
  • the parsing module includes a first obtaining submodule, a second obtaining submodule, and a statistical submodule; the first obtaining submodule is configured to parse the program variable defining part by using a regular expression to obtain Each variable of the program and its register definition; the second acquisition sub-module is configured to parse the program instruction line by using a regular expression to obtain the life cycle of each variable; the statistical sub-module is configured to be defined according to each variable of the program and its register The life cycle of each variable counts the life cycle of each variable in each register.
  • the alarm module implements an error by the script to implement an error.
  • the apparatus further includes a text output module; when the life cycle of each variable in the register does not overlap, the detection module will notify the text output module, and the text output module outputs the life of each variable in the register. Cycle into a text file.
  • the embodiment of the present invention further provides a computer readable storage medium, the storage medium comprising a set of computer executable instructions for performing a method for avoiding register conflicts according to an embodiment of the present invention.
  • the beneficial effects of the embodiments of the present invention are:
  • a method and apparatus for avoiding register conflicts provided by an embodiment of the present invention can avoid register conflicts during program running.
  • the method of the embodiment of the present invention specifically includes: acquiring a life cycle of each variable of the program in the register; detecting whether the life cycle of each variable in the register overlaps, and performing an alarm when the detection result is YES; In the programming process or after writing the first draft of the program, the specific life cycle of each variable of the program in the register is obtained.
  • the programmer is alerted, so that the programmer knows that there is a conflict in the register, so that the time can be timely.
  • the program is modified to make the variables of the program in the registers no longer overlap.
  • the method of the embodiment of the present invention can effectively avoid the conflict of the registers during the running of the program, and improve the programming. effectiveness.
  • FIG. 1 is a schematic flowchart of a method according to Embodiment 1 of the present invention.
  • FIG. 2 is a schematic flowchart of a method according to Embodiment 3 of the present invention.
  • Embodiment 3 is a partial content of a microcode file according to Embodiment 3 of the present invention.
  • FIG. 4 is a text file of an output variable life cycle according to Embodiment 3 of the present invention
  • FIG. 5 is a schematic structural diagram of an apparatus according to Embodiment 4 of the present invention. detailed description
  • Embodiment 1 is a diagrammatic representation of Embodiment 1:
  • This embodiment provides a method for avoiding register conflicts.
  • the flow of the method is shown in Figure 1:
  • Step S101 Start.
  • Step S102 Acquire a life cycle of each variable of the program in the register.
  • the main solution of the embodiment of the present invention is to prevent a program conflict between the programs written by the programmer during the running process, so generally the programmer obtains the register during the process of writing the program or after the programmer writes the first draft of the program. The life cycle of each variable.
  • the program defines a destination IP address of a variable storage message, named destlp, stored in register R1. If destlp is used starting from the mth line in the program, the nth line is used, and its lifetime value is nm. , and after the nth row, the register R1 is released and can be defined as other variables.
  • the mth line above is the starting position of the life cycle
  • the nth line is the end position of the life cycle
  • n-m is the life cycle value of the variable. Therefore, the life cycle of a variable includes the starting position, the ending position, and the lifetime value of the variable.
  • variable definition part in the parsing program obtains the variable and its register definition (ie, the register in which the variable is located); parses the instruction line of the program, and obtains the life cycle of each variable; finally, according to each variable and its register definition, each variable The life cycle counts the life cycle of each variable in each register.
  • Step S103 detecting whether the life cycle of each variable in the register overlaps, if yes, executing step S104, if not, executing step S105;
  • the detection step can be performed by the programmer during the process of writing the program, or after the programmer has written the first draft of the program.
  • the detecting step is performed by the programmer during the process of writing the program, if it is detected that the life cycles of the variables in the register overlap, the programmer is alerted in time.
  • Step S104 an alarm
  • the alarm mode can prompt the programmer to give an error through the script, or can prompt the programmer to give an error by issuing an alarm sound.
  • the script contains information including: overlapping variables, registers in which the variables are located.
  • the script may also include the position where the variable life cycle overlaps, for example: variables 1 and 2 overlap, and the specific overlap occurs in the register. Lines 4 to 7 of R Q.
  • the program is parsed by using a regular expression to obtain the life cycle of each variable in the register, and the program is a condensing code program.
  • variable definition part of the code file begins with assign and is used to specify a register for each variable. Assume that the register resources available for microcode are R0, R1; the total number of lines in the microcode file is 21. Part of the code is shown in Figure 3 (for convenience of description, a simplified representation of assign in Figure 3).
  • Step S201 start;
  • Step S202 parsing the program variable definition part by using a regular expression, and acquiring each variable of the program and its register definition; according to the content of the above code, the instruction behavior variable starting with the assign defines the command line, and the code is performed by using the regular expression.
  • the variables that can be obtained by parsing and their registers are defined as: Variables VI, V2, V3, V4 occupy register R0; Variables V5, V6 occupy register R1.
  • Step S203 parsing the program instruction line by using a regular expression to obtain the life cycle of each variable, the life cycle of the variable VI is the 0th line to the 3rd line; the life cycle of the variable V2 is the 7th line to the 8th line; The life cycle of V3 is line 10 to line 13; the life cycle of variable V4 is line 18 to line 21; the life cycle of variable V5 is line 1 to line 5; the life cycle of variable V6 is line 8 Go to line 10.
  • Step S204 According to each variable and its register definition, and the life cycle of each variable, the life cycle of each variable in each register is counted; the statistical result is: the variables VI, V2, V3, V4 occupy the register R0; the life cycle of the variable VI is the first Line 0 to line 3; the life cycle of variable V2 is line 7 to line 8; the life cycle of variable V3 is line 10 to line 13; the life cycle of variable V4 is line 18 to line 21.
  • the variables V5 and V6 occupy the register R1; the life cycle of the variable V5 is the 1st line to the 5th line; the life cycle of the variable V6 is the 8th line to the 10th line.
  • Step S205 Detect whether the life cycle of each variable in the register overlaps, and if yes, go to step S206; if no, go to step S207. Because there is no overlap in the life cycle of the variables in the registers R0 and R1 in this embodiment, the process goes to step S207;
  • Step S206 The alarm and the alarm mode use a script to prompt the user to make an error.
  • Step S207 Output the life cycle of each variable in the register to the text file, and the output text file is presented in the form of a table, as shown in FIG.
  • the embodiment provides an apparatus for avoiding register conflicts, including: an obtaining module 10, a detecting module 20, and an alarm module 30, as shown in FIG. 5; the obtaining module 10 is configured to acquire a life cycle of each variable in the register; The detecting module 20 is configured to detect whether the life cycle of each variable in the register overlaps, and send a notification to the alarm module 30 when the detection result is yes; the alarm module 30 is configured to: after receiving the notification sent by the detecting module 20 Alarm.
  • the main solution of the embodiment of the present invention is to prevent the program written by the programmer from having a register conflict. Therefore, generally, the programmer acquires the register after acquiring the module 10 in the process of writing the program or after the programmer writes the first draft of the program.
  • the detection module can be whether the life cycle of each variable in the detection register overlaps during the programming of the programmer or after the programmer has written the first draft of the program.
  • the detection process of the detection module 20 is performed during the programming process by the programmer, if the detection module 20 detects that the life cycles of the variables in the register overlap, the alarm module 30 is notified in time.
  • the program defines a destination IP address of a variable storage message, named destlp, stored in register R1. If destlp is used starting from the mth line in the program, the nth line is used, and its lifetime value is nm. , and after the nth row, the register R1 is released and can be defined as other variables.
  • the mth line above is the starting position of the life cycle
  • the nth line is the end position of the life cycle
  • n-m is the life cycle value of the variable. Therefore, the life cycle of a variable includes the starting position, the ending position, and the lifetime value of the variable.
  • the detecting module 20 can determine whether the start position or the end position of the life cycle of a variable in the register is in the beginning of the life cycle of another variable in the same register. Between the positions to determine whether the life cycle of each variable in the register overlaps.
  • the above alarm module 30 can prompt the programmer to give an error through a script, or can prompt the programmer to give an error by issuing an alarm sound.
  • the script contains information including: overlapping variables, registers in which the variables are located.
  • the script may also include the position where the variable life cycle overlaps, for example: the variable VI and V2 overlap, and the specific overlapping position is in the register. Lines 4 to 7 of R0.
  • the obtaining module 10 further includes a parsing module. Since most of the scripting languages currently have regular expression parsing functions, such as python, perl, etc., the regular expression can be used to parse the program to obtain the life cycle of each variable in the register; The module is configured to use a regular expression to parse the program to obtain the life cycle of each variable in the register.
  • the parsing module includes a first obtaining submodule, a second obtaining submodule, and a statistical submodule; the first obtaining submodule is configured to obtain a variable of the program and a register definition thereof by using a regular expression to parse the program (ie, where the variable is located)
  • the second acquisition sub-module is configured to obtain a life cycle of each variable by parsing the program by using a regular expression; the statistical sub-module is configured to, according to each variable and its register definition, the life cycle of each variable is counted in each register. The life cycle of each variable.
  • the device further includes a text output module; when the life cycle of each variable in the register does not overlap, the detection module will inform the text output module, and the text output module outputs the life cycle of each variable in the register to the text file, and the text file can be expressed. For tables, graphics, etc.
  • the foregoing obtaining module 10, the detecting module 20, the alarm module 30, the parsing module, the first obtaining submodule, the second obtaining submodule, the statistical submodule, and the output module may all be central to the device that avoids register conflicts.
  • a CPU Central Processing Unit
  • MPU Microprocessor
  • DSP Digital Signal Processor
  • FPGA Field-Programmable Gate Array
  • An embodiment of the present invention further provides a computer readable storage medium, where the storage medium includes a The group of computer executable instructions for performing the method of avoiding register conflicts in accordance with an embodiment of the present invention.
  • the present invention can be provided as a method, system, or computer program product. Accordingly, the present invention can take the form of a hardware embodiment, a software embodiment, or a combination of software and hardware aspects.
  • the invention can take the form of a computer program product embodied on one or more computer usable storage media (including but not limited to disk storage and optical storage, etc.) in which computer usable program code is embodied.
  • the computer program instructions can also be stored in a computer readable memory that can direct a computer or other programmable data processing device to operate in a particular manner, such that the instructions stored in the computer readable memory produce an article of manufacture comprising the instruction device.
  • the apparatus implements the functions specified in one or more blocks of a flow or a flow and/or block diagram of the flowchart.

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

A method and an apparatus for preventing register conflict, wherein the method comprises: obtaining a life cycle of each variable of a program in a register; and detecting whether the life cycle of the each variable in the register overlaps another, and reporting an alarm if a detection result is yes. The apparatus comprises: an obtaining module, a detection module and an alarm module. The obtaining module is configured to obtain the life cycle of the each variable of the program in the register; the detection module is configured to detect whether the life cycle of the each variable in the register overlaps another, and send a notification to the alarm module if the detection result is yes; and the alarm module is configured to report an alarm when receiving the notification sent by the detection module.

Description

一种避免寄存器冲突的方法及装置 技术领域  Method and device for avoiding register conflict
本发明涉及计算机领域, 特别涉及一种避免寄存器冲突的方法及装置。 背景技术  The present invention relates to the field of computers, and in particular, to a method and apparatus for avoiding register conflicts. Background technique
现今计算机、 手机、 平板电脑等电子设备的使用已经非常的普遍, 这 些电子设备中的软件都是由编程人员编写的程序组成的。 在程序中会使用 到变量, 变量通常存储于寄存器中, 以微码为例, 微码是程序的一种, 它 是存储于网络处理器中的指令集, 驻留于网络处理器的微引擎中, 是整个 数据转发层面的核心。 寄存器是网络处理器微引擎中的重要资源, 微码编 程利用寄存器存储一些临时变量,根据转发逻辑实现各种业务。在程序中, 每个变量在寄存器中都有各自的生命周期, 即从开始使用该变量到该变量 不再使用之间的指令周期间隔。 因程序中的变量会有多个, 寄存器的数量 又有限, 所以经常会将多个变量放置于同一个寄存器中, 如果同一寄存器 的两个变量的生命周期出现重叠, 就会出现寄存器冲突的情况。  The use of electronic devices such as computers, mobile phones, and tablets is now very common. The software in these electronic devices is composed of programs written by programmers. Variables are used in the program. Variables are usually stored in registers. Take microcode as an example. Microcode is a kind of program. It is a set of instructions stored in a network processor. The microengine resides on the network processor. Medium is the core of the entire data forwarding layer. Registers are an important resource in the network processor microengine. Microcode programming uses registers to store temporary variables and implement various services based on forwarding logic. In the program, each variable has its own life cycle in the register, that is, the instruction cycle interval between when the variable is used and when the variable is no longer used. Since there are multiple variables in the program and the number of registers is limited, multiple variables are often placed in the same register. If the lifetimes of the two variables in the same register overlap, a register conflict will occur. .
由于编程人员在编写程序的过程中, 并不知道寄存器的使用情况, 所 以在定义变量的时候, 经常是凭感觉确定寄存器的使用情况, 这样导致的 后果就是经常会出现寄存器冲突的情况。 发明内容  Because the programmer does not know the use of the register during the process of writing the program, when the variable is defined, the use of the register is often determined by the feeling, which has the consequence that the register conflict often occurs. Summary of the invention
为解决现有存在的技术问题, 本发明实施例提供了一种避免寄存器冲 突的方法及装置。  In order to solve the existing technical problems, embodiments of the present invention provide a method and apparatus for avoiding register conflicts.
本发明实施例提供一种避免寄存器冲突的方法, 包括: 获取程序在寄 存器中各变量的生命周期; 检测所述寄存器中各变量的生命周期是否重叠, 并在检测结果为是时进行告警。 在本发明的一种实施例中, 获取程序在寄存器中各变量的生命周期的 步骤包括: 利用正则表达式对程序进行解析获取寄存器中各变量的生命周 期。 An embodiment of the present invention provides a method for avoiding a register conflict, including: acquiring a life cycle of each variable in a register; detecting whether a life cycle of each variable in the register overlaps, and performing an alarm when the detection result is yes. In an embodiment of the invention, the step of obtaining the life cycle of each variable of the program in the register comprises: parsing the program with a regular expression to obtain a life cycle of each variable in the register.
在本发明的一种实施例中, 利用正则表达式对程序进行解析获取寄存 器中各变量的生命周期的步骤包括: 利用正则表达式对程序变量定义部分 进行解析, 获取程序的各变量及其寄存器定义; 利用正则表达式对程序指 令行进行解析, 获取各个变量的生命周期; 根据程序的各变量及其寄存器 定义、 各个变量的生命周期统计各个寄存器中各变量的生命周期。  In an embodiment of the present invention, the step of parsing a program by using a regular expression to obtain a life cycle of each variable in the register includes: parsing a program variable definition portion by using a regular expression, and acquiring each variable of the program and its register Definition; Use the regular expression to parse the program instruction line to obtain the life cycle of each variable; According to the variables of the program and its register definition, the life cycle of each variable in each register is counted.
在本发明的一种实施例中, 所述进行告警的步骤包括: 通过脚本向用 户提示错误来实现告警。  In an embodiment of the present invention, the step of performing an alarm comprises: prompting an error by using a script to implement an alarm.
在本发明的一种实施例中, 所述方法还包括: 当所述寄存器中各变量 的生命周期没有重叠时, 输出所述程序在寄存器中各变量的生命周期到文 本文件中。  In an embodiment of the invention, the method further comprises: outputting a life cycle of each variable in the register to the text file when the life cycles of the variables in the register do not overlap.
本发明实施例还提供了一种避免寄存器冲突的装置, 包括:获取模块、 检测模块及告警模块; 获取模块配置为, 获取程序在寄存器中各变量的生 命周期;检测模块配置为,检测所述寄存器中各变量的生命周期是否重叠, 并在检测结果为是时发送通知给告警模块; 告警模块配置为, 在收到检测 模块发送的通知后进行告警。  The embodiment of the invention further provides an apparatus for avoiding register conflict, comprising: an obtaining module, a detecting module and an alarm module; the obtaining module is configured to obtain a life cycle of each variable of the program in the register; and the detecting module is configured to detect the Whether the life cycle of each variable in the register overlaps, and sends a notification to the alarm module when the detection result is yes; the alarm module is configured to perform an alarm after receiving the notification sent by the detection module.
在本发明的一种实施例中, 获取模块还包括解析模块, 解析模块利用 正则表达式对程序进行解析获取寄存器中各变量的生命周期。  In an embodiment of the present invention, the obtaining module further includes a parsing module, wherein the parsing module parses the program by using a regular expression to obtain a life cycle of each variable in the register.
在本发明的一种实施例中, 解析模块包括第一获取子模块、 第二获取 子模块及统计子模块; 第一获取子模块配置为, 利用正则表达式对程序变 量定义部分进行解析, 获取程序的各变量及其寄存器定义; 第二获取子模 块配置为, 利用正则表达式对程序指令行进行解析, 获取各个变量的生命 周期; 统计子模块配置为, 根据程序的各变量及其寄存器定义、 各个变量 的生命周期统计各个寄存器中各变量的生命周期。 在本发明的一种实施例中, 告警模块通过脚本向用户提示错误来实现 杏口 。 In an embodiment of the present invention, the parsing module includes a first obtaining submodule, a second obtaining submodule, and a statistical submodule; the first obtaining submodule is configured to parse the program variable defining part by using a regular expression to obtain Each variable of the program and its register definition; the second acquisition sub-module is configured to parse the program instruction line by using a regular expression to obtain the life cycle of each variable; the statistical sub-module is configured to be defined according to each variable of the program and its register The life cycle of each variable counts the life cycle of each variable in each register. In an embodiment of the present invention, the alarm module implements an error by the script to implement an error.
在本发明的一种实施例中, 该装置还包括文本输出模块; 当寄存器中 各变量的生命周期没有重叠时, 检测模块将告知文本输出模块, 文本输出 模块输出程序在寄存器中各变量的生命周期到文本文件中。  In an embodiment of the invention, the apparatus further includes a text output module; when the life cycle of each variable in the register does not overlap, the detection module will notify the text output module, and the text output module outputs the life of each variable in the register. Cycle into a text file.
本发明实施例还提供一种计算机可读存储介质, 所述存储介质包括一 组计算机可执行指令, 所述指令用于执行本发明实施例所述的避免寄存器 冲突的方法。 本发明实施例的有益效果是:  The embodiment of the present invention further provides a computer readable storage medium, the storage medium comprising a set of computer executable instructions for performing a method for avoiding register conflicts according to an embodiment of the present invention. The beneficial effects of the embodiments of the present invention are:
本发明实施例提供的一种避免寄存器冲突的方法及装置, 能够避免在 程序运行的过程中寄存器发生冲突。 本发明实施例的方法具体包括: 获取 程序在寄存器中各变量的生命周期; 检测所述寄存器中各变量的生命周期 是否重叠, 并在检测结果为是时进行告警; 本发明实施例的方法可以在编 程过程中或编写好程序的初稿后, 获取寄存器中程序各变量具体的生命周 期, 当发现寄存器中有变量重叠时, 便对编程人员进行告警, 使编程人员 获知寄存器存在冲突, 从而才能及时地对程序进行修改, 使程序在各寄存 器中的变量不再重叠; 与现有技术相比, 本发明实施例的方法能够有效地 避免在程序运行的过程中寄存器发生冲突的情况, 提高编程的效率。 附图说明  A method and apparatus for avoiding register conflicts provided by an embodiment of the present invention can avoid register conflicts during program running. The method of the embodiment of the present invention specifically includes: acquiring a life cycle of each variable of the program in the register; detecting whether the life cycle of each variable in the register overlaps, and performing an alarm when the detection result is YES; In the programming process or after writing the first draft of the program, the specific life cycle of each variable of the program in the register is obtained. When the variables in the register are found to overlap, the programmer is alerted, so that the programmer knows that there is a conflict in the register, so that the time can be timely. The program is modified to make the variables of the program in the registers no longer overlap. Compared with the prior art, the method of the embodiment of the present invention can effectively avoid the conflict of the registers during the running of the program, and improve the programming. effectiveness. DRAWINGS
图 1为本发明实施例一提供的方法的流程示意图;  1 is a schematic flowchart of a method according to Embodiment 1 of the present invention;
图 2为本发明实施例三提供的方法的流程示意图;  2 is a schematic flowchart of a method according to Embodiment 3 of the present invention;
图 3为本发明实施例三提供的微码文件的部分内容;  3 is a partial content of a microcode file according to Embodiment 3 of the present invention;
图 4为本发明实施例三提供的输出的变量生命周期的文本文件; 图 5为本发明实施例四提供的装置的结构示意图。 具体实施方式 4 is a text file of an output variable life cycle according to Embodiment 3 of the present invention; FIG. 5 is a schematic structural diagram of an apparatus according to Embodiment 4 of the present invention. detailed description
下面通过具体实施方式结合附图对本发明作进一步详细说明。  The present invention will be further described in detail below with reference to the accompanying drawings.
实施例一:  Embodiment 1:
本实施例提供了一种避免寄存器冲突的方法, 该方法的流程如图 1 所 示:  This embodiment provides a method for avoiding register conflicts. The flow of the method is shown in Figure 1:
步骤 S101 : 开始。  Step S101: Start.
步骤 S102: 获取程序在寄存器中各变量的生命周期。  Step S102: Acquire a life cycle of each variable of the program in the register.
因本发明实施例主要解决的是避免编程人员编写的程序在运行的过程 中出现寄存器冲突的情况, 所以一般在编程人员在编写程序的过程中、 或 者在编程人员编写好程序的初稿后获取寄存器中各变量的生命周期。  The main solution of the embodiment of the present invention is to prevent a program conflict between the programs written by the programmer during the running process, so generally the programmer obtains the register during the process of writing the program or after the programmer writes the first draft of the program. The life cycle of each variable.
以下用一个具体的例子来说明变量的生命周期的含义。 比如程序中定 义了一个变量存储报文的目的 IP地址, 取名 destlp, 存储于寄存器 R1中, 如果在程序中从第 m行开始使用 destlp, 第 n行使用完毕, 则其生命周期 值为 n-m,并且在第 n行以后寄存器 R1便释放出来,可以定义为其他变量。 上述第 m行就是生命周期的起始位置, 第 n行就是生命周期的终止位置, n-m为变量的生命周期值。 因此, 变量的生命周期包括起始位置、 终止位置 和变量的生命周期值。  The following uses a concrete example to illustrate the meaning of the life cycle of a variable. For example, the program defines a destination IP address of a variable storage message, named destlp, stored in register R1. If destlp is used starting from the mth line in the program, the nth line is used, and its lifetime value is nm. , and after the nth row, the register R1 is released and can be defined as other variables. The mth line above is the starting position of the life cycle, the nth line is the end position of the life cycle, and n-m is the life cycle value of the variable. Therefore, the life cycle of a variable includes the starting position, the ending position, and the lifetime value of the variable.
获取程序在寄存器中各变量的生命周期的方式有多种, 因目前大部分 脚本语言都带有正则表达式解析功能, 比如 python、 perl等。 所以可以利用 正则表达式对程序进行解析获取寄存器中各变量的生命周期。 具体的, 解 析程序中的变量定义部分获取变量及其寄存器定义(即变量所在的寄存器); 解析程序的指令行, 获取每个变量的生命周期; 最后, 根据各变量及其寄 存器定义、 各个变量的生命周期统计各个寄存器中各变量的生命周期。  There are several ways to get the life cycle of each variable in a program, because most scripting languages currently have regular expression parsing functions, such as python, perl, and so on. So you can use regular expressions to parse the program to get the life cycle of each variable in the register. Specifically, the variable definition part in the parsing program obtains the variable and its register definition (ie, the register in which the variable is located); parses the instruction line of the program, and obtains the life cycle of each variable; finally, according to each variable and its register definition, each variable The life cycle counts the life cycle of each variable in each register.
步骤 S103 : 检测所述寄存器中各变量的生命周期是否重叠, 如是, 则 执行步骤 S104, 如否, 执行步骤 S105; 检测步骤可以是在编程人员在编写程序的过程中、 或者在编程人员编 写好程序的初稿后进行。 对应的, 当检测步骤是在编程人员在编写程序的 过程中进行时, 如果检测到寄存器中各变量的生命周期有重叠, 则及时对 编程人员进行告警。 Step S103: detecting whether the life cycle of each variable in the register overlaps, if yes, executing step S104, if not, executing step S105; The detection step can be performed by the programmer during the process of writing the program, or after the programmer has written the first draft of the program. Correspondingly, when the detecting step is performed by the programmer during the process of writing the program, if it is detected that the life cycles of the variables in the register overlap, the programmer is alerted in time.
检测的方式有多种, 较优的, 可以通过以下方式进行: 判断寄存器中 的某个变量的生命周期的起始位置或者终止位置是否在同一寄存器中另一 变量的生命周期的起始位置到终止位置之间, 如果是, 则存在重叠。  There are several ways to detect, and the best ones can be performed by: judging whether the start position or end position of the life cycle of a variable in the register is at the beginning of the life cycle of another variable in the same register. Between termination positions, if yes, there is overlap.
步骤 S104: 告警;  Step S104: an alarm;
告警方式可以通过脚本向编程人员提示错误, 也可以通过发出告警声 音向编程人员提示错误。 通过脚本向编程人员提示错误时, 脚本包含的信 息包括: 重叠的变量、 变量所在的寄存器。 较优地, 为使编程人员能尽快 地修改程序, 解决变量生命周期重叠的问题, 脚本中还可以包括变量生命 周期重叠的位置, 例如: 变量 12发生重叠, 具体发生重叠的位置在 寄存器 RQ的第 4至第 7行。 The alarm mode can prompt the programmer to give an error through the script, or can prompt the programmer to give an error by issuing an alarm sound. When an error is prompted to the programmer through a script, the script contains information including: overlapping variables, registers in which the variables are located. Preferably, in order to enable the programmer to modify the program as soon as possible to solve the problem of variable life cycle overlap, the script may also include the position where the variable life cycle overlaps, for example: variables 1 and 2 overlap, and the specific overlap occurs in the register. Lines 4 to 7 of R Q.
步骤 S105: 结束。  Step S105: End.
在本发明的另一种实施例中提供了另一种方法, 该方法的具体流程和 上述方法基本一致, 不同之处在于: 在该方法中, 当寄存器中各变量的生 命周期没有重叠时, 则输出寄存器中各变量的生命周期到文本文件中, 文 本文件中包含: 变量的生命周期、 占用的寄存器等信息。 这样可以方便编 程人员在修改代码, 增加变量时寻找空闲的寄存器资源。 表示各变量的生 命周期的文本文件的表现形式可以为表格、 图形等。 实施例二:  In another embodiment of the present invention, another method is provided, and the specific process of the method is basically the same as the above method, except that: in the method, when the life cycles of variables in the register do not overlap, Then the life cycle of each variable in the output register is in a text file, and the text file contains: the life cycle of the variable, the occupied register, and the like. This makes it easy for programmers to look for free register resources when modifying code and adding variables. The text file representing the life cycle of each variable can be expressed as a table, a graph, or the like. Embodiment 2:
为更好的说明上述方法中获取的程序在寄存器中各变量的生命周期包 含的内容, 及如何检测寄存器中各变量的生命周期是否重叠, 下面以一个 具体的操作过程进行说明: 编程人员编写的程序中定义了 5个变量, 分别是 VI、 V2、 V3、 V4、In order to better explain the contents of the life cycle of each variable in the register obtained in the above method, and how to detect whether the life cycle of each variable in the register overlaps, the following describes a specific operation process: Five variables are defined in the program written by the programmer, namely VI, V2, V3, V4,
V5, 在编程人员编写完程序之后, 对程序进行解析, 获取了这 5个变量的 生命周期, 如表 1所示: V5, after the programmer has finished writing the program, parsing the program and obtaining the life cycle of the five variables, as shown in Table 1:
Figure imgf000008_0001
V3的生命周期信息, 以及程序在寄存器 R1 中的变量 V4、 V5的生命周期 信息。 在获取完生命周期后, 检测寄存器中各变量的生命周期是否重叠, 在检测时, 可以依次对寄存器 R0和寄存器 R1进行检测, 也可以对两个寄 存器同时进行检测。 在对寄存器 R0检测后, 发现变量 V2的初始位置在第 2行, 其在变量 VI的初始位置和终止位置之间, 所以判定变量 VI的生命 周期和 V2 的生命周期重叠。 此时, 向编程人员进行告警, 并告知其变量 VI的生命周期和 V2的生命周期重叠, 需要进行调整。
Figure imgf000008_0001
The life cycle information of V3, and the life cycle information of variables V4 and V5 in the program R1. After the life cycle is acquired, it is detected whether the life cycles of the variables in the register overlap. When detecting, the register R0 and the register R1 may be detected in turn, or both registers may be simultaneously detected. After detecting the register R0, it is found that the initial position of the variable V2 is in the second line, which is between the initial position and the end position of the variable VI, so it is determined that the life cycle of the variable VI overlaps with the life cycle of V2. At this point, the programmer is alerted and the life cycle of the variable VI is overlapped with the life cycle of V2, which needs to be adjusted.
虽然变量 V4的生命周期初始位置是第 1行与变量 VI的生命周期的初 始位置相同,终止位置是第 4行与变量 VI的生命周期的终止位置相同, 但 因为他们使用的寄存器不是同一个, 所以变量 VI和变量 V4的生命周期之 间并不存在重叠。 实施例三:  Although the initial position of the life cycle of the variable V4 is the same as the initial position of the life cycle of the variable VI, the end position is the same as the end position of the life cycle of the variable VI, but because the registers they use are not the same, So there is no overlap between the variable VI and the life cycle of variable V4. Embodiment 3:
为更好的说明本发明提供的方法, 下面以具体的实施例进行说明, 请 参见图 2。在本实施例中, 利用正则表达式对程序进行解析获取寄存器中各 变量的生命周期, 且程序为凝:码程序。 In order to better illustrate the method provided by the present invention, the following describes the specific embodiment, please See Figure 2. In this embodiment, the program is parsed by using a regular expression to obtain the life cycle of each variable in the register, and the program is a condensing code program.
该 码文件中的变量定义部分以 assign开头, 用于为每个变量指定寄 存器。假设微码可用的寄存器资源为 R0,R1 ;微码文件中指令总行数为 21。 码的部分内容请见图 3 (为描述方便, 图 3中用 a简化的表示 assign )。  The variable definition part of the code file begins with assign and is used to specify a register for each variable. Assume that the register resources available for microcode are R0, R1; the total number of lines in the microcode file is 21. Part of the code is shown in Figure 3 (for convenience of description, a simplified representation of assign in Figure 3).
步骤 S201 : 开始;  Step S201: start;
步骤 S202: 利用正则表达式对程序变量定义部分进行解析, 获取程序 的各变量及其寄存器定义; 由上述 码的内容可知, 以 assign开头的指令 行为变量定义指令行, 利用正则表达式对 码进行解析可以获取到的变量 及其寄存器定义为: 变量 VI、 V2、 V3、 V4占用寄存器 R0; 变量 V5、 V6 占用寄存器 Rl。  Step S202: parsing the program variable definition part by using a regular expression, and acquiring each variable of the program and its register definition; according to the content of the above code, the instruction behavior variable starting with the assign defines the command line, and the code is performed by using the regular expression. The variables that can be obtained by parsing and their registers are defined as: Variables VI, V2, V3, V4 occupy register R0; Variables V5, V6 occupy register R1.
步骤 S203 : 利用正则表达式对程序指令行进行解析, 获取各个变量的 生命周期, 变量 VI的生命周期为第 0行到第 3行; 变量 V2的生命周期为 第 7行到第 8行; 变量 V3的生命周期为第 10行到第 13行; 变量 V4的生 命周期为第 18行到第 21行; 变量 V5的生命周期为第 1行到第 5行; 变量 V6的生命周期为第 8行到第 10行。  Step S203: parsing the program instruction line by using a regular expression to obtain the life cycle of each variable, the life cycle of the variable VI is the 0th line to the 3rd line; the life cycle of the variable V2 is the 7th line to the 8th line; The life cycle of V3 is line 10 to line 13; the life cycle of variable V4 is line 18 to line 21; the life cycle of variable V5 is line 1 to line 5; the life cycle of variable V6 is line 8 Go to line 10.
步骤 S204: 根据各变量及其寄存器定义、 各个变量的生命周期统计各 个寄存器中各变量的生命周期; 统计的结果是: 变量 VI、 V2、 V3、 V4占 用寄存器 R0; 变量 VI的生命周期为第 0行到第 3行; 变量 V2的生命周期 为第 7行到第 8行; 变量 V3的生命周期为第 10行到第 13行; 变量 V4的 生命周期为第 18行到第 21行。 变量 V5、 V6占用寄存器 R1 ; 变量 V5的 生命周期为第 1行到第 5行; 变量 V6的生命周期为第 8行到第 10行。  Step S204: According to each variable and its register definition, and the life cycle of each variable, the life cycle of each variable in each register is counted; the statistical result is: the variables VI, V2, V3, V4 occupy the register R0; the life cycle of the variable VI is the first Line 0 to line 3; the life cycle of variable V2 is line 7 to line 8; the life cycle of variable V3 is line 10 to line 13; the life cycle of variable V4 is line 18 to line 21. The variables V5 and V6 occupy the register R1; the life cycle of the variable V5 is the 1st line to the 5th line; the life cycle of the variable V6 is the 8th line to the 10th line.
步骤 S205: 检测所述寄存器中各变量的生命周期是否重叠, 如是, 则 转到步骤 S206; 如否, 则转到步骤 S207。 因为本实施例中的寄存器 R0和 R1中的变量的生命周期都不存在重叠, 所以转到步骤 S207;  Step S205: Detect whether the life cycle of each variable in the register overlaps, and if yes, go to step S206; if no, go to step S207. Because there is no overlap in the life cycle of the variables in the registers R0 and R1 in this embodiment, the process goes to step S207;
步骤 S206: 告警, 告警的方式采用脚本向用户提示错误。 步骤 S207: 输出寄存器中各变量的生命周期到文本文件中, 输出的文 本文件以表格的形式呈现, 如图 4所示。 Step S206: The alarm and the alarm mode use a script to prompt the user to make an error. Step S207: Output the life cycle of each variable in the register to the text file, and the output text file is presented in the form of a table, as shown in FIG.
步骤 S208: 结束。 实施例四:  Step S208: End. Embodiment 4:
本实施例提供了一种避免寄存器冲突的装置, 包括: 获取模块 10、 检 测模块 20及告警模块 30, 如图 5所示; 获取模块 10配置为, 获取程序在 寄存器中各变量的生命周期; 检测模块 20配置为, 检测所述寄存器中各变 量的生命周期是否重叠, 并在检测结果为是时发送通知给告警模块 30; 告 警模块 30配置为, 在收到检测模块 20发送的通知后进行告警。  The embodiment provides an apparatus for avoiding register conflicts, including: an obtaining module 10, a detecting module 20, and an alarm module 30, as shown in FIG. 5; the obtaining module 10 is configured to acquire a life cycle of each variable in the register; The detecting module 20 is configured to detect whether the life cycle of each variable in the register overlaps, and send a notification to the alarm module 30 when the detection result is yes; the alarm module 30 is configured to: after receiving the notification sent by the detecting module 20 Alarm.
因本发明实施例主要解决的是避免编程人员编写的程序存在寄存器冲 突的情况, 所以一般在编程人员在编写程序的过程中、 或者在编程人员编 写好程序的初稿后获取模块 10才开始获取寄存器中各变量的生命周期。 检 测模块可以是在编程人员在编写程序的过程中、 或者在编程人员编写好程 序的初稿后对检测寄存器中各变量的生命周期是否重叠。 对应的, 如果检 测模块 20的检测过程是在编程人员编写程序的过程中进行时, 如果检测模 块 20检测到寄存器中各变量的生命周期有重叠, 则及时通知告警模块 30。  The main solution of the embodiment of the present invention is to prevent the program written by the programmer from having a register conflict. Therefore, generally, the programmer acquires the register after acquiring the module 10 in the process of writing the program or after the programmer writes the first draft of the program. The life cycle of each variable. The detection module can be whether the life cycle of each variable in the detection register overlaps during the programming of the programmer or after the programmer has written the first draft of the program. Correspondingly, if the detection process of the detection module 20 is performed during the programming process by the programmer, if the detection module 20 detects that the life cycles of the variables in the register overlap, the alarm module 30 is notified in time.
以下用一个具体的例子来说明变量的生命周期的含义。 比如程序中定 义了一个变量存储报文的目的 IP地址, 取名 destlp, 存储于寄存器 R1中, 如果在程序中从第 m行开始使用 destlp, 第 n行使用完毕, 则其生命周期 值为 n-m,并且在第 n行以后寄存器 R1便释放出来,可以定义为其他变量。 上述第 m行就是生命周期的起始位置, 第 n行就是生命周期的终止位置, n-m为变量的生命周期值。 因此, 变量的生命周期包括起始位置、 终止位置 和变量的生命周期值。  The following uses a concrete example to illustrate the meaning of the life cycle of a variable. For example, the program defines a destination IP address of a variable storage message, named destlp, stored in register R1. If destlp is used starting from the mth line in the program, the nth line is used, and its lifetime value is nm. , and after the nth row, the register R1 is released and can be defined as other variables. The mth line above is the starting position of the life cycle, the nth line is the end position of the life cycle, and n-m is the life cycle value of the variable. Therefore, the life cycle of a variable includes the starting position, the ending position, and the lifetime value of the variable.
上述检测模块 20可通过判断寄存器中的某个变量的生命周期的起始位 置或者终止位置是否在同一寄存器中另一变量的生命周期的起始位置到终 止位置之间来确定寄存器中各变量的生命周期是否重叠。 The detecting module 20 can determine whether the start position or the end position of the life cycle of a variable in the register is in the beginning of the life cycle of another variable in the same register. Between the positions to determine whether the life cycle of each variable in the register overlaps.
上述告警模块 30可以通过脚本向编程人员提示错误, 也可以通过发出 告警声音向编程人员提示错误。 通过脚本向编程人员提示错误时, 脚本包 含的信息包括: 重叠的变量、 变量所在的寄存器。 较优地, 为使编程人员 能尽快地修改程序, 解决变量生命周期重叠的问题, 脚本中还可以包括变 量生命周期重叠的位置, 例如: 变量 VI和 V2发生重叠, 具体发生重叠的 位置在寄存器 R0的第 4至第 7行。  The above alarm module 30 can prompt the programmer to give an error through a script, or can prompt the programmer to give an error by issuing an alarm sound. When an error is prompted to the programmer through a script, the script contains information including: overlapping variables, registers in which the variables are located. Preferably, in order to enable the programmer to modify the program as soon as possible to solve the problem of variable life cycle overlap, the script may also include the position where the variable life cycle overlaps, for example: the variable VI and V2 overlap, and the specific overlapping position is in the register. Lines 4 to 7 of R0.
上述获取模块 10还包括解析模块, 因目前大部分脚本语言都带有正则 表达式解析功能, 比如 python、 perl等, 所以可以利用正则表达式对程序进 行解析获取寄存器中各变量的生命周期; 解析模块即配置为, 利用正则表 达式对程序进行解析获取寄存器中各变量的生命周期。 解析模块包括第一 获取子模块、 第二获取子模块及统计子模块; 第一获取子模块配置为, 利 用正则表达式对程序进行解析后获取程序的各变量及其寄存器定义(即变 量所在的寄存器); 第二获取子模块配置为, 利用正则表达式对程序进行解 析后获取各个变量的生命周期; 统计子模块配置为, 根据各变量及其寄存 器定义、 各个变量的生命周期统计各个寄存器中各变量的生命周期。  The obtaining module 10 further includes a parsing module. Since most of the scripting languages currently have regular expression parsing functions, such as python, perl, etc., the regular expression can be used to parse the program to obtain the life cycle of each variable in the register; The module is configured to use a regular expression to parse the program to obtain the life cycle of each variable in the register. The parsing module includes a first obtaining submodule, a second obtaining submodule, and a statistical submodule; the first obtaining submodule is configured to obtain a variable of the program and a register definition thereof by using a regular expression to parse the program (ie, where the variable is located) The second acquisition sub-module is configured to obtain a life cycle of each variable by parsing the program by using a regular expression; the statistical sub-module is configured to, according to each variable and its register definition, the life cycle of each variable is counted in each register. The life cycle of each variable.
该装置还包括文本输出模块; 当寄存器中各变量的生命周期没有重叠 时, 检测模块将告知文本输出模块, 文本输出模块输出寄存器中各变量的 生命周期到文本文件中, 文本文件的表现形式可以为表格、 图形等。  The device further includes a text output module; when the life cycle of each variable in the register does not overlap, the detection module will inform the text output module, and the text output module outputs the life cycle of each variable in the register to the text file, and the text file can be expressed. For tables, graphics, etc.
需要说明的是, 上述获取模块 10、 检测模块 20及告警模块 30, 解析 模块、 第一获取子模块、 第二获取子模块及统计子模块, 输出模块, 都可 以由避免寄存器冲突的装置的中央处理器( CPU, Central Processing Unit )、 微处理器 (MPU, Micro Processing Unit )、 数字信号处理器(DSP, Digital Signal Processor )或可编程逻辑阵列( FPGA, Field - Programmable Gate Array ) 实现。  It should be noted that the foregoing obtaining module 10, the detecting module 20, the alarm module 30, the parsing module, the first obtaining submodule, the second obtaining submodule, the statistical submodule, and the output module may all be central to the device that avoids register conflicts. A CPU (Central Processing Unit), a Microprocessor (MPU), a Digital Signal Processor (DSP), or a Field-Programmable Gate Array (FPGA).
本发明实施例还提供一种计算机可读存储介质, 所述存储介质包括一 组计算机可执行指令, 所述指令用于执行本发明实施例所述的避免寄存器 冲突的方法。 本领域内的技术人员应明白, 本发明的实施例可提供为方法、 系统、 或计算机程序产品。 因此, 本发明可采用硬件实施例、 软件实施例、 或结 合软件和硬件方面的实施例的形式。 而且, 本发明可采用在一个或多个其 中包含有计算机可用程序代码的计算机可用存储介质 (包括但不限于磁盘 存储器和光学存储器等)上实施的计算机程序产品的形式。 An embodiment of the present invention further provides a computer readable storage medium, where the storage medium includes a The group of computer executable instructions for performing the method of avoiding register conflicts in accordance with an embodiment of the present invention. Those skilled in the art will appreciate that embodiments of the present invention can be provided as a method, system, or computer program product. Accordingly, the present invention can take the form of a hardware embodiment, a software embodiment, or a combination of software and hardware aspects. Moreover, the invention can take the form of a computer program product embodied on one or more computer usable storage media (including but not limited to disk storage and optical storage, etc.) in which computer usable program code is embodied.
本发明是参照根据本发明实施例的方法、 设备(系统)、 和计算机程序 产品的流程图和 /或方框图来描述的。 应理解可由计算机程序指令实现流程 图和 /或方框图中的每一流程和 /或方框、以及流程图和 /或方框图中的流程和 /或方框的结合。 可提供这些计算机程序指令到通用计算机、 专用计算机、 嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器, 使得 通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现 在流程图一个流程或多个流程和 /或方框图一个方框或多个方框中指定的功 能的装置。  The present invention has been described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (system), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flowchart and/or block diagrams, and combinations of flow and / or blocks in the flowcharts and / or block diagrams can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing device to produce a machine for the execution of instructions for execution by a processor of a computer or other programmable data processing device. Means for implementing the functions specified in one or more of the flow or in a block or blocks of the flow chart.
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理 设备以特定方式工作的计算机可读存储器中, 使得存储在该计算机可读存 储器中的指令产生包括指令装置的制造品, 该指令装置实现在流程图一个 流程或多个流程和 /或方框图一个方框或多个方框中指定的功能。  The computer program instructions can also be stored in a computer readable memory that can direct a computer or other programmable data processing device to operate in a particular manner, such that the instructions stored in the computer readable memory produce an article of manufacture comprising the instruction device. The apparatus implements the functions specified in one or more blocks of a flow or a flow and/or block diagram of the flowchart.
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上, 使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现 的处理, 从而在计算机或其他可编程设备上执行的指令提供用于实现在流 程图一个流程或多个流程和 /或方框图一个方框或多个方框中指定的功能的 步骤。 能认定本发明的具体实施只局限于这些说明。 对于本发明所属技术领域的 普通技术人员来说, 在不脱离本发明构思的前提下, 还可以做出若干简单 推演或替换, 都应当视为属于本发明的保护范围。 These computer program instructions can also be loaded onto a computer or other programmable data processing device such that a series of operational steps are performed on a computer or other programmable device to produce computer-implemented processing for execution on a computer or other programmable device. The instructions provide steps for implementing the functions specified in one or more of the flow or in a block or blocks of a flow diagram. It is to be understood that the specific embodiments of the invention are limited only by the description. It will be apparent to those skilled in the art that the present invention may be made without departing from the spirit and scope of the invention.

Claims

权利要求书 claims
1、 一种避免寄存器冲突的方法, 包括: 1. A method to avoid register conflicts, including:
获取程序在寄存器中各变量的生命周期; Get the life cycle of each variable in the register of the program;
检测所述寄存器中各变量的生命周期是否重叠, 并在检测结果为是 时进行告警。 Detect whether the life cycles of each variable in the register overlap, and issue an alarm when the detection result is yes.
2、 如权利要求 1所述的避免寄存器冲突的方法, 其中, 所述获取程 序在寄存器中各变量的生命周期的步骤包括: 2. The method of avoiding register conflicts as claimed in claim 1, wherein the step of obtaining the life cycle of each variable in the register of the program includes:
利用正则表达式对程序进行解析获取寄存器中各变量的生命周期。 Use regular expressions to parse the program to obtain the life cycle of each variable in the register.
3、 如权利要求 2所述的避免寄存器冲突的方法, 其中, 利用正则表 达式对程序进行解析获取寄存器中各变量的生命周期的步骤包括: 3. The method of avoiding register conflicts as claimed in claim 2, wherein the step of using regular expressions to parse the program to obtain the life cycle of each variable in the register includes:
利用正则表达式对程序变量定义部分进行解析, 获取程序的各变量 及其寄存器定义; Use regular expressions to parse the program variable definition part and obtain the program variables and their register definitions;
利用正则表达式对程序指令行进行解析, 获取各个变量的生命周期; 根据程序的各变量及其寄存器定义、 各个变量的生命周期统计各个 寄存器中各变量的生命周期。 Use regular expressions to parse the program instruction line to obtain the life cycle of each variable; calculate the life cycle of each variable in each register based on the definition of each variable of the program and its register, and the life cycle of each variable.
4、 如权利要求 1所述的避免寄存器冲突的方法, 其中, 所述进行告 警的步骤包括: 通过脚本向用户提示错误来实现告警。 4. The method for avoiding register conflicts as claimed in claim 1, wherein the step of alerting includes: prompting an error to the user through a script to implement the alert.
5、 如权利要求 1-4任一项所述的避免寄存器冲突的方法, 其中, 所 述方法还包括: 当所述寄存器中各变量的生命周期没有重叠时, 输出所 述程序在寄存器中各变量的生命周期到文本文件中。 5. The method for avoiding register conflicts according to any one of claims 1 to 4, wherein the method further includes: when the life cycles of the variables in the register do not overlap, outputting the program's values for each variable in the register. The lifetime of the variable into a text file.
6、 一种避免寄存器冲突的装置, 包括: 获取模块、 检测模块及告警 模块; 6. A device to avoid register conflicts, including: an acquisition module, a detection module and an alarm module;
所述获取模块配置为, 获取程序在寄存器中各变量的生命周期; 所述检测模块配置为, 检测所述寄存器中各变量的生命周期是否重 叠, 并在检测结果为是时发送通知给告警模块; 所述告警模块配置为, 在收到检测模块发送的通知后进行告警。 The acquisition module is configured to obtain the life cycle of each variable in the register of the program; the detection module is configured to detect whether the life cycles of each variable in the register overlap, and send a notification to the alarm module when the detection result is yes. ; The alarm module is configured to alarm after receiving the notification sent by the detection module.
7、 如权利要求 6所述的避免寄存器冲突的装置, 其中, 所述获取模 块还包括解析模块, 所述解析模块利用正则表达式对程序进行解析获取 寄存器中各变量的生命周期。 7. The device for avoiding register conflicts according to claim 6, wherein the acquisition module further includes a parsing module, and the parsing module uses regular expressions to parse the program to obtain the life cycle of each variable in the register.
8、 如权利要求 7所述的避免寄存器冲突的装置, 其中, 所述解析模 块包括第一获取子模块、 第二获取子模块及统计子模块; 8. The device for avoiding register conflicts as claimed in claim 7, wherein the analysis module includes a first acquisition sub-module, a second acquisition sub-module and a statistics sub-module;
所述第一获取子模块配置为, 利用正则表达式对程序变量定义部分 进行解析, 获取程序的各变量及其寄存器定义; The first acquisition sub-module is configured to use regular expressions to parse the program variable definition part and obtain each variable of the program and its register definition;
所述第二获取子模块配置为, 利用正则表达式对程序指令行进行解 析, 获取各个变量的生命周期; The second acquisition sub-module is configured to use regular expressions to parse the program instruction line and obtain the life cycle of each variable;
所述统计子模块配置为, 根据程序的各变量及其寄存器定义、 各个 变量的生命周期统计各个寄存器中各变量的生命周期。 The statistics submodule is configured to count the life cycle of each variable in each register according to each variable of the program and its register definition, and the life cycle of each variable.
9、 如权利要求 6所述的避免寄存器冲突的装置, 其中, 告警模块通 过脚本向用户提示错误来实现告警。 9. The device for avoiding register conflicts as claimed in claim 6, wherein the alarm module implements the alarm by prompting errors to the user through a script.
10、 如权利要求 6-9任一项所述的避免寄存器冲突的装置, 其中, 还 包括文本输出模块; 当所述寄存器中各变量的生命周期没有重叠时, 检 测模块将告知文本输出模块, 文本输出模块输出所述程序在寄存器中各 变量的生命周期到文本文件中。 10. The device for avoiding register conflicts according to any one of claims 6 to 9, further comprising a text output module; when the life cycles of the variables in the register do not overlap, the detection module will inform the text output module, The text output module outputs the life cycle of each variable in the register of the program to a text file.
11、 一种计算机可读存储介质, 所述存储介质包括一组计算机可执 行指令,所述指令用于执行权利要求 1-5任一项所述的避免寄存器冲突的 方法。 11. A computer-readable storage medium, the storage medium includes a set of computer-executable instructions, the instructions are used to execute the method of avoiding register conflicts according to any one of claims 1-5.
PCT/CN2014/080553 2013-12-23 2014-06-23 Method and apparatus for preventing register conflict WO2015096425A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201310719460.5 2013-12-23
CN201310719460.5A CN104731555A (en) 2013-12-23 2013-12-23 Method and device for avoiding conflict among registers

Publications (1)

Publication Number Publication Date
WO2015096425A1 true WO2015096425A1 (en) 2015-07-02

Family

ID=53455485

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2014/080553 WO2015096425A1 (en) 2013-12-23 2014-06-23 Method and apparatus for preventing register conflict

Country Status (2)

Country Link
CN (1) CN104731555A (en)
WO (1) WO2015096425A1 (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101151843A (en) * 2005-06-22 2008-03-26 中兴通讯股份有限公司 Text data digging method
CN101694627A (en) * 2009-10-23 2010-04-14 天津大学 Compiler system based on TCore configurable processor
US20130198728A1 (en) * 2012-01-26 2013-08-01 Qualcomm Incorporated Method and apparatus for avoiding register interference

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6434743B1 (en) * 1999-04-23 2002-08-13 Sun Microsystems, Inc. Method and apparatus for allocating stack slots
CN101539867B (en) * 2009-04-23 2011-07-20 上海交通大学 Retargetable register allocation method in dynamic binary translation system
US8434074B2 (en) * 2010-02-24 2013-04-30 Intel Corporation Register allocation with SIMD architecture using write masks
CN102033773B (en) * 2010-11-12 2013-08-14 西安电子科技大学 Method for distributing register in embedded system based on inverse image description
CN102360280B (en) * 2011-10-28 2014-04-23 浙江大学 Method for allocating registers for mixed length instruction set

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101151843A (en) * 2005-06-22 2008-03-26 中兴通讯股份有限公司 Text data digging method
CN101694627A (en) * 2009-10-23 2010-04-14 天津大学 Compiler system based on TCore configurable processor
US20130198728A1 (en) * 2012-01-26 2013-08-01 Qualcomm Incorporated Method and apparatus for avoiding register interference

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
CHANG, ZHIYAN: "Register Allocation Problem for Embedded Systems: Heuristic and Evolutionary Algorithm'';", ELECTRONIC TECHNOLOGY & INFORMATION SCIENCE , CHINA MASTER'S THESES FULL-TEXT DATABASE;, 15 May 2013 (2013-05-15), pages 8 *

Also Published As

Publication number Publication date
CN104731555A (en) 2015-06-24

Similar Documents

Publication Publication Date Title
WO2017041657A1 (en) Application interface management method and device
JP2016508350A5 (en)
JP2009509212A5 (en)
JP2016506698A5 (en)
JP2015508527A (en) Secure direct memory access
WO2016095570A1 (en) Debugging method and apparatus for embedded system, and storage medium
WO2021022710A1 (en) Message queue processing method, device, electronic apparatus, and computer readable non-volatile storage medium
JP2020537227A5 (en)
US11709756B2 (en) Dynamic distributed tracing instrumentation in a microservice architecture
WO2017049893A1 (en) Application program testing method, testing apparatus, and mobile terminal
WO2017107843A1 (en) Periodic task processing method and apparatus, computer program, and readable medium
CN104679493B (en) A kind of improved method of the event processing mechanism of procedure
WO2021120713A1 (en) Data processing method, decoding circuit, and processor
WO2024027240A1 (en) Calling method, apparatus and system for diagnosis module
TW201502985A (en) Method and device for processing file
JP2013030167A5 (en)
WO2022027773A1 (en) Multi-protocol port sharing method and system, and server
US11381630B2 (en) Transmitting data over a network in representational state transfer (REST) applications
US9298502B2 (en) Pausing virtual machines using API signaling
WO2015096425A1 (en) Method and apparatus for preventing register conflict
WO2017202083A1 (en) Microcode debugging method and single board
JPWO2012117500A1 (en) Communication device
JP2014013570A (en) Source level debugging apparatus and method for reconfigurable processor
WO2017054581A1 (en) Application program stopping failure detection method, system and apparatus
JP2011022778A (en) Flash memory processor and polling method for flash memory

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: 14874461

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: 14874461

Country of ref document: EP

Kind code of ref document: A1