Register access method and electronic device

By establishing the register address space and virtual access instructions during compilation and converting them into hardware access instructions, the problem of insufficient flexibility in traditional register operations is solved, and the application scenarios and access speed advantages of registers are improved.

CN118550585APending Publication Date: 2024-08-27SHANGHAI BIREN TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410667593.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-27
Publication Date
2024-08-27

AI Technical Summary

Technical Problem

Traditional registers have insufficient operational flexibility in the instruction scheduling optimization of application programs, making it difficult to expand application scenarios, and their access speed advantages cannot be fully utilized.

Method used

By establishing the register address space and virtual access instructions of the target register during compilation, and converting them into hardware access instructions after compilation is completed, the operational flexibility and versatility of the registers are increased.

Benefits of technology

Without changing the register hardware control mechanism, the operational flexibility and versatility of the register are improved, and its application scenarios in practical applications are enhanced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118550585A
    Figure CN118550585A
Patent Text Reader

Abstract

The invention provides a register access method and an electronic device. The method comprises the steps of obtaining a program code; during compiling of the program code, a register address space and a virtual access instruction corresponding to the target register are established, the register address space comprises multiple pieces of address information, the multiple pieces of address information point to the target register, and the virtual access instruction indicates that the target register is accessed based on at least one of the multiple pieces of address information; and after compilation of the program code is completed, converting the virtual access instruction into a hardware access instruction to access the target register based on the hardware access instruction.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to a register access technology, and more particularly to a register access method and an electronic device. Background Art

[0002] Traditionally, when a compiler compiles the program code of an application, it can choose to use registers alone, memory alone (i.e. storage), or both registers and memory as data cache space. If memory is used as data cache space, the address of the memory is unknown (i.e. variable) during compilation. However, if registers are used as data cache space, the index of the register is known (i.e. fixed) during compilation. Generally speaking, compared to registers, using memory as data cache space with a variable memory address can facilitate the execution of optimization processes such as instruction scheduling for application programs. However, compared to memory, registers have an absolute advantage in access speed. Therefore, how to overcome the inherent defects of registers and further expand the possible application scenarios of registers is one of the topics that technicians in this field are committed to studying. Summary of the invention

[0003] The present disclosure provides a register access method and an electronic device, which can increase the operational flexibility and versatility of the register in practical applications without changing the conventional hardware control mechanism of the register.

[0004] An embodiment of the present disclosure provides a register access method, which includes: obtaining a program code; during the compilation of the program code, establishing a register address space and a virtual access instruction corresponding to a target register, wherein the register address space includes a plurality of address information, the plurality of address information points to the target register, and the virtual access instruction indicates access to the target register based on at least one of the plurality of address information; and after completing the compilation of the program code, converting the virtual access instruction into a hardware access instruction to access the target register based on the hardware access instruction.

[0005] An embodiment of the present disclosure further provides an electronic device, which includes a target register and a processor. The processor is connected to the target register. The processor is used to: obtain a program code; during the compilation of the program code, establish a register address space and a virtual access instruction corresponding to the target register, wherein the register address space includes a plurality of address information, the plurality of address information points to the target register, and the virtual access instruction indicates access to the target register based on at least one of the plurality of address information; and after completing the compilation of the program code, convert the virtual access instruction into a hardware access instruction to access the target register based on the hardware access instruction.

[0006] Based on the above, during the compilation of the program code, a register address space and a virtual access instruction corresponding to the target register can be established. In particular, the register address space may include multiple address information, the multiple address information points to the target register, and the virtual access instruction may indicate to access the target register based on at least one of the multiple address information. After completing the compilation of the program code, the virtual access instruction can be converted into a hardware access instruction to facilitate the subsequent access to the target register based on the hardware access instruction. Therefore, the operational flexibility and versatility of the register in practical applications can be increased without changing the conventional hardware control mechanism of the register. BRIEF DESCRIPTION OF THE DRAWINGS

[0007] Figure 1 is a schematic diagram of an electronic device according to an embodiment of the present disclosure;

[0008] Figure 2 is a schematic diagram of a register address space corresponding to a target register according to an embodiment of the present disclosure;

[0009] Figure 3 is a flowchart of a register access method according to an embodiment of the present disclosure. DETAILED DESCRIPTION

[0010] As mentioned above, generally speaking, compared to registers, using memory as a data cache space with a variable memory address can facilitate optimization processes such as instruction scheduling for applications. However, compared to memory, registers have an absolute advantage in access speed.

