Skip to content

LittleSwift/llvm2mc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

llvm2mc

Instruction Coverage Command Coverage

llvm2mc is a project that compiles LLVM IR into a Minecraft datapack. It translates LLVM instructions into Minecraft functions, enabling you to run LLVM-based programs inside Minecraft.

Development Status

We are currently working on supporting Clang IR subset of LLVM IR, which is much easier to implement in Minecraft.

Supported Instructions

Terminator Instructions
  • ret Instruction
  • br Instruction
  • switch Instruction
  • indirectbr Instruction
  • invoke Instruction
  • callbr Instruction
  • resume Instruction
  • catchswitch Instruction (won't implement)
  • catchret Instruction (won't implement)
  • cleanupret Instruction (won't implement)
  • unreachable Instruction (won't implement)
Unary Operations
  • fneg Instruction
Binary Operations
  • add Instruction
  • fadd Instruction
  • sub Instruction
  • fsub Instruction
  • mul Instruction
  • fmul Instruction
  • udiv Instruction
  • sdiv Instruction
  • fdiv Instruction
  • urem Instruction
  • srem Instruction
  • frem Instruction
Bitwise Binary Operations
  • shl Instruction
  • lshr Instruction
  • ashr Instruction
  • and Instruction
  • or Instruction
  • xor Instruction
Vector Operations
  • extractelement Instruction
  • insertelement Instruction
  • shufflevector Instruction
Aggregate Operations
  • extractvalue Instruction
  • insertvalue Instruction
Memory Access and Addressing Operations
  • alloca Instruction
  • load Instruction (Clang IR subset)
  • store Instruction (Clang IR subset)
  • fence Instruction (won't implement)
  • cmpxchg Instruction
  • atomicrmw Instruction
  • getelementptr Instruction
Conversion Operations
  • trunc .. to Instruction
  • zext .. to Instruction
  • sext .. to Instruction
  • fptrunc .. to Instruction
  • fpext .. to Instruction
  • fptoui .. to Instruction
  • fptosi .. to Instruction
  • uitofp .. to Instruction
  • sitofp .. to Instruction
  • ptrtoint .. to Instruction
  • ptrtoaddr .. to Instruction
  • inttoptr .. to Instruction
  • bitcast .. to Instruction
  • addrspacecast .. to Instruction
Other Operations
  • icmp Instruction
  • fcmp Instruction
  • phi Instruction
  • select Instruction
  • freeze Instruction
  • call Instruction
  • va_arg Instruction
  • landingpad Instruction (won't implement)
  • catchpad Instruction (won't implement)
  • cleanuppad Instruction (won't implement)

Tips

  • Please note that llvm2mc only supports LLVM libc++ at 32 bit. This means you should not compile any code using MSVC STL or gcc libstdc++.
  • All Minecraft native functions can be imported from llvm2mc/mcfunc.h.
  • We suggest using clang -c -emit-llvm -Xclang -disable-llvm-passes -O0 -target i386-pc-linux-gnu -std=c++20 -fno-exceptions -fno-rtti foo.cpp -o foo.bc to compile your code when you are using c++.

About

A compilor that compiles llvm to Minecraft datapack

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published