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.
We are currently working on supporting Clang IR subset of LLVM IR, which is much easier to implement in Minecraft.
Terminator Instructions
-
retInstruction -
brInstruction -
switchInstruction -
indirectbrInstruction -
invokeInstruction -
callbrInstruction -
resumeInstruction -
catchswitchInstruction (won't implement) -
catchretInstruction (won't implement) -
cleanupretInstruction (won't implement) -
unreachableInstruction (won't implement)
Unary Operations
-
fnegInstruction
Binary Operations
-
addInstruction -
faddInstruction -
subInstruction -
fsubInstruction -
mulInstruction -
fmulInstruction -
udivInstruction -
sdivInstruction -
fdivInstruction -
uremInstruction -
sremInstruction -
fremInstruction
Bitwise Binary Operations
-
shlInstruction -
lshrInstruction -
ashrInstruction -
andInstruction -
orInstruction -
xorInstruction
Vector Operations
-
extractelementInstruction -
insertelementInstruction -
shufflevectorInstruction
Aggregate Operations
-
extractvalueInstruction -
insertvalueInstruction
Memory Access and Addressing Operations
-
allocaInstruction -
loadInstruction (Clang IR subset) -
storeInstruction (Clang IR subset) -
fenceInstruction (won't implement) -
cmpxchgInstruction -
atomicrmwInstruction -
getelementptrInstruction
Conversion Operations
-
trunc .. toInstruction -
zext .. toInstruction -
sext .. toInstruction -
fptrunc .. toInstruction -
fpext .. toInstruction -
fptoui .. toInstruction -
fptosi .. toInstruction -
uitofp .. toInstruction -
sitofp .. toInstruction -
ptrtoint .. toInstruction -
ptrtoaddr .. toInstruction -
inttoptr .. toInstruction -
bitcast .. toInstruction -
addrspacecast .. toInstruction
Other Operations
-
icmpInstruction -
fcmpInstruction -
phiInstruction -
selectInstruction -
freezeInstruction -
callInstruction -
va_argInstruction -
landingpadInstruction (won't implement) -
catchpadInstruction (won't implement) -
cleanuppadInstruction (won't implement)
- 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.bcto compile your code when you are using c++.