WO2009084570A1 - Compiler embedded function adding device - Google Patents
Compiler embedded function adding device Download PDFInfo
- Publication number
- WO2009084570A1 WO2009084570A1 PCT/JP2008/073552 JP2008073552W WO2009084570A1 WO 2009084570 A1 WO2009084570 A1 WO 2009084570A1 JP 2008073552 W JP2008073552 W JP 2008073552W WO 2009084570 A1 WO2009084570 A1 WO 2009084570A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- additional instruction
- function
- built
- compiler
- instruction
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Ceased
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
Definitions
- the present invention is based on the priority claim of Japanese patent application: Japanese Patent Application No. 2007-340532 (filed on Dec. 28, 2007), the entire contents of which are incorporated herein by reference. Shall.
- the present invention relates to a compiler technique for a processor, and more particularly to a technique for adding an embedded function corresponding to a new instruction (additional instruction) added to an instruction set of a basic processor (base processor) to a compiler.
- processor design support device Various tools have been developed for efficient processor design.
- One of these types of tools is a tool that generates the hardware configuration of the processor and software development tools (compiler, assembler, simulator, etc.) from the design specifications of the processor, and is provided as a program that runs on a computer. .
- the computer on which the tool operates is also called a “processor design support device”.
- Non-Patent Document 1 discloses a processor design support apparatus that generates an assembler and compiler for a processor based on a processor instruction set defined by a designer.
- the processor design support apparatus disclosed in Non-Patent Document 1, Patent Documents 1 to 3, and the like can add a new instruction to a basic processor (referred to as a “base processor”).
- a basic processor referred to as a “base processor”.
- the processor design support apparatus In order to make the built-in function corresponding to the instruction added to the base processor available from the compiler, the processor design support apparatus generates a header file that defines the function described in the inline assembler as the built-in function.
- the descriptions in Patent Document 1 (paragraph number 0329), Patent Document 2 (paragraph number 0056), Patent Document 3 (paragraph number 0052), and the like are also referred to.
- Built-in functions are functions that correspond one-to-one with processor instructions.
- the compiler handles built-in functions as one of the normal functions, so the compiler performs register allocation for arguments and return values of built-in functions.
- the inline assembler is, for example, an assembler language described in C language source code. By using an inline assembler, assembler language can be inserted into the source code.
- Non-Patent Documents 1 to 4 and Patent Documents 1 to 3 described above are incorporated herein by reference.
- the following is an analysis of the related art according to the present invention.
- the addition of the compiler built-in function uses the built-in function for the additional instruction by adding only the header file without changing the compiler for the base processor. enable.
- the instruction word length is information indicating how many bytes the additional instruction is.
- Latency is information indicating how many cycles the operation result of the additional instruction is obtained.
- the compiler cannot inform the compiler of the latency of the additional instruction, so the compiler cannot schedule the additional instruction efficiently.
- the compiler can efficiently schedule additional instructions using the control flow and data flow information of the target source code, but this is not possible with the related technology.
- a main object of the present invention is to provide an apparatus, a method, and a program that allow specification information such as the instruction word length and latency of an additional instruction to be reflected in the compiler when a compiler built-in function is added.
- an embedded function corresponding to the additional instruction is added to the compiler of the base processor.
- an intrinsic function is added to the compiler by adding source code for enabling the compiler to understand the instruction word length and latency information of the additional instruction to the source code of the base compiler.
- the extended processor which is a base processor having the additional instruction
- the source code of the compiler for the base processor is input, and based on the specification description of the additional instruction newly added to the instruction set of the base processor, the source code of the compiler for the base processor
- the source code of the compiler for the base processor is input, and based on the specification description of the additional instruction newly added to the instruction set of the base processor, the source code of the compiler for the base processor.
- a method for generating a compiler source code for an extended processor having an additional instruction in an instruction set and executing an embedded function adding process for adding an embedded function corresponding to the additional instruction to the compiler for the extended processor is provided.
- the built-in function adding process is: Processing to read the specification description of the additional instruction; Processing for generating a configuration definition statement of an additional instruction based on the specification description; Processing for generating a relationship definition statement between an additional instruction and a corresponding built-in function based on the specification description; Processing for generating a compiler source code for the extension processor by adding the configuration definition statement and the relationship definition statement to the source code of the compiler for the base processor.
- the configuration definition statement includes an additional instruction template expressed in an intermediate language of a compiler, and a latency definition statement that defines the number of cycles required to execute the additional instruction
- the configuration definition statement is The generating process generates the template based on the name of the additional instruction, the input operand, and the output operand included in the specification description, and further, based on the number of cycles necessary for executing the additional instruction included in the specification description.
- the latency definition sentence may be generated.
- the relationship definition statement includes a prototype declaration of an embedded function corresponding to an additional instruction and an embedded function expansion function for replacing the embedded function with the additional instruction
- the process of generating the relationship definition statement includes Generating a prototype declaration of the built-in function based on the name of an additional instruction included in the specification description, an input operand, and an output operand, and further generating the built-in function expansion function based on a predetermined format of a compiler It is also good.
- the first compiler built-in function adding device when generating the template in the configuration definition statement, Determining the operand number in the intermediate language definition statement of the additional instruction by arranging the output operand and the input operand of the additional instruction of the specification description in order; Generating a name for the template based on the name of the additional instruction in the specification description; Generating a description of the output operand of the template based on the type of the output operand of the additional instruction of the specification description; Generating a description of the input operand of the template based on the type of the input operand of the additional instruction of the specification description; Generate an action description of the additional instruction in the template using an operator that indicates that the additional instruction performs an operation unknown to the compiler, Generating a template syntax by replacing an operand included in the syntax of the additional instruction in the specification description with the operand number; Generating an instruction word length definition statement in the template based on the instruction word length of the additional instruction in the specification description; A configuration may be adopted in which a series of processes
- FIG. 15 is a diagram showing an RTL template for an additional instruction mac32 generated based on the specification description of FIG. 14 in the RTL template generation process (step 200).
- FIG. 15 is a diagram showing an RTL template for an additional instruction avg2 generated based on the specification description of FIG. 14 in the RTL template generation process (step 200).
- FIG. 15 is a diagram showing a latency definition sentence generated based on the specification description of FIG. 14 in step 310 and step 320 of FIG. 6.
- FIG. 15 is a diagram showing a latency definition statement for an additional instruction mac32 generated based on the specification description of FIG. 14 in step 330 of FIG.
- FIG. 15 is a diagram showing a latency definition sentence of an additional instruction avg2 generated based on the specification description of FIG. 14 in step 330 of FIG.
- FIG. 15 is a diagram showing an embedded function prototype declaration for an additional instruction mac32 generated based on the specification description of FIG. 14 in the embedded function prototype declaration generation process (step 400).
- FIG. 15 is a diagram showing an embedded function prototype declaration for an additional instruction avg2 generated based on the specification description of FIG. 14 in the embedded function prototype declaration generation process (step 400).
- FIG. 15 is a diagram showing the contents of a function generated based on the specification description of FIG. 14 in the built-in function prototype declaration generation process (step 400).
- the compiler built-in function adding device is a device that adds a built-in function corresponding to the additional instruction to the compiler for the base processor based on the specification description regarding the additional instruction to the base processor.
- the built-in function is also called “intrinsic”. Built-in functions are functions that correspond one-to-one with processor instructions.
- the program developer can use the additional instruction from the compiler in the form of a function call.
- the source code of the compiler for the base processor is modified so that the compiler can handle the built-in functions corresponding to the additional instructions.
- a modification is performed in which a fragment of the source code necessary for handling the built-in function for the additional instruction is added to the source code of the compiler.
- information such as the instruction word length and latency of the additional instruction can be reflected in the compiler.
- the compiler can correctly calculate the word length of the program including the additional instruction and can appropriately schedule the additional instruction.
- FIG. 1 is a diagram showing a configuration of a compiler built-in function adding device in an exemplary embodiment of the present invention.
- the compiler built-in function adding device 70 includes a CPU 10, a storage device 20, a compiler built-in function adding means (compiler built-in function adding program) 30, an additional instruction specification description file 40, a compiler source code 50 for a base processor, and an extended processor. Compiler source code 60.
- the compiler built-in function adding unit 30 is also referred to as a compiler built-in function adding program 30 because processing and functions are realized by a program executed by the CPU 10.
- the additional instruction specification description file 40 and the base processor compiler source code 50 are read from the storage device 20 and correspond to the additional instructions described in the additional instruction specification description file 40.
- An extension function compiler source code 60 is generated by generating an embedded function definition statement corresponding to the additional instruction to the base processor compiler source code 50 and generating the extension processor compiler source code 60. Is stored in the storage device 20.
- the compiler built-in function adding device 70 can be realized using a general computer (for example, a personal computer).
- the user can also build an extended processor compiler using the extended processor compiler source code 60.
- the construction function can be added to the compiler built-in function adding device 70.
- FIG. 2 is a diagram showing details of the input / output relationship of the compiler built-in function addition program 30 of FIG.
- the input files of the compiler built-in function adding program 30 are an additional instruction specification description file 40 and a base processor compiler source code 50.
- the final output file of the compiler built-in function addition program 30 is the compiler source code 60 for the extended processor.
- the extended processor compiler source code 60 includes a base processor compiler source code 50, a configuration definition statement 61 of an additional instruction, and a relationship definition statement 64 of the additional instruction and an embedded function.
- the CPU 10 By executing the compiler built-in function addition program 30, the CPU 10 generates a configuration definition statement 61 of an additional instruction and a relationship definition statement 64 between the additional instruction and the built-in function based on the additional instruction specification description file 40.
- the CPU 10 adds the configuration definition statement 61 of the additional instruction and the relationship definition statement 64 between the additional instruction and the built-in function to the compiler source code 50 for the base processor. Then, the CPU 10 outputs the configuration definition statement 61 of the additional instruction, the relationship definition statement 64 between the additional instruction and the built-in function, and the added source code as the extended processor compiler source code 60.
- the additional instruction configuration definition statement 61 includes an additional instruction template 62 defined in an intermediate language of the compiler, and a latency definition sentence 63 that defines the latency of the additional instruction.
- the template 62 is generally described in an intermediate language of a compiler called “RTL (register transfer language)”.
- RTL register transfer language
- a specific example of the template 62 will be referred to as an “RTL template”.
- the latency definition statement 63 defines the number of cycles (latency) necessary for executing the additional instruction.
- the relation definition statement 64 between the additional instruction and the built-in function includes a prototype declaration 65 of the built-in function corresponding to the additional instruction and an expansion function 66 of the built-in function.
- the prototype declaration 65 of the built-in function defines the return value and argument type of the built-in function.
- the built-in function prototype declaration 65 allows the compiler for the extended processor to know the name of the built-in function, the return value, and the argument type.
- the expansion function 66 of the built-in function is a function used by the compiler for the extended processor in order to detect an additional instruction corresponding to the built-in function.
- FIG. 3 is a flowchart showing the processing procedure of the compiler built-in function addition program 30.
- the compiler built-in function addition program 30 is A step 100 for reading the specification description; Step 200 for performing processing for generating an RTL template; Step 300 for performing processing for generating a latency definition statement; A step 400 of performing a process of generating a built-in function prototype declaration; Step 500 for performing processing for generating an embedded function expansion function; Step 600 for performing additional processing of compiler source code; including.
- a computer program for causing the computer to execute the processing procedure of the flowchart shown in FIG. 3 is supplied to the compiler built-in function adding device 70 via a predetermined medium or the like, and the computer program is added to the compiler built-in function.
- the CPU 10 of the device 70 may be loaded into the main memory and executed.
- the computer program supplied to the compiler built-in function adding device 70 may be stored in a readable / writable memory or a storage medium such as a hard disk device.
- the present invention is constituted by such a computer program or a storage medium.
- the input to the compiler built-in function addition program 30 is the specification description file 40 regarding the additional instruction to the base processor.
- the specification description of the additional instruction is based on XML (extensible markup language).
- XML tags for specification description of additional instructions are ⁇ nickname> and ⁇ insn>.
- the ⁇ nickname> tag is a tag that defines a nickname of a target processor.
- the number of characters in the nickname is arbitrary, and the characters that can be used as the nickname are alphabets and numbers.
- the nickname defined by the ⁇ nickname> tag is used as a part of the name of a variable, function, or the like generated by the compiler built-in function addition program 30.
- the ⁇ insn> tag is a tag that defines an instruction of the target processor.
- the value of the ⁇ insn> tag is another tag for defining instruction syntax, word length, and input operand.
- FIG. 14 shows a description example of the ⁇ insn> tag. As illustrated in FIG. 14, the following six tags can be described as values of the ⁇ insn> tag.
- ⁇ Mnemonic> is a tag that defines the mnemonic of the instruction.
- ⁇ Syntax> is a tag that defines the syntax of an instruction.
- ⁇ Length> is a tag that defines the word length of the instruction.
- ⁇ Latency> is a tag that defines the latency of the instruction.
- ⁇ Output> is a tag that defines an output operand into which an instruction writes a value.
- ⁇ Input> is a tag that defines an input operand used by the instruction.
- tags that can be described as values of the ⁇ insn> tag will be described in detail.
- the ⁇ mnemonic> tag is a tag that defines a mnemonic of an instruction.
- the number of mnemonic characters is arbitrary, and the characters that can be used as mnemonics are alphabets and numbers (mac32 in FIG. 14).
- the mnemonic of one instruction must not be the same as the mnemonic of any other instruction. Mnemonics are not case sensitive. For example, mnemonic Foo and mnemonic foo are considered to be the same. An instruction mnemonic is used as part of the name of the built-in function corresponding to the instruction.
- the ⁇ syntax> tag is a tag that defines the syntax of an instruction.
- the value of the ⁇ syntax> tag is an arbitrary character string (“mac32% rd% ra% rb% rc” in FIG. 14) representing the syntax of the instruction.
- This character string can include a format character string.
- the format character string is a character string for designating the output position of the instruction operand.
- the format string begins with a% symbol.
- a character string (for example, rd) following the% symbol must match a value of an ⁇ operand> tag described later.
- the ⁇ operand> tag will be described later.
- the format string is replaced with an appropriate string representing the operand.
- an appropriate string representing the operand For example, a format character string corresponding to an ⁇ operand> tag representing a register is replaced with a register name, and a format character string corresponding to an ⁇ operand> tag representing an immediate value is replaced with a register name.
- the ⁇ length> tag is a tag that defines the word length of an instruction in bits.
- the instruction word length is a multiple of 8 (in FIG. 14, 32 bits, that is, 4 bytes).
- the ⁇ latency> tag is a tag that defines the latency of an instruction. Latency is the number of cycles it takes for an instruction to execute after the instruction is executed. The instruction latency may vary depending on the program context. In such cases, this tag defines the longest possible latency.
- the ⁇ output> tag is a tag that defines an output operand of an instruction.
- the value of the ⁇ output> tag is an ⁇ operand> tag that represents an operand.
- the ⁇ input> tag is a tag that defines an input operand of an instruction.
- the value of the ⁇ input> tag is an ⁇ operand> tag that represents an operand.
- the ⁇ operand> tag is a tag that defines an operand of an additional instruction.
- the ⁇ operand> tag is used as a value of an ⁇ output> tag or an ⁇ input> tag.
- the value of the ⁇ operand> tag is the name of the operand. This name is associated with the format string (eg% rd) of the ⁇ syntax> tag.
- Only the name of the operand defined by the ⁇ operand> tag can be used as a format character string in the syntax of the instruction defined by the ⁇ syntax> tag.
- Operand names not defined in the ⁇ operand> tag cannot be used as format strings.
- the ⁇ operand> tag has two attributes, type and width.
- Attribute type is an attribute that represents the operand type.
- the names that can be used as the value of this attribute are register and immediate.
- Register indicates that the operand is a register.
- Immediate indicates that the operand is an immediate value.
- Attribute width is an attribute that represents the bit width of the operand.
- the specification description of the additional instruction is described by a ⁇ nickname> tag or an ⁇ insn> tag based on the XML language specification. Therefore, using a general lexical analyzer and syntax analyzer for XML, the CPU 10 in FIG. 1 replaces the specification description of the additional instruction with a data structure understandable by the computer program.
- the replaced data structure corresponds to the tags described in the additional instruction specification description file 40 on a one-to-one basis. Therefore, hereinafter, the operation of FIG. 1 will be described with reference to a tag instead of the data structure.
- RTL template generation processing An RTL template generation process for an additional instruction in the compiler built-in function adding device 70 will be described. This process is step 200 in FIG.
- RTL register transfer language
- the compiler converts source code described in a high-level language such as C / C ++ into an intermediate language called RTL, and outputs a processor instruction based on the RTL.
- RTL intermediate language
- An RTL template is a representation of processor instructions in RTL. Generally, RTL templates are written so that the compiler can understand the operation of the processor instructions.
- the exact operation of the additional instruction is not described in the RTL template.
- the RTL template is output so that the compiler can correctly understand only the input / output operands of the additional instruction. By doing so, the complicated problem of correctly expressing the operation of the additional instruction with the RTL template is avoided.
- FIG. 15 shows an example of the RTL template for the additional instruction.
- FIG. 15 is an RTL template for a product-sum operation instruction.
- the RTL template is described by an expression “define_insn”.
- the define_insn expression is similar to an expression in the Lisp language.
- the RTL template for additional instructions in this example is (1) RTL template name, (2) Output operand, (3) input operands, (4) Action description of additional instructions, (5) Additional instruction syntax, (6) Word length of the additional instruction, (7) Additional instruction mnemonics, 7 elements are included.
- FIG. 4 is a flowchart showing the procedure of the RTL template generation process (200 in FIG. 3) in the present embodiment.
- the RTL template generation process A step 210 of determining input / output operand numbers; Generating a name of the RTL template 220; Generating 230 an output operand; Generating an input operand 240; Generating an operation description of the additional instruction 250; Generating 260 additional instruction syntax; Generating a word length definition sentence of the additional command; 270; Generating a mnemonic definition statement of the additional instruction, 280; including.
- step 210) the determination of the input / output operand number (step 210) will be described.
- each operand such as an output operand or input operand starts from 0. It is to be given a number that begins.
- Step 210 is a process for determining the number.
- the CPU 10 in FIG. 1 determines the output operand and input operand in the RTL template of the additional instruction based on the ⁇ operand> tag in the specification description of the additional instruction. To do.
- the output operand is determined by the ⁇ operand> tag described inside the ⁇ output> tag, and the input operand is determined by the ⁇ operand> tag described inside the ⁇ input> tag.
- the compiler built-in function addition program 30 determines the operand number op_index of the RTL template according to the following procedure.
- FIG. 5 is a flowchart for explaining the procedure for determining the operand number op_index of the RTL template.
- ⁇ A number op_index from 0 to P-1 is assigned to all ⁇ operand> tags described inside the ⁇ output> tag (step 213).
- ⁇ Numbers op_index from P to P + Q-1 are assigned to all ⁇ operand> tags described inside the ⁇ input> tag (step 214).
- Step 220 is a process for determining the name of the RTL template corresponding to the additional command.
- the compiler built-in function addition program 30 determines the name of the RTL template based on the ⁇ nickname> tag and the ⁇ mnemonic> tag in the specification description of the additional instruction.
- nkname is the nickname of the processor defined by the ⁇ nickname> tag.
- mnem is a mnemonic of an additional instruction defined by the ⁇ mnemonic> tag.
- Step 230 in FIG. 4 is processing for generating an output operand of the RTL template corresponding to the additional instruction.
- the output operand represents an operand that stores the operation result of the additional instruction
- the output operand is generally a register.
- modenameshort is a character representing the word length of the output operand.
- Modenameshort is determined based on the attribute width of the ⁇ operand> tag.
- FIG. 7 shows the relationship between the attribute width and the modemshort.
- Op_index is a number representing the number of the output operand. This op_index is the number determined in step 210.
- Step 240 in FIG. 4 is processing for generating an input operand of the RTL template corresponding to the additional instruction.
- Step 240 handles two types of input operands: registers and immediate values.
- This format is similar to the output operand of register (1).
- the compiler built-in function addition program 30 sets the format of the output operand corresponding to the ⁇ operand> tag to (match_operand: SI op_index “immediate_operand” “n”) (3) And
- Step 250 in FIG. 4 is processing for generating a description representing the operation of the additional instruction in the RTL template.
- step 250 the compiler built-in function addition program 30 generates an operation description of the additional instruction on the assumption that the additional instruction performs an unknown operation.
- This format represents that all_input_operands is used as an input operand, and an operation result of an unknown operation represented by the number unspec_insn_id is assigned to the output operand output_operand.
- unspec is an operator representing an operation unknown to the compiler.
- Output_operand represents an output operand.
- All_input_operands represents all input operands.
- Unspec_insn_id represents a number for distinguishing an unknown operation of an additional instruction. The value of unspec_insn_id differs for each additional instruction.
- Step 260 in FIG. 4 is a process for generating the syntax of the additional instruction in the RTL template.
- the compiler built-in function addition program 30 Based on the syntax defined by the ⁇ syntax> tag in the specification description of the additional instruction, the compiler built-in function addition program 30 generates the syntax of the additional instruction in the RTL template.
- the syntax defined by the ⁇ syntax> tag includes a format character string.
- the format character string is a character string that has a one-to-one correspondence with the operand of the additional instruction defined by the ⁇ operand> tag.
- the compiler built-in function addition program 30 replaces the format character string included in the syntax defined by the ⁇ syntax> tag with a number (op_index described above) representing the operand of the RTL template, and adds an additional instruction in the RTL template.
- Use syntax Since the number op_index is a number determined by the RTL template generation process based on the ⁇ operand> tag, the number op_index has a one-to-one correspondence with the format character string.
- Step 270 in FIG. 4 is processing for generating a description that defines the word length of the additional instruction in the RTL template.
- the compiler built-in function addition program 30 Based on the word length defined by the ⁇ length> tag in the specification description of the additional instruction, the compiler built-in function addition program 30 outputs the word length of the additional instruction in the RTL template in the following format.
- len is a number representing the word length defined by the ⁇ length> tag.
- the word length of the additional instruction in the RTL template is used by the compiler to calculate the code size.
- Step 280 in FIG. 4 is processing for generating a description that defines the mnemonic of the additional instruction in the RTL template.
- the compiler built-in function addition program 30 Based on the mnemonic defined by the ⁇ mnemonic> tag in the specification description of the additional instruction, the compiler built-in function addition program 30 outputs the mnemonic definition statement of the additional instruction in the RTL template in the following format.
- mnem is a character string representing a mnemonic defined by the ⁇ mnemonic> tag.
- the compiler built-in function addition program 30 uses the mnemonic of the additional instruction in the RTL template as the identification code of the additional instruction in the latency definition sentence generation process to generate the latency definition sentence of the additional instruction.
- a latency definition statement generation process (step 300 in FIG. 3) for an additional instruction in the compiler built-in function adding device of this embodiment will be described.
- the latency definition statement is a definition statement for informing the instruction scheduler of the compiler of the latency of the additional instruction.
- the latency definition sentence generation process uses the following three types of expressions.
- the define_automaton expression defines the name of the state transition machine used by the compiler instruction scheduler.
- the define_cpu_unit expression defines an execution unit of a processor to be managed by the state transition machine.
- the define_insn_reservation expression defines an instruction train and an execution unit used by the instruction.
- the execution unit of the processor is notified to the instruction scheduler of the compiler by the define_cpu_unit expression.
- the state transition machine with the name defined by the define_automaton expression manages the usage status of the execution unit and the latency of the instruction.
- FIG. 6 is a flowchart showing a processing procedure of the latency definition sentence generation process (step 300) of FIG.
- Latency definition statement generation processing generating 310 a define_automaton expression; generating a define_cpu_unit expression 320; generating 330 a define_insn_reservation expression; including.
- Step 330 is executed for all additional instructions.
- the compiler built-in function additional program 30 One define_automaton expression, One define_cpu_unit expression, Define_insn_reservation expression for the number of additional instructions, Is generated.
- the specification description of the additional instruction does not include information on the execution unit of the processor or information on which execution unit the additional instruction uses.
- the compiler built-in function addition program 30 generates the above three expressions on the assumption that all the additional instructions use the same execution unit.
- Step 310 and step 320 will be described together.
- the format of the define_automaton expression generated by the latency definition sentence generation processing for the additional instruction is given by the following (10).
- the first argument of this expression represents the name of the state transition machine.
- the first argument of this expression represents the name of the processor execution unit, and the second argument represents the name of the state transition machine.
- the latency definition statement generation process for the additional instruction defines a fictitious execution unit “unit_builtin”.
- step 330 The format of the define_insn_reservation expression generated by the latency definition sentence generation process for the additional instruction is given by the following expression.
- the first argument of this expression is the name given to this whole expression,
- the second argument is the number of latency cycles,
- the third argument is the condition of the additional command to which this expression applies,
- the fourth argument is the execution unit used by the additional instruction, Respectively.
- mnem is a mnemonic of the additional instruction defined in the ⁇ mnemonic> tag in the specification description of the additional instruction.
- Ltcy is a value representing the latency of the additional instruction defined by the ⁇ latency> tag.
- Ltcy_minus_1 is a value obtained by subtracting 1 from ltcy.
- condition of the additional instruction that applies to this expression is specified by using the attribute mnemonic defined in the define_insn expression of the additional instruction.
- execution unit used by the additional instruction uses only the execution unit “unit_builtin” defined by the define_cpu_unit expression in the first cycle, and does not use any execution unit in the subsequent cycles.
- the compiler built-in function adding program 30 sets the fourth argument of the define_insn_reservation expression as “unit_builtin” to indicate that only the execution unit used in the first cycle is used. To do.
- the compiler built-in function addition program 30 In the latency definition statement generation process for the additional instruction, the compiler built-in function addition program 30 generates a define_insn_reservation expression for all the additional instructions according to this format.
- the built-in function prototype declaration generation process for the additional instruction is a process of generating a built-in function prototype declaration for the compiler.
- the prototype declaration of the built-in function is information indicating what arguments the built-in function has and what the return value of the built-in function is.
- the compiler can recognize the embedded function as an embedded function.
- the compiler built-in function addition program 30 In the built-in function prototype declaration generation process, the compiler built-in function addition program 30 generates a definition statement that defines the name of a function that tells the compiler the prototype declaration of the built-in function and the contents of the function.
- This definition statement does not depend on the specification description of the additional instruction. This definition statement is used for any additional command.
- the function target_init_builds () is a function having no argument and no return value, and executes a prototype declaration of a built-in function corresponding to each additional instruction described therein.
- the compiler built-in function addition program 30 generates a definition statement of the prototype declaration of the built-in function corresponding to all the additional instructions as the contents of the function target_init_builds ().
- the compiler built-in function addition program 30 determines a return value and an argument of the built-in function corresponding to the additional instruction based on the number of output operands of the additional instruction.
- the compiler built-in function additional program 30 causes the built-in function prototype declaration generation processing to use the output operand as the return value of the built-in function, and to set all input operands of the additional instruction as built-in functions As an argument.
- the compiler intrinsic function additional program 30 determines that the intrinsic function prototype declaration generation process does not have a return value for the intrinsic function, and outputs all the additional instructions. Operands and input operands are built-in function arguments.
- the compiler intrinsic function addition program 30 After determining what arguments the intrinsic function has based on the return value of the intrinsic function and the method of determining the argument, the compiler intrinsic function addition program 30 performs the above-mentioned in the intrinsic function prototype declaration generation process (step 400 in FIG. 3). Based on the operand number op_index in the define_insn expression, the arguments are arranged in order from the smallest operand number op_index corresponding to the argument.
- the compiler built-in function addition program 30 sets the argument corresponding to the operand having the smallest number op_index as the first argument, and the argument corresponding to the operand having the next smaller number op_index as the first argument. It takes two arguments, and so on, determines the order of the arguments of the built-in function.
- mnem is a mnemonic of the additional instruction defined by the ⁇ mnemonic> tag in the specification description of the additional instruction.
- nkname is the nickname of the processor defined by the ⁇ nickname> tag.
- modenamelong is a character string representing the type of the argument of the built-in function.
- ⁇ tree ftype_mnem build_function_type_list ( modenamelong_type_node, / * operand 0 * / modenamelong_type_node, / * operand 1 * / modenamelong_type_node, / * operand 2 * / .. . NULL_TREE); builtin_function (“__ builtin_nkname_mnem”, / * name of intrinsic * / ftype_mnem, / * prototype * / CODE_FOR_builtin_nkname_mnem, / * RTL template name * / BUILT_IN_MD, NULL, NULL_TREE); ⁇ ⁇ ⁇ ⁇ (14)
- This form first creates a list ftype_mnem representing the return value and argument type of a built-in function using the function build_function_type_list (), and then uses the function built_function () to give the name of the built-in function and the list ftype_mnem to the compiler. It means to register.
- the argument of the function build_function_type_list () is a type specifier “modenamelong_type_node” representing the return value type of the built-in function and the argument type.
- the first argument of the function build_function_type_list () is a type specifier of the return value of the built-in function, and the second and subsequent arguments are type specifiers of the argument of the built-in function.
- the compiler built-in function adding program 30 sets void_type_node as the first argument of the function build_function_type_list ().
- modelnamelong_type_node is determined based on the attribute width of the ⁇ operand> tag.
- FIG. 9 is a diagram showing the relationship between the attribute width and modernalong.
- modemalong is char
- modemamelong is short_integer
- modemalong is an integer
- Function “function_function ()” is a function for registering an embedded function in the compiler.
- This registration allows the compiler to know the name of the built-in function, the return value type and argument type of the built-in function, and the name of the RTL template corresponding to the built-in function.
- the built-in function name format is __builtin_nkname_mnem (15) It is.
- the name of the built-in function includes the nickname nkname of the processor and the mnemonic mnem of the additional instruction.
- the return value type and argument type of the built-in function are expressed as a list of type specifiers, ftype_mnem.
- This list ftype_mnem is generated by the function build_function_type_list ().
- the format of the name of the RTL template corresponding to the built-in function is CODE_FOR_builtin_nkname_mnem. This is obtained by adding CODE_FOR_ to the head of the name of the RTL template in the define_insn expression.
- the expansion function of the built-in function analyzes which additional instruction corresponds to the given built-in function, and generates an RTL expression representing the additional instruction corresponding to the given built-in function.
- the expansion function of the built-in function generated in this process is called by the compiler.
- the expansion function generation process of the built-in function generates the contents of the expansion function of the built-in function.
- the expansion function of the built-in function includes three steps of step 510, step 520, and step 530.
- Step 510 is a step of checking the argument type of the built-in function.
- Step 520 is a step of acquiring the return type of the built-in function.
- Step 530 is a step of generating an RTL expression corresponding to the built-in function.
- FIG. 13 is a diagram showing an example of the contents of the expansion function of the built-in function. All the built-in functions corresponding to the additional instruction are processed by the expansion function of the built-in function in FIG. The detailed processing contents of each step are shown below.
- the expansion function of the embedded function arranges the argument of the embedded function in an appropriate storage location.
- the built-in function expansion function stores the argument in the virtual register.
- the expansion function of the built-in function treats the argument as an immediate value as it is.
- the expansion function of the built-in function acquires the return value type of the built-in function based on the RTL template defined by the define_insn expression corresponding to the built-in function. If a built-in function has a return value, the expansion function of the built-in function creates a virtual register corresponding to the return value. If the built-in function has no return value, the built-in function expansion function does nothing with the return value.
- the expansion function of the built-in function In the generation of the RTL expression corresponding to the built-in function (step 530), the expansion function of the built-in function generates the RTL expression corresponding to the built-in function based on the name, return value, and argument of the built-in function.
- a macro function called GEN_FCN (X) is used to generate the RTL expression.
- the macro function GEN_FCN (X) is a function provided by the compiler, and is a function that returns a function pointer of an RTL expression generation function corresponding to the built-in function X.
- the expansion function of the built-in function uses the function returned by the macro function GEN_FCN (X), the expansion function of the built-in function generates an RTL expression corresponding to the built-in function.
- Compiler source code addition processing in the compiler built-in function addition apparatus 70 (step 600 in FIG. 3 will be described. This addition processing is based on the source code fragment of the compiler generated in steps 200, 300, 400, and 500 in FIG. This is processing to be added to the compiler source code for the processor (compiler source code 50 for the base processor).
- the compiler built-in function addition program 30 determines which source code of the compiler to add the fragment based on the ⁇ nickname> tag in the specification description of the additional instruction. If the nickname defined by the ⁇ nickname> tag is nkname, the source code of the compiler to which the fragment is added is nkname.com in the directory gcc / config / nkname. c and nkname. There are two files named md. These two files become the base processor compiler source code 50. Source code fragments are the following four.
- RTL template generated by step 200 of FIG. 3
- Latency definition statement generated by step 300
- Built-in function prototype declaration generated by step 400
- Built-in function expansion function generated by step 500
- step 600 the compiler built-in function addition program 30 stores the RTL template and the latency definition statement in the file nkname. Append to the end of md.
- the compiler built-in function addition program 30 stores the built-in function prototype declaration and the built-in function expansion function in the file nkname. Append to the end of c.
- a fragment of the source code generated by the processing from step 200 to step 500 is added to the compiler source code 50 for the base processor.
- the source code to which the fragments are added becomes the compiler source code 60 for the extended processor in FIG.
- the procedure for building a compiler using the compiler source code 60 for the extended processor is exactly the same as a general compiler build procedure.
- the build procedure of the compiler refer to the description of “Configuration” on page 7 and “Building” on page 21 of Non-Patent Document 4.
- FIG. 40 An example of the additional instruction specification description file 40 is shown in FIG. A description will be given of how the compiler built-in function adding apparatus operates using the XML file shown in FIG.
- step 100 of FIG. 3 the compiler built-in function addition program 30 reads the contents of the XML file of FIG.
- step 100 the compiler built-in function addition program 30 replaces the content shown in FIG. 14 with a data structure understandable by the computer program.
- step 200 of FIG. 3 the compiler built-in function addition program 30 generates an RTL template corresponding to the additional instruction described in FIG.
- FIG. 14 describes the specifications of two additional instructions using the ⁇ insn> tag.
- the first ⁇ insn> tag is an additional instruction called mac32.
- the second ⁇ insn> tag is an additional instruction avg2.
- step 200 the compiler built-in function addition program 30 generates an RTL template for one additional instruction at a time. Step 200 is performed twice to generate an RTL template for two additional instructions.
- Step 200 includes eight steps from Step 210 to Step 280.
- the compiler built-in function addition program 30 generates RTL template components and combines them as one RTL template.
- FIG. 15 shows the RTL template of the additional instruction mac32 generated in step 200.
- FIG. 16 shows an RTL template for the additional instruction avg2. The following describes what the CPU 10 of FIG. 1 generates for the additional instruction mac32 and the additional instruction avg2 in each step.
- Step 210 is a process of determining the input / output operand number of the additional instruction.
- step 210 the compiler built-in function addition program 30 determines the number of the input / output operand based on the ⁇ operand> tag of the additional instruction mac32.
- the number of output operands of the additional instruction mac32 is one.
- the number of input operands of the additional instruction mac32 is three.
- step 210 the compiler built-in function adding program 30 assigns a number first from the output operand, and assigns a number first to the operand described earlier in FIG.
- the compiler built-in function addition program 30 relates to the input / output operand of the additional instruction mac32.
- the number of the output operand rd is 0,
- the number of the input operand ra is 1,
- the number of the input operand rb is 2,
- the number of the input operand rc is 3,
- the number of the input / output operand is determined based on the ⁇ operand> tag.
- the number of the output operand rd is 0,
- the number of the input operand rm is 1,
- the number of the input operand rn is 2, It is decided.
- Step 220 is a process of determining the name of the RTL template based on the ⁇ nickname> tag and the ⁇ mnemonic> tag of the additional instruction.
- the format of the name of the RTL template is builtin_nkname_mnem. Therefore, the compiler built-in function addition program 30 is The name of the RTL template of the additional instruction mac32 is defined as buildin_mycpu_mac32. The name of the RTL template of the additional instruction avg2 is builtin_mycpu_avg2 And
- Step 230 is a process of generating an output operand description of the RTL template based on the ⁇ operand> tag of the additional instruction.
- the output operand of the additional instruction mac32 is only rd. According to step 210, since the number of the output operand rd is determined to be 0, the op_index of rd is 0.
- the mode's modemshort is SI.
- the compiler built-in function addition program 30 sets the output operand of the RTL template of the additional instruction mac32 as (18) below.
- the output operand of the RTL template is determined for the additional instruction avg2.
- Step 240 is a process for generating an output operand description of the RTL template based on the ⁇ operand> tag of the additional instruction.
- the input operand format of the register is (match_operand: modenameshort op_index "register_operand”"r") (20) It is.
- the input instruction mac32 has three input operands, ra, rb, and rc, all of which are 32-bit registers.
- step 210 of FIG. 4 the numbers of the input operands ra, rb, and rc are already determined as 1, 2, and 3, respectively. Therefore, the compiler built-in function addition program 30 sets the three input operands ra, rb, and rc of the RTL template of the additional instruction mac32 as follows.
- Input operand ra (match_operand: SI 1 “register_operand” “r”) (21)
- Input operand rc (match_operand: SI 3 “register_operand” “r”) (23)
- the input operand of the RTL template is determined for the additional instruction avg2.
- the two input operands rm and rn of the RTL template of the additional instruction avg2 are set as follows. Input operand rm: (match_operand: SI 1 “register_operand” “r”) (24) Input operand rn: (match_operand: SI 2 “register_operand” “r”) (25)
- Step 250 is a process of generating an operation description of the RTL template of the additional instruction.
- the format of the behavior description of the RTL template for additional instructions is (set output_operand (unspec: VOID [all_input_operands] unspec_insn_id)) (26) It is.
- Output_operand represents an output operand. This was generated in step 230.
- All_input_operand represents all input operands. This was generated in step 240.
- Unspec_insn_id is an appropriate number, and each additional instruction has a different value of unspec_insn_id.
- the compiler built-in function addition program 30 is 10000 unspec_insn_id of the additional instruction mac32 Unspec_insn_id of the additional instruction avg2 is set to 10001, And
- Step 260 is a process of generating the syntax of the RTL template based on the ⁇ syntax> tag of the additional instruction.
- the syntax of the additional instruction mac32 is “mac32% rd% ra% rb% rc”. This syntax includes a format character string (% rd,% ra,% rb,% rc). These format character strings correspond to input / output operands.
- step 260 the compiler built-in function addition program 30 replaces these format character strings with the operand numbers of the RTL template. % Rd is replaced with% 0,% ra is replaced with% 1,% rb is replaced with% 2, and% rc is replaced with% 3.
- the compiler built-in function addition program 30 uses the syntax of the RTL template of the additional instruction mac32 as follows: “Mac32% 0% 1% 2% 3” (27) And
- the syntax of the RTL template is determined for the additional instruction avg2.
- the syntax of the RTL template for the additional instruction avg2 is “Avg2% 0% 1% 2” (28) It is decided.
- Step 270 is processing for generating a word length definition sentence of the RTL template based on the ⁇ length> tag of the additional instruction.
- the format of the word length definition sentence in the RTL template is (set_attr “length” “len”) (29) It is.
- the word length of the additional instruction mac32 is 32 bits (4 bytes). Therefore, the compiler built-in function addition program 30 changes the word length definition sentence of the RTL template of the additional instruction mac32 to (set_attr “length” “4”) (30) And
- a word length definition sentence of the RTL template is generated for the additional instruction avg2.
- the word length definition sentence of the RTL template of the additional instruction avg2 is (set_attr "length”"4") (31) It is decided.
- Step 280 is processing for generating a mnemonic definition sentence of the RTL template based on the ⁇ mnemonic> tag of the additional instruction.
- the compiler built-in function adding program 30 converts the mnemonic definition statement of the RTL template of the additional instruction mac32 into (set_attr “mnemonic” “mac32”) (33) And
- a mnemonic definition sentence of the RTL template is generated for the additional instruction avg2.
- the mnemonic definition statement of the RTL template for the additional instruction avg2 is (set_attr "mnemonic""avg2") (34) It is decided.
- step 200 the compiler built-in function adding program 30 combines the ones generated in steps 210 to 230 into an RTL template (FIG. 15) of the additional instruction mac32 and an RTL template (FIG. 16) of the additional instruction avg2. ) And generate.
- step 300 of FIG. 3 the compiler built-in function addition program 30 generates a latency definition statement corresponding to the additional instruction described in FIG.
- step 300 is composed of three steps: step 310, step 320, and step 330.
- Steps 310 and 320 are processes for generating a definition sentence common to all additional instructions.
- FIG. 17 shows an example of a common definition sentence generated in step 310 and step 320.
- Step 330 for the two additional instructions described in FIG.
- step 330 the compiler built-in function addition program 30 generates a latency definition statement for each additional instruction.
- the format of the latency definition statement is (define_insn_reservation “mnem” ltcy (eq_attr “mnemonic””mnem”)”unti_builtin, nothing * ltcy_minus_1”)) (35) It is.
- the compiler built-in function addition program 30 sets the latency definition statement of the additional instruction mac32 as shown in FIG.
- a latency definition statement is also generated for the additional instruction avg2.
- the latency definition statement of the additional instruction avg2 is as shown in FIG.
- step 400 of FIG. 3 the compiler built-in function addition program 30 generates a built-in function prototype declaration corresponding to the additional instruction described in FIG.
- step 400 first, the compiler built-in function addition program 30 generates a definition statement that defines the name of the function that tells the compiler the prototype declaration of the built-in function. This definition sentence is as shown in FIG.
- step 400 the compiler built-in function addition program 30 generates a prototype declaration of the built-in function corresponding to the additional instruction mac32 and the additional instruction avg2 described in FIG.
- the format of the prototype declaration of the built-in function is as shown in FIG.
- the number of the output operand rd is 0, the number of the input operand ra is 1, the number of the input operand rb is 2, and the number of the input operand rc is 3.
- the bit widths of these operands are all 32 bits.
- the operand of the 32-bit width operand is an integer. Accordingly, the compiler built-in function addition program 30 sets all arguments of the function build_function_type_list () for the additional instruction mac32 to be integer_type_node.
- the nickname of the processor is mycpu.
- the mnemonic of the additional instruction mac32 is mac32.
- a prototype declaration of an embedded function is generated for the additional instruction avg2.
- the prototype declaration of the built-in function of the additional instruction avg2 is as shown in FIG.
- the compiler built-in function addition program 30 arranges the prototype declaration of the built-in function corresponding to the add instruction mac32 and the add instruction avg2 in the function target_init_builds ().
- step 500 of FIG. A definition statement that defines the name of a built-in function expansion function, The contents of the expansion function of the built-in function, Is generated. These do not depend on the specification description of the additional instruction.
- the definition statement that defines the name of the expansion function of the built-in function is as shown in FIG.
- the contents of the expansion function of the built-in function are as shown in FIG.
- step 600 of FIG. 3 the compiler built-in function addition program 30 adds a source code fragment to the compiler source code for the base processor (base processor compiler source code 50).
- the source code fragments are the following four items generated from step 200 to step 500.
- RTL template (generated in step 200 of FIG. 3: FIGS. 15 and 16); Latency definition statement (generated in step 300 of FIG. 3: FIGS. 17, 18 and 19); Built-in function prototype declaration (generated in step 400 of FIG. 3: FIGS. 8 and 22); Built-in function expansion function (generated in step 500 of FIG. 3: FIGS. 12 and 13)
- the nickname of the processor is mycpu. Therefore, in step 600, the source code of the compiler to which the CPU 10 of FIG. 1 adds the above source code fragment is mycpu. c and mycpu. There are two files named md. These two files become the base processor compiler source code 50.
- step 600 of FIG. 3 the compiler built-in function addition program 30 stores the RTL template (FIGS. 15 and 16) and the latency definition statement (FIGS. 17, 18, and 19) in the file mycpu. Append to the end of md.
- the compiler built-in function addition program 30 stores the built-in function prototype declaration (FIGS. 8 and 22) and the built-in function expansion function (FIGS. 12 and 13) in the file mycpu. Append to the end of c.
- the compiler correctly calculates the word length of the program including the additional instruction. Or additional instructions can be scheduled appropriately.
- program developers can develop programs using built-in functions. The processor designer can take advantage of the present invention in designing a processor instruction set for a specific application.
- Patent Documents 1-3 and Non-Patent Documents 1-4 above are incorporated herein by reference.
- the embodiments and examples can be changed and adjusted based on the basic technical concept.
- Various combinations and selections of various disclosed elements are possible within the scope of the claims of the present invention. That is, the present invention of course includes various variations and modifications that could be made by those skilled in the art according to the entire disclosure including the claims and the technical idea.
Landscapes
- Engineering & Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Devices For Executing Special Programs (AREA)
Abstract
Description
[関連出願の記載]
本発明は、日本国特許出願:特願2007-340532号(2007年12月28日出願)の優先権主張に基づくものであり、同出願の全記載内容は引用をもって本書に組み込み記載されているものとする。
本発明は、プロセッサのコンパイラ技術に関し、特に、基本となるプロセッサ(ベースプロセッサ)の命令セットへ追加された新たな命令(追加命令)に一対一に対応した組み込み関数をコンパイラへ追加する技術に関する。
[Description of related applications]
The present invention is based on the priority claim of Japanese patent application: Japanese Patent Application No. 2007-340532 (filed on Dec. 28, 2007), the entire contents of which are incorporated herein by reference. Shall.
The present invention relates to a compiler technique for a processor, and more particularly to a technique for adding an embedded function corresponding to a new instruction (additional instruction) added to an instruction set of a basic processor (base processor) to a compiler.
プロセッサの設計を効率良く行なうためにさまざまなツールが開発されている。この種のツールの一つにプロセッサの設計仕様からプロセッサのハードウェア構成やソフトウェア開発ツール(コンパイラ、アセンブラ、シミュレータなど)を生成するツールが用いられており、コンピュータ上で動作するプログラムとして提供される。ツールが動作するコンピュータは「プロセッサ設計支援装置」とも呼ばれる。 Various tools have been developed for efficient processor design. One of these types of tools is a tool that generates the hardware configuration of the processor and software development tools (compiler, assembler, simulator, etc.) from the design specifications of the processor, and is provided as a program that runs on a computer. . The computer on which the tool operates is also called a “processor design support device”.
設計者が定義したプロセッサの命令セットに基づいてプロセッサのためのアセンブラやコンパイラを生成するプロセッサ設計支援装置が、非特許文献1、特許文献1乃至3等に開示されている。
Non-Patent
非特許文献1、特許文献1乃至3等に開示されているプロセッサ設計支援装置は、基本となるプロセッサ(「ベースプロセッサ」という)へ新たな命令を追加することができる。ベースプロセッサへ追加された命令に対応する組み込み関数をコンパイラから利用可能にするために、インラインアセンブラで記述された関数を組み込み関数として定義するようなヘッダファイルをプロセッサ設計支援装置が生成する。なお、ヘッダファイルの生成については、特許文献1(段落番号0329)、特許文献2(段落番号0056)、特許文献3(段落番号0052)等の記載も参照される。
The processor design support apparatus disclosed in Non-Patent
組み込み関数は、プロセッサの命令に一対一に対応する関数である。 ∙ Built-in functions are functions that correspond one-to-one with processor instructions.
組み込み関数を使うことによって、プログラム開発者は、コンパイラが通常使用しない命令をコンパイラに使用させることができる。 By using built-in functions, program developers can let the compiler use instructions that the compiler does not normally use.
コンパイラは、組み込み関数を通常の関数の一つとして扱うため、組み込み関数の引数や戻り値に関するレジスタ割当をコンパイラが行う。 ∙ The compiler handles built-in functions as one of the normal functions, so the compiler performs register allocation for arguments and return values of built-in functions.
インラインアセンブラは、例えば、C言語のソースコードの中に記述されたアセンブラ言語である。インラインアセンブラを使うことによって、ソースコードの中にアセンブラ言語を挿入することができる。 The inline assembler is, for example, an assembler language described in C language source code. By using an inline assembler, assembler language can be inserted into the source code.
以上の非特許文献1乃至4及び特許文献1乃至3の開示事項は、本書に引用をもって繰り込み記載されているものとする。以下に本発明による関連技術の分析を与える。
The disclosures of
特許文献1乃至3等の上記関連技術においては、コンパイラ組み込み関数の追加は、ベースプロセッサのためのコンパイラを何ら変更せずに、ヘッダファイルだけを追加することによって追加命令のための組み込み関数を使用可能にする。
In the related technologies such as
すなわち、ヘッダファイルをコンパイラへ追加するだけなので、コンパイラの変更が必要ないという利点がある。 That is, there is an advantage that no compiler change is required since only the header file is added to the compiler.
しかしながら、上記関連技術によるコンパイラ組み込み関数の追加においては、追加命令の命令語長や、レイテンシなどの情報はまったくコンパイラに反映されない、という問題がある。 However, when a compiler built-in function is added by the related technology, there is a problem that information such as instruction word length of an additional instruction and latency is not reflected in the compiler at all.
なお、命令語長は、追加命令が何バイトの命令であるかを表す情報である。 The instruction word length is information indicating how many bytes the additional instruction is.
レイテンシは、追加命令の演算結果が何サイクル後に得られるかを表す情報である。 Latency is information indicating how many cycles the operation result of the additional instruction is obtained.
上記関連技術によるコンパイラ組み込み関数の追加において、追加命令の命令語長をコンパイラへ知らせることができない。このため、コンパイラは、追加命令の語長が全て同一で、既知の値をもつと仮定しなければならない。 * When adding a compiler built-in function using the above related technology, the instruction word length of the additional instruction cannot be notified to the compiler. For this reason, the compiler must assume that the word lengths of the additional instructions are all the same and have known values.
これは語長が異なる追加命令を作成できないことを意味する。 This means that additional commands with different word lengths cannot be created.
さらに、上記関連技術によるコンパイラ組み込み関数の追加において、追加命令のレイテンシをコンパイラへ知らせることができないことから、コンパイラがその追加命令を効率良くスケジューリングすることができない。対象となるソースコードの制御フローやデータフローの情報を利用して、コンパイラは追加命令を効率良くスケジューリングできる可能性があるが、上記関連技術ではそれが不可能である。 Furthermore, in the addition of the compiler built-in function according to the related technology, the compiler cannot inform the compiler of the latency of the additional instruction, so the compiler cannot schedule the additional instruction efficiently. There is a possibility that the compiler can efficiently schedule additional instructions using the control flow and data flow information of the target source code, but this is not possible with the related technology.
上記の如く、関連技術によるコンパイラ組み込み関数の追加においては、追加命令の命令語長やレイテンシなどの情報はまったくコンパイラに反映されない。 As described above, when adding a compiler built-in function according to related technology, information such as the instruction word length and latency of the additional instruction is not reflected in the compiler at all.
したがって、本発明の主たる目的は、コンパイラ組み込み関数の追加において、追加命令の命令語長やレイテンシなどの仕様情報をコンパイラに反映可能とする装置、方法、プログラムを提供することにある。 Therefore, a main object of the present invention is to provide an apparatus, a method, and a program that allow specification information such as the instruction word length and latency of an additional instruction to be reflected in the compiler when a compiler built-in function is added.
本発明の1つの側面においては、基本となるプロセッサ(ベースプロセッサ)の命令セットへ追加される追加命令について、追加命令に対応する組み込み関数をベースプロセッサのコンパイラへ追加する。本発明においては、追加命令の命令語長やレイテンシの情報をコンパイラが理解できるようにするためのソースコードを、ベースコンパイラのソースコードへ追加することによって、組み込み関数をコンパイラへ追加する。 In one aspect of the present invention, for an additional instruction added to the instruction set of the basic processor (base processor), an embedded function corresponding to the additional instruction is added to the compiler of the base processor. In the present invention, an intrinsic function is added to the compiler by adding source code for enabling the compiler to understand the instruction word length and latency information of the additional instruction to the source code of the base compiler.
本発明によれば、ベースプロセッサ用のコンパイラのソースコードに対して、ベースプロセッサの命令セットに新たに追加される追加命令の仕様記述に基づいて、その追加命令を備えたベースプロセッサである拡張プロセッサ用のコンパイラのソースコードを生成することにより、該追加命令に対応する組み込み関数をコンパイラへ追加する組み込み関数追加処理を実行する装置が提供される。 According to the present invention, based on the specification description of an additional instruction newly added to the instruction set of the base processor with respect to the source code of the compiler for the base processor, the extended processor which is a base processor having the additional instruction By generating the source code of the compiler for use, an apparatus for executing an embedded function addition process for adding an embedded function corresponding to the additional instruction to the compiler is provided.
本発明によれば、ベースプロセッサ用のコンパイラのソースコードを入力し、前記ベースプロセッサの命令セットに新たに追加される追加命令の仕様記述に基づき、前記ベースプロセッサ用のコンパイラのソースコードから、前記追加命令を命令セットに備えた拡張プロセッサ用のコンパイラのソースコードを生成し、前記追加命令に対応する組み込み関数を、前記拡張プロセッサ用のコンパイラへ追加する組み込み関数追加処理をコンピュータに実行させるプログラムが提供される。 According to the present invention, the source code of the compiler for the base processor is input, and based on the specification description of the additional instruction newly added to the instruction set of the base processor, the source code of the compiler for the base processor A program for generating a source code of a compiler for an extended processor having an additional instruction in an instruction set and causing the computer to execute an embedded function adding process for adding an embedded function corresponding to the additional instruction to the compiler for the extended processor. Provided.
本発明によれば、ベースプロセッサ用のコンパイラのソースコードを入力し、前記ベースプロセッサの命令セットに新たに追加される追加命令の仕様記述に基づき、前記ベースプロセッサ用のコンパイラのソースコードから、前記追加命令を命令セットに備えた拡張プロセッサ用のコンパイラのソースコードを生成し、前記追加命令に対応する組み込み関数を、前記拡張プロセッサ用のコンパイラへ追加する組み込み関数追加処理を実行する方法が提供される。 According to the present invention, the source code of the compiler for the base processor is input, and based on the specification description of the additional instruction newly added to the instruction set of the base processor, the source code of the compiler for the base processor A method for generating a compiler source code for an extended processor having an additional instruction in an instruction set and executing an embedded function adding process for adding an embedded function corresponding to the additional instruction to the compiler for the extended processor is provided. The
本発明において、前記組み込み関数追加処理は、
追加命令の仕様記述を読み込む処理と、
前記仕様記述に基づいて追加命令の構成定義文を生成する処理と、
前記仕様記述に基づいて追加命令とそれに対応する組み込み関数との関係定義文を生成する処理と、
前記構成定義文と前記関係定義文とを前記ベースプロセッサのためのコンパイラのソースコードへ追加することによって前記拡張プロセッサのためのコンパイラのソースコードを生成する処理と、を含むようにしてもよい。
In the present invention, the built-in function adding process is:
Processing to read the specification description of the additional instruction;
Processing for generating a configuration definition statement of an additional instruction based on the specification description;
Processing for generating a relationship definition statement between an additional instruction and a corresponding built-in function based on the specification description;
Processing for generating a compiler source code for the extension processor by adding the configuration definition statement and the relationship definition statement to the source code of the compiler for the base processor.
本発明において、前記構成定義文は、コンパイラの中間言語で表現された追加命令のテンプレートと、追加命令の実行に必要なサイクル数を定義するレイテンシ定義文と、から構成され、前記構成定義文を生成する処理が、前記仕様記述に含まれる追加命令の名前と入力オペランドと出力オペランドとに基づいて前記テンプレートを生成し、さらに前記仕様記述に含まれる追加命令の実行に必要なサイクル数に基づいて前記レイテンシ定義文を生成する、構成としても良い。 In the present invention, the configuration definition statement includes an additional instruction template expressed in an intermediate language of a compiler, and a latency definition statement that defines the number of cycles required to execute the additional instruction, and the configuration definition statement is The generating process generates the template based on the name of the additional instruction, the input operand, and the output operand included in the specification description, and further, based on the number of cycles necessary for executing the additional instruction included in the specification description. The latency definition sentence may be generated.
本発明において、前記関係定義文は、追加命令に対応する組み込み関数のプロトタイプ宣言と、組み込み関数を追加命令へ置き換えるための組み込み関数展開関数と、から構成され、前記関係定義文を生成する処理が、前記仕様記述に含まれる追加命令の名前と入力オペランドと出力オペランドとに基づいて前記組み込み関数のプロトタイプ宣言を生成し、さらにコンパイラの所定の形式に基づいて前記組み込み関数展開関数を生成する、構成としても良い。 In the present invention, the relationship definition statement includes a prototype declaration of an embedded function corresponding to an additional instruction and an embedded function expansion function for replacing the embedded function with the additional instruction, and the process of generating the relationship definition statement includes Generating a prototype declaration of the built-in function based on the name of an additional instruction included in the specification description, an input operand, and an output operand, and further generating the built-in function expansion function based on a predetermined format of a compiler It is also good.
本発明において、前記構成定義文における前記テンプレートを生成する際に、第一のコンパイラ組み込み関数追加装置は、
前記仕様記述の追加命令の出力オペランドと入力オペランドとを順番に並べることによって追加命令の中間言語定義文におけるオペランドの番号を決定し、
前記仕様記述の追加命令の名前に基づいてテンプレートの名前を生成し、
前記仕様記述の追加命令の出力オペランドの型に基づいてテンプレートの出力オペランドの記述を生成し、
前記仕様記述の追加命令の入力オペランドの型に基づいてテンプレートの入力オペランドの記述を生成し、
追加命令がコンパイラにとって不明な演算を実行することを示す演算子をもちいてテンプレートにおける追加命令の動作記述を生成し、
前記仕様記述の追加命令のシンタックスに含まれるオペランドを前記オペランド番号で置き換えることによってテンプレートのシンタックスを生成し、
前記仕様記述の追加命令の命令語長に基づいてテンプレートにおける命令語長定義文を生成し、
前記仕様記述の追加命令の名前に基づいてテンプレートにおけるニモニック定義文を生成する、という一連の処理を行う構成としても良い。
In the present invention, when generating the template in the configuration definition statement, the first compiler built-in function adding device,
Determining the operand number in the intermediate language definition statement of the additional instruction by arranging the output operand and the input operand of the additional instruction of the specification description in order;
Generating a name for the template based on the name of the additional instruction in the specification description;
Generating a description of the output operand of the template based on the type of the output operand of the additional instruction of the specification description;
Generating a description of the input operand of the template based on the type of the input operand of the additional instruction of the specification description;
Generate an action description of the additional instruction in the template using an operator that indicates that the additional instruction performs an operation unknown to the compiler,
Generating a template syntax by replacing an operand included in the syntax of the additional instruction in the specification description with the operand number;
Generating an instruction word length definition statement in the template based on the instruction word length of the additional instruction in the specification description;
A configuration may be adopted in which a series of processes of generating a mnemonic definition sentence in the template based on the name of the additional instruction in the specification description is performed.
本発明によれば、コンパイラ組み込み関数の追加において、追加命令の命令語長やレイテンシなどの情報をコンパイラに反映することができる。 According to the present invention, when a compiler built-in function is added, information such as instruction word length and latency of the additional instruction can be reflected in the compiler.
10 CPU
20 記憶装置
30 コンパイラ組み込み関数追加プログラム
40 追加命令仕様記述ファイル
50 ベースプロセッサ用コンパイラソースコード
60 拡張プロセッサ用コンパイラソースコード
61 追加命令の構成定義文
62 追加命令のテンプレート
63 追加命令のレイテンシを定義するレイテンシ定義
64 追加命令と組み込み関数との関係定義文
65 組み込み関数のプロトタイプ宣言
66 組み込み関数展開関数
70 コンパイラ組み込み関数追加装置
10 CPU
DESCRIPTION OF SYMBOLS 20 Storage device 30 Compiler built-in function additional program 40 Additional instruction specification description file 50 Base processor compiler source code 60 Extended processor compiler source code 61 Additional instruction configuration definition statement 62 Additional instruction template 63 Latency for defining additional instruction latency Definition 64 Definition statement of relationship between additional instruction and built-in function 65 Prototype declaration of built-in function 66 Built-in function expansion function 70 Compiler built-in function adding device
本発明の実施の形態について図面を参照して詳細に説明する。本発明のコンパイラ組み込み関数追加装置は、ベースプロセッサへの追加命令に関する仕様記述に基づいて、ベースプロセッサのためのコンパイラへその追加命令に対応する組み込み関数を追加する装置である。 Embodiments of the present invention will be described in detail with reference to the drawings. The compiler built-in function adding device according to the present invention is a device that adds a built-in function corresponding to the additional instruction to the compiler for the base processor based on the specification description regarding the additional instruction to the base processor.
組み込み関数は、「イントリンジック(intrinsic)」とも呼ばれる。組み込み関数とはプロセッサの命令に一対一に対応する関数である。 The built-in function is also called “intrinsic”. Built-in functions are functions that correspond one-to-one with processor instructions.
一般的には、プログラムのソースコードの中で組み込み関数を使うと、それは対応する命令へコンパイラによって置き換えられる。 Generally, when an embedded function is used in the source code of a program, it is replaced by the compiler with the corresponding instruction.
ベースプロセッサへの追加命令に対応した組み込み関数をコンパイラへ追加すると、プログラム開発者は、その追加命令を関数呼び出しのような形式でコンパイラから使用することができる。 When an embedded function corresponding to an additional instruction to the base processor is added to the compiler, the program developer can use the additional instruction from the compiler in the form of a function call.
本発明の一実施例においては、ベースプロセッサのコンパイラは既に存在しており、該コンパイラのソースコードも利用可能であることを前提としている。 In one embodiment of the present invention, it is assumed that a compiler for a base processor already exists and that the source code of the compiler can also be used.
かかる前提において、追加命令に対応する組み込み関数をコンパイラが扱えるようにするために、ベースプロセッサのコンパイラのソースコードを修正する。該ソースコードの修正においては、追加命令のための組み込み関数を扱うために必要となるソースコードの断片を、コンパイラのソースコードへ追加する修正が行われる。本発明によれば、追加命令の命令語長やレイテンシなどの情報をコンパイラに反映させることができる。この結果、コンパイラは、追加命令を含むプログラムの語長を正しく計算したり、追加命令を適切にスケジューリングすることが可能となる。 Based on this premise, the source code of the compiler for the base processor is modified so that the compiler can handle the built-in functions corresponding to the additional instructions. In the modification of the source code, a modification is performed in which a fragment of the source code necessary for handling the built-in function for the additional instruction is added to the source code of the compiler. According to the present invention, information such as the instruction word length and latency of the additional instruction can be reflected in the compiler. As a result, the compiler can correctly calculate the word length of the program including the additional instruction and can appropriately schedule the additional instruction.
図1は、本発明の模範的な一実施例におけるコンパイラ組み込み関数追加装置の構成を示す図である。コンパイラ組み込み関数追加装置70は、CPU10と、記憶装置20と、コンパイラ組み込み関数追加手段(コンパイラ組み込み関数追加プログラム)30と、追加命令仕様記述ファイル40と、ベースプロセッサ用コンパイラソースコード50と、拡張プロセッサ用コンパイラソースコード60と、を備えている。コンパイラ組み込み関数追加手段30は、CPU10で実行されるプログラムによって処理・機能が実現されため、コンパイラ組み込み関数追加プログラム30ともいう。
FIG. 1 is a diagram showing a configuration of a compiler built-in function adding device in an exemplary embodiment of the present invention. The compiler built-in function adding device 70 includes a
CPU10がコンパイラ組み込み関数追加プログラム30を実行することによって、記憶装置20から追加命令仕様記述ファイル40とベースプロセッサ用コンパイラソースコード50とを読み込み、追加命令仕様記述ファイル40に記述された追加命令に対応する組み込み関数の定義文を生成し、追加命令に対応する組み込み関数の定義文をベースプロセッサ用コンパイラソースコード50へ追加したものを、拡張プロセッサ用コンパイラソースコード60とし、拡張プロセッサ用コンパイラソースコード60を記憶装置20へ格納する。
When the
コンパイラ組み込み関数追加装置70は、一般的なコンピュータ(例えば、パーソナルコンピュータ)をもちいて実現可能である。使用者(ユーザ)は、拡張プロセッサ用コンパイラソースコード60を使って、拡張プロセッサ用コンパイラを構築することも可能である。さらに、その構築機能を、コンパイラ組み込み関数追加装置70に付加することも可能である。 The compiler built-in function adding device 70 can be realized using a general computer (for example, a personal computer). The user (user) can also build an extended processor compiler using the extended processor compiler source code 60. Furthermore, the construction function can be added to the compiler built-in function adding device 70.
図2は、図1のコンパイラ組み込み関数追加プログラム30の入出力関係の詳細を示す図である。コンパイラ組み込み関数追加プログラム30の入力ファイルは、追加命令仕様記述ファイル40と、ベースプロセッサ用コンパイラソースコード50である。 FIG. 2 is a diagram showing details of the input / output relationship of the compiler built-in function addition program 30 of FIG. The input files of the compiler built-in function adding program 30 are an additional instruction specification description file 40 and a base processor compiler source code 50.
コンパイラ組み込み関数追加プログラム30の最終的な出力ファイルは、拡張プロセッサ用コンパイラソースコード60である。 The final output file of the compiler built-in function addition program 30 is the compiler source code 60 for the extended processor.
拡張プロセッサ用コンパイラソースコード60は、ベースプロセッサ用コンパイラソースコード50と、追加命令の構成定義文61と、追加命令と組み込み関数との関係定義文64と、を含む。 The extended processor compiler source code 60 includes a base processor compiler source code 50, a configuration definition statement 61 of an additional instruction, and a relationship definition statement 64 of the additional instruction and an embedded function.
コンパイラ組み込み関数追加プログラム30を実行することによって、CPU10は、追加命令仕様記述ファイル40に基づいて、追加命令の構成定義文61と、追加命令と組み込み関数との関係定義文64とを生成する。
By executing the compiler built-in function addition program 30, the
さらに、CPU10は、追加命令の構成定義文61と、追加命令と組み込み関数との関係定義文64とを、ベースプロセッサ用コンパイラソースコード50へ追加する。そして、CPU10は、追加命令の構成定義文61と、追加命令と組み込み関数との関係定義文64と追加したソースコードを、拡張プロセッサ用コンパイラソースコード60として出力する。
Further, the
追加命令の構成定義文61は、コンパイラの中間言語で定義された追加命令のテンプレート62と、追加命令のレイテンシを定義するレイテンシ定義文63と、を含む。 The additional instruction configuration definition statement 61 includes an additional instruction template 62 defined in an intermediate language of the compiler, and a latency definition sentence 63 that defines the latency of the additional instruction.
テンプレート62は、一般的には、「RTL(register transfer language)」と呼ばれるコンパイラの中間言語で記述される。以下では、テンプレート62の具体的な例を「RTLテンプレート」と呼ぶことにする。 The template 62 is generally described in an intermediate language of a compiler called “RTL (register transfer language)”. Hereinafter, a specific example of the template 62 will be referred to as an “RTL template”.
レイテンシ定義文63は、追加命令の実行に必要なサイクル数(レイテンシ)を定義する。 The latency definition statement 63 defines the number of cycles (latency) necessary for executing the additional instruction.
追加命令と組み込み関数との関係定義文64は、追加命令に対応する組み込み関数のプロトタイプ宣言65と、組み込み関数の展開関数66と、を含む。 The relation definition statement 64 between the additional instruction and the built-in function includes a prototype declaration 65 of the built-in function corresponding to the additional instruction and an expansion function 66 of the built-in function.
組み込み関数のプロトタイプ宣言65は、組み込み関数の戻り値や引数の型を定義する。 The prototype declaration 65 of the built-in function defines the return value and argument type of the built-in function.
組み込み関数のプロトタイプ宣言65によって、拡張プロセッサ用コンパイラは、組み込み関数の名前、戻り値や引数の型を知ることができる。 The built-in function prototype declaration 65 allows the compiler for the extended processor to know the name of the built-in function, the return value, and the argument type.
組み込み関数の展開関数66は、組み込み関数に対応する追加命令を検出するために、拡張プロセッサ用コンパイラが用いる関数である。 The expansion function 66 of the built-in function is a function used by the compiler for the extended processor in order to detect an additional instruction corresponding to the built-in function.
図3は、コンパイラ組み込み関数追加プログラム30の処理手順を示すフローチャートである。図3を参照すると、コンパイラ組み込み関数追加プログラム30は、
仕様記述の読み込み処理を行うステップ100と、
RTLテンプレートを生成する処理を行うステップ200と、
レイテンシ定義文を生成する処理を行うステップ300と、
組み込み関数プロトタイプ宣言を生成する処理を行うステップ400と、
組み込み関数展開関数を生成する処理を行うステップ500と、
コンパイラソースコードの追加処理を行うステップ600と、
を含む。
FIG. 3 is a flowchart showing the processing procedure of the compiler built-in function addition program 30. Referring to FIG. 3, the compiler built-in function addition program 30 is
A step 100 for reading the specification description;
Step 200 for performing processing for generating an RTL template;
Step 300 for performing processing for generating a latency definition statement;
A step 400 of performing a process of generating a built-in function prototype declaration;
Step 500 for performing processing for generating an embedded function expansion function;
Step 600 for performing additional processing of compiler source code;
including.
本実施例において、図3に示したフローチャートの処理手順をコンピュータに実行させるためのコンピュータプログラムを、コンパイラ組み込み関数追加装置70へ所定の媒体等を介して供給し、該コンピュータプログラムをコンパイラ組み込み関数追加装置70のCPU10が主メモリにロードして実行するようにしてもよい。また、コンパイラ組み込み関数追加装置70に供給されたコンピュータプログラムは、読み書き可能なメモリまたはハードディスク装置などの記憶媒体に格納すれば良い。本発明は、係るコンピュータプログラムあるいは記憶媒体によって構成される。
In this embodiment, a computer program for causing the computer to execute the processing procedure of the flowchart shown in FIG. 3 is supplied to the compiler built-in function adding device 70 via a predetermined medium or the like, and the computer program is added to the compiler built-in function. The
以下では、まず、追加命令に関する仕様記述について説明してから、図3の各ステップを説明する。 In the following, first, the specification description regarding the additional instruction will be described, and then each step of FIG. 3 will be described.
[ベースプロセッサへの追加命令に関する仕様記述]
前述したように、コンパイラ組み込み関数追加プログラム30への入力は、ベースプロセッサへの追加命令に関する仕様記述ファイル40である。特に制限されないが、本実施例において、追加命令の仕様記述は、XML(extensible markup language)に基づいている。追加命令の仕様を、XMLで記述することによって、XMLに対応した既存の字句解析器や構文解析器を使って追加命令の仕様記述を解析したり変換したりできる。そのため、追加命令の仕様記述の解析や変換が容易になる。なお、XML以外の言語を使ったとしても、追加命令の仕様を記述することは可能である。
[Specification description for additional instructions to base processor]
As described above, the input to the compiler built-in function addition program 30 is the specification description file 40 regarding the additional instruction to the base processor. Although not particularly limited, in the present embodiment, the specification description of the additional instruction is based on XML (extensible markup language). By describing the specification of the additional instruction in XML, it is possible to analyze or convert the specification description of the additional instruction using an existing lexical analyzer or syntax analyzer that supports XML. This facilitates the analysis and conversion of the specification description of the additional instruction. Even if a language other than XML is used, it is possible to describe the specifications of additional instructions.
以下、XMLに基づいた追加命令の仕様記述について説明する。 The following describes the specification description of the additional instruction based on XML.
追加命令の仕様記述のためのXMLのタグは、<nickname>と<insn>である。 XML tags for specification description of additional instructions are <nickname> and <insn>.
<nickname>タグは、ターゲットとなるプロセッサのニックネームを定義するタグである。ニックネームの文字数は任意であり、ニックネームとして使用可能な文字はアルファベットと数字である。<nickname>タグで定義されたニックネームは、コンパイラ組み込み関数追加プログラム30によって生成される変数や関数などの名前の一部に使用される。 The <nickname> tag is a tag that defines a nickname of a target processor. The number of characters in the nickname is arbitrary, and the characters that can be used as the nickname are alphabets and numbers. The nickname defined by the <nickname> tag is used as a part of the name of a variable, function, or the like generated by the compiler built-in function addition program 30.
<nickname>タグの記述例を以下に示す。 <Example of <nickname> tag description is shown below.
<nickname>foo</nickname> <Nickname> foo </ nickname>
<insn>タグはターゲットプロセッサの命令を定義するタグである。
<insn>タグの値は命令のシンタックスや語長や入力オペランドを定義するための別のタグである。
The <insn> tag is a tag that defines an instruction of the target processor.
The value of the <insn> tag is another tag for defining instruction syntax, word length, and input operand.
<insn>タグの記述例を、図14に示す。図14に例示したように、<insn>タグの値として記述可能なタグは以下の六個である。 FIG. 14 shows a description example of the <insn> tag. As illustrated in FIG. 14, the following six tags can be described as values of the <insn> tag.
<mnemonic>は、命令のニモニックを定義するタグである。 <Mnemonic> is a tag that defines the mnemonic of the instruction.
<syntax>は、命令のシンタックスを定義するタグである。 <Syntax> is a tag that defines the syntax of an instruction.
<length>は、命令の語長を定義するタグである。 <Length> is a tag that defines the word length of the instruction.
<latency>は、命令のレイテンシを定義するタグである。 <Latency> is a tag that defines the latency of the instruction.
<output>は、命令が値を書き込む出力オペランドを定義するタグである。 <Output> is a tag that defines an output operand into which an instruction writes a value.
<input>は、命令が使用する入力オペランドを定義するタグである。
以下、<insn>タグの値として記述可能なタグについて詳しく説明する。
<Input> is a tag that defines an input operand used by the instruction.
Hereinafter, tags that can be described as values of the <insn> tag will be described in detail.
<mnemonic>タグは、命令のニモニックを定義するタグである。ニモニックの文字数は任意であり、ニモニックとして使用可能な文字はアルファベットと数字である
(図14ではmac32)。
The <mnemonic> tag is a tag that defines a mnemonic of an instruction. The number of mnemonic characters is arbitrary, and the characters that can be used as mnemonics are alphabets and numbers (mac32 in FIG. 14).
ある命令のニモニックは他のどの命令のニモニックとも同じであってはならない。ニモニックでは大文字と小文字を区別しない。例えば、ニモニックFooとニモニックfooを同一であると見なす。命令のニモニックはその命令に対応する組み込み関数の名前の一部に使用される。 The mnemonic of one instruction must not be the same as the mnemonic of any other instruction. Mnemonics are not case sensitive. For example, mnemonic Foo and mnemonic foo are considered to be the same. An instruction mnemonic is used as part of the name of the built-in function corresponding to the instruction.
<syntax>タグは、命令のシンタックスを定義するタグである。 The <syntax> tag is a tag that defines the syntax of an instruction.
<syntax>タグの値は、命令のシンタックスを表す任意の文字列(図14の”mac32 %rd %ra %rb %rc”)である。この文字列には、フォーマット文字列を含めることができる。フォーマット文字列とは命令オペランドの出力位置を指定するための文字列である。フォーマット文字列は%記号で始まる。%記号に続く文字列(例えばrd)は、後述する<operand>タグの値と一致しなければならない。<operand>タグについては後で説明する。 The value of the <syntax> tag is an arbitrary character string (“mac32% rd% ra% rb% rc” in FIG. 14) representing the syntax of the instruction. This character string can include a format character string. The format character string is a character string for designating the output position of the instruction operand. The format string begins with a% symbol. A character string (for example, rd) following the% symbol must match a value of an <operand> tag described later. The <operand> tag will be described later.
フォーマット文字列は、オペランドを表す適切な文字列で置き換えられる。例えば、レジスタを表す<operand>タグに対応するフォーマット文字列はレジスタの名前に置き換えられ、即値を表す<operand>タグに対応するフォーマット文字列はレジスタの名前に置き換えられる。 The format string is replaced with an appropriate string representing the operand. For example, a format character string corresponding to an <operand> tag representing a register is replaced with a register name, and a format character string corresponding to an <operand> tag representing an immediate value is replaced with a register name.
<length>タグは、命令の語長をビット単位で定義するタグである。ただし、
命令語長は8の倍数とする(図14では32ビット、すなわち4バイト)。
The <length> tag is a tag that defines the word length of an instruction in bits. However,
The instruction word length is a multiple of 8 (in FIG. 14, 32 bits, that is, 4 bytes).
<latency>タグは、命令のレイテンシを定義するタグである。レイテンシとは命令を実行してからその命令の実行結果が利用可能になるまでにかかるサイクル数である。命令のレイテンシは、プログラムの文脈に応じて変化することも考えられる。そのような場合は、考えられる最長のレイテンシをこのタグで定義する。 The <latency> tag is a tag that defines the latency of an instruction. Latency is the number of cycles it takes for an instruction to execute after the instruction is executed. The instruction latency may vary depending on the program context. In such cases, this tag defines the longest possible latency.
<output>タグは、命令の出力オペランドを定義するタグである。<output>タグの値はオペランドを表す<operand>タグである。 The <output> tag is a tag that defines an output operand of an instruction. The value of the <output> tag is an <operand> tag that represents an operand.
<input>タグは、命令の入力オペランドを定義するタグである。<input>タグの値はオペランドを表す<operand>タグである。 The <input> tag is a tag that defines an input operand of an instruction. The value of the <input> tag is an <operand> tag that represents an operand.
<operand>タグは、追加命令のオペランドを定義するタグである。<operand>タグは、<output>タグや<input>タグの値として使用される。<operand>タグの値は、オペランドの名前である。この名前は<syntax>タグのフォーマット文字列(例えば%rd)と関連している。 The <operand> tag is a tag that defines an operand of an additional instruction. The <operand> tag is used as a value of an <output> tag or an <input> tag. The value of the <operand> tag is the name of the operand. This name is associated with the format string (eg% rd) of the <syntax> tag.
<operand>タグで定義されたオペランドの名前だけを<syntax>タグで定義された命令のシンタックスにおけるフォーマット文字列として使用することができる。 Only the name of the operand defined by the <operand> tag can be used as a format character string in the syntax of the instruction defined by the <syntax> tag.
<operand>タグで定義されていないオペランドの名前をフォーマット文字列として使うことはできない。<operand>タグはtypeとwidthという二つの属性をもつ。 * Operand names not defined in the <operand> tag cannot be used as format strings. The <operand> tag has two attributes, type and width.
属性typeは、オペランドの型を表す属性である。この属性の値として使用可能な名前は、registerとimmediateである。 Attribute type is an attribute that represents the operand type. The names that can be used as the value of this attribute are register and immediate.
registerは、オペランドがレジスタであることを表す。 Register indicates that the operand is a register.
immeidateは、オペランドが即値であることを表す。 Immediate indicates that the operand is an immediate value.
属性widthはオペランドのビット幅を表す属性である。 Attribute width is an attribute that represents the bit width of the operand.
[追加命令の仕様記述の読み込み処理]
コンパイラ組み込み関数追加装置70(図1)における追加命令の仕様記述の読み込み処理について説明する。この処理は、図3のステップ100である。この処理において、図1のCPU10は、XMLで記述された追加命令の仕様記述を読み込んで、それらをコンピュータプログラムが理解可能なデータ構造に置き換える。
[Loading specification description of additional instructions]
Processing for reading the specification description of the additional instruction in the compiler built-in function adding device 70 (FIG. 1) will be described. This process is step 100 in FIG. In this process, the
追加命令の仕様記述は、XMLの言語仕様に基づき、<nickname>タグや<insn>タグで記述されている。したがって、XMLのための一般的な字句解析器と構文解析器とを使って、図1のCPU10は、追加命令の仕様記述をコンピュータプログラムが理解可能なデータ構造に置き換える。置き換えられたデータ構造は、追加命令仕様記述ファイル40に記述されたタグに一対一に対応する。したがって、以降は、該データ構造の代わりにタグを参照して、図1の動作を説明する。
The specification description of the additional instruction is described by a <nickname> tag or an <insn> tag based on the XML language specification. Therefore, using a general lexical analyzer and syntax analyzer for XML, the
[RTLテンプレート生成処理]
コンパイラ組み込み関数追加装置70における追加命令のためのRTLテンプレート生成処理について説明する。この処理は図3のステップ200である。
[RTL template generation processing]
An RTL template generation process for an additional instruction in the compiler built-in function adding device 70 will be described. This process is step 200 in FIG.
RTL(register transfer language)とは、コンパイラにおける中間言語である。コンパイラはC/C++などの高級言語で記述されたソースコードをRTLと呼ばれる中間言語に変換し、RTLに基づいて、プロセッサの命令を出力する。RTLとプロセッサの命令は一対一に対応している。RTLテンプレートとはプロセッサの命令をRTLで表現したものである。一般的に、コンパイラがプロセッサの命令の動作を理解できるように、RTLテンプレートを記述する。 RTL (register transfer language) is an intermediate language in the compiler. The compiler converts source code described in a high-level language such as C / C ++ into an intermediate language called RTL, and outputs a processor instruction based on the RTL. There is a one-to-one correspondence between RTL and processor instructions. An RTL template is a representation of processor instructions in RTL. Generally, RTL templates are written so that the compiler can understand the operation of the processor instructions.
しかし、本実施例では、追加命令の正確な動作はRTLテンプレートには記述しない。本実施例においては、コンパイラが追加命令の入出力オペランドだけを正しく理解できるようなRTLテンプレートを出力する。このようにすることで、追加命令の動作をRTLテンプレートで正しく表現する、という複雑な問題を回避する。 However, in this embodiment, the exact operation of the additional instruction is not described in the RTL template. In this embodiment, the RTL template is output so that the compiler can correctly understand only the input / output operands of the additional instruction. By doing so, the complicated problem of correctly expressing the operation of the additional instruction with the RTL template is avoided.
追加命令のためのRTLテンプレートの例を、図15に示す。図15は、積和演算命令のためのRTLテンプレートである。 FIG. 15 shows an example of the RTL template for the additional instruction. FIG. 15 is an RTL template for a product-sum operation instruction.
RTLテンプレートは、define_insnという式で記述される。define_insn式は、Lisp言語の式に似ている。なお、define_insn式の詳しい説明については、非特許文献2の第239ページ、“14 Machine Description”,又は非特許文献2の第178頁の“機械記述”の記載が参照される。
The RTL template is described by an expression “define_insn”. The define_insn expression is similar to an expression in the Lisp language. For a detailed description of the define_insn formula, refer to the description on page 239 of
本実施例における追加命令のためのRTLテンプレートは、
(1)RTLテンプレートの名前、
(2)出力オペランド、
(3)入力オペランド、
(4)追加命令の動作記述、
(5)追加命令のシンタックス、
(6)追加命令の語長、
(7)追加命令のニモニック、
の7個の要素を含む。
The RTL template for additional instructions in this example is
(1) RTL template name,
(2) Output operand,
(3) input operands,
(4) Action description of additional instructions,
(5) Additional instruction syntax,
(6) Word length of the additional instruction,
(7) Additional instruction mnemonics,
7 elements are included.
図4は、本実施例におけるRTLテンプレート生成処理(図3の200)の手順を示すフローチャートである。上記の7個の要素を生成するために、RTLテンプレート生成処理は、
入出力オペランド番号の決定するステップ210と、
RTLテンプレートの名前を生成するステップ220と、
出力オペランドを生成するステップ230と、
入力オペランドを生成するステップ240と、
追加命令の動作記述を生成するステップ250と、
追加命令のシンタックスを生成するステップ260と、
追加命令の語長定義文を生成するステップ270と、
追加命令のニモニック定義文を生成するステップ280と、
を含む。
FIG. 4 is a flowchart showing the procedure of the RTL template generation process (200 in FIG. 3) in the present embodiment. In order to generate the above seven elements, the RTL template generation process
A step 210 of determining input / output operand numbers;
Generating a name of the RTL template 220;
Generating 230 an output operand;
Generating an input operand 240;
Generating an operation description of the additional instruction 250;
Generating 260 additional instruction syntax;
Generating a word length definition sentence of the additional command; 270;
Generating a mnemonic definition statement of the additional instruction, 280;
including.
まず、入出力オペランド番号の決定(ステップ210)について説明する。 First, the determination of the input / output operand number (step 210) will be described.
非特許文献2の第241頁の“14.4 RTL Template”又は非特許文献3の第180頁の“RTLテンプレート”によると、RTLテンプレートにおいて、出力オペランドや入力オペランドなどの各オペランドには0から始まる番号を与えることになっている。
According to “14.4 RTL Template” on page 241 of
本実施例において、RTLテンプレート生成処理(図3のステップ200)では、図1のCPU10は追加命令の仕様記述に基づいて各オペランドへ番号を与える。ステップ210は、その番号を決定する処理である。
In this embodiment, in the RTL template generation process (step 200 in FIG. 3), the
本実施例において、RTLテンプレート生成処理(図3のステップ200)では、図1のCPU10は、追加命令の仕様記述における<operand>タグに基づいて追加命令のRTLテンプレートにおける出力オペランドや入力オペランドを決定する。
In the present embodiment, in the RTL template generation process (step 200 in FIG. 3), the
出力オペランドは、<output>タグの内側に記述された<operand>タグによって、また入力オペランドは、<input>タグの内側に記述された<operand>タグによって、それぞれ決定される。 The output operand is determined by the <operand> tag described inside the <output> tag, and the input operand is determined by the <operand> tag described inside the <input> tag.
コンパイラ組み込み関数追加プログラム30は、以下の手順で、RTLテンプレートのオペランドの番号op_indexを決める。 The compiler built-in function addition program 30 determines the operand number op_index of the RTL template according to the following procedure.
図5は、RTLテンプレートのオペランドの番号op_indexを決める手順を説明するフローチャートである。 FIG. 5 is a flowchart for explaining the procedure for determining the operand number op_index of the RTL template.
<output>タグの内側に記述された<operand>タグの数をP個とする(ステップ211)。 Suppose that the number of <operand> tags described inside the <output> tag is P (step 211).
次に、<input>タグの内側に記述された<operand>タグの数をQ個とする(ステップ212)。 Next, let the number of <operand> tags described inside the <input> tag be Q (step 212).
<output>タグの内側に記述された全ての<operand>タグに0からP-1までの番号op_indexをつける(ステップ213)。 <A number op_index from 0 to P-1 is assigned to all <operand> tags described inside the <output> tag (step 213).
<input>タグの内側に記述された全ての<operand>タグにPからP+Q-1までの番号op_indexをつける(ステップ214)。 <Numbers op_index from P to P + Q-1 are assigned to all <operand> tags described inside the <input> tag (step 214).
次に、RTLテンプレートの名前生成(ステップ220)について説明する。 Next, name generation (step 220) of the RTL template will be described.
ステップ220は、追加命令に対応するRTLテンプレートの名前を決定する処理である。RTLテンプレート生成処理では、コンパイラ組み込み関数追加プログラム30は、RTLテンプレートの名前を追加命令の仕様記述における<nickname>タグと<mnemonic>タグに基づいて決定する。 Step 220 is a process for determining the name of the RTL template corresponding to the additional command. In the RTL template generation process, the compiler built-in function addition program 30 determines the name of the RTL template based on the <nickname> tag and the <mnemonic> tag in the specification description of the additional instruction.
RTLテンプレートの名前の形式は、builtin_nkname_mnemである。ここで、nknameは、<nickname>タグで定義されたプロセッサのニックネームである。mnemは、<mnemonic>タグで定義された追加命令のニモニックである。 The format of the name of the RTL template is builtin_nkname_mnem. Here, nkname is the nickname of the processor defined by the <nickname> tag. mnem is a mnemonic of an additional instruction defined by the <mnemonic> tag.
次に、図4の出力オペランドの生成(ステップ230)について説明する。図4のステップ230は追加命令に対応するRTLテンプレートの出力オペランドを生成する処理である。 Next, the generation of the output operand (step 230) in FIG. 4 will be described. Step 230 in FIG. 4 is processing for generating an output operand of the RTL template corresponding to the additional instruction.
出力オペランドは追加命令の演算結果を格納するオペランドを表すので、一般的には出力オペランドはレジスタである。 Since the output operand represents an operand that stores the operation result of the additional instruction, the output operand is generally a register.
追加命令の仕様記述において、<output>タグの内側に記述された<operand>タグの属性typeの値がレジスタ(register)である場合、コンパイラ組み込み関数追加プログラム30は、当該<operand>タグに対応する出力オペランドの形式を、
(match_operand:modenameshort op_index “register_operand” “=r”) ・・・(1)
とする。
In the specification description of the additional instruction, if the value of the attribute type of the <operand> tag described inside the <output> tag is a register, the compiler built-in function addition program 30 corresponds to the <operand> tag. The format of the output operand to
(match_operand: modenameshort op_index “register_operand” “= r”) (1)
And
(1)において、modenameshortは、出力オペランドの語長を表す文字である。 (1) “modenameshort” is a character representing the word length of the output operand.
modenameshortは、<operand>タグの属性widthに基づいて決定される。図7に、属性widthとmodenameshortの関係を示す。 “Modenameshort” is determined based on the attribute width of the <operand> tag. FIG. 7 shows the relationship between the attribute width and the modemshort.
op_indexは、出力オペランドの番号を表す数字である。このop_indexはステップ210において決定された番号である。 Op_index is a number representing the number of the output operand. This op_index is the number determined in step 210.
次に、図4の入力オペランドの生成(ステップ240)について説明する。図4のステップ240は、追加命令に対応するRTLテンプレートの入力オペランドを生成する処理である。 Next, the generation of the input operand (step 240) in FIG. 4 will be described. Step 240 in FIG. 4 is processing for generating an input operand of the RTL template corresponding to the additional instruction.
ステップ240は、レジスタと即値の二種類の入力オペランドを扱う。 Step 240 handles two types of input operands: registers and immediate values.
追加命令の仕様記述において、<input>タグの内側に記述された<operand>タグの属性typeがレジスタ(register)である場合、コンパイラ組み込み関数追加プログラム30は、当該<operand>タグに対応する入力オペランドの形式を、
(match_operand:modenameshort op_index “register_operand” “r”) ・(2)
とする。
In the specification description of the additional instruction, when the attribute type of the <operand> tag described inside the <input> tag is a register, the compiler built-in function addition program 30 inputs corresponding to the <operand> tag. Operand format
(match_operand: modenameshort op_index “register_operand” “r”) (2)
And
この形式は、(1)のレジスタの出力オペランドに似ている。 This format is similar to the output operand of register (1).
出力オペランドの形式では“=r”となる部分が、入力オペランドの形式では“r”となる。 The part that becomes “= r” in the format of the output operand becomes “r” in the format of the input operand.
次に即値の入力オペランドについて説明する。 Next, immediate input operands are explained.
<input>タグの内側に記述された<operand>タグの属性typeが即値(immediate)の場合、コンパイラ組み込み関数追加プログラム30は、その<operand>タグに対応する出力オペランドの形式を
(match_operand:SI op_index “immediate_operand” “n”) ・・・(3)
とする。
When the attribute type of the <operand> tag described inside the <input> tag is an immediate value, the compiler built-in function addition program 30 sets the format of the output operand corresponding to the <operand> tag to (match_operand: SI op_index “immediate_operand” “n”) (3)
And
次に、図4の追加命令の動作記述の生成(ステップ250)について説明する。図4のステップ250はRTLテンプレートにおける追加命令の動作を表す記述を生成する処理である。 Next, the generation (step 250) of the operation description of the additional instruction in FIG. 4 will be described. Step 250 in FIG. 4 is processing for generating a description representing the operation of the additional instruction in the RTL template.
ステップ250において、コンパイラ組み込み関数追加プログラム30は、追加命令が不明な演算をするものとして、追加命令の動作記述を生成する。 In step 250, the compiler built-in function addition program 30 generates an operation description of the additional instruction on the assumption that the additional instruction performs an unknown operation.
ステップ250が生成する追加命令の動作記述の形式は、以下の通りである。 The format of the operation description of the additional instruction generated by step 250 is as follows.
(set output_operand (unspec:VOID [all_input_operands] unspec_insn_id)) ・・・(4) (Set output_operand (unspec: VOID [all_input_operands] unspec_insn_id)) (4)
この形式は、all_input_operandsを入力オペランドとして、番号unspec_insn_idで表される不明な演算の演算結果を出力オペランドoutput_operandへ代入することを表す。 This format represents that all_input_operands is used as an input operand, and an operation result of an unknown operation represented by the number unspec_insn_id is assigned to the output operand output_operand.
(4)において、unspecは、コンパイラにとって不明な演算を表す演算子である。 In (4), unspec is an operator representing an operation unknown to the compiler.
output_operandは、出力オペランドを表す。 Output_operand represents an output operand.
all_input_operandsは、全ての入力オペランドを表す。 All_input_operands represents all input operands.
unspec_insn_idは、追加命令の不明な演算を区別するための番号を表す。各追加命令ごとにunspec_insn_idの値は異なる。 Unspec_insn_id represents a number for distinguishing an unknown operation of an additional instruction. The value of unspec_insn_id differs for each additional instruction.
次に、図4の追加命令のシンタックスの生成(ステップ260)について説明する。図4のステップ260はRTLテンプレートにおける追加命令のシンタックスを生成する処理である。 Next, generation of the syntax of the additional instruction in FIG. 4 (step 260) will be described. Step 260 in FIG. 4 is a process for generating the syntax of the additional instruction in the RTL template.
追加命令の仕様記述における<syntax>タグで定義されたシンタックスに基づいて、コンパイラ組み込み関数追加プログラム30は、RTLテンプレートにおける追加命令のシンタックスを生成する。 Based on the syntax defined by the <syntax> tag in the specification description of the additional instruction, the compiler built-in function addition program 30 generates the syntax of the additional instruction in the RTL template.
<syntax>タグで定義されたシンタックスは、フォーマット文字列を含む。フォーマット文字列は、<operand>タグで定義された追加命令のオペランドと一対一に対応する文字列である。 The syntax defined by the <syntax> tag includes a format character string. The format character string is a character string that has a one-to-one correspondence with the operand of the additional instruction defined by the <operand> tag.
コンパイラ組み込み関数追加プログラム30は、<syntax>タグで定義されたシンタックスに含まれるフォーマット文字列を、RTLテンプレートのオペランドを表す番号(前述のop_index)で置き換えたものを、RTLテンプレートにおける追加命令のシンタックスとする。番号op_indexは、<operand>タグに基づいてRTLテンプレート生成処理が決定する番号であることから、番号op_indexはフォーマット文字列と一対一に対応する。 The compiler built-in function addition program 30 replaces the format character string included in the syntax defined by the <syntax> tag with a number (op_index described above) representing the operand of the RTL template, and adds an additional instruction in the RTL template. Use syntax. Since the number op_index is a number determined by the RTL template generation process based on the <operand> tag, the number op_index has a one-to-one correspondence with the format character string.
次に、図4の追加命令の語長定義文の生成(ステップ270)について説明する。図4のステップ270は、RTLテンプレートにおける追加命令の語長を定義する記述を生成する処理である。 Next, generation of a word length definition sentence (step 270) of the additional instruction in FIG. 4 will be described. Step 270 in FIG. 4 is processing for generating a description that defines the word length of the additional instruction in the RTL template.
追加命令の仕様記述における<length>タグで定義された語長に基づいて、コンパイラ組み込み関数追加プログラム30は、RTLテンプレートにおける追加命令の語長を次のような形式で出力する。 Based on the word length defined by the <length> tag in the specification description of the additional instruction, the compiler built-in function addition program 30 outputs the word length of the additional instruction in the RTL template in the following format.
(set_attr“length”“len”) ・・・(5)
ここで、lenは、<length>タグで定義された語長を表す数字である。RTLテンプレートにおける追加命令の語長はコンパイラがコードサイズを計算するために使われる。
(set_attr “length” “len”) (5)
Here, len is a number representing the word length defined by the <length> tag. The word length of the additional instruction in the RTL template is used by the compiler to calculate the code size.
次に、図4の追加命令のニモニック定義文の生成(ステップ280)について説明する。図4のステップ280はRTLテンプレートにおける追加命令のニモニックを定義する記述を生成する処理である。 Next, generation of a mnemonic definition sentence (step 280) of the additional instruction in FIG. 4 will be described. Step 280 in FIG. 4 is processing for generating a description that defines the mnemonic of the additional instruction in the RTL template.
追加命令の仕様記述における<mnemonic>タグで定義されたニモニックにもとづいて、コンパイラ組み込み関数追加プログラム30は、RTLテンプレートにおける追加命令のニモニック定義文を以下の形式で出力する。 Based on the mnemonic defined by the <mnemonic> tag in the specification description of the additional instruction, the compiler built-in function addition program 30 outputs the mnemonic definition statement of the additional instruction in the RTL template in the following format.
(set_attr“mnemonic”“mnem”) ・・・(6)
ここで、mnemは<mnemonic>タグで定義されたニモニックを表す文字列である。
(set_attr “mnemonic” “mnem”) (6)
Here, mnem is a character string representing a mnemonic defined by the <mnemonic> tag.
コンパイラ組み込み関数追加プログラム30は、レイテンシ定義文生成処理は追加命令のレイテンシ定義文を生成するために、RTLテンプレートにおける追加命令のニモニックを追加命令の識別コードとして使用する。 The compiler built-in function addition program 30 uses the mnemonic of the additional instruction in the RTL template as the identification code of the additional instruction in the latency definition sentence generation process to generate the latency definition sentence of the additional instruction.
[レイテンシ定義文生成処理]
本実施例のコンパイラ組み込み関数追加装置における追加命令のためのレイテンシ定義文生成処理(図3のステップ300)について説明する。レイテンシ定義文は、コンパイラの命令スケジューラへ追加命令のレイテンシを知らせるための定義文である。レイテンシ定義文生成処理は以下の3種類の式を使用する。
[Latency definition statement generation processing]
A latency definition statement generation process (step 300 in FIG. 3) for an additional instruction in the compiler built-in function adding device of this embodiment will be described. The latency definition statement is a definition statement for informing the instruction scheduler of the compiler of the latency of the additional instruction. The latency definition sentence generation process uses the following three types of expressions.
define_automaton ・・・(7)
define_cpu_unit ・・・(8)
define_insn_reservation ・・・(9)
define_automaton (7)
define_cpu_unit (8)
define_insn_reservation (9)
define_automaton式は、コンパイラの命令スケジューラが使用する状態遷移マシンの名前を定義する。 The define_automaton expression defines the name of the state transition machine used by the compiler instruction scheduler.
define_cpu_unit式は、状態遷移マシンが管理すべきプロセッサの実行ユニットを定義する。 The define_cpu_unit expression defines an execution unit of a processor to be managed by the state transition machine.
define_insn_reservation式は、命令のレインシと命令が使用する実行ユニットを定義する。 The define_insn_reservation expression defines an instruction train and an execution unit used by the instruction.
つまり、define_cpu_unit式によってプロセッサがもつ実行ユニットをコンパイラの命令スケジューラへ知らせる。 That is, the execution unit of the processor is notified to the instruction scheduler of the compiler by the define_cpu_unit expression.
define_insn_reservation式によってどの命令がどの実行ユニットを使用するかをコンパイラの命令スケジューラへ知らせる。 It tells the instruction scheduler of the compiler which instruction uses which execution unit by the define_insn_reservation expression.
define_automaton式で定義された名前の状態遷移マシンで、実行ユニットの使用状況と命令のレイテンシを管理する。 The state transition machine with the name defined by the define_automaton expression manages the usage status of the execution unit and the latency of the instruction.
これらの式の詳しい説明については非特許文献2の第327頁の“14.19.8 Specifiying processor pipeline description”の記載が参照される。
For a detailed description of these equations, refer to the description of “14.19.8 Specifying processor pipeline description” on page 327 of
図6は、図3のレイテンシ定義文生成処理(ステップ300)の処理手順を示すフローチャートである。レイテンシ定義文生成処理は、
define_automaton式を生成するステップ310と、
define_cpu_unit式を生成するステップ320と、
define_insn_reservation式を生成するステップ330と、
を含む。
FIG. 6 is a flowchart showing a processing procedure of the latency definition sentence generation process (step 300) of FIG. Latency definition statement generation processing
generating 310 a define_automaton expression;
generating a define_cpu_unit expression 320;
generating 330 a define_insn_reservation expression;
including.
ステップ330は全ての追加命令に対して実行される。 Step 330 is executed for all additional instructions.
追加命令のためのレイテンシ定義文生成処理において、コンパイラ組み込み関数追加プログラム30は、
一つのdefine_automaton式と、
一つのdefine_cpu_unit式と、
追加命令の個数分のdefine_insn_reservation式と、
を生成する。
In the latency definition statement generation process for the additional instruction, the compiler built-in function additional program 30
One define_automaton expression,
One define_cpu_unit expression,
Define_insn_reservation expression for the number of additional instructions,
Is generated.
追加命令の仕様記述には、プロセッサの実行ユニットに関する情報や追加命令がどの実行ユニットをいつ使用するかという情報は含まれない。 The specification description of the additional instruction does not include information on the execution unit of the processor or information on which execution unit the additional instruction uses.
追加命令のためのレイテンシ定義文生成処理では、コンパイラ組み込み関数追加プログラム30は、全ての追加命令が同じ実行ユニットを使用すると仮定して、上記の3つの式を生成する。 In the latency definition statement generation process for the additional instruction, the compiler built-in function addition program 30 generates the above three expressions on the assumption that all the additional instructions use the same execution unit.
ステップ310とステップ320とをまとめて説明する。追加命令のためのレイテンシ定義文生成処理が生成するdefine_automaton式の形式は、以下の(10)で与えられる。 Step 310 and step 320 will be described together. The format of the define_automaton expression generated by the latency definition sentence generation processing for the additional instruction is given by the following (10).
(define_automaton“dfa_builtin_insns”) ・・・(10) (Define_automaton “dfa_builtin_insns”) (10)
この式の第一引数は、状態遷移マシンの名前を表す。 The first argument of this expression represents the name of the state transition machine.
追加命令のためのレイテンシ定義文生成処理が生成するdefine_cpu_unit式の形式は、以下の(11)で与えられる。 The format of the define_cpu_unit expression generated by the latency definition sentence generation process for the additional instruction is given by the following (11).
(define_cpu_unit“unit_builtin”“dfa_builtin_insns”) ・・・(11) (Define_cpu_unit “unit_builtin” “dfa_builtin_insns”) (11)
この式の第一引数はプロセッサの実行ユニットの名前を、第二引数は状態遷移マシンの名前を、それぞれ表す。 The first argument of this expression represents the name of the processor execution unit, and the second argument represents the name of the state transition machine.
追加命令のためのレイテンシ定義文生成処理は、架空の実行ユニット“unit_builtin”を定義する。 The latency definition statement generation process for the additional instruction defines a fictitious execution unit “unit_builtin”.
これらの2つの形式は全ての追加命令に共通して使用され、どの追加命令の仕様記述にも依存しない。 These two formats are used in common for all additional instructions and do not depend on the specification description of any additional instructions.
次に、ステップ330について説明する。追加命令のためのレイテンシ定義文生成処理が生成するdefine_insn_reservation式の形式は、以下の式で与えられる。 Next, step 330 will be described. The format of the define_insn_reservation expression generated by the latency definition sentence generation process for the additional instruction is given by the following expression.
(define_insn_reservation“mnem”ltcy (eq_attr“mnemonic”“mnem”)“unit_builtin,nothing*ltcy_minus_1”) ・・・(12) (Define_insn_reservation “mnem” ltcy (eq_attr “mnemonic” “mnem”) “unit_builtin, nothing * ltcy_minus_1”)) (12)
この式の第一引数はこの式全体に与えられた名前、
第二引数はレイテンシのサイクル数、
第三引数はこの式が当てはまる追加命令の条件、
第四引数は追加命令が使用する実行ユニット、
をそれぞれ表す。
The first argument of this expression is the name given to this whole expression,
The second argument is the number of latency cycles,
The third argument is the condition of the additional command to which this expression applies,
The fourth argument is the execution unit used by the additional instruction,
Respectively.
ここで、mnemは、追加命令の仕様記述において、<mnemonic>タグで定義された追加命令のニモニックである。 Here, mnem is a mnemonic of the additional instruction defined in the <mnemonic> tag in the specification description of the additional instruction.
ltcyは、<latency>タグで定義された追加命令のレイテンシを表す値である。 Ltcy is a value representing the latency of the additional instruction defined by the <latency> tag.
ltcy_minus_1は、ltcyから1を引いた値である。 Ltcy_minus_1 is a value obtained by subtracting 1 from ltcy.
この形式では、追加命令のdefine_insn式で定義された属性mnemonicを使ってこの式に当てはまる追加命令の条件を指定する。 In this format, the condition of the additional instruction that applies to this expression is specified by using the attribute mnemonic defined in the define_insn expression of the additional instruction.
さらに、追加命令が使用する実行ユニットは、define_cpu_unit式で定義された実行ユニット“unit_builtin”だけを最初のサイクルで使用し、その後のサイクルでは何も実行ユニットを使用しないものとする。 Further, the execution unit used by the additional instruction uses only the execution unit “unit_builtin” defined by the define_cpu_unit expression in the first cycle, and does not use any execution unit in the subsequent cycles.
追加命令のレイテンシltcyが1である場合、最初のサイクルで使用される実行ユニットだけを使用することを表すために、コンパイラ組み込み関数追加プログラム30は、define_insn_reservation式の第4引数を、“unit_builtin”とする。 When the latency of the additional instruction is 1, the compiler built-in function adding program 30 sets the fourth argument of the define_insn_reservation expression as “unit_builtin” to indicate that only the execution unit used in the first cycle is used. To do.
追加命令のためのレイテンシ定義文生成処理では、コンパイラ組み込み関数追加プログラム30は、全ての追加命令についてこの形式にしたがってdefine_insn_reservation式を生成する。 In the latency definition statement generation process for the additional instruction, the compiler built-in function addition program 30 generates a define_insn_reservation expression for all the additional instructions according to this format.
[組み込み関数プロトタイプ宣言生成処理]
コンパイラ組み込み関数追加装置における追加命令のための組み込み関数プロトタイプ宣言生成処理(図3のステップ400)について説明する。追加命令のための組み込み関数プロトタイプ宣言生成処理は、コンパイラのための組み込み関数のプロトタイプ宣言を生成する処理である。
[Built-in function prototype declaration generation processing]
An embedded function prototype declaration generation process (step 400 in FIG. 3) for an additional instruction in the compiler embedded function adding device will be described. The built-in function prototype declaration generation process for the additional instruction is a process of generating a built-in function prototype declaration for the compiler.
組み込み関数のプロトタイプ宣言とは、組み込み関数がどんな引数をもつかとか組み込み関数の戻り値は何かなどを表す情報である。 The prototype declaration of the built-in function is information indicating what arguments the built-in function has and what the return value of the built-in function is.
組み込み関数のプロトタイプ宣言をコンパイラへ組み込むことによって、コンパイラは組み込み関数を組み込み関数として認識することができる。 * By incorporating the prototype declaration of an embedded function into the compiler, the compiler can recognize the embedded function as an embedded function.
組み込み関数プロトタイプ宣言生成処理において、コンパイラ組み込み関数追加プログラム30は、組み込み関数のプロトタイプ宣言をコンパイラへ教える関数の名前を定義する定義文と、その関数の内容と、を生成する。 In the built-in function prototype declaration generation process, the compiler built-in function addition program 30 generates a definition statement that defines the name of a function that tells the compiler the prototype declaration of the built-in function and the contents of the function.
組み込み関数のプロトタイプ宣言をコンパイラへ教える関数の名前の定義文の形式を以下に示す(図8)。
#undef TARGET_INIT_BUILTINS
#define TARGET_INIT_BUILTINS target_init_builtins ・・・(13)
The format of a function name definition statement that tells the compiler the prototype declaration of an embedded function is shown below (FIG. 8).
#undef TARGET_INIT_BUILTINS
#define TARGET_INIT_BUILTINS target_init_builtins (13)
この定義文は、追加命令の仕様記述には依存しない。どんな追加命令に対してもこの定義文が使用される。 This definition statement does not depend on the specification description of the additional instruction. This definition statement is used for any additional command.
この定義文に対応する関数target_init_builtins()の内容は、図10のようになる。 The contents of the function target_init_builds () corresponding to this definition statement are as shown in FIG.
関数target_init_builtins()は引数も戻り値も持たない関数であり、その内部に記述された各追加命令に対応する組み込み関数のプロトタイプ宣言を実行する。 The function target_init_builds () is a function having no argument and no return value, and executes a prototype declaration of a built-in function corresponding to each additional instruction described therein.
さらに、組み込み関数プロトタイプ宣言生成処理では、コンパイラ組み込み関数追加プログラム30は、全ての追加命令に対応する組み込み関数のプロトタイプ宣言の定義文を、関数target_init_builtins()の内容として生成する。 Furthermore, in the built-in function prototype declaration generation process, the compiler built-in function addition program 30 generates a definition statement of the prototype declaration of the built-in function corresponding to all the additional instructions as the contents of the function target_init_builds ().
組み込み関数プロトタイプ宣言の定義文の生成方法について説明する。組み込み関数プロトタイプ宣言生成処理では、コンパイラ組み込み関数追加プログラム30は、追加命令の出力オペランドの数に基づいて追加命令に対応する組み込み関数の戻り値と引数を決定する。 Describes how to generate definition statements for built-in function prototype declarations. In the built-in function prototype declaration generation process, the compiler built-in function addition program 30 determines a return value and an argument of the built-in function corresponding to the additional instruction based on the number of output operands of the additional instruction.
追加命令の出力オペランドの数が1個の場合、コンパイラ組み込み関数追加プログラム30は、組み込み関数プロトタイプ宣言生成処理はその出力オペランドを組み込み関数の戻り値とし、その追加命令の全ての入力オペランドを組み込み関数の引数とする。 When the number of output operands of the additional instruction is one, the compiler built-in function additional program 30 causes the built-in function prototype declaration generation processing to use the output operand as the return value of the built-in function, and to set all input operands of the additional instruction as built-in functions As an argument.
追加命令の出力オペランドの数が0個か2個以上の場合、コンパイラ組み込み関数追加プログラム30は、組み込み関数プロトタイプ宣言生成処理は組み込み関数は戻り値をもたないことにし、追加命令の全ての出力オペランドと入力オペランドとを組み込み関数の引数とする。 When the number of output operands of the additional instruction is 0 or 2 or more, the compiler intrinsic function additional program 30 determines that the intrinsic function prototype declaration generation process does not have a return value for the intrinsic function, and outputs all the additional instructions. Operands and input operands are built-in function arguments.
次に、組み込み関数の引数の順番について説明する。組み込み関数の戻り値と引数の決定方法に基づいて組み込み関数がどんな引数を持つかを決定した後に、コンパイラ組み込み関数追加プログラム30は、組み込み関数プロトタイプ宣言生成処理(図3のステップ400)において、前述のdefine_insn式におけるオペランドの番号op_indexに基づいて、引数に対応するオペランドの番号op_indexが小さいものから順番に引数を並べる。 Next, the order of arguments of built-in functions will be described. After determining what arguments the intrinsic function has based on the return value of the intrinsic function and the method of determining the argument, the compiler intrinsic function addition program 30 performs the above-mentioned in the intrinsic function prototype declaration generation process (step 400 in FIG. 3). Based on the operand number op_index in the define_insn expression, the arguments are arranged in order from the smallest operand number op_index corresponding to the argument.
つまり、組み込み関数プロトタイプ宣言生成処理では、コンパイラ組み込み関数追加プログラム30は、最も小さな番号op_indexをもつオペランドに対応する引数を第一引数とし、その次に小さな番号op_indexをもつオペランドに対応する引数を第二引数とし、・・・という具合に、組み込み関数の引数の順番を決定する。 In other words, in the built-in function prototype declaration generation process, the compiler built-in function addition program 30 sets the argument corresponding to the operand having the smallest number op_index as the first argument, and the argument corresponding to the operand having the next smaller number op_index as the first argument. It takes two arguments, and so on, determines the order of the arguments of the built-in function.
組み込み関数プロトタイプ宣言生成処理(図3のステップ400)で生成される組み込み関数プロトタイプ宣言の定義文の形式を以下の(14)に示す(図11参照)。 The format of the definition statement of the built-in function prototype declaration generated in the built-in function prototype declaration generation process (step 400 in FIG. 3) is shown in (14) below (see FIG. 11).
ここで、mnemは、追加命令の仕様記述の<mnemonic>タグで定義された追加命令のニモニックである。nknameは、<nickname>タグで定義されたプロセッサのニックネームである。modenamelongは組み込み関数の引数の型を表す文字列である。 Here, mnem is a mnemonic of the additional instruction defined by the <mnemonic> tag in the specification description of the additional instruction. nkname is the nickname of the processor defined by the <nickname> tag. “modenamelong” is a character string representing the type of the argument of the built-in function.
{
tree ftype_mnem=build_function_type_list (
modenamelong_type_node, /* operand 0 */
modenamelong_type_node, /* operand 1 */
modenamelong_type_node, /* operand 2 */ ..
. NULL_TREE);
builtin_function(“__builtin_nkname_mnem”,/* name of intrinsic */
ftype_mnem, /* prototype */
CODE_FOR_builtin_nkname_mnem, /* RTL template name */
BUILT_IN_MD, NULL, NULL_TREE);
} ・・・(14)
{
tree ftype_mnem = build_function_type_list (
modenamelong_type_node, / *
modenamelong_type_node, / *
modenamelong_type_node, / *
. NULL_TREE);
builtin_function (“__ builtin_nkname_mnem”, / * name of intrinsic * /
ftype_mnem, / * prototype * /
CODE_FOR_builtin_nkname_mnem, / * RTL template name * /
BUILT_IN_MD, NULL, NULL_TREE);
} ・ ・ ・ (14)
この形式は、まず関数build_function_type_list()を使って組み込み関数の戻り値と引数の型を表すリストftype_mnemを作成し、次に、関数builtin_function()を使って、組み込み関数の名前やリストftype_mnemをコンパイラに登録する、ということを意味する。 This form first creates a list ftype_mnem representing the return value and argument type of a built-in function using the function build_function_type_list (), and then uses the function built_function () to give the name of the built-in function and the list ftype_mnem to the compiler. It means to register.
関数build_function_type_list()の引数は組み込み関数の戻り値の型と引数の型を表す型指定子modenamelong_type_nodeである。 The argument of the function build_function_type_list () is a type specifier “modenamelong_type_node” representing the return value type of the built-in function and the argument type.
関数build_function_type_list()の第一引数は、組み込み関数の戻り値の型指定子であり、第二引数以降は、組み込み関数の引数の型指定子である。 The first argument of the function build_function_type_list () is a type specifier of the return value of the built-in function, and the second and subsequent arguments are type specifiers of the argument of the built-in function.
もし組み込み関数が戻り値をもたないならば、コンパイラ組み込み関数追加プログラム30は、void_type_nodeを関数build_function_type_list()の第一引数とする。 If the built-in function has no return value, the compiler built-in function adding program 30 sets void_type_node as the first argument of the function build_function_type_list ().
組み込み関数の戻り値の型と引数の型を表す型指定子modenamelong_type_nodeについて説明する。 The type specifier modelnamelong_type_node representing the return value type and argument type of the built-in function will be described.
組み込み関数の戻り値や引数は追加命令の仕様記述における<operand>タグに一対一に対応する。 The return values and arguments of built-in functions correspond one-to-one with the <operand> tag in the specification description of additional instructions.
型指定子modenamelong_type_nodeにおけるmodenamelongは、<operand>タグの属性widthに基づいて決定される。 <Modelnamelong> in the type specifier modelnamelong_type_node is determined based on the attribute width of the <operand> tag.
図9は、属性widthとmodenamelongの関係を示す図である。 FIG. 9 is a diagram showing the relationship between the attribute width and modernalong.
属性widthが8ならば、modenamelongはcharであり、
属性widthが16ならば、modenamelongはshort_integerであり、
属性widthが32ならば、modenamelongはintegerである。
If the attribute width is 8, then modemalong is char,
If the attribute width is 16, then modemamelong is short_integer,
If the attribute width is 32, modemalong is an integer.
関数builtin_function()は、組み込み関数をコンパイラへ登録する関数である。 Function “function_function ()” is a function for registering an embedded function in the compiler.
この登録によって、コンパイラは、組み込み関数の名前と、組み込み関数の戻り値の型や引数の型と、組み込み関数に対応するRTLテンプレートの名前と、を知ることができる。 This registration allows the compiler to know the name of the built-in function, the return value type and argument type of the built-in function, and the name of the RTL template corresponding to the built-in function.
組み込み関数の名前の形式は
__builtin_nkname_mnem ・・・(15)
である。
The built-in function name format is __builtin_nkname_mnem (15)
It is.
組み込み関数の名前にはプロセッサのニックネームnknameと追加命令のニモニックmnemが含まれる。組み込み関数の戻り値の型や引数の型は型指定子のリストftype_mnemとして表される。 The name of the built-in function includes the nickname nkname of the processor and the mnemonic mnem of the additional instruction. The return value type and argument type of the built-in function are expressed as a list of type specifiers, ftype_mnem.
このリストftype_mnemは、関数build_function_type_list()によって生成される。 This list ftype_mnem is generated by the function build_function_type_list ().
組み込み関数に対応するRTLテンプレートの名前の形式は、CODE_FOR_builtin_nkname_mnemである。これは、define_insn式におけるRTLテンプレートの名前の先頭にCODE_FOR_を付加したものである。 The format of the name of the RTL template corresponding to the built-in function is CODE_FOR_builtin_nkname_mnem. This is obtained by adding CODE_FOR_ to the head of the name of the RTL template in the define_insn expression.
[組み込み関数の展開関数生成処理]
コンパイラ組み込み関数追加装置における組み込み関数の展開関数生成処理(図3のステップ500)について説明する。この処理において、コンパイラ組み込み関数追加プログラム30は、組み込み関数の展開関数の名前を定義する定義文と、その関数の内容と、を生成する。
[Built-in function expansion function generation processing]
An expansion function generation process (step 500 in FIG. 3) of the embedded function in the compiler embedded function adding device will be described. In this process, the compiler built-in function addition program 30 generates a definition statement that defines the name of the expansion function of the built-in function and the contents of the function.
組み込み関数の展開関数は、与えられた組み込み関数がどの追加命令に対応するかを分析し、与えられた組み込み関数に対応する追加命令を表すRTL式を生成する。 The expansion function of the built-in function analyzes which additional instruction corresponds to the given built-in function, and generates an RTL expression representing the additional instruction corresponding to the given built-in function.
この処理において生成された組み込み関数の展開関数は、コンパイラによって呼び出されることになる。 The expansion function of the built-in function generated in this process is called by the compiler.
組み込み関数の展開関数の名前の定義文の形式を以下に示す。この定義文によって、組み込み関数の展開関数の名前は、target_expand_builtin()となる。
#undef TARGET_EXPAND_BUILTIN
#define TARGET_EXPAND_BUILTIN target_expand_builtin
・・・(16)
The format of a definition statement for the name of a built-in function expansion function is shown below. By this definition statement, the name of the expansion function of the built-in function becomes target_expand_buildin ().
#undef TARGET_EXPAND_BUILTIN
#define TARGET_EXPAND_BUILTIN target_expand_builtin
... (16)
さらに、組み込み関数の展開関数生成処理は、組み込み関数の展開関数の内容を生成する。組み込み関数の展開関数は、ステップ510とステップ520とステップ530の三つのステップから構成される。ステップ510は組み込み関数の引数の型を検査するステップである。ステップ520は組み込み関数の戻り値の型を取得するステップである。ステップ530は組み込み関数に対応するRTL式を生成するステップである。
Furthermore, the expansion function generation process of the built-in function generates the contents of the expansion function of the built-in function. The expansion function of the built-in function includes three steps of
図13は、組み込み関数の展開関数の内容の一例を示す図である。追加命令に対応する全ての組み込み関数は、図13の組み込み関数の展開関数によって処理される。各ステップの詳しい処理内容を以下に示す。 FIG. 13 is a diagram showing an example of the contents of the expansion function of the built-in function. All the built-in functions corresponding to the additional instruction are processed by the expansion function of the built-in function in FIG. The detailed processing contents of each step are shown below.
引数の型検査(ステップ510)において、組み込み関数に対応するdefine_insn式で定義されたRTLテンプレートに基づいて、組み込み関数の展開関数は、組み込み関数の引数を適切な記憶場所に配置する。 In the argument type check (step 510), based on the RTL template defined by the define_insn expression corresponding to the embedded function, the expansion function of the embedded function arranges the argument of the embedded function in an appropriate storage location.
もし、引数に対応するRTLテンプレートのオペランドがレジスタである場合、組み込み関数の展開関数は、引数を仮想レジスタへ格納する。 If the operand of the RTL template corresponding to the argument is a register, the built-in function expansion function stores the argument in the virtual register.
もし、引数に対応するRTLテンプレートのオペランドが即値である場合、組み込み関数の展開関数は引数をそのまま即値として扱う。 If the operand of the RTL template corresponding to the argument is an immediate value, the expansion function of the built-in function treats the argument as an immediate value as it is.
戻り値の型取得(ステップ520)において、組み込み関数に対応するdefine_insn式で定義されたRTLテンプレートに基づいて、組み込み関数の展開関数は組み込み関数の戻り値の型を取得する。もし組み込み関数が戻り値をもつならば、組み込み関数の展開関数はその戻り値に対応する仮想レジスタを作成する。もし組み込み関数が戻り値をもたないならば、組み込み関数の展開関数は戻り値に関してはなにもしない。 In the return type acquisition (step 520), the expansion function of the built-in function acquires the return value type of the built-in function based on the RTL template defined by the define_insn expression corresponding to the built-in function. If a built-in function has a return value, the expansion function of the built-in function creates a virtual register corresponding to the return value. If the built-in function has no return value, the built-in function expansion function does nothing with the return value.
組み込み関数に対応するRTL式の生成(ステップ530)において、組み込み関数の名前と戻り値と引数に基づいて、組み込み関数の展開関数は組み込み関数に対応するRTL式を生成する。RTL式の生成にはGEN_FCN(X)というマクロ関数が使われる。マクロ関数GEN_FCN(X)はコンパイラが提供している関数であり、組み込み関数Xに対応するRTL式生成関数の関数ポインタを返す関数である。マクロ関数GEN_FCN(X)が返す関数を使用して、組み込み関数の展開関数は組み込み関数に対応するRTL式を生成する。 In the generation of the RTL expression corresponding to the built-in function (step 530), the expansion function of the built-in function generates the RTL expression corresponding to the built-in function based on the name, return value, and argument of the built-in function. A macro function called GEN_FCN (X) is used to generate the RTL expression. The macro function GEN_FCN (X) is a function provided by the compiler, and is a function that returns a function pointer of an RTL expression generation function corresponding to the built-in function X. Using the function returned by the macro function GEN_FCN (X), the expansion function of the built-in function generates an RTL expression corresponding to the built-in function.
[コンパイラソースコード追加処理]
コンパイラ組み込み関数追加装置70におけるコンパイラソースコード追加処理(図3のステップ600について説明する。この追加処理は、図3のステップ200、300、400、500が生成したコンパイラのソースコードの断片を、ベースプロセッサためのコンパイラのソースコード(ベースプロセッサ用コンパイラソースコード50)へ追加する処理である。
[Compiler source code addition processing]
Compiler source code addition processing in the compiler built-in function addition apparatus 70 (step 600 in FIG. 3 will be described. This addition processing is based on the source code fragment of the compiler generated in steps 200, 300, 400, and 500 in FIG. This is processing to be added to the compiler source code for the processor (compiler source code 50 for the base processor).
ステップ600において、コンパイラ組み込み関数追加プログラム30は、追加命令の仕様記述における<nickname>タグに基づいて、コンパイラのどのソースコードへ断片を追加するかを決める。<nickname>タグで定義されたニックネームをnknameとすると、断片を追加するコンパイラのソースコードはgcc/config/nknameというディレクトリにあるnkname.cとnkname.mdという二つのファイルである。これら二つのファイルがベースプロセッサ用コンパイラソースコード50となる。ソースコードの断片とは以下の四つのことである。 In step 600, the compiler built-in function addition program 30 determines which source code of the compiler to add the fragment based on the <nickname> tag in the specification description of the additional instruction. If the nickname defined by the <nickname> tag is nkname, the source code of the compiler to which the fragment is added is nkname.com in the directory gcc / config / nkname. c and nkname. There are two files named md. These two files become the base processor compiler source code 50. Source code fragments are the following four.
・RTLテンプレート(図3のステップ200が生成したもの)、
・レイテンシ定義文(ステップ300が生成したもの)、
・組み込み関数プロトタイプ宣言(ステップ400が生成したもの)、
・組み込み関数展開関数(ステップ500が生成したもの)
RTL template (generated by step 200 of FIG. 3),
Latency definition statement (generated by step 300),
Built-in function prototype declaration (generated by step 400),
Built-in function expansion function (generated by step 500)
ステップ600において、コンパイラ組み込み関数追加プログラム30は、RTLテンプレートとレイテンシ定義文とをファイルnkname.mdの末尾へ追加する。 In step 600, the compiler built-in function addition program 30 stores the RTL template and the latency definition statement in the file nkname. Append to the end of md.
さらに、ステップ600において、コンパイラ組み込み関数追加プログラム30は、組み込み関数プロトタイプ宣言と組み込み関数展開関数とをファイルnkname.cの末尾へ追加する。この追加によってステップ200からステップ500までの処理が生成したソースコードの断片がベースプロセッサ用コンパイラソースコード50へ追加される。断片を追加されたソースコードは図1の拡張プロセッサ用コンパイラソースコード60となる。 Further, in step 600, the compiler built-in function addition program 30 stores the built-in function prototype declaration and the built-in function expansion function in the file nkname. Append to the end of c. By this addition, a fragment of the source code generated by the processing from step 200 to step 500 is added to the compiler source code 50 for the base processor. The source code to which the fragments are added becomes the compiler source code 60 for the extended processor in FIG.
拡張プロセッサ用コンパイラソースコード60を使ってコンパイラをビルドする手順は一般的なコンパイラのビルド手順と全く同じである。コンパイラのビルド手順については、非特許文献4の第7頁の“Configuration”と第21頁の“Building”の記載が参照される。
The procedure for building a compiler using the compiler source code 60 for the extended processor is exactly the same as a general compiler build procedure. Regarding the build procedure of the compiler, refer to the description of “Configuration” on
本実施例の動作を具体的な例に基づいて以下に説明する。追加命令仕様記述ファイル40の例を図14に示す。図14に示したXMLファイルを入力ファイルとして、コンパイラ組み込み関数追加装置がどのように動作するかを説明する。 The operation of this embodiment will be described below based on a specific example. An example of the additional instruction specification description file 40 is shown in FIG. A description will be given of how the compiler built-in function adding apparatus operates using the XML file shown in FIG.
まず、図3のステップ100において、コンパイラ組み込み関数追加プログラム30は、図14のXMLファイルの内容を読み込む。 First, in step 100 of FIG. 3, the compiler built-in function addition program 30 reads the contents of the XML file of FIG.
ステップ100において、コンパイラ組み込み関数追加プログラム30は、図14の内容をコンピュータプログラムが理解可能なデータ構造に置き換える。 In step 100, the compiler built-in function addition program 30 replaces the content shown in FIG. 14 with a data structure understandable by the computer program.
次に、図3のステップ200において、コンパイラ組み込み関数追加プログラム30は、図14に記述された追加命令に対応するRTLテンプレートを生成する。 Next, in step 200 of FIG. 3, the compiler built-in function addition program 30 generates an RTL template corresponding to the additional instruction described in FIG.
図14には、<insn>タグを使って二個の追加命令の仕様が記述されている。図14において、最初の<insn>タグはmac32という追加命令である。二番目の<insn>タグはavg2という追加命令である。 FIG. 14 describes the specifications of two additional instructions using the <insn> tag. In FIG. 14, the first <insn> tag is an additional instruction called mac32. The second <insn> tag is an additional instruction avg2.
ステップ200において、コンパイラ組み込み関数追加プログラム30は、一度に一個の追加命令のRTLテンプレートを生成する。二個の追加命令のRTLテンプレートを生成するために、ステップ200が二回実行される。 In step 200, the compiler built-in function addition program 30 generates an RTL template for one additional instruction at a time. Step 200 is performed twice to generate an RTL template for two additional instructions.
ステップ200は、ステップ210からステップ280までの8つのステップを含む。各ステップにおいて、コンパイラ組み込み関数追加プログラム30は、RTLテンプレートの構成部品を生成し、それらを一つのRTLテンプレートとして結合する。 Step 200 includes eight steps from Step 210 to Step 280. In each step, the compiler built-in function addition program 30 generates RTL template components and combines them as one RTL template.
図15は、ステップ200において生成された追加命令mac32のRTLテンプレートを示す。図16は、追加命令avg2のRTLテンプレートを示す。以下、各ステップにおいて、図1のCPU10が追加命令mac32と追加命令avg2について何を生成するのかについて説明する。
FIG. 15 shows the RTL template of the additional instruction mac32 generated in step 200. FIG. 16 shows an RTL template for the additional instruction avg2. The following describes what the
図4のステップ210の動作について説明する。ステップ210は、追加命令の入出力オペランドの番号を決定する処理である。 The operation of step 210 in FIG. 4 will be described. Step 210 is a process of determining the input / output operand number of the additional instruction.
まず、ステップ210において、コンパイラ組み込み関数追加プログラム30は、追加命令mac32の<operand>タグに基づいて、入出力オペランドの番号を決定する。 First, in step 210, the compiler built-in function addition program 30 determines the number of the input / output operand based on the <operand> tag of the additional instruction mac32.
追加命令mac32の<output>タグによると、追加命令mac32の出力オペランドの数は1個である。 According to the <output> tag of the additional instruction mac32, the number of output operands of the additional instruction mac32 is one.
追加命令mac32の<input>タグによると、追加命令mac32の入力オペランドの数は3個である。 According to the <input> tag of the additional instruction mac32, the number of input operands of the additional instruction mac32 is three.
ステップ210において、コンパイラ組み込み関数追加プログラム30は、出力オペランドから先に番号を割り当て、図14で先に記述されたオペランドに先に番号を割り当てる。 In step 210, the compiler built-in function adding program 30 assigns a number first from the output operand, and assigns a number first to the operand described earlier in FIG.
したがって、コンパイラ組み込み関数追加プログラム30は、追加命令mac32の入出力オペランドに関して、
出力オペランドrdの番号を0、
入力オペランドraの番号を1、
入力オペランドrbの番号を2、
入力オペランドrcの番号を3、
とする。
Therefore, the compiler built-in function addition program 30 relates to the input / output operand of the additional instruction mac32.
The number of the output operand rd is 0,
The number of the input operand ra is 1,
The number of the input operand rb is 2,
The number of the input operand rc is 3,
And
さらに、同様にして、追加命令avg2についても、<operand>タグに基づいて入出力オペランドの番号が決定される。 Furthermore, in the same manner, for the additional instruction avg2, the number of the input / output operand is determined based on the <operand> tag.
追加命令avg2の入出力オペランドについては、
出力オペランドrdの番号は0、
入力オペランドrmの番号は1、
入力オペランドrnの番号は2、
と決まる。
For the input / output operands of the additional instruction avg2,
The number of the output operand rd is 0,
The number of the input operand rm is 1,
The number of the input operand rn is 2,
It is decided.
図4のステップ220の動作について説明する。ステップ220は、追加命令の<nickname>タグと<mnemonic>タグに基づいてRTLテンプレートの名前を決定する処理である。 The operation of step 220 in FIG. 4 will be described. Step 220 is a process of determining the name of the RTL template based on the <nickname> tag and the <mnemonic> tag of the additional instruction.
RTLテンプレートの名前の形式は、builtin_nkname_mnemである。したがって、コンパイラ組み込み関数追加プログラム30は、
追加命令mac32のRTLテンプレートの名前を、builtin_mycpu_mac32とし、
追加命令avg2のRTLテンプレートの名前を、builtin_mycpu_avg2
とする。
The format of the name of the RTL template is builtin_nkname_mnem. Therefore, the compiler built-in function addition program 30 is
The name of the RTL template of the additional instruction mac32 is defined as buildin_mycpu_mac32.
The name of the RTL template of the additional instruction avg2 is builtin_mycpu_avg2
And
次に図4のステップ230の動作について説明する。ステップ230は、追加命令の<operand>タグに基づいてRTLテンプレートの出力オペランド記述を生成する処理である。 Next, the operation of step 230 in FIG. 4 will be described. Step 230 is a process of generating an output operand description of the RTL template based on the <operand> tag of the additional instruction.
出力オペランドの形式は、以下の(17)で与えられる。
(match_operand:modenameshort op_index "register_operand" "=r") ・・・(17)
The format of the output operand is given by (17) below.
(match_operand: modenameshort op_index "register_operand""=r") (17)
追加命令mac32の出力オペランドはrdだけである。ステップ210によると、出力オペランドrdの番号は0と決められているので、rdのop_indexは0である。 The output operand of the additional instruction mac32 is only rd. According to step 210, since the number of the output operand rd is determined to be 0, the op_index of rd is 0.
そして、出力オペランドrdは32ビット幅のレジスタであることから、rdのmodenameshortはSIである。 And, since the output operand rd is a 32-bit wide register, the mode's modemshort is SI.
したがって、コンパイラ組み込み関数追加プログラム30は、追加命令mac32のRTLテンプレートの出力オペランドを以下の(18)とする。 Therefore, the compiler built-in function addition program 30 sets the output operand of the RTL template of the additional instruction mac32 as (18) below.
(match_operand:SI 0 "register_operand" "=r") ・・・(18)
(Match_operand:
同様にして、追加命令avg2についても、RTLテンプレートの出力オペランドが決定される。 Similarly, the output operand of the RTL template is determined for the additional instruction avg2.
追加命令avg2のRTLテンプレートの出力オペランドは、
(match_operand:SI 0 "register_operand" "=r") ・・・(19)
と決まる。
The output operand of the RTL template of the additional instruction avg2 is
(match_operand:
It is decided.
次に、図4のステップ240の動作について説明する。ステップ240は追加命令の<operand>タグに基づいてRTLテンプレートの出力オペランド記述を生成する処理である。レジスタの入力オペランドの形式は、
(match_operand:modenameshort op_index "register_operand" "r") ・・(20)
である。
Next, the operation of step 240 in FIG. 4 will be described. Step 240 is a process for generating an output operand description of the RTL template based on the <operand> tag of the additional instruction. The input operand format of the register is
(match_operand: modenameshort op_index "register_operand""r") (20)
It is.
追加命令mac32の入力オペランドはraとrbとrcの三つで、全て32ビット幅のレジスタである。 The input instruction mac32 has three input operands, ra, rb, and rc, all of which are 32-bit registers.
図4のステップ210において、既に、入力オペランドraとrbとrcの番号はそれぞれ1,2,3と決められている。したがって、コンパイラ組み込み関数追加プログラム30は、追加命令mac32のRTLテンプレートの三つの入力オペランドra、rb、rcをそれぞれ以下のようにする。
入力オペランドra: (match_operand:SI 1 "register_operand" "r") ・・・(21)
入力オペランドrb: (match_operand:SI 2 "register_operand" "r") ・・・(22)
入力オペランドrc: (match_operand:SI 3 "register_operand" "r") ・・・(23)
In step 210 of FIG. 4, the numbers of the input operands ra, rb, and rc are already determined as 1, 2, and 3, respectively. Therefore, the compiler built-in function addition program 30 sets the three input operands ra, rb, and rc of the RTL template of the additional instruction mac32 as follows.
Input operand ra: (match_operand:
Input operand rb: (match_operand:
Input operand rc: (match_operand:
さらに、同様にして、追加命令avg2についてもRTLテンプレートの入力オペランドが決定される。追加命令avg2のRTLテンプレートの二つの入力オペランドrm、rnをそれぞれ以下のようにする。
入力オペランドrm: (match_operand:SI 1 "register_operand" "r") ・・・(24)
入力オペランドrn: (match_operand:SI 2 "register_operand" "r") ・・・(25)
Similarly, the input operand of the RTL template is determined for the additional instruction avg2. The two input operands rm and rn of the RTL template of the additional instruction avg2 are set as follows.
Input operand rm: (match_operand:
Input operand rn: (match_operand:
次に図4のステップ250の動作について説明する。ステップ250は追加命令のRTLテンプレートの動作記述を生成する処理である。追加命令のRTLテンプレートの動作記述の形式は、
(set output_operand (unspec:VOID [all_input_operands] unspec_insn_id)) ・・・(26)
である。
Next, the operation of step 250 in FIG. 4 will be described. Step 250 is a process of generating an operation description of the RTL template of the additional instruction. The format of the behavior description of the RTL template for additional instructions is
(set output_operand (unspec: VOID [all_input_operands] unspec_insn_id)) (26)
It is.
output_operandは出力オペランドを表す。これはステップ230において生成されたものである。 Output_operand represents an output operand. This was generated in step 230.
all_input_operandは、全ての入力オペランドを表す。これはステップ240において生成されたものである。 All_input_operand represents all input operands. This was generated in step 240.
unspec_insn_idは適当な番号であり、各追加命令が異なる値のunspec_insn_idをもつ。 Unspec_insn_id is an appropriate number, and each additional instruction has a different value of unspec_insn_id.
ここでは、コンパイラ組み込み関数追加プログラム30は、
追加命令mac32のunspec_insn_idを10000、
追加命令avg2のunspec_insn_idを10001、
とする。
Here, the compiler built-in function addition program 30 is
10000 unspec_insn_id of the additional instruction mac32
Unspec_insn_id of the additional instruction avg2 is set to 10001,
And
次に図4のステップ260の動作について説明する。ステップ260は追加命令の<syntax>タグに基づいてRTLテンプレートのシンタックスを生成する処理である。 Next, the operation of step 260 in FIG. 4 will be described. Step 260 is a process of generating the syntax of the RTL template based on the <syntax> tag of the additional instruction.
追加命令mac32の<syntax>タグによると、追加命令mac32のシンタックスは“mac32 %rd %ra %rb %rc”である。このシンタックスには、フォーマット文字列(%rd、%ra、%rb、%rc)が含まれている。これらのフォーマット文字列は入出力オペランドに対応している。 According to the <syntax> tag of the additional instruction mac32, the syntax of the additional instruction mac32 is “mac32% rd% ra% rb% rc”. This syntax includes a format character string (% rd,% ra,% rb,% rc). These format character strings correspond to input / output operands.
ステップ260において、コンパイラ組み込み関数追加プログラム30は、これらのフォーマット文字列をRTLテンプレートのオペランド番号へ置き換える。%rdは%0へ、%raは%1へ、%rbは%2へ、%rcは%3へ、それぞれ置き換えられる。 In step 260, the compiler built-in function addition program 30 replaces these format character strings with the operand numbers of the RTL template. % Rd is replaced with% 0,% ra is replaced with% 1,% rb is replaced with% 2, and% rc is replaced with% 3.
したがって、コンパイラ組み込み関数追加プログラム30は、追加命令mac32のRTLテンプレートのシンタックスを、
“mac32 %0 %1 %2 %3” ・・・(27)
とする。
Accordingly, the compiler built-in function addition program 30 uses the syntax of the RTL template of the additional instruction mac32 as follows:
“
And
同様にして、追加命令avg2についてもRTLテンプレートのシンタックスが決定される。追加命令avg2のRTLテンプレートのシンタックスは、
“avg2 %0 %1 %2” ・・・(28)
と決まる。
Similarly, the syntax of the RTL template is determined for the additional instruction avg2. The syntax of the RTL template for the additional instruction avg2 is
“
It is decided.
次に図4のステップ270の動作について説明する。ステップ270は、追加命令の<length>タグに基づいてRTLテンプレートの語長定義文を生成する処理である。RTLテンプレートにおける語長定義文の形式は、
(set_attr "length" "len") ・・・(29)
である。
Next, the operation of step 270 in FIG. 4 will be described. Step 270 is processing for generating a word length definition sentence of the RTL template based on the <length> tag of the additional instruction. The format of the word length definition sentence in the RTL template is
(set_attr “length” “len”) (29)
It is.
追加命令mac32の<length>タグによると、追加命令mac32の語長は32ビット(4バイト)である。したがって、コンパイラ組み込み関数追加プログラム30は、追加命令mac32のRTLテンプレートの語長定義文を
(set_attr "length" "4") ・・・(30)
とする。
According to the <length> tag of the additional instruction mac32, the word length of the additional instruction mac32 is 32 bits (4 bytes). Therefore, the compiler built-in function addition program 30 changes the word length definition sentence of the RTL template of the additional instruction mac32 to (set_attr “length” “4”) (30)
And
同様にして、追加命令avg2についてもRTLテンプレートの語長定義文が生成される。追加命令avg2のRTLテンプレートの語長定義文は、
(set_attr "length" "4") ・・・(31)
と決まる。
Similarly, a word length definition sentence of the RTL template is generated for the additional instruction avg2. The word length definition sentence of the RTL template of the additional instruction avg2 is
(set_attr "length""4") (31)
It is decided.
次に図4のステップ280の動作について説明する。ステップ280は追加命令の<mnemonic>タグに基づいてRTLテンプレートのニモニック定義文を生成する処理である。 Next, the operation of step 280 in FIG. 4 will be described. Step 280 is processing for generating a mnemonic definition sentence of the RTL template based on the <mnemonic> tag of the additional instruction.
RTLテンプレートにおけるニモニック定義文の形式は、
(set_attr "mnemonic" "mnem") ・・・(32)
である。
The format of the mnemonic definition statement in the RTL template is
(set_attr “mnemonic” “mnem”) (32)
It is.
追加命令mac32の<mnemonic>タグによると、追加命令mac32のニモニックはmac32である。したがって、コンパイラ組み込み関数追加プログラム30は、追加命令mac32のRTLテンプレートのニモニック定義文を、
(set_attr "mnemonic" "mac32") ・・・(33)
とする。
According to the <mnemonic> tag of the additional instruction mac32, the mnemonic of the additional instruction mac32 is mac32. Therefore, the compiler built-in function adding program 30 converts the mnemonic definition statement of the RTL template of the additional instruction mac32 into
(set_attr “mnemonic” “mac32”) (33)
And
同様にして、追加命令avg2についてもRTLテンプレートのニモニック定義文が生成される。追加命令avg2のRTLテンプレートのニモニック定義文は、
(set_attr "mnemonic" "avg2") ・・・(34)
と決まる。
Similarly, a mnemonic definition sentence of the RTL template is generated for the additional instruction avg2. The mnemonic definition statement of the RTL template for the additional instruction avg2 is
(set_attr "mnemonic""avg2") (34)
It is decided.
最終的に、ステップ200において、コンパイラ組み込み関数追加プログラム30は、ステップ210からステップ230において生成されたものをまとめて、追加命令mac32のRTLテンプレート(図15)と追加命令avg2のRTLテンプレート(図16)とを生成する。 Finally, in step 200, the compiler built-in function adding program 30 combines the ones generated in steps 210 to 230 into an RTL template (FIG. 15) of the additional instruction mac32 and an RTL template (FIG. 16) of the additional instruction avg2. ) And generate.
次に、図3のステップ300において、コンパイラ組み込み関数追加プログラム30は、図14に記述された追加命令に対応するレイテンシ定義文を生成する。前述したように、ステップ300はステップ310とステップ320とステップ330の三つのステップから構成される。ステップ310とステップ320は全ての追加命令に共通な定義文を生成する処理である。図17に、ステップ310とステップ320において生成される共通な定義文の一例を示す。 Next, in step 300 of FIG. 3, the compiler built-in function addition program 30 generates a latency definition statement corresponding to the additional instruction described in FIG. As described above, step 300 is composed of three steps: step 310, step 320, and step 330. Steps 310 and 320 are processes for generating a definition sentence common to all additional instructions. FIG. 17 shows an example of a common definition sentence generated in step 310 and step 320.
つづいて、図14に記述された2個の追加命令に対して、コンパイラ組み込み関数追加プログラム30は、ステップ330を実行する。 Subsequently, the compiler built-in function addition program 30 executes Step 330 for the two additional instructions described in FIG.
ステップ330において、コンパイラ組み込み関数追加プログラム30は、各追加命令のレイテンシ定義文を生成する。 In step 330, the compiler built-in function addition program 30 generates a latency definition statement for each additional instruction.
レイテンシ定義文の形式は、
(define_insn_reservation "mnem" ltcy (eq_attr "mnemonic" "mnem" ) "unti_builtin,nothing*ltcy_minus_1") ・・・(35)
である。
The format of the latency definition statement is
(define_insn_reservation "mnem" ltcy (eq_attr "mnemonic""mnem")"unti_builtin, nothing * ltcy_minus_1")) (35)
It is.
追加命令mac32の<mnemonic>タグと<latency>タグによると、追加命令mac32のニモニックはmac32で、追加命令mac32の語長は32ビット(4バイト)である。したがって、コンパイラ組み込み関数追加プログラム30は、追加命令mac32のレイテンシ定義文を図18のようにする。 According to the <mnemonic> tag and the <latency> tag of the additional instruction mac32, the mnemonic of the additional instruction mac32 is mac32, and the word length of the additional instruction mac32 is 32 bits (4 bytes). Therefore, the compiler built-in function addition program 30 sets the latency definition statement of the additional instruction mac32 as shown in FIG.
同様にして、追加命令avg2についてもレイテンシ定義文が生成される。追加命令avg2のレイテンシ定義文は、図19のようになる。 Similarly, a latency definition statement is also generated for the additional instruction avg2. The latency definition statement of the additional instruction avg2 is as shown in FIG.
次に、図3のステップ400において、コンパイラ組み込み関数追加プログラム30は、図14に記述された追加命令に対応する組み込み関数プロトタイプ宣言を生成する。ステップ400において、まず、コンパイラ組み込み関数追加プログラム30は、組み込み関数のプロトタイプ宣言をコンパイラへ教える関数の名前を定義する定義文を生成する。この定義文は、図8のようになる。 Next, in step 400 of FIG. 3, the compiler built-in function addition program 30 generates a built-in function prototype declaration corresponding to the additional instruction described in FIG. In step 400, first, the compiler built-in function addition program 30 generates a definition statement that defines the name of the function that tells the compiler the prototype declaration of the built-in function. This definition sentence is as shown in FIG.
ステップ400において、コンパイラ組み込み関数追加プログラム30は、図14に記述された追加命令mac32と追加命令avg2に対応する組み込み関数のプロトタイプ宣言を生成する。組み込み関数のプロトタイプ宣言の形式は、図11のようになる。 In step 400, the compiler built-in function addition program 30 generates a prototype declaration of the built-in function corresponding to the additional instruction mac32 and the additional instruction avg2 described in FIG. The format of the prototype declaration of the built-in function is as shown in FIG.
追加命令mac32のRTLテンプレートのオペランドは四個あり、図4のステップ210においてそれらのオペランドの番号op_indexは決定されている。出力オペランドrdの番号は0であり、入力オペランドraの番号は1であり、入力オペランドrbの番号は2であり、入力オペランドrcの番号は3である。 There are four operands in the RTL template of the additional instruction mac32, and the number op_index of these operands is determined in step 210 of FIG. The number of the output operand rd is 0, the number of the input operand ra is 1, the number of the input operand rb is 2, and the number of the input operand rc is 3.
図14の<operand>タグによると、これらのオペランドのビット幅は全て32ビットである。 According to the <operand> tag in FIG. 14, the bit widths of these operands are all 32 bits.
図9によると、32ビット幅のオペランドのmodenamelongはintegerである。したがって、コンパイラ組み込み関数追加プログラム30は、追加命令mac32のための関数build_function_type_list()の引数を全てinteger_type_nodeとする。 According to FIG. 9, the operand of the 32-bit width operand is an integer. Accordingly, the compiler built-in function addition program 30 sets all arguments of the function build_function_type_list () for the additional instruction mac32 to be integer_type_node.
図14の<nickname>タグによると、プロセッサのニックネームはmycpuである。そして、追加命令mac32の<mnemonic>タグによると、追加命令mac32のニモニックはmac32である。最終的に、コンパイラ組み込み関数追加プログラム30は、追加命令mac32に対応する組み込み関数のプロトタイプ宣言を図20のようにする。 According to the <nickname> tag in FIG. 14, the nickname of the processor is mycpu. According to the <mnemonic> tag of the additional instruction mac32, the mnemonic of the additional instruction mac32 is mac32. Finally, the compiler built-in function addition program 30 makes the prototype declaration of the built-in function corresponding to the add instruction mac32 as shown in FIG.
同様にして、追加命令avg2についても組み込み関数のプロトタイプ宣言が生成される。追加命令avg2の組み込み関数のプロトタイプ宣言は図21のようになる。最終的に、コンパイラ組み込み関数追加プログラム30は、図22に示すように、追加命令mac32と追加命令avg2に対応する組み込み関数のプロトタイプ宣言を関数target_init_builtins()の中に配置する。 Similarly, a prototype declaration of an embedded function is generated for the additional instruction avg2. The prototype declaration of the built-in function of the additional instruction avg2 is as shown in FIG. Finally, as shown in FIG. 22, the compiler built-in function addition program 30 arranges the prototype declaration of the built-in function corresponding to the add instruction mac32 and the add instruction avg2 in the function target_init_builds ().
次に、図3のステップ500において、コンパイラ組み込み関数追加プログラム30は、
組み込み関数の展開関数の名前を定義する定義文と、
組み込み関数の展開関数の内容と、
を生成する。これらは追加命令の仕様記述には依存しない。
Next, in step 500 of FIG.
A definition statement that defines the name of a built-in function expansion function,
The contents of the expansion function of the built-in function,
Is generated. These do not depend on the specification description of the additional instruction.
組み込み関数の展開関数の名前を定義する定義文は、図12のようになる。そして、組み込み関数の展開関数の内容は、図13となる。 The definition statement that defines the name of the expansion function of the built-in function is as shown in FIG. The contents of the expansion function of the built-in function are as shown in FIG.
次に、図3のステップ600において、コンパイラ組み込み関数追加プログラム30は、ソースコードの断片をベースプロセッサのためのコンパイラのソースコード(ベースプロセッサ用コンパイラソースコード50)へ追加する。 Next, in step 600 of FIG. 3, the compiler built-in function addition program 30 adds a source code fragment to the compiler source code for the base processor (base processor compiler source code 50).
ソースコードの断片とは、ステップ200からステップ500において生成された以下の四つのことである。 The source code fragments are the following four items generated from step 200 to step 500.
・RTLテンプレート(図3のステップ200において生成されたもの:図15と図16);
・レイテンシ定義文(図3のステップ300において生成されたもの:図17と図18と図19);
・組み込み関数プロトタイプ宣言(図3のステップ400において生成されたもの:図8と図22);
・組み込み関数展開関数(図3のステップ500において生成されたもの:図12と図13)
RTL template (generated in step 200 of FIG. 3: FIGS. 15 and 16);
Latency definition statement (generated in step 300 of FIG. 3: FIGS. 17, 18 and 19);
Built-in function prototype declaration (generated in step 400 of FIG. 3: FIGS. 8 and 22);
Built-in function expansion function (generated in step 500 of FIG. 3: FIGS. 12 and 13)
図14の<nickname>タグによると、プロセッサのニックネームはmycpuである。したがって、ステップ600において、図1のCPU10が上記のソースコード断片を追加するコンパイラのソースコードは、gcc/config/mycpuというディレクトリにあるmycpu.cとmycpu.mdという二つのファイルである。これら二つのファイルがベースプロセッサ用コンパイラソースコード50となる。
According to the <nickname> tag in FIG. 14, the nickname of the processor is mycpu. Therefore, in step 600, the source code of the compiler to which the
図3のステップ600において、コンパイラ組み込み関数追加プログラム30は、RTLテンプレート(図15と図16)と、レイテンシ定義文(図17と図18と図19)と、をファイルmycpu.mdの末尾へ追加する。 3 In step 600 of FIG. 3, the compiler built-in function addition program 30 stores the RTL template (FIGS. 15 and 16) and the latency definition statement (FIGS. 17, 18, and 19) in the file mycpu. Append to the end of md.
さらに、図3のステップ600において、コンパイラ組み込み関数追加プログラム30は、組み込み関数プロトタイプ宣言(図8と図22)と、組み込み関数展開関数(図12と図13)と、をファイルmycpu.cの末尾へ追加する。 Further, in step 600 of FIG. 3, the compiler built-in function addition program 30 stores the built-in function prototype declaration (FIGS. 8 and 22) and the built-in function expansion function (FIGS. 12 and 13) in the file mycpu. Append to the end of c.
この追加によって、図3のステップ200からステップ500までの処理において生成されたソースコードの断片がベースプロセッサ用コンパイラソースコード50へ追加される。断片を追加されたソースコードが、図1の拡張プロセッサ用コンパイラソースコード60となる。 As a result of this addition, a fragment of the source code generated in the processing from step 200 to step 500 in FIG. 3 is added to the compiler source code 50 for the base processor. The source code to which the fragments are added becomes the compiler source code 60 for the extended processor in FIG.
拡張プロセッサ用コンパイラソースコード60を使ってコンパイラをビルドする手順は一般的なコンパイラのビルド手順と全く同じである。コンパイラのビルド手順については非特許文献4(第7頁、”Configuration”と第21ページの“Building”)の記載が参照される。
The procedure for building a compiler using the compiler source code 60 for the extended processor is exactly the same as a general compiler build procedure. Reference is made to the description of Non-Patent Document 4 (
本発明を使用すれば、追加命令の仕様記述に基づいてその追加命令に対応する組み込み関数をコンパイラへ簡単に追加することに加えて、そのコンパイラは追加命令を含むプログラムの語長を正しく計算したり、追加命令を適切にスケジューリングできるようになる。そのコンパイラを使うことにより、プログラム開発者は組み込み関数を使ったプログラム開発が可能となる。特定用途向けのプロセッサの命令セットを設計する際にプロセッサ設計者が本発明を活用することができる。 According to the present invention, in addition to simply adding an intrinsic function corresponding to the additional instruction to the compiler based on the specification description of the additional instruction, the compiler correctly calculates the word length of the program including the additional instruction. Or additional instructions can be scheduled appropriately. By using the compiler, program developers can develop programs using built-in functions. The processor designer can take advantage of the present invention in designing a processor instruction set for a specific application.
なお、上記の特許文献1-3、非特許文献1-4の各開示を、本書に引用をもって繰り込むものとする。本発明の全開示(請求の範囲を含む)の枠内において、さらにその基本的技術思想に基づいて、実施形態ないし実施例の変更・調整が可能である。また、本発明の請求の範囲の枠内において種々の開示要素の多様な組み合わせ乃至選択が可能である。すなわち、本発明は、請求の範囲を含む全開示、技術的思想にしたがって当業者であればなし得るであろう各種変形、修正を含むことは勿論である。 The disclosures of Patent Documents 1-3 and Non-Patent Documents 1-4 above are incorporated herein by reference. Within the scope of the entire disclosure (including claims) of the present invention, the embodiments and examples can be changed and adjusted based on the basic technical concept. Various combinations and selections of various disclosed elements are possible within the scope of the claims of the present invention. That is, the present invention of course includes various variations and modifications that could be made by those skilled in the art according to the entire disclosure including the claims and the technical idea.
Claims (23)
前記追加命令に対応する組み込み関数を、前記拡張プロセッサ用のコンパイラへ追加する組み込み関数追加手段を備えた、ことを特徴とするコンパイラ組み込み関数追加装置。 Based on the specification description of the additional instruction newly added to the instruction set of the base processor, the source code of the compiler for the extended processor having the additional instruction in the instruction set is compared with the source code of the compiler for the base processor. Generate
A compiler built-in function adding device, comprising: a built-in function adding unit that adds a built-in function corresponding to the additional instruction to the compiler for the extension processor.
前記追加命令の仕様記述を読み込み、
前記仕様記述に基づいて前記追加命令の構成定義文を生成し、
前記仕様記述に基づいて前記追加命令と前記追加命令に対応する組み込み関数との関係定義文を生成し、
前記構成定義文と前記関係定義文とを、前記ベースプロセッサ用のコンパイラのソースコードへ追加し、前記拡張プロセッサ用のコンパイラのソースコードを生成する、ことを特徴とする、請求項1又は2に記載のコンパイラ組み込み関数追加装置。 The built-in function adding means is
Read the specification description of the additional instruction,
Generate a configuration definition statement of the additional instruction based on the specification description,
Generating a relationship definition statement between the additional instruction and a built-in function corresponding to the additional instruction based on the specification description;
The configuration definition statement and the relationship definition statement are added to a source code of the compiler for the base processor, and a source code of the compiler for the extension processor is generated. The compiler built-in function addition device described.
コンパイラの中間言語で表現された追加命令のテンプレートと、
追加命令の実行に必要なサイクル数を定義するレイテンシ定義文と、
を含み、
前記組み込み関数追加手段は、前記追加命令の前記構成定義文を生成するにあたり、
前記仕様記述に含まれる前記追加命令の名前と、入力オペランドと出力オペランドとに基づいて前記テンプレートを生成し、
前記仕様記述に含まれる前記追加命令の実行に必要なサイクル数に基づいて、前記レイテンシ定義文を生成する、ことを特徴とする、請求項3に記載のコンパイラ組み込み関数追加装置。 The configuration statement is
A template for additional instructions expressed in the intermediate language of the compiler;
A latency definition statement that defines the number of cycles required to execute the additional instruction;
Including
The built-in function adding means generates the configuration definition statement of the additional instruction.
Generating the template based on a name of the additional instruction included in the specification description, an input operand, and an output operand;
4. The compiler built-in function adding device according to claim 3, wherein the latency definition statement is generated based on a number of cycles necessary for executing the additional instruction included in the specification description.
前記追加命令に対応する組み込み関数のプロトタイプ宣言と、
前記組み込み関数を追加命令へ置き換えるための組み込み関数展開関数と、
を含み、
前記組み込み関数追加手段は、前記関係定義文を生成するにあたり、
前記仕様記述に含まれる前記追加命令の名前と、入力オペランドと、出力オペランドとに基づいて、前記組み込み関数のプロトタイプ宣言を生成し、
コンパイラの所定の形式に基づいて、前記組み込み関数展開関数を生成する、ことを特徴とする、請求項4に記載のコンパイラ組み込み関数追加装置。 The relationship definition statement is
A prototype declaration of a built-in function corresponding to the additional instruction;
A built-in function expansion function for replacing the built-in function with an additional instruction;
Including
The built-in function adding means generates the relationship definition statement.
Generating a prototype declaration of the built-in function based on the name of the additional instruction, the input operand, and the output operand included in the specification description;
5. The compiler built-in function adding device according to claim 4, wherein the built-in function expansion function is generated based on a predetermined format of the compiler.
前記仕様記述に含まれる前記追加命令の出力オペランドと入力オペランドとを順番に並べることによって、前記追加命令の中間言語定義文におけるオペランドの番号を決定し、
前記仕様記述に含まれる前記追加命令の名前に基づいて前記テンプレートの名前を生成し、
前記仕様記述に含まれる前記追加命令の出力オペランドの型に基づいて前記テンプレートの出力オペランドの記述を生成し、
前記仕様記述に含まれる前記追加命令の入力オペランドの型に基づいて前記テンプレートの入力オペランドの記述を生成し、
前記追加命令がコンパイラにとって不明な演算を実行することを示す演算子を用いてテンプレートにおける追加命令の動作記述を生成し、
前記仕様記述に含まれる前記追加命令のシンタックスに含まれるオペランドを前記オペランド番号で置き換えることによって、前記テンプレートのシンタックスを生成し、
前記仕様記述に含まれる前記追加命令の命令語長に基づいて前記テンプレートにおける命令語長定義文を生成し、
前記仕様記述に含まれる前記追加命令の名前に基づいて前記テンプレートにおけるニモニック定義文を生成する、
ことを特徴とする、請求項4又は5に記載のコンパイラ組み込み関数追加装置。 When the built-in function adding means generates the template,
By arranging the output operand and the input operand of the additional instruction included in the specification description in order, the number of the operand in the intermediate language definition sentence of the additional instruction is determined;
Generating a name for the template based on the name of the additional instruction included in the specification description;
Generating a description of the output operand of the template based on the type of the output operand of the additional instruction included in the specification description;
Generating a description of the input operand of the template based on the type of the input operand of the additional instruction included in the specification description;
Generating an action description of the additional instruction in the template using an operator indicating that the additional instruction performs an operation unknown to the compiler;
Generating the syntax of the template by replacing an operand included in the syntax of the additional instruction included in the specification description with the operand number;
Generating an instruction word length definition sentence in the template based on an instruction word length of the additional instruction included in the specification description;
Generating a mnemonic definition sentence in the template based on the name of the additional instruction included in the specification description;
The compiler built-in function adding device according to claim 4 or 5, characterized in that:
生成されたソースコードと、に基づいて、前記コンパイラを構築する手段を備えるコンパイラ構築装置。 A compiler built-in function adding device according to any one of claims 1 to 6,
A compiler construction apparatus comprising means for constructing the compiler based on generated source code.
前記ベースプロセッサの命令セットに新たに追加される追加命令の仕様記述に基づき、前記ベースプロセッサ用のコンパイラのソースコードから、前記追加命令を命令セットに備えた拡張プロセッサ用のコンパイラのソースコードを生成し、
前記追加命令に対応する組み込み関数を、前記拡張プロセッサ用のコンパイラへ追加する、組み込み関数追加処理をコンピュータに実行させるプログラム。 Enter the compiler source code for the base processor
Based on the specification description of the additional instruction newly added to the instruction set of the base processor, the compiler source code for the extended processor having the additional instruction in the instruction set is generated from the source code of the compiler for the base processor And
A program for causing a computer to execute an embedded function addition process for adding an embedded function corresponding to the additional instruction to the compiler for the extension processor.
前記追加命令の仕様記述を読み込む処理と、
前記仕様記述に基づいて前記追加命令の構成定義文を生成する処理と、
前記仕様記述に基づいて前記追加命令と前記追加命令に対応する組み込み関数との関係定義文を生成する処理と、
前記構成定義文と前記関係定義文とを、前記ベースプロセッサ用のコンパイラのソースコードへ追加し、前記拡張プロセッサ用のコンパイラのソースコードを生成する処理とを含む、ことを特徴とする請求項8又は9に記載のプログラム。 The built-in function addition process
A process of reading the specification description of the additional instruction;
Processing for generating a configuration definition statement of the additional instruction based on the specification description;
Processing for generating a relationship definition statement between the additional instruction and a built-in function corresponding to the additional instruction based on the specification description;
9. The process of adding the configuration definition statement and the relationship definition statement to a source code of the compiler for the base processor to generate a source code of the compiler for the extension processor. Or the program of 9.
コンパイラの中間言語で表現された追加命令のテンプレートと、
追加命令の実行に必要なサイクル数を定義するレイテンシ定義文と、
を含み、
前記組み込み関数追加処理は、
前記構成定義文を生成する処理において、
前記仕様記述に含まれる前記追加命令の名前と、入力オペランドと出力オペランドとに基づいて、前記テンプレートを生成し、
前記仕様記述に含まれる前記追加命令の実行に必要なサイクル数に基づいて、前記レイテンシ定義文を生成する、ことを特徴とする請求項10に記載のプログラム。 The configuration statement is
A template for additional instructions expressed in the intermediate language of the compiler;
A latency definition statement that defines the number of cycles required to execute the additional instruction;
Including
The built-in function adding process is:
In the process of generating the configuration definition statement,
Generating the template based on a name of the additional instruction included in the specification description, an input operand, and an output operand;
The program according to claim 10, wherein the latency definition sentence is generated based on the number of cycles necessary for executing the additional instruction included in the specification description.
前記追加命令に対応する組み込み関数のプロトタイプ宣言と、
前記組み込み関数を追加命令へ置き換えるための組み込み関数展開関数と、を含み、
前記組み込み関数追加処理は、
前記関係定義文を生成する処理において、
前記仕様記述に含まれる前記追加命令の名前と、入力オペランドと、出力オペランドとに基づいて、前記組み込み関数のプロトタイプ宣言を生成し、
コンパイラの所定の形式に基づいて、前記組み込み関数展開関数を生成する、ことを特徴とする請求項11に記載のプログラム。 The relationship definition statement is
A prototype declaration of a built-in function corresponding to the additional instruction;
A built-in function expansion function for replacing the built-in function with an additional instruction,
The built-in function adding process is:
In the process of generating the relationship definition statement,
Generating a prototype declaration of the built-in function based on the name of the additional instruction, the input operand, and the output operand included in the specification description;
12. The program according to claim 11, wherein the built-in function expansion function is generated based on a predetermined format of a compiler.
前記仕様記述の前記追加命令の出力オペランドと、入力オペランドとを順番に並べることによって、追加命令の中間言語定義文におけるオペランドの番号を決定し、
前記仕様記述に含まれる前記追加命令の名前に基づいて前記テンプレートの名前を生成し、
前記仕様記述に含まれる前記追加命令の出力オペランドの型に基づいて前記テンプレートの出力オペランドの記述を生成し、
前記仕様記述に含まれる前記追加命令の入力オペランドの型に基づいて前記テンプレートの入力オペランドの記述を生成し、
追加命令がコンパイラにとって不明な演算を実行することを示す演算子を用いてテンプレートにおける追加命令の動作記述を生成し、
前記仕様記述に含まれる前記追加命令のシンタックスに含まれるオペランドを前記オペランド番号で置き換えることによってテンプレートのシンタックスを生成し、
前記仕様記述に含まれる前記追加命令の命令語長に基づいて前記テンプレートにおける命令語長定義文を生成し、
前記仕様記述に含まれる前記追加命令の名前に基づいて前記テンプレートにおけるニモニック定義文を生成する、
ことを特徴とする、請求項11又は12に記載のプログラム。 In the built-in function adding process, when generating the template,
Determining the number of the operand in the intermediate language definition statement of the additional instruction by arranging the output operand and the input operand of the additional instruction in the specification description in order;
Generating a name for the template based on the name of the additional instruction included in the specification description;
Generating a description of the output operand of the template based on the type of the output operand of the additional instruction included in the specification description;
Generating a description of the input operand of the template based on the type of the input operand of the additional instruction included in the specification description;
Generate an action description of the additional instruction in the template using an operator that indicates that the additional instruction performs an operation unknown to the compiler;
Generating a template syntax by replacing an operand included in the syntax of the additional instruction included in the specification description with the operand number;
Generating an instruction word length definition sentence in the template based on an instruction word length of the additional instruction included in the specification description;
Generating a mnemonic definition sentence in the template based on the name of the additional instruction included in the specification description;
The program according to claim 11 or 12, characterized in that:
前記ベースプロセッサの命令セットに新たに追加される追加命令の仕様記述に基づき、前記ベースプロセッサ用のコンパイラのソースコードから、前記追加命令を命令セットに備えた拡張プロセッサ用のコンパイラのソースコードを生成し、
前記追加命令に対応する組み込み関数を、前記拡張プロセッサ用のコンパイラへ追加する組み込み関数追加工程を含む、ことを特徴とするコンパイラ組み込み関数追加方法。 Enter the compiler source code for the base processor
Based on the specification description of the additional instruction newly added to the instruction set of the base processor, the compiler source code for the extended processor having the additional instruction in the instruction set is generated from the source code of the compiler for the base processor And
A method for adding a compiler built-in function, comprising a step of adding a built-in function corresponding to the additional instruction to a compiler for the extension processor.
記憶装置から前記追加命令の仕様記述と前記ベースプロセッサ用のコンパイラのソースコードとを読み込み、
前記追加命令の仕様記述に記述された追加命令に対応する組み込み関数の定義文を生成し、
前記追加命令に対応する組み込み関数の定義文を前記ベースプロセッサ用のコンパイラのソースコードへ追加したものを、前記拡張プロセッサ用のコンパイラのソースコードとして記憶装置に出力する、ことを特徴とする請求項14に記載のコンパイラ組み込み関数追加方法。 The built-in function adding step includes
Read the specification description of the additional instruction and the source code of the compiler for the base processor from the storage device,
A definition statement of an embedded function corresponding to the additional instruction described in the specification description of the additional instruction;
The definition statement of the built-in function corresponding to the additional instruction added to the source code of the compiler for the base processor is output to the storage device as the source code of the compiler for the extension processor. 14. A method for adding a compiler built-in function according to 14.
前記追加命令の仕様記述を読み込み、
前記仕様記述に基づいて前記追加命令の構成定義文を生成し、
前記仕様記述に基づいて前記追加命令と前記追加命令に対応する組み込み関数との関係定義文を生成し、
前記構成定義文と前記関係定義文とを前記ベースプロセッサ用のコンパイラのソースコードへ追加し、前記拡張プロセッサ用のコンパイラのソースコードを生成する、ことを特徴とする、請求項14又は15に記載のコンパイラ組み込み関数追加方法。 The built-in function adding step includes
Read the specification description of the additional instruction,
Generate a configuration definition statement of the additional instruction based on the specification description,
Generating a relationship definition statement between the additional instruction and a built-in function corresponding to the additional instruction based on the specification description;
16. The source code of the compiler for the extension processor is generated by adding the configuration definition statement and the relationship definition statement to the source code of the compiler for the base processor. To add a built-in compiler function.
コンパイラの中間言語で表現された追加命令のテンプレートと、
追加命令の実行に必要なサイクル数を定義するレイテンシ定義文と、
を含み、
前記追加命令の前記構成定義文を生成するにあたり、
前記仕様記述に含まれる前記追加命令の名前と、入力オペランドと出力オペランドとに基づいて、前記テンプレートを生成し、
前記仕様記述に含まれる前記追加命令の実行に必要なサイクル数に基づいて、前記レイテンシ定義文を生成する、ことを特徴とする、請求項16に記載のコンパイラ組み込み関数追加方法。 The configuration statement is
A template for additional instructions expressed in the intermediate language of the compiler;
A latency definition statement that defines the number of cycles required to execute the additional instruction;
Including
In generating the configuration statement of the additional instruction,
Generating the template based on a name of the additional instruction included in the specification description, an input operand, and an output operand;
17. The method for adding a compiler built-in function according to claim 16, wherein the latency definition statement is generated based on the number of cycles required for executing the additional instruction included in the specification description.
前記追加命令に対応する組み込み関数のプロトタイプ宣言と、
前記組み込み関数を追加命令へ置き換えるための組み込み関数展開関数と、を含み、
前記関係定義文を生成するにあたり、
前記仕様記述に含まれる前記追加命令の名前と、入力オペランドと、出力オペランドとに基づいて、前記組み込み関数のプロトタイプ宣言を生成し、
コンパイラの所定の形式に基づいて、前記組み込み関数展開関数を生成する、ことを特徴とする、請求項17に記載のコンパイラ組み込み関数追加方法。 The relationship definition statement is
A prototype declaration of a built-in function corresponding to the additional instruction;
A built-in function expansion function for replacing the built-in function with an additional instruction,
In generating the relationship definition statement,
Generating a prototype declaration of the built-in function based on the name of the additional instruction, the input operand, and the output operand included in the specification description;
18. The method for adding a compiler built-in function according to claim 17, wherein the built-in function expansion function is generated based on a predetermined format of the compiler.
前記仕様記述の前記追加命令の出力オペランドと、入力オペランドとを順番に並べることによって、追加命令の中間言語定義文におけるオペランドの番号を決定し、
前記仕様記述に含まれる前記追加命令の名前に基づいて前記テンプレートの名前を生成し、
前記仕様記述に含まれる前記追加命令の出力オペランドの型に基づいて前記テンプレートの出力オペランドの記述を生成し、
前記仕様記述に含まれる前記追加命令の入力オペランドの型に基づいて前記テンプレートの入力オペランドの記述を生成し、
追加命令がコンパイラにとって不明な演算を実行することを示す演算子を用いてテンプレートにおける追加命令の動作記述を生成し、
前記仕様記述に含まれる前記追加命令のシンタックスに含まれるオペランドを前記オペランド番号で置き換えることによってテンプレートのシンタックスを生成し、
前記仕様記述に含まれる前記追加命令の命令語長に基づいて前記テンプレートにおける命令語長定義文を生成し、
前記仕様記述に含まれる前記追加命令の名前に基づいて前記テンプレートにおけるニモニック定義文を生成する、ことを特徴とする、請求項17又は18に記載のコンパイラ組み込み関数追加方法。 In the built-in function adding step, the template is generated.
Determining the number of the operand in the intermediate language definition statement of the additional instruction by arranging the output operand and the input operand of the additional instruction in the specification description in order;
Generating a name for the template based on the name of the additional instruction included in the specification description;
Generating a description of the output operand of the template based on the type of the output operand of the additional instruction included in the specification description;
Generating a description of the input operand of the template based on the type of the input operand of the additional instruction included in the specification description;
Generate an action description of the additional instruction in the template using an operator that indicates that the additional instruction performs an operation unknown to the compiler;
Generating a template syntax by replacing an operand included in the syntax of the additional instruction included in the specification description with the operand number;
Generating an instruction word length definition sentence in the template based on an instruction word length of the additional instruction included in the specification description;
19. The method for adding a compiler built-in function according to claim 17, wherein a mnemonic definition sentence in the template is generated based on a name of the additional instruction included in the specification description.
前記追加命令の仕様記述として前記追加命令のニモニック、前記追加命令のシンタックス、前記追加命令の入力オペランドと出力オペランド、前記追加命令の命令語長情報、及び、前記追加命令のレイテンシ情報を含む追加命令仕様記述ファイルと、前記ベースプロセッサ用のコンパイラのソースコードとを記憶した記憶装置と、
前記記憶装置から、前記追加命令仕様記述ファイルと、前記ベースプロセッサ用のコンパイラのソースコードとを入力し、前記追加命令仕様記述ファイルから、前記追加命令の構成定義情報と、前記追加命令と前記組み込み関数との関係定義情報とを生成し、前記追加命令の構成定義情報と、前記追加命令と前記組み込み関数との関係定義情報とを前記ベースプロセッサ用のコンパイラのソースコードに追加することで、前記追加命令を命令セットに備えたプロセッサ用の前記新たなコンパイラのソースコードを生成して記憶装置に出力する組み込み関数追加手段を備え、
前記構成定義情報は、
コンパイラの中間言語で表現された前記追加命令のテンプレートと、
前記追加命令の実行に必要なサイクル数を定義するレイテンシ定義と、
を含み、
前記組み込み関数追加手段は、
前記追加命令の前記構成定義情報を生成するにあたり、
前記追加命令の仕様記述から、前記追加命令のニモニックと、入力オペランドと出力オペランド、前記追加命令の動作、前記追加命令の語長とシンタックスを含む前記テンプレートを生成し、
前記仕様記述に含まれる前記追加命令のレイテンシ情報に基づいて、前記レイテンシ定義を生成し、
前記関係定義情報は、
前記追加命令に対応する組み込み関数の引数情報、組み込み関数の戻り値に関する情報を含み、コンパイラに対して組み込み関数を組み込み関数として認識させる組み込み関数のプロトタイプ宣言と、
前記組み込み関数を追加命令へ置き換えるための組み込み関数展開関数と、
を含み、
前記組み込み関数追加手段は、
前記関係定義情報を生成するにあたり、
前記仕様記述に含まれる前記追加命令ニモニックと、入力オペランドと、出力オペランドとに基づいて、前記組み込み関数のプロトタイプ宣言を生成し、
前記組み込み関数の展開関数生成において、前記組み込み関数の引数の型の検査、前記組み込み関数の戻り値の型の取得、前記組み込み関数に対応する中間言語の式であるRTL(Register Transfer Level)式の生成を行う、ことを特徴とする、コンパイラ組み込み関数追加装置。 A new compiler is automatically generated by adding built-in functions corresponding to new instructions added to the instruction set of the base processor (called "additional instructions") from the compiler of the basic processor (called "base processor") The additional instruction mnemonic, the additional instruction syntax, the input instruction and output operands of the additional instruction, the instruction word length information of the additional instruction, and the additional instruction A storage device storing an additional instruction specification description file including latency information, and a source code of the compiler for the base processor;
The additional instruction specification description file and the source code of the base processor compiler are input from the storage device, and the additional instruction configuration definition information, the additional instruction, and the embedded instruction are input from the additional instruction specification description file. Generating the relationship definition information with the function, and adding the configuration definition information of the additional instruction and the relationship definition information of the additional instruction and the built-in function to the source code of the compiler for the base processor, Built-in function adding means for generating source code of the new compiler for a processor having an additional instruction in an instruction set and outputting the generated source code to a storage device;
The configuration definition information is
A template for the additional instruction expressed in an intermediate language of the compiler;
A latency definition that defines the number of cycles required to execute the additional instruction;
Including
The built-in function adding means includes
In generating the configuration definition information of the additional instruction,
Generating the template including the mnemonic of the additional instruction, the input and output operands, the operation of the additional instruction, the word length and syntax of the additional instruction from the specification description of the additional instruction;
Based on the latency information of the additional instruction included in the specification description, the latency definition is generated,
The relationship definition information is
A prototype declaration of an embedded function including information on arguments of the embedded function corresponding to the additional instruction, information on a return value of the embedded function, and causing the compiler to recognize the embedded function as an embedded function;
A built-in function expansion function for replacing the built-in function with an additional instruction;
Including
The built-in function adding means includes
In generating the relationship definition information,
Generating a prototype declaration of the built-in function based on the additional instruction mnemonic, the input operand, and the output operand included in the specification description;
In the expansion function generation of the built-in function, the argument type of the built-in function is checked, the return type of the built-in function is obtained, and an RTL (Register Transfer Level) expression that is an intermediate language expression corresponding to the built-in function. A compiler built-in function adding device characterized by generating.
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP2007340532 | 2007-12-28 | ||
| JP2007-340532 | 2007-12-28 |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2009084570A1 true WO2009084570A1 (en) | 2009-07-09 |
Family
ID=40824284
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/JP2008/073552 Ceased WO2009084570A1 (en) | 2007-12-28 | 2008-12-25 | Compiler embedded function adding device |
Country Status (1)
| Country | Link |
|---|---|
| WO (1) | WO2009084570A1 (en) |
Citations (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JP2002024029A (en) * | 2000-07-11 | 2002-01-25 | Toshiba Corp | Compiler, compiling method, and computer-readable recording medium recording compiled program |
| JP2002230065A (en) * | 2001-02-02 | 2002-08-16 | Toshiba Corp | System LSI development apparatus and system LSI development method |
| JP2003518280A (en) * | 1999-02-05 | 2003-06-03 | テンシリカ インコーポレイテッド | Automatic processor generation system and method for designing a configurable processor |
-
2008
- 2008-12-25 WO PCT/JP2008/073552 patent/WO2009084570A1/en not_active Ceased
Patent Citations (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JP2003518280A (en) * | 1999-02-05 | 2003-06-03 | テンシリカ インコーポレイテッド | Automatic processor generation system and method for designing a configurable processor |
| JP2002024029A (en) * | 2000-07-11 | 2002-01-25 | Toshiba Corp | Compiler, compiling method, and computer-readable recording medium recording compiled program |
| JP2002230065A (en) * | 2001-02-02 | 2002-08-16 | Toshiba Corp | System LSI development apparatus and system LSI development method |
Non-Patent Citations (2)
| Title |
|---|
| "DA Symposium 2001", vol. 2001, 23 July 2001, article KENTARO MITA ET AL.: "PEAS-III System no Tameno Compiler. Generator no Shisaku", pages: 143 - 147 * |
| YUJI NAGAMATSU ET AL.: "Meirei Set Kakucho ni Taisuru GCC Oyobi GNU Tool Chain no Retargeting", IPSJ SIG NOTES, vol. 2006, no. 4, 18 January 2006 (2006-01-18), pages 91 - 94 * |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| JP4202673B2 (en) | System LSI development environment generation method and program thereof | |
| US9268539B2 (en) | User interface component | |
| US7313773B1 (en) | Method and device for simulator generation based on semantic to behavioral translation | |
| JP4057938B2 (en) | Compiler, compiling method, and program development tool | |
| JP2003323463A5 (en) | ||
| US11513818B1 (en) | Method, product, and system for integrating a hardware accelerator with an extensible processor | |
| JP2011060277A (en) | Integration environment generator | |
| JP2006506710A (en) | Method and apparatus for disassembling and verifying configurable hardware | |
| JP2007323573A (en) | Functional test script generator | |
| JPH11513512A (en) | Method of manufacturing digital signal processor | |
| US7702499B1 (en) | Systems and methods for performing software performance estimations | |
| US20170300305A1 (en) | Executable guidance experiences based on implicitly generated guidance models | |
| Brandner et al. | Automatic generation of compiler backends | |
| Freitag et al. | The Vienna Architecture Description Language | |
| Kleine Büning et al. | Using DimSpec for bounded and unbounded software model checking | |
| WO2009084570A1 (en) | Compiler embedded function adding device | |
| Graf | Compiler backend generation using the VADL processor description language | |
| Bezzubikov et al. | Automatic dynamic binary translator generation from instruction set description | |
| US20050015778A1 (en) | Method and system for expressing the algorithms for the manipulation of hardware state using an abstract language | |
| dos Santos | C Compiler and Tools for P3 Educational Processor | |
| Daverveldt | LLVM-based ρ-VEX compiler | |
| Meyerowitz et al. | A visual language for describing instruction sets and generating decoders | |
| Andersson | Translation of CAN Bus XML Messages to C Source Code | |
| WO2025129636A1 (en) | Source file construction method and apparatus, device, and readable storage medium | |
| Akhlaq et al. | Assembler generator and cycle-accurate simulator generator for nogap |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 08866809 Country of ref document: EP Kind code of ref document: A1 |
|
| NENP | Non-entry into the national phase |
Ref country code: DE |
|
| 122 | Ep: pct application non-entry in european phase |
Ref document number: 08866809 Country of ref document: EP Kind code of ref document: A1 |
|
| NENP | Non-entry into the national phase |
Ref country code: JP |