From d4bfa0d6ce936fecd8cef2c25ccc5165fe793fc6 Mon Sep 17 00:00:00 2001 From: "William S. Moses" Date: Thu, 1 Jul 2021 02:04:14 -0400 Subject: [PATCH] fix format --- mlir-clang/CMakeLists.txt | 62 ++++++++++++------- mlir-clang/Test/Verification/affun.c | 10 +-- mlir-clang/Test/Verification/call.c | 8 ++- mlir-clang/Test/Verification/cond.c | 22 ++++--- mlir-clang/Test/Verification/cond2.c | 18 +++--- mlir-clang/Test/Verification/der.c | 6 +- mlir-clang/Test/Verification/deref.c | 8 ++- mlir-clang/Test/Verification/fscanf.c | 33 +++++----- mlir-clang/Test/Verification/fw.c | 26 ++++---- mlir-clang/Test/Verification/fwfree.c | 25 ++++---- mlir-clang/Test/Verification/ker.c | 4 +- mlir-clang/Test/Verification/ler.c | 4 +- mlir-clang/Test/Verification/lum.c | 4 +- mlir-clang/Test/Verification/malloc.c | 6 +- mlir-clang/Test/Verification/mer.c | 4 +- mlir-clang/Test/Verification/nestloop.c | 21 ++++--- mlir-clang/Test/Verification/nus.c | 13 ++-- mlir-clang/Test/Verification/palloc.c | 8 ++- mlir-clang/Test/Verification/raiseToAffine.c | 35 +++++------ .../Verification/raiseToAffineUnsignedCmp.c | 16 ++--- mlir-clang/Test/Verification/red.mlir | 2 +- mlir-clang/Test/Verification/redstore.c | 38 ++++++------ mlir-clang/Test/Verification/redstore2.c | 33 +++++----- mlir-clang/Test/Verification/reduction.c | 1 + mlir-clang/Test/Verification/reverseRaise.c | 3 +- mlir-clang/Test/Verification/scor.c | 28 +++++---- mlir-clang/Test/Verification/scor2.c | 8 +-- mlir-clang/Test/Verification/scor3.c | 20 +++--- mlir-clang/Test/Verification/scor4.c | 18 +++--- mlir-clang/Test/Verification/setter.c | 8 ++- mlir-clang/Test/Verification/sgesv.c | 39 +++++++----- mlir-clang/Test/Verification/snus.c | 15 +++-- mlir-clang/Test/Verification/threeInt.c | 4 +- mlir-clang/Test/Verification/unlinked.c | 17 ++--- mlir-clang/Test/Verification/whileset.c | 35 ++++++----- mlir-clang/Test/Verification/whiletofor.c | 19 +++--- mlir-clang/Test/Verification/x.c | 8 +-- 37 files changed, 348 insertions(+), 281 deletions(-) diff --git a/mlir-clang/CMakeLists.txt b/mlir-clang/CMakeLists.txt index fbc90fa..52a5b28 100644 --- a/mlir-clang/CMakeLists.txt +++ b/mlir-clang/CMakeLists.txt @@ -1,28 +1,44 @@ -add_clang_tool(mlir - clang mlir - clang.cc) +add_clang_tool(mlir-clang + mlir-clang.cc +) - target_include_directories(mlir - clang PRIVATE - "${LLVM_SOURCE_DIR}/../clang/include" - "${CMAKE_BINARY_DIR}/tools/clang/include") -#MLIRTransformsPassIncGen +target_include_directories(mlir-clang PRIVATE + "${LLVM_SOURCE_DIR}/../clang/include" + "${CMAKE_BINARY_DIR}/tools/clang/include" +) +# MLIRTransformsPassIncGen - target_compile_definitions(mlir - clang PUBLIC - - DLLVM_OBJ_ROOT = "${LLVM_BINARY_DIR}") - target_link_libraries( - mlir - - clang PRIVATE LLVMCore LLVMOption LLVMSupport +target_compile_definitions(mlir-clang PUBLIC -DLLVM_OBJ_ROOT="${LLVM_BINARY_DIR}") +target_link_libraries(mlir-clang PRIVATE + LLVMCore + LLVMOption + LLVMSupport - MLIRSCFTransforms MLIRPolygeist + MLIRSCFTransforms + MLIRPolygeist - MLIRSupport MLIRIR MLIRAnalysis MLIRLLVMIR MLIRNVVMIR - MLIRGPU MLIRTransforms MLIRSCFToStandard - MLIRStandardToLLVM MLIRAffineTransforms - MLIRAffineToStandard MLIRTargetLLVMIRImport - MLIRPolygeistTransforms + MLIRSupport + MLIRIR + MLIRAnalysis + MLIRLLVMIR + MLIRNVVMIR + MLIRGPU + MLIRTransforms + MLIRSCFToStandard + MLIRStandardToLLVM + MLIRAffineTransforms + MLIRAffineToStandard + MLIRTargetLLVMIRImport + MLIRPolygeistTransforms - clangAST clangBasic clangCodeGen - clangDriver clangFrontend - clangFrontendTool clangLex - clangSerialization) - add_dependencies( - mlir - clang MLIRPolygeistOpsIncGen MLIRPolygeistPassIncGen) - add_subdirectory(Test) + clangAST + clangBasic + clangCodeGen + clangDriver + clangFrontend + clangFrontendTool + clangLex + clangSerialization +) +add_dependencies(mlir-clang MLIRPolygeistOpsIncGen MLIRPolygeistPassIncGen) +add_subdirectory(Test) diff --git a/mlir-clang/Test/Verification/affun.c b/mlir-clang/Test/Verification/affun.c index 224df8a..c6ddecd 100644 --- a/mlir-clang/Test/Verification/affun.c +++ b/mlir-clang/Test/Verification/affun.c @@ -1,13 +1,15 @@ // RUN: mlir-clang %s --function=okernel_2mm | FileCheck %s -void okernel_2mm(unsigned int ni, double *tmp) { +void okernel_2mm(unsigned int ni, + double *tmp) { int i, j, k; #pragma scop /* D := alpha*A*B*C + beta*D */ - for (i = 0; i < ni; i++) { - tmp[i] = 0.0; - } + for (i = 0; i < ni; i++) + { + tmp[i] = 0.0; + } #pragma endscop } diff --git a/mlir-clang/Test/Verification/call.c b/mlir-clang/Test/Verification/call.c index 3204a98..4c5593a 100644 --- a/mlir-clang/Test/Verification/call.c +++ b/mlir-clang/Test/Verification/call.c @@ -1,10 +1,12 @@ // RUN: mlir-clang %s --function=kernel_deriche | FileCheck %s -void sub(int a[2]) { a[2]++; } +void sub(int a[2]) { + a[2]++; +} void kernel_deriche() { - int a[2]; - sub(a); + int a[2]; + sub(a); } // CHECK: func @kernel_deriche() { diff --git a/mlir-clang/Test/Verification/cond.c b/mlir-clang/Test/Verification/cond.c index 3658a9b..7c80808 100644 --- a/mlir-clang/Test/Verification/cond.c +++ b/mlir-clang/Test/Verification/cond.c @@ -1,20 +1,22 @@ // RUN: mlir-clang %s %stdinclude --function=set | FileCheck %s -#include #include -#include #include +#include +#include + /* Array initialization. */ -int set(int b) { - int res; - if (b) - res = 1; - else - res = 2; - return res; - // path[0][1] = 2; +int set (int b) +{ + int res; + if (b) + res = 1; + else + res = 2; + return res; + //path[0][1] = 2; } // CHECK: func @set(%arg0: i32) -> i32 { diff --git a/mlir-clang/Test/Verification/cond2.c b/mlir-clang/Test/Verification/cond2.c index 8e7e796..5e19a73 100644 --- a/mlir-clang/Test/Verification/cond2.c +++ b/mlir-clang/Test/Verification/cond2.c @@ -1,18 +1,20 @@ // RUN: mlir-clang %s %stdinclude --function=set | FileCheck %s -#include #include -#include #include +#include +#include + /* Array initialization. */ -int set(int b) { - int res = 1; - if (b) - res = 2; - return res; - // path[0][1] = 2; +int set (int b) +{ + int res = 1; + if (b) + res = 2; + return res; + //path[0][1] = 2; } // CHECK: func @set(%arg0: i32) -> i32 { diff --git a/mlir-clang/Test/Verification/der.c b/mlir-clang/Test/Verification/der.c index eb7711d..8a2f928 100644 --- a/mlir-clang/Test/Verification/der.c +++ b/mlir-clang/Test/Verification/der.c @@ -1,9 +1,9 @@ // RUN: mlir-clang %s --function=kernel_deriche | FileCheck %s float kernel_deriche() { - float a2, a6; - a2 = a6 = 2.0; // EXP_FUN(-alpha); - return a2; + float a2, a6; + a2 = a6 = 2.0;//EXP_FUN(-alpha); + return a2; } // CHECK: func @kernel_deriche() -> f32 { diff --git a/mlir-clang/Test/Verification/deref.c b/mlir-clang/Test/Verification/deref.c index 15c8a19..2048bb9 100644 --- a/mlir-clang/Test/Verification/deref.c +++ b/mlir-clang/Test/Verification/deref.c @@ -1,8 +1,12 @@ // RUN: mlir-clang %s --function=kernel_deriche | FileCheck %s -int deref(int a) { return a; } +int deref(int a) { + return a; +} -void kernel_deriche(int *a) { deref(*a); } +void kernel_deriche(int *a) { + deref(*a); +} // CHECK: func @kernel_deriche(%arg0: memref) { // CHECK-NEXT: %0 = affine.load %arg0[0] : memref diff --git a/mlir-clang/Test/Verification/fscanf.c b/mlir-clang/Test/Verification/fscanf.c index fa96c3f..072ef60 100644 --- a/mlir-clang/Test/Verification/fscanf.c +++ b/mlir-clang/Test/Verification/fscanf.c @@ -3,19 +3,20 @@ #include #include -int *alloc() { - int no_of_nodes; +int* alloc() { + int no_of_nodes; - scanf("%d", &no_of_nodes); + scanf("%d",&no_of_nodes); + + // allocate host memory + int* h_graph_nodes = (int*) malloc(sizeof(int)*no_of_nodes); - // allocate host memory - int *h_graph_nodes = (int *)malloc(sizeof(int) * no_of_nodes); - - // initalize the memory - for (unsigned int i = 0; i < no_of_nodes; i++) { - scanf("%d\n", &h_graph_nodes[i]); - } - return h_graph_nodes; + // initalize the memory + for( unsigned int i = 0; i < no_of_nodes; i++) + { + scanf("%d\n", &h_graph_nodes[i]); + } + return h_graph_nodes; } // CHECK: llvm.mlir.global internal constant @str1("%d\0A\00") @@ -29,9 +30,8 @@ int *alloc() { // CHECK-DAG: %c1 = constant 1 : index // CHECK-NEXT: %0 = llvm.alloca %c1_i64 x i32 : (i64) -> !llvm.ptr // CHECK-NEXT: %1 = llvm.mlir.addressof @str0 : !llvm.ptr> -// CHECK-NEXT: %2 = llvm.getelementptr %1[%c0_i64, %c0_i64] : -// (!llvm.ptr>, i64, i64) -> !llvm.ptr CHECK-NEXT: %3 = -// llvm.call @__isoc99_scanf(%2, %0) : (!llvm.ptr, !llvm.ptr) -> i32 +// CHECK-NEXT: %2 = llvm.getelementptr %1[%c0_i64, %c0_i64] : (!llvm.ptr>, i64, i64) -> !llvm.ptr +// CHECK-NEXT: %3 = llvm.call @__isoc99_scanf(%2, %0) : (!llvm.ptr, !llvm.ptr) -> i32 // CHECK-NEXT: %4 = llvm.load %0 : !llvm.ptr // CHECK-NEXT: %5 = zexti %4 : i32 to i64 // CHECK-NEXT: %6 = index_cast %5 : i64 to index @@ -41,9 +41,8 @@ int *alloc() { // CHECK-NEXT: %10 = index_cast %4 : i32 to index // CHECK-NEXT: scf.for %arg0 = %c0 to %10 step %c1 { // CHECK-NEXT: %11 = llvm.mlir.addressof @str1 : !llvm.ptr> -// CHECK-NEXT: %12 = llvm.getelementptr %11[%c0_i64, %c0_i64] : -// (!llvm.ptr>, i64, i64) -> !llvm.ptr CHECK-NEXT: %13 = -// llvm.call @__isoc99_scanf(%12, %0) : (!llvm.ptr, !llvm.ptr) -> i32 +// CHECK-NEXT: %12 = llvm.getelementptr %11[%c0_i64, %c0_i64] : (!llvm.ptr>, i64, i64) -> !llvm.ptr +// CHECK-NEXT: %13 = llvm.call @__isoc99_scanf(%12, %0) : (!llvm.ptr, !llvm.ptr) -> i32 // CHECK-NEXT: %14 = llvm.load %0 : !llvm.ptr // CHECK-NEXT: memref.store %14, %9[%arg0] : memref // CHECK-NEXT: } diff --git a/mlir-clang/Test/Verification/fw.c b/mlir-clang/Test/Verification/fw.c index b6b8db0..93ab6a4 100644 --- a/mlir-clang/Test/Verification/fw.c +++ b/mlir-clang/Test/Verification/fw.c @@ -1,31 +1,35 @@ // RUN: mlir-clang %s %stdinclude | FileCheck %s -#include #include -#include #include +#include +#include /* Include polybench common header. */ #include -#define N 2800 +# define N 2800 /* Array initialization. */ -static void init_array(int path[N]) { - // path[0][1] = 2; +static +void init_array (int path[N]) +{ + //path[0][1] = 2; } -int main() { +int main() +{ /* Retrieve problem size. */ /* Variable declaration/allocation. */ - // POLYBENCH_1D_ARRAY_DECL(path, int, N, n); - int(*path)[N]; - // int path[POLYBENCH_C99_SELECT(N,n) + POLYBENCH_PADDING_FACTOR]; - path = (int(*)[N])polybench_alloc_data(N, sizeof(int)); + //POLYBENCH_1D_ARRAY_DECL(path, int, N, n); + int (*path)[N]; + //int path[POLYBENCH_C99_SELECT(N,n) + POLYBENCH_PADDING_FACTOR]; + path = (int(*)[N])polybench_alloc_data (N, sizeof(int)) ; /* Initialize array(s). */ - init_array(*path); + init_array (*path); + return 0; } diff --git a/mlir-clang/Test/Verification/fwfree.c b/mlir-clang/Test/Verification/fwfree.c index 020d4b0..8968326 100644 --- a/mlir-clang/Test/Verification/fwfree.c +++ b/mlir-clang/Test/Verification/fwfree.c @@ -1,31 +1,34 @@ // RUN: mlir-clang %s %stdinclude | FileCheck %s -#include #include -#include #include +#include +#include /* Include polybench common header. */ #include -#define N 2800 +# define N 2800 /* Array initialization. */ -static void init_array(int path[N]) { - // path[0][1] = 2; +static +void init_array (int path[N]) +{ + //path[0][1] = 2; } -int main() { +int main() +{ /* Retrieve problem size. */ /* Variable declaration/allocation. */ - // POLYBENCH_1D_ARRAY_DECL(path, int, N, n); - int(*path)[N]; - // int path[POLYBENCH_C99_SELECT(N,n) + POLYBENCH_PADDING_FACTOR]; - path = (int(*)[N])polybench_alloc_data(N, sizeof(int)); + //POLYBENCH_1D_ARRAY_DECL(path, int, N, n); + int (*path)[N]; + //int path[POLYBENCH_C99_SELECT(N,n) + POLYBENCH_PADDING_FACTOR]; + path = (int(*)[N])polybench_alloc_data (N, sizeof(int)) ; /* Initialize array(s). */ - init_array(*path); + init_array (*path); POLYBENCH_FREE_ARRAY(path); return 0; diff --git a/mlir-clang/Test/Verification/ker.c b/mlir-clang/Test/Verification/ker.c index fe7060c..f405817 100644 --- a/mlir-clang/Test/Verification/ker.c +++ b/mlir-clang/Test/Verification/ker.c @@ -1,8 +1,8 @@ // RUN: mlir-clang %s --function=kernel_deriche | FileCheck %s int kernel_deriche(int a[30][40]) { - a[3][5]++; - return a[1][2]; + a[3][5]++; + return a[1][2]; } // CHECK: func @kernel_deriche(%arg0: memref) -> i32 { diff --git a/mlir-clang/Test/Verification/ler.c b/mlir-clang/Test/Verification/ler.c index a197178..10a9a5d 100644 --- a/mlir-clang/Test/Verification/ler.c +++ b/mlir-clang/Test/Verification/ler.c @@ -1,8 +1,8 @@ // RUN: mlir-clang %s --function=kernel_deriche | FileCheck %s int kernel_deriche(int *a) { - a[3]++; - return a[1]; + a[3]++; + return a[1]; } // CHECK: func @kernel_deriche(%arg0: memref) -> i32 { diff --git a/mlir-clang/Test/Verification/lum.c b/mlir-clang/Test/Verification/lum.c index e7b9032..c43b2ea 100644 --- a/mlir-clang/Test/Verification/lum.c +++ b/mlir-clang/Test/Verification/lum.c @@ -1,6 +1,8 @@ // RUN: mlir-clang %s --function=test | FileCheck %s -int test() { return -3; } +int test() { + return -3; +} // CHECK: func @test() -> i32 { // CHECK-NEXT: %c-3_i32 = constant -3 : i32 diff --git a/mlir-clang/Test/Verification/malloc.c b/mlir-clang/Test/Verification/malloc.c index 7dfa365..d0aa0ac 100644 --- a/mlir-clang/Test/Verification/malloc.c +++ b/mlir-clang/Test/Verification/malloc.c @@ -5,9 +5,9 @@ void sum(double *result); void caller(int size) { - double *array = (double *)malloc(sizeof(double) * size); - sum(array); - free(array); + double* array = (double*)malloc(sizeof(double) * size); + sum(array); + free(array); } // CHECK: func @caller(%arg0: i32) { diff --git a/mlir-clang/Test/Verification/mer.c b/mlir-clang/Test/Verification/mer.c index d7c7e79..0b49ce3 100644 --- a/mlir-clang/Test/Verification/mer.c +++ b/mlir-clang/Test/Verification/mer.c @@ -1,8 +1,8 @@ // RUN: mlir-clang %s --function=kernel_deriche | FileCheck %s int kernel_deriche(int a[30]) { - a[0]++; - return a[1]; + a[0]++; + return a[1]; } // CHECK: func @kernel_deriche(%arg0: memref) -> i32 { diff --git a/mlir-clang/Test/Verification/nestloop.c b/mlir-clang/Test/Verification/nestloop.c index a122c05..565332e 100644 --- a/mlir-clang/Test/Verification/nestloop.c +++ b/mlir-clang/Test/Verification/nestloop.c @@ -1,18 +1,21 @@ // RUN: mlir-clang %s %stdinclude --function=init_array | FileCheck %s -#include #include -#include #include +#include +#include -void init_array(int path[10][10]) { + + +void init_array (int path[10][10]) +{ int i, j; for (i = 0; i < 10; i++) for (j = 0; j < 10; j++) { - path[i][j] = i * j % 7 + 1; - if ((i + j) % 13 == 0 || (i + j) % 7 == 0 || (i + j) % 11 == 0) - path[i][j] = 999; + path[i][j] = i*j%7+1; + if ((i+j)%13 == 0 || (i+j)%7==0 || (i+j)%11 == 0) + path[i][j] = 999; } } @@ -53,8 +56,10 @@ void init_array(int path[10][10]) { // CHECK-NEXT: scf.yield %11 : i1 // CHECK-NEXT: } // CHECK-NEXT: scf.if %9 { -// CHECK-NEXT: memref.store %c999_i32, %arg0[%arg1, %arg2] : -// memref CHECK-NEXT: } CHECK-NEXT: } CHECK-NEXT: } +// CHECK-NEXT: memref.store %c999_i32, %arg0[%arg1, %arg2] : memref +// CHECK-NEXT: } +// CHECK-NEXT: } +// CHECK-NEXT: } // CHECK-NEXT: return // CHECK-NEXT: } // CHECK-NEXT: } \ No newline at end of file diff --git a/mlir-clang/Test/Verification/nus.c b/mlir-clang/Test/Verification/nus.c index 4b47b38..83b34cb 100644 --- a/mlir-clang/Test/Verification/nus.c +++ b/mlir-clang/Test/Verification/nus.c @@ -15,14 +15,17 @@ // CHECK-NEXT: return // CHECK-NEXT: } -void kernel_nussinov(int n, int table[N]) { +void kernel_nussinov(int n, int table[N]) +{ int j; #pragma scop - for (j = 1; j < N; j++) { + for (j=1; j= 0) - table[j] = max_score(table[j], table[j - 1]); - } + if (j-1>=0) + table[j] = max_score(table[j], table[j-1]); + + } #pragma endscop + } diff --git a/mlir-clang/Test/Verification/palloc.c b/mlir-clang/Test/Verification/palloc.c index 8fec6b7..ad6d740 100644 --- a/mlir-clang/Test/Verification/palloc.c +++ b/mlir-clang/Test/Verification/palloc.c @@ -1,8 +1,8 @@ // RUN: mlir-clang %s %stdinclude --function=init_array | FileCheck %s #include -#include #include +#include /* Include polybench common header. */ #include @@ -10,12 +10,14 @@ void use(double A[20]); /* Array initialization. */ -void init_array(int n) { - double(*B)[20] = (double(*)[20])polybench_alloc_data(20, sizeof(double)); +void init_array (int n) +{ + double (*B)[20] = (double(*)[20])polybench_alloc_data (20, sizeof(double)) ; (*B)[2] = 3.0; use(*B); } + // CHECK: func @init_array(%arg0: i32) // CHECK-NEXT: %cst = constant 3.000000e+00 : f64 // CHECK-NEXT: %0 = memref.alloc() : memref<20xf64> diff --git a/mlir-clang/Test/Verification/raiseToAffine.c b/mlir-clang/Test/Verification/raiseToAffine.c index c4618c4..ae885db 100644 --- a/mlir-clang/Test/Verification/raiseToAffine.c +++ b/mlir-clang/Test/Verification/raiseToAffine.c @@ -1,9 +1,7 @@ // RUN: split-file %s %t -// RUN: mlir-clang %t/matmul_signed_cmp.cpp --function=matmul -// --raise-scf-to-affine | FileCheck %s -check-prefix=GEMMSIGNED RUN: mlir-clang -// %t/matmul_unsigned_cmp.cpp --function=matmul_unsigned_cmp -// --raise-scf-to-affine | FileCheck %s -check-prefix=GEMMUNSIGNED +// RUN: mlir-clang %t/matmul_signed_cmp.cpp --function=matmul --raise-scf-to-affine | FileCheck %s -check-prefix=GEMMSIGNED +// RUN: mlir-clang %t/matmul_unsigned_cmp.cpp --function=matmul_unsigned_cmp --raise-scf-to-affine | FileCheck %s -check-prefix=GEMMUNSIGNED //--- matmul_signed_cmp.cpp #define N 200 @@ -19,36 +17,33 @@ void matmul(DATA_TYPE A[N][K], DATA_TYPE B[K][M], DATA_TYPE C[N][M]) { for (j = 0; j < M; j++) // GEMMSIGNED: affine.for for (k = 0; k < K; k++) - // GEMMSIGNED: {{.*}} = affine.load %{{.*}}[%{{.*}}, %{{.*}}] : - // memref GEMMSIGNED: {{.*}} = affine.load %{{.*}}[%{{.*}}, - // %{{.*}}] : memref GEMMSIGNED: {{.*}} = mulf GEMMSIGNED: - // {{.*}} = affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref + // GEMMSIGNED: {{.*}} = affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref + // GEMMSIGNED: {{.*}} = affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref + // GEMMSIGNED: {{.*}} = mulf + // GEMMSIGNED: {{.*}} = affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref // GEMMSIGNED: {{.*}} = addf - // GEMMSIGNED: affine.store {{.*}}, %{{.*}}[%{{.*}}, %{{.*}}] : - // memref + // GEMMSIGNED: affine.store {{.*}}, %{{.*}}[%{{.*}}, %{{.*}}] : memref C[i][j] += A[i][k] * B[k][j]; } //--- matmul_unsigned_cmp.cpp -void matmul_unsigned_cmp(float A[100][200], float B[200][300], - float C[100][300]) { +void matmul_unsigned_cmp(float A[100][200], float B[200][300], float C[100][300]) { int i, j, k; // GEMMUNSIGNED: affine.for for (i = 0; i < 100; i++) { // GEMMUNSIGNED: affine.for for (j = 0; j < 300; j++) { - // GEMMUNSIGNED: affine.store %{{.*}}, %{{.*}}[%{{.*}}, %{{.*}}] : - // memref + // GEMMUNSIGNED: affine.store %{{.*}}, %{{.*}}[%{{.*}}, %{{.*}}] : memref C[i][j] = 0; // GEMMUNSIGNED: affine.for for (k = 0; k < 200; k++) { - // GEMMUNSIGNED: {{.*}} = affine.load %{{.*}}[%{{.*}}, %{{.*}}] : - // memref GEMMUNSIGNED: {{.*}} = affine.load %{{.*}}[%{{.*}}, - // %{{.*}}] : memref GEMMUNSIGNED: {{.*}} = mulf - // GEMMUNSIGNED: {{.*}} = affine.load %{{.*}}[%{{.*}}, %{{.*}}] : - // memref GEMMUNSIGNED: {{.*}} = addf GEMMUNSIGNED: - // affine.store {{.*}}, %{{.*}}[%{{.*}}, %{{.*}}] : memref + // GEMMUNSIGNED: {{.*}} = affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref + // GEMMUNSIGNED: {{.*}} = affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref + // GEMMUNSIGNED: {{.*}} = mulf + // GEMMUNSIGNED: {{.*}} = affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref + // GEMMUNSIGNED: {{.*}} = addf + // GEMMUNSIGNED: affine.store {{.*}}, %{{.*}}[%{{.*}}, %{{.*}}] : memref C[i][j] += A[i][k] * B[k][j]; } } diff --git a/mlir-clang/Test/Verification/raiseToAffineUnsignedCmp.c b/mlir-clang/Test/Verification/raiseToAffineUnsignedCmp.c index f4e8d35..417633e 100644 --- a/mlir-clang/Test/Verification/raiseToAffineUnsignedCmp.c +++ b/mlir-clang/Test/Verification/raiseToAffineUnsignedCmp.c @@ -7,18 +7,18 @@ void matmul(float A[100][200], float B[200][300], float C[100][300]) { for (i = 0; i < 100; i++) { // CHECK: affine.for for (j = 0; j < 300; j++) { - // CHECK: affine.store %{{.*}}, %{{.*}}[%{{.*}}, %{{.*}}] : - // memref + // CHECK: affine.store %{{.*}}, %{{.*}}[%{{.*}}, %{{.*}}] : memref C[i][j] = 0; // CHECK: affine.for for (k = 0; k < 200; k++) { - // CHECK: {{.*}} = affine.load %{{.*}}[%{{.*}}, %{{.*}}] : - // memref CHECK: {{.*}} = affine.load %{{.*}}[%{{.*}}, - // %{{.*}}] : memref CHECK: {{.*}} = mulf CHECK: {{.*}} = - // affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref CHECK: - // {{.*}} = addf CHECK: affine.store {{.*}}, %{{.*}}[%{{.*}}, %{{.*}}] : - // memref + // CHECK: {{.*}} = affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref + // CHECK: {{.*}} = affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref + // CHECK: {{.*}} = mulf + // CHECK: {{.*}} = affine.load %{{.*}}[%{{.*}}, %{{.*}}] : memref + // CHECK: {{.*}} = addf + // CHECK: affine.store {{.*}}, %{{.*}}[%{{.*}}, %{{.*}}] : memref C[i][j] += A[i][k] * B[k][j]; } } } + diff --git a/mlir-clang/Test/Verification/red.mlir b/mlir-clang/Test/Verification/red.mlir index 8ef37c2..1c5dc39 100644 --- a/mlir-clang/Test/Verification/red.mlir +++ b/mlir-clang/Test/Verification/red.mlir @@ -1,7 +1,7 @@ // RUN: mlir-opt --detect-reduction %s | FileCheck %s // XFAIL: * -module { +module { func @reduce_with_iter_args(%arg0: memref) -> f32 { %c0 = constant 0 : index %0 = memref.dim %arg0, %c0 : memref diff --git a/mlir-clang/Test/Verification/redstore.c b/mlir-clang/Test/Verification/redstore.c index c798836..edbf2f2 100644 --- a/mlir-clang/Test/Verification/redstore.c +++ b/mlir-clang/Test/Verification/redstore.c @@ -2,31 +2,33 @@ extern int print(double); -void sum(double *result, double *array, int N) { -#pragma scop - for (int j = 0; j < N; j++) { - result[0] = 0; - for (int i = 0; i < 10; i++) { - result[0] += array[i]; +void sum(double *result, double* array, int N) { + #pragma scop + for (int j=0; j) { // CHECK-NEXT: %c1_i32 = constant 1 : i32 // CHECK-NEXT: %0 = memref.alloca() : memref<1xf64> // CHECK-NEXT: %1 = memref.cast %0 : memref<1xf64> to memref -// CHECK-NEXT: call @sum(%1, %arg0, %c1_i32) : (memref, memref, -// i32) -> () CHECK-NEXT: %2 = affine.load %0[0] : memref<1xf64> CHECK-NEXT: -// %3 = call @print(%2) : (f64) -> i32 CHECK-NEXT: return CHECK-NEXT: } +// CHECK-NEXT: call @sum(%1, %arg0, %c1_i32) : (memref, memref, i32) -> () +// CHECK-NEXT: %2 = affine.load %0[0] : memref<1xf64> +// CHECK-NEXT: %3 = call @print(%2) : (f64) -> i32 +// CHECK-NEXT: return +// CHECK-NEXT: } // CHECK: func @sum(%arg0: memref, %arg1: memref, %arg2: i32) { // CHECK-NEXT: %c0_i32 = constant 0 : i32 @@ -35,8 +37,8 @@ void caller(double *array) { // CHECK-NEXT: affine.for %arg3 = 0 to %0 { // CHECK-NEXT: affine.store %1, %arg0[0] : memref // CHECK-NEXT: %2 = affine.load %arg0[0] : memref -// CHECK-NEXT: %3 = affine.for %arg4 = 0 to 10 iter_args(%arg5 = %2) -> -// (f64) { CHECK-NEXT: %6 = affine.load %arg1[%arg4] : memref +// CHECK-NEXT: %3 = affine.for %arg4 = 0 to 10 iter_args(%arg5 = %2) -> (f64) { +// CHECK-NEXT: %6 = affine.load %arg1[%arg4] : memref // CHECK-NEXT: %7 = addf %arg5, %6 : f64 // CHECK-NEXT: affine.yield %7 : f64 // CHECK-NEXT: } diff --git a/mlir-clang/Test/Verification/redstore2.c b/mlir-clang/Test/Verification/redstore2.c index 0f376f4..fbc0bb6 100644 --- a/mlir-clang/Test/Verification/redstore2.c +++ b/mlir-clang/Test/Verification/redstore2.c @@ -2,19 +2,19 @@ extern int print(double); -void sum(double *result, double *array) { - result[0] = 0; -#pragma scop - for (int i = 0; i < 10; i++) { - result[0] += array[i]; - } -#pragma endscop +void sum(double *result, double* array) { + result[0] = 0; + #pragma scop + for (int i=0; i<10; i++) { + result[0] += array[i]; + } + #pragma endscop } -void caller(double *array) { - double result; - sum(&result, array); - print(result); +void caller(double* array) { + double result; + sum(&result, array); + print(result); } // CHECK: func @caller(%arg0: memref) { @@ -31,8 +31,11 @@ void caller(double *array) { // CHECK-NEXT: %0 = sitofp %c0_i32 : i32 to f64 // CHECK-NEXT: affine.store %0, %arg0[0] : memref // CHECK-NEXT: %1 = affine.load %arg0[0] : memref -// CHECK-NEXT: %2 = affine.for %arg2 = 0 to 10 iter_args(%arg3 = %1) -> (f64) -// { CHECK-NEXT: %3 = affine.load %arg1[%arg2] : memref CHECK-NEXT: -// %4 = addf %arg3, %3 : f64 CHECK-NEXT: affine.yield %4 : f64 CHECK-NEXT: -// } CHECK-NEXT: affine.store %2, %arg0[0] : memref CHECK-NEXT: return +// CHECK-NEXT: %2 = affine.for %arg2 = 0 to 10 iter_args(%arg3 = %1) -> (f64) { +// CHECK-NEXT: %3 = affine.load %arg1[%arg2] : memref +// CHECK-NEXT: %4 = addf %arg3, %3 : f64 +// CHECK-NEXT: affine.yield %4 : f64 +// CHECK-NEXT: } +// CHECK-NEXT: affine.store %2, %arg0[0] : memref +// CHECK-NEXT: return // CHECK-NEXT: } diff --git a/mlir-clang/Test/Verification/reduction.c b/mlir-clang/Test/Verification/reduction.c index 013cfa6..e563dab 100644 --- a/mlir-clang/Test/Verification/reduction.c +++ b/mlir-clang/Test/Verification/reduction.c @@ -43,3 +43,4 @@ void reduction_sum() { sum += A[i]; #pragma endscop } + diff --git a/mlir-clang/Test/Verification/reverseRaise.c b/mlir-clang/Test/Verification/reverseRaise.c index a397a7b..1554bcd 100644 --- a/mlir-clang/Test/Verification/reverseRaise.c +++ b/mlir-clang/Test/Verification/reverseRaise.c @@ -1,5 +1,4 @@ -// RUN: mlir-clang %s --function=kernel_correlation --raise-scf-to-affine | -// FileCheck %s +// RUN: mlir-clang %s --function=kernel_correlation --raise-scf-to-affine | FileCheck %s #define DATA_TYPE double diff --git a/mlir-clang/Test/Verification/scor.c b/mlir-clang/Test/Verification/scor.c index 5592a35..5448e3d 100644 --- a/mlir-clang/Test/Verification/scor.c +++ b/mlir-clang/Test/Verification/scor.c @@ -6,26 +6,30 @@ /* Main computational kernel. The whole function will be timed, including the call and return. */ -void kernel_correlation(double out[28], double stddev[28], _Bool cmp) { +void kernel_correlation(double out[28], double stddev[28], _Bool cmp) +{ int j; + #pragma scop - for (j = 0; j < 28; j++) { - stddev[j] = 0.0; - stddev[j] = 3.14; - /* The following in an inelegant but usual way to handle - near-zero std. dev. values, which below would cause a zero- - divide. */ - - out[j] = cmp ? 1.0 : stddev[j]; - } + for (j = 0; j < 28; j++) + { + stddev[j] = 0.0; + stddev[j] = 3.14; + /* The following in an inelegant but usual way to handle + near-zero std. dev. values, which below would cause a zero- + divide. */ + + out[j] = cmp ? 1.0 : stddev[j]; + } #pragma endscop + } -// CHECK: func @kernel_correlation(%arg0: memref, %arg1: memref, -// %arg2: i1) { CHECK-DAG: %[[cst:.+]] = constant 1.000000e+00 : f64 +// CHECK: func @kernel_correlation(%arg0: memref, %arg1: memref, %arg2: i1) { +// CHECK-DAG: %[[cst:.+]] = constant 1.000000e+00 : f64 // CHECK-DAG: %[[cst_0:.+]] = constant 3.140000e+00 : f64 // CHECK: %0 = select %arg2, %[[cst]], %[[cst_0]] : f64 // CHECK-NEXT: affine.for %arg3 = 0 to 28 { diff --git a/mlir-clang/Test/Verification/scor2.c b/mlir-clang/Test/Verification/scor2.c index 193343f..b76b43c 100644 --- a/mlir-clang/Test/Verification/scor2.c +++ b/mlir-clang/Test/Verification/scor2.c @@ -1,5 +1,4 @@ -// RUN: mlir-clang %s --function=kernel_correlation --raise-scf-to-affine | -// FileCheck %s +// RUN: mlir-clang %s --function=kernel_correlation --raise-scf-to-affine | FileCheck %s #define DATA_TYPE double @@ -7,8 +6,9 @@ /* Main computational kernel. The whole function will be timed, including the call and return. */ -void kernel_correlation(int m, double corr[28]) { - for (int i = 0; i < m - 1; i++) { +void kernel_correlation(int m, double corr[28]) +{ + for (int i = 0; i < m-1; i++) { corr[i] = 0.; } } diff --git a/mlir-clang/Test/Verification/scor3.c b/mlir-clang/Test/Verification/scor3.c index b7b279a..1d07055 100644 --- a/mlir-clang/Test/Verification/scor3.c +++ b/mlir-clang/Test/Verification/scor3.c @@ -1,5 +1,4 @@ -// RUN: mlir-clang %s --function=kernel_correlation --raise-scf-to-affine | -// FileCheck %s +// RUN: mlir-clang %s --function=kernel_correlation --raise-scf-to-affine | FileCheck %s #define DATA_TYPE double @@ -7,14 +6,17 @@ /* Main computational kernel. The whole function will be timed, including the call and return. */ -void kernel_correlation(int m, double corr[28][28]) { - int i, j, k; - // i = 0; - for (i = 0; i < 28; i++) { - for (j = i + 1; j < m; j++) { - corr[i][j] = SCALAR_VAL(0.0); +void kernel_correlation(int m, double corr[28][28]) +{ + int i, j, k; + //i = 0; + for (i = 0; i < 28; i++) + { + for (j = i+1; j < m; j++) + { + corr[i][j] = SCALAR_VAL(0.0); + } } - } } // CHECK: func @kernel_correlation(%arg0: i32, %arg1: memref) { diff --git a/mlir-clang/Test/Verification/scor4.c b/mlir-clang/Test/Verification/scor4.c index 6b5ffcb..045b3d0 100644 --- a/mlir-clang/Test/Verification/scor4.c +++ b/mlir-clang/Test/Verification/scor4.c @@ -1,5 +1,4 @@ -// RUN: mlir-clang %s --function=kernel_correlation --raise-scf-to-affine | -// FileCheck %s +// RUN: mlir-clang %s --function=kernel_correlation --raise-scf-to-affine | FileCheck %s #define DATA_TYPE double @@ -9,7 +8,8 @@ void use(int i); /* Main computational kernel. The whole function will be timed, including the call and return. */ -void kernel_correlation(double A[28], double B[28]) { +void kernel_correlation(double A[28], double B[28]) +{ int i; for (i = 1; i < 10; i++) { A[i] = 0.; @@ -19,11 +19,13 @@ void kernel_correlation(double A[28], double B[28]) { } } -// CHECK: func @kernel_correlation(%arg0: memref, %arg1: memref) -// { CHECK-NEXT: %cst = constant 0.000000e+00 : f64 CHECK-NEXT: affine.for -// %arg2 = 1 to 10 { CHECK-NEXT: affine.store %cst, %arg0[%arg2] : -// memref CHECK-NEXT: } CHECK-NEXT: affine.for %arg2 = 1 to -// 10 { CHECK-NEXT: affine.store %cst, %arg1[%arg2] : memref +// CHECK: func @kernel_correlation(%arg0: memref, %arg1: memref) { +// CHECK-NEXT: %cst = constant 0.000000e+00 : f64 +// CHECK-NEXT: affine.for %arg2 = 1 to 10 { +// CHECK-NEXT: affine.store %cst, %arg0[%arg2] : memref +// CHECK-NEXT: } +// CHECK-NEXT: affine.for %arg2 = 1 to 10 { +// CHECK-NEXT: affine.store %cst, %arg1[%arg2] : memref // CHECK-NEXT: } // CHECK-NEXT: return // CHECK-NEXT: } \ No newline at end of file diff --git a/mlir-clang/Test/Verification/setter.c b/mlir-clang/Test/Verification/setter.c index ab03268..9f76e8c 100644 --- a/mlir-clang/Test/Verification/setter.c +++ b/mlir-clang/Test/Verification/setter.c @@ -1,10 +1,12 @@ // RUN: mlir-clang %s --function=kernel_deriche | FileCheck %s -void sub(int *a) { *a = 3; } +void sub(int *a) { + *a = 3; +} void kernel_deriche() { - int a; - sub(&a); + int a; + sub(&a); } // CHECK: func @kernel_deriche() { diff --git a/mlir-clang/Test/Verification/sgesv.c b/mlir-clang/Test/Verification/sgesv.c index fdea125..4ad7b46 100644 --- a/mlir-clang/Test/Verification/sgesv.c +++ b/mlir-clang/Test/Verification/sgesv.c @@ -1,5 +1,4 @@ -// RUN: mlir-clang %s --function=kernel_correlation --raise-scf-to-affine | -// FileCheck %s +// RUN: mlir-clang %s --function=kernel_correlation --raise-scf-to-affine | FileCheck %s #define DATA_TYPE double @@ -7,26 +6,32 @@ /* Main computational kernel. The whole function will be timed, including the call and return. */ -void kernel_correlation(int n, double alpha, double beta, double A[28][28], - double B[28][28], double tmp[28], double x[28], - double y[28]) { +void kernel_correlation(int n, double alpha, double beta, + double A[28][28], + double B[28][28], + double tmp[28], + double x[28], + double y[28]) +{ int i, j; - for (i = 0; i < n; i++) { - tmp[i] = SCALAR_VAL(0.0); - y[i] = SCALAR_VAL(0.0); - for (j = 0; j < n; j++) { - tmp[i] = A[i][j] * x[j] + tmp[i]; - y[i] = B[i][j] * x[j] + y[i]; + for (i = 0; i < n; i++) + { + tmp[i] = SCALAR_VAL(0.0); + y[i] = SCALAR_VAL(0.0); + for (j = 0; j < n; j++) + { + tmp[i] = A[i][j] * x[j] + tmp[i]; + y[i] = B[i][j] * x[j] + y[i]; + } + y[i] = alpha * tmp[i] + beta * y[i]; } - y[i] = alpha * tmp[i] + beta * y[i]; - } + } -// CHECK: func @kernel_correlation(%arg0: i32, %arg1: f64, %arg2: f64, %arg3: -// memref, %arg4: memref, %arg5: memref, %arg6: -// memref, %arg7: memref) { CHECK-NEXT: %cst = constant -// 0.000000e+00 : f64 CHECK-NEXT: %0 = index_cast %arg0 : i32 to index +// CHECK: func @kernel_correlation(%arg0: i32, %arg1: f64, %arg2: f64, %arg3: memref, %arg4: memref, %arg5: memref, %arg6: memref, %arg7: memref) { +// CHECK-NEXT: %cst = constant 0.000000e+00 : f64 +// CHECK-NEXT: %0 = index_cast %arg0 : i32 to index // CHECK-NEXT: affine.for %arg8 = 0 to %0 { // CHECK-NEXT: affine.store %cst, %arg5[%arg8] : memref // CHECK-NEXT: affine.store %cst, %arg7[%arg8] : memref diff --git a/mlir-clang/Test/Verification/snus.c b/mlir-clang/Test/Verification/snus.c index c1c6f52..6a853f4 100644 --- a/mlir-clang/Test/Verification/snus.c +++ b/mlir-clang/Test/Verification/snus.c @@ -1,17 +1,16 @@ -// RUN: mlir-clang %s -detect-reduction --function=kernel_nussinov | FileCheck -// %s +// RUN: mlir-clang %s -detect-reduction --function=kernel_nussinov | FileCheck %s #define max_score(s1, s2) ((s1 >= s2) ? s1 : s2) void set(double table[20]); -void kernel_nussinov(double *out, int n) { +void kernel_nussinov(double* out, int n) { double table[20]; set(table); #pragma scop - for (int k = 0; k < 10; k++) { - out[n] = max_score(out[n], table[k]); - } + for (int k=0; k<10; k++) { + out[n] = max_score(out[n], table[k]); + } //} #pragma endscop } @@ -22,8 +21,8 @@ void kernel_nussinov(double *out, int n) { // CHECK-NEXT: %2 = memref.cast %0 : memref<20xf64> to memref // CHECK-NEXT: call @set(%2) : (memref) -> () // CHECK-NEXT: %3 = affine.load %arg0[symbol(%1)] : memref -// CHECK-NEXT: %4 = affine.for %arg2 = 0 to 10 iter_args(%arg3 = %3) -> -// (f64) { CHECK-NEXT: %5 = affine.load %0[%arg2] : memref<20xf64> +// CHECK-NEXT: %4 = affine.for %arg2 = 0 to 10 iter_args(%arg3 = %3) -> (f64) { +// CHECK-NEXT: %5 = affine.load %0[%arg2] : memref<20xf64> // CHECK-NEXT: %6 = cmpf uge, %arg3, %5 : f64 // CHECK-NEXT: %7 = select %6, %arg3, %5 : f64 // CHECK-NEXT: affine.yield %7 : f64 diff --git a/mlir-clang/Test/Verification/threeInt.c b/mlir-clang/Test/Verification/threeInt.c index 4562c28..92e29cb 100644 --- a/mlir-clang/Test/Verification/threeInt.c +++ b/mlir-clang/Test/Verification/threeInt.c @@ -4,7 +4,9 @@ typedef struct { int a, b, c; } threeInt; -int struct_pass_all_same(threeInt *a) { return a->b; } +int struct_pass_all_same(threeInt* a) { + return a->b; +} // CHECK: func @struct_pass_all_same(%arg0: memref) -> i32 { // CHECK-NEXT: %0 = affine.load %arg0[0, 1] : memref diff --git a/mlir-clang/Test/Verification/unlinked.c b/mlir-clang/Test/Verification/unlinked.c index 579a878..4f7318e 100644 --- a/mlir-clang/Test/Verification/unlinked.c +++ b/mlir-clang/Test/Verification/unlinked.c @@ -1,19 +1,18 @@ -// RUN: mlir-clang %s --function=kernel_correlation --raise-scf-to-affine | -// FileCheck %s +// RUN: mlir-clang %s --function=kernel_correlation --raise-scf-to-affine | FileCheck %s #define DATA_TYPE double #define N 10 -#define match(b1, b2) (((b1) + (b2)) == 3 ? 1 : 0) +#define match(b1, b2) (((b1)+(b2)) == 3 ? 1 : 0) #define max_score(s1, s2) ((s1 >= s2) ? s1 : s2) /* Main computational kernel. The whole function will be timed, including the call and return. */ void kernel_correlation(int table[N][N]) { - for (int i = 9; i >= 0; i--) { - for (int j = 0; j < 10; j++) { - table[i][j] = i + j; + for (int i = 9; i >= 0; i--) { + for (int j=0; j<10; j++) { + table[i][j] = i+j; } } } @@ -26,6 +25,8 @@ void kernel_correlation(int table[N][N]) { // CHECK-NEXT: affine.for %arg2 = 0 to 10 { // CHECK-NEXT: %2 = index_cast %arg2 : index to i32 // CHECK-NEXT: %3 = addi %1, %2 : i32 -// CHECK-NEXT: affine.store %3, %arg0[-%arg1 + 9, %arg2] : -// memref CHECK-NEXT: } CHECK-NEXT: } CHECK-NEXT: return +// CHECK-NEXT: affine.store %3, %arg0[-%arg1 + 9, %arg2] : memref +// CHECK-NEXT: } +// CHECK-NEXT: } +// CHECK-NEXT: return // CHECK-NEXT: } \ No newline at end of file diff --git a/mlir-clang/Test/Verification/whileset.c b/mlir-clang/Test/Verification/whileset.c index 69d1f46..1c14140 100644 --- a/mlir-clang/Test/Verification/whileset.c +++ b/mlir-clang/Test/Verification/whileset.c @@ -1,21 +1,22 @@ // RUN: mlir-clang %s %stdinclude --function=set | FileCheck %s -#include #include -#include #include +#include +#include + /* Array initialization. */ -void set(int path[20]) { - int i = 0; - while (1) { - path[i] = 3; - i++; - if (i == 20) - break; - } - // path[0][1] = 2; +void set (int path[20]) +{ + int i = 0; + while (1) { + path[i] = 3; + i++; + if (i == 20) break; + } + //path[0][1] = 2; } // TODO consider making into for @@ -25,11 +26,13 @@ void set(int path[20]) { // CHECK-DAG: %c3_i32 = constant 3 : i32 // CHECK-DAG: %c20_i32 = constant 20 : i32 // CHECK-DAG: %true = constant true -// CHECK-NEXT: %0 = scf.while (%arg1 = %true, %arg2 = %c0_i32) : (i1, i32) -// -> i32 { CHECK-NEXT: scf.condition(%arg1) %arg2 : i32 CHECK-NEXT: } -// do { CHECK-NEXT: ^bb0(%arg1: i32): // no predecessors CHECK-NEXT: %1 = -// index_cast %arg1 : i32 to index CHECK-NEXT: memref.store %c3_i32, -// %arg0[%1] : memref CHECK-NEXT: %2 = addi %arg1, %c1_i32 : i32 +// CHECK-NEXT: %0 = scf.while (%arg1 = %true, %arg2 = %c0_i32) : (i1, i32) -> i32 { +// CHECK-NEXT: scf.condition(%arg1) %arg2 : i32 +// CHECK-NEXT: } do { +// CHECK-NEXT: ^bb0(%arg1: i32): // no predecessors +// CHECK-NEXT: %1 = index_cast %arg1 : i32 to index +// CHECK-NEXT: memref.store %c3_i32, %arg0[%1] : memref +// CHECK-NEXT: %2 = addi %arg1, %c1_i32 : i32 // CHECK-NEXT: %3 = cmpi ne, %2, %c20_i32 : i32 // CHECK-NEXT: scf.yield %3, %2 : i1, i32 // CHECK-NEXT: } diff --git a/mlir-clang/Test/Verification/whiletofor.c b/mlir-clang/Test/Verification/whiletofor.c index 30623d2..c7cd8b4 100644 --- a/mlir-clang/Test/Verification/whiletofor.c +++ b/mlir-clang/Test/Verification/whiletofor.c @@ -31,22 +31,23 @@ void whiletofor() { // CHECK-NEXT: %c3_i32 = constant 3 : i32 // CHECK-NEXT: %c1_i32 = constant 1 : i32 // CHECK-NEXT: %0 = memref.alloca() : memref<100x100xi32> -// CHECK-NEXT: %1 = scf.for %arg0 = %c0 to %c100 step %c1 iter_args(%arg1 = -// %c7_i32) -> (i32) { CHECK-NEXT: %3 = scf.for %arg2 = %c0 to %c100 step -// %c1 iter_args(%arg3 = %arg1) -> (i32) { CHECK-NEXT: %4 = index_cast -// %arg2 : index to i32 CHECK-NEXT: %5 = addi %4, %arg1 : i32 +// CHECK-NEXT: %1 = scf.for %arg0 = %c0 to %c100 step %c1 iter_args(%arg1 = %c7_i32) -> (i32) { +// CHECK-NEXT: %3 = scf.for %arg2 = %c0 to %c100 step %c1 iter_args(%arg3 = %arg1) -> (i32) { +// CHECK-NEXT: %4 = index_cast %arg2 : index to i32 +// CHECK-NEXT: %5 = addi %4, %arg1 : i32 // CHECK-NEXT: %[[i4:.+]] = remi_signed %5, %c20_i32 : i32 // CHECK-NEXT: %[[i5:.+]] = cmpi eq, %[[i4]], %c0_i32 : i32 // CHECK-NEXT: scf.if %[[i5]] { -// CHECK-NEXT: memref.store %c2_i32, %0[%arg0, %arg2] : -// memref<100x100xi32> CHECK-NEXT: } else { CHECK-NEXT: memref.store -// %c3_i32, %0[%arg0, %arg2] : memref<100x100xi32> CHECK-NEXT: } +// CHECK-NEXT: memref.store %c2_i32, %0[%arg0, %arg2] : memref<100x100xi32> +// CHECK-NEXT: } else { +// CHECK-NEXT: memref.store %c3_i32, %0[%arg0, %arg2] : memref<100x100xi32> +// CHECK-NEXT: } // CHECK-NEXT: %[[i6:.+]] = addi %5, %c1_i32 : i32 // CHECK-NEXT: scf.yield %[[i6]] : i32 // CHECK-NEXT: } // CHECK-NEXT: scf.yield %3 : i32 // CHECK-NEXT: } -// CHECK-NEXT: %2 = memref.cast %0 : memref<100x100xi32> to -// memref CHECK-NEXT: call @use(%2) : (memref) -> () +// CHECK-NEXT: %2 = memref.cast %0 : memref<100x100xi32> to memref +// CHECK-NEXT: call @use(%2) : (memref) -> () // CHECK-NEXT: return // CHECK-NEXT: } diff --git a/mlir-clang/Test/Verification/x.c b/mlir-clang/Test/Verification/x.c index 5b0dd17..63d62c1 100644 --- a/mlir-clang/Test/Verification/x.c +++ b/mlir-clang/Test/Verification/x.c @@ -1,10 +1,10 @@ // RUN: mlir-clang %s --function=kernel_deriche | FileCheck %s int kernel_deriche(int x) { - x++; - x += 3; - x *= 2; - return x; + x++; + x+=3; + x*=2; + return x; } // CHECK: func @kernel_deriche(%arg0: i32) -> i32 {