# plc2llvm_PLCCOMPILER **Repository Path**: balababa/plc2llvm_PLCCOMPILER ## Basic Information - **Project Name**: plc2llvm_PLCCOMPILER - **Description**: 一款由IEC61131-3 ST 到 LLVM IR 的编译器。 - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 5 - **Created**: 2023-03-13 - **Last Updated**: 2023-07-17 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # PLC2LLVM ### 介绍 PLC到LLVM的编译器,使用ANTLR4自动工具 ### 配置 #### 编译LLVM ```BASH # 从github上下载: $ git clone https://github.com/llvm/llvm-project.git # 或者从gitee下载: $ git clone https://gitee.com/mirrors/LLVM.git $ cd llvm | mkidr build && cd build $ cmake ../llvm -G Ninja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON $ ninja ``` ### 获得Antlr4运行时和生成工具 ```bash $ git clone https://github.com/antlr/antlr4.git $ cd antlr4/runtime/Cpp ``` 根据antlr4/runtime/Cpp/readme.md的说明构建antlr4 Runtime antlr4自动生成工具可以从antlr4官网下载,链接:[LINK](https://www.antlr.org/download/antlr-4.12.0-complete.jar) ### 构建plc2llvm ```bash $ cd plc2llvm | mkdir build && cd build # 替换为LLVM构建目录 # 替换为antlr4安装目录 # 替换为antlr4 runtime所在目录 $ cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Debug \ -DLLVM_DIR=/lib/cmake/llvm \ -DANTLR_INCLUDE_DIR=/usr/local/include/antlr4-runtime \ -DANTLR4_RUNTIME=/libantlr4-runtime.a $ ninja ``` ### 运行plc2llvm ```bash $ cd plc2llvm/build/bin # 替换为plc st源文件,如test/test1.plc $ ./plc2llvm ```