[0011] The register access method and electronic device proposed in the present disclosure can increase the operational flexibility and versatility of the register in practical applications without changing the conventional hardware control mechanism of the register by establishing and using a register address space and virtual access instructions corresponding to the target register.

[0012] Reference will now be made in detail to exemplary embodiments of the present disclosure, examples of which are illustrated in the accompanying drawings. Whenever possible, the same reference numerals are used in the drawings and the description to refer to the same or like parts.

[0013] Figure 1 is a schematic diagram of an electronic device according to an embodiment of the present disclosure. Figure 1 The electronic device 10 may be a smart phone, a tablet computer, a notebook computer, a desktop computer, an industrial computer, a server, or a vehicle-mounted computer, and other electronic devices with computing and information processing functions, and the type of the electronic device 10 is not limited thereto.

[0014] The electronic device 10 includes a processor 11, a register (also referred to as a target register) 12, and a memory 13. The processor 11 may be used to be responsible for the overall or partial operation of the electronic device 10. In one embodiment, the processor 11 refers to a central processing unit (CPU). In one embodiment, the processor 11 may also include a programmable general-purpose or special-purpose microprocessor, a digital signal processor (DSP), a programmable controller, an application specific integrated circuit (ASIC), a programmable logic device (PLD), or other similar devices or a combination of these devices.

[0015] The register 12 is connected to the processor 11. The register 12 can be used to temporarily store data. For example, the register 12 can be configured inside the processor 11 for the processor 11 to quickly access (i.e., access). For example, the register 12 can include an n-bit register to store n bits. For example, n can be 8, 16, or other integers. When storing data in the register 12, the processor 11 can write the data to the register 12 in parallel or serially at one or more input terminals of the register 12. In addition, when reading data from the register 12, the processor 11 can read the data in parallel or serially at one or more output terminals of the register 12. It should be noted that the present disclosure does not limit the type and number of registers 12.

[0016] The memory 13 is connected to the processor 11. The memory 13 can be used to temporarily store data. For example, the memory 13 can be configured outside the processor 11. For example, the memory 13 can be connected to the processor 11 through an external pin of the processor 11 and transmit signals with the processor 11. For example, the memory 13 may include a dynamic random access memory (DRAM), a static random access memory (DRAM), or other types of memory. In one embodiment, the memory 13 is also referred to as a primary memory or memory used with the processor 11. It should be noted that the access speed of the processor 11 to the register 12 is higher than the access speed of the processor 11 to the memory 13. In addition, the present disclosure does not limit the type and quantity of the memory 13.

[0017] In one embodiment, the electronic device 10 may further include a storage circuit, a network interface card, a screen, a power management circuit, a mouse, a keyboard, a touch pad, other types of peripheral devices or (input / output devices), which are not limited in the present disclosure.

[0018] In one embodiment, the processor 11 can obtain the program code 14. For example, the program code 14 can be written and arranged by a developer based on a high-level programming language. For example, common high-level programming languages ​​include C, C++, Java or Python, and the types of high-level programming languages ​​are not limited thereto. In one embodiment, a high-level programming language is a general term compared to a low-level programming language. For example, common low-level programming languages ​​include machine languages ​​and assembly languages. The processor 11 can compile the program code 14 through a compiler to generate an executable file corresponding to the program code 14.

[0019] In one embodiment, during the compilation of the program code 14, the processor 11 may establish an address space (also referred to as a register address space) corresponding to the register 12. The register address space may include a plurality of address information. In particular, the plurality of address information all point to the register 12. Therefore, the processor 11 (or a developer) may manage, access or store the register 12 based on the plurality of address information.

[0020] Figure 2 is a schematic diagram of a register address space corresponding to a target register according to an embodiment of the present disclosure. Figure 2In one embodiment, it is assumed that the register address space 21 includes address information 201(1)-201(n), and the register 12 includes a plurality of sub-storage spaces 202(1)-202(n). Each of the address information 201(1)-201(n) may point to one of the sub-storage spaces 202(1)-202(n). For example, the address information 201(i) may point to the sub-storage space 202(i). i may be an integer between 1 and n. The sub-storage space 202(i) may be used to store one or more bits, which is not limited by the present disclosure.

[0021] In one embodiment, the processor 11 may manage, access or store the sub-storage space 202(i) based on the address information 201(i). For example, the processor 11 may instruct to write data to the sub-storage space 202(i) or read data from the sub-storage space 202(i) based on the address information 201(i).

[0022] In one embodiment, the processor 11 may classify a plurality of registers (also referred to as candidate registers). For example, the plurality of candidate registers are all configured inside the processor 11 for quick access by the processor 11. In one embodiment, the processor 11 may classify at least one of the plurality of candidate registers as a first type of register, and classify at least another of the plurality of candidate registers as a second type of register. After completing the compilation of the program code 14 and generating an executable file corresponding to the program code 14, the first type of registers may be used to cache transient data generated during the running of the executable file. In addition, the second type of registers are not used to cache the transient data.

[0023] In one embodiment, the processor 11 may determine at least one of the plurality of candidate registers as the register 12 (i.e., the target register) according to the classification result of the plurality of candidate registers. For example, the processor 11 may determine at least one register classified as a first-category register among the plurality of candidate registers as the register 12 (i.e., the target register).

[0024] In one embodiment, for at least one register (i.e., the second type of register) among the plurality of candidate registers that is not determined as the register 12 (i.e., the target register), the processor 11 may not establish an address space corresponding to the second type of register. For example, for the remaining registers (i.e., the second type of registers) in the processor 11 that do not belong to the first type of registers, the processor 11 may maintain normal operations for the second type of registers to support normal operations of the electronic device 10.

[0025] In one embodiment, during the compilation of the program code 14, the processor 11 may also establish a virtual access instruction. The virtual access instruction may indicate accessing the register 12 based on at least one of the plurality of address information. For example, the virtual access instruction is generated based on compiling a high-level programming language (i.e., a portion of an array in the program code 14 written in a high-level programming language). For example, the virtual access instruction may include a virtual load instruction and a virtual store instruction. The virtual load instruction may be used to indicate reading data from the register 12. The virtual store instruction may be used to indicate storing data in the register 12.

[0026] In one embodiment, the virtual access instruction is used to emulate a memory access instruction that can be used to access the memory 13. For example, the memory access instruction may include a load instruction and a store instruction. The load instruction may be used to instruct to read data from the memory 13. The store instruction may be used to instruct to store data in the memory 13.

[0027] It should be noted that the memory access instruction can be used to directly access the memory (e.g., the memory 13), but the virtual access instruction cannot be used to directly access the register 12. For example, the processor 11 can instruct the memory controller (not shown) to access the memory 13 according to the memory access instruction. However, according to the virtual access instruction, the processor 11 must convert the virtual access instruction into a hardware instruction (also called a hardware access instruction) and then instruct the register 12 to write or output data through the hardware access instruction.

[0028] In one embodiment, after completing the compilation of the program code 14, the processor 11 may convert the virtual access instruction into a hardware access instruction corresponding to the register 12, so as to access the register 12 based on the hardware access instruction. In one embodiment, the processor 11 may generate a hardware access instruction corresponding to the virtual access instruction (or the register 12) according to the address information indicated or carried by the virtual access instruction. Figure 2 For example, assume that the address information 201(i) indicated or carried by the virtual access instruction points to the sub-storage space 202(i) in the register 12. After completing the compilation of the program code 14, the processor 11 may convert the virtual access instruction into a hardware access instruction indicating access to the sub-storage space 202(i) in the register 12. Thereafter, during the execution of the executable file corresponding to the program code 14, the processor 11 may access or store the register 12 (e.g., the sub-storage space 202(i)) according to the hardware access instruction.

[0029] In one embodiment, the register 12 cannot recognize the virtual access instruction, but the register 12 can recognize the hardware access instruction. For example, the register 12 can recognize the hardware access instruction and can execute the access behavior indicated by the hardware access instruction. Figure 2 For example, the register 12 may write data to the sub-storage space 202 ( i ) or read data from the sub-storage space 202 ( i ) according to the hardware access instruction.

[0030] In one embodiment, after converting the virtual access instruction into the hardware access instruction, the processor 11 may synchronously remove (i.e., delete) the virtual access instruction. In one embodiment, the virtual access instruction may be regarded as a transient access instruction generated in order to generate the hardware access instruction. Therefore, in response to the hardware access instruction being generated, the virtual access instruction may be removed.

