Skip to content

Commit 78a86cf

Browse files
author
Aryan Sefidi
committed
Support target extension types in vectors
1 parent 30c9909 commit 78a86cf

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

llvm/lib/IR/Type.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,8 @@ VectorType *VectorType::get(Type *ElementType, ElementCount EC) {
791791

792792
bool VectorType::isValidElementType(Type *ElemTy) {
793793
return ElemTy->isIntegerTy() || ElemTy->isFloatingPointTy() ||
794-
ElemTy->isPointerTy() || ElemTy->getTypeID() == TypedPointerTyID;
794+
ElemTy->isPointerTy() || ElemTy->getTypeID() == TypedPointerTyID ||
795+
(ElemTy->isTargetExtTy() && ElemTy->isSized());
795796
}
796797

797798
//===----------------------------------------------------------------------===//
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
; RUN: not llvm-as %s -o /dev/null 2>&1 | FileCheck %s
2+
3+
; CHECK: invalid vector element type
4+
5+
define void @bad() {
6+
%v = alloca <2 x target("spirv.IntegralConstant")>
7+
ret void
8+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
; RUN: llvm-as -o - %s | llvm-dis | FileCheck %s
2+
3+
; CHECK-LABEL: @vec_ops(
4+
define <2 x target("spirv.Image")> @vec_ops(<2 x target("spirv.Image")> %x) {
5+
%a = alloca <2 x target("spirv.Image")>
6+
store <2 x target("spirv.Image")> %x, ptr %a
7+
%load = load <2 x target("spirv.Image")>, ptr %a
8+
%elt = extractelement <2 x target("spirv.Image")> %load, i64 0
9+
%res = insertelement <2 x target("spirv.Image")> undef, target("spirv.Image") %elt, i64 1
10+
ret <2 x target("spirv.Image")> %res
11+
}

0 commit comments

Comments
 (0)