diff --git a/k-distribution/tests/regression-new/proof-instrumentation/.gitignore b/k-distribution/tests/regression-new/proof-instrumentation/.gitignore new file mode 100644 index 00000000000..c75c8d9c4ad --- /dev/null +++ b/k-distribution/tests/regression-new/proof-instrumentation/.gitignore @@ -0,0 +1 @@ +out.hint diff --git a/k-distribution/tests/regression-new/proof-instrumentation/Makefile b/k-distribution/tests/regression-new/proof-instrumentation/Makefile new file mode 100644 index 00000000000..ea956049d40 --- /dev/null +++ b/k-distribution/tests/regression-new/proof-instrumentation/Makefile @@ -0,0 +1,22 @@ +DEF=test +KOMPILE_BACKEND=llvm +KOMPILE_FLAGS+=--gen-glr-bison-parser --llvm-proof-hint-instrumentation +LLVM_KRUN_FLAGS=-d ./test-kompiled --proof-hints + +check: out.hint + head -c4 out.hint | diff - <(echo -n 'HINT') + +out.hint: test.kore + rm -f $@ + $(LLVM_KRUN) $(LLVM_KRUN_FLAGS) \ + -c PGM $< Foo korefile -o $@ + +test.kore: test.in kompile + ./test-kompiled/parser_PGM $< > $@ + +include ../../../include/kframework/ktest.mak + +clean: + rm -rf out.hint test.kore $(KOMPILED_DIR) .depend-tmp .depend .kompile-* .krun-* .kprove-* kore-exec.tar.gz + +update-results: CHECK=> test.out diff --git a/k-distribution/tests/regression-new/proof-instrumentation/test.in b/k-distribution/tests/regression-new/proof-instrumentation/test.in new file mode 100644 index 00000000000..eb28ef4401b --- /dev/null +++ b/k-distribution/tests/regression-new/proof-instrumentation/test.in @@ -0,0 +1 @@ +foo() diff --git a/k-distribution/tests/regression-new/proof-instrumentation/test.k b/k-distribution/tests/regression-new/proof-instrumentation/test.k new file mode 100644 index 00000000000..d1ceb04f3d2 --- /dev/null +++ b/k-distribution/tests/regression-new/proof-instrumentation/test.k @@ -0,0 +1,9 @@ +// Copyright (c) K Team. All Rights Reserved. +module TEST-SYNTAX + syntax Foo ::= foo() | bar() +endmodule + +module TEST + imports TEST-SYNTAX + rule foo() => bar() +endmodule diff --git a/llvm-backend/src/main/java/org/kframework/backend/llvm/LLVMBackend.java b/llvm-backend/src/main/java/org/kframework/backend/llvm/LLVMBackend.java index 3d0ad8fa45f..d2dae356c3a 100644 --- a/llvm-backend/src/main/java/org/kframework/backend/llvm/LLVMBackend.java +++ b/llvm-backend/src/main/java/org/kframework/backend/llvm/LLVMBackend.java @@ -124,6 +124,10 @@ private void llvmKompile(String type, String executable) { args.add(files.resolveKompiled("dt").getCanonicalPath()); args.add(type); + if (options.enableProofHints) { + args.add("--proof-hint-instrumentation"); + } + // Arguments after this point are passed on to Clang. args.add("--"); diff --git a/llvm-backend/src/main/java/org/kframework/backend/llvm/LLVMKompileOptions.java b/llvm-backend/src/main/java/org/kframework/backend/llvm/LLVMKompileOptions.java index 5a1ea131b5a..9a7732d2572 100644 --- a/llvm-backend/src/main/java/org/kframework/backend/llvm/LLVMKompileOptions.java +++ b/llvm-backend/src/main/java/org/kframework/backend/llvm/LLVMKompileOptions.java @@ -100,4 +100,10 @@ public List convert(String str) { descriptionKey = "file", hidden = true) public String llvmKompileOutput = null; + + @Parameter( + names = "--llvm-proof-hint-instrumentation", + description = "Emit proof hint instrumentation code into the generated interpreter", + hidden = true) + public boolean enableProofHints; } diff --git a/nix/k.nix b/nix/k.nix index 7adedd785e8..2551f4208fc 100644 --- a/nix/k.nix +++ b/nix/k.nix @@ -1,7 +1,7 @@ { src, maven, mvnHash, manualMvnArtifacts, clang, stdenv, lib, runCommand , makeWrapper, bison, flex, gcc, git, gmp, jdk, jre, jre_minimal, mpfr, ncurses , pkgconfig, python3, z3, haskell-backend, booster, prelude-kore, llvm-backend -, debugger, version, llvm-kompile-libs }: +, debugger, version, llvm-kompile-libs, runtimeShell }: let runtimeInputs = [ @@ -26,6 +26,13 @@ let llvm-backend ] ++ lib.optional (debugger != null) debugger; runtimePath = lib.makeBinPath runtimeInputs; + + which-python = '' + #!${runtimeShell} + echo "${lib.makeBinPath [python3]}/python3" + ''; + + k = current-llvm-kompile-libs: maven.buildMavenPackage rec { pname = "k"; @@ -46,6 +53,9 @@ let installPhase = '' mkdir -p $out/bin-unwrapped mkdir -p $out/bin + echo -n "${which-python}" > $out/bin/k-which-python + chmod +x $out/bin/k-which-python + cp -r k-distribution/target/release/k/bin/* $out/bin-unwrapped/ cp -r k-distribution/target/release/k/{include,lib} $out/