WO2000045260A1 - Compilateur, procede de compilation et support de stockage sur lequel est stocke un programme pour la mise en oeuvre dudit procede - Google Patents

Compilateur, procede de compilation et support de stockage sur lequel est stocke un programme pour la mise en oeuvre dudit procede Download PDF

Info

Publication number
WO2000045260A1
WO2000045260A1 PCT/JP1999/000381 JP9900381W WO0045260A1 WO 2000045260 A1 WO2000045260 A1 WO 2000045260A1 JP 9900381 W JP9900381 W JP 9900381W WO 0045260 A1 WO0045260 A1 WO 0045260A1
Authority
WO
WIPO (PCT)
Prior art keywords
program
compiler
procedure
code
sum
Prior art date
Application number
PCT/JP1999/000381
Other languages
English (en)
French (fr)
Inventor
Hidetoshi Iwashita
Original Assignee
Fujitsu Limited
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Fujitsu Limited filed Critical Fujitsu Limited
Priority to PCT/JP1999/000381 priority Critical patent/WO2000045260A1/ja
Priority to JP2000596451A priority patent/JP3762867B2/ja
Publication of WO2000045260A1 publication Critical patent/WO2000045260A1/ja
Priority to US09/835,623 priority patent/US7073167B2/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation

Definitions

  • the present invention relates to a compiler that compiles at least a part of an input program described in a certain language and outputs a program described in the same language as that language or another language different from that language.
  • a preprocessor compiler whose output program is Fortran or C language.
  • HPF high frequency coding
  • C ++, C9x, DPCE, and the like are known as extension languages based on the C language.
  • ARRAY is an array of any numeric type and any number of dimensions.
  • the numeric type is an integer type, real type, or complex type of any number of bytes allowed by the processing system.
  • BASE is the same type as “ARRAY”, and is an array with an arbitrary number of dimensions.
  • INDX1, INDX2, ..., INDXn is a scalar or an array with the same number of dimensions as “BASEj”, and “n” has the same number of dimensions as “ARRAY”.
  • MASK is a scalar, an array with the same dimensions as “ARRAY”, or is omitted.
  • the degree of freedom of this function can be calculated as follows.
  • the total number of combinations is 53340. Furthermore, in the HPF, the array is generally divided into multiple processors and arranged. Therefore, considering the types of divided arrangement (block, cyclic, etc.) and the division dimensions, and multidimensional division, etc., the combination is considered. Will be huge.
  • the library becomes huge, and as a result, the storage medium (memory capacity) for storing the library also becomes large.
  • One way to avoid this problem is to create a library at compile time for only the part of the intrinsic procedure that is called, rather than having a library for all parts of the intrinsic procedure.
  • a method is conceivable. For example, a method of converting a procedure call in a source program using inline expansion technology can be considered.
  • inline expansion is not possible or difficult.
  • a compiler whose object language has few restrictions on the appearance of executable code, such as a machine language or assembler, there are few problems in inline expansion, but the object language is a Fortran or C language.
  • the problems described above are likely to occur when performing inline expansion.
  • An object of the present invention is to provide a compiler of a preprocessor system which has a high execution speed and a small storage area for storing information necessary for compilation. Disclosure of the invention
  • the compiler apparatus of the present invention presupposes a configuration in which an input first program is compiled and a second program is output, and a part of the first program is converted into a procedure call to convert the second program.
  • a conversion unit to be created a generation unit for generating a code describing a definition of a procedure to be called by the procedure call, and an output unit for outputting the code generated by the second program and the generation means.
  • Figures 1A and 1B are examples (part 1) that cannot be inlined by a conventional compiler.
  • Figures 2A and 2B are examples (part 2) that cannot be inlined by a conventional compiler.
  • Figures 3A and 3B are examples where inline expansion is complicated by conventional compilers.
  • FIG. 4 is a diagram illustrating an example of a schematic operation of the compiler according to the present embodiment.
  • FIG. 5 is a functional block diagram of the compiler of the present embodiment.
  • FIG. 6 is a flowchart for explaining the operation of the compiler shown in FIG.
  • FIG. 7A is an example of input code to the compiler shown in FIG.
  • FIG. 7B is an example of the output code from the compiler shown in FIG. Figure 8 is an example of a template for expanding the function SUM.
  • FIGS. 9A and 9B are diagrams showing the result of expanding the function SUM using the template.
  • FIG. 10 is a functional block diagram of a compiler according to another embodiment of the present invention.
  • FIG. 11 is a flowchart for explaining the operation of the compiler shown in FIG.
  • FIG. 12A is an example of input code to the compiler shown in FIG.
  • FIG. 12B is an example of the output code from the compiler shown in FIG.
  • FIGS. 13A to 13D are diagrams illustrating a management table used in the overlap determination.
  • Figure 14 is a diagram showing the result of expanding the function SUM.
  • Figure 15 shows an example of a template created with a high level of abstraction.
  • FIG. 16 is a diagram showing parameters to be compared when the object to be converted is developed using the template shown in FIG.
  • FIG. 17 is a diagram showing the output of the compiler when the template shown in FIG. 15 is used.
  • FIG. 18 is a functional block diagram of a compiler according to still another embodiment of the present invention.
  • FIG. 19 is a flowchart for explaining the operation of the compiler shown in FIG.
  • FIG. 20 is an example of input code to the compiler shown in FIG.
  • FIG. 21 is an example of the output code from the compiler shown in FIG.
  • FIG. 22 is a functional block diagram of a compiler according to still another embodiment of the present invention.
  • FIG. 23 is a flowchart for explaining the operation of the compiler shown in FIG. It is.
  • FIG. 24 is an example of the input code to the compiler shown in FIG.
  • FIG. 25 is an example of output code from the compiler shown in FIG.
  • Figure 26A is an example of an input code.
  • FIG. 26B is an example of an output corresponding to the input code shown in FIG. 26A.
  • Figures 27A-27D, 28A, and 28B are examples of templates.
  • FIG. 29 is a block diagram of a computer that executes a software program according to the present invention.
  • FIG. 30 is a diagram for explaining a method of providing a software program according to the present invention.
  • the present invention relates to a preprocessor-based compiler that compiles at least a part of an input program.
  • a preprocessor-style compiler (also known as a "precompiler”) is a program that reads a source program, modifies at least part of the source program, and prepares the source program for compilation. is there.
  • precompiler also known as a "precompiler”
  • object code such as calls (calls to call built-in procedures such as functions, subroutines, and libraries) in the source program.
  • the compiler of this embodiment is applicable to both cases where the source language and the object language are different from each other and where the source language and the object language are the same.
  • the compiler 2 generates the object program 3 by, for example, converting “A * N” in the source program 1 into “P OW (A, N)”, and also generates “P OW (A, N N) Outputs a code (online code) 4 that describes the procedure to be called by ").
  • This procedure is, for example, "When N is smaller than a predetermined value, a multiplication is performed, and when N is equal to or more than a predetermined value, a power operation is performed.”
  • Code 4 is obtained by developing this procedure online. “Online deployment” means that the procedures that appear in a program are deployed as subprograms outside the program. The code obtained by online development is called “online code”.
  • the compiler 2 adds a description (for example, an interface declaration) for calling the online code 4 to the object program 3 by using the procedure call of the object program 3 as necessary.
  • a description for example, an interface declaration
  • FIG. 5 is a functional block diagram of the compiler of the present embodiment. Here, it is assumed that source code is provided for each program.
  • the source program is input to the compiler 10 after being decomposed and analyzed by the syntax analyzer 21.
  • the syntax analyzer 21 has a function of converting an input code into an intermediate code, and can use an existing program as it is.
  • the compiler 10 includes a detection unit 11, a conversion unit 12, and an expansion unit 13.
  • the detection unit 11 detects an object to be converted. Specifically, the detection unit 11 detects a predetermined specific pattern (for example, a procedure call) from the source program.
  • the conversion unit 12 determines a procedure name corresponding to the conversion target detected by the detection unit 11, and replaces the conversion target with the procedure name. Then, the compiler 10 outputs the source program partially converted by the conversion unit 12 as an object program.
  • the development unit 13 generates an online code (procedure code or execution code) corresponding to the conversion target detected by the detection unit 11. This online code is called in association with the procedure name determined by the conversion unit 12 when the object program is executed. Then, the compiler 10 outputs the online code generated by the expansion unit 13.
  • the code generator 22 translates the object program and the online code output from the compiler 10 into assembler or machine language, and outputs them respectively.
  • the code generation unit 22 can use an existing program as it is, and can perform optimization processing.
  • FIG. 6 is a flowchart for explaining the operation of the compiler 10 shown in FIG. It is.
  • the source program input to the compiler 10 is called a program P
  • the object program compiled by the compiler 10 is called a program P '. This process is executed every time one source program is input.
  • step S1 a target C1 Cn to be converted in the program P is detected.
  • the objects to be converted C1,..., Cn are, for example, calls to functions, subroutines, and libraries.
  • steps S2 to S5 are executed for each of the conversion target CIs and Cn detected in step S1.
  • the feature Ai of the target Ci to be converted is extracted.
  • the "feature” is, for example, the name of a procedure to be called, such as a function name, the dimension of an argument, or a numeric type.
  • a unique procedure name f i is generated in the program P for the target Ci to be converted. That is, a different procedure name is assigned to each conversion target Cl,..., Cn.
  • step S4 the target Ci to be converted is replaced with the call of procedure ⁇ i.
  • "call of procedure f i" is a call for calling procedure f i when the program is executed.
  • step S5 a procedure code Si corresponding to the feature A i is generated.
  • f i is specified as the procedure name of this procedure code Si.
  • the procedure code Si is called by calling the procedure f i when the program is executed.
  • step S6 When the processes in steps S2 to S5 are executed for all the objects to be converted C1,..., Cn, the objects to be converted CI,. are replaced by calls to fl, ...., fn, and each procedure f 1, ...., fn , The procedure codes SI and Sn are generated in response to the respective calls. Then, in step S6, the program P ′ obtained by replacing the target Ci to be converted with the call of the procedure fi, and the generated procedure codes SI and Sn are output. Note that the program P 'and the procedure codes S1,..., Sn may be output to the same file, or may be output to different files.
  • the source code includes a plurality of program units, the above processing is repeatedly executed for each program unit.
  • the source program shown in FIG. 7A is input to the compiler 10, and the call of the function SUM is described as an object to be converted.
  • the function SUM is a function that returns the sum of the elements of the array specified by the argument.
  • the source program may be converted to an intermediate code.
  • the compiler 10 detects a call to the function SUM by scanning the source program. In the example shown in Figure 7A, it is detected that the function SUM is called by “SUM (A)” on line 4 and “SUM (N (51: 100))” on line 5. You.
  • Compiler 10 converts “SUM (A)” into a call to a procedure with a unique name.
  • the newly generated name is determined by a combination of the name of the procedure to be converted, the name of the source program, and the order in which it appears in the source program.
  • "SUM (A)” is the conversion target that first appeared in the program SAMPLE, so "SUM-SAMPLE-1" is assigned as a new procedure name.
  • the compiler 10 may select a name that cannot be used by the user. For example, you can restrict user access by pre-reserving names beginning with “xxx—”, or use names that contain characters that users rarely use, such as “#” or “$”. A method for generating the data is conceivable.
  • Compiler 10 converts the fourth line of the source program as follows. At this time, the argument of “SUM_SAMPLE_1” uses the argument of “SUM (A)” as it is.
  • the compiler 10 analyzes the argument A to extract the characteristics of “SUM (A)”. As a result, the following information is obtained.
  • Compiler 10 uses a template when generating the procedure code of "SUM_SAMPLE_1".
  • the template is a template for expanding a predetermined object to be converted, and is stored in a database or the like. Expand function SUM Figure 8 shows an example of a template for this.
  • the template is created using an abstract representation, and the corresponding procedural code is generated by customizing the template according to the features to be converted.
  • a plurality of templates may be provided for one call.
  • a plurality of types of templates may be provided for important calls, and an appropriate one may be selected from the plurality of templates according to the characteristics of the call.
  • the compiler 10 uses the template shown in FIG. 8 and generates a procedure code for “SUM—SAMPLE—1 (A)” according to the information obtained by analyzing the argument A.
  • An example of the procedure code generated in this way is shown in Figure 9A.
  • the procedure code is created specifically as follows. That is, since the “type” of the argument A is “REAL”, “REAL” is written as “arg-typej” in the template shown in FIG. Also, “1”, “1 0”, “1”, “2 0”, “1”, and “3 0” are written as the lower and upper limit values of each dimension of the argument.
  • “SUM—SAMPLE_1” is written as the procedure name so that this code is called by “SUM—SAMPLE—1 (A)”.
  • the process for rsUM (N (51: 100)) j is basically the same as the process for “(A) J.
  • the compiler 10 first executes“ SUM (N (51: 100) J )) ”Into a call to a procedure assigned a unique name.
  • rSUM (N (51: 100)) j is the second function SUM that appeared in the program SAMPLE, so "SUM SAMPLE 2j" is assigned as a new procedure name.
  • Con The pipeline 10 converts the fifth line of the source program as follows.
  • the compiler 10 generates a procedure code for “SUM_SAMPLE_2 (N (51: 100))” using the template shown in FIG. Figure 9B shows an example of the generated procedure code.
  • FIG. 7B is a diagram showing a result of compiling the source program shown in FIG. 7A using the compiler 10, and the program? In the flowchart shown in FIG. Equivalent to '.
  • the compiler 10 assigns different procedure names to them. By doing so, those conversion targets are replaced with mutually identifiable procedure calls.
  • the code (object program) obtained by this conversion processing is output to a file as a program code image as shown in Fig. 7B or a corresponding object code.
  • the compiler 10 generates and outputs a procedure code for each procedure call.
  • the compiler 10 may output a plurality of procedure codes at a time, or may output the procedure codes sequentially each time they are generated.
  • the compiler 10 receives the source program shown in Figure 7A. Then, the object code shown in FIG. 7B and the procedure code shown in FIGS. 9A and 9B are output.
  • the procedure code is not expanded in the object code. Therefore, even if the object language of Compiler 10 has restrictions on where the procedure code can be written, the compilation result does not violate the restrictions.
  • FIG. 10 is a functional block diagram of a compiler according to another embodiment of the present invention. Of the symbols used in FIG. 10, those used earlier in FIG. 5 have the same function. Represents a unit with. That is, in the compiler 30, the detection unit 11, the conversion unit 12, and the expansion unit 13 are basically the same units as those of the compiler 10 shown in FIG.
  • the compiler 30 includes a duplication determination unit 31.
  • the duplication determination unit 31 checks whether or not the same one of a plurality of objects to be converted detected in the source program by the detection unit 11 exists, and compares the result with the conversion unit 12 and the expansion unit 1. Notify 3. If the same conversion target does not exist, the conversion unit 12 and the development unit 13 execute the operations described with reference to FIGS. On the other hand, if the same conversion target exists, the conversion unit 12 converts them into the same calls, and the expansion unit 13 generates the procedure code (on-line code) that is shared by these calls. ) Is generated only once.
  • FIG. 11 is a flowchart for explaining the operation of the compiler shown in FIG.
  • step S11 first, the memory area R (management table) used by the duplication determination unit 31 is cleared.
  • the memory area R features to be converted existing in the source program are registered, and furthermore, a procedure name uniquely assigned to each feature is registered.
  • step S12 similarly to step S1 in FIG. 6, the objects C1,..., Cn to be converted in the program P are detected.
  • steps S13 to S19 are executed for each of the conversion targets C1Cn detected in step S12.
  • step S13 similarly to step S2 in FIG. 6, the feature A i of the target C i to be converted is extracted.
  • step S 14 the feature A i is obtained by first completing the processing of steps S 14 to S 19.
  • step S15 the memory area R is searched to generate a unique procedure name f i in the program P for the target Ci to be converted.
  • step S16 similarly to step S4 in FIG. 6, the target Ci to be converted is replaced with a call to the procedure f i.
  • step S17 similar to step S5 in FIG. 6, a procedure code Si corresponding to the feature Ai is generated. F i is specified as the procedure name of this procedure code Si.
  • step S18 the feature Ai of the target Ci to be converted and f i as a procedure name for calling the corresponding procedure code Si are registered in the memory area R.
  • step S19 the target Ci to be converted is replaced with the call of the procedure f i for calling the procedure code Sj corresponding to the feature Aj.
  • step S19 is executed, no new procedure code is generated, and no new registration in the memory area R is performed.
  • each object CI, Cn to be converted in the program P becomes the procedure f1,..., Fm (m ⁇ n) .., Fm are generated corresponding to the calls of the procedures f 1,..., Fm, respectively.
  • a program P 'obtained by replacing the object to be converted with a procedure call and the generated procedure code are output.
  • the program P 'and the procedure codes SI, ..., Sm are the same Output to different files or to different files.
  • the minimum necessary procedure code is generated without duplicating the procedure code for the objects to be converted which are present in a certain source program and overlap each other. Therefore, the total output code amount of the compiler is reduced.
  • the compiler 30 detects a call to the function SUM by scanning the source program.
  • the function SUM consists of “SUM (A)” and “SUM (A2)” on line 4, rsUM (N (51: 100)) j on line 5, and line 6 It is detected that it is called by "SUM (M (51: 200))" in the eye.
  • Compiler 30 first extracts the features of "SUM (A)” and executes online development according to the features.
  • the result of this online expansion is the same as the result of expansion by the compiler 10 described above, and generates the procedure code shown in FIG. 9A.
  • the operation in which “SUM (A)” is replaced with “SUM—SAMPLE_1 (A)” is also as described above.
  • Compiler 30 registers the name of the call to call the generated procedure code and the characteristics of the procedure in the management table. You.
  • the “features” are the type of argument, the number of dimensions of the argument, and the lower and upper limits of each dimension of the argument. Therefore, When online deployment is performed for “SUM (A)”, a record corresponding to “SUM (A)” is registered as shown in FIG. 13A.
  • the compiler 30 extracts the feature of “SUM (A2)”, and compares the feature of the call already registered in the management table with the extracted feature as shown in FIG. 13B.
  • the features of “SM—SAMPLE_1 (A)” and “SUM (A2)” completely match each other, a new procedure code is generated for “SUM (A2)”.
  • the fourth line of the source program is transformed as follows.
  • the compiler 30 extracts the characteristics of “SUM (N (51: 100))”, and as shown in FIG. 13C, the characteristics of the call already registered in the management table and the extracted characteristics. Compare. Here, since the features of “SUM_SAMPLE_1 (A)” and “SUM (N (51: 100))” do not match each other, a procedure code corresponding to “SUM (N (51: 100))” has been newly added. To be generated. This procedure code is the same as the procedure code shown in Figure 9B. Then, the compiler 30 searches the management table, determines an unregistered name (here, “SUM_SAMPLE—2”), and assigns it to “SUM (N (5 100))”. After this, the fifth line of the source program is rewritten as follows. This process is the same as the process described with reference to FIGS.
  • the compiler 30 performs the same processing for “SUM (M (51: 200))”.
  • the features of “SUM (M (51: 200))” are similar to those of “SUM—SAMPLE—2” registered earlier, but are completely Since they do not match, a new procedure code corresponding to “SUM (M (51: 200))” is generated.
  • Figure 14 shows the newly generated procedure code.
  • Compiler 30 searches the management table, determines one unregistered name (“SUM—SAMPLE_3”), and maps it to “SUM (M (51: 200))”. assign. After this, the sixth line of the source program is rewritten as follows.
  • the compiler 30 receives the source program shown in Figure 12A. Then, the object code shown in FIG. 12B and the procedure code shown in FIGS. 9A, 9B, and 14 are output.
  • the procedure code shown in FIG. 9A is commonly called by two calls. That is, in the above embodiment, four objects to be converted were detected from the software program, but three procedure codes were generated. In this way, multiple identical conversion targets are included in the source program If there is, the total output code amount of Compiler 30 is reduced as compared with Compiler 10 shown in FIG.
  • the procedure code of the function SUM is generated using the template shown in FIG. 8, but when the abstraction of the template expression is increased, the generated procedure is generated. The number of codes can be further reduced.
  • Figure 15 is an example of a template created with a higher level of abstraction than the template shown in Figure 8.
  • the template shown in Fig. 8 is a format in which the procedure is developed with the argument type, the number of dimensions of the bow I number, and the lower and upper limit values of each dimension of the argument as parameters, but the template shown in Fig. 15 is This is a format in which the procedure is expanded using only the argument type and the number of dimensions of the argument as parameters. Therefore, when the template shown in Fig. 15 is used, if the types of arguments and the dimensions of arguments are the same, the mismatch between the lower and upper limits of each dimension of the arguments is ignored, and the size of the array is ignored. A procedural code is created regardless of this.
  • FIG. 16 is a diagram showing parameters that are compared when a target to be converted is developed using the template shown in FIG. Here, four objects to be converted detected from the source program shown in Fig. 12A are shown.
  • the parameters to be compared are the "type of argument” and "the number of dimensions of the argument" to be converted, as described above. Therefore, the same procedure code is generated for "SUM (A)” and “SUM (A2)", and similarly, rsUM (N (51: 100)) j and “SUM (M ( 51: 200)) ”, the same procedure code will be generated. That is, the compiler 30 generates one procedure code for "SUM (A)” and "SUM (A2)”, and similarly, rsUM (N (51: 100)) j and rsUM (M (M ( 51: 200)) j —Generate a code.
  • FIG. 17 is a diagram showing an output of the compiler 30 when the template shown in FIG. 15 is used.
  • the compiler 30 uses the template shown in FIG. 15 to execute the object code shown in FIG. 17 and the two procedure codes (online code). ) Is output.
  • procedure code A is called by “SUM—SAMPLE—1”
  • procedure code B is called by “SUM—SAMPLE—2”.
  • the interface declaration for the procedure code must actually be described in the object code.
  • the compiler when generating object code as a Fort ran90 program, when converting the object to be converted in the source program into a new procedure call, the compiler generates an interface declaration for the new procedure call. This is the same in other embodiments.
  • FIG. 18 is a functional block diagram of a compiler according to still another embodiment of the present invention.
  • reference numerals used in FIG. 18 those used earlier in FIG. 5 or FIG. are the units of the same function.
  • the compiler 40 is basically the same as the compiler 30 shown in FIG. However, the duplication determination unit 31 provided in the compiler 30 checks whether or not there is a duplication target to be converted in each source program. Step 1 checks whether there are duplicate conversion targets for each input file. The judgment result by the duplication judgment unit 41 is notified to the conversion unit 12 and the development unit 13. The operations of the conversion unit 12 and the expansion unit 13 that have received this notification are basically as described with reference to FIG.
  • FIG. 19 is a flowchart for explaining the operation of the compiler shown in FIG.
  • the source file input to the compiler 40 is referred to as file F
  • the object file compiled by the compiler 40 is referred to as file F '.
  • the file F includes one or more source programs P 1,..., P t. This process is executed every time one source file is input.
  • steps S21 to S30 are basically the same as those in steps S11 to S20 shown in FIG. However, in steps S21 to S30, processing is performed in file units. That is, in step S22, an object to be converted is detected from one or more source programs included in file F. In step S25, a unique name is generated in the file F for the object to be converted.
  • the compiler 40 executes the processes of steps S 21 to S 30 to perform each conversion.
  • Object program whose objects have been replaced by procedure calls .., P 't are generated, and a procedure code S 1 S m is generated corresponding to each procedure call. Then, the object program and the generated procedure code are output to the same file.
  • the procedure code may be output one by one each time it is generated, may be output each time the processing of a program unit is completed, or may be output at the time of completion of the processing of a file unit. May be output collectively.
  • the above process may be repeatedly performed for each file.
  • the compiler 40 it is possible to minimize the necessary procedure code without duplicating the procedure code for the objects to be converted which are present in a file including a plurality of source programs and which are mutually overlapping. Since the minimum procedural code is generated, the total output code of the compiler is further reduced.
  • Compiler 40 detects calls to the function SUM by scanning two programs (main program and subprogram) contained in the source file.
  • the function SUM is called by “SUM (A)” and “SUM (N (51: 100))” in the main program and “SUM (Q)” in the subprogram. Is detected.
  • the compiler 40 generates the same procedure code to be generated based on the detected characteristics of each object to be converted (type of argument, number of dimensions of argument, etc.). Check if it exists.
  • the characteristics of “SUM (A)” and “SUM (Q)” are the same. Therefore, for “SUM (A)” and “SUM (Q)”, one procedure code shared by them is generated. One independent procedure code is generated for “SUM (N (51: 100))”.
  • FIG. 21 shows the output of the compiler 40 when the source file shown in FIG. 20 is input.
  • the name of the call is determined by a combination of the name of the procedure, the file name, and the order of appearance in the file. Therefore, “SUM (A)” and “SUM (Q)” have been replaced by “SUM_TINY—1”. “SUM (N (51: 100))” has been replaced by “SUM_TINY—2”. Then, procedure code A and procedure code B are called by “SUM—TINY_1” and “SUM_TINY—2”, respectively.
  • the compiler 40 when the same objects to be converted exist in the same file, a procedure code shared by them is generated. For this reason, if the generated procedure code is output to the same file as the object program, the handling of the file will be simplified. For example, if the file name of the input file is “tiny.f”, the file name of the output file is “tiny.oj.” Then, both the object program and the procedure code are output to that file. .
  • FIG. 22 is a functional block diagram of a compiler according to still another embodiment of the present invention.
  • the compiler 50 considers that a plurality of files are input collectively and converts the same conversion target existing in the plurality of input files into the same procedure call, and also performs To generate one procedure code. This procedure code is shared by multiple files and shared by multiple procedure calls. Is called.
  • the duplication determination unit 51 checks whether or not there is an overlapping conversion target in a plurality of input files, and compares the determination result with the conversion unit 12 and the expansion unit 1. Notify 3.
  • the operations of the conversion unit 12 and the expansion unit 13 that have received this notification are basically as described with reference to FIG.
  • the link editing unit 23 can be realized by an existing general program, and is a program that generates an executable program by linking a compiled code and a data file.
  • One file generally contains one or more program units (subroutines, functions, etc.), and one executable file is created by compiling the source code of one or more files and link-editing them.
  • the link editor 23 also has a library generation function.
  • FIG. 23 is a flowchart for explaining the operation of the compiler shown in FIG.
  • a plurality of source files input to the compiler 50 will be referred to as a file F1Fs
  • object files compiled by the compiler 50 will be referred to as files F'1,..., F's.
  • Each source file shall contain one or more source programs.
  • the process shown in Fig. 23 is executed every time a series of multiple source files is input.
  • the processes in steps S31 to S40 are basically the same as those in steps S11 to S20 shown in FIG. However, in steps S31 to S40, processing is performed in units of a series of plural files. That is, in step S32, an object to be converted is detected from a plurality of source programs included in the files F1,..., Fs. In step S35, the target to be converted Generate a unique name in the sequence of files Fl, ..., Fs. If the output file is a normal file handled by the user, the object code is associated with the procedure code (online code).
  • the compiler 50 executes the processes of steps S31 to S40 to obtain an object in which each object to be converted is replaced with a procedure call. Generates programs and outputs files F '1 and F's containing these object programs. Further, compiler 50 generates a procedure code corresponding to each procedure call, and outputs these procedure codes to common file F0.
  • the procedure code may be output one by one each time it is generated, or may be output each time the processing in the program unit ends or the processing in the file unit ends.
  • the procedure code may be output to the same file as the file containing the object file.
  • the compiler 50 may generate an execution file by managing the output file as a temporary file and performing a link editing process.
  • the minimum necessary procedure code is generated without duplicating the procedure code for the objects to be converted which are present in a plurality of source files and which overlap with each other. Therefore, the total output code amount of the compiler is further reduced.
  • the compiler 40 checks whether or not there is any code whose procedure code to be generated is the same, based on the detected characteristics of each object to be converted (the type of the argument, the number of dimensions of the argument, etc.). .
  • the characteristics of “SUM (A)” and “SUM (Q)” are the same. Therefore, for “SUM (A)” and “SUM (Q)”, one procedure code shared by them is generated. One independent procedure code is generated for “SUM (N (51: 100))”.
  • FIG. 25 shows the output of the compiler 50 when the source file shown in FIG. 24 is input.
  • the name of the call is determined by a combination of the name of the procedure and the order of appearance in a series of multiple input files. Therefore, “SUM (A)” and “SUM (Q)” have been replaced with “SUM_1”. Also, rsUM (N (51: 100)) j has been replaced with "SUM_2”. Then, the procedure code A and the procedure code B are called by “SUM_1” and “SUM-2”, respectively.
  • the compiler 50 shares the procedural code with a series of files that are compiled simultaneously.
  • the file in which the procedure code is stored is specified in the object file.
  • This linking may be performed by compiler 50, or alternatively, as shown in FIG. It may be executed by a module different from the compiler as in the configuration described above. If the link-editing process is executed by the compiler, storing the procedure code in a temporary file and deleting the temporary file after compiling will prevent problems in associating with the source. Become.
  • “function SUM” is taken as an object to be converted, but other functions and subroutines are processed in the same manner.
  • the source program shown in FIG. 26A is input to the compiler 10 shown in FIG. 5, and “A * N” is to be converted.
  • “A ** N” represents “A to the Nth power”.
  • “A” is a real, complex, or integer scalar
  • “N” is an integer scalar.
  • the compiler 10 When the compiler 10 detects "A * N” from the source program, the compiler 10 generates an object program by converting it to "POW (A, N)", and also generates "POW (A, N)". ) ”To output the procedure code (online code) to be called.
  • the definition of this procedure is, for example, "Perform multiplication when N is less than or equal to 3, and perform width multiplication when N is greater than 3.”
  • the compiler 10 refers to the following three features when generating a procedure code corresponding to “POW (A, N)”.
  • the compiler 10 uses the sample data shown in Figs. 27A to 27D and Figs. 28A and 28A as sample data to be used when generating the procedure code corresponding to "P ⁇ W (A, N)". And the template shown in Figure 28B. In these templates, the above feature 1 is abstracted.
  • each template shown in FIGS. 27B to 27D is described corresponding to a case where “N” is “1” to “3”.
  • the compiler 10 detects the expression “A ** N” by searching each line.
  • "2 ** LEN” on the fourth line and "(R * 2) ** 2j" on the fifth line are detected.
  • Type INTEGER
  • the compiler 10 selects an appropriate template based on the information obtained above and generates an online code. That is, here, since the value of “N” has not been obtained, the template shown in FIG. 28B is selected, and the online code A shown in FIG. 26B is generated.
  • the compiler 10 selects the template shown in FIG. 27C according to the information obtained above, and generates the online code B shown in FIG. 26B. Then, the compiler 10 outputs online codes A and B together with the object program.
  • the online code generated in the compiler of this embodiment must be replaced by a subsequent compiler (if the object language is used after the machine or assembler, etc.).
  • Inline expansion may be performed by a compiler. As described above, inline expansion often causes problems when a high-level language is targeted by a preprocessor-based compiler.However, with a normal compiler whose object language is post-machine or assembler, inline expansion can be performed without any problem. Can often be done.
  • FIG. 29 shows a block diagram of a computer 60 that executes the program.
  • the CPU 61 loads a program describing the processing shown in the flowchart of FIG. 6, FIG. 11, FIG. 19, or FIG. 23 from the storage device 62 to the memory 63 and executes it.
  • the storage device 62 is, for example, a hard disk, and stores the above programs and various templates.
  • the memory 63 is, for example, a semiconductor memory, and is used as a work area of the CPU 61.
  • the management table shown in FIG. 13A and the like is created in the memory 63.
  • the storage medium driver 64 accesses the portable storage medium 65 according to the instruction of the CPU 61.
  • the portable storage medium 65 includes a semiconductor device (such as an IC card), a medium for inputting and outputting information by magnetic action (such as a floppy disk and a magnetic tape), and a medium for inputting and outputting information by optical action. (Such as optical discs).
  • the communication control device 66 transmits and receives data to and from the network according to the instruction of the CPU 61.
  • FIG. 30 is a diagram for explaining a method of providing a software program or the like (including a template) according to the present invention.
  • the program according to the present invention is provided by, for example, any of the following three methods.
  • (c) Provided from a server on the network.
  • the computer 60 obtains the program or the like by downloading the program or the like stored in the server.
  • the compiler of the present embodiment can easily expand the object to be converted irrespective of the appearance position of the object to be converted in the source program even in the preprocessor system.
  • the compiler of this embodiment is more advantageous in terms of the total output code amount and the compile time.
  • the time required for optimization processing in a compiler is often proportional to the square or cube of the size of a compilation unit (one function or subroutine). For this reason, if the amount of code per compilation unit increases several times, the processing time for optimization may increase several tens of times.
  • the total amount of output code is almost the same as in the case of inline expansion, but the expanded code (online code) is divided and generated as an independent compilation unit. The overall compilation time is reduced.
  • the present invention can be widely used as a preprocessor-type compiler.

