Skip to content

remysys/llvm-riscv-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

71 Commits
 
 
 
 
 
 
 
 

Repository files navigation

llvm-riscv-backend

learn LLVM by creating a RISC-V backend step by step

build

build rrisc-v target, ensuring LLVM_TARGETS_TO_BUILD includes RRISCV

cd llvm-project/
cmake -G "Unix Makefiles" -S llvm -B build -DLLVM_ENABLE_PROJECTS="clang" -DLLVM_TARGETS_TO_BUILD="X86;RRISCV;RISCV" -DCMAKE_BUILD_TYPE="Release" -DLLVM_ENABLE_ASSERTIONS=On
cd build && make -j$(nproc)

check rrisc-v target build success, a new rriscv backend will be available

./bin/llc --version
Registered Targets:
    ...
    rriscv  - Remy's RISC-V backend

run examples

run test examples on the rrisc-v target. compiling test examples to LLVM BitCode and IR

./bin/clang ../../test/test.c -c -emit-llvm -O0 -o test.bc
./bin/llvm-dis test.bc
cat test.ll

run IR with llc using the rrisc-v target

./bin/llc test.bc -march=rriscv

view more runtime information:

./bin/llc test.ll -march=rriscv --debug
./bin/llc test.ll -march=rriscv --debug -o -

About

learn LLVM by creating a RISC-V backend step by step

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published