[llvm-dev] How to create vector pointer type?

Celine via llvm-dev llvm-dev at lists.llvm.org
Mon Oct 21 05:24:10 PDT 2019


Say the original type is Integer i16*,  I want to create a v16i16* type to replace it.
static Type *getVectorPtr(Type *Ty) {
    PointerType *PointerTy = dyn_cast<PointerType>(Ty);
    assert(PointerTy && "PointerType expected");

    unsigned addSpace = PointerTy->getAddressSpace();
    Type *ScalarType = PointerTy->getElementType();
    VectorType *VectorType = VectorType::get(ScalarType, 16);
    return PointerType::get(VectorType, addSpace);

There's no isVectorPtr() check, so I add

static bool isVectorPtr(Type *Ty) {
  bool a = false;
  if(Ty->isPointerTy() ){
    PointerType *PointerTy = dyn_cast<PointerType>(Ty);
    Type *vt = PointerTy->getElementType();
    a = vt->isVectorTy();
  return a;

Then meet the following error:
Assertion failed: ResultElementType == cast<PointerType>(getType()->getScalarType())->getElementType(), file D:\cygwin64\home\celine\clang-102\llvm\include\llvm/IR/Instructions.h, line 958

I wonder how to create vector pointer type correctly?

Best Regards,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20191021/23fa9134/attachment.html>

More information about the llvm-dev mailing list