Check patentability & draft patents in minutes with Patsnap Eureka AI!

LLVM-based ST language compiling method and system and compiler

A compilation method and language technology, applied in the field of language compilation, can solve the problems of lack of universality and lack of universality in intermediate languages, and achieve the effects of convenient optimization processing, strong universality and good portability

Pending Publication Date: 2020-02-21
NARI TECH CO LTD +1
View PDF5 Cites 8 Cited by
  • Summary
  • Abstract
  • Description
  • Claims
  • Application Information

AI Technical Summary

Problems solved by technology

The front-end and back-end of the traditional compiler architecture are coupled together, and the design of the optimizer also depends on the intermediate language and the specific hardware platform, which lacks versatility. When it is necessary to support new programming languages ​​and new hardware devices, due to the lack of intermediate language For generality, both the front end and the back end must be reimplemented

Method used

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
View more

Image

Smart Image Click on the blue labels to locate them in the text.
Viewing Examples
Smart Image
  • LLVM-based ST language compiling method and system and compiler
  • LLVM-based ST language compiling method and system and compiler
  • LLVM-based ST language compiling method and system and compiler

Examples

Experimental program
Comparison scheme
Effect test

Embodiment 1

[0049] figure 1It shows a schematic flowchart of the implementation of the LLVM-based ST language compiling method provided by this embodiment.

[0050] A kind of LLVM-based ST language compiling method provided by this embodiment includes:

[0051] Get the source code of structured text ST language;

[0052] Perform lexical analysis on the source code of structured text ST language according to the lexical rules defined by IEC61131-3, and obtain the symbol flow;

[0053] Based on the symbol stream, perform grammatical analysis on the symbol stream according to the grammatical expression defined by IEC61131-3, and obtain an abstract syntax tree representing the program structure corresponding to the source code of the ST language, and the abstract syntax tree is represented by the expression for the node;

[0054] Based on the abstract syntax tree, performing semantic analysis on the abstract syntax tree to obtain an abstract syntax tree with a type identifier;

[0055] Co...

Embodiment 2

[0063] figure 2 A block diagram of the ST language compiling system based on LLVM provided by this embodiment is shown.

[0064] A compilation system comprising:

[0065] The obtaining module is used for: obtaining the source code of the structured text ST language;

[0066] The lexical analysis module is used to: perform lexical analysis on the source code of the structured text ST language according to the lexical rules defined in IEC61131-3, and obtain the symbol flow;

[0067] The grammatical analysis module is used to: perform grammatical analysis on the symbol flow according to the grammatical expression defined by IEC61131-3, and obtain an abstract syntax tree representing the program structure corresponding to the source code of the ST language, and the abstract syntax tree is expressed in The formula is node;

[0068] A semantic analysis module, configured to: perform semantic analysis on the abstract syntax tree to obtain an abstract syntax tree with a type ident...

Embodiment 3

[0082] A compiler comprising:

[0083] The compilation system (ie, the compilation front end) is used to complete lexical analysis, syntax analysis and semantic analysis, and generate machine-independent LLVM IR;

[0084] LLVM optimizer, used to optimize LLVM IR to obtain optimized LLVM IR;

[0085] LLVM backend for generating target machine code based on optimized LLVM IR, depending on the target platform.

[0086] In some embodiments, an LLVM-based compiler such as image 3 As shown, including the front end (Frontend), the underlying virtual machine optimizer (LLVM Optimizer) and the underlying virtual machine backend (LLVM Backend). Among them, the front end is responsible for lexical analysis, syntax analysis and semantic analysis, the source code (Source Code) finally generates the underlying virtual machine intermediate code (LLVMIR), LLVM Optimizer optimizes LLVM IR, and LLVM Backend finally generates platform-specific machine code. The object processed by LLVM Optim...

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to View More

PUM

No PUM Login to View More

Abstract

The invention discloses an LLVM-based ST language compiling method, compiling system and compiler. The method comprises the steps of obtaining a source code of a structured text ST language; performing lexical analysis on the source code of the ST language of the structured text according to a lexical rule defined by IEC61131-3 to obtain a symbol stream; carrying out syntax analysis on the symbolstream according to a syntax expression defined by IEC61131-3, obtaining an abstract syntax tree representing a program structure corresponding to a source code of an ST language, and the abstract syntax tree taking the expression as a node; performing semantic analysis on the abstract syntax tree to obtain an abstract syntax tree with a type identifier; and converting the abstract syntax tree with the type identifier to generate LLVM IR. According to the method, the ST language code is converted into the LLVM IR, the LLVM IR is independent of the ST language and the target platform, the LLVMoptimizer can be used for optimization, and finally the machine code for the target platform is generated through the LLVM rear end.

Description

technical field [0001] The invention belongs to the technical field of language compilation, and in particular relates to an LLVM-based ST language compilation method, a compilation system and a compiler. Background technique [0002] ST language is one of the PLC programming languages ​​in the IEC61131-3 standard, which is suitable for writing complex PLC programs in large and medium-sized PLC systems. [0003] Programmable logic controller (PLC) is designed and manufactured for industrial control applications. Its logic control is realized through PLC programming language. The international standard IEC61131-3 defines five PLC programming languages: ladder diagram (LD), function block diagram ( FBD), Sequential Function Chart (SFC), Instruction List (IL) and Structured Text (ST). The first three are visual programming languages, which are simple and intuitive. Among them, the ladder diagram is similar to the traditional relay control diagram. Users do not need to have pro...

Claims

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to View More

Application Information

Patent Timeline
no application Login to View More
IPC IPC(8): G06F8/41
CPCG06F8/42G06F8/425G06F8/436
Inventor 郭壁垒孙延岭熊光亚景波云李冰程潇黠姜晓姜鑫
Owner NARI TECH CO LTD
Features
  • R&D
  • Intellectual Property
  • Life Sciences
  • Materials
  • Tech Scout
Why Patsnap Eureka
  • Unparalleled Data Quality
  • Higher Quality Content
  • 60% Fewer Hallucinations
Social media
Patsnap Eureka Blog
Learn More