18#include "mlir/IR/BuiltinAttributes.h"
19#include "mlir/IR/Value.h"
37 llvm::StringRef fieldName,
38 unsigned fieldIndex) {
41 "emitAddrOfFieldStorage: zero-sized field");
48 auto fieldPtr = cir::PointerType::get(fieldType);
52 cir::GetMemberOp memberAddr = builder.createGetMember(
53 loc, fieldPtr, base.
getPointer(), fieldName, fieldIndex);
61 layout.
getCIRType().getElementOffset(
cgm.getDataLayout().layout, idx));
70 assert(
expr->getType()->isPointerType() ||
71 expr->getType()->isObjCObjectPointerType());
75 if (
auto const *ce = dyn_cast<CastExpr>(
expr)) {
76 if (
const auto *ece = dyn_cast<ExplicitCastExpr>(ce))
77 cgm.emitExplicitCastExprType(ece);
79 switch (ce->getCastKind()) {
83 case CK_AddressSpaceConversion: {
84 if (
const auto *ptrTy =
85 ce->getSubExpr()->getType()->getAs<
PointerType>()) {
86 if (ptrTy->getPointeeType()->isVoidType())
94 *baseInfo = innerBaseInfo;
99 const QualType pointeeType =
expr->getType()->getPointeeType();
101 cgm.getNaturalTypeAlignment(pointeeType, &targetTypeBaseInfo);
114 const mlir::Type eltTy =
126 case CK_ArrayToPointerDecay:
129 case CK_UncheckedDerivedToBase:
130 case CK_DerivedToBase: {
135 ce->getSubExpr()->getType()->getPointeeCXXRecordDecl();
141 case CK_AnyPointerToBlockPointerCast:
142 case CK_BaseToDerived:
143 case CK_BaseToDerivedMemberPointer:
144 case CK_BlockPointerToObjCPointerCast:
145 case CK_BuiltinFnToFnPtr:
146 case CK_CPointerToObjCPointerCast:
147 case CK_DerivedToBaseMemberPointer:
149 case CK_FunctionToPointerDecay:
150 case CK_IntegralToPointer:
151 case CK_LValueToRValue:
152 case CK_LValueToRValueBitCast:
153 case CK_NullToMemberPointer:
154 case CK_NullToPointer:
155 case CK_ReinterpretMemberPointer:
161 case CK_ARCConsumeObject:
162 case CK_ARCExtendBlockObject:
163 case CK_ARCProduceObject:
164 case CK_ARCReclaimReturnedObject:
165 case CK_AtomicToNonAtomic:
166 case CK_BooleanToSignedIntegral:
167 case CK_ConstructorConversion:
168 case CK_CopyAndAutoreleaseBlockObject:
170 case CK_FixedPointCast:
171 case CK_FixedPointToBoolean:
172 case CK_FixedPointToFloating:
173 case CK_FixedPointToIntegral:
174 case CK_FloatingCast:
175 case CK_FloatingComplexCast:
176 case CK_FloatingComplexToBoolean:
177 case CK_FloatingComplexToIntegralComplex:
178 case CK_FloatingComplexToReal:
179 case CK_FloatingRealToComplex:
180 case CK_FloatingToBoolean:
181 case CK_FloatingToFixedPoint:
182 case CK_FloatingToIntegral:
183 case CK_HLSLAggregateSplatCast:
184 case CK_HLSLArrayRValue:
185 case CK_HLSLElementwiseCast:
186 case CK_HLSLVectorTruncation:
187 case CK_IntToOCLSampler:
188 case CK_IntegralCast:
189 case CK_IntegralComplexCast:
190 case CK_IntegralComplexToBoolean:
191 case CK_IntegralComplexToFloatingComplex:
192 case CK_IntegralComplexToReal:
193 case CK_IntegralRealToComplex:
194 case CK_IntegralToBoolean:
195 case CK_IntegralToFixedPoint:
196 case CK_IntegralToFloating:
197 case CK_LValueBitCast:
199 case CK_MemberPointerToBoolean:
200 case CK_NonAtomicToAtomic:
201 case CK_ObjCObjectLValueCast:
202 case CK_PointerToBoolean:
203 case CK_PointerToIntegral:
206 case CK_UserDefinedConversion:
208 case CK_ZeroToOCLOpaqueType:
209 llvm_unreachable(
"unexpected cast for emitPointerWithAlignment");
216 if (uo->getOpcode() == UO_AddrOf) {
226 if (
auto const *call = dyn_cast<CallExpr>(
expr)) {
227 switch (call->getBuiltinCallee()) {
230 case Builtin::BIaddressof:
231 case Builtin::BI__addressof:
232 case Builtin::BI__builtin_addressof: {
233 cgm.errorNYI(
expr->getSourceRange(),
234 "emitPointerWithAlignment: builtin addressof");
248 if (!dst.isSimple()) {
249 if (dst.isVectorElt()) {
251 const mlir::Location loc = dst.getVectorPointer().getLoc();
252 const mlir::Value vector =
253 builder.createLoad(loc, dst.getVectorAddress());
254 const mlir::Value newVector = builder.create<cir::VecInsertOp>(
255 loc, vector, src.
getValue(), dst.getVectorIdx());
256 builder.createStore(loc, newVector, dst.getVectorAddress());
260 assert(dst.isBitField() &&
"Unknown LValue type");
264 cgm.errorNYI(dst.getPointer().getLoc(),
265 "emitStoreThroughLValue: non-simple lvalue");
271 assert(src.
isScalar() &&
"Can't emit an aggregate store with this method");
283 "emitGlobalVarDeclLValue: thread_local variable");
297 if (realPtrTy != v.getType())
301 Address addr(v, realVarTy, alignment);
305 "emitGlobalVarDeclLValue: reference type");
314 bool isInit,
bool isNontemporal) {
319 if (clangVecTy->isExtVectorBoolType())
321 "emitStoreOfScalar ExtVectorBoolType");
329 if (vecTy.getSize() == 3 && !
getLangOpts().PreserveVec3Type)
331 "emitStoreOfScalar Vec3 & PreserveVec3Type disabled");
339 assert(addr.
getPointer() &&
"expected pointer to exist");
341 if (currVarDecl && srcAlloca) {
342 const VarDecl *vd = currVarDecl;
343 assert(vd &&
"VarDecl expected");
348 assert(
currSrcLoc &&
"must pass in source location");
349 builder.createStore(*
currSrcLoc, value, addr, isVolatile);
352 cgm.errorNYI(addr.
getPointer().getLoc(),
"emitStoreOfScalar nontemporal");
362 return targetInfo.
getABI().starts_with(
"aapcs");
370 Address ptr = dst.getBitFieldAddress();
372 bool useVoaltile =
cgm.getCodeGenOpts().AAPCSBitfieldWidth &&
373 dst.isVolatileQualified() &&
376 mlir::Value dstAddr = dst.getAddress().getPointer();
378 return builder.createSetBitfield(dstAddr.getLoc(), resLTy, ptr,
380 dst.isVolatileQualified(), useVoaltile);
402 mlir::Type fieldType,
405 cir::PointerType fieldPtr = cir::PointerType::get(fieldType);
411 rec.getElementOffset(
cgm.getDataLayout().layout,
index));
419 cgm.getTypes().getCIRGenRecordLayout(field->
getParent());
429 addr = builder.createElementBitCast(loc, addr, info.
storageType);
452 if (
auto *classDecl = dyn_cast<CXXRecordDecl>(rec)) {
453 if (
cgm.getCodeGenOpts().StrictVTablePointers &&
454 classDecl->isDynamicClass()) {
456 "emitLValueForField: strict vtable for dynamic class");
462 llvm::StringRef fieldName = field->
getName();
470 cgm.getTypes().getCIRGenRecordLayout(field->
getParent());
483 if (field->
hasAttr<AnnotateAttr>()) {
494 "emitLValueForField: __weak attribute");
509 cgm.getTypes().getCIRGenRecordLayout(field->
getParent());
539 assert(0 &&
"NYI: emitStoreOfScalar constant matrix type");
544 lvalue.
getType(), isInit,
false);
554 if (clangVecTy->isExtVectorBoolType()) {
555 cgm.errorNYI(loc,
"emitLoadOfScalar: ExtVectorBoolType");
563 if (vecTy.getSize() == 3 && !
getLangOpts().PreserveVec3Type)
565 "emitLoadOfScalar Vec3 & PreserveVec3Type disabled");
571 cgm.errorNYI(
"emitLoadOfScalar: load atomic");
573 if (mlir::isa<cir::VoidType>(eltTy))
574 cgm.errorNYI(loc,
"emitLoadOfScalar: void type");
578 mlir::Value loadOp = builder.createLoad(
getLoc(loc), addr, isVolatile);
580 cgm.errorNYI(
"emitLoadOfScalar: boolean type with boolean representation");
607 const mlir::Value load =
613 cgm.errorNYI(loc,
"emitLoadOfLValue");
631 mlir::Type fnTy = funcOp.getFunctionType();
632 mlir::Type ptrTy = cir::PointerType::get(fnTy);
633 mlir::Value addr = cgf.
getBuilder().create<cir::GetGlobalOp>(
634 loc, ptrTy, funcOp.getSymName());
638 ptrTy = cir::PointerType::get(fnTy);
640 addr = cir::CastOp::create(cgf.
getBuilder(), addr.getLoc(), ptrTy,
641 cir::CastKind::bitcast, addr);
653 "should not emit an unevaluated operand");
655 if (
const auto *vd = dyn_cast<VarDecl>(nd)) {
665 if (vd->hasLinkage() || vd->isStaticDataMember())
689 assert((vd->isStaticLocal() ||
symbolTable.count(vd)) &&
690 "non-static locals should be already mapped");
695 if (
const auto *bd = dyn_cast<BindingDecl>(nd)) {
704 if (
const auto *fd = dyn_cast<FunctionDecl>(nd)) {
708 if (
getContext().getTargetInfo().allowDebugInfoForExternalRef())
725 "evaluateExprAsBool: member pointer type");
741 if (op == UO_Extension)
747 assert(!t.
isNull() &&
"CodeGenFunction::EmitUnaryOpLValue: Illegal type");
767 assert(lv.
isSimple() &&
"real/imag on non-ordinary l-value");
782 ? builder.createComplexRealPtr(loc, lv.
getAddress())
783 : builder.createComplexImagPtr(loc, lv.
getAddress());
791 cir::UnaryOpKind kind =
792 e->
isIncrementOp() ? cir::UnaryOpKind::Inc : cir::UnaryOpKind::Dec;
795 assert(e->
isPrefix() &&
"Prefix operator in unexpected state!");
807 llvm_unreachable(
"UnaryOperator extension should be handled above!");
816 llvm_unreachable(
"UnaryOperator of non-lvalue kind!");
818 llvm_unreachable(
"Unknown unary operator kind!");
826 const auto *
castExpr = dyn_cast<CastExpr>(e);
840 if (
auto constantOp = idx.getDefiningOp<cir::ConstantOp>())
841 return constantOp.getValueAttr<cir::IntAttr>();
850 const CharUnits offset = constantIdx.getValue().getZExtValue() * eltSize;
867 mlir::Location beginLoc,
868 mlir::Location endLoc, mlir::Value ptr,
869 mlir::Type eltTy, mlir::Value idx,
880 mlir::Location beginLoc,
881 mlir::Location endLoc,
Address addr,
883 mlir::Location loc,
bool shouldDecay) {
898 const mlir::Value eltPtr =
902 return Address(eltPtr, elementType, eltAlign);
909 "emitArraySubscriptExpr: ExtVectorElementExpr");
915 "emitArraySubscriptExpr: VariableArrayType");
927 "index was neither LHS nor RHS");
929 auto emitIdxAfterBase = [&](
bool promote) -> mlir::Value {
933 auto ptrTy = mlir::dyn_cast<cir::PointerType>(idx.getType());
934 if (promote && ptrTy && ptrTy.isPtrTo<cir::IntType>())
936 "emitArraySubscriptExpr: index type cast");
944 const mlir::Value idx = emitIdxAfterBase(
false);
950 const mlir::Value idx = emitIdxAfterBase(
true);
953 if (
const auto *ase = dyn_cast<ArraySubscriptExpr>(array))
960 *
this,
cgm.getLoc(array->getBeginLoc()),
cgm.getLoc(array->getEndLoc()),
975 "The base must be a pointer");
995 cir::GlobalOp globalOp =
cgm.getGlobalForStringLiteral(e);
996 assert(globalOp.getAlignment() &&
"expected alignment for string literal");
997 unsigned align = *(globalOp.getAlignment());
1015 case CK_LValueToRValueBitCast:
1016 case CK_ArrayToPointerDecay:
1017 case CK_FunctionToPointerDecay:
1018 case CK_NullToMemberPointer:
1019 case CK_NullToPointer:
1020 case CK_IntegralToPointer:
1021 case CK_PointerToIntegral:
1022 case CK_PointerToBoolean:
1023 case CK_IntegralCast:
1024 case CK_BooleanToSignedIntegral:
1025 case CK_IntegralToBoolean:
1026 case CK_IntegralToFloating:
1027 case CK_FloatingToIntegral:
1028 case CK_FloatingToBoolean:
1029 case CK_FloatingCast:
1030 case CK_FloatingRealToComplex:
1031 case CK_FloatingComplexToReal:
1032 case CK_FloatingComplexToBoolean:
1033 case CK_FloatingComplexCast:
1034 case CK_FloatingComplexToIntegralComplex:
1035 case CK_IntegralRealToComplex:
1036 case CK_IntegralComplexToReal:
1037 case CK_IntegralComplexToBoolean:
1038 case CK_IntegralComplexCast:
1039 case CK_IntegralComplexToFloatingComplex:
1040 case CK_DerivedToBaseMemberPointer:
1041 case CK_BaseToDerivedMemberPointer:
1042 case CK_MemberPointerToBoolean:
1043 case CK_ReinterpretMemberPointer:
1044 case CK_AnyPointerToBlockPointerCast:
1045 case CK_ARCProduceObject:
1046 case CK_ARCConsumeObject:
1047 case CK_ARCReclaimReturnedObject:
1048 case CK_ARCExtendBlockObject:
1049 case CK_CopyAndAutoreleaseBlockObject:
1050 case CK_IntToOCLSampler:
1051 case CK_FloatingToFixedPoint:
1052 case CK_FixedPointToFloating:
1053 case CK_FixedPointCast:
1054 case CK_FixedPointToBoolean:
1055 case CK_FixedPointToIntegral:
1056 case CK_IntegralToFixedPoint:
1058 case CK_HLSLVectorTruncation:
1059 case CK_HLSLArrayRValue:
1060 case CK_HLSLElementwiseCast:
1061 case CK_HLSLAggregateSplatCast:
1062 llvm_unreachable(
"unexpected cast lvalue");
1065 llvm_unreachable(
"dependent cast kind in IR gen!");
1067 case CK_BuiltinFnToFnPtr:
1068 llvm_unreachable(
"builtin functions are handled elsewhere");
1071 case CK_NonAtomicToAtomic:
1072 case CK_AtomicToNonAtomic:
1075 case CK_BaseToDerived:
1076 case CK_AddressSpaceConversion:
1077 case CK_ObjCObjectLValueCast:
1078 case CK_VectorSplat:
1079 case CK_ConstructorConversion:
1080 case CK_UserDefinedConversion:
1081 case CK_CPointerToObjCPointerCast:
1082 case CK_BlockPointerToObjCPointerCast:
1083 case CK_LValueToRValue: {
1085 std::string(
"emitCastLValue for unhandled cast kind: ") +
1091 case CK_LValueBitCast: {
1095 cgm.emitExplicitCastExprType(ce,
this);
1110 "emitCastLValue: NoOp changes volatile qual");
1117 "emitCastLValue: NoOp needs bitcast");
1123 case CK_UncheckedDerivedToBase:
1124 case CK_DerivedToBase: {
1142 case CK_ZeroToOCLOpaqueType:
1143 llvm_unreachable(
"NULL to OpenCL opaque type lvalue cast is not valid");
1146 llvm_unreachable(
"Invalid cast kind");
1183 if (
auto *field = dyn_cast<FieldDecl>(nd)) {
1200 llvm_unreachable(
"Unhandled member declaration!");
1230 llvm_unreachable(
"bad evaluation kind");
1235 const Expr *inner) {
1246 cir::AllocaOp extDeclAlloca;
1250 extDeclAlloca = extDeclAddrIter->second.getDefiningOp<cir::AllocaOp>();
1252 mlir::OpBuilder::InsertPoint ip;
1254 ip = {extDeclAlloca->getBlock(), extDeclAlloca->getIterator()};
1263 "createReferenceTemporary: static/thread storage duration");
1268 llvm_unreachable(
"temporary can't have dynamic storage duration");
1270 llvm_unreachable(
"unknown storage duration");
1294 if (
const auto *classDecl =
1298 referenceTemporaryDtor = classDecl->getDestructor();
1300 if (!referenceTemporaryDtor)
1304 "storage duration with destructors");
1315 "pushTemporaryCleanup: automatic storage duration");
1319 llvm_unreachable(
"temporary cannot have dynamic storage duration");
1329 "Reference should never be pseudo-strong!");
1337 "emitMaterializeTemporaryExpr: ObjCLifetime");
1345 for (
const Expr *ignored : commaLHSs)
1350 "emitMaterializeTemporaryExpr: OpaqueValueExpr");
1357 if (
auto var =
object.getPointer().getDefiningOp<cir::GlobalOp>()) {
1370 if (!adjustments.empty()) {
1372 "emitMaterializeTemporaryExpr: Adjustments");
1387 assert(e->
isUnique() &&
"LValue for a nonunique OVE hasn't been emitted");
1399 assert(e->
isUnique() &&
"RValue for a nonunique OVE hasn't been emitted");
1411 "emitCompoundLiteralLValue: VariablyModifiedType");
1416 ".compoundliteral");
1427 "emitCompoundLiteralLValue: non C++ DestructedType");
1443 "Can't have a scalar return unless the return type is a "
1461 assert(e->
getOpcode() == BO_Assign &&
"unexpected binary l-value");
1500 llvm_unreachable(
"bad evaluation kind");
1519 llvm_unreachable(
"bad evaluation kind");
1527 if (!pd->isInlineBuiltinDeclaration())
1532CIRGenCallee CIRGenFunction::emitDirectCallee(
const GlobalDecl &gd) {
1535 if (
unsigned builtinID = fd->getBuiltinID()) {
1536 if (fd->getAttr<AsmLabelAttr>()) {
1537 cgm.errorNYI(
"AsmLabelAttr");
1540 StringRef ident = fd->getName();
1541 std::string fdInlineName = (ident +
".inline").str();
1543 bool isPredefinedLibFunction =
1544 cgm.getASTContext().BuiltinInfo.isPredefinedLibFunction(builtinID);
1546 bool hasAttributeNoBuiltin =
true;
1553 cgm.errorNYI(
"Inline only builtin function calls");
1562 else if (!isPredefinedLibFunction || !hasAttributeNoBuiltin)
1577 cgm.errorNYI(
"unsupported type for undef rvalue");
1588 "Callee must have function pointer type!");
1609 cgm.getTypes().arrangeFreeFunctionCall(args, fnType);
1631 calleeTy = cir::FuncType::get(calleeTy.getInputs(),
1632 calleeTy.getReturnType(),
false);
1633 auto calleePtrTy = cir::PointerType::get(calleeTy);
1637 if (
auto funcOp = mlir::dyn_cast<cir::FuncOp>(fn)) {
1638 addr = builder.create<cir::GetGlobalOp>(
1640 cir::PointerType::get(funcOp.getFunctionType()), funcOp.getSymName());
1642 addr = fn->getResult(0);
1645 fn = builder.createBitcast(addr, calleePtrTy).getDefiningOp();
1653 cir::CIRCallOpInterface callOp;
1666 if (
const auto *implicitCast = dyn_cast<ImplicitCastExpr>(e)) {
1667 if (implicitCast->getCastKind() == CK_FunctionToPointerDecay ||
1668 implicitCast->getCastKind() == CK_BuiltinFnToFnPtr) {
1669 return emitCallee(implicitCast->getSubExpr());
1674 assert(implicitCast->getCastKind() == CK_LValueToRValue &&
1675 "unexpected implicit cast on function pointers");
1676 }
else if (
const auto *declRef = dyn_cast<DeclRefExpr>(e)) {
1679 return emitDirectCallee(funcDecl);
1682 "emitCallee: call to member function is NYI");
1684 }
else if (
auto *pde = dyn_cast<CXXPseudoDestructorExpr>(e)) {
1689 mlir::Value calleePtr;
1701 if (
const auto *vd =
1706 CIRGenCallee callee(calleeInfo, calleePtr.getDefiningOp());
1714 if (
const auto *ce = dyn_cast<CXXMemberCallExpr>(e))
1722 if (
const auto *operatorCall = dyn_cast<CXXOperatorCallExpr>(e)) {
1726 dyn_cast_or_null<CXXMethodDecl>(operatorCall->getCalleeDecl()))
1761 "Array to pointer decay must have array source type!");
1769 auto lvalueAddrTy = mlir::cast<cir::PointerType>(addr.
getPointer().getType());
1774 [[maybe_unused]]
auto pointeeTy =
1775 mlir::cast<cir::ArrayType>(lvalueAddrTy.getPointee());
1778 assert(mlir::isa<cir::ArrayType>(arrayTy) &&
"expected array");
1779 assert(pointeeTy == arrayTy);
1789 mlir::Value ptr = builder.maybeBuildArrayDecay(
1801 cgm.errorNYI(loc,
"convertTempToRValue: complex type");
1804 cgm.errorNYI(loc,
"convertTempToRValue: aggregate type");
1809 llvm_unreachable(
"bad evaluation kind");
1816 const Stmt *elseS) {
1818 std::optional<mlir::Location> elseLoc;
1822 mlir::LogicalResult resThen = mlir::success(), resElse = mlir::success();
1825 [&](mlir::OpBuilder &, mlir::Location) {
1826 LexicalScope lexScope{*
this, thenLoc, builder.getInsertionBlock()};
1831 [&](mlir::OpBuilder &, mlir::Location) {
1832 assert(elseLoc &&
"Invalid location for elseS.");
1833 LexicalScope lexScope{*
this, *elseLoc, builder.getInsertionBlock()};
1838 return mlir::LogicalResult::success(resThen.succeeded() &&
1839 resElse.succeeded());
1847 std::optional<mlir::Location> elseLoc) {
1853 ifLocs.push_back(*elseLoc);
1854 mlir::Location loc = mlir::FusedLoc::get(&
getMLIRContext(), ifLocs);
1858 return builder.create<cir::IfOp>(loc, condV, elseLoc.has_value(),
1877 Expr *trueExpr = condOp->getTrueExpr();
1878 Expr *falseExpr = condOp->getFalseExpr();
1881 mlir::Value ternaryOpRes =
1883 .create<cir::TernaryOp>(
1885 [
this, trueExpr](mlir::OpBuilder &
b, mlir::Location loc) {
1887 b.create<cir::YieldOp>(loc, lhs);
1890 [
this, falseExpr](mlir::OpBuilder &
b, mlir::Location loc) {
1892 b.create<cir::YieldOp>(loc, rhs);
1901 cgm.errorNYI(
"NYI");
1915 mlir::Location loc,
CharUnits alignment,
1916 bool insertIntoFnEntryBlock,
1917 mlir::Value arraySize) {
1918 mlir::Block *entryBlock = insertIntoFnEntryBlock
1933 mlir::Location loc,
CharUnits alignment,
1934 mlir::OpBuilder::InsertPoint ip,
1935 mlir::Value arraySize) {
1940 cir::PointerType localVarPtrTy = builder.
getPointerTo(ty);
1941 mlir::IntegerAttr alignIntAttr =
cgm.
getSize(alignment);
1945 mlir::OpBuilder::InsertionGuard guard(builder);
1946 builder.restoreInsertionPoint(ip);
1948 ty, name, alignIntAttr);
1962 "emitCXXMemberCallExpr: C++ binary operator");
1969 if (md->isStatic()) {
1974 bool hasQualifier = me->hasQualifier();
1976 bool isArrow = me->isArrow();
1977 const Expr *base = me->getBase();
1980 ce, md,
returnValue, hasQualifier, qualifier, isArrow, base);
1985 assert(!dest.
isIgnored() &&
"Must have a destination!");
2002 "emitCXXConstructExpr: base requires initialization");
2032 bool forVirtualBase =
false;
2033 bool delegating =
false;
2045 forVirtualBase =
true;
2070 cgm.errorNYI(loc,
"load of volatile reference");
2073 builder.create<cir::LoadOp>(loc, refLVal.
getAddress().getElementType(),
2079 CharUnits align =
cgm.getNaturalTypeAlignment(pointeeType, pointeeBaseInfo);
2096 cir::TrapOp::create(builder, loc);
2098 builder.createBlock(builder.getBlock()->getParent());
2102 bool createNewBlock) {
2104 cir::UnreachableOp::create(builder,
getLoc(loc));
2106 builder.createBlock(builder.getBlock()->getParent());
2113 return builder.createDummyValue(loc, t, alignment);
2121 const Twine &name,
Address *alloca,
2122 mlir::OpBuilder::InsertPoint ip) {
2129 mlir::Location loc,
const Twine &name,
2131 mlir::OpBuilder::InsertPoint ip) {
2133 nullptr, alloca, ip);
2136 cgm.errorNYI(loc,
"temporary matrix value");
2144 mlir::Type ty,
CharUnits align, mlir::Location loc,
const Twine &name,
2145 mlir::Value arraySize, mlir::OpBuilder::InsertPoint ip) {
2146 cir::AllocaOp alloca = ip.isSet()
2149 alloca.setAlignmentAttr(
cgm.getSize(align));
2150 return Address(alloca, ty, align);
2156 mlir::Location loc,
const Twine &name,
2157 mlir::Value arraySize,
2159 mlir::OpBuilder::InsertPoint ip) {
2163 *allocaAddr = alloca;
2179 mlir::Value arraySize,
2180 bool insertIntoFnEntryBlock) {
2182 insertIntoFnEntryBlock, arraySize)
2190 mlir::OpBuilder::InsertPoint ip,
2191 mlir::Value arraySize) {
2192 assert(ip.isSet() &&
"Insertion point is not set");
2193 return mlir::cast<cir::AllocaOp>(
2234 mlir::TypedAttr cstToEmit = mlir::dyn_cast_if_present<mlir::TypedAttr>(
c);
2235 assert(cstToEmit &&
"expected a typed attribute");
2251 assert(constant &&
"not a constant");
2263 if (!
cgm.getLangOpts().MSVolatile)
2266 cgm.errorNYI(
"LValueSuitableForInlineAtomic LangOpts MSVolatile");
llvm::function_ref< void(mlir::OpBuilder &, mlir::Location)> BuilderCallbackRef
static Address createReferenceTemporary(CIRGenFunction &cgf, const MaterializeTemporaryExpr *m, const Expr *inner)
static bool isAAPCS(const TargetInfo &targetInfo)
Helper method to check if the underlying ABI is AAPCS.
static LValue emitFunctionDeclLValue(CIRGenFunction &cgf, const Expr *e, GlobalDecl gd)
static CharUnits getArrayElementAlign(CharUnits arrayAlign, mlir::Value idx, CharUnits eltSize)
static void pushTemporaryCleanup(CIRGenFunction &cgf, const MaterializeTemporaryExpr *m, const Expr *e, Address referenceTemporary)
static cir::IntAttr getConstantIndexOrNull(mlir::Value idx)
static const Expr * getSimpleArrayDecayOperand(const Expr *e)
If the specified expr is a simple decay from an array to pointer, return the array subexpression.
static QualType getFixedSizeElementType(const ASTContext &astContext, const VariableArrayType *vla)
static DeclRefExpr * tryToConvertMemberExprToDeclRefExpr(CIRGenFunction &cgf, const MemberExpr *me)
static cir::FuncOp emitFunctionDeclPointer(CIRGenModule &cgm, GlobalDecl gd)
static LValue emitGlobalVarDeclLValue(CIRGenFunction &cgf, const Expr *e, const VarDecl *vd)
static mlir::Value emitArraySubscriptPtr(CIRGenFunction &cgf, mlir::Location beginLoc, mlir::Location endLoc, mlir::Value ptr, mlir::Type eltTy, mlir::Value idx, bool shouldDecay)
static bool onlyHasInlineBuiltinDeclaration(const FunctionDecl *fd)
Defines the clang::Expr interface and subclasses for C++ expressions.
__device__ __2f16 float c
static OpBuilder::InsertPoint getBestAllocaInsertPoint(mlir::Block *block)
cir::GetMemberOp createGetMember(mlir::Location loc, mlir::Type resultTy, mlir::Value base, llvm::StringRef name, unsigned index)
cir::PointerType getPointerTo(mlir::Type ty)
mlir::Value createBitcast(mlir::Value src, mlir::Type newTy)
mlir::Value createAlloca(mlir::Location loc, cir::PointerType addrType, mlir::Type type, llvm::StringRef name, mlir::IntegerAttr alignment, mlir::Value dynAllocSize)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
CharUnits getTypeAlignInChars(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in characters.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
CharUnits getDeclAlign(const Decl *D, bool ForAlignof=false) const
Return a conservative estimate of the alignment of the specified decl D.
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
const VariableArrayType * getAsVariableArrayType(QualType T) const
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
SourceLocation getExprLoc() const LLVM_READONLY
Expr * getLHS()
An array access can be written A[4] or 4[A] (both are equivalent).
SourceLocation getBeginLoc() const LLVM_READONLY
SourceLocation getEndLoc() const
Represents an array type, per C99 6.7.5.2 - Array Declarators.
QualType getElementType() const
A builtin binary operation expression such as "x + y" or "x <= y".
mlir::Value getPointer() const
mlir::Type getElementType() 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::Type getType() const
mlir::Operation * getDefiningOp() const
Get the operation which defines this address.
IsZeroed_t isZeroed() const
static AggValueSlot forAddr(Address addr, clang::Qualifiers quals, IsDestructed_t isDestructed, IsAliased_t isAliased, Overlap_t mayOverlap, IsZeroed_t isZeroed=IsNotZeroed)
Address getAddress() const
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...
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.
Abstract information about a function or function prototype.
bool isPseudoDestructor() const
void setFunctionPointer(mlir::Operation *functionPtr)
const clang::FunctionDecl * getBuiltinDecl() const
const CXXPseudoDestructorExpr * getPseudoDestructorExpr() const
static CIRGenCallee forDirect(mlir::Operation *funcPtr, const CIRGenCalleeInfo &abstractInfo=CIRGenCalleeInfo())
unsigned getBuiltinID() const
static CIRGenCallee forBuiltin(unsigned builtinID, const clang::FunctionDecl *builtinDecl)
mlir::Operation * getFunctionPointer() const
static CIRGenCallee forPseudoDestructor(const clang::CXXPseudoDestructorExpr *expr)
static ConstantEmission forValue(mlir::TypedAttr c)
mlir::TypedAttr getValue() const
static bool shouldBindAsLValue(const Expr *expr)
void emitCallArgs(CallArgList &args, PrototypeWrapper prototype, llvm::iterator_range< clang::CallExpr::const_arg_iterator > argRange, AbstractCallee callee=AbstractCallee(), unsigned paramsToSkip=0)
mlir::Type convertType(clang::QualType t)
static cir::TypeEvaluationKind getEvaluationKind(clang::QualType type)
Return the cir::TypeEvaluationKind of QualType type.
clang::GlobalDecl curGD
The GlobalDecl for the current function being compiled or the global variable currently being initial...
RValue convertTempToRValue(Address addr, clang::QualType type, clang::SourceLocation loc)
Given the address of a temporary variable, produce an r-value of its type.
CIRGenTypes & getTypes() const
Address emitPointerWithAlignment(const clang::Expr *expr, LValueBaseInfo *baseInfo=nullptr)
Given an expression with a pointer type, emit the value and compute our best estimate of the alignmen...
RValue emitLoadOfLValue(LValue lv, SourceLocation loc)
Given an expression that represents a value lvalue, this method emits the address of the lvalue,...
const clang::LangOptions & getLangOpts() const
cir::AllocaOp createTempAlloca(mlir::Type ty, mlir::Location loc, const Twine &name="tmp", mlir::Value arraySize=nullptr, bool insertIntoFnEntryBlock=false)
This creates an alloca and inserts it into the entry block if ArraySize is nullptr,...
void emitTrap(mlir::Location loc, bool createNewBlock)
Emit a trap instruction, which is used to abort the program in an abnormal way, usually for debugging...
mlir::Block * getCurFunctionEntryBlock()
RValue emitCXXMemberCallExpr(const clang::CXXMemberCallExpr *e, ReturnValueSlot returnValue)
LValue emitLValueForBitField(LValue base, const FieldDecl *field)
mlir::LogicalResult emitIfOnBoolExpr(const clang::Expr *cond, const clang::Stmt *thenS, const clang::Stmt *elseS)
Emit an if on a boolean condition to the specified blocks.
mlir::Value emitComplexExpr(const Expr *e)
Emit the computation of the specified expression of complex type, returning the result.
LValue makeNaturalAlignPointeeAddrLValue(mlir::Value v, clang::QualType t)
Given a value of type T* that may not be to a complete object, construct an l-vlaue withi the natural...
RValue emitCallExpr(const clang::CallExpr *e, ReturnValueSlot returnValue=ReturnValueSlot())
LValue emitMemberExpr(const MemberExpr *e)
LValue emitLValue(const clang::Expr *e)
Emit code to compute a designator that specifies the location of the expression.
Address makeNaturalAddressForPointer(mlir::Value ptr, QualType t, CharUnits alignment, bool forPointeeType=false, LValueBaseInfo *baseInfo=nullptr)
Construct an address with the natural alignment of T.
mlir::Value evaluateExprAsBool(const clang::Expr *e)
Perform the usual unary conversions on the specified expression and compare the result against zero,...
std::string getCounterRefTmpAsString()
void emitStoreOfScalar(mlir::Value value, Address addr, bool isVolatile, clang::QualType ty, bool isInit=false, bool isNontemporal=false)
mlir::Location getLoc(clang::SourceLocation srcLoc)
Helpers to convert Clang's SourceLocation to a MLIR Location.
mlir::Value emitOpOnBoolExpr(mlir::Location loc, const clang::Expr *cond)
TODO(cir): see EmitBranchOnBoolExpr for extra ideas).
Address getAddressOfBaseClass(Address value, const CXXRecordDecl *derived, llvm::iterator_range< CastExpr::path_const_iterator > path, bool nullCheckValue, SourceLocation loc)
LValue emitStringLiteralLValue(const StringLiteral *e)
LValue emitLoadOfReferenceLValue(Address refAddr, mlir::Location loc, QualType refTy, AlignmentSource source)
mlir::Value emitScalarPrePostIncDec(const UnaryOperator *e, LValue lv, cir::UnaryOpKind kind, bool isPre)
void emitAnyExprToMem(const Expr *e, Address location, Qualifiers quals, bool isInitializer)
Emits the code necessary to evaluate an arbitrary expression into the given memory location.
LValue getOrCreateOpaqueLValueMapping(const OpaqueValueExpr *e)
Given an opaque value expression, return its LValue mapping if it exists, otherwise create one.
void emitNullInitialization(mlir::Location loc, Address destPtr, QualType ty)
RValue emitReferenceBindingToExpr(const Expr *e)
Emits a reference binding to the passed in expression.
RValue emitAnyExpr(const clang::Expr *e, AggValueSlot aggSlot=AggValueSlot::ignored())
Emit code to compute the specified expression which can have any type.
LValue emitArraySubscriptExpr(const clang::ArraySubscriptExpr *e)
mlir::Value emitScalarConversion(mlir::Value src, clang::QualType srcType, clang::QualType dstType, clang::SourceLocation loc)
Emit a conversion from the specified type to the specified destination type, both of which are CIR sc...
AggValueSlot createAggTemp(QualType ty, mlir::Location loc, const Twine &name="tmp", Address *alloca=nullptr)
Create a temporary memory object for the given aggregate type.
mlir::Type convertTypeForMem(QualType t)
mlir::Value emitAlloca(llvm::StringRef name, mlir::Type ty, mlir::Location loc, clang::CharUnits alignment, bool insertIntoFnEntryBlock, mlir::Value arraySize=nullptr)
void emitUnreachable(clang::SourceLocation loc, bool createNewBlock)
Emit a reached-unreachable diagnostic if loc is valid and runtime checking is enabled.
mlir::Value createDummyValue(mlir::Location loc, clang::QualType qt)
void emitCXXConstructExpr(const clang::CXXConstructExpr *e, AggValueSlot dest)
static Destroyer destroyCXXObject
RValue getUndefRValue(clang::QualType ty)
Get an appropriate 'undef' rvalue for the given type.
Address returnValue
The temporary alloca to hold the return value.
void emitCXXConstructorCall(const clang::CXXConstructorDecl *d, clang::CXXCtorType type, bool forVirtualBase, bool delegating, AggValueSlot thisAVS, const clang::CXXConstructExpr *e)
std::string getCounterAggTmpAsString()
LValue emitUnaryOpLValue(const clang::UnaryOperator *e)
RValue emitLoadOfBitfieldLValue(LValue lv, SourceLocation loc)
RValue emitCall(const CIRGenFunctionInfo &funcInfo, const CIRGenCallee &callee, ReturnValueSlot returnValue, const CallArgList &args, cir::CIRCallOpInterface *callOp, mlir::Location loc)
LValue emitComplexAssignmentLValue(const BinaryOperator *e)
LValue emitLValueForFieldInitialization(LValue base, const clang::FieldDecl *field, llvm::StringRef fieldName)
Like emitLValueForField, excpet that if the Field is a reference, this will return the address of the...
LValue emitCallExprLValue(const clang::CallExpr *e)
mlir::Value emitScalarExpr(const clang::Expr *e)
Emit the computation of the specified expression of scalar type.
mlir::Value emitToMemory(mlir::Value value, clang::QualType ty)
Given a value and its clang type, returns the value casted to its memory representation.
LValue emitLValueForField(LValue base, const clang::FieldDecl *field)
cir::FuncOp curFn
The function for which code is currently being generated.
void pushDestroy(CleanupKind kind, Address addr, QualType type, Destroyer *destroyer)
Address emitLoadOfReference(LValue refLVal, mlir::Location loc, LValueBaseInfo *pointeeBaseInfo)
bool shouldNullCheckClassCastValue(const CastExpr *ce)
CIRGenBuilderTy & getBuilder()
LValue emitBinaryOperatorLValue(const BinaryOperator *e)
Address getAddrOfBitFieldStorage(LValue base, const clang::FieldDecl *field, mlir::Type fieldType, unsigned index)
CIRGenModule & getCIRGenModule()
mlir::MLIRContext & getMLIRContext()
LValue emitCastLValue(const CastExpr *e)
Casts are never lvalues unless that cast is to a reference type.
mlir::Value emitLoadOfScalar(LValue lvalue, SourceLocation loc)
EmitLoadOfScalar - Load a scalar value from an address, taking care to appropriately convert from the...
DeclMapTy localDeclMap
This keeps track of the CIR allocas or globals for local C declarations.
LValue emitDeclRefLValue(const clang::DeclRefExpr *e)
void emitComplexExprIntoLValue(const Expr *e, LValue dest, bool isInit)
ConstantEmission tryEmitAsConstant(const DeclRefExpr *refExpr)
Try to emit a reference to the given value without producing it as an l-value.
LValue makeAddrLValue(Address addr, QualType ty, AlignmentSource source=AlignmentSource::Type)
llvm::DenseMap< const OpaqueValueExpr *, RValue > opaqueRValues
Address emitArrayToPointerDecay(const Expr *e, LValueBaseInfo *baseInfo=nullptr)
void emitCXXAggrConstructorCall(const CXXConstructorDecl *ctor, const clang::ArrayType *arrayType, Address arrayBegin, const CXXConstructExpr *e, bool newPointerIsChecked, bool zeroInitialize=false)
Emit a loop to call a particular constructor for each of several members of an array.
LexicalScope * curLexScope
mlir::Value emitStoreThroughBitfieldLValue(RValue src, LValue dstresult)
llvm::DenseMap< const OpaqueValueExpr *, LValue > opaqueLValues
Keeps track of the current set of opaque value expressions.
std::optional< mlir::Location > currSrcLoc
Use to track source locations across nested visitor traversals.
LValue emitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *e)
clang::ASTContext & getContext() const
RValue emitCXXMemberOrOperatorMemberCallExpr(const clang::CallExpr *ce, const clang::CXXMethodDecl *md, ReturnValueSlot returnValue, bool hasQualifier, clang::NestedNameSpecifier qualifier, bool isArrow, const clang::Expr *base)
mlir::Value emitScalarConstant(const ConstantEmission &constant, Expr *e)
RValue emitBuiltinExpr(const clang::GlobalDecl &gd, unsigned builtinID, const clang::CallExpr *e, ReturnValueSlot returnValue)
RValue emitCXXOperatorMemberCallExpr(const CXXOperatorCallExpr *e, const CXXMethodDecl *md, ReturnValueSlot returnValue)
void emitStoreThroughLValue(RValue src, LValue dst, bool isInit=false)
Store the specified rvalue into the specified lvalue, where both are guaranteed to the have the same ...
bool isLValueSuitableForInlineAtomic(LValue lv)
An LValue is a candidate for having its loads and stores be made atomic if we are operating under /vo...
mlir::LogicalResult emitStmt(const clang::Stmt *s, bool useCurrentScope, llvm::ArrayRef< const Attr * > attrs={})
RValue getOrCreateOpaqueRValueMapping(const OpaqueValueExpr *e)
Given an opaque value expression, return its RValue mapping if it exists, otherwise create one.
Address createTempAllocaWithoutCast(mlir::Type ty, CharUnits align, mlir::Location loc, const Twine &name="tmp", mlir::Value arraySize=nullptr, mlir::OpBuilder::InsertPoint ip={})
This creates a alloca and inserts it into the entry block of the current region.
void emitIgnoredExpr(const clang::Expr *e)
Emit code to compute the specified expression, ignoring the result.
Address createMemTemp(QualType t, mlir::Location loc, const Twine &name="tmp", Address *alloca=nullptr, mlir::OpBuilder::InsertPoint ip={})
Create a temporary memory object of the given type, with appropriate alignmen and cast it to the defa...
void emitAggExpr(const clang::Expr *e, AggValueSlot slot)
RValue emitCXXPseudoDestructorExpr(const CXXPseudoDestructorExpr *expr)
LValue emitCompoundLiteralLValue(const CompoundLiteralExpr *e)
CIRGenCallee emitCallee(const clang::Expr *e)
Address emitAddrOfFieldStorage(Address base, const FieldDecl *field, llvm::StringRef fieldName, unsigned fieldIndex)
Get the address of a zero-sized field within a record.
This class organizes the cross-function state that is used while generating CIR code.
DiagnosticBuilder errorNYI(SourceLocation, llvm::StringRef)
Helpers to emit "not yet implemented" error diagnostics.
mlir::IntegerAttr getSize(CharUnits size)
CIRGenBuilderTy & getBuilder()
cir::FuncOp getAddrOfFunction(clang::GlobalDecl gd, mlir::Type funcType=nullptr, bool forVTable=false, bool dontDefer=false, ForDefinition_t isForDefinition=NotForDefinition)
Return the address of the given function.
mlir::Value getAddrOfGlobalVar(const VarDecl *d, mlir::Type ty={}, ForDefinition_t isForDefinition=NotForDefinition)
Return the mlir::Value for the address of the given global variable.
This class handles record and union layout info while lowering AST types to CIR types.
cir::RecordType getCIRType() const
Return the "complete object" LLVM type associated with this record.
const CIRGenBitFieldInfo & getBitFieldInfo(const clang::FieldDecl *fd) const
Return the BitFieldInfo that corresponds to the field FD.
unsigned getCIRFieldNo(const clang::FieldDecl *fd) const
Return cir::RecordType element number that corresponds to the field FD.
cir::FuncType getFunctionType(const CIRGenFunctionInfo &info)
Get the CIR function type for.
mlir::Attribute emitAbstract(const Expr *e, QualType destType)
Emit the result of the given expression as an abstract constant, asserting that it succeeded.
AlignmentSource getAlignmentSource() const
void mergeForCast(const LValueBaseInfo &info)
const clang::Qualifiers & getQuals() const
mlir::Value getVectorIdx() const
Address getAddress() const
static LValue makeAddr(Address address, clang::QualType t, LValueBaseInfo baseInfo)
static LValue makeVectorElt(Address vecAddress, mlir::Value index, clang::QualType t, LValueBaseInfo baseInfo)
unsigned getVRQualifiers() const
clang::QualType getType() const
static LValue makeBitfield(Address addr, const CIRGenBitFieldInfo &info, clang::QualType type, LValueBaseInfo baseInfo)
Create a new object to represent a bit-field access.
mlir::Value getPointer() const
bool isVolatileQualified() const
Address getVectorAddress() const
clang::CharUnits getAlignment() const
LValueBaseInfo getBaseInfo() const
const CIRGenBitFieldInfo & getBitFieldInfo() const
Address getBitFieldAddress() const
This trivial value class is used to represent the result of an expression that is evaluated.
static RValue get(mlir::Value v)
static RValue getComplex(mlir::Value v)
mlir::Value getValue() const
Return the value of this scalar value.
Contains the address where the return value of a function can be stored, and whether the address is v...
Represents a call to a C++ constructor.
bool isElidable() const
Whether this construction is elidable.
Expr * getArg(unsigned Arg)
Return the specified argument.
bool requiresZeroInitialization() const
Whether this construction first requires zero-initialization before the initializer is called.
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will (ultimately) call.
CXXConstructionKind getConstructionKind() const
Determine whether this constructor is actually constructing a base class (rather than a complete obje...
Represents a C++ constructor within a class.
bool isDefaultConstructor() const
Whether this constructor is a default constructor (C++ [class.ctor]p5), which can be used to default-...
Represents a C++ destructor within a class.
Represents a call to a member function that may be written either with member call syntax (e....
Represents a static or instance method of a struct/union/class.
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined.
Represents a C++ struct/union/class.
bool hasTrivialDestructor() const
Determine whether this class has a trivial destructor (C++ [class.dtor]p3)
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return null.
QualType getCallReturnType(const ASTContext &Ctx) const
getCallReturnType - Get the return type of the call expr.
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
CastKind getCastKind() const
llvm::iterator_range< path_iterator > path()
Path through the class hierarchy taken by casts between base and derived classes (see implementation ...
bool changesVolatileQualification() const
Return.
static const char * getCastKindName(CastKind CK)
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?
CharUnits alignmentOfArrayElement(CharUnits elementSize) const
Given that this is the alignment of the first element of an array, return the minimum alignment of an...
static CharUnits fromQuantity(QuantityType Quantity)
fromQuantity - Construct a CharUnits quantity from a raw integer type.
Complex values, per C99 6.2.5p11.
CompoundLiteralExpr - [C99 6.5.2.5].
const Expr * getInitializer() const
ConditionalOperator - The ?
A reference to a declared variable, function, enum, etc.
bool refersToEnclosingVariableOrCapture() const
Does this DeclRefExpr refer to an enclosing local or a captured variable?
static DeclRefExpr * Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *D, bool RefersToEnclosingVariableOrCapture, SourceLocation NameLoc, QualType T, ExprValueKind VK, NamedDecl *FoundD=nullptr, const TemplateArgumentListInfo *TemplateArgs=nullptr, NonOdrUseReason NOUR=NOUR_None)
NonOdrUseReason isNonOdrUse() const
Is this expression a non-odr-use reference, and if so, why?
SourceLocation getLocation() const
SourceLocation getLocation() const
This represents one expression.
const Expr * skipRValueSubobjectAdjustments(SmallVectorImpl< const Expr * > &CommaLHS, SmallVectorImpl< SubobjectAdjustment > &Adjustments) const
Walk outwards from an expression we want to bind a reference to and find the expression whose lifetim...
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
bool EvaluateAsRValue(EvalResult &Result, const ASTContext &Ctx, bool InConstantContext=false) const
EvaluateAsRValue - Return true if this is a constant which we can fold to an rvalue using any crazy t...
Decl * getReferencedDeclOfCallee()
bool isTemporaryObject(ASTContext &Ctx, const CXXRecordDecl *TempTy) const
Determine whether the result of this expression is a temporary object of the given class type.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
Represents a member of a struct/union/class.
bool isBitField() const
Determines whether this field is a bitfield.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
unsigned getFieldIndex() const
Returns the index of this field within its record, as appropriate for passing to ASTRecordLayout::get...
const RecordDecl * getParent() const
Returns the parent of this field declaration, which is the struct in which this field is defined.
bool isZeroSize(const ASTContext &Ctx) const
Determine if this field is a subobject of zero size, that is, either a zero-length bit-field or a fie...
Represents a function declaration or definition.
bool isTrivial() const
Whether this function is "trivial" in some specialized C++ senses.
FunctionDecl * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
Represents a prototype with parameter type info, e.g.
GlobalDecl - represents a global declaration.
const Decl * getDecl() const
Represents a prvalue temporary that is written into memory so that a reference can bind to it.
StorageDuration getStorageDuration() const
Retrieve the storage duration for the materialized temporary.
Expr * getSubExpr() const
Retrieve the temporary-generating subexpression whose value will be materialized into a glvalue.
ValueDecl * getExtendingDecl()
Get the declaration which triggered the lifetime-extension of this temporary, if any.
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
NonOdrUseReason isNonOdrUse() const
Is this expression a non-odr-use reference, and if so, why?
SourceLocation getExprLoc() const LLVM_READONLY
A pointer to member type per C++ 8.3.3 - Pointers to members.
This represents a decl that may have a name.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
A C++ nested-name-specifier augmented with source location information.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class.
Expr * getSourceExpr() const
The source expression of an opaque value expression is the expression which originally generated the ...
PointerType - C99 6.7.5.1 - Pointer Declarators.
A (possibly-)qualified type.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
QualType withCVRQualifiers(unsigned CVR) const
DestructionKind isDestructedType() const
Returns a nonzero value if objects of this type require non-trivial work to clean up after.
The collection of all-type qualifiers we support.
@ OCL_ExplicitNone
This object can be modified without requiring retains or releases.
@ OCL_None
There is no lifetime qualification on this type.
void addCVRQualifiers(unsigned mask)
void addQualifiers(Qualifiers Q)
Add the qualifiers from the given set to this set.
Represents a struct/union/class.
Encodes a location in the source.
Stmt - This represents one statement.
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
StringLiteral - This represents a string literal expression, e.g.
Exposes information about the current target.
virtual StringRef getABI() const
Get the ABI currently in use.
bool isBooleanType() const
const ArrayType * castAsArrayTypeUnsafe() const
A variant of castAs<> for array type which silently discards qualifiers from the outermost type.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isFunctionPointerType() const
CXXRecordDecl * castAsCXXRecordDecl() const
bool isArithmeticType() const
bool isConstantMatrixType() const
bool isPointerType() const
const T * castAs() const
Member-template castAs<specific type>.
bool isReferenceType() const
bool isVariableArrayType() const
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isAnyComplexType() const
const Type * getBaseElementTypeUnsafe() const
Get the base element type of this type, potentially discarding type qualifiers.
bool isAtomicType() const
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
bool isFunctionType() const
bool isVectorType() const
const T * getAs() const
Member-template getAs<specific type>'.
bool hasBooleanRepresentation() const
Determine whether this type has a boolean representation â i.e., it is a boolean type,...
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
SourceLocation getExprLoc() const
Expr * getSubExpr() const
static bool isIncrementOp(Opcode Op)
static bool isPrefix(Opcode Op)
isPrefix - Return true if this is a prefix operation, like âx.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Represents a variable declaration or definition.
TLSKind getTLSKind() const
@ TLS_Dynamic
TLS with a dynamic initializer.
Represents a C array with a specified size that is not an integer-constant-expression.
Represents a GCC generic vector type.
AlignmentSource
The source of the alignment of an l-value; an expression of confidence in the alignment actually matc...
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
static AlignmentSource getFieldAlignmentSource(AlignmentSource source)
Given that the base address has the given alignment source, what's our confidence in the alignment of...
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
const AstTypeMatcher< ArrayType > arrayType
const AstTypeMatcher< FunctionType > functionType
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
const internal::VariadicDynCastAllOfMatcher< Stmt, CastExpr > castExpr
Matches any cast nodes of Clang's AST.
The JSON file list parser is used to communicate input to InstallAPI.
CXXCtorType
C++ constructor types.
@ Ctor_Base
Base object ctor.
@ Ctor_Complete
Complete object ctor.
bool isa(CodeGen::Address addr)
@ SD_Thread
Thread storage duration.
@ SD_Static
Static storage duration.
@ SD_FullExpression
Full-expression storage duration (for temporaries).
@ SD_Automatic
Automatic storage duration (most local variables).
@ SD_Dynamic
Dynamic storage duration.
U cast(CodeGen::Address addr)
@ NOUR_Unevaluated
This name appears in an unevaluated operand.
static bool weakRefReference()
static bool objCLifetime()
static bool emitLifetimeMarkers()
static bool opLoadEmitScalarRangeCheck()
static bool addressSpace()
static bool opLoadStoreThreadLocal()
static bool opAllocaNonGC()
static bool opGlobalThreadLocal()
static bool opAllocaOpenMPThreadPrivate()
static bool preservedAccessIndexRegion()
static bool mergeAllConstants()
static bool opLoadStoreAtomic()
static bool opLoadStoreTbaa()
static bool cgFPOptionsRAII()
static bool opCallChain()
static bool opAllocaImpreciseLifetime()
static bool opAllocaStaticLocal()
static bool aggValueSlot()
static bool opAllocaTLS()
static bool emitCheckedInBoundsGEP()
static bool attributeNoBuiltin()
static bool lambdaFieldToName()
static bool setObjCGCLValueClass()
static bool cirgenABIInfo()
static bool opLoadStoreObjC()
static bool opCallArgEvaluationOrder()
static bool lambdaCaptures()
static bool insertBuiltinUnpredictable()
static bool opCallMustTail()
static bool shouldReverseUnaryCondOnBoolExpr()
static bool tryEmitAsConstant()
static bool addressIsKnownNonNull()
static bool astVarDeclInterface()
static bool opAllocaEscapeByReference()
static bool opLoadStoreNontemporal()
static bool opCallFnInfoOpts()
static bool generateDebugInfo()
Record with information about how a bitfield should be accessed.
unsigned volatileStorageSize
The storage size in bits which should be used when accessing this bitfield.
unsigned volatileOffset
The offset within a contiguous run of bitfields that are represented as a single "field" within the c...
Represents a scope, including function bodies, compound statements, and the substatements of if/while...
EvalResult is a struct with detailed info about an evaluated expression.
APValue Val
Val - This is the value the expression can be folded to.
bool HasSideEffects
Whether the evaluated expression has side effects.