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));
74 if (
const auto *section =
76 origType = section->getElementType();
82 std::string exprString;
83 llvm::raw_string_ostream os(exprString);
86 auto addBoundType = [&](
const Expr *e) {
87 if (
const auto *section = dyn_cast<ArraySectionExpr>(curVarExpr))
88 boundTypes.push_back(section->getElementType());
90 boundTypes.push_back(curVarExpr->
getType());
93 addBoundType(curVarExpr);
97 mlir::Value lowerBound;
98 mlir::Value upperBound;
101 if (
const auto *section = dyn_cast<ArraySectionExpr>(curVarExpr)) {
102 if (
const Expr *lb = section->getLowerBound())
107 if (
const Expr *len = section->getLength()) {
110 QualType baseTy = section->getBaseType();
118 arrayTy->getLimitedSize() - 1);
131 bounds.push_back(createBound(*
this, this->builder, boundLoc, lowerBound,
132 upperBound, extent));
133 addBoundType(curVarExpr);
136 if (
const auto *memExpr = dyn_cast<MemberExpr>(curVarExpr))
143 std::move(boundTypes)};
156 std::move(boundTypes)};
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)
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::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)