14#include "mlir/Dialect/Arith/IR/Arith.h"
15#include "mlir/Dialect/OpenACC/OpenACC.h"
23 mlir::Location boundLoc, mlir::Value lowerBound,
24 mlir::Value upperBound, mlir::Value extent) {
31 builder.create<mlir::acc::DataBoundsOp>(boundLoc, lowerBound, upperBound);
32 bound.getStartIdxMutable().assign(startIdx);
34 bound.getExtentMutable().assign(extent);
35 bound.getStrideMutable().assign(stride);
45 mlir::IntegerType targetType = mlir::IntegerType::get(
48 ? mlir::IntegerType::SignednessSemantics::Signed
49 : mlir::IntegerType::SignednessSemantics::Unsigned);
51 auto conversionOp = builder.create<mlir::UnrealizedConversionCastOp>(
52 exprLoc, targetType,
expr);
53 return conversionOp.getResult(0);
59 mlir::IntegerType ty =
61 mlir::IntegerType::SignednessSemantics::Signless);
62 auto constOp = builder.create<mlir::arith::ConstantOp>(
63 loc, builder.getIntegerAttr(ty, value));
65 return constOp.getResult();
75 std::string exprString;
76 llvm::raw_string_ostream os(exprString);
79 while (isa<ArraySectionExpr, ArraySubscriptExpr>(curVarExpr)) {
81 mlir::Value lowerBound;
82 mlir::Value upperBound;
85 if (
const auto *section = dyn_cast<ArraySectionExpr>(curVarExpr)) {
86 if (
const Expr *lb = section->getLowerBound())
91 if (
const Expr *len = section->getLength()) {
95 section->getBase()->IgnoreParenImpCasts());
103 arrayTy->getLimitedSize() - 1);
108 const auto *subscript = cast<ArraySubscriptExpr>(curVarExpr);
116 bounds.push_back(createBound(*
this, this->builder, boundLoc, lowerBound,
117 upperBound, extent));
120 if (
const auto *memExpr = dyn_cast<MemberExpr>(curVarExpr))
129 const auto *dre = cast<DeclRefExpr>(curVarExpr);
Defines the clang::Expr interface and subclasses for C++ expressions.
const ConstantArrayType * getAsConstantArrayType(QualType T) const
static QualType getBaseOriginalType(const Expr *Base)
Return original type of the base expression for array section.
LValue emitMemberExpr(const MemberExpr *e)
OpenACCDataOperandInfo getOpenACCDataOperandInfo(const Expr *e)
mlir::Value emitScalarExpr(const clang::Expr *e)
Emit the computation of the specified expression of scalar type.
mlir::Value emitOpenACCIntExpr(const Expr *intExpr)
mlir::MLIRContext & getMLIRContext()
mlir::Value createOpenACCConstantInt(mlir::Location loc, unsigned width, int64_t value)
LValue emitDeclRefLValue(const clang::DeclRefExpr *e)
clang::ASTContext & getContext() const
mlir::Location getLoc(clang::SourceLocation cLoc)
Helpers to convert the presumed location of Clang's SourceLocation to an MLIR Location.
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.