10#include "mlir/IR/BuiltinAttributes.h" 
   12#include "llvm/ADT/ArrayRef.h" 
   13#include "llvm/ADT/TypeSwitch.h" 
   20  const auto arrayPtrTy = mlir::cast<cir::PointerType>(arrayPtr.getType());
 
   21  const auto arrayTy = mlir::dyn_cast<cir::ArrayType>(arrayPtrTy.getPointee());
 
   24    const cir::PointerType flatPtrTy = 
getPointerTo(arrayTy.getElementType());
 
   25    return cir::CastOp::create(*
this, loc, flatPtrTy,
 
   26                               cir::CastKind::array_to_ptrdecay, arrayPtr);
 
   29  assert(arrayPtrTy.getPointee() == eltTy &&
 
   30         "flat pointee type must match original array element type");
 
 
   35                                             mlir::Location arrayLocEnd,
 
   37                                             mlir::Type eltTy, mlir::Value idx,
 
   39  mlir::Value basePtr = arrayPtr;
 
   42  const mlir::Type flatPtrTy = basePtr.getType();
 
   43  return cir::PtrStrideOp::create(*
this, arrayLocEnd, flatPtrTy, basePtr, idx);
 
 
   47                                             llvm::APSInt intVal) {
 
   48  bool isSigned = intVal.isSigned();
 
   49  unsigned width = intVal.getBitWidth();
 
   52                     isSigned ? intVal.getSExtValue() : intVal.getZExtValue());
 
 
   62  assert(mlir::isa<cir::IntType>(t) && 
"expected cir::IntType");
 
   63  return cir::ConstantOp::create(*
this, loc, cir::IntAttr::get(t, 
c));
 
 
   68                                           llvm::APFloat fpVal) {
 
   69  assert(mlir::isa<cir::FPTypeInterface>(t) && 
"expected floating point type");
 
   70  return cir::ConstantOp::create(*
this, loc, cir::FPAttr::get(t, fpVal));
 
 
   79  auto getIndexAndNewOffset =
 
   80      [](int64_t offset, int64_t eltSize) -> std::pair<int64_t, int64_t> {
 
   81    int64_t divRet = offset / eltSize;
 
   84    int64_t modRet = offset - (divRet * eltSize);
 
   85    return {divRet, modRet};
 
   89      llvm::TypeSwitch<mlir::Type, mlir::Type>(ty)
 
   90          .Case<cir::ArrayType>([&](
auto arrayTy) {
 
   92            const auto [
index, newOffset] =
 
   93                getIndexAndNewOffset(offset, eltSize);
 
   94            indices.push_back(
index);
 
   96            return arrayTy.getElementType();
 
   98          .Case<cir::RecordType>([&](
auto recordTy) {
 
  101            for (
size_t i = 0; i < elts.size(); ++i) {
 
  105              if (recordTy.getPacked())
 
  111              if (!recordTy.isUnion())
 
  112                pos = (pos + alignMask) & ~alignMask;
 
  114              if (offset < pos + eltSize) {
 
  115                indices.push_back(i);
 
  120              if (!recordTy.isUnion())
 
  123            llvm_unreachable(
"offset was not found within the record");
 
  125          .
Default([](mlir::Type otherTy) {
 
  126            llvm_unreachable(
"unexpected type");
 
 
  137    mlir::ArrayAttr fields, 
bool packed, 
bool padded, llvm::StringRef name) {
 
  140  members.reserve(fields.size());
 
  141  llvm::transform(fields, std::back_inserter(members),
 
  142                  [](mlir::Attribute 
attr) {
 
  143                    return mlir::cast<mlir::TypedAttr>(
attr).getType();
 
 
  153    mlir::ArrayAttr arrayAttr, 
bool packed, 
bool padded, mlir::Type 
type) {
 
  154  auto recordTy = mlir::cast_or_null<cir::RecordType>(
type);
 
  162  const bool isZero = llvm::all_of(
 
  163      arrayAttr, [&](mlir::Attribute a) { 
return isNullValue(a); });
 
  165    return cir::ZeroAttr::get(recordTy);
 
  166  return cir::ConstRecordAttr::get(recordTy, arrayAttr);
 
 
  172                                 mlir::Type elemTy)
 const {
 
 
__device__ __2f16 float c
 
cir::PointerType getPointerTo(mlir::Type ty)
 
mlir::Value createPtrBitcast(mlir::Value src, mlir::Type newPointeeTy)
 
llvm::TypeSize getTypeAllocSize(mlir::Type ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
 
llvm::Align getABITypeAlign(mlir::Type ty) const
 
Address withElementType(CIRGenBuilderTy &builder, mlir::Type ElemTy) const
Return address with different element type, a bitcast pointer, and the same alignment.
 
clang::CharUnits getAlignment() const
 
mlir::Value getBasePointer() const
 
cir::RecordType getCompleteNamedRecordType(llvm::ArrayRef< mlir::Type > members, bool packed, bool padded, llvm::StringRef name)
Get a CIR named record type.
 
cir::IntType getSIntNTy(int n)
 
mlir::Attribute getConstRecordOrZeroAttr(mlir::ArrayAttr arrayAttr, bool packed=false, bool padded=false, mlir::Type type={})
 
cir::RecordType getAnonRecordTy(llvm::ArrayRef< mlir::Type > members, bool packed=false, bool padded=false)
Get a CIR anonymous record type.
 
mlir::Value maybeBuildArrayDecay(mlir::Location loc, mlir::Value arrayPtr, mlir::Type eltTy)
Returns a decayed pointer to the first element of the array pointed to by arrayPtr.
 
cir::ConstantOp getConstFP(mlir::Location loc, mlir::Type t, llvm::APFloat fpVal)
 
bool isNullValue(mlir::Attribute attr) const
 
cir::RecordType getCompleteRecordType(mlir::ArrayAttr fields, bool packed=false, bool padded=false, llvm::StringRef name="")
 
cir::ConstantOp getConstInt(mlir::Location loc, llvm::APSInt intVal)
 
void computeGlobalViewIndicesFromFlatOffset(int64_t offset, mlir::Type ty, cir::CIRDataLayout layout, llvm::SmallVectorImpl< int64_t > &indices)
 
cir::IntType getUIntNTy(int n)
 
mlir::Value getArrayElement(mlir::Location arrayLocBegin, mlir::Location arrayLocEnd, mlir::Value arrayPtr, mlir::Type eltTy, mlir::Value idx, bool shouldDecay)
Create a cir.ptr_stride operation to get access to an array element.
 
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
 
static bool addressPointerAuthInfo()
 
static bool addressOffset()
 
static bool astRecordDeclAttr()
 
static bool addressIsKnownNonNull()