[go: up one dir, main page]

CN111240682A - Method and device, device, and storage medium for processing instruction data - Google Patents

Method and device, device, and storage medium for processing instruction data Download PDF

Info

Publication number
CN111240682A
CN111240682A CN201811436260.8A CN201811436260A CN111240682A CN 111240682 A CN111240682 A CN 111240682A CN 201811436260 A CN201811436260 A CN 201811436260A CN 111240682 A CN111240682 A CN 111240682A
Authority
CN
China
Prior art keywords
instruction
type
source operand
field
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.)
Granted
Application number
CN201811436260.8A
Other languages
Chinese (zh)
Other versions
CN111240682B (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

Images

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

本申请实施例公开了一种指令数据的处理方法及装置、设备、存储介质,其中,所述方法包括:如果确定编译前的指令之间有相同类型的字段,编译时,将所述相同类型的字段存储至指定编码位置;根据每一所述编译前的指令的类型和所述相同类型的字段的属性信息,生成对应的操作码;将所述操作码存储至编译后的指令中;输出所述编译后的指令。

Figure 201811436260

The embodiment of the present application discloses a method, device, 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 the instructions before compilation, when compiling, the same type of field is The field is stored to the specified encoding position; according to the type of each said pre-compiled instruction and the attribute information of the same type of field, the corresponding opcode is generated; the said opcode is stored in the compiled instruction; output the compiled instructions.

Figure 201811436260

Description

一种指令数据的处理方法及装置、设备、存储介质Method and device, 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, apparatus, device, and storage medium for processing instruction data.

背景技术Background technique

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

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

发明内容SUMMARY OF THE INVENTION

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

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

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

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

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

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

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

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

本申请实施例提供了一种指令数据的处理方法及装置、设备、存储介质,其中,所述方法包括:如果确定编译前的指令之间有相同类型的字段,编译时,将所述相同类型的字段存储至指定编码位置;根据每一所述编译前的指令的类型和所述相同类型的字段的属性信息,生成对应的操作码;将所述操作码存储至编译后的指令中;输出所述编译后的指令。这样,将令操作码与指令的类型以及指令源操作数的数量和类型直接关联,实现据所述指令操作码完成对指令源操作数的分类获取。Embodiments of the present application provide a method, device, 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, when compiling The field is stored to the specified coding position; according to the type of each said pre-compiled instruction and the attribute information of the same type of field, the corresponding opcode is generated; the said opcode is stored in the compiled instruction; output the compiled instructions. In this way, the operation code is directly associated with the type of the instruction and the quantity and type of the instruction source operand, so that the classification and acquisition of the instruction source operand can be completed according to the instruction operation code.

附图说明Description of drawings

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

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

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

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

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

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

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

具体实施方式Detailed ways

相关技术中,在设计网络处理器的指令集时,需要考虑指令编码、储存、获取、解码等几个关键技术,其中指令编解码是指令集设计的基础,直接决定指令集处理的复杂度。同时为了能够处理网络中各种业务数据,需要设计多种不同功能的指令以及大容量的指令空间。因此,如果指令编解码没有对应的好的设计方案,往往会导致逻辑设计的复杂度很高,而且会占用大量的芯片内存,功耗也很高。In the related art, when designing an instruction set of a network processor, several key technologies such as instruction encoding, storage, acquisition, and decoding need to be considered. Instruction encoding and decoding are the basis of instruction set design, and directly determine 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 a variety of commands with different functions and a large-capacity command space. Therefore, if the instruction encoding and decoding does not have a corresponding good design scheme, it will often lead to high complexity of the logic design, and will occupy a large amount of chip memory, and the power consumption is also high.

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

基于网络处理器的指令数量非常多,通过这样的方式获取源操作数,不仅需要额外增加芯片内存资源,用于存储每个指令的源操作数信息;而且也大大增加了芯片内核的逻辑复杂度。The number of instructions based on network processors is very large. 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 logic complexity of the chip core. .

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

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

图1为本申请实施例提供的指令数据的处理方法流程示意图一,如图1所示,该方法包括:FIG. 1 is a schematic flow chart 1 of a method for processing instruction data provided by 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, during compilation, the fields of the same type are stored in a specified encoding position.

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

步骤S12,据每一所述编译前的指令的类型和所述相同类型的字段的属性信息,生成对应的操作码。Step S12: Generate a corresponding operation code according to the type of each pre-compiled instruction 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 the embodiment of the present application, the type of the instruction before compilation and the attribute information of the field of the same type can be obtained, the type of the instruction before compilation and the attribute information of the field of the same type can be marked respectively, and the corresponding opcode. Here, the types of instructions may be: logical calculation instructions, data upload/download instructions, jump instructions, and some special instructions, etc., which can be preset as required. Fields of the same type can be different source operands, destination operands, or other fields.

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

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

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

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

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

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

步骤S102,如果确定所述相同类型的字段包括源操作数字段,确定所述源操作数字段的数量和类型。Step S102, 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.

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

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

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

上述的步骤S102至步骤S103提供了一种实现步骤“根据每一所述编译前的指令的类型和所述相同类型字段的属性信息,生成对应的操作码”的方式。该方式中,如果确定所述相同类型的字段包括源操作数字段,确定所述源操作数字段的数量和类型,根据每一所述编译前的指令的类型、所述源操作数字段的数量和类型,生成对应的操作码。能够将令操作码与指令的类型以及源操作数字段的数量和类型直接关联,实现据所述指令操作码完成对指令源操作数的分类获取。The above steps S102 to S103 provide a way of implementing the step "generate a corresponding operation code according to the type of each of the pre-compiled instructions and the attribute information of the same type field". In this manner, 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 type of each of the precompiled instructions, the number of the source operand fields and type to generate the corresponding opcode. The command operation code can be directly associated with the type of the instruction and the quantity and type of the source operand field, so as to realize the classification and acquisition of the instruction source operand according to the instruction operation code.

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

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

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

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

这里,可以根据指令所要执行的功能,将编译前的指令分为至少一类。其中,分类结果可以为:逻辑计算类指令、数据上传/下载类指令、跳转类指令和一些特殊类指令等。Here, the instructions before compilation can be classified into at least one type according to the function to be performed by the instruction. Wherein, the classification results may be: logical calculation instructions, data upload/download instructions, jump instructions, some special instructions, and the like.

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

步骤S203,如果确定所述相同类型的字段包括源操作数字段,根据所述分类结果,确定所述源操作数字段的数量和类型。Step S203, 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.

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

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

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

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

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

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

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

步骤S303,如果确定所述相同类型的字段包括源操作数字段,根据所述分类结果,确定所述源操作数字段的数量和类型。Step S303, 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.

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

这里,对指令的类型进行标记是指:编译单元根据指令的类型,生成相应的标识码。例如,可以将指令分为逻辑计算类指令、数据上传/下载类指令、跳转类指令和特殊类指令四种类型,再根据该四种类型生成四个对应标记,分别为逻辑计算类指令对应第一标识码一00、数据上传/下载类指令对应第一标识码二01、跳转类指令对应第一标识码三10、特殊类指令对应第一标识码四11。将上述标识码作为相应的指令的操作码字段编码的第一部分。Here, marking the type of the instruction means that the compiling unit generates a corresponding identification code according to the type of the instruction. For example, the instructions can be divided into four types: logical calculation instructions, data upload/download instructions, jump instructions and special instructions, and then generate four corresponding tags according to the four types, which are corresponding to the logical calculation instructions. The first identification code one is 00, the data upload/download type instruction corresponds to the first identification code two 01, the jump type instruction corresponds to the first identification code three 10, and the special type instruction corresponds to the first identification code four 11. The above identification code is used as the first part of the encoding of the opcode field 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, according to the number and type of source operands, the four types of instructions are divided into logical calculation instructions, data upload/download instructions, jump instructions and special instructions are divided into eight types as an example. Respectively: the instruction that does not require a source operand or a source operand in the form of an immediate value is type 1; the instruction that only needs to operate a source operand in the form of a condition register is type 2; only needs to operate a source operation in the form of a normal register. Number instructions are type three; instructions that only need to operate a source operand in the form of 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 memory are type five; Instructions with source operands in the form of ordinary registers and one source operand in the form of condition registers 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 memory and a Instructions with source operands in the form of condition registers are of type eight.

编译单元根据源操作数的数量和类型,对指令进行分类,得到分类结果,对分类结果得到相应的标识码。以上述八种类型为例,类型一对应第二标识码一000,类型二对应第二标识码二001,类型三对应第二标识码三010,类型四对应第二标识码四011,类型五对应第二标识码五100,类型六对应第二标识码六101,类型七对应第二标识码七110,类型八对应第二标识码八111。将上述标识码作为相应的指令的操作码字段编码的第二部分。The compiling unit classifies the instruction according to the quantity and type of the source operand, obtains the classification result, and obtains the corresponding identification code for the classification result. Taking the above eight types as an example, type one corresponds to the second identification code 1000, 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, and type five corresponds to the second identification code four 011. Corresponding 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 code is used as the second part of the encoding of the opcode field of the corresponding instruction.

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

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

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

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

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

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

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

这里,解码单元接收到编译后的指令之后,可以从编译后的指令中确定对应的操作码。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 a field 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 determines the type of the instruction and the attribute information of the fields in the instruction according to the operation code.

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

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

步骤S24,根据所述相应类型的字段获取对应的操作数,并输出所述操作数。Step S24: Acquire the corresponding operand according to the field of the corresponding type, and output the operand.

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

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

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

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

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

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

步骤S403,根据所述解析结果,确定所述指令的类型和所述源操作数字段的属性信息。Step S403: Determine the type of the instruction and 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 the 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 way of implementing the steps of "determining the type of the instruction and the attribute information of the fields in the instruction according to the operation code". In this method, if it is detected that the instruction needs to obtain the source operand field, the operation code 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, according to the attribute information of the field, determine the field of the corresponding type from the specified encoding position in the instruction.

步骤S405,根据所述相应类型的字段获取对应的操作数,并输出所述操作数。Step S405: Acquire the corresponding operand according to the field of the corresponding type, and output the operand.

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

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

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

步骤S503,根据所述解析结果,确定所述指令的类型和所述源操作数字段的属性信息。Step S503: Determine the type of the instruction and 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 opcode, that is, parses the first identification code of the opcode, and can determine the type of the instruction.

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

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

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

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

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

步骤S507,根据所述相应类型的字段获取对应的操作数,并输出所述操作数。Step S507: Acquire a corresponding operand according to the field of the corresponding type, and output the operand.

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

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

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

步骤S603,根据所述解析结果,确定所述指令的类型和所述源操作数字段的属性信息。Step S603: Determine the type of the instruction and 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 field according to the second identification code parsed from the operation code.

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

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

步骤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: Acquire the source operand according to the number and address of the source operand, and output the source operand.

上述的步骤S608至步骤S609提供了一种实现步骤“根据所述相应类型的字段获取对应的操作数,并输出所述操作数”的方式。该方式中,根据源操作数字段,确定源操作数的编号和地址;根据源操作数的编号和地址,获取源操作数,并输出所述源操作数。能够根据源操作数字段数量和类型,直接从指令中的指定编码位置确定源操作数字段,然后根据源操作数字段直接获取相应的源操作数,可以减少解码的复杂度。The above-mentioned steps S608 to S609 provide a way of implementing the steps of "acquiring corresponding operands according to the fields of the corresponding types, and outputting the operands". In this manner, 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 directly determined 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所示,该方法包括以下步骤:3 is a schematic flowchart of a method for processing instruction source operands of a network processor provided by an embodiment of the present application. As shown in FIG. 3 , the method includes the following steps:

步骤S31,编译单元将各个指令之间的相同字段放在指令编码中固定位置。In step S31, the compiling unit places the same field between each instruction in a fixed position in the instruction encoding.

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

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

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

步骤S32,编译单元对指令的类型及指令的源操作数进行判断和标记,根据所述标记生成指令相应的操作码。Step S32, the compiling unit judges and marks the type of the 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 completes the judgment and marking of the type of the instruction and the source operand of the instruction, and generates the corresponding instruction opcode, which is directly related to the type of the instruction and the number and type of the instruction source operand; The above instruction opcode completes the classification and acquisition of the instruction source operand.

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

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

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

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

所述对指令的源操作数进行标记是指:编译单元根据源操作数的数量和类型,对指令进行分类,得到分类结果,对分类结果进行标记。以上述八种类型为例,类型一对应标记一000,类型二对应标记二001,类型三对应标记三010,类型四对应标记四011,类型五对应标记五100,类型六对应标记六101,类型七对应标记七110,类型八对应标记八111,作为指令的操作码字段编码的第二部分。The labeling of the source operands of the instruction means that the compiling unit classifies the instruction according to the number and type of the source operands, obtains the classification result, and marks the classification result. 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 tag seven 110, and type eight corresponds to tag eight 111, as the second part of the instruction's opcode field encoding.

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

本申请实施例中,解码单元判断操作码的第二部分,对于源操作数一分成三种情况:指令不需要获取源操作数一,直接透传读取单元的,对应上述步骤S32操作码第二部分的000,001和011;指令需要获取源操作数一,且需要从指令编码中截取源寄存器的编号和地址的,对应上述步骤S32操作码第二部分的010,100,101和110;指令需要获取源操作数一,且读地址固定无需其他解码操作的,对应上述步骤S32操作码第二部分的111。In the embodiment of the present application, the decoding unit determines the second part of the opcode, and the source operand 1 is divided into three cases: the instruction does not need to obtain the source operand 1, and the read unit is directly transparently transmitted, corresponding to the above step S32. Two parts of 000, 001 and 011; if 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 encoding, it corresponds to 010, 100, 101 and 110 of the second part of the operation code in the above step S32; If the instruction needs to obtain the source operand one, and the read address is fixed and no other decoding operation is required, it corresponds to 111 in the second part of the operation code in the above step S32.

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

解码单元需要的包括三种操作方式,其中,在截取源操作的编号和地址时,部分指令的源操作数二条件寄存器需要转换成普通寄存器的操作。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 registers.

步骤S34,解码单元根据所述源操作数的编号和地址,在内核寄存器中获取源操作数的数据,并送给执行单元。Step S34, the decoding unit obtains the data of the source operand in the kernel 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 obtained number and address of the source operand to the reading unit, and the reading unit obtains the data of the source operand in the kernel register and sends it to the execution unit. Transparently transmitted to the execution unit.

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

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

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

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

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

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

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

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

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

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

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

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

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

在其他的实施例中,所述生成单元,还配置为:如果确定所述相同类型的字段包括源操作数字段,确定所述源操作数字段的数量和类型;根据每一所述编译前的指令的类型、所述源操作数字段的数量和类型,生成对应的操作码。In other embodiments, the generating 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; The type of instruction, the number and type of the source operand field, and the corresponding opcode is generated.

在其他的实施例中,所述装置还包括:分类单元,配置为:根据每一编译前的指令所要执行的功能,对所述编译前的指令进行分类,得到分类结果;对应地,所述生成单元,还配置为:如果确定所述相同类型的字段包括源操作数字段,根据所述分类结果,确定所述源操作数字段的数量和类型。In other embodiments, the apparatus 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 The generating 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 according to the classification result.

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

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

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

第二确定单元62,配置为根据所述操作码,确定所述指令的类型和所述指令中的字段的属性信息。The second determination 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 the specified encoding position in the instruction according to the attribute information of the field.

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

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

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

在其他的实施例中,所述第二输出单元,还配置为:根据所述源操作数字段,确定所述源操作数的编号和地址;根据所述源操作数的编号和地址,获取所述源操作数,并输出所述源操作数。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 number and address of the source operand according to the number and address of the source operand the source operand, and output the source operand.

需要说明的是,本申请实施例中,如果以软件功能模块的形式实现上述指令数据的处理方法,并作为独立的产品销售或使用时,也可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请实施例的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备执行本申请各个实施例所述方法的全部或部分。而前述的存储介质包括:U盘、移动硬盘、只读存储器(Read Only Memory,ROM)、磁碟或者光盘等各种可以存储程序代码的介质。这样,本申请实施例不限制于任何特定的硬件和软件结合。It should be noted that, in the embodiments of the present application, if the above-mentioned instruction data processing method 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 understanding, the technical solutions of the embodiments of the present application can be embodied in the form of software products in essence or in the parts that make contributions to the prior art. The computer software products are stored in a storage medium and include several instructions for A computer device is caused to execute all or part of the methods described in the various embodiments of the present application. The aforementioned storage medium includes: a U disk, a removable hard disk, a read only memory (Read Only Memory, ROM), a magnetic disk or an optical disk and other mediums that can store program codes. As such, the embodiments of the present application are not limited to any specific combination of hardware and software.

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

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

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

需要说明的是,图7为本申请实施例提供的一种计算机设备结构示意图,如图7所示,该计算机设备70至少包括:处理器71、通信接口72和存储器73,其中It should be noted that FIG. 7 is a schematic structural diagram of a computer device provided by an embodiment of the 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的总体操作。The processor 71 generally controls the overall operation of the computer device 70 .

通信接口72可以使计算机设备通过网络与其他计算机设备或服务器通信。Communication interface 72 may enable the computer device to communicate with other computer devices or servers over 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 may also cache data to be processed or processed by the processor 71 and various modules in the computer device 70 (eg, image data, audio data, voice communication data and video communication data), which can be implemented by flash memory (FLASH) or random access memory (Random Access Memory, RAM).

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

本领域内的技术人员应明白,本申请的实施例可提供为方法、系统、或计算机程序产品。因此,本申请可采用硬件实施例、软件实施例、或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器和光学存储器等)上实施的计算机程序产品的形式。As will be appreciated by those skilled in the art, the embodiments of the present application may be provided as a method, a system, or a computer program product. Accordingly, the application may take the form of a hardware embodiment, a software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media having computer-usable program code embodied therein, including but not limited to disk storage, optical storage, and the like.

