diff options
| author | Michael Williamson <mike@zwobble.org> | 2026-03-28 09:29:49 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2026-03-28 09:29:49 +0000 |
| commit | 17c745e977dbe696d3293b363d0aa36cdbf35e9c (patch) | |
| tree | f5f95380df3b75868c7b153e002eef33215dbb1e /src/test/java | |
| parent | 81fedf90c181c305703a088f097c81d37e6745a4 (diff) | |
Add initial skeleton of cranelift backend
Diffstat (limited to 'src/test/java')
| -rw-r--r-- | src/test/java/org/shedlang/compiler/backends/cranelift/PatioToCraneliftTests.java | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/test/java/org/shedlang/compiler/backends/cranelift/PatioToCraneliftTests.java b/src/test/java/org/shedlang/compiler/backends/cranelift/PatioToCraneliftTests.java new file mode 100644 index 00000000..ff9b1d82 --- /dev/null +++ b/src/test/java/org/shedlang/compiler/backends/cranelift/PatioToCraneliftTests.java @@ -0,0 +1,44 @@ +package org.shedlang.compiler.backends.cranelift; + +import org.junit.jupiter.api.Disabled; +import org.shedlang.compiler.backends.llvm.LlvmTarget; +import org.shedlang.compiler.backends.paths.PartialTargetPath; +import org.shedlang.compiler.patio.PatioCompilationUnit; +import org.shedlang.compiler.patio.PatioExampleTests; +import org.shedlang.compiler.runtime.ShedRuntime; +import org.shedlang.compiler.testing.ExecutionResult; +import org.shedlang.compiler.testing.TestProcessRunner; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.List; + +@Disabled +public class PatioToCraneliftTests extends PatioExampleTests { + @Override + protected ExecutionResult executeCompilationUnit(PatioCompilationUnit patio) throws IOException, InterruptedException { + Files.createDirectories(Path.of("tests-tmp")); + var workingDirectory = Files.createTempDirectory(Path.of("tests-tmp"), "PatioToCraneliftTests"); + + var objectFilePath = CraneliftBackend.compileCompilationUnit( + patio, + new PartialTargetPath(workingDirectory.resolve("main")) + ); + + var executablePath = workingDirectory.resolve("main"); + + var runtime = ShedRuntime.defaultRuntime(LlvmTarget.AMD64.targetName()); + CraneliftBackend.link( + List.of( + objectFilePath, + runtime.dir().resolve("libpatio_test.a") + ), + executablePath, + runtime + ); + + return TestProcessRunner.runCaptureOutput(List.of(executablePath.toString())); + + } +} |
