WO2015013895A1 - Method and device for jump processing of a command - Google Patents

Method and device for jump processing of a command Download PDF

Info

Publication number
WO2015013895A1
WO2015013895A1 PCT/CN2013/080442 CN2013080442W WO2015013895A1 WO 2015013895 A1 WO2015013895 A1 WO 2015013895A1 CN 2013080442 W CN2013080442 W CN 2013080442W WO 2015013895 A1 WO2015013895 A1 WO 2015013895A1
Authority
WO
WIPO (PCT)
Prior art keywords
jump
current instruction
address
instruction
prefetch
Prior art date
Application number
PCT/CN2013/080442
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 华为技术有限公司
Priority to CN201380003958.XA priority Critical patent/CN104541243A/en
Priority to PCT/CN2013/080442 priority patent/WO2015013895A1/en
Publication of WO2015013895A1 publication Critical patent/WO2015013895A1/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/3802Instruction prefetching
    • G06F9/3804Instruction prefetching for branches, e.g. hedging, branch folding

Definitions

  • the present invention relates to computer technology, and in particular, to a method and apparatus for processing jumps of instructions. Background technique
  • the overhead of the jump of the instruction mainly comes from three aspects:
  • the jump instruction generates a beat from the PC (P-stage) to generate a jump.
  • the overhead caused by the destination address that is, the overhead caused by the execution of the instruction (E-stage);
  • the second aspect the overhead caused by the jump instruction jump, that is, from the current instruction (jump instruction) to the destination address
  • the overhead caused by the cache miss may occur when the instruction of the destination address takes a value.
  • the processor generally adopts a Branch Target Buffer (BTB) technology to reduce the overhead generated by the first aspect and the second aspect.
  • BTB Branch Target Buffer
  • the processor prefetches the existing instruction prefetching function mainly in accordance with the execution order of the instructions, so as to reduce the overhead generated by the third aspect.
  • the process of prefetching according to the execution order of the instruction is mainly: prefetch logic (prefetch) when the cache block (also called cache line) in which the Nth instruction is being executed is hit (hit) Logic) pre-fetches the N+1 line, or N+1 to N+2 line, or N+1 to N+4 line, etc. according to different prefetch strategies.
  • prefetch logic generally initiates the prefetch operation at the I-stage.
  • the present invention provides a method and apparatus for processing jumps of instructions for effectively reducing the overhead of the entire jump.
  • a first aspect of the present invention provides a method for processing a jump of an instruction, including:
  • the destination address of the jump corresponding to the current instruction is prefetched from the external memory, and the destination address corresponding to the current instruction is cached in the cache;
  • the current instruction is subjected to a jump processing according to the destination address of the jump corresponding to the current instruction in the cache.
  • the destination address of the jump corresponding to the current instruction is pre-fetched from the external memory, including:
  • the current instruction is a jump instruction
  • querying acquiring, from the BTB, a prefetch address corresponding to the current instruction
  • the destination address of the jump corresponding to the prefetch address is prefetched from the external memory.
  • the method further includes:
  • the next hop address of the address of the current instruction is prefetched from the external memory and the current instruction is corresponding to Before the destination address of the jump, the method further includes:
  • next hop address of the address of the current instruction and the destination address of the jump corresponding to the current instruction are pre-fetched from the external memory, including:
  • the method further includes:
  • the current instruction is subjected to jump processing according to the next hop address of the address of the current instruction in the cache.
  • a second aspect of the present invention provides a jump processing apparatus for an instruction, including:
  • a prefetching module configured to prefetch a destination address of the jump corresponding to the current instruction from an external memory when the current instruction is a jump instruction
  • a cache module configured to cache a destination address corresponding to the current instruction jump
  • a jump processing module configured to perform a jump processing on the current instruction according to a destination address of a jump corresponding to the current instruction in the cache module when determining that the jump result of the current instruction is a jump .
  • the prefetching module includes:
  • a query obtaining unit configured to: when the current instruction is a jump instruction, obtain a prefetch address corresponding to the current instruction from the BTB;
  • a prefetching unit configured to prefetch a destination address of the jump corresponding to the prefetch address from an external memory.
  • the prefetching unit is further configured to prefetch an address of the current instruction from the external memory. Next hop address;
  • the cache module is further configured to cache a next hop address of an address of the current instruction.
  • the method further includes:
  • a prediction module configured to perform branch prediction processing on the current instruction, to predict whether the jump result of the current instruction is a jump or not;
  • the prefetching unit is specifically configured to prefetch a destination address of the jump corresponding to the current instruction from the external memory when the prediction module predicts that the jump result of the current instruction is a jump, and Prefetching a next hop address of the address of the current instruction from the external memory after a preset period; or
  • the prefetching unit is specifically configured to prefetch a next hop address of an address of the current instruction from the external memory when the prediction module predicts that the jump result of the current instruction is no jump, and And pre-fetching a destination address of the jump corresponding to the current instruction from the external memory after the preset period.
  • the jump processing module is further configured to: when determining that the current instruction jump result is not jumping And performing a jump process on the current instruction according to a next hop address of an address of the current instruction in the cache module.
  • a third aspect of the present invention provides a computer, comprising: a memory for storing an instruction; a processor coupled to the memory, the processor configured to execute an instruction stored in the memory, and The processor is configured as a jump processing method for executing an instruction as described above.
  • FIG. 1 is a flow chart of an embodiment of a method for processing a twist in accordance with the present invention
  • FIG. 2 is a flow chart of another embodiment of a method for processing a twist in accordance with the present invention.
  • FIG. 3 is a flow chart of still another embodiment of a method for processing a twist in accordance with the present invention.
  • Figure 4 is a diagram showing the structure of an embodiment of the twirling processing apparatus of the present invention.
  • FIG. 5 is a flowchart of another embodiment of a method for processing a call forwarding according to the present invention.
  • FIG. 1 is a flowchart of an embodiment of a method for processing a jump of an instruction according to the present invention. As shown in FIG. Includes:
  • Step 101 When the current instruction is a jump instruction, prefetch the destination address of the jump corresponding to the current instruction from the external memory, and cache the destination address of the jump corresponding to the current instruction in the cache.
  • the current instruction when the currently executed instruction is a jump instruction, the current instruction may be in the P
  • the P-stage initiates a prefetch operation and simultaneously issues two commands (command) in the P+1 stage, where one command is used to prefetch in accordance with the current program counter (current PC). That is, the next hop address of the current instruction address is prefetched from the external memory; the other command starts prefetching according to the target program counter (Target PC) in the BTB, that is, prefetching the jump corresponding to the current instruction from the external memory Destination address.
  • the address of the current instruction is N
  • the next hop address of the current instruction address is N+1
  • the destination address of the jump corresponding to the current instruction may be N+100.
  • Step 102 When it is determined that the jump result of the current instruction is a jump, perform a jump processing on the current instruction according to the destination address of the jump corresponding to the current instruction in the cache.
  • the overhead of the instruction jump mainly comes from three aspects: The first aspect (which can be expressed as a), the jump instruction generates a beat from the PC (P-stage) to the destination address of the generated jump The overhead, that is, the overhead caused by the execution of the instruction (E-stage); the second aspect (which can be expressed as b), the overhead caused by the jump instruction jump, that is, from the current instruction (jump instruction) to the destination address The overhead caused by the jump; the third aspect (which can be expressed as c), the overhead caused by the cache miss may occur when the destination address is fetched.
  • the branch prediction is correct (that is, the predicted destination address is the same as the generated destination address), and the purpose of the jump
  • the overhead of the implementation may be c-1 (2 or 3) cycles.
  • the overhead of the entire jump can be Max ⁇ (a+b). ), (cl(2 or 3)) ⁇ cycles 0 where 1(2 or 3) means 1 or 2 or 3.
  • the current instruction when the current instruction is a jump instruction, prefetching the destination address of the jump corresponding to the current instruction from the external memory, and buffering the destination address of the jump of the current instruction in the cache, and determining When the jump result of the current instruction is a jump, the current instruction is jumped according to the destination address of the jump corresponding to the current instruction in the cache. Since the destination address of the jump corresponding to the current instruction is cached in the cache when the current instruction is a jump instruction, the branch prediction can be eliminated, and the overhead of the entire jump can be effectively reduced.
  • Step 101a When the current instruction is a jump instruction, query and obtain a prefetch corresponding to the current instruction from the BTB. address.
  • the prefetch address is the destination address of the jump corresponding to the current instruction.
  • Step 101b Prefetch the destination address of the jump corresponding to the prefetch address from the external memory.
  • Step 101c Cache the destination address corresponding to the current instruction in the cache.
  • the method may further include:
  • Step 103 Prefetch the next hop address of the address of the current instruction from the external memory; and cache the next hop address of the address of the current instruction in the cache.
  • next hop address of the current instruction address and the destination address of the jump corresponding to the current instruction may be pre-fetched from the external memory, and the current instruction is cached in the cache.
  • the next hop address of the address and the destination address of the jump corresponding to the current instruction may also prefetch the next hop address of the current instruction address and the destination address of the jump corresponding to the current instruction from the external memory.
  • FIG. 3 is a flowchart of still another embodiment of a method for processing a jump of an instruction according to the present invention. As shown in FIG. 3, the method includes:
  • Step 201 When the current instruction is a jump instruction, perform branch prediction processing on the current instruction to predict whether the jump result of the current instruction is a jump or not; if the jump result of the current instruction is predicted to be a jump Then, step 202 is performed; if the result of the jump of the current instruction is predicted to be no jump, step 203 is performed.
  • Step 202 Prefetch and cache the destination address of the jump corresponding to the current instruction from the external memory, and prefetch and cache the next hop address of the current instruction address from the external memory after the preset period. Then step 204 is performed.
  • step 202 a specific implementation manner of step 202 is:
  • Step 203 Prefetch and cache the next hop address of the current instruction address from the external memory, and prefetch and cache the destination address of the jump corresponding to the current instruction from the external memory after the preset period.
  • a specific implementation manner of step 203 is: prefetching a next hop address of the current instruction address from the external memory;
  • the prefetch address corresponding to the current instruction is obtained from the BTB, and the destination address of the jump corresponding to the current instruction is prefetched from the external memory.
  • the preset period may be any period between 1 and 2 periods.
  • Step 204 Determine whether the jump result of the current instruction is a jump or no jump. When it is determined that the jump result of the current instruction is a jump, perform step 205; when determining that the jump result of the current instruction is not jumping Then, step 206 is performed.
  • Step 205 Perform a jump process on the current instruction according to the destination address of the jump corresponding to the current instruction in the cache. End.
  • Step 206 Perform a jump process on the current instruction according to the next hop address of the address of the current instruction in the cache.
  • the aforementioned program can be stored in a computer readable storage medium.
  • the program when executed, performs the steps including the foregoing method embodiments; and the foregoing storage medium includes: a medium that can store program codes, such as a ROM, a RAM, a magnetic disk, or an optical disk.
  • the device includes: a prefetch module 11, a cache module 12, and a jump processing module 13; wherein, the prefetch module 11 For pre-fetching the destination address of the jump corresponding to the current instruction from the external memory when the current instruction is a jump instruction; the cache module 12 is configured to cache the destination address of the jump corresponding to the current instruction; When it is determined that the jump result of the current instruction is a jump, the current instruction is jumped according to the destination address of the jump corresponding to the current instruction in the cache module 12.
  • the jump processing device of the instruction of this embodiment can perform the technical solution of the method embodiment shown in FIG. 1 , and the implementation principles thereof are similar, and details are not described herein again.
  • the destination address of the jump corresponding to the current instruction is prefetched from the external memory, and the jump of the current instruction is cached in the cache.
  • the destination address and when it is determined that the jump result of the current instruction is a jump, the current instruction is jumped according to the destination address of the jump corresponding to the current instruction in the cache. Because when the pre-instruction is a jump instruction, the destination address of the jump corresponding to the current instruction is cached in the cache. Therefore, the branch prediction can be eliminated, and the overhead of the entire jump can be effectively reduced.
  • FIG. 5 is a schematic diagram showing the result of another embodiment of the jump processing device of the present invention.
  • the prefetch module 11 includes: a query obtaining unit 111 and The prefetching unit 112 is configured to: when the current instruction is a jump instruction, obtain a prefetch address corresponding to the current instruction from the BTB; the prefetch unit 112 is configured to prefetch from the external memory. The destination address of the jump corresponding to the prefetch address.
  • the device further includes: a prediction module 14 configured to perform branch prediction processing on the current instruction to predict whether the jump result of the current instruction is a jump or not;
  • the prefetching unit 112 is specifically configured to: when the prediction module 14 predicts that the jump result of the current instruction is a jump, prefetch the destination address of the jump corresponding to the current instruction from the external memory, and after the preset period Prefetching the next hop address of the address of the current instruction from the external memory; or, the prefetching unit 112 is specifically configured to: when the prediction module 14 predicts that the jump result of the current instruction is not jumping, from the external The next hop address of the address of the current instruction is prefetched in the memory, and the destination address of the jump corresponding to the current instruction is prefetched from the external memory after the preset period.
  • the jump processing module 13 is further configured to: when determining that the jump result of the current instruction is not jumping, skipping the current instruction according to a next hop address of an address of the current instruction in the cache module Transfer processing.
  • the jump processing device of the instruction of this embodiment may perform the technical solution of the method embodiment shown in FIG. 2 or FIG. 3, and the implementation principles thereof are similar, and details are not described herein again.
  • the present invention also provides a computer comprising a memory and a processor; wherein the memory is for storing instructions; the processor is coupled to the memory, the processor is configured to execute instructions stored in the memory, and the processor is
  • the implementation of the jump processing method for executing the instructions of any of the following FIG. 1 to FIG. 3 is similar to the implementation principle, and details are not described herein again.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Memory System Of A Hierarchy Structure (AREA)
  • Advance Control (AREA)

