Skip to content
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

[lldb] Make GetClangTypeNode aware of SIMD types. #3322

Open
wants to merge 1 commit into
base: stable/20210726
Choose a base branch
from

Conversation

augusto2112
Copy link

The compiler has some special handling for SIMD types, implement the
same rules on TypeSystemSwiftTypeRef on GetClangTypeNode.

The compiler has some special handling for SIMD types, implement the
same rules on TypeSystemSwiftTypeRef on GetClangTypeNode.
@augusto2112 augusto2112 force-pushed the special_rule_simd_on_clang_node branch from 479e65a to ddcaae6 Compare October 1, 2021 18:31
Copy link
Member

@adrian-prantl adrian-prantl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!


// Check if this is a SIMD type. For a vector this is something like
// type __attribute__((ext_vector_type(dimension))).
if (!clang_name.contains("__attribute__((ext_vector_type"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it would be cleaner to use ClangUtil::GetQualType(clang_type)->hasAttr()?

// kind=Structure
// kind=Module, text="Swift"
// kind=Identifier, text="Type"
NodePointer element_type_node =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe factor out a static DemangleNode* GetBoundGenericStruct(Name, TypeParam)?

NodePointer type_list = dem.createNode(Node::Kind::TypeList);
type_list->addChild(element_type_node, dem);
NodePointer identifier =
dem.createNode(Node::Kind::Identifier, "SIMD" + std::to_string(size));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a micro-optimization that will not matter, but we could do this with fewer memory allocations by using

SmallString<6> name;
llvm::raw_string_ostream(name)<<"SIMD"<<size;

// Check if this is a SIMD type. SIMD structs are matrixes, and they're
// in the format simd_typeNxN.
// Regex: start with simd_ and end with NxN.
std::regex simd_matrix_recognizer("^simd_.*[0-9]+x[0-9]+");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC, there was some supported platform that didn't have a regex implementation. Maybe grep for regex in the lldb sources. If there is no comment about it there then this is probably no longer an issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants