9#ifndef LLVM_CLANG_LIB_CIR_CODEGEN_CIRGENBUILDER_H
10#define LLVM_CLANG_LIB_CIR_CODEGEN_CIRGENBUILDER_H
15#include "mlir/Dialect/Ptr/IR/MemorySpaceInterfaces.h"
16#include "mlir/IR/Attributes.h"
17#include "mlir/IR/Builders.h"
18#include "mlir/IR/BuiltinAttributes.h"
19#include "mlir/Support/LLVM.h"
25#include "llvm/ADT/APFloat.h"
26#include "llvm/ADT/STLExtras.h"
27#include "llvm/IR/FPEnv.h"
34 llvm::StringMap<unsigned> recordNames;
35 llvm::StringMap<unsigned> globalsVersioning;
44 mlir::Attribute
getString(llvm::StringRef str, mlir::Type eltTy,
45 std::optional<size_t> size,
46 bool ensureNullTerm =
true) {
47 size_t finalSize = size.value_or(str.size());
49 size_t lastNonZeroPos = str.find_last_not_of(
'\0');
52 if (lastNonZeroPos == llvm::StringRef::npos) {
53 auto arrayTy = cir::ArrayType::get(eltTy, finalSize);
54 return cir::ZeroAttr::get(arrayTy);
60 size_t trailingZerosNum = finalSize - lastNonZeroPos - 1;
61 auto truncatedArrayTy =
62 cir::ArrayType::get(eltTy, finalSize - trailingZerosNum);
63 auto strAttr = mlir::StringAttr::get(str.drop_back(trailingZerosNum),
70 finalSize += (ensureNullTerm && trailingZerosNum == 0);
72 auto fullArrayTy = cir::ArrayType::get(eltTy, finalSize);
73 return cir::ConstArrayAttr::get(fullArrayTy, strAttr);
77 cir::ArrayType arrayTy)
const {
78 return cir::ConstArrayAttr::get(arrayTy, attrs);
86 for (
auto &f : arrayAttr) {
87 auto ta = mlir::cast<mlir::TypedAttr>(f);
88 members.push_back(ta.getType());
93 return cir::ConstRecordAttr::get(sTy, arrayAttr);
98 return cir::TypeInfoAttr::get(anonRecord.getType(), fieldsAttr);
104 auto it = recordNames.find(baseName);
105 if (it == recordNames.end()) {
106 recordNames[baseName] = 0;
110 return baseName +
"." + std::to_string(recordNames[baseName]++);
114 if (&
format == &llvm::APFloat::IEEEdouble())
115 return cir::LongDoubleType::get(getContext(), typeCache.doubleTy);
116 if (&
format == &llvm::APFloat::x87DoubleExtended())
117 return cir::LongDoubleType::get(getContext(), typeCache.fP80Ty);
118 if (&
format == &llvm::APFloat::IEEEquad())
119 return cir::LongDoubleType::get(getContext(), typeCache.fP128Ty);
120 if (&
format == &llvm::APFloat::PPCDoubleDouble())
121 llvm_unreachable(
"NYI: PPC double-double format for long double");
122 llvm_unreachable(
"Unsupported format for long double");
130 bool isVarArg =
false) {
131 return cir::FuncType::get(params, retTy, isVarArg);
153 const auto nameAttr = getStringAttr(name);
157 auto type = cir::StructType::get(getContext(), members, nameAttr, packed,
162 assert(!
type.isIncomplete() ||
163 (
type.getMembers() == members &&
type.getPacked() == packed));
167 type.complete(members, packed, memberKinds);
177 const mlir::StringAttr nameAttr = getStringAttr(name);
179 return cir::UnionType::get(getContext(), nameAttr);
181 return cir::StructType::get(getContext(), nameAttr, is_class);
190 bool skipTailPadding =
false) {
199 mlir::Value src, mlir::Value len) {
200 return cir::MemCpyOp::create(*
this, loc, dst, src, len);
204 mlir::Value src, mlir::Value len) {
205 return cir::MemMoveOp::create(*
this, loc, dst, src, len);
209 mlir::Value val, mlir::Value len) {
211 return cir::MemSetOp::create(*
this, loc, dst, {}, val, len);
218 return cir::MemSetOp::create(*
this, loc, dst.
getPointer(), align, val, len);
224 return cir::DataMemberAttr::get(ty, path);
228 return cir::DataMemberAttr::get(ty);
234 if (mlir::isa<cir::ZeroAttr>(
attr))
237 if (
const auto ptrVal = mlir::dyn_cast<cir::ConstPtrAttr>(
attr))
238 return ptrVal.isNullValue();
240 if (
const auto intVal = mlir::dyn_cast<cir::IntAttr>(
attr))
241 return intVal.isNullValue();
243 if (
const auto boolVal = mlir::dyn_cast<cir::BoolAttr>(
attr))
244 return !boolVal.getValue();
246 if (
auto fpAttr = mlir::dyn_cast<cir::FPAttr>(
attr)) {
247 auto fpVal = fpAttr.getValue();
249 llvm::APFloat fv(+0.0);
250 fv.convert(fpVal.getSemantics(), llvm::APFloat::rmNearestTiesToEven,
252 return fv.bitwiseIsEqual(fpVal);
254 if (
const auto recordVal = mlir::dyn_cast<cir::ConstRecordAttr>(
attr)) {
255 for (
const auto elt : recordVal.getMembers()) {
257 if (mlir::isa<mlir::StringAttr>(elt))
265 if (
const auto arrayVal = mlir::dyn_cast<cir::ConstArrayAttr>(
attr)) {
266 if (mlir::isa<mlir::StringAttr>(arrayVal.getElts()))
270 mlir::cast<mlir::ArrayAttr>(arrayVal.getElts()),
271 [&](
const mlir::Attribute &elt) { return isNullValue(elt); });
291 return cir::IntType::get(getContext(), n,
false);
306 return cir::IntType::get(getContext(), n,
true);
327 cir::ConstantOp
getConstInt(mlir::Location loc, llvm::APSInt intVal);
329 cir::ConstantOp
getConstInt(mlir::Location loc, llvm::APInt intVal,
332 cir::ConstantOp
getConstInt(mlir::Location loc, mlir::Type t, uint64_t c);
334 cir::ConstantOp
getConstFP(mlir::Location loc, mlir::Type t,
335 llvm::APFloat fpVal);
338 return i == typeCache.uInt8Ty || i == typeCache.sInt8Ty;
341 return i == typeCache.uInt16Ty || i == typeCache.sInt16Ty;
344 return i == typeCache.uInt32Ty || i == typeCache.sInt32Ty;
347 return i == typeCache.uInt64Ty || i == typeCache.sInt64Ty;
349 bool isInt(mlir::Type i) {
return mlir::isa<cir::IntType>(i); }
352 switch (ty.getWidth()) {
354 return isSigned ? typeCache.sInt16Ty : typeCache.uInt16Ty;
356 return isSigned ? typeCache.sInt32Ty : typeCache.uInt32Ty;
358 return isSigned ? typeCache.sInt64Ty : typeCache.uInt64Ty;
360 llvm_unreachable(
"NYI");
365 switch (ty.getWidth()) {
367 return isSigned ? typeCache.sInt8Ty : typeCache.uInt8Ty;
369 return isSigned ? typeCache.sInt16Ty : typeCache.uInt16Ty;
371 return isSigned ? typeCache.sInt32Ty : typeCache.uInt32Ty;
373 llvm_unreachable(
"NYI");
379 bool isSigned =
false) {
380 auto elementTy = mlir::dyn_cast_or_null<cir::IntType>(vt.getElementType());
381 assert(elementTy &&
"expected int vector");
382 return cir::VectorType::get(isExtended
396 return cir::StructType::get(getContext(), members, packed,
409 cir::ConstantOp
getSInt64(uint64_t c, mlir::Location loc) {
412 cir::ConstantOp
getUInt64(uint64_t c, mlir::Location loc) {
416 cir::ConstantOp
getZero(mlir::Location loc, mlir::Type ty) {
418 assert((mlir::isa<cir::RecordType>(ty) || mlir::isa<cir::ArrayType>(ty) ||
419 mlir::isa<cir::VectorType>(ty)) &&
420 "NYI for other types");
421 return cir::ConstantOp::create(*
this, loc, cir::ZeroAttr::get(ty));
427 mlir::Value
createNeg(mlir::Location loc, mlir::Value value,
430 if (
auto intTy = mlir::dyn_cast<cir::IntType>(value.getType())) {
432 if (intTy.isUnsigned())
437 llvm_unreachable(
"negation for the given type is NYI");
447 return cir::CastOp::create(*
this, v.getLoc(), destType,
448 cir::CastKind::floating, v,
453 cir::PointerType destType,
bool isRefCast,
454 cir::DynamicCastInfoAttr info) {
456 isRefCast ? cir::DynamicCastKind::Ref : cir::DynamicCastKind::Ptr;
457 return cir::DynamicCastOp::create(*
this, loc, destType, castKind, src, info,
462 bool vtableUseRelativeLayout) {
466 return cir::DynamicCastOp::create(
467 *
this, loc, destTy, cir::DynamicCastKind::Ptr, src,
468 cir::DynamicCastInfoAttr{}, vtableUseRelativeLayout);
475 mlir::Type destType,
unsigned offset,
476 bool assumeNotNull) {
482 cir::BaseClassAddrOp::create(*
this, loc, ptrTy, addr.
getPointer(),
483 mlir::APInt(64, offset), assumeNotNull);
488 mlir::Type destType,
unsigned offset,
489 bool assumeNotNull) {
495 cir::DerivedClassAddrOp::create(*
this, loc, ptrTy, addr.
getPointer(),
496 mlir::APInt(64, offset), assumeNotNull);
504 mlir::Value addr, uint64_t offset) {
505 return cir::VTTAddrPointOp::create(*
this, loc, retTy,
506 mlir::FlatSymbolRefAttr{}, addr, offset);
510 mlir::FlatSymbolRefAttr sym, uint64_t offset) {
511 return cir::VTTAddrPointOp::create(*
this, loc, retTy, sym, mlir::Value{},
519 cir::FPClassTest flags) {
525 assert((raw & ~
all) == 0 &&
"FPClassTest mask has bits outside 0-9");
526 flags =
static_cast<cir::FPClassTest
>(raw &
all);
527 return cir::IsFPClassOp::create(*
this, loc, src, flags);
533 mlir::Type destType) {
543 bool isVolatile =
false,
bool isNontemporal =
false) {
545 return cir::LoadOp::create(*
this, loc, addr.
getPointer(),
false,
546 isVolatile, isNontemporal,
548 cir::SyncScopeKindAttr{},
554 mlir::Value ptr, llvm::MaybeAlign align) {
555 if (ty != mlir::cast<cir::PointerType>(ptr.getType()).getPointee())
557 uint64_t alignment = align ? align->value() : 0;
559 return cir::LoadOp::create(*
this, loc, ptr,
false,
562 cir::SyncScopeKindAttr{},
574 bool isVolatile =
false,
bool isNontemporal =
false,
575 mlir::IntegerAttr align = {},
576 cir::SyncScopeKindAttr scope = {},
577 cir::MemOrderAttr order = {}) {
581 isNontemporal, align, scope, order);
587 auto srcPtrTy = mlir::cast<cir::PointerType>(value.getType());
588 auto srcComplexTy = mlir::cast<cir::ComplexType>(srcPtrTy.getPointee());
589 return cir::ComplexRealPtrOp::create(
590 *
this, loc,
getPointerTo(srcComplexTy.getElementType()), value);
602 auto srcPtrTy = mlir::cast<cir::PointerType>(value.getType());
603 auto srcComplexTy = mlir::cast<cir::ComplexType>(srcPtrTy.getPointee());
604 return cir::ComplexImagPtrOp::create(
605 *
this, loc,
getPointerTo(srcComplexTy.getElementType()), value);
615 llvm::StringRef name,
unsigned index) {
616 auto recordTy = mlir::cast<cir::RecordType>(base.
getElementType());
618 assert(
index < recordTy.getMembers().size() &&
619 "member index out of bounds");
620 mlir::Type memberTy = recordTy.getMembers()[
index];
624 getInsertionBlock()->getParentOp()->getParentOfType<mlir::ModuleOp>();
625 mlir::DataLayout layout(moduleOp);
629 mlir::Value memberPtr =
631 return Address(memberPtr, memberTy,
637 mlir::Value objectPtr,
638 mlir::Value memberPtr) {
639 auto memberPtrTy = mlir::cast<cir::DataMemberType>(memberPtr.getType());
643 cir::PointerType resultTy =
getPointerTo(memberPtrTy.getMemberTy());
645 return cir::GetRuntimeMemberOp::create(*
this, loc, resultTy, objectPtr,
653 mlir::Location arrayLocEnd, mlir::Value arrayPtr,
654 mlir::Type eltTy, mlir::Value idx,
678 [[nodiscard]] cir::GlobalOp
680 mlir::StringRef name, mlir::Type
type,
bool isConstant,
681 cir::GlobalLinkageKind linkage,
682 mlir::ptr::MemorySpaceAttrInterface addrSpace = {}) {
684 std::string uniqueName;
685 if (
unsigned version = globalsVersioning[name.str()]++)
686 uniqueName = name.str() +
"." + std::to_string(version);
688 uniqueName = name.str();
695 return cir::StackSaveOp::create(*
this, loc, ty);
699 return cir::StackRestoreOp::create(*
this, loc, v);
703 mlir::Location loc, mlir::Value lhs, mlir::Value rhs,
704 const llvm::APSInt <Res,
const llvm::APSInt &eqRes,
705 const llvm::APSInt >Res, cir::CmpOrdering ordering) {
706 assert(ltRes.getBitWidth() == eqRes.getBitWidth() &&
707 ltRes.getBitWidth() == gtRes.getBitWidth() &&
708 "the three comparison results must have the same bit width");
709 assert((ordering == cir::CmpOrdering::Strong ||
710 ordering == cir::CmpOrdering::Weak) &&
711 "total ordering must be strong or weak");
712 cir::IntType cmpResultTy =
getSIntNTy(ltRes.getBitWidth());
713 auto infoAttr = cir::CmpThreeWayInfoAttr::get(
714 getContext(), ordering, ltRes.getSExtValue(), eqRes.getSExtValue(),
715 gtRes.getSExtValue());
716 return cir::CmpThreeWayOp::create(*
this, loc, cmpResultTy, lhs, rhs,
721 mlir::Location loc, mlir::Value lhs, mlir::Value rhs,
722 const llvm::APSInt <Res,
const llvm::APSInt &eqRes,
723 const llvm::APSInt >Res,
const llvm::APSInt &unorderedRes) {
724 assert(ltRes.getBitWidth() == eqRes.getBitWidth() &&
725 ltRes.getBitWidth() == gtRes.getBitWidth() &&
726 ltRes.getBitWidth() == unorderedRes.getBitWidth() &&
727 "the four comparison results must have the same bit width");
728 cir::IntType cmpResultTy =
getSIntNTy(ltRes.getBitWidth());
729 auto infoAttr = cir::CmpThreeWayInfoAttr::get(
730 getContext(), ltRes.getSExtValue(), eqRes.getSExtValue(),
731 gtRes.getSExtValue(), unorderedRes.getSExtValue());
732 return cir::CmpThreeWayOp::create(*
this, loc, cmpResultTy, lhs, rhs,
737 Address dstAddr, mlir::Type storageType,
739 bool isLvalueVolatile,
bool useVolatile) {
740 unsigned offset = useVolatile ? info.volatileOffset : info.offset;
745 useVolatile ? cir::IntType::get(storageType.getContext(),
746 info.volatileStorageSize, info.isSigned)
748 return cir::SetBitfieldOp::create(
749 *
this, loc, resultType, dstAddr.
getPointer(), storageType, src,
750 info.name, info.size, offset, info.isSigned, isLvalueVolatile,
755 Address addr, mlir::Type storageType,
757 bool isLvalueVolatile,
bool useVolatile) {
758 unsigned offset = useVolatile ? info.volatileOffset : info.offset;
763 useVolatile ? cir::IntType::get(storageType.getContext(),
764 info.volatileStorageSize, info.isSigned)
766 return cir::GetBitfieldOp::create(*
this, loc, resultType, addr.
getPointer(),
767 storageType, info.name, info.size, offset,
768 info.isSigned, isLvalueVolatile,
773 mlir::Value ptr, llvm::Align alignment,
774 mlir::Value mask, mlir::Value passThru) {
775 assert(mlir::isa<cir::VectorType>(ty) &&
"Type should be vector");
776 assert(mask &&
"Mask should not be all-ones (null)");
779 passThru = this->
getConstant(loc, cir::PoisonAttr::get(ty));
782 this->getI64IntegerAttr(
static_cast<int64_t
>(alignment.value()));
784 return cir::VecMaskedLoadOp::create(*
this, loc, ty, ptr, mask, passThru,
791 auto vecType = mlir::cast<cir::VectorType>(vec1.getType());
793 cir::VectorType::get(vecType.getElementType(), maskAttrs.size());
794 return cir::VecShuffleOp::create(*
this, loc, resultTy, vec1, vec2,
795 getArrayAttr(maskAttrs));
801 auto maskAttrs = llvm::to_vector_of<mlir::Attribute>(
802 llvm::map_range(mask, [&](
int32_t idx) {
812 cir::ConstantOp poison =
813 getConstant(loc, cir::PoisonAttr::get(vec1.getType()));
817 template <
typename... Operands>
819 const mlir::Type &resTy, Operands &&...op) {
820 return cir::LLVMIntrinsicCallOp::create(*
this, loc,
821 this->getStringAttr(str), resTy,
822 std::forward<Operands>(op)...)
static bool isUnsigned(SValBuilder &SVB, NonLoc Value)
*collection of selector each with an associated kind and an ordered *collection of selectors A selector has a kind
cir::CopyOp createCopy(mlir::Value dst, mlir::Value src, bool isVolatile=false, bool skipTailPadding=false)
Create a copy with inferred length.
cir::GetMemberOp createGetMember(mlir::Location loc, mlir::Type resultTy, mlir::Value base, llvm::StringRef name, unsigned index)
cir::StoreOp createStore(mlir::Location loc, mlir::Value val, mlir::Value dst, bool isVolatile=false, bool isNontemporal=false, mlir::IntegerAttr align={}, cir::SyncScopeKindAttr scope={}, cir::MemOrderAttr order={})
cir::FenvAttr getConstrainedFPAttr()
Build the #cir.fenv attribute describing the constrained floating-point environment currently in effe...
cir::ConstantOp getConstant(mlir::Location loc, mlir::TypedAttr attr)
cir::PointerType getPointerTo(mlir::Type ty)
mlir::Value createPtrBitcast(mlir::Value src, mlir::Type newPointeeTy)
mlir::Value createIntCast(mlir::Value src, mlir::Type newTy)
mlir::Value createBitcast(mlir::Value src, mlir::Type newTy)
CIRBaseBuilderTy(mlir::MLIRContext &mlirContext)
mlir::IntegerAttr getAlignmentAttr(clang::CharUnits alignment)
mlir::Value createMinus(mlir::Location loc, mlir::Value input, bool nsw=false)
cir::ConstantOp getConstantInt(mlir::Location loc, mlir::Type ty, int64_t value)
cir::PointerType getVoidPtrTy(clang::LangAS langAS=clang::LangAS::Default)
cir::GlobalOp createGlobal(mlir::ModuleOp mlirModule, mlir::Location loc, mlir::StringRef name, mlir::Type type, bool isConstant, cir::GlobalLinkageKind linkage, mlir::ptr::MemorySpaceAttrInterface addrSpace)
C++ view class that accepts both !cir.struct and !cir.union types.
static llvm::SmallVector< RecordMemberKind > getAllDataKinds(llvm::ArrayRef< mlir::Type > members)
One Data kind per member.
bool isKnownNonNull() const
Whether the pointer is known not to be null.
mlir::Value getPointer() const
mlir::Type getElementType() const
clang::CharUnits getAlignment() const
mlir::Value getBasePointer() const
cir::MemMoveOp createMemMove(mlir::Location loc, mlir::Value dst, mlir::Value src, mlir::Value len)
cir::StackSaveOp createStackSave(mlir::Location loc, mlir::Type ty)
cir::IntType getUInt64Ty()
cir::IntType getUInt8Ty()
cir::TypeInfoAttr getTypeInfo(mlir::ArrayAttr fieldsAttr)
cir::CmpThreeWayOp createThreeWayCmpTotalOrdering(mlir::Location loc, mlir::Value lhs, mlir::Value rhs, const llvm::APSInt <Res, const llvm::APSInt &eqRes, const llvm::APSInt >Res, cir::CmpOrdering ordering)
mlir::Value createComplexRealPtr(mlir::Location loc, mlir::Value value)
Create a cir.complex.real_ptr operation that derives a pointer to the real part of the complex value ...
cir::VecShuffleOp createVecShuffle(mlir::Location loc, mlir::Value vec1, mlir::Value vec2, llvm::ArrayRef< int64_t > mask)
cir::ConstantOp getUInt64(uint64_t c, mlir::Location loc)
mlir::Value emitIntrinsicCallOp(mlir::Location loc, const llvm::StringRef str, const mlir::Type &resTy, Operands &&...op)
cir::IntType getSIntNTy(int n)
cir::DataMemberAttr getDataMemberAttr(cir::DataMemberType ty, llvm::ArrayRef< int32_t > path)
cir::ConstantOp getSInt64(uint64_t c, mlir::Location loc)
cir::IntType getTruncatedIntTy(cir::IntType ty, bool isSigned)
cir::RecordType getIncompleteRecordTy(llvm::StringRef name, const clang::RecordDecl *rd)
Get an incomplete CIR record type.
cir::ConstantOp getUInt32(uint32_t c, mlir::Location loc)
Address createGetMember(mlir::Location loc, Address base, llvm::StringRef name, unsigned index)
cir::MemCpyOp createMemCpy(mlir::Location loc, mlir::Value dst, mlir::Value src, mlir::Value len)
cir::VecShuffleOp createVecShuffle(mlir::Location loc, mlir::Value vec1, mlir::Value vec2, llvm::ArrayRef< mlir::Attribute > maskAttrs)
mlir::Value createNeg(mlir::Location loc, mlir::Value value, bool nsw=false)
cir::PointerType getUInt8PtrTy()
mlir::Attribute getConstRecordOrZeroAttr(mlir::ArrayAttr arrayAttr, cir::RecordType recordTy)
cir::RecordType getCompleteNamedRecordType(llvm::ArrayRef< mlir::Type > members, bool packed, llvm::StringRef name, llvm::ArrayRef< cir::RecordMemberKind > memberKinds)
Get a CIR named record type.
std::string getUniqueRecordName(const std::string &baseName)
cir::LoadOp createLoad(mlir::Location loc, Address addr, bool isVolatile=false, bool isNontemporal=false)
cir::CmpThreeWayOp createThreeWayCmpPartialOrdering(mlir::Location loc, mlir::Value lhs, mlir::Value rhs, const llvm::APSInt <Res, const llvm::APSInt &eqRes, const llvm::APSInt >Res, const llvm::APSInt &unorderedRes)
mlir::Value createVTTAddrPoint(mlir::Location loc, mlir::Type retTy, mlir::FlatSymbolRefAttr sym, uint64_t offset)
mlir::Value createMaskedLoad(mlir::Location loc, mlir::Type ty, mlir::Value ptr, llvm::Align alignment, mlir::Value mask, mlir::Value passThru)
Address createBaseClassAddr(mlir::Location loc, Address addr, mlir::Type destType, unsigned offset, bool assumeNotNull)
mlir::Value createComplexImagPtr(mlir::Location loc, mlir::Value value)
Create a cir.complex.imag_ptr operation that derives a pointer to the imaginary part of the complex v...
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::StoreOp createStore(mlir::Location loc, mlir::Value val, Address dst, bool isVolatile=false, bool isNontemporal=false, mlir::IntegerAttr align={}, cir::SyncScopeKindAttr scope={}, cir::MemOrderAttr order={})
cir::LoadOp createAlignedLoad(mlir::Location loc, mlir::Type ty, mlir::Value ptr, llvm::MaybeAlign align)
cir::ConstantOp getConstFP(mlir::Location loc, mlir::Type t, llvm::APFloat fpVal)
mlir::Value createFloatingCast(mlir::Value v, mlir::Type destType)
cir::FuncType getFuncType(llvm::ArrayRef< mlir::Type > params, mlir::Type retTy, bool isVarArg=false)
cir::MemSetOp createMemSet(mlir::Location loc, Address dst, mlir::Value val, mlir::Value len)
cir::FP16Type getFp16Ty()
cir::IntType getExtendedIntTy(cir::IntType ty, bool isSigned)
cir::SingleType getSingleTy()
Address createDerivedClassAddr(mlir::Location loc, Address addr, mlir::Type destType, unsigned offset, bool assumeNotNull)
static bool tagKindIsUnion(const clang::TagTypeKind kind)
Returns true if the tag kind is a union.
std::string getUniqueAnonRecordName()
uint64_t computeOffsetFromGlobalViewIndices(const cir::CIRDataLayout &layout, mlir::Type ty, llvm::ArrayRef< int64_t > indices)
cir::GetRuntimeMemberOp createGetIndirectMember(mlir::Location loc, mlir::Value objectPtr, mlir::Value memberPtr)
Address createElementBitCast(mlir::Location loc, Address addr, mlir::Type destType)
Cast the element type of the given address to a different type, preserving information like the align...
cir::IntType getSInt8Ty()
cir::ConstRecordAttr getAnonConstRecord(mlir::ArrayAttr arrayAttr)
bool isInt16Ty(mlir::Type i)
bool isInt32Ty(mlir::Type i)
static bool tagKindIsClass(const clang::TagTypeKind kind)
Get a CIR record kind from a AST declaration tag.
mlir::Value createDynCastToVoid(mlir::Location loc, mlir::Value src, bool vtableUseRelativeLayout)
cir::ConstantOp getZero(mlir::Location loc, mlir::Type ty)
cir::VecShuffleOp createVecShuffle(mlir::Location loc, mlir::Value vec1, llvm::ArrayRef< int64_t > mask)
cir::BF16Type getBfloat6Ty()
cir::IntType getUInt16Ty()
mlir::Value createDynCast(mlir::Location loc, mlir::Value src, cir::PointerType destType, bool isRefCast, cir::DynamicCastInfoAttr info)
mlir::Value createGetBitfield(mlir::Location loc, mlir::Type resultType, Address addr, mlir::Type storageType, const CIRGenBitFieldInfo &info, bool isLvalueVolatile, bool useVolatile)
bool isNullValue(mlir::Attribute attr) const
bool isInt64Ty(mlir::Type i)
cir::StackRestoreOp createStackRestore(mlir::Location loc, mlir::Value v)
mlir::Value createSetBitfield(mlir::Location loc, mlir::Type resultType, Address dstAddr, mlir::Type storageType, mlir::Value src, const CIRGenBitFieldInfo &info, bool isLvalueVolatile, bool useVolatile)
Address createComplexRealPtr(mlir::Location loc, Address addr)
cir::GlobalOp createVersionedGlobal(mlir::ModuleOp module, mlir::Location loc, mlir::StringRef name, mlir::Type type, bool isConstant, cir::GlobalLinkageKind linkage, mlir::ptr::MemorySpaceAttrInterface addrSpace={})
Creates a versioned global variable.
cir::StructType getAnonRecordTy(llvm::ArrayRef< mlir::Type > members, bool packed, llvm::ArrayRef< cir::RecordMemberKind > memberKinds)
Get a CIR anonymous struct type.
CIRGenBuilderTy(mlir::MLIRContext &mlirContext, const CIRGenTypeCache &tc)
cir::IsFPClassOp createIsFPClass(mlir::Location loc, mlir::Value src, cir::FPClassTest flags)
mlir::Attribute getString(llvm::StringRef str, mlir::Type eltTy, std::optional< size_t > size, bool ensureNullTerm=true)
Get a cir::ConstArrayAttr for a string literal.
cir::ConstantOp getConstInt(mlir::Location loc, llvm::APSInt intVal)
cir::VoidType getVoidTy()
void computeGlobalViewIndicesFromFlatOffset(int64_t offset, mlir::Type ty, cir::CIRDataLayout layout, llvm::SmallVectorImpl< int64_t > &indices)
cir::IntType getUInt32Ty()
mlir::Type getPtrToVPtrType()
cir::IntType getSInt32Ty()
Address createComplexImagPtr(mlir::Location loc, Address addr)
cir::VectorType getExtendedOrTruncatedElementVectorType(cir::VectorType vt, bool isExtended, bool isSigned=false)
cir::IntType getSInt64Ty()
cir::DataMemberAttr getNullDataMemberAttr(cir::DataMemberType ty)
cir::ConstantOp getSInt32(int32_t c, mlir::Location loc)
mlir::Value createVTTAddrPoint(mlir::Location loc, mlir::Type retTy, mlir::Value addr, uint64_t offset)
cir::MemSetOp createMemSet(mlir::Location loc, mlir::Value dst, mlir::Value val, mlir::Value len)
cir::LongDoubleType getLongDoubleTy(const llvm::fltSemantics &format) const
cir::CopyOp createCopy(Address dst, Address src, bool isVolatile=false, bool skipTailPadding=false)
cir::IntType getSInt16Ty()
cir::ConstArrayAttr getConstArray(mlir::Attribute attrs, cir::ArrayType arrayTy) const
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.
bool isInt8Ty(mlir::Type i)
cir::LoadOp createAlignedLoad(mlir::Location loc, mlir::Type ty, mlir::Value ptr, clang::CharUnits align=clang::CharUnits::One())
cir::DoubleType getDoubleTy()
CharUnits - This is an opaque type for sizes expressed in character units.
CharUnits alignmentAtOffset(CharUnits offset) const
Given that this is a non-zero alignment value, what is the alignment at the given offset?
llvm::Align getAsAlign() const
getAsAlign - Returns Quantity as a valid llvm::Align, Beware llvm::Align assumes power of two 8-bit b...
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
static CharUnits One()
One - Construct a CharUnits quantity of one.
static CharUnits fromQuantity(QuantityType Quantity)
fromQuantity - Construct a CharUnits quantity from a raw integer type.
Represents a struct/union/class.
TagKind getTagKind() const
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
TagTypeKind
The kind of a tag type.
@ Class
The "class" keyword.
@ Union
The "union" keyword.
int __ovld __cnfn all(char)
Returns 1 if the most significant bit in all components of x is set; otherwise returns 0.
__packed_splat4 __packed_splat2 __packed_splat8 __packed_splat4 int32_t
__packed_splat4 __packed_splat2 __packed_splat8 __packed_splat4 __packed_splat2 __packed_splat4 __packed_splat2 __packed_splat8 __packed_splat4 uint32_t
static bool addressSpace()
static bool astRecordDeclAttr()
Record with information about how a bitfield should be accessed.
This structure provides a set of types that are commonly used during IR emission.