[go: up one dir, main page]

CN111240682B - A method, device, and storage medium for processing instruction data - Google Patents

A method, device, and storage medium for processing instruction data Download PDF

Info

Publication number
CN111240682B
CN111240682B CN201811436260.8A CN201811436260A CN111240682B CN 111240682 B CN111240682 B CN 111240682B CN 201811436260 A CN201811436260 A CN 201811436260A CN 111240682 B CN111240682 B CN 111240682B
Authority
CN
China
Prior art keywords
instruction
source operand
type
fields
instructions
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201811436260.8A
Other languages
Chinese (zh)
Other versions
CN111240682A (en
Inventor
徐东伟
石金锋
姚克奇
朱智华
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Sanechips Technology Co Ltd
Original Assignee
Sanechips Technology Co Ltd
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 Sanechips Technology Co Ltd filed Critical Sanechips Technology Co Ltd
Priority to CN201811436260.8A priority Critical patent/CN111240682B/en
Priority to PCT/CN2019/111729 priority patent/WO2020108158A1/en
Publication of CN111240682A publication Critical patent/CN111240682A/en
Application granted granted Critical
Publication of CN111240682B publication Critical patent/CN111240682B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/44Encoding
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • 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

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Devices For Executing Special Programs (AREA)
  • Executing Machine-Instructions (AREA)

Abstract

The embodiment of the application discloses a method, a device, equipment and a storage medium for processing instruction data, wherein the method comprises the following steps: if the fact that the same type of fields exist among the instructions before compiling is determined, storing the same type of fields to a designated coding position during compiling; generating a corresponding operation code according to the type of each instruction before compiling and the attribute information of the fields of the same type; storing the operation code into a compiled instruction; outputting the compiled instruction.

Description

一种指令数据的处理方法及装置、设备、存储介质A method, device, and storage medium for processing instruction data

技术领域Technical Field

本申请实施例涉及计算机系统,涉及但不限于一种指令数据的处理方法及装置、设备、存储介质。The embodiments of the present application relate to a computer system, and relate to but are not limited to a method and apparatus, device, and storage medium for processing instruction data.

背景技术Background Art

网络处理器是专门用于网络数据处理的处理器,主要应用于交换机,路由器等网络产品,多用于处理网络中的报文;它具有高处理性能、可编程、可灵活扩展、开发周期短等优势。正是由于网络业务数据的处理与普通系统类程序的不同以及其特性需求,导致网络处理器的指令集设计,必须具有指令执行效率高、指令扩展性强、指令集丰富等特征。A network processor is a processor specifically used for network data processing. It is mainly used in network products such as switches and routers, and is mostly used to process messages in the network. It has the advantages of high processing performance, programmability, flexible expansion, and short development cycle. It is precisely because the processing of network business data is different from that of ordinary system programs and its characteristic requirements that the instruction set design of the network processor must have the characteristics of high instruction execution efficiency, strong instruction scalability, and rich instruction set.

同时,在满足转发性能的基础上,要降低逻辑设计的复杂度,减少芯片资源和降低功耗。而这些特征要求不仅需要从指令集设计的每个流程单独考虑,更要把所有流程作整体统一考虑,因此网络处理器的指令集设计和处理是非常复杂的。At the same time, on the basis of satisfying forwarding performance, it is necessary to reduce the complexity of logic design, reduce chip resources and reduce power consumption. These feature requirements require not only individual considerations for each process of instruction set design, but also overall considerations for all processes. Therefore, the instruction set design and processing of network processors is very complex.

发明内容Summary of the invention

有鉴于此,本申请实施例为解决现有技术中存在的至少一个问题而提供一种指令数据的处理方法及装置、设备、存储介质。In view of this, embodiments of the present application provide a method and apparatus, device, and storage medium for processing instruction data to solve at least one problem existing in the prior art.

本申请实施例的技术方案是这样实现的:The technical solution of the embodiment of the present application is implemented as follows:

第一方面,本申请实施例提供了一种指令数据的处理方法,所述方法包括:如果确定编译前的指令之间有相同类型的字段,编译时,将所述相同类型的字段存储至指定编码位置;根据每一所述编译前的指令的类型和所述相同类型的字段的属性信息,生成对应的操作码;将所述操作码存储至编译后的指令中;输出所述编译后的指令。In a first aspect, an embodiment of the present application provides a method for processing instruction data, the method comprising: if it is determined that there are fields of the same type between instructions before compilation, during compilation, storing the fields of the same type to a specified encoding position; generating a corresponding opcode based on the type of each instruction before compilation and the attribute information of the fields of the same type; storing the opcode in the compiled instruction; and outputting the compiled instruction.

第二方面,本申请实施例提供了一种指令数据的处理方法,所述方法包括:确定编译后的指令中的操作码;根据所述操作码,确定所述指令的类型和所述指令中的字段的属性信息;根据所述字段的属性信息,从所述指令中的指定编码位置确定相应类型的字段;根据所述相应类型的字段获取对应的操作数,并输出所述操作数。In a second aspect, an embodiment of the present application provides a method for processing instruction data, the method comprising: determining an opcode in a compiled instruction; determining the type of the instruction and attribute information of a field in the instruction based on the opcode; determining a field of a corresponding type from a specified encoding position in the instruction based on the attribute information of the field; obtaining a corresponding operand based on the field of the corresponding type, and outputting the operand.

第三方面,本申请实施例提供了一种指令数据的处理装置,所述装置包括:第一存储单元,配置为如果确定编译前的指令之间有相同类型的字段,编译时,将所述相同类型的字段存储至指定编码位置;生成单元,配置为根据每一所述编译前的指令的类型和所述相同类型的字段的属性信息,生成对应的操作码;第二存储单元,配置为将所述操作码存储至编译后的指令中;第一输出单元,配置为输出所述编译后的指令。In a third aspect, an embodiment of the present application provides an instruction data processing device, the device comprising: a first storage unit, configured to store the fields of the same type to a designated encoding position during compilation if it is determined that there are fields of the same type between instructions before compilation; a generation unit, configured to generate a corresponding operation code based on the type of each instruction before compilation and the attribute information of the fields of the same type; a second storage unit, configured to store the operation code in the compiled instruction; and a first output unit, configured to output the compiled instruction.

第四方面,本申请实施例提供了一种指令数据的处理装置,所述装置包括:第一确定单元,配置为确定编译后的指令中的操作码;第二确定单元,配置为根据所述操作码,确定所述指令的类型和所述指令中的字段的属性信息;第三确定单元,配置为根据所述字段的属性信息,从所述指令中的指定编码位置确定相应类型的字段;第二输出单元,配置为根据所述相应类型的字段获取对应的操作数,并输出所述操作数。In a fourth aspect, an embodiment of the present application provides a device for processing instruction data, the device comprising: a first determination unit, configured to determine an opcode in a compiled instruction; a second determination unit, configured to determine the type of the instruction and attribute information of a field in the instruction based on the opcode; a third determination unit, configured to determine a field of a corresponding type from a specified encoding position in the instruction based on the attribute information of the field; and a second output unit, configured to obtain a corresponding operand based on the field of the corresponding type and output the operand.

第五方面,本申请实施例提供了一种计算机设备,所述计算机设备至少包括:处理器和配置为存储可执行指令的存储介质,其中:处理器配置为执行存储的可执行指令,所述可执行指令配置为执行上述实施例提供的指令数据的处理方法。In a fifth aspect, an embodiment of the present application provides a computer device, which comprises at least: a processor and a storage medium configured to store executable instructions, wherein: the processor is configured to execute the stored executable instructions, and the executable instructions are configured to execute the instruction data processing method provided in the above embodiment.

第六方面,本申请实施例提供了一种计算机可读存储介质,所述计算机存储介质中存储有计算机可执行指令,该计算机可执行指令配置为执行上述实施例提供的指令数据的处理方法中的步骤。In a sixth aspect, an embodiment of the present application provides a computer-readable storage medium, in which computer-executable instructions are stored, and the computer-executable instructions are configured to execute the steps in the instruction data processing method provided in the above embodiment.

本申请实施例提供了一种指令数据的处理方法及装置、设备、存储介质,其中,所述方法包括:如果确定编译前的指令之间有相同类型的字段,编译时,将所述相同类型的字段存储至指定编码位置;根据每一所述编译前的指令的类型和所述相同类型的字段的属性信息,生成对应的操作码;将所述操作码存储至编译后的指令中;输出所述编译后的指令。这样,将令操作码与指令的类型以及指令源操作数的数量和类型直接关联,实现据所述指令操作码完成对指令源操作数的分类获取。The embodiment of the present application provides a method and apparatus, device, and storage medium for processing instruction data, wherein the method includes: if it is determined that there are fields of the same type between instructions before compilation, during compilation, the fields of the same type are stored in a specified encoding position; according to the type of each instruction before compilation and the attribute information of the fields of the same type, a corresponding operation code is generated; the operation code is stored in the compiled instruction; and the compiled instruction is output. In this way, the operation code is directly associated with the type of instruction and the number and type of instruction source operands, so that the classified acquisition of instruction source operands is completed according to the instruction operation code.

附图说明BRIEF DESCRIPTION OF THE DRAWINGS

图1为本申请实施例提供的指令数据的处理方法流程示意图一;FIG1 is a flowchart of a method for processing instruction data provided by an embodiment of the present application;

图2为本申请实施例提供的指令数据的处理方法流程示意图二;FIG2 is a second flow chart of a method for processing instruction data provided in an embodiment of the present application;

图3为本申请实施例提供的一种网络处理器的指令源操作数处理方法的流程示意图;3 is a flow chart of an instruction source operand processing method of a network processor provided in an embodiment of the present application;

图4为本申请实施例提供的一种网络处理器指令源操作数的处理装置的组成结构示意图;FIG4 is a schematic diagram of the composition structure of a network processor instruction source operand processing device provided in an embodiment of the present application;

图5为本申请实施例提供的指令数据的处理装置的组成结构示意图一;FIG5 is a schematic diagram of a first structure of a device for processing instruction data provided in an embodiment of the present application;

图6为本申请实施例提供的指令数据的处理装置的组成结构示意图二;FIG6 is a second schematic diagram of the composition structure of the instruction data processing device provided in an embodiment of the present application;

图7为本申请实施例提供的一种计算机设备结构示意图。FIG. 7 is a schematic diagram of the structure of a computer device provided in an embodiment of the present application.

具体实施方式DETAILED DESCRIPTION

相关技术中,在设计网络处理器的指令集时,需要考虑指令编码、储存、获取、解码等几个关键技术,其中指令编解码是指令集设计的基础,直接决定指令集处理的复杂度。同时为了能够处理网络中各种业务数据,需要设计多种不同功能的指令以及大容量的指令空间。因此,如果指令编解码没有对应的好的设计方案,往往会导致逻辑设计的复杂度很高,而且会占用大量的芯片内存,功耗也很高。In the related technology, when designing the instruction set of a network processor, it is necessary to consider several key technologies such as instruction encoding, storage, acquisition, and decoding. Among them, instruction encoding and decoding is the basis of instruction set design and directly determines the complexity of instruction set processing. At the same time, in order to be able to process various business data in the network, it is necessary to design instructions with multiple different functions and a large-capacity instruction space. Therefore, if there is no corresponding good design solution for instruction encoding and decoding, it often leads to a high complexity of logic design, and it will occupy a large amount of chip memory and consume high power.

传统的网络处理器的指令集设计采用与精简指令集计算机(ReducedInstruction Set Computer,RISC)类似的指令流水线解码技术,指令编码采用的是定长方式进行编码。由于仅根据每个指令的功能操作对指令的操作码字段进行编码,导致在解码阶段获取源操作数时,需要先判断每个指令的类型,再根据每个指令记录的源操作数在指令编码中的位置,获取源操作数的编号和地址等字段信息。The instruction set design of traditional network processors uses an instruction pipeline decoding technology similar to that of Reduced Instruction Set Computer (RISC), and the instruction encoding is encoded in a fixed-length manner. Since the opcode field of the instruction is encoded only according to the functional operation of each instruction, when obtaining the source operand in the decoding stage, it is necessary to first determine the type of each instruction, and then obtain the source operand number and address field information according to the position of the source operand recorded by each instruction in the instruction encoding.

基于网络处理器的指令数量非常多,通过这样的方式获取源操作数,不仅需要额外增加芯片内存资源,用于存储每个指令的源操作数信息;而且也大大增加了芯片内核的逻辑复杂度。There are a large number of instructions based on network processors. Obtaining source operands in this way not only requires additional chip memory resources to store the source operand information of each instruction, but also greatly increases the logical complexity of the chip core.

为使本申请实施例的目的、技术方案和优点更加清楚,下面将结合本申请实施例中的附图,对发明的具体技术方案做进一步详细描述。以下实施例用于说明本申请,但不用来限制本申请的范围。In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the specific technical solution of the invention will be further described in detail below in conjunction with the drawings in the embodiments of the present application. The following embodiments are used to illustrate the present application, but are not used to limit the scope of the present application.

本申请实施例提供一种指令数据的处理方法,该方法应用于计算机设备,该方法所实现的功能可以通过计算机设备中的处理器调用程序代码来实现,当然程序代码可以保存在计算机存储介质中,可见,该计算机设备至少包括处理器和存储介质。An embodiment of the present application provides a method for processing instruction data, which is applied to a computer device. The function implemented by the method can be implemented by calling a program code through a processor in the computer device. Of course, the program code can be stored in a computer storage medium. It can be seen that the computer device at least includes a processor and a storage medium.

图1为本申请实施例提供的指令数据的处理方法流程示意图一,如图1所示,该方法包括:FIG. 1 is a flow chart of a method for processing instruction data provided in an embodiment of the present application. As shown in FIG. 1 , the method includes:

步骤S11,如果确定编译前的指令之间有相同类型的字段,编译时,将所述相同类型的字段存储至指定编码位置。Step S11: If it is determined that there are fields of the same type between the instructions before compilation, the fields of the same type are stored in a designated encoding position during compilation.

这里,从预设的指令集中获取至少一个指令,由于每个指令的功能和作用是预设的,可以根据获取到的指令确定编译前的指令之间相同类型的字段,在通过编译单元进行编译时,可以根据相应的规则将每个指令分为几段,每一段占用预设的位置和相应的字节长度,并将该预设的位置和相应的字节长度设置为对应的编码位置,在编译时,可以将各个指令之间相同类型的字段存储至指定编码位置,制定的编码位置可以根据需要预设。例如,指令集中有指令A和指令B,指令A有字段A1,A2,A3,指令B有字段B1,B2,B3,如果A3和B3是相同类型的字段,编译单元会把指令A的A3字段,和指令B的B3字段放在各自编码的相同比特位置。Here, at least one instruction is obtained from a preset instruction set. Since the function and effect of each instruction are preset, the same type of fields between the instructions before compilation can be determined based on the obtained instructions. When compiling through the compilation unit, each instruction can be divided into several segments according to the corresponding rules, and each segment occupies a preset position and a corresponding byte length, and the preset position and the corresponding byte length are set to the corresponding encoding position. When compiling, the same type of fields between the instructions can be stored in the specified encoding position, and the formulated encoding position can be preset as needed. For example, there are instructions A and instruction B in the instruction set, instruction A has fields A1, A2, A3, and instruction B has fields B1, B2, B3. If A3 and B3 are fields of the same type, the compilation unit will put the A3 field of instruction A and the B3 field of instruction B in the same bit position of their respective encodings.

步骤S12,据每一所述编译前的指令的类型和所述相同类型的字段的属性信息,生成对应的操作码。Step S12: Generate a corresponding operation code according to the type of each instruction before compilation and the attribute information of the field of the same type.

这里,操作码用于指明指令所要完成的操作,操作码的长度可以是固定的,也可以是变化的。本申请实施例中,可以获取编译前的指令的类型和相同类型的字段的属性信息,对编译前的指令的类型和相同类型的字段的属性信息分别进行标记,根据生成的标记信息生成对应的操作码。这里,指令的类型可以为:逻辑计算类指令、数据上传/下载类指令、跳转类指令和一些特殊类指令等,可以根据需要预设。相同类型的字段可以为不同的源操作数、目的操作数或者其他的字段等。Here, the opcode is used to indicate the operation to be performed by the instruction, and the length of the opcode can be fixed or variable. In an embodiment of the present application, the type of instruction before compilation and the attribute information of the same type of field can be obtained, and the type of instruction before compilation and the attribute information of the same type of field are marked respectively, and the corresponding opcode is generated according to the generated marking information. Here, the type of instruction can be: logical calculation instructions, data upload/download instructions, jump instructions, and some special instructions, etc., which can be preset as needed. The same type of field can be different source operands, destination operands, or other fields, etc.

步骤S13,将所述操作码存储至编译后的指令中。Step S13, storing the operation code into the compiled instruction.

这里,编译单元可以将根据上述步骤生成的操作码存储至编译后的指令中的相应编码位置。Here, the compilation unit may store the opcode generated according to the above steps to a corresponding encoding position in the compiled instruction.

步骤S14,输出所述编译后的指令。Step S14, outputting the compiled instructions.

本申请实施例中,如果确定编译前的指令之间有相同类型的字段,编译时,将相同类型的字段存储至指定编码位置,根据每一编译前的指令的类型和相同类型的字段的属性信息,生成对应的操作码,将操作码存储至编译后的指令中,输出编译后的指令。能够将令操作码与指令的类型以及字段的属性信息直接关联,实现据所述指令操作码完成对字段相应的操作数的分类获取。In the embodiment of the present application, if it is determined that there are fields of the same type between the pre-compiled instructions, during compilation, the fields of the same type are stored in the designated encoding position, and the corresponding opcode is generated according to the type of each pre-compiled instruction and the attribute information of the fields of the same type, and the opcode is stored in the compiled instruction, and the compiled instruction is output. The opcode can be directly associated with the type of instruction and the attribute information of the field, so as to achieve the classification acquisition of the operands corresponding to the field according to the instruction opcode.

本申请实施例还供了另一指令数据的处理方法,该方法包括:The present application also provides another method for processing instruction data, the method comprising:

步骤S101,如果确定编译前的指令之间有相同类型的字段,编译时,将所述相同类型的字段存储至指定编码位置。Step S101: If it is determined that there are fields of the same type between instructions before compilation, the fields of the same type are stored in a designated encoding position during compilation.

步骤S102,如果确定所述相同类型的字段包括源操作数字段,确定所述源操作数字段的数量和类型。Step S102: If it is determined that the fields of the same type include source operand fields, the number and type of the source operand fields are determined.

这里,指令中可以包括一个或者多个源操作数字段。本申请实施例中,如果确定相同类型的字段包括源操作数字段,确定源操作数字段的数量和类型。Here, the instruction may include one or more source operand fields. In the embodiment of the present application, if it is determined that fields of the same type include source operand fields, the number and type of the source operand fields are determined.

步骤S103,根据每一所述编译前的指令的类型、所述源操作数字段的数量和类型,生成对应的操作码。Step S103, generating a corresponding operation code according to the type of each pre-compiled instruction and the number and type of the source operand fields.

这里,可以获取编译前的指令的类型和源操作数字段的数量和类型,对编译前的指令的类型、源操作数字段的数量和类型分别进行标记,根据该标记生成的标识码生成对应的操作码。对源操作数字段的数量和类型分别进行标记,包括:确定源操作数的数量和类型,并根据源操作数的数量和类型生成一个标记。例如:不需要源操作数或者是立即数形式的标记为000;只需要操作一个条件的寄存器的形式标记为001等。Here, the type of instruction before compilation and the number and type of source operand fields can be obtained, and the type of instruction before compilation and the number and type of source operand fields can be marked respectively, and the corresponding operation code can be generated according to the identification code generated by the mark. The number and type of source operand fields are marked respectively, including: determining the number and type of source operands, and generating a mark according to the number and type of source operands. For example: the mark that does not require source operands or immediate numbers is 000; the mark that only needs to operate a conditional register is 001, etc.

上述的步骤S102至步骤S103提供了一种实现步骤“根据每一所述编译前的指令的类型和所述相同类型字段的属性信息,生成对应的操作码”的方式。该方式中,如果确定所述相同类型的字段包括源操作数字段,确定所述源操作数字段的数量和类型,根据每一所述编译前的指令的类型、所述源操作数字段的数量和类型,生成对应的操作码。能够将令操作码与指令的类型以及源操作数字段的数量和类型直接关联,实现据所述指令操作码完成对指令源操作数的分类获取。The above-mentioned steps S102 to S103 provide a method for implementing the step of "generating a corresponding operation code according to the type of each instruction before compilation and the attribute information of the same type field". In this method, if it is determined that the same type of field includes a source operand field, the number and type of the source operand field are determined, and the corresponding operation code is generated according to the type of each instruction before compilation, the number and type of the source operand field. The operation code can be directly associated with the type of instruction and the number and type of the source operand field, so as to achieve the classification acquisition of the instruction source operand according to the instruction operation code.

步骤S104,将所述操作码存储至编译后的指令中。Step S104, storing the operation code into the compiled instruction.

步骤S105,输出所述编译后的指令。Step S105, outputting the compiled instructions.

本申请实施例还供了另一指令数据的处理方法,该方法包括:The present application also provides another method for processing instruction data, the method comprising:

步骤S201,根据每一编译前的指令所要执行的功能,对所述编译前的指令进行分类,得到分类结果。Step S201, classifying the pre-compiled instructions according to the function to be executed by each pre-compiled instruction to obtain a classification result.

这里,可以根据指令所要执行的功能,将编译前的指令分为至少一类。其中,分类结果可以为:逻辑计算类指令、数据上传/下载类指令、跳转类指令和一些特殊类指令等。Here, the pre-compiled instructions may be classified into at least one category according to the functions to be executed by the instructions, wherein the classification results may include: logic calculation instructions, data upload/download instructions, jump instructions, and some special instructions.

步骤S202,如果确定编译前的指令之间有相同类型的字段,编译时,将所述相同类型的字段存储至指定编码位置。Step S202: If it is determined that there are fields of the same type between the instructions before compilation, the fields of the same type are stored in a designated encoding position during compilation.

步骤S203,如果确定所述相同类型的字段包括源操作数字段,根据所述分类结果,确定所述源操作数字段的数量和类型。Step S203: If it is determined that the fields of the same type include source operand fields, the number and type of the source operand fields are determined according to the classification result.

这里,可以根据编译前的指令所要执行的功能确定该指令是否需要源操作数,如果需要源操作数,确定所需要的源操作数的数量和类型。以将指令分为逻辑计算类指令、数据上传/下载类指令、跳转类指令为例。其中,逻辑计算类指令通常有目的寄存器,普通寄存器源操作数一,普通寄存器源操作数二或立即数源操作数二等字段等;数据上传/下载类指令通常有目的寄存器,条件寄存器源操作数二,内存源操作数数一或内存源操作数二,立即数源操作数二等字段等;跳转类指令通常有标签,条件寄存器源操作数二等;特殊类指令通常完成网络业务查表,协处理等处理,不需要源操作数。其中,源操作数一指的是有一个操作数,或者有两个操作数时,处于第一位的源操作数;源操作数二指的是有两个操作数时,处于第二位的源操作数。Here, it can be determined whether the instruction needs a source operand according to the function to be executed by the instruction before compilation. If a source operand is needed, the number and type of the required source operands can be determined. Take the division of instructions into logic calculation instructions, data upload/download instructions, and jump instructions as an example. Among them, logic calculation instructions usually have fields such as destination register, common register source operand one, common register source operand two or immediate source operand two, etc.; data upload/download instructions usually have fields such as destination register, conditional register source operand two, memory source operand one or memory source operand two, immediate source operand two, etc.; jump instructions usually have labels, conditional register source operand two, etc.; special instructions usually complete network service table lookup, co-processing and other processing, and do not require source operands. Among them, source operand one refers to the source operand in the first position when there is one operand, or when there are two operands; source operand two refers to the source operand in the second position when there are two operands.

步骤S204,根据每一所述编译前的指令的类型、所述源操作数字段的数量和类型,生成对应的操作码。Step S204: Generate a corresponding operation code according to the type of each pre-compiled instruction and the number and type of the source operand fields.

步骤S205,将所述操作码存储至编译后的指令中。Step S205: store the operation code into the compiled instruction.

步骤S206,输出所述编译后的指令。Step S206: output the compiled instructions.

本申请实施例还供了另一指令数据的处理方法,该方法包括:The present application also provides another method for processing instruction data, the method comprising:

步骤S301,根据每一编译前的指令所要执行的功能,对所述编译前的指令进行分类,得到分类结果。Step S301, classifying the pre-compiled instructions according to the functions to be executed by each pre-compiled instruction to obtain classification results.

步骤S302,如果确定编译前的指令之间有相同类型的字段,编译时,将所述相同类型的字段存储至指定编码位置。Step S302: If it is determined that there are fields of the same type between the instructions before compilation, the fields of the same type are stored in a designated encoding position during compilation.

步骤S303,如果确定所述相同类型的字段包括源操作数字段,根据所述分类结果,确定所述源操作数字段的数量和类型。Step S303: If it is determined that the fields of the same type include source operand fields, the number and type of the source operand fields are determined according to the classification result.

步骤S304,对每一所述编译前的指令的类型进行标记,生成与每一所述编译前的指令对应的第一标识码。Step S304: Mark the type of each pre-compiled instruction and generate a first identification code corresponding to each pre-compiled instruction.

这里,对指令的类型进行标记是指:编译单元根据指令的类型,生成相应的标识码。例如,可以将指令分为逻辑计算类指令、数据上传/下载类指令、跳转类指令和特殊类指令四种类型,再根据该四种类型生成四个对应标记,分别为逻辑计算类指令对应第一标识码一00、数据上传/下载类指令对应第一标识码二01、跳转类指令对应第一标识码三10、特殊类指令对应第一标识码四11。将上述标识码作为相应的指令的操作码字段编码的第一部分。Here, marking the type of instruction means that the compilation unit generates a corresponding identification code according to the type of instruction. For example, instructions can be divided into four types: logic calculation instructions, data upload/download instructions, jump instructions, and special instructions. Then, four corresponding tags are generated according to the four types, namely, the first identification code 10 for logic calculation instructions, the first identification code 201 for data upload/download instructions, the first identification code 310 for jump instructions, and the first identification code 411 for special instructions. The above identification code is used as the first part of the opcode field encoding of the corresponding instruction.

步骤S305,根据所述源操作数字段的数量和类型,生成对应的第二标识码。Step S305: Generate a corresponding second identification code according to the number and type of the source operand fields.

这里,以根据源操作数的数量和类型,将指令分为逻辑计算类指令、数据上传/下载类指令、跳转类指令和特殊类指令四种类型分为八种类型为例,形成的类型分别为:不需要源操作数或者是立即数形式的源操作数的指令为类型一;只需要操作一个条件寄存器形式的源操作数的指令为类型二;只需要操作一个普通寄存器形式的源操作数的指令为类型三;只需要操作一个内存形式的源操作数的指令为类型四;需要操作一个普通寄存器形式的源操作数和一个内存形式的源操作数的指令为类型五;需要操作一个普通寄存器形式的源操作数和一个条件寄存器形式的源操作数的指令为类型六;需要操作两个普通寄存器形式的源操作数的指令为类型七;需要操作一个内存形式的源操作数和一个条件寄存器形式的源操作数的指令为类型八。Here, taking the example of dividing instructions into eight types according to the number and type of source operands, namely, logic calculation instructions, data upload/download instructions, jump instructions and special instructions, the types formed are: instructions that do not require source operands or source operands in the form of immediate numbers are type one; instructions that only need to operate a source operand in the form of a conditional register are type two; instructions that only need to operate a source operand in the form of an ordinary register are type three; instructions that only need to operate a source operand in the form of a memory are type four; instructions that need to operate a source operand in the form of an ordinary register and a source operand in the form of a memory are type five; instructions that need to operate a source operand in the form of an ordinary register and a source operand in the form of a conditional register are type six; instructions that need to operate two source operands in the form of ordinary registers are type seven; instructions that need to operate a source operand in the form of a memory and a source operand in the form of a conditional register are type eight.

编译单元根据源操作数的数量和类型,对指令进行分类,得到分类结果,对分类结果得到相应的标识码。以上述八种类型为例,类型一对应第二标识码一000,类型二对应第二标识码二001,类型三对应第二标识码三010,类型四对应第二标识码四011,类型五对应第二标识码五100,类型六对应第二标识码六101,类型七对应第二标识码七110,类型八对应第二标识码八111。将上述标识码作为相应的指令的操作码字段编码的第二部分。The compilation unit classifies the instructions according to the number and type of source operands, obtains the classification results, and obtains corresponding identification codes for the classification results. Taking the above eight types as an example, type one corresponds to the second identification code one 000, type two corresponds to the second identification code two 001, type three corresponds to the second identification code three 010, type four corresponds to the second identification code four 011, type five corresponds to the second identification code five 100, type six corresponds to the second identification code six 101, type seven corresponds to the second identification code seven 110, and type eight corresponds to the second identification code eight 111. The above identification codes are used as the second part of the opcode field encoding of the corresponding instruction.

步骤S306,将所述第一标识码和所述第二标识码合并,生成对应的操作码。Step S306: combine the first identification code and the second identification code to generate a corresponding operation code.

这里,可以将经过上述步骤生成的操作码字段编码的第一部分和操作码字段编码的第二部分进行合并,生成对应的操作码。Here, the first part of the operation code field code generated through the above steps and the second part of the operation code field code may be combined to generate a corresponding operation code.

上述的步骤S304至步骤S306提供了一种实现步骤“根据每一所述编译前的指令的类型、所述源操作数字段的数量和类型,生成对应的操作码”的方式。该方式中,能够将令操作码与指令的类型以及源操作数字段的数量和类型直接关联,实现据所述指令操作码完成对指令源操作数的分类获取。The above steps S304 to S306 provide a method for implementing the step of "generating a corresponding operation code according to the type of each instruction before compilation, the number and type of the source operand fields". In this method, the operation code can be directly associated with the type of instruction and the number and type of the source operand fields, so as to achieve the classification acquisition of the instruction source operand according to the instruction operation code.

步骤S307,将所述操作码存储至编译后的指令中。Step S307, storing the operation code into the compiled instruction.

步骤S308,输出所述编译后的指令。Step S308: output the compiled instructions.

图2为本申请实施例提供的指令数据的处理方法流程示意图二,如图2所示,该方法包括:FIG. 2 is a second flow chart of a method for processing instruction data provided in an embodiment of the present application. As shown in FIG. 2 , the method includes:

步骤S21,确定编译后的指令中的操作码。Step S21, determining the operation code in the compiled instruction.

这里,解码单元接收到编译后的指令之后,可以从编译后的指令中确定对应的操作码。Here, after receiving the compiled instruction, the decoding unit may determine the corresponding operation code from the compiled instruction.

步骤S22,根据所述操作码,确定所述指令的类型和所述指令中的字段的属性信息。Step S22: Determine the type of the instruction and attribute information of the fields in the instruction according to the operation code.

这里,解码单元获取到编译后的指令,可以从指令中解析出相应的操作码,并根据操作码,确定指令的类型和指令中的字段的属性信息。Here, the decoding unit obtains the compiled instruction, can parse the corresponding operation code from the instruction, and determine the type of instruction and the attribute information of the field in the instruction according to the operation code.

步骤S23,根据所述字段的属性信息,从所述指令中的指定编码位置确定相应类型的字段。Step S23, determining a field of a corresponding type from a designated encoding position in the instruction according to the attribute information of the field.

这里,字段是存储在编译后的指令中的指定编码位置,解码单元可以根据字段的属性信息从指定编码位置直接确定相应类型的字段。Here, the field is a designated encoding position stored in the compiled instruction, and the decoding unit can directly determine the corresponding type of field from the designated encoding position according to the attribute information of the field.

步骤S24,根据所述相应类型的字段获取对应的操作数,并输出所述操作数。Step S24, obtaining corresponding operands according to the fields of the corresponding types, and outputting the operands.

这里,基于上述步骤确定了相应类型的字段之后,可以直接从相应的寄存器中获取相应的操作数,并对获取的操作数进行相应的处理。Here, after the fields of corresponding types are determined based on the above steps, corresponding operands can be directly obtained from corresponding registers, and the obtained operands can be processed accordingly.

本申请实施例中,确定编译后的指令中的操作码,根据操作码,确定指令的类型和指令中的字段的属性信息,根据字段的属性信息,从指令中的指定编码位置确定相应类型的字段,根据相应类型的字段获取对应的操作数,并输出操作数。解码单元能够从编译后的指令中直接截取相应的操作数,不用通过确定指令的类型,再根据指令的类型确定相应的操作数,能够减少判断步骤,并且减少对操作数处理的复杂度。In the embodiment of the present application, the opcode in the compiled instruction is determined, and the type of instruction and the attribute information of the field in the instruction are determined according to the opcode, and the field of the corresponding type is determined from the specified encoding position in the instruction according to the attribute information of the field, and the corresponding operand is obtained according to the field of the corresponding type, and the operand is output. The decoding unit can directly intercept the corresponding operand from the compiled instruction without determining the type of instruction and then determining the corresponding operand according to the type of instruction, which can reduce the judgment steps and reduce the complexity of operand processing.

本申请实施例还供了另一指令数据的处理方法,该方法包括:The present application also provides another method for processing instruction data, the method comprising:

步骤S401,确定编译后的指令中的操作码。Step S401, determining the operation code in the compiled instruction.

步骤S402,如果检测出所述指令需要获取源操作数字段,解析所述需要获取源操作数字段的指令对应的操作码,得到解析结果。Step S402: If it is detected that the instruction needs to obtain a source operand field, the opcode corresponding to the instruction that needs to obtain a source operand field is parsed to obtain a parsing result.

这里,解码单元根据操作码判断是否需要获取源操作数,当需要获取源操作数时,解析需要获取源操作数字段的指令对应的操作码,得到解析结果。Here, the decoding unit determines whether it is necessary to obtain the source operand according to the operation code. When the source operand needs to be obtained, the operation code corresponding to the instruction for which the source operand field needs to be obtained is parsed to obtain the parsing result.

步骤S403,根据所述解析结果,确定所述指令的类型和所述源操作数字段的属性信息。Step S403: Determine the type of the instruction and the attribute information of the source operand field according to the parsing result.

这里,由于操作码包括第一标识码和第二标识码,可以根据第一标识码确定指令的类型,根据第二标识码确定源操作数字段的属性信息。Here, since the operation code includes the first identification code and the second identification code, the type of instruction can be determined according to the first identification code, and the attribute information of the source operand field can be determined according to the second identification code.

上述的步骤S402至步骤S403提供了一种实现步骤“根据所述操作码,确定所述指令的类型和所述指令中的字段的属性信息”的方式。该方式中,如果检测出指令需要获取源操作数字段,解析需要获取源操作数字段的指令对应的操作码,得到解析结果,根据解析结果,确定指令的类型和源操作数字段的属性信息。通过对操作码进行解析,能够直接获取指令的类型和源操作数字段的属性信息,可以减少解码的复杂度。The above steps S402 to S403 provide a method for implementing the step of "determining the type of the instruction and the attribute information of the fields in the instruction according to the opcode". In this method, if it is detected that the instruction needs to obtain the source operand field, the opcode corresponding to the instruction that needs to obtain the source operand field is parsed to obtain the parsing result, and the type of the instruction and the attribute information of the source operand field are determined according to the parsing result. By parsing the opcode, the type of the instruction and the attribute information of the source operand field can be directly obtained, which can reduce the complexity of decoding.

步骤S404,根据所述字段的属性信息,从所述指令中的指定编码位置确定相应类型的字段。Step S404: determining a field of a corresponding type from a designated encoding position in the instruction according to the attribute information of the field.

步骤S405,根据所述相应类型的字段获取对应的操作数,并输出所述操作数。Step S405, obtaining corresponding operands according to the fields of the corresponding types, and outputting the operands.

本申请实施例还供了另一指令数据的处理方法,该方法包括:The present application also provides another method for processing instruction data, the method comprising:

步骤S501,确定编译后的指令中的操作码。Step S501, determining the operation code in the compiled instruction.

步骤S502,如果检测出所述指令需要获取源操作数字段,解析所述需要获取源操作数字段的指令对应的操作码,得到解析结果。Step S502: If it is detected that the instruction needs to obtain a source operand field, the opcode corresponding to the instruction that needs to obtain a source operand field is parsed to obtain a parsing result.

步骤S503,根据所述解析结果,确定所述指令的类型和所述源操作数字段的属性信息。Step S503: Determine the type of the instruction and the attribute information of the source operand field according to the parsing result.

步骤S504,根据从所述操作码中解析出的第一标识码,确定所述指令的类型。Step S504: Determine the type of the instruction according to the first identification code parsed from the operation code.

这里,解码单元解析操作码的第一部分,即解析操作码的第一标识码,可以确定指令的类型。Here, the decoding unit parses the first part of the operation code, that is, parses the first identification code of the operation code, and can determine the type of the instruction.

步骤S505,根据从所述操作码中解析出的第二标识码,确定所述源操作数字段数量和类型。Step S505: Determine the number and type of the source operand fields according to the second identification code parsed from the operation code.

这里,解码单元解析操作码的第二部分,即解析操作码的第二标识码,可以确定源操作数字段数量和类型。Here, the decoding unit parses the second part of the operation code, that is, parses the second identification code of the operation code, and can determine the number and type of source operand fields.

步骤S506,根据所述源操作数字段数量和类型,从所述指令中的指定编码位置确定相应类型的字段。Step S506: Determine a field of a corresponding type from a specified encoding position in the instruction according to the number and type of the source operand fields.

这里,可以根据源操作数字段数量和类型,从指令中的指定编码位置确定相应类型的字段。例如,对于源操作数一分成三种情况:指令不需要获取源操作数一,指令直接透传至读取单元;指令需要获取源操作数一,且需要从指令编码中截取源寄存器的编号和地址;指令需要获取源操作数一,且读地址固定无需其他解码操作。对于源操作数二分四种情况:指令不需要获取源操作二,直接透传至读取单元;指令需要获取源操作数二,且需要从指令编码中截取源寄存器的编号和地址;指令需要获取源操作数二,且所需源寄存器从指令编码中截取后并做转换;指令需要获取源操作数二,且读地址固定无需其他解码操作。Here, the corresponding type of field can be determined from the specified encoding position in the instruction according to the number and type of source operand fields. For example, for source operand one, there are three cases: the instruction does not need to obtain source operand one, and the instruction is directly transmitted to the read unit; the instruction needs to obtain source operand one, and the number and address of the source register need to be intercepted from the instruction encoding; the instruction needs to obtain source operand one, and the read address is fixed and no other decoding operations are required. For source operand two, there are four cases: the instruction does not need to obtain source operand two, and it is directly transmitted to the read unit; the instruction needs to obtain source operand two, and the number and address of the source register need to be intercepted from the instruction encoding; the instruction needs to obtain source operand two, and the required source register is intercepted from the instruction encoding and converted; the instruction needs to obtain source operand two, and the read address is fixed and no other decoding operations are required.

上述的步骤S504至步骤S506提供了一种实现步骤“根据所述字段的属性信息,从所述指令中的指定编码位置确定相应类型的字段”的方式。该方式中,根据从操作码中解析出的第一标识码,确定指令的类型;根据从操作码中解析出的第二标识码,确定源操作数字段数量和类型;根据源操作数字段数量和类型,从指令中的指定编码位置确定源操作数字段。能够根据源操作数字段数量和类型,直接从指令中的指定编码位置确定源操作数字段,能够减少解码的复杂度。The above-mentioned steps S504 to S506 provide a method for implementing the step of "determining a field of a corresponding type from a designated encoding position in the instruction according to the attribute information of the field". In this method, the type of the instruction is determined according to the first identification code parsed from the opcode; the number and type of source operand fields are determined according to the second identification code parsed from the opcode; and the source operand fields are determined from the designated encoding position in the instruction according to the number and type of source operand fields. The source operand fields can be directly determined from the designated encoding position in the instruction according to the number and type of source operand fields, which can reduce the complexity of decoding.

步骤S507,根据所述相应类型的字段获取对应的操作数,并输出所述操作数。Step S507, obtaining corresponding operands according to the fields of the corresponding types, and outputting the operands.

本申请实施例还供了另一指令数据的处理方法,该方法包括:The present application also provides another method for processing instruction data, the method comprising:

步骤S601,确定编译后的指令中的操作码。Step S601, determining the operation code in the compiled instruction.

步骤S602,如果检测出所述指令需要获取源操作数字段,解析所述需要获取源操作数字段的指令对应的操作码,得到解析结果。Step S602: If it is detected that the instruction needs to obtain a source operand field, the opcode corresponding to the instruction that needs to obtain a source operand field is parsed to obtain a parsing result.

步骤S603,根据所述解析结果,确定所述指令的类型和所述源操作数字段的属性信息。Step S603: Determine the type of the instruction and the attribute information of the source operand field according to the parsing result.

步骤S604,根据从所述操作码中解析出的第一标识码,确定所述指令的类型。Step S604: Determine the type of the instruction according to the first identification code parsed from the operation code.

步骤S605,根据从所述操作码中解析出的第二标识码,确定所述源操作数字段数量和类型。Step S605: Determine the number and type of the source operand fields according to the second identification code parsed from the operation code.

步骤S606,根据所述源操作数字段数量和类型,从所述指令中的指定编码位置确定相应类型的字段。Step S606: Determine a field of a corresponding type from a specified encoding position in the instruction according to the number and type of the source operand fields.

步骤S607,根据所述源操作数字段的数量和类型,从所述指令中的指定编码位置获取相应的源操作数字段。Step S607 : acquiring corresponding source operand fields from designated encoding positions in the instruction according to the number and type of the source operand fields.

步骤S608,根据所述源操作数字段,确定所述源操作数的编号和地址。Step S608: Determine the number and address of the source operand according to the source operand field.

这里,解码单元根据源操作数字段在指令编码中的固定位置,确定源操作数字段,并获取源操作数的编号和地址,送给读取单元。Here, the decoding unit determines the source operand field according to the fixed position of the source operand field in the instruction encoding, obtains the number and address of the source operand, and sends them to the reading unit.

步骤S609,根据所述源操作数的编号和地址,获取所述源操作数,并输出所述源操作数。Step S609, acquiring the source operand according to the number and address of the source operand, and outputting the source operand.

上述的步骤S608至步骤S609提供了一种实现步骤“根据所述相应类型的字段获取对应的操作数,并输出所述操作数”的方式。该方式中,根据源操作数字段,确定源操作数的编号和地址;根据源操作数的编号和地址,获取源操作数,并输出所述源操作数。能够根据源操作数字段数量和类型,直接从指令中的指定编码位置确定源操作数字段,然后根据源操作数字段直接获取相应的源操作数,可以减少解码的复杂度。The above steps S608 to S609 provide a method for implementing the step of "obtaining the corresponding operand according to the field of the corresponding type, and outputting the operand". In this method, the number and address of the source operand are determined according to the source operand field; the source operand is obtained according to the number and address of the source operand, and the source operand is output. The source operand field can be determined directly from the specified encoding position in the instruction according to the number and type of the source operand field, and then the corresponding source operand can be directly obtained according to the source operand field, which can reduce the complexity of decoding.

在其他的实施例中,根据指令的类型确定指令的功能,根据指令的功能对源操作数进行处理。In other embodiments, the function of the instruction is determined according to the type of the instruction, and the source operand is processed according to the function of the instruction.

图3为本申请实施例提供的一种网络处理器的指令源操作数处理方法的流程示意图,如图3所示,该方法包括以下步骤:FIG3 is a flow chart of a method for processing an instruction source operand of a network processor provided in an embodiment of the present application. As shown in FIG3 , the method includes the following steps:

步骤S31,编译单元将各个指令之间的相同字段放在指令编码中固定位置。In step S31, the compiling unit places the same fields between various instructions at fixed positions in the instruction code.

这里,首先指令采用定长编码方式对指令进行编码,然后把指令集中每个编码后的指令进行分段,并根据功能对指令集中的指令进行分类,通常网络处理器的指令分为逻辑计算类指令、数据上传/下载类指令、跳转类指令和一些特殊类指令。然后根据每一类指令的功能,确认各个指令需要的字段类型。Here, the instructions are first encoded using a fixed-length encoding method, and then each encoded instruction in the instruction set is segmented and classified according to function. Usually, the instructions of the network processor are divided into logical calculation instructions, data upload/download instructions, jump instructions, and some special instructions. Then, according to the function of each type of instruction, the field type required for each instruction is determined.

本申请实施例中,通过采用定长编码方式,能够将指令转化为便于编译单元存储的格式,而且解码单元不需要记录指令的存储位置和长度,直接在存储内存中获取到编码后的指令。In the embodiment of the present application, by adopting a fixed-length encoding method, instructions can be converted into a format that is convenient for storage by the compilation unit, and the decoding unit does not need to record the storage location and length of the instructions, and can directly obtain the encoded instructions in the storage memory.

其中,逻辑计算类指令:通常有目的寄存器操作数字段,普通寄存器源操作数一字段,普通寄存器源操作数二字段、立即数源操作数二字段等;数据上传/下载类指令:通常有目的寄存器操作数字段,条件寄存器源操作数二字段,内存源操作数一字段、内存源操作数二字段,立即数源操作数二字段等;跳转类指令:通常有标签、条件寄存器源操作数二等字段;特殊类指令:通常完成网络业务查表、协处理等操作,不需要源操作数字段。Among them, logical calculation instructions usually have a destination register operand field, a common register source operand one field, a common register source operand two field, an immediate source operand two field, etc.; data upload/download instructions usually have a destination register operand field, a conditional register source operand two field, a memory source operand one field, a memory source operand two field, an immediate source operand two field, etc.; jump instructions usually have fields such as labels and conditional register source operand two; special instructions usually complete network service table lookup, co-processing and other operations, and do not require a source operand field.

步骤S32,编译单元对指令的类型及指令的源操作数进行判断和标记,根据所述标记生成指令相应的操作码。Step S32: the compiling unit determines and marks the type of instruction and the source operand of the instruction, and generates an operation code corresponding to the instruction according to the mark.

这里,编译单元完成对指令的类型和指令的源操作数进行判断和标记,生成相应的指令操作码,该操作码与指令的类型以及指令源操作数的数量和类型直接关联;采用了根据所述指令操作码完成对指令源操作数的分类获取。Here, the compilation unit judges and marks the type of instruction and the source operands of the instruction, and generates a corresponding instruction opcode, which is directly related to the type of instruction and the number and type of the instruction source operands; and the classification acquisition of the instruction source operands is completed according to the instruction opcode.

其中,对指令的类型进行判断是指:根据功能操作把指令分为至少一种类型。例如,可以将指令分为逻辑计算类指令、数据上传/下载类指令、跳转类指令和一些特殊类指令等四种类型。The determination of the type of instruction refers to: classifying the instruction into at least one type according to the functional operation. For example, the instruction can be classified into four types: logic calculation instruction, data upload/download instruction, jump instruction and some special instruction.

对指令的类型进行标记是指:编译单元根据指令的类型,生成相应的标记。例如,可以将指令分为逻辑计算类指令、数据上传/下载类指令、跳转类指令和特殊类指令四种类型,再根据该四种类型生成四个对应标记,分别为逻辑计算类指令对应标记一00、数据上传/下载类指令对应标记二01、跳转类指令对应标记三10、特殊类指令对应标记四11,作为指令的操作码字段编码的第一部分。Marking the type of instruction means that the compilation unit generates a corresponding tag according to the type of instruction. For example, instructions can be divided into four types: logic calculation instructions, data upload/download instructions, jump instructions, and special instructions. Then, four corresponding tags are generated according to the four types, namely, logic calculation instructions corresponding to tag 1 00, data upload/download instructions corresponding to tag 2 01, jump instructions corresponding to tag 3 10, and special instructions corresponding to tag 4 11, as the first part of the opcode field encoding of the instruction.

对指令的源操作数进行判断是指:根据源操作数的数量和类型,对指令进行分类。Judging the source operands of the instructions means classifying the instructions according to the number and type of the source operands.

以根据源操作数的数量和类型,将指令分为逻辑计算类指令、数据上传/下载类指令、跳转类指令和特殊类指令四种类型分为八种类型为例,形成的类型分别为:不需要源操作数或者是立即数形式的源操作数的指令为类型一;只需要操作一个条件寄存器形式的源操作数的指令为类型二;只需要操作一个普通寄存器形式的源操作数的指令为类型三;只需要操作一个内存形式的源操作数的指令为类型四;需要操作一个普通寄存器形式的源操作数和一个内存形式的源操作数的指令为类型五;需要操作一个普通寄存器形式的源操作数和一个条件寄存器形式的源操作数的指令为类型六;需要操作两个普通寄存器形式的源操作数的指令为类型七;需要操作一个内存形式的源操作数和一个条件寄存器形式的源操作数的指令为类型八。Taking the example of dividing instructions into eight types according to the number and type of source operands, namely, logic calculation instructions, data upload/download instructions, jump instructions and special instructions, the types formed are: instructions that do not require source operands or source operands in the form of immediate numbers are type one; instructions that only need to operate a source operand in the form of a conditional register are type two; instructions that only need to operate a source operand in the form of an ordinary register are type three; instructions that only need to operate a source operand in the form of a memory are type four; instructions that need to operate a source operand in the form of an ordinary register and a source operand in the form of a memory are type five; instructions that need to operate a source operand in the form of an ordinary register and a source operand in the form of a conditional register are type six; instructions that need to operate two source operands in the form of ordinary registers are type seven; instructions that need to operate a source operand in the form of a memory and a source operand in the form of a conditional register are type eight.

所述对指令的源操作数进行标记是指:编译单元根据源操作数的数量和类型,对指令进行分类,得到分类结果,对分类结果进行标记。以上述八种类型为例,类型一对应标记一000,类型二对应标记二001,类型三对应标记三010,类型四对应标记四011,类型五对应标记五100,类型六对应标记六101,类型七对应标记七110,类型八对应标记八111,作为指令的操作码字段编码的第二部分。The marking of the source operands of the instructions refers to: the compilation unit classifies the instructions according to the number and type of the source operands, obtains the classification results, and marks the classification results. Taking the above eight types as an example, type one corresponds to mark one 000, type two corresponds to mark two 001, type three corresponds to mark three 010, type four corresponds to mark four 011, type five corresponds to mark five 100, type six corresponds to mark six 101, type seven corresponds to mark seven 110, and type eight corresponds to mark eight 111, as the second part of the opcode field encoding of the instruction.

步骤S33,解码单元根据所述操作码进行判断是否需要获取源操作数,当需要获取源操作数时,利用源操作数在指令编码中的固定位置,解码单元直接截取获得指令中源操作数的编号和地址。Step S33, the decoding unit determines whether it is necessary to obtain the source operand according to the operation code. When the source operand needs to be obtained, the decoding unit directly intercepts and obtains the number and address of the source operand in the instruction by using the fixed position of the source operand in the instruction encoding.

本申请实施例中,解码单元判断操作码的第二部分,对于源操作数一分成三种情况:指令不需要获取源操作数一,直接透传读取单元的,对应上述步骤S32操作码第二部分的000,001和011;指令需要获取源操作数一,且需要从指令编码中截取源寄存器的编号和地址的,对应上述步骤S32操作码第二部分的010,100,101和110;指令需要获取源操作数一,且读地址固定无需其他解码操作的,对应上述步骤S32操作码第二部分的111。In an embodiment of the present application, the decoding unit determines the second part of the opcode, and divides the source operand one into three situations: the instruction does not need to obtain the source operand one, and directly transmits it to the reading unit, corresponding to 000, 001 and 011 of the second part of the opcode of the above step S32; the instruction needs to obtain the source operand one, and the number and address of the source register need to be intercepted from the instruction code, corresponding to 010, 100, 101 and 110 of the second part of the opcode of the above step S32; the instruction needs to obtain the source operand one, and the read address is fixed and no other decoding operation is required, corresponding to 111 of the second part of the opcode of the above step S32.

对于源操作数二分四种情况:指令不需要获取源操作二,直接透传读取单元的,对应上述步骤S32操作码第二部分的000和010;指令需要获取源操作数二,且需要从指令编码中截取源寄存器的编号和地址的,对应上述步骤S32操作码第二部分的110;指令需要获取源操作数二,且所需源寄存器从指令编码中截取后并做转换的,对应上述步骤S32操作码第二部分的001,101和111;指令需要获取源操作数二,且读地址固定无需其他解码操作的,对应上述步骤S32操作码第二部分的111。There are four cases for source operand two: the instruction does not need to obtain source operand two and directly passes through the read unit, which corresponds to 000 and 010 in the second part of the opcode of step S32 above; the instruction needs to obtain source operand two, and the number and address of the source register need to be intercepted from the instruction code, which corresponds to 110 in the second part of the opcode of step S32 above; the instruction needs to obtain source operand two, and the required source register is intercepted from the instruction code and converted, which corresponds to 001, 101 and 111 in the second part of the opcode of step S32 above; the instruction needs to obtain source operand two, and the read address is fixed and no other decoding operation is required, which corresponds to 111 in the second part of the opcode of step S32 above.

解码单元需要的包括三种操作方式,其中,在截取源操作的编号和地址时,部分指令的源操作数二条件寄存器需要转换成普通寄存器的操作。The decoding unit needs to include three operation modes, among which, when intercepting the number and address of the source operation, the source operand two condition registers of some instructions need to be converted into ordinary register operations.

步骤S34,解码单元根据所述源操作数的编号和地址,在内核寄存器中获取源操作数的数据,并送给执行单元。Step S34: the decoding unit obtains the data of the source operand in the core register according to the number and address of the source operand, and sends it to the execution unit.

解码单元处理完成后,将获取到的源操作数的编号和地址送给读取单元,读取单元在内核寄存器中获取源操作数的数据,送给执行单元,对于其中没有源操作数的直接透传至执行单元。After the decoding unit completes the processing, it sends the number and address of the obtained source operand to the reading unit. The reading unit obtains the data of the source operand in the core register and sends it to the execution unit. If there is no source operand, it is directly transmitted to the execution unit.

步骤S35,执行单元执行完成后,将处理结果存储至内核寄存器中。Step S35, after the execution unit completes the execution, the processing result is stored in the core register.

这里,执行单元根据指令功能和源操作数处理指令,处理成功后把结果重新写进内核寄存器中。Here, the execution unit processes the instruction according to the instruction function and source operands, and writes the result back into the core register after successful processing.

图4为本申请实施例提供的一种网络处理器指令源操作数的处理装置的组成结构示意图,如图4所示,该装置包括:FIG. 4 is a schematic diagram of the composition structure of a network processor instruction source operand processing device provided in an embodiment of the present application. As shown in FIG. 4 , the device includes:

编译单元41,用于对指令间的相同字段放在指令编码中固定位置;用于对指令的类型及指令的源操作进行判断和标记,根据所述标记生成指令相应的操作码。The compiling unit 41 is used to place the same fields between instructions at a fixed position in the instruction encoding; and to judge and mark the type of instruction and the source operation of the instruction, and generate the corresponding operation code of the instruction according to the mark.

解码单元42,用于根据所述指令的操作码判断指令是否需要获取源操作,当所述指令需要获取源操作数时,根据所述源操作数在指令编码中的固定位置,完成对各种形式的源操作数的编号和地址的获取,送给读取单元。The decoding unit 42 is used to determine whether the instruction needs to obtain a source operation based on the operation code of the instruction. When the instruction needs to obtain a source operand, the numbering and address of various forms of source operands are obtained according to the fixed position of the source operand in the instruction encoding, and sent to the reading unit.

读取单元43,用于根据所述指令的源操作数的编号和地址,在内核寄存器中获取源操作数的数据。The reading unit 43 is used to obtain the data of the source operand in the core register according to the number and address of the source operand of the instruction.

执行单元44,用于根据指令功能对所述源操作数进行处理。The execution unit 44 is used to process the source operand according to the instruction function.

输出单元45,用于将处理结果存储至内核寄存器中。The output unit 45 is used to store the processing result in the core register.

本申请实施例中,编译单元在将指令转换为二进制编码时,把指令间的相同字段放在指令编码中的固定位置,保证指令间的相同字段对齐编码,这样,在对该指令进行解码时,解码单元可以直接截取源操作数的编号和地址,而不用先区分各个指令类型,再到指令编码中获取源操作数,这样解码单元无需额外的判断逻辑,也无需记录各个指令中源操作数的位置,大大减少了解码单元的逻辑复杂度和节省了芯片资源。In an embodiment of the present application, when the compilation unit converts instructions into binary codes, it places the same fields between instructions at a fixed position in the instruction code to ensure that the same fields between instructions are aligned in the code. In this way, when decoding the instruction, the decoding unit can directly intercept the number and address of the source operand without first distinguishing the various instruction types and then obtaining the source operand from the instruction code. In this way, the decoding unit does not need additional judgment logic, nor does it need to record the position of the source operand in each instruction, which greatly reduces the logical complexity of the decoding unit and saves chip resources.

基于前述的实施例,本申请实施例提供一种指令数据的处理装置。该装置所包括的各单元、以及各单元所包括的各子单元,都可以通过计算机设备中的处理器来实现;当然也可通过的逻辑电路实现;在实施的过程中,处理器可以为中央处理器(CPU)、微处理器(MPU)、数字信号处理器(DSP)或现场可编程门阵列(FPGA)等。Based on the above embodiments, the embodiments of the present application provide a device for processing instruction data. Each unit included in the device, and each sub-unit included in each unit, can be implemented by a processor in a computer device; of course, it can also be implemented by a logic circuit; in the implementation process, the processor can be a central processing unit (CPU), a microprocessor (MPU), a digital signal processor (DSP) or a field programmable gate array (FPGA), etc.

图5为本申请实施例提供的指令数据的处理装置的组成结构示意图一,如图5所示,所述装置包括:FIG. 5 is a schematic diagram of a first structure of a device for processing instruction data provided in an embodiment of the present application. As shown in FIG. 5 , the device includes:

第一存储单51,配置为如果确定编译前的指令之间有相同类型的字段,编译时,将所述相同类型的字段存储至指定编码位置。The first storage unit 51 is configured to store the fields of the same type to a designated encoding position during compilation if it is determined that there are fields of the same type between instructions before compilation.

生成单元52,配置为根据每一所述编译前的指令的类型和所述相同类型的字段的属性信息,生成对应的操作码。The generating unit 52 is configured to generate a corresponding operation code according to the type of each of the pre-compiled instructions and the attribute information of the fields of the same type.

第二存储单元53,配置为将所述操作码存储至编译后的指令中。The second storage unit 53 is configured to store the operation code into the compiled instruction.

第一输出单元54,配置为输出所述编译后的指令。The first output unit 54 is configured to output the compiled instructions.

在其他的实施例中,所述生成单元,还配置为:如果确定所述相同类型的字段包括源操作数字段,确定所述源操作数字段的数量和类型;根据每一所述编译前的指令的类型、所述源操作数字段的数量和类型,生成对应的操作码。In other embodiments, the generation unit is further configured to: if it is determined that the fields of the same type include source operand fields, determine the number and type of the source operand fields; and generate a corresponding opcode according to the type of each pre-compiled instruction and the number and type of the source operand fields.

在其他的实施例中,所述装置还包括:分类单元,配置为:根据每一编译前的指令所要执行的功能,对所述编译前的指令进行分类,得到分类结果;对应地,所述生成单元,还配置为:如果确定所述相同类型的字段包括源操作数字段,根据所述分类结果,确定所述源操作数字段的数量和类型。In other embodiments, the device further includes: a classification unit, configured to: classify the pre-compiled instructions according to the function to be performed by each pre-compiled instruction to obtain a classification result; correspondingly, the generation unit is also configured to: if it is determined that the fields of the same type include source operand fields, determine the number and type of the source operand fields according to the classification result.

在其他的实施例中,所述生成单元,还配置为:对每一所述编译前的指令的类型进行标记,生成与每一所述编译前的指令对应的第一标识码;根据所述源操作数字段的数量和类型,生成对应的第二标识码;将所述第一标识码和所述第二标识码合并,生成对应的操作码。In other embodiments, the generation unit is further configured to: mark the type of each pre-compiled instruction to generate a first identification code corresponding to each pre-compiled instruction; generate a corresponding second identification code based on the number and type of the source operand fields; and merge the first identification code and the second identification code to generate a corresponding operation code.

图6为本申请实施例提供的指令数据的处理装置的组成结构示意图二,如图6所示,所述装置包括:FIG6 is a second schematic diagram of the composition structure of the instruction data processing device provided in an embodiment of the present application. As shown in FIG6 , the device includes:

第一确定单元61,配置为确定编译后的指令中的操作码。The first determining unit 61 is configured to determine an operation code in the compiled instruction.

第二确定单元62,配置为根据所述操作码,确定所述指令的类型和所述指令中的字段的属性信息。The second determining unit 62 is configured to determine the type of the instruction and attribute information of the fields in the instruction according to the operation code.

第三确定单元63,配置为根据所述字段的属性信息,从所述指令中的指定编码位置确定相应类型的字段。The third determining unit 63 is configured to determine a field of a corresponding type from a designated encoding position in the instruction according to the attribute information of the field.

第二输出单元64,配置为根据所述相应类型的字段获取对应的操作数,并输出所述操作数。The second output unit 64 is configured to obtain a corresponding operand according to the field of the corresponding type and output the operand.

在其他的实施例中,所述第二确定单元,还配置为:如果检测出所述指令需要获取源操作数字段,解析所述需要获取源操作数字段的指令对应的操作码,得到解析结果;根据所述解析结果,确定所述指令的类型和所述源操作数字段的属性信息。In other embodiments, the second determination unit is further configured to: if it is detected that the instruction needs to obtain a source operand field, parse the opcode corresponding to the instruction that needs to obtain the source operand field to obtain a parsing result; and determine the type of the instruction and attribute information of the source operand field based on the parsing result.

在其他的实施例中,所述第三确定单元,还配置为:根据从所述操作码中解析出的第一标识码,确定所述指令的类型;根据从所述操作码中解析出的第二标识码,确定所述源操作数字段数量和类型;根据所述源操作数字段数量和类型,从所述指令中的指定编码位置确定所述源操作数字段。In other embodiments, the third determination unit is further configured to: determine the type of the instruction based on a first identification code parsed from the opcode; determine the number and type of source operand fields based on a second identification code parsed from the opcode; and determine the source operand fields from a specified encoding position in the instruction based on the number and type of source operand fields.

在其他的实施例中,所述第二输出单元,还配置为:根据所述源操作数字段,确定所述源操作数的编号和地址;根据所述源操作数的编号和地址,获取所述源操作数,并输出所述源操作数。In other embodiments, the second output unit is further configured to: determine the number and address of the source operand according to the source operand field; obtain the source operand according to the number and address of the source operand, and output the source operand.

需要说明的是,本申请实施例中,如果以软件功能模块的形式实现上述指令数据的处理方法,并作为独立的产品销售或使用时,也可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请实施例的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备执行本申请各个实施例所述方法的全部或部分。而前述的存储介质包括:U盘、移动硬盘、只读存储器(Read Only Memory,ROM)、磁碟或者光盘等各种可以存储程序代码的介质。这样,本申请实施例不限制于任何特定的硬件和软件结合。It should be noted that in the embodiment of the present application, if the processing method of the above-mentioned instruction data is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the embodiment of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions to enable a computer device to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a U disk, a mobile hard disk, a read-only memory (ROM), a disk or an optical disk. In this way, the embodiment of the present application is not limited to any specific combination of hardware and software.

对应地,本申请实施例提供一种计算机可读存储介质,其上存储有计算机程序,该计算机程序被处理器执行时实现上述实施例提供的指令数据的处理方法中的步骤。Correspondingly, an embodiment of the present application provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps in the instruction data processing method provided in the above embodiment are implemented.

本申请装置实施例的描述,与上述方法实施例的描述是类似的,具有同方法实施例相似的有益效果。对于本申请装置实施例中未披露的技术细节,请参照本申请方法实施例的描述而理解。The description of the device embodiment of the present application is similar to the description of the above method embodiment, and has similar beneficial effects as the method embodiment. For technical details not disclosed in the device embodiment of the present application, please refer to the description of the method embodiment of the present application for understanding.

这里需要指出的是:以上存储介质和设备实施例的描述,与上述方法实施例的描述是类似的,具有同方法实施例相似的有益效果。对于本申请存储介质和设备实施例中未披露的技术细节,请参照本申请方法实施例的描述而理解。It should be noted here that the description of the above storage medium and device embodiments is similar to the description of the above method embodiments, and has similar beneficial effects as the method embodiments. For technical details not disclosed in the storage medium and device embodiments of this application, please refer to the description of the method embodiments of this application for understanding.

需要说明的是,图7为本申请实施例提供的一种计算机设备结构示意图,如图7所示,该计算机设备70至少包括:处理器71、通信接口72和存储器73,其中It should be noted that FIG. 7 is a schematic diagram of a computer device structure provided in an embodiment of the present application. As shown in FIG. 7 , the computer device 70 at least includes: a processor 71, a communication interface 72 and a memory 73, wherein

处理器71通常控制计算机设备70的总体操作。Processor 71 generally controls the overall operation of computer device 70 .

通信接口72可以使计算机设备通过网络与其他计算机设备或服务器通信。The communication interface 72 may enable the computer device to communicate with other computer devices or servers via a network.

存储器73配置为存储由处理器71可执行的指令和应用,还可以缓存待处理器71以及计算机设备70中各模块待处理或已经处理的数据(例如,图像数据、音频数据、语音通信数据和视频通信数据),可以通过闪存(FLASH)或随机访问存储器(Random Access Memory,RAM)实现。The memory 73 is configured to store instructions and applications executable by the processor 71, and can also cache data to be processed or processed by the processor 71 and various modules in the computer device 70 (for example, image data, audio data, voice communication data, and video communication data), which can be implemented through flash memory (FLASH) or random access memory (Random Access Memory, RAM).

当然,本申请实施例中的装置还可有其他类似的协议交互实现案例,在不背离本申请精神及其实质的情况下,本领域的技术人员当可根据本申请实施例做出各种相应的改变和变形,但这些相应的改变和变形都应属于本申请方法所附的权利要求的保护范围。Of course, the device in the embodiment of the present application may also have other similar protocol interaction implementation cases. Without departing from the spirit and essence of the present application, technicians in this field can make various corresponding changes and deformations according to the embodiment of the present application, but these corresponding changes and deformations should all fall within the scope of protection of the claims attached to the method of the present application.

本领域内的技术人员应明白,本申请的实施例可提供为方法、系统、或计算机程序产品。因此,本申请可采用硬件实施例、软件实施例、或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器和光学存储器等)上实施的计算机程序产品的形式。Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of hardware embodiments, software embodiments, or embodiments in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage and optical storage, etc.) that contain computer-usable program code.

本申请是参照根据本申请实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的设备。The present application is described with reference to the flowchart and/or block diagram of the method, device (system) and computer program product according to the embodiment of the present application. It should be understood that each process and/or box in the flowchart and/or block diagram, and the combination of the process and/or box in the flowchart and/or block diagram can be realized by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device produce a device for realizing the function specified in one process or multiple processes in the flowchart and/or one box or multiple boxes in the block diagram.

这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令设备的制造品,该指令设备实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device that implements the functions specified in one or more processes in the flowchart and/or one or more boxes in the block diagram.

这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions may also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, whereby the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one or more processes in the flowchart and/or one or more boxes in the block diagram.

应理解,说明书通篇中提到的“一个实施例”或“一实施例”意味着与实施例有关的特定特征、结构或特性包括在本申请的至少一个实施例中。因此,在整个说明书各处出现的“在一个实施例中”或“在一实施例中”未必一定指相同的实施例。此外,这些特定的特征、结构或特性可以任意适合的方式结合在一个或多个实施例中。应理解,在本申请的各种实施例中,上述各过程的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本申请实施例的实施过程构成任何限定。上述本申请实施例序号仅仅为了描述,不代表实施例的优劣。It should be understood that "one embodiment" or "an embodiment" mentioned throughout the specification means that specific features, structures or characteristics related to the embodiment are included in at least one embodiment of the present application. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. It should be understood that in various embodiments of the present application, the size of the sequence number of the above-mentioned processes does not mean the order of execution, and the execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application. The above-mentioned sequence numbers of the embodiments of the present application are only for description and do not represent the advantages and disadvantages of the embodiments.

