Apparatus and method for supporting development of compiler
Patent Information
- Application Number
- JP2024119202
- Authority / Receiving Office
- JP · JP
- Patent Type
- Applications
- Current Assignee / Owner
- Filing Date
- 2024-07-25
- Publication Date
- 2026-02-05
Smart Images

Figure 2026018116000001_ABST
Abstract
Description
[Technical Field]
[0001] The present invention relates to an apparatus and method for assisting the development of a front-end compiler. [Background technology]
[0002] When source code is converted into object code, it may be converted into an intermediate representation by a front-end compiler. In this case, the compiler infrastructure may be realized by, for example, LLVM. For example, in the procedure described in Patent Document 1, high-level software code such as C or C++ is converted into low-level software code (LLVM IR) using a front-end compiler such as Clang. [Prior art documents] [Patent documents]
[0003] [Patent Document 1] Special Publication No. 2022-530498 Summary of the Invention [Problem to be solved by the invention]
[0004] Depending on the language of the source code, there may be no front-end compiler available. In this case, it is necessary to develop a corresponding front-end compiler. However, developing a new front-end compiler requires sufficient knowledge of the intermediate representation (e.g., LLVM IR). In other words, developing a front-end compiler can be difficult.
[0005] It is an object of one aspect of the present invention to provide a template for use in developing a front-end compiler. [Means for solving the problem]
[0006] A compiler development support device according to one aspect of the present invention includes: a front-end compiler that generates an intermediate representation written in a third language from second source code written in a second language, the second source code having content equivalent to first source code written in a first language, and outputs debug information indicating a correspondence between the second source code and the intermediate representation; an intermediate representation management table creation unit that creates an intermediate representation management table in which each process in the second source code is associated with a corresponding description in the intermediate representation based on the debug information; a comment management table creation unit that extracts, from the second source code, comment statements assigned to one or more processes in the second source code, to create a comment management table; a storage unit that stores a function management table in which each instruction used in the third language is associated with a function for creating the instruction; and a template creation unit that creates, based on the intermediate representation management table, the comment management table, and the function management table, a template in which, for each process in the second source code, a corresponding comment statement and a template code for creating a corresponding instruction used in the third language are associated. [Effects of the Invention]
[0007] According to the above-described aspect, it is possible to reduce the effort or time required to develop a front-end compiler. [Brief explanation of the drawings]
[0008] [Figure 1] 1 is a diagram illustrating an overview of a compiler development support method according to an embodiment of the present invention. [Figure 2] 1 is a diagram illustrating an example of a compiler development support device according to an embodiment of the present invention. [Figure 3] 1 is a flowchart illustrating an example of a method for creating a template for use in developing a front-end compiler. [Figure 4] FIG. 10 illustrates an example of a method for creating a function management table. [Figure 5]FIG. 1 is a diagram illustrating an example of LLVM IR generation by a front-end compiler. [Figure 6] FIG. 10 is a diagram illustrating an example of a method for creating an LLVM IR management table using debug information. [Figure 7] FIG. 10 is a diagram illustrating an example of an LLVM IR management table. [Figure 8] FIG. 10 is a diagram illustrating an example of a method for creating a comment management table. [Figure 9] FIG. 1 illustrates an example of a method for generating template code for a front-end compiler. [Figure 10] FIG. 1 illustrates an example of a method for creating a template for a front-end compiler. [Figure 11] FIG. 10 is a diagram illustrating an example of a template for a front-end compiler. [Figure 12] FIG. 10 is a diagram illustrating an example of how to use a template. [Figure 13] FIG. 1 illustrates an example of a hardware configuration of a compiler development support device. DETAILED DESCRIPTION OF THE INVENTION
[0009] When source code written in a widely used programming language such as C or C++ is converted into object code, it may be converted into an intermediate representation (IR) by an existing front-end compiler such as Clang. In this case, the intermediate representation is, for example, LLVM IR. Note that a front-end compiler is sometimes called a compiler front-end.
[0010] On the other hand, for programming languages that are not widely used, there may be no front-end compilers. In this case, a corresponding front-end compiler must be newly developed to generate the intermediate representation. However, developing a new front-end compiler requires sufficient knowledge of the intermediate representation (e.g., LLVM IR). Specifically, it is necessary to understand the specifications of the source code, the intermediate representation, and the library functions (e.g., LLVM IR Builder) used to convert the source code into the intermediate representation.
[0011] However, there are a large number of library functions, and the official LLVM documentation is difficult for beginners to understand. In addition, there are few reference materials related to LLVM, making it difficult to find the necessary technology. For this reason, developing a front-end compiler takes a significant amount of time, especially for beginners.
[0012] 1 shows an overview of a compiler development support method according to an embodiment of the present invention. In this example, a front-end compiler is developed to convert source code 1 into an intermediate representation.
[0013] The source code 1 is assumed to be written in a programming language that is not widely used. For example, the source code 1 is a software program implemented in a programmable logic controller (PLC) that controls various devices or equipment in a factory, and is written in a PLC development language or the like, although this is not a particular limitation. In addition, the intermediate representation in this embodiment is LLVM IR. Therefore, in the following description, the intermediate representation generated by the front-end compiler from the source code 1 may be referred to as "LLVM IR3."
[0014] The front-end compiler 2 is a software program for generating LLVM IR 3 from the source code 1. However, in this example, it is assumed that there is currently no front-end compiler for converting the programming language in which the source code 1 is written into LLVM IR. Therefore, in an embodiment of the present invention, a template 15, which will be described later, is created to support the development of the front-end compiler 2.
[0015] The equivalent source code 11 is a software program written in a programming language for which a front-end compiler exists for converting it into LLVM IR, and its content is equivalent to the source code 1. In this embodiment, the equivalent source code 11 is written in C or C++. The equivalent source code 11 is created for the purpose of creating a template 15, which will be described later.
[0016] Comment statements are added to each or some of the processes described in the equivalent source code 11. Each comment statement describes the content of the corresponding process. The comment statements are written, for example, by the creator of the equivalent source code 11.
[0017] The front-end compiler 12 is an existing software program for converting program code written in C or C++ into LLVM IR. Although not particularly limited, the front-end compiler 12 is, for example, Clang.
[0018] LLVM IR with debug information 13 is an intermediate representation generated by providing equivalent source code 11 to a front-end compiler 12. This intermediate representation is provided with debug information. The debug information includes information that indicates the correspondence between the source code to be compiled and the code obtained by compilation. Specifically, the debug information includes information on data structures (structure and type information), code structures (functions, subroutines, etc.), local variables, arguments, etc. The debug information may also include information that indicates the correspondence between file and line number information of the source code to be compiled and address information of the compiled code. The debug information may also include line information, address information, frame information, location information, name information, etc.
[0019] The comment management table 14 manages the comment statements written in the equivalent source code 11. That is, the comment management table 14 is created by extracting each comment statement from the equivalent source code 11. At this time, the line number where each comment statement is written is also extracted, and the comment statement is managed in association with the extracted line number.
[0020] The template 15 is a front-end template that is referred to when developing the front-end compiler 2. The template 15 is created based on LLVM IR 13 with debug information and a comment management table 14, as will be described in detail later.
[0021] As described above, in the compiler development support method according to the embodiment of the present invention, LLVM IR is generated by creating equivalent source code 11 that is equivalent to source code 1 for which a front-end compiler is to be developed and providing this to an existing front-end compiler. It is relatively easy to create equivalent source code 11 in a widely used programming language such as C or C++. The LLVM IR generated in this manner is then used to create a template 15 that is referenced when developing the target front-end compiler. The developer then references this template 15 to create a front-end compiler for source code 1 (i.e., front-end compiler 2).
[0022] 2 shows an example of a compiler development support device according to an embodiment of the present invention. The compiler development support device 20 according to the embodiment of the present invention includes a front-end compiler 21, an intermediate representation management table creation unit 22, a comment management table creation unit 23, a storage unit 24, and a template creation unit 25. The compiler development support device 20 may further include other functions or devices not shown in FIG. 2.
[0023] In the example shown in FIG. 1, the front-end compiler 21 corresponds to the front-end compiler 12. The front-end compiler 21 generates an intermediate representation written in a third language from a second source code written in a second language, which has content equivalent to a first source code written in a first language. Here, it is assumed that the first language is a programming language that is not widely used, and no front-end compiler for generating LLVM IR exists. The second language is a widely used programming language, such as C or C++. The intermediate representation written in the third language is, for example, LLVM IR. In this case, the front-end compiler 21 generates LLVM IR from equivalent source code 11 written in C or C++. Note that, as in the case shown in FIG. 1, the equivalent source code 11 describes content equivalent to source code written in a language other than C / C++ (source code 1 in FIG. 1).
[0024] The front-end compiler 21 is, for example, Clang when the equivalent source code 11 is written in C or C++. In this case, the front-end compiler 21 can output debug information using optional functions of Clang. The debug information represents the correspondence between the equivalent source code 11 and LLVM IR generated from the equivalent source code by the front-end compiler 21. In the following description, the intermediate representation generated from the equivalent source code 11 by the front-end compiler 21 may be referred to as "LLVM IR32." Furthermore, the debug information added to the LLVM IR32 may be referred to as "debug information 32a."
[0025] The intermediate representation management table creation unit 22 creates an LLVM IR management table 33 in which each process in the equivalent source code 11 is associated with a corresponding description in the LLVM IR 32 based on the debug information 32a added to the LLVM IR 32.
[0026] The comment management table creation unit 23 extracts from the equivalent source code 11 comment statements assigned to one or more processes in the equivalent source code 11 to create a comment management table 34. At this time, the comment management table creation unit 23 also extracts the line number in which each comment statement is written in the equivalent source code 11. Each comment statement is then managed in association with the line number in the comment management table 34. It is assumed that a comment statement is assigned in advance to each process or several processes written in the equivalent source code 11. The comment statement describes the content of the corresponding process. The comment statement is written, for example, by the creator of the equivalent source code 11.
[0027] The storage unit 24 stores a function management table 35. The function management table 35 indicates the correspondence between each instruction used in the LLVM IR and the function for creating that instruction. Note that the function management table 35 is assumed to have been created in advance by, for example, a user of the compiler development support device 20.
[0028] The template creation unit 25 creates the template 15 based on the LLVM IR management table 33, the comment management table 34, and the function management table 35. The template creation unit 25 includes a template code generation tool 26 and a merging tool 27. For each process in the equivalent source code 11, the template code generation tool 26 assigns the corresponding description in the LLVM IR management table 33 to the corresponding function in the function management table 35, thereby generating template code 36 for creating a corresponding instruction used in the LLVM IR. The merging tool 27 creates the template 15 by associating each template code 36 with the corresponding process in the equivalent source code 11 and the corresponding comment statement in the comment management table 34. Therefore, in the template 15, the corresponding comment statement and the corresponding template code 36 are associated with each process in the equivalent source code 11.
[0029] In this way, the compiler development support device 20 creates a template 15 that includes template code for creating each instruction used in LLVM IR. Here, each template code is associated with a comment statement. Therefore, a developer of source code for which no front-end compiler exists can use the comment statements to search for template code for creating the corresponding instruction used in LLVM IR. This reduces the effort and time required to develop a new front-end compiler.
[0030] 3 is a flowchart showing an example of a method for creating a template for use in developing a front-end compiler. In the following description, the source code for which a front-end compiler for generating LLVM IR is to be created may be referred to as the "target source code."
[0031] In S1, the function management table 35 is created. The function management table 35 is stored in the storage unit 24.
[0032] In S2, an equivalent source code 11 having the same content as the target source code is created. Comment statements are added to one or more processes in the equivalent source code 11.
[0033] In S3, the front-end compiler 21 converts the equivalent source code 11 into LLVM IR32 with debug information, i.e., LLVM IR32 and debug information 32a are generated.
[0034] In S4, the intermediate representation management table creation unit 22 creates the LLVM IR management table 33 by extracting information indicating the correspondence with the equivalent source code 11 from the LLVM IR 32 using the debug information 32a.
[0035] In S5, the comment management table creating unit 23 creates the comment management table 34 by extracting comment statements from the equivalent source code 11.
[0036] In S6, the template creation unit 25 creates a template 15 to be referenced when developing a front-end compiler from the function management table 35, the LLVM IR management table 33, and the comment management table 34. The order in which each step is executed is not limited to the procedure shown in FIG. 3. For example, the function management table 35 may be created after the equivalent source code 11 is created. Also, the comment management table 34 may be created before the equivalent source code 11 is converted into LLVM IR32.
[0037] 4 shows an example of a method for creating the function management table 35. The process for creating the function management table 35 corresponds to S1 in the flowchart shown in FIG.
[0038] In this embodiment, the function management table 35 represents the correspondence between each instruction used in LLVM IR and the function for creating that instruction. Library functions for creating each instruction in LLVM IR in C or C++ (hereinafter sometimes referred to as "C / C++") are provided by organizations that manage or support LLVM. For example, standard C++ libraries such as libc++ or libstdc++ are provided.
[0039] Therefore, the function management table 35 can be created based on such a standard library. The example shown in Figure 4 shows that the function for creating "alloca," which is one of the LLVM IR instructions, is "CreateAlloca." In other words, by using "CreateAlloca" in C++, it is possible to create "alloca" in LLVM IR. "alloca" is an instruction that allocates memory on the stack and returns a pointer to the beginning of the allocated area.
[0040] In this case, "CreateAlloca" is registered in association with "alloca." Similarly, for other LLVM IR instructions, corresponding functions are extracted from the standard library and registered. This creates a function management table 35. Note that in the example shown in FIG. 4, only the names of the functions extracted from the standard library are listed, but information on how to use the functions and / or their arguments may also be stored together with the function names. Furthermore, the function management table 35 may be created manually or automatically by a computer. The created function management table 35 is then stored in the storage unit 24. The storage unit 24 is realized by a memory or storage device included in the compiler development support device 20.
[0041] 5 shows an example of LLVM IR generation by the front-end compiler 21. The generation of LLVM IR corresponds to S3 in the flowchart shown in FIG. 3. In this example, the equivalent source code 11 is "example.c" written in the C language. The front-end compiler 21 also provides a function for converting a program written in C language (here, the equivalent source code 11) into LLVM IR.
[0042] The equivalent source code 11 is provided to the front-end compiler 21. Then, the front-end compiler 21 generates and outputs LLVM IR32. At this time, the front-end compiler 21 is set to output debug information 32a. The output of the debug information 32a can be realized by an optional function of the front-end compiler 21. For example, if the front-end compiler 21 is Clang, the debug information 32a is generated by using "-g" during compilation as follows: Example: clang example.c -S -emit-llvm -g
[0043] In response to the above instructions, the front-end compiler 21 generates and outputs LLVM IR32 from the equivalent source code 11. At this time, debug information 32a is also output. The debug information 32a shown in Figure 5 indicates the correspondence between the description on line 6 of the equivalent source code 11 and the description in LLVM IR32.
[0044] 6 shows an example of a method for creating the LLVM IR management table 33 using the debug information 32a. The creation of the LLVM IR management table 33 corresponds to S4 in the flowchart shown in FIG. 3. In this embodiment, as described with reference to FIG. 5, the front-end compiler 21 generates the LLVM IR32. The debug information 32a is added to the LLVM IR32.
[0045] In the embodiment shown in Fig. 6, the debug information 32a represents the debug information for the sixth line (i.e., "int i = 1") of the equivalent source code 11 shown in Fig. 5. That is, lines !12 to !15 of the debug information 32a represent the debug information for the sixth line of the equivalent source code 11.
[0046] In line !14 of the debug information 32a, description D2 means that there is a variable named "i" on line 6 of the original code to be compiled (i.e., equivalent source code 11). It also describes a reference to line !12 for the "type." Here, description D1 on line !12 reveals that this variable is a 32-bit int type. Furthermore, description D3 on line !15 reveals that it is in column 9 of line 6 of the original code to be compiled.
[0047] The LLVM IR32 description D11 contains "!14". Here, "!14" relates to line 6 of the source code. The description D11 also contains "%2". Therefore, it can be seen that the description on the line starting with "%2" corresponds to line 6 of the source code. Similarly, the LLVM IR32 description D12 contains "!15", which relates to line 6 of the source code. Therefore, it can be seen that the description D12 also corresponds to line 6 of the source code.
[0048] As described above, the intermediate representation management table creation unit 22 analyzes the contents of the debug information 32a to find a description corresponding to each process of the original code to be compiled (i.e., the equivalent source code 11) from the LLVM IR 32. Then, the intermediate representation management table creation unit 22 creates the LLVM IR management table 33 by associating each process of the equivalent source code 11 with a corresponding description in the LLVM IR 32.
[0049] 7 shows an example of the LLVM IR management table 33. In this embodiment, it is registered that the LLVM IR descriptions corresponding to the process "int i = 1" described on the sixth line of the equivalent source code 11 are "%2 = alloca i32, align 4" and "store i32 1, ptr %2, align 4." For processes described on other lines of the equivalent source code 11, the corresponding descriptions in the LLVM IR32 are extracted and registered.
[0050] Fig. 8 shows an example of a method for creating the comment management table 34. The creation of the comment management table 34 corresponds to S5 in the flowchart shown in Fig. 3. In this embodiment, the comment management table creation unit 23 creates the comment management table 34 from the equivalent source code 11 shown in Fig. 8.
[0051] Comment statements are added to one or more processes in the equivalent source code 11. Comment statements are written according to predetermined rules. In this embodiment, the comment statements are written after the keyword "@llvm." The comment statements are added, for example, by the creator of the equivalent source code 11.
[0052] Comment statements indicate the content of the processing. For example, line 6 of equivalent source code 11 describes the process of declaring and assigning a variable by specifying its data type. Therefore, the comment statement "declaration and assignment" is added to the processing described on this line. Also, line 9 of equivalent source code 11 describes the addition of variables i and j. Therefore, the comment statement "addition of two values" is added to the processing described on this line. Furthermore, comments are added to lines 10 and 11 as well. Note that the processing on lines 7 and 8 are similar to the processing on line 6 and are therefore redundant, so there is no need to add comments.
[0053] The comment management table creation unit 23 searches for the keyword "@llvm" in the equivalent source code 11 and extracts the character string from the character following each keyword to the line feed code as a comment. The comment management table 34 is created by registering the extracted character string in association with the line number where the keyword was detected.
[0054] In the example shown in Figure 8, the comment begins with " / / ", but the comment may be added in other formats. For example, the comment may be enclosed in " / ** / ". Furthermore, if the processing related to "#ifdef" and "#if" is disabled, the comment may not be extracted.
[0055] 9 shows an example of a method for generating template code for a front-end compiler. It is assumed that the intermediate representation management table creation unit 22 has created an LLVM IR management table 33, and that the storage unit 24 has stored a function management table 35.
[0056] The template code generation tool 26 references the LLVM IR management table 33 and the function management table 35 to create template code 36 for the front-end compiler. If the intermediate representation is LLVM IR, the template code 36 written in C++ is created.
[0057] Template code generation tool 26 analyzes the lexical content of the corresponding LLVM IR for each process registered in LLVM IR management table 33. Then, template code generation tool 26 refers to function management table 35 according to the contents of the LLVM IR to identify the functions required to generate the LLVM IR.
[0058] In the example shown in FIG. 9, the LLVM IR corresponding to the process described on line 6 of equivalent source code 11 (hereinafter sometimes referred to as the "target process") includes "alloca" and "store." Furthermore, by referencing function management table 35, functions (CreateAlloca, CreateStore) for creating these instructions are identified. Then, by providing necessary information for the arguments of each identified function, template code 36 is created. The parts corresponding to the arguments of each function are represented as "(···)" in FIG. 9.
[0059] In this way, the template code generation tool 26 generates template code 36 for each process registered in the LLVM IR management table 33. Here, lexical analysis of the LLVM IR can be achieved by known techniques. Furthermore, information to be provided as arguments to each function is extracted from the LLVM IR registered in association with the target process in the LLVM IR management table 33 and from the standard library provided by the organization that manages or supports LLVM.
[0060] 10 shows an example of a method for creating a template for a front-end compiler. The template 15 is created by combining the template code 36 described with reference to FIG. 9 with the corresponding comment statement managed by the comment management table 34. In the following example, a template is created for the process described on line 6 of the equivalent source code 11 (hereinafter, sometimes referred to as the "target process").
[0061] Template creation unit 25 searches comment management table 34 for the number of the line where the target processing is described. In this embodiment, comment management table 34 is searched for "line number = 6." As a result, the corresponding comment statement "declaration and assignment" is extracted.
[0062] 11, in the template 15, a process type and a template code are stored for each process of the source code. That is, the merging tool 27 stores, as the process type, a comment statement extracted from the comment management table 34. The merging tool 27 also stores, as the template code, the template code 36 generated by the template code generation tool 26.
[0063] The template creation unit 25 performs the same process for each process of the equivalent source code 11 (i.e., each process registered in the LLVM IR management table 33). This completes the template 15 shown in Fig. 11. Note that in the template 15 shown in Fig. 11, necessary information is substituted into the arguments of each function.
[0064] 12 shows an example of how to use the template 15. In this embodiment, a user refers to the template 15 when developing a front-end compiler. In this embodiment, a front-end compiler creation tool is implemented as an extension of an integrated development environment (IDE). The integrated development environment is not particularly limited, but may be, for example, VSCode.
[0065] A UI screen 40 provided by the integrated development environment has a search button 41. When the user clicks the search button 41, a search box 42 appears on the UI screen 40. The user then inputs the type of process for which the user wants to create front-end compiler code into the search box 42. At this time, the user can select partial match or exact match in the search process.
[0066] When a search is executed, the template 15 is queried. At this time, the template 15 is searched for the character string (i.e., the processing type) entered in the search box 42. Then, the search results are displayed, for example, in a pop-up screen 50.
[0067] In this embodiment, the template 15 is searched for by "process type = declaration and assignment." The template 15 is as described with reference to FIG. 11. The search results, that is, the corresponding process in the source code and the template code, are displayed on the pop-up screen 50. After this, when the user clicks the insert button 51 displayed on the pop-up screen 50, the template code extracted from the template 15 is inserted on the UI screen 40 of the integrated development environment.
[0068] In this way, in the template 15 created by the compiler development support device 20, template code for creating a corresponding instruction used in LLVM IR is associated with each operation in the source code (i.e., equivalent source code 11). Therefore, by accessing the template 15, a user can obtain a program code template for converting any operation in the source code (e.g., "int i = 1") into LLVM IR. Then, by referring to this template, a front-end compiler for converting any operation in the source code into LLVM IR can be easily created.
[0069] Here, template 15 is not a program code for converting target source code that requires a new front-end compiler into an intermediate representation, but a program code for converting equivalent source code into an intermediate representation. In the example shown in FIG. 1 , template 15 is not a program code for converting source code 1 that requires a new front-end compiler 2 into an intermediate representation, but a program code for converting equivalent source code 11 into an intermediate representation. However, equivalent source code 11 is written to have content equivalent to source code 1. Therefore, template 15 is substantially the same as program code for converting target source code (source code 1 in FIG. 1 ) into an intermediate representation. For example, template 15 includes a function for converting target source code into an intermediate representation. Therefore, a user can create program code for converting target source code into an intermediate representation by modifying template 15, taking into account differences between the programming language of the target source code and the programming language of the equivalent source code. In this embodiment, a user can create a front-end compiler 2 that converts source code 1 into LLVM IR by modifying template 15, taking into account differences between the programming language of source code 1 and the programming language of equivalent source code 11.
[0070] <Hardware configuration> 13 shows an example of the hardware configuration of the compiler development support device 20. The compiler development support device 20 is realized by a computer 100 including a processor 101, a memory 102, a storage device 103, an input / output device 104, a recording medium reader 105, and a communication interface 106.
[0071] The processor 101 executes a compiler development support program stored in the storage device 103. When the processor 101 executes the compiler development support program, the functions of the front-end compiler 21, intermediate representation management table creation unit 22, comment management table creation unit 23, and template creation unit 25 shown in FIG. 2 are provided. The memory 102 is used as a work area for the processor 101. The storage device 103 stores the compiler development support program and other programs. The storage unit 24 is realized by the memory 102 or the storage device 103.
[0072] The input / output device 104 may include input devices such as a keyboard, a mouse, a touch panel, and a microphone. The input / output device 104 may also include output devices such as a display device and a speaker. The recording medium reader 105 can acquire data and information recorded on the recording medium 110. The recording medium 110 is a removable recording medium that can be attached to and detached from the computer 100. The recording medium 110 may be realized by, for example, a semiconductor memory, a medium that records signals optically, or a medium that records signals magnetically. The compiler development support program may be provided to the computer 100 from the recording medium 110. The communication interface 106 provides a function for connecting to a network. When the compiler development support program is stored in the program server 120, the computer 100 may acquire the compiler development support program from the program server 120. [Explanation of symbols]
[0073] 1 Source code 11 Equivalent Source Code 15 Templates 20 Compiler development support device 21 Front-end compiler 22 Intermediate Representation Management Table Creation Unit 23 Comment management table creation section 24 Preservation Department 25 Template Creation Department 26 Template Code Generator 27 Combine Tools 32 LLVM IR 32a Debugging Information 33 LLVM IR Management Table 34 Comment Management Table 35 Function Management Table 36 Template Code
Claims
1. a front-end compiler that generates an intermediate representation written in a third language from second source code written in a second language, the second source code having content equivalent to first source code written in a first language, and outputs debug information that indicates a correspondence between the second source code and the intermediate representation; an intermediate representation management table creation unit that creates an intermediate representation management table in which each process in the second source code is associated with a corresponding description in the intermediate representation based on the debug information; a comment management table creation unit that extracts, from the second source code, comment statements that are assigned to one or more processes in the second source code, and creates a comment management table; a storage unit that stores a function management table in which each instruction used in the third language is associated with a function for creating the instruction; a template creation unit that creates, for each process in the second source code, a template in which a corresponding comment statement and a template code for creating a corresponding instruction used in the third language are associated with each process based on the intermediate representation management table, the comment management table, and the function management table; A compiler development support device comprising:
2. The template creation unit a template code generation tool that generates the template code by providing a description associated in the intermediate representation management table to a function associated in the function management table for each process in the second source code; 2. The compiler development support device according to claim 1.
3. The intermediate representation written in the third language is an LLVM intermediate representation.
2. The compiler development support device according to claim 1.
4. In the function management table, each instruction used in the third language is associated with a library function for creating the instruction in the second language.
2. The compiler development support device according to claim 1.
5. generating an intermediate representation written in a third language from a second source code written in a second language, the second source code having content equivalent to a first source code written in a first language, and outputting debug information indicating a correspondence between the second source code and the intermediate representation; creating an intermediate representation management table in which each process in the second source code is associated with a corresponding description in the intermediate representation based on the debug information; extracting, from the second source code, comment statements assigned to one or more processes in the second source code, and creating a comment management table; obtaining a function management table in which a function for creating each instruction used in the third language is associated with the instruction; Based on the intermediate representation management table, the comment management table, and the function management table, a template is created for each process in the second source code, in which a corresponding comment statement and a template code for creating a corresponding instruction used in the third language are associated. A compiler development support method comprising:
Citation Information
Patent Citations
A method for implementing a hardware device to perform operations defined by high-level software code.
JP2022530498A