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"
33 bool isFPConstrained =
false;
34 llvm::fp::ExceptionBehavior defaultConstrainedExcept = llvm::fp::ebStrict;
35 llvm::RoundingMode defaultConstrainedRounding = llvm::RoundingMode::Dynamic;
37 llvm::StringMap<unsigned> recordNames;
38 llvm::StringMap<unsigned> globalsVersioning;
47 mlir::Attribute
getString(llvm::StringRef str, mlir::Type eltTy,
48 std::optional<size_t> size,
49 bool ensureNullTerm =
true) {
50 size_t finalSize = size.value_or(str.size());
52 size_t lastNonZeroPos = str.find_last_not_of(
'\0');
55 if (lastNonZeroPos == llvm::StringRef::npos) {
56 auto arrayTy = cir::ArrayType::get(eltTy, finalSize);
57 return cir::ZeroAttr::get(arrayTy);
63 size_t trailingZerosNum = finalSize - lastNonZeroPos - 1;
64 auto truncatedArrayTy =
65 cir::ArrayType::get(eltTy, finalSize - trailingZerosNum);
66 auto strAttr = mlir::StringAttr::get(str.drop_back(trailingZerosNum),
73 finalSize += (ensureNullTerm && trailingZerosNum == 0);
75 auto fullArrayTy = cir::ArrayType::get(eltTy, finalSize);
76 return cir::ConstArrayAttr::get(fullArrayTy, strAttr);
80 cir::ArrayType arrayTy)
const {
81 return cir::ConstArrayAttr::get(arrayTy, attrs);
87 mlir::Type
type = {});
94 for (
auto &f : arrayAttr) {
95 auto ta = mlir::cast<mlir::TypedAttr>(f);
96 members.push_back(ta.getType());
102 auto sTy = mlir::cast<cir::RecordType>(ty);
103 return cir::ConstRecordAttr::get(sTy, arrayAttr);
108 return cir::TypeInfoAttr::get(anonRecord.getType(), fieldsAttr);
114 auto it = recordNames.find(baseName);
115 if (it == recordNames.end()) {
116 recordNames[baseName] = 0;
120 return baseName +
"." + std::to_string(recordNames[baseName]++);
138 assert(llvm::convertExceptionBehaviorToStr(newExcept) &&
139 "Garbage strict exception behavior!");
140 defaultConstrainedExcept = newExcept;
145 return defaultConstrainedExcept;
150 assert(llvm::convertRoundingModeToStr(newRounding) &&
151 "Garbage strict rounding mode!");
152 defaultConstrainedRounding = newRounding;
157 return defaultConstrainedRounding;
161 if (&
format == &llvm::APFloat::IEEEdouble())
162 return cir::LongDoubleType::get(getContext(), typeCache.doubleTy);
163 if (&
format == &llvm::APFloat::x87DoubleExtended())
164 return cir::LongDoubleType::get(getContext(), typeCache.fP80Ty);
165 if (&
format == &llvm::APFloat::IEEEquad())
166 return cir::LongDoubleType::get(getContext(), typeCache.fP128Ty);
167 if (&
format == &llvm::APFloat::PPCDoubleDouble())
168 llvm_unreachable(
"NYI: PPC double-double format for long double");
169 llvm_unreachable(
"Unsupported format for long double");
177 bool isVarArg =
false) {
178 return cir::FuncType::get(params, retTy, isVarArg);
198 bool packed,
bool padded,
199 llvm::StringRef name) {
200 const auto nameAttr = getStringAttr(name);
205 auto type = cir::StructType::get(getContext(), members, nameAttr, packed,
210 assert(!
type.isIncomplete() ||
211 (
type.getMembers() == members &&
type.getPacked() == packed &&
212 type.getPadded() == padded));
216 type.complete(members, packed, padded);
224 llvm::StringRef name =
"");
231 const mlir::StringAttr nameAttr = getStringAttr(name);
233 return cir::UnionType::get(getContext(), nameAttr);
235 return cir::StructType::get(getContext(), nameAttr, is_class);
243 mlir::Value src, mlir::Value len) {
244 return cir::MemCpyOp::create(*
this, loc, dst, src, len);
248 mlir::Value src, mlir::Value len) {
249 return cir::MemMoveOp::create(*
this, loc, dst, src, len);
253 mlir::Value val, mlir::Value len) {
255 return cir::MemSetOp::create(*
this, loc, dst, {}, val, len);
262 return cir::MemSetOp::create(*
this, loc, dst.
getPointer(), align, val, len);
267 unsigned memberIndex) {
268 return cir::DataMemberAttr::get(ty, memberIndex);
272 return cir::DataMemberAttr::get(ty);
278 if (mlir::isa<cir::ZeroAttr>(
attr))
281 if (
const auto ptrVal = mlir::dyn_cast<cir::ConstPtrAttr>(
attr))
282 return ptrVal.isNullValue();
284 if (
const auto intVal = mlir::dyn_cast<cir::IntAttr>(
attr))
285 return intVal.isNullValue();
287 if (
const auto boolVal = mlir::dyn_cast<cir::BoolAttr>(
attr))
288 return !boolVal.getValue();
290 if (
auto fpAttr = mlir::dyn_cast<cir::FPAttr>(
attr)) {
291 auto fpVal = fpAttr.getValue();
293 llvm::APFloat fv(+0.0);
294 fv.convert(fpVal.getSemantics(), llvm::APFloat::rmNearestTiesToEven,
296 return fv.bitwiseIsEqual(fpVal);
298 if (
const auto recordVal = mlir::dyn_cast<cir::ConstRecordAttr>(
attr)) {
299 for (
const auto elt : recordVal.getMembers()) {
301 if (mlir::isa<mlir::StringAttr>(elt))
309 if (
const auto arrayVal = mlir::dyn_cast<cir::ConstArrayAttr>(
attr)) {
310 if (mlir::isa<mlir::StringAttr>(arrayVal.getElts()))
314 mlir::cast<mlir::ArrayAttr>(arrayVal.getElts()),
315 [&](
const mlir::Attribute &elt) { return isNullValue(elt); });
335 return cir::IntType::get(getContext(), n,
false);
350 return cir::IntType::get(getContext(), n,
true);
371 cir::ConstantOp
getConstInt(mlir::Location loc, llvm::APSInt intVal);
373 cir::ConstantOp
getConstInt(mlir::Location loc, llvm::APInt intVal,
376 cir::ConstantOp
getConstInt(mlir::Location loc, mlir::Type t, uint64_t c);
378 cir::ConstantOp
getConstFP(mlir::Location loc, mlir::Type t,
379 llvm::APFloat fpVal);
382 return i == typeCache.uInt8Ty || i == typeCache.sInt8Ty;
385 return i == typeCache.uInt16Ty || i == typeCache.sInt16Ty;
388 return i == typeCache.uInt32Ty || i == typeCache.sInt32Ty;
391 return i == typeCache.uInt64Ty || i == typeCache.sInt64Ty;
393 bool isInt(mlir::Type i) {
return mlir::isa<cir::IntType>(i); }
396 switch (ty.getWidth()) {
398 return isSigned ? typeCache.sInt16Ty : typeCache.uInt16Ty;
400 return isSigned ? typeCache.sInt32Ty : typeCache.uInt32Ty;
402 return isSigned ? typeCache.sInt64Ty : typeCache.uInt64Ty;
404 llvm_unreachable(
"NYI");
409 switch (ty.getWidth()) {
411 return isSigned ? typeCache.sInt8Ty : typeCache.uInt8Ty;
413 return isSigned ? typeCache.sInt16Ty : typeCache.uInt16Ty;
415 return isSigned ? typeCache.sInt32Ty : typeCache.uInt32Ty;
417 llvm_unreachable(
"NYI");
423 bool isSigned =
false) {
424 auto elementTy = mlir::dyn_cast_or_null<cir::IntType>(vt.getElementType());
425 assert(elementTy &&
"expected int vector");
426 return cir::VectorType::get(isExtended
437 bool packed =
false,
bool padded =
false) {
439 return cir::StructType::get(getContext(), members, packed, padded,
446 cir::ConstantOp
getSInt32(int32_t c, mlir::Location loc) {
449 cir::ConstantOp
getUInt32(uint32_t c, mlir::Location loc) {
452 cir::ConstantOp
getSInt64(uint64_t c, mlir::Location loc) {
455 cir::ConstantOp
getUInt64(uint64_t c, mlir::Location loc) {
459 cir::ConstantOp
getZero(mlir::Location loc, mlir::Type ty) {
461 assert((mlir::isa<cir::RecordType>(ty) || mlir::isa<cir::ArrayType>(ty) ||
462 mlir::isa<cir::VectorType>(ty)) &&
463 "NYI for other types");
464 return cir::ConstantOp::create(*
this, loc, cir::ZeroAttr::get(ty));
470 mlir::Value
createNeg(mlir::Location loc, mlir::Value value,
473 if (
auto intTy = mlir::dyn_cast<cir::IntType>(value.getType())) {
475 if (intTy.isUnsigned())
480 llvm_unreachable(
"negation for the given type is NYI");
492 return cir::CastOp::create(*
this, v.getLoc(), destType,
493 cir::CastKind::floating, v);
497 cir::PointerType destType,
bool isRefCast,
498 cir::DynamicCastInfoAttr info) {
500 isRefCast ? cir::DynamicCastKind::Ref : cir::DynamicCastKind::Ptr;
501 return cir::DynamicCastOp::create(*
this, loc, destType, castKind, src, info,
506 bool vtableUseRelativeLayout) {
510 return cir::DynamicCastOp::create(
511 *
this, loc, destTy, cir::DynamicCastKind::Ptr, src,
512 cir::DynamicCastInfoAttr{}, vtableUseRelativeLayout);
519 mlir::Type destType,
unsigned offset,
520 bool assumeNotNull) {
526 cir::BaseClassAddrOp::create(*
this, loc, ptrTy, addr.
getPointer(),
527 mlir::APInt(64, offset), assumeNotNull);
532 mlir::Type destType,
unsigned offset,
533 bool assumeNotNull) {
539 cir::DerivedClassAddrOp::create(*
this, loc, ptrTy, addr.
getPointer(),
540 mlir::APInt(64, offset), assumeNotNull);
548 mlir::Value addr, uint64_t offset) {
549 return cir::VTTAddrPointOp::create(*
this, loc, retTy,
550 mlir::FlatSymbolRefAttr{}, addr, offset);
554 mlir::FlatSymbolRefAttr sym, uint64_t offset) {
555 return cir::VTTAddrPointOp::create(*
this, loc, retTy, sym, mlir::Value{},
563 cir::FPClassTest flags) {
564 return cir::IsFPClassOp::create(*
this, loc, src, flags);
570 mlir::Type destType) {
580 bool isVolatile =
false) {
582 return cir::LoadOp::create(*
this, loc, addr.
getPointer(),
false,
584 cir::SyncScopeKindAttr{},
585 cir::MemOrderAttr{});
589 mlir::Value ptr, llvm::MaybeAlign align) {
590 if (ty != mlir::cast<cir::PointerType>(ptr.getType()).getPointee())
592 uint64_t alignment = align ? align->value() : 0;
594 return cir::LoadOp::create(*
this, loc, ptr,
false,
596 cir::SyncScopeKindAttr{},
597 cir::MemOrderAttr{});
607 bool isVolatile =
false,
608 mlir::IntegerAttr align = {},
609 cir::SyncScopeKindAttr scope = {},
610 cir::MemOrderAttr order = {}) {
613 return CIRBaseBuilderTy::createStore(loc, val, dst.
getPointer(), isVolatile,
614 align, scope, order);
620 auto srcPtrTy = mlir::cast<cir::PointerType>(value.getType());
621 auto srcComplexTy = mlir::cast<cir::ComplexType>(srcPtrTy.getPointee());
622 return cir::ComplexRealPtrOp::create(
623 *
this, loc,
getPointerTo(srcComplexTy.getElementType()), value);
635 auto srcPtrTy = mlir::cast<cir::PointerType>(value.getType());
636 auto srcComplexTy = mlir::cast<cir::ComplexType>(srcPtrTy.getPointee());
637 return cir::ComplexImagPtrOp::create(
638 *
this, loc,
getPointerTo(srcComplexTy.getElementType()), value);
646 using CIRBaseBuilderTy::createGetMember;
648 llvm::StringRef name,
unsigned index) {
649 auto recordTy = mlir::cast<cir::RecordType>(base.
getElementType());
651 assert(
index < recordTy.getMembers().size() &&
652 "member index out of bounds");
653 mlir::Type memberTy = recordTy.getMembers()[
index];
657 getInsertionBlock()->getParentOp()->getParentOfType<mlir::ModuleOp>();
658 mlir::DataLayout layout(moduleOp);
662 mlir::Value memberPtr =
664 return Address(memberPtr, memberTy,
670 mlir::Value objectPtr,
671 mlir::Value memberPtr) {
672 auto memberPtrTy = mlir::cast<cir::DataMemberType>(memberPtr.getType());
676 cir::PointerType resultTy =
getPointerTo(memberPtrTy.getMemberTy());
678 return cir::GetRuntimeMemberOp::create(*
this, loc, resultTy, objectPtr,
686 mlir::Location arrayLocEnd, mlir::Value arrayPtr,
687 mlir::Type eltTy, mlir::Value idx,
711 [[nodiscard]] cir::GlobalOp
713 mlir::StringRef name, mlir::Type
type,
bool isConstant,
714 cir::GlobalLinkageKind linkage,
715 mlir::ptr::MemorySpaceAttrInterface addrSpace = {}) {
717 std::string uniqueName;
718 if (
unsigned version = globalsVersioning[name.str()]++)
719 uniqueName = name.str() +
"." + std::to_string(version);
721 uniqueName = name.str();
728 return cir::StackSaveOp::create(*
this, loc, ty);
732 return cir::StackRestoreOp::create(*
this, loc, v);
736 mlir::Location loc, mlir::Value lhs, mlir::Value rhs,
737 const llvm::APSInt <Res,
const llvm::APSInt &eqRes,
738 const llvm::APSInt >Res, cir::CmpOrdering ordering) {
739 assert(ltRes.getBitWidth() == eqRes.getBitWidth() &&
740 ltRes.getBitWidth() == gtRes.getBitWidth() &&
741 "the three comparison results must have the same bit width");
742 assert((ordering == cir::CmpOrdering::Strong ||
743 ordering == cir::CmpOrdering::Weak) &&
744 "total ordering must be strong or weak");
745 cir::IntType cmpResultTy =
getSIntNTy(ltRes.getBitWidth());
746 auto infoAttr = cir::CmpThreeWayInfoAttr::get(
747 getContext(), ordering, ltRes.getSExtValue(), eqRes.getSExtValue(),
748 gtRes.getSExtValue());
749 return cir::CmpThreeWayOp::create(*
this, loc, cmpResultTy, lhs, rhs,
754 mlir::Location loc, mlir::Value lhs, mlir::Value rhs,
755 const llvm::APSInt <Res,
const llvm::APSInt &eqRes,
756 const llvm::APSInt >Res,
const llvm::APSInt &unorderedRes) {
757 assert(ltRes.getBitWidth() == eqRes.getBitWidth() &&
758 ltRes.getBitWidth() == gtRes.getBitWidth() &&
759 ltRes.getBitWidth() == unorderedRes.getBitWidth() &&
760 "the four comparison results must have the same bit width");
761 cir::IntType cmpResultTy =
getSIntNTy(ltRes.getBitWidth());
762 auto infoAttr = cir::CmpThreeWayInfoAttr::get(
763 getContext(), ltRes.getSExtValue(), eqRes.getSExtValue(),
764 gtRes.getSExtValue(), unorderedRes.getSExtValue());
765 return cir::CmpThreeWayOp::create(*
this, loc, cmpResultTy, lhs, rhs,
770 Address dstAddr, mlir::Type storageType,
772 bool isLvalueVolatile,
bool useVolatile) {
778 useVolatile ? cir::IntType::get(storageType.getContext(),
781 return cir::SetBitfieldOp::create(
782 *
this, loc, resultType, dstAddr.
getPointer(), storageType, src,
788 Address addr, mlir::Type storageType,
790 bool isLvalueVolatile,
bool useVolatile) {
796 useVolatile ? cir::IntType::get(storageType.getContext(),
799 return cir::GetBitfieldOp::create(*
this, loc, resultType, addr.
getPointer(),
800 storageType, info.
name, info.
size, offset,
806 mlir::Value ptr, llvm::Align alignment,
807 mlir::Value mask, mlir::Value passThru) {
808 assert(mlir::isa<cir::VectorType>(ty) &&
"Type should be vector");
809 assert(mask &&
"Mask should not be all-ones (null)");
812 passThru = this->
getConstant(loc, cir::PoisonAttr::get(ty));
815 this->getI64IntegerAttr(
static_cast<int64_t
>(alignment.value()));
817 return cir::VecMaskedLoadOp::create(*
this, loc, ty, ptr, mask, passThru,
824 auto vecType = mlir::cast<cir::VectorType>(vec1.getType());
826 cir::VectorType::get(vecType.getElementType(), maskAttrs.size());
827 return cir::VecShuffleOp::create(*
this, loc, resultTy, vec1, vec2,
828 getArrayAttr(maskAttrs));
834 auto maskAttrs = llvm::to_vector_of<mlir::Attribute>(
835 llvm::map_range(mask, [&](int32_t idx) {
845 cir::ConstantOp poison =
846 getConstant(loc, cir::PoisonAttr::get(vec1.getType()));
850 template <
typename... Operands>
852 const mlir::Type &resTy, Operands &&...op) {
853 return cir::LLVMIntrinsicCallOp::create(*
this, loc,
854 this->getStringAttr(str), resTy,
855 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::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::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)
void setDefaultConstrainedRounding(llvm::RoundingMode newRounding)
Set the rounding mode handling to be used with constrained floating point.
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::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::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)
llvm::RoundingMode getDefaultConstrainedRounding() const
Get the rounding mode handling used with constrained floating point.
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()
void setDefaultConstrainedExcept(llvm::fp::ExceptionBehavior newExcept)
Set the exception handling to be used with constrained floating point.
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)
llvm::fp::ExceptionBehavior getDefaultConstrainedExcept() const
Get the exception handling used with constrained floating point.
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.
cir::StoreOp createStore(mlir::Location loc, mlir::Value val, Address dst, bool isVolatile=false, mlir::IntegerAttr align={}, cir::SyncScopeKindAttr scope={}, cir::MemOrderAttr order={})
bool getIsFPConstrained() const
Query for the use of constrained floating point math.
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 setIsFPConstrained(bool isCon)
Enable/Disable use of constrained floating point math.
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::LoadOp createLoad(mlir::Location loc, Address addr, bool isVolatile=false)
cir::LongDoubleType getLongDoubleTy(const llvm::fltSemantics &format) const
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::DataMemberAttr getDataMemberAttr(cir::DataMemberType ty, unsigned memberIndex)
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...
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.
static bool addressSpace()
static bool fpConstraints()
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.