================ @@ -66,6 +66,62 @@ clang::CIRGen::CIRGenBuilderTy::getConstFP(mlir::Location loc, mlir::Type t, return create<cir::ConstantOp>(loc, cir::FPAttr::get(t, fpVal)); } +void CIRGenBuilderTy::computeGlobalViewIndicesFromFlatOffset( + int64_t offset, mlir::Type ty, cir::CIRDataLayout layout, + llvm::SmallVectorImpl<int64_t> &indices) { + if (!offset) + return; + + mlir::Type subType; + + auto getIndexAndNewOffset = + [](int64_t offset, int64_t eltSize) -> std::pair<int64_t, int64_t> { + int64_t divRet = offset / eltSize; + if (divRet < 0) + divRet -= 1; // make sure offset is positive + int64_t modRet = offset - (divRet * eltSize); + return {divRet, modRet}; + }; + + if (auto arrayTy = mlir::dyn_cast<cir::ArrayType>(ty)) { ---------------- bcardosolopes wrote:
Should we use `TypeSwitch` here and it's result is directly into `subType`? https://github.com/llvm/llvm-project/pull/153254 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits