COMMAND CONVERSION SUPPORT PROGRAM, COMMAND CONVERSION SUPPORT METHOD, AND INFORMATION PROCESSING APPARATUS
The instruction conversion support program automates the conversion between complex and simple instruction sets using table data, reducing developer burden and minimizing errors, thus facilitating efficient conversion.
Patent Information
- Application Number
- JP2021074348
- Authority / Receiving Office
- JP · JP
- Patent Type
- Patents
- Current Assignee / Owner
- Priority Date
- 2020-05-22
- Filing Date
- 2021-04-26
- Publication Date
- 2024-11-20
- Estimated Expiration
- 2041-04-26
AI Technical Summary
Converting complex instruction sets to simple instruction sets is burdensome for developers due to the need to manually analyze and manually modify conversion programs for varying operand types and instruction sets, especially when expanding the instruction set.
An instruction conversion support program and method that uses table data to define operand patterns and corresponding instructions, automating the generation of conversion programs to reduce the manual effort required, allowing developers to efficiently convert between different instruction sets.
Reduces the implementation burden on developers by automating the conversion process, minimizing errors, and enabling seamless conversion between complex and simple instruction sets without manual code writing, even when the instruction set is expanded.
Smart Images

Figure 0007587152000001 
Figure 0007587152000002 
Figure 0007587152000003
Abstract
Description
[Technical field]
[0001] The present invention relates to an instruction conversion support program, an instruction conversion support method, and an information processing device. [Background technology]
[0002] A user of an information processing system may want to run an existing program for a processor with one instruction set on another processor with another instruction set. For example, the user may want to run an existing program developed for a small computer on a large computer. In this case, if the source code written in a high-level programming language is available as the existing program, the user can compile the source code using a compiler for the other processor to generate an executable file for the other processor.
[0003] However, for existing programs, the executable file for the original processor may be available, but the source code may not. In such cases, a possible approach is to convert the assembly code for the original instruction set into assembly code or machine code for the other instruction set. Assembly code is written in assembly language, a low-level programming language. Assembly code instructions have a one-to-one correspondence with machine code instructions that the processor can interpret. For each combination of source and target instruction sets, a conversion program is implemented to convert the assembly code instructions.
[0004] A program conversion device has been proposed that generates source code for processor B from object code for processor A. The proposed program conversion device replaces a given instruction in the object code with a built-in function for processor B.
[0005] A conversion method has been proposed that uses native binding to replace calls to target system library functions in an executable file with calls to native system library functions.Another proposed instruction recombination method is to insert a transfer instruction that jumps to the beginning of an instruction recombination library before the end of a machine language instruction segment and rewrite the value of an address register included in a processor context. [Prior art documents] [Patent documents]
[0006] [Patent Document 1] JP 2008-276735 A [Patent Document 2] JP 2011-123917 A [Patent Document 3] International Publication No. 2012 / 145917 Summary of the Invention [Problem to be solved by the invention]
[0007] The source instruction set may include compound instructions capable of expressing complex operations, such as the so-called CISC (Complex Instruction Set Computer). The instruction length of the compound instruction may be variable. Even instructions of the same type with the same mnemonic may have different types of operands (arguments). Different types of operands may include, for example, a different number of operands, a different type of memory area specified by the operands, or a different data length of the memory area specified by the operands.
[0008] On the other hand, the target instruction set may be composed of simple instructions that can only express simple operations, such as in the case of a so-called RISC (Reduced Instruction Set Computer). When converting from a complex instruction set to a simple instruction set, it may be difficult to express an operation equivalent to an instruction in the source instruction set with a single instruction in the target instruction set. Therefore, one instruction in the pre-conversion assembly code may correspond to a combination of two or more instructions in the post-conversion assembly code or machine code.
[0009] Here, when implementing a conversion program that converts a complex instruction set into a simple instruction set, there is a problem that the burden on the developer who implements the conversion program is large. For example, the conversion program analyzes the mnemonics of the instructions before conversion as well as the operands of the instructions, and outputs different combinations of converted instructions depending on the types of operands. Creating such a conversion program manually places a large burden on the developer. In addition, every time the source instruction set is expanded, the conversion program must be manually revised.
[0010] In one aspect, the present invention aims to provide an instruction conversion support program, an instruction conversion support method, and an information processing device that reduce the burden of implementing a conversion program for converting instructions between different instruction sets. [Means for solving the problem]
[0011] In one embodiment, an instruction conversion support program is provided that causes a computer to execute the following process: accept table data indicating a correspondence relationship between a plurality of operand patterns indicating types of operands that may be included in a first instruction used in a first assembly language and a plurality of second instructions used in a second assembly language or a machine language corresponding to the second assembly language, the table data associating two or more of the plurality of second instructions with each operand pattern; generate, based on the table data, a conversion program for converting a first code written in the first assembly language into a second code written in the second assembly language or machine language, the conversion program defining a process of determining an operand pattern of an instruction included in the first code and outputting two or more instructions of the second code corresponding to the determined operand pattern.
[0012] In one aspect, a command conversion support method executed by a computer is provided.In another aspect, an information processing device having a storage unit and a processing unit is provided. Effect of the Invention
[0013] On the one hand, it reduces the burden of implementing a translator to translate instructions between different instruction sets. The above and other objects, features and advantages of the present invention will become apparent from the following description taken in conjunction with the accompanying drawings illustrating preferred embodiments of the present invention. [Brief description of the drawings]
[0014] [Figure 1] FIG. 1 is a diagram illustrating an information processing device according to a first embodiment. [Diagram 2] FIG. 11 illustrates an example of hardware of an information processing apparatus according to a second embodiment. [Diagram 3] FIG. 13 is a diagram illustrating an example of a data flow for program porting. [Figure 4] 1A and 1B are diagrams illustrating examples of assembly code before and after conversion. [Diagram 5]FIG. 13 illustrates an example of a conversion program. [Figure 6] FIG. 13 is a diagram illustrating an example of a pattern table. [Figure 7] FIG. 13 is a diagram showing an example of a pattern table (continued 1). [Figure 8] FIG. 2 is a diagram showing an example of a pattern table (continued 2). [Figure 9] FIG. 3 is a diagram showing an example of a pattern table (continued 3). [Figure 10] FIG. 13 is a diagram illustrating an example of a data flow for generating a conversion function. [Figure 11] FIG. 13 is a diagram showing a first example of a conversion function program. [Figure 12] FIG. 13 is a diagram showing a preview example of a conversion function program. [Figure 13] FIG. 13 is a diagram showing a second example of a conversion function program. [Figure 14] FIG. 13 is a diagram illustrating an example of simplifying an operand condition. [Figure 15] FIG. 13 is a diagram (continued) showing an example of simplification of an operand condition. [Figure 16] FIG. 2 is a block diagram showing an example of functions of the information processing device; [Figure 17] 13 is a flowchart showing a first example of a procedure for generating a conversion function. [Figure 18] 13 is a flowchart showing a second example of a procedure for generating a conversion function. [Figure 19] 13 is a flowchart (continuation 1) showing a second example of the procedure for generating a conversion function. [Figure 20] 13 is a flowchart (continued 2) showing a second example of a procedure for generating a conversion function. [Figure 21] 13 is a flowchart showing an example of a procedure for converting an executable file. [Figure 22] FIG. 13 is a diagram illustrating an example of an instruction set having different vector lengths. [Figure 23] FIG. 13 is a diagram illustrating an example of use of a SIMD register. [Figure 24] FIG. 13 is a diagram illustrating an example of conversion of vector lengths into instructions of an instruction set having a different length. [Diagram 25]FIG. 13 is a diagram showing a first modified example of the pattern table. [Figure 26] FIG. 13 is a diagram (continuation) showing a first modified example of the pattern table. [Figure 27] 13 is a flowchart showing a third example of a procedure for generating a conversion function. [Figure 28] FIG. 13 is a diagram showing a second modified example of the pattern table. [Figure 29] FIG. 13 is a diagram (continuation) showing a second modified example of the pattern table. [Diagram 30] FIG. 13 is a diagram illustrating an example of a library function of a conversion function program. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS
[0015] The present embodiment will be described below with reference to the drawings. [First embodiment] A first embodiment will be described.
[0016] FIG. 1 is a diagram illustrating an information processing apparatus according to a first embodiment. The information processing device 10 of the first embodiment generates, from table data, a conversion program for converting code written in a certain assembly language into code written in another assembly language or a machine language corresponding to the other assembly language. The generated conversion program may be executed by the information processing device 10 or another information processing device. The information processing device 10 may be a client device or a server device. The information processing device 10 may be called a computer, an instruction conversion support device, or the like.
[0017] The information processing device 10 has a storage unit 11 and a processing unit 12. The storage unit 11 may be a volatile semiconductor memory such as a random access memory (RAM). The storage unit 11 may also be a non-volatile storage such as a hard disk drive (HDD) or a flash memory. The processing unit 12 is a processor such as a central processing unit (CPU), a graphics processing unit (GPU), or a digital signal processor (DSP). The processing unit 12 may include an electronic circuit for a specific purpose such as an application specific integrated circuit (ASIC) or a field programmable gate array (FPGA). The processor executes a program stored in a memory such as a RAM (which may be the storage unit 11). A set of multiple processors may be called a "multiprocessor" or simply a "processor".
[0018] The storage unit 11 stores table data 13. The table data 13 indicates a correspondence between a plurality of operand patterns of a source assembly language and a plurality of instructions of a destination assembly language or machine language. An assembly language is a low-level programming language that defines assembly instructions that correspond one-to-one to machine language instructions that a processor can interpret. The source assembly language corresponds to a processor having a complex instruction set, such as a so-called CISC processor. The destination assembly language or machine language corresponds to a processor having a relatively simple instruction set, such as a so-called RISC processor.
[0019] However, the information processing device 10 of the first embodiment is not limited to the process of converting the instruction of a CISC processor into the instruction of a RISC processor. This embodiment can be easily applied to the case where it is desired to convert the assembly code of a RISC processor into the assembly code of a CISC processor. Since the instruction set of a CISC processor includes an instruction that performs a simple process similar to that of a RISC processor, it is possible to convert the instruction of a RISC processor into an instruction of a CISC processor and execute it. Also, in order to increase the processing performance per clock, even a RISC processor is equipped with an instruction that can perform complex processing with one instruction. In this case, one instruction of a RISC processor can be converted into multiple instructions of a CISC processor.
[0020] The operand patterns include operand patterns 13a, 13b, and 13c. The operand patterns 13a, 13b, and 13c each indicate a type of operand that may be included in the instruction X1 used in the assembly language of the source. The instruction X1 may be a compound instruction representing a complex operation, and the type of operand may be different even for the same instruction X1. For example, the instruction length of the instruction X1 may be different. Also, for example, the number of operands of the instruction X1 may be different. Also, for example, the type of memory area indicated by the operand of the instruction X1 may be different, such as the difference between a register and a main memory or the difference in the type of register. Also, the data length of the data indicated by the operand of the instruction X1 may be different, such as 128 bits, 256 bits, and 512 bits. The instruction X1 may be a vector operation instruction that executes the same type of operation in parallel on multiple unit data (words).
[0021] In the example of Fig. 1, operand pattern 13a indicates that the second operand points to a register and has a data length of 128 bits. Operand pattern 13b indicates that the second operand points to a register and has a data length of 256 bits. Operand pattern 13c indicates that the second operand points to a storage area in main memory and has a data length of 128 bits.
[0022] The multiple instructions used in the converted assembly language or machine language include instructions Y1, Y2, Y3, Y4, and Y5. The instructions Y1, Y2, Y3, Y4, and Y5 are simple instructions that represent relatively simple operations. For example, the instructions Y1, Y2, Y3, Y4, and Y5 have the same instruction length. Also, for example, a simple instruction that represents an operation between two data does not include an operand that points to a main memory. Also, for example, the instructions Y1, Y2, Y3, Y4, and Y5 have the same data length of the operand. Also, for example, the instructions Y1, Y2, Y3, Y4, and Y5 do not include a vector operation instruction.
[0023] However, it is difficult to express an operation equivalent to one compound instruction with one simple instruction. In many cases, one compound instruction is equivalent to a combination of two or more simple instructions. Therefore, the table data 13 associates two or more instructions from among instructions Y1, Y2, Y3, Y4, and Y5 with each of the operand patterns 13a, 13b, and 13c.
[0024] The table data 13 is matrix-type data including, for example, a plurality of rows corresponding to the operand patterns 13a, 13b, and 13c, and a plurality of columns corresponding to the instructions Y1, Y2, Y3, Y4, and Y5. For example, one flag is placed at the intersection of one row and one column. The flag indicates whether or not the instruction corresponding to that column is used in converting the instruction X1 having the operand pattern corresponding to that row. For example, if the instruction is used, the flag=1 is written. The table data 13 is created, for example, by a developer who develops a conversion program. The table data 13 may be created using spreadsheet software.
[0025] 1, instructions Y2 and Y5 are associated with operand pattern 13a. Instructions Y3 and Y5 are associated with operand pattern 13b. Instructions Y1, Y2, and Y5 are associated with operand pattern 13c. A developer can define the above correspondences by entering "1" in cells (1,2), (1,5), (2,3), (2,5), (3,1), (3,2), and (3,5).
[0026] The processing unit 12 generates a conversion program 14 based on the table data 13. The conversion program 14 is software for converting a code 15 written in a source assembly language into a code 16 written in a destination assembly language or machine language. The code 15 is assembly code. The code 16 is assembly code or machine code. The processing unit 12 generates, for example, source code for the conversion program 14. The source code may be written in a high-level programming language such as C.
[0027] Here, the processing unit 12 analyzes the table data 13 and generates a conversion program 14 so that an instruction in a destination assembly language or machine language is output according to the correspondence relationship defined in the table data 13. The conversion program 14 specifies a process of determining an operand pattern of an instruction X1 included in the code 15 and outputting two or more instructions associated with the determined operand pattern. The processing unit 12 may implement a determination process of determining whether or not a combination of two or more specific instructions is satisfied by scanning the table data 13 horizontally and determining a condition for outputting the combination of two or more specific instructions, and an output process of outputting the combination of two or more specific instructions. The processing unit 12 may also implement a determination process of determining whether or not a condition for outputting one specific specific instruction is satisfied by scanning the table data 13 vertically and determining a condition for outputting one specific specific instruction, and an output process of determining whether or not the determined condition is satisfied, and an output process of outputting the one specific specific instruction.
[0028] In the example of FIG. 1, code 15 includes instruction X1, and the operand included in instruction X1 satisfies operand pattern 13c. In table data 13, instructions Y1, Y2, and Y5 are associated with operand pattern 13c. Therefore, instructions Y1, Y2, and Y5 are inserted into code 16. Note that processing unit 12 may generate conversion program 14 so that two or more instructions associated with one operand pattern are output in order from the left column to the right column of table data 13. In this case, table data 13 also represents the order of instructions after conversion.
[0029] According to the information processing device 10 of the first embodiment, table data 13 is created which indicates the correspondence between operand patterns 13a, 13b, and 13c of an instruction X1 in an assembly language as a source and instructions Y1, Y2, Y3, Y4, and Y5 in an assembly language or machine language as a destination. In the table data 13, a combination of two or more instructions is associated with one operand pattern. Then, based on the table data 13, a conversion program 14 is generated which converts the instruction X1 according to the correspondence indicated by the table data 13.
[0030] This allows the developer of the conversion program 14 to efficiently define the specifications of the conversion program 14 by using the table data 13. Then, once the developer creates the table data 13, he or she can implement the conversion program 14 without having to manually write the source code of the conversion program 14. This reduces the implementation burden of the conversion program 14. In particular, in the case of converting from a CISC type instruction set to a RISC type instruction set, where one compound instruction having a variety of operands is converted into a combination of simple instructions corresponding to the operands, the implementation burden of the conversion program 14 is reduced.
[0031] In addition, when the source instruction set is extended, the developer can implement the conversion program 14 corresponding to the extended instruction set by extending the table data 13 without having to manually modify the conversion program 14.
[0032] For example, assume that the instruction set is extended so that the mnemonics targeted by the table data 13 can be combined with new operand patterns. In this case, a row corresponding to the new operand pattern is added to the table data 13, and a flag is set only in the added row for the combination of simple instructions corresponding to this operand pattern. Also, if there is a shortage in the processing of the instruction to be converted in the existing instructions Y1, Y2, Y3, Y4, and Y5, it is sufficient to increase the number of columns of the converted instruction. In this case, the correspondence between the existing operand patterns 13a, 13b, and 13c and the converted instruction is not changed (the rows of the operand patterns 13a, 13b, and 13c do not need to be modified). Therefore, even if a description error occurs when adding a conversion process for a new operand pattern, it only causes a defect (conversion error) for the new operand pattern and does not affect the conversion process for the existing operand pattern. In other words, it is possible to independently check whether the conversion process is correct for each operand pattern, and this also reduces the implementation burden of the conversion program 14.
[0033] [Second embodiment] Next, a second embodiment will be described. The information processing device of the second embodiment generates a conversion program for converting assembly code of one instruction set (I instruction set) into assembly code of another instruction set (A instruction set) from table format data. The information processing device of the second embodiment also uses the generated conversion program to perform program porting for converting machine code of the I instruction set into machine code of the A instruction set. However, the generation of the conversion program and the execution of the conversion program can be performed by different information processing devices. The information processing device of the second embodiment may be a client device or a server device.
[0034] FIG. 2 illustrates an example of hardware of an information processing apparatus according to the second embodiment. The information processing device 100 has a CPU 101, a RAM 102, a HDD 103, a GPU 104, an input interface 105, a medium reader 106, and a communication interface 107. These units of the information processing device 100 are connected to a bus. The information processing device 100 corresponds to the information processing device 10 of the first embodiment. The CPU 101 corresponds to the processing unit 12 of the first embodiment. The RAM 102 or the HDD 103 corresponds to the storage unit 11 of the first embodiment.
[0035] The CPU 101 is a processor that executes program instructions. The CPU 101 loads at least a part of the programs and data stored in the HDD 103 into the RAM 102 and executes the programs. The CPU 101 may include multiple processor cores, and the information processing device 100 may include multiple processors. A set of multiple processors may be called a "multiprocessor" or simply a "processor."
[0036] The RAM 102 is a volatile semiconductor memory that temporarily stores programs executed by the CPU 101 and data used in calculations by the CPU 101. The information processing device 100 may include a type of memory other than a RAM, or may include multiple memories.
[0037] The HDD 103 is a non-volatile storage that stores software programs such as an OS (Operating System), middleware, and application software, as well as data. The information processing device 100 may include other types of storage, such as a flash memory or an SSD (Solid State Drive), or may include multiple storages.
[0038] The GPU 104 cooperates with the CPU 101 to generate an image and outputs the image to a display device 111 connected to the information processing device 100. Any type of display device can be used as the display device 111, such as a CRT (Cathode Ray Tube) display, a liquid crystal display (LCD), an organic electro-luminescence (OEL) display, or a projector. An output device other than the display device 111, such as a printer, may be connected to the information processing device 100.
[0039] The input interface 105 receives an input signal from an input device 112 connected to the information processing device 100. As the input device 112, any type of input device can be used, such as a mouse, a touch panel, a touch pad, or a keyboard. A plurality of types of input devices may be connected to the information processing device 100.
[0040] The medium reader 106 is a reading device that reads programs and data recorded on the recording medium 113. Any type of recording medium can be used as the recording medium 113, such as a magnetic disk such as a flexible disk (FD) or HDD, an optical disk such as a compact disc (CD) or a digital versatile disc (DVD), or a semiconductor memory. For example, the medium reader 106 copies the programs and data read from the recording medium 113 to another recording medium such as the RAM 102 or the HDD 103. The read program is executed by the CPU 101, for example. The recording medium 113 may be a portable recording medium, and may be used to distribute programs and data. The recording medium 113 and the HDD 103 may also be called computer-readable recording media.
[0041] The communication interface 107 is connected to a network 114 and communicates with other information processing devices via the network 114. The communication interface 107 may be a wired communication interface connected to a wired communication device such as a switch or a router, or a wireless communication interface connected to a wireless communication device such as a base station or an access point.
[0042] Next, we will explain the flow of program porting, where a user program developed for a CPU with an I instruction set is executed on a CPU with an A instruction set. For user programs, there may be cases where an executable file for the source CPU exists, but the source code written in a high-level programming language does not exist. In such cases, the executable file for the source CPU is converted into an executable file for the destination CPU.
[0043] FIG. 3 is a diagram showing an example of a data flow in program porting. The information processing device 100 acquires a machine code 131. The machine code 131 is written in a machine language that can be interpreted by a CPU having an I instruction set. The machine code 131 is included in an execution file for a CPU of the I instruction set. The information processing device 100 also acquires a disassembler 132. The disassembler 132 is software that converts machine code of the I instruction set into assembly code of the I instruction set. The disassembler 132 is provided, for example, by a CPU manufacturer.
[0044] The information processing device 100 inputs the machine code 131 to a disassembler 132, which converts the machine code 131 into an assembly code 133. The assembly code 133 is written in an assembly language of the I instruction set. The assembly language is a low-level programming language that improves readability by expressing the type of machine instruction and operands as character strings. There is a one-to-one correspondence between the machine instructions of the I instruction set and the assembly instructions of the I instruction set.
[0045] The information processing device 100 inputs the assembly code 133 into a conversion program 134 to convert the assembly code 133 into an assembly code 135. The assembly code 135 is written in an assembly language of the A instruction set. There is a one-to-one correspondence between the machine language instructions of the A instruction set and the assembly instructions of the A instruction set. The I instruction set corresponds to CISC, and the A instruction set corresponds to RISC. Therefore, one instruction of the assembly code 133 may be converted into two or more instructions of the assembly code 135.
[0046] As described later, the information processing device 100 generates a conversion program 134 in advance. A conversion program is prepared for each combination of a source assembly language and a destination assembly language. The information processing device 100 acquires an assembler 136. The assembler 136 is software that converts assembly code of the A instruction set into machine code of the A instruction set. The assembler 136 is provided by, for example, a CPU manufacturer.
[0047] The information processing device 100 inputs the assembly code 135 to the assembler 136 and converts the assembly code 135 into a machine code 137. The machine code 137 is written in a machine code that can be interpreted by a CPU having an A instruction set. The machine code 137 is included in an execution file for the CPU of the A instruction set. This allows the information processing device 100 to convert the machine code 131 for the I instruction set into the machine code 137 for the A instruction set. The conversion program 134 does not necessarily have to be used in combination with the disassembler 132 and the assembler 136.
[0048] FIG. 4 is a diagram showing an example of an assembly code before and after conversion. Assembly code 141 is written in an assembly language of the I instruction set. Assembly code 141 corresponds to assembly code 133 described above. Assembly code 142 is written in an assembly language of the A instruction set. Assembly code 142 corresponds to assembly code 135 described above.
[0049] The I instruction set corresponds to CISC. Therefore, the assembly code 141 includes compound instructions that represent complex operations. Specifically, the assembly code 141 includes four instructions: mov, add, sub, and vpmaxsd. The first instruction of the assembly code 141 is an instruction to store 64-bit data in a register. The fourth instruction of the assembly code 141 is an instruction to compare operand #1 (xmm14) and operand #2 (xmm15) in units of 32-bit words and store the larger word in operand #0 (xmm0). Operands #0, #1, and #2 are operands that represent a vector register with a data length of 128 bits, and the fourth instruction executes a comparison of four pairs of words and a storage of the four words.
[0050] In contrast, the A instruction set corresponds to RISC. Therefore, the assembly code 142 includes only simple instructions that represent simple operations. Specifically, the assembly code 142 includes 21 instructions, which is more than the assembly code 141. The instruction group 142a including 7 instructions corresponds to the first instruction of the assembly code 141. That is, an operation equivalent to the first instruction of the assembly code 141 is expressed by 7 instructions of the A instruction set. This is because, in the instruction group 142a, the storage of a word having a length of 64 bits is executed in four steps of 16 bits each. Also, the instruction group 142b including 12 instructions corresponds to the fourth instruction of the assembly code 141. That is, an operation equivalent to the fourth instruction of the assembly code 141 is expressed by 12 instructions of the A instruction set.
[0051] In assembly code 141, rN (N is a natural number from 0 to 15) represents a general-purpose register with register index N. In assembly code 142, xN (N is a natural number from 0 to 30) represents a general-purpose register with register index N. SP represents a stack pointer register. pN (N is a natural number from 0 to 15) represents a predicate register (mask register) with register index N. zN (N is a natural number from 0 to 31) represents a vector register with register index N.
[0052] Additionally, mov represents an instruction to copy data, add represents an instruction to add data, sub represents an instruction to subtract data, orr represents an instruction to perform a bitwise logical OR operation, str represents an instruction to read data from memory and set it in a register, and bitwise not represents an instruction to perform a logical negation operation. cmpge represents an instruction to compare each word in two vector registers and set the comparison result in a predicate register. cmpgt represents an instruction to compare each word in two vector registers and set the comparison result in a predicate register, and ldr represents an instruction to write data stored in a register to memory.
[0053] Additionally, [x24] indicates that the str and ldr instructions will be executed using the x24 register as the address register. Additionally, ".s" indicates that the instruction will be executed using the vector register or predicate register as storing data that is one word long, 32 bits in length. The " / m" and " / z" following the predicate register indicate that only words with valid flags in the predicate register will be processed when the instruction is executed. " / m" indicates that for words with invalid flags, the values before the instruction was executed will be retained. " / z" indicates that for words with invalid flags, the values will be cleared to 0 after the instruction is executed.
[0054] FIG. 5 is a diagram illustrating an example of a conversion program. The information processing device 100 creates in advance a conversion program 143 capable of converting the assembly code 141 into the assembly code 142. The conversion program 143 corresponds to the conversion program 134 described above.
[0055] The conversion process defined by the conversion program 143 reads one instruction from the source assembly code, extracts the mnemonic contained in the read instruction, and analyzes the operands contained in the read instruction to generate operand information. The mnemonic is the part of the instruction other than the operands, and indicates the type of instruction, such as add, sub, or vpmaxsd. The operand information indicates the analysis result of the operand, and indicates the characteristics of the operand. The operand information includes information such as the number of operands, the type of each operand, such as an immediate value, a register, or a main memory address, the data length of each operand, and the presence or absence of options.
[0056] The conversion process defined by the conversion program 143 calls different conversion functions depending on the extracted mnemonic. The conversion program 143 includes a conversion function for each mnemonic. For example, the conversion program 143 includes a conversion function translateADD corresponding to the mnemonic add, a conversion function translateSUB corresponding to the mnemonic sub, and a conversion function translateVPMAXSD corresponding to the mnemonic vpmaxsd. When calling a conversion function, the conversion process specifies the above operand information as an argument. Each conversion function outputs a set of instructions according to the operand information provided as an argument. Even if the mnemonic is the same, different sets of instructions may be output if the operand information is different.
[0057] Here, the implementation method of each conversion function becomes an issue. Since the correspondence between the type of operand and the output command may be complicated, if the developer manually writes the source code of each conversion function, the developer will have a heavy burden. In addition, there is a risk that an error may be mixed into the conversion function due to a mistake in the source code written by the developer. Therefore, the information processing device 100 supports the implementation of the conversion function. The developer briefly writes the specifications of the conversion function using a pattern table described below. The information processing device 100 automatically generates the source code of the conversion function based on the pattern table described by the developer. An implementation example of the conversion function translateVPMAXSD among the multiple conversion functions will be described below.
[0058] FIG. 6 is a diagram illustrating an example of the pattern table. A pattern table is prepared for each mnemonic. Pattern table 144 is a pattern table corresponding to the mnemonic vpmaxsd. Pattern table 144 indicates the specifications of the translation function translateVPMAXSD.
[0059] The pattern table 144 includes a plurality of rows and a plurality of columns. A developer can write the pattern table 144 using a user interface of the spreadsheet software. The pattern table 144 includes a title row indicating the column names. The pattern table 144 also includes 31 rows corresponding to the 31 operand patterns.
[0060] Pattern table 144 also includes a B column indicating a pattern number. Pattern table 144 also includes an E column indicating the format of an instruction in the I instruction set. Pattern table 144 also includes F, G, H, I, N, O, and P columns indicating seven operand conditions that define an operand pattern. The operand conditions are information included in the operand information that is an argument of the translation function translateVPMAXSD.
[0061] Furthermore, the pattern table 144 includes 36 columns indicating 36 different source code descriptions for outputting instructions of the A instruction set. A column indicating a source code description usually corresponds to one instruction of the A instruction set. These 36 columns are arranged so that the converted instructions indicated by some of the 36 columns will be output from the left column to the right column of the pattern table 144 to obtain an appropriate instruction sequence. Therefore, some of the 36 columns indicate converted instructions with the same content.
[0062] 6 shows a portion of the entire pattern table 144, which is specified by some rows and some columns. The some rows include a title row and rows with pattern numbers #1 to #11. The some columns include column B indicating the pattern number, column E indicating the format of the instruction, columns F, G, H, I, N, O, and P indicating the operand conditions, and eight columns indicating the converted instructions. That is, FIG. 6 shows the upper left portion of pattern table 144.
[0063] Column F indicates the type of operand #0. In pattern table 144, column F has only one value, REG0. REG0 represents the first register. Column G indicates the type of operand #1. In pattern table 144, column G has only one value, REG1. REG1 represents the second register. Column H indicates the type of operand #2. The value in column H is REG2 or MEM0. REG2 represents the third register. MEM0 represents the main memory area. Column I indicates the type of operand #3. The value in column I is INVALID, REG3 or MEM0. INVALID represents that operand #3 does not exist. REG3 represents the fourth register. MEM0 represents the main memory area.
[0064] The N column indicates the data length (bit width) of operand #0. In the pattern table 144, the value of the N column is 128 bits, 256 bits, or 512 bits. The O column indicates a mask specification. The value of the O column is blank, NO, ZERO, or MERG. A blank or NO indicates no mask. When no mask is specified, all of the multiple words in the vector register are specified as the objects of operation. Note that 128-bit data includes four 32-bit words, 256-bit data includes eight words, and 512-bit data includes 16 words.
[0065] ZERO indicates that a mask is used and that zero padding is performed. MERG indicates that a mask is used and that data combining is performed. When a mask is used, only some of the multiple words are specified as the objects of the operation. When zero padding is performed, the operation result of the unspecified words will be a bit string with all bits set to 0. When data combining is performed, the operation result of the unspecified words will inherit the bit string that exists immediately before in the register that stores the operation result. Thus, data combining means combining the result of the previous operation with the result of the current operation.
[0066] Note that pre-conversion instructions may include optional options k and z. Optional option k is an option that specifies which of multiple words is to be operated on. A pre-conversion instruction that does not include optional option k means no masking. Optional option z is an option that indicates zero padding. A pre-conversion instruction that includes optional option z when there is a masking means zero padding. A pre-conversion instruction that does not include optional option z when there is a masking means data merge specification. Therefore, the value of column O is determined from the optional options k and z of the pre-conversion instruction.
[0067] The P column indicates the broadcast specification. The value of the P column is blank, 0 (no broadcast), or 1 (broadcast). When there is no broadcast, a one-to-one comparison operation is performed between the multiple words indicated by operand #2 and the multiple words indicated by operand #3. When there is broadcast, a many-to-one comparison operation is performed between the multiple words indicated by operand #2 and one word indicated by operand #3.
[0068] The values of the 36 columns indicating the converted instruction are blank or 1. However, 0 may be entered instead of blank. The values of these 36 columns can be said to be 1-bit flags. A blank value in a cell located at the intersection of a row indicating one operand pattern and a column indicating one converted instruction means that the converted instruction is not used to convert a pre-converted instruction having that operand pattern. On the other hand, a value of 1 in the cell means that the converted instruction is used to convert a pre-converted instruction having that operand pattern. A developer can define the specification of the translation function translateVPMAXSD by entering 1 in the appropriate cell in the pattern table 144.
[0069] FIG. 7 is a diagram (continuation 1) showing an example of a pattern table. Fig. 7 shows a portion of the entire pattern table 144, which is specified by some rows and some columns. The some rows include the title row and rows with pattern numbers #1 to #11, as in Fig. 6. The some columns include the remaining 28 columns that indicate the converted instructions. That is, Fig. 7 shows the upper right portion of the pattern table 144.
[0070] FIG. 8 is a diagram (continuation 2) showing an example of a pattern table. 8 shows a portion of the entire pattern table 144 that is specified by some rows and some columns. The some rows include rows with pattern numbers #12 to #31. The some columns include, as in FIG. 6, column B indicating the pattern number, column E indicating the instruction format, columns F, G, H, I, N, O, and P indicating the operand conditions, and eight columns indicating the converted instructions. That is, FIG. 8 shows the lower left portion of pattern table 144.
[0071] FIG. 9 is a diagram (continuation 3) showing an example of a pattern table. Fig. 9 shows a portion of the entire pattern table 144 that is specified by some rows and some columns. The some rows include rows with pattern numbers #12 to #31, as in Fig. 8. The some columns include the remaining 28 columns that indicate the converted instructions, as in Fig. 7. That is, Fig. 9 shows the lower right portion of pattern table 144.
[0072] FIG. 10 is a diagram illustrating an example of a data flow for generating a conversion function. As described above, the developer creates a pattern table for each mnemonic. For example, the developer creates a pattern table 151a representing the specifications of the mnemonic vpmaxsd, a pattern table 151b representing the specifications of the mnemonic add, and a pattern table 151c representing the specifications of the mnemonic sub. The pattern table 151a corresponds to the above-mentioned pattern table 144. The information processing device 100 receives the pattern tables 151a, 151b, and 151c, and inputs the pattern tables 151a, 151b, and 151c to the generation tool 152 to generate source codes 153a, 153b, and 153c.
[0073] The generation tool 152 is software that generates source code for one conversion function from one pattern table. The source code for the conversion function is written in a high-level programming language such as C. Source code 153a is the source code for the conversion function translateVPMAXSD and is generated from the pattern table 151a. Source code 153b is the source code for the conversion function translateADD and is generated from the pattern table 151b. Source code 153c is the source code for the conversion function translateSUB and is generated from the pattern table 151c.
[0074] The information processing device 100 compiles the source code of the conversion program body and the source codes 153a, 153b, and 153c using a compiler corresponding to the programming language. As a result, the information processing device 100 generates a conversion program 154 including conversion functions 154a, 154b, and 154c. The conversion function 154a corresponds to the mnemonic vpmaxsd and is generated from the source code 153a. The conversion function 154b corresponds to the mnemonic add and is generated from the source code 153b. The conversion function 154c corresponds to the mnemonic sub and is generated from the source code 153c.
[0075] After generating the conversion program 154, the information processing device 100 accepts assembly code 155 written in an assembly language of the I instruction set. The information processing device 100 starts the conversion program 154 by specifying the assembly code 155 as input data, and generates assembly code 156 written in an assembly language of the A instruction set. During execution of the conversion program 154, the information processing device 100 extracts instructions from the assembly code 155 and calls a conversion function corresponding to the mnemonic of the extracted instruction. The called conversion function outputs an appropriate instruction sequence based on operand information.
[0076] Next, a method for generating a conversion function from a pattern table will be described. There are a row-major method and a column-major method as methods for expressing the correspondence indicated by the pattern table 144 in a transformation function program. In the row-major method, the transformation function program includes 31 blocks corresponding to 31 operand patterns. In the row-major method, the information processing device 100 scans the pattern table 144 horizontally to generate one block of the transformation function program from one row of the pattern table 144. On the other hand, in the column-major method, the transformation function program includes 36 blocks corresponding to 36 source code descriptions. In the column-major method, the information processing device 100 scans the pattern table 144 vertically to generate one block of the transformation function program from one column of the pattern table 144. First, the row-major method will be described.
[0077] FIG. 11 is a diagram illustrating a first example of a conversion function program. The conversion function program 145 is a source code of the conversion function translateVPMAXSD, and is generated by a row-major method from the pattern table 144. The conversion function program 145 includes blocks 145a and 145b. The block 145a corresponds to the row of pattern number #1 in the pattern table 144. The block 145b corresponds to the row of pattern number #2 in the pattern table 144. The conversion function program 145 also includes blocks corresponding to the rows of pattern numbers #3 to #31.
[0078] Block 145a includes a conditional decision statement that decides whether or not the operand information, which is an argument, satisfies a specific execution condition. The execution condition of block 145a is to satisfy the operand conditions in columns F, G, H, I, and N of the row of pattern number #1 in pattern table 144. That is, the execution condition of block 145a is that operand #0 is REG0, operand #1 is REG1, operand #2 is REG2, operand #3 is INVALID, and the data length is 128 bits.
[0079] Block 145a also includes 12 executable statements for outputting instructions of instruction set A. In the row of pattern number #1 in pattern table 144, flags = 1 are placed in columns U, AD, AG, AH, AK, AN, AO, AU, AY, BC, BJ, and BK. Therefore, block 145a includes 12 executable statements corresponding to the column names of these 12 columns. The 12 executable statements are arranged in order from the left column to the right column.
[0080] Block 145b includes a condition determination statement that determines whether the operand information, which is an argument, satisfies a specific execution condition. The execution condition of block 145b is to satisfy the operand conditions in columns F, G, H, I, and N of the row of pattern number #2 in pattern table 144. That is, the execution condition of block 145b is that operand #0 is REG0, operand #1 is REG1, operand #2 is MEM0, operand #3 is INVALID, and the data length is 128 bits.
[0081] Block 145b also includes 16 executable statements for outputting instructions of the A instruction set. In the row of pattern number #2 in pattern table 144, flags = 1 are placed in columns T, U, W, AA, AD, AG, AI, AK, AN, AU, AW, AZ, BC, BI, BJ, and BK. Therefore, block 145b includes 16 executable statements corresponding to the column names of these 16 columns. The 16 executable statements are arranged in order from the left column to the right column.
[0082] In this way, in the row-major method, one block of the conversion function program 145 is generated from one row of the pattern table 144. The information processing device 100 can generate 31 blocks corresponding to 31 operand patterns independently of each other. The condition decision statements of each block are generated from the operand conditions indicated by the F, G, H, I, N, O, and P columns. The executable statements of each block are generated from the column names of the columns in which "1" is entered. The information processing device 100 may arrange the multiple column names in the pattern table 144 in a priority order starting from the left column.
[0083] FIG. 12 is a diagram showing a preview example of a conversion function program. The information processing device 100 may display a preview of each block of the conversion function program 145 on the pattern table 144. In the example of FIG. 12, previews of blocks 145a and 145b are displayed in column Q of the pattern table 144. The preview function can be implemented using a user interface of spreadsheet software. In this case, the spreadsheet software updates the preview of column Q in real time when the developer adds or deletes flag=1. This allows the information processing device 100 to support the developer in creating the pattern table 144. For example, the preview function can be realized by writing the following formula in cell Q1 of the pattern table.
[0084] =IF(T1<>"", $T0 & CHAR(10), "") & IF(U1<>"", $U0 & CHAR(10), "") & IF(W1<>"", $W0 & CHAR(10), "") & IF(Y1<>"", $Y0 & CHAR(10), "") & IF(Y1<>"", $Y0 & CHAR(10), "") … & IF(BK1<>"", $BK0, "").
[0085] The above formula outputs the string already written in the first row of column T + a line feed character to cell Q1 when a value other than 0 is entered in the cell of column T in row 1. Furthermore, the above formula additionally outputs the string already written in the first row of column U + a line feed character to cell Q1 when a value other than 0 is entered in the cell of column U in row 1. Furthermore, the above formula additionally outputs the string already written in the first row of column BK in cell Q1 when a value other than 0 is entered in the cell of column BK in row 1.
[0086] Next, the column-major method will be described. The developer may specify to the information processing device 100 whether to generate the transformation function program using the row-major method or the column-major method. FIG. 13 is a diagram illustrating a second example of the conversion function program.
[0087] The translation function program 146 is source code for the translation function translateVPMAXSD, and is generated by a column-major method from the pattern table 144. The translation function program 146 includes blocks 146a and 146b. The block 146a corresponds to the T column of the pattern table 144. The block 146b corresponds to the U column of the pattern table 144. The translation function program 146 also includes blocks corresponding to the remaining 34 columns.
[0088] Block 146a includes a conditional decision statement that decides whether or not the operand information, which is an argument, satisfies a specific execution condition. The execution condition of block 146a is that the operand information corresponds to one of 26 operand patterns in which the T column is "1" among the 31 operand patterns in pattern table 144. The operand conditions of the 26 operand patterns are linked by a logical sum. Block 146a also includes one executable statement that corresponds to the T column. The executable statement of block 146a is the column name of the T column.
[0089] Block 146b includes a conditional decision statement that decides whether or not the operand information, which is an argument, satisfies a specific execution condition. The execution condition of block 146b is that the operand information corresponds to any one of 23 operand patterns in which the U column is "1" among the 31 operand patterns in pattern table 144. The operand conditions of the 23 operand patterns are linked by a logical sum. Block 146b also includes one executable statement that corresponds to the U column. The executable statement of block 146b is the column name of the U column.
[0090] In this way, in the column-priority method, one block of the conversion function program 146 is generated from one column of the pattern table 144. The information processing device 100 can generate 36 blocks corresponding to the 36 columns independently of each other. In the conversion function program 146, the information processing device 100 arranges the 36 blocks in a priority order starting from the block corresponding to the left column of the pattern table 144.
[0091] Here, in the column-major method, if the operand conditions of the operand patterns with flag=1 are simply combined with a logical sum, the condition decision statement of each block becomes large. However, the condition decision statement of each block contains a redundant comparison expression, and if it is simplified, the condition decision statement becomes sufficiently small. On the other hand, in the column-major method, each block contains only one executable statement, and the repeated appearance of the same executable statement in the transformation function program is suppressed. Therefore, compared to the row-major method, the column-major method can reduce the program size of the transformation function program if the condition decision statement is simplified, and can generate a high-speed transformation function program.
[0092] The simplification of the conditional decision statement may be automatically performed by a compiler during optimization processing when compiling the source code of the conversion function program 146. Furthermore, the information processing device 100 may use a formula processing library to perform logic compression on the conditional decision statement to simplify the logical expression when generating the source code of the conversion function program 146. Furthermore, the information processing device 100 may simplify the conditional decision statement by an explicit procedure as described below.
[0093] FIG. 14 is a diagram showing an example of simplifying an operand condition. First, the information processing device 100 counts columns indicating operand conditions in the pattern table 144 to calculate the number of columns C, and counts rows indicating operand patterns to calculate the number of rows R. The information processing device 100 generates an array 161 (array pattern) of size C×R and an array 162 (array flag) of size C.
[0094] Next, information processing device 100 scans each of columns F, G, H, I, N, O, and P, which indicate operand conditions, and lists unique values for each column, which are registered in array 161. A unique value of column F is registered in element (0,*) of array 161. Therefore, element (0,0)=REG0. A unique value of column G is registered in element (1,*). Therefore, element (1,0)=REG1. A unique value of column H is registered in element (2,*). Therefore, element (2,0)=REG2, and element (2,1)=MEM0.
[0095] Additionally, a unique value of column I is registered in element (3,*) of array 161. Therefore, element (3,0) = INVALID, element (3,1) = REG3, and element (3,2) = MEM0. A unique value of column N is registered in element (4,*). Therefore, element (4,0) = 128, element (4,1) = 256, and element (4,2) = 512. A unique value of column O is registered in element (5,*). Therefore, element (5,0) = NO, element (5,1) = ZERO, and element (5,2) = MERG. A unique value of column P is registered in element (6,*). Therefore, element (6,0) = 0, and element (6,1) = 1.
[0096] Next, the information processing device 100 detects a column having only one unique value among the columns F, G, H, I, N, O, and P indicating the operand condition based on the array 161. An operand condition having only one unique value can be ignored because it does not affect the selection of the operand pattern. The information processing device 100 can detect a column having only one unique value by searching the array 161 for an element number of the first dimension in which the element (*, 1) is empty. Here, the columns F and G among the columns F, G, H, I, N, O, and P are columns having only one unique value. The information processing device 100 updates the elements of the array 162 corresponding to the detected columns to false. The initial value of the elements of the array 162 is true.
[0097] Next, the information processing device 100 extracts element numbers of elements whose values are true from the array 162, and extracts elements having the same first-dimension element numbers from the array 161. The information processing device 100 generates a proposition "string symbol = value" from the extracted elements of the array 161, and registers it in the array 163 (array proposition).
[0098] Element (2,0) of array 163 is the proposition "The value of column H is REG2". Element (2,1) is the proposition "The value of column H is MEM0". Element (3,0) is the proposition "The value of column I is INVALID". Element (3,1) is the proposition "The value of column I is REG3". Element (3,2) is the proposition "The value of column I is MEM0". Element (4,0) is the proposition "The value of column N is 128". Element (4,1) is the proposition "The value of column N is 256". Element (4,2) is the proposition "The value of column N is 512". Element (5,0) is the proposition "The value of column O is NO". Element (5,1) is the proposition "The value of column O is ZERO". Element (5,2) is the proposition "The value of column O is MERG". Element (6,0) is the proposition "The value of column P is 0." Element (6,1) is the proposition "The value of column P is 1."
[0099] Next, the information processing device 100 replaces the values of the H, I, N, O, and P columns in which a proposition is defined, among the F, G, H, I, N, O, and P columns in the pattern table 144, with proposition symbols indicating elements of the array 163. In Fig. 14, the elements of the array 163 are written as P[*][*]. In this way, the pattern table 164 is generated.
[0100] The value of column H of pattern number #1 is replaced with P[2][0], the value of column I is replaced with P[3][0], and the value of column N is replaced with P[4][0]. The value of column H of pattern number #2 is replaced with P[2][1], the value of column I is replaced with P[3][0], and the value of column N is replaced with P[4][0]. The value of column H of pattern number #3 is replaced with P[2][0], the value of column I is replaced with P[3][0], and the value of column N is replaced with P[4][1]. The value of column H of pattern number #4 is replaced with P[2][1], the value of column I is replaced with P[3][0], and the value of column N is replaced with P[4][1].
[0101] FIG. 15 is a diagram (continuation) showing an example of simplification of the operand condition. Next, the information processing device 100 generates a combined proposition for each of the columns T through BK indicating the converted instruction based on the pattern table 164. At this time, the information processing device 100 generates a combined proposition by combining the proposition symbols of the columns H, I, N, O, and P with a logical product for each row of the pattern table 164. The information processing device 100 generates a combined proposition by further combining the combined propositions of the rows in which "1" is written with a logical sum as a combined proposition for each column. Then, the information processing device 100 simplifies the combined proposition using the proposition symbols using a logic compression algorithm.
[0102] For the sake of simplicity, it is assumed that the pattern table 164 includes only four rows of pattern numbers #1 to #4 and columns B, H, I, N, and T, as shown in FIG. 15. In this case, the information processing device 100 generates a combined proposition of P[2][0]andP[3][0]andP[4][0] for pattern number #1. The information processing device 100 also generates a combined proposition of P[2][1]andP[3][0]andP[4][0] for pattern number #2. The information processing device 100 generates a combined proposition of P[2][0]andP[3][0]andP[4][1] for pattern number #3. The information processing device 100 also generates a combined proposition of P[2][1]andP[3][0]andP[4][1] for pattern number #4.
[0103] In the T column, flag=1 is written at the positions of pattern numbers #2 and #4. Therefore, the information processing device 100 combines the combined propositions of pattern numbers #2 and #4 with a logical sum to generate a combined proposition 165 for the T column. The combined proposition 165 is P[2][1]andP[3][0]andP[4][0]orP[2][1]andP[3][0]andP[4][1].
[0104] The information processing device 100 simplifies the combined proposition 165 to generate a combined proposition 166. Here, only the proposition P[3][0] appears in the I column of the pattern table 164 (the mnemonic to be converted is input with only the pattern specified in the I column, among the operand patterns, in which the proposition P[3][0] always holds). Therefore, the proposition P[3][0] does not affect the conclusion of the combined proposition 165 and can be deleted. Furthermore, only the propositions P[4][0] and P[4][1] appear in the N column of the pattern table 164. Since both the propositions P[4][0] and P[4][1] appear in the combined proposition 165, the propositions P[4][0] and P[4][1] can be deleted. As a result, the simplified combined proposition 166 becomes P[2][1].
[0105] The information processing device 100 returns the proposition symbol included in the combined proposition 166 to the original proposition format. As a result, the combined proposition 166 is converted to "the value of column H is MEM0". The information processing device 100 converts each proposition into a conditional expression in the format of "column name == value". As a result, a condition determination statement of opName2 == MEM0 is generated. The information processing device 100 generates a block 167 including this condition determination statement and an executable statement corresponding to the column name of column T. In this way, the information processing device 100 can generate a conversion function program in a column-major method.
[0106] Next, the functions and processing procedures of the information processing device 100 will be described. FIG. 16 is a block diagram illustrating an example of functions of the information processing device. The information processing device 100 has a table storage unit 121, a conversion function storage unit 122, and an executable file storage unit 123. These storage units are realized, for example, by using the storage areas of the RAM 102 or the HDD 103. The information processing device 100 also has a table editing unit 124, a conversion function generating unit 125, and an executable file converting unit 126. These processing units are realized, for example, by using programs executed by the CPU 101.
[0107] The table storage unit 121 stores pattern tables corresponding to the mnemonics included in the I instruction set. The conversion function storage unit 122 stores source code of conversion functions corresponding to the mnemonics included in the I instruction set. The conversion function storage unit 122 also stores source code of the main body of the conversion program.
[0108] The conversion function storage unit 122 also stores a compiler for compiling these source codes. The conversion function storage unit 122 also stores compiled conversion programs. The conversion function storage unit 122 also stores a disassembler for the I instruction set and an assembler for the A instruction set. The executable file storage unit 123 stores executable files for the I instruction set before conversion and executable files for the A instruction set after conversion.
[0109] The table editing unit 124 displays the pattern table stored in the table storage unit 121 on the display device 111. The table editing unit 124 accepts an input operation using the input device 112, updates the pattern table in response to the input operation, and stores the updated pattern table in the table storage unit 121. The table editing unit 124 may be implemented using spreadsheet software.
[0110] The conversion function generating unit 125 reads out a pattern table corresponding to each mnemonic from the table storage unit 121, generates source code of a conversion function corresponding to each mnemonic, and stores the generated source code in the conversion function storage unit 122. The conversion function generating unit 125 generates source code of the conversion function by either the row-major method or the column-major method described above. The conversion function generating unit 125 may receive an input operation indicating a selection between the row-major method and the column-major method from the developer.
[0111] Furthermore, the conversion function generation unit 125 generates source code of a conversion program body that calls a conversion function corresponding to the mnemonic, and stores it in the conversion function storage unit 122. The conversion function generation unit 125 inputs the source code of the conversion program body and the conversion function to a compiler to generate a compiled conversion program, and stores it in the conversion function storage unit 122.
[0112] The executable file conversion unit 126 accepts an input operation specifying an executable file of the I instruction set to be converted. The executable file conversion unit 126 then reads the executable file of the I instruction set from the executable file storage unit 123, inputs it to a disassembler, and generates assembly code of the I instruction set. The executable file conversion unit 126 reads a compiled conversion program from the conversion function storage unit 122, specifies the assembly code of the I instruction set as input, starts the conversion program, and generates assembly code of the A instruction set. The executable file conversion unit 126 inputs the assembly code of the A instruction set to an assembler, generates an executable file of the A instruction set, and saves it in the executable file storage unit 123.
[0113] FIG. 17 is a flowchart showing a first example of a procedure for generating a conversion function. Here, we describe generation of transformation functions using a row-major method. (S10) The conversion function generation unit 125 selects one row indicating an operand pattern from the pattern table. The row selected here is expressed as the i-th row (i is an integer equal to or greater than 1). Furthermore, the conversion function generation unit 125 outputs a character string "if(". However, when selecting the second or subsequent row, the conversion function generation unit 125 outputs a character string "else if(".
[0114] (S11) The conversion function generating unit 125 selects one column indicating an operand condition from the pattern table. The column selected here is expressed as column j (j is an integer equal to or greater than 1). (S12) The conversion function generating unit 125 judges whether a value exists in the cell (i, j) of the pattern table. If a value exists in the cell (i, j), the process proceeds to step S13, and if the cell (i, j) is empty, the process proceeds to step S14.
[0115] (S13) The conversion function generation unit 125 extracts the column name and the value of cell (i, j) written in the title row of column j from the pattern table. The conversion function generation unit 125 outputs the character string "[column name]==[value of cell (i, j)]&&".
[0116] (S14) The conversion function generation unit 125 determines whether or not all columns indicating the operand conditions have been selected in step S11. If all columns indicating the operand conditions have been selected, the process proceeds to step S15. If there are any unselected columns, the process returns to step S11.
[0117] (S15) The conversion function generation unit 125 outputs a character string "true){". (S16) The conversion function generation unit 125 selects one column indicating a converted command from the pattern table. The column selected here is expressed as k-columns (k is an integer equal to or greater than 1).
[0118] (S17) The conversion function generation unit 125 determines whether the value of cell (i, k) in the pattern table is 1. If the value of cell (i, k) is 1, the process proceeds to step S18, and if cell (i, k) is empty, the process proceeds to step S19.
[0119] (S18) The conversion function generation unit 125 extracts the column name written in the title row of column k from the pattern table. This column name corresponds to an executable statement in the source code for generating instructions in the A instruction set. The conversion function generation unit 125 outputs the extracted column name.
[0120] (S19) Conversion function generation unit 125 determines whether all columns indicating the converted instruction have been selected in step S16. If all columns indicating the converted instruction have been selected, the process proceeds to step S20. If there are any unselected columns, the process returns to step S16.
[0121] (S20) The conversion function generation unit 125 outputs the character string "}". (S21) The conversion function generation unit 125 determines how to select all rows indicating the operand pattern in step S10. If all rows indicating the operand pattern have been selected, the conversion function generation ends, and if there are any rows that have not been selected, the process returns to step S10.
[0122] FIG. 18 is a flowchart showing a second example of a procedure for generating a conversion function. Here, we describe generation of transformation functions using a column-major method. (S30) The conversion function generation unit 125 counts the rows indicating operand patterns from the pattern table to calculate the number of rows R. In addition, the conversion function generation unit 125 counts the columns indicating operand conditions from the pattern table to calculate the number of columns C.
[0123] (S31) The transformation function generation unit 125 generates an array flag of size C, and initializes each element of the array flag to true. The transformation function generation unit 125 also generates an array pattern of size C×R, and initializes each element of the array pattern to null. The element numbers of the array flag are integers from 0 to C-1 inclusive. The numbers of the first dimension of the array pattern are integers from 0 to C-1 inclusive, and the numbers of the second dimension are integers from 0 to R-1 inclusive.
[0124] (S32) The conversion function generation unit 125 selects one column indicating an operand condition from the pattern table. The column selected here is represented as column j. (S33) The conversion function generation unit 125 scans the jth column of the pattern table, detects unique values in the jth column, and stores them in pattern[j][*]. A unique value is a value obtained after eliminating duplicates from among the values appearing in the jth column. Pattern[j][*] is an element of the array pattern whose first dimension number is j. At this time, the conversion function generation unit 125 fills in unique values preferentially starting from elements with the smallest second dimension number.
[0125] (S34) The conversion function generation unit 125 determines whether or not all columns indicating the operand conditions have been selected in step S32. If all columns indicating the operand conditions have been selected, the process proceeds to step S35, and if there are any unselected columns, the process returns to step S32.
[0126] (S35) The conversion function generation unit 125 selects one column indicating an operand condition from the pattern table. The column selected here is represented as column j. (S36) The conversion function generation unit 125 determines whether there is only one unique value in column j based on the array pattern. For example, the conversion function generation unit 125 determines whether pattern[j][1] is empty. If pattern[j][1] is empty, there is only one unique value in column j. If pattern[j][1] is not empty, there are two or more unique values in column j. If there is only one unique value in column j, proceed to step S37, and if there are two or more unique values in column j, proceed to step S38.
[0127] (S37) The conversion function generation unit 125 updates flag[j] to false. (S38) The conversion function generation unit 125 determines whether or not all columns indicating the operand conditions have been selected in step S35. If all columns indicating the operand conditions have been selected, the process proceeds to step S39, and if there are any unselected columns, the process returns to step S35.
[0128] FIG. 19 is a flowchart (continued 1) showing a second example of the procedure for generating a conversion function. (S39) The conversion function generation unit 125 selects one column indicating an operand condition from the pattern table. The column selected here is represented as column j.
[0129] (S40) The conversion function generation unit 125 judges whether flag[j] is true. If it is true, the process proceeds to step S41, and if it is false, the process proceeds to step S42. (S41) The conversion function generation unit 125 identifies the string symbol indicating the j-th string and the condition value stored in pattern[j][*] for each non-empty pattern[j][*], and generates a proposition that "the value of [string symbol] is [condition value]." The conversion function generation unit 125 stores the generated proposition in proposition[j][*]. The number of the second dimension of proposition[j][*] is set to be the same as that of pattern[j][*].
[0130] (S42) The conversion function generation unit 125 determines whether or not all columns indicating the operand conditions have been selected in step S39. If all columns indicating the operand conditions have been selected, the process proceeds to step S43. If there are any unselected columns, the process returns to step S39.
[0131] (S43) The conversion function generation unit 125 selects one column indicating an operand condition from the pattern table. The column selected here is represented as column j. (S44) The conversion function generation unit 125 judges whether flag[j] is true. If it is true, the process proceeds to step S45, and if it is false, the process proceeds to step S46.
[0132] (S45) The conversion function generating unit 125 replaces the value of cell (i, j) in the pattern table with a proposition symbol indicating the proposition of proposition [j] [*]. (S46) The conversion function generation unit 125 determines whether or not all columns indicating the operand conditions have been selected in step S43. If all columns indicating the operand conditions have been selected, the process proceeds to step S47. If there are any unselected columns, the process returns to step S43.
[0133] FIG. 20 is a flowchart (continued 2) showing a second example of the procedure for generating a conversion function. (S47) The conversion function generation unit 125 selects one column indicating the converted instruction from the pattern table. The column selected here is expressed as column k. The conversion function generation unit 125 also defines a character string variable called a combined proposition, and initializes the combined proposition to null.
[0134] (S48) The conversion function generation unit 125 selects one row indicating an operand pattern from the pattern table. The selected row is represented as the i-th row. The conversion function generation unit 125 also defines a character string variable called a tmp combined proposition, and initializes the tmp combined proposition to null.
[0135] (S49) The conversion function generation unit 125 determines whether the value of cell (i, k) in the pattern table is 1. If the value of cell (i, k) is 1, the process proceeds to step S50, and if cell (i, k) is empty, the process proceeds to step S55.
[0136] (S50) The conversion function generation unit 125 selects one column indicating an operand condition from the pattern table. The column selected here is represented as column j. (S51) The conversion function generation unit 125 determines whether flag[j] is true. If it is true, the process proceeds to step S52, and if it is false, the process proceeds to step S53.
[0137] (S52) The conversion function generation unit 125 extracts the value of cell (i, j) from the pattern table, and generates a new proposition indicating the logical product of the tmp combined proposition and the value of cell (i, j). The conversion function generation unit 125 assigns the generated proposition to the tmp combined proposition.
[0138] (S53) The conversion function generation unit 125 determines whether or not all columns indicating the operand conditions have been selected in step S50. If all columns indicating the operand conditions have been selected, the process proceeds to step S54, and if there are any unselected columns, the process returns to step S50.
[0139] (S54) The conversion function generation unit 125 generates a new proposition indicating the logical sum of the combined proposition and the tmp combined proposition. The conversion function generation unit 125 assigns the generated proposition to the combined proposition. (S55) The conversion function generation unit 125 determines whether or not all rows indicating the operand pattern have been selected in step S48. If all rows indicating the operand pattern have been selected, the process proceeds to step S56, and if there are any rows that have not been selected, the process returns to step S48.
[0140] (S56) The conversion function generation unit 125 simplifies the combined proposition. The conversion function generation unit 125 may use a mathematical expression processing library in which a logic compression algorithm is implemented. (S57) The conversion function generation unit 125 extracts the column name written in the title row of column k from the pattern table. The conversion function generation unit 125 outputs the character string "if ([join proposition]) {[column name]}".
[0141] (S58) Conversion function generation unit 125 determines whether all columns indicating the converted instruction have been selected in step S47. If all columns indicating the converted instruction have been selected, conversion function generation ends, and if there are any unselected columns, the process returns to step S47.
[0142] FIG. 21 is a flowchart showing an example of a procedure for converting an executable file. (S60) The executable file conversion unit 126 reads out from the executable file storage unit 123 the executable file of the I instruction set designated as the object of conversion.
[0143] (S61) The executable file conversion unit 126 generates an assembly code of the I instruction set from the executable file of the I instruction set by using a disassembler for the I instruction set. (S62) The executable file conversion unit 126 selects one instruction from the assembly code generated in step S61. The instruction selected here is referred to as an I instruction.
[0144] (S63) The executable file conversion unit 126 extracts a mnemonic from the I command. The mnemonic is a character string that indicates the type of command, such as add or sub. (S64) The executable file conversion unit 126 extracts and analyzes the operands from the I instruction. The operands are character strings following the mnemonic. The executable file conversion unit 126 generates operand information indicating the characteristics of the operands, such as the number of operands and their data length.
[0145] (S65) The executable file conversion unit 126 calls the conversion function corresponding to the mnemonic extracted in step S63, specifying the operand information generated in step S64 as an argument. The executable file conversion unit 126 obtains an instruction of the A instruction set as a return value from the conversion function. The instruction obtained here is referred to as an A instruction. The executable file conversion unit 126 may obtain only one A instruction, or may obtain two or more A instructions.
[0146] (S66) The executable file conversion unit 126 adds the A instruction acquired in step S65 to the end of the assembly code of the converted A instruction set. (S67) The executable file conversion unit 126 determines whether or not all instructions included in the assembly code of the I instruction set have been selected in step S62. If all instructions have been selected, the process proceeds to step S68. If there are any unselected instructions, the process returns to step S62.
[0147] (S68) The executable file conversion unit 126 generates an executable file of the instruction set A from the assembly code of the instruction set A using an assembler for the instruction set A. The executable file conversion unit 126 stores the executable file of the instruction set A in the executable file storage unit 123.
[0148] According to the information processing device 100 of the second embodiment, an executable file for a processor having an I instruction set is converted into an executable file for a processor having an A instruction set. Therefore, even if the source code of the existing program does not exist, it is possible to reuse the existing program in a different computing environment. In addition, a conversion program for converting the assembly code is automatically generated from a pattern table created by a developer. Therefore, compared to the case where the developer manually implements the conversion program, the developer's implementation burden is reduced. In addition, the risk of introducing errors into the conversion program due to operational mistakes is reduced.
[0149] In particular, the conversion from a CISC instruction set to a RISC instruction set is complicated in that a single pre-conversion instruction is converted into a different set of instructions depending on the type of operand. In this regard, the automatic generation of the conversion program reduces the developer's implementation burden. The pattern table has a user interface that includes rows corresponding to operand patterns and columns corresponding to converted instructions, and includes a field for entering flags at the intersections of the rows and columns. The multiple columns corresponding to multiple converted instructions are arranged from left to right according to the order in which they are executed. Therefore, developers can efficiently define the specifications of the conversion function simply by entering flags such as "1" in the pattern table.
[0150] Furthermore, when the instruction set of the conversion source is extended, the developer can modify the conversion program by adding a row corresponding to the new operand pattern to the pattern table. This reduces the developer's workload compared to when the developer manually modifies the conversion program. Furthermore, the entry of a row corresponding to a new operand pattern does not affect the specifications of the conversion function for the existing operand pattern. This reduces the risk of errors in modifying the conversion program. Furthermore, the developer can write the pattern table in stages starting from the operand pattern whose specifications have been finalized.
[0151] In addition, by using the preview function of the pattern table, developers can edit the pattern table while checking the source code of the generated conversion program in real time. This improves the developer's work efficiency. In addition, by adopting the column-major method and simplifying the conditional decision statements, a small and efficient conversion program is generated.
[0152] [Third embodiment] Next, a third embodiment will be described, focusing on the differences from the second embodiment described above, and descriptions of the same contents as the second embodiment may be omitted.
[0153] The converted A instruction set may contain SIMD (Single Instruction Multiple Data) instructions, in which the data length of the operand varies depending on the CPU. SIMD instructions are parallel processing instructions that execute the same type of operation, such as addition, on multiple units of data in parallel. The data length of the operand of a SIMD instruction is sometimes called the vector length.
[0154] The vector length supported by a CPU is determined by the size of the SIMD register that stores the data of the SIMD instruction. On the other hand, the A instruction set can be used in CPUs for various purposes, such as CPUs for embedded devices and CPUs for server equipment. Therefore, the A instruction set allows the CPU implementer to select the vector length for a certain SIMD instruction. This SIMD instruction can be said to be a CPU-dependent or implementation-dependent SIMD instruction.
[0155] For example, the A instruction set allows no support for CPU-dependent SIMD instructions. Also, the A instruction set allows the vector length of the CPU-dependent SIMD instructions to be selected from 128, 256, 384, 512, 640, 768, 896, 1024, 1152, 1280, 1408, 1536, 1664, 1792, 1920, and 2048 bits. In the third embodiment, four examples of CPU implementations are given: no support, 128 bits, 256 bits, and 512 bits.
[0156] Here, when CPU-dependent SIMD instructions are used in the converted assembly code, the information processing device may execute the method of the second embodiment by assuming that CPUs with different vector lengths have different instruction sets. In this case, the information processing device creates a pattern table for each vector length to generate a conversion program. The information processing device also receives a designation of the vector length of the conversion destination CPU, and generates assembly code of the A instruction set using a conversion program corresponding to the designated vector length.
[0157] However, the assembly codes of the A instruction set that differ only in vector length are similar to each other, and the pattern tables and conversion programs for generating such assembly codes are also similar to each other. Therefore, it is inefficient to create a pattern table for each vector length, and the burden of creating and maintaining the pattern table increases. Therefore, in the third embodiment, one pattern table covers multiple CPUs with different vector lengths. Furthermore, the information processing device of the third embodiment generates a conversion program that covers multiple CPUs with different vector lengths from this pattern table.
[0158] The information processing device of the third embodiment is realized by a module structure similar to that of the information processing device 100 of the second embodiment shown in Figures 2 and 16. Therefore, the third embodiment will be described below using the same reference numerals as in Figures 2 and 16.
[0159] FIG. 22 is a diagram showing examples of instruction sets with different vector lengths. The I instruction set 211 is an instruction set owned by the source CPU. The I instruction set 211 does not include CPU-dependent SIMD instructions. The A instruction sets 212-215 are instruction sets owned by candidates for the destination CPU. The A instruction sets 212-215 are compatible with multiple CPUs with different vector lengths. The A instruction set 212 does not include CPU-dependent SIMD instructions. The A instruction sets 213-215 include CPU-dependent SIMD instructions. The A instruction set 213 is compatible with a vector length of 128 bits. The A instruction set 214 is compatible with a vector length of 256 bits. The A instruction set 215 is compatible with a vector length of 512 bits.
[0160] The I instruction set 211 includes a scalar instruction 221, a SIMDi1 instruction 222, a SIMDi2 instruction 223, and a SIMDi3 instruction 224. The scalar instruction 221 is a simple instruction that indicates an operation such as addition, subtraction, and multiplication on one 64-bit unit data. The SIMDi1 instruction 222 is a parallel processing instruction that indicates an operation on two 64-bit unit data, i.e., 128-bit data. The SIMDi2 instruction 223 is a parallel processing instruction that indicates an operation on four 64-bit unit data, i.e., 256-bit data. The SIMDi3 instruction 224 is a parallel processing instruction that indicates an operation on eight 64-bit unit data, i.e., 512-bit data. The data length of the SIMDi1 instruction 222, the SIMDi2 instruction 223, and the SIMDi3 instruction 224 is fixed regardless of the CPU.
[0161] The A instruction set 212 includes a scalar instruction 231 and a SIMDa1 instruction 232. The scalar instruction 231 is a simple instruction that indicates an operation on one 64-bit unit data. The SIMDa1 instruction 232 is a parallel processing instruction that indicates an operation on two 64-bit unit data, i.e., 128-bit data. The data length of the SIMDa1 instruction 232 is fixed regardless of the CPU. A CPU having the A instruction set 212 includes a 128-bit SIMD register.
[0162] The A instruction set 213 includes a scalar instruction 231, a SIMDa1 instruction 232, and a SIMDa2 instruction 233. The SIMDa2 instruction 233 is a parallel processing instruction that indicates an operation on two 64-bit unit data, i.e., 128-bit data. A CPU having the A instruction set 213 includes a 128-bit SIMD register.
[0163] The A instruction set 214 includes a scalar instruction 231, a SIMDa1 instruction 232, and a SIMDa2 instruction 234. The SIMDa2 instruction 234 is a parallel processing instruction that indicates an operation on four 64-bit unit data, i.e., 256-bit data. A CPU having the A instruction set 214 includes a 256-bit SIMD register.
[0164] The A instruction set 215 includes a scalar instruction 231, a SIMDa1 instruction 232, and a SIMDa2 instruction 235. The SIMDa2 instruction 235 is a parallel processing instruction that indicates an operation on eight 64-bit unit data, i.e., 512-bit data. A CPU having the A instruction set 215 includes a 512-bit SIMD register. The SIMDa2 instructions 233, 234, and 235 correspond to CPU-dependent instructions whose vector length differs depending on the CPU.
[0165] The information processing device 100 converts the assembly code of the I instruction set 211 into assembly code of one of the A instruction sets 212 to 215. In converting from the I instruction set 211 to the A instruction set 212, the information processing device 100 converts the scalar instruction 221 into a scalar instruction 231, and converts the SIMDi1 instruction 222 into a SIMDA1 instruction 232. The SIMDi2 instruction 223 and the SIMDi3 instruction 224 are not subject to conversion because the size of the SIMD register is insufficient.
[0166] Similarly, in converting from the I instruction set 211 to the A instruction set 213, the information processing apparatus 100 converts the scalar instruction 221 to a scalar instruction 231, and converts the SIMDi1 instruction 222 to a SIMDA1 instruction 232. The SIMDi2 instruction 223 and the SIMDi3 instruction 224 are not subject to conversion because the size of the SIMD register is insufficient.
[0167] In converting from the I instruction set 211 to the A instruction set 214, the information processing device 100 converts the scalar instruction 221 to a scalar instruction 231, converts the SIMDi1 instruction 222 to a SIMDA1 instruction 232, and converts the SIMDi2 instruction 223 to a SIMDA2 instruction 234. The SIMDi3 instruction 224 is not subject to conversion because the size of the SIMD register is insufficient.
[0168] In converting from the I instruction set 211 to the A instruction set 214, the information processing apparatus 100 converts the scalar instruction 221 into a scalar instruction 231, and converts the SIMDi1 instruction 222 into a SIMDA1 instruction 232. In addition, the information processing apparatus 100 converts the SIMDi2 instruction 223 and the SIMDi3 instruction 224 into a SIMDA2 instruction 235.
[0169] Since the A instruction set 215 does not include 256-bit SIMD instructions, 256-bit operations are executed using 512-bit SIMD instructions. In this case, only the lower 256-bit operation result in the 512-bit SIMD register is meaningful, and the upper 256-bit operation result is meaningless. Therefore, in order to ensure the equivalence of the operations, an additional process is performed in which the upper 256-bit operation result is discarded (for example, replaced with zero).
[0170] FIG. 23 is a diagram illustrating an example of how to use the SIMD register. The SIMD register 241 is included in a CPU having the I instruction set 211. The SIMD register 241 has a size of 512 bits and holds eight 64-bit unit data. The SIMD register 241 is used in common by the SIMDi1 instruction 222, the SIMDi2 instruction 223, and the SIMDi3 instruction 224. The scalar instruction 221 uses a 64-bit normal register.
[0171] The SIMDi1 instruction 222 uses the lower 128 bits of the SIMD register 241. At this time, the upper 384 bits are automatically controlled to be invalid. The SIMDi2 instruction 223 uses the lower 256 bits of the SIMD register 241. At this time, the upper 256 bits are automatically controlled to be invalid. The SIMDi3 instruction 223 uses the entire 512 bits of the SIMD register 241.
[0172] The SIMD register 242 is included in a CPU having the A instruction set 212. The SIMD register 242 has a size of 128 bits and holds two 64-bit unit data. The SIMDa1 instruction 232 uses the entire 128 bits of the SIMD register 242. The scalar instruction 231 uses a 64-bit normal register.
[0173] The SIMD register 243 is included in a CPU having the A instruction set 213. The SIMD register 243 has a size of 128 bits and holds two unit data of 64 bits. The SIMD register 243 is used in common by the SIMDa1 instruction 232 and the SIMDa2 instruction 233. The SIMDa1 instruction 232 and the SIMDa2 instruction 233 use the entire 128 bits of the SIMD register 243.
[0174] The SIMD register 244 is included in a CPU having the A instruction set 214. The SIMD register 244 has a size of 256 bits and holds four unit data of 64 bits. The SIMD register 244 is used in common by the SIMDa1 instruction 232 and the SIMDa2 instruction 234. The SIMDa1 instruction 232 uses the lower 128 bits of the SIMD register 244. At this time, the upper 128 bits are automatically controlled to be invalid. The SIMDa2 instruction 234 uses the entire 256 bits of the SIMD register 244.
[0175] The SIMD register 245 is included in a CPU having the A instruction set 215. The SIMD register 245 has a size of 512 bits and holds eight unit data of 64 bits. The SIMD register 245 is used in common by the SIMDa1 instruction 232 and the SIMDa2 instruction 235. The SIMDa1 instruction 232 uses the lower 128 bits of the SIMD register 245. At this time, the upper 384 bits are automatically controlled to be invalid. The SIMDa2 instruction 235 uses the entire 512 bits of the SIMD register 245.
[0176] When converting the SIMDi2 instruction 223 into the SIMDa2 instruction 235, the upper 256 bits of the SIMD register 245 are not automatically invalidated. Therefore, the information processing device 100 generates assembly code that assigns zero to the upper 256 bits of the SIMD register 245. Note that in the other conversion patterns described in Fig. 22, the vector lengths of the instructions before and after conversion are the same, so it is not necessary to assign zero to the upper bits.
[0177] FIG. 24 is a diagram illustrating an example of conversion to instructions of an instruction set having a different vector length. Table 251 shows assembly code of the A instruction set 212 to 215 that is equivalent to the vaddps instruction of the I instruction set 211. The vaddps instruction is a SIMD instruction that performs parallel addition. The vaddps instruction stores the sum of the second and third operands in the first operand. The operand patterns of the vaddps instruction are classified into six types depending on the vector length and whether the third operand is a memory address or not.
[0178] When the vector length is 128 bits and the third operand is the data to be operated on, this vaddps instruction corresponds to the SIMDi1 instruction 222. The equivalent assembly code in the A instruction set 215 performs a 128-bit addition using the SIMDi1 instruction 232. The assembly code in the A instruction sets 212-214 is similar.
[0179] If the vector length is 128 bits and the third operand is a memory address, then this vaddps instruction corresponds to SIMDi1 instruction 222. The equivalent assembly code in A instruction set 215 saves 64 bytes (512 bits) of data from a SIMD register to a stack area, and loads the data indicated by the memory address from memory to the SIMD register. The assembly code performs a 128-bit addition using SIMDi1 instruction 232, and returns the saved data from the stack area to the SIMD register.
[0180] The equivalent assembly code of the A instruction set 214 is basically the same as that of the A instruction set 215. However, the data saved in the stack area is 32 bytes (256 bits). The equivalent assembly code of the A instruction sets 212 and 213 is also basically the same as that of the A instruction set 215. However, the data of the SIMD register saved in the stack area is 16 bytes (128 bits).
[0181] When the vector length is 256 bits and the third operand is the data to be operated on, this vaddps instruction corresponds to SIMDi2 instruction 223. The equivalent assembly code in A instruction set 215 performs a 512-bit addition using a SIMDa2 instruction 235 and assigns zero to the most significant 256 bits of the SIMD register that stores the result. The equivalent assembly code in instruction set 214 performs a 256-bit addition using a SIMDa2 instruction 234. The assignment of zero to the SIMD register that stores the result is not necessary.
[0182] When the vector length is 256 bits and the third operand is a memory address, this vaddps instruction corresponds to the SIMDi2 instruction 223. The equivalent assembly code in the A instruction set 215 saves 64 bytes of data in a certain SIMD register to the stack area, and loads the data indicated by the memory address from memory to the SIMD register. The assembly code performs a 512-bit addition using the SIMDi2 instruction 235, assigns zero to the upper 256 bits of the SIMD register that stores the operation result, and returns the saved data from the stack area to the SIMD register of the operand. The equivalent assembly code in the A instruction set 214 differs from the A instruction set 215 in that the data saved to the stack area is 32 bytes, and there is no need to assign zero to the SIMD register.
[0183] When the vector length is 512 bits and the third operand is the data to be operated on, this vaddps instruction corresponds to a SIMDi3 instruction 224. The equivalent assembly code in the A instruction set 215 uses a SIM Da2 instruction 235 to perform the 512-bit addition.
[0184] If the vector length is 512 bits and the third operand is a memory address, then this vaddps instruction corresponds to a SIMDi3 instruction 224. The equivalent assembly code in the A instruction set 215 saves 64 bytes of data from a SIMD register to a stack area, and loads the data pointed to by the memory address from memory into the SIMD register. The assembly code performs a 512-bit addition using a SIMDa2 instruction 235, and returns the saved data from the stack area to the SIMD register.
[0185] In this way, assembly codes for CPUs with different vector lengths may be similar but not identical. Therefore, the information processing device 100 extends the pattern table described in the second embodiment to represent the effect of different vector lengths.
[0186] FIG. 25 is a diagram showing a first modified example of the pattern table. The pattern table 252 includes a plurality of rows corresponding to a plurality of operand patterns, similar to the pattern table 144 of the second embodiment. The pattern table 252 also includes a column describing the operand pattern, and a plurality of columns corresponding to a plurality of instructions of the A instruction set. The column names corresponding to the instructions of the A instruction set include statements for outputting the instructions of the A instruction set in the conversion function program.
[0187] Furthermore, the pattern table 252 of the third embodiment includes a row describing CPU-dependent information indicating the correspondence between vector lengths and instructions of the A instruction set, between the row describing the column names and the multiple rows corresponding to the multiple operand patterns. As rows describing CPU-dependent information, the pattern table 252 includes four rows corresponding to none, 128 bits, 256 bits, and 512 bits. The CPU-dependent information includes flags indicating whether each of the multiple instructions of the A instruction set is valid or not for each vector length. For example, if it is valid, "1" is described as the flag, and if it is invalid, nothing is described.
[0188] When using the conversion function program, the user specifies the vector length of the destination CPU. Instructions that are valid for the specified vector length are output if a "1" is written in the line corresponding to the operand pattern. On the other hand, instructions that are invalid for the specified vector length are not output even if a "1" is written in the line corresponding to the operand pattern. Thus, the CPU-dependent information acts as a filter for instructions in the A instruction set. This allows instructions to be output that are used for a CPU with a specific vector length.
[0189] FIG. 26 is a diagram (continuation) showing a first modified example of the pattern table. The pattern table 252 includes a column showing a preview of the source code of the conversion function program, similar to the pattern table 144 of the second embodiment. A statement that outputs an instruction that is valid for all vector lengths is inserted into the source code as is. On the other hand, a statement that outputs an instruction that is valid only for some vector lengths is inserted into the source code after a conditional branch statement that determines the vector length is added.
[0190] The instruction shown in the second last column of pattern table 252 is an instruction that is valid only for a CPU whose vector length is 512 bits, out of none, 128 bits, 256 bits, and 512 bits. This instruction is also used for the third and fourth operand patterns. Thus, the source code corresponding to the third operand pattern includes a statement that determines whether the specified vector length is 512 bits, and outputs the above instruction if it is 512 bits. Similarly, the source code corresponding to the fourth operand pattern includes a statement that determines whether the specified vector length is 512 bits, and outputs the above instruction if it is 512 bits.
[0191] FIG. 27 is a flowchart showing a third example of a procedure for generating a conversion function. Here, an example of generating a conversion function by the row-major method will be described. It is also possible to generate a conversion function by the column-major method described in the second embodiment.
[0192] (S70) The conversion function generation unit 125 selects one row that corresponds to the operand pattern from the pattern table 252. The row selected here is represented as the i-th row (i is an integer equal to or greater than 1). (S71) The conversion function generating unit 125 outputs a condition determination statement for determining an operand condition in a manner similar to that in steps S11 to S15 of FIG.
[0193] (S72) Conversion function generation unit 125 selects one column corresponding to the converted command from pattern table 252. The column selected here is expressed as k columns (k is an integer equal to or greater than 1). (S73) The conversion function generation unit 125 counts the number of True flags (flags whose value is 1) in the kth column from isNoVector to isVector 512. The minimum count value is 0, and the maximum count value is 4.
[0194] (S74) The conversion function generation unit 125 determines whether the value of cell (i, k) in the pattern table 252 is 1. If the value of cell (i, k) is 1, the process proceeds to step S75, and if the value of cell (i, k) is not 1, the process proceeds to step S78.
[0195] (S75) The conversion function generation unit 125 determines whether the count in step S73 is 4. If the count is 4, that is, if the selected instruction is valid for all vector lengths, the process proceeds to step S77. If the count is not 4, that is, if the selected instruction is invalid for some vector lengths, the process proceeds to step S76.
[0196] (S76) The conversion function generation unit 125 outputs a conditional branch statement according to the True flag. The judgment condition of this conditional branch statement is a logical expression obtained by combining, by logical sum, those of isNoVector, isVector128, isVector256, and isVector512 whose flags are 1. For example, when the flags of isNoVector and isVector128 are 1, the judgment condition is isNoVector||isVector128.
[0197] (S77) The conversion function generation unit 125 extracts column names of k columns from the pattern table 252. The conversion function generation unit 125 outputs the extracted column names. (S78) Conversion function generation unit 125 determines whether or not all columns corresponding to the converted command have been selected in step S72. If all columns have been selected, the process proceeds to step S79. If there are any unselected columns, the process returns to step S72.
[0198] (S79) The conversion function generation unit 125 determines whether or not all rows corresponding to the operand pattern have been selected in step S70. If all rows have been selected, the conversion function generation ends. If there are any rows that have not been selected, the process returns to step S70.
[0199] Conversion of an executable file can be performed in the same manner as in the flowchart of the second embodiment shown in Fig. 21. However, in conversion of an executable file in the third embodiment, the information processing device 100 accepts a designation of the vector length of the target CPU from the user. The information processing device 100 designates the vector length when calling a conversion function.
[0200] According to the information processing device 100 of the third embodiment, the same effect as that of the second embodiment can be obtained. Furthermore, the information processing device 100 generates assembly code and machine code of the A instruction set by using SIMD instructions whose vector lengths differ depending on the CPU. Therefore, the information processing device 100 can cover various CPUs having the A instruction set.
[0201] Moreover, the information processing device 100 defines conversion rules for a plurality of vector lengths by a single pattern table. Therefore, compared with the case where a pattern table is created for each vector length, the burden on the developer of the conversion program to create a pattern table is reduced, and the burden of maintaining the pattern table is also reduced. Moreover, the pattern table of the third embodiment includes a flag for filtering the converted instruction to be used according to the vector length. Therefore, the developer can concisely describe the conversion rules for different vector lengths.
[0202] [Fourth embodiment] Next, a fourth embodiment will be described, focusing on the differences from the third embodiment described above, and descriptions of the same contents as the third embodiment may be omitted.
[0203] The information processing device of the fourth embodiment supports SIMD instructions of the A instruction set with different vector lengths depending on the CPU, similar to the third embodiment. However, the fourth embodiment differs from the third embodiment in the structure of the pattern table.
[0204] The information processing device of the fourth embodiment is realized by a module structure similar to that of the information processing device 100 of the second embodiment shown in Figures 2 and 16. Therefore, the fourth embodiment will be described below using the same reference numerals as in Figures 2 and 16.
[0205] FIG. 28 is a diagram showing a second modified example of the pattern table. The pattern table 253 includes a plurality of rows corresponding to a plurality of operand patterns, similar to the pattern table 144 of the second embodiment. The pattern table 253 also includes a column describing the operand pattern, and a plurality of columns corresponding to a plurality of instructions of the A instruction set. The column names corresponding to the instructions of the A instruction set include statements for outputting the instructions of the A instruction set in the conversion function program.
[0206] Here, the statement corresponding to the column name may call a library function that outputs different instructions depending on the vector length. The first, eighth, and ninth converted instructions of the pattern table 253 depend on the vector length. Therefore, the function XT_PUSH_ZREG included in the first statement, the function MOV_FOR_512 included in the eighth statement, and the function XT_POP_ZREG included in the ninth statement are library functions that depend on the vector length.
[0207] FIG. 29 is a diagram (continuation) showing a second modified example of the pattern table. The pattern table 253 includes a column showing a preview of the source code of the conversion function program, similar to the pattern table 144 of the second embodiment. The information processing device 100 generates the source code of the conversion function program by sequentially listing, from left to right, the column names of columns whose flags are 1 for each operand pattern. The source code includes a call to a library function that outputs a different instruction depending on the vector length.
[0208] The second operand pattern of pattern table 253 uses the first and ninth post-conversion instructions. Therefore, the source code of the second operand pattern includes calls to the functions XT_PUSH_ZREG and XT_POP_ZREG. Also, the third operand pattern uses the eighth post-conversion instruction. Therefore, the source code of the third operand pattern includes a call to the function MOV_FOR_512.
[0209] Additionally, the fourth operand pattern uses the first, eighth, and ninth post-conversion instructions. Therefore, the source code for the fourth operand pattern includes calls to the functions XT_PUSH_ZREG, MOV_FOR_512, and XT_POP_ZREG. Additionally, the sixth operand pattern uses the first and ninth post-conversion instructions. Therefore, the source code for the sixth operand pattern includes calls to the functions XT_PUSH_ZREG and XT_POP_ZREG.
[0210] FIG. 30 is a diagram showing an example of a library function of the conversion function program. The conversion function program 254 includes the functions XT_PUSH_ZREG, XT_POP_ZREG, and MOV_FOR_512 as library functions. The function XT_PUSH_ZREG obtains the register number of the SIMD register to be used and calculates the number of bytes of the vector length. If the vector length is specified as "none" or 128 bits, this function generates a store instruction to save 128 bits of data, and otherwise generates a store instruction to save the entire data of the SIMD register.
[0211] The function XT_POP_ZREG generates a load instruction to read 128 bits of data if the vector length is "none" or 128 bits, otherwise it generates a load instruction to read the entire SIMD register data. The function MOV_FOR_512 generates an assignment instruction to assign zeros to the upper 256 bits of the SIMD register if the vector length is 512 bytes, otherwise it does not output an instruction.
[0212] In this way, library functions that output different instructions depending on the vector length are prepared in advance, and the differences in post-conversion instructions that directly result from differences in vector length are absorbed by the library functions. By setting the flag in the column indicating the call of the library function to 1, developers of conversion programs can write conversion specifications without being aware of the effects of vector length.
[0213] Conversion function generation can be performed in the same procedure as in the flowchart of the second embodiment shown in Figures 17 to 20. Also, executable file conversion can be performed in the same procedure as in the flowchart of the second embodiment shown in Figure 21. However, in the executable file conversion of the fourth embodiment, the information processing device 100 accepts designation of the vector length of the target CPU from the user, and designates the vector length when calling the conversion function.
[0214] According to the information processing device 100 of the fourth embodiment, the same effect as that of the second embodiment can be obtained. Furthermore, the information processing device 100 generates assembly code and machine code of the A instruction set by using SIMD instructions whose vector lengths differ depending on the CPU. Therefore, the information processing device 100 can cover various CPUs having the A instruction set.
[0215] Furthermore, the information processing device 100 defines conversion rules for a plurality of vector lengths using a single pattern table. Therefore, compared with the case where a pattern table is created for each vector length, the burden on the developer of the conversion program to create the pattern table is reduced, and the burden of maintaining the pattern table is also reduced.
[0216] In addition, the pattern table of the fourth embodiment encapsulates the effect of different vector lengths in a library function that outputs a converted instruction. Therefore, once the effect of vector length at the converted instruction level is specified and the library function is defined, the developer can use the library function to abstractly describe conversion rules for various vector lengths. As a result, the developer can concisely describe conversion rules for different vector lengths. [Explanation of symbols]
[0217] 10. Information processing device 11 Storage section 12 Processing section 13 Table Data 13a, 13b, 13c Operand Patterns 14 Conversion Programs 15,16 Code
Claims
1. On the computer, receiving table data indicating a correspondence relationship between a plurality of operand patterns indicating types of operands that may be included in a first instruction used in a first assembly language and a plurality of second instructions used in a second assembly language or a machine language corresponding to the second assembly language, the table data associating two or more second instructions of the plurality of second instructions with each operand pattern; a conversion program for converting a first code written in the first assembly language into a second code written in the second assembly language or the machine language, the conversion program defining a process of determining an operand pattern of an instruction included in the first code and outputting two or more instructions of the second code corresponding to the determined operand pattern, based on the table data; An instruction conversion support program that executes processing.
2. the table data is matrix data including a plurality of rows indicating the plurality of operand patterns and a plurality of columns indicating the plurality of second instructions, In the table data, a flag indicating whether or not the one second instruction is used in converting the first instruction having one operand pattern is arranged at an intersection of a row corresponding to one operand pattern and a column corresponding to one second instruction.
2. The instruction conversion support program according to claim 1.
3. In the table data, two or more flags indicating that the flags are used for converting the first instruction having the one operand pattern are arranged in the one row, the converted program is generated such that a second instruction corresponding to a leftmost column among the two or more columns in which the two or more flags are arranged is output preferentially.
3. The instruction conversion support program according to claim 2.
4. the conversion program includes a plurality of program blocks corresponding to the plurality of operand patterns, each of the plurality of program blocks defining a process of outputting the two or more second instructions when a specific condition is satisfied; In generating the conversion program, the specific condition for each of the plurality of program blocks is determined by scanning flags arranged in the same row.
3. The instruction conversion support program according to claim 2.
5. the conversion program includes a plurality of program blocks corresponding to the plurality of second instructions, each of the plurality of program blocks defining a process of outputting the second instruction corresponding to the program block when a specific condition is satisfied; In generating the conversion program, the specific condition for each of the plurality of program blocks is determined by scanning flags arranged in the same column.
3. The instruction conversion support program according to claim 2.
6. The plurality of operand patterns differ in at least one of the number of the operands, the type of the storage area specified by the operand, and the data length of the operand.
2. The instruction conversion support program according to claim 1.
7. The receiving of the table data includes receiving a plurality of table data corresponding to a plurality of first instructions used in the first assembly language; In the generation of the conversion program, the conversion program is generated based on the plurality of table data, the conversion program including a plurality of conversion functions corresponding to the plurality of first instructions.
2. The instruction conversion support program according to claim 1.
8. The computer further comprises: accepting the first code and activating the generated conversion program to convert the first code into the second code; 2. The instruction conversion support program according to claim 1, which executes processing.
9. the plurality of second instructions include parallel processing instructions in which a maximum data length of data to be processed in parallel varies depending on the processor; the table data further includes processor-dependent information indicating a correspondence between a plurality of maximum data lengths and the plurality of second instructions; generating the conversion program based on the processor-dependent information such that the two or more second instructions corresponding to the determined operand pattern are narrowed down in accordance with a specified maximum data length among the plurality of maximum data lengths; 2. The instruction conversion support program according to claim 1.
10. the plurality of second instructions include parallel processing instructions in which a maximum data length of data to be processed in parallel varies depending on the processor; the conversion program includes a library function that changes an output command in accordance with a specified maximum data length among a plurality of maximum data lengths; the table data associates the library function with an operand pattern, among the plurality of operand patterns, in which a method of converting into the second assembly language or the machine language depends on the specified maximum data length; 2. The instruction conversion support program according to claim 1.
11. The computer receiving table data indicating a correspondence relationship between a plurality of operand patterns indicating types of operands that may be included in a first instruction used in a first assembly language and a plurality of second instructions used in a second assembly language or a machine language corresponding to the second assembly language, the table data associating two or more second instructions of the plurality of second instructions with each operand pattern; a conversion program for converting a first code written in the first assembly language into a second code written in the second assembly language or the machine language, the conversion program defining a process of determining an operand pattern of an instruction included in the first code and outputting two or more instructions of the second code corresponding to the determined operand pattern, based on the table data; A method for assisting in command conversion.
12. a storage unit that stores table data indicating a correspondence relationship between a plurality of operand patterns indicating types of operands that may be included in a first instruction used in a first assembly language and a plurality of second instructions used in a second assembly language or a machine language corresponding to the second assembly language, the table data associating each operand pattern with two or more second instructions among the plurality of second instructions; a processing unit that generates, based on the table data, a conversion program for converting a first code written in the first assembly language into a second code written in the second assembly language or the machine language, the conversion program defining a process of determining an operand pattern of an instruction included in the first code and outputting two or more instructions of the second code corresponding to the determined operand pattern; An information processing device having the above configuration.
Citation Information
Patent Citations
Assembler
JP1989026934A
Optimization processing system
JP1994131196A
Compiler
JP2006079494A
Program code converter and program code conversion method
JP2008276735A
Method for converting subject program code into target program code, computer program, and computer
JP2011123917A
