brintos

brintos / llvm-project-archived public Read only

0
0
Text · 6.1 KiB · e632caf Raw
203 lines · cpp
1// Check no warnings/errors2// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=60 -fsyntax-only -verify %s3// expected-no-diagnostics4 5// Check AST and unparsing6// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=60 -ast-dump  %s \7// RUN: | FileCheck %s --check-prefix=DUMP8// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=60 -ast-print %s \9// RUN: | FileCheck %s --check-prefix=PRINT10 11// Check same results after serialization round-trip12// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=60 -emit-pch -o %t %s13// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=60 -ast-dump-all %s \14// RUN: | FileCheck %s --check-prefix=DUMP15// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=60 -ast-print %s \16// RUN: | FileCheck %s --check-prefix=PRINT17 18// placeholder for loop body code.19extern "C" void body(...);20 21 22// PRINT-LABEL: void foo1(23// DUMP-LABEL:  FunctionDecl {{.*}} foo124void foo1() {25  // PRINT:     #pragma omp stripe sizes(5, 5)26  // DUMP:      OMPStripeDirective27  // DUMP-NEXT:   OMPSizesClause28  // DUMP-NEXT:     IntegerLiteral {{.*}} 529  // DUMP-NEXT:     IntegerLiteral {{.*}} 530  #pragma omp stripe sizes(5,5)31  // PRINT: for (int i = 7; i < 17; i += 3)32  // DUMP-NEXT: ForStmt33  for (int i = 7; i < 17; i += 3)34    // PRINT: for (int j = 7; j < 17; j += 3)35    // DUMP:  ForStmt36    for (int j = 7; j < 17; j += 3)37    // PRINT: body(i, j);38    // DUMP:  CallExpr39      body(i, j);40}41 42 43// PRINT-LABEL: void foo2(44// DUMP-LABEL:  FunctionDecl {{.*}} foo245void foo2(int start1, int start2, int end1, int end2) {46  // PRINT:     #pragma omp stripe sizes(5, 5)47  // DUMP:      OMPStripeDirective48  // DUMP-NEXT:   OMPSizesClause49  // DUMP-NEXT:     IntegerLiteral {{.*}} 550  // DUMP-NEXT:     IntegerLiteral {{.*}} 551  #pragma omp stripe sizes(5,5)52  // PRINT: for (int i = start1; i < end1; i += 1)53  // DUMP-NEXT: ForStmt54  for (int i = start1; i < end1; i += 1)55    // PRINT: for (int j = start2; j < end2; j += 1)56    // DUMP:  ForStmt57    for (int j = start2; j < end2; j += 1)58      // PRINT: body(i, j);59      // DUMP:  CallExpr60      body(i, j);61}62 63 64// PRINT-LABEL: void foo3(65// DUMP-LABEL:  FunctionDecl {{.*}} foo366void foo3() {67  // PRINT: #pragma omp for68  // DUMP:  OMPForDirective69  // DUMP-NEXT:    CapturedStmt70  // DUMP-NEXT:      CapturedDecl71  #pragma omp for72  // PRINT:     #pragma omp stripe sizes(5)73  // DUMP-NEXT:      OMPStripeDirective74  // DUMP-NEXT:   OMPSizesClause75  // DUMP-NEXT:     IntegerLiteral {{.*}} 576  #pragma omp stripe sizes(5)77  for (int i = 7; i < 17; i += 3)78    // PRINT: body(i);79    // DUMP:  CallExpr80    body(i);81}82 83 84// PRINT-LABEL: void foo4(85// DUMP-LABEL:  FunctionDecl {{.*}} foo486void foo4() {87  // PRINT: #pragma omp for collapse(3)88  // DUMP: OMPForDirective89  // DUMP-NEXT: OMPCollapseClause90  // DUMP-NEXT:  ConstantExpr91  // DUMP-NEXT:  value: Int 392  // DUMP-NEXT:  IntegerLiteral {{.*}} 393  // DUMP-NEXT:    CapturedStmt94  // DUMP-NEXT:      CapturedDecl95  #pragma omp for collapse(3)96  // PRINT:     #pragma omp stripe sizes(5, 5)97  // DUMP:      OMPStripeDirective98  // DUMP-NEXT:   OMPSizesClause99  // DUMP-NEXT:     IntegerLiteral {{.*}} 5100  // DUMP-NEXT:     IntegerLiteral {{.*}} 5101  #pragma omp stripe sizes(5, 5)102  // PRINT: for (int i = 7; i < 17; i += 1)103  // DUMP-NEXT: ForStmt104  for (int i = 7; i < 17; i += 1)105    // PRINT: for (int j = 7; j < 17; j += 1)106    // DUMP:  ForStmt107    for (int j = 7; j < 17; j += 1)108      // PRINT: body(i, j);109      // DUMP:  CallExpr110      body(i, j);111}112 113 114// PRINT-LABEL: void foo5(115// DUMP-LABEL:  FunctionDecl {{.*}} foo5116void foo5(int start, int end, int step) {117  // PRINT: #pragma omp for collapse(2)118  // DUMP:      OMPForDirective119  // DUMP-NEXT:   OMPCollapseClause120  // DUMP-NEXT:    ConstantExpr121  // DUMP-NEXT:      value: Int 2122  // DUMP-NEXT:    IntegerLiteral {{.*}} 2123  // DUMP-NEXT:  CapturedStmt124  // DUMP-NEXT:    CapturedDecl125  #pragma omp for collapse(2)126  // PRINT: for (int i = 7; i < 17; i += 1)127  // DUMP-NEXT: ForStmt128  for (int i = 7; i < 17; i += 1)129    // PRINT:     #pragma omp stripe sizes(5)130    // DUMP:      OMPStripeDirective131    // DUMP-NEXT:   OMPSizesClause132    // DUMP-NEXT:     IntegerLiteral {{.*}} 5133    #pragma omp stripe sizes(5)134    // PRINT: for (int j = 7; j < 17; j += 1)135    // DUMP-NEXT: ForStmt136    for (int j = 7; j < 17; j += 1)137      // PRINT: body(i, j);138      // DUMP:  CallExpr139      body(i, j);140}141 142 143// PRINT-LABEL: void foo6(144// DUMP-LABEL: FunctionTemplateDecl {{.*}} foo6145template<typename T, T Step, T Stripe>146void foo6(T start, T end) {147  // PRINT: #pragma omp stripe sizes(Stripe)148  // DUMP:      OMPStripeDirective149  // DUMP-NEXT:   OMPSizesClause150  // DUMP-NEXT:     DeclRefExpr {{.*}} 'Stripe' 'T'151  #pragma omp stripe sizes(Stripe)152    // PRINT-NEXT:  for (T i = start; i < end; i += Step)153    // DUMP-NEXT: ForStmt154    for (T i = start; i < end; i += Step)155      // PRINT-NEXT: body(i);156      // DUMP:  CallExpr157      body(i);158}159 160// Also test instantiating the template.161void tfoo6() {162  foo6<int,3,5>(0, 42);163}164 165 166// PRINT-LABEL: template <int Stripe> void foo7(int start, int stop, int step) {167// DUMP-LABEL: FunctionTemplateDecl {{.*}} foo7168template <int Stripe>169void foo7(int start, int stop, int step) {170  // PRINT: #pragma omp stripe sizes(Stripe)171  // DUMP:      OMPStripeDirective172  // DUMP-NEXT:   OMPSizesClause173  // DUMP-NEXT:     DeclRefExpr {{.*}} 'Stripe' 'int'174  #pragma omp stripe sizes(Stripe)175    // PRINT-NEXT:  for (int i = start; i < stop; i += step)176    // DUMP-NEXT: ForStmt177    for (int i = start; i < stop; i += step)178      // PRINT-NEXT: body(i);179      // DUMP:  CallExpr180      body(i);181}182void tfoo7() {183  foo7<5>(0, 42, 2);184}185 186 187// PRINT-LABEL: void foo8(188// DUMP-LABEL:  FunctionDecl {{.*}} foo8189void foo8(int a) {190  // PRINT:     #pragma omp stripe sizes(a)191  // DUMP:      OMPStripeDirective192  // DUMP-NEXT:   OMPSizesClause193  // DUMP-NEXT:     ImplicitCastExpr194  // DUMP-NEXT:       DeclRefExpr {{.*}} 'a'195  #pragma omp stripe sizes(a)196  // PRINT-NEXT: for (int i = 7; i < 19; i += 3)197  // DUMP-NEXT: ForStmt198  for (int i = 7; i < 19; i += 3)199    // PRINT: body(i);200    // DUMP:  CallExpr201    body(i);202}203