42#include <system_error>
46#define DEBUG_TYPE "ir"
68 *Major = LLVM_VERSION_MAJOR;
70 *Minor = LLVM_VERSION_MINOR;
72 *Patch = LLVM_VERSION_PATCH;
78 return strdup(Message);
101 void *DiagnosticContext) {
102 unwrap(
C)->setDiagnosticHandlerCallBack(
110 unwrap(
C)->getDiagnosticHandlerCallBack());
114 return unwrap(
C)->getDiagnosticContext();
118 void *OpaqueHandle) {
121 unwrap(
C)->setYieldCallback(YieldCallback, OpaqueHandle);
125 return unwrap(
C)->shouldDiscardValueNames();
129 unwrap(
C)->setDiscardValueNames(Discard);
150 return Attribute::AttrKind::EndAttrKinds;
166 if (Attr.isEnumAttribute())
168 return Attr.getValueAsInt();
180 return wrap(Attr.getValueAsType());
184 const char *K,
unsigned KLength,
185 const char *V,
unsigned VLength) {
206 return Attr.isEnumAttribute() || Attr.isIntAttribute();
218 std::string MsgStorage;
231 switch(
unwrap(DI)->getSeverity()) {
265 auto &Str =
unwrap(M)->getModuleIdentifier();
275 auto &Str =
unwrap(M)->getSourceFileName();
286 return unwrap(M)->getDataLayoutStr().c_str();
294 unwrap(M)->setDataLayout(DataLayoutStr);
299 return unwrap(M)->getTargetTriple().c_str();
318 return Module::ModFlagBehavior::Error;
320 return Module::ModFlagBehavior::Warning;
322 return Module::ModFlagBehavior::Require;
324 return Module::ModFlagBehavior::Override;
326 return Module::ModFlagBehavior::Append;
328 return Module::ModFlagBehavior::AppendUnique;
336 case Module::ModFlagBehavior::Error:
338 case Module::ModFlagBehavior::Warning:
340 case Module::ModFlagBehavior::Require:
342 case Module::ModFlagBehavior::Override:
344 case Module::ModFlagBehavior::Append:
346 case Module::ModFlagBehavior::AppendUnique:
355 unwrap(M)->getModuleFlagsMetadata(MFEs);
359 for (
unsigned i = 0; i < MFEs.
size(); ++i) {
360 const auto &ModuleFlag = MFEs[i];
362 Result[i].Key = ModuleFlag.Key->getString().data();
363 Result[i].KeyLen = ModuleFlag.Key->getString().size();
364 Result[i].Metadata =
wrap(ModuleFlag.Val);
383 unsigned Index,
size_t *Len) {
398 const char *Key,
size_t KeyLen) {
399 return wrap(
unwrap(M)->getModuleFlag({Key, KeyLen}));
403 const char *Key,
size_t KeyLen,
406 {Key, KeyLen},
unwrap(Val));
417 char **ErrorMessage) {
421 *ErrorMessage = strdup(EC.message().c_str());
425 unwrap(M)->print(dest,
nullptr);
430 std::string
E =
"Error printing to file: " + dest.
error().message();
431 *ErrorMessage = strdup(
E.c_str());
442 unwrap(M)->print(os,
nullptr);
445 return strdup(buf.c_str());
462 auto &Str =
unwrap(M)->getModuleInlineAsm();
468 size_t AsmStringSize,
char *Constraints,
469 size_t ConstraintsSize,
LLVMBool HasSideEffects,
484 HasSideEffects, IsAlignStack, AD, CanThrow));
549 return unwrap(Ty)->isSized();
567 os <<
"Printing <null> Type";
571 return strdup(buf.c_str());
621 return unwrap<IntegerType>(IntegerTy)->getBitWidth();
688 return wrap(FunctionType::get(
unwrap(ReturnType), Tys, IsVarArg != 0));
692 return unwrap<FunctionType>(FunctionTy)->isVarArg();
696 return wrap(unwrap<FunctionType>(FunctionTy)->getReturnType());
700 return unwrap<FunctionType>(FunctionTy)->getNumParams();
705 for (
Type *
T : Ty->params())
731 if (!
Type->hasName())
733 return Type->getName().data();
739 unwrap<StructType>(StructTy)->setBody(Tys, Packed != 0);
743 return unwrap<StructType>(StructTy)->getNumElements();
747 StructType *Ty = unwrap<StructType>(StructTy);
753 StructType *Ty = unwrap<StructType>(StructTy);
758 return unwrap<StructType>(StructTy)->isPacked();
762 return unwrap<StructType>(StructTy)->isOpaque();
766 return unwrap<StructType>(StructTy)->isLiteral();
781 for (
auto *
T :
unwrap(Tp)->subtypes()) {
800 return unwrap(Ty)->isOpaquePointerTy();
813 auto *Ty =
unwrap(WrappedTy);
814 if (
auto *ATy = dyn_cast<ArrayType>(Ty))
815 return wrap(ATy->getElementType());
816 return wrap(cast<VectorType>(Ty)->getElementType());
820 return unwrap(Tp)->getNumContainedTypes();
824 return unwrap<ArrayType>(ArrayTy)->getNumElements();
828 return unwrap<ArrayType>(ArrayTy)->getNumElements();
832 return unwrap<PointerType>(
PointerTy)->getAddressSpace();
836 return unwrap<VectorType>(VectorTy)->getElementCount().getKnownMinValue();
867 unsigned TypeParamCount,
869 unsigned IntParamCount) {
885 switch(
unwrap(Val)->getValueID()) {
887#define HANDLE_VALUE(Name) \
888 case Value::Name##Val: \
889 return LLVM##Name##ValueKind;
890#include "llvm/IR/Value.def"
898 *
Length = V->getName().size();
899 return V->getName().data();
907 return unwrap(Val)->getName().data();
925 os <<
"Printing <null> Value";
929 return strdup(buf.c_str());
937 return unwrap<Instruction>(Inst)->hasMetadata();
941 auto *
I = unwrap<Instruction>(Inst);
942 assert(
I &&
"Expected instruction");
943 if (
auto *MD =
I->getMetadata(KindID))
953 assert((isa<MDNode>(MD) || isa<ConstantAsMetadata>(MD)) &&
954 "Expected a metadata node or a canonicalized constant");
956 if (
MDNode *
N = dyn_cast<MDNode>(MD))
965 unwrap<Instruction>(Inst)->setMetadata(KindID,
N);
983 for (
unsigned i = 0; i < MVEs.
size(); ++i) {
984 const auto &ModuleFlag = MVEs[i];
985 Result[i].Kind = ModuleFlag.first;
986 Result[i].Metadata =
wrap(ModuleFlag.second);
988 *NumEntries = MVEs.
size();
994 size_t *NumEntries) {
997 unwrap<Instruction>(
Value)->getAllMetadata(Entries);
1003#define LLVM_DEFINE_VALUE_CAST(name) \
1004 LLVMValueRef LLVMIsA##name(LLVMValueRef Val) { \
1005 return wrap(static_cast<Value*>(dyn_cast_or_null<name>(unwrap(Val)))); \
1011 if (
auto *MD = dyn_cast_or_null<MetadataAsValue>(
unwrap(Val)))
1012 if (isa<MDNode>(MD->getMetadata()) ||
1013 isa<ValueAsMetadata>(MD->getMetadata()))
1019 if (
auto *MD = dyn_cast_or_null<MetadataAsValue>(
unwrap(Val)))
1020 if (isa<ValueAsMetadata>(MD->getMetadata()))
1026 if (
auto *MD = dyn_cast_or_null<MetadataAsValue>(
unwrap(Val)))
1027 if (isa<MDString>(MD->getMetadata()))
1036 if (
I == V->use_end())
1063 if (
auto *
C = dyn_cast<ConstantAsMetadata>(Op))
1064 return wrap(
C->getValue());
1070 if (
auto *MD = dyn_cast<MetadataAsValue>(V)) {
1071 if (
auto *L = dyn_cast<ValueAsMetadata>(MD->getMetadata())) {
1072 assert(
Index == 0 &&
"Function-local metadata can only have one operand");
1073 return wrap(L->getValue());
1076 cast<MDNode>(MD->getMetadata()),
Index);
1079 return wrap(cast<User>(V)->getOperand(
Index));
1084 return wrap(&cast<User>(V)->getOperandUse(
Index));
1093 if (isa<MetadataAsValue>(V))
1096 return cast<User>(V)->getNumOperands();
1118 return isa<Constant>(
unwrap(Ty));
1123 return C->isNullValue();
1128 return isa<UndefValue>(
unwrap(Val));
1132 return isa<PoisonValue>(
unwrap(Val));
1166 for (
auto *OV :
ArrayRef(Vals, Count)) {
1171 else if (
auto *
C = dyn_cast<Constant>(V))
1173 else if (
auto *MDV = dyn_cast<MetadataAsValue>(V)) {
1174 MD = MDV->getMetadata();
1175 assert(!isa<LocalAsMetadata>(MD) &&
"Unexpected function-local metadata "
1176 "outside of direct argument to call");
1180 "Expected only one operand to function-local metadata");
1199 if (
auto *
C = dyn_cast<Constant>(V))
1201 if (
auto *MAV = dyn_cast<MetadataAsValue>(V))
1202 return wrap(MAV->getMetadata());
1207 if (
const auto *MD = dyn_cast<MetadataAsValue>(
unwrap(V)))
1208 if (
const MDString *S = dyn_cast<MDString>(MD->getMetadata())) {
1209 *
Length = S->getString().size();
1210 return S->getString().data();
1217 auto *MD = unwrap<MetadataAsValue>(V);
1218 if (isa<ValueAsMetadata>(MD->getMetadata()))
1220 return cast<MDNode>(MD->getMetadata())->getNumOperands();
1256 const char *
Name,
size_t NameLen) {
1261 const char *
Name,
size_t NameLen) {
1262 return wrap(
unwrap(M)->getOrInsertNamedMetadata({
Name, NameLen}));
1272 auto *MD = unwrap<MetadataAsValue>(V);
1273 if (
auto *MDV = dyn_cast<ValueAsMetadata>(MD->getMetadata())) {
1274 *Dest =
wrap(MDV->getValue());
1277 const auto *
N = cast<MDNode>(MD->getMetadata());
1278 const unsigned numOperands =
N->getNumOperands();
1280 for (
unsigned i = 0; i < numOperands; i++)
1286 auto *MD = cast<MetadataAsValue>(
unwrap(V));
1287 auto *
N = cast<MDNode>(MD->getMetadata());
1288 N->replaceOperandWith(
Index, unwrap<Metadata>(Replacement));
1293 return N->getNumOperands();
1304 for (
unsigned i=0;i<
N->getNumOperands();i++)
1319 if (!
Length)
return nullptr;
1321 if (
const auto *
I = dyn_cast<Instruction>(
unwrap(Val))) {
1322 if (
const auto &
DL =
I->getDebugLoc()) {
1323 S =
DL->getDirectory();
1325 }
else if (
const auto *GV = dyn_cast<GlobalVariable>(
unwrap(Val))) {
1327 GV->getDebugInfo(GVEs);
1330 S = DGV->getDirectory();
1331 }
else if (
const auto *
F = dyn_cast<Function>(
unwrap(Val))) {
1333 S = DSP->getDirectory();
1335 assert(0 &&
"Expected Instruction, GlobalVariable or Function");
1343 if (!
Length)
return nullptr;
1345 if (
const auto *
I = dyn_cast<Instruction>(
unwrap(Val))) {
1346 if (
const auto &
DL =
I->getDebugLoc()) {
1347 S =
DL->getFilename();
1349 }
else if (
const auto *GV = dyn_cast<GlobalVariable>(
unwrap(Val))) {
1351 GV->getDebugInfo(GVEs);
1354 S = DGV->getFilename();
1355 }
else if (
const auto *
F = dyn_cast<Function>(
unwrap(Val))) {
1357 S = DSP->getFilename();
1359 assert(0 &&
"Expected Instruction, GlobalVariable or Function");
1368 if (
const auto *
I = dyn_cast<Instruction>(
unwrap(Val))) {
1369 if (
const auto &
DL =
I->getDebugLoc()) {
1372 }
else if (
const auto *GV = dyn_cast<GlobalVariable>(
unwrap(Val))) {
1374 GV->getDebugInfo(GVEs);
1378 }
else if (
const auto *
F = dyn_cast<Function>(
unwrap(Val))) {
1382 assert(0 &&
"Expected Instruction, GlobalVariable or Function");
1390 if (
const auto *
I = dyn_cast<Instruction>(
unwrap(Val)))
1391 if (
const auto &
DL =
I->getDebugLoc())
1392 C =
DL->getColumn();
1418 unsigned SLen, uint8_t Radix) {
1437 return unwrap<ConstantInt>(ConstantVal)->getZExtValue();
1441 return unwrap<ConstantInt>(ConstantVal)->getSExtValue();
1445 ConstantFP *cFP = unwrap<ConstantFP>(ConstantVal) ;
1456 APF.
convert(APFloat::IEEEdouble(), APFloat::rmNearestTiesToEven, &APFLosesInfo);
1457 *LosesInfo = APFLosesInfo;
1469 DontNullTerminate == 0));
1479 return wrap(unwrap<Constant>(
C)->getAggregateElement(
Idx));
1483 return wrap(unwrap<ConstantDataSequential>(
C)->getElementAsConstant(idx));
1487 return unwrap<ConstantDataSequential>(
C)->isString();
1491 StringRef Str = unwrap<ConstantDataSequential>(
C)->getAsString();
1511 Constant **Elements = unwrap<Constant>(ConstantVals, Count);
1525 Constant **Elements = unwrap<Constant>(ConstantVals, Count);
1526 StructType *Ty = unwrap<StructType>(StructTy);
1542#define HANDLE_INST(num, opc, clas) case num: return LLVM##opc;
1543#include "llvm/IR/Instruction.def"
1551#define HANDLE_INST(num, opc, clas) case LLVM##opc: return num;
1552#include "llvm/IR/Instruction.def"
1591 unwrap<Constant>(RHSConstant)));
1597 unwrap<Constant>(RHSConstant)));
1603 unwrap<Constant>(RHSConstant)));
1608 unwrap<Constant>(RHSConstant)));
1614 unwrap<Constant>(RHSConstant)));
1620 unwrap<Constant>(RHSConstant)));
1625 unwrap<Constant>(RHSConstant)));
1631 unwrap<Constant>(RHSConstant)));
1637 unwrap<Constant>(RHSConstant)));
1642 unwrap<Constant>(RHSConstant)));
1647 unwrap<Constant>(RHSConstant)));
1652 unwrap<Constant>(RHSConstant)));
1658 unwrap<Constant>(LHSConstant),
1659 unwrap<Constant>(RHSConstant)));
1665 unwrap<Constant>(LHSConstant),
1666 unwrap<Constant>(RHSConstant)));
1671 unwrap<Constant>(RHSConstant)));
1676 unwrap<Constant>(RHSConstant)));
1681 unwrap<Constant>(RHSConstant)));
1688 Constant *Val = unwrap<Constant>(ConstantVal);
1694 unsigned NumIndices) {
1697 Constant *Val = unwrap<Constant>(ConstantVal);
1805 unwrap<Constant>(IndexConstant)));
1812 unwrap<Constant>(ElementValueConstant),
1813 unwrap<Constant>(IndexConstant)));
1822 unwrap<Constant>(VectorBConstant),
1827 const char *Constraints,
1831 Constraints, HasSideEffects, IsAlignStack));
1845 return unwrap<GlobalValue>(
Global)->isDeclaration();
1849 switch (unwrap<GlobalValue>(
Global)->getLinkage()) {
1895 errs() <<
"LLVMSetLinkage(): LLVMLinkOnceODRAutoHideLinkage is no "
1896 "longer supported.");
1922 <<
"LLVMSetLinkage(): LLVMDLLImportLinkage is no longer supported.");
1927 <<
"LLVMSetLinkage(): LLVMDLLExportLinkage is no longer supported.");
1934 errs() <<
"LLVMSetLinkage(): LLVMGhostLinkage is no longer supported.");
1945 return unwrap<GlobalValue>(
Global)->getSection().data();
1949 unwrap<GlobalObject>(
Global)->setSection(Section);
1954 unwrap<GlobalValue>(
Global)->getVisibility());
1958 unwrap<GlobalValue>(
Global)
1964 unwrap<GlobalValue>(
Global)->getDLLStorageClass());
1968 unwrap<GlobalValue>(
Global)->setDLLStorageClass(
1973 switch (unwrap<GlobalValue>(
Global)->getUnnamedAddr()) {
1974 case GlobalVariable::UnnamedAddr::None:
1976 case GlobalVariable::UnnamedAddr::Local:
1978 case GlobalVariable::UnnamedAddr::Global:
1987 switch (UnnamedAddr) {
1998 return unwrap<GlobalValue>(
Global)->hasGlobalUnnamedAddr();
2002 unwrap<GlobalValue>(
Global)->setUnnamedAddr(
2003 HasUnnamedAddr ? GlobalValue::UnnamedAddr::Global
2004 : GlobalValue::UnnamedAddr::None);
2008 return wrap(unwrap<GlobalValue>(
Global)->getValueType());
2016 return GV->getAlign() ? GV->getAlign()->value() : 0;
2018 return AI->getAlign().value();
2019 if (
LoadInst *LI = dyn_cast<LoadInst>(
P))
2020 return LI->getAlign().value();
2022 return SI->getAlign().value();
2024 return RMWI->getAlign().value();
2026 return CXI->getAlign().value();
2029 "only GlobalValue, AllocaInst, LoadInst, StoreInst, AtomicRMWInst, "
2030 "and AtomicCmpXchgInst have alignment");
2037 else if (
AllocaInst *AI = dyn_cast<AllocaInst>(
P))
2038 AI->setAlignment(
Align(Bytes));
2039 else if (
LoadInst *LI = dyn_cast<LoadInst>(
P))
2040 LI->setAlignment(
Align(Bytes));
2042 SI->setAlignment(
Align(Bytes));
2044 RMWI->setAlignment(
Align(Bytes));
2046 CXI->setAlignment(
Align(Bytes));
2049 "only GlobalValue, AllocaInst, LoadInst, StoreInst, AtomicRMWInst, and "
2050 "and AtomicCmpXchgInst have alignment");
2054 size_t *NumEntries) {
2058 Instr->getAllMetadata(Entries);
2060 unwrap<GlobalObject>(
Value)->getAllMetadata(Entries);
2086 unwrap<GlobalObject>(
Global)->setMetadata(Kind, unwrap<MDNode>(MD));
2090 unwrap<GlobalObject>(
Global)->eraseMetadata(Kind);
2094 unwrap<GlobalObject>(
Global)->clearMetadata();
2109 nullptr, GlobalVariable::NotThreadLocal,
2150 unwrap<GlobalVariable>(GlobalVar)->eraseFromParent();
2161 unwrap<GlobalVariable>(GlobalVar)
2162 ->setInitializer(unwrap<Constant>(ConstantVal));
2166 return unwrap<GlobalVariable>(GlobalVar)->isThreadLocal();
2170 unwrap<GlobalVariable>(GlobalVar)->setThreadLocal(IsThreadLocal != 0);
2174 return unwrap<GlobalVariable>(GlobalVar)->isConstant();
2178 unwrap<GlobalVariable>(GlobalVar)->setConstant(IsConstant != 0);
2182 switch (unwrap<GlobalVariable>(GlobalVar)->getThreadLocalMode()) {
2183 case GlobalVariable::NotThreadLocal:
2185 case GlobalVariable::GeneralDynamicTLSModel:
2187 case GlobalVariable::LocalDynamicTLSModel:
2189 case GlobalVariable::InitialExecTLSModel:
2191 case GlobalVariable::LocalExecTLSModel:
2221 return unwrap<GlobalVariable>(GlobalVar)->isExternallyInitialized();
2225 unwrap<GlobalVariable>(GlobalVar)->setExternallyInitialized(IsExtInit);
2235 unwrap<Constant>(Aliasee),
unwrap(M)));
2239 const char *
Name,
size_t NameLen) {
2276 return wrap(unwrap<GlobalAlias>(Alias)->getAliasee());
2280 unwrap<GlobalAlias>(Alias)->setAliasee(unwrap<Constant>(Aliasee));
2312 Function *Func = unwrap<Function>(Fn);
2314 if (++
I == Func->getParent()->end())
2320 Function *Func = unwrap<Function>(Fn);
2322 if (
I == Func->getParent()->begin())
2328 unwrap<Function>(Fn)->eraseFromParent();
2332 return unwrap<Function>(Fn)->hasPersonalityFn();
2336 return wrap(unwrap<Function>(Fn)->getPersonalityFn());
2340 unwrap<Function>(Fn)->setPersonalityFn(unwrap<Constant>(PersonalityFn));
2345 return F->getIntrinsicID();
2350 assert(
ID < llvm::Intrinsic::num_intrinsics &&
"Intrinsic ID out of range");
2357 size_t ParamCount) {
2366 *NameLength = Str.size();
2380 size_t *NameLength) {
2384 *NameLength = Str.length();
2385 return strdup(Str.c_str());
2391 size_t *NameLength) {
2395 *NameLength = Str.length();
2396 return strdup(Str.c_str());
2409 return unwrap<Function>(Fn)->getCallingConv();
2413 return unwrap<Function>(Fn)->setCallingConv(
2419 return F->hasGC()?
F->getGC().c_str() :
nullptr;
2432 unwrap<Function>(
F)->addAttributeAtIndex(
Idx,
unwrap(
A));
2436 auto AS = unwrap<Function>(
F)->getAttributes().getAttributes(
Idx);
2437 return AS.getNumAttributes();
2442 auto AS = unwrap<Function>(
F)->getAttributes().getAttributes(
Idx);
2450 return wrap(unwrap<Function>(
F)->getAttributeAtIndex(
2456 const char *K,
unsigned KLen) {
2458 unwrap<Function>(
F)->getAttributeAtIndex(
Idx,
StringRef(K, KLen)));
2467 const char *K,
unsigned KLen) {
2468 unwrap<Function>(
F)->removeAttributeAtIndex(
Idx,
StringRef(K, KLen));
2473 Function *Func = unwrap<Function>(Fn);
2475 Func->addFnAttr(Attr);
2483 return unwrap<Function>(FnRef)->arg_size();
2487 Function *Fn = unwrap<Function>(FnRef);
2489 *ParamRefs++ =
wrap(&
A);
2493 Function *Fn = unwrap<Function>(FnRef);
2502 Function *Func = unwrap<Function>(Fn);
2504 if (
I == Func->arg_end())
2510 Function *Func = unwrap<Function>(Fn);
2512 if (
I == Func->arg_begin())
2520 if (
A->getArgNo() + 1 >= Fn->
arg_size())
2527 if (
A->getArgNo() == 0)
2529 return wrap(&
A->getParent()->arg_begin()[
A->getArgNo() - 1]);
2540 const char *
Name,
size_t NameLen,
2550 const char *
Name,
size_t NameLen) {
2587 return wrap(unwrap<GlobalIFunc>(IFunc)->getResolver());
2591 unwrap<GlobalIFunc>(IFunc)->setResolver(unwrap<Constant>(
Resolver));
2595 unwrap<GlobalIFunc>(IFunc)->eraseFromParent();
2599 unwrap<GlobalIFunc>(IFunc)->removeFromParent();
2609 return isa<BasicBlock>(
unwrap(Val));
2613 return wrap(unwrap<BasicBlock>(Val));
2617 return unwrap(BB)->getName().data();
2629 return unwrap<Function>(FnRef)->size();
2633 Function *Fn = unwrap<Function>(FnRef);
2635 *BasicBlocksRefs++ =
wrap(&BB);
2639 return wrap(&unwrap<Function>(Fn)->getEntryBlock());
2643 Function *Func = unwrap<Function>(Fn);
2645 if (
I == Func->end())
2651 Function *Func = unwrap<Function>(Fn);
2653 if (
I == Func->begin())
2661 if (++
I == Block->getParent()->end())
2669 if (
I == Block->getParent()->begin())
2683 assert(CurBB &&
"current insertion point is invalid!");
2689 unwrap<Function>(Fn)->insert(unwrap<Function>(Fn)->end(),
unwrap(BB));
2715 unwrap(BBRef)->eraseFromParent();
2719 unwrap(BBRef)->removeFromParent();
2739 if (
I == Block->end())
2747 if (
I == Block->begin())
2769 unwrap<Instruction>(Inst)->removeFromParent();
2773 unwrap<Instruction>(Inst)->eraseFromParent();
2777 unwrap<Instruction>(Inst)->deleteValue();
2784 if (CE->getOpcode() == Instruction::ICmp)
2793 if (CE->getOpcode() == Instruction::FCmp)
2806 return wrap(
C->clone());
2812 return (
I &&
I->isTerminator()) ?
wrap(
I) :
nullptr;
2817 return FPI->arg_size();
2819 return unwrap<CallBase>(Instr)->arg_size();
2825 return unwrap<CallBase>(Instr)->getCallingConv();
2829 return unwrap<CallBase>(Instr)->setCallingConv(
2835 auto *Call = unwrap<CallBase>(Instr);
2838 Call->addAttributeAtIndex(
Idx, AlignAttr);
2843 unwrap<CallBase>(
C)->addAttributeAtIndex(
Idx,
unwrap(
A));
2848 auto *Call = unwrap<CallBase>(
C);
2849 auto AS = Call->getAttributes().getAttributes(
Idx);
2850 return AS.getNumAttributes();
2855 auto *Call = unwrap<CallBase>(
C);
2856 auto AS = Call->getAttributes().getAttributes(
Idx);
2864 return wrap(unwrap<CallBase>(
C)->getAttributeAtIndex(
2870 const char *K,
unsigned KLen) {
2872 unwrap<CallBase>(
C)->getAttributeAtIndex(
Idx,
StringRef(K, KLen)));
2881 const char *K,
unsigned KLen) {
2882 unwrap<CallBase>(
C)->removeAttributeAtIndex(
Idx,
StringRef(K, KLen));
2886 return wrap(unwrap<CallBase>(Instr)->getCalledOperand());
2890 return wrap(unwrap<CallBase>(Instr)->getFunctionType());
2896 return unwrap<CallInst>(Call)->isTailCall();
2900 unwrap<CallInst>(Call)->setTailCall(isTailCall);
2906 return wrap(unwrap<InvokeInst>(Invoke)->getNormalDest());
2911 return wrap(CRI->getUnwindDest());
2913 return wrap(CSI->getUnwindDest());
2915 return wrap(unwrap<InvokeInst>(Invoke)->getUnwindDest());
2919 unwrap<InvokeInst>(Invoke)->setNormalDest(
unwrap(
B));
2924 return CRI->setUnwindDest(
unwrap(
B));
2926 return CSI->setUnwindDest(
unwrap(
B));
2928 unwrap<InvokeInst>(Invoke)->setUnwindDest(
unwrap(
B));
2934 return unwrap<Instruction>(Term)->getNumSuccessors();
2938 return wrap(unwrap<Instruction>(Term)->getSuccessor(i));
2942 return unwrap<Instruction>(Term)->setSuccessor(i,
unwrap(
block));
2948 return unwrap<BranchInst>(Branch)->isConditional();
2952 return wrap(unwrap<BranchInst>(Branch)->getCondition());
2956 return unwrap<BranchInst>(Branch)->setCondition(
unwrap(
Cond));
2962 return wrap(unwrap<SwitchInst>(Switch)->getDefaultDest());
2968 return wrap(unwrap<AllocaInst>(Alloca)->getAllocatedType());
2974 return unwrap<GEPOperator>(
GEP)->isInBounds();
2978 return unwrap<GetElementPtrInst>(
GEP)->setIsInBounds(InBounds);
2982 return wrap(unwrap<GEPOperator>(
GEP)->getSourceElementType());
2989 PHINode *PhiVal = unwrap<PHINode>(PhiNode);
2990 for (
unsigned I = 0;
I != Count; ++
I)
2995 return unwrap<PHINode>(PhiNode)->getNumIncomingValues();
2999 return wrap(unwrap<PHINode>(PhiNode)->getIncomingValue(
Index));
3003 return wrap(unwrap<PHINode>(PhiNode)->getIncomingBlock(
Index));
3010 if (
auto *
GEP = dyn_cast<GEPOperator>(
I))
3011 return GEP->getNumIndices();
3012 if (
auto *EV = dyn_cast<ExtractValueInst>(
I))
3013 return EV->getNumIndices();
3014 if (
auto *
IV = dyn_cast<InsertValueInst>(
I))
3015 return IV->getNumIndices();
3017 "LLVMGetNumIndices applies only to extractvalue and insertvalue!");
3022 if (
auto *EV = dyn_cast<ExtractValueInst>(
I))
3023 return EV->getIndices().data();
3024 if (
auto *
IV = dyn_cast<InsertValueInst>(
I))
3025 return IV->getIndices().data();
3027 "LLVMGetIndices applies only to extractvalue and insertvalue!");
3044 auto I = Instr ? unwrap<Instruction>(Instr)->getIterator() : BB->
end();
3094 L ? cast<MDNode>(unwrap<MetadataAsValue>(L)->getMetadata()) :
nullptr;
3105 unwrap(
Builder)->SetInstDebugLocation(unwrap<Instruction>(Inst));
3109 unwrap(
Builder)->AddMetadataToInst(unwrap<Instruction>(Inst));
3116 ? unwrap<MDNode>(FPMathTag)
3154 unsigned NumDests) {
3174 unwrap(
B)->GetInsertBlock()->getParent()->setPersonalityFn(
3175 unwrap<Function>(PersFn));
3189 if (ParentPad ==
nullptr) {
3203 unsigned NumHandlers,
const char *
Name) {
3204 if (ParentPad ==
nullptr) {
3209 NumHandlers,
Name));
3214 return wrap(
unwrap(
B)->CreateCatchRet(unwrap<CatchPadInst>(CatchPad),
3220 return wrap(
unwrap(
B)->CreateCleanupRet(unwrap<CleanupPadInst>(CatchPad),
3230 unwrap<SwitchInst>(Switch)->addCase(unwrap<ConstantInt>(OnVal),
unwrap(Dest));
3234 unwrap<IndirectBrInst>(IndirectBr)->addDestination(
unwrap(Dest));
3238 return unwrap<LandingPadInst>(LandingPad)->getNumClauses();
3242 return wrap(unwrap<LandingPadInst>(LandingPad)->getClause(
Idx));
3246 unwrap<LandingPadInst>(LandingPad)->addClause(unwrap<Constant>(
ClauseVal));
3250 return unwrap<LandingPadInst>(LandingPad)->isCleanup();
3254 unwrap<LandingPadInst>(LandingPad)->setCleanup(Val);
3258 unwrap<CatchSwitchInst>(CatchSwitch)->addHandler(
unwrap(Dest));
3262 return unwrap<CatchSwitchInst>(CatchSwitch)->getNumHandlers();
3268 *Handlers++ =
wrap(
H);
3272 return wrap(unwrap<CatchPadInst>(CatchPad)->getCatchSwitch());
3276 unwrap<CatchPadInst>(CatchPad)
3277 ->setCatchSwitch(unwrap<CatchSwitchInst>(CatchSwitch));
3283 return wrap(unwrap<FuncletPadInst>(Funclet)->getArgOperand(i));
3287 unwrap<FuncletPadInst>(Funclet)->setArgOperand(i,
unwrap(
value));
3459 ITy,
unwrap(Ty), AllocSize,
3460 nullptr,
nullptr,
"");
3470 ITy,
unwrap(Ty), AllocSize,
3471 unwrap(Val),
nullptr,
"");
3533 return AtomicOrdering::AcquireRelease;
3535 return AtomicOrdering::SequentiallyConsistent;
3548 case AtomicOrdering::AcquireRelease:
3550 case AtomicOrdering::SequentiallyConsistent:
3615 unsigned NumIndices,
const char *
Name) {
3622 unsigned NumIndices,
const char *
Name) {
3647 if (
LoadInst *LI = dyn_cast<LoadInst>(
P))
3648 return LI->isVolatile();
3650 return SI->isVolatile();
3652 return AI->isVolatile();
3653 return cast<AtomicCmpXchgInst>(
P)->isVolatile();
3658 if (
LoadInst *LI = dyn_cast<LoadInst>(
P))
3659 return LI->setVolatile(isVolatile);
3661 return SI->setVolatile(isVolatile);
3663 return AI->setVolatile(isVolatile);
3664 return cast<AtomicCmpXchgInst>(
P)->setVolatile(isVolatile);
3668 return unwrap<AtomicCmpXchgInst>(CmpXchgInst)->isWeak();
3672 return unwrap<AtomicCmpXchgInst>(CmpXchgInst)->setWeak(isWeak);
3678 if (
LoadInst *LI = dyn_cast<LoadInst>(
P))
3679 O = LI->getOrdering();
3681 O =
SI->getOrdering();
3683 O = cast<AtomicRMWInst>(
P)->