本申请是参照根据本申请实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的设备。The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the present application. It will be understood that each flow and/or block in the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to the processor of a general purpose computer, special purpose computer, embedded processor or other programmable data processing device to produce a machine such that the instructions executed by the processor of the computer or other programmable data processing device produce A device that implements the functions specified in a flow or flow of a flowchart and/or a block or blocks of a block diagram.

这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令设备的制造品,该指令设备实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer readable memory result in an article of manufacture comprising the instruction apparatus, the instructions The device implements the functions specified in the flow or flows of the flowcharts and/or the block or blocks of the block diagrams.

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

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

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

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

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

以上所述,仅为本申请的实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以所述权利要求的保护范围为准。The above is only the embodiment of the present application, but the protection scope of the present application is not limited to this. Covered within the scope of protection of this application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.

Claims (12)

1.一种指令数据的处理方法,其特征在于,所述方法包括:1. A method for processing instruction data, wherein the method comprises: 如果确定编译前的指令之间有相同类型的字段,编译时,将所述相同类型的字段存储至指定编码位置;If it is determined that there are fields of the same type between the instructions before compilation, during compilation, the fields of the same type are stored in the specified encoding position; 根据每一所述编译前的指令的类型和所述相同类型的字段的属性信息,生成对应的操作码;generating a corresponding opcode according to the type of each of the pre-compiled instructions and the attribute information of the field of the same type; 将所述操作码存储至编译后的指令中;storing the opcode in the compiled instruction; 输出所述编译后的指令。The compiled instructions are output. 2.根据权利要求1所述的方法,其特征在于,所述根据每一所述编译前的指令的类型和所述相同类型字段的属性信息,生成对应的操作码,包括:2. The method according to claim 1, wherein generating a corresponding opcode according to the type of each of the pre-compiled instructions and the attribute information of the same type field, comprising: 如果确定所述相同类型的字段包括源操作数字段,确定所述源操作数字段的数量和类型;If it is determined that the fields of the same type include source operand fields, determining the number and type of the source operand fields; 根据每一所述编译前的指令的类型、所述源操作数字段的数量和类型,生成对应的操作码。A corresponding opcode is generated according to the type of each of the precompiled instructions, and the number and type of the source operand fields. 3.根据权利要求2所述的方法,其特征在于,所述方法还包括:3. The method according to claim 2, wherein the method further comprises: 根据每一编译前的指令所要执行的功能,对所述编译前的指令进行分类,得到分类结果;According to the function to be performed by each pre-compiled instruction, classify the pre-compiled instructions to obtain a classification result; 对应地,所述如果确定所述相同类型的字段包括源操作数字段,确定所述源操作数字段的数量和类型,包括:Correspondingly, if it is determined that the fields of the same type include source operand fields, determining the number and type of the source operand fields includes: 如果确定所述相同类型的字段包括源操作数字段,根据所述分类结果,确定所述源操作数字段的数量和类型。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. 4.根据权利要求3所述的方法,其特征在于,根据每一所述编译前的指令的类型、所述源操作数字段的数量和类型,生成对应的操作码,包括:4. The method according to claim 3, wherein generating a corresponding opcode according to the type of each said pre-compiled instruction, the quantity and type of the source operand field, comprising: 对每一所述编译前的指令的类型进行标记,生成与每一所述编译前的指令对应的第一标识码;Marking the type of each of the pre-compiled instructions, and generating a first identification code corresponding to each of the pre-compiled instructions; 根据所述源操作数字段的数量和类型,生成对应的第二标识码;generating a corresponding second identification code according to the quantity and type of the source operand field; 将所述第一标识码和所述第二标识码合并,生成对应的操作码。The first identification code and the second identification code are combined to generate a corresponding operation code. 5.一种指令数据的处理方法,其特征在于,所述方法包括:5. A method for processing instruction data, wherein the method comprises: 确定编译后的指令中的操作码;Determine the opcode in the compiled instruction; 根据所述操作码,确定所述指令的类型和所述指令中的字段的属性信息;According to the operation code, determine the type of the instruction and attribute information of the field in the instruction; 根据所述字段的属性信息,从所述指令中的指定编码位置确定相应类型的字段;According to the attribute information of the field, determine the field of the corresponding type from the specified encoding position in the instruction; 根据所述相应类型的字段获取对应的操作数,并输出所述操作数。Obtain the corresponding operand according to the field of the corresponding type, and output the operand. 6.根据权利要求5所述的方法,其特征在于,所述根据所述操作码,确定所述指令的类型和所述指令中的字段的属性信息,包括:6. The method according to claim 5, wherein the determining the type of the instruction and the attribute information of the fields in the instruction according to the operation code comprises: 如果检测出所述指令需要获取源操作数字段,解析所述需要获取源操作数字段的指令对应的操作码,得到解析结果;If it is detected that the instruction needs to obtain the source operand field, parse the operation code corresponding to the instruction that needs to obtain the source operand field, and obtain the analysis result; 根据所述解析结果,确定所述指令的类型和所述源操作数字段的属性信息。According to the parsing result, the type of the instruction and the attribute information of the source operand field are determined. 7.根据权利要求6所述的方法,其特征在于,所述根据所述字段的属性信息,从所述指令中的指定编码位置确定相应类型的字段,包括:7. The method according to claim 6, characterized in that, determining a field of a corresponding type from a specified encoding position in the instruction according to the attribute information of the field, comprising: 根据从所述操作码中解析出的第一标识码,确定所述指令的类型;Determine the type of the instruction according to the first identification code parsed from the operation code; 根据从所述操作码中解析出的第二标识码,确定所述源操作数字段数量和类型;Determine the number and type of the source operand field according to the second identification code parsed from the opcode; 根据所述源操作数字段数量和类型,从所述指令中的指定编码位置确定所述源操作数字段。The source operand field is determined from a specified encoding position in the instruction based on the number and type of the source operand field. 8.根据权利要求7所述的方法,其特征在于,所述根据所述相应类型的字段获取对应的操作数,并输出所述操作数,包括:8. The method according to claim 7, characterized in that, acquiring the corresponding operand according to the field of the corresponding type, and outputting the operand, comprising: 根据所述源操作数字段,确定所述源操作数的编号和地址;determining 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. 9.一种指令数据的处理装置,其特征在于,所述装置包括:9. An apparatus for processing instruction data, wherein the apparatus comprises: 第一存储单元,配置为如果确定编译前的指令之间有相同类型的字段,编译时,将所述相同类型的字段存储至指定编码位置;a first storage unit, configured to store the same type of field in a specified encoding position when compiling if it is determined that there are fields of the same type between the instructions before compilation; 生成单元,配置为根据每一所述编译前的指令的类型和所述相同类型的字段的属性信息,生成对应的操作码;a generating unit, configured to generate a corresponding opcode according to the type of each of the pre-compiled instructions and the attribute information of the field of the same type; 第二存储单元,配置为将所述操作码存储至编译后的指令中;a second storage unit, configured to store the operation code in the compiled instruction; 第一输出单元,配置为输出所述编译后的指令。The first output unit is configured to output the compiled instruction. 10.一种指令数据的处理装置,其特征在于,所述装置包括:10. An apparatus for processing instruction data, wherein the apparatus comprises: 第一确定单元,配置为确定编译后的指令中的操作码;a first determining unit, configured to determine an opcode in the compiled instruction; 第二确定单元,配置为根据所述操作码,确定所述指令的类型和所述指令中的字段的属性信息;a second determining unit, configured to determine the type of the instruction and attribute information of a field in the instruction according to the operation code; 第三确定单元,配置为根据所述字段的属性信息,从所述指令中的指定编码位置确定相应类型的字段;a third determining unit, configured to determine a corresponding type of field from the specified encoding position in the instruction according to the attribute information of the field; 第二输出单元,配置为根据所述相应类型的字段获取对应的操作数,并输出所述操作数。The second output unit is configured to obtain the corresponding operand according to the field of the corresponding type, and output the operand. 11.一种计算机设备,其特征在于,所述计算机设备至少包括:处理器和配置为存储可执行指令的存储介质,其中:11. A computer device, characterized in that the computer device at least comprises: a processor and a storage medium configured to store executable instructions, wherein: 处理器配置为执行存储的可执行指令,所述可执行指令配置为执行上述权利要求1至10任一项提供的指令数据的处理方法。The processor is configured to execute the stored executable instructions, and the executable instructions are configured to execute the method for processing instruction data provided by any one of claims 1 to 10 above. 12.一种计算机可读存储介质,所述计算机存储介质中存储有计算机可执行指令,该计算机可执行指令配置为执行上述权利要求1至10中任一项提供的指令数据的处理方法中的步骤。12. A computer-readable storage medium storing computer-executable instructions, the computer-executable instructions being configured to execute the processing method of the instruction data provided by any one of the preceding claims 1 to 10. step.
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 true CN111240682A (en) 2020-06-05
CN111240682B 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)

