@fraczak/k 7.0.1 → 7.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +78 -0
- package/DOCS/BIG_PICTURE.md +5 -5
- package/DOCS/FILE_FORMATS.md +241 -18
- package/DOCS/OBJECT_FILE_AND_PATTERN.md +9 -9
- package/DOCS/PATTERNS.md +3 -3
- package/DOCS/POLYMORPHIC_IR.md +104 -0
- package/DOCS/PROFILING_AND_TRACING.md +60 -72
- package/DOCS/REPL.md +3 -3
- package/DOCS/book/03-types-as-finite-automata.md +4 -4
- package/DOCS/book/06-values-in-memory.md +9 -9
- package/DOCS/book/08-operational-semantics-and-execution.md +1 -1
- package/DOCS/book/09-compiler-architecture.md +2 -2
- package/DOCS/book/10-from-ast-to-intermediate-representation.md +2 -2
- package/DOCS/book/14-canonical-serialization.md +1 -1
- package/Examples/arithmetics.k +2 -2
- package/Examples/bnat.k +1 -1
- package/Examples/karatsuba-mult.k +2 -2
- package/JOURNAL.md +288 -0
- package/README.md +13 -10
- package/access-table.mjs +343 -0
- package/backend-api.mjs +18 -0
- package/backends/llvm/README.md +20 -21
- package/backends/llvm/bin/k-llvm-build.mjs +105 -32
- package/backends/llvm/bin/k-llvm-compile.mjs +63 -24
- package/backends/llvm/bin/k-llvm.mjs +292 -0
- package/backends/llvm/runtime/krt.c +41 -0
- package/backends/llvm/runtime/krt.h +2 -0
- package/backends/llvm/src/cli.mjs +95 -17
- package/backends/llvm/src/executable.mjs +132 -15
- package/backends/llvm/src/kvm2llvm.mjs +50 -23
- package/backends/llvm/src/llvm.mjs +133 -20
- package/backends/llvm/tests/integration.sh +11 -11
- package/backends/llvm/{bin → tests}/k-llvm-run.mjs +48 -22
- package/backends/llvm/tests/perf-support.mjs +25 -58
- package/backends/llvm/tests/test-llvm.mjs +25 -4
- package/backends/wasm/bin/k-wasm-compile.mjs +46 -20
- package/backends/wasm/bin/k-wasm-run.mjs +61 -20
- package/backends/wasm/bin/k-wasm.mjs +47 -13
- package/backends/wasm/src/cli.mjs +141 -19
- package/backends/wasm/src/wasm.mjs +132 -24
- package/backends/wasm/tests/test-wasm.mjs +5 -5
- package/browser/repl-browser.mjs +16 -5
- package/browser/vfs-data.mjs +5 -5
- package/codecs/k-parse.mjs +29 -8
- package/codecs/k-print.mjs +22 -6
- package/codecs/runtime/codec-sdk.mjs +8 -4
- package/codecs/show.mjs +20 -6
- package/core.k +8 -8
- package/harness/format.mjs +2 -2
- package/harness/registry.mjs +0 -2
- package/k.mjs +56 -16
- package/kir.mjs +200 -75
- package/kvm.mjs +49 -12
- package/objects/compile.mjs +37 -23
- package/objects/decompile.mjs +40 -10
- package/objects/extract-aliases.mjs +44 -14
- package/objects/inspect.mjs +19 -14
- package/objects/validate.mjs +18 -11
- package/package.json +10 -7
- package/pkir.mjs +772 -0
- package/repl.mjs +36 -18
- package/scripts/benchmark-idempotency.mjs +12 -8
- package/scripts/benchmark.mjs +5 -9
- package/scripts/build-repl-html.mjs +16 -4
- package/scripts/perf-ieee.mjs +253 -103
- package/scripts/perf-int.mjs +585 -297
- package/scripts/perf-multiplication.mjs +66 -25
- package/scripts/perf-poly.mjs +292 -164
- package/scripts/run-tests.mjs +3 -0
- package/tests/code-derivation/pattern-envelope.mjs +4 -4
- package/tests/test-access-table.mjs +213 -0
- package/tests/test-kvm-polymorphic.mjs +2 -2
- package/tests/test-pkir.mjs +530 -0
- package/tests/test-polymorphic-tdd.mjs +196 -0
- package/tests/test-repl-html.mjs +15 -2
- package/tests/test-repl.mjs +30 -1
- package/backends/arm64/README.md +0 -103
- package/backends/arm64/bin/k-arm64-compile.mjs +0 -93
- package/backends/arm64/bin/k-arm64-run.mjs +0 -58
- package/backends/arm64/bin/k-arm64.mjs +0 -88
- package/backends/arm64/scripts/run-tests.mjs +0 -57
- package/backends/arm64/src/arm64.mjs +0 -229
- package/backends/arm64/src/cli.mjs +0 -155
- package/backends/arm64/src/kvm2arm64.mjs +0 -906
- package/backends/arm64/src/runtime.c +0 -744
- package/backends/arm64/tests/integration.sh +0 -112
- package/backends/arm64/tests/test-arm64.mjs +0 -240
- package/backends/llvm/bin/k-llvm-jit.mjs +0 -160
- package/harness/adapters/arm64.mjs +0 -105
package/backend-api.mjs
CHANGED
|
@@ -27,3 +27,21 @@ export {
|
|
|
27
27
|
isIdentityIntrinsic,
|
|
28
28
|
unsupportedIntrinsic
|
|
29
29
|
} from "./intrinsics.mjs";
|
|
30
|
+
export { buildAccessTable, AccessTable } from "./access-table.mjs";
|
|
31
|
+
export {
|
|
32
|
+
PKIR_FORMAT,
|
|
33
|
+
PKIR_VERSION,
|
|
34
|
+
compileRelationToPKIR,
|
|
35
|
+
executePKIR,
|
|
36
|
+
specializePKIR,
|
|
37
|
+
valueToKVal,
|
|
38
|
+
kvalToValue,
|
|
39
|
+
lowerPKIRToKVM
|
|
40
|
+
} from "./pkir.mjs";
|
|
41
|
+
export {
|
|
42
|
+
compileWasmArtifactFromPKIR
|
|
43
|
+
} from "./backends/wasm/src/wasm.mjs";
|
|
44
|
+
export {
|
|
45
|
+
compileLLVMArtifactFromPKIR
|
|
46
|
+
} from "./backends/llvm/src/llvm.mjs";
|
|
47
|
+
|
package/backends/llvm/README.md
CHANGED
|
@@ -46,34 +46,33 @@ status in `k_result`. These operations can compose through KIR `comp`.
|
|
|
46
46
|
```sh
|
|
47
47
|
k-llvm-build [options] [source-snippet | input-file [output-exe]]
|
|
48
48
|
k-llvm-compile [options] [source-snippet | input-file [output.ll]]
|
|
49
|
-
k-llvm
|
|
50
|
-
k-llvm-run [options] object.ko [input.kv]
|
|
49
|
+
k-llvm [options] ( source-snippet | input-file ) [ input-wire-file ]
|
|
51
50
|
```
|
|
52
51
|
|
|
53
52
|
Options:
|
|
54
53
|
|
|
55
54
|
- `-o, --output path`: specify output file path explicitly.
|
|
56
55
|
- `--lib file`: load one `.klib` or `.k` dependency before compiling.
|
|
57
|
-
- `--export spec`: export a library alias into
|
|
58
|
-
- `--
|
|
59
|
-
- `--retype rel`:
|
|
60
|
-
- `--
|
|
61
|
-
- `-h
|
|
62
|
-
|
|
63
|
-
The compile commands follow the unified k CLI input convention: pass
|
|
64
|
-
source, an existing `.k` source file, or a `.ko`/`.klib` object.
|
|
65
|
-
source from stdin when input is omitted. Output paths can be
|
|
66
|
-
positional argument or explicitly with `-o, --output`.
|
|
67
|
-
Without `--expect`, `k-llvm-run` prints the result value as compact JSON.
|
|
56
|
+
- `--export spec`: export a library alias into scope. Repeatable.
|
|
57
|
+
- `--pkir`: lower via Polymorphic K IR (PKIR).
|
|
58
|
+
- `--retype rel`: relation to specialize (defaults to object main).
|
|
59
|
+
- `--opt flag`: Clang optimization flag (-O0, -O1, -O2, -O3).
|
|
60
|
+
- `-h, --help`: show usage.
|
|
61
|
+
|
|
62
|
+
The compile commands follow the unified k CLI input convention: pass
|
|
63
|
+
inline source, an existing `.k` source file, or a `.ko`/`.klib` object.
|
|
64
|
+
Reads UTF-8 source from stdin when input is omitted. Output paths can be
|
|
65
|
+
specified as a positional argument or explicitly with `-o, --output`.
|
|
68
66
|
`k-llvm-build` emits a native executable that reads and writes the binary
|
|
69
|
-
k pattern+value envelope used by `codecs/k-parse.mjs` and
|
|
70
|
-
The executable checks the stdin envelope pattern
|
|
71
|
-
pattern and encodes stdout with the compiled
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
67
|
+
k pattern+value envelope used by `codecs/k-parse.mjs` and
|
|
68
|
+
`codecs/k-print.mjs`. The executable checks the stdin envelope pattern
|
|
69
|
+
against the compiled input pattern and encodes stdout with the compiled
|
|
70
|
+
output pattern.
|
|
71
|
+
`k-llvm` reads the binary wire envelope, specializes the relation to
|
|
72
|
+
that input pattern, caches the compiled native executable, and writes
|
|
73
|
+
the compiled output envelope to stdout.
|
|
74
|
+
The native envelope codec supports the k Unicode string encoding used
|
|
75
|
+
for labels and tags.
|
|
77
76
|
|
|
78
77
|
## Tests
|
|
79
78
|
|
|
@@ -9,35 +9,61 @@ import {
|
|
|
9
9
|
} from "../src/cli.mjs";
|
|
10
10
|
import {
|
|
11
11
|
compileKVMToExecutable,
|
|
12
|
-
compileObjectToExecutable
|
|
12
|
+
compileObjectToExecutable,
|
|
13
|
+
compilePKIRToExecutable
|
|
13
14
|
} from "../src/executable.mjs";
|
|
14
15
|
|
|
15
|
-
function
|
|
16
|
+
function helpText() {
|
|
16
17
|
const prog = argv[1] || "k-llvm-build.mjs";
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
18
|
+
return [
|
|
19
|
+
"Compile k source, .ko, .klib, .kvm, or .pkir into a native",
|
|
20
|
+
"standalone executable.",
|
|
21
|
+
"",
|
|
22
|
+
`Usage: ${prog} [options]`,
|
|
23
|
+
" [source-snippet | input-file [output-exe]]",
|
|
24
|
+
"",
|
|
25
|
+
"Arguments:",
|
|
26
|
+
" source-snippet Inline k source snippet (in the style of k.mjs).",
|
|
27
|
+
" input-file Source .k, .ko, .klib, .kvm, or .pkir file.",
|
|
28
|
+
" Reads UTF-8 source from stdin when omitted.",
|
|
29
|
+
" output-exe Output executable path.",
|
|
30
|
+
"",
|
|
31
|
+
"The executable reads a binary k pattern+value envelope from stdin",
|
|
32
|
+
"and writes a binary k pattern+value envelope to stdout.",
|
|
33
|
+
"The stdin envelope pattern must match the compiled input pattern;",
|
|
34
|
+
"stdout is encoded with the compiled output pattern.",
|
|
35
|
+
"",
|
|
36
|
+
"Options:",
|
|
37
|
+
" -o, --output path Specify output file path explicitly.",
|
|
38
|
+
" --pkir Lower via Polymorphic K IR (PKIR).",
|
|
39
|
+
" --input-pattern pattern Input pattern JSON or file for spec.",
|
|
40
|
+
" --retype rel Relation to specialize (default: main).",
|
|
41
|
+
" --lib file Load .klib or .k library before build.",
|
|
42
|
+
" --export spec Export library alias into scope. Repeatable.",
|
|
43
|
+
" spec is 'name' or 'libname:localname'.",
|
|
44
|
+
" --opt flag Clang optimization flag (default: -O3).",
|
|
45
|
+
" -h, --help Show this help.",
|
|
46
|
+
"",
|
|
47
|
+
"Environment Variables:",
|
|
48
|
+
" CLANG, CC Path to Clang compiler (default: clang).",
|
|
49
|
+
" K_LLVM_CLANG_OPT Clang optimization flag (default: -O3).",
|
|
50
|
+
" K_LLVM_RUNTIME_MODE Runtime mode: fast, compact (default: fast).",
|
|
51
|
+
"",
|
|
52
|
+
"Examples:",
|
|
53
|
+
` ${prog} 'x = |x; x x' -o program.exe`,
|
|
54
|
+
` ${prog} program.k program.exe`,
|
|
55
|
+
` ${prog} --lib Examples/poly.k --export concat 's' -o s.exe`
|
|
56
|
+
].join("\n");
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function usage(stream = console.error) {
|
|
60
|
+
stream(helpText());
|
|
37
61
|
}
|
|
38
62
|
|
|
39
63
|
function readMaybeFile(textOrPath) {
|
|
40
|
-
return fs.existsSync(textOrPath)
|
|
64
|
+
return fs.existsSync(textOrPath)
|
|
65
|
+
? fs.readFileSync(textOrPath, "utf8")
|
|
66
|
+
: textOrPath;
|
|
41
67
|
}
|
|
42
68
|
|
|
43
69
|
function readPattern(inputPattern) {
|
|
@@ -54,17 +80,38 @@ try {
|
|
|
54
80
|
|
|
55
81
|
let explicitOutput = null;
|
|
56
82
|
let rawInputPattern = null;
|
|
83
|
+
let relation = null;
|
|
84
|
+
let clangOpt = process.env.K_LLVM_CLANG_OPT || "-O3";
|
|
85
|
+
let runtimeMode = process.env.K_LLVM_RUNTIME_MODE || "fast";
|
|
57
86
|
const remainingArgs = [];
|
|
58
87
|
while (args.length > 0) {
|
|
59
88
|
const arg = args[0];
|
|
60
89
|
if (arg === "-o" || arg === "--output") {
|
|
61
90
|
args.shift();
|
|
62
91
|
explicitOutput = args.shift();
|
|
63
|
-
if (!explicitOutput)
|
|
92
|
+
if (!explicitOutput) {
|
|
93
|
+
throw new Error("-o/--output requires a file argument");
|
|
94
|
+
}
|
|
64
95
|
} else if (arg === "--input-pattern") {
|
|
65
96
|
args.shift();
|
|
66
97
|
rawInputPattern = args.shift();
|
|
67
|
-
if (!rawInputPattern)
|
|
98
|
+
if (!rawInputPattern) {
|
|
99
|
+
throw new Error(
|
|
100
|
+
"--input-pattern requires a JSON or file argument"
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
} else if (arg === "--retype") {
|
|
104
|
+
args.shift();
|
|
105
|
+
relation = args.shift();
|
|
106
|
+
if (!relation) {
|
|
107
|
+
throw new Error("--retype requires a relation name");
|
|
108
|
+
}
|
|
109
|
+
} else if (arg === "--opt") {
|
|
110
|
+
args.shift();
|
|
111
|
+
clangOpt = args.shift();
|
|
112
|
+
if (!clangOpt) {
|
|
113
|
+
throw new Error("--opt requires a flag (e.g. -O3)");
|
|
114
|
+
}
|
|
68
115
|
} else {
|
|
69
116
|
remainingArgs.push(args.shift());
|
|
70
117
|
}
|
|
@@ -72,17 +119,38 @@ try {
|
|
|
72
119
|
|
|
73
120
|
const inputPattern = readPattern(rawInputPattern);
|
|
74
121
|
|
|
75
|
-
const { libraries, exportSpecs } =
|
|
76
|
-
|
|
122
|
+
const { libraries, exportSpecs, usePKIR } =
|
|
123
|
+
parseCompileOptions(remainingArgs);
|
|
124
|
+
const input = resolveProgramInput(remainingArgs, {
|
|
125
|
+
allowStdinSource: true
|
|
126
|
+
});
|
|
77
127
|
const positionalOutput = remainingArgs.shift();
|
|
78
128
|
if (remainingArgs.length > 0) throw new Error("Too many arguments");
|
|
79
129
|
|
|
80
130
|
const outputPath = explicitOutput || positionalOutput || null;
|
|
81
|
-
if (outputPath == null)
|
|
131
|
+
if (outputPath == null) {
|
|
132
|
+
throw new Error(
|
|
133
|
+
"Output executable path required (pass output-exe or -o/--output)"
|
|
134
|
+
);
|
|
135
|
+
}
|
|
82
136
|
|
|
83
|
-
if (input.kind === "
|
|
137
|
+
if (input.kind === "pkir") {
|
|
138
|
+
const pkir = JSON.parse(fs.readFileSync(input.path, "utf8"));
|
|
139
|
+
compilePKIRToExecutable(pkir, outputPath, {
|
|
140
|
+
entry: relation,
|
|
141
|
+
inputPattern,
|
|
142
|
+
clangOpt,
|
|
143
|
+
runtimeMode
|
|
144
|
+
});
|
|
145
|
+
} else if (input.kind === "kvm") {
|
|
84
146
|
const kvm = JSON.parse(fs.readFileSync(input.path, "utf8"));
|
|
85
|
-
compileKVMToExecutable(kvm, outputPath, {
|
|
147
|
+
compileKVMToExecutable(kvm, outputPath, {
|
|
148
|
+
entry: relation,
|
|
149
|
+
inputPattern,
|
|
150
|
+
clangOpt,
|
|
151
|
+
runtimeMode,
|
|
152
|
+
usePKIR
|
|
153
|
+
});
|
|
86
154
|
} else {
|
|
87
155
|
const object = await compileProgramInputToObject(input, {
|
|
88
156
|
libraries,
|
|
@@ -90,10 +158,15 @@ try {
|
|
|
90
158
|
stdin
|
|
91
159
|
});
|
|
92
160
|
|
|
93
|
-
compileObjectToExecutable(object, outputPath, {
|
|
161
|
+
compileObjectToExecutable(object, outputPath, {
|
|
162
|
+
relation: relation || object.main,
|
|
163
|
+
inputPattern,
|
|
164
|
+
clangOpt,
|
|
165
|
+
runtimeMode,
|
|
166
|
+
usePKIR
|
|
167
|
+
});
|
|
94
168
|
}
|
|
95
169
|
} catch (error) {
|
|
96
170
|
console.error(error.stack || error.message || String(error));
|
|
97
|
-
usage();
|
|
98
171
|
exit(1);
|
|
99
172
|
}
|
|
@@ -9,26 +9,44 @@ import {
|
|
|
9
9
|
} from "../src/cli.mjs";
|
|
10
10
|
import {
|
|
11
11
|
compileObjectToLLVM,
|
|
12
|
-
compileLLVMArtifactFromKVM
|
|
12
|
+
compileLLVMArtifactFromKVM,
|
|
13
|
+
compileLLVMArtifactFromPKIR
|
|
13
14
|
} from "../src/llvm.mjs";
|
|
14
15
|
import { inputPatternForObjectRelation } from "../src/executable.mjs";
|
|
15
16
|
|
|
16
|
-
function
|
|
17
|
+
function helpText() {
|
|
17
18
|
const prog = argv[1] || "k-llvm-compile.mjs";
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
19
|
+
return [
|
|
20
|
+
"Compile a k .ko/.klib object, source, .kvm, or .pkir into LLVM IR.",
|
|
21
|
+
"",
|
|
22
|
+
`Usage: ${prog} [options]`,
|
|
23
|
+
" [source-snippet | input-file [output.ll]]",
|
|
24
|
+
"",
|
|
25
|
+
"Arguments:",
|
|
26
|
+
" source-snippet Inline k source snippet (in the style of k.mjs).",
|
|
27
|
+
" input-file Source .k, .ko, .klib, .kvm, or .pkir file.",
|
|
28
|
+
" Reads UTF-8 source from stdin when omitted.",
|
|
29
|
+
" output.ll Output LLVM IR path (default: stdout).",
|
|
30
|
+
"",
|
|
31
|
+
"Options:",
|
|
32
|
+
" -o, --output path Specify output file path explicitly.",
|
|
33
|
+
" --pkir Lower via Polymorphic K IR (PKIR).",
|
|
34
|
+
" --retype rel Relation to compile (default: object main).",
|
|
35
|
+
" --lib file Load one .klib or .k library before compiling.",
|
|
36
|
+
" --export spec Export library alias into scope. Repeatable.",
|
|
37
|
+
" spec is 'name' or 'libname:localname'.",
|
|
38
|
+
" -h, --help Show this help.",
|
|
39
|
+
"",
|
|
40
|
+
"Examples:",
|
|
41
|
+
` ${prog} 'x = |x; x x' program.ll`,
|
|
42
|
+
` ${prog} program.k -o program.ll`,
|
|
43
|
+
` ${prog} --pkir program.k -o program.ll`,
|
|
44
|
+
` ${prog} --lib core.klib --export add program.k program.ll`
|
|
45
|
+
].join("\n");
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function usage(stream = console.error) {
|
|
49
|
+
stream(helpText());
|
|
32
50
|
}
|
|
33
51
|
|
|
34
52
|
try {
|
|
@@ -39,29 +57,49 @@ try {
|
|
|
39
57
|
}
|
|
40
58
|
|
|
41
59
|
let explicitOutput = null;
|
|
60
|
+
let relation = null;
|
|
42
61
|
const remainingArgs = [];
|
|
43
62
|
while (args.length > 0) {
|
|
44
63
|
const arg = args[0];
|
|
45
64
|
if (arg === "-o" || arg === "--output") {
|
|
46
65
|
args.shift();
|
|
47
66
|
explicitOutput = args.shift();
|
|
48
|
-
if (!explicitOutput)
|
|
67
|
+
if (!explicitOutput) {
|
|
68
|
+
throw new Error("-o/--output requires a file argument");
|
|
69
|
+
}
|
|
70
|
+
} else if (arg === "--retype") {
|
|
71
|
+
args.shift();
|
|
72
|
+
relation = args.shift();
|
|
73
|
+
if (!relation) {
|
|
74
|
+
throw new Error("--retype requires a relation name");
|
|
75
|
+
}
|
|
49
76
|
} else {
|
|
50
77
|
remainingArgs.push(args.shift());
|
|
51
78
|
}
|
|
52
79
|
}
|
|
53
80
|
|
|
54
|
-
const { libraries, exportSpecs } =
|
|
55
|
-
|
|
81
|
+
const { libraries, exportSpecs, usePKIR } =
|
|
82
|
+
parseCompileOptions(remainingArgs);
|
|
83
|
+
const input = resolveProgramInput(remainingArgs, {
|
|
84
|
+
allowStdinSource: true
|
|
85
|
+
});
|
|
56
86
|
const positionalOutput = remainingArgs.shift();
|
|
57
87
|
if (remainingArgs.length > 0) throw new Error("Too many arguments");
|
|
58
88
|
|
|
59
89
|
const outputPath = explicitOutput || positionalOutput || null;
|
|
60
90
|
|
|
61
91
|
let llvm;
|
|
62
|
-
if (input.kind === "
|
|
92
|
+
if (input.kind === "pkir") {
|
|
93
|
+
const pkir = JSON.parse(fs.readFileSync(input.path, "utf8"));
|
|
94
|
+
const entry = relation || pkir.entry || pkir.name || "__main__";
|
|
95
|
+
llvm = compileLLVMArtifactFromPKIR(pkir, {
|
|
96
|
+
relation: entry,
|
|
97
|
+
inputPattern: pkir.inputPattern,
|
|
98
|
+
outputPattern: pkir.outputPattern
|
|
99
|
+
});
|
|
100
|
+
} else if (input.kind === "kvm") {
|
|
63
101
|
const kvm = JSON.parse(fs.readFileSync(input.path, "utf8"));
|
|
64
|
-
const entry = kvm.entry || kvm.relation || "__main__";
|
|
102
|
+
const entry = relation || kvm.entry || kvm.relation || "__main__";
|
|
65
103
|
const mainFunc = kvm.functions?.[entry];
|
|
66
104
|
const artifact = compileLLVMArtifactFromKVM(kvm, {
|
|
67
105
|
relation: entry,
|
|
@@ -76,9 +114,11 @@ try {
|
|
|
76
114
|
stdin
|
|
77
115
|
});
|
|
78
116
|
|
|
117
|
+
const targetRel = relation || object.main;
|
|
79
118
|
const res = compileObjectToLLVM(object, {
|
|
80
|
-
relation:
|
|
81
|
-
inputPattern: inputPatternForObjectRelation(object,
|
|
119
|
+
relation: targetRel,
|
|
120
|
+
inputPattern: inputPatternForObjectRelation(object, targetRel),
|
|
121
|
+
usePKIR
|
|
82
122
|
});
|
|
83
123
|
llvm = res.llvm;
|
|
84
124
|
}
|
|
@@ -90,6 +130,5 @@ try {
|
|
|
90
130
|
}
|
|
91
131
|
} catch (error) {
|
|
92
132
|
console.error(error.stack || error.message || String(error));
|
|
93
|
-
usage();
|
|
94
133
|
exit(1);
|
|
95
134
|
}
|