Description

明 細 書 コンパイラ装置、 コンパイル方法、
およびそのためのプログラムを格納した記憶媒体 技術分野
本発明は、 ある言語で記述された入力プログラムの少なくとも一部をコンパ ィルしてその言語と同一の言語またはその言語と異なる他の言語で記述された プログラムを出力するコンパイラに係わる。 特に、 出力プログラムが For t ran または C言語などであるプリプロセッサ方式のコンパイラに係わる。 背景技術
コンピュータの動作を記述するためのプログラミング言語は、 使用目的や適 用分野などに応じて様々な拡張言語または改良言語が開発されている。 たとえ ば、 For t ran をベースとする拡張言語としては、 H P Fが広く知られている。 また、 C言語をベースとする拡張言語としては、 C ++、 C 9x、 D P C Eなどが 知られている。
ところが、 これらの拡張言語で記述されたプログラム等をアセンブラまたは 機械語に翻訳する際には、 いったんベース言語に変換することが有利なことが 多い。 このため、 これらの拡張言語を扱うコンパイラは、 一般に、 出力の言語 がその拡張言語のベース言語であるプリプロセッサ方式で実現されることが多 レ^ たとえば、 H P Fで記述されたプログラムを For t ranで記述されたプログ ラムに変換して出力するコンパイラが開発されている。 関数 SUM一 SCATTER は、 下記の形式で呼び出される。
SUM_SCATTER (ARRAY, BASE, I DX1, I DX2, ... , I DXn, MASK)
ここで、 「ARRAY」 は、 任意の数値型であり、 且つ任意の次元数を持つ配列で ある。 数値型は、 処理系が許す任意のバイト数の整数型、 実数型、 複素数型な どである。 「BASE」 は、 「ARRAY」 と同じ型であり、 任意の次元数を持つ配列 である。 「INDX1, INDX2, ... , INDXn」 は、 スカラであるか 「BASEj と同じ 次元数を持つ配列であり、 「n」 は 「ARRAY」 と同じ次元数である。 「MASK」 は、 スカラであるか、 「ARRAY」 と同じ次元数を持つ配列であるか、 あるいは 省略される。
したがって、 たとえば、 もし、 処理系が 10種類の数値型を持ち、 1次元〜 7次元までの配列をサボ一トすると仮定すると、 この関数の自由度は以下のよ うに計算できる。
「ARRAY」 が 1次元のときは、 「ARRAY」 の自由度が 10、 「BASE」 の自由度 が 7、 「n= l」 なので 「INDX1, INDX2, ... , INDXn J の自由度が 2、 さら に 「MASK」 の自由度が 3である。 従って、 この場合、 組合せの数は、 10 X 7 X 2 X 3 = 420となる。 同様に、 「ARRAY」 が 2次元〜 7次元のときの組合 せの数は以下の通りである。
2次元: 1 0 X 7 X 2 2 X 3 = 840
3次元: 1 0 X 7 X 2 3 X 3= 1680 7次元: 10 X 7 X 27 X 3=26880
よって、 合計の組合せ数は、 53340通りになる。 さらに、 HPFでは、 一般に、 配列は複数のプロセッサに分割して配置されるので、 分割配置の種類 (block, cyclic など ) や分割次元の違い、 および多次元分割などを考慮す ると、 その組合せは膨大なものとなる。
したがって、 抽象度の高い組込み手続の変換を、 通常のライブラリを用いて 実現しょうとすると、 以下の問題が生じる。
(1) すべての組合せに対応しょうとすると、 ライブラリが巨大になり、 結果 としてそのライブラリを記憶するための記憶媒体 (メモリ容量) も大きくなつ てしまう。
(2) 複数のケースに対応できるような入口名 (総称的な名前、 あるいは抽象 的な名前) を使ったとしても、 結局はライブラリの中でケース分けをする必要 があるので、 上記(1) の問題は解決されない。
(3) 複数のケースに対応できるような入口名 (総称的な名前、 あるいは抽象 的な名前) を使い、 且つ様々な型や次元数でライブラリを作る方法も考えられ るが、 実際には以下の問題を伴う。
(a) 次元数の違いに対応するためには、 ループのネスト数を可変にできれ ばよいが、 Fortranや C言語ではそのような記述はできない。 また、 再帰呼出 しで記述すると、 実行速度が低下する。
(b) 型 (たとえば、 4バイトの整数型や 8バイトの実数型) を共通化する ことは困難である。 たとえば、 プログラム中の式の中に整数型の数値と実数型 の数値が混在していた場合、 これらの型は実行コードが互いに異なるので、 型 ごとに処理を分ける必要がある。 このため、 命令列中に判断分岐が多数登場す ることになり、 実行速度が低下する。
(c) 複数のプロセッサに分割された配列を引数としてサポートする言語に おいては、 単純な分割 (例えば、 最終次元での均等な b l ock分割) に対しても 一般的な分割 (すべての次元において任意の分割方法で分割できる方法を想定 する) と同じ扱いになるので、 実行速度が低下してしまう。
このように、 抽象度の高い組込み手続をプリプロセッサ方式で変換しょうと すると、 ライブラリを記憶するための記憶媒体が巨大になってしまった。 ある いは、 記憶媒体の巨大化を回避しょうとすると、 コンパイル能力が低下してい た。
この問題を回避する方法の 1つとして、 組込み手続のすべての部分について ライブラリを用意しておくのではなく、 組込み手続の呼出しパラメ一夕に係わ る部分のみをコンパイル時に生成 (具体化) する方法が考えられる。 例えば、 インライン展開技術を用いてソースプログラム中の手続き呼出を変換する手法 が考えられる。
ところが、 プリプロセッサ方式のコンパイラにおいては、 手続き呼出の登場 場所によっては、 インライン展開が出来なかったり、 困難であったりすること がある。 以下、 問題点を説明する。
(1) 通常、 宣言部において実行文を展開することは出来ない。 このため、 宣 言部に関数呼出等が存在する場合は、 それをインライン展開することはできな い。 もし、 宣言部に登場する関数呼出等をそのままインライン展開すると、 得 られたプログラムをベース言語のコンパイラで翻訳したときにエラ一が発生す ることになる。 たとえば、 図 1 Aに示す入力プログラムの宣言部を For t ran プ ログラムにコンパイルすると、 図 1 Bに示すコードが得られる。 また、 図 2 A に示す入力プログラムの宣言部を Cプログラムにコンパイルすると、 図 2 Bに 示すコードが得られる。 これらの例では、 宣言部において実行文 (図 1の例で は、 関数 ABS 、 図 2の例では、 関数 s t r l en (s) ) が展開されているので、 コ ンパイル結果として得られるプログラムをそれぞれ For t ranコンパイラまたは Cコンパイラで翻訳すると、 エラーが発生してしまう。
(2) 実行部においても、 文法上の制約により、 インライン展開が出来ない場 合がある。 たとえば、 For t ran 90では、 「where文の中では代入文以外の実行 文を記述してはいなない」 という制約があるので、 where 文の中に登場する関 数をインライン展開できない場合が生じる。
(3) 名前の衝突の回避が困難な場合がある。 たとえば、 展開すべき手続内で 組込み関数 SUMが使用されている場合、 もし、 呼び出される側で変数名 SUMが 使われており、 この変数が呼出の実引数として現れるとすると、 同一の名前が 重複するという問題を回避することは困難である。
(4) 実行文等を展開する場合、 それを単にその場所に展開するだけでなく、 文脈に応じて周辺のコードも変換しなければならないことがある。 たとえば、 図 3 Aに示すように、 入力プログラムの中の ELSEIF文の条件節に関数呼出
(図 3の例では、 関数 ABS) が現れる場合には、 IF文の入れ子構造を変換する 必要が生じる。 このため、 図 3 Bに示すように、 インライン展開が複雑になる。 また、 入力プログラムの中の DO WHILE文の条件節に呼出し関数が現れる場合 は、 その関数をループの直前およびループ内の双方で展開しなければならず、 この場合もインライン展開が複雑になる。 一方、 C言語では、 たとえば、 for 文の括弧内の 2番目または 3番目の式を展開する場合には、 同様に- 展開が複雑になる。 このように、 プログラム等をコンパイルする際、 インライン展開が可能であ れば、 そのコンパイルに必要な情報を格納するための記憶領域を小さくするこ とができるなどのメリッ卜が得られるが、 オブジェクト言語が処理手続を記述 できる場所について制約がある言語であった場合には、 インライン展開が出来 なかったり、 あるいは困難だったりする。 すなわち、 オブジェクト言語が機械 語やアセンブラのように実行コードの出現場所についての制約が少ないコンパ イラにおいては、 インライン展開をするにあたっての問題も少ないが、 ォブジ ェク卜言語が For t ran や C言語などのように実行コードの出現場所についての 制約が多いプリプロセッサ方式のコンパイラにおいては、 インライン展開をす るにあたって上述のような問題が発生しやすい。
本発明の課題は、 実行速度が高速で、 且つコンパイルに必要な情報を格納す るための記憶領域が小さくなるプリプロセッサ方式のコンパイラを提供するこ とである。 発明の開示
本発明のコンパイラ装置は、 入力された第 1のプログラムをコンパイルして 第 2のプログラムを出力する構成を前提とし、 第 1のプログラムの一部を手続 呼出に変換して上記第 2のプログラムを作成する変換ユニットと、 上記手続呼 出により呼び出されるべき手続の定義を記述したコードを生成する生成ュニッ トと、 上記第 2のプログラムおよび上記生成手段により生成されたコードを出 力する出力ユニットとを有する。
第 1のプログラムをコンパイルすることにより第 2のプログラムを作成する 際、 手続の定義を記述したコードは第 2のプログラムの外に生成され、 第 2の プログラム中にはそのコードを呼び出すための手続呼出が記述される。 すなわ ち、 第 2のプログラム中には実行コードは展開されない。 したがって、 ォブジ ェクト言語が処理手続を記述できる場所について制約がある言語であった場合 においても、 実行されたときにエラーの発生を伴わない第 2のプログラムが得 られる。 また、 第 2のプログラムの記述が複雑になることはなく、 インライン 展開を用いる場合と比べ、 第 2のプログラムをべ一ス言語コンパイラで翻訳す る速度の向上が期待される。 さらに、 上記装置においては、 入力プログラム中 の変換すべき対象のすべての組合せに対してコンパイルに必要な情報を用意し ておく必要がないので、 そのためのメモリ容量が小さくなる。 図面の簡単な説明
図 1 Aおよび図 1 Bは、 従来のコンパイラによってインライン展開できない 例 (その 1 ) である。
図 2 Aおよび図 2 Bは、 従来のコンパイラによってインライン展開できない 例 (その 2 ) である。
図 3 Aおよび図 3 Bは、 従来のコンパイラによってインライン展開が複雑に なる例である。
図 4は、 本実施例のコンパイラの概略動作の一例を説明する図である。 図 5は、 本実施例のコンパイラの機能ブロック図である。
図 6は、 図 5に示したコンパイラの動作を説明するためのフローチヤ一トで ある。
図 7 Aは、 図 5に示したコンパイラへの入力コ一ドの例である。
図 7 Bは、 図 5に示したコンパイラからの出力コードの例である。 図 8は、 関数 SUM を展開するためのテンプレートの例である。
図 9 Aおよび図 9 Bは、 テンプレートを用いて関数 SUM を展開した結果を示 す図である。
図 1 0は、 本発明の他の形態のコンパイラの機能ブロック図である。
図 1 1は、 図 1 0に示したコンパイラの動作を説明するためのフローチヤ一 トである。
図 1 2 Aは、 図 1 0に示したコンパイラへの入力コードの例である。
図 1 2 Bは、 図 1 0に示したコンパイラからの出力コードの例である。 図 1 3八〜図1 3 Dは、 重複判定において使用する管理テーブルを説明する 図である。
図 1 4は、 関数 SUM を展開した結果を示す図である。
図 1 5は、 抽象度の高い表現で作成したテンプレートの例である。
図 1 6は、 図 1 5に示すテンプレートを用いて変換すべき対象を展開する際 に比較されるパラメータを示す図である。
図 1 7は、 図 1 5に示すテンプレートを用いた場合のコンパイラの出力を示 す図である。
図 1 8は、 本発明の更に他の形態のコンパイラの機能ブロック図である。 図 1 9は、 図 1 8に示したコンパイラの動作を説明するためのフローチヤ一 トである。
図 2 0は、 図 1 8に示したコンパイラへの入力コードの例である。
図 2 1は、 図 1 8に示したコンパイラからの出力コードの例である。
図 2 2は、 本発明の更に他の形態のコンパイラの機能ブロック図である。 図 2 3は、 図 2 2に示したコンパイラの動作を説明するためのフローチヤ一 トである。
図 2 4は、 図 2 2に示したコンパィラへの入カコードの例である。
図 2 5は、 図 2 2に示したコンパイラからの出力コードの例である。
図 2 6 Aは、 入力コードの例である。
図 2 6 Bは、 図 2 6 Aに示す入力コードに対応する出力の例である。
図 2 7 A〜図 2 7 D、 図 2 8 A、 および図 2 8 Bは、 テンプレートの例であ る。
図 2 9は、 本発明に係わるソフトウエアプログラムを実行するコンピュータ のブロック図である。
図 3 0は、 本発明に係わるソフトウェアプログラムの提供方法を説明する図 である。 発明を実施するための最良の形態
本発明は、 入力されたプログラムの少なくとも一部をコンパイルするプリプ 口セッサ方式のコンパイラに係わる。 プリプロセッサ方式のコンパイラ ( 「プ リコンパイラ」 とも呼ばれている) は、 ソースプログラムを読み込み、 そのソ —スプログラムの少なくとも一部を変更してそのソースプログラムのコンパィ ルのための準備を行うプログラムである。 以下の実施例では、 For t ranおよび C言語を採り上げ、 ソースプログラムの中の呼出 (関数、 サブルーチン、 ライ ブラリ等の組込み手続を呼び出すための呼出) などをオブジェクトコードに変 換する機能を中心に説明する。 なお、 本実施例のコンパイラは、 ソース言語と オブジェクト言語とが互いに異なっている場合、 およびソース言語とオブジェ クト言語とが互いに同じ場合の双方に適用可能である。 本実施例のコンパイラの概略動作の一例を図 4を参照しながら説明する。 こ こでは、 ソースプログラム 1が、 たとえば、 Fortran の拡張言語の 1つである H P Fで記述されており、 その中に 「A * * N」 が含まれているものとする。 「A * * N」 は、 「Aの N乗」 を表す。 また、 オブジェクト言語は、 例えば、 For tran であるものとする。 この場合、 コンパイラ 2は、 たとえば、 ソースプ ログラム 1の中の 「A * * N」 を 「P OW (A, N) 」 に変換することにより オブジェクトプログラム 3を生成すると共に、 「P OW (A, N) 」 により呼 び出されるべき手続を記述するコード (オンラインコード) 4を出力する。 こ の手続の定義は、 たとえば、 「Nが所定値よりも小さいときには掛け算を実行 し、 Nが所定値以上のときには巾乗演算を実行する。 」 である。 また、 コード 4は、 この手続をオンライン展開することにより得られる。 なお、 「オンライ ン展開」 とは、 あるプログラム中に登場する手続等をそのプログラムの外でサ ブプログラムとして展開することを意味する。 また、 オンライン展開により得 られるコードを 「オンラインコード」 と呼ぶことにする。
なお、 コンパイラ 2は、 必要に応じて、 オブジェクトプログラム 3の手続呼 出を用いてオンラインコード 4を呼び出すための記述 (たとえば、 インタフエ —ス宣言) をオブジェクトプログラム 3に加える。
このように、 コンパイラ 2は、 ソースプログラム 1の一部を手続呼出に変換 することによりオブジェクトプログラム 3を生成する際、 その手続呼出により 呼び出されるべきコードをオンラインコード 4としてオブジェクトプログラム 3の外に作成する。 すなわち、 手続呼出により呼び出されるべきコードは、 ォ ブジェクトプログラム 3の中では展開されない。 従って、 オブジェクト言語が 手続を記述できる場所について制約がある言語であったとしても、 オブジェク トプログラム 3が実行されたときに文法エラ一等が発生することはない。 図 5は、 本実施例のコンパイラの機能ブロック図である。 ここでは、 プログ ラム毎にソースコードが与えられることを前提とする。
ソースプログラムは、 構文解析部 2 1により分解 '解析された後にコンパィ ラ 1 0に入力される。 構文解析部 2 1は、 入力コードを中間コードに変換する 機能を備え、 既存のプログラムをそのまま流用できる。
コンパイラ 1 0は、 検出部 1 1、 変換部 1 2、 および展開部 1 3を備える。 検出部 1 1は、 変換すべき対象を検出する。 具体的には、 検出部 1 1は、 ソー スプログラムから予め決められた特定のパターン (たとえば、 手続呼出など) を検出する。 変換部 1 2は、 検出部 1 1により検出された変換すべき対象に対 応する手続名を決定し、 その変換すべき対象をその手続名に置き換える。 そし て、 コンパイラ 1 0は、 変換部 1 2によりその一部が変換されたソースプログ ラムをオブジェクトプログラムとして出力する。 展開部 1 3は、 検出部 1 1に より検出された変換すべき対象に対応するオンラインコ一ド (手続コ一ドまた は実行コード) を生成する。 なお、 このオンラインコードは、 オブジェクトプ ログラムが実行されたときに、 変換部 1 2により決定された手続名に対応付け られて呼び出される。 そして、 コンパイラ 1 0は、 その展開部 1 3により生成 されたオンラインコードを出力する。
コード生成部 2 2は、 コンパイラ 1 0から出力されたォブジェクトプロダラ ムおよびオンラインコードをアセンブラまたは機械語に翻訳し、 それらをそれ ぞれ出力する。 コード生成部 2 2は、 既存のプログラムをそのまま流用でき、 最適化処理を行うこともできる。
図 6は、 図 5に示したコンパイラ 1 0の動作を説明するためのフローチヤ一 トである。 ここでは、 コンパイラ 10に入力されるソースプログラムをプラグ ラム P、 コンパイラ 10によりコンパイルされたオブジェクトプログラムをプ ログラム P' と呼ぶことにする。 なお、 この処理は、 1つのソースプログラム が入力される毎に実行される。
ステップ S 1では、 プログラム P内で変換すべき対象 C1 Cn を検出 する。 変換すべき対象 C1 ,...·, Cn は、 たとえば、 関数、 サブルーチン、 ラ イブラリの呼出である。
ステップ S 2〜S 5の処理は、 ステップ S 1において検出された各変換すベ き対象 CI , Cn について実行される。 ステップ S 2では、 変換すべき対 象 Ci の特徴 Aiを抽出する。 「特徴」 とは、 例えば、 関数名などの呼び出す べき手続の名前、 引数の次元、 数値型などである。 ステップ S 3では、 変換す べき対象 Ci に対して、 プログラム P内でユニークな手続名 f i を生成する。 すなわち、 各変換すべき対象 Cl,...., Cn に対して、 互いに異なる手続名を 割り当てる。
ステップ S 4では、 変換すべき対象 Ci を手続 ί iの呼出に置換する。 ここ で、 「手続 f i の呼出」 とは、 当該プログラムが実行されたときに、 手続 f i を呼び出すための呼出である。 ステップ S 5では、 特徴 A iに対応する手続コ —ド Si を生成する。 そして、 この手続コード Siの手続名として f i を指定 する。 これにより、 手続コード Si は、 当該プログラムが実行されたときに、 手続 f i の呼出により呼び出されることになる。
上記ステップ S 2〜S 5の処理をすベての変換すべき対象 C1 ,...., Cn に ついて実行すると、 プログラム Pにおいて各変換すべき対象 CI ,...., Cn が それぞれ手続 f l ,...., f n の呼出に置換され、 また、 各手続 f 1 ,...., f n の呼出にそれぞれ対応して手続コード SI , Sn が生成される。 そして、 ステップ S 6において、 変換すべき対象 Ci を手続 f i の呼出に置き換えるこ とにより得られるプログラム P' 、 及び生成された手続コード SI , Sn が出力される。 なお、 プログラム P' および手続コード S1 ,...., Sn は、 互 いに同じファイルに出力されてもよいし、 互いに異なるファイルに出力されて もよい。 また、 ソースコードが複数のプログラム単位を含む場合には、 各プロ グラム単位に対して上記処理が繰り返し実行される。
次に、 具体的な実施例を説明する。 以下では、 コンパイラ 1 0に対して図 7 Aに示すソースプログラムが入力された場合を想定し、 関数 SUM の呼出を変換 すべき対象として説明する。 なお、 関数 SUM は、 引数により指定された配列の 要素の総和を返す関数であるものとする。 また、 ソースプログラムは、 中間コ ―ドに変換されていてもよい。
ソースプログラムが入力されると、 コンパイラ 1 0は、 そのソースプロダラ ムをスキャンすることにより関数 SUM の呼出を検出する。 図 7 Aに示す例にお いては、 関数 SUM は、 4行目の 「SUM(A)」 および 5行目の 「SUM(N(51: 100))」 により呼ばれていることが検出される。
続いて、 コンパイラ 1 0は、 「SUM(A)」 をユニークな名前が割り当てられた 手続の呼出に変換する。 この実施例では、 新たに生成される名前は、 変換すベ き対象の手続名と、 ソースプログラムの名前と、 そのソースプログラムの中で 登場した順番との組合せにより決定される。 この場合、 図 7 Aに示す例では、 「SUM(A)」 はプログラム SAMPLEの中で最初に登場した変換対象なので、 新た な手続名として 「SUM— SAMPLE— 1」 が割り当てられる。 なお、 コンパイラ 1 0が 新たに生成する名前とユーザにより定義される変数名などとの重複を回避する ためには、 コンパイラ 10は、 ユーザが使用できない名前を選択するようにす ればよい。 たとえば、 「xxx—」 で始まる名前を予め予約しておくことによりュ 一ザの使用を制限する方法や、 「#」 や 「$」 などのユーザが滅多に使用しな い文字を含む名前を生成するようにする方法が考えられる。
この後、 コンパイラ 1 0は、 ソースプログラムの 4行目を以下のように変換 する。 このとき、 「SUM_SAMPLE_1」 の引数は、 「SUM(A)」 の引数をそのまま使 用する。
B=SUM(A) → B=SUM— SAMPLE— 1 (A)
続いて、 コンパイラ 10は、 引数 Aを解析することにより、 「SUM(A)」 の特 徴を抽出する。 これにより、 以下の情報が得られる。
arg-type = REAL
m= 3
lb(l) = 1
ub(l) = 10
lb(2) = 1
ub(2) =20
lb (3) = 1
ub (3) =30
ここで、 「arg-type」 は引数の型、 「m」 は引数の次元数、 「lb(i) 」 および 「ub(i) 」 はそれぞれ引数の第 i次元の下限値および上限値である。
コンパイラ 1 0は、 「SUM_SAMPLE_1」 の手続コードを生成する際、 テンプレ —トを利用する。 テンプレートは、 予め決められた変換すべき対象を展開する ためのひな形であり、 データベース等に格納されている。 関数 SUM を展開する ためのテンプレートの例を図 8に示す。
テンプレートは、 抽象的な表現を用いて作成されており、 変換すべき対象の 特徴に応じてそのテンプレートをカスタマイズすることにより対応する手続コ —ドが生成される。 また、 1つの呼出に対して複数のテンプレートを設けても よい。 例えば、 重要な呼出に対しては複数種類のテンプレートを設けておき、 その呼出の特徴に応じてそれら複数のテンプレートの中から適切な 1つを選択 して利用するようにしてもよい。 さらに、 手続の引数などをパラメータとして 具体的なソースコードまたはオブジェクトコ一ドを生成するような処理プログ ラムとしてテンプレートを作成することも可能である。
コンパイラ 1 0は、 図 8に示すテンプレートを利用し、 引数 Aを解析するこ とにより得られている情報に従って 「SUM— SAMPLE— 1 (A) 」 についての手続コ一 ドを生成する。 このようにして生成された手続コードの例を図 9 Aに示す。 手続コードは、 具体的には、 以下のようにして作成される。 すなわち、 引数 Aの 「型」 が 「REAL」 であるので、 図 8に示すテンプレートにおいて、 「arg - typej として 「REAL」 が書き込まれる。 また、 引数の各次元の下限値および上 限値として 「1」 「1 0」 「1」 「2 0」 「1」 「3 0」 が書き込まれる。 さ らに、 このコードが 「SUM— SAMPLE— 1 (A) 」 により呼び出されるようにするため に、 手続名として 「SUM— SAMPLE_1」 が書き込まれる。
rsUM(N(51:100))j についての処理は、 基本的に、 「通 (A)J についての処 理と同じである。 すなわち、 コンパイラ 1 0は、 まず 「SUM(N(51:100))」 をュ 二一クな名前が割り当てられた手続の呼出に変換する。 図 7 Aに示す例では、 rSUM(N(51:100))j はプログラム SAMPLEの中で 2番目に登場した関数 SUMな ので、 新たな手続名として 「SUM SAMPLE 2j が割り当てられる。 この後、 コン パイラ 1 0は、 ソースプログラムの 5行目を以下のように変換する。
WRITE , = SUM(N(51:100)) → WRITE (*,*) SUM— SAMPLE— 2 (N (51: 100)) 続いて、 コンパイラ 10は、 引数を解析して 「SUM(N(51:100))」 の特徴を抽 出する。 これにより、 以下の情報が得られる。
arg-type = I NTEGER
m= 1
lb(l) = 5 1
ub(l) = 100
この後、 コンパイラ 10は、 図 8に示したテンプレートを利用して 「SUM_SA MPLE_2 (N(51:100)) 」 についての手続コードを生成する。 生成された手続コ一 ドの例を図 9 Bに示す。
図 7 Bは、 コンパイラ 10を用いて図 7 Aに示したソースプログラムをコン パイルした結果を示す図であり、 図 6に示したフローチャートにおけるプログ ラム?' に相当する。 図 7 Aおよび図 7 Bに示すように、 ソースプログラム中 に複数の変換すべき対象 (関数 SUM を呼び出すための呼出) が存在する場合、 コンパイラ 10は、 それらに対して互いに異なる手続名を割り当てることによ り、 それらの変換対象を互いに識別可能な手続呼出に置き換える。 この変換処 理により得られたコード (オブジェクトプログラム) は、 図 7 Bに示すような プログラムコードイメージか、 対応するォブジェクトコ一ドとしてファイルに 出力される。 また、 コンパイラ 10は、 各手続呼出に対して、 手続コードを生 成して出力する。 ここで、 コンパイラ 1 0は、 複数の手続コードを一括して出 力してもよいし、 生成するごとに、 順次、 出力するようにうしてもよい。
このように、 コンパイラ 1 0は、 図 7 Aに示すソースプログラムが入力され ると、 図 7 Bに示すオブジェクトコード、 および図 9 Aおよび図 9 Bに示す手 続コードを出力する。 ここで、 手続コードは、 オブジェクトコード内では展開 されない。 したがって、 コンパイラ 1 0のオブジェクト言語が手続コードを記 述できる場所について制約を持っていたとしても、 コンパィル結果がその制約 に違反することはない。
従来、 たとえば、 FORTRANや C言語などでは、 プログラムの宣言部において 実行文を展開することができないので、 宣言部に組込み手続等の呼出が記述さ れていた場合には、 従来のコンパイラではその宣言部を正しくコンパイルする ことはできなかった。 ところが、 本実施例のコンパイラによれば、 組込み手続 等の呼出はォブジェクト言語における手続呼出に置き換えられるだけなので、 そのような問題は生じない。
上記図 5〜図 9を参照しながら説明した実施例では、 ソースプログラム中の 変換すべき対象が互いに同一ではない場合を採り上げた。 すなわち、 図 7 Aに 示した例では、 2つの変換すべき対象は、 呼び出すべき関数は互いに同じであ つたが、 その引数は互いに異なっていた。
ところが、 ソースプログラム中に複数の互いに同一の変換すべき対象が存在 することがある。 この場合、 もし、 図 5に示したコンパイラ 1 0を用いてその ソースプログラムをコンパイルすると、 複数の互いに同一の手続コード (オン ラインコード) を生成することになり、 コンパイラの総出力コード量が必要以 上に多くなつてしまう。 以下、 この問題を解決したコンパイラについて説明す る。
図 1 0は、 本発明の他の形態のコンパイラの機能ブロック図である。 図 1 0 において使用する符号のうち、 図 5において先に使用しているものは同じ機能 を持つユニットを表す。 すなわち、 コンパイラ 3 0において、 検出部 1 1、 変 換部 1 2、 展開部 1 3は、 基本的に図 5に示したコンパイラ 1 0のものと同じ ュニットである。
コンパイラ 3 0は、 重複判定部 3 1を備えることを特徴とする。 重複判定部 3 1は、 検出部 1 1によりソースプログラムにおいて検出された複数の変換す べき対象のうち、 互いに同じものが存在するか否かを調べ、 その結果を変換部 1 2および展開部 1 3に通知する。 互いに同じ変換すべき対象が存在しなけれ ば、 変換部 1 2および展開部 1 3は、 図 5〜図 9を参照しながら説明した動作 を実行する。 一方、 互いに同じ変換すべき対象が存在する場合は、 変換部 1 2 は、 それらをそれぞれ互いに同じ呼出に変換し、 展開部 1 3はそれらの呼出に より共有的に呼び出される手続コード (オンラインコード) を 1つだけ生成す る。
図 1 1は、 図 1 0に示したコンパイラの動作を説明するためのフローチヤ一 卜である。
ステップ S 1 1では、 まず、 重複判定部 3 1が使用するメモリ領域 R (管理 テーブル) をクリアする。 なお、 メモリ領域 Rには、 ソースプログラム中に存 在する変換すべき対象の特徴が登録され、 さらに、 各特徴に対してユニークに 割り当てられる手続名が登録される。 ステップ S 1 2は、 図 6のステップ S 1 と同様に、 プログラム P内で変換すべき対象 C 1 ,. . . ., Cn を検出する。 ステップ S 1 3〜S 1 9の処理は、 ステップ S 1 2において検出された各変 換すべき対象 C 1 Cn について実行される。 ステップ S 1 3では、 図 6 のステップ S 2と同様に、 変換すべき対象 C i の特徴 A i を抽出する。 ステツ プ S 1 4では、 特徴 A i が、 先にステップ S 1 4〜S 1 9の処理が終了してい る変換すべき対象 CI ,...., Ci-1 の特徴の中のいずれかと同じであるか否か を調べる。 特徴 Ai が、 先の処理がなされた変換すべき対象 C1 Ci-1 の特徴の中のいずれかと同じであればステップ S 19へ進み、 いずれにも一致 しなければステップ S 15へ進む。
ステップ S 15では、 メモリ領域 Rをサーチし、 変換すべき対象 Ci に対し てプログラム P内でユニークな手続名 f i を生成する。 ステップ S 16では、 図 6のステップ S 4と同様に、 変換すべき対象 Ci を手続 f i の呼出に置換す る。 ステップ S 17では、 図 6のステップ S 5と同様に、 特徴 Ai に対応する 手続コード Si を生成する。 この手続コード Si の手続名として f i が指定さ れる。 さらに、 ステップ S 18において、 変換すべき対象 Ci の特徴 Ai およ び対応する手続コード Si を呼び出すための手続名としての f i がメモリ領域 Rに登録される。
一方、 ステップ S 19では、 変換すべき対象 Ci を、 特徴 Aj に対応する手 続コード Sj を呼び出すための手続 f i の呼出に置換する。 なお、 ステップ S 19が実行された場合は、 新たな手続コードが生成されず、 また、 メモリ領域 Rへの新たな登録も行われない。
上記ステップ S 13〜S 19の処理を全ての変換すべき対象 C1 Cn について実行すると、 プログラム Pにおいて各変換すべき対象 CI , Cn が手続 f 1 ,...., f m (m≤n) の呼出に置換され、 また、 各手続 f 1 ,.·.., fmの呼出にそれぞれ対応して手続コード SI ,...., Smが生成される。 そし て、 ステップ S 20において、 変換すべき対象を手続の呼出に置き換えること により得られるプログラム P' 、 および生成された手続コードが出力される。 なお、 プログラム P' および手続コード SI ,...., Sm は、 互いに同じフアイ ルに出力されてもよいし、 互いに異なるファイルに出力されてもよい。
このように、 コンパイラ 3 0によれば、 あるソ一スプログラム内に存在する 互いに重複した変換すべき対象に対して、 重複して手続コードを生成すること なく、 必要最小限の手続コードを生成するので、 コンパイラの総出力コード量 が減少する。
次に、 具体的な実施例を説明する。 以下では、 コンパイラ 3 0に対して図 1 2 Aに示すソースプログラムが入力された場合を想定し、 関数 SUM の呼出を変 換対象として説明する。 なお、 コンパイラ 3 0は、 図 8に示したテンプレート を利用するものとする。
ソースプログラムが入力されると、 コンパイラ 3 0は、 そのソースプロダラ ムをスキャンすることによって関数 SUM の呼出を検出する。 図 1 2 Aに示す例 においては、 関数 SUM は、 4行目の 「SUM (A)」 および 「SUM (A2) 」 、 5行目の rsUM (N (51 : 100) ) j 、 および 6行目の 「SUM (M (51 : 200) )」 により呼ばれている ことが検出される。
コンパイラ 3 0は、 まず、 「SUM (A)」 についてその特徴を抽出し、 その特徴 に従ってオンライン展開を実行する。 このオンライン展開の結果は、 上述した コンパイラ 1 0による展開結果と同じであり、 図 9 Aに示した手続コードを生 成する。 また、 「SUM (A)」 が 「SUM— SAMPLE_1 (A) 」 に置き換えられる動作も上 述した通りである。
ただし、 コンパイラ 3 0においては、 同じ手続コードを重複して生成するこ とを回避するために、 順次、 生成した手続コードを呼び出すための呼出の名前 と、 その手続の特徴が管理テーブルに登録される。 なお、 「特徴」 は、 引数の 型、 引数の次元数、 引数の各次元の下限値および上限値である。 したがって、 「SUM(A)」 についてオンライン展開が実行されると、 図 13Aに示すように、 「SUM(A)」 に対応するレコードが登録される。
続いて、 コンパイラ 30は、 「SUM(A2) 」 の特徴を抽出し、 図 13Bに示す ように、 管理テ一ブルに既に登録されている呼出の特徴とその抽出した特徴と を比較する。 ここでは、 「SM— SAMPLE_1 (A) 」 および 「SUM(A2) 」 の特徴が互 いに完全に一致しているので、 「SUM(A2) 」 に対しては新たに手続コードを生 成することなく、 「SUM(A)」 に対して生成された手続コードを 「SUM(A2) 」 か ら呼び出すようにするために、 「SUM(A2) 」 を 「SUM_SAMPLE_1 (A2)」 に変換す る。 この結果、 ソースプログラムの 4行目は、 以下にように変換されることに なる。
B=SUM (A) +SUM (A2) → B=SUM— SAMPLE— 1 (A) +SUM— SAMPLE— 1 (A2)
したがって、 この行が実行されると、 「SUM— SAMPLE— 1 (A) 」 により図 9 Aに示 した手続コードが呼び出され、 さらに、 「SUM_SAMPLE_1 (A2)」 によってもその 同じ手続コードが呼び出されることになる。
なお、 「SUM— SAMPLE— 1 (A) 」 および 「SUM(A2) 」 の特徴が互いに完全に一致 していたので、 管理テーブルには新たなレコードは追加されず、 管理テーブル は図 13 Aに示す状態を保持する。
続いて、 コンパイラ 30は、 「SUM(N(51:100))」 の特徴を抽出し、 図 13C に示すように、 管理テ一ブルに既に登録されている呼出の特徴とその抽出した 特徴とを比較する。 ここでは、 「SUM_SAMPLE_1 (A) 」 及び 「SUM(N(51: 100))」 の特徴が互いに一致していないので、 「SUM(N(51:100))」 に対応する手続コー ドを新たに生成する。 この手続コードは、 図 9 Bに示した手続コードと同じで ある。 そして、 コンパイラ 30は、 管理テーブルをサーチし、 先に登録されていな い名前 (ここでは、 「SUM_SAMPLE— 2」 ) を決定し、 それを 「SUM(N(5 100))」 に割り当てる。 この後、 ソースプログラムの 5行目が下記のように書き換えら れる。 この処理は、 図 5〜図 9を参照しながら説明した処理と同じである。
WRITE (*,*) SUM(N(51:100)) → WRITE (*,*) SUM_SAMPLE_2 (N(51:100)) なお、 新たに使用されることとなった名前および対応する特徴は、 管理テ一 ブルに登録される。
さらに、 コンパイラ 30は、 「SUM(M(51:200))」 に対して同様の処理を実行 する。 この場合、 図 13Dに示すように、 「SUM(M(51:200))」 の特徴は、 先に 登録されている 「SUM— SAMPLE— 2」 の特徴と類似しているが、 完全には一致して いないので、 「SUM(M(51:200))」 に対応する手続コードを新たに生成する。 こ の新たに生成される手続コードを図 14に示す。
そして、 コンパイラ 30は、 管理テーブルをサーチし、 先に登録されていな い 1つの名前 ( 「SUM— SAMPLE_3」 ) を決定し、 それを 「SUM(M(51 :200))」 に対 して割り当てる。 この後、 ソースプログラムの 6行目が下記のように書き換え られる。
WRITE (*,*) SUM (M (51:200)) → WRITE (*,*) SUM_SA PLE_3 (M (51:200)) このように、 コンパイラ 30は、 図 12 Aに示すソースプログラムが入力さ れると、 図 12 Bに示すオブジェクトコード、 および図 9A、 図 9B、 および 図 14に示す手続コードを出力する。 ここで、 図 9 Aに示す手続コードは、 2 つの呼出により共有的に呼び出される。 すなわち、 上記実施例では、 ソ一スプ ログラムから変換すべき対象が 4つ検出されたが、 生成された手続コ一ドは 3 つである。 このように、 ソースプログラムの中に複数の互いに同じ変換対象が あった場合、 コンパイラ 3 0の総出力コード量は図 5に示したコンパイラ 1 0 と比較して減少する。
なお、 図 1 0〜図 1 4に示した実施例では、 図 8に示したテンプレートを用 いて関数 SUM の手続コードを生成したが、 テンプレートの表現の抽象度を高め ると、 生成される手続コードの数をさらに減少させることができる。
図 1 5は、 図 8に示したテンプレートと比較して抽象度の高い表現で作成し たテンプレートの例である。 図 8に示したテンプレートは、 引数の型、 弓 I数の 次元数、 および引数の各次元の下限値および上限値をパラメータとして手続を 展開するフォーマットであつたが、 図 1 5に示すテンプレートは、 引数の型お よび引数の次元数のみををパラメ一タとして手続を展開するフォーマツトであ る。 したがって、 図 1 5に示すテンプレートを用いた場合、 引数の型および引 数の次元数が互いに同じであれば、 引数の各次元の下限値および上限値の不一 致は無視され、 配列の大きさに因らない手続コードが作成される。
図 1 6は、 図 1 5に示すテンプレートを用いて変換すべき対象を展開する際 に比較されるパラメ一夕を示す図である。 ここでは、 図 1 2Aに示したソース プログラムから検出された 4つの変換すべき対象について示している。
図 1 5に示すテンプレートを用いる場合、 比較すべきパラメータは、 上述し たように、 変換すべき対象の 「引数の型」 および 「引数の次元数」 である。 従 つて、 「SUM(A)」 および 「SUM(A2) 」 に対して互いに同じ手続コードが生成さ れることになり、 同様に、 rsUM(N(51:100))j および 「SUM(M(51 :200))」 に対 して互いに同じ手続コードが生成されることになる。 すなわち、 コンパイラ 3 0は、 「SUM(A)」 および 「SUM(A2) 」 に対して 1つの手続コードを生成し、 同 様に、 rsUM(N(51:100))j および rsUM(M(51:200))j に対しても 1つの手続コ —ドを生成する。 このとき、 「SUM (A)」 および 「SUM (A2) 」 は、 互いに同じ手 続呼出 (ここでは、 「SUM_SAMPLE_1」 とする。 ) に変換される。 同様に、 「SU M (N (51 : 100) )」 および rsUM (M (51 : 200) ) j も互いに同じ手続呼出 (ここでは、 「SUM— SAMPLE— 2」 とする。 ) に変換される。
図 1 7は、 図 1 5に示すテンプレートを用いた場合のコンパイラ 3 0の出力 を示す図である。 コンパイラ 3 0は、 図 1 2 Aに示したソースプログラムが入 力されると、 図 1 5に示したテンプレートを用いた場合、 図 1 7に示すォブジ ェクトコード、 および 2つの手続コード (オンラインコード) を出力する。 こ こで、 手続コード Aは、 「SUM— SAMPLE— 1」 により呼び出され、 また、 手続コー ド Bは、 「SUM— SAMPLE— 2」 により呼び出される。
なお、 図 1 7に示す例では省略されているが、 実際には、 オブジェクトコ一 ドにおいて手続コードに対するインタフェース宣言が記述される必要がある。 例えば、 Fort ran90 プログラムとしてオブジェクトコードを生成する場合は、 ソースプログラム中の変換すべき対象を新たな手続呼出に変換する際、 コンパ イラが、 その新たな手続呼出に関するインタフェース宣言を生成する。 このこ とは、 他の実施例においても同様である。
上記図 5および図 1 0に示した実施例では、 コンパイラへの入力が 1つのプ ログラムであることを前提としていたが、 実際には、 複数のソースプログラム を含むファイルを一括してコンパイルしたい場合が多々ある。 以下では、 複数 のソースプログラムを含むファィルを一括してコンパイルするコンパイラにつ いて説明する。
図 1 8は、 本発明のさらに他の形態のコンパイラの機能ブロック図である。 図 1 8において使用する符号のうち、 図 5または図 1 0において先に使用して いるものは同じ機能のュニットを表す。
コンパイラ 4 0は、 基本的には、 図 1 0に示したコンパイラ 3 0と同じであ る。 ただし、 コンパイラ 3 0に設けられる重複判定部 3 1は、 各ソースプログ ラム中に重複する変換すべき対象が存在するか否かを調べるのに対し、 コンパ イラ 4 0に設けられる重複判定部 4 1は、 入力ファイル毎に重複する変換すベ き対象が存在するか否かを調べる。 重複判定部 4 1による判定結果は、 変換部 1 2および展開部 1 3に通知される。 この通知を受けた変換部 1 2および展開 部 1 3の動作は、 基本的に、 図 1 0を参照しながら説明した通りである。 図 1 9は、 図 1 8に示したコンパイラの動作を説明するためのフローチヤ一 トである。 ここでは、 コンパイラ 4 0に入力されるソースファイルをファイル F、 コンパイラ 4 0によりコンパイルされたオブジェクトファイルをファイル F ' と呼ぶことにする。 なお、 以下では、 ファイル Fは、 1以上のソースプロ グラム P 1 ,. . . ., P t を含むものとする。 また、 この処理は、 1つのソ一スフ ァィルが入力されるごとに実行される。
ステップ S 2 1〜S 3 0の各処理は、 基本的に、 図 1 1に示したステップ S 1 1〜S 2 0とそれぞれ同じである。 ただし、 ステップ S 2 1〜S 3 0では、 ファイル単位で処理が行われる。 すなわち、 ステップ S 2 2では、 ファイル F に含まれている 1以上のソースプログラムから変換すべき対象が検出される。 また、 ステップ S 2 5では、 変換すべき対象に対してファイル F内でユニーク な名前を生成する。
コンパイラ 4 0は、 ソースプログラム P 1 ,. . . ., P t を含むファイル Fが入 力されると、 上記ステップ S 2 1〜S 3 0の処理を実行することにより、 各変 換すべき対象がそれぞれ手続の呼出に置き換えられたオブジェクトプログラム P ' l,. . . ., P ' tを生成し、 また、 各手続の呼出にそれぞれ対応して手続コード S 1 S mを生成する。 そして、 これらのオブジェクトプログラムおよび 生成された手続コードは、 同一のファイルに出力される。
なお、 手続コードは、 生成される毎に、 順次、 1つずつ出力してもよいし、 プログラム単位の処理が終了する毎に出力してもよいし、 あるいはファイル単 位の処理が終了した時点で一括して出力してもよい。 また、 ソースコードが複 数のファイルから構成される場合には、 各ファイル毎に上記処理を繰り返し実 行すればよい。
このように、 コンパイラ 4 0によれば、 複数のソースプログラムを含むファ ィル内に存在する互いに重複した変換すべき対象に対して、 重複して手続コ一 ドを生成することなく、 必要最小限の手続コードを生成するので、 コンパイラ の総出力コード量がさらに減少する。
次に、 具体的な実施例を説明する。 以下では、 コンパイラ 4 0に対して図 2 0に示すソースファイル (t iny, f) が入力された場合を想定し、 関数 SUM の呼 出を変換対象として説明する。 なお、 コンパイラ 4 0は、 図 8に示したテンプ レートを利用するものとする。
ソースファイルが入力されると、 コンパイラ 4 0は、 そのソースファイルに 含まれている 2つのプログラム (メインプログラムおよびサブプログラム) を スキャンすることにより関数 SUM の呼出を検出する。 図 2 0に示す例において は、 関数 SUM は、 メインプログラムの 「SUM (A)」 及び 「SUM (N (51 : 100))」 、 お よびサブプログラムの 「SUM (Q)」 により呼ばれていることが検出される。
続いて、 コンパイラ 4 0は、 検出した各変換すべき対象の特徴 (引数の型、 引数の次元数など) に基づいて、 生成すべき手続コードが同一になるものが存 在するか否かを調べる。 ここでは、 「SUM(A)」 および 「SUM(Q)」 の特徴が互い に同じである。 従って、 「SUM(A)」 および 「SUM(Q)」 に対しては、 これらによ り共有される 1つの手続コードが生成される。 なお、 「SUM(N(51:100))」 に対 しては、 1つの独立した手続コードが生成される。
図 2 1は、 図 2 0に示すソースファイルが入力されたときのコンパイラ 40 の出力である。 ここでは、 呼出の名前は、 手続の名前と、 ファイル名と、 その ファイルの中での登場順番との組合せにより決定されるものとしている。 従つ て、 「SUM(A)」 および 「SUM(Q)」 は 「SUM_TINY— 1」 に置き換えられている。 ま た、 「SUM(N(51:100))」 は 「SUM_TINY— 2」 に置き換えられている。 そして、 手 続コード A及び手続コード Bは、 それぞれ 「SUM— TINY_1」 及び 「SUM_TINY— 2」 により呼び出されることになる。
このように、 コンパイラ 40によれば、 互いに同じ変換すべき対象が同一フ アイル内に存在する場合、 それらにより共有される手続コードが生成される。 このため、 生成した手続コードをォブジェクトプログラムと同じファイルに出 力するようにすれば、 ファイルの取り扱いが簡単になる。 例えば、 入カフアイ ルのファイル名が 「tiny. f」 であるときは、 出力ファイルのファイル名を 「ti ny.oj とする。 そして、 そのファイルにオブジェクトプログラムおよび手続コ —ドの双方を出力する。
図 2 2は、 本発明のさらに他の形態のコンパイラの機能ブロック図である。 コンパイラ 5 0は、 複数のファイルが一括して入力されることを考慮し、 入力 された複数のファイルに存在する互いに同じ変換すべき対象を同一の手続呼出 に変換すると共に、 その手続呼出に対して 1つの手続コードを生成する。 この 手続コードは、 複数のファイルにより共通化され、 複数の手続呼出により共有 的に呼び出される。
上記機能を実現するために、 重複判定部 5 1は、 複数の入力ファイル中に重 複する変換すべき対象が存在するか否かを調べ、 その判定結果を変換部 1 2お よび展開部 1 3に通知する。 この通知を受けた変換部 1 2および展開部 1 3の 動作は、 基本的に、 図 1 0を参照しながら説明した通りである。
リンク編集部 2 3は、 既存の一般的なプログラムにより実現可能であり、 コ ンパイル済みのコ一ドとデータファイルとをリンクさせることにより実行可能 プログラムを生成するプログラムである。 1つのファイルは、 一般に 1つ以上 のプログラム単位 (サブルーチンや関数等) を含み、 1つの実行可能ファイル は、 1つ以上のファイルのソースコードをコンパイルし、 それらをリンク編集 して作成される。 また、 リンク編集部 2 3は、 ライブラリの生成機能も持って いる。
図 2 3は、 図 2 2に示したコンパイラの動作を説明するためのフローチヤ一 トである。 ここでは、 コンパイラ 5 0に入力される複数のソースファイルをフ アイル F 1 F s 、 コンパイラ 5 0によりコンパイルされたオブジェクト ファイルをファイル F ' 1,. . . ., F ' sと呼ぶことにする。 また、 各ソースフアイ ルは、 それぞれ 1以上のソースプログラムを含むものとする。 なお、 図 2 3に 示す処理は、 一連の複数のソースファイルが入力されるごとに実行される。 ステップ S 3 1〜S 4 0の各処理は、 基本的に、 図 1 1に示したステップ S 1 1〜S 2 0とそれぞれ同じである。 ただし、 ステップ S 3 1〜S 4 0では、 一連の複数のファイルを単位として処理が行われる。 すなわち、 ステップ S 3 2では、 ファイル F 1 ,. . . ., F s に含まれている複数のソースプログラムから 変換すべき対象が検出される。 また、 ステップ S 3 5では、 変換すべき対象に 対して一連のファイル Fl ,...., Fs 内でユニークな名前を生成する。 なお、 出力ファイルをュ一ザが扱う通常のファイルとする場合には、 オブジェクトコ —ドと手続コード (オンラインコード) とが対応付けられる。
コンパイラ 50は、 ファイル F1 ,··.., Fs が入力されると、 上記ステップ S 31〜 S 40の処理を実行することにより、 各変換すべき対象がそれぞれ手 続の呼出に置き換えられたオブジェクトプログラムを生成し、 これらのォブジ ェクトプログラムを含むファイル F' 1 , F'sを出力する。 また、 コンパィ ラ 50は、 各手続の呼出にそれぞれ対応する手続コードを生成し、 これらの手 続コードを共通ファイル F0 に出力する。
なお、 手続コードは、 生成される毎に、 順次、 1つずつ出力してもよいし、 プログラム単位の処理が終了する毎あるいはファイル単位の処理が終了する毎 に出力してもよい。 また、 手続コードは、 オブジェクトファイルを含むフアイ ルと同じファイルに出力してもよい。 また、 コンパイラ 50は、 出力ファイル を一時ファイルとして管理し、 リンク編集処理をも行うことによって実行ファ ィルを生成してもよい。
このように、 コンパイラ 50によれば、 複数のソースファイル内に存在する 互いに重複した変換すべき対象に対して、 重複して手続コードを生成すること なく、 必要最小限の手続コードを生成するので、 コンパイラの総出力コード量 がさらに減少する。
次に、 具体的な実施例を説明する。 以下では、 コンパイラ 50に対して図 2 4に示す 2つのソースファイル (tinyl.f および tiny2.f ) が入力された場合 を想定し、 関数 SUM の呼出を変換対象として説明する。 なお、 コンパイラ 50 は、 図 8に示したテンプレートを利用するものとする。 ソースファイルが入力されると、 コンパイラ 50は、 ファイル tinyl.f に含 まれているプログラム (メインプログラム) 、 およびファイル tiny2. f に含ま れているプログラム (サブプログラム) をスキャンすることにより関数 SUM の 呼出を検出する。 図 24に示す例においては、 関数 SUM は、 ファイル tinyl.f の 「SUM(A)」 及び 「SUM(N(51:100))」 、 およびファイル t iny2. f 「SUM(Q)」 により呼ばれていることが検出される。
続いて、 コンパイラ 40は、 検出した各変換すべき対象の特徴 (引数の型、 引数の次元数など) に基づいて、 生成すべき手続コードが同一になるものが存 在するか否かを調べる。 ここでは、 「SUM(A)」 および 「SUM(Q)」 の特徴が互い に同じである。 従って、 「SUM(A)」 および 「SUM(Q)」 に対しては、 これらによ り共有される 1つの手続コードが生成される。 なお、 「SUM(N(51:100))」 に対 しては、 1つの独立した手続コードが生成される。
図 25は、 図 24に示すソースファイルが入力されたときのコンパイラ 50 の出力である。 ここでは、 呼出の名前は、 手続の名前と、 一連の複数の入カフ アイルの中での登場順番との組合せにより決定されるものとしている。 したが つて、 「SUM(A)」 及び 「SUM(Q)」 は 「SUM_1 」 に置き換えられている。 また、 rsUM(N(51:100))j は 「SUM_2 」 に置き換えられている。 そして、 手続コード Aおよび手続コード Bは、 それぞれ 「SUM_1 」 及び 「SUM— 2 」 により呼び出さ れることになる。
このように、 コンパイラ 50は、 手続コードは同時にコンパイルされる一連 のファイルにより共有される。 なお、 リンク編集処理では、 オブジェクトファ ィルにおいて手続コードが格納されているファイルが指定される。 このリンク 処理は、 コンパイラ 50により実行されてもよいし、 あるいは、 図 22に示し た構成のように、 コンパイラとは別のモジュールにより実行されてもよい。 コ ンパイラによりリンク編集処理が実行される場合には、 手続コードを一時ファ ィルに格納し、 コンパイル後にその一時ファイルを削除するようにすれば、 ソ —スとの対応付けにおいて問題が生じにくくなる。
上記実施例では、 変換すべき対象として 「関数 SUM」 を採り上げたが、 他の 関数やサブルーチンなどであっても同様に処理される。 以下では、 図 5に示し たコンパイラ 1 0に図 2 6 Aに示すソースプログラムが入力された場合を想定 し、 「A * * N」 を変換すべき対象とする。 「A * * N」 は、 「Aの N乗」 を 表す。 ここで、 「A」 は、 実数型、 複素数型、 または整数型のスカラであり、 「N」 は、 整数型のスカラであるものとする。
コンパイラ 1 0は、 ソ一スプログラムから 「A * * N」 を検出すると、 それ を 「P OW (A, N) 」 に変換することによりオブジェクトプログラムを生成 すると共に、 「P OW (A, N) 」 により呼び出されるべき手続コード (オン ラインコード) を出力する。 この手続の定義は、 例えば、 「Nが 3以下のとき に掛け算を実行し、 Nが 3よりも大きいときには巾乗演算を実行する。 」 であ る。
コンパイラ 1 0は、 「P OW (A, N) 」 に対応する手続コ一ドを生成する 際、 以下の 3つの特徵を参照する。
特徴 1 : Aの型
特徴 2 : Nの値が得られるか否か
特徴 3 : Nの値が得られたとき、 その値
コンパイラ 1 0は、 「P〇W (A, N) 」 に対応する手続コードを生成する 際に利用するサンプルデータとして図 2 7 A〜図 2 7 D、 および図 2 8 Aおよ び図 28 Bに示すテンプレートを備える。 これらのテンプレートでは、 上記特 徴 1が抽象化されている。
図 27 Aに示すテンプレートは、 「N」 が 「0」 の場合に対応して記述され ている。 すなわち、 「N=0」 の場合は、 「Aの 0乗」 は常に 「1」 なので、 テンプレートには予め 「R=1」 が記述されている。
図 27 B〜図 27 Dに示す各テンプレートは、 それぞれ 「N」 が 「1」 から 「3」 の場合に対応して記述されている。 ここでは、 「Nが小さいときには、 巾乗演算を実行するよりも掛け算を実行した方が有利である」 という前提に立 ち、 各テンプレートには、 それぞれ掛け算式 ( 「R = A」 「R = A*A」 およ び 「R = A*A*A」 ) が予め記述されている。
図 28 Aに示すテンプレートは、 「N」 が 3よりも大きい場合に対応して記 述されている。 即ち、 テンプレートには、 巾乗演算式 ( 「R = A* *A」 ) が 予め記述されている。
図 28 Bに示すテンプレートは、 ソースプログラムがコンパイルされる際に 「N」 の値が不明である場合に対応して記述されている。 この場合、 テンプレ —卜には、 「N」 の値が決まった時点でその値に対応する演算式が選択される ような記述となっている。
コンパイラ 10は、 ソースプログラムが入力されると、 各行をサーチするこ とにより 「A* *N」 という表現を検出する。 図 26 Aに示すプログラムが入 力された場合、 4行目の 「2 * *LEN」 および 5行目の 「 (R* 2) * * 2 j が検出される。
まず、 「2 * *LEN」 がオンライン展開される。 「2 * *LEN」 は、 プログ ラム SUBROUTINEの中で最初に登場した変換すべき対象なので、 「P0W SUBP 1J という名前が割り当てられる。 続いて、 上述した変換規則に従って以下の 変換を行う。
REAL: :S(2**LEN-1) → REAL:: S (P0W_SUBP_1 (2, LEN) -1)
そして、 引数を解析することによって以下の情報を得る。
特徴 1 :型 = INTEGER
特徴 2 : Nの値は得られず
特徴 3 :なし
コンパイラ 1 0は、 上記得られた情報により適切なテンプレートを選択して オンラインコードを生成する。 すなわち、 ここでは、 「N」 の値が得られてい ないので、 図 28 Bに示したテンプレートが選択され、 図 26 Bに示すオンラ インコード Aが生成される。
同様に、 「 (R* 2) * * 2」 がオンライン展開される。 「 (R* 2) * * 2」 は、 プログラム SUBROUTINEの中で第 2番目に登場した変換すべき対象な ので、 「P0W— SUBP— 2」 という名前が割り当てられ、 以下の変換が行われる。
M=PAI*(R*2)**2 → M=PA P0W_SUBP_2 ((R*2) , 2)
そして、 引数を解析することによって以下の情報を得る。
特徴 1 :型- REAL
特徴 2 : Nの値は得られた
特徴 3 : N=2
コンパイラ 1 0は、 上記得られた情報に従って図 27 Cに示すテンプレート を選択し、 図 26 Bに示すオンラインコード Bを生成する。 そして、 コンパィ ラ 10は、 オブジェクトプログラムと共に、 オンラインコード Aおよび Bを出 力する。 なお、 プログラムの実行時にオンラインコードを呼び出すためのオーバ一へ ッドを減少させるためには、 本実施例のコンパレー夕で生成したオンラインコ —ドを後続のコンパイラ (オブジェクト言語が機械後又はアセンブラ等である コンパイラ) によりインライン展開してもよい。 インライン展開は、 上述した ように、 プリプロセッサ方式のコンパイラで高級言語を対象とすると問題が生 じることが多いが、 オブジェクト言語が機械後又はアセンブラ等である通常の コンパイラでは、 問題なくインライン展開を実行できることが多い。
上記コンパイラの機能は、 コンピュータを用いて図 6、 図 1 1、 図 1 9、 ま たは図 2 3のフローチャートに示した処理を記述したプログラムを実行するこ とにより実現される。 そのプログラムを実行するコンピュータ 6 0のブロック 図を図 2 9に示す。
C P U 6 1は、 図 6、 図 1 1、 図 1 9、 または図 2 3のフローチャートに示 した処理を記述したプログラムを記憶装置 6 2からメモリ 6 3にロードして実 行する。 記憶装置 6 2は、 例えばハードディスクであり、 上記プログラム、 お よび各種テンプレートを格納する。 一方、 メモリ 6 3は、 例えば半導体メモリ であり、 C P U 6 1の作業領域として使用される。 図 1 3 Aなどに示した管理 テーブルは、 このメモリ 6 3に作成される。
記憶媒体ドライバ 6 4は、 C P U 6 1の指示に従って可搬性記憶媒体 6 5に アクセスする。 可搬性記憶媒体 6 5は、 半導体デバイス (I Cカード等) 、 磁 気的作用により情報が入出力される媒体 (フロッピ一ディスク、 磁気テープな ど) 、 光学的作用により情報が入出力される媒体 (光ディスクなど) を含む。 通信制御装置 6 6は、 C P U 6 1の指示に従って網との間でデータを送受信す る。 図 3 0は、 本発明に係わるソフトウェアプログラムなど (テンプレートを含 む) の提供方法を説明する図である。 本発明に係わるプログラムは、 例えば、 以下の 3つの方法の中の任意の方法により提供される。
(a) コンピュータ 6 0にインストールされて提供される。 この場合、 プログ ラム等は、 たとえば、 出荷前にプレインストールされる。
(b) 可搬性記憶媒体に格納されて提供される。 この場合、 可搬性記憶媒体 6 5に格納されているプログラム等は、 基本的に、 記憶媒体ドライバ 6 4を介し て記憶装置 6 2にィンス 1 ルされる。
(c) 網上のサーバから提供される。 この場合、 基本的には、 コンピュータ 6 0がサーバに格納されているプログラム等をダウンロードすることによってそ のプログラム等を取得する。
このように、 本実施例のコンパイラは、 プリプロセッサ方式であっても、 ソ —スプログラム中における変換すべき対象の出現位置に係わらず、 その変換す べき対象を容易に展開することができる。
また、 手続呼出をインライン展開できる場合であっても、 総出力コード量、 およびコンパイル時間の点で本実施例のコンパイラの方が有利である。
(a) 出力コードの総量
図 1 0、 図 1 8、 および図 2 2に示したコンパイラによれば、 互いに同種の 変換すべき対象が複数存在する場合には、 それらに対して 1つのオンラインコ —ドが生成され、 複数の手続呼出によりその生成されたオンラインコードが共 有的に呼び出されるので、 オブジェクトの総量が小さくなる。 なお、 図 5に示 したコンパイラの出力の総量は、 インライン展開の場合のそれと比較して同程 度である。 (b) コンパイル時間
一般に、 コンパイラ内での最適化処理に要する時間は、 コンパイル単位 (1 つの関数やサブルーチン等) の大きさの 2乗〜 3乗に比例することが多い。 こ のため、 コンパイル単位のコード量が数倍になると、 最適化のための処理時間 は数十倍になることがある。
図 5に示したコンパイラによれば、 上述したように、 出力コードの総量はィ ンライン展開の場合と同程度だが、 展開コード (オンラインコード) は独立し たコンパイル単位として分割されて生成されるため、 全体のコンパイル時間が 短縮される。
また、 図 1 0、 図 1 8、 および図 2 2に示したコンパイラの場合は、 生成さ れるオンラインコードの数が減少するので、 コンパイル時間はさらに短縮され る。
さらに、 本実施例のコンパイラを使用した場合、 オンライン展開後、 入力コ ードのコンパイルをオンラインコードのコンパイルよりも先に実行するように すれば、 入力コードのエラ一を速く検出することができる。 インライン展開を 使用した場合には、 入力コードが大きくなるので、 エラー検出に長い時間を要 することが予想される。 産業上の利用可能性
本発明は、 プリプロセッサ方式のコンパィラとして広く利用され得る。

