Intermediate expression generation device, intermediate expression generation method, and recording medium
The intermediate expression generation device and method address the challenge of handling operations that rewrite argument values by generating intermediate representations for both in-place and out-of-place operations, ensuring accurate and correct execution of operations within the intermediate language, even when it lacks explicit support for argument rewriting.
Patent Information
- Application Number
- PCT/JP2023/028276
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Filing Date
- 2023-08-02
- Publication Date
- 2025-02-06
AI Technical Summary
Existing intermediate representation generation methods fail to effectively handle operations that involve rewriting the value of an argument, especially when the intermediate language lacks objects indicating such operations, leading to incorrect results or failure to reflect the intended operation.
The development of an intermediate expression generation device and method that generates intermediate representations for both in-place and out-of-place type operations, allowing for the creation of intermediate expressions that correspond to operations involving argument value rewriting, even when the intermediate language does not explicitly support such operations, by using out-of-place type operations to represent in-place type operations without rewriting the argument values.
Enables the generation of accurate intermediate representations for operations that rewrite argument values, ensuring correct execution and reflection of intended operations, even when the intermediate language lacks explicit support for argument rewriting operations.
Smart Images

Figure JP2023028276_06022025_PF_FP_ABST
Abstract
Description
Intermediate representation generation device, intermediate representation generation method, and recording medium
[0001] The present invention relates to an intermediate representation generation device, an intermediate representation generation method, and a recording medium.
[0002] When compiling a program, an intermediate representation of the program may be generated (see, for example, Patent Document 1).
[0003] Special Publication No. 2002-527815
[0004] It is preferable to be able to generate an intermediate representation corresponding to an operation involving rewriting of argument values even when the program includes an operation involving rewriting of argument values and the intermediate language does not include an object indicating the operation involving rewriting of argument values.
[0005] An example of an object of the present invention is to provide an intermediate representation generation device, an intermediate representation generation method, and a recording medium that can solve the above-mentioned problems.
[0006] According to a first aspect of the present invention, an intermediate representation generation device includes intermediate representation generation means for generating an intermediate representation corresponding to an in-place operation, which is an operation involving rewriting of argument values, using an intermediate representation of an out-of-place operation, which is an operation without rewriting of argument values.
[0007] According to a second aspect of the present invention, an intermediate representation generation method includes a computer generating an intermediate representation corresponding to an in-place operation, which is an operation involving rewriting of argument values, using an intermediate representation of an out-of-place operation, which is an operation without rewriting of argument values.
[0008] According to a third aspect of the present invention, a recording medium is a recording medium having recorded thereon a program that causes a computer to execute the following: generating an intermediate representation corresponding to an in-place operation, which is an operation involving rewriting of argument values, using an intermediate representation of an out-of-place operation, which is an operation without rewriting of argument values.
[0009] According to the present invention, even if a program includes an operation involving rewriting of argument values and the intermediate language does not include an object indicating the operation involving rewriting of argument values, an intermediate representation corresponding to the operation involving rewriting of argument values can be generated.
[0010] 1 is a diagram showing an example of the configuration of an information processing device according to at least one embodiment. FIG. 1 is a diagram showing an example of a source program using out-of-place operations. FIG. 2 is a diagram showing an example of generation of an intermediate representation for executing the source program shown in FIG. 2 , performed by an intermediate representation generation unit according to at least one embodiment. FIG. 3 is a diagram showing an example of a source program including in-place operations. FIG. 4 is a diagram showing an example of generation of an intermediate representation for executing the source program shown in FIG. 5 , performed by an intermediate representation generation unit according to at least one embodiment. FIG. 5 is a diagram showing an example of a source program in which, after an in-place operation, a reference to an argument rewritten by the operation occurs. FIG. 6 is a diagram showing an example of an intermediate representation for executing the source program shown in FIG. 7 , generated by an intermediate representation generation unit according to at least one embodiment. FIG. 7 is a diagram showing another example of generation of an intermediate representation for executing the source program shown in FIG. 4 , performed by an intermediate representation generation unit according to at least one embodiment. 1 is a diagram illustrating an example of a processing procedure in a method for generating an intermediate representation according to at least one embodiment;
[0011] The following describes embodiments of the present invention, but the following embodiments do not limit the scope of the invention as claimed. Furthermore, not all of the combinations of features described in the embodiments are necessarily essential to the solution of the invention.
[0012] <First Embodiment> Fig. 1 is a diagram showing an example of the configuration of an information processing device according to at least one embodiment. In the configuration shown in Fig. 1, the information processing device 100 includes a communication unit 110, a display unit 120, an operation input unit 130, a storage unit 180, and a control unit 190. The control unit 190 includes a front-end unit 210, an intermediate unit 220, and a back-end unit 230. The front-end unit 210 includes a program execution unit 211 and an intermediate representation generation unit 212. The intermediate unit 220 includes an optimization unit 221. The back-end unit 230 includes an intermediate representation execution unit 231.
[0013] The information processing device 100 partially converts a source program, which is a program to be executed such as a user program, into an intermediate representation and executes the converted source program. The information processing device 100 may also operate as a just-in-time compiler and partially convert the source program into an intermediate representation and execute the converted source program. The source program portion is also referred to as the source program. The source program is also simply referred to as the program.
[0014] Converting a source program into an intermediate representation is also called intermediate representation generation or intermediate representation generation. The information processing device 100 is an example of an intermediate representation generation device. The information processing device 100 may be configured using a computer such as a personal computer (PC).
[0015] The communication unit 110 communicates with other devices. For example, the communication unit 110 may communicate with another computer, such as a user's terminal device, to receive the source program. However, the method by which the information processing device 100 acquires the source program is not limited to a specific method.
[0016] The display unit 120 has a display screen such as a liquid crystal panel or an LED (Light Emitting Diode) panel, and acquires various images. For example, the display unit 120 may display the intermediate representation in accordance with a user instruction.
[0017] The operation input unit 130 includes input devices such as a keyboard and a mouse, and accepts user operations. For example, the operation input unit 130 may accept a user operation to instruct execution of a source program. Alternatively, the operation input unit 130 may accept a user operation to instruct display of an intermediate representation, and as described above, the display unit 120 may display the intermediate representation in accordance with the user's instruction.
[0018] The storage unit 180 stores various types of data. For example, the storage unit 180 may store a source program and an intermediate representation. The storage unit 180 is configured using a storage device included in the information processing device 100.
[0019] The control unit 190 controls each unit of the information processing device 100 to perform various processes. In particular, the control unit 190 executes a source program. As described above with respect to the information processing device 100, the control unit 190 partially converts the source program into an intermediate representation and executes it. The functions of the control unit 190 are performed, for example, by a CPU (Central Processing Unit) included in the information processing device 100 reading out a program from the storage unit 180 and executing it.
[0020] The front-end unit 210 converts part of the source program into an intermediate representation for the back-end unit 230, and causes the obtained intermediate representation to be executed by the back-end unit 230. Furthermore, the front-end unit 210 executes the part of the source program that is not converted into the intermediate representation as the source program.
[0021] Here, "executing as a source program" means executing without converting it into an intermediate representation for the backend unit 230. In particular, the expression "executing as a source program" does not exclude the case where a source program is converted into an intermediate representation in an intermediate language other than the intermediate language for the backend unit 230 and then executed. The intermediate language for the backend unit 230 is also simply referred to as the intermediate language. The intermediate representation for the backend unit 230 is also simply referred to as the intermediate representation.
[0022] The program execution unit 211 executes the source program. Specifically, the program execution unit 211 distinguishes between parts of the source program that are to be executed as the source program and parts that are to be converted into an intermediate representation and executed. The program execution unit 211 then executes the parts that it has decided to execute as the source program as is.
[0023] Furthermore, the program execution unit 211 causes the intermediate representation generation unit 212 to convert into an intermediate representation the portion that has been determined to be converted into an intermediate representation for execution. The program execution unit 211 also executes instructions that involve evaluation (value acquisition), such as the "print" instruction, in the source program. If execution of an intermediate representation becomes necessary when executing an instruction that involves evaluation, the program execution unit 211 causes the back-end unit 230 to execute the intermediate representation.
[0024] The intermediate representation generation unit 212 converts a portion of the source program into an intermediate representation (an intermediate representation intended for the back-end unit 230). Specifically, the intermediate representation generation unit 212 converts into the intermediate representation a portion of the source program that the program execution unit 211 has decided to convert into the intermediate representation and execute.
[0025] In particular, the intermediate representation generator 212 converts a source program written in a programming language that includes an operation involving the rewriting of argument values into an intermediate representation in an intermediate language that does not include objects that represent an operation involving the rewriting of argument values. An operation here refers to a process of applying an operation rule to one or more argument values and obtaining a value as the operation result.
[0026] The intermediate language objects referred to here are elements that make up the intermediate language. Intermediate language objects are also simply called objects. Intermediate language objects are also called intermediate language objects. Rewriting the value of an argument can also be considered a side effect of the argument. The intermediate representation generation unit 212 is an example of intermediate representation generation means.
[0027] The intermediate unit 220 performs processing between the generation of an intermediate representation by the front-end unit 210, and between an execution command for the intermediate representation and the execution of the intermediate representation by the back-end unit 230. The optimization unit 221 optimizes the intermediate representation generated by the intermediate representation generation unit 212. For example, when the intermediate representation generation unit 212 generates an intermediate representation specialized for a specific domain such as matrix operation, the optimization unit 221 may optimize the intermediate representation based on knowledge specific to that domain. Here, optimization of the intermediate representation may also mean converting the intermediate representation so that the back-end unit 230 can execute the intermediate representation faster.
[0028] The intermediate representation is executed by the back-end unit 230. The functions of the back-end unit 230 may be executed using hardware separate from the hardware that executes the functions of the front-end unit 210.
[0029] For example, the information processing device 100 may include an accelerator such as a GPU (Graphics Processing Unit) in addition to a CPU, and the functions of the control unit 190 may be executed using the accelerator in addition to the CPU. The functions of the front-end unit 210 may be executed using the CPU, and the functions of the back-end unit 230 may be executed using an accelerator such as a GPU. Furthermore, for example, the control unit 190 may convert a portion of the source program that can be executed by a GPU into an intermediate representation for a GPU and execute it on the GPU, and the remaining portion may be executed as the source program on the CPU.
[0030] The intermediate representation execution unit 231 executes the intermediate representation generated by the intermediate representation generation unit 212 or the intermediate representation optimized by the optimization unit 221 in accordance with an instruction from the program execution unit 211. That is, if the intermediate representation instructed to be executed by the program execution unit 211 has been optimized by the optimization unit 221, the intermediate representation execution unit 231 executes the optimized intermediate representation. Furthermore, if the intermediate representation instructed to be executed by the program execution unit 211 has not been optimized by the optimization unit 221, the intermediate representation execution unit 231 executes the intermediate representation generated by the intermediate representation execution unit 231. The intermediate representation execution unit 231 outputs the execution result of the intermediate representation (the value obtained by executing the intermediate representation) to the program execution unit 211.
[0031] A library may be used to execute both the source program in the front-end unit 210 and the intermediate representation in the back-end unit 230. In this case, the library used to execute the source program in the front-end unit 210 is called a parent library, and the library used to execute the intermediate representation in the back-end unit 230 is called a child library.
[0032] For example, the programming languages of the parent library and the source program may be ones that provide a relatively wide variety of operations, etc., to make it easier for users to write source programs (user programs). Furthermore, the programming languages of the child library and the intermediate representation (intermediate language) may be ones that provide fewer operations, etc., but are executable at high speed compared to the execution of the source program. Furthermore, for example, the programming languages of the child library and the intermediate representation may be domain-specific languages (DSLs) specialized for devices that execute the intermediate representation, such as GPUs.
[0033] Furthermore, for example, the parent library may provide an operation involving rewriting of argument values, while the child library may not provide an operation involving rewriting of argument values, so that the intermediate representation generation unit 212 may convert a source program written in a programming language that includes an operation involving rewriting of argument values into an intermediate representation in an intermediate language that does not include an object indicating an operation involving rewriting of argument values.
[0034] However, the configuration and functions of the information processing device 100 are not limited to a specific one, and various configurations and functions are possible, such as converting a source program written in a programming language that includes an operation involving rewriting argument values into an intermediate representation in an intermediate language that does not include objects that indicate an operation involving rewriting argument values. For example, the information processing device 100 may be configured as a compiler that generates an intermediate representation by compiling a source program.
[0035] An operation that involves rewriting the argument value is also called an inplace operation, and an operation that does not involve rewriting the argument value is also called an out-of-place operation.
[0036] Figure 2 is a diagram showing an example of a source program using out-of-place operations. In the example in Figure 2, "mat_add" is an out-of-place addition. In "c = mat_add(a, b)", the result of adding a and b is c. "mat_mul" is an out-of-place multiplication. In "e = mat_mul(c, d)", the result of multiplying c and d is e. "#1" and "#2" are annotations (comments) indicating line numbers and are ignored when the source program is executed.
[0037] Fig. 3 is a diagram showing an example of generation of an intermediate representation for executing the source program shown in Fig. 2, performed by the intermediate representation generation unit 212. In generating the intermediate representation of "c = mat_add(a, b)", the intermediate representation generation unit 212 generates an object "add" indicating out-of-place addition as operation information of c (information indicating the operation for calculating c).
[0038] An "input data reference" is information that indicates the reference destination of data. When generating an object of "c = mat_add(a, b)", the intermediate representation generation unit 212 sets the reference destination of the actual data of a and the reference destination of the actual data of b as the "input data reference". a and b may each be a variable or a calculation result. Therefore, the reference destination of the actual data of a and the reference destination of the actual data of b may each be a storage area of a variable or an object that indicates a calculation. When an object that indicates a calculation is set as the reference destination of data, the intermediate representation execution unit 231 obtains the result of the calculation of the reference destination when executing the intermediate representation.
[0039] When generating an object for "e = mat_mul(c, d)", the intermediate representation generation unit 212 generates an object "mul" that indicates out-of-place multiplication as the operation information for e. The intermediate representation generation unit 212 also sets the object for the operation information for c and the reference destination for the actual data of d as the "input data reference". The reference destination for the actual data of d may be the storage area for a variable or may be an object that indicates the operation.
[0040] In this way, the intermediate representation generation unit 212 can generate an intermediate representation of an out-of-place operation by generating an object for that operation and setting the reference destination of the argument in the "input data reference".
[0041] Figure 4 shows an example of a source program including an in-place operation. In the example in Figure 4, "mat_add" is an out-of-place addition, as in Figure 2. In "c = mat_add(a, b)", the result of the addition of a and b is set to c. On the other hand, "mat_mul_inplace" is an in-place multiplication. In "mat_mul_inplace(c, d)", the result of the multiplication of c and d is assigned to c.
[0042] In the case of an in-place operation, simply performing an out-of-place operation does not update the argument values, and the correct operation result cannot be obtained. In the example of Figure 4, if an out-of-place multiplication is performed by executing "mat_mul_inplace(c, d)", c will remain the operation result of "mat_add(a, b)". In this case, when the value of c is referenced after "mat_mul_inplace(c, d)", an incorrect value that does not reflect the multiplication by "mat_mul_inplace(c, d)" will be referenced.
[0043] Therefore, the intermediate representation generation unit 212 generates an intermediate language corresponding to an in-place operation using a procedure different from that used when generating an intermediate language for an out-of-place operation. The intermediate representation corresponding to an in-place operation here is an intermediate representation that produces the same value as the result of the operation as would be obtained by executing the in-place operation. In particular, the execution of the intermediate representation corresponding to an in-place operation does not need to include a process of overwriting values in memory that stores argument values. Figure 5 is a diagram showing an example of the generation of an intermediate representation for executing the source program shown in Figure 4, performed by the intermediate representation generation unit 212.
[0044] The generation of the intermediate representation of "c = mat_add(a, b)" is the same as in Figure 3. On the other hand, if the generation of the intermediate representation of "mat_mul_inplace(c, d)" were the same as in Figure 3, the multiplication by "mat_mul_inplace(c, d)" would not be reflected in the value of c, as described above.
[0045] Therefore, the intermediate representation generation unit 212 replaces the operation information of c with the object "mul" based on "mat_mul_inplace(c, d)." As described above, the object "mul" is an object that indicates out-of-place multiplication.
[0046] At this time, the intermediate representation generation unit 212 saves the intermediate representation of "c = mat_add(a, b)" by, for example, copying it to the working memory. The intermediate representation of "c = mat_add(a, b)" can be said to be an intermediate representation that is a reference destination for the value of the argument c to be rewritten before it is rewritten.
[0047] Then, the intermediate representation generation unit 212 sets the reference of the argument c to the saved intermediate representation of "c = mat_add(a, b)". This is equivalent to setting the reference of the argument c to c before it was rewritten by executing "mat_mul_inplace(c, d)". The intermediate representation generation unit 212 sets the reference of the argument d to the reference of the actual data of d.
[0048] According to the intermediate representation obtained in the example of Fig. 5, the value of c is the product of the operation result of "mat_add(a, b)" and d. Therefore, according to the intermediate representation obtained in the example of Fig. 5, when the value of c is referenced after "mat_mul_inplace(c, d)", the intermediate representation execution unit 231 can reference the correct value that reflects the multiplication by "mat_mul_inplace(c, d)".
[0049] 6 is a diagram showing an example of a source program in which, after an in-place operation, a reference is made to an argument rewritten by that operation. Lines 1 and 2 of the source program shown in FIG. 6 are the same as the example in FIG. 5. In the example in FIG. 6, line 3 "e = mat_sub(c, f)" references argument c after its value is rewritten by the execution of "mat_mul_inplace(c, d)".
[0050] "mat_sub" is an out-of-place subtraction. In "e = mat_sub(c, f)", the result of subtracting f from c is e. "#3" is a comment indicating the line number, and is ignored when the source program is executed.
[0051] Fig. 7 is a diagram showing an example of an intermediate representation generated by the intermediate representation generation unit 212 for executing the source program shown in Fig. 6. The generation of the intermediate representations of "c = mat_add(a, b)" and "mat_mul_inplace(c, d)" is similar to the case of Fig. 5.
[0052] When generating the intermediate representation of "e = mat_sub(c, f)", the intermediate representation generation unit 212 generates an object "sub" indicating out-of-place subtraction as the operation information of e. The intermediate representation generation unit 212 also sets the object of the operation information of c and the reference destination of the actual data of f as the "input data reference". The reference destination of the actual data of f may be the storage area of a variable or may be an object indicating the operation.
[0053] According to the intermediate representation shown in FIG. 7, when performing subtraction in the object "sub", the intermediate representation execution unit 231 can refer to the value of c in which the multiplication in the object "mul" is reflected.
[0054] 8 is a diagram showing an example of a processing procedure in which the intermediate representation generation unit 212 generates an intermediate representation corresponding to an in-place operation. In the processing in Fig. 8, the intermediate representation generation unit 212 saves the intermediate representation of the argument to be rewritten (step S11). Here, the intermediate representation of the argument to be rewritten is the intermediate representation that is the reference destination of the value of the argument to be rewritten before it is rewritten.
[0055] Next, the intermediate representation generation unit 212 generates an object of an out-of-place operation as operation information of the argument to be rewritten (step S12). Specifically, the intermediate representation generation unit 212 generates an object of an out-of-place operation corresponding to the in-place operation.
[0056] Here, an out-of-place operation corresponding to an in-place operation is an operation in which the in-place operation is modified so that it does not involve argument rewriting. The argument values after rewriting in the in-place operation are shown as the output values of the corresponding out-of-place operation.
[0057] For example, the intermediate representation generation unit 212 generates an object of out-of-place multiplication "mat_mul" for the in-place multiplication "mat_mul_inplace." The generation of the object in step S12 corresponds to an example of object replacement. The object saved by the intermediate representation generation unit 212 in step S11 corresponds to an example of the object before replacement.
[0058] Next, the intermediate representation generation unit 212 sets the saved intermediate representation as the reference destination of the argument to be rewritten (the reference destination of the value of the argument to be rewritten before rewriting) (step S13). The intermediate representation generation unit 212 also sets the reference destination of other arguments (arguments other than the argument to be rewritten) (step S14). After step S14, the intermediate representation generation unit 212 ends the processing of FIG. 8.
[0059] The intermediate representation generation unit 212 may generate an object that indicates the reference destination of the value. Then, the intermediate representation generation unit 212 may insert an object of an out-of-place operation that corresponds to the in-place operation between the object that indicates the reference destination of the value and the reference destination. The object that indicates the reference destination of the value is called a "Glue."
[0060] 9 is a diagram showing another example of the generation of an intermediate representation by the intermediate representation generation unit 212 for executing the source program shown in FIG. 4. When generating an intermediate representation for the first line of the source program in FIG. 4, "c = mat_add(a, b)," the object generation and the setting of "input data reference" are the same as in FIG. 5. On the other hand, in the example of FIG. 9, the intermediate representation generation unit 212 generates a group for c and sets its reference to the generated object "add." This is equivalent to setting the reference of c (the reference of the value of c) as the operation result of "mat_add(a, b)."
[0061] In generating the intermediate representation of "mat_mul_inplace(c, d)", the intermediate representation generation unit 212 inserts the object "mul" between the glue of c and the object "add". In setting the "input data reference" of the object "mul", the intermediate representation generation unit 212 sets the object "add" generated in the intermediate representation of "c = mat_add(a, b)" and the actual data of d. In this way, with the method using glue, the intermediate representation generation unit 212 can generate an intermediate representation of a source program including an in-place operation without having to rewrite the object.
[0062] The intermediate representation generation unit 212 may generate a group each time it generates an object that is not referenced by other objects. For example, when the intermediate representation generation unit 212 generates the object "add" for "c = mat_add(a, b)" in the source program of FIG. 4, it may generate a group (group of c) that references the object "add".
[0063] Alternatively, the intermediate representation generation unit 212 may generate a group as preprocessing for generating an intermediate representation corresponding to an in-place operation. For example, when the intermediate representation generation unit 212 generates the object "add" for "c = mat_add(a, b)" in the source program of Fig. 4, the object "add" may be generated as operation information for c, as in the example of Fig. 5. Then, when the intermediate representation generation unit 212 generates the object "mul" for "mat_mul_inplace(c, d)", the intermediate representation generation unit 212 may generate a group (a group of c) that references the object "add" as preprocessing for generating the object "mul".
[0064] In this case, the intermediate representation generation unit 212 may change the object "add" from the operation information of c to simple operation information (operation information that does not refer to specific actual data). This makes it possible to prevent the object "add" from being referenced when the value of c is referenced after "mat_mul_inplace(c, d)" in the source program. In other words, it is possible to prevent an incorrect value that does not reflect the multiplication by "mat_mul_inplace(c, d)" from being referenced.
[0065] 10 is a diagram showing another example of the processing procedure in which the intermediate representation generation unit 212 generates an intermediate representation corresponding to an in-place operation. In the processing in Fig. 10, the intermediate representation generation unit 212 inserts an object of an out-of-place operation corresponding to the in-place operation between the group of the argument to be rewritten and the reference of that group (step S21). At that time, the intermediate representation generation unit 212 sets the reference of the argument to be rewritten in the "input data reference" to the reference of the original group.
[0066] Next, the intermediate representation generation unit 212 sets reference destinations for other arguments (arguments other than the argument to be rewritten) (step S22). If there are no arguments other than the argument to be rewritten, the intermediate representation generation unit 212 does not perform any other processing in step S22. After step S22, the intermediate representation generation unit 212 ends the processing of FIG. 10.
[0067] As described above, the intermediate representation generation unit 212 generates an intermediate representation corresponding to an in-place operation, which is an operation involving rewriting of argument values, by using an intermediate representation of an out-of-place operation, which is an operation without rewriting of argument values. According to the information processing device 100, even if the source program includes an operation involving rewriting of argument values and the intermediate language does not include an object indicating the operation involving rewriting of argument values, it is possible to generate an intermediate representation corresponding to the operation involving rewriting of argument values.
[0068] Furthermore, the intermediate representation generation unit 212 replaces an object indicating an operation of the argument value to be rewritten in an in-place operation with an object of an out-of-place operation corresponding to the in-place operation, and sets the reference destination of the argument of the out-of-place operation that was to be rewritten in the in-place operation to the object before replacement.
[0069] This allows the information processing device 100 to reflect the in-place operation on the value of the argument that is the target of rewriting by the in-place operation. In this way, according to the information processing device 100, even if the source program includes an operation that involves rewriting the value of an argument and the intermediate language does not include an object indicating the operation that involves rewriting the value of an argument, it is possible to generate an intermediate representation corresponding to the operation that involves rewriting the value of an argument.
[0070] Furthermore, the intermediate representation generation unit 212 saves the original object before replacing the object. According to the information processing device 100, it is possible to set the reference destination of the argument value to be rewritten without having to re-generate the object before replacement. In this respect, according to the information processing device 100, it is possible to generate intermediate representations corresponding to in-place operations relatively easily.
[0071] Furthermore, the intermediate representation generation unit 212 inserts an object of an out-of-place operation corresponding to the in-place operation between the object indicating the reference destination of the value before rewriting of the argument that is the target of rewriting in the in-place operation and that reference destination, and sets the reference destination of the value of the argument that was the target of rewriting in the in-place operation, among the arguments of the out-of-place operation, to the reference destination of the value before rewriting.
[0072] This allows the information processing device 100 to reflect the in-place operation on the value of the argument that is the target of rewriting by the in-place operation. In this way, according to the information processing device 100, even if the source program includes an operation that involves rewriting the value of an argument and the intermediate language does not include an object indicating the operation that involves rewriting the value of an argument, it is possible to generate an intermediate representation corresponding to the operation that involves rewriting the value of an argument.
[0073] Furthermore, each time the intermediate representation generation unit 212 generates an object that references an object that is not referenced by another object, the intermediate representation generation unit 212 generates an object that references that object. According to the information processing device 100, the reference destination of a value is indicated by an object (glue) that indicates the reference destination of the value, so that it is relatively easy to refer to a value and change the reference destination of a value.
[0074] Furthermore, if there is no object indicating a reference to the pre-rewrite value of an argument to be rewritten in an in-place operation for which an intermediate representation is being generated, the intermediate representation generation unit 212 generates that object. In the information processing device 100, when generating an intermediate representation corresponding to an in-place operation, if there is no object (glue) indicating a reference to the pre-rewrite value of an argument to be rewritten in an in-place operation for which an intermediate representation is being generated, the information processing device 100 generates that object (glue). According to the information processing device 100, the number of glues to be generated is relatively small, and therefore the load of generating an intermediate representation is relatively small.
[0075] Second Embodiment Fig. 11 is a diagram showing an example of the configuration of an intermediate representation generation device according to at least one embodiment. In the configuration shown in Fig. 11, an intermediate representation generation device 610 includes an intermediate representation generation unit 611.
[0076] With this configuration, the intermediate representation generation unit 611 generates an intermediate representation corresponding to an in-place operation, which is an operation involving rewriting of argument values, by using an intermediate representation of an out-of-place operation, which is an operation without rewriting of argument values. The intermediate representation generation unit 611 is an example of an intermediate representation generation means.
[0077] According to the intermediate representation generation device 610, even if the source program includes an operation involving rewriting of argument values and the intermediate language does not include an object indicating the operation involving rewriting of argument values, it is possible to generate an intermediate representation corresponding to the operation involving rewriting of argument values.
[0078] Third Embodiment Fig. 12 is a diagram showing an example of a processing procedure in a method for generating an intermediate representation according to at least one embodiment. The method for generating an intermediate representation shown in Fig. 12 includes generating an intermediate representation (step S611).
[0079] In generating an intermediate representation (step S611), the computer generates an intermediate representation corresponding to an in-place operation, which is an operation involving rewriting of argument values, using an intermediate representation of an out-of-place operation, which is an operation without rewriting of argument values.
[0080] According to the intermediate representation generation method shown in FIG. 12, even if the source program includes an operation involving rewriting of argument values and the intermediate language does not include an object indicating the operation involving rewriting of argument values, it is possible to generate an intermediate representation corresponding to the operation involving rewriting of argument values.
[0081] 13 is a diagram illustrating an example of a computer configuration according to at least one embodiment. In the configuration illustrated in FIG. 13, a computer 700 includes a CPU 710, a main memory device 720, an auxiliary memory device 730, an interface 740, a non-volatile recording medium 750, and an accelerator 760.
[0082] One or more of the information processing device 100 and the intermediate representation generation device 610, or a part thereof, may be implemented in a computer 700. In this case, the operation of each of the above-described processing units is stored in the auxiliary storage device 730 in the form of a program. The CPU 710 and the accelerator 760 read the program from the auxiliary storage device 730, load it into the main storage device 720, and execute the above-described processing in accordance with the program. The CPU 710 also allocates storage areas in the main storage device 720 corresponding to each of the above-described storage units in accordance with the program. Communication between each device and other devices is performed by an interface 740 having a communication function and performing communication under the control of the CPU 710.
[0083] When the information processing device 100 is implemented in a computer 700, the operations of the control unit 190 and each of its units are stored in the form of a program in the auxiliary storage device 730. The CPU 710 and the accelerator 760 read the program from the auxiliary storage device 730, load it into the main storage device 720, and execute the above-described processing in accordance with the program.
[0084] Furthermore, the CPU 710 allocates a storage area for the storage unit 180 in the main storage device 720 in accordance with the program. Communication with other devices by the communication unit 110 is performed by the interface 740 having a communication function and operating under the control of the CPU 710. Display of images by the display unit 120 is performed by the interface 740 having a display device and displaying various images under the control of the CPU 710. Reception of user operations by the operation input unit 130 is performed by the interface 740 having an input device and receiving user operations under the control of the CPU 710.
[0085] When the intermediate representation generation device 610 is implemented in the computer 700, the operation of the intermediate representation generation unit 611 is stored in the form of a program in the auxiliary storage device 730. The CPU 710 and the accelerator 760 read the program from the auxiliary storage device 730, load it into the main storage device 720, and execute the above-described processing in accordance with the program.
[0086] Furthermore, the CPU 710, in accordance with the program, allocates a storage area in the main memory device 720 for the intermediate representation generation device 610 to perform processing. Communication between the intermediate representation generation device 610 and other devices is achieved by the interface 740, which has a communication function and operates under the control of the CPU 710. Interaction between the intermediate representation generation device 610 and a user is achieved by the interface 740, which has a display device and an input device, displaying various images under the control of the CPU 710 and accepting user operations.
[0087] One or more of the above-described programs may be recorded on the nonvolatile recording medium 750. In this case, the interface 740 may read the programs from the nonvolatile recording medium 750. The CPU 710 and the accelerator 760 may then directly execute the programs read by the interface 740, or may temporarily store the programs in the main storage device 720 or the auxiliary storage device 730 and then execute them.
[0088] Note that a program for executing all or part of the processing performed by the information processing device 100 and the intermediate representation generation device 610 may be recorded on a computer-readable recording medium, and the program recorded on the recording medium may be loaded into a computer system and executed to perform the processing of each unit. Note that the term "computer system" here includes hardware such as an operating system (OS) and peripheral devices. Furthermore, the term "computer-readable recording medium" refers to portable media such as flexible disks, optical magnetic disks, read-only memories (ROMs), and compact disc read-only memories (CD-ROMs), as well as storage devices such as hard disks built into computer systems. The program may be designed to implement part of the aforementioned functions, or may be capable of implementing the aforementioned functions in combination with a program already recorded on the computer system.
[0089] Although an embodiment of the present invention has been described above in detail with reference to the drawings, the specific configuration is not limited to this embodiment, and includes designs within the scope of the gist of the present invention.
[0090] A part or all of the above-described embodiments can be described as, but not limited to, the following supplementary notes.
[0091] (Supplementary Note 1) An intermediate representation generation device comprising: intermediate representation generation means for generating an intermediate representation corresponding to an in-place operation, which is an operation involving rewriting of argument values, using an intermediate representation of an out-of-place operation, which is an operation without rewriting of argument values.
[0092] (Supplementary Note 2) The intermediate representation generation device according to Supplementary Note 1, wherein the intermediate representation generation means replaces an intermediate language object indicating an operation on the value of an argument that is to be rewritten in an in-place operation with an intermediate language object of an out-of-place operation that corresponds to the in-place operation, and sets the reference destination of the argument of the out-of-place operation that was to be rewritten in the in-place operation to the intermediate language object before replacement.
[0093] (Supplementary Note 3) The intermediate representation generation device according to Supplementary Note 2, wherein the intermediate representation generation means saves the original intermediate language object before replacing the intermediate language object.
[0094] (Supplementary Note 4) The intermediate representation generation means of the intermediate representation generation device according to Supplementary Note 1 inserts an intermediate language object of an out-of-place operation corresponding to the in-place operation between an intermediate language object indicating a reference destination of the value before rewriting of an argument that is the target of rewriting in the in-place operation and the reference destination, and sets the reference destination of the value of the argument that was the target of rewriting in the in-place operation among the arguments of the out-of-place operation to the reference destination of the value before rewriting.
[0095] (Supplementary Note 5) The intermediate representation generation device according to Supplementary Note 4, wherein the intermediate representation generation means generates an intermediate language object that references the intermediate language object each time it generates an intermediate language object that is not referenced by another intermediate language object.
[0096] (Supplementary Note 6) The intermediate representation generation device according to Supplementary Note 4, wherein the intermediate representation generation means generates an intermediate language object when there is no intermediate language object indicating a reference to a value before rewriting of an argument that is to be rewritten in an in-place operation for which an intermediate representation is to be generated.
[0097] (Supplementary Note 7) A method for generating an intermediate representation, the method comprising: a computer generating an intermediate representation corresponding to an in-place operation, which is an operation involving rewriting of argument values, using an intermediate representation of an out-of-place operation, which is an operation without rewriting of argument values.
[0098] (Supplementary Note 8) The intermediate representation generation method according to Supplementary Note 7, wherein the generation replaces an intermediate language object indicating an operation on the value of an argument that is to be rewritten in an in-place operation with an intermediate language object of an out-of-place operation that corresponds to the in-place operation, and sets the reference of the argument of the out-of-place operation that was to be rewritten in the in-place operation to the intermediate language object before replacement.
[0099] (Supplementary Note 9) The method for generating an intermediate representation according to Supplementary Note 8, wherein the generating step includes saving the original intermediate language object before replacing the intermediate language object.
[0100] (Supplementary Note 10) The intermediate representation generation method according to Supplementary Note 7, wherein the generating step inserts an intermediate language object of an out-of-place operation corresponding to the in-place operation between an intermediate language object indicating a reference destination of the value before rewriting of an argument that is the target of rewriting in an in-place operation and the reference destination, and sets the reference destination of the value of the argument that was the target of rewriting in the in-place operation among the arguments of the out-of-place operation to the reference destination of the value before rewriting.
[0101] (Supplementary Note 11) The intermediate representation generation method according to Supplementary Note 10, wherein, in the generating step, each time an intermediate language object that is not referenced by another intermediate language object is generated, an intermediate language object that references that intermediate language object is generated.
[0102] (Supplementary Note 12) The intermediate representation generation method according to Supplementary Note 10, wherein in the generation, if there is no intermediate language object indicating a reference destination for a value before rewriting of an argument that is to be rewritten in an in-place operation for which an intermediate representation is to be generated, that intermediate language object is generated.
[0103] (Supplementary Note 13) A recording medium having recorded thereon a program that causes a computer to execute the following: Generate an intermediate representation corresponding to an in-place operation, which is an operation involving rewriting of argument values, using an intermediate representation of an out-of-place operation, which is an operation without rewriting of argument values.
[0104] (Appendix 14) The recording medium described in Appendix 13, wherein the generating causes a computer to: replace an intermediate language object indicating an operation on the value of an argument that is to be rewritten in an in-place operation with an intermediate language object of an out-of-place operation corresponding to the in-place operation; and set the reference of the argument of the out-of-place operation that was to be rewritten in the in-place operation to the intermediate language object before replacement.
[0105] (Supplementary Note 15) The recording medium according to Supplementary Note 14, wherein the generating step causes the computer to: save the original intermediate language object before replacing the intermediate language object.
[0106] (Appendix 16) The recording medium according to appendix 13, wherein the generating causes a computer to: insert an intermediate language object of an out-of-place operation corresponding to the in-place operation between an intermediate language object indicating a reference destination of the value before rewriting of an argument that is the target of rewriting in an in-place operation and the reference destination; and set the reference destination of the value of the argument that was the target of rewriting in the in-place operation, among the arguments of the out-of-place operation, to the reference destination of the value before rewriting.
[0107] (Appendix 17) The recording medium described in Appendix 16, wherein the generating causes the computer to execute the following: each time an intermediate language object that is not referenced by another intermediate language object is generated, an intermediate language object that references that intermediate language object is generated.
[0108] (Appendix 18) The recording medium described in Appendix 13, wherein the generating causes a computer to execute the following: if there is no intermediate language object indicating the reference destination of the value before rewriting of an argument that is to be rewritten in an in-place operation for which an intermediate representation is to be generated, generating the intermediate language object.
[0109] The present invention may be applied to an intermediate representation generation device, an intermediate representation generation method, and a recording medium.
[0110] REFERENCE SIGNS LIST 100 Information processing device 110 Communication unit 120 Display unit 130 Operation input unit 180 Storage unit 190 Control unit 210 Front-end unit 211 Program execution unit 212 Intermediate representation generation unit 220 Intermediate unit 221 Optimization unit 230 Back-end unit 231 Intermediate representation execution unit 610 Intermediate representation generation device 611 Intermediate representation generation unit
Claims
1. An intermediate representation generation device comprising an intermediate representation generation means for generating an intermediate representation corresponding to an in-place operation, which is an operation involving rewriting of argument values, using an intermediate representation of an out-of-place operation, which is an operation without rewriting of argument values.
2. The intermediate representation generating device according to claim 1, wherein the intermediate representation generating means replaces an intermediate language object indicating an operation of the value of an argument that is to be rewritten in an in-place type operation with an intermediate language object of an out-of-place type operation corresponding to the in-place type operation, and sets the reference destination of the argument that was to be rewritten in the in-place type operation, among the arguments of the out-of-place type operation, to the intermediate language object before the replacement.
3. The intermediate representation generating device according to claim 2, wherein said intermediate representation generating means saves the original intermediate language object before replacing the intermediate language object.
4. The intermediate representation generating device according to claim 1, wherein the intermediate representation generating means inserts an intermediate language object of an out-of-place type operation corresponding to the in-place type operation between an intermediate language object indicating the reference destination of the value before rewriting of an argument that is the target of rewriting in an in-place type operation and the reference destination, and sets the reference destination of the value of the argument that was the target of rewriting in the in-place type operation among the arguments of the out-of-place type operation to the reference destination of the value before rewriting.
5. The intermediate representation generating device according to claim 4, wherein each time said intermediate representation generating means generates an intermediate language object that references an intermediate language object that is not referenced by other intermediate language objects, said intermediate representation generating means generates an intermediate language object that references that intermediate language object.
6. The intermediate representation generating device according to claim 4, wherein the intermediate representation generating means generates an intermediate language object when there is no intermediate language object indicating the reference destination of the value before rewriting of an argument that is to be rewritten in an in-place operation for which an intermediate representation is to be generated.
7. A method for generating an intermediate representation, comprising: a computer generating an intermediate representation corresponding to an in-place operation, which is an operation involving rewriting of argument values, using an intermediate representation for an out-of-place operation, which is an operation without rewriting of argument values.
8. A recording medium having recorded thereon a program for causing a computer to execute the following: Generate an intermediate representation corresponding to an in-place type operation, which is an operation involving rewriting of argument values, using an intermediate representation of an out-of-place type operation, which is an operation without rewriting of argument values.
Citation Information
Patent Citations
System for reversible circuit compilation with space constraint, method and program
WO2016200747A1