[0031] Figure 3 is a flow chart of a register access method according to an embodiment of the present disclosure. Figure 3 In step S301, a program code is obtained. In step S302, during the compilation of the program code, a register address space and a virtual access instruction corresponding to a target register are established, wherein the register address space includes a plurality of address information, the plurality of address information points to the target register, and the virtual access instruction indicates accessing the target register based on at least one of the plurality of address information. In step S302, after the compilation of the program code is completed, the virtual access instruction is converted into a hardware access instruction to access the target register based on the hardware access instruction.

[0032] In one embodiment, the register access method further includes: classifying a plurality of candidate registers; and determining at least one of the plurality of candidate registers as the target register according to the classification result.

[0033] In one embodiment, the register access method further comprises: after converting the virtual access instruction into the hardware access instruction, removing the virtual access instruction.

[0034] However, Figure 3 The steps in the above are described in detail, so I will not repeat them here. It is worth noting that Figure 3 Each step in the above process can be implemented as multiple program codes or circuits, which is not limited in this case. Figure 3 The method can be used in conjunction with the above exemplary embodiments or can be used alone, and this case is not limited thereto.

[0035] According to another aspect of the present disclosure, a computer-readable storage medium is also provided. A computer program is stored on the computer-readable storage medium. The computer program includes computer-readable instructions. When the computer program is run by a processor, the register access method according to the embodiment of the present disclosure described above can be executed. The computer-readable storage medium in the embodiment of the present disclosure can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories. The non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM) or a flash memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous linked dynamic random access memory (SLDRAM), and direct memory bus random access memory (DR RAM).

[0036] In summary, the register access method and electronic device proposed in the embodiments of the present disclosure can increase the operational flexibility and versatility of the register in practical applications without changing the conventional hardware control mechanism of the register by establishing and using the register address space and virtual access instructions corresponding to the target register. In addition, the register access method and electronic device proposed in the embodiments of the present disclosure can also classify and use multiple candidate registers to support and avoid affecting the normal operation of the electronic device.

[0037] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present disclosure, rather than to limit them. Although the present disclosure has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein by equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present disclosure.

Claims

1. A register access method, characterized in that: include: Get the program code; During the compilation of the program code, a register address space and a virtual access instruction corresponding to the target register are established, wherein the register address space includes a plurality of address information, the plurality of address information points to the target register, and the virtual access instruction indicates accessing the target register based on at least one of the plurality of address information; as well as After the program code is compiled, the virtual access instruction is converted into a hardware access instruction, so as to access the target register based on the hardware access instruction.

2. The register access method according to claim 1, further comprising: classifying a plurality of candidate registers; as well as According to the classification result, at least one of the plurality of candidate registers is determined as the target register.

3. The register access method according to claim 1, wherein: The target register includes a plurality of sub-storage spaces, and each of the plurality of address information points to one of the plurality of sub-storage spaces.

4. The register access method according to claim 1, wherein: The virtual access instruction is generated based on compiling a high-level programming language.

5. The register access method according to claim 1, wherein: The virtual access instruction is used to imitate a memory access instruction. The memory access instruction is used to directly access a memory. The virtual access instruction cannot be used to directly access the target register.

6. The register access method according to claim 1, further comprising: After converting the virtual access instruction into the hardware access instruction, the virtual access instruction is removed.

7. The register access method according to claim 1, wherein: The program code is compiled by a processor, and the target register is configured inside the processor.

8. An electronic device, characterized in that: include: Destination register; as well as a processor, connected to the target register, Wherein, the processor is used to: Get the program code; During the compilation of the program code, a register address space and a virtual access instruction corresponding to the target register are established, wherein the register address space includes a plurality of address information, the plurality of address information points to the target register, and the virtual access instruction instructs to access the target register based on at least one of the plurality of address information; and After the program code is compiled, the virtual access instruction is converted into a hardware access instruction, so as to access the target register based on the hardware access instruction.

9. The electronic device according to claim 8, wherein: The processor is also used to: classifying a plurality of candidate registers; and According to the classification result, at least one of the plurality of candidate registers is determined as the target register.

10. The electronic device according to claim 8, wherein: The target register includes a plurality of sub-storage spaces, and each of the plurality of address information points to one of the plurality of sub-storage spaces.

11. The electronic device according to claim 8, wherein: The virtual access instruction is used to imitate a memory access instruction. The memory access instruction is used to directly access a memory. The virtual access instruction cannot be used to directly access the target register.

12. The electronic device according to claim 8, wherein: The program code is compiled by the processor, and the target register is configured inside the processor.