diff options
| author | Michael Williamson <mike@zwobble.org> | 2026-03-29 09:40:06 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2026-03-29 09:40:06 +0100 |
| commit | 957410553cb0ebdcfb00b933f893735be3c7e681 (patch) | |
| tree | b0d8a251fac48f1e29f4c38756c4409d25a525ce /src/main/java | |
| parent | 05bd9a969a89c070d683928727fece4ab9eaa490 (diff) | |
Load target ISA in patio-to-cranelift
Diffstat (limited to 'src/main/java')
| -rw-r--r-- | src/main/java/org/shedlang/compiler/backends/cranelift/CraneliftBackend.java | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/main/java/org/shedlang/compiler/backends/cranelift/CraneliftBackend.java b/src/main/java/org/shedlang/compiler/backends/cranelift/CraneliftBackend.java index 97d0a156..d66f9a92 100644 --- a/src/main/java/org/shedlang/compiler/backends/cranelift/CraneliftBackend.java +++ b/src/main/java/org/shedlang/compiler/backends/cranelift/CraneliftBackend.java @@ -18,7 +18,19 @@ import java.util.List; import static org.shedlang.compiler.util.processes.ProcessRunner.runInheritIo; public class CraneliftBackend { - public static Path compileCompilationUnit( + public static final CraneliftBackend AMD64 = forTarget(LlvmTarget.AMD64); + + public static CraneliftBackend forTarget(LlvmTarget target) { + return new CraneliftBackend(target); + } + + private final LlvmTarget target; + + private CraneliftBackend(LlvmTarget target) { + this.target = target; + } + + public Path compileCompilationUnit( PatioCompilationUnit patio, PartialTargetPath partialTargetPath ) throws IOException, InterruptedException { @@ -32,19 +44,21 @@ public class CraneliftBackend { runInheritIo(List.of( ShedCompilerFiles.getRoot().resolve("patio-to-cranelift/target/debug/patio-to-cranelift").toString(), - patioPath.toString() + patioPath.toString(), + "--target", + this.target.targetTriple() )); var objectFilePath = partialTargetPath.withExtension(".o"); return objectFilePath; } - public static void link( + public void link( List<Path> inputs, Path outputPath, ShedRuntime shedRuntime ) throws ProcessError, InterruptedException { // TODO: extract linking if it's not specific to LLVM. - LlvmBackend.forTarget(LlvmTarget.AMD64).link(inputs, outputPath, shedRuntime); + LlvmBackend.forTarget(this.target).link(inputs, outputPath, shedRuntime); } } |
