mirror of
https://github.com/engineer-man/piston.git
synced 2025-04-22 21:16:29 +02:00
add piston nix pkg for llvm_ir
This commit is contained in:
parent
560b4ac1ee
commit
daeed0ce5e
8 changed files with 48 additions and 31 deletions
|
@ -61,4 +61,5 @@ args: {
|
|||
"brainfuck" = import ./brainfuck.nix args;
|
||||
"node-coffeescript" = import ./node-coffeescript.nix args;
|
||||
"jvm-scala" = import ./jvm-scala.nix args;
|
||||
"llvm_ir" = import ./llvm_ir.nix args;
|
||||
}
|
||||
|
|
47
runtimes/llvm_ir.nix
Normal file
47
runtimes/llvm_ir.nix
Normal file
|
@ -0,0 +1,47 @@
|
|||
{pkgs, piston, ...}:
|
||||
let
|
||||
pkg = pkgs.llvm;
|
||||
clang = pkgs.llvmPackages_13.libcxxClang;
|
||||
in piston.mkRuntime {
|
||||
language = "llvm_ir";
|
||||
version = clang.version;
|
||||
|
||||
aliases = [
|
||||
"llvm"
|
||||
"llvm-ir"
|
||||
"ll"
|
||||
];
|
||||
|
||||
compile = ''
|
||||
${pkg}/bin/llc "$@" -o binary.s
|
||||
${clang}/bin/clang binary.s -o binary
|
||||
'';
|
||||
|
||||
run = ''
|
||||
shift
|
||||
./binary "$@"
|
||||
'';
|
||||
|
||||
tests = [
|
||||
(piston.mkTest {
|
||||
files = {
|
||||
"test.ll" = ''
|
||||
@.str = private unnamed_addr constant [2 x i8] c"OK"
|
||||
|
||||
declare i32 @puts(i8* nocapture) nounwind
|
||||
|
||||
define i32 @main() {
|
||||
%cast210 = getelementptr [2 x i8],[2 x i8]* @.str, i64 0, i64 0
|
||||
|
||||
call i32 @puts(i8* %cast210)
|
||||
ret i32 0
|
||||
}
|
||||
'';
|
||||
};
|
||||
args = [];
|
||||
stdin = "";
|
||||
packages = [];
|
||||
main = "test.ll";
|
||||
})
|
||||
];
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue