clang: lib/CIR/CodeGen/CIRGenOpenACC.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

14#include "mlir/Dialect/Arith/IR/Arith.h"

15#include "mlir/Dialect/OpenACC/OpenACC.h"

17

18using namespace clang;

20

21namespace {

23 mlir::Location boundLoc, mlir::Value lowerBound,

24 mlir::Value upperBound, mlir::Value extent) {

25

27

29

30 auto bound = mlir::acc::DataBoundsOp::create(builder, boundLoc, lowerBound,

31 upperBound);

32 bound.getStartIdxMutable().assign(startIdx);

33 if (extent)

34 bound.getExtentMutable().assign(extent);

35 bound.getStrideMutable().assign(stride);

36

37 return bound;

38}

39}

40

43 mlir::Location exprLoc = cgm.getLoc(intExpr->getBeginLoc());

44

45 mlir::IntegerType targetType = mlir::IntegerType::get(

48 ? mlir::IntegerType::SignednessSemantics::Signed

49 : mlir::IntegerType::SignednessSemantics::Unsigned);

50

51 auto conversionOp = mlir::UnrealizedConversionCastOp::create(

52 builder, exprLoc, targetType, expr);

53 return conversionOp.getResult(0);

54}

55

57 unsigned width,

58 int64_t value) {

59 mlir::IntegerType ty =

61 mlir::IntegerType::SignednessSemantics::Signless);

62 auto constOp = mlir::arith::ConstantOp::create(

63 builder, loc, builder.getIntegerAttr(ty, value));

64

65 return constOp;

66}

67

73

74 if (const auto *section =

76 origType = section->getElementType();

77

78 mlir::Location exprLoc = cgm.getLoc(curVarExpr->getBeginLoc());

81

82 std::string exprString;

83 llvm::raw_string_ostream os(exprString);

85

86 auto addBoundType = [&](const Expr *e) {

87 if (const auto *section = dyn_cast(curVarExpr))

88 boundTypes.push_back(section->getElementType());

89 else

90 boundTypes.push_back(curVarExpr->getType());

91 };

92

93 addBoundType(curVarExpr);

94

96 mlir::Location boundLoc = cgm.getLoc(curVarExpr->getBeginLoc());

97 mlir::Value lowerBound;

98 mlir::Value upperBound;

99 mlir::Value extent;

100

101 if (const auto *section = dyn_cast(curVarExpr)) {

102 if (const Expr *lb = section->getLowerBound())

104 else

106

107 if (const Expr *len = section->getLength()) {

109 } else {

110 QualType baseTy = section->getBaseType();

111

112

113

115

116

118 arrayTy->getLimitedSize() - 1);

119 }

120

122 } else {

124

126

129 }

130

131 bounds.push_back(createBound(*this, this->builder, boundLoc, lowerBound,

132 upperBound, extent));

133 addBoundType(curVarExpr);

134 }

135

136 if (const auto *memExpr = dyn_cast(curVarExpr))

137 return {exprLoc,

139 exprString,

140 origType,

142 std::move(bounds),

143 std::move(boundTypes)};

144

145

146

147

148

150 return {exprLoc,

152 exprString,

153 origType,

155 std::move(bounds),

156 std::move(boundTypes)};

157}

Defines the clang::Expr interface and subclasses for C++ expressions.

const ConstantArrayType * getAsConstantArrayType(QualType T) const

LValue emitMemberExpr(const MemberExpr *e)

OpenACCDataOperandInfo getOpenACCDataOperandInfo(const Expr *e)

Definition CIRGenOpenACC.cpp:69

mlir::Value emitScalarExpr(const clang::Expr *e, bool ignoreResultAssign=false)

Emit the computation of the specified expression of scalar type.

mlir::Value emitOpenACCIntExpr(const Expr *intExpr)

Definition CIRGenOpenACC.cpp:41

mlir::MLIRContext & getMLIRContext()

mlir::Value createOpenACCConstantInt(mlir::Location loc, unsigned width, int64_t value)

Definition CIRGenOpenACC.cpp:56

LValue emitDeclRefLValue(const clang::DeclRefExpr *e)

clang::ASTContext & getContext() const

mlir::Value getPointer() const

This represents one expression.

Expr * IgnoreParenImpCasts() LLVM_READONLY

Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...

A (possibly-)qualified type.

QualType getNonReferenceType() const

If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...

QualType getUnqualifiedType() const

Retrieve the unqualified variant of the given type, removing as little sugar as possible.

void printPretty(raw_ostream &OS, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation=0, StringRef NewlineSymbol="\n", const ASTContext *Context=nullptr) const

SourceLocation getBeginLoc() const LLVM_READONLY

bool isSignedIntegerOrEnumerationType() const

Determines whether this is an integer type that is signed or an enumeration types whose underlying ty...

const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr

Matches expressions.

The JSON file list parser is used to communicate input to InstallAPI.

bool isa(CodeGen::Address addr)

U cast(CodeGen::Address addr)