EdgeLang is a simple language supporting basic varaible creation and arithmetic operations. With its own frontend for parsing, it leverages MLIR to lower IR from the Edge dialect down to LLVM IR for JIT compilation.
System Requirements:
- LLVM/Clang with MLIR
- Linux (Currently uses linux sys calls for fast file reads)
- CMake 3.22 or higher
git clone https://github.com/bradenhelmer/EdgeLang.git
cd EdgeLang
mkdir build
cd build
cmake ../
make
This will build an edge
binary in the build directory.
The EdgeSyntax is very simple.
- You can create variables holding integer values:
var = 10
- Create a varaible with an expression and then reference created variable:
var = 10 + 20 var_1 = var * 3
- Output an expression:
var = 10 output var
- Supported operators: + - * \
A = 4 * 3
B = A * 5
C = A + B
output C
Run with:
edge <program_file>
Output:
Initializing Lexer...
Initializing Parser...
Initializing MLIR Generator...
Executing test_file.edge
Result: 72
-
You may specify a compilation strategy with the
-cs
option:mlir
(default): Edge code -> Edge/Func Dialects -> Arith/Func/Memref Dialects -> LLVM Dialect -> JIT compiled with MLIR execution engine.llvm
: Edge code -> LLVM IR -> JIT Compiled with LLVM LLJITNative
: Edge code -> LLVM IR -> SelectionDAG-based Instruction Selection -> Register Allocation -> X86-64 Assembly -> ELF Binary
All strategies utilize the same frontend methods.
Example:
edge -cs llvm <program>
-
If you would like to output an IR or assmbly file, use the
-emit
option. This option takes no parameters but the IR file produced is based on the chosen compilation strategy:mlir
will produce one file containing three sperate modules corresponding to each stage of the lowering process:llvm
will produce an LLVM IR file.native
will produce an X86-64 Assembly file.