1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
|
/*========================== begin_copyright_notice ============================
Copyright (C) 2018-2021 Intel Corporation
SPDX-License-Identifier: MIT
============================= end_copyright_notice ===========================*/
#ifndef IGCLLVM_IR_INSTRUCTIONS_H
#define IGCLLVM_IR_INSTRUCTIONS_H
#include "llvm/Config/llvm-config.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/User.h"
#if LLVM_VERSION_MAJOR <= 7
#include "llvm/Support/Casting.h"
#endif
#include "Probe/Assertion.h"
namespace IGCLLVM
{
inline llvm::Value* getCalledValue(llvm::CallInst& CI)
{
#if LLVM_VERSION_MAJOR <= 10
return CI.getCalledValue();
#else
return CI.getCalledOperand();
#endif
}
inline llvm::Value* getCalledValue(llvm::CallInst* CI)
{
#if LLVM_VERSION_MAJOR <= 10
return CI->getCalledValue();
#else
return CI->getCalledOperand();
#endif
}
inline const llvm::Value* getCalledValue(const llvm::CallInst* CI)
{
#if LLVM_VERSION_MAJOR <= 10
return CI->getCalledValue();
#else
return CI->getCalledOperand();
#endif
}
inline bool isIndirectCall(const llvm::CallInst& CI)
{
#if LLVM_VERSION_MAJOR == 7
const llvm::Value *V = CI.getCalledValue();
if (llvm::isa<llvm::Function>(V) || llvm::isa<llvm::Constant>(V))
return false;
if (CI.isInlineAsm())
return false;
return true;
#else
return CI.isIndirectCall();
#endif
}
inline unsigned arg_size(const llvm::CallInst& CI)
{
#if LLVM_VERSION_MAJOR < 8
return (unsigned)(CI.arg_end() - CI.arg_begin());
#else
return (unsigned)CI.arg_size();
#endif
}
inline llvm::iterator_range<llvm::User::op_iterator> args(llvm::CallInst& CI)
{
#if LLVM_VERSION_MAJOR < 8
return CI.arg_operands();
#else
return CI.args();
#endif
}
inline llvm::iterator_range<llvm::User::op_iterator> args(llvm::CallInst* CI)
{
#if LLVM_VERSION_MAJOR < 8
return CI->arg_operands();
#else
return CI->args();
#endif
}
inline unsigned getNumArgOperands(const llvm::CallInst* CI)
{
#if LLVM_VERSION_MAJOR < 14
return CI->getNumArgOperands();
#else
return CI->arg_size();
#endif
}
inline unsigned getArgOperandNo(llvm::CallInst &CI, const llvm::Use *U) {
#if LLVM_VERSION_MAJOR < 10
IGC_ASSERT_MESSAGE(CI.isArgOperand(U), "Arg operand # out of range!");
return (unsigned)(U - CI.arg_begin());
#else
return CI.getArgOperandNo(U);
#endif
}
inline llvm::Constant* getShuffleMaskForBitcode(llvm::ShuffleVectorInst* SVI)
{
#if LLVM_VERSION_MAJOR < 11
return SVI->getMask();
#else
return SVI->getShuffleMaskForBitcode();
#endif
}
}
#endif
|