brintos

brintos / llvm-project-archived public Read only

0
0
Text · 7.4 KiB · 4b0818f Raw
234 lines · cpp
1// Check no warnings/errors2// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -std=c++20 -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 -std=c++20 -fopenmp -fopenmp-version=60 -ast-dump  %s | FileCheck %s --check-prefix=DUMP7// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -std=c++20 -fopenmp -fopenmp-version=60 -ast-print %s | FileCheck %s --check-prefix=PRINT8 9// Check same results after serialization round-trip10// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -std=c++20 -fopenmp -fopenmp-version=60 -emit-pch -o %t %s11// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -std=c++20 -fopenmp -fopenmp-version=60 -include-pch %t -ast-dump-all %s | FileCheck %s --check-prefix=DUMP12// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -std=c++20 -fopenmp -fopenmp-version=60 -include-pch %t -ast-print    %s | FileCheck %s --check-prefix=PRINT13 14#ifndef HEADER15#define HEADER16 17// placeholder for loop body code.18extern "C" void body(...);19 20// PRINT-LABEL: void foo1(21// DUMP-LABEL:  FunctionDecl {{.*}} foo122void foo1() {23  // PRINT: #pragma omp interchange24  // DUMP:  OMPInterchangeDirective25  #pragma omp interchange26  // PRINT: for (int i = 7; i < 17; i += 3)27  // DUMP-NEXT: ForStmt28  for (int i = 7; i < 17; i += 3)29    // PRINT: for (int j = 7; j < 17; j += 3)30    // DUMP:  ForStmt31    for (int j = 7; j < 17; j += 3)32      // PRINT: body(i, j);33      // DUMP:  CallExpr34      body(i, j);35}36 37 38// PRINT-LABEL: void foo2(39// DUMP-LABEL:  FunctionDecl {{.*}} foo240void foo2(int start1, int start2, int start3, int end1, int end2, int end3) {41  // PRINT:     #pragma omp interchange permutation(2, 3, 1)42  // DUMP:      OMPInterchangeDirective43  // DUMP-NEXT:   OMPPermutationClause44  // DUMP-NEXT:     ConstantExpr45  // DUMP-NEXT:       value: Int 246  // DUMP-NEXT:       IntegerLiteral {{.*}} 247  // DUMP-NEXT:     ConstantExpr48  // DUMP-NEXT:       value: Int 349  // DUMP-NEXT:       IntegerLiteral {{.*}} 350  // DUMP-NEXT:     ConstantExpr51  // DUMP-NEXT:       value: Int 152  // DUMP-NEXT:       IntegerLiteral {{.*}} 153 #pragma omp interchange permutation(2,3,1)54  // PRINT: for (int i = start1; i < end1; i += 1)55  // DUMP-NEXT: ForStmt56  for (int i = start1; i < end1; i += 1)57    // PRINT: for (int j = start2; j < end2; j += 1)58    // DUMP:  ForStmt59    for (int j = start2; j < end2; j += 1)60    // PRINT: for (int k = start3; k < end3; k += 1)61    // DUMP:  ForStmt62      for (int k = start3; k < end3; k += 1)63      // PRINT: body(i, j, k);64      // DUMP:  CallExpr65      body(i, j, k);66}67 68 69// PRINT-LABEL: void foo3(70// DUMP-LABEL:  FunctionDecl {{.*}} foo371void foo3() {72  // PRINT: #pragma omp for collapse(3)73  // DUMP:      OMPForDirective74  // DUMP-NEXT:   OMPCollapseClause75  // DUMP-NEXT:     ConstantExpr76  // DUMP-NEXT:       value: Int 377  // DUMP-NEXT:     IntegerLiteral {{.*}} 378  // DUMP-NEXT:     CapturedStmt79  // DUMP-NEXT:       CapturedDecl80  #pragma omp for collapse(3)81  // PRINT: #pragma omp interchange82  // DUMP:  OMPInterchangeDirective83  #pragma omp interchange84  // PRINT: for (int i = 7; i < 17; i += 1)85  // DUMP-NEXT: ForStmt86  for (int i = 7; i < 17; i += 1)87    // PRINT: for (int j = 7; j < 17; j += 1)88    // DUMP:  ForStmt89    for (int j = 7; j < 17; j += 1)90      // PRINT: for (int k = 7; k < 17; k += 1)91      // DUMP:  ForStmt92      for (int k = 7; k < 17; k += 1)93        // PRINT: body(i, j, k);94        // DUMP:  CallExpr95        body(i, j, k);96}97 98 99// PRINT-LABEL: void foo4(100// DUMP-LABEL:  FunctionDecl {{.*}} foo4101void foo4(int start, int end, int step) {102  // PRINT: #pragma omp for collapse(3)103  // DUMP:      OMPForDirective104  // DUMP-NEXT:   OMPCollapseClause105  // DUMP-NEXT:    ConstantExpr106  // DUMP-NEXT:      value: Int 3107  // DUMP-NEXT:    IntegerLiteral {{.*}} 3108  // DUMP-NEXT:  CapturedStmt109  // DUMP-NEXT:    CapturedDecl110  #pragma omp for collapse(3)111  // PRINT:     for (int i = 7; i < 17; i += 1)112  // DUMP-NEXT: ForStmt113  for (int i = 7; i < 17; i += 1)114    // PRINT:     #pragma omp interchange permutation(1)115    // DUMP:      OMPInterchangeDirective116    // DUMP-NEXT:   OMPPermutationClause117    // DUMP-NEXT:     ConstantExpr118    // DUMP-NEXT:       value: Int 1119    // DUMP-NEXT:       IntegerLiteral {{.*}} 1120    #pragma omp interchange permutation(1)121    // PRINT:     for (int j = 7; j < 17; j += 1)122    // DUMP-NEXT: ForStmt123    for (int j = 7; j < 17; j += 1)124      // PRINT: for (int k = 7; k < 17; k += 1)125      // DUMP:  ForStmt126      for (int k = 7; k < 17; k += 1)127        // PRINT: body(i, j, k);128        // DUMP:  CallExpr129        body(i, j, k);130}131 132 133// PRINT-LABEL: void foo5(134// DUMP-LABEL: FunctionTemplateDecl {{.*}} foo5135template<typename T, T P>136void foo5(T start, T end) {137  // PRINT: #pragma omp for138  // DUMP:  OMPForDirective139  #pragma omp for140    // PRINT:     #pragma omp interchange permutation(P + 1, 2 - P)141    // DUMP:      OMPInterchangeDirective142    // DUMP-NEXT:   OMPPermutationClause143    // DUMP-NEXT:     BinaryOperator {{.*}} '+'144    // DUMP-NEXT:       DeclRefExpr {{.*}} 'P' 'T'145    // DUMP-NEXT:       IntegerLiteral {{.*}} 'int' 1146    // DUMP-NEXT:     BinaryOperator {{.*}} '-'147    // DUMP-NEXT:       IntegerLiteral {{.*}} 'int' 2148    // DUMP-NEXT:       DeclRefExpr {{.*}} 'P' 'T'149    #pragma omp interchange permutation(P + 1, 2 - P)150    // PRINT-NEXT: for (T i = start; i < end; i += 2)151    // DUMP-NEXT:  ForStmt152    for (T i = start; i < end; i += 2)153      // PRINT-NEXT: for (T j = start; j < end; j += 2)154      // DUMP:       ForStmt155      for (T j = start; j < end; j += 2)156        // PRINT-NEXT: body(i, j);157        // DUMP:       CallExpr158        body(i,j);159}160 161// Also test instantiating the template.162void tfoo5() {163  foo5<int,0>(0, 42);164  foo5<int,1>(0, 42);165}166 167 168// PRINT-LABEL: void foo6(169// DUMP-LABEL: FunctionTemplateDecl {{.*}} foo6170template<int Tile>171void foo6() {172    // PRINT:     #pragma omp interchange173    // DUMP:      OMPInterchangeDirective174    #pragma omp interchange175      // PRINT-NEXT: for (int i = 0; i < 11; i += 2)176      // DUMP-NEXT:  ForStmt177      for (int i = 0; i < 11; i += 2)178        // PRINT-NEXT: #pragma omp tile sizes(Tile)179        // DUMP:       OMPTileDirective180        #pragma omp tile sizes(Tile)181        // PRINT-NEXT: for (int j = 0; j < 13; j += 2)182        // DUMP:       ForStmt183        for (int j = 0; j < 13; j += 2)184          // PRINT-NEXT: body(i, j);185          // DUMP:       CallExpr186          body(i, j);187}188 189// Also test instantiating the template.190void tfoo6() {191  foo6<32>();192}193 194 195// PRINT-LABEL: void foo7(196// DUMP-LABEL: FunctionDecl {{.*}} foo7197void foo7() {198  double arr[128];199  // PRINT: #pragma omp interchange200  // DUMP:  OMPInterchangeDirective201  #pragma omp interchange202  // PRINT-NEXT: for (double c = 42; auto &&v : arr)203  // DUMP-NEXT:  CXXForRangeStmt204  for (double c = 42; auto &&v : arr)205    // PRINT-NEXT: for (int i = 0; i < 42; i += 2)206    // DUMP:       ForStmt207    for (int i = 0; i < 42; i += 2)208      // PRINT-NEXT: body(c, v, i);209      // DUMP:       CallExpr210      body(c, v, i);211}212 213 214// PRINT-LABEL: void foo8(215// DUMP-LABEL: FunctionDecl {{.*}} foo8216void foo8() {217  double arr[128];218  // PRINT: #pragma omp interchange219  // DUMP:  OMPInterchangeDirective220  #pragma omp interchange221  // PRINT-NEXT: for (int i = 0; i < 42; i += 2)222  // DUMP-NEXT:  ForStmt223  for (int i = 0; i < 42; i += 2)224    // PRINT-NEXT: for (double c = 42; auto &&v : arr)225    // DUMP:       CXXForRangeStmt226    for (double c = 42; auto &&v : arr)227      // PRINT-NEXT: body(i, c, v);228      // DUMP:       CallExpr229      body(i, c, v);230}231 232#endif233 234