Skip to content

Commit

Permalink
encode end-to-end compilation pipeline as a test
Browse files Browse the repository at this point in the history
  • Loading branch information
j2kun committed Oct 30, 2023
1 parent 24ac606 commit e0e6ea3
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
4 changes: 4 additions & 0 deletions tests/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@ filegroup(
testonly = True,
data = [
"//tests:lit.cfg.py",
"//tests:poly_to_llvm_main.c",
"//tools:tutorial-opt",
"@llvm-project//clang:clang",
"@llvm-project//llvm:FileCheck",
"@llvm-project//llvm:count",
"@llvm-project//llvm:llc",
"@llvm-project//llvm:not",
"@llvm-project//mlir:mlir-cpu-runner",
"@llvm-project//mlir:mlir-opt",
"@llvm-project//mlir:mlir-translate",
"@mlir_tutorial_pip_deps_lit//:pkg",
],
)
Expand Down
7 changes: 5 additions & 2 deletions tests/poly_to_llvm.mlir
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// RUN: tutorial-opt --poly-to-llvm %s | FileCheck %s
// RUN: tutorial-opt --poly-to-llvm %s | mlir-translate --mlir-to-llvmir | llc -filetype=obj > %t
// RUN: clang -c poly_to_llvm_main.c
// RUN: clang poly_to_llvm_main.o %t -o a.out
// RUN: ./a.out | FileCheck %s

// CHECK-NOT: poly
// CHECK: 351
func.func @test_poly_fn(%arg : i32) -> i32 {
%tens = tensor.splat %arg : tensor<10xi32>
%input = poly.from_tensor %tens : tensor<10xi32> -> !poly.poly<10>
Expand Down
12 changes: 12 additions & 0 deletions tests/poly_to_llvm_main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <stdio.h>

// This is the function we want to call from LLVM
int test_poly_fn(int x);

int main(int argc, char *argv[]) {
int i = 1;
int result = test_poly_fn(i);
printf("Result: %d\n", result);

return 0;
}

0 comments on commit e0e6ea3

Please sign in to comment.