Claims

請求 の 範 囲
1 . 入力された第 1のプログラムをコンパイルして第 2のプログラムを出力す るコンパイラ装置であって、
上記第 1のプログラムの一部を手続呼出に変換して上記第 2のプログラムを 作成する変換手段と、
上記手続呼出により呼び出されるべき手続の定義を記述したコードを生成す る生成手段と、
上記第 2のプログラムおよび上記生成手段により生成されたコードを出力す る出力手段と、
を有するコンパイラ装置。
2 . 上記第 1のプログラムから予め決められた特定のパターンを検出する検出 手段をさらに有し、
上記変換手段は、 その検出手段により検出されたパターンをそのパターンに 対応する手続呼出に変換する請求項 1に記載のコンパイラ装置。
3 . 上記検出手段は、 上記第 1のプログラムから組込み手続を呼び出すための 呼出を検出する請求項 2に記載のコンパィラ装置。
4. 上記検出手段が上記第 1のプログラムから複数の互いに同じパターンを検 出した際には、 上記変換手段は、 それら複数のパターンを同一の手続呼出に変 換する請求項 1に記載のコンパィラ装置。
5 . 1以上のプログラムを含む第 1のファイルが入力され、 その 1以上のプロ グラムをコンパイルし、 そのコンパイルされた 1以上のプログラムを含む第 2 のファイルを出力するコンパイラ装置であって、 上記第 1のファイルに含まれている 1以上のプログラムから予め決められた 特定のパターンを検出する検出手段と、
上記検出手段により検出されたパターンをそのパターンに対応する手続呼出 に変換することにより上記第 1のファイルに含まれている 1以上のプログラム をコンパイルする変換手段と、
上記手続呼出により呼び出されるべき手続の定義を記述したコードを生成す る生成手段と、
上記変換手段によりコンパイルされたプログラムおよび上記生成手段により 生成されたコードを出力する出力手段とを有し、
上記変換手段が上記第 1のファイルから複数の互いに同じパターンを検出し た際には、 上記変換手段は、 それら複数のパターンを同一の手続呼出に変換す るコンパイラ装置。
6 . 上記出力手段は、 上記生成手段により生成されたコードを上記第 2のファ ィルに出力する請求項 5に記載のコンパイラ装置。
7 . 各ファイルがそれぞれ 1以上のプログラムを含む複数のファイルが入力さ れ、 それら入力ファイルに含まれているプログラムをコンパイルするコンパィ ラ装置であって、
上記入力ファイルに含まれているプログラムから予め決められた特定のパ夕 ーンを検出する検出手段と、
上記検出手段により検出されたパターンをそのパターンに対応する手続呼出 に変換することにより上記入力ファイルに含まれているプログラムをコンパィ ルする変換手段と、
上記手続呼出により呼び出されるべき手続の定義を記述したコードを生成す る生成手段と、
上記変換手段によりコンパイルされたプログラムおよび上記生成手段により 生成されたコードを出力する出力手段とを有し、
上記変換手段が上記入力された複数のファイルから複数の互いに同じパター ンを検出した際には、 上記変換手段は、 それら複数のパターンを同一の手続呼 出に変換するコンパイラ装置。
8 . 入力された第 1のプログラムをコンパイルして第 2のプログラムを出力す るコンパイル方法であつて、
上記第 1のプログラムの一部を手続呼出に変換して上記第 2のプログラムを 作成するステップと、
上記手続呼出により呼び出されるべき手続の定義を記述したコードを生成す るステップと、
上記第 2のプログラムおよび上記生成手段により生成されたコードを出力す るステップと、
を有するコンパイル方法。
9 . コンピュータに、 入力された第 1のプログラムをコンパイルして第 2のプ ログラムを出力させる、 ためのプログラムを格納する記憶媒体であって、 上記第 1のプログラムの一部を手続呼出に変換して上記第 2のプログラムを 作成させ、
上記手続呼出により呼び出されるべき手続の定義を記述したコードを生成さ せ、
上記第 2のプログラムおよび上記生成手段により生成されたコードを出力さ せるプログラムを格納する記憶媒体。
PCT/JP1999/000381 1999-01-29 1999-01-29 Compilateur, procede de compilation et support de stockage sur lequel est stocke un programme pour la mise en oeuvre dudit procede WO2000045260A1 (fr)

Priority Applications (3)

Application Number Priority Date Filing Date Title
PCT/JP1999/000381 WO2000045260A1 (fr) 1999-01-29 1999-01-29 Compilateur, procede de compilation et support de stockage sur lequel est stocke un programme pour la mise en oeuvre dudit procede
JP2000596451A JP3762867B2 (ja) 1999-01-29 1999-01-29 コンパイラ装置、コンパイル方法、およびそのためのプログラムを格納した記憶媒体
US09/835,623 US7073167B2 (en) 1999-01-29 2001-04-17 Compiler system compiling method, and storage medium for storing compiling program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/JP1999/000381 WO2000045260A1 (fr) 1999-01-29 1999-01-29 Compilateur, procede de compilation et support de stockage sur lequel est stocke un programme pour la mise en oeuvre dudit procede

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US09/835,623 Continuation US7073167B2 (en) 1999-01-29 2001-04-17 Compiler system compiling method, and storage medium for storing compiling program

Publications (1)

Publication Number Publication Date
WO2000045260A1 true WO2000045260A1 (fr) 2000-08-03

Family

ID=14234823

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/JP1999/000381 WO2000045260A1 (fr) 1999-01-29 1999-01-29 Compilateur, procede de compilation et support de stockage sur lequel est stocke un programme pour la mise en oeuvre dudit procede

