Skip to content
/ T-Lang Public

A Tensor based PL inspired by Toy from MLIR.

Notifications You must be signed in to change notification settings

WLFJ/T-Lang

Repository files navigation

T-Lang

A Tensor based Programing Language.

Build

Usage

How to add Op

How to build

note: due to we need latest bison, so you may need compile from source and add soft link under /usr/bin/bison to make sure cmake find it.

sudo apt install cmake flex ninja-build clang
git clone git@github.com:WLFJ/T-Lang.git
cd T-Lang
git submodule update --init --depth 1
mkdir 3rdparty/llvm-project/build && cd 3rdparty/llvm-project/build
cmake -G Ninja ../llvm \
   -DLLVM_ENABLE_PROJECTS=mlir \
   -DLLVM_BUILD_EXAMPLES=ON \
   -DLLVM_TARGETS_TO_BUILD="X86;NVPTX;AMDGPU" \
   -DCMAKE_BUILD_TYPE=Release \
   -DLLVM_ENABLE_ASSERTIONS=ON \
   -DLLVM_ENABLE_RTTI=true
ninja
cd -
mkdir build && cd build
cmake ..
cmake --build . -j$(nproc)

How to use

  1. compile project.
  2. write your source code saved in test.tc.
  3. run following command:
chmod +x build/tc && ./tcc test.tc && ./a.out

How to write test cases

Coming Soon ...

TO-DO

  • A simple (hello-world example) bison example.
  • A flex.
  • A AST dumper.
  • CMake
  • Migrate build system from GNU make to CMake.
  • Mem safer (avoid useing new directly, instead of unique_ptr?). No, we'll use AST from ToyLang.
  • Simplify yy and ll file. Seems it's already clean yet.
  • Freeze MLIR into 3rdparty, and include it into CMakeLists. (Should we build it automatically ?).
  • Add backend support.
  • Support print in grammar.
  • Add TIR, make them all runnable.
  • Add variable dec like var a = 1;. (partial, id bind in grammar is needed.)
  • Add RTTI support cmd.
  • Dump llvm::Module into file. using JIT instead.
  • Add math calc. (for + *)
  • Add function fully support. (arbitary argument, return value, caller, callee).
  • For now sub function must have return type.
  • Add advanced operator (transpost etc.)
  • grammar confict fix (binop precident).
  • support redundent tensor decl.
  • support none value variable declearation.
  • research how ir generated.
  • add linalg opt layer.
  • writing some ref ;P.
  • Add linalg.generic like expr support. like this:
# a -> [1, 2, 3, 4] then b -> [ [1, 2], [3, 4] ]
# usage: [[ tile(a) ]]
# reshape
lin tile(a<m>) {
  map {a<i> -> <m>, b<j, k> -> <i / k, i % k>}
  (a) {
    a;
  }
} -> b<n, k>
  • support more binop (-, .)
  • FileCheck (LLVM is needed).
  • Automatic Test.(Maybe cmake test).
  • Add remain supported expr.