需要说明的是,在本文中,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者装置不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者装置所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括该要素的过程、方法、物品或者装置中还存在另外的相同要素。It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.

在本申请所提供的几个实施例中,应该理解到,所揭露的设备和方法,可以通过其它的方式实现。以上所描述的设备实施例仅仅是示意性的,例如,所述模块的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,如:多个模块或组件可以结合,或可以集成到另一个系统,或一些特征可以忽略,或不执行。另外,所显示或讨论的各组成部分相互之间的耦合、或直接耦合、或通信连接可以是通过一些接口,设备或模块的间接耦合或通信连接,可以是电性的、机械的或其它形式的。In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of the modules is only a logical function division. There may be other division methods in actual implementation, such as: multiple modules or components can be combined, or can be integrated into another system, or some features can be ignored, or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or modules can be electrical, mechanical or other forms.

上述作为分离部件说明的模块可以是、或也可以不是物理上分开的,作为模块显示的部件可以是、或也可以不是物理模块;既可以位于一个地方,也可以分布到多个网络模块上;可以根据实际的需要选择其中的部分或全部模块来实现本实施例方案的目的。The modules described above as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules; they may be located in one place or distributed on multiple network modules; some or all of the modules may be selected according to actual needs to achieve the purpose of the present embodiment.

