-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[CIR] Implement LValueBitcast for ComplexType #150668
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -923,4 +923,129 @@ CIRGenFunction::emitArrayLength(const clang::ArrayType *origArrayType, | |
| return builder.getConstInt(*currSrcLoc, SizeTy, countFromCLAs); | ||
| } | ||
|
|
||
| // TODO(cir): most part of this function can be shared between CIRGen | ||
| // and traditional LLVM codegen | ||
| void CIRGenFunction::emitVariablyModifiedType(QualType type) { | ||
| assert(type->isVariablyModifiedType() && | ||
| "Must pass variably modified type to EmitVLASizes!"); | ||
|
|
||
| // We're going to walk down into the type and look for VLA | ||
| // expressions. | ||
| do { | ||
| assert(type->isVariablyModifiedType()); | ||
|
|
||
| const Type *ty = type.getTypePtr(); | ||
| switch (ty->getTypeClass()) { | ||
| case Type::CountAttributed: | ||
| case Type::PackIndexing: | ||
| case Type::ArrayParameter: | ||
| case Type::HLSLAttributedResource: | ||
| case Type::HLSLInlineSpirv: | ||
| case Type::PredefinedSugar: | ||
| llvm_unreachable("NYI"); | ||
|
||
|
|
||
| #define TYPE(Class, Base) | ||
| #define ABSTRACT_TYPE(Class, Base) | ||
| #define NON_CANONICAL_TYPE(Class, Base) | ||
| #define DEPENDENT_TYPE(Class, Base) case Type::Class: | ||
| #define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) | ||
| #include "clang/AST/TypeNodes.inc" | ||
| llvm_unreachable("unexpected dependent type!"); | ||
|
||
|
|
||
| // These types are never variably-modified. | ||
| case Type::Builtin: | ||
| case Type::Complex: | ||
| case Type::Vector: | ||
| case Type::ExtVector: | ||
| case Type::ConstantMatrix: | ||
| case Type::Record: | ||
| case Type::Enum: | ||
| case Type::Using: | ||
| case Type::TemplateSpecialization: | ||
| case Type::ObjCTypeParam: | ||
| case Type::ObjCObject: | ||
| case Type::ObjCInterface: | ||
| case Type::ObjCObjectPointer: | ||
| case Type::BitInt: | ||
| llvm_unreachable("type class is never variably-modified!"); | ||
|
|
||
| case Type::Elaborated: | ||
| type = cast<clang::ElaboratedType>(ty)->getNamedType(); | ||
| break; | ||
|
|
||
| case Type::Adjusted: | ||
| type = cast<clang::AdjustedType>(ty)->getAdjustedType(); | ||
| break; | ||
|
|
||
| case Type::Decayed: | ||
| type = cast<clang::DecayedType>(ty)->getPointeeType(); | ||
| break; | ||
|
|
||
| case Type::Pointer: | ||
| type = cast<clang::PointerType>(ty)->getPointeeType(); | ||
| break; | ||
|
|
||
| case Type::BlockPointer: | ||
| type = cast<clang::BlockPointerType>(ty)->getPointeeType(); | ||
| break; | ||
|
|
||
| case Type::LValueReference: | ||
| case Type::RValueReference: | ||
| type = cast<clang::ReferenceType>(ty)->getPointeeType(); | ||
| break; | ||
|
|
||
| case Type::MemberPointer: | ||
| type = cast<clang::MemberPointerType>(ty)->getPointeeType(); | ||
| break; | ||
|
|
||
| case Type::ConstantArray: | ||
| case Type::IncompleteArray: | ||
| // Losing element qualification here is fine. | ||
| type = cast<clang::ArrayType>(ty)->getElementType(); | ||
| break; | ||
|
|
||
| case Type::VariableArray: { | ||
| cgm.errorNYI("CIRGenFunction::emitVariablyModifiedType VLA"); | ||
| break; | ||
| } | ||
|
|
||
| case Type::FunctionProto: | ||
| case Type::FunctionNoProto: | ||
| type = cast<clang::FunctionType>(ty)->getReturnType(); | ||
| break; | ||
|
|
||
| case Type::Paren: | ||
| case Type::TypeOf: | ||
| case Type::UnaryTransform: | ||
| case Type::Attributed: | ||
| case Type::BTFTagAttributed: | ||
| case Type::SubstTemplateTypeParm: | ||
| case Type::MacroQualified: | ||
| // Keep walking after single level desugaring. | ||
| type = type.getSingleStepDesugaredType(getContext()); | ||
| break; | ||
|
|
||
| case Type::Typedef: | ||
| case Type::Decltype: | ||
| case Type::Auto: | ||
| case Type::DeducedTemplateSpecialization: | ||
| // Stop walking: nothing to do. | ||
| return; | ||
|
|
||
| case Type::TypeOfExpr: | ||
| // Stop walking: emit typeof expression. | ||
| emitIgnoredExpr(cast<clang::TypeOfExprType>(ty)->getUnderlyingExpr()); | ||
| return; | ||
|
|
||
| case Type::Atomic: | ||
| type = cast<clang::AtomicType>(ty)->getValueType(); | ||
| break; | ||
|
|
||
| case Type::Pipe: | ||
| type = cast<clang::PipeType>(ty)->getElementType(); | ||
| break; | ||
| } | ||
| } while (type->isVariablyModifiedType()); | ||
| } | ||
|
|
||
| } // namespace clang::CIRGen | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1208,6 +1208,16 @@ cir::GlobalOp CIRGenModule::getGlobalForStringLiteral(const StringLiteral *s, | |
| return gv; | ||
| } | ||
|
|
||
| void CIRGenModule::emitExplicitCastExprType(const ExplicitCastExpr *e, | ||
| CIRGenFunction *cgf) { | ||
| // Bind VLAs in the cast type. | ||
|
||
| if (cgf && e->getType()->isVariablyModifiedType()) | ||
| cgf->emitVariablyModifiedType(e->getType()); | ||
|
|
||
| assert(!cir::MissingFeatures::generateDebugInfo() && | ||
| "emitExplicitCastExprType"); | ||
| } | ||
|
|
||
| void CIRGenModule::emitDeclContext(const DeclContext *dc) { | ||
| for (Decl *decl : dc->decls()) { | ||
| // Unlike other DeclContexts, the contents of an ObjCImplDecl at TU scope | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.