74 lines · plain
1// RUN: mlir-translate -mlir-to-cpp %s | FileCheck %s2 3// CHECK-LABEL: test_for_siblings4func.func @test_for_siblings() {5 %start = emitc.literal "0" : index6 %stop = emitc.literal "10" : index7 %step = emitc.literal "1" : index8 9 %var1 = "emitc.variable"() <{value = 0 : index}> : () -> !emitc.lvalue<index>10 %var2 = "emitc.variable"() <{value = 0 : index}> : () -> !emitc.lvalue<index>11 12 // CHECK: for (size_t [[ITER0:i[0-9]*]] = {{.*}}; [[ITER0]] < {{.*}}; [[ITER0]] += {{.*}}) {13 emitc.for %i0 = %start to %stop step %step {14 // CHECK: for (size_t [[ITER1:j[0-9]*]] = {{.*}}; [[ITER1]] < {{.*}}; [[ITER1]] += {{.*}}) {15 emitc.for %i1 = %start to %stop step %step {16 // CHECK: {{.*}} = [[ITER0]];17 //"emitc.assign"(%var1,%i0) : (!emitc.lvalue<!emitc.size_t>, !emitc.size_t) -> ()18 emitc.assign %i0 : index to %var1 : !emitc.lvalue<index>19 // CHECK: {{.*}} = [[ITER1]];20 //"emitc.assign"(%var2,%i1) : (!emitc.lvalue<!emitc.size_t>, !emitc.size_t) -> ()21 emitc.assign %i1 : index to %var2 : !emitc.lvalue<index>22 }23 }24 // CHECK: for (size_t [[ITER2:i[0-9]*]] = {{.*}}; [[ITER2]] < {{.*}}; [[ITER2]] += {{.*}})25 emitc.for %ki2 = %start to %stop step %step {26 // CHECK: for (size_t [[ITER3:j[0-9]*]] = {{.*}}; [[ITER3]] < {{.*}}; [[ITER3]] += {{.*}})27 emitc.for %i3 = %start to %stop step %step {28 %1 = emitc.call_opaque "f"() : () -> i3229 }30 }31 return32}33 34// CHECK-LABEL: test_for_nesting35func.func @test_for_nesting() {36 %start = emitc.literal "0" : index37 %stop = emitc.literal "10" : index38 %step = emitc.literal "1" : index39 40 // CHECK-COUNT-12: for (size_t [[ITER:[i-t][0-9]*]] = {{.*}}; [[ITER]] < {{.*}}; [[ITER]] += {{.*}}) {41 emitc.for %i0 = %start to %stop step %step {42 emitc.for %i1 = %start to %stop step %step {43 emitc.for %i2 = %start to %stop step %step {44 emitc.for %i3 = %start to %stop step %step {45 emitc.for %i4 = %start to %stop step %step {46 emitc.for %i5 = %start to %stop step %step {47 emitc.for %i6 = %start to %stop step %step {48 emitc.for %i7 = %start to %stop step %step {49 emitc.for %i8 = %start to %stop step %step {50 emitc.for %i9 = %start to %stop step %step {51 emitc.for %i10 = %start to %stop step %step {52 emitc.for %i11 = %start to %stop step %step {53 // CHECK: for (size_t [[ITERu0:u13]] = {{.*}}; [[ITERu0]] < {{.*}}; [[ITERu0]] += {{.*}}) {54 emitc.for %i14 = %start to %stop step %step {55 // CHECK: for (size_t [[ITERu1:u14]] = {{.*}}; [[ITERu1]] < {{.*}}; [[ITERu1]] += {{.*}}) {56 emitc.for %i15 = %start to %stop step %step {57 %0 = emitc.call_opaque "f"() : () -> i3258 }59 }60 }61 }62 }63 }64 }65 }66 }67 }68 }69 }70 }71 }72 return73}74