Now that Intrinsic::ID is a typed enum, we can forward declare it and so return it from this method.
This updates all users which were either using an unsigned to store it, or had a now unnecessary cast.
llvm-svn: 237810
// function.
NumArgs = F->arg_size();
- if (Intrinsic::ID IID = (Intrinsic::ID)F->getIntrinsicID()) {
+ if (Intrinsic::ID IID = F->getIntrinsicID()) {
FunctionType *FTy = F->getFunctionType();
SmallVector<Type *, 8> ParamTys(FTy->param_begin(), FTy->param_end());
return static_cast<T *>(this)
/// zero to allow easy checking for whether a function is intrinsic or not.
/// The particular intrinsic functions which correspond to this value are
/// defined in llvm/Intrinsics.h.
- unsigned getIntrinsicID() const LLVM_READONLY { return IntID; }
+ Intrinsic::ID getIntrinsicID() const LLVM_READONLY { return IntID; }
bool isIntrinsic() const { return getName().startswith("llvm."); }
/// \brief Recalculate the ID for this function if it is an Intrinsic defined
private:
/// \brief Create a call to a masked intrinsic with given Id.
/// Masked intrinsic has only one overloaded type - data type.
- CallInst *CreateMaskedIntrinsic(unsigned Id, ArrayRef<Value *> Ops,
+ CallInst *CreateMaskedIntrinsic(Intrinsic::ID Id, ArrayRef<Value *> Ops,
Type *DataTy, const Twine &Name = "");
Value *getCastedInt8PtrValue(Value *Ptr);
// Special helper function to delegate to CallInst subclass visitors.
RetTy delegateCallInst(CallInst &I) {
if (const Function *F = I.getCalledFunction()) {
- switch ((Intrinsic::ID)F->getIntrinsicID()) {
+ switch (F->getIntrinsicID()) {
default: DELEGATE(IntrinsicInst);
case Intrinsic::dbg_declare: DELEGATE(DbgDeclareInst);
case Intrinsic::dbg_value: DELEGATE(DbgValueInst);
/// getIntrinsicID - Return the intrinsic ID of this intrinsic.
///
Intrinsic::ID getIntrinsicID() const {
- return (Intrinsic::ID)getCalledFunction()->getIntrinsicID();
+ return getCalledFunction()->getIntrinsicID();
}
// Methods for support type inquiry through isa, cast, and dyn_cast:
return DoesNotAccessMemory;
// For intrinsics, we can check the table.
- if (unsigned iid = F->getIntrinsicID()) {
+ if (Intrinsic::ID iid = F->getIntrinsicID()) {
#define GET_INTRINSIC_MODREF_BEHAVIOR
#include "llvm/IR/Intrinsics.gen"
#undef GET_INTRINSIC_MODREF_BEHAVIOR
if (!F)
return nullptr;
- if (unsigned IID = F->getIntrinsicID())
+ if (Intrinsic::ID IID = F->getIntrinsicID())
if (Value *Ret =
- SimplifyIntrinsic((Intrinsic::ID) IID, ArgBegin, ArgEnd, Q, MaxRecurse))
+ SimplifyIntrinsic(IID, ArgBegin, ArgEnd, Q, MaxRecurse))
return Ret;
if (!canConstantFoldCallTo(F))
// llvm.gcroot is safe because it doesn't do anything at runtime.
if (CallInst *CI = dyn_cast<CallInst>(I))
if (Function *F = CI->getCalledFunction())
- if (unsigned IID = F->getIntrinsicID())
+ if (Intrinsic::ID IID = F->getIntrinsicID())
if (IID == Intrinsic::gcroot)
return false;
return;
}
}
- if (unsigned IID = F->getIntrinsicID()) {
+ if (Intrinsic::ID IID = F->getIntrinsicID()) {
RenameFn = visitIntrinsicCall(I, IID);
if (!RenameFn)
return;
// Upgrade intrinsic attributes. This does not change the function.
if (NewFn)
F = NewFn;
- if (unsigned id = F->getIntrinsicID())
- F->setAttributes(Intrinsic::getAttributes(F->getContext(),
- (Intrinsic::ID)id));
+ if (Intrinsic::ID id = F->getIntrinsicID())
+ F->setAttributes(Intrinsic::getAttributes(F->getContext(), id));
return Upgraded;
}
/// Create a call to a Masked intrinsic, with given intrinsic Id,
/// an array of operands - Ops, and one overloaded type - DataTy
-CallInst *IRBuilderBase::CreateMaskedIntrinsic(unsigned Id,
+CallInst *IRBuilderBase::CreateMaskedIntrinsic(Intrinsic::ID Id,
ArrayRef<Value *> Ops,
Type *DataTy,
const Twine &Name) {
Module *M = BB->getParent()->getParent();
Type *OverloadedTypes[] = { DataTy };
- Value *TheFn = Intrinsic::getDeclaration(M, (Intrinsic::ID)Id, OverloadedTypes);
+ Value *TheFn = Intrinsic::getDeclaration(M, Id, OverloadedTypes);
return createCallHelper(TheFn, Ops, this, Name);
}
verifyMustTailCall(CI);
if (Function *F = CI.getCalledFunction())
- if (Intrinsic::ID ID = (Intrinsic::ID)F->getIntrinsicID())
+ if (Intrinsic::ID ID = F->getIntrinsicID())
visitIntrinsicFunctionCall(ID, CI);
}
std::swap(LHS, RHS);
// Simplify multiplies.
- unsigned IID = II->getIntrinsicID();
+ Intrinsic::ID IID = II->getIntrinsicID();
switch (IID) {
default:
break;
std::swap(LHS, RHS);
// Simplify multiplies.
- unsigned IID = II->getIntrinsicID();
+ Intrinsic::ID IID = II->getIntrinsicID();
switch (IID) {
default:
break;
ARCInstKind Class = GetFunctionClass(F);
if (Class != ARCInstKind::CallOrUser)
return Class;
- unsigned ID = F->getIntrinsicID();
+ Intrinsic::ID ID = F->getIntrinsicID();
if (isInertIntrinsic(ID))
return ARCInstKind::None;
if (isUseOnlyIntrinsic(ID))
// floor((double)floatval) -> (double)floorf(floatval)
if (Callee->isIntrinsic()) {
Module *M = CI->getParent()->getParent()->getParent();
- Intrinsic::ID IID = (Intrinsic::ID) Callee->getIntrinsicID();
+ Intrinsic::ID IID = Callee->getIntrinsicID();
Function *F = Intrinsic::getDeclaration(M, IID, B.getFloatTy());
V = B.CreateCall(F, V);
} else {
Function *F = I->getCalledFunction();
if (!F) return false;
- Intrinsic::ID IID = (Intrinsic::ID) F->getIntrinsicID();
+ Intrinsic::ID IID = F->getIntrinsicID();
if (!IID) return false;
switch(IID) {
CallInst *CI = dyn_cast<CallInst>(I);
Function *FI;
if (CI && (FI = CI->getCalledFunction())) {
- Intrinsic::ID IID = (Intrinsic::ID) FI->getIntrinsicID();
+ Intrinsic::ID IID = FI->getIntrinsicID();
if (IID == Intrinsic::powi || IID == Intrinsic::ctlz ||
IID == Intrinsic::cttz) {
Value *A1I = CI->getArgOperand(1),
continue;
} else if (isa<CallInst>(I)) {
Function *F = cast<CallInst>(I)->getCalledFunction();
- Intrinsic::ID IID = (Intrinsic::ID) F->getIntrinsicID();
+ Intrinsic::ID IID = F->getIntrinsicID();
if (o == NumOperands-1) {
BasicBlock &BB = *I->getParent();
Intrinsic::ID IID = Intrinsic::not_intrinsic;
Value *ScalarArg = nullptr;
if (CI && (FI = CI->getCalledFunction())) {
- IID = (Intrinsic::ID) FI->getIntrinsicID();
+ IID = FI->getIntrinsicID();
}
std::vector<Value *> OpVecs;
for (int j = 0, e = CI->getNumArgOperands(); j < e; ++j) {