-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[LLVM][IR] Support target extension types in vectors #140630
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 5 commits
78a86cf
9951121
11cbeee
3324462
9ad6926
56639dc
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 | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -790,8 +790,12 @@ VectorType *VectorType::get(Type *ElementType, ElementCount EC) { | |||||||
| } | ||||||||
|
|
||||||||
| bool VectorType::isValidElementType(Type *ElemTy) { | ||||||||
| return ElemTy->isIntegerTy() || ElemTy->isFloatingPointTy() || | ||||||||
| ElemTy->isPointerTy() || ElemTy->getTypeID() == TypedPointerTyID; | ||||||||
| if (ElemTy->isIntegerTy() || ElemTy->isFloatingPointTy() || | ||||||||
| ElemTy->isPointerTy() || ElemTy->getTypeID() == TypedPointerTyID) | ||||||||
| return true; | ||||||||
| if (auto *TTy = dyn_cast<TargetExtType>(ElemTy)) | ||||||||
| return TTy->hasProperty(TargetExtType::CanBeVectorElement); | ||||||||
| return false; | ||||||||
| } | ||||||||
|
|
||||||||
| //===----------------------------------------------------------------------===// | ||||||||
|
|
@@ -801,8 +805,9 @@ bool VectorType::isValidElementType(Type *ElemTy) { | |||||||
| FixedVectorType *FixedVectorType::get(Type *ElementType, unsigned NumElts) { | ||||||||
| assert(NumElts > 0 && "#Elements of a VectorType must be greater than 0"); | ||||||||
| assert(isValidElementType(ElementType) && "Element type of a VectorType must " | ||||||||
| "be an integer, floating point, or " | ||||||||
| "pointer type."); | ||||||||
| "be an integer, floating point, " | ||||||||
| "pointer type, or a valid target " | ||||||||
| "extension type."); | ||||||||
|
|
||||||||
| auto EC = ElementCount::getFixed(NumElts); | ||||||||
|
|
||||||||
|
|
@@ -968,7 +973,10 @@ struct TargetTypeInfo { | |||||||
|
|
||||||||
| template <typename... ArgTys> | ||||||||
| TargetTypeInfo(Type *LayoutType, ArgTys... Properties) | ||||||||
| : LayoutType(LayoutType), Properties((0 | ... | Properties)) {} | ||||||||
| : LayoutType(LayoutType), Properties((0 | ... | Properties)) { | ||||||||
| if (this->Properties & TargetExtType::CanBeVectorElement) | ||||||||
| assert(LayoutType->isSized() && "Vector element type must be sized"); | ||||||||
|
||||||||
| if (this->Properties & TargetExtType::CanBeVectorElement) | |
| assert(LayoutType->isSized() && "Vector element type must be sized"); | |
| assert((!(this->Properties & TargetExtType::CanBeVectorElement) || LayoutType->isSized()) && "Vector element type must be sized"); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| ; RUN: not llvm-as %s -o /dev/null 2>&1 | FileCheck %s | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. -disable-output instead of -o /dev/null |
||
|
|
||
| ; CHECK: invalid vector element type | ||
|
|
||
| define void @bad() { | ||
| %v = alloca <2 x target("spirv.Image")> | ||
| ret void | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing newline error |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 | ||
| ; RUN: opt -passes=verify -S %s | FileCheck %s | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should run just llvm-as and be in test/Assembler. test/Verifier is for cases that fail |
||
|
|
||
| define <2 x target("llvm.test.vectorelement")> @vec_ops(<2 x target("llvm.test.vectorelement")> %x) { | ||
| ; CHECK-LABEL: define <2 x target("llvm.test.vectorelement")> @vec_ops( | ||
| ; CHECK-SAME: <2 x target("llvm.test.vectorelement")> [[X:%.*]]) { | ||
| ; CHECK-NEXT: [[A:%.*]] = alloca <2 x target("llvm.test.vectorelement")>{{.*}} | ||
| ; CHECK-NEXT: store <2 x target("llvm.test.vectorelement")> [[X]], ptr [[A]], {{.*}} | ||
| ; CHECK-NEXT: [[LOAD:%.*]] = load <2 x target("llvm.test.vectorelement")>, ptr [[A]], {{.*}} | ||
| ; CHECK-NEXT: [[ELT:%.*]] = extractelement <2 x target("llvm.test.vectorelement")> [[LOAD]], i64 0 | ||
| ; CHECK-NEXT: [[RES:%.*]] = insertelement <2 x target("llvm.test.vectorelement")> poison, target("llvm.test.vectorelement") [[ELT]], i64 1 | ||
| ; CHECK-NEXT: ret <2 x target("llvm.test.vectorelement")> [[RES]] | ||
| ; | ||
| %a = alloca <2 x target("llvm.test.vectorelement")> | ||
| store <2 x target("llvm.test.vectorelement")> %x, ptr %a | ||
| %load = load <2 x target("llvm.test.vectorelement")>, ptr %a | ||
| %elt = extractelement <2 x target("llvm.test.vectorelement")> %load, i64 0 | ||
| %res = insertelement <2 x target("llvm.test.vectorelement")> poison, target("llvm.test.vectorelement") %elt, i64 1 | ||
| ret <2 x target("llvm.test.vectorelement")> %res | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.