Country Status (3)

Country Link
US (1) US7073167B2 (ja)
JP (1) JP3762867B2 (ja)
WO (1) WO2000045260A1 (ja)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2012014526A (ja) * 2010-07-01 2012-01-19 Hitachi Ltd プログラムコードの構造変換装置、並びにコード構造変換プログラム
US9841919B2 (en) 2014-11-12 2017-12-12 Fujitsu Limited Information processing apparatus, communication method and information processing system for communication of global data shared by information processing apparatuses

Families Citing this family (32)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7516440B2 (en) * 2001-10-18 2009-04-07 Bea Systems, Inc. System and method for providing a java interface to an application view component
US7516447B2 (en) 2002-02-22 2009-04-07 Bea Systems, Inc. Methods and apparatus for building, customizing and using software abstractions of external entities
US8135772B2 (en) * 2002-05-01 2012-03-13 Oracle International Corporation Single servlets for B2B message routing
US7155438B2 (en) 2002-05-01 2006-12-26 Bea Systems, Inc. High availability for event forwarding
US7676538B2 (en) 2002-05-02 2010-03-09 Bea Systems, Inc. Systems and methods for application view transactions
US7222148B2 (en) 2002-05-02 2007-05-22 Bea Systems, Inc. System and method for providing highly available processing of asynchronous service requests
US7350184B2 (en) * 2002-05-02 2008-03-25 Bea Systems, Inc. System and method for enterprise application interactions
US6988099B2 (en) 2002-06-27 2006-01-17 Bea Systems, Inc. Systems and methods for maintaining transactional persistence
US7650591B2 (en) 2003-01-24 2010-01-19 Bea Systems, Inc. Marshaling and un-marshaling data types in XML and Java
US7584474B2 (en) 2003-02-25 2009-09-01 Bea Systems, Inc. Systems and methods for transaction chaining
US7774697B2 (en) 2003-02-25 2010-08-10 Bea Systems, Inc. System and method for structuring distributed applications
US7293038B2 (en) 2003-02-25 2007-11-06 Bea Systems, Inc. Systems and methods for client-side filtering of subscribed messages
US7752599B2 (en) 2003-02-25 2010-07-06 Bea Systems Inc. Systems and methods extending an existing programming language with constructs
US20050108682A1 (en) * 2003-02-26 2005-05-19 Bea Systems, Inc. Systems for type-independent source code editing
US7707564B2 (en) 2003-02-26 2010-04-27 Bea Systems, Inc. Systems and methods for creating network-based software services using source code annotations
US7539985B2 (en) * 2003-02-26 2009-05-26 Bea Systems, Inc. Systems and methods for dynamic component versioning
US7650276B2 (en) 2003-02-26 2010-01-19 Bea Systems, Inc. System and method for dynamic data binding in distributed applications
US8032860B2 (en) * 2003-02-26 2011-10-04 Oracle International Corporation Methods for type-independent source code editing
US20040230955A1 (en) * 2003-02-26 2004-11-18 Bea Systems, Inc. System for multi-language debugging
US7444620B2 (en) * 2003-02-28 2008-10-28 Bea Systems, Inc. Systems and methods for a common runtime container framework
US7636722B2 (en) * 2003-02-28 2009-12-22 Bea Systems, Inc. System and method for describing application extensions in XML
US7650592B2 (en) 2003-03-01 2010-01-19 Bea Systems, Inc. Systems and methods for multi-view debugging environment
US20070089097A1 (en) * 2005-10-13 2007-04-19 Liangxiao Hu Region based code straightening
US7992139B2 (en) * 2006-11-29 2011-08-02 International Business Machines Corporation Method, system and program product for transforming a single language program into multiple language programs
US8423980B1 (en) * 2008-09-18 2013-04-16 Google Inc. Methods for handling inlined functions using sample profiles
US10120663B2 (en) * 2014-03-28 2018-11-06 Intel Corporation Inter-architecture compatability module to allow code module of one architecture to use library module of another architecture
US9244664B1 (en) * 2014-04-28 2016-01-26 Visualon, Inc. System for video development kits with control of executable size
CN104731596A (zh) * 2015-03-27 2015-06-24 浪潮集团有限公司 一种支持多人在线编辑xbrl的分类编辑方法
KR101906823B1 (ko) * 2016-03-07 2018-12-05 주식회사 럭스로보 멀티 모듈 컴파일 시스템 및 멀티 모듈 컴파일 방법, 그리고 컴파일러 프로그램을 갖는 컴퓨터 판독가능 저장매체
US10140105B2 (en) * 2016-03-10 2018-11-27 Wowza Media Systems, LLC Converting source code
JP6940751B2 (ja) * 2017-05-10 2021-09-29 富士通株式会社 情報処理装置、情報処理方法および情報処理プログラム
CN113296789A (zh) * 2021-06-16 2021-08-24 北京有竹居网络技术有限公司 一种代码生成方法、装置、设备以及存储介质

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS63115236A (ja) * 1986-10-31 1988-05-19 Nec Corp オブジエクト選択方式
JPH08263272A (ja) * 1995-03-22 1996-10-11 Fujitsu Ltd 共通ルーチンのライブラリ登録方法およびそのための装置
JPH09128246A (ja) * 1995-10-30 1997-05-16 Fujitsu Ltd コンパイラ装置

Family Cites Families (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5699310A (en) * 1990-06-29 1997-12-16 Dynasty Technologies, Inc. Method and apparatus for a fully inherited object-oriented computer system for generating source code from user-entered specifications
US5420965A (en) * 1992-06-05 1995-05-30 Software Projects, Inc. Single pass method of compressing data transmitted to command driven terminal
US5488717A (en) * 1992-07-06 1996-01-30 1St Desk Systems, Inc. MTree data structure for storage, indexing and retrieval of information
JPH06309204A (ja) * 1993-04-20 1994-11-04 Matsushita Electric Ind Co Ltd データ処理方法及びその装置
US5701489A (en) * 1995-06-06 1997-12-23 International Business Machines Corporation System for partial in-line expansion of procedure calls during program compilation
US5835771A (en) * 1995-06-07 1998-11-10 Rogue Wave Software, Inc. Method and apparatus for generating inline code using template metaprograms
US5740443A (en) * 1995-08-14 1998-04-14 International Business Machines Corporation Call-site specific selective automatic inlining
US5925109A (en) * 1996-04-10 1999-07-20 National Instruments Corporation System for I/O management where I/O operations are determined to be direct or indirect based on hardware coupling manners and/or program privilege modes
US5822591A (en) * 1996-08-29 1998-10-13 Hewlett-Packard Company Virtual code system
JP3284956B2 (ja) * 1998-01-26 2002-05-27 日本電気株式会社 プログラム変換方法、プログラム変換装置及びプログラム変換プログラムを記憶した記憶媒体
US6195793B1 (en) * 1998-07-22 2001-02-27 International Business Machines Corporation Method and computer program product for adaptive inlining in a computer system
US6161217A (en) * 1998-09-14 2000-12-12 Sun Microsystems, Inc. Accurate method for inlining virtual calls
US6223340B1 (en) * 1998-10-09 2001-04-24 Sun Microsystems, Inc. Method for directly inlining virtual calls without on-stack replacement
US6574790B1 (en) * 1998-12-10 2003-06-03 Art Technology Group, Inc. System and method for interfacing and separating formatted content and program code
US6704924B1 (en) * 1999-02-03 2004-03-09 William H. Gates, III Method and system for implementing virtual functions of an interface

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS63115236A (ja) * 1986-10-31 1988-05-19 Nec Corp オブジエクト選択方式
JPH08263272A (ja) * 1995-03-22 1996-10-11 Fujitsu Ltd 共通ルーチンのライブラリ登録方法およびそのための装置
JPH09128246A (ja) * 1995-10-30 1997-05-16 Fujitsu Ltd コンパイラ装置

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2012014526A (ja) * 2010-07-01 2012-01-19 Hitachi Ltd プログラムコードの構造変換装置、並びにコード構造変換プログラム
US9841919B2 (en) 2014-11-12 2017-12-12 Fujitsu Limited Information processing apparatus, communication method and information processing system for communication of global data shared by information processing apparatuses

Also Published As

Publication number Publication date
JP3762867B2 (ja) 2006-04-05
US20040205729A1 (en) 2004-10-14
US7073167B2 (en) 2006-07-04

Similar Documents

Publication Publication Date Title
JP3762867B2 (ja) コンパイラ装置、コンパイル方法、およびそのためのプログラムを格納した記憶媒体
US11036614B1 (en) Data control-oriented smart contract static analysis method and system
De Roover et al. The SOUL tool suite for querying programs in symbiosis with Eclipse
US5946489A (en) Apparatus and method for cross-compiling source code
US5606697A (en) Compiler system for language processing program
US6901579B1 (en) Generation of source code from classes and maintaining the comment that indicates the role of the class in the generated source code
US7657878B2 (en) Compiler, method of compiling and program development tool
US6961931B2 (en) Dependency specification using target patterns
JP4118456B2 (ja) プログラム言語処理システム、コード最適化方法、及び機械読み出し可能な記憶媒体
JP2007012088A (ja) インクリメンタル生成システム
Miecznikowski et al. Decompiling Java using staged encapsulation
WO2002093383A2 (en) System and method for combinatorial test generation in a compatibility testing environment
US7441237B2 (en) System and method for extending a compiler through a composer
US20170075668A1 (en) Methods and Systems for Generating Client-Server Applications for Target Devices
Fritzson et al. Metamodelica–a symbolic-numeric modelica language and comparison to julia
US9703576B2 (en) Aspect scoping in a modularity runtime
JP5399601B2 (ja) 実装コード開発システム、及び実装コード開発プログラム
GB2420638A (en) Method of substituting code fragments in Internal Representation
JP3266097B2 (ja) 非リエントラントプログラムの自動リエントラント化方法及びシステム
JP7059757B2 (ja) Api処理方法、端末、api処理プログラム
Lengyel et al. Implementing an OCL Compiler for .NET
CN106663011B (zh) 桥接模块系统和非模块系统
Nyznar et al. Generating source code templates on the basis of unit tests
Wagner et al. Comparative analysis of tools for automated software re-engineering purposes
CN116560761A (zh) 全局函数的信息获取方法及装置、电子设备及存储介质

Legal Events

Date Code Title Description
AK Designated states

Kind code of ref document: A1

Designated state(s): JP US

DFPE Request for preliminary examination filed prior to expiration of 19th month from priority date (pct application filed before 20040101)
ENP Entry into the national phase

Ref country code: JP

Ref document number: 2000 596451

Kind code of ref document: A

Format of ref document f/p: F

WWE Wipo information: entry into national phase

Ref document number: 09835623

Country of ref document: US