Cited By (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 (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5421029A (en) * 1991-01-22 1995-05-30 Mitsubishi Denki Kabushiki Kaisha Multiprocessor including system for pipeline processing of multi-functional instructions
DE19737658A1 (en) * 1996-10-18 1998-07-23 Nat Semiconductor Corp Instruction decoder for microprocessor system
US5819097A (en) * 1996-12-09 1998-10-06 Allen Bradley Company, Llc Industrial controller compiler with expandable instruction set
CN101071410A (en) * 2006-05-09 2007-11-14 飞思卡尔半导体公司 Microcontroller unit
US7302550B1 (en) * 1999-07-19 2007-11-27 Giesecke & Devrient Gmbh Stack of variable length operands and method for use
CN101118498A (en) * 2007-09-13 2008-02-06 上海交通大学 Assembler Based on User Description and Its Realization Method
US20100042812A1 (en) * 2008-08-14 2010-02-18 International Business Machines Corporation Data Dependent Instruction Decode
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
CN104731558A (en) * 2015-01-13 2015-06-24 山东大学 Instruction set design method for embedded graphic processing unit
US20170090922A1 (en) * 2015-09-30 2017-03-30 Futurewei Technologies, Inc. Efficient Instruction Pair for Central Processing Unit (CPU) Instruction Design

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TW200739419A (en) * 2006-04-07 2007-10-16 Univ Feng Chia Prediction mechanism of a program backward jump instruction
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
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
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 (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5421029A (en) * 1991-01-22 1995-05-30 Mitsubishi Denki Kabushiki Kaisha Multiprocessor including system for pipeline processing of multi-functional instructions
DE19737658A1 (en) * 1996-10-18 1998-07-23 Nat Semiconductor Corp Instruction decoder for microprocessor system
US5819097A (en) * 1996-12-09 1998-10-06 Allen Bradley Company, Llc Industrial controller compiler with expandable instruction set
US7302550B1 (en) * 1999-07-19 2007-11-27 Giesecke & Devrient Gmbh Stack of variable length operands and method for use
CN101071410A (en) * 2006-05-09 2007-11-14 飞思卡尔半导体公司 Microcontroller unit
CN101118498A (en) * 2007-09-13 2008-02-06 上海交通大学 Assembler Based on User Description and Its Realization Method
US20100042812A1 (en) * 2008-08-14 2010-02-18 International Business Machines Corporation Data Dependent Instruction Decode
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
CN104731558A (en) * 2015-01-13 2015-06-24 山东大学 Instruction set design method for embedded graphic processing unit
US20170090922A1 (en) * 2015-09-30 2017-03-30 Futurewei Technologies, Inc. Efficient Instruction Pair for Central Processing Unit (CPU) Instruction Design

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
WAITINGSKY: "指令系统的设计", Retrieved from the Internet <URL:https://www.cnblogs.com/waitingsky/archive/2012/03/03/PCInstructionDesign.html> *

Cited By (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

Also Published As

Publication number Publication date
CN111240682B (en) 2024-11-08
WO2020108158A1 (en) 2020-06-04

Similar Documents

Publication Publication Date Title
KR102532173B1 (en) Memory access technology and computer system
TWI486810B (en) Counter operation in a state machine lattice
CN111352889B (en) A device management method, device, device and medium based on MCTP protocol
CN110036380A (en) Bimodulus PHY for low latency in high speed interconnection
US10496595B2 (en) Method for zero-copy object serialization and deserialization
US10778815B2 (en) Methods and systems for parsing and executing instructions to retrieve data using autonomous memory
WO2020057411A1 (en) Packet forwarding method, device, equipment, and system
WO2020147253A1 (en) Data read/write method and apparatus, and exchange chip and storage medium
CN103092798B (en) The method of the access means under SOC(system on a chip) and bus
EP3270322B1 (en) Encrypting system level data structures
CN103914404B (en) Configuration information cache device in coarseness reconfigurable system and compression method
CN117714398B (en) Data transmission system, method, electronic device and storage medium
CN103428184A (en) Method and system for converting communication messages
WO2016202113A1 (en) Queue management method, apparatus, and storage medium
CN113179216B (en) Remote configuration method of register, computer equipment and storage medium
CN115499312A (en) Integration configuration method based on FPGA (field programmable Gate array) back-end P4 multi-mode intelligent network card
CN105426322A (en) Data prefetching method and device
EP4052141B1 (en) System and method for constructing filter graph-based media processing pipelines in a browser
CN111240682B (en) A method, device, and storage medium for processing instruction data
CN105824647A (en) Form page generating method and device
CN111324645B (en) Block chain data processing method and device
CN115277553A (en) Flow table storage method, device, equipment and computer readable storage medium
CN116615874B (en) Data transmission method and device and communication equipment
CN105320673A (en) Method and device for transmitting data among multiple data sources
CN109144853B (en) A software-defined radio SoC chip debugging system

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