From 17c745e977dbe696d3293b363d0aa36cdbf35e9c Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sat, 28 Mar 2026 09:29:49 +0000 Subject: Add initial skeleton of cranelift backend --- .../backends/cranelift/PatioToCraneliftTests.java | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/test/java/org/shedlang/compiler/backends/cranelift/PatioToCraneliftTests.java (limited to 'src/test/java') 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())); + + } +} -- cgit v1.2.3