Abstract

The present invention provides a method and device for jump processing of a command, the method comprising: if the current command is a jump command, pre-fetching from external memory the destination address of the jump corresponding to the current command, and caching in the cache the destination address of the jump corresponding to the current command; if the jump result of the current command is determined to be a jump, performing jump processing on the current command according to the destination address in the cache and of the jump corresponding to the current command.

Description

指令的跳转处理方法和装置  Instruction jump processing method and device
技术领域 Technical field
本发明涉及计算机技术, 尤其涉及一种指令的跳转处理方法和装置。 背景技术  The present invention relates to computer technology, and in particular, to a method and apparatus for processing jumps of instructions. Background technique
目前, 在指令的跳转为条件跳转 (conditional jump ) 时, 指令的跳转的 开销主要来自三个方面: 第一方面, 跳转指令从 PC生成节拍 (P-stage)到生 成跳转的目的地址所造成的开销, 即指令执行完成节拍 (E-stage) 所造成的 开销; 第二方面, 跳转指令发生跳转所造成的开销, 即从当前指令 (跳转指 令) 到目的地址的跳转所造成的开销; 第三方面, 在目的地址的指令取值时 可能会发生高速缓存缺失而造成的开销。  At present, when the jump of the instruction is a conditional jump, the overhead of the jump of the instruction mainly comes from three aspects: In the first aspect, the jump instruction generates a beat from the PC (P-stage) to generate a jump. The overhead caused by the destination address, that is, the overhead caused by the execution of the instruction (E-stage); the second aspect, the overhead caused by the jump instruction jump, that is, from the current instruction (jump instruction) to the destination address The overhead caused by the jump; In the third aspect, the overhead caused by the cache miss may occur when the instruction of the destination address takes a value.
现有技术中,处理器一般采用动态分支预测(Branch Target Buffer;简称: BTB ) 技术来减少上述第一方面和第二方面所产生的开销。 另外, 处理器对 于现有指令预取功能也主要按照指令的执行顺序预取, 以减少上述第三方面 所产生的开销。 具体的, 按照指令的执行顺序预取的过程主要为: 当正在执 行的第 N条指令所在的缓存块 (cache block, 还可以称之为 cache line) 命中 (hit) 时, 预取逻辑(prefetch logic)根据不同的预取策略, 自动顺序的预取 第 N+1 line, 或者 N+1 to N+2 line, 或者 N+1 to N+4 line等。 其中, 需要说 明的是, 该 prefetch logic一般在 I-stage时发起上述预取操作。  In the prior art, the processor generally adopts a Branch Target Buffer (BTB) technology to reduce the overhead generated by the first aspect and the second aspect. In addition, the processor prefetches the existing instruction prefetching function mainly in accordance with the execution order of the instructions, so as to reduce the overhead generated by the third aspect. Specifically, the process of prefetching according to the execution order of the instruction is mainly: prefetch logic (prefetch) when the cache block (also called cache line) in which the Nth instruction is being executed is hit (hit) Logic) pre-fetches the N+1 line, or N+1 to N+2 line, or N+1 to N+4 line, etc. according to different prefetch strategies. It should be noted that the prefetch logic generally initiates the prefetch operation at the I-stage.
但是, 若仅是采用 BTB技术或者执行顺序预取的功能, 则还是会存在如 下三种情况的跳转开销:  However, if you only use BTB technology or perform sequential prefetching, there are still jump costs in the following three cases:
第一种情况, 在跳转指令发生跳转、 分支预测正确 (即预测的目的地址 与生成的目的地址相同) , 且跳转的目的地址超出了现有预取范围时, 还会 造成在第三方面的开销;  In the first case, when the jump instruction jumps and the branch prediction is correct (that is, the predicted destination address is the same as the generated destination address), and the destination address of the jump exceeds the existing prefetch range, Three aspects of the cost;
第二种情况, 在跳转指令发生跳转、 分支预测错误 (即预测的目的地址 与生成的目的地址不相同) , 且跳转的目的地址超出了现有预取范围时, 还 会造成上述三个方面的开销。 发明内容 In the second case, when the jump instruction jumps and the branch prediction error (that is, the predicted destination address is different from the generated destination address), and the destination address of the jump exceeds the existing prefetch range, Three aspects of overhead. Summary of the invention
本发明提供一种指令的跳转处理方法和装置, 用于有效地降低了整个跳 转的开销。  The present invention provides a method and apparatus for processing jumps of instructions for effectively reducing the overhead of the entire jump.
本发明的第一个方面是提供一种指令的跳转处理方法, 包括:  A first aspect of the present invention provides a method for processing a jump of an instruction, including:
在当前指令为跳转指令时, 从外部存储器中预取所述当前指令对应的跳 转的目的地址, 并在缓存中缓存所述当前指令对应跳转的目的地址;  When the current instruction is a jump instruction, the destination address of the jump corresponding to the current instruction is prefetched from the external memory, and the destination address corresponding to the current instruction is cached in the cache;
当确定所述当前指令的跳转结果为跳转时, 根据所述缓存中的所述当前 指令对应的跳转的目的地址, 对所述当前指令进行跳转处理。  When it is determined that the jump result of the current instruction is a jump, the current instruction is subjected to a jump processing according to the destination address of the jump corresponding to the current instruction in the cache.
在第一个方面的第一种可能实现方式中,所述在当前指令为跳转指令时, 从外部存储器中预取所述当前指令对应的跳转的目的地址, 包括:  In a first possible implementation manner of the first aspect, when the current instruction is a jump instruction, the destination address of the jump corresponding to the current instruction is pre-fetched from the external memory, including:
在所述当前指令为跳转指令时,从 BTB中查询获取所述当前指令对应的 预取地址;  When the current instruction is a jump instruction, querying, acquiring, from the BTB, a prefetch address corresponding to the current instruction;
从外部存储器中预取与所述预取地址对应的跳转的目的地址。  The destination address of the jump corresponding to the prefetch address is prefetched from the external memory.
结合第一个方面或第一个方面的第一种可能实现方式, 在第一个方面的 第二种可能实现方式中, 在当前指令为跳转指令时, 所述方法还包括:  With the first aspect or the first possible implementation of the first aspect, in a second possible implementation manner of the first aspect, when the current instruction is a jump instruction, the method further includes:
从所述外部存储器中预取所述当前指令的地址的下一跳地址; 并在所述 缓存中缓存所述当前指令的地址的下一跳地址。  Prefetching a next hop address of the address of the current instruction from the external memory; and buffering a next hop address of the address of the current instruction in the cache.
结合第一方面的第二种可能实现方式, 在第一方面的第三种可能实现方 式中, 从所述外部存储器中预取所述当前指令的地址的下一跳地址和所述当 前指令对应的跳转的目的地址之前, 所述方法还包括:  In conjunction with the second possible implementation of the first aspect, in a third possible implementation of the first aspect, the next hop address of the address of the current instruction is prefetched from the external memory and the current instruction is corresponding to Before the destination address of the jump, the method further includes:
对所述当前指令进行分支预测处理, 以预测所述当前指令的跳转结果为 跳转还是不跳转;  Performing branch prediction processing on the current instruction to predict whether the jump result of the current instruction is a jump or not;
则所述从所述外部存储器中预取所述当前指令的地址的下一跳地址和所 述当前指令对应的跳转的目的地址, 包括:  Then, the next hop address of the address of the current instruction and the destination address of the jump corresponding to the current instruction are pre-fetched from the external memory, including:
当预测所述当前指令的跳转结果为跳转时, 从所述外部存储器中预取所 述当前指令对应的跳转的目的地址, 并在预设周期后从所述外部存储器中预 取所述当前指令的地址的下一跳地址;  When predicting that the jump result of the current instruction is a jump, prefetching a destination address of the jump corresponding to the current instruction from the external memory, and prefetching the external memory from the external memory after a preset period The next hop address of the address of the current instruction;
当预测所述当前指令的跳转结果为不跳转时, 从所述外部存储器中预取 所述当前指令的地址的下一跳地址, 并在所述预设周期后从所述外部存储器 中预取所述当前指令对应的跳转的目的地址。 结合第一方面的第二种可能实现方式, 在第一方面的第四种可能实现方 式中, 还包括: Prefetching a next hop address of an address of the current instruction from the external memory when predicting a jump result of the current instruction as not jumping, and from the external memory after the preset period Prefetching the destination address of the jump corresponding to the current instruction. In conjunction with the second possible implementation of the first aspect, in a fourth possible implementation of the first aspect, the method further includes:
当确定所述当前指令的跳转结果为不跳转时, 根据所述缓存中的所述当 前指令的地址的下一跳地址, 对所述当前指令进行跳转处理。  When it is determined that the jump result of the current instruction is no jump, the current instruction is subjected to jump processing according to the next hop address of the address of the current instruction in the cache.
本发明的第二个方面是提供一种指令的跳转处理装置, 包括:  A second aspect of the present invention provides a jump processing apparatus for an instruction, including:
预取模块, 用于在当前指令为跳转指令时, 从外部存储器中预取所述当 前指令对应的跳转的目的地址;  a prefetching module, configured to prefetch a destination address of the jump corresponding to the current instruction from an external memory when the current instruction is a jump instruction;
缓存模块, 用于缓存所述当前指令对应跳转的目的地址;  a cache module, configured to cache a destination address corresponding to the current instruction jump;
跳转处理模块, 用于当确定所述当前指令的跳转结果为跳转时, 根据所 述缓存模块中的所述当前指令对应的跳转的目的地址, 对所述当前指令进行 跳转处理。  a jump processing module, configured to perform a jump processing on the current instruction according to a destination address of a jump corresponding to the current instruction in the cache module when determining that the jump result of the current instruction is a jump .
在第二个方面的第一种可能实现方式中, 所述预取模块包括:  In a first possible implementation manner of the second aspect, the prefetching module includes:
查询获取单元, 用于在所述当前指令为跳转指令时, 从 BTB中查询获取 所述当前指令对应的预取地址;  a query obtaining unit, configured to: when the current instruction is a jump instruction, obtain a prefetch address corresponding to the current instruction from the BTB;
预取单元, 用于从外部存储器中预取与所述预取地址对应的跳转的目的 地址。  And a prefetching unit, configured to prefetch a destination address of the jump corresponding to the prefetch address from an external memory.
结合第二个方面的第一种可能实现方式中, 在第二个方面的第二种可能 实现方式中, 所述预取单元还用于从所述外部存储器中预取所述当前指令的 地址的下一跳地址;  In conjunction with the first possible implementation of the second aspect, in a second possible implementation of the second aspect, the prefetching unit is further configured to prefetch an address of the current instruction from the external memory. Next hop address;
所述缓存模块还用于缓存所述当前指令的地址的下一跳地址。  The cache module is further configured to cache a next hop address of an address of the current instruction.
结合第二个方面的第二种可能实现方式, 在第二个方面的第三种可能实 现方式中, 还包括:  In combination with the second possible implementation of the second aspect, in a third possible implementation of the second aspect, the method further includes:
预测模块, 用于对所述当前指令进行分支预测处理, 以预测所述当前指 令的跳转结果为跳转还是不跳转;  a prediction module, configured to perform branch prediction processing on the current instruction, to predict whether the jump result of the current instruction is a jump or not;
则所述预取单元具体用于当所述预测模块预测所述当前指令的跳转结果 为跳转时, 从所述外部存储器中预取所述当前指令对应的跳转的目的地址, 并在预设周期后从所述外部存储器中预取所述当前指令的地址的下一跳地 址; 或者,  The prefetching unit is specifically configured to prefetch a destination address of the jump corresponding to the current instruction from the external memory when the prediction module predicts that the jump result of the current instruction is a jump, and Prefetching a next hop address of the address of the current instruction from the external memory after a preset period; or
所述预取单元具体用于当所述预测模块预测所述当前指令的跳转结果为 不跳转时, 从所述外部存储器中预取所述当前指令的地址的下一跳地址, 并 在所述预设周期后从所述外部存储器中预取所述当前指令对应的跳转的目的 地址。 The prefetching unit is specifically configured to prefetch a next hop address of an address of the current instruction from the external memory when the prediction module predicts that the jump result of the current instruction is no jump, and And pre-fetching a destination address of the jump corresponding to the current instruction from the external memory after the preset period.
结合第二个方面的第二种可能实现方式, 在第二个方面的第四种可能实 现方式中, 所述跳转处理模块还用于当确定所述当前指令的跳转结果为不跳 转时, 根据所述缓存模块中的所述当前指令的地址的下一跳地址, 对所述当 前指令进行跳转处理。  With the second possible implementation of the second aspect, in a fourth possible implementation manner of the second aspect, the jump processing module is further configured to: when determining that the current instruction jump result is not jumping And performing a jump process on the current instruction according to a next hop address of an address of the current instruction in the cache module.
本发明的第三个方面是提供一种计算机, 包括: 存储器, 用于存储指令; 处理器, 与所述存储器耦合, 所述处理器被配置为执行存储在所述存储 器中的指令, 且所述处理器被配置为用于执行如上述所述的指令的跳转处理 方法。  A third aspect of the present invention provides a computer, comprising: a memory for storing an instruction; a processor coupled to the memory, the processor configured to execute an instruction stored in the memory, and The processor is configured as a jump processing method for executing an instruction as described above.
本发明的技术效果是: 在当前指令为跳转指令时, 从外部存储器中预取 该当前指令对应的跳转的目的地址, 并在缓存中缓存该当前指令的跳转的目 的地址, 并当确定该当前指令的跳转结果为跳转时, 根据该缓存中的当前指 令对应的跳转的目的地址, 对该当前指令进行跳转处理。 由于在当前指令为 跳转指令时, 缓存中缓存了该当前指令对应的跳转的目的地址, 因此, 即可 以不依赖于分支预测, 还可以有效地降低了在整个跳转的开销。 附图说明 图 1为本发明指 眺转处理方法的一个实施例的流程图;  The technical effect of the present invention is: when the current instruction is a jump instruction, prefetching the destination address of the jump corresponding to the current instruction from the external memory, and buffering the destination address of the jump of the current instruction in the cache, and When it is determined that the jump result of the current instruction is a jump, the current instruction is jumped according to the destination address of the jump corresponding to the current instruction in the cache. Since the destination address of the jump corresponding to the current instruction is cached in the cache when the current instruction is a jump instruction, the overhead of the entire jump can be effectively reduced without relying on branch prediction. BRIEF DESCRIPTION OF DRAWINGS FIG. 1 is a flow chart of an embodiment of a method for processing a twist in accordance with the present invention;
图 2为本发明指 眺转处理方法的另一个实施例的流程图;  2 is a flow chart of another embodiment of a method for processing a twist in accordance with the present invention;
图 3为本发明指 眺转处理方法的又一个实施例的流程图;  3 is a flow chart of still another embodiment of a method for processing a twist in accordance with the present invention;
图 4为本发明指 眺转处理装置的一个实施例的结构  Figure 4 is a diagram showing the structure of an embodiment of the twirling processing apparatus of the present invention;
图 5为本发明指 眺转处理装置的另一个实施例的结 具体实施方式 图 1为本发明指令的跳转处理方法的一个实施例的流程图,如图 1所示, 本实施例的方法包括:  FIG. 5 is a flowchart of another embodiment of a method for processing a call forwarding according to the present invention. FIG. 1 is a flowchart of an embodiment of a method for processing a jump of an instruction according to the present invention. As shown in FIG. Includes:
步骤 101、 在当前指令为跳转指令时, 从外部存储器中预取该当前指令 对应的跳转的目的地址,并在缓存中缓存该当前指令对应的跳转的目的地址。  Step 101: When the current instruction is a jump instruction, prefetch the destination address of the jump corresponding to the current instruction from the external memory, and cache the destination address of the jump corresponding to the current instruction in the cache.
在本实施例中, 在当前执行的指令为跳转指令时, 可以在当前指令的 P 阶段 (P-stage) 发起预取操作, 并在 P+1阶段 (P+1 stage) 同时发出两条命 令 (command) , 其中, 一条命令用于按照当前程序计数器 (current PC) 顺 序预取, 即从外部存储器中预取该当前指令的地址的下一跳地址; 另一条命 令按照 BTB中目标程序计数器(Target PC)开始预取, 即从外部存储器中预 取该当前指令对应的跳转的目的地址。 举例来说, 当前指令的地址为 N, 则 当前指令的地址的下一跳地址为 N+1 , 该当前指令对应的跳转的目的地址可 以为 N+100。 In this embodiment, when the currently executed instruction is a jump instruction, the current instruction may be in the P The P-stage initiates a prefetch operation and simultaneously issues two commands (command) in the P+1 stage, where one command is used to prefetch in accordance with the current program counter (current PC). That is, the next hop address of the current instruction address is prefetched from the external memory; the other command starts prefetching according to the target program counter (Target PC) in the BTB, that is, prefetching the jump corresponding to the current instruction from the external memory Destination address. For example, if the address of the current instruction is N, the next hop address of the current instruction address is N+1, and the destination address of the jump corresponding to the current instruction may be N+100.
步骤 102、 当确定该当前指令的跳转结果为跳转时, 根据该缓存中的该 当前指令对应的跳转的目的地址, 对该当前指令进行跳转处理。  Step 102: When it is determined that the jump result of the current instruction is a jump, perform a jump processing on the current instruction according to the destination address of the jump corresponding to the current instruction in the cache.
在本实施例中, 指令的跳转的开销主要来自三个方面: 第一方面 (可以 表示为 a) , 跳转指令从 PC生成节拍 (P-stage) 到生成跳转的目的地址所造 成的开销, 即指令执行完成节拍 (E-stage ) 所造成的开销; 第二方面 (可以 表示为 b ) , 跳转指令发生跳转所造成的开销, 即从当前指令 (跳转指令) 到目的地址的跳转所造成的开销; 第三方面(可以表示为 c) , 在目的地址的 指令取值时可能会发生高速缓存缺失而造成的开销.  In this embodiment, the overhead of the instruction jump mainly comes from three aspects: The first aspect (which can be expressed as a), the jump instruction generates a beat from the PC (P-stage) to the destination address of the generated jump The overhead, that is, the overhead caused by the execution of the instruction (E-stage); the second aspect (which can be expressed as b), the overhead caused by the jump instruction jump, that is, from the current instruction (jump instruction) to the destination address The overhead caused by the jump; the third aspect (which can be expressed as c), the overhead caused by the cache miss may occur when the destination address is fetched.
另外, 在本实施例中, 针对现有技术中的第一种情况, 即在跳转指令发 生跳转、 分支预测正确 (即预测的目的地址与生成的目的地址相同) , 且跳 转的目的地址超出了现有预取范围时, 采用本实施的技术方案, 整个跳转的 开销可以为 c-1 (2 or 3 ) cycles  In addition, in this embodiment, for the first case in the prior art, that is, the jump instruction jumps, the branch prediction is correct (that is, the predicted destination address is the same as the generated destination address), and the purpose of the jump When the address exceeds the existing prefetch range, the overhead of the implementation may be c-1 (2 or 3) cycles.
针对现有技术中的第二种情况, 即在跳转指令发生跳转、 分支预测错误 For the second case in the prior art, that is, a jump instruction jump, a branch prediction error
(即预测的目的地址与生成的目的地址不相同) , 且跳转的目的地址超出了 现有预取范围时, 采用本实施的技术方案, 整个跳转的开销可以为 Max{(a+b),(c-l(2 or 3))}cycles0 其中, 1(2 or 3)表示 1或 2或 3。 (The predicted destination address is different from the generated destination address), and the destination address of the jump exceeds the existing prefetch range. With the technical solution of this implementation, the overhead of the entire jump can be Max{(a+b). ), (cl(2 or 3))}cycles 0 where 1(2 or 3) means 1 or 2 or 3.
在本实施例中, 在当前指令为跳转指令时, 从外部存储器中预取该当前 指令对应的跳转的目的地址,并在缓存中缓存该当前指令的跳转的目的地址, 并当确定该当前指令的跳转结果为跳转时, 根据该缓存中的当前指令对应的 跳转的目的地址, 对该当前指令进行跳转处理。 由于在当前指令为跳转指令 时, 缓存中缓存了该当前指令对应的跳转的目的地址, 因此, 即可以不依赖 于分支预测, 还可以有效地降低了在整个跳转的开销。  In this embodiment, when the current instruction is a jump instruction, prefetching the destination address of the jump corresponding to the current instruction from the external memory, and buffering the destination address of the jump of the current instruction in the cache, and determining When the jump result of the current instruction is a jump, the current instruction is jumped according to the destination address of the jump corresponding to the current instruction in the cache. Since the destination address of the jump corresponding to the current instruction is cached in the cache when the current instruction is a jump instruction, the branch prediction can be eliminated, and the overhead of the entire jump can be effectively reduced.
图 2为本发明指令的跳转处理方法的另一个实施例的流程图, 在上述图 1所示上述例的基础上, 如图 2所示, 步骤 101的一种具体实现方式为: 步骤 101a、在该当前指令为跳转指令时,从 BTB中查询获取该当前指令 对应的预取地址。 2 is a flow chart of another embodiment of a jump processing method of an instruction of the present invention, in the above figure On the basis of the above example shown in FIG. 2, a specific implementation manner of step 101 is as follows: Step 101a: When the current instruction is a jump instruction, query and obtain a prefetch corresponding to the current instruction from the BTB. address.
在本实施例中, 该预取地址为当前指令对应的跳转的目的地址。  In this embodiment, the prefetch address is the destination address of the jump corresponding to the current instruction.
步骤 101b、 从外部存储器中预取与该预取地址对应的跳转的目的地址。 步骤 101c、 在缓存中缓存该当前指令对应的目的地址。  Step 101b: Prefetch the destination address of the jump corresponding to the prefetch address from the external memory. Step 101c: Cache the destination address corresponding to the current instruction in the cache.
可选地, 该方法还可以包括:  Optionally, the method may further include:
步骤 103, 从该外部存储器中预取该当前指令的地址的下一跳地址; 并 在该缓存中缓存该当前指令的地址的下一跳地址。  Step 103: Prefetch the next hop address of the address of the current instruction from the external memory; and cache the next hop address of the address of the current instruction in the cache.
在本实施例中, 需要说明的是, 可以从外部存储器中同时预取该当前指 令的地址的下一跳地址和该当前指令对应的跳转的目的地址, 并在该缓存中 缓存该当前指令的地址的下一跳地址和该当前指令对应的跳转的目的地址, 还可以先后从外部存储器中预取该当前指令的地址的下一跳地址和该当前指 令对应的跳转的目的地址。  In this embodiment, it should be noted that the next hop address of the current instruction address and the destination address of the jump corresponding to the current instruction may be pre-fetched from the external memory, and the current instruction is cached in the cache. The next hop address of the address and the destination address of the jump corresponding to the current instruction may also prefetch the next hop address of the current instruction address and the destination address of the jump corresponding to the current instruction from the external memory.
图 3为本发明指令的跳转处理方法的又一个实施例的流程图, 如图 3所 示, 该方法包括:  FIG. 3 is a flowchart of still another embodiment of a method for processing a jump of an instruction according to the present invention. As shown in FIG. 3, the method includes:
步骤 201、 在当前指令为跳转指令时, 对该当前指令进行分支预测处理, 以预测该当前指令的跳转结果为跳转还是不跳转; 若预测该当前指令的跳转 结果为跳转, 则执行步骤 202; 若预测该当前指令的跳转结果为不跳转, 则 执行步骤 203。  Step 201: When the current instruction is a jump instruction, perform branch prediction processing on the current instruction to predict whether the jump result of the current instruction is a jump or not; if the jump result of the current instruction is predicted to be a jump Then, step 202 is performed; if the result of the jump of the current instruction is predicted to be no jump, step 203 is performed.
步骤 202、 从该外部存储器中预取并缓存该当前指令对应的跳转的目的 地址, 并在预设周期后从该外部存储器中预取并缓存该当前指令的地址的下 一跳地址。 再执行步骤 204。  Step 202: Prefetch and cache the destination address of the jump corresponding to the current instruction from the external memory, and prefetch and cache the next hop address of the current instruction address from the external memory after the preset period. Then step 204 is performed.
在本实施例中, 可选地, 步骤 202的一种具体实现方式为:  In this embodiment, optionally, a specific implementation manner of step 202 is:
从 BTB中查询获取该当前指令对应的预取地址,并从该外部存储器中预 取该当前指令对应的跳转的目的地址;  Obtaining a prefetch address corresponding to the current instruction from the BTB, and prefetching a destination address of the jump corresponding to the current instruction from the external memory;
在预设周期后从该外部存储器中预取该当前指令的地址的下一跳地址。 步骤 203、 从该外部存储器中预取并缓存该当前指令的地址的下一跳地 址, 并在该预设周期后从该外部存储器中预取并缓存该当前指令对应的跳转 的目的地址。 在本实施例中, 可选地, 步骤 203的一种具体实现方式为: 从该外部存储器中预取该当前指令的地址的下一跳地址; The next hop address of the address of the current instruction is prefetched from the external memory after a preset period. Step 203: Prefetch and cache the next hop address of the current instruction address from the external memory, and prefetch and cache the destination address of the jump corresponding to the current instruction from the external memory after the preset period. In this embodiment, optionally, a specific implementation manner of step 203 is: prefetching a next hop address of the current instruction address from the external memory;
在预设周期后从 BTB中查询获取该当前指令对应的预取地址,并从该外 部存储器中预取该当前指令对应的跳转的目的地址。  After the preset period, the prefetch address corresponding to the current instruction is obtained from the BTB, and the destination address of the jump corresponding to the current instruction is prefetched from the external memory.
另外, 该预设周期可以为 1至 2个周期之间的任意周期。  In addition, the preset period may be any period between 1 and 2 periods.
步骤 204、 确定该当前指令的跳转结果为跳转还是不跳转, 当确定该当 前指令的跳转结果为跳转, 则执行步骤 205 ; 当确定该当前指令的跳转结果 为不跳转, 则执行步骤 206。  Step 204: Determine whether the jump result of the current instruction is a jump or no jump. When it is determined that the jump result of the current instruction is a jump, perform step 205; when determining that the jump result of the current instruction is not jumping Then, step 206 is performed.
步骤 205、 根据该缓存中的该当前指令对应的跳转的目的地址, 对该当 前指令进行跳转处理。 结束。  Step 205: Perform a jump process on the current instruction according to the destination address of the jump corresponding to the current instruction in the cache. End.
步骤 206、 根据该缓存中的该当前指令的地址的下一跳地址, 对该当前 指令进行跳转处理。  Step 206: Perform a jump process on the current instruction according to the next hop address of the address of the current instruction in the cache.
本领域普通技术人员可以理解: 实现上述各方法实施例的全部或部分步 骤可以通过程序指令相关的硬件来完成。 前述的程序可以存储于一计算机可 读取存储介质中。 该程序在执行时, 执行包括上述各方法实施例的步骤; 而 前述的存储介质包括: ROM、 RAM,磁碟或者光盘等各种可以存储程序代码 的介质。  One of ordinary skill in the art will appreciate that all or a portion of the steps to implement the various method embodiments described above can be accomplished by hardware associated with the program instructions. The aforementioned program can be stored in a computer readable storage medium. The program, when executed, performs the steps including the foregoing method embodiments; and the foregoing storage medium includes: a medium that can store program codes, such as a ROM, a RAM, a magnetic disk, or an optical disk.
图 4为本发明指令的跳转处理装置的一个实施例的结构示意图, 如图 4 所示, 该装置包括: 预取模块 11、 缓存模块 12和跳转处理模块 13 ; 其中, 预取模块 11用于在当前指令为跳转指令时,从外部存储器中预取该当前指令 对应的跳转的目的地址;缓存模块 12用于缓存该当前指令对应跳转的目的地 址; 跳转处理模块 13用于当确定该当前指令的跳转结果为跳转时, 根据该缓 存模块 12中的该当前指令对应的跳转的目的地址,对该当前指令进行跳转处 理。  4 is a schematic structural diagram of an embodiment of a jump processing device of the present invention. As shown in FIG. 4, the device includes: a prefetch module 11, a cache module 12, and a jump processing module 13; wherein, the prefetch module 11 For pre-fetching the destination address of the jump corresponding to the current instruction from the external memory when the current instruction is a jump instruction; the cache module 12 is configured to cache the destination address of the jump corresponding to the current instruction; When it is determined that the jump result of the current instruction is a jump, the current instruction is jumped according to the destination address of the jump corresponding to the current instruction in the cache module 12.
本实施例的指令的跳转处理装置可以执行图 1所示方法实施例的技术方 案, 其实现原理相类似, 此处不再赘述。  The jump processing device of the instruction of this embodiment can perform the technical solution of the method embodiment shown in FIG. 1 , and the implementation principles thereof are similar, and details are not described herein again.
在本实施例中, 在本实施例中, 在当前指令为跳转指令时, 从外部存储 器中预取该当前指令对应的跳转的目的地址, 并在缓存中缓存该当前指令的 跳转的目的地址, 并当确定该当前指令的跳转结果为跳转时, 根据该缓存中 的当前指令对应的跳转的目的地址, 对该当前指令进行跳转处理。 由于在当 前指令为跳转指令时, 缓存中缓存了该当前指令对应的跳转的目的地址, 因 此, 即可以不依赖于分支预测, 还可以有效地降低了在整个跳转的开销。 In this embodiment, in the embodiment, when the current instruction is a jump instruction, the destination address of the jump corresponding to the current instruction is prefetched from the external memory, and the jump of the current instruction is cached in the cache. The destination address, and when it is determined that the jump result of the current instruction is a jump, the current instruction is jumped according to the destination address of the jump corresponding to the current instruction in the cache. Because when When the pre-instruction is a jump instruction, the destination address of the jump corresponding to the current instruction is cached in the cache. Therefore, the branch prediction can be eliminated, and the overhead of the entire jump can be effectively reduced.
图 5为本发明指令的跳转处理装置的另一个实施例的结果示意图, 在上 述图 4所示实施例的基础上, 如图 5所示, 该预取模块 11包括: 查询获取单 元 111和预取单元 112; 其中, 查询获取单元 111用于在该当前指令为跳转 指令时, 从 BTB中查询获取该当前指令对应的预取地址; 预取单元 112用于 从外部存储器中预取与该预取地址对应的跳转的目的地址。  FIG. 5 is a schematic diagram showing the result of another embodiment of the jump processing device of the present invention. On the basis of the embodiment shown in FIG. 4, as shown in FIG. 5, the prefetch module 11 includes: a query obtaining unit 111 and The prefetching unit 112 is configured to: when the current instruction is a jump instruction, obtain a prefetch address corresponding to the current instruction from the BTB; the prefetch unit 112 is configured to prefetch from the external memory. The destination address of the jump corresponding to the prefetch address.
可选地, 装置还包括: 预测模块 14, 用于对该当前指令进行分支预测处 理, 以预测该当前指令的跳转结果为跳转还是不跳转;  Optionally, the device further includes: a prediction module 14 configured to perform branch prediction processing on the current instruction to predict whether the jump result of the current instruction is a jump or not;
则预取单元 112具体用于当该预测模块 14预测该当前指令的跳转结果为 跳转时, 从该外部存储器中预取该当前指令对应的跳转的目的地址, 并在预 设周期后从该外部存储器中预取该当前指令的地址的下一跳地址; 或者, 该预取单元 112具体用于当该预测模块 14预测该当前指令的跳转结果为 不跳转时, 从该外部存储器中预取该当前指令的地址的下一跳地址, 并在该 预设周期后从该外部存储器中预取该当前指令对应的跳转的目的地址。  The prefetching unit 112 is specifically configured to: when the prediction module 14 predicts that the jump result of the current instruction is a jump, prefetch the destination address of the jump corresponding to the current instruction from the external memory, and after the preset period Prefetching the next hop address of the address of the current instruction from the external memory; or, the prefetching unit 112 is specifically configured to: when the prediction module 14 predicts that the jump result of the current instruction is not jumping, from the external The next hop address of the address of the current instruction is prefetched in the memory, and the destination address of the jump corresponding to the current instruction is prefetched from the external memory after the preset period.
可选地,跳转处理模块 13还用于当确定该当前指令的跳转结果为不跳转 时, 根据该缓存模块中的该当前指令的地址的下一跳地址, 对该当前指令进 行跳转处理。  Optionally, the jump processing module 13 is further configured to: when determining that the jump result of the current instruction is not jumping, skipping the current instruction according to a next hop address of an address of the current instruction in the cache module Transfer processing.
本实施例的指令的跳转处理装置可以执行图 2或图 3所示方法实施例的 技术方案, 其实现原理相类似, 此处不再赘述。  The jump processing device of the instruction of this embodiment may perform the technical solution of the method embodiment shown in FIG. 2 or FIG. 3, and the implementation principles thereof are similar, and details are not described herein again.
本发明还提供了一种计算机, 包括存储器和处理器; 其中, 存储器用于 存储指令; 处理器, 与存储器耦合, 该处理器被配置为执行存储在该存储器 中的指令, 且该处理器被配置为用于执行图 1至图 3任一所述的指令的跳转 处理方法, 其实现原理相类似, 此处不再赘述。  The present invention also provides a computer comprising a memory and a processor; wherein the memory is for storing instructions; the processor is coupled to the memory, the processor is configured to execute instructions stored in the memory, and the processor is The implementation of the jump processing method for executing the instructions of any of the following FIG. 1 to FIG. 3 is similar to the implementation principle, and details are not described herein again.
最后应说明的是: 以上各实施例仅用以说明本发明的技术方案, 而非对 其限制; 尽管参照前述各实施例对本发明进行了详细的说明, 本领域的普通 技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改, 或者对其中部分或者全部技术特征进行等同替换; 而这些修改或者替换, 并 不使相应技术方案的本质脱离本发明各实施例技术方案的范围。  Finally, it should be noted that the above embodiments are only for explaining the technical solutions of the present invention, and are not intended to be limiting thereof; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art will understand that The technical solutions described in the foregoing embodiments may be modified, or some or all of the technical features may be equivalently replaced; and the modifications or substitutions do not deviate from the technical solutions of the embodiments of the present invention. range.

Claims

权 利 要 求 书 claims
1、 一种指令的跳转处理方法, 其特征在于, 包括: 1. An instruction jump processing method, characterized by including:
在当前指令为跳转指令时, 从外部存储器中预取所述当前指令对应的跳 转的目的地址, 并在缓存中缓存所述当前指令对应跳转的目的地址; When the current instruction is a jump instruction, prefetch the destination address of the jump corresponding to the current instruction from the external memory, and cache the destination address of the jump corresponding to the current instruction in the cache;
当确定所述当前指令的跳转结果为跳转时, 根据所述缓存中的所述当前 指令对应的跳转的目的地址, 对所述当前指令进行跳转处理。 When it is determined that the jump result of the current instruction is a jump, jump processing is performed on the current instruction according to the jump destination address corresponding to the current instruction in the cache.
2、 根据权利要求 1所述的指令的跳转处理方法, 其特征在于, 所述在当 前指令为跳转指令时, 从外部存储器中预取所述当前指令对应的跳转的目的 地址, 包括: 2. The instruction jump processing method according to claim 1, wherein when the current instruction is a jump instruction, prefetching the jump destination address corresponding to the current instruction from the external memory includes: :
在所述当前指令为跳转指令时,从 BTB中查询获取所述当前指令对应的 预取地址; When the current instruction is a jump instruction, query and obtain the prefetch address corresponding to the current instruction from the BTB;
从外部存储器中预取与所述预取地址对应的跳转的目的地址。 Prefetch the jump destination address corresponding to the prefetch address from the external memory.
3、 根据权利要求 1或 2所述的指令的跳转处理方法, 其特征在于, 在当 前指令为跳转指令时, 所述方法还包括: 3. The instruction jump processing method according to claim 1 or 2, characterized in that when the current instruction is a jump instruction, the method further includes:
从所述外部存储器中预取所述当前指令的地址的下一跳地址; 并在所述 缓存中缓存所述当前指令的地址的下一跳地址。 Prefetch the next hop address of the address of the current instruction from the external memory; and cache the next hop address of the address of the current instruction in the cache.
4、 根据权利要求 3所述的指令的跳转处理方法, 其特征在于, 从所述外 部存储器中预取所述当前指令的地址的下一跳地址和所述当前指令对应的跳 转的目的地址之前, 所述方法还包括: 4. The instruction jump processing method according to claim 3, characterized in that, the next jump address of the address of the current instruction and the purpose of the jump corresponding to the current instruction are prefetched from the external memory. Before the address, the method also includes:
对所述当前指令进行分支预测处理, 以预测所述当前指令的跳转结果为 跳转还是不跳转; Perform branch prediction processing on the current instruction to predict whether the jump result of the current instruction will be a jump or not;
则所述从所述外部存储器中预取所述当前指令的地址的下一跳地址和所 述当前指令对应的跳转的目的地址, 包括: Then, prefetching the next jump address of the address of the current instruction and the destination address of the jump corresponding to the current instruction from the external memory include:
当预测所述当前指令的跳转结果为跳转时, 从所述外部存储器中预取所 述当前指令对应的跳转的目的地址, 并在预设周期后从所述外部存储器中预 取所述当前指令的地址的下一跳地址; When the jump result of the current instruction is predicted to be a jump, the destination address of the jump corresponding to the current instruction is prefetched from the external memory, and the destination address of the jump corresponding to the current instruction is prefetched from the external memory after a preset period. The next hop address of the address of the current instruction;
当预测所述当前指令的跳转结果为不跳转时, 从所述外部存储器中预取 所述当前指令的地址的下一跳地址, 并在所述预设周期后从所述外部存储器 中预取所述当前指令对应的跳转的目的地址。 When the jump result of the current instruction is predicted to be no jump, the next jump address of the address of the current instruction is prefetched from the external memory, and after the preset cycle, the next jump address of the address of the current instruction is fetched from the external memory. Prefetch the destination address of the jump corresponding to the current instruction.
5、 根据权利要求 3所述的指令的跳转处理方法, 其特征在于, 还包括: 当确定所述当前指令的跳转结果为不跳转时, 根据所述缓存中的所述当 前指令的地址的下一跳地址, 对所述当前指令进行跳转处理。 5. The instruction jump processing method according to claim 3, further comprising: When it is determined that the jump result of the current instruction is not to jump, jump processing is performed on the current instruction according to the next jump address of the address of the current instruction in the cache.
6、 一种指令的跳转处理装置, 其特征在于, 包括: 6. An instruction jump processing device, characterized in that it includes:
预取模块, 用于在当前指令为跳转指令时, 从外部存储器中预取所述当 前指令对应的跳转的目的地址; A prefetch module, used to prefetch the jump destination address corresponding to the current instruction from the external memory when the current instruction is a jump instruction;
缓存模块, 用于缓存所述当前指令对应跳转的目的地址; A cache module, used to cache the destination address of the jump corresponding to the current instruction;
跳转处理模块, 用于当确定所述当前指令的跳转结果为跳转时, 根据所 述缓存模块中的所述当前指令对应的跳转的目的地址, 对所述当前指令进行 跳转处理。 A jump processing module, configured to perform jump processing on the current instruction according to the destination address of the jump corresponding to the current instruction in the cache module when it is determined that the jump result of the current instruction is a jump. .
7、 根据权利要求 6所述的指令的跳转处理装置, 其特征在于, 所述预取 模块包括: 7. The instruction jump processing device according to claim 6, characterized in that the prefetch module includes:
查询获取单元, 用于在所述当前指令为跳转指令时, 从 BTB中查询获取 所述当前指令对应的预取地址; A query acquisition unit, configured to query and acquire the prefetch address corresponding to the current instruction from the BTB when the current instruction is a jump instruction;
预取单元, 用于从外部存储器中预取与所述预取地址对应的跳转的目的 地址。 The prefetch unit is used to prefetch the jump destination address corresponding to the prefetch address from the external memory.
8、 根据权利要求 7所述的指令的跳转处理装置, 其特征在于, 所述预取 单元还用于从所述外部存储器中预取所述当前指令的地址的下一跳地址; 所述缓存模块还用于缓存所述当前指令的地址的下一跳地址。 8. The instruction jump processing device according to claim 7, wherein the prefetch unit is further used to prefetch the next hop address of the address of the current instruction from the external memory; The cache module is also used to cache the next hop address of the address of the current instruction.
9、 根据权利要求 8所述的指令的跳转处理装置, 其特征在于, 还包括: 预测模块, 用于对所述当前指令进行分支预测处理, 以预测所述当前指 令的跳转结果为跳转还是不跳转; 9. The instruction jump processing device according to claim 8, further comprising: a prediction module, configured to perform branch prediction processing on the current instruction to predict the jump result of the current instruction as a jump To jump or not to jump;
则所述预取单元具体用于当所述预测模块预测所述当前指令的跳转结果 为跳转时, 从所述外部存储器中预取所述当前指令对应的跳转的目的地址, 并在预设周期后从所述外部存储器中预取所述当前指令的地址的下一跳地 址; 或者, Then the prefetch unit is specifically configured to prefetch the destination address of the jump corresponding to the current instruction from the external memory when the prediction module predicts that the jump result of the current instruction is a jump, and Prefetch the next hop address of the address of the current instruction from the external memory after a preset period; or,
所述预取单元具体用于当所述预测模块预测所述当前指令的跳转结果为 不跳转时, 从所述外部存储器中预取所述当前指令的地址的下一跳地址, 并 在所述预设周期后从所述外部存储器中预取所述当前指令对应的跳转的目的 地址。 The prefetch unit is specifically configured to prefetch the next jump address of the address of the current instruction from the external memory when the prediction module predicts that the jump result of the current instruction is no jump, and After the preset period, the destination address of the jump corresponding to the current instruction is prefetched from the external memory.
10、 根据权利要求 8所述的指令的跳转处理装置, 其特征在于, 所述跳 转处理模块还用于当确定所述当前指令的跳转结果为不跳转时, 根据所述缓 存模块中的所述当前指令的地址的下一跳地址, 对所述当前指令进行跳转处 理。 10. The instruction jump processing device according to claim 8, characterized in that: the jump The transfer processing module is also configured to perform jump processing on the current instruction according to the next jump address of the address of the current instruction in the cache module when it is determined that the jump result of the current instruction is not to jump. .
11、 一种计算机, 其特征在于, 包括: 存储器, 用于存储指令; 处理器, 与所述存储器耦合, 所述处理器被配置为执行存储在所述存储 器中的指令, 且所述处理器被配置为用于执行如权利要求 1至 5任一所述的 指令的跳转处理方法。 11. A computer, characterized in that it includes: a memory for storing instructions; a processor coupled to the memory, the processor being configured to execute instructions stored in the memory, and the processor A jump processing method configured to execute instructions according to any one of claims 1 to 5.
PCT/CN2013/080442 2013-07-30 2013-07-30 Method and device for jump processing of a command WO2015013895A1 (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201380003958.XA CN104541243A (en) 2013-07-30 2013-07-30 Method and device for jump processing of a command
PCT/CN2013/080442 WO2015013895A1 (en) 2013-07-30 2013-07-30 Method and device for jump processing of a command

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2013/080442 WO2015013895A1 (en) 2013-07-30 2013-07-30 Method and device for jump processing of a command

Publications (1)

Publication Number Publication Date
WO2015013895A1 true WO2015013895A1 (en) 2015-02-05

Family

ID=52430842

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2013/080442 WO2015013895A1 (en) 2013-07-30 2013-07-30 Method and device for jump processing of a command

Country Status (2)

Country Link
CN (1) CN104541243A (en)
WO (1) WO2015013895A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106445466A (en) * 2015-08-13 2017-02-22 深圳市中兴微电子技术有限公司 Instruction processing method and apparatus of very-long-instruction-word instruction set

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109634666B (en) * 2018-12-11 2022-11-15 华夏芯(北京)通用处理器技术有限公司 Method for fusing BTBs (Branch target bus) under prefetching mechanism
CN110083389A (en) * 2019-05-08 2019-08-02 苏州浪潮智能科技有限公司 A kind of forecasting method, device and the equipment of branch's jump instruction

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102087634A (en) * 2011-01-27 2011-06-08 凌阳科技股份有限公司 Device and method for improving cache hit ratio
CN102184091A (en) * 2011-04-18 2011-09-14 孙瑞琛 Branch predicting method and device
CN102349051A (en) * 2008-12-04 2012-02-08 美国亚德诺半导体公司 Methods and apparatus for performing jump operations in a digital processor
US20120084497A1 (en) * 2010-09-30 2012-04-05 Samantika Subramaniam Instruction Prefetching Using Cache Line History

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102349051A (en) * 2008-12-04 2012-02-08 美国亚德诺半导体公司 Methods and apparatus for performing jump operations in a digital processor
US20120084497A1 (en) * 2010-09-30 2012-04-05 Samantika Subramaniam Instruction Prefetching Using Cache Line History
CN102087634A (en) * 2011-01-27 2011-06-08 凌阳科技股份有限公司 Device and method for improving cache hit ratio
CN102184091A (en) * 2011-04-18 2011-09-14 孙瑞琛 Branch predicting method and device

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106445466A (en) * 2015-08-13 2017-02-22 深圳市中兴微电子技术有限公司 Instruction processing method and apparatus of very-long-instruction-word instruction set

Also Published As

Publication number Publication date
CN104541243A (en) 2015-04-22

Similar Documents

Publication Publication Date Title
TWI529618B (en) Single cycle multi-branch prediction including shadow cache for early far branch prediction
US7444501B2 (en) Methods and apparatus for recognizing a subroutine call
JP5579694B2 (en) Method and apparatus for managing a return stack
TWI502347B (en) Branch prediction power reduction
CN112579175B (en) Branch prediction method, branch prediction device and processor core
TWI502496B (en) Microprocessor capable of branch prediction power reduction
US10031852B2 (en) Arithmetic processing apparatus and control method of the arithmetic processing apparatus
Ishii et al. Re-establishing fetch-directed instruction prefetching: An industry perspective
JP2011013864A (en) Instruction controller, instruction control method and arithmetic circuit
JP2016505972A (en) Speculative addressing using virtual address-physical address page cross buffer
JP2023531913A (en) Instruction address translation and instruction prefetch engine
WO2015013895A1 (en) Method and device for jump processing of a command
JP2008186233A (en) Instruction cache pre-fetch control method and device thereof
CN116048627B (en) Instruction buffering method, apparatus, processor, electronic device and readable storage medium
JP2004145454A (en) Information processor and information processing method
US20140025894A1 (en) Processor using branch instruction execution cache and method of operating the same
JP2007193433A (en) Information processor
JP5696210B2 (en) Processor and instruction processing method thereof
US10318303B2 (en) Method and apparatus for augmentation and disambiguation of branch history in pipelined branch predictors
JP2008015668A (en) Task management device
CN117472446B (en) Branch prediction method of multi-stage instruction fetching target buffer based on processor
CN111124494B (en) Method and circuit for accelerating unconditional jump in CPU
JP4002288B2 (en) Information processing device
US20140344551A1 (en) Dual-mode instruction fetching apparatus and method
US7343481B2 (en) Branch prediction in a data processing system utilizing a cache of previous static predictions

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

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

Country of ref document: EP

Kind code of ref document: A1