以上所述,仅为本申请的实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以所述权利要求的保护范围为准。The above is only an implementation method of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims (8)

1. A method of processing instruction data, the method comprising:
If the fact that the fields of the same type among the instructions before compiling comprise source operand fields is determined, the number and the types of the source operand fields are determined, and the fields of the same type are stored to the same bit positions preset by each instruction during compiling;
Marking the type of each pre-compiling instruction, and generating a first identification code corresponding to each pre-compiling instruction;
Generating a corresponding second identification code according to the number and the type of the source operand fields;
Combining the first identification code and the second identification code to generate a corresponding operation code;
Storing the operation code into a compiled instruction;
outputting the compiled instruction.
2. The method according to claim 1, wherein the method further comprises:
Classifying the pre-compiled instructions according to the functions to be executed by each pre-compiled instruction to obtain classification results;
correspondingly, the determining the number and type of the source operand fields includes:
and determining the number and the type of the source operand fields according to the classification result.
3. A method of processing instruction data, the method comprising:
Determining an operation code in the compiled instruction;
If the instruction is detected to need to acquire the source operand field, analyzing an operation code corresponding to the instruction needing to acquire the source operand field to obtain an analysis result;
Determining the type of the instruction according to a first identification code analyzed from the operation code; determining the number and the type of the source operand fields according to a second identification code analyzed from the operation code; determining the source operand fields from specified encoding positions in the instruction according to the number and type of the source operand fields;
And acquiring a corresponding operand according to the source operand field, and outputting the operand.
4. A method according to claim 3, wherein said retrieving a corresponding operand from said source operand field and outputting said operand comprises:
Determining the number and address of the source operand according to the source operand field;
And acquiring the source operand according to the number and the address of the source operand, and outputting the source operand.
5. An apparatus for processing instruction data, the apparatus comprising:
A first storage unit configured to store, if it is determined that the same type of field includes a source operand field between the instructions before compiling, the number and type of the source operand fields, and at the time of compiling, the same type of field to the same bit position preset by each instruction;
A generating unit configured to mark a type of each pre-compiling instruction and generate a first identification code corresponding to each pre-compiling instruction; generating a corresponding second identification code according to the number and the type of the source operand fields; combining the first identification code and the second identification code to generate a corresponding operation code;
a second storage unit configured to store the operation code into a compiled instruction;
And the first output unit is configured to output the compiled instruction.
6. An apparatus for processing instruction data, the apparatus comprising:
a first determination unit configured to determine an operation code in the compiled instruction;
The second determining unit is configured to parse the operation code corresponding to the instruction needing to acquire the source operand field if the instruction needing to acquire the source operand field is detected, so as to obtain a parsing result; a third determining unit configured to determine a type of the instruction according to a first identification code parsed from the operation code; determining the number and the type of the source operand fields according to a second identification code analyzed from the operation code; determining the source operand fields from specified encoding positions in the instruction according to the number and type of the source operand fields;
And the second output unit is configured to acquire a corresponding operand according to the source operand field and output the operand.
7. A computer device, the computer device comprising at least: a processor and a storage medium configured to store executable instructions, wherein:
The processor is configured to execute stored executable instructions configured to perform the method of processing instruction data provided in any of the preceding claims 1 to 4.
8. A computer-readable storage medium having stored therein computer-executable instructions configured to perform the steps of the method of processing instruction data provided in any one of the preceding claims 1 to 4.
CN201811436260.8A 2018-11-28 2018-11-28 A method, device, and storage medium for processing instruction data Active CN111240682B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201811436260.8A CN111240682B (en) 2018-11-28 2018-11-28 A method, device, and storage medium for processing instruction data
PCT/CN2019/111729 WO2020108158A1 (en) 2018-11-28 2019-10-17 Instruction data processing method and apparatus, and device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811436260.8A CN111240682B (en) 2018-11-28 2018-11-28 A method, device, and storage medium for processing instruction data

Publications (2)

Publication Number Publication Date
CN111240682A CN111240682A (en) 2020-06-05
CN111240682B true CN111240682B (en) 2024-11-08

Family

ID=70854310

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811436260.8A Active CN111240682B (en) 2018-11-28 2018-11-28 A method, device, and storage medium for processing instruction data

Country Status (2)

Country Link
CN (1) CN111240682B (en)
WO (1) WO2020108158A1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117311727A (en) * 2023-11-27 2023-12-29 摩尔线程智能科技(北京)有限责任公司 Analysis methods, devices, electronic equipment and storage media

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5819097A (en) * 1996-12-09 1998-10-06 Allen Bradley Company, Llc Industrial controller compiler with expandable instruction set
CN102141903A (en) * 2011-03-22 2011-08-03 杭州中天微系统有限公司 Device for symmetrically encoding 16/32-bit mixed instruction and device for decoding 16/32-bit mixed instruction

Family Cites Families (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2669158B2 (en) * 1991-01-22 1997-10-27 三菱電機株式会社 Data processing device
DE19737658C2 (en) * 1996-10-18 1999-10-14 Nat Semiconductor Corp Command decoder for a microprocessor
DE19933130A1 (en) * 1999-07-19 2001-01-25 Giesecke & Devrient Gmbh Operand stack and method for operating an operand stack
TW200739419A (en) * 2006-04-07 2007-10-16 Univ Feng Chia Prediction mechanism of a program backward jump instruction
US20070266225A1 (en) * 2006-05-09 2007-11-15 Ko Tak K V Microcontroller unit
CN100541433C (en) * 2007-09-13 2009-09-16 上海交通大学 Assembler Based on User Description and Its Realization Method
US8028153B2 (en) * 2008-08-14 2011-09-27 International Business Machines Corporation Data dependent instruction decode
US9766888B2 (en) * 2014-03-28 2017-09-19 Intel Corporation Processor instruction to store indexes of source data elements in positions representing a sorted order of the source data elements
CN104731558A (en) * 2015-01-13 2015-06-24 山东大学 Instruction set design method for embedded graphic processing unit
CN106406820B (en) * 2015-07-29 2019-01-15 深圳市中兴微电子技术有限公司 A kind of multi-emitting parallel instructions processing method and processing device of network processor micro-engine
US20170090922A1 (en) * 2015-09-30 2017-03-30 Futurewei Technologies, Inc. Efficient Instruction Pair for Central Processing Unit (CPU) Instruction Design
CN107016175B (en) * 2017-03-23 2018-08-31 中国科学院计算技术研究所 It is applicable in the Automation Design method, apparatus and optimization method of neural network processor

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5819097A (en) * 1996-12-09 1998-10-06 Allen Bradley Company, Llc Industrial controller compiler with expandable instruction set
CN102141903A (en) * 2011-03-22 2011-08-03 杭州中天微系统有限公司 Device for symmetrically encoding 16/32-bit mixed instruction and device for decoding 16/32-bit mixed instruction

Also Published As

Publication number Publication date
WO2020108158A1 (en) 2020-06-04
CN111240682A (en) 2020-06-05

Similar Documents

Publication Publication Date Title
US10949442B2 (en) Method and apparatus for accelerated format translation of data in a delimited data format
US10902013B2 (en) Method and apparatus for accelerated record layout detection
US10102260B2 (en) Method and apparatus for accelerated data translation using record layout detection
JP6109186B2 (en) Counter operation in a state machine grid
US10621192B2 (en) Method and apparatus for accelerated format translation of data in a delimited data format
JP6126127B2 (en) Method and system for routing in a state machine
CN104471552B (en) For disposing the method and system of state machine engine received data
US8726256B2 (en) Unrolling quantifications to control in-degree and/or out-degree of automaton
KR20140102274A (en) Boolean logic in a state machine lattice
JP6449287B2 (en) Autonomous memory method and system
US20220261257A1 (en) Systems and devices for accessing a state machine
CN111030998A (en) A configurable protocol parsing method and system
US11580055B2 (en) Devices for time division multiplexing of state machine engine signals
CN111240682B (en) A method, device, and storage medium for processing instruction data
CN111324645B (en) Block chain data processing method and device
Fang et al. SIFO: Secure computational infrastructure using FPGA overlays
CN115277553A (en) Flow table storage method, device, equipment and computer readable storage medium
US9979802B2 (en) Assembling response packets
US10642710B2 (en) Apparatus and method for generating and processing a trace stream indicative of execution of predicated vector memory access instructions by processing circuitry
CN109542904A (en) Business data processing method, device, server and medium
US10915547B2 (en) Optimizing data conversion using pattern frequency
US8661162B2 (en) Address handling
CN118409771A (en) Method and storage medium for automatically adding computer instructions in compiler
TW565775B (en) Arrangement for command transmission
WO2024234924A1 (en) Metadata generation method, metadata verification method and electronic device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information

Country or region after: China

Address after: 518055, 2nd Floor, ZTE Industrial Park, No. 2 Chuangyan Road, Xili Community, Xili Street, Nanshan District, Shenzhen City, Guangdong Province, China

Applicant after: SANECHIPS TECHNOLOGY Co.,Ltd.

Address before: 518055 Zhongxing Industrial Park, Liuxian Avenue, Xili street, Nanshan District, Shenzhen City, Guangdong Province

Applicant before: SANECHIPS TECHNOLOGY Co.,Ltd.

Country or region before: China

CB02 Change of applicant information
GR01 Patent grant
GR01 Patent grant