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);
84 mlir::Type
type = {});
91 for (
auto &f : arrayAttr) {
92 auto ta = mlir::cast<mlir::TypedAttr>(f);
93 members.push_back(ta.getType());
99 auto sTy = mlir::cast<cir::RecordType>(ty);
100 return cir::ConstRecordAttr::get(sTy, arrayAttr);
105 return cir::TypeInfoAttr::get(anonRecord.getType(), fieldsAttr);
111 auto it = recordNames.find(baseName);
112 if (it == recordNames.end()) {
113 recordNames[baseName] = 0;
117 return baseName +
"." + std::to_string(recordNames[baseName]++);
121 if (&
format == &llvm::APFloat::IEEEdouble())
122 return cir::LongDoubleType::get(getContext(), typeCache.doubleTy);
123 if (&
format == &llvm::APFloat::x87DoubleExtended())
124 return cir::LongDoubleType::get(getContext(), typeCache.fP80Ty);
125 if (&
format == &llvm::APFloat::IEEEquad())
126 return cir::LongDoubleType::get(getContext(), typeCache.fP128Ty);
127 if (&
format == &llvm::APFloat::PPCDoubleDouble())
128 llvm_unreachable(
"NYI: PPC double-double format for long double");
129 llvm_unreachable(
"Unsupported format for long double");
137 bool isVarArg =
false) {
138 return cir::FuncType::get(params, retTy, isVarArg);
158 bool packed,
bool padded,
159 llvm::StringRef name) {
160 const auto nameAttr = getStringAttr(name);
165 auto type = cir::StructType::get(getContext(), members, nameAttr, packed,
170 assert(!
type.isIncomplete() ||
171 (
type.getMembers() == members &&
type.getPacked() == packed &&
172 type.getPadded() == padded));
176 type.complete(members, packed, padded);
184 llvm::StringRef name =
"");
191 const mlir::StringAttr nameAttr = getStringAttr(name);
193 return cir::UnionType::get(getContext(), nameAttr);
195 return cir::StructType::get(getContext(), nameAttr, is_class);
204 bool skipTailPadding =
false) {
213 mlir::Value src, mlir::Value len) {
214 return cir::MemCpyOp::create(*
this, loc, dst, src, len);
218 mlir::Value src, mlir::Value len) {
219 return cir::MemMoveOp::create(*
this, loc, dst, src, len);
223 mlir::Value val, mlir::Value len) {
225 return cir::MemSetOp::create(*
this, loc, dst, {}, val, len);
232 return cir::MemSetOp::create(*
this, loc, dst.
getPointer(), align, val, len);
238 return cir::DataMemberAttr::get(ty, path);
242 return cir::DataMemberAttr::get(ty);
248 if (mlir::isa<cir::ZeroAttr>(
attr))
251 if (
const auto ptrVal = mlir::dyn_cast<cir::ConstPtrAttr>(
attr))
252 return ptrVal.isNullValue();
254 if (
const auto intVal = mlir::dyn_cast<cir::IntAttr>(
attr))
255 return intVal.isNullValue();
257 if (
const auto boolVal = mlir::dyn_cast<cir::BoolAttr>(
attr))
258 return !boolVal.getValue();
260 if (
auto fpAttr = mlir::dyn_cast<cir::FPAttr>(
attr)) {
261 auto fpVal = fpAttr.getValue();
263 llvm::APFloat fv(+0.0);
264 fv.convert(fpVal.getSemantics(), llvm::APFloat::rmNearestTiesToEven,
266 return fv.bitwiseIsEqual(fpVal);
268 if (
const auto recordVal = mlir::dyn_cast<cir::ConstRecordAttr>(
attr)) {
269 for (
const auto elt : recordVal.getMembers()) {
271 if (mlir::isa<mlir::StringAttr>(elt))
279 if (
const auto arrayVal = mlir::dyn_cast<cir::ConstArrayAttr>(
attr)) {
280 if (mlir::isa<mlir::StringAttr>(arrayVal.getElts()))
284 mlir::cast<mlir::ArrayAttr>(arrayVal.getElts()),
285 [&](
const mlir::Attribute &elt) { return isNullValue(elt); });
305 return cir::IntType::get(getContext(), n,
false);
320 return cir::IntType::get(getContext(), n,
true);
341 cir::ConstantOp
getConstInt(mlir::Location loc, llvm::APSInt intVal);
343 cir::ConstantOp
getConstInt(mlir::Location loc, llvm::APInt intVal,
346 cir::ConstantOp
getConstInt(mlir::Location loc, mlir::Type t, uint64_t c);
348 cir::ConstantOp
getConstFP(mlir::Location loc, mlir::Type t,
349 llvm::APFloat fpVal);
352 return i == typeCache.uInt8Ty || i == typeCache.sInt8Ty;
355 return i == typeCache.uInt16Ty || i == typeCache.sInt16Ty;
358 return i == typeCache.uInt32Ty || i == typeCache.sInt32Ty;
361 return i == typeCache.uInt64Ty || i == typeCache.sInt64Ty;
363 bool isInt(mlir::Type i) {
return mlir::isa<cir::IntType>(i); }
366 switch (ty.getWidth()) {
368 return isSigned ? typeCache.sInt16Ty : typeCache.uInt16Ty;
370 return isSigned ? typeCache.sInt32Ty : typeCache.uInt32Ty;
372 return isSigned ? typeCache.sInt64Ty : typeCache.uInt64Ty;
374 llvm_unreachable(
"NYI");
379 switch (ty.getWidth()) {
381 return isSigned ? typeCache.sInt8Ty : typeCache.uInt8Ty;
383 return isSigned ? typeCache.sInt16Ty : typeCache.uInt16Ty;
385 return isSigned ? typeCache.sInt32Ty : typeCache.uInt32Ty;
387 llvm_unreachable(
"NYI");
393 bool isSigned =
false) {
394 auto elementTy = mlir::dyn_cast_or_null<cir::IntType>(vt.getElementType());
395 assert(elementTy &&
"expected int vector");
396 return cir::VectorType::get(isExtended
407 bool packed =
false,
bool padded =
false) {
409 return cir::StructType::get(getContext(), members, packed, padded,
422 cir::ConstantOp
getSInt64(uint64_t c, mlir::Location loc) {
425 cir::ConstantOp
getUInt64(uint64_t c, mlir::Location loc) {
429 cir::ConstantOp
getZero(mlir::Location loc, mlir::Type ty) {
431 assert((mlir::isa<cir::RecordType>(ty) || mlir::isa<cir::ArrayType>(ty) ||
432 mlir::isa<cir::VectorType>(ty)) &&
433 "NYI for other types");
434 return cir::ConstantOp::create(*
this, loc, cir::ZeroAttr::get(ty));
440 mlir::Value
createNeg(mlir::Location loc, mlir::Value value,
443 if (
auto intTy = mlir::dyn_cast<cir::IntType>(value.getType())) {
445 if (intTy.isUnsigned())
450 llvm_unreachable(
"negation for the given type is NYI");
460 return cir::CastOp::create(*
this, v.getLoc(), destType,
461 cir::CastKind::floating, v,
466 cir::PointerType destType,
bool isRefCast,
467 cir::DynamicCastInfoAttr info) {
469 isRefCast ? cir::DynamicCastKind::Ref : cir::DynamicCastKind::Ptr;
470 return cir::DynamicCastOp::create(*
this, loc, destType, castKind, src, info,
475 bool vtableUseRelativeLayout) {
479 return cir::DynamicCastOp::create(
480 *
this, loc, destTy, cir::DynamicCastKind::Ptr, src,
481 cir::DynamicCastInfoAttr{}, vtableUseRelativeLayout);
488 mlir::Type destType,
unsigned offset,
489 bool assumeNotNull) {
495 cir::BaseClassAddrOp::create(*
this, loc, ptrTy, addr.
getPointer(),
496 mlir::APInt(64, offset), assumeNotNull);
501 mlir::Type destType,
unsigned offset,
502 bool assumeNotNull) {
508 cir::DerivedClassAddrOp::create(*
this, loc, ptrTy, addr.
getPointer(),
509 mlir::APInt(64, offset), assumeNotNull);
517 mlir::Value addr, uint64_t offset) {
518 return cir::VTTAddrPointOp::create(*
this, loc, retTy,
519 mlir::FlatSymbolRefAttr{}, addr, offset);
523 mlir::FlatSymbolRefAttr sym, uint64_t offset) {
524 return cir::VTTAddrPointOp::create(*
this, loc, retTy, sym, mlir::Value{},
532 cir::FPClassTest flags) {
538 assert((raw & ~
all) == 0 &&
"FPClassTest mask has bits outside 0-9");
539 flags =
static_cast<cir::FPClassTest
>(raw &
all);
540 return cir::IsFPClassOp::create(*
this, loc, src, flags);
546 mlir::Type destType) {
556 bool isVolatile =
false,
bool isNontemporal =
false) {
558 return cir::LoadOp::create(*
this, loc, addr.
getPointer(),
false,
559 isVolatile, isNontemporal,
561 cir::SyncScopeKindAttr{},
567 mlir::Value ptr, llvm::MaybeAlign align) {
568 if (ty != mlir::cast<cir::PointerType>(ptr.getType()).getPointee())
570 uint64_t alignment = align ? align->value() : 0;
572 return cir::LoadOp::create(*
this, loc, ptr,
false,
575 cir::SyncScopeKindAttr{},
587 bool isVolatile =
false,
bool isNontemporal =
false,
588 mlir::IntegerAttr align = {},
589 cir::SyncScopeKindAttr scope = {},
590 cir::MemOrderAttr order = {}) {
594 isNontemporal, align, scope, order);
600 auto srcPtrTy = mlir::cast<cir::PointerType>(value.getType());
601 auto srcComplexTy = mlir::cast<cir::ComplexType>(srcPtrTy.getPointee());
602 return cir::ComplexRealPtrOp::create(
603 *
this, loc,
getPointerTo(srcComplexTy.getElementType()), value);
615 auto srcPtrTy = mlir::cast<cir::PointerType>(value.getType());
616 auto srcComplexTy = mlir::cast<cir::ComplexType>(srcPtrTy.getPointee());
617 return cir::ComplexImagPtrOp::create(
618 *
this, loc,
getPointerTo(srcComplexTy.getElementType()), value);
628 llvm::StringRef name,
unsigned index) {
629 auto recordTy = mlir::cast<cir::RecordType>(base.
getElementType());
631 assert(
index < recordTy.getMembers().size() &&
632 "member index out of bounds");
633 mlir::Type memberTy = recordTy.getMembers()[
index];
637 getInsertionBlock()->getParentOp()->getParentOfType<mlir::ModuleOp>();
638 mlir::DataLayout layout(moduleOp);
642 mlir::Value memberPtr =
644 return Address(memberPtr, memberTy,
650 mlir::Value objectPtr,
651 mlir::Value memberPtr) {
652 auto memberPtrTy = mlir::cast<cir::DataMemberType>(memberPtr.getType());
656 cir::PointerType resultTy =
getPointerTo(memberPtrTy.getMemberTy());
658 return cir::GetRuntimeMemberOp::create(*
this, loc, resultTy, objectPtr,
666 mlir::Location arrayLocEnd, mlir::Value arrayPtr,
667 mlir::Type eltTy, mlir::Value idx,
691 [[nodiscard]] cir::GlobalOp
693 mlir::StringRef name, mlir::Type
type,
bool isConstant,
694 cir::GlobalLinkageKind linkage,
695 mlir::ptr::MemorySpaceAttrInterface addrSpace = {}) {
697 std::string uniqueName;
698 if (
unsigned version = globalsVersioning[name.str()]++)
699 uniqueName = name.str() +
"." + std::to_string(version);
701 uniqueName = name.str();
708 return cir::StackSaveOp::create(*
this, loc, ty);
712 return cir::StackRestoreOp::create(*
this, loc, v);
716 mlir::Location loc, mlir::Value lhs, mlir::Value rhs,
717 const llvm::APSInt <Res,
const llvm::APSInt &eqRes,
718 const llvm::APSInt >Res, cir::CmpOrdering ordering) {
719 assert(ltRes.getBitWidth() == eqRes.getBitWidth() &&
720 ltRes.getBitWidth() == gtRes.getBitWidth() &&
721 "the three comparison results must have the same bit width");
722 assert((ordering == cir::CmpOrdering::Strong ||
723 ordering == cir::CmpOrdering::Weak) &&
724 "total ordering must be strong or weak");
725 cir::IntType cmpResultTy =
getSIntNTy(ltRes.getBitWidth());
726 auto infoAttr = cir::CmpThreeWayInfoAttr::get(
727 getContext(), ordering, ltRes.getSExtValue(), eqRes.getSExtValue(),
728 gtRes.getSExtValue());
729 return cir::CmpThreeWayOp::create(*
this, loc, cmpResultTy, lhs, rhs,
734 mlir::Location loc, mlir::Value lhs, mlir::Value rhs,
735 const llvm::APSInt <Res,
const llvm::APSInt &eqRes,
736 const llvm::APSInt >Res,
const llvm::APSInt &unorderedRes) {
737 assert(ltRes.getBitWidth() == eqRes.getBitWidth() &&
738 ltRes.getBitWidth() == gtRes.getBitWidth() &&
739 ltRes.getBitWidth() == unorderedRes.getBitWidth() &&
740 "the four comparison results must have the same bit width");
741 cir::IntType cmpResultTy =
getSIntNTy(ltRes.getBitWidth());
742 auto infoAttr = cir::CmpThreeWayInfoAttr::get(
743 getContext(), ltRes.getSExtValue(), eqRes.getSExtValue(),
744 gtRes.getSExtValue(), unorderedRes.getSExtValue());
745 return cir::CmpThreeWayOp::create(*
this, loc, cmpResultTy, lhs, rhs,
750 Address dstAddr, mlir::Type storageType,
752 bool isLvalueVolatile,
bool useVolatile) {
758 useVolatile ? cir::IntType::get(storageType.getContext(),
761 return cir::SetBitfieldOp::create(
762 *
this, loc, resultType, dstAddr.
getPointer(), storageType, src,
768 Address addr, mlir::Type storageType,
770 bool isLvalueVolatile,
bool useVolatile) {
776 useVolatile ? cir::IntType::get(storageType.getContext(),
779 return cir::GetBitfieldOp::create(*
this, loc, resultType, addr.
getPointer(),
780 storageType, info.
name, info.
size, offset,
786 mlir::Value ptr, llvm::Align alignment,
787 mlir::Value mask, mlir::Value passThru) {
788 assert(mlir::isa<cir::VectorType>(ty) &&
"Type should be vector");
789 assert(mask &&
"Mask should not be all-ones (null)");
792 passThru = this->
getConstant(loc, cir::PoisonAttr::get(ty));
795 this->getI64IntegerAttr(
static_cast<int64_t
>(alignment.value()));
797 return cir::VecMaskedLoadOp::create(*
this, loc, ty, ptr, mask, passThru,
804 auto vecType = mlir::cast<cir::VectorType>(vec1.getType());
806 cir::VectorType::get(vecType.getElementType(), maskAttrs.size());
807 return cir::VecShuffleOp::create(*
this, loc, resultTy, vec1, vec2,
808 getArrayAttr(maskAttrs));
814 auto maskAttrs = llvm::to_vector_of<mlir::Attribute>(
815 llvm::map_range(mask, [&](
int32_t idx) {
825 cir::ConstantOp poison =
826 getConstant(loc, cir::PoisonAttr::get(vec1.getType()));
830 template <
typename... Operands>
832 const mlir::Type &resTy, Operands &&...op) {
833 return cir::LLVMIntrinsicCallOp::create(*
this, loc,
834 this->getStringAttr(str), resTy,
835 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.
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::RecordType getCompleteNamedRecordType(llvm::ArrayRef< mlir::Type > members, bool packed, bool padded, llvm::StringRef name)
Get a CIR named record type.
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::ConstRecordAttr getAnonConstRecord(mlir::ArrayAttr arrayAttr, bool packed=false, bool padded=false, mlir::Type ty={})
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()
std::string getUniqueRecordName(const std::string &baseName)
mlir::Attribute getConstRecordOrZeroAttr(mlir::ArrayAttr arrayAttr, bool packed=false, bool padded=false, mlir::Type type={})
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()
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)
cir::StructType getAnonRecordTy(llvm::ArrayRef< mlir::Type > members, bool packed=false, bool padded=false)
Get a CIR anonymous struct type.
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.
CIRGenBuilderTy(mlir::MLIRContext &mlirContext, const CIRGenTypeCache &tc)
cir::IsFPClassOp createIsFPClass(mlir::Location loc, mlir::Value src, cir::FPClassTest flags)
cir::RecordType getCompleteRecordType(mlir::ArrayAttr fields, bool packed=false, bool padded=false, llvm::StringRef name="")
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.
unsigned offset
The offset within a contiguous run of bitfields that are represented as a single "field" within the c...
unsigned volatileStorageSize
The storage size in bits which should be used when accessing this bitfield.
unsigned size
The total size of the bit-field, in bits.
unsigned isSigned
Whether the bit-field is signed.
unsigned volatileOffset
The offset within a contiguous run of bitfields that are represented as a single "field" within the c...
llvm::StringRef name
The name of a bitfield.
This structure provides a set of types that are commonly used during IR emission.