static unsigned getPointerOperandIndex() { return 1U; }
unsigned getPointerAddressSpace() const {
- return cast<PointerType>(getPointerOperand()->getType())->getAddressSpace();
+ if (getPointerOperand()->getType()->isPointerTy())
+ return cast<PointerType>(getPointerOperand()->getType())
+ ->getAddressSpace();
+ if (getPointerOperand()->getType()->isVectorTy()
+ && cast<VectorType>(getPointerOperand()->getType())->isPointerTy())
+ return cast<PointerType>(cast<VectorType>(
+ getPointerOperand()->getType())->getElementType())
+ ->getAddressSpace();
+ llvm_unreachable("Only a vector of pointers or pointers can be used!");
+ return 0;
}
// Methods for support type inquiry through isa, cast, and dyn_cast:
void setIsNoInline() {
Attributes::Builder B;
B.addAttribute(Attributes::NoInline);
- addAttribute(~0, Attributes::get(getContext(), B));
+ addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
}
/// @brief Return true if the call can return twice
void setCanReturnTwice() {
Attributes::Builder B;
B.addAttribute(Attributes::ReturnsTwice);
- addAttribute(~0U, Attributes::get(getContext(), B));
+ addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
}
/// @brief Determine if the call does not access memory.
void setDoesNotAccessMemory() {
Attributes::Builder B;
B.addAttribute(Attributes::ReadNone);
- addAttribute(~0U, Attributes::get(getContext(), B));
+ addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
}
/// @brief Determine if the call does not access or only reads memory.
void setOnlyReadsMemory() {
Attributes::Builder B;
B.addAttribute(Attributes::ReadOnly);
- addAttribute(~0, Attributes::get(getContext(), B));
+ addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
}
/// @brief Determine if the call cannot return.
void setDoesNotReturn() {
Attributes::Builder B;
B.addAttribute(Attributes::NoReturn);
- addAttribute(~0, Attributes::get(getContext(), B));
+ addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
}
/// @brief Determine if the call cannot unwind.
void setDoesNotThrow() {
Attributes::Builder B;
B.addAttribute(Attributes::NoUnwind);
- addAttribute(~0, Attributes::get(getContext(), B));
+ addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
}
/// @brief Determine if the call returns a structure through first
void setIsNoInline() {
Attributes::Builder B;
B.addAttribute(Attributes::NoInline);
- addAttribute(~0, Attributes::get(getContext(), B));
+ addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
}
/// @brief Determine if the call does not access memory.
void setDoesNotAccessMemory() {
Attributes::Builder B;
B.addAttribute(Attributes::ReadNone);
- addAttribute(~0, Attributes::get(getContext(), B));
+ addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
}
/// @brief Determine if the call does not access or only reads memory.
void setOnlyReadsMemory() {
Attributes::Builder B;
B.addAttribute(Attributes::ReadOnly);
- addAttribute(~0, Attributes::get(getContext(), B));
+ addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
}
/// @brief Determine if the call cannot return.
void setDoesNotReturn() {
Attributes::Builder B;
B.addAttribute(Attributes::NoReturn);
- addAttribute(~0, Attributes::get(getContext(), B));
+ addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
}
/// @brief Determine if the call cannot unwind.
void setDoesNotThrow() {
Attributes::Builder B;
B.addAttribute(Attributes::NoUnwind);
- addAttribute(~0, Attributes::get(getContext(), B));
+ addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
}
/// @brief Determine if the call returns a structure through first
/// @brief return the address space of the pointer.
unsigned getAddressSpace() const {
- return cast<PointerType>(getType())->getAddressSpace();
+ if (getType()->isPointerTy())
+ return cast<PointerType>(getType())->getAddressSpace();
+ if (getType()->isVectorTy() &&
+ cast<VectorType>(getType())->getElementType()->isPointerTy())
+ return cast<PointerType>(
+ cast<VectorType>(getType())->getElementType())
+ ->getAddressSpace();
+ llvm_unreachable("Must be a pointer or a vector of pointers.");
+ return 0;
}
// Methods for support type inquiry through isa, cast, and dyn_cast:
/// @brief return the address space of the pointer.
unsigned getPointerAddressSpace() const {
- return cast<PointerType>(getOperand(0)->getType())->getAddressSpace();
+ Type *Ty = getOperand(0)->getType();
+ if (Ty->isPointerTy())
+ return cast<PointerType>(Ty)->getAddressSpace();
+ if (Ty->isVectorTy()
+ && cast<VectorType>(Ty)->getElementType()->isPointerTy())
+ return cast<PointerType>(
+ cast<VectorType>(Ty)->getElementType())
+ ->getAddressSpace();
+ llvm_unreachable("Must be a pointer or a vector of pointers.");
+ return 0;
}
// Methods for support type inquiry through isa, cast, and dyn_cast: