Skip to content

src/OmpPragma.h

Classes

Name
class OmpPragma
A helper class to rewrite some "pragma omp" (mostly teams and similar combined constructs), which are not supported by sotoc.

Source code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//===-- sotoc/src/OmpPragma.h ---------------------------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#pragma once

#include "clang/AST/OpenMPClause.h"
#include "clang/AST/StmtOpenMP.h"
#include "llvm/ADT/APInt.h"
#include "llvm/Support/raw_ostream.h"

#include "TargetCodeFragment.h"
#include <vector>

class OmpPragma {
  clang::PrintingPolicy PP;
  llvm::ArrayRef<clang::OMPClause *> Clauses;
  clang::OpenMPDirectiveKind Kind;
  unsigned int ClauseParamCounter;

public:
  OmpPragma(TargetCodeRegion *TCR)
      : PP(TCR->getPP()), Clauses(TCR->getOMPClauses()),
        Kind(TCR->getTargetCodeKind()), ClauseParamCounter(0) {};
  OmpPragma(clang::OMPExecutableDirective *Directive, clang::PrintingPolicy PP)
      : PP(PP), Clauses(Directive->clauses()),
        Kind(Directive->getDirectiveKind()), ClauseParamCounter(0) {};
  bool needsStructuredBlock();
  void printReplacement(llvm::raw_ostream &Out);
  void printAddition(llvm::raw_ostream &Out);
  static bool isReplaceable(clang::OMPExecutableDirective *Directive);
  static bool needsAdditionalPragma(clang::OMPExecutableDirective *Directive);
private:
  bool isClausePrintable(clang::OMPClause *Clause);
  void rewriteParam(std::string *In);
  void printClauses(llvm::raw_ostream &Out);
};

Last update: 2021-11-24
Back to top