Vector shift method, processor and electronic device
The vector shift method in SIMD processors simplifies operations by using a single instruction with register identifiers and shift parameters, enhancing execution efficiency.
Patent Information
- Application Number
- JP2024534617
- Authority / Receiving Office
- JP · JP
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2021-12-10
- Filing Date
- 2022-12-08
- Publication Date
- 2024-11-21
- Estimated Expiration
- 2042-12-08
AI Technical Summary
Existing vector shift operations in SIMD processors require multiple instructions, leading to a complicated operation method and reduced execution efficiency.
A vector shift method that includes a single instruction with register identifiers and shift parameters to perform vector shift operations, utilizing a processor with vector registers, an instruction decoding unit, and an execution unit to execute the shift operation based on specified rules.
This approach simplifies the operation method and improves execution efficiency by allowing vector shift operations to be performed with a single instruction, reducing system overhead.
Smart Images

Figure 2024543659000001_ABST
Abstract
Description
[Technical field]
[0001] The present invention relates to the field of computer technology, and in particular to a vector shifting method, a processor and an electronic device. [Background technology]
[0002] With the development of multimedia applications, more and more of the computing tasks of processors are coming from the field of digital image processing, and image-based applications are becoming a workload that cannot be ignored in servers, desktop computers, personal mobile devices, i.e. embedded devices. To meet the realities of digital image processing software, updating the instruction system architecture and adding instruction support for operations commonly used in applications to processors is the main direction of processor development, and is also a simple and effective way to improve the performance of processors for certain applications, so Single Instruction Multiple Data (SIMD) structures are being added to more and more processors to support similar operations on regular sets of data.
[0003] At present, shift instructions are commonly introduced in SIMD processors, and different shift instructions can meet different needs. However, in the conventional technical means, when implementing vector shift operations for a specific function, multiple instructions are required to implement a series of operations, which complicates the operation method and reduces the execution efficiency of the specific function. Summary of the Invention [Problem to be solved by the invention]
[0004] The present application provides a vector shifting method, a processor and an electronic device to solve problems in the prior art, such as the need for multiple instructions to implement a vector shifting operation, the complexity of the operation method, and the reduced efficiency of executing certain functions. [Means for solving the problem]
[0005] In order to solve the above problem, the present application provides a vector shift method, the method comprising: receiving an instruction including a register identifier and a shift parameter, the register identifier including a source register identifier and a destination register identifier, the source register identifier for indicating a source register, the source register being a register for storing a source element to be operated on when performing a vector shift operation, the destination register identifier for indicating a destination register, the destination register being a register for storing a target element obtained after performing the vector shift operation, and the shift parameter for indicating a rule based on which the vector shift operation is performed on the source element; executing the instruction to perform a vector shift operation on a source element obtained from the source register according to the shift parameter to obtain a target element after the vector shift operation; writing the target element to the destination register.
[0006] In order to solve the above problem, the present application provides a processor, the processor including a plurality of vector registers, an instruction decoding unit, and an execution unit, The plurality of vector registers include: The source element that is operated on when performing a vector shift operation a source register for storing a first bit, and a destination register for storing a second bit, the instruction decode unit is for decoding a vector shift instruction including a register identifier and a shift parameter, the register identifier including a source register identifier for indicating a source register and a destination register identifier for indicating a destination register; The execution unit is responsive to the vector shift instruction to perform a vector shift operation on a source element obtained from the source register according to the shift parameters, obtain a target element after the vector shift operation, and write the target element to the destination register.
[0007] In order to solve the above problem, the present application provides an electronic device including a memory and one or more programs, the one or more programs being stored in the memory and configured to execute, by one or more processors, one or more of the vector shifting methods described above. Effect of the Invention
[0008] The present application has the following advantages over the conventional techniques:
[0009] The vector shift method, processor, and electronic device provided by the embodiments of the present application add a register identifier and a shift parameter to a vector shift instruction, and use the register identifier to indicate a register that stores a source element to be operated on when the vector shift operation is performed, and a register that stores a target element obtained after the vector shift operation is performed, and use the shift parameter to indicate a rule to be used as a basis for performing the vector shift operation on the source element.This makes it possible to implement a vector shift operation for a specific function with a single instruction, rather than using multiple instructions for the vector shift operation, thereby simplifying the operation method and improving the execution efficiency for the specific function. [Brief description of the drawings]
[0010] [Figure 1]4 is a flowchart of steps of a vector shifting method according to the first embodiment of the present application. [Diagram 2] 4 is a flowchart of steps of a target element acquisition method according to an embodiment of the present application. [Diagram 3] 4 is a flowchart of steps of a method for obtaining a shift operation result according to an embodiment of the present application; [Figure 4] 4 is a flow chart of steps of a method for storing target elements according to an embodiment of the present application. [Diagram 5] 11 is a flowchart of steps of a vector shifting method according to a second embodiment of the present application. [Figure 6] 11 is a flowchart of steps of a vector shifting method according to a third embodiment of the present application. [Figure 7] 11 is a flowchart of steps of a vector shifting method according to a fourth embodiment of the present application. [Figure 8] FIG. 11 is a structural block diagram of a processor according to a fifth embodiment of the present invention. [Figure 9] FIG. 13 is a structural block diagram of an electronic device according to a sixth embodiment of the present invention. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS
[0011] In order to make the above objects, features and advantages of the present application more clear and understandable, the present application will be described in more detail below with reference to the drawings and specific embodiments.
[0012] The terms "first," "second," "third," etc. in the specification and claims of this application and in the drawings above are intended to distinguish between similar objects and are not necessarily intended to describe a particular order or sequence. It is understood that the data so used may be interchangeable where appropriate, such as being capable of being implemented in an order other than that given in the illustration or description of the embodiments of this application.
[0013] Although the following embodiments are described with reference to one processor, other embodiments apply to other types of integrated circuits and logic devices. The foregoing techniques and teachings of the present application can be more readily applied to other types of circuits or semiconductor devices that benefit from higher pipeline throughput rates and improved performance. The embodiments of the present application apply to any processor or machine that performs data manipulation. However, the present application is not limited to processors or machines that perform 256-bit, 128-bit, 64-bit, 32-bit, or 16-bit data manipulation, but rather to any processors and machines where combinatorial data manipulation is desired.
[0014] In the following description, numerous specific details are provided for the purpose of explanation in order to fully understand the present application. However, those skilled in the art should recognize that these specific details are not necessary to implement the present application. In other cases, some well-known electrical structures and circuits are not shown in detail to avoid unnecessarily confusing the present application. Furthermore, the following description provides a number of examples, and the accompanying drawings show various examples for illustration purposes. However, these examples should not be construed as limiting, as they are intended to provide some examples of the present invention, and are not intended to provide an exhaustive list of all possible embodiments of the present invention.
[0015] Although the following examples describe instruction processing and distribution in the context of an execution unit, other embodiments of the present invention may be implemented in the form of software. In one embodiment, the methods of the present application are expressed as machine-executable instructions. The instructions can be used to cause a general-purpose processor or a special-purpose processor programmed with these instructions to perform the steps of the present application. The present application may be provided as a computer program product or software, which may include a machine or computer-readable medium and instructions stored therein that can be used to program a computer (or other electronic device) to be executed by a processor according to the present application. Alternatively, the steps of the present invention may be performed by a dedicated hardware assembly that includes hardwired logic for performing the steps, or by any combination of a programmed computer assembly and a custom hardware assembly. These software may be stored in a memory in the system.
[0016] The vector shifting method provided by the embodiment of the present application may be executed by a CPU (Central Processing Unit).
[0017] Example 1
[0018] Please refer to Figure 1. Figure 1 shows a flow chart of the steps of the vector shifting method according to the first embodiment of the present application, where the vector shifting process includes the following steps:
[0019] In step 101, an instruction is received that includes a register identifier and a shift parameter.
[0020] In the embodiment of the present application, the instruction refers to an instruction for performing a vector shift operation, and the instruction is an instruction executed by a processor, and the instruction includes a register identifier and a shift parameter, the register identifier includes a source register identifier and a destination register identifier, the source register identifier is for indicating a source register, the source register is a register for storing a source element operated when performing the vector shift operation, the destination register identifier is for indicating a destination register, the destination register is a register for storing a target element obtained after performing the vector shift operation, and the shift parameter is for indicating a rule based on which the vector shift operation is performed on the source element.
[0021] Alternatively, the number of source registers may be one or two, i.e., a source element is derived from one or two registers; specifically, the number of source registers may be set according to business needs, and the embodiments of the present application are not limited thereto.
[0022] Alternatively, the received instruction is decoded to obtain a shift parameter included in the instruction, the shift parameter being for indicating a rule to be followed when performing a vector shift operation on a source element, and in this example, the shift parameter may include parameters such as a shift amount and an opcode. Alternatively, the opcode is a code represented in binary form, or the opcode is an identifier that can be converted to a binary code.
[0023] After the instruction is decoded, step 102 is executed.
[0024] In step 102, the instruction is executed to perform a vector shift operation on a source element obtained from the source register according to the shift parameter to obtain a target element after the vector shift operation.
[0025] In an embodiment of the present application, after a CPU receives an instruction to perform a vector shift operation, the CPU may execute the instruction to perform the vector shift operation on a source element obtained from a source register according to a shift parameter, and obtain a target element after the vector shift operation.
[0026] After the target element after performing the vector shift operation is obtained, step 103 is performed.
[0027] Step 103 writes the target element to the destination register.
[0028] In an embodiment of the present application, after the target element after the vector shift operation is obtained, the target element can be written to a destination register.
[0029] Alternatively, a shift amount and a shift operation rule can be determined according to the shift parameter, and a vector shift operation can be performed according to the shift amount and the shift operation rule, which can be described in detail with reference to the specific implementation form below.
[0030] Please refer to Figure 2. Figure 2 shows a flowchart of the steps of the target element acquisition method provided by the embodiment of the present application, and the target element acquisition process includes the following steps:
[0031] In step 201, a shift amount and a shift operation rule are determined according to the shift parameters, and there is at least one source element on which a vector shift operation is performed.
[0032] In the embodiment of the present application, the number of source registers may be one or more, the number of destination registers is one, the source register identifier and the destination register identifier are the same or different, and the data type of the source element is halfword, word, doubleword, or quadword. The shift amount is a vector shift operation is executed, the shift amount comes from either an immediate number or a shift amount register, the immediate number is a parameter defined by the opcode among the shift parameters, the immediate number can determine its value by referring to the data type of the source element defined by the opcode, the shift amount register is a register for storing the shift amount, and when the shift amount comes from the shift amount register, the shift amount is a group of data, for example, the shift amount can include different bits to represent the shift status of different source elements. A shift operation rule refers to one or more operations performed on a source element.
[0033] After determining the shift amount and the shift calculation rule according to the shift parameters, step 202 is executed.
[0034] In step 202, according to the shift amount and the shift operation rule, perform a corresponding shift operation on a source element in the source register to generate a shift operation result.
[0035] In the present embodiment, a shift operation rule refers to a shift operation method and / or constraints on elements in a source register.
[0036] After performing a corresponding shift operation on the source element in the source register according to the shift amount and the shift operation rule to generate a shift operation result, step 203 is performed.
[0037] In step 203, the result of the shift operation is determined as the target element.
[0038] In the embodiment of the present application, the shift parameters may include an opcode, which may be used to select a source element from among the source registers and to indicate the storage form of the target element in the destination register, specifically, a vector shift operation The process can be explained in detail with reference to the following implementations.
[0039] Please refer to Figure 3. Figure 3 shows a flowchart of the steps of a shift operation result generating method provided by an embodiment of the present application, and the shift operation result generating process includes the following steps:
[0040] In step 301, the vector shift register is selected from the source register according to the operation code. operation A source element for which the above-mentioned is executed is selected, and the selected source element is determined as an operand.
[0041] In an embodiment of the present application, the shift parameters include a shift amount and an opcode. The shift amount is a vector shift operation opcode can be used to indicate the number of shift bits of the source element that is operated on when is executed. Opcode can be used to indicate the shift operation rule to be performed on the source element in the source register and the target element in the destination register.
[0042] Optionally, the format of the instruction is "opcode destination register, source register, shift amount." Exemplarily, the instruction is "[X]VSSR. {BH / HW / WD / DQ / BU.H / HU.W / WU.D / DU.Q} vd / xd,vj / xj,ui], where [X]VSSR represents the instruction name in the opcode, [X] is optional and is determined by the type of register, the part before the "." in {BH / HW / WD / DQ / BU.H / HU.W / WU.D / DU.Q} represents the data type of the target element in the opcode, the part after the "." represents the data type of the source element in the opcode, B represents byte, H represents halfword, W represents word, D represents doubleword, Q represents quadword, U represents unsigned, vd / xd represents the destination register, vj / xj represent the source register, or vd / xd can represent the source register, vj and vd represent registers with the same number of bits, xj and xd represent registers with the same number of bits, and ui represents an immediate number, i.e., the immediate number is the shift amount. For example, the instruction can also be expressed as "[X]VSSR.{BH / HW / WD / DQ / BU.H / HU.W / WU.D / DU.Q} vd / xd, vj / xj, vk / xk", where [X]VSSR, {BH / HW / WD / DQ / BU.H / HU.W / WU.D / DU.Q}, vd / xd, and vj / xj have the same meaning as in the previous example, and vk / xk represents a shift amount register.
[0043] Vector shift from source register according to opcode operation After selecting a source element for which the above formula is to be executed and determining the selected source element as an operand, step 302 is executed.
[0044] In step 302, perform a corresponding shift operation on the operand according to the opcode to generate a shift operation result.
[0045] In the embodiment of the present application, after the operand is determined, a corresponding shift operation can be performed on the operand according to the opcode to generate a shift operation result, and an element included in the shift operation result is the target element.
[0046] After the shift operation result is generated, step 401 is executed.
[0047] Please refer to Figure 4. Figure 4 shows a flowchart of the steps of the target element storage method provided by the embodiment of the present application, and the target element storage process includes the following steps:
[0048] In step 401, the storage format of the target element in the destination register is determined according to the opcode.
[0049] In the embodiment of the present application, the storage form refers to a rule for storing a target element in a destination register. Optionally, the storage form mainly represents a location rule for storing a target element in a destination register, and illustratively, the storage form can include a form for storing the upper half of the data of a target element in the upper half of the location where the target element is located in the destination register, or a form for storing the lower half of the data of a target element in the lower half of the location where the target element is located in the destination register, or a form for storing data within a specified range of a target element within a specified address range of the location where the target element is located in the destination register.
[0050] After determining the storage format of the target element in the destination register according to the opcode, step 402 is executed.
[0051] In step 402, the target element is stored in the destination register according to the storage configuration.
[0052] In the embodiment of the present application, after the shift operation result is obtained, the shift operation result can be determined as a target element, and after determining the storage format of the target element in the destination register according to the opcode, the target element can be stored in the destination register.
[0053] In the prior art, when implementing a vector shift operation, it is necessary to implement the vector shift with multiple instructions according to the vector shift needs, and the vector shift needs are determined according to the actual application. For example, if the vector shift needs are to right shift the operands of two vector registers and truncate to half-width, at least two right shift instructions, two truncate instructions, and one saturate to half-width instruction are required to achieve the vector shift needs. In the embodiment of the present application, an instruction including a shift parameter is implemented, and different shift needs can be achieved with different shift parameters, so that multiple vector shift needs can be achieved with one shift instruction, effectively reducing system overhead and improving the execution efficiency of vector shift for a specific function.
[0054] Hereinafter, the implementation process of the vector shift instruction in the case of different opcodes and different shift amounts will be described in detail with reference to the second to fourth embodiments.
[0055] Example 2
[0056] In an embodiment of the present application, the opcode may be a first type vector opcode, the source register may include a first source register and a second source register, and the first type vector opcode may obtain a source element from the source register and perform a vector shift operation on the source element, and as shown in FIG. 5 , a processing method for a vector shift instruction may include the following steps:
[0057] In step 501, an instruction is received that includes a register identifier and a shift parameter.
[0058] In the embodiment of the present application, the meaning of the command and the parameters contained in the command are described in the first embodiment and will not be repeated here.
[0059] Alternatively, the number of source registers is two, i.e., the source elements come from two different registers, and when the number of source registers is multiple, each source register identifier in all the source registers is different from the destination register identifier, or when the number of source registers is multiple, there is one source register identifier among all the source registers that is the same as the destination register identifier.
[0060] Optionally, the received instruction may be decoded to obtain shift parameters contained in the instruction, the shift parameters indicating rules to be followed when performing a vector shift operation on the source elements, in this example the shift parameters may include parameters such as a shift amount and an opcode.
[0061] In step 502, the shift amount and the shift calculation rule are determined according to the shift parameters.
[0062] In an embodiment of the present application, the source element on which a vector shift operation is performed is at least one, the shift amount is an immediate number, the shift operation rule is an opcode, the opcode is a first type vector opcode, and the immediate number is a positive integer greater than or equal to 0.
[0063] Alternatively, the first type vector opcode is a code expressed in binary form, or the opcode is an identifier that can be converted to a binary code. The format of the instruction is "opcode destination register, source register, shift amount". When the opcode is a first type vector opcode, in actual implementation, the instruction is "VSSR 第1のタイプ.{BH / HW / WD / DQ / BU.H / HU.W / WU.D / DU.Q} vd,vj,ui 第1のタイプ " and VSSR 第1のタイプ is the instruction name in the first type of vector opcode, {BH / HW / WD / DQ / BU.H / HU.W / WU.D / DU.Q} are parameters in the first type of opcode to indicate the data types of the source and target elements, where B stands for byte, H stands for halfword, W stands for word, D stands for doubleword, Q stands for quadword, U stands for unsigned, vd stands for both destination and source registers, vj stands for source register, ui stands for destination register, u stands for destination register, v ... 第1のタイプ represents the number of immediate values included in the instruction when the opcode is a vector opcode of the first type. 第1のタイプ1 .BH is the first type of vector opcode that can be converted to binary form, e.g., VSSR 第1のタイプ1 The first type of vector opcode is .BH, which converts to binary form as 011100110101000001.
[0064] In addition, UI 第1のタイプ is defined by the opcode, ui 第1のタイプ can determine its value by referring to the data types of the source and target elements, 第1のタイプ is within a given range (i.e., ui 第1のタイプ ∈[min, max]), that is, ui 第1のタイプ The minimum value is determined according to the data types of the source and target elements, and the ui 第1のタイプ has a maximum value of infinity. For example, the first type of vector opcode is VSSR. 第1のタイプ1 If it is .BH, then ui 第1のタイプ has a minimum value of ui4 and the first type of vector opcode is VSSR 第1のタイプ1 If it is .HW, ui 第1のタイプ has a minimum value of ui5 and the first type of vector opcode is VSSR 第1のタイプ1 If it is .WD, ui第1のタイプ The minimum value is ui6, and the first type of vector opcode is VSSR. 第1のタイプ1 If it is .DQ, ui 第1のタイプ The minimum value is ui7, and the first type of vector opcode is VSSR. 第1のタイプ1 If .BU.H, ui 第1のタイプ has a minimum value of ui4 and the first type of vector opcode is VSSR 第1のタイプ1 If it is .HU.W, then ui 第1のタイプ has a minimum value of ui5 and the first type of vector opcode is VSSR 第1のタイプ1 If it is .WU.D, ui 第1のタイプ The minimum value is ui6, and the first type of vector opcode is VSSR. 第1のタイプ1 If .DU.Q, ui 第1のタイプ has a minimum value of ui7. This means that if the data type of the source element is halfword and the data type of the target element is byte, then ui 第1のタイプ ∈[ui4, infinity], the data type of the source element is word and the data type of the target element is halfword, then ui 第1のタイプ ∈[ui5, infinity], the data type of the source element is doubleword and the data type of the target element is word, then ui 第1のタイプ ∈[ui6, infinity], the data type of the source element is a quadword and the data type of the target element is a doubleword, then ui 第1のタイプ ∈[ui7, infinity], and it can be seen that the target element may be an unsigned or signed numeric value.
[0065] After determining the shift amount and the shift calculation rule according to the shift parameters, step 503 is executed.
[0066] In step 503, according to the first type vector opcode, determine all source elements in a first source register as one operand, and determine all source elements in a second source register as another operand.
[0067] In the embodiment of the present application, all elements in a first source register may be set as source elements, or some elements in the first source register may be set as source elements, or all elements in a second source register may be set as source elements, or some elements in the second source register may be set as source elements, according to the first type vector opcode. Exemplarily, the first source register is a register vd and the second source register is a register vj, and all elements in the first register vd are determined as source elements and elements in the second register vj are determined as source elements, so that all source elements in the first source register are determined as one operand and all source elements in the second source register are determined as another operand.
[0068] Alternatively, the source elements respectively selected from the first source register and the second source register have the same data type, and the data type of the source elements is one of a halfword, a word, a doubleword, and a quadword.
[0069] After determining the source element obtained from the first source register as the operand of the second source register according to a first type vector opcode, step 504 is performed.
[0070] In step 504, according to the first type vector opcode, An operand in a first source register and an operand in a second source register After splicing, a first splice vector is generated.
[0071] In an embodiment of the present application, after left-right splicing of the operand in the first source register and the operand in the second source register, a first splice vector is generated, and the positioning of the left-right splicing of the operand in the first source register and the operand in the second source register is determined according to the position of the source register identifier in the instruction, i.e., if the first source register identifier is a source register identifier immediately following a first type vector opcode in the instruction and the second source register identifier is a source register identifier located after the first source register identifier in the instruction, the operand in the first source register is located on the left side and the operand in the second source register is located on the right side to generate the first splice vector, but if the second source register identifier is a source register identifier immediately following a first type vector opcode in the instruction and the first source register identifier is a source register identifier located after the first source register identifier in the instruction, the operand in the first source register is located on the left side and the operand in the second source register is located on the right side to generate the first splice vector, Second If the source register identifier is a source register identifier located after the first type vector opcode vd, vj, the operand in the second source register is located on the left side and the operand in the first source register is located on the right side to generate a first splice vector. Illustratively, if the format of the instruction is "first type vector opcode vd, vj, immediate number", the first source register is represented as vd, the second source register is represented as vj, and the destination register is represented as vd, and all the source elements in the first source register are regarded as one operand, and the operand vd and all the Source Element The whole is considered as a separate operand, and the operand vj The first splice vector is denoted as "operand vd operand vj "
[0072] Alternatively, the operand in the first source register and the operand in the second source register may also be cross-spliced on an element-by-element basis to generate a first splice vector, in which during cross-splicing, source elements having the same position information in the source registers are crossed as a group, and the positions of different groups in the first splice vector are arranged in descending order according to the addresses of the source elements, and the setting of the left and right positions when splicing every two elements in different registers as a group is determined according to the position of the source register identifier in the instruction, which is the same as the above example, and will not be repeated here.
[0073] Illustratively, the operands in the first source register include "source element 1 (position information is a), source element 2 (position information is b), and source element 3 (position information is c)", and the operands in the second source register are "source element 4 (position information is a), source element 5 (position information is b), and source element 6 (position information is c)", The operand in the first source register The source register identifier corresponding to is placed in the left position of the instruction, The operand in the second source register is assumed to be located at the right-hand position of the instruction, the left and right are opposite positions of the two source register position identifiers, and the result obtained by splicing the two operands left and right may be "source element 1 source element 2 source element 3 source element 4 source element 5 source element 6", or by cross-splicing source element 1 and source element 4, which have the same position information a, as one group, and cross-splicing them, source element 2 and source element 5, which have the same position information b, as one group, and cross-splicing them, and source element 3 and source element 6, which have the same position information c, as one group, and cross-splicing them, the final first splice vector obtained is "source element 1 source element 4 source element 2 source element 5 source element 3 source element 6".
[0074] Alternatively, The operand in the first source registerIf the first splice vector is N bits and the operand in the second source register is N bits, the first splice vector is 2N bits, where N is a positive integer greater than 0. The number of bits of the operand in the first source register may be determined according to the elements included in the first source register and the bits corresponding to the data type of the elements, and the number of bits of the operand in the second source register may be determined according to the elements included in the second source register and the bits corresponding to the data type of the elements.
[0075] After the first splice vector is generated, step 505 is performed.
[0076] In step 505, a shift, round and saturate to half-width operation is performed on each source element in the first splice vector according to the immediate number to generate a first initial shift operation result.
[0077] In an embodiment of the present application, the first splice vector includes a plurality of elements (source elements), and a shift, round and half-width saturation operation is performed on each element in the first splice vector according to an immediate number, the shift amount is an immediate number, and a first initial shift operation result is generated, the shift operation is a right shift operation, and the shift operation includes a logical shift and an arithmetic shift, and the half-width saturation process refers to a process of performing a numerical saturation process on the data to be processed according to a range of values that can be expressed by binary data after the width of the data bit is halved, and the processed data is correlated with the width before processing, and optionally the processed data is still a multiple (e.g., 1 / 2) of the width before processing.
[0078] Alternatively, each source element in the first splice vector is shifted, and the shift amount of each element is the same and is an immediate value. For example, the first splice vector includes an element 1, an element 2, and an element 3, and the shift amount is ui4, shifting the first splice vector means shifting element 1 by ui4 bits, shifting element 2 by ui4 bits, and shifting element 3 by ui4 bits, and the elements include multiple bits, and right-shifting the elements means right-shifting each bit of the elements by a preset number of bits, discarding the right-shifted bits in the elements, and setting a specified value in the vacant position to the left of the elements, and the preset number of bits and the specified value are both values set according to a specific situation.
[0079] Optionally, the shift rounding operation performed on each source element in the first splice vector includes four rounding operations: round to even, round to zero, round up, and round down. Preferably, the shift rounding operation performed on the first splice vector is a shift round up operation on the first splice vector.
[0080] Optionally, for any element x having a bit number of 2N and a shift amount of sa, a process of performing a right logical shift, rounding, and saturation to half-width operation on the element x includes the following first to second steps.
[0081] In the first step, a calculation result A is obtained according to the shift amount. Specifically, when the shift amount is 0, the obtained calculation result A becomes element x, and when the shift amount is an integer greater than 0, an intermediate calculation result is set, and the lower bits of the intermediate calculation result are data from the sa bit to the 2N-1th bit of element x, the upper bits of the remaining sa bits are 0, the number of bits of the intermediate calculation result is 2N, and the intermediate calculation result is added to the sa-1 bit of element x to obtain the calculation result A. Here, N is a positive integer greater than 0, and sa is an immediate number.
[0082] In the second step, the value of the calculation result is obtained, the value is compared with the specified data, and the final calculation result is obtained according to the comparison result. Specifically, the value of the calculation result A is multiplied by 2. N-1 Compared with, the operation result A is 2 N-1 If x is greater than , the final operation result will be data in which all N bits are 1, otherwise the final operation result will be data from the 0th bit to the N-1th bit of the operation result A. The element x is a signed or unsigned vector.
[0083] Optionally, for any element x whose number of bits is 2N and whose shift amount is sa, a process of performing a right arithmetic shift, rounding, and saturation to half-width operation on the element x includes the following first to second steps.
[0084] In the first step, a calculation result A is obtained according to the shift amount. Specifically, when the shift amount is 0, the obtained calculation result A becomes element x, and when the shift amount is an integer greater than 0, an intermediate calculation result is set, and the lower bits of the intermediate calculation result are data from the sa bit to the 2N-1th bit of element x, and the upper bits of the remaining sa bits are all 2N-1-bit data of element x, the number of bits of the intermediate calculation result is 2N, and the intermediate calculation result A is added to the sa-1 bit of element x to obtain the calculation result A. Here, N is a positive integer greater than 0, and sa is an immediate number.
[0085] In the second step, the value of the calculation result is obtained, the value is compared with the specified data, and the final calculation result is obtained according to the comparison result. N-1 and the result of the calculation A is -2. N-1 The comparison is performed for each, and the calculation result A is 2 N-1 If A is greater than 0, the most significant bit of the final operation result will be 0, the remaining least significant bits will be 1, the number of bits in the final operation result will be N, and the operation result A will be -2. N-1 If A is smaller than 1, the most significant bit of the final operation result will be 1, the remaining least significant bits will be 0, the number of bits in the final operation result will be N, and the operation result A will be 2.N-1 Less than -2 N-1 If the number of bits in the final operation result is N, then the final operation result is the data from the 0th bit to the N-1th bit of the operation result A.
[0086] The process of saturating to half-width for rounded data includes a process of saturating to half-width for rounded signed data and a process of saturating to half-width for rounded unsigned data.
[0087] With reference to the embodiment of the present application, the final operation result in the above example becomes an element in the first initial shift operation result in the embodiment of the present application, and the operation result A becomes an element in the first splice vector in the embodiment of the present application.
[0088] Shift, round and saturate to half-width are performed on the first splice vector according to the immediate number to generate a first initial shift operation result, and then step 506 is executed.
[0089] In step 506, a bit selection operation is performed on the first initial shift operation result to generate a shift operation result.
[0090] In an embodiment of the present application, the bit selection operation includes an operation of selecting consecutive lower half data for each element included in the first initial shift operation result, an operation of selecting consecutive upper half data for each element included in the first initial shift operation result, an operation of selecting consecutive designated bits in the middle for each element included in the first initial shift operation result, The and an operation of selecting data of designated non-consecutive bits for each element included in the first initial shift operation result.
[0091] After performing a bit selection operation on the first initial shift operation result to generate a shift operation result, step 507 is performed.
[0092] In step 507, the elements in the shift operation result are written sequentially to the destination register as target elements.
[0093] In the embodiment of the present application, the data type of the target element is determined according to the data type of the source element, and optionally, the number of bits corresponding to the data type of the target element is half the number of bits corresponding to the data type of the source element. Illustratively, if the data type of the source element is a halfword, the data type of the target element is a byte; if the data type of the source element is a word, the data type of the target element is a halfword; if the data type of the source element is a doubleword, the data type of the target element is a word; if the data type of the source element is a quadword, the data type of the target element is a doubleword. The source element may be signed data or unsigned data.
[0094] Optionally, after the target elements are determined, the method for sequentially writing the target elements to the destination register includes determining position information of each target element in the first initial shift operation result, and sequentially writing the target elements to positions in the destination register that match the position information corresponding to the target elements, where the position information indicates an order of elements in the first initial shift operation result, and sequentially writing the target elements to positions in the destination register that match the position information corresponding to the target elements means sequentially writing the target elements from the most significant bit to the least significant bit to positions from the N / 2-1th bit to the 0th bit of the destination register, or sequentially writing the target elements from the least significant bit to the most significant bit to positions from the 0th bit to the N / 2-1th bit of the destination register.
[0095] Referring to the process of obtaining a target element according to the first type vector opcode in the embodiment of the present application, the first type vector opcode includes four types of vector opcodes (i.e., a first vector opcode, a second vector opcode, a third vector opcode, and a fourth vector opcode) to indicate different vector shift operations. Nobe The present invention further includes a vector opcode, which can be described in detail with reference to the following four specific implementations:
[0096] In a first specific implementation form of the present application, the first type vector opcode is a first vector opcode, and a specific processing method may include the following sub-steps A1 to A2.
[0097] In sub-step A1, a right logical shift, rounding and signed saturation to half-width is performed on each source element in the first splice vector according to the immediate number to generate a first initial shift operation result.
[0098] In an embodiment of the present application, the first type vector opcode may be a first vector opcode usable to indicate a right logical shift with rounding and signed saturate to half-width operation on a first splice vector, the first splice vector being 2N bits, N being a positive integer greater than 0, and preferably N being 128 bits.
[0099] Alternatively, a logical right shift refers to shifting elements without considering the sign bit, i.e., every time an element is shifted right by one bit, one zero is added as the most significant bit. Signed saturation means that for a 16-bit number, saturation is performed according to the signed value range of an 8-bit number (-128 to +127). Half-width means half a bit-width segment. For any vector, a logical right shift can be Roll it upThe process for performing the signed saturation to half-width operation has been described above and will not be repeated here.
[0100] If the first type vector opcode is a first vector opcode, then a right logical shift with rounding and signed saturation to half-width can be performed on each source element in the first splice vector according to the immediate number to generate a first initial shift operation result.
[0101] In sub-step A2, consecutive data in the lower half of each element included in the first initial shift operation result is selected, and the element after the selection operation is determined as the shift operation result.
[0102] In the embodiment of the present application, after generating the first initial shift operation result, consecutive lower half data of each element included in the first initial shift operation result are selected, and after the selection operation, The key The prime may be determined as the result of the shift operation.
[0103] Alternatively, when the first source element and the second source element included in the first source register are both N / 2 bits, and the third source element and the fourth source element included in the second source register are N / 2 bits, the first initial shift operation result is N bits, and the shift operation result is the data indicated by the first initial shift operation result from the 0th bit to the N / 2-1th bit.
[0104] Furthermore, for each target element in the shift operation result, the lower half is selected, and sequentially written to a memory location corresponding to each target element in the destination register. Illustratively, the first source register is a vector register vd, the second source register is a vector register vj, the vector register vd includes a first source element and a second source element, the vector register vj includes a third source element and a fourth source element, the number of bits of the first source element, the second source element, the third source element, and the fourth source element is N / 2, and the first source element、 Second Source Element , a third source element, and a fourth source element can be left and right spliced using vector shift instructions to form a 2N-bit vector (2N=256), where each source element in the vector is logically shifted right with rounding and signed saturation to half-width, where the shift amount is derived from an immediate number, and the first source element's shifted result has its lower half element selected as a target element, the second source element's shifted result has its lower half element selected as a target element, the third source element's shifted result has its lower half element selected as a target element, and the fourth source element's shifted result has its lower half element selected as a target element, and written sequentially to vector register vd.
[0105] It should be understood that the above examples are merely illustrative examples for better understanding of the technical solutions according to the embodiments of the present application, and do not uniquely limit the embodiments of the present application.
[0106] In a second specific implementation form of the present application, the first type vector opcode is a second vector opcode, and a specific processing method may include the following sub-steps B1 to B2.
[0107] In sub-step B1, a right arithmetic shift with rounding and signed saturation to half-width is performed on each source element in the first splice vector according to the immediate number to generate a first initial shift operation result.
[0108] In an embodiment of the present application, the first type vector opcode may be a second vector opcode, which is usable to indicate a right arithmetic shift with rounding and signed saturate to half-width operation on the first splice vector, and the first splice vector is 2N bits, where N is a positive integer greater than 0, and preferably N is 128 bits.
[0109] Alternatively, right arithmetic shift refers to a shift method of elements that requires consideration of the sign bit, i.e., every time an element is shifted right by one bit, if the sign bit is 1, the most significant bit on the left side is supplemented with 1, otherwise the most significant bit on the left side is supplemented with 0. The meaning of signed saturation and half-width is the same as that described above, so it will not be repeated here. For any vector, right arithmetic shift can be performed to obtain Roll it up The process for performing the signed saturation to half-width operation has been described above and will not be repeated here.
[0110] The first type of vector opcode is Second , then each source element in the first splice vector may be right arithmetically shifted with rounding and signed saturation to half-width according to the immediate number to generate a first initial shift operation result.
[0111] According to the immediate number, a right arithmetic shift, rounding and signed saturation to half-width are performed on the first splice vector to generate a first initial shift operation result, and then sub-step B2 is performed. In sub-step B2, consecutive lower half data of each element included in the first initial shift operation result is selected, and the element after the selection operation is determined as the shift operation result.
[0112] In the embodiment of the present application, after generating the first initial shift operation result, consecutive lower half data of each element included in the first initial shift operation result are selected, and after the selection operation, The key The prime can be determined as the result of the shift operation.
[0113] Alternatively, when the first source element and the second source element included in the first source register are both N / 2 bits and the third source element and the fourth source element included in the second source register are both N / 2 bits, the first initial shift operation result is N bits, and the shift operation result is the data indicated by the first initial shift operation result from the 0th bit to the N / 2-1th bit.
[0114] Furthermore, for each target element in the shift operation result, the lower half is selected, and sequentially written to a storage location corresponding to each target element in the destination register. Illustratively, the first source register is a vector register vd, the second source register is a vector register vj, the vector register vd includes a first source element and a second source element, the vector register vj includes a third source element and a fourth source element, the number of bits of the first source element, the second source element, the third source element, and the fourth source element is N / 2, and the first source element 、 Second Source Element , a third source element, and a fourth source element can be spliced left and right using a vector shift instruction to form a 2N-bit vector (2N=256), and each source element in the vector is subjected to a right arithmetic shift with rounding and signed saturation to half-width, where the shift amount is derived from an immediate number, and the first source element's shifted result is selected as a target element, the second source element's shifted result is selected as a target element, the third source element's shifted result is selected as a target element, and the fourth source element's shifted result is selected as a target element, and written sequentially to the vector register vd.
[0115] It should be understood that the above examples are merely illustrative examples for better understanding of the technical solutions according to the embodiments of the present application, and do not uniquely limit the embodiments of the present application.
[0116] In a third specific implementation form of the present application, the first type vector opcode is a third vector opcode, and a specific processing method may include the following sub-steps C1 to C2.
[0117] In a sub-step C1, a right logical shift with rounding and unsigned saturation to half width is performed on each source element in the first splice vector according to the immediate number to generate a first initial shift operation result.
[0118] In an embodiment of the present application, the first type vector opcode may be a third vector opcode, which is usable to indicate a right logical shift with rounding and unsigned saturation to half-width operation on the first splice vector, and the first splice vector is 2N bits, where N is a positive integer greater than 0, and preferably N is 128 bits.
[0119] Alternatively, rounding and unsigned saturation means that 16-bit numbers are saturated according to the range of signed values for 8-bit numbers (0 to 255). The meaning of the right logical shift and saturation to half-width processing is the same as that described above, so it will not be repeated here. For any vector, a right logical shift is Roll it up The process for performing the unsigned saturation to half-width operation has been described above and will not be repeated here.
[0120] If the first type vector opcode is a third vector opcode, then a right logical shift with rounding and unsigned saturation to half width can be performed on each source element in the first splice vector according to the immediate number to generate a first initial shift operation result.
[0121] According to the immediate number, a right logical shift, rounding and unsigned saturation to half-width are performed on the first splice vector to generate a first initial shift operation result, and then sub-step C2 is performed.
[0122] In sub-step C2, consecutive data in the lower half of each element included in the first initial shift operation result is selected, and the element after the selection operation is determined as the shift operation result.
[0123] In the embodiment of the present application, after generating the first initial shift operation result, consecutive lower half data of each element included in the first initial shift operation result are selected, and after the selection operation, The key The prime can be determined as the result of the shift operation.
[0124] Alternatively, when the first source element and the second source element included in the first source register are both N / 2 bits and the third source element and the fourth source element included in the second source register are both N / 2 bits, the first initial shift operation result is N bits, and the shift operation result is the data indicated by the first initial shift operation result from the 0th bit to the N / 2-1th bit.
[0125] Furthermore, for each target element in the shift operation result, the lower half is selected, and sequentially written to a memory location corresponding to each target element in the destination register. Illustratively, the first source register is a vector register vd, the second source register is a vector register vj, the vector register vd includes a first source element and a second source element, the vector register vj includes a third source element and a fourth source element, the number of bits of the first source element, the second source element, the third source element, and the fourth source element is N / 2, and the first source element 、 Second Source Element , a third source element, and a fourth source elementcan be spliced left and right using vector shift instructions to form a 2N-bit vector (2N=256), and for each source element in the vector, a right logical shift with rounding and unsigned saturation to half-width is performed, where the shift amount is from an immediate number, and the lowest half element of the shifted result of the first source element is selected as a target element, the lowest half element of the shifted result of the second source element is selected as a target element, the lowest half element of the shifted result of the third source element is selected as a target element, and the lowest half element of the shifted result of the fourth source element is selected as a target element, and written sequentially to vector register vd.
[0126] It should be understood that the above examples are merely illustrative examples for better understanding of the technical solutions according to the embodiments of the present application, and do not uniquely limit the embodiments of the present application.
[0127] In a fourth specific implementation of the present application, the first type vector opcode is a fourth Nobe The specific processing method may include the following sub-steps D1 to D2.
[0128] In sub-step D1, a right arithmetic shift with rounding and unsigned saturation to half-width is performed on each source element in the first splice vector according to the immediate number to generate a first initial shift operation result.
[0129] In the present embodiment, the first type of vector opcode is the fourth Nobe It may be a vector opcode, Nobe A vector opcode can be used to indicate a right arithmetic shift with rounding and unsigned saturate to half width operation on a first splice vector, the first splice vector being 2N bits, where N is a positive integer greater than 0, but preferably N is 128 bits.
[0130] Alternatively, the meanings of right arithmetic shift, rounding, and half-width are the same as those described above, and therefore will not be repeated here. Right arithmetic shift The meaning of the process of saturating to half-width is the same as that described above, and will not be repeated here. The process of performing an arithmetic right shift and unsigned saturation to half-width on an arbitrary vector has been described above, and will not be repeated here.
[0131] The first type of vector opcode is the fourth Nobe If the first splice vector is an integer opcode, then a right arithmetic shift with rounding and unsigned saturation to half-width may be performed on each source element in the first splice vector according to the immediate number to generate a first initial shift operation result.
[0132] According to the immediate number, a right arithmetic shift, rounding and unsigned saturation to half-width are performed on the first splice vector to generate a first initial shift operation result, and then sub-step D2 is performed.
[0133] In sub-step D2, consecutive lower half data of each element included in the first initial shift operation result is selected, and the element after the selection operation is determined as the shift operation result.
[0134] In the embodiment of the present application, after generating the first initial shift operation result, consecutive lower half data of each element included in the first initial shift operation result is selected, and after the selection operation, The key The prime can be determined as the result of the shift operation.
[0135] Alternatively, when the first source element and the second source element included in the first source register are both N / 2 bits and the third source element and the fourth source element included in the second source register are both N / 2 bits, the first initial shift operation result is N bits, and the shift operation result is the data indicated by the first initial shift operation result from the 0th bit to the N / 2-1th bit.
[0136] Furthermore, for each target element in the shift operation result, the lower half is selected, and sequentially written to a memory location corresponding to each target element in the destination register. Illustratively, the first source register is a vector register vd, the second source register is a vector register vj, the vector register vd includes a first source element and a second source element, the vector register vj includes a third source element and a fourth source element, the number of bits of the first source element, the second source element, the third source element, and the fourth source element is N / 2, and the first source element 、 Second Source Element , a third source element, and a fourth source element can be spliced left and right using vector shift instructions to form a 2N-bit vector (2N=256), and each source element in the vector is arithmetically shifted right with rounding and unsigned saturation to half-width, where the shift amount is derived from an immediate number, and the first source element's shifted result has its lower half element selected as a target element, the second source element's shifted result has its lower half element selected as a target element, the third source element's shifted result has its lower half element selected as a target element, and the fourth source element's shifted result has its lower half element selected as a target element, and written sequentially to vector register vd.
[0137] It should be understood that the above examples are merely illustrative examples for better understanding of the technical solutions according to the embodiments of the present application, and do not uniquely limit the embodiments of the present application.
[0138] The technical solution of the present application is adopted, and a series of operations such as logical shift and rounded half-width signed saturation operations on two source elements are implemented by executing an instruction including a first vector opcode and an immediate number; a series of operations such as arithmetic shift and rounded half-width signed saturation operations on two source elements are implemented by executing an instruction including a second vector opcode and an immediate number; a series of operations such as logical shift and rounded half-width unsigned saturation operations on two source elements are implemented by executing an instruction including a third vector opcode and an immediate number; Nobe By executing an instruction including a vector opcode and an immediate number, a series of operations such as arithmetic shift on two source elements and unsigned saturation to half-width with rounding are implemented. Therefore, by adopting the technical solution of the present invention, different shift needs can be achieved by using different shift parameters, so that multiple vector shift needs can be achieved by one shift instruction, effectively reducing system overhead and improving the execution efficiency of vector shift for a specific function.
[0139] Example 3
[0140] In an embodiment of the present application, the opcode may be a second type vector opcode, and the source registers include a first source register and a second source register, and the second type vector opcode may be used to indicate performing a selection operation in the first source register and the second source register, respectively, to perform a corresponding vector shift operation, and as shown in FIG. 6 , the method for processing the vector shift instruction may include the following steps 601-609.
[0141] In step 601, an instruction is received that includes a register identifier and a shift parameter.
[0142] In the embodiment of the present application, the meaning of the command and the parameters contained in the command have been described in the first and second embodiments, so they will not be described again here.
[0143] Alternatively, the number of source registers is two, i.e., the source elements come from two different registers, and when the number of source registers is more than one, each source register identifier in all the source registers is different from the destination register identifier, or when the number of source registers is more than one, there is one source register identifier in all the source registers that is the same as the destination register identifier. Compared with the second embodiment, the number of bits of the source register and the destination register in the embodiment of the present application is twice the number of bits of the source register and the destination register in the second embodiment, and illustratively, when the number of bits of the source register in the embodiment of the present application is 256 bits, the number of bits of the source register in the second embodiment is 128 bits.
[0144] Optionally, the received instruction may be decoded to obtain shift parameters contained in the instruction, the shift parameters indicating rules to be followed when performing a vector shift operation on the source elements, in this example the shift parameters may include parameters such as a shift amount and an opcode.
[0145] In step 602, the shift amount and the shift calculation rule are determined according to the shift parameters.
[0146] In an embodiment of the present application, there is at least one source element on which a vector shift operation is performed, the shift amount is an immediate number, the shift operation rule is an opcode, the opcode is a second type vector opcode, and the immediate number is a positive integer greater than or equal to 0.
[0147] Alternatively, the second type vector opcode is a code expressed in binary form, or the opcode is an identifier that can be converted to a binary code. The format of the instruction is "opcode destination register, source register, shift amount". If the opcode is a second type vector opcode, in actual implementation, the instruction is "XVSSR 第2のタイプ .{BH / HW / WD / DQ / BU.H / HU.W / WU.D / DU.Q} xd,xj,ui 第2のタイプ " and XVSSR 第2のタイプ is the instruction name in the second type of vector opcode, {BH / HW / WD / DQ / BU.H / HU.W / WU.D / DU.Q} The second type of vector opcode are parameters for indicating the data types of the source and target elements, B stands for byte, H stands for halfword, W stands for word, D stands for doubleword, Q stands for quadword, U stands for unsigned, xd stands for both destination and source registers, xj stands for source register, and ui stands for byte. 第2のタイプ represents the number of immediate values included in the instruction if the opcode is a vector opcode of the second type. 第2のタイプ1 .BH is the second type of vector opcode that can be converted to binary form, e.g., XVSSR 第2のタイプ1 The second type of vector opcode is .BH, which converts to binary form 011101110101000001.
[0148] In addition, UI 第2のタイプ are parameters defined according to the data types of the source and target elements, 第2のタイプ The range and value of the ui in Example 2 are the same as those of the 第1のタイプ Since this is the same as the case of (1), the explanation will not be repeated here.
[0149] After the shift amount and the shift calculation rule are determined according to the shift parameters, step 603 is executed.
[0150] In step 603, perform a selection operation on the first source register and the second source register respectively according to the second type vector opcode to obtain a first operand and a second operand.
[0151] In an embodiment of the present application, according to the second type vector opcode, a selection operation is performed on a first source register to obtain a first operand, and a selection operation is performed on a second source register to obtain a second operand, where the first operand and the second operand have the same data type, and the source element in the first operand and the element in the second operand have a data type of halfword, word, doubleword, or quadword.
[0152] Optionally, the selection operation may include an operation of selecting consecutive lower half data for each element of the first source register and the second source register, an operation of selecting consecutive upper half data for each element of the first source register and the second source register, an operation of selecting consecutive designated bits of data in the middle ... Ta and The operation includes any one of the operations of selecting non-consecutive designated bits of data for each element of the second source register.
[0153] Alternatively, the selection operation performed on the first source register and the selection operation performed on the second source register are the same. Illustratively, for example, performing the selection operation on the first source register is to select successive lower half data from each element included in the first source register, and performing the selection operation on the second source register is to select successive lower half data from each element included in the second source register. data For example, performing a selection operation on a first source register may involve selecting successive upper halves of elements contained in the first source register. dataand for the second source register Select The selection operation is performed by selecting successive most significant halves of elements contained in a second source register. data of each Furthermore, for example, the first source register Select The selection operation is performed by selecting from among each element contained in a first source register, successive bits of the middle designated bit. data of each The second source register is To On the other hand Select Performing the select operation includes selecting a second source register From each element contained in of the specified consecutive bits in the middle data of each Furthermore, for example, the first source register Select The selection operation is performed by selecting non-consecutive designated bits from among the elements contained in the first source register. data of each The second source register is Select The selection operation is performed by selecting non-consecutive designated bits from among the elements contained in the second source register. data of each It's a matter of choice.
[0154] Perform a selection operation on the first source register and the second source register respectively according to the second type vector opcode to obtain the first operand and the second operand, and then perform step 604.
[0155] In step 604, data in the first source register other than the first operand is determined as a third operand, and data in the second source register other than the second operand is determined as a fourth operand.
[0156] In an embodiment of the present application, the third operand and the fourth operand have the same data type as the first operand and the second operand, and the data type of the source element in the third operand and the element in the fourth operand is either a halfword, a word, a doubleword, or a quadword.
[0157] Alternatively, data other than the first operand in the first source register is determined as the third operand, and data other than the second operand in the second source register is determined as the fourth operand. For example, when the first operand is data of successive lower halves of elements included in the first source register, the third operand is data of successive upper halves of elements included in the first source register, and similarly, the second operand is data of successive lower halves of elements included in the first source register. data and the fourth operand is the successive most significant halves of the elements contained in the first source register. data It becomes.
[0158] After the first operand, the second operand, the third operand, and the fourth operand are obtained, step 605 is performed.
[0159] In step 605, a second splice vector is generated after splicing the first operand and the second operand, and a third splice vector is generated after splicing the third operand and the fourth operand.
[0160] In an embodiment of the present application, after splicing the first operand and the second operand left and right, a second splice vector is generated, where the setting of the position where the first operand and the second operand are spliced left and right is determined according to the position of the source register identifier in the instruction, i.e., if the first source register identifier is a source register identifier immediately after a second type vector opcode in the instruction and the second source register identifier is a source register identifier located after the first source register identifier in the instruction, the first operand is from the first source register and the second operand is from the second source register, so the first operand is located on the left side and the second operand is located on the right side, and a second splice vector is generated, but if the second source register identifier is a source register identifier immediately after a second type vector opcode in the instruction and the first ... Second If the source register identifier is placed after the source register identifier, the first operand is derived from the first source register and the second operand is derived from the second source register, so the second operand is placed on the left and the first operand is placed on the right, and a second splice vector is generated. For example, if the format of the instruction is "second type vector opcode vd, vj, immediate number", it is represented that the first source register is vd, the second source register is vj, and the destination register is vd, and in this case, the first operand is vd (first operand vd (written as ""), and the second operand vj (the second operand vj ) and the second splice vector is derived from the first operand vd Second operand vj Similarly, if the instruction format is "second type vector opcode vd, vj, immediate number", then the second source register is vd, the first source register is vj, and the destination register is vd. In this case, the second operand is vd (the second operandvd ), and the first operand is vj (the first operand vj ) and the second splice vector is " Operand 2 vd First operand vj The method for generating the third splice vector using the third and fourth operands is the same as the above method for generating the second splice vector using the first and second operands, so it will not be repeated here.
[0161] Alternatively, the first operand and the second operand may be further cross-spliced on an element-by-element basis to generate a second splice vector, in which during cross-splicing, source elements having the same address in a source register are crossed as a group, and the positions of different groups in the second splice vector are arranged in descending order according to the addresses of the source elements, and the setting of the left and right positions when splicing two elements respectively originating from two different registers as a group is determined according to the position of the source register identifier in the instruction, which is the same as the above example and will not be repeated here. For example, the first operand includes "source element 1 (address a), source element 2 (address b), and source element 3 (address c)", the second operand includes "source element 4 (address a), source element 5 (address b), and source element 6 (address c)", and the source element 1 and the source element 4, which have the same address a, are cross-spliced as one group, the source element 2 and the source element 5, which have the same address b, are cross-spliced as one group, the source element 3 and the source element 6, which have the same address c, are cross-spliced as one group, and the first operand A source register identifier corresponding to operandAssuming that the source register identifier corresponding to is placed at the right position of the instruction, the final second splice vector is "source element 1 source element 4 source element 2 source element 5 source element 3 source element 6". The method of generating the third splice vector using the third and fourth operands is the same as the method of generating the second splice vector using the first and second operands, so it will not be repeated here.
[0162] Alternatively, if the first operand has a total number of bits of N bits and the second operand has a total number of bits of N bits, the second splice vector will be 2N bits, and similarly, if the third operand has a total number of bits of N bits and the fourth operand has a total number of bits of N bits, the third splice vector will be 2N bits, where N is a positive integer greater than 0. The total number of bits of the first operand can be determined according to bits corresponding to each element included in the first operand and a data type of the element, and the total number of bits of the second operand can be determined according to bits corresponding to each element included in the second operand and a data type of the element.
[0163] After the second splice vector and the third splice vector are obtained, step 606 is performed.
[0164] In step 606, a shift, round and saturate to half width operation is performed on each element in the second splice vector according to the immediate number to generate a second initial shift operation result, and a shift, round and saturate to half width operation is performed on each element in the third splice vector according to the immediate number to generate a third initial shift operation result.
[0165] In the embodiment of the present application, the second splice vector includes multiple elements, and performing a shift, round and saturate at half-width operation on the second splice vector according to an immediate number is to perform a shift, round and saturate at half-width operation on each element in the second splice vector, with the shift amount being an immediate number, to generate a second initial shift operation result; similarly, the third splice vector includes multiple elements, and performing a shift, round and saturate at half-width operation on the third splice vector according to an immediate number is to perform a shift, round and saturate at half-width operation on each element in the third splice vector, with the shift amount being an immediate number, to generate a third initial shift operation result, where the shift operation is a right shift operation, and the shift operation includes a logical shift and an arithmetic shift.
[0166] Optionally, shifting the second splice vector includes performing a shift operation on each element in the second splice vector, and the shift amount is an immediate number, i.e., the shift amount of each element is the same and is an immediate number. For example, if the second splice vector includes element 1, element 2, and element 3, and the shift amount is ui4, then: Second Shifting the splice vectors of 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 70, 71, 72, 7
[0167] Alternatively, shifting the third splice vector includes performing a shift operation on each element in the third splice vector, and the shift amount is an immediate number, i.e., the shift amount of each element is the same and is an immediate number. For example, if the third splice vector includes an element 4, an element 5, and an element 6, and the shift amount is ui4, shifting the third splice vector includes shifting the element 4 by ui4 bits, shifting the element 5 by ui4 bits, and shifting the element 6 by ui4 bits.
[0168] Optionally, the shift rounding operation performed on the second splice vector / third splice vector includes four rounding operations: round to even, round to zero, round up, and round down. Preferably, the shift rounding operation performed on the second splice vector / third splice vector performs a shift round up operation on the second splice vector / third splice vector.
[0169] The method of performing right logical shift, rounding, and saturation to half-width on the second splice vector / third splice vector is the same as the method described in Example 2, and therefore will not be repeated here. Similarly, the method of performing right arithmetic shift, rounding, and saturation to half-width on the second splice vector / third splice vector is the same as the method described in Example 2, and therefore will not be repeated here.
[0170] After the second initial shift operation result and the third initial shift operation result are generated, step 607 is performed.
[0171] In step 607, a bit selection operation is performed on the second initial shift result to generate a first shift result, and a bit selection operation is performed on the third initial shift result to generate a second shift result.
[0172] In an embodiment of the present application, performing a bit selection operation includes any one of an operation of selecting consecutive lower half data for each element included in the second initial shift operation result and each element included in the third initial shift operation result, an operation of selecting consecutive upper half data for each element included in the second initial shift operation result and each element included in the third initial shift operation result, an operation of selecting consecutive designated bits in the middle for each element included in the second initial shift operation result and each element included in the third initial shift operation result, and an operation of selecting non-consecutive designated bits for each element included in the second initial shift operation result and each element included in the third initial shift operation result.
[0173] After the first shift operation result and the second shift operation result are generated, steps 608 and 609 are executed.
[0174] In step 608, the result of the first shift operation is written to a corresponding location in the destination register according to a bit selection operation position of the result of the first shift operation.
[0175] In step 609, the result of the second shift operation is written to a corresponding storage location in the destination register according to a bit selection operation position of the result of the second shift operation.
[0176] In the embodiment of the present application, the elements in the first shift operation result and the second shift operation result are taken as target elements and written to corresponding storage locations in the destination register.
[0177] Optionally, the data type of the target element is determined according to the data type of the source element, and optionally the number of bits corresponding to the data type of the target element is half the number of bits corresponding to the data type of the source element. Illustratively, if the data type of the source element is a halfword, the data type of the target element is a byte, if the data type of the source element is a word, the data type of the target element is a halfword, if the data type of the source element is a doubleword, the data type of the target element is a word, and if the data type of the source element is a quadword, the data type of the target element is a doubleword. The source element may be signed data or unsigned data.
[0178] Optionally, after determining the target elements, the method for sequentially writing the target elements to the destination register includes the steps of determining position information of each target element in the second shift operation result and the third shift operation result; and sequentially writing the target elements to positions matching position information corresponding to the target elements, where the position information indicates an order of elements in the second shift operation result and the third shift operation result, and sequentially writing the target elements to positions in the destination register matching the position information corresponding to the target elements means determining a storage position of each target element in the destination register, and for each target element, storing the target element derived from the second shift operation result in the most significant half of the storage location where the target element is located and storing the target element derived from the third shift operation result in the least significant half of the storage location where the target element is located, or storing the target element derived from the second shift operation result in the least significant half of the storage location where the target element is located and storing the target element derived from the third shift operation result in the most significant half of the storage location where the target element is located.
[0179] Referring to the process of obtaining a target element according to the second type vector opcode in the embodiment of the present application, the second type vector opcode includes a fifth vector opcode, a sixth vector opcode, a seventh vector opcode, and an eighth vector opcode, which respectively indicate different vector shift operations, and can be specifically described in detail with reference to the specific implementation forms below.
[0180] In a first specific implementation form of the embodiment of the present application, the second type vector opcode is a fifth vector opcode, the first operand is successive lower half data of each element of the first source register, the second operand is successive lower half data of each element of the second source register, the third operand is successive upper half data of each element of the first source register, and the fourth operand is successive upper half data of each element of the second source register, and a specific processing method may include the following sub-steps E1 to E4.
[0181] In sub-step E1, a right logical shift, rounding and signed saturation to half-width is performed on each element in the second splice vector according to the immediate number to generate a second initial shift operation result, and a right logical shift, rounding and signed saturation to half-width is performed on each element in the third splice vector according to the immediate number to generate a third initial shift operation result.
[0182] In the embodiment of the present application, the second type vector opcode may be a fifth vector opcode, which is for instructing the second splice vector to perform a right logical shift, round, half-width signed saturation operation and a selection operation of data of each element, and the third splice vector to perform a right logical shift, round, half-width signed saturation operation and a selection operation of data of each element, and the second splice vector and the third splice vector are 2N bits, N is a positive integer greater than 0, and preferably N is 128 bits. The meanings of right logical shift, round, half-width, and signed saturation are the same as those in the second embodiment, and the process of performing right logical shift, round, half-width signed saturation operation is the same as that in the second embodiment, so they will not be repeated here.
[0183] After the second initial shift operation result and the third initial shift operation result are generated, sub-step E2 is performed.
[0184] In sub-step E2, consecutive lower half data of each element included in the second initial shift operation result are selected and the selected data are determined as a first shift operation result, and consecutive upper half data of each element included in the third initial shift operation result are selected and the selected data are determined as a second shift operation result.
[0185] In an embodiment of the present application, at least one first target element is determined according to data included in the result of the first shift operation, and at least one second target element is determined according to an element included in the result of the second shift operation.
[0186] After the first shift operation result and the second shift operation result are obtained, sub-steps E3 and E4 are executed.
[0187] Substep E3 consists of writing each first target element contained in the result of the first shift operation into the lower half of the destination register at the position in which the first target element is located.
[0188] Sub-step E4 writes each second target element contained in the result of the second shift operation into the upper half of the destination register at the location where the second target element is located.
[0189] Alternatively, if the total number of bits of the first operand is N bits and the total number of bits of the second operand is N bits, the second initial shift operation result is N bits; 1. The shift operation result is the data indicated by the second initial shift operation result from the 0th bit to the N / 2-1th bit. For example, the first source register is a vector register xd, the second source register is a vector register xj, the lower half data of each element in xd is the first operand, the lower half data of each element in xj is the second operand, and the first operand and the second operand are spliced left and right using a vector shift instruction to form a 2N (2N=256)-bit vector, and operations of right logical shift, rounding, and half-width signed saturation are respectively performed on each element in the vector, and the shift amount is derived from an immediate number, SecondAfter selecting the lower half of each element included in the initial shift operation result, each element subjected to the lower half selection operation is written as a first target element to the lower half of the vector register xd at the position where each first target element is located, where the data type of the source element in the first operand and the source element in the second operand are one of halfword, word, doubleword, and quadword, the data type of the source element in the first operand and the source element in the second operand are the same, the data type of the target element written to the vector register xd is byte, halfword, word, or doubleword corresponding to the data type of the source element, and the correspondence between the data type of the source element and the data type of the target element has been described before and will not be repeated here.
[0190] Alternatively, if the total number of bits of the third operand is N bits and the total number of bits of the fourth operand is N bits, the third initial shift operation result is N bits, Second The shift operation result is the data indicated by the third initial shift operation result from the N / 2th bit to the N-1th bit. For example, the first source register is a vector register xd, the second source register is a vector register xj, the upper half of the data of each element in xd is the third operand, the upper half of the data of each element in xj is the fourth operand, and the third operand and the fourth operand are spliced left and right using a vector shift instruction to form a 2N (2N=256)-bit vector, and operations of right logical shift, rounding, and half-width signed saturation are respectively performed on each element in the vector, and the shift amount is derived from an immediate number, ThirdAfter selecting the upper half of each element included in the initial shift operation result, each element subjected to the upper half selection operation is written as a second target element to the upper half of the vector register xd at the position where each second target element is located, where the data type of the source element in the third operand and the source element in the fourth operand is one of halfword, word, doubleword, and quadword, the source element in the third operand and the source element in the fourth operand have the same data type, the data type of the target element written to the vector register xd is byte, halfword, word, or doubleword corresponding to the data type of the source element, and the correspondence between the data type of the source element and the data type of the target element has been described before and will not be repeated here.
[0191] It should be understood that the above examples are merely illustrative examples for better understanding of the technical solutions according to the embodiments of the present application, and do not uniquely limit the embodiments of the present application.
[0192] In a second specific implementation of the embodiment of the present application, the second type vector opcode is a sixth vector opcode, the first operand is successive lower half data of each element of the first source register, and the second operand is successive lower half data of each element of the second source register. Lower the third operand is successive upper half data of each element of a first source register, the fourth operand is successive upper half data of each element of a second source register, and a specific processing method may include the following sub-steps F1 to F4.
[0193] In sub-step F1, a right arithmetic shift with rounding and signed saturation to half-width is performed on each element in the second splice vector according to the immediate number to generate a second initial shift operation result, and a right arithmetic shift with rounding and signed saturation to half-width is performed on each element in the third splice vector according to the immediate number to generate a third initial shift operation result.
[0194] In an embodiment of the present application, the second type vector opcode may be a sixth vector opcode, which performs a right arithmetic shift with rounding and signed saturation to half width and a selection operation of data of each element on the second splice vector, and a right arithmetic shift with rounding and signed saturation to half width and a selection operation of data of each element on the third splice vector. Selecting data for each element wherein the second splice vector and the third splice vector are both 2N bits, where N is a positive integer greater than 0, and preferably N is 128 bits. The meanings of right arithmetic shift, rounding, half-width, and signed saturation are the same as those in the second embodiment, and the process of performing right arithmetic shift, rounding, and half-width signed saturation is the same as that in the second embodiment, so they will not be repeated here.
[0195] After the second initial shift operation result and the third initial shift operation result are generated, sub-step F2 is executed.
[0196] In sub-step F2, consecutive lower half data of each element included in the second initial shift operation result are selected and the selected data are determined as a first shift operation result, and consecutive upper half data of each element included in the third initial shift operation result are selected and the selected data are determined as a second shift operation result.
[0197] In an embodiment of the present application, at least one first target element is determined according to data included in the result of the first shift operation, and at least one second target element is determined according to an element included in the result of the second shift operation.
[0198] After the first shift operation result and the second shift operation result are obtained, sub-steps F3 and F4 are executed.
[0199] In a sub-step F3, each first target element included in the result of the first shift operation is written into the lower half of the destination register at the position where the each first target element is located.
[0200] In sub-step F4, each second target element included in the result of the second shift operation is written into the upper half of the location in the destination register where the second target element is located.
[0201] Alternatively, if the total number of bits of the first operand is N bits and the total number of bits of the second operand is N bits, the second initial shift operation result is N bits; 1. The shift operation result is the data indicated by the second initial shift operation result from the 0th bit to the N / 2-1th bit. For example, the first source register is a vector register xd, the second source register is a vector register xj, the lower half data of each element in xd is the first operand, the lower half data of each element in xj is the second operand, and the first operand and the second operand are spliced left and right using a vector shift instruction to form a 2N (2N=256)-bit vector, and each element in the vector is subjected to right arithmetic shift, rounding, and signed saturation to half-width, respectively, and the shift amount is derived from an immediate number, SecondAfter selecting the lower half of each element included in the initial shift operation result, each element subjected to the lower half selection operation is written as a first target element to the lower half of the vector register xd at the position where each first target element is located, where the data type of the source element in the first operand and the source element in the second operand are one of halfword, word, doubleword, and quadword, the source element in the first operand and the source element in the second operand have the same data type, the data type of the target element written to the vector register xd is byte, halfword, word, or doubleword corresponding to the data type of the source element, and the correspondence between the data type of the source element and the data type of the target element has been described before and will not be repeated here.
[0202] Alternatively, if the total number of bits of the third operand is N bits and the total number of bits of the fourth operand is N bits, the third initial shift operation result is N bits, Second The shift operation result is the data indicated by the third initial shift operation result from the N / 2th bit to the N-1th bit. For example, the first source register is vector register xd, the second source register is vector register xj, the upper half of the data of each element in xd is the third operand, the upper half of the data of each element in xj is the fourth operand, and the third operand and the fourth operand are spliced left and right using a vector shift instruction to form a 2N (2N=256)-bit vector, and each element in the vector is subjected to right arithmetic shift, rounding, and signed saturation to half-width, respectively, and the shift amount is derived from an immediate number, ThirdAfter selecting the upper half of each element included in the initial shift operation result, each element subjected to the upper half selection operation is written as a second target element to the upper half of the vector register xd at the position where each second target element is located, where the data type of the source element in the third operand and the source element in the fourth operand is one of halfword, word, doubleword, and quadword, the source element in the third operand and the source element in the fourth operand have the same data type, the data type of the target element written to the vector register xd is byte, halfword, word, or doubleword corresponding to the data type of the source element, and the correspondence between the data type of the source element and the data type of the target element has been described before and will not be repeated here.
[0203] It should be understood that the above examples are merely illustrative examples for better understanding of the technical solutions according to the embodiments of the present application, and do not uniquely limit the embodiments of the present application.
[0204] In a third specific implementation form of the embodiment of the present application, the second type vector opcode is a seventh vector opcode, the first operand is successive lower half data of each element of the first source register, the second operand is successive lower half data of each element of the second source register, the third operand is successive upper half data of each element of the first source register, and the fourth operand is successive upper half data of each element of the second source register, and a specific processing method may include the following sub-steps G1 to G4.
[0205] In sub-step G1, a right logical shift, rounding and unsigned saturation to half width is performed on each element in the second splice vector according to the immediate number to generate a second initial shift operation result, and a right logical shift, rounding and unsigned saturation to half width is performed on each element in the third splice vector according to the immediate number to generate a third initial shift operation result.
[0206] In an embodiment of the present application, the second type vector opcode may be a seventh vector opcode, which is for instructing the second splice vector to perform a right logical shift, round, and unsigned saturate to half-width operation and a selection operation of data of each element, and the third splice vector to perform a right logical shift, round, and unsigned saturate to half-width operation and a selection operation of data of each element, and the second splice vector and the third splice vector are both 2N bits, where N is a positive integer greater than 0, and preferably N is 128 bits. The meanings of right logical shift, round, and half-width are the same as those in embodiment 2, and the process of performing right logical shift, round, and unsigned saturate to half-width operation is the same as that in embodiment 2, so they will not be repeated here.
[0207] After the second initial shift operation result and the third initial shift operation result are generated, sub-step G2 is executed.
[0208] In sub-step G2, consecutive lower half data of each element included in the second initial shift operation result are selected and the selected data are determined as a first shift operation result, and consecutive upper half data of each element included in the third initial shift operation result are selected and the selected data are determined as a second shift operation result.
[0209] In an embodiment of the present application, at least one first target element is determined according to data included in the result of the first shift operation, and at least one second target element is determined according to an element included in the result of the second shift operation.
[0210] After the first shift operation result and the second shift operation result are determined, sub-step G3 and sub-step G4 are executed.
[0211] In sub-step G3, each first target element included in the result of the first shift operation is written into the lower half of the destination register at the location where the first target element is located.
[0212] In sub-step G4, each second target element included in the result of the second shift operation is written into the upper half of the location in the destination register where the second target element is located.
[0213] Alternatively, if the total number of bits of the first operand is N bits and the total number of bits of the second operand is N bits, the second initial shift operation result is N bits; 1. The shift operation result is the data indicated by the second initial shift operation result from the 0th bit to the N / 2-1th bit. For example, the first source register is a vector register xd, the second source register is a vector register xj, the lower half data of each element in xd is the first operand, the lower half data of each element in xj is the second operand, and the first operand and the second operand are spliced left and right using a vector shift instruction to form a 2N (2N=256)-bit vector, and operations of right logical shift, rounding, and unsigned saturation to half-width are respectively performed on each element in the vector, and the shift amount is derived from an immediate number, SecondAfter selecting the lower half of each element included in the initial shift operation result of the above, each element subjected to the lower half selection operation is written as a first target element to the lower half of the vector register xd at the position where each first target element is located, in sequence. Here, the data type of the source element in the first operand and the source element in the second operand is one of halfword, word, doubleword, and quadword, the source element in the first operand and the source element in the second operand have the same data type, the data type of the target element written to the vector register xd is byte, halfword, word, or doubleword corresponding to the data type of the source element, and the correspondence between the data type of the source element and the data type of the target element has been described before and will not be repeated here.
[0214] Alternatively, if the total number of bits of the third operand is N bits and the total number of bits of the fourth operand is N bits, the third initial shift operation result is N bits, Second The shift operation result is the data indicated by the third initial shift operation result from the N / 2th bit to the N-1th bit. For example, the first source register is a vector register xd, the second source register is a vector register xj, the upper half of the data of each element in xd is the third operand, the upper half of the data of each element in xj is the fourth operand, and the third operand and the fourth operand are spliced left and right using a vector shift instruction to form a 2N (2N=256)-bit vector, and each element in the vector is subjected to a right logical shift, rounded, and unsigned saturation to half-width, respectively, and the shift amount is derived from an immediate number, ThirdAfter selecting the upper half of each element included in the initial shift operation result, each element subjected to the upper half selection operation is written as a second target element to the upper half of the vector register xd at the position where each second target element is located, where the data type of the source element in the third operand and the source element in the fourth operand is one of halfword, word, doubleword, and quadword, the source element in the third operand and the source element in the fourth operand have the same data type, the data type of the target element written to the vector register xd is byte, halfword, word, or doubleword corresponding to the data type of the source element, and the correspondence between the data type of the source element and the data type of the target element has been described before and will not be repeated here.
[0215] It should be understood that the above examples are merely illustrative examples for better understanding of the technical solutions according to the embodiments of the present application, and do not uniquely limit the embodiments of the present application.
[0216] In a fourth specific implementation form of the embodiment of the present application, the second type vector opcode is an eighth vector opcode, the first operand is successive lower half data of each element of the first source register, the second operand is successive lower half data of each element of the second source register, the third operand is successive upper half data of each element of the first source register, and the fourth operand is successive upper half data of each element of the second source register, and a specific processing method may include the following sub-steps H1 to H4.
[0217] In sub-step H1, a right arithmetic shift with rounding and unsigned saturation to half-width is performed on each element in the second splice vector according to the immediate number to generate a second initial shift operation result, and a right arithmetic shift with rounding and unsigned saturation to half-width is performed on each element in the third splice vector according to the immediate number to generate a third initial shift operation result.
[0218] In an embodiment of the present application, the second type vector opcode may be an eighth vector opcode, which performs an arithmetic right shift, round and unsigned saturate to half-width operation and data selection for each element on the second splice vector. selective manipulation For the third splice vector, a right arithmetic shift, rounding, and unsigned saturation to half-width are performed, and data selection for each element is performed. selective manipulation The second splice vector and the third splice vector are 2N bits, where N is a positive integer greater than 0, and preferably N is 128 bits. The meanings of right arithmetic shift, rounding, and half-width are the same as in the second embodiment, and the process of performing right arithmetic shift, rounding, and unsigned saturation to half-width is the same as in the second embodiment, so they will not be repeated here.
[0219] After the second initial shift operation result and the third initial shift operation result are generated, sub-step H2 is executed.
[0220] In sub-step H2, consecutive lower half data of each element included in the second initial shift operation result are selected and the selected data are determined as a first shift operation result, and consecutive upper half data of each element included in the third initial shift operation result are selected and the selected data are determined as a second shift operation result.
[0221] In an embodiment of the present application, at least one first target element is determined according to data included in the result of the first shift operation, and at least one second target element is determined according to an element included in the result of the second shift operation.
[0222] After the first shift operation result and the second shift operation result are obtained, sub-step H3 and sub-step H4 are executed.
[0223] In sub-step H3, each first target element included in the result of the first shift operation is written into the lower half of the destination register at the position where the first target element is located.
[0224] In sub-step H4, each second target element included in the second shift operation result is written into the upper half of the location in the destination register where the second target element is located.
[0225] Alternatively, if the total number of bits of the first operand is N bits and the total number of bits of the second operand is N bits, 1. The initial shift operation result is N bits, and the second shift operation result is the data indicated by the second initial shift operation result from the 0th bit to the N / 2-1th bit. For example, the first source register is a vector register xd, the second source register is a vector register xj, the lower half data of each element in xd is the first operand, the lower half data of each element in xj is the second operand, and the first operand and the second operand are spliced left and right using a vector shift instruction to form a 2N (2N=256)-bit vector, and each element in the vector is respectively subjected to a right arithmetic shift, rounded, and unsigned saturation to half-width, and the shift amount is derived from an immediate number, SecondAfter selecting the lower half of each element included in the initial shift operation result, each element subjected to the lower half selection operation is written as a first target element to the lower half of the vector register xd at the position where each first target element is located, where the data type of the source element in the first operand and the source element in the second operand are one of halfword, word, doubleword, and quadword, the source element in the first operand and the source element in the second operand have the same data type, the data type of the target element written to the vector register xd is byte, halfword, word, or doubleword corresponding to the data type of the source element, and the correspondence between the data type of the source element and the data type of the target element has been described before and will not be repeated here.
[0226] Alternatively, if the total number of bits of the third operand is N bits and the total number of bits of the fourth operand is N bits, the third initial shift operation result is N bits, Second The shift operation result is the data indicated by the third initial shift operation result from the N / 2th bit to the N-1th bit. For example, the first source register is vector register xd, the second source register is vector register xj, the upper half of the data of each element in xd is the third operand, the upper half of the data of each element in xj is the fourth operand, and the third operand and the fourth operand are spliced left and right using a vector shift instruction to form a 2N (2N=256)-bit vector, and each element in the vector is respectively subjected to right arithmetic shift, rounding, and unsigned saturation to half-width, and the shift amount is derived from an immediate number. ThirdAfter selecting the upper half of each element included in the initial shift operation result, each element subjected to the upper half selection operation is written as a second target element to the upper half of the vector register xd at the position where each second target element is located, where the data type of the source element in the third operand and the source element in the fourth operand is one of halfword, word, doubleword, and quadword, the source element in the third operand and the source element in the fourth operand have the same data type, the data type of the target element written to the vector register xd is byte, halfword, word, or doubleword corresponding to the data type of the source element, and the correspondence between the data type of the source element and the data type of the target element has been described before and will not be repeated here.
[0227] It should be understood that the above examples are merely illustrative examples for better understanding of the technical solutions according to the embodiments of the present application, and do not uniquely limit the embodiments of the present application.
[0228] By adopting the technical solution of the present application and executing an instruction including a fifth vector opcode and an immediate number, No It implements a set of operations such as logical shifts and rounding and signed saturation to half-width on base elements, and executes instructions that contain a sixth vector opcode and an immediate number. No It implements a set of operations such as arithmetic shifts on base elements and rounding and signed saturation to half-width, and executes an instruction containing a seventh vector opcode and an immediate number to implement two No The 8th vector opcode implements a set of operations such as logical shifts on base elements and rounding and unsigned saturation to half-width, and executes an instruction containing an immediate number. NoThe vector shift instruction implements a series of operations such as arithmetic shift on the vector elements and rounding and unsigned saturation to half-width. Therefore, by adopting the technical solution of the present invention, different shift needs can be achieved by using different shift parameters, so that multiple vector shift needs can be achieved by one shift instruction, effectively reducing system overhead and improving the execution efficiency of vector shift for a specific function.
[0229] Example 4
[0230] In an embodiment of the present application, the opcode is a third type vector opcode, the source register is a first source register, and the Third A vector opcode of type select operation in the first source register. Realize As shown in FIG. 7, the method for processing a vector shift instruction may include the following steps 701 to 707.
[0231] In step 701, an instruction is received that includes a register identifier and a shift parameter.
[0232] In the embodiments of the present application, the meaning of the commands and the parameters included in the commands are explained in the first to third embodiments, and therefore will not be explained repeatedly here.
[0233] Optionally, the number of source registers is one, i.e. all source elements come from the same source register, and the number of destination registers is one, and the source register and the destination register are the same or different. The number of bits of the first source register is preferably 128 bits or 256 bits.
[0234] Optionally, the received instruction may be decoded to obtain shift parameters contained in the instruction, the shift parameters indicating rules to be followed when performing a vector shift operation on the source elements, in this example the shift parameters may include parameters such as a shift amount and an opcode.
[0235] In step 702, the shift amount and the shift calculation rule are determined according to the shift parameters.
[0236] In an embodiment of the present application, there is at least one source element on which a vector shift operation is performed, the shift amount is derived from a shift amount register, the shift operation rule is an opcode, the opcode is a third type vector opcode, and each element shift amount included in the shift amount register is a positive integer greater than or equal to 0.
[0237] Alternatively, the third type vector opcode is a code expressed in binary form, or the opcode is an identifier that can be converted to a binary code. The format of the instruction is "opcode destination register, source register, shift amount". When the opcode is a third type vector opcode, in actual implementation, the instruction is "[X]VSSR 第3のタイプ .{BH / HW / WD / BU.H / HU.W / WU.D} vd / xd,vj / xj,vk 第3のタイプ / xk 第3のタイプ " and [X]VSSR 第3のタイプ is the instruction name in the third type of vector opcode, {BH / HW / WD / BU.H / HU.W / WU.D} The third type of vector opcode are parameters to indicate the data type of the source and target elements, B stands for byte, H stands for halfword, W stands for word, D stands for doubleword, vd / xd stands for both destination and source registers, vj / xj stands for source register, and vk 第3のタイプ / xk 第3のタイプrepresents a shift amount register identifier included in the instruction when the opcode is a third type vector opcode, the binary included in the shift amount register is an array, the number of parameters included in the array is the same as the number of target elements, and the parameters included in the data are the same or different. For example, VSSR 第3のタイプ1 .BH is the third type of vector opcode that can be converted to binary form, e.g., VSSR. 第3のタイプ1 A third type of vector opcode is .BH, which is converted to binary form as 01110001000000001.
[0238] After the shift amount and the shift calculation rule are determined according to the shift parameters, step 703 is executed.
[0239] In step 703, a selection operation is performed on the first source register according to the third type vector opcode to obtain a fifth operand.
[0240] In an embodiment of the present application, the selection operation comprises selecting, for each element of the first source register, successive lower halves of the data for each element of said first source register, selecting successive most significant halves of said data for each element of the first source register, data an operation of selecting, for each element of the first register, the non-consecutive designated bits of the data where the data type of the source elements in the fifth operand is either a halfword, word, or doubleword.
[0241] Alternatively, the first source register includes 2N-bit data, the 2N-bit data can correspond to a number of half-word elements, word elements, or double-word elements, and the step of performing a selection operation in the first source register to obtain a fifth operand includes the steps of: taking every M-bit data of the first source register as a data group, each data group including at least one source element, and determining all source elements corresponding to all data groups as the fifth operand, where M and N are positive integers greater than 0, M≦N, and the corresponding relationship between the source elements and the data is determined according to the conversion relationship between the data type of the source elements and the data bits.
[0242] Alternatively, there is no data at the same address between different data groups, or some data at the same address between different data groups, where the address is location information of the data in the first source register, and the address of each data is uniquely identified in the first source register.
[0243] It is preferable that N is a multiple of M. Illustratively, when N=128, M=128, and the first source register includes 256-bit data, the data of the first source register is divided into a total of two groups (a first data group and a second data group) with one group being 128 bits each, the first data group being data of the 0th to 127th bits of the first source register, the second data group being data of the 128th to 255th bits of the first source register, and the first data group and the second data group do not have data of the same address. If the data type of the source elements is halfword, the first data group includes eight halfword source elements, whereas if the data type of the source elements is word, the first data group includes four word source elements, whereas if the data type of the source elements is doubleword, the first data group includes two doubleword source elements.
[0244] After performing a selection operation on the first source register according to the third type vector opcode to obtain a fifth operand, step 704 is performed.
[0245] In step 704, a shift, round and half-width saturation operation is performed on the fifth operand according to the third type vector opcode and the shift amount to generate a fourth initial shift operation result.
[0246] In an embodiment of the present application, the shift amount comes from a shift amount register, and the content stored in the shift amount register may be a group of data including a number of shift values, each shift value associated with a respective source element in the fifth operand, the shift values for different source elements may be the same or different, and the number of shift values is the same as the number of source elements in the fifth operand, or the number of shift values is the same as the result of the fourth initial shift operation.
[0247] Alternatively, when the number of shift values is the same as the number of source elements of the fifth operand, each shift value corresponds to one source element in the fifth operand, and each source element in the fifth operand is shifted, rounded, and saturated to half-width according to the shift amount to generate a fourth initial shift operation result. Exemplarily, the fifth operand includes source element 1, source element 2, source element 3, and source element 4, and the shift amount register includes four shift values (shift value 1, shift value 2, shift value 3, and shift value 4), and the shift amount corresponding to source element 1 is shift value 1, the shift amount corresponding to source element 2 is shift value 2, the shift amount corresponding to source element 3 is shift value 3, and the shift amount corresponding to source element 4 is shift value 4, then source element 1 is shifted according to shift value 1, source element 2 is shifted according to shift value 2, source element 3 is shifted according to shift value 3, and source element 4 is shifted according to shift value 4.
[0248] Alternatively, if the number of shift values is the same as the fourth initial shift operation result, the fifth operand is divided into a plurality of element groups according to the number of shift values, such that the number of element groups is the same as the number of shift values, i.e., each shift value corresponds to one element group, and for each source element in the fifth operand, a shift, rounding, and half-width saturation operation is performed according to a shift amount corresponding to the element group in which it is arranged to generate the fourth initial shift operation result. Illustratively, the fifth operand includes source element 1, source element 2, source element 3, and source element 4, and the shift amount register includes: 2 If the input data includes two shift values (shift value 1 and shift value 2), source element 1 and source element 2 form a first element group, the shift amount corresponding to the first element group is shift value 1, and source element 3 and source element 4 form a second element group, the shift amount corresponding to the second element group is shift value 2, then source element 1 and source element 2 shift according to shift value 1, and source element 3 and source element 4 shift according to shift value 2.
[0249] After the fourth initial shift operation result is generated, step 705 is executed.
[0250] In step 705, a bit selection operation is performed on the fourth initial shift operation result to generate a shift operation result.
[0251] In the present embodiment, the bit selection operation is performed by selecting consecutive lower halves of the fourth initial shift operation result. data an operation of selecting successive upper halves of the fourth initial shift operation result; data an operation of selecting successive designated bits in the middle of the fourth initial shift operation result; data an operation of selecting non-consecutive designated bits of the fourth initial shift operation result; data This includes any one of the operations to select
[0252] After the shift operation result is generated, step 706 is executed.
[0253] In step 706, the data in the shift operation result is written sequentially to corresponding locations in the destination register.
[0254] In the embodiment of the present application, after the shift operation result is generated, a target element corresponding to each data in the shift operation result is determined, and each data is written sequentially to the memory location of each target element in the destination register.
[0255] Optionally, the data type of the target element is determined according to the data type of the source element, and optionally the number of bits corresponding to the data type of the target element is half the number of bits corresponding to the data type of the source element. Illustratively, if the data type of the source element is a halfword, the data type of the target element is a byte, if the data type of the source element is a word, the data type of the target element is a halfword, and if the data type of the source element is a doubleword, the data type of the target element is a word. The source element may be signed data or unsigned data.
[0256] Optionally, after the target elements are determined, the method for sequentially writing the target elements to the destination register includes determining position information of each target element in the shift operation result, and sequentially writing the target elements to positions in the destination register that match the position information corresponding to the target elements, where the position information indicates the order of the elements in the shift operation result, and sequentially writing the target elements to positions in the destination register that match the position information corresponding to the target elements means sequentially writing the target elements from the most significant bit to the least significant bit to positions from the N / 2-1th bit to the 0th bit of the destination register, or sequentially writing the target elements from the least significant bit to the most significant bit to positions from the 0th bit to the N / 2-1th bit of the destination register.
[0257] After the elements in the shift operation result are written in sequence as target elements into the destination register, step 707 is executed.
[0258] In step 707, the value of the location in the destination register where the data has not been written is set according to the third type vector opcode.
[0259] After the data in the shift operation result is sequentially written to the corresponding positions in the destination register, the values of the positions in the destination register to which data has not been written can be set according to the third type vector opcode.
[0260] Referring to the process of obtaining a target element according to the third type vector opcode in the embodiment of the present application, the third type vector opcode may include a ninth vector opcode, a tenth vector opcode, an eleventh vector opcode, and a twelfth vector opcode to respectively indicate different vector shift operations. Specifically, it can be described in detail with reference to the following specific implementation.
[0261] In a first specific implementation form of the embodiment of the present application, the third type vector opcode is a ninth vector opcode, and the fifth operand is any consecutive source element of the first source register, and a specific processing method may include the following sub-steps K1 to K5.
[0262] In sub-step K1, the fifth operand is logically shifted right, rounded, and signed-saturated to half-width according to the shift amount, to generate a fourth initial shift operation result.
[0263] In an embodiment of the present application, after the ninth vector opcode is obtained, each element included in the fifth operand may be logically shifted right with rounding and signed saturation to half-width according to a shift amount to generate a fourth initial shift operation result, where the shift amount is derived from a shift amount register.
[0264] Alternatively, the first source register includes 2N-bit data, the 2N-bit data may correspond to a plurality of half-word elements, word elements, or double-word elements, and performing a selection operation in the first source register to obtain a fifth operand includes determining every M-bit data in the first source register as one data group and all source elements corresponding to each data group as a fifth operand. The step of performing a right logical shift, round and half-width signed saturation operation on each element included in the fifth operand according to the shift amount to generate a fourth initial shift operation result includes determining a shift value in a shift amount register corresponding to each source element in the fifth operand, and performing a right logical shift, round and half-width signed saturation operation on each source element according to the shift value corresponding to each source element to obtain a fourth initial shift operation result.
[0265] Furthermore, the meanings of right logical shift, rounding, half-width, and signed saturation are the same as in the second embodiment, and the process of performing right logical shift, rounding, and half-width signed saturation is the same as in the second embodiment, so they will not be described repeatedly here.
[0266] After the fourth initial shift operation result is generated, sub-step K2 is executed.
[0267] In sub-step K2, consecutive lower half data of each element included in the fourth initial shift operation result is selected, and the element after the selection operation is determined as the shift operation result.
[0268] In an embodiment of the present application, after a fourth initial shift operation result is generated, consecutive lower half data of each element in the fourth initial shift operation result are selected, and the consecutive lower half data of each element after the selection operation are determined as the shift operation result.
[0269] After the shift operation result is obtained, sub-step K3 is executed.
[0270] Sub-step K3 divides the storage location in the destination register according to a preset value to generate a number of storage areas.
[0271] In the embodiment of the present application, the preset value refers to a value for dividing the memory location in the vector register, the preset value is the data bit width occupied by the target element, and the specific value of the preset value can be determined according to business needs, and the embodiment of the present application does not limit it. The preset value is preferably a value that allows each memory area divided according to the preset value to have the same size (each memory area has the same data bit width).
[0272] After the multiple storage areas have been created, sub-step K4 is executed.
[0273] In sub-step K4, the data resulting from the shift operation is written sequentially into the lower half of each storage area.
[0274] In the embodiment of the present application, when the fifth operand is M bits, the fourth initial shift operation result is M / 2 bits, and in this case, the shift operation result is the data shown from the 0th bit to the M / 4-1th bit in the fourth initial shift operation result. Illustratively, the first source register is a vector register xj, the first source register is 2M, the source element corresponding to each M bit of xj is set as the fifth operand, and the vector shift instruction is used to perform a right logical shift, rounding, and half-width signed saturation operation on each M bit source element included in the fifth operand to obtain the fourth initial shift operation result, the shift amount is derived from the shift amount register, and the lower half element selected from each element in the fourth initial shift operation result is written as the lower half of each target element to the lower half of the target element for each M bit of the vector register xd in sequence, and the upper half data of each target element for each M bit is set to 0. Here, the data type of the source element in the fifth operand is one of halfword, word, or doubleword, and the data type of the target element written to the vector register xd is byte, halfword, or word, corresponding to the data types of the source elements above. The correspondence between the data types of the source elements and the data types of the target elements has been described before and will not be repeated here.
[0275] After the data resulting from the shift operation has been written in sequence into the lower half of each storage area, sub-step K5 is executed.
[0276] In sub-step K5, the values of positions in each storage area where no data has been written are set to zero.
[0277] In the embodiment of the present application, the element in the shift operation result is taken as the target element and written sequentially into the lower half of each memory area, and then the value of the position in each memory area where the target element is not written is set to zero.
[0278] For example, the first source register is vj / xj and the third type of vector opcode is 10 execute a vector shift instruction, i.e., perform a right logical shift with rounding and signed saturation to half-width on each 128-bit source element of a first source register vj / xj, select the lower half of each element in the shift result to write sequentially to the lower half of each 128-bit target element of a destination register vd / xd, set the upper half of each 128-bit target element of the destination register to 0, the shift amount for each element is from a shift amount register vk / xk, and the data type of the source elements is either halfword, word, or doubleword.
[0279] It should be understood that the above examples are merely illustrative examples for better understanding of the technical solutions according to the embodiments of the present application, and do not uniquely limit the embodiments of the present application.
[0280] In a second specific implementation form of the embodiment of the present application, the third type vector opcode is a tenth vector opcode, and the fifth operand is any consecutive source element of the first source register, and a specific processing method may include the following sub-steps M1 to M5.
[0281] In sub-step M1, the fifth operand is arithmetically shifted right, rounded, and signed-saturated to half-width according to the shift amount, to generate a fourth initial shift operation result.
[0282] In an embodiment of the present application, after the tenth vector opcode is obtained, each element in the fifth operand may be right arithmetically shifted with rounding and signed saturation to half-width according to a shift amount to generate a fourth initial shift operation result, where the shift amount is derived from a shift amount register.
[0283] Alternatively, the first source register includes 2N-bit data, the 2N-bit data may correspond to a plurality of half-word elements, word elements, or double-word elements, and performing a selection operation in the first source register to obtain a fifth operand includes determining every M-bit data of the first source register as one data group and all source elements corresponding to each data group as a fifth operand. The step of performing a right arithmetic shift with rounding and signed saturation to half-width operation on each element included in the fifth operand according to the shift amount to generate a fourth initial shift operation result includes determining a shift value in a shift amount register corresponding to each source element in the fifth operand, and performing a right arithmetic shift with rounding and signed saturation to half-width operation on each source element according to the shift value corresponding to each source element to obtain a fourth initial shift operation result.
[0284] Furthermore, the meanings of right arithmetic shift, rounding, half-width, and signed saturation are the same as in the second embodiment, and the process of performing right arithmetic shift, rounding, and half-width signed saturation is the same as in the second embodiment, so they will not be described repeatedly here.
[0285] After the fourth initial shift operation result is generated, sub-step M2 is executed.
[0286] In sub-step M2, consecutive lower half data of each element included in the fourth initial shift operation result is selected, and the element after the selection operation is determined as the shift operation result.
[0287] In an embodiment of the present application, after the fourth initial shift operation result is generated, consecutive lower half data of each element are selected from the fourth initial shift operation result, and the consecutive lower half data of each element after the selection operation can be determined as the shift operation result.
[0288] After the shift operation result is obtained, sub-step M3 is executed.
[0289] In sub-step M3, the storage location in the destination register is divided according to a preset value to generate a plurality of storage areas.
[0290] In the embodiment of the present application, the preset value refers to a numerical value for dividing the memory location in the destination register, the preset value is the data bit width occupied by the target element, and the specific numerical value of the preset value can be determined according to business needs, and the embodiment of the present application does not limit it. The preset value is preferably a value that makes each memory area divided according to the preset value have the same size (each memory area has the same data bit width).
[0291] After dividing the storage location in the destination register according to the preset value to generate a plurality of storage areas, sub-step M4 is executed.
[0292] In sub-step M4, the data resulting from the shift operation is written sequentially into the lower half of each storage area.
[0293] In the embodiment of the present application, after multiple storage areas are generated and the shift operation results are obtained, the elements in the shift operation results can be written sequentially into the lower half of each storage area as target elements.
[0294] Alternatively, if the fifth operand is M bits, the fourth initial shift operation result is M / 2 bits, in which case the shift operation result is the data shown from the 0th bit to the M / 4-1th bit in the fourth initial shift operation result. For example, the first source register is a vector register xj, the first source register is 2M, the source elements corresponding to each M bits of xj are used as the fifth operand, and a vector shift instruction is used to perform right arithmetic shift, rounding, and signed saturation to half-width on each M-bit source element included in the fifth operand to obtain the fourth initial shift operation result, the shift amount is derived from the shift amount register, and the lower half elements selected from each element in the fourth initial shift operation result are written as each target element to the lower half of each target element for each M bits of the vector register xd in sequence, and the upper half data of each target element for each M bits is set to 0. Here, the data type of the source element in the fifth operand is one of halfword, word, or doubleword, and the data type of the target element written to the vector register xd is byte, halfword, or word, corresponding to the data types of the source elements above. The correspondence between the data types of the source elements and the data types of the target elements has been described before and will not be repeated here.
[0295] After the data resulting from the shift operation is written sequentially into the lower half of each storage area, sub-step M5 is executed.
[0296] In sub-step M5, the values of the locations in each storage area where no data is written are set to zero.
[0297] In an embodiment of the present application, the elements in the shift operation result are written sequentially as target elements into the lower half of each memory area, and then the values of the positions in each memory area where the target elements are not written can be set to 0.
[0298] For example, when the first source register is vj / xj and the third type vector opcode is the ninth vector opcode, execute a vector shift instruction, that is, perform right arithmetic shift with rounding and signed saturation to half-width on each 128-bit source element of the first source register vj / xj, select the lower half of each element in the shift result and write it sequentially to the lower half of each 128-bit target element of the destination register vd / xd, set the upper half of each 128-bit target element of the destination register to 0, the shift amount of each element is derived from the shift amount register vk / xk, and the data type of the source element is either halfword, word, or doubleword.
[0299] It should be understood that the above examples are merely illustrative examples for better understanding of the technical solutions according to the embodiments of the present application, and do not uniquely limit the embodiments of the present application.
[0300] In a third specific implementation form of the embodiment of the present application, the third type vector opcode is an eleventh vector opcode, the fifth operand is any consecutive source element of the first source register, and a specific processing method may include the following sub-steps N1 to N5.
[0301] In sub-step N1, the fifth operand is logically shifted right and rounded according to the shift amount, and unsigned saturated to half-width is performed to generate a fourth initial shift operation result.
[0302] In an embodiment of the present application, after an eleventh vector opcode is obtained, each element included in the fifth operand may be logically shifted right with rounding and unsigned saturation to half-width according to a shift amount to generate a fourth initial shift operation result, where the shift amount is derived from a shift amount register.
[0303] Alternatively, the first source register includes 2N-bit data, the 2N-bit data may correspond to a plurality of half-word elements, word elements, or double-word elements, and performing a selection operation in the first source register to obtain a fifth operand includes determining every M-bit data of the first source register as one data group and all source elements corresponding to each data group as a fifth operand. The step of performing a right logical shift, round and unsigned saturation to half-width operation on each element included in the fifth operand according to the shift amount to generate a fourth initial shift operation result includes determining a shift value in a shift amount register corresponding to each source element in the fifth operand, and performing a right logical shift, round and unsigned saturation to half-width operation on each source element according to the shift value corresponding to each source element to obtain a fourth initial shift operation result.
[0304] Furthermore, the meanings of right logical shift, rounding, and half-width are the same as in Example 2, and the process of performing right logical shift, rounding, and unsigned saturation to half-width is the same as in Example 2, so they will not be repeated here.
[0305] According to the shift amount, the fifth operand is logically shifted right, rounded, and unsigned saturated to half-width, to generate a fourth initial shift operation result, and then sub-step N2 is executed.
[0306] In sub-step N2, consecutive lower half data of each element included in the fourth initial shift operation result is selected, and the element after the selection operation is determined as the shift operation result.
[0307] In an embodiment of the present application, after the fourth initial shift operation result is generated, consecutive lower half data of each element are selected from the fourth initial shift operation result, and the consecutive lower half data of each selected element are determined as the shift operation result.
[0308] After the shift operation result is obtained, sub-step N3 is executed.
[0309] In sub-step N3, the storage location in the destination register is divided according to a preset value to generate a plurality of storage areas.
[0310] In the embodiment of the present application, the preset value refers to a value for dividing the memory location in the destination register, the preset value is the data bit width occupied by the target element, and the specific value of the preset value can be determined according to business needs, and the embodiment of the present application does not limit it. The preset value is preferably a value that makes each memory area divided according to the preset value have the same size (each memory area has the same data bit width).
[0311] After the multiple storage areas are generated, sub-step N4 is executed.
[0312] In sub-step N4, the data resulting from the shift operation is written sequentially into the lower half of each storage area.
[0313] In the embodiment of the present application, after multiple storage areas are generated and the shift operation result is obtained, the elements in the shift operation result can be written sequentially into the lower half of each storage area as target elements.
[0314] Alternatively, if the fifth operand is M bits, the fourth initial shift operation result is M / 2 bits, in which case the shift operation result is the data shown from the 0th bit to the M / 4-1th bit in the fourth initial shift operation result. For example, the first source register is a vector register xj, the first source register is 2M, the source elements corresponding to each M bits of xj are used as the fifth operand, and the fourth initial shift operation result is obtained by performing a right logical shift, rounding, and unsigned saturation to half-width operation on each M-bit source element included in the fifth operand using a vector shift instruction, and the shift amount is derived from the shift amount register, and the lower half elements selected from each element in the fourth initial shift operation result are written as each target element to the lower half of each target element for each M bits of the vector register xd in sequence, and the upper half data of each target element for each M bits is set to 0. Here, the data type of the source element in the fifth operand is one of halfword, word, or doubleword, and the data type of the target element written to the vector register xd is byte, halfword, or word, corresponding to the data types of the source elements above. The correspondence between the data types of the source elements and the data types of the target elements has been described before and will not be repeated here.
[0315] After the data resulting from the shift operation is written sequentially into the lower half of each storage area, sub-step N5 is executed.
[0316] In sub-step N5, the values of the positions in each storage area where no data is written are set to zero.
[0317] After the elements in the shift operation result are written sequentially into the lower half of each storage area as target elements, the values of the positions in each storage area where the target elements have not been written can be set to zero.
[0318] For example, the first source register is vj / xj, the third type vector opcode is 11 execute a vector shift instruction, i.e., perform a right logical shift with rounding and unsigned saturation to half-width on each 128-bit source element of a first source register vj / xj, select the lower half of each element in the shift result to write sequentially to the lower half of each 128-bit target element of a destination register vd / xd, set the upper half of each 128-bit target element of the destination register to 0, the shift amount for each element is from a shift amount register vk / xk, and the data type of the source elements is either halfword, word, or doubleword.
[0319] It should be understood that the above examples are merely illustrative examples for better understanding of the technical solutions according to the embodiments of the present application, and do not uniquely limit the embodiments of the present application.
[0320] In a fourth specific implementation form of the present application, the third type vector opcode is a twelfth vector opcode, the fifth operand is any consecutive source element of the first source register, and a specific processing method may include the following substeps S1 to S5.
[0321] In sub-step S1, the fifth operand is arithmetically shifted right, rounded, and unsigned saturated to half-width according to the shift amount, to generate a fourth initial shift operation result.
[0322] In an embodiment of the present application, after the twelfth vector opcode is obtained, each element in the fifth operand may be arithmetically shifted right with rounding and unsigned saturation to half-width according to a shift amount to generate a fourth initial shift operation result, where the shift amount is derived from a shift amount register.
[0323] After the fourth initial shift operation result is generated, sub-step S2 is executed.
[0324] In sub-step S2, consecutive lower half data of each element included in the fourth initial shift operation result is selected, and the element after the selection operation is determined as the shift operation result.
[0325] In an embodiment of the present application, after the fourth initial shift operation result is generated, consecutive lower half data of each element can be selected from the fourth initial shift operation result, and the consecutive lower half data of each selected element can be determined as the shift operation result.
[0326] Alternatively, the first source register includes 2N-bit data, the 2N-bit data may correspond to a plurality of half-word elements, word elements, or double-word elements, and performing a selection operation in the first source register to obtain a fifth operand includes determining every M-bit data of the first source register as one group of data groups, and all source elements corresponding to each data group as a fifth operand. Performing a right arithmetic shift with rounding and unsigned saturation to half-width operation on the fifth operand according to the shift amount to generate a fourth initial shift operation result includes determining a shift value in a shift amount register corresponding to each source element in the fifth operand, and performing a right arithmetic shift with rounding and unsigned saturation to half-width operation on each source element according to the shift value corresponding to each source element, respectively, to obtain a fourth initial shift operation result.
[0327] In addition, right arithmetic shift, rounding, half-width, Unsigned The meaning of saturation is the same as in the second embodiment, and the process of performing the right arithmetic shift, rounding, and unsigned saturation to half-width is the same as in the second embodiment, so it will not be described again here.
[0328] After the shift operation result is obtained, sub-step S3 is executed.
[0329] In sub-step S3, the storage location in the destination register is divided according to a preset value to generate a plurality of storage areas.
[0330] In the embodiment of the present application, the preset value refers to a numerical value for dividing the memory location in the destination register, the preset value is the data bit width occupied by the target element, and the specific numerical value of the preset value can be determined according to business needs, and the embodiment of the present application does not limit it. The preset value is preferably a value that makes each memory area divided according to the preset value have the same size (each memory area has the same data bit width).
[0331] After the multiple storage areas are created, sub-step S4 is executed.
[0332] In sub-step S4, the data resulting from the shift operation is written sequentially into the lower half of each storage area.
[0333] In the embodiment of the present application, after a plurality of storage areas are generated and a shift operation result is obtained, an element in the shift operation result can be written sequentially into the lower half of each storage area as a target element.
[0334] Alternatively, if the fifth operand is M bits, the fourth initial shift operation result is M / 2 bits, in which case the shift operation result is the data shown from the 0th bit to the M / 4-1th bit in the fourth initial shift operation result. Exemplarily, the first source register is a vector register xj, the first source register is 2M, the source elements corresponding to each M bits of xj are used as the fifth operand, and a vector shift instruction is used to perform right arithmetic shift, rounding, and unsigned saturation to half-width on each M-bit source element included in the fifth operand to obtain the fourth initial shift operation result, the shift amount is derived from the shift amount register, and the lower half elements selected from each element in the fourth initial shift operation result are written as each target element to the lower half of each target element for each M bits of the vector register xd in sequence, and the upper half data of each target element for each M bits is set to 0. Here, the data type of the source element in the fifth operand is one of halfword, word, or doubleword, and the data type of the target element written to the vector register xd is byte, halfword, or word, corresponding to the data types of the source elements above. The correspondence between the data types of the source elements and the data types of the target elements has been described before and will not be repeated here.
[0335] After the data resulting from the shift operation is written sequentially into the lower half of each storage area, sub-step S5 is executed.
[0336] In sub-step S5, the values of the positions in each storage area where no data is written are set to zero.
[0337] The elements in the shift operation result are written as target elements into the lower half of each storage area in sequence, and then the values of the positions in each storage area where the target elements are not written can be set to 0.
[0338] It should be understood that the above examples are merely illustrative examples for better understanding of the technical solutions according to the embodiments of the present application, and do not uniquely limit the embodiments of the present application.
[0339] The technical solution of the present application is adopted, and an instruction including a ninth vector opcode and a shift amount is executed to implement a series of operations such as a logical shift and a rounded half-width signed saturation operation on two source elements, and an instruction including a tenth vector opcode and a shift amount is executed, and the shift amount is derived from a register, to implement a series of operations such as an arithmetic shift and a rounded half-width signed saturation operation on two source elements, and an instruction including an eleventh vector opcode and a shift amount is executed to implement a series of operations such as a logical shift and a rounded half-width unsigned saturation operation on two source elements, and an instruction including a twelfth vector opcode and a shift amount is executed to implement a series of operations such as an arithmetic shift and a rounded half-width unsigned saturation operation on two source elements. Therefore, by adopting the technical solution of the present invention, different shift needs can be achieved by using different shift parameters, and thus multiple vector shift needs can be achieved by one shift instruction, which effectively reduces system overhead and improves the execution efficiency of vector shift for a specific function.
[0340] Example 5
[0341] Please refer to Fig. 8. Fig. 8 shows a structural block diagram of a processor according to a second embodiment of the present application.
[0342] As shown in FIG. 8, the processor may include a number of vector registers, an instruction decode unit 83, and an execution unit 84. The plurality of vector registers includes a source register 81 for storing source elements to be operated on when performing a vector shift operation, and a destination register 82; the instruction decode unit 83 is for decoding a vector shift instruction including a register identifier and a shift parameter, the register identifier including a source register identifier and a destination register identifier, the source register identifier is for indicating a source register 81, and the destination register identifier is for indicating a destination register 82; In response to the vector shift instruction, the execution unit 84 performs a vector shift operation on a source element obtained from the source register 81 according to the shift parameters, obtains a target element after the vector shift operation, and writes the target element to the destination register 82.
[0343] Preferably, the execution unit 84 determines a shift amount and a shift operation rule according to the shift parameters, where there is at least one source element on which a vector shift operation is performed, and performs a corresponding shift operation on the source element in the source register according to the shift amount and the shift operation rule to generate a shift operation result; and Elements in is determined as the target element.
[0344] Preferably, the shift parameters include a shift amount and an opcode, and the shift amount is the vector shift operation is for indicating a number of shift bits of a source element to be operated on when the opcode is executed, the opcode being for indicating a shift operation rule to be performed on a source element in the source register and a target element in a destination register; The execution unit 84 executes the vector shift instruction from among the source registers according to the opcode. operationa source element to execute the shift operation; determine the selected source element as an operand; perform a corresponding shift operation on the operand according to the opcode to generate a shift operation result; determine a storage format of the target element in the destination register according to the opcode; and store the target element in the destination register according to the storage format.
[0345] Preferably, the shift amount is an immediate number, and the source registers include a first source register and a second source register.
[0346] Preferably, said opcode is a vector opcode of a first type; The execution unit 84 determines all source elements in a first source register as one operand and all source elements in a second source register as operands according to the first type vector opcode; splicing an operand in the first source register and an operand in the second source register according to a vector opcode of the first type, to generate a first splice vector; performing a shift, round and saturate to half-width operation on each source element in the first splice vector according to the immediate number to generate a first initial shift operation result; performing a bit selection operation on the first initial shift operation result to generate a shift operation result, wherein the bit selection operation includes an operation of selecting consecutive lower half data for each element included in the first initial shift operation result, an operation of selecting consecutive upper half data for each element included in the first initial shift operation result, an operation of selecting consecutive designated bits in the middle for each element included in the first initial shift operation result, The and an operation of selecting data of designated non-consecutive bits for each element included in the first initial shift operation result.
[0347] Preferably, the first type vector opcode is a first vector opcode; The execution unit 84 performs a right logical shift with rounding and signed saturation to half-width on each source element in the first splice vector according to the immediate number to generate a first initial shift operation result; Consecutive lower half data of each element included in the first initial shift operation result is selected, and the element after the selection operation is determined as the shift operation result.
[0348] Preferably, the first type vector opcode is a second type vector opcode; The execution unit 84 performs a right arithmetic shift with rounding and signed saturation to half-width on each source element in the first splice vector according to the immediate number to generate a first initial shift operation result; Consecutive lower half data of each element included in the first initial shift operation result is selected, and the element after the selection operation is determined as the shift operation result.
[0349] Preferably, the first type vector opcode is a third vector opcode; The execution unit 84 performs a right logical shift with rounding and unsigned saturation to half-width on each source element in the first splice vector according to the immediate number to generate a first initial shift operation result; Consecutive lower half data of each element included in the first initial shift operation result is selected, and the element after the selection operation is determined as the shift operation result.
[0350] Preferably, the first type vector opcode is a fourth vector opcode; The execution unit 84 performs a right arithmetic shift with rounding and unsigned saturation to half-width on each source element in the first splice vector according to the immediate number to generate a first initial shift operation result; Consecutive lower half data of each element included in the first initial shift operation result is selected, and the element after the selection operation is determined as the shift operation result.
[0351] Preferably, said opcode is a vector opcode of a second type; The execution unit 84 performs a selection operation on a first source register and a second source register, respectively, according to the second type vector opcode to obtain a first operand and a second operand, where the selection operation includes: an operation of selecting consecutive lower half data for each element of the first source register and the second source register; an operation of selecting consecutive upper half data for each element of the first source register and the second source register; an operation of selecting intermediate consecutive designated bits of data for each element of the first source register and the second source register; Ta and selecting non-consecutive designated bits of data for each element of the second source register; The execution unit 84 also includes: determining data in the first source register other than the first operand as a third operand, and determining data in the second source register other than the second operand as a fourth operand; generating a second splice vector after splicing the first operand and the second operand, and generating a third splice vector after splicing the third operand and the fourth operand, where the data types of elements included in the second splice vector and the third splice vector are halfword, word, doubleword, or quadword; performing a shift, round and saturate to half width operation on each element in the second splice vector according to the immediate number to generate a second initial shift operation result; and performing a shift, round and saturate to half width operation on each element in the third splice vector according to the immediate number to generate a third initial shift operation result; performing a bit selection operation on the second initial shift operation result to generate a first shift operation result; and performing a bit selection operation on the third initial shift operation result to generate a second shift operation result, wherein the performed bit selection operation includes any one of an operation of selecting consecutive lower half data for each element included in the second initial shift operation result and each element included in the third initial shift operation result, an operation of selecting consecutive upper half data for each element included in the second initial shift operation result and each element included in the third initial shift operation result, an operation of selecting consecutive designated bit data in the middle for each element included in the second initial shift operation result and each element included in the third initial shift operation result, and an operation of selecting non-consecutive designated bit data for each element included in the second initial shift operation result and each element included in the third initial shift operation result; writing the result of the first shift operation to a corresponding storage location within the destination register in response to a bit selection operation location of the result of the first shift operation; The result of the second shift operation is written to a corresponding storage location in the destination register according to a bit selection operation position of the result of the second shift operation.
[0352] Preferably, the second type vector opcode is a fifth vector opcode, the first operand is data consisting of successive lower halves of elements of the first source register, the second operand is data consisting of successive lower halves of elements of the second source register, the third operand is data consisting of successive upper halves of elements of the first source register, and the fourth operand is data consisting of successive upper halves of elements of the second source register; the execution unit 84 performs a right logical shift with rounding and signed saturation to half-width on each element in the second splice vector according to the immediate number to generate a second initial shift operation result; and performs a right logical shift with rounding and signed saturation to half-width on each element in the third splice vector according to the immediate number to generate a third initial shift operation result; Selecting consecutive lower half data of each element included in the second initial shift operation result, and determining the selected data as a first shift operation result, and selecting consecutive upper half data of each element included in the third initial shift operation result, and determining the selected data as a second shift operation result, wherein at least one first target element is determined according to the data included in the first shift operation result, and determining a first target element included in the second shift operation result. data determining at least one second target element according to writing each first target element included in the result of the first shift operation into a lower half of the destination register at a location where each first target element is located; Each second target element included in the result of the second shift operation is written into the upper half of the destination register at the location where the second target element is located.
[0353] Preferably, the second type vector opcode is a sixth vector opcode, the first operand is data consisting of successive lower halves of elements of the first source register, the second operand is data consisting of successive lower halves of elements of the second source register, the third operand is data consisting of successive upper halves of elements of the first source register, and the fourth operand is data consisting of successive upper halves of elements of the second source register. data and the execution unit performs a right arithmetic shift with rounding and signed saturation to half-width on each element in the second splice vector according to the immediate number to generate a second initial shift operation result, and performs a right arithmetic shift with rounding and signed saturation to half-width on each element in the third splice vector according to the immediate number to generate a third initial shift operation result; Selecting consecutive lower half data of each element included in the second initial shift operation result, and determining the selected data as a first shift operation result, and selecting consecutive upper half data of each element included in the third initial shift operation result, and determining the selected data as a second shift operation result, wherein at least one first target element is determined according to the data included in the first shift operation result, and determining a first target element included in the second shift operation result. data determining at least one second target element according to Each of the first shift operation results No. 1 The target elements of the destination register are No. 1 writes to the lower half of the position where the target element of Each of the second shift operation results Second The target elements of the destination register are Second Write each of the target elements into the upper half of the row where they are located.
[0354] Preferably, the second type vector opcode is a seventh vector opcode, the first operand is data consisting of successive lower halves of elements of the first source register, the second operand is data consisting of successive lower halves of elements of the second source register, the third operand is data consisting of successive upper halves of elements of the first source register, and the fourth operand is data consisting of successive upper halves of elements of the second source register; The execution unit 84 performs a right logical shift, round and unsigned saturate to half-width operation on each element in the second splice vector according to the immediate number to generate a second initial shift operation result; and performing a right logical shift with rounding and unsigned saturation to half-width on each element in the third splice vector according to the immediate number to generate a third initial shift operation result; selecting successive lower half data of each element included in the second initial shift operation result, and determining the selected data as a first shift operation result, and selecting successive upper half data of each element included in the third initial shift operation result, and determining the selected data as a second shift operation result; determining at least one first target element according to the data included in the first shift operation result; data determining at least one second target element according to writing each first target element included in the result of the first shift operation into a lower half of the destination register at a location where each first target element is located; Each second target element included in the result of the second shift operation is written into the upper half of the destination register at the location where the second target element is located.
[0355] Preferably, the second type vector opcode is an eighth vector opcode, the first operand is data consisting of successive lower halves of elements of the first source register, the second operand is data consisting of successive lower halves of elements of the second source register, the third operand is data consisting of successive upper halves of elements of the first source register, and the fourth operand is data consisting of successive upper halves of elements of the second source register; The execution unit 84 performs a right arithmetic shift with rounding and unsigned saturation to half-width on each element in the second splice vector according to the immediate number to generate a second initial shift operation result; and performing a right arithmetic shift with rounding and unsigned saturation to half-width on each element in the third splice vector according to the immediate number to generate a third initial shift operation result; Selecting consecutive lower half data of each element included in the second initial shift operation result, and determining the selected data as a first shift operation result, and selecting consecutive upper half data of each element included in the third initial shift operation result, and determining the selected data as a second shift operation result, wherein at least one first target element is determined according to the data included in the first shift operation result, and determining a first target element included in the second shift operation result. data determining at least one second target element according to writing each first target element included in the result of the first shift operation into a lower half of the destination register at a location where each first target element is located; Each second target element included in the result of the second shift operation is written into the upper half of the destination register at the location where the second target element is located.
[0356] Preferably, the instruction further includes a shift amount register identifier for indicating a shift amount register which is a register for storing the shift amount.
[0357] Preferably, the opcode is a third type vector opcode, and the source register comprises a first source register; the execution unit performs a selection operation on the first source register in accordance with the third type vector opcode to obtain a fifth operand, wherein the selection operation includes one of an operation of selecting consecutive lower half data for each element of the first source register, an operation of selecting consecutive upper half data for each element of the first source register, an operation of selecting intermediate consecutive designated bits of data for each element of the first source register, and an operation of selecting non-consecutive designated bits of data for each element of the first source register; performing a shift, round, and half-width saturation operation on the fifth operand according to the third type vector opcode and the shift amount to generate a fourth initial shift operation result; performing a bit selection operation on the fourth initial shift operation result to generate a shift operation result, wherein the bit selection operation includes any one of an operation of selecting consecutive lower half data for each element included in the fourth initial shift operation result, an operation of selecting consecutive upper half data for each element included in the fourth initial shift operation result, an operation of selecting consecutive designated bit data in the middle for each element included in the fourth initial shift operation result, and an operation of selecting non-consecutive designated bit data for each element included in the fourth initial shift operation result; Sequentially writing the data in the shift operation result to corresponding positions in the destination register; A value is set in the destination register at a location where the data has not been written in accordance with the third type vector opcode.
[0358] Preferably, the third type vector opcode is a ninth vector opcode, and the fifth operand is any successive source element of the first source register; The execution unit 84 performs a right logical shift, rounding, and signed saturation to half-width on each element included in the fifth operand according to the shift amount to generate a fourth initial shift operation result; The successive lower halves of each element included in the fourth initial shift operation result data Each of the elements is selected, and the element after the selection is determined as the shift operation result. Dividing the storage locations in the destination register according to a preset value to determine a storage area for each target element; The data in the shift operation result is written sequentially into the lower half of each storage area; The values of the locations in each storage area where no data is written are set to zero.
[0359] Preferably, the third type vector opcode is a tenth vector opcode, and the fifth operand is any successive source element of the first source register; The execution unit 84 performs a right arithmetic shift, rounding, and half-width signed saturation operation on each element included in the fifth operand according to the shift amount to generate a fourth initial shift operation result; The successive lower halves of each element included in the fourth initial shift operation result data Each of the elements is selected, and the element after the selection is determined as the shift operation result. Dividing the storage locations in the destination register according to a preset value to determine a storage area for each target element; The data in the shift operation result is written sequentially into the lower half of each storage area; The values of the locations in each storage area where no data is written are set to zero.
[0360] Preferably ,before the third type vector opcode is an eleventh vector opcode, and the fifth operand is any consecutive source element of the first source register; The execution unit 84 performs a right logical shift, rounding, and unsigned saturation to half-width on each element included in the fifth operand according to the shift amount to generate a fourth initial shift operation result; The successive lower halves of each element included in the fourth initial shift operation result data Select the element after the selection operation and determine it as the shift operation result. Dividing the storage locations in the destination register according to a preset value to determine a storage area for each target element; The data in the shift operation result is written sequentially into the lower half of each storage area; The values of the locations in each storage area where no data is written are set to zero.
[0361] Preferably, the third type vector opcode is a twelfth vector opcode, and the fifth operand is any successive source element of the first source register; The execution unit 84 performs a right arithmetic shift, rounding, and unsigned saturation to half-width on each element included in the fifth operand according to the shift amount to generate a fourth initial shift operation result; The successive lower halves of each element included in the fourth initial shift operation result data Each of the elements is selected, and the element after the selection is determined as the shift operation result. Dividing the storage locations in the destination register according to a preset value to determine a storage area for each target element; The data in the shift operation result is written sequentially into the lower half of each storage area; The values of the locations in each storage area where no data is written are set to zero.
[0362] Preferably, the number of source registers is one or more, the number of destination registers is one, and the source register identifier is the same as or different from the destination register identifier.
[0363] Preferably, the number of said source registers is a plurality of registers, and the number of said destination registers is one register; Either each source register identifier in all of the source registers is different from the destination register identifier, or there is one source register identifier in all of the source registers that is the same as the destination register identifier.
[0364] Example 6
[0365] Please refer to FIG. 9. FIG. Example 6 1 shows a structural schematic diagram of an electronic device for performing a vector shift operation according to
[0366] As shown in FIG. 9, the electronic device may include one or more assemblies including a processing assembly 902, a memory 904, a power supply assembly 906, a multimedia assembly 908, an audio assembly 910, an input / output (I / O) interface 912, a sensor assembly 914, and a communication assembly 916.
[0367] The processing assembly 902 generally controls the overall operation of the electronic device, including operations related to display, data communication, camera operation, and recording operations. Processing Assembly 902 The processing assembly 902 may include one or more processors 920 that execute instructions to complete all or a portion of the steps of the methods described above. The processing assembly 902 may also include one or more modules for facilitating interaction between the processing assembly 902 and other assemblies. For example, Processing Assembly 902 may include a multimedia module for facilitating interaction between the multimedia assembly 908 and the processing assembly 902 .
[0368] The memory 904 is configured to store various types of data to support operation on the electronic device. Examples of such data include instructions for any application or method operated on the electronic device, contact data, phone book data, messages, images, videos, etc. The memory 904 may be implemented by any type of volatile or non-volatile storage device, such as a static random access memory (SRAM), an electrically erasable programmable read-only memory (EEPROM), an erasable programmable read-only memory (EPROM), a programmable read-only memory (PROM), a read-only memory (ROM), a magnetic memory, a flash memory, a magnetic disk, or an optical disk, or a combination thereof.
[0369] The power assembly 906 provides power to the various assemblies of the electronic device. The power assembly 906 includes a power management system, one or more power sources, and electronic equipment 900 may include other assemblies related to the generation, management, and distribution of electrical power.
[0370] The multimedia assembly 908 includes a screen that provides an output interface between the electronic device and a user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen for receiving input signals from a user. The touch panel includes one or more touch sensors for sensing touches, swipes, and gestures on the touch panel. The touch sensors can sense the boundaries of a touch or swipe operation as well as detect the duration and pressure associated with the touch or swipe operation. In some embodiments, the multimedia assembly 908The electronic device includes one front camera and / or one rear camera. The front camera and / or the rear camera can receive external multimedia data when the electronic device is in an operation mode such as a photo mode or a video mode. Each of the front camera and the rear camera may be a fixed optical lens system or may have a focal length and an optical zoom function.
[0371] The audio assembly 910 is configured to output and / or input audio signals. For example, the audio assembly 910 includes a microphone (MIC) configured to receive an external audio signal when the terminal is in an operation mode such as a call mode, a recording mode, a voice recognition mode, etc. The received audio signal may be further stored in the memory 904 or transmitted by the communication assembly 916. In some embodiments, the audio assembly 910 further includes a speaker for outputting the audio signal.
[0372] The I / O interface 912 provides an interface between the processing assembly 902 and a peripheral interface module, which may be a keypad, a click wheel, buttons, etc. These buttons may include, but are not limited to, a home button, volume buttons, a start button, and a lock button.
[0373] The sensor assembly 914 includes one or more sensors for providing an assessment of various aspects of the state of the electronic device 900. For example, the sensor assembly 914 can detect the open / closed state of the electronic device 900, the relative positioning of an assembly, such as the display and keypad of a terminal, the sensor assembly 914 can also detect changes in the position of the terminal or one of the assemblies of the terminal, the presence or absence of a user's contact with the electronic device, the orientation or acceleration / deceleration of the electronic device, and changes in the temperature of the electronic device. The sensor assembly 914 can also include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 914 can also include a CMOS or MOS FET for use in imaging applications. Charge coupled device CCD ) It may include an optical sensor, such as an image sensor, In some embodiments, the sensor assembly 914 may further include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0374] The communication assembly 916 is configured to facilitate wired or wireless communication between the electronic device and other devices. The electronic device can access a wireless network based on a communication standard such as WiFi, 2G, or 3G, or a combination thereof. In one exemplary embodiment, the communication component 916 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In one exemplary embodiment, the communication component 916 further comprises a Near Field Communication (NFC) module for facilitating short-range communication. For example, the NFC module can be implemented based on Radio Frequency Identification (RFID) technology, Infrared Data Association (IrDA) technology, Ultra Wide Band (UWB) technology, Bluetooth (BT) technology, and other technologies.
[0375] In an exemplary embodiment, the electronics may be implemented with one or more application specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic elements to perform the vector shifting methods described above.
[0376] The electronic device according to the embodiment of the present application is for implementing a vector shifting method executed using instructions corresponding to the embodiments of the methods described above, and has beneficial effects of implementing the corresponding methods, so they will not be described again here.
[0377] Each embodiment in this specification will be described step by step, and each embodiment will focus on the differences with other embodiments, and the same or similar parts between each embodiment can be referred to each other. The device embodiment is basically similar to the method embodiment, so the description will be relatively simple, and the relevant parts can be described with reference to the method embodiment.
[0378] The above is a detailed description of the vector shift method, processor, electronic device, and readable storage medium provided by the present application. In this specification, the principle and embodiment of the present invention are described by applying specific examples, but the above examples are merely described to help understand the method of the present invention and its main concept, and at the same time, those skilled in the art can make changes to the specific embodiment and its application scope based on the concept of the present invention. As mentioned above, the description in this specification should not be understood as limiting the present invention.
[0379] The algorithms and displays provided herein are not inherently related to any particular computer, electronic system, or other device. Various general-purpose systems may also be used in conjunction with the teachings herein. The necessary structure for building such a system will be apparent in light of the above description. Furthermore, this application is not directed to any particular programming language. It should be understood that a variety of programming languages can be used to implement the contents of the application as described herein, and the above description of a particular language is provided to disclose the best mode of carrying out the application.
[0380] In the specification provided by the present application, a large amount of specific details are described. However, it can be understood that the embodiments of the present application can be practiced without these specific details. In some instances, well-known methods, structures and techniques have not been shown in detail so as not to obscure the understanding of this specification.
[0381] Similarly, in the above description of exemplary embodiments of the present application, it should be understood that various features of the present application may be grouped together in a single embodiment, drawing, or description thereof in order to simplify the disclosure and aid in the understanding of one or more aspects of the various inventions. However, this method of disclosure should not be interpreted as reflecting an intention that the present application requires more features than are expressly recited in each claim. Rather, as reflected in the following claims, aspects of the present invention include fewer than all features of each of the embodiments disclosed above. Thus, any claims according to a particular embodiment are hereby expressly incorporated into that particular embodiment, with each claim serving as a separate embodiment of the present application in its own right.
[0382] Those skilled in the art can understand that the modules in the devices in the embodiments can be adaptively changed and arranged in one or more devices different from the embodiments. The modules, units or assemblies in the embodiments can be combined into a single module, unit or assembly, and can be further divided into multiple sub-modules, sub-units or sub-assemblies. All features disclosed in this specification (including the appended claims, abstract and accompanying drawings) and all processes or units of the methods or devices thus disclosed can be combined in any combination, except where at least some of such features and / or processes or units are mutually exclusive. Each feature disclosed in this specification (including the appended claims, abstract and accompanying drawings) may be replaced by an alternative feature serving the same, equivalent or similar purpose, unless otherwise specified.
[0383] In addition, those skilled in the art will appreciate that some embodiments described herein include some features but not other features included in other embodiments, but that combinations of features from different embodiments are within the scope of the present application and are meant to form different embodiments. For example, in the following claims, any one of the claimed embodiments may be used in any combination.
[0384] Various embodiments of the present application may be implemented in hardware, or as software modules running on one or more processors, or a combination thereof. Those skilled in the art will appreciate that a microprocessor or digital signal processor (DSP) may be used to implement the present application. electronic equipmentIt should be understood that the present application may in fact be used to implement some or all of the functionality of some or all of the components in the present application. The present application may also be implemented as a device or apparatus program (e.g., computer program and computer program product) for performing some or all of the methods described herein. Such programs implementing the present application may be stored on a computer readable medium or may have the form of one or more signals. Such signals may be downloadable from an Internet site, provided on a carrier signal, or provided in any other form.
[0385] It should be noted that the above examples are illustrative of the present application, but do not limit it, and that a person skilled in the art may design alternative examples without departing from the scope of the appended claims. In the claims, reference signs placed between parentheses shall not be interpreted as limiting the scope of the claims. The term "comprises" does not exclude the presence of an element or step not stated in the claim. The term "a" or "one" preceding an element does not exclude the presence of a plurality of such elements. The present application may be implemented by hardware comprising several different elements, and by a suitably programmed computer. In individual claims enumerating several devices, several of these devices may be embodied by the same hardware. The use of the terms first, second, third, etc. does not indicate any order. These terms may be interpreted as names.
[0386] This application claims priority to a Chinese patent application filed with the China National Intellectual Property Office on December 10, 2021, bearing application number 202111509173.2 and titled "Vector shift method, processor and electronic device," the entire contents of which are incorporated herein by reference.
Claims
1. receiving an instruction including a register identifier and a shift parameter, wherein the register identifier includes a source register identifier and a destination register identifier, the source register identifier is for indicating a source register, the source register being a register that stores a source element to be operated on when performing a vector shift operation, the destination register identifier is for indicating a destination register, the destination register being a register that stores a target element obtained after performing the vector shift operation, and the shift parameter is for indicating a rule based on which to perform the vector shift operation on the source element; executing the instruction to perform a vector shift operation on a source element obtained from the source register according to the shift parameter to obtain a target element after the vector shift operation; writing the target element to the destination register.
2. performing a vector shift operation on a source element obtained from the source register according to the shift parameter to obtain a target element after the vector shift operation; determining a shift amount and a shift operation rule according to the shift parameters, where the source element on which a vector shift operation is performed is at least one; performing a corresponding shift operation on a source element in the source register according to the shift amount and the shift operation rule to generate a shift operation result; determining an element in the shift operation result as a target element.
3. the shift parameters include a shift amount and an opcode, the shift amount being for indicating a number of shift bits of a source element to be operated when the vector shift operation is performed, and the opcode being for indicating a shift operation rule to be performed on a source element in the source register and a target element in a destination register; performing a corresponding shift operation on a source element in the source register according to the shift amount and the shift operation rule to generate a shift operation result; selecting a source element from the source registers according to the opcode to perform the vector shift operation, and determining the selected source element as an operand; performing a corresponding shift operation on the operand according to the opcode to generate a shift operation result; determining an element in the shift operation result as a target element, and then writing the target element to the destination register, determining a storage format of the target element in the destination register according to the opcode; 3. The method of claim 2, further comprising the step of: storing said target element in said destination register according to said storage format.
4. 4. The method of claim 3, wherein the shift amount is an immediate number, and the source registers include a first source register and a second source register.
5. the opcode is a first type vector opcode; selecting a source element from the source registers according to the opcode to perform the vector shift operation, and determining the selected source element as an operand, determining all source elements in a first source register as one operand and all source elements in a second source register as operands according to the first type vector opcode; performing a corresponding shift operation on the operand according to the opcode to generate a shift operation result; generating a first splice vector after splicing an operand in the first source register and an operand in the second source register according to a vector opcode of the first type; performing a shift, round and saturate to half-width operation on each source element in the first splice vector according to the immediate number to generate a first initial shift operation result; and performing a bit selection operation on the first initial shift operation result to generate a shift operation result, wherein the bit selection operation includes any one of an operation of selecting consecutive lower half data for each element included in the first initial shift operation result, an operation of selecting consecutive upper half data for each element included in the first initial shift operation result, an operation of selecting data of elements of intermediate consecutive designated bits for each element included in the first initial shift operation result, and an operation of selecting data of non-consecutive designated bits for each element included in the first initial shift operation result.
6. the first type vector opcode is a first vector opcode; performing a shift, round and saturate to half-width operation on each source element in the first splice vector according to the immediate number to generate a first initial shift operation result, performing a right logical shift with rounding and signed saturation to half-width on each source element in the first splice vector according to the immediate number to generate a first initial shift operation result; performing a bit selection operation on the first initial shift operation result to generate a shift operation result, 6. The vector shift method according to claim 5, further comprising the step of selecting consecutive lower half data of each element included in the first initial shift operation result, and determining the element after the selection operation as a shift operation result.
7. the first type vector opcode is a second vector opcode; performing a shift, round and saturate to half-width operation on each source element in the first splice vector according to the immediate number to generate a first initial shift operation result, performing a right arithmetic shift with rounding and signed saturation to half-width on each source element in the first splice vector according to the immediate number to generate a first initial shift operation result; performing a bit selection operation on the first initial shift operation result to generate a shift operation result, 6. The vector shift method according to claim 5, further comprising the step of selecting consecutive lower half data of each element included in the first initial shift operation result, and determining the element after the selection operation as a shift operation result.
8. the first type vector opcode is a third vector opcode; performing a shift, round and saturate to half-width operation on each source element in the first splice vector according to the immediate number to generate a first initial shift operation result, performing a right logical shift with rounding and unsigned saturation to half-width on each source element in the first splice vector according to the immediate number to generate a first initial shift operation result; performing a bit selection operation on the first initial shift operation result to generate a shift operation result, 6. The vector shift method according to claim 5, further comprising the step of selecting consecutive lower half data of each element included in the first initial shift operation result, and determining the element after the selection operation as a shift operation result.
9. the first-type vector opcode is a fourth first-type vector opcode; performing a shift, round and saturate to half-width operation on each source element in the first splice vector according to the immediate number to generate a first initial shift operation result, performing a right arithmetic shift with rounding and unsigned saturation to half-width on each source element in the first splice vector according to the immediate number to generate a first initial shift operation result; performing a bit selection operation on the first initial shift operation result to generate a shift operation result, 6. The vector shift method according to claim 5, further comprising the step of selecting consecutive lower half data of each element included in the first initial shift operation result, and determining the element after the selection operation as a shift operation result.
10. the opcode is a second type vector opcode; selecting a source element from the source registers according to the opcode to perform the vector shift operation, and determining the selected source element as an operand, performing a selection operation in a first source register and a second source register, respectively, according to the second type vector opcode to obtain a first operand and a second operand, wherein the selection operation includes any one of an operation of selecting consecutive lower half data for each element of the first source register and the second source register, an operation of selecting consecutive upper half data for each element of the first source register and the second source register, an operation of selecting intermediate consecutive designated bit data for each element of the first source register and the second source register, and an operation of selecting non-consecutive designated bit data for each element of the first source register and the second source register; determining data in the first source register other than the first operand as a third operand, and determining data in the second source register other than the second operand as a fourth operand; performing a corresponding shift operation on the operand according to the opcode to generate a shift operation result; generating a second splice vector after splicing the first operand and the second operand, and generating a third splice vector after splicing the third operand and the fourth operand, where data types of elements included in the second splice vector and the third splice vector are halfword, word, doubleword, or quadword; performing a shift, round and saturate to half width operation on each element in the second splice vector according to the immediate number to generate a second initial shift operation result, and performing a shift, round and saturate to half width operation on each element in the third splice vector according to the immediate number to generate a third initial shift operation result; performing a bit selection operation on the second initial shift operation result to generate a first shift operation result, and performing a bit selection operation on the third initial shift operation result to generate a second shift operation result, wherein the performed bit selection operation includes any one of an operation of selecting consecutive lower half data for each element included in the second initial shift operation result and each element included in the third initial shift operation result, an operation of selecting consecutive upper half data for each element included in the second initial shift operation result and each element included in the third initial shift operation result, an operation of selecting consecutive designated bit data in the middle for each element included in the second initial shift operation result and each element included in the third initial shift operation result, and an operation of selecting non-consecutive designated bit data for each element included in the second initial shift operation result and each element included in the third initial shift operation result, Storing the target element at a determined storage location in accordance with the storage configuration includes: writing the result of the first shift operation to a corresponding storage location in the destination register in response to a bit selection operation position of the result of the first shift operation; and writing the result of the second shift operation to a corresponding memory location in the destination register according to a bit selection operation position of the result of the second shift operation.
11. the second type vector opcode is a fifth vector opcode, the first operand is data consisting of successive lower halves of elements of the first source register, the second operand is data consisting of successive lower halves of elements of the second source register, the third operand is data consisting of successive upper halves of elements of the first source register, and the fourth operand is data consisting of successive upper halves of elements of the second source register; performing a shift, round and saturate to half width operation on each element in the second splice vector according to the immediate number to generate a second initial shift operation result, and performing a shift, round and saturate to half width operation on each element in the third splice vector according to the immediate number to generate a third initial shift operation result, performing a right logical shift, round and half-width signed saturation operation on each source element in the second splice vector according to the immediate number to generate a second initial shift operation result; and performing a right logical shift, round and half-width signed saturation operation on each source element in the third splice vector according to the immediate number to generate a third initial shift operation result, performing a bit selection operation on the second initial shift operation result to generate a second shift operation result, and performing a bit selection operation on the third initial shift operation result to generate a third shift operation result, a step of selecting successive lower half data of each element included in the second initial shift operation result and determining the selected data as a first shift operation result, and selecting successive upper half data of each element included in the third initial shift operation result and determining the selected data as a second shift operation result, wherein at least one first target element is determined according to data included in the first shift operation result, and at least one second target element is determined according to elements included in the second shift operation result, writing the result of the first shift operation to a corresponding storage location in the destination register in response to a bit selection operation location of the result of the first shift operation, writing each first target element included in the result of the first shift operation into a lower half of the destination register at a location where the first target element is located; writing the second shift operation result to a corresponding storage location in the destination register in response to a bit selection operation location of the second shift operation result, 11. The vector shifting method according to claim 10, further comprising the step of writing each second target element included in the result of the second shift operation into a high-order half of a location in the destination register where the each second target element is located.
12. the second type vector opcode is a sixth vector opcode, the first operand is data consisting of successive lower halves of elements of the first source register, the second operand is data consisting of successive lower halves of elements of the second source register, the third operand is data consisting of successive upper halves of elements of the first source register, and the fourth operand is data consisting of successive upper halves of elements of the second source register; performing a shift, round and saturate to half width operation on each element in the second splice vector according to the immediate number to generate a second initial shift operation result, and performing a shift, round and saturate to half width operation on each element in the third splice vector according to the immediate number to generate a third initial shift operation result, performing a right arithmetic shift with rounding and signed saturation to half-width on each source element in the second splice vector according to the immediate number to generate a second initial shift operation result; and performing a right arithmetic shift with rounding and signed saturation to half-width on each source element in the third splice vector according to the immediate number to generate a third initial shift operation result, performing a bit selection operation on the second initial shift operation result to generate a second shift operation result, and performing a bit selection operation on the third initial shift operation result to generate a third shift operation result, a step of selecting successive lower half data of each element included in the second initial shift operation result and determining the selected data as a first shift operation result, and selecting successive upper half data of each element included in the third initial shift operation result and determining the selected data as a second shift operation result, wherein at least one first target element is determined according to data included in the first shift operation result, and at least one second target element is determined according to elements included in the second shift operation result, writing the result of the first shift operation to a corresponding storage location in the destination register in response to a bit selection operation location of the result of the first shift operation, writing each second target element included in the result of the first shift operation into a lower half of the destination register at a location where the second target element is located; writing the second shift operation result to a corresponding storage location in the destination register in response to a bit selection operation location of the second shift operation result, 11. The vector shifting method according to claim 10, further comprising the step of writing each first target element included in the result of the second shift operation into a high-order half of a location in the destination register where the each first target element is located.
13. the second type vector opcode is a seventh vector opcode, the first operand is data consisting of successive lower halves of elements of the first source register, the second operand is data consisting of successive lower halves of elements of the second source register, the third operand is data consisting of successive upper halves of elements of the first source register, and the fourth operand is data consisting of successive upper halves of elements of the second source register; performing a shift, round and saturate to half width operation on each element in the second splice vector according to the immediate number to generate a second initial shift operation result, and performing a shift, round and saturate to half width operation on each element in the third splice vector according to the immediate number to generate a third initial shift operation result, performing a right logical shift with rounding and unsigned saturation to half-width on each source element in the second splice vector according to the immediate number to generate a second initial shift operation result; performing a right logical shift with rounding and unsigned saturation to half-width on each source element in the third splice vector according to the immediate number to generate a third initial shift operation result; performing a bit selection operation on the second initial shift operation result to generate a second shift operation result, and performing a bit selection operation on the third initial shift operation result to generate a third shift operation result, a step of selecting successive lower half data of each element included in the second initial shift operation result and determining the selected data as a first shift operation result, and selecting successive upper half data of each element included in the third initial shift operation result and determining the selected data as a second shift operation result, wherein at least one first target element is determined according to data included in the first shift operation result, and at least one second target element is determined according to elements included in the second shift operation result, writing the result of the first shift operation to a corresponding storage location in the destination register in response to a bit selection operation location of the result of the first shift operation, writing each first target element included in the result of the first shift operation into a lower half of the destination register at a location where the first target element is located; writing the second shift operation result to a corresponding storage location in the destination register in response to a bit selection operation location of the second shift operation result, 11. The vector shifting method according to claim 10, further comprising the step of writing each second target element included in the result of the second shift operation into a high-order half of a location in the destination register where the each second target element is located.
14. the second type vector opcode is an eighth vector opcode, the first operand is data consisting of successive lower halves of elements of the first source register, the second operand is data consisting of successive lower halves of elements of the second source register, the third operand is data consisting of successive upper halves of elements of the first source register, and the fourth operand is data consisting of successive upper halves of elements of the second source register; performing a shift, round and saturate to half width operation on each element in the second splice vector according to the immediate number to generate a second initial shift operation result, and performing a shift, round and saturate to half width operation on each element in the third splice vector according to the immediate number to generate a third initial shift operation result, performing a right arithmetic shift with rounding and unsigned saturation to half-width on each source element in the second splice vector according to the immediate number to generate a second initial shift operation result; performing a right arithmetic shift with rounding and unsigned saturation to half-width on each source element in the third splice vector according to the immediate number to generate a third initial shift operation result; performing a bit selection operation on the second initial shift operation result to generate a second shift operation result, and performing a bit selection operation on the third initial shift operation result to generate a third shift operation result, a step of selecting successive lower half data of each element included in the second initial shift operation result and determining the selected data as a first shift operation result, and selecting successive upper half data of each element included in the third initial shift operation result and determining the selected data as a second shift operation result, wherein at least one first target element is determined according to data included in the first shift operation result, and at least one second target element is determined according to elements included in the second shift operation result, writing the result of the first shift operation to a corresponding storage location in the destination register in response to a bit selection operation location of the result of the first shift operation, writing each first target element included in the result of the first shift operation into a lower half of the destination register at a location where the first target element is located; writing the second shift operation result to a corresponding storage location in the destination register in response to each first target element included in a bit selection operation position of the second shift operation result, 11. The vector shifting method according to claim 10, further comprising the step of writing each second target element included in the result of the second shift operation into a high-order half of a location in the destination register where the each second target element is located.
15. 4. The vector shifting method according to claim 3, wherein the instruction further includes a shift amount register identifier for indicating a shift amount register that is a register for storing the shift amount.
16. the opcode is a third type vector opcode, and the source registers include a first source register; selecting a source element from the source registers according to the opcode to perform the vector shift operation, and determining the selected source element as an operand, performing a selection operation in the first source register according to the third type vector opcode to obtain a fifth operand, the selection operation including any one of an operation of selecting consecutive lower half data for each element of the first source register, an operation of selecting consecutive upper half data for each element of the first source register, an operation of selecting intermediate consecutive designated bits of data for each element of the first source register, and an operation of selecting non-consecutive designated bits of data for each element of the first source register; performing a corresponding shift operation on the operand according to the opcode to generate a shift operation result; performing a shift, round and half-width saturation operation on the fifth operand according to the third type vector opcode and the shift amount to generate a fourth initial shift operation result; and performing a bit selection operation on the fourth initial shift operation result to generate a shift operation result, wherein the bit selection operation includes any one of an operation of selecting consecutive lower half data for each element included in the fourth initial shift operation result, an operation of selecting consecutive upper half data for each element included in the fourth initial shift operation result, an operation of selecting consecutive designated bit data in the middle for each element included in the fourth initial shift operation result, and an operation of selecting non-consecutive designated bit data for each element included in the fourth initial shift operation result, Storing the target element in the destination register according to the storage configuration comprises: writing the data in the shift operation result sequentially to corresponding locations in the destination register; and setting a value of the location in the destination register to which data is not written in accordance with the third type vector opcode.
17. the third type vector opcode is a ninth vector opcode, the fifth operand being any successive source elements of the first source register; performing a shift, round, and half-width saturation operation on the fifth operand according to the third type vector opcode and the shift amount to generate a fourth initial shift operation result, performing a right logical shift, rounding, and signed saturation to half-width on each element included in the fifth operand according to the shift amount to generate a fourth initial shift operation result; performing a bit selection operation on the fourth initial shift operation result to generate a shift operation result, selecting successive lower half elements of each element included in the fourth initial shift operation result, and determining the selected elements as a shift operation result; The step of sequentially writing the data in the shift operation result to the corresponding positions in the destination register and setting the values of the positions in the destination register to which the data has not been written in accordance with the third type vector opcode, Dividing storage locations in a destination register according to a preset value to determine a storage area for each target element; writing the data resulting from the shift operation into the lower half of each storage area in sequence; 17. The vector shift method according to claim 16, further comprising the step of: setting values of positions in each storage area to which no data is written to zero.
18. the third type vector opcode is a tenth vector opcode, the fifth operand is any successive source element of the first source register; performing a shift, round, and half-width saturation operation on the fifth operand according to the third type vector opcode and the shift amount to generate a fourth initial shift operation result, performing a right arithmetic shift, rounding, and signed saturation to half-width on each element included in the fifth operand according to the shift amount to generate a fourth initial shift operation result; performing a bit selection operation on the fourth initial shift operation result to generate a shift operation result, selecting successive lower half elements of each element included in the fourth initial shift operation result, and determining the selected elements as a shift operation result; The step of sequentially writing the data in the shift operation result to the corresponding positions in the destination register and setting the values of the positions in the destination register to which the data has not been written in accordance with the third type vector opcode, Dividing storage locations in a destination register according to a preset value to determine a storage area for each target element; writing the data resulting from the shift operation into the lower half of each storage area in sequence; 17. The vector shift method according to claim 16, further comprising the step of: setting values of positions in each storage area to which no data is written to zero.
19. the third type vector opcode is an eleventh vector opcode, the fifth operand being any successive source elements of the first source register; performing a shift, round, and half-width saturation operation on the fifth operand according to the third type vector opcode and the shift amount to generate a fourth initial shift operation result, performing a right logical shift, rounding, and unsigned saturation to half-width on each element included in the fifth operand according to the shift amount to generate a fourth initial shift operation result; performing a bit selection operation on the fourth initial shift operation result to generate a shift operation result, selecting consecutive lower half elements of each element included in the fourth initial shift operation result, and determining the selected elements as a shift operation result; The step of sequentially writing the data in the shift operation result to the corresponding positions in the destination register and setting the values of the positions in the destination register to which the data has not been written in accordance with the third type vector opcode, Dividing storage locations in a destination register according to a preset value to determine a storage area for each target element; writing the data resulting from the shift operation into the lower half of each storage area in sequence; 17. The vector shift method according to claim 16, further comprising the step of: setting values of positions in each storage area to which no data is written to zero.
20. the third type vector opcode is a twelfth vector opcode, the fifth operand is any successive source element of the first source register; performing a shift, round, and half-width saturation operation on the fifth operand according to the third type vector opcode and the shift amount to generate a fourth initial shift operation result, performing an arithmetic right shift, rounding, and unsigned saturation to half-width on each element included in the fifth operand according to the shift amount to generate a fourth initial shift operation result; performing a bit selection operation on the fourth initial shift operation result to generate a shift operation result, selecting successive lower half elements of each element included in the fourth initial shift operation result, and determining the selected elements as a shift operation result; The step of sequentially writing the data in the shift operation result to the corresponding positions in the destination register and setting the values of the positions in the destination register to which the data has not been written in accordance with the third type vector opcode, Dividing storage locations in a destination register according to a preset value to determine a storage area for each target element; writing the data resulting from the shift operation into the lower half of each storage area in sequence; 17. The vector shift method according to claim 16, further comprising the step of: setting values of positions in each storage area to which no data is written to zero.
21. The vector shift method according to any one of claims 1 to 3 and 16 to 20, characterized in that the number of source registers is one or more, the number of destination registers is one, and the source register identifier is the same as or different from the destination register identifier.
22. the number of said source registers is a plurality, the number of said destination registers is one, The vector shift method according to any one of claims 1 to 15, characterized in that each source register identifier in all the source registers is different from the destination register identifier, or there is one source register identifier in all the source registers that is the same as the destination register identifier.
23. 1. A processor including a plurality of vector registers, an instruction decode unit, and an execution unit, the plurality of vector registers includes a source register for storing source elements to be operated on when performing a vector shift operation, and a destination register; the instruction decode unit is for decoding a vector shift instruction including a register identifier and a shift parameter, the register identifier including a source register identifier for indicating a source register and a destination register identifier for indicating a destination register; the execution unit is responsive to the vector shift instruction to perform a vector shift operation on a source element obtained from the source register according to the shift parameters, obtain a target element after the vector shift operation, and write the target element to the destination register.
24. 24. The processor of claim 23, wherein the execution unit determines a shift amount and a shift operation rule according to the shift parameters, where there is at least one source element on which a vector shift operation is performed, performs a corresponding shift operation on a source element in the source register according to the shift amount and the shift operation rule, generates a shift operation result, and determines the shift operation result as a target element.
25. the shift parameters include a shift amount and an opcode, the shift amount being for indicating a number of shift bits of a source element to be operated when the vector shift operation is performed, and the opcode being for indicating a shift operation rule to be performed on a source element in the source register and a target element in a destination register; 25. The processor of claim 24, wherein the execution unit selects a source element from among the source registers on which to perform the vector shift operation in accordance with the opcode, determines the selected source element as an operand, performs a corresponding shift operation on the operand in accordance with the opcode to generate a shift operation result, determines a storage format of the target element in the destination register in accordance with the opcode, and stores the target element in the destination register in accordance with the storage format.
26. 26. The processor of claim 25, wherein the shift amount is an immediate number, and the source registers include a first source register and a second source register.
27. the opcode is a first type vector opcode; the execution unit determines all source elements in a first source register as one operand and all source elements in a second source register as operands according to the first type vector opcode; generating a first splice vector after splicing an operand in the first source register and an operand in the second source register according to a vector opcode of the first type; performing a shift, round and saturate to half-width operation on each source element in the first splice vector according to the immediate number to generate a first initial shift operation result; 27. The processor of claim 26, further comprising: performing a bit selection operation on the first initial shift operation result to generate a shift operation result, wherein the bit selection operation includes any one of an operation of selecting consecutive lower half data for each element included in the first initial shift operation result, an operation of selecting consecutive upper half data for each element included in the first initial shift operation result, an operation of selecting data of intermediate consecutive designated bits for each element included in the first initial shift operation result, and an operation of selecting data of non-consecutive designated bits for each element included in the first initial shift operation result.
28. the first type vector opcode is a first vector opcode; the execution unit performs a right logical shift with rounding and signed saturation to half-width operation on each source element in the first splice vector according to the immediate number to generate a first initial shift operation result; 28. The processor according to claim 27, further comprising: selecting consecutive lower half data of each element included in the first initial shift operation result; and determining the element after the selection operation as the shift operation result.
29. the first type vector opcode is a second vector opcode; The execution unit performs a right arithmetic shift with rounding and signed saturation to half-width on each source element in the first splice vector according to the immediate number to generate a first initial shift operation result; 28. The processor according to claim 27, further comprising: selecting consecutive lower half data of each element included in the first initial shift operation result; and determining the element after the selection operation as the shift operation result.
30. the first type vector opcode is a third vector opcode; The execution unit performs a right logical shift with rounding and unsigned saturation to half-width on each source element in the first splice vector according to the immediate number to generate a first initial shift operation result; 28. The processor according to claim 27, further comprising: selecting consecutive lower half data of each element included in the first initial shift operation result; and determining the element after the selection operation as the shift operation result.
31. the first type vector opcode is a fourth vector opcode; The execution unit performs a right arithmetic shift with rounding and unsigned saturation to half-width on each source element in the first splice vector according to the immediate number to generate a first initial shift operation result; 28. The processor according to claim 27, further comprising: selecting consecutive lower half data of each element included in the first initial shift operation result; and determining the element after the selection operation as the shift operation result.
32. the opcode is a second type vector opcode; the execution unit performs a selection operation on a first source register and a second source register, respectively, according to the second type vector opcode to obtain a first operand and a second operand, wherein the selection operation includes any one of an operation of selecting consecutive lower half data for each element of the first source register and the second source register, an operation of selecting consecutive upper half data for each element of the first source register and the second source register, an operation of selecting intermediate consecutive designated bits of data for each element of the first source register and the second source register, and an operation of selecting non-consecutive designated bits of data for each element of the first source register and the second source register; The execution unit also includes: determining data in the first source register other than the first operand as a third operand, and determining data in the second source register other than the second operand as a fourth operand; generating a second splice vector after splicing the first operand and the second operand, and generating a third splice vector after splicing the third operand and the fourth operand, where the data types of elements included in the second splice vector and the third splice vector are halfword, word, doubleword, or quadword; performing a shift, round and saturate to half width operation on each element in the second splice vector according to the immediate number to generate a second initial shift operation result; and performing a shift, round and saturate to half width operation on each element in the third splice vector according to the immediate number to generate a third initial shift operation result; performing a bit selection operation on the second initial shift operation result to generate a first shift operation result; and performing a bit selection operation on the third initial shift operation result to generate a second shift operation result, wherein the performed bit selection operation includes any one of an operation of selecting consecutive lower half data for each element included in the second initial shift operation result and each element included in the third initial shift operation result, an operation of selecting consecutive upper half data for each element included in the second initial shift operation result and each element included in the third initial shift operation result, an operation of selecting consecutive designated bit data in the middle for each element included in the second initial shift operation result and each element included in the third initial shift operation result, and an operation of selecting non-consecutive designated bit data for each element included in the second initial shift operation result and each element included in the third initial shift operation result; writing the result of the first shift operation to a corresponding storage location in the destination register in response to a bit selection operation position of the result of the first shift operation; 27. The processor of claim 26, further comprising: writing the result of the second shift operation to a corresponding memory location in the destination register in response to a bit selection operation position of the result of the second shift operation.
33. the second type vector opcode is a fifth vector opcode, the first operand is data consisting of successive lower halves of elements of the first source register, the second operand is data consisting of successive lower halves of elements of the second source register, the third operand is data consisting of successive upper halves of elements of the first source register, and the fourth operand is data consisting of successive upper halves of elements of the second source register; the execution unit performs a right logical shift with rounding and signed saturation to half-width on each element in the second splice vector according to the immediate number to generate a second initial shift operation result; and performs a right logical shift with rounding and signed saturation to half-width on each element in the third splice vector according to the immediate number to generate a third initial shift operation result; selecting successive lower half data of each element included in the second initial shift operation result, and determining the selected data as a first shift operation result, and selecting successive upper half data of each element included in the third initial shift operation result, and determining the selected data as a second shift operation result, wherein at least one first target element is determined according to the data included in the first shift operation result, and at least one second target element is determined according to the elements included in the second shift operation result, writing each first target element included in the result of the first shift operation into a lower half of the destination register at a position where each first target element is located; 33. The processor of claim 32, further comprising: a processor operable to write each second target element included in the result of the second shift operation into a high-order half of the destination register at a location where the second target element is located.
34. the second type vector opcode is a sixth vector opcode, the first operand is data consisting of successive lower halves of elements of the first source register, the second operand is data consisting of successive lower halves of elements of the second source register, the third operand is data consisting of successive upper halves of elements of the first source register, and the fourth operand is data consisting of successive upper halves of elements of the second source register; the execution unit performs a right arithmetic shift with rounding and signed saturation to half-width on each element in the second splice vector according to the immediate number to generate a second initial shift operation result; and performs a right arithmetic shift with rounding and signed saturation to half-width on each element in the third splice vector according to the immediate number to generate a third initial shift operation result; selecting successive lower half data of each element included in the second initial shift operation result, and determining the selected data as a first shift operation result, and selecting successive upper half data of each element included in the third initial shift operation result, and determining the selected data as a second shift operation result, wherein at least one first target element is determined according to the data included in the first shift operation result, and at least one second target element is determined according to the elements included in the second shift operation result, writing each second target element included in the result of the first shift operation into a lower half of the destination register at a position where each second target element is located; 33. The processor of claim 32, further comprising: writing each first target element included in the result of the second shift operation into a high-order half of the destination register at a location where the first target element is located.
35. the second type vector opcode is a seventh vector opcode, the first operand is data consisting of successive lower halves of elements of the first source register, the second operand is data consisting of successive lower halves of elements of the second source register, the third operand is data consisting of successive upper halves of elements of the first source register, and the fourth operand is data consisting of successive upper halves of elements of the second source register; the execution unit performs a right logical shift with rounding and unsigned saturation to half-width on each element in the second splice vector according to the immediate number to generate a second initial shift operation result; performing a right logical shift with rounding and unsigned saturation to half-width on each element in the third splice vector according to the immediate number to generate a third initial shift operation result; selecting successive lower half data of each element included in the second initial shift operation result, and determining the selected data as a first shift operation result, and selecting successive upper half data of each element included in the third initial shift operation result, and determining the selected data as a second shift operation result, wherein at least one first target element is determined according to the data included in the first shift operation result, and at least one second target element is determined according to the elements included in the second shift operation result, writing each first target element included in the result of the first shift operation into a lower half of the destination register at a position where each first target element is located; 33. The processor of claim 32, further comprising: a processor operable to write each second target element included in the result of the second shift operation into a high-order half of the destination register at a location where the second target element is located.
36. the second type vector opcode is an eighth vector opcode, the first operand is data consisting of successive lower halves of elements of the first source register, the second operand is data consisting of successive lower halves of elements of the second source register, the third operand is data consisting of successive upper halves of elements of the first source register, and the fourth operand is data consisting of successive upper halves of elements of the second source register; The execution unit performs a right arithmetic shift with rounding and unsigned saturation to half-width on each element in the second splice vector according to the immediate number to generate a second initial shift operation result; performing a right arithmetic shift with rounding and unsigned saturation to half-width on each element in the third splice vector according to the immediate number to generate a third initial shift operation result; selecting successive lower half data of each element included in the second initial shift operation result, and determining the selected data as a first shift operation result, and selecting successive upper half data of each element included in the third initial shift operation result, and determining the selected data as a second shift operation result, wherein at least one first target element is determined according to the data included in the first shift operation result, and at least one second target element is determined according to the elements included in the second shift operation result, writing each first target element included in the result of the first shift operation into a lower half of the destination register at a position where each first target element is located; 33. The processor of claim 32, further comprising: a processor operable to write each second target element included in the result of the second shift operation into a high-order half of the destination register at a location where the second target element is located.
37. 26. The processor of claim 25, wherein the instruction further comprises a shift amount register identifier for indicating a shift amount register, the shift amount register being a register that stores a shift amount.
38. the opcode is a third type vector opcode, and the source registers include a first source register; the execution unit performs a selection operation on the first source register in accordance with the third type vector opcode to obtain a fifth operand, wherein the selection operation includes any one of an operation of selecting consecutive lower half data for each element of the first source register, an operation of selecting consecutive upper half data for each element of the first source register, an operation of selecting intermediate consecutive designated bits of data for each element of the first source register, and an operation of selecting non-consecutive designated bits of data for each element of the first source register; performing a shift, round, and half-width saturation operation on the fifth operand according to the third type vector opcode and the shift amount to generate a fourth initial shift operation result; performing a bit selection operation on the fourth initial shift operation result to generate a shift operation result, wherein the bit selection operation includes any one of an operation of selecting consecutive lower half data for each element included in the fourth initial shift operation result, an operation of selecting consecutive upper half data for each element included in the fourth initial shift operation result, an operation of selecting consecutive designated bit data in the middle for each element included in the fourth initial shift operation result, and an operation of selecting non-consecutive designated bit data for each element included in the fourth initial shift operation result; Sequentially writing the data in the shift operation result to corresponding positions in the destination register; 38. The processor of claim 37, further comprising: a processor operable to set a value of the unwritten location in the destination register in response to the third type vector opcode.
39. the third type vector opcode is a ninth vector opcode, the fifth operand being any successive source elements of the first source register; the execution unit performs a right logical shift, rounding, and signed saturation to half-width on each element included in the fifth operand according to the shift amount to generate a fourth initial shift operation result; Selecting consecutive lower half elements of each element included in the fourth initial shift operation result, and determining the selected elements as a shift operation result; Dividing the storage locations in the destination register according to a preset value to determine a storage area for each target element; The data in the shift operation result is written sequentially into the lower half of each storage area; 39. The processor of claim 38, further comprising: setting the value of each of the locations in each storage area to which no data has been written to zero.
40. the third type vector opcode is a tenth vector opcode, the fifth operand is any successive source element of the first source register; the execution unit performs a right arithmetic shift, rounding, and signed saturation to half-width on each element included in the fifth operand according to the shift amount to generate a fourth initial shift operation result; Selecting consecutive lower half elements of each element included in the fourth initial shift operation result, and determining the selected elements as a shift operation result; Dividing the storage locations in the destination register according to a preset value to determine a storage area for each target element; The data in the shift operation result is written sequentially into the lower half of each storage area; 39. The processor of claim 38, further comprising: setting the value of each of the locations in each storage area to which no data has been written to zero.
41. the third type vector opcode is an eleventh vector opcode, the fifth operand being any successive source elements of the first source register; the execution unit performs a right logical shift, rounding, and unsigned saturation to half-width on each element included in the fifth operand according to the shift amount to generate a fourth initial shift operation result; Selecting consecutive lower half elements of each element included in the fourth initial shift operation result, and determining the selected elements as a shift operation result; Dividing the storage locations in the destination register according to a preset value to determine a storage area for each target element; The data in the shift operation result is written sequentially into the lower half of each storage area; 39. The processor of claim 38, further comprising: setting the value of each of the locations in each storage area to which no data has been written to zero.
42. the third type vector opcode is a twelfth vector opcode, the fifth operand is any successive source element of the first source register; the execution unit performs a right arithmetic shift, rounding, and unsigned saturation to half-width on each element included in the fifth operand according to the shift amount to generate a fourth initial shift operation result; Selecting consecutive lower half elements of each element included in the fourth initial shift operation result, and determining the selected elements as a shift operation result; Dividing the storage locations in the destination register according to a preset value to determine a storage area for each target element; The data in the shift operation result is written sequentially into the lower half of each storage area; 39. The processor of claim 38, further comprising: setting the value of each of the locations in each storage area to which no data has been written to zero.
43. The processor of any one of claims 23 to 25 and 38 to 42, wherein the number of source registers is one or more, the number of destination registers is one, and the source register identifier is the same as or different from the destination register identifier.
44. the number of said source registers is a plurality, the number of said destination registers is one, 38. The processor of claim 23, wherein each source register identifier in all of the source registers is different from the destination register identifier, or there is one source register identifier in all of the source registers that is the same as the destination register identifier.
45. An electronic device comprising a memory and one or more programs, the one or more programs being stored in the memory and configured to execute, by one or more processors, one or more of the vector shifting methods according to claims 1 to 22.
Citation Information
Patent Citations
Vector Frequency Compress Instruction
CN104011673A
Apparatus and method for right shifting packed quadwords and extracting packed doublewords
CN109947697A
Data shifting method, device and equipment and computer readable storage medium
CN110221807A
Multiplexing operation for SIMD processing
JP2005174297A
Vector arithmetic and logical instructions performing operations on different first and second data element widths from corresponding first and second vector registers
US11003447B2
