LLVM 24.0.0git
Core.cpp
Go to the documentation of this file.
1//===-- Core.cpp ----------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file implements the common infrastructure (including the C bindings)
10// for libLLVMCore.a, which implements the LLVM intermediate representation.
11//
12//===----------------------------------------------------------------------===//
13
14#include "llvm-c/Core.h"
15#include "llvm-c/Types.h"
16#include "llvm/IR/Attributes.h"
17#include "llvm/IR/BasicBlock.h"
19#include "llvm/IR/Constants.h"
25#include "llvm/IR/GlobalAlias.h"
27#include "llvm/IR/IRBuilder.h"
28#include "llvm/IR/InlineAsm.h"
31#include "llvm/IR/LLVMContext.h"
33#include "llvm/IR/Module.h"
35#include "llvm/PassRegistry.h"
37#include "llvm/Support/Debug.h"
46#include <cassert>
47#include <cstdlib>
48#include <cstring>
49#include <system_error>
50
51using namespace llvm;
52
54
56 return reinterpret_cast<BasicBlock **>(BBs);
57}
58
59#define DEBUG_TYPE "ir"
60
68
71}
72
73/*===-- Version query -----------------------------------------------------===*/
74
75void LLVMGetVersion(unsigned *Major, unsigned *Minor, unsigned *Patch) {
76 if (Major)
77 *Major = LLVM_VERSION_MAJOR;
78 if (Minor)
79 *Minor = LLVM_VERSION_MINOR;
80 if (Patch)
81 *Patch = LLVM_VERSION_PATCH;
82}
83
84/*===-- Error handling ----------------------------------------------------===*/
85
86char *LLVMCreateMessage(const char *Message) {
87 return strdup(Message);
88}
89
90void LLVMDisposeMessage(char *Message) {
91 free(Message);
92}
93
94
95/*===-- Operations on contexts --------------------------------------------===*/
96
98 static LLVMContext GlobalContext;
99 [[maybe_unused]] static bool Seeded = [] {
101 return true;
102 }();
103 return GlobalContext;
104}
105
109
111 auto *C = new LLVMContext();
112 C->getLibraryOptions().assign(cl::getCAPILibraryOptions());
113 return wrap(C);
114}
115
117
119 LLVMDiagnosticHandler Handler,
120 void *DiagnosticContext) {
121 unwrap(C)->setDiagnosticHandlerCallBack(
123 Handler),
124 DiagnosticContext);
125}
126
128 return LLVM_EXTENSION reinterpret_cast<LLVMDiagnosticHandler>(
129 unwrap(C)->getDiagnosticHandlerCallBack());
130}
131
133 return unwrap(C)->getDiagnosticContext();
134}
135
137 void *OpaqueHandle) {
138 auto YieldCallback =
139 LLVM_EXTENSION reinterpret_cast<LLVMContext::YieldCallbackTy>(Callback);
140 unwrap(C)->setYieldCallback(YieldCallback, OpaqueHandle);
141}
142
144 return unwrap(C)->shouldDiscardValueNames();
145}
146
148 unwrap(C)->setDiscardValueNames(Discard);
149}
150
152 delete unwrap(C);
153}
154
155unsigned LLVMGetMDKindIDInContext(LLVMContextRef C, const char *Name,
156 unsigned SLen) {
157 return unwrap(C)->getMDKindID(StringRef(Name, SLen));
158}
159
160unsigned LLVMGetMDKindID(const char *Name, unsigned SLen) {
162}
163
164unsigned LLVMGetSyncScopeID(LLVMContextRef C, const char *Name, size_t SLen) {
165 return unwrap(C)->getOrInsertSyncScopeID(StringRef(Name, SLen));
166}
167
168unsigned LLVMGetEnumAttributeKindForName(const char *Name, size_t SLen) {
169 return Attribute::getAttrKindFromName(StringRef(Name, SLen));
170}
171
175
177 uint64_t Val) {
178 auto &Ctx = *unwrap(C);
179 auto AttrKind = (Attribute::AttrKind)KindID;
180 return wrap(Attribute::get(Ctx, AttrKind, Val));
181}
182
186
188 auto Attr = unwrap(A);
189 if (Attr.isEnumAttribute())
190 return 0;
191 return Attr.getValueAsInt();
192}
193
195 LLVMTypeRef type_ref) {
196 auto &Ctx = *unwrap(C);
197 auto AttrKind = (Attribute::AttrKind)KindID;
198 return wrap(Attribute::get(Ctx, AttrKind, unwrap(type_ref)));
199}
200
202 auto Attr = unwrap(A);
203 return wrap(Attr.getValueAsType());
204}
205
207 unsigned KindID,
208 unsigned NumBits,
209 const uint64_t LowerWords[],
210 const uint64_t UpperWords[]) {
211 auto &Ctx = *unwrap(C);
212 auto AttrKind = (Attribute::AttrKind)KindID;
213 unsigned NumWords = divideCeil(NumBits, 64);
214 return wrap(Attribute::get(
215 Ctx, AttrKind,
216 ConstantRange(APInt(NumBits, ArrayRef(LowerWords, NumWords)),
217 APInt(NumBits, ArrayRef(UpperWords, NumWords)))));
218}
219
221 LLVMContextRef C, LLVMDenormalModeKind DefaultModeOutput,
222 LLVMDenormalModeKind DefaultModeInput, LLVMDenormalModeKind FloatModeOutput,
223 LLVMDenormalModeKind FloatModeInput) {
224 auto &Ctx = *unwrap(C);
225
226 DenormalFPEnv Env(
228 static_cast<DenormalMode::DenormalModeKind>(DefaultModeOutput),
229 static_cast<DenormalMode::DenormalModeKind>(DefaultModeInput)),
231 static_cast<DenormalMode::DenormalModeKind>(FloatModeOutput),
232 static_cast<DenormalMode::DenormalModeKind>(FloatModeInput)));
233 return wrap(Attribute::get(Ctx, Attribute::DenormalFPEnv, Env.toIntValue()));
234}
235
237 const char *K, unsigned KLength,
238 const char *V, unsigned VLength) {
239 return wrap(Attribute::get(*unwrap(C), StringRef(K, KLength),
240 StringRef(V, VLength)));
241}
242
244 unsigned *Length) {
245 auto S = unwrap(A).getKindAsString();
246 *Length = S.size();
247 return S.data();
248}
249
251 unsigned *Length) {
252 auto S = unwrap(A).getValueAsString();
253 *Length = S.size();
254 return S.data();
255}
256
258 auto Attr = unwrap(A);
259 return Attr.isEnumAttribute() || Attr.isIntAttribute();
260}
261
265
269
271 std::string MsgStorage;
272 raw_string_ostream Stream(MsgStorage);
274
275 unwrap(DI)->print(DP);
276
277 return LLVMCreateMessage(MsgStorage.c_str());
278}
279
281 LLVMDiagnosticSeverity severity;
282
283 switch(unwrap(DI)->getSeverity()) {
284 default:
285 severity = LLVMDSError;
286 break;
287 case DS_Warning:
288 severity = LLVMDSWarning;
289 break;
290 case DS_Remark:
291 severity = LLVMDSRemark;
292 break;
293 case DS_Note:
294 severity = LLVMDSNote;
295 break;
296 }
297
298 return severity;
299}
300
301/*===-- Operations on modules ---------------------------------------------===*/
302
304 return wrap(new Module(ModuleID, getGlobalContext()));
305}
306
309 return wrap(new Module(ModuleID, *unwrap(C)));
310}
311
313 delete unwrap(M);
314}
315
316const char *LLVMGetModuleIdentifier(LLVMModuleRef M, size_t *Len) {
317 auto &Str = unwrap(M)->getModuleIdentifier();
318 *Len = Str.length();
319 return Str.c_str();
320}
321
322void LLVMSetModuleIdentifier(LLVMModuleRef M, const char *Ident, size_t Len) {
323 unwrap(M)->setModuleIdentifier(StringRef(Ident, Len));
324}
325
326const char *LLVMGetSourceFileName(LLVMModuleRef M, size_t *Len) {
327 auto &Str = unwrap(M)->getSourceFileName();
328 *Len = Str.length();
329 return Str.c_str();
330}
331
332void LLVMSetSourceFileName(LLVMModuleRef M, const char *Name, size_t Len) {
333 unwrap(M)->setSourceFileName(StringRef(Name, Len));
334}
335
336/*--.. Data layout .........................................................--*/
338 return unwrap(M)->getDataLayoutStr().c_str();
339}
340
342 return LLVMGetDataLayoutStr(M);
343}
344
345void LLVMSetDataLayout(LLVMModuleRef M, const char *DataLayoutStr) {
346 unwrap(M)->setDataLayout(DataLayoutStr);
347}
348
349/*--.. Target triple .......................................................--*/
351 return unwrap(M)->getTargetTriple().str().c_str();
352}
353
354void LLVMSetTarget(LLVMModuleRef M, const char *TripleStr) {
355 unwrap(M)->setTargetTriple(Triple(TripleStr));
356}
357
358/*--.. Module flags ........................................................--*/
360 LLVMModuleFlagBehavior Behavior;
361 const char *Key;
362 size_t KeyLen;
364};
365
384
404
407 unwrap(M)->getModuleFlagsMetadata(MFEs);
408
410 safe_malloc(MFEs.size() * sizeof(LLVMOpaqueModuleFlagEntry)));
411 for (unsigned i = 0; i < MFEs.size(); ++i) {
412 const auto &ModuleFlag = MFEs[i];
413 Result[i].Behavior = map_from_llvmModFlagBehavior(ModuleFlag.Behavior);
414 Result[i].Key = ModuleFlag.Key->getString().data();
415 Result[i].KeyLen = ModuleFlag.Key->getString().size();
416 Result[i].Metadata = wrap(ModuleFlag.Val);
417 }
418 *Len = MFEs.size();
419 return Result;
420}
421
423 free(Entries);
424}
425
428 unsigned Index) {
430 static_cast<LLVMOpaqueModuleFlagEntry>(Entries[Index]);
431 return MFE.Behavior;
432}
433
435 unsigned Index, size_t *Len) {
437 static_cast<LLVMOpaqueModuleFlagEntry>(Entries[Index]);
438 *Len = MFE.KeyLen;
439 return MFE.Key;
440}
441
443 unsigned Index) {
445 static_cast<LLVMOpaqueModuleFlagEntry>(Entries[Index]);
446 return MFE.Metadata;
447}
448
450 const char *Key, size_t KeyLen) {
451 return wrap(unwrap(M)->getModuleFlag({Key, KeyLen}));
452}
453
455 const char *Key, size_t KeyLen,
456 LLVMMetadataRef Val) {
457 unwrap(M)->addModuleFlag(map_to_llvmModFlagBehavior(Behavior),
458 {Key, KeyLen}, unwrap(Val));
459}
460
462
464 if (!UseNewFormat)
465 llvm_unreachable("LLVM no longer supports intrinsic based debug-info");
466 (void)M;
467}
468
469/*--.. Printing modules ....................................................--*/
470
472 unwrap(M)->print(errs(), nullptr,
473 /*ShouldPreserveUseListOrder=*/false, /*IsForDebug=*/true);
474}
475
477 char **ErrorMessage) {
478 std::error_code EC;
480 if (EC) {
481 *ErrorMessage = strdup(EC.message().c_str());
482 return true;
483 }
484
485 unwrap(M)->renumberMetadataForAssembly();
486 unwrap(M)->print(dest, nullptr);
487
488 dest.close();
489
490 if (dest.has_error()) {
491 std::string E = "Error printing to file: " + dest.error().message();
492 *ErrorMessage = strdup(E.c_str());
493 return true;
494 }
495
496 return false;
497}
498
500 std::string buf;
501 raw_string_ostream os(buf);
502
503 unwrap(M)->renumberMetadataForAssembly();
504 unwrap(M)->print(os, nullptr);
505
506 return strdup(buf.c_str());
507}
508
509/*--.. Operations on inline assembler ......................................--*/
510void LLVMSetModuleInlineAsm2(LLVMModuleRef M, const char *Asm, size_t Len) {
511 unwrap(M)->setModuleInlineAsm(StringRef(Asm, Len));
512}
513
514void LLVMSetModuleInlineAsm(LLVMModuleRef M, const char *Asm) {
515 unwrap(M)->setModuleInlineAsm(StringRef(Asm));
516}
517
518void LLVMAppendModuleInlineAsm(LLVMModuleRef M, const char *Asm, size_t Len) {
519 unwrap(M)->appendModuleInlineAsm(StringRef(Asm, Len));
520}
521
522const char *LLVMGetModuleInlineAsm(LLVMModuleRef M, size_t *Len) {
523 Module *Mod = unwrap(M);
524 ArrayRef<Module::GlobalAsmFragment> Frags = Mod->getModuleInlineAsm();
525 if (Frags.empty()) {
526 *Len = 0;
527 return nullptr;
528 }
529
530 if (Frags.size() != 1)
531 reportFatalUsageError("LLVMGetModuleInlineAsm is not supported if there is "
532 "more than one module inline assembly fragment");
533
534 auto &Str = Frags.begin()->Asm;
535 *Len = Str.length();
536 return Str.c_str();
537}
538
539LLVMValueRef LLVMGetInlineAsm(LLVMTypeRef Ty, const char *AsmString,
540 size_t AsmStringSize, const char *Constraints,
541 size_t ConstraintsSize, LLVMBool HasSideEffects,
542 LLVMBool IsAlignStack,
543 LLVMInlineAsmDialect Dialect, LLVMBool CanThrow) {
545 switch (Dialect) {
548 break;
551 break;
552 }
554 StringRef(AsmString, AsmStringSize),
555 StringRef(Constraints, ConstraintsSize),
556 HasSideEffects, IsAlignStack, AD, CanThrow));
557}
558
559const char *LLVMGetInlineAsmAsmString(LLVMValueRef InlineAsmVal, size_t *Len) {
560
561 Value *Val = unwrap<Value>(InlineAsmVal);
562 StringRef AsmString = cast<InlineAsm>(Val)->getAsmString();
563
564 *Len = AsmString.size();
565 return AsmString.data();
566}
567
569 size_t *Len) {
570 Value *Val = unwrap<Value>(InlineAsmVal);
571 StringRef ConstraintString = cast<InlineAsm>(Val)->getConstraintString();
572
573 *Len = ConstraintString.size();
574 return ConstraintString.data();
575}
576
578
579 Value *Val = unwrap<Value>(InlineAsmVal);
580 InlineAsm::AsmDialect Dialect = cast<InlineAsm>(Val)->getDialect();
581
582 switch (Dialect) {
587 }
588
589 llvm_unreachable("Unrecognized inline assembly dialect");
591}
592
594 Value *Val = unwrap<Value>(InlineAsmVal);
595 return (LLVMTypeRef)cast<InlineAsm>(Val)->getFunctionType();
596}
597
599 Value *Val = unwrap<Value>(InlineAsmVal);
600 return cast<InlineAsm>(Val)->hasSideEffects();
601}
602
604 Value *Val = unwrap<Value>(InlineAsmVal);
605 return cast<InlineAsm>(Val)->isAlignStack();
606}
607
609 Value *Val = unwrap<Value>(InlineAsmVal);
610 return cast<InlineAsm>(Val)->canThrow();
611}
612
613/*--.. Operations on module contexts ......................................--*/
617
618
619/*===-- Operations on types -----------------------------------------------===*/
620
621/*--.. Operations on all types (mostly) ....................................--*/
622
624 switch (unwrap(Ty)->getTypeID()) {
625 case Type::VoidTyID:
626 return LLVMVoidTypeKind;
627 case Type::HalfTyID:
628 return LLVMHalfTypeKind;
629 case Type::BFloatTyID:
630 return LLVMBFloatTypeKind;
631 case Type::FloatTyID:
632 return LLVMFloatTypeKind;
633 case Type::DoubleTyID:
634 return LLVMDoubleTypeKind;
637 case Type::FP128TyID:
638 return LLVMFP128TypeKind;
641 case Type::LabelTyID:
642 return LLVMLabelTypeKind;
645 case Type::ByteTyID:
646 return LLVMByteTypeKind;
648 return LLVMIntegerTypeKind;
651 case Type::StructTyID:
652 return LLVMStructTypeKind;
653 case Type::ArrayTyID:
654 return LLVMArrayTypeKind;
656 return LLVMPointerTypeKind;
658 return LLVMVectorTypeKind;
660 return LLVMX86_AMXTypeKind;
661 case Type::TokenTyID:
662 return LLVMTokenTypeKind;
668 llvm_unreachable("Typed pointers are unsupported via the C API");
669 }
670 llvm_unreachable("Unhandled TypeID.");
671}
672
674{
675 return unwrap(Ty)->isSized();
676}
677
681
683 return unwrap(Ty)->print(errs(), /*IsForDebug=*/true);
684}
685
687 std::string buf;
688 raw_string_ostream os(buf);
689
690 if (unwrap(Ty))
691 unwrap(Ty)->print(os);
692 else
693 os << "Printing <null> Type";
694
695 return strdup(buf.c_str());
696}
697
698/*--.. Operations on byte types ............................................--*/
699
701 return wrap(ByteType::get(*unwrap(C), NumBits));
702}
703
705 return unwrap<ByteType>(ByteTy)->getBitWidth();
706}
707
708/*--.. Operations on integer types .........................................--*/
709
729 return wrap(IntegerType::get(*unwrap(C), NumBits));
730}
731
750LLVMTypeRef LLVMIntType(unsigned NumBits) {
752}
753
754unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy) {
755 return unwrap<IntegerType>(IntegerTy)->getBitWidth();
756}
757
758/*--.. Operations on real types ............................................--*/
759
784
809
810/*--.. Operations on function types ........................................--*/
811
813 LLVMTypeRef *ParamTypes, unsigned ParamCount,
814 LLVMBool IsVarArg) {
815 ArrayRef<Type*> Tys(unwrap(ParamTypes), ParamCount);
816 return wrap(FunctionType::get(unwrap(ReturnType), Tys, IsVarArg != 0));
817}
818
820 return unwrap<FunctionType>(FunctionTy)->isVarArg();
821}
822
824 return wrap(unwrap<FunctionType>(FunctionTy)->getReturnType());
825}
826
827unsigned LLVMCountParamTypes(LLVMTypeRef FunctionTy) {
828 return unwrap<FunctionType>(FunctionTy)->getNumParams();
829}
830
832 FunctionType *Ty = unwrap<FunctionType>(FunctionTy);
833 for (Type *T : Ty->params())
834 *Dest++ = wrap(T);
835}
836
837/*--.. Operations on struct types ..........................................--*/
838
840 unsigned ElementCount, LLVMBool Packed) {
841 ArrayRef<Type*> Tys(unwrap(ElementTypes), ElementCount);
842 return wrap(StructType::get(*unwrap(C), Tys, Packed != 0));
843}
844
846 unsigned ElementCount, LLVMBool Packed) {
848 ElementCount, Packed);
849}
850
852{
853 return wrap(StructType::create(*unwrap(C), Name));
854}
855
857{
859 if (!Type->hasName())
860 return nullptr;
861 return Type->getName().data();
862}
863
864void LLVMStructSetBody(LLVMTypeRef StructTy, LLVMTypeRef *ElementTypes,
865 unsigned ElementCount, LLVMBool Packed) {
866 ArrayRef<Type*> Tys(unwrap(ElementTypes), ElementCount);
867 unwrap<StructType>(StructTy)->setBody(Tys, Packed != 0);
868}
869
871 return unwrap<StructType>(StructTy)->getNumElements();
872}
873
875 StructType *Ty = unwrap<StructType>(StructTy);
876 for (Type *T : Ty->elements())
877 *Dest++ = wrap(T);
878}
879
881 StructType *Ty = unwrap<StructType>(StructTy);
882 return wrap(Ty->getTypeAtIndex(i));
883}
884
886 return unwrap<StructType>(StructTy)->isPacked();
887}
888
890 return unwrap<StructType>(StructTy)->isOpaque();
891}
892
894 return unwrap<StructType>(StructTy)->isLiteral();
895}
896
898 return wrap(StructType::getTypeByName(unwrap(M)->getContext(), Name));
899}
900
902 return wrap(StructType::getTypeByName(*unwrap(C), Name));
903}
904
905/*--.. Operations on array, pointer, and vector types (sequence types) .....--*/
906
908 int i = 0;
909 for (auto *T : unwrap(Tp)->subtypes()) {
910 Arr[i] = wrap(T);
911 i++;
912 }
913}
914
916 return wrap(ArrayType::get(unwrap(ElementType), ElementCount));
917}
918
922
924 return wrap(
926}
927
929 return true;
930}
931
933 return wrap(FixedVectorType::get(unwrap(ElementType), ElementCount));
934}
935
937 unsigned ElementCount) {
938 return wrap(ScalableVectorType::get(unwrap(ElementType), ElementCount));
939}
940
942 auto *Ty = unwrap(WrappedTy);
943 if (auto *ATy = dyn_cast<ArrayType>(Ty))
944 return wrap(ATy->getElementType());
945 return wrap(cast<VectorType>(Ty)->getElementType());
946}
947
949 return unwrap(Tp)->getNumContainedTypes();
950}
951
953 return unwrap<ArrayType>(ArrayTy)->getNumElements();
954}
955
957 return unwrap<ArrayType>(ArrayTy)->getNumElements();
958}
959
961 return unwrap<PointerType>(PointerTy)->getAddressSpace();
962}
963
964unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy) {
965 return unwrap<VectorType>(VectorTy)->getElementCount().getKnownMinValue();
966}
967
971
975
977 return wrap(unwrap<ConstantPtrAuth>(PtrAuth)->getDiscriminator());
978}
979
981 return wrap(unwrap<ConstantPtrAuth>(PtrAuth)->getAddrDiscriminator());
982}
983
984/*--.. Operations on other types ...........................................--*/
985
989
1002
1009
1011 LLVMTypeRef *TypeParams,
1012 unsigned TypeParamCount,
1013 unsigned *IntParams,
1014 unsigned IntParamCount) {
1015 ArrayRef<Type *> TypeParamArray(unwrap(TypeParams), TypeParamCount);
1016 ArrayRef<unsigned> IntParamArray(IntParams, IntParamCount);
1017 return wrap(
1018 TargetExtType::get(*unwrap(C), Name, TypeParamArray, IntParamArray));
1019}
1020
1021const char *LLVMGetTargetExtTypeName(LLVMTypeRef TargetExtTy) {
1023 return Type->getName().data();
1024}
1025
1028 return Type->getNumTypeParameters();
1029}
1030
1032 unsigned Idx) {
1034 return wrap(Type->getTypeParameter(Idx));
1035}
1036
1039 return Type->getNumIntParameters();
1040}
1041
1042unsigned LLVMGetTargetExtTypeIntParam(LLVMTypeRef TargetExtTy, unsigned Idx) {
1044 return Type->getIntParameter(Idx);
1045}
1046
1047/*===-- Operations on values ----------------------------------------------===*/
1048
1049/*--.. Operations on all values ............................................--*/
1050
1052 return wrap(unwrap(Val)->getType());
1053}
1054
1056 switch(unwrap(Val)->getValueID()) {
1057#define LLVM_C_API 1
1058#define HANDLE_VALUE(Name) \
1059 case Value::Name##Val: \
1060 return LLVM##Name##ValueKind;
1061#include "llvm/IR/Value.def"
1062 default:
1064 }
1065}
1066
1067const char *LLVMGetValueName2(LLVMValueRef Val, size_t *Length) {
1068 auto *V = unwrap(Val);
1069 *Length = V->getName().size();
1070 return V->getName().data();
1071}
1072
1073void LLVMSetValueName2(LLVMValueRef Val, const char *Name, size_t NameLen) {
1074 unwrap(Val)->setName(StringRef(Name, NameLen));
1075}
1076
1078 return unwrap(Val)->getName().data();
1079}
1080
1081void LLVMSetValueName(LLVMValueRef Val, const char *Name) {
1082 unwrap(Val)->setName(Name);
1083}
1084
1086 unwrap(Val)->print(errs(), /*IsForDebug=*/true);
1087}
1088
1090 std::string buf;
1091 raw_string_ostream os(buf);
1092
1093 if (unwrap(Val))
1094 unwrap(Val)->print(os);
1095 else
1096 os << "Printing <null> Value";
1097
1098 return strdup(buf.c_str());
1099}
1100
1104
1106 std::string buf;
1107 raw_string_ostream os(buf);
1108
1109 if (unwrap(Record))
1110 unwrap(Record)->print(os);
1111 else
1112 os << "Printing <null> DbgRecord";
1113
1114 return strdup(buf.c_str());
1115}
1116
1118 unwrap(OldVal)->replaceAllUsesWith(unwrap(NewVal));
1119}
1120
1122 return unwrap<Instruction>(Inst)->hasMetadata();
1123}
1124
1126 auto *I = unwrap<Instruction>(Inst);
1127 assert(I && "Expected instruction");
1128 if (auto *MD = I->getMetadata(KindID))
1129 return wrap(MetadataAsValue::get(I->getContext(), MD));
1130 return nullptr;
1131}
1132
1133// MetadataAsValue uses a canonical format which strips the actual MDNode for
1134// MDNode with just a single constant value, storing just a ConstantAsMetadata
1135// This undoes this canonicalization, reconstructing the MDNode.
1137 Metadata *MD = MAV->getMetadata();
1139 "Expected a metadata node or a canonicalized constant");
1140
1141 if (MDNode *N = dyn_cast<MDNode>(MD))
1142 return N;
1143
1144 return MDNode::get(MAV->getContext(), MD);
1145}
1146
1147void LLVMSetMetadata(LLVMValueRef Inst, unsigned KindID, LLVMValueRef Val) {
1148 MDNode *N = Val ? extractMDNode(unwrap<MetadataAsValue>(Val)) : nullptr;
1149
1150 unwrap<Instruction>(Inst)->setMetadata(KindID, N);
1151}
1152
1157
1160llvm_getMetadata(size_t *NumEntries,
1161 llvm::function_ref<void(MetadataEntries &)> AccessMD) {
1163 AccessMD(MVEs);
1164
1166 static_cast<LLVMOpaqueValueMetadataEntry *>(
1168 for (unsigned i = 0; i < MVEs.size(); ++i) {
1169 const auto &ModuleFlag = MVEs[i];
1170 Result[i].Kind = ModuleFlag.first;
1171 Result[i].Metadata = wrap(ModuleFlag.second);
1172 }
1173 *NumEntries = MVEs.size();
1174 return Result;
1175}
1176
1179 size_t *NumEntries) {
1180 return llvm_getMetadata(NumEntries, [&Value](MetadataEntries &Entries) {
1181 Entries.clear();
1182 unwrap<Instruction>(Value)->getAllMetadata(Entries);
1183 });
1184}
1185
1186/*--.. Conversion functions ................................................--*/
1187
1188#define LLVM_DEFINE_VALUE_CAST(name) \
1189 LLVMValueRef LLVMIsA##name(LLVMValueRef Val) { \
1190 return wrap(static_cast<Value*>(dyn_cast_or_null<name>(unwrap(Val)))); \
1191 }
1192
1194
1196 if (Value *V = unwrap(Val))
1197 return isa<UncondBrInst, CondBrInst>(V) ? Val : nullptr;
1198 return nullptr;
1199}
1200
1202 if (auto *MD = dyn_cast_or_null<MetadataAsValue>(unwrap(Val)))
1203 if (isa<MDNode>(MD->getMetadata()) ||
1204 isa<ValueAsMetadata>(MD->getMetadata()))
1205 return Val;
1206 return nullptr;
1207}
1208
1210 if (auto *MD = dyn_cast_or_null<MetadataAsValue>(unwrap(Val)))
1211 if (isa<ValueAsMetadata>(MD->getMetadata()))
1212 return Val;
1213 return nullptr;
1214}
1215
1217 if (auto *MD = dyn_cast_or_null<MetadataAsValue>(unwrap(Val)))
1218 if (isa<MDString>(MD->getMetadata()))
1219 return Val;
1220 return nullptr;
1221}
1222
1223/*--.. Operations on Uses ..................................................--*/
1225 Value *V = unwrap(Val);
1226 Value::use_iterator I = V->use_begin();
1227 if (I == V->use_end())
1228 return nullptr;
1229 return wrap(&*I);
1230}
1231
1233 Use *Next = unwrap(U)->getNext();
1234 if (Next)
1235 return wrap(Next);
1236 return nullptr;
1237}
1238
1240 return wrap(unwrap(U)->getUser());
1241}
1242
1246
1247/*--.. Operations on Users .................................................--*/
1248
1250 unsigned Index) {
1251 Metadata *Op = N->getOperand(Index);
1252 if (!Op)
1253 return nullptr;
1254 if (auto *C = dyn_cast<ConstantAsMetadata>(Op))
1255 return wrap(C->getValue());
1256 return wrap(MetadataAsValue::get(Context, Op));
1257}
1258
1260 Value *V = unwrap(Val);
1261 if (auto *MD = dyn_cast<MetadataAsValue>(V)) {
1262 if (auto *L = dyn_cast<ValueAsMetadata>(MD->getMetadata())) {
1263 assert(Index == 0 && "Function-local metadata can only have one operand");
1264 return wrap(L->getValue());
1265 }
1266 return getMDNodeOperandImpl(V->getContext(),
1267 cast<MDNode>(MD->getMetadata()), Index);
1268 }
1269
1270 return wrap(cast<User>(V)->getOperand(Index));
1271}
1272
1274 Value *V = unwrap(Val);
1275 return wrap(&cast<User>(V)->getOperandUse(Index));
1276}
1277
1278void LLVMSetOperand(LLVMValueRef Val, unsigned Index, LLVMValueRef Op) {
1279 unwrap<User>(Val)->setOperand(Index, unwrap(Op));
1280}
1281
1283 Value *V = unwrap(Val);
1285 return LLVMGetMDNodeNumOperands(Val);
1286
1287 return cast<User>(V)->getNumOperands();
1288}
1289
1290/*--.. Operations on constants of any type .................................--*/
1291
1295
1299
1303
1307
1311
1313 if (Constant *C = dyn_cast<Constant>(unwrap(Val)))
1314 return C->isNullValue();
1315 return false;
1316}
1317
1321
1325
1329
1330/*--.. Operations on metadata nodes ........................................--*/
1331
1333 size_t SLen) {
1334 return wrap(MDString::get(*unwrap(C), StringRef(Str, SLen)));
1335}
1336
1341
1343 unsigned SLen) {
1344 LLVMContext &Context = *unwrap(C);
1346 Context, MDString::get(Context, StringRef(Str, SLen))));
1347}
1348
1349LLVMValueRef LLVMMDString(const char *Str, unsigned SLen) {
1351}
1352
1354 unsigned Count) {
1355 LLVMContext &Context = *unwrap(C);
1357 for (auto *OV : ArrayRef(Vals, Count)) {
1358 Value *V = unwrap(OV);
1359 Metadata *MD;
1360 if (!V)
1361 MD = nullptr;
1362 else if (auto *C = dyn_cast<Constant>(V))
1364 else if (auto *MDV = dyn_cast<MetadataAsValue>(V)) {
1365 MD = MDV->getMetadata();
1366 assert(!isa<LocalAsMetadata>(MD) && "Unexpected function-local metadata "
1367 "outside of direct argument to call");
1368 } else {
1369 // This is function-local metadata. Pretend to make an MDNode.
1370 assert(Count == 1 &&
1371 "Expected only one operand to function-local metadata");
1373 }
1374
1375 MDs.push_back(MD);
1376 }
1377 return wrap(MetadataAsValue::get(Context, MDNode::get(Context, MDs)));
1378}
1379
1383
1387
1389 auto *V = unwrap(Val);
1390 if (auto *C = dyn_cast<Constant>(V))
1392 if (auto *MAV = dyn_cast<MetadataAsValue>(V))
1393 return wrap(MAV->getMetadata());
1394 return wrap(ValueAsMetadata::get(V));
1395}
1396
1398 std::string buf;
1399 raw_string_ostream os(buf);
1400
1401 if (unwrap(MD))
1402 unwrap(MD)->print(os);
1403 else
1404 os << "Printing <null> Metadata";
1405
1406 return strdup(buf.c_str());
1407}
1408
1409const char *LLVMGetMDString(LLVMValueRef V, unsigned *Length) {
1410 if (const auto *MD = dyn_cast<MetadataAsValue>(unwrap(V)))
1411 if (const MDString *S = dyn_cast<MDString>(MD->getMetadata())) {
1412 *Length = S->getString().size();
1413 return S->getString().data();
1414 }
1415 *Length = 0;
1416 return nullptr;
1417}
1418
1420 auto *MD = unwrap<MetadataAsValue>(V);
1421 if (isa<ValueAsMetadata>(MD->getMetadata()))
1422 return 1;
1423 return cast<MDNode>(MD->getMetadata())->getNumOperands();
1424}
1425
1427 Module *Mod = unwrap(M);
1428 Module::named_metadata_iterator I = Mod->named_metadata_begin();
1429 if (I == Mod->named_metadata_end())
1430 return nullptr;
1431 return wrap(&*I);
1432}
1433
1435 Module *Mod = unwrap(M);
1436 Module::named_metadata_iterator I = Mod->named_metadata_end();
1437 if (I == Mod->named_metadata_begin())
1438 return nullptr;
1439 return wrap(&*--I);
1440}
1441
1443 NamedMDNode *NamedNode = unwrap(NMD);
1445 if (++I == NamedNode->getParent()->named_metadata_end())
1446 return nullptr;
1447 return wrap(&*I);
1448}
1449
1451 NamedMDNode *NamedNode = unwrap(NMD);
1453 if (I == NamedNode->getParent()->named_metadata_begin())
1454 return nullptr;
1455 return wrap(&*--I);
1456}
1457
1459 const char *Name, size_t NameLen) {
1460 return wrap(unwrap(M)->getNamedMetadata(StringRef(Name, NameLen)));
1461}
1462
1464 const char *Name, size_t NameLen) {
1465 return wrap(unwrap(M)->getOrInsertNamedMetadata({Name, NameLen}));
1466}
1467
1468const char *LLVMGetNamedMetadataName(LLVMNamedMDNodeRef NMD, size_t *NameLen) {
1469 NamedMDNode *NamedNode = unwrap(NMD);
1470 *NameLen = NamedNode->getName().size();
1471 return NamedNode->getName().data();
1472}
1473
1475 auto *MD = unwrap<MetadataAsValue>(V);
1476 if (auto *MDV = dyn_cast<ValueAsMetadata>(MD->getMetadata())) {
1477 *Dest = wrap(MDV->getValue());
1478 return;
1479 }
1480 const auto *N = cast<MDNode>(MD->getMetadata());
1481 const unsigned numOperands = N->getNumOperands();
1482 LLVMContext &Context = unwrap(V)->getContext();
1483 for (unsigned i = 0; i < numOperands; i++)
1484 Dest[i] = getMDNodeOperandImpl(Context, N, i);
1485}
1486
1488 LLVMMetadataRef Replacement) {
1489 auto *MD = cast<MetadataAsValue>(unwrap(V));
1490 auto *N = cast<MDNode>(MD->getMetadata());
1491 N->replaceOperandWith(Index, unwrap<Metadata>(Replacement));
1492}
1493
1494unsigned LLVMGetNamedMetadataNumOperands(LLVMModuleRef M, const char *Name) {
1495 if (NamedMDNode *N = unwrap(M)->getNamedMetadata(Name)) {
1496 return N->getNumOperands();
1497 }
1498 return 0;
1499}
1500
1502 LLVMValueRef *Dest) {
1503 NamedMDNode *N = unwrap(M)->getNamedMetadata(Name);
1504 if (!N)
1505 return;
1506 LLVMContext &Context = unwrap(M)->getContext();
1507 for (unsigned i=0;i<N->getNumOperands();i++)
1508 Dest[i] = wrap(MetadataAsValue::get(Context, N->getOperand(i)));
1509}
1510
1512 LLVMValueRef Val) {
1513 NamedMDNode *N = unwrap(M)->getOrInsertNamedMetadata(Name);
1514 if (!N)
1515 return;
1516 if (!Val)
1517 return;
1518 N->addOperand(extractMDNode(unwrap<MetadataAsValue>(Val)));
1519}
1520
1521const char *LLVMGetDebugLocDirectory(LLVMValueRef Val, unsigned *Length) {
1522 if (!Length) return nullptr;
1523 StringRef S;
1524 if (const auto *I = dyn_cast<Instruction>(unwrap(Val))) {
1525 if (const auto &DL = I->getDebugLoc()) {
1526 S = DL->getDirectory();
1527 }
1528 } else if (const auto *GV = dyn_cast<GlobalVariable>(unwrap(Val))) {
1530 GV->getDebugInfo(GVEs);
1531 if (GVEs.size())
1532 if (const DIGlobalVariable *DGV = GVEs[0]->getVariable())
1533 S = DGV->getDirectory();
1534 } else if (const auto *F = dyn_cast<Function>(unwrap(Val))) {
1535 if (const DISubprogram *DSP = F->getSubprogram())
1536 S = DSP->getDirectory();
1537 } else {
1538 assert(0 && "Expected Instruction, GlobalVariable or Function");
1539 return nullptr;
1540 }
1541 *Length = S.size();
1542 return S.data();
1543}
1544
1545const char *LLVMGetDebugLocFilename(LLVMValueRef Val, unsigned *Length) {
1546 if (!Length) return nullptr;
1547 StringRef S;
1548 if (const auto *I = dyn_cast<Instruction>(unwrap(Val))) {
1549 if (const auto &DL = I->getDebugLoc()) {
1550 S = DL->getFilename();
1551 }
1552 } else if (const auto *GV = dyn_cast<GlobalVariable>(unwrap(Val))) {
1554 GV->getDebugInfo(GVEs);
1555 if (GVEs.size())
1556 if (const DIGlobalVariable *DGV = GVEs[0]->getVariable())
1557 S = DGV->getFilename();
1558 } else if (const auto *F = dyn_cast<Function>(unwrap(Val))) {
1559 if (const DISubprogram *DSP = F->getSubprogram())
1560 S = DSP->getFilename();
1561 } else {
1562 assert(0 && "Expected Instruction, GlobalVariable or Function");
1563 return nullptr;
1564 }
1565 *Length = S.size();
1566 return S.data();
1567}
1568
1570 unsigned L = 0;
1571 if (const auto *I = dyn_cast<Instruction>(unwrap(Val))) {
1572 if (const auto &DL = I->getDebugLoc()) {
1573 L = DL->getLine();
1574 }
1575 } else if (const auto *GV = dyn_cast<GlobalVariable>(unwrap(Val))) {
1577 GV->getDebugInfo(GVEs);
1578 if (GVEs.size())
1579 if (const DIGlobalVariable *DGV = GVEs[0]->getVariable())
1580 L = DGV->getLine();
1581 } else if (const auto *F = dyn_cast<Function>(unwrap(Val))) {
1582 if (const DISubprogram *DSP = F->getSubprogram())
1583 L = DSP->getLine();
1584 } else {
1585 assert(0 && "Expected Instruction, GlobalVariable or Function");
1586 return -1;
1587 }
1588 return L;
1589}
1590
1592 unsigned C = 0;
1593 if (const auto *I = dyn_cast<Instruction>(unwrap(Val)))
1594 if (const auto &DL = I->getDebugLoc())
1595 C = DL->getColumn();
1596 return C;
1597}
1598
1599/*--.. Operations on scalar constants ......................................--*/
1600
1601LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N,
1602 LLVMBool SignExtend) {
1603 return wrap(ConstantInt::get(unwrap<IntegerType>(IntTy), N, SignExtend != 0));
1604}
1605
1607 unsigned NumWords,
1608 const uint64_t Words[]) {
1609 IntegerType *Ty = unwrap<IntegerType>(IntTy);
1610 return wrap(ConstantInt::get(
1611 Ty->getContext(), APInt(Ty->getBitWidth(), ArrayRef(Words, NumWords))));
1612}
1613
1615 uint8_t Radix) {
1616 return wrap(ConstantInt::get(unwrap<IntegerType>(IntTy), StringRef(Str),
1617 Radix));
1618}
1619
1621 unsigned SLen, uint8_t Radix) {
1622 return wrap(ConstantInt::get(unwrap<IntegerType>(IntTy), StringRef(Str, SLen),
1623 Radix));
1624}
1625
1626LLVMValueRef LLVMConstByte(LLVMTypeRef ByteTy, unsigned long long N) {
1627 return wrap(ConstantByte::get(unwrap<ByteType>(ByteTy), N));
1628}
1629
1631 unsigned NumWords,
1632 const uint64_t Words[]) {
1633 ByteType *Ty = unwrap<ByteType>(ByteTy);
1634 return wrap(ConstantByte::get(
1635 Ty->getContext(), APInt(Ty->getBitWidth(), ArrayRef(Words, NumWords))));
1636}
1637
1639 uint8_t Radix) {
1640 return wrap(
1641 ConstantByte::get(unwrap<ByteType>(ByteTy), StringRef(Str), Radix));
1642}
1643
1645 size_t SLen, uint8_t Radix) {
1646 return wrap(
1647 ConstantByte::get(unwrap<ByteType>(ByteTy), StringRef(Str, SLen), Radix));
1648}
1649
1651 return wrap(ConstantFP::get(unwrap(RealTy), N));
1652}
1653
1655 return wrap(ConstantFP::get(unwrap(RealTy), StringRef(Text)));
1656}
1657
1659 unsigned SLen) {
1660 return wrap(ConstantFP::get(unwrap(RealTy), StringRef(Str, SLen)));
1661}
1662
1664 Type *T = unwrap(Ty);
1665 unsigned SB = T->getScalarSizeInBits();
1666 APInt AI(SB, ArrayRef<uint64_t>(N, divideCeil(SB, 64)));
1667 APFloat Quad(T->getFltSemantics(), AI);
1668 return wrap(ConstantFP::get(T, Quad));
1669}
1670
1671unsigned long long LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal) {
1672 return unwrap<ConstantInt>(ConstantVal)->getZExtValue();
1673}
1674
1676 return unwrap<ConstantInt>(ConstantVal)->getSExtValue();
1677}
1678
1679unsigned long long LLVMConstByteGetZExtValue(LLVMValueRef ConstantVal) {
1680 return unwrap<ConstantByte>(ConstantVal)->getZExtValue();
1681}
1682
1684 return unwrap<ConstantByte>(ConstantVal)->getSExtValue();
1685}
1686
1687double LLVMConstRealGetDouble(LLVMValueRef ConstantVal, LLVMBool *LosesInfo) {
1688 ConstantFP *cFP = unwrap<ConstantFP>(ConstantVal) ;
1689 Type *Ty = cFP->getType();
1690
1691 if (Ty->isHalfTy() || Ty->isBFloatTy() || Ty->isFloatTy() ||
1692 Ty->isDoubleTy()) {
1693 *LosesInfo = false;
1694 return cFP->getValueAPF().convertToDouble();
1695 }
1696
1697 bool APFLosesInfo;
1698 APFloat APF = cFP->getValueAPF();
1700 *LosesInfo = APFLosesInfo;
1701 return APF.convertToDouble();
1702}
1703
1704/*--.. Operations on composite constants ...................................--*/
1705
1707 unsigned Length,
1708 LLVMBool DontNullTerminate) {
1709 /* Inverted the sense of AddNull because ', 0)' is a
1710 better mnemonic for null termination than ', 1)'. */
1712 DontNullTerminate == 0));
1713}
1714
1716 size_t Length,
1717 LLVMBool DontNullTerminate) {
1718 /* Inverted the sense of AddNull because ', 0)' is a
1719 better mnemonic for null termination than ', 1)'. */
1721 DontNullTerminate == 0));
1722}
1723
1724LLVMValueRef LLVMConstString(const char *Str, unsigned Length,
1725 LLVMBool DontNullTerminate) {
1727 DontNullTerminate);
1728}
1729
1731 return wrap(unwrap<Constant>(C)->getAggregateElement(Idx));
1732}
1733
1735 return wrap(unwrap<ConstantDataSequential>(C)->getElementAsConstant(idx));
1736}
1737
1741
1742const char *LLVMGetAsString(LLVMValueRef C, size_t *Length) {
1744 *Length = Str.size();
1745 return Str.data();
1746}
1747
1748const char *LLVMGetRawDataValues(LLVMValueRef C, size_t *SizeInBytes) {
1749 StringRef Str = unwrap<ConstantDataSequential>(C)->getRawDataValues();
1750 *SizeInBytes = Str.size();
1751 return Str.data();
1752}
1753
1755 LLVMValueRef *ConstantVals, unsigned Length) {
1757 return wrap(ConstantArray::get(ArrayType::get(unwrap(ElementTy), Length), V));
1758}
1759
1765
1767 size_t SizeInBytes) {
1768 Type *Ty = unwrap(ElementTy);
1769 size_t Len = SizeInBytes / (Ty->getPrimitiveSizeInBits() / 8);
1770 return wrap(ConstantDataArray::getRaw(StringRef(Data, SizeInBytes), Len, Ty));
1771}
1772
1774 LLVMValueRef *ConstantVals,
1775 unsigned Count, LLVMBool Packed) {
1776 Constant **Elements = unwrap<Constant>(ConstantVals, Count);
1777 return wrap(ConstantStruct::getAnon(*unwrap(C), ArrayRef(Elements, Count),
1778 Packed != 0));
1779}
1780
1782 LLVMBool Packed) {
1784 Count, Packed);
1785}
1786
1788 LLVMValueRef *ConstantVals,
1789 unsigned Count) {
1790 Constant **Elements = unwrap<Constant>(ConstantVals, Count);
1791 StructType *Ty = unwrap<StructType>(StructTy);
1792
1793 return wrap(ConstantStruct::get(Ty, ArrayRef(Elements, Count)));
1794}
1795
1796LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size) {
1798 ArrayRef(unwrap<Constant>(ScalarConstantVals, Size), Size)));
1799}
1800
1809
1810/*-- Opcode mapping */
1811
1813{
1814 switch (opcode) {
1815 default: llvm_unreachable("Unhandled Opcode.");
1816#define HANDLE_INST(num, opc, clas) case num: return LLVM##opc;
1817#include "llvm/IR/Instruction.def"
1818#undef HANDLE_INST
1819 }
1820}
1821
1823{
1824 switch (code) {
1825#define HANDLE_INST(num, opc, clas) case LLVM##opc: return num;
1826#include "llvm/IR/Instruction.def"
1827#undef HANDLE_INST
1828 }
1829 llvm_unreachable("Unhandled Opcode.");
1830}
1831
1832/*-- GEP wrap flag conversions */
1833
1835 GEPNoWrapFlags NewGEPFlags;
1836 if ((GEPFlags & LLVMGEPFlagInBounds) != 0)
1837 NewGEPFlags |= GEPNoWrapFlags::inBounds();
1838 if ((GEPFlags & LLVMGEPFlagNUSW) != 0)
1839 NewGEPFlags |= GEPNoWrapFlags::noUnsignedSignedWrap();
1840 if ((GEPFlags & LLVMGEPFlagNUW) != 0)
1841 NewGEPFlags |= GEPNoWrapFlags::noUnsignedWrap();
1842
1843 return NewGEPFlags;
1844}
1845
1847 LLVMGEPNoWrapFlags NewGEPFlags = 0;
1848 if (GEPFlags.isInBounds())
1849 NewGEPFlags |= LLVMGEPFlagInBounds;
1850 if (GEPFlags.hasNoUnsignedSignedWrap())
1851 NewGEPFlags |= LLVMGEPFlagNUSW;
1852 if (GEPFlags.hasNoUnsignedWrap())
1853 NewGEPFlags |= LLVMGEPFlagNUW;
1854
1855 return NewGEPFlags;
1856}
1857
1858/*--.. Constant expressions ................................................--*/
1859
1861 return map_to_llvmopcode(unwrap<ConstantExpr>(ConstantVal)->getOpcode());
1862}
1863
1869
1875
1877 return wrap(ConstantExpr::getNeg(unwrap<Constant>(ConstantVal)));
1878}
1879
1883
1887
1888
1890 return wrap(ConstantExpr::getNot(unwrap<Constant>(ConstantVal)));
1891}
1892
1894 return wrap(ConstantExpr::getAdd(unwrap<Constant>(LHSConstant),
1895 unwrap<Constant>(RHSConstant)));
1896}
1897
1899 LLVMValueRef RHSConstant) {
1900 return wrap(ConstantExpr::getNSWAdd(unwrap<Constant>(LHSConstant),
1901 unwrap<Constant>(RHSConstant)));
1902}
1903
1905 LLVMValueRef RHSConstant) {
1906 return wrap(ConstantExpr::getNUWAdd(unwrap<Constant>(LHSConstant),
1907 unwrap<Constant>(RHSConstant)));
1908}
1909
1911 return wrap(ConstantExpr::getSub(unwrap<Constant>(LHSConstant),
1912 unwrap<Constant>(RHSConstant)));
1913}
1914
1916 LLVMValueRef RHSConstant) {
1917 return wrap(ConstantExpr::getNSWSub(unwrap<Constant>(LHSConstant),
1918 unwrap<Constant>(RHSConstant)));
1919}
1920
1922 LLVMValueRef RHSConstant) {
1923 return wrap(ConstantExpr::getNUWSub(unwrap<Constant>(LHSConstant),
1924 unwrap<Constant>(RHSConstant)));
1925}
1926
1928 return wrap(ConstantExpr::getXor(unwrap<Constant>(LHSConstant),
1929 unwrap<Constant>(RHSConstant)));
1930}
1931
1933 LLVMValueRef *ConstantIndices, unsigned NumIndices) {
1935 ArrayRef<Constant *> IdxList(unwrap<Constant>(ConstantIndices, NumIndices),
1936 NumIndices);
1937 Constant *Val = unwrap<Constant>(ConstantVal);
1938 return wrap(ConstantExpr::getGetElementPtr(unwrap(Ty), Val, IdxList));
1940}
1941
1943 LLVMValueRef *ConstantIndices,
1944 unsigned NumIndices) {
1946 ArrayRef<Constant *> IdxList(unwrap<Constant>(ConstantIndices, NumIndices),
1947 NumIndices);
1948 Constant *Val = unwrap<Constant>(ConstantVal);
1949 return wrap(ConstantExpr::getInBoundsGetElementPtr(unwrap(Ty), Val, IdxList));
1951}
1952
1954 LLVMValueRef ConstantVal,
1955 LLVMValueRef *ConstantIndices,
1956 unsigned NumIndices,
1957 LLVMGEPNoWrapFlags NoWrapFlags) {
1959 ArrayRef<Constant *> IdxList(unwrap<Constant>(ConstantIndices, NumIndices),
1960 NumIndices);
1961 Constant *Val = unwrap<Constant>(ConstantVal);
1963 unwrap(Ty), Val, IdxList, mapFromLLVMGEPNoWrapFlags(NoWrapFlags)));
1965}
1966
1968 LLVMValueRef ConstantOffset,
1969 LLVMGEPNoWrapFlags NoWrapFlags) {
1970 return wrap(ConstantExpr::getPtrAdd(unwrap<Constant>(ConstantVal),
1971 unwrap<Constant>(ConstantOffset),
1972 mapFromLLVMGEPNoWrapFlags(NoWrapFlags)));
1973}
1974
1976 LLVMTypeRef Ty,
1977 LLVMValueRef ConstantVal,
1978 LLVMValueRef *ConstantIndices,
1979 unsigned NumIndices,
1980 LLVMGEPNoWrapFlags NoWrapFlags) {
1981 ArrayRef<Constant *> IdxList(unwrap<Constant>(ConstantIndices, NumIndices),
1982 NumIndices);
1984 *unwrap(DataLayout), unwrap(Ty), unwrap<Constant>(ConstantVal), IdxList,
1985 mapFromLLVMGEPNoWrapFlags(NoWrapFlags)));
1986}
1987
1989 return wrap(ConstantExpr::getTrunc(unwrap<Constant>(ConstantVal),
1990 unwrap(ToType)));
1991}
1992
1995 unwrap(ToType)));
1996}
1997
2000 unwrap(ToType)));
2001}
2002
2005 unwrap(ToType)));
2006}
2007
2009 LLVMTypeRef ToType) {
2011 unwrap(ToType)));
2012}
2013
2015 LLVMTypeRef ToType) {
2017 unwrap(ToType)));
2018}
2019
2021 LLVMTypeRef ToType) {
2023 unwrap(ToType)));
2024}
2025
2027 LLVMValueRef IndexConstant) {
2029 unwrap<Constant>(IndexConstant)));
2030}
2031
2033 LLVMValueRef ElementValueConstant,
2034 LLVMValueRef IndexConstant) {
2036 unwrap<Constant>(ElementValueConstant),
2037 unwrap<Constant>(IndexConstant)));
2038}
2039
2041 LLVMValueRef VectorBConstant,
2042 LLVMValueRef MaskConstant) {
2043 SmallVector<int, 16> IntMask;
2046 unwrap<Constant>(VectorBConstant),
2047 IntMask));
2048}
2049
2051 const char *Constraints,
2052 LLVMBool HasSideEffects,
2053 LLVMBool IsAlignStack) {
2054 return wrap(InlineAsm::get(dyn_cast<FunctionType>(unwrap(Ty)), AsmString,
2055 Constraints, HasSideEffects, IsAlignStack));
2056}
2057
2061
2065
2067 return wrap(unwrap<BlockAddress>(BlockAddr)->getBasicBlock());
2068}
2069
2070/*--.. Operations on global variables, functions, and aliases (globals) ....--*/
2071
2075
2079
2108
2111
2112 switch (Linkage) {
2115 break;
2118 break;
2121 break;
2124 break;
2126 LLVM_DEBUG(
2127 errs() << "LLVMSetLinkage(): LLVMLinkOnceODRAutoHideLinkage is no "
2128 "longer supported.");
2129 break;
2130 case LLVMWeakAnyLinkage:
2132 break;
2133 case LLVMWeakODRLinkage:
2135 break;
2138 break;
2141 break;
2142 case LLVMPrivateLinkage:
2144 break;
2147 break;
2150 break;
2152 LLVM_DEBUG(
2153 errs()
2154 << "LLVMSetLinkage(): LLVMDLLImportLinkage is no longer supported.");
2155 break;
2157 LLVM_DEBUG(
2158 errs()
2159 << "LLVMSetLinkage(): LLVMDLLExportLinkage is no longer supported.");
2160 break;
2163 break;
2164 case LLVMGhostLinkage:
2165 LLVM_DEBUG(
2166 errs() << "LLVMSetLinkage(): LLVMGhostLinkage is no longer supported.");
2167 break;
2168 case LLVMCommonLinkage:
2170 break;
2171 }
2172}
2173
2175 // Using .data() is safe because of how GlobalObject::setSection is
2176 // implemented.
2177 return unwrap<GlobalValue>(Global)->getSection().data();
2178}
2179
2180void LLVMSetSection(LLVMValueRef Global, const char *Section) {
2181 unwrap<GlobalObject>(Global)->setSection(Section);
2182}
2183
2185 return static_cast<LLVMVisibility>(
2186 unwrap<GlobalValue>(Global)->getVisibility());
2187}
2188
2191 ->setVisibility(static_cast<GlobalValue::VisibilityTypes>(Viz));
2192}
2193
2195 return static_cast<LLVMDLLStorageClass>(
2196 unwrap<GlobalValue>(Global)->getDLLStorageClass());
2197}
2198
2200 unwrap<GlobalValue>(Global)->setDLLStorageClass(
2201 static_cast<GlobalValue::DLLStorageClassTypes>(Class));
2202}
2203
2215
2228
2232
2234 unwrap<GlobalValue>(Global)->setDSOLocal(IsDSOLocal);
2235}
2236
2238 return unwrap<GlobalValue>(Global)->hasGlobalUnnamedAddr();
2239}
2240
2242 unwrap<GlobalValue>(Global)->setUnnamedAddr(
2243 HasUnnamedAddr ? GlobalValue::UnnamedAddr::Global
2245}
2246
2250
2251/*--.. Operations on global variables, load and store instructions .........--*/
2252
2254 Value *P = unwrap(V);
2256 return GV->getAlign() ? GV->getAlign()->value() : 0;
2258 return F->getAlign() ? F->getAlign()->value() : 0;
2260 return AI->getAlign().value();
2261 if (LoadInst *LI = dyn_cast<LoadInst>(P))
2262 return LI->getAlign().value();
2264 return SI->getAlign().value();
2266 return RMWI->getAlign().value();
2268 return CXI->getAlign().value();
2269
2271 "only GlobalValue, AllocaInst, LoadInst, StoreInst, AtomicRMWInst, "
2272 "and AtomicCmpXchgInst have alignment");
2273}
2274
2275void LLVMSetAlignment(LLVMValueRef V, unsigned Bytes) {
2276 Value *P = unwrap(V);
2278 GV->setAlignment(MaybeAlign(Bytes));
2279 else if (Function *F = dyn_cast<Function>(P))
2280 F->setAlignment(MaybeAlign(Bytes));
2281 else if (AllocaInst *AI = dyn_cast<AllocaInst>(P))
2282 AI->setAlignment(Align(Bytes));
2283 else if (LoadInst *LI = dyn_cast<LoadInst>(P))
2284 LI->setAlignment(Align(Bytes));
2285 else if (StoreInst *SI = dyn_cast<StoreInst>(P))
2286 SI->setAlignment(Align(Bytes));
2287 else if (AtomicRMWInst *RMWI = dyn_cast<AtomicRMWInst>(P))
2288 RMWI->setAlignment(Align(Bytes));
2290 CXI->setAlignment(Align(Bytes));
2291 else
2293 "only GlobalValue, AllocaInst, LoadInst, StoreInst, AtomicRMWInst, and "
2294 "and AtomicCmpXchgInst have alignment");
2295}
2296
2298 size_t *NumEntries) {
2299 return llvm_getMetadata(NumEntries, [&Value](MetadataEntries &Entries) {
2300 Entries.clear();
2302 Instr->getAllMetadata(Entries);
2303 } else {
2304 unwrap<GlobalObject>(Value)->getAllMetadata(Entries);
2305 }
2306 });
2307}
2308
2310 unsigned Index) {
2312 static_cast<LLVMOpaqueValueMetadataEntry>(Entries[Index]);
2313 return MVE.Kind;
2314}
2315
2318 unsigned Index) {
2320 static_cast<LLVMOpaqueValueMetadataEntry>(Entries[Index]);
2321 return MVE.Metadata;
2322}
2323
2325 free(Entries);
2326}
2327
2329 LLVMMetadataRef MD) {
2330 unwrap<GlobalObject>(Global)->setMetadata(Kind, unwrap<MDNode>(MD));
2331}
2332
2334 LLVMMetadataRef MD) {
2335 unwrap<GlobalObject>(Global)->addMetadata(Kind, *unwrap<MDNode>(MD));
2336}
2337
2339 unwrap<GlobalObject>(Global)->eraseMetadata(Kind);
2340}
2341
2345
2350
2351/*--.. Operations on global variables ......................................--*/
2352
2354 return wrap(new GlobalVariable(*unwrap(M), unwrap(Ty), false,
2355 GlobalValue::ExternalLinkage, nullptr, Name));
2356}
2357
2359 const char *Name,
2360 unsigned AddressSpace) {
2361 return wrap(new GlobalVariable(*unwrap(M), unwrap(Ty), false,
2362 GlobalValue::ExternalLinkage, nullptr, Name,
2364 AddressSpace));
2365}
2366
2368 return wrap(unwrap(M)->getNamedGlobal(Name));
2369}
2370
2372 size_t Length) {
2373 return wrap(unwrap(M)->getNamedGlobal(StringRef(Name, Length)));
2374}
2375
2377 Module *Mod = unwrap(M);
2378 Module::global_iterator I = Mod->global_begin();
2379 if (I == Mod->global_end())
2380 return nullptr;
2381 return wrap(&*I);
2382}
2383
2385 Module *Mod = unwrap(M);
2386 Module::global_iterator I = Mod->global_end();
2387 if (I == Mod->global_begin())
2388 return nullptr;
2389 return wrap(&*--I);
2390}
2391
2393 GlobalVariable *GV = unwrap<GlobalVariable>(GlobalVar);
2395 if (++I == GV->getParent()->global_end())
2396 return nullptr;
2397 return wrap(&*I);
2398}
2399
2401 GlobalVariable *GV = unwrap<GlobalVariable>(GlobalVar);
2403 if (I == GV->getParent()->global_begin())
2404 return nullptr;
2405 return wrap(&*--I);
2406}
2407
2409 unwrap<GlobalVariable>(GlobalVar)->eraseFromParent();
2410}
2411
2413 GlobalVariable* GV = unwrap<GlobalVariable>(GlobalVar);
2414 if ( !GV->hasInitializer() )
2415 return nullptr;
2416 return wrap(GV->getInitializer());
2417}
2418
2419void LLVMSetInitializer(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal) {
2420 unwrap<GlobalVariable>(GlobalVar)->setInitializer(
2421 ConstantVal ? unwrap<Constant>(ConstantVal) : nullptr);
2422}
2423
2425 return unwrap<GlobalVariable>(GlobalVar)->isThreadLocal();
2426}
2427
2428void LLVMSetThreadLocal(LLVMValueRef GlobalVar, LLVMBool IsThreadLocal) {
2429 unwrap<GlobalVariable>(GlobalVar)->setThreadLocal(IsThreadLocal != 0);
2430}
2431
2433 return unwrap<GlobalVariable>(GlobalVar)->isConstant();
2434}
2435
2436void LLVMSetGlobalConstant(LLVMValueRef GlobalVar, LLVMBool IsConstant) {
2437 unwrap<GlobalVariable>(GlobalVar)->setConstant(IsConstant != 0);
2438}
2439
2441 switch (unwrap<GlobalVariable>(GlobalVar)->getThreadLocalMode()) {
2443 return LLVMNotThreadLocal;
2451 return LLVMLocalExecTLSModel;
2452 }
2453
2454 llvm_unreachable("Invalid GlobalVariable thread local mode");
2455}
2456
2478
2480 return unwrap<GlobalVariable>(GlobalVar)->isExternallyInitialized();
2481}
2482
2484 unwrap<GlobalVariable>(GlobalVar)->setExternallyInitialized(IsExtInit);
2485}
2486
2487/*--.. Operations on aliases ......................................--*/
2488
2490 unsigned AddrSpace, LLVMValueRef Aliasee,
2491 const char *Name) {
2492 return wrap(GlobalAlias::create(unwrap(ValueTy), AddrSpace,
2494 unwrap<Constant>(Aliasee), unwrap(M)));
2495}
2496
2498 const char *Name, size_t NameLen) {
2499 return wrap(unwrap(M)->getNamedAlias(StringRef(Name, NameLen)));
2500}
2501
2503 Module *Mod = unwrap(M);
2504 Module::alias_iterator I = Mod->alias_begin();
2505 if (I == Mod->alias_end())
2506 return nullptr;
2507 return wrap(&*I);
2508}
2509
2511 Module *Mod = unwrap(M);
2512 Module::alias_iterator I = Mod->alias_end();
2513 if (I == Mod->alias_begin())
2514 return nullptr;
2515 return wrap(&*--I);
2516}
2517
2519 GlobalAlias *Alias = unwrap<GlobalAlias>(GA);
2521 if (++I == Alias->getParent()->alias_end())
2522 return nullptr;
2523 return wrap(&*I);
2524}
2525
2527 GlobalAlias *Alias = unwrap<GlobalAlias>(GA);
2529 if (I == Alias->getParent()->alias_begin())
2530 return nullptr;
2531 return wrap(&*--I);
2532}
2533
2535 return wrap(unwrap<GlobalAlias>(Alias)->getAliasee());
2536}
2537
2539 unwrap<GlobalAlias>(Alias)->setAliasee(unwrap<Constant>(Aliasee));
2540}
2541
2542/*--.. Operations on functions .............................................--*/
2543
2545 LLVMTypeRef FunctionTy) {
2546 return wrap(Function::Create(unwrap<FunctionType>(FunctionTy),
2548}
2549
2551 size_t NameLen, LLVMTypeRef FunctionTy) {
2552 return wrap(unwrap(M)
2553 ->getOrInsertFunction(StringRef(Name, NameLen),
2554 unwrap<FunctionType>(FunctionTy))
2555 .getCallee());
2556}
2557
2559 return wrap(unwrap(M)->getFunction(Name));
2560}
2561
2563 size_t Length) {
2564 return wrap(unwrap(M)->getFunction(StringRef(Name, Length)));
2565}
2566
2568 Module *Mod = unwrap(M);
2569 Module::iterator I = Mod->begin();
2570 if (I == Mod->end())
2571 return nullptr;
2572 return wrap(&*I);
2573}
2574
2576 Module *Mod = unwrap(M);
2577 Module::iterator I = Mod->end();
2578 if (I == Mod->begin())
2579 return nullptr;
2580 return wrap(&*--I);
2581}
2582
2584 Function *Func = unwrap<Function>(Fn);
2585 Module::iterator I(Func);
2586 if (++I == Func->getParent()->end())
2587 return nullptr;
2588 return wrap(&*I);
2589}
2590
2592 Function *Func = unwrap<Function>(Fn);
2593 Module::iterator I(Func);
2594 if (I == Func->getParent()->begin())
2595 return nullptr;
2596 return wrap(&*--I);
2597}
2598
2600 unwrap<Function>(Fn)->eraseFromParent();
2601}
2602
2604 return unwrap<Function>(Fn)->hasPersonalityFn();
2605}
2606
2608 return wrap(unwrap<Function>(Fn)->getPersonalityFn());
2609}
2610
2612 unwrap<Function>(Fn)->setPersonalityFn(
2613 PersonalityFn ? unwrap<Constant>(PersonalityFn) : nullptr);
2614}
2615
2617 if (Function *F = dyn_cast<Function>(unwrap(Fn)))
2618 return F->getIntrinsicID();
2619 return 0;
2620}
2621
2623 assert(ID < llvm::Intrinsic::num_intrinsics && "Intrinsic ID out of range");
2624 return llvm::Intrinsic::ID(ID);
2625}
2626
2628 LLVMTypeRef *OverloadTypes,
2629 size_t OverloadCount) {
2630 ArrayRef<Type *> OverloadTys(unwrap(OverloadTypes), OverloadCount);
2631 auto IID = llvm_map_to_intrinsic_id(ID);
2632 return wrap(
2634}
2635
2636const char *LLVMIntrinsicGetName(unsigned ID, size_t *NameLength) {
2637 auto IID = llvm_map_to_intrinsic_id(ID);
2638 auto Str = llvm::Intrinsic::getName(IID);
2639 *NameLength = Str.size();
2640 return Str.data();
2641}
2642
2644 LLVMTypeRef *OverloadTypes,
2645 size_t OverloadCount) {
2646 auto IID = llvm_map_to_intrinsic_id(ID);
2647 ArrayRef<Type *> OverloadTys(unwrap(OverloadTypes), OverloadCount);
2648 return wrap(llvm::Intrinsic::getType(*unwrap(Ctx), IID, OverloadTys));
2649}
2650
2651char *LLVMIntrinsicCopyOverloadedName(unsigned ID, LLVMTypeRef *OverloadTypes,
2652 size_t OverloadCount,
2653 size_t *NameLength) {
2654 auto IID = llvm_map_to_intrinsic_id(ID);
2655 ArrayRef<Type *> OverloadTys(unwrap(OverloadTypes), OverloadCount);
2656 auto Str = llvm::Intrinsic::getNameNoUnnamedTypes(IID, OverloadTys);
2657 *NameLength = Str.length();
2658 return strdup(Str.c_str());
2659}
2660
2662 LLVMTypeRef *OverloadTypes,
2663 size_t OverloadCount,
2664 size_t *NameLength) {
2665 auto IID = llvm_map_to_intrinsic_id(ID);
2666 ArrayRef<Type *> OverloadTys(unwrap(OverloadTypes), OverloadCount);
2667 auto Str = llvm::Intrinsic::getName(IID, OverloadTys, unwrap(Mod));
2668 *NameLength = Str.length();
2669 return strdup(Str.c_str());
2670}
2671
2672unsigned LLVMLookupIntrinsicID(const char *Name, size_t NameLen) {
2673 return Intrinsic::lookupIntrinsicID({Name, NameLen});
2674}
2675
2677 auto IID = llvm_map_to_intrinsic_id(ID);
2679}
2680
2682 return unwrap<Function>(Fn)->getCallingConv();
2683}
2684
2686 return unwrap<Function>(Fn)->setCallingConv(
2687 static_cast<CallingConv::ID>(CC));
2688}
2689
2690const char *LLVMGetGC(LLVMValueRef Fn) {
2692 return F->hasGC()? F->getGC().c_str() : nullptr;
2693}
2694
2695void LLVMSetGC(LLVMValueRef Fn, const char *GC) {
2697 if (GC)
2698 F->setGC(GC);
2699 else
2700 F->clearGC();
2701}
2702
2705 return wrap(F->getPrefixData());
2706}
2707
2710 return F->hasPrefixData();
2711}
2712
2715 Constant *prefix = unwrap<Constant>(prefixData);
2716 F->setPrefixData(prefix);
2717}
2718
2721 return wrap(F->getPrologueData());
2722}
2723
2726 return F->hasPrologueData();
2727}
2728
2731 Constant *prologue = unwrap<Constant>(prologueData);
2732 F->setPrologueData(prologue);
2733}
2734
2737 unwrap<Function>(F)->addAttributeAtIndex(Idx, unwrap(A));
2738}
2739
2741 auto AS = unwrap<Function>(F)->getAttributes().getAttributes(Idx);
2742 return AS.getNumAttributes();
2743}
2744
2746 LLVMAttributeRef *Attrs) {
2747 auto AS = unwrap<Function>(F)->getAttributes().getAttributes(Idx);
2748 for (auto A : AS)
2749 *Attrs++ = wrap(A);
2750}
2751
2754 unsigned KindID) {
2755 return wrap(unwrap<Function>(F)->getAttributeAtIndex(
2756 Idx, (Attribute::AttrKind)KindID));
2757}
2758
2761 const char *K, unsigned KLen) {
2762 return wrap(
2763 unwrap<Function>(F)->getAttributeAtIndex(Idx, StringRef(K, KLen)));
2764}
2765
2767 unsigned KindID) {
2768 unwrap<Function>(F)->removeAttributeAtIndex(Idx, (Attribute::AttrKind)KindID);
2769}
2770
2772 const char *K, unsigned KLen) {
2773 unwrap<Function>(F)->removeAttributeAtIndex(Idx, StringRef(K, KLen));
2774}
2775
2777 const char *V) {
2778 Function *Func = unwrap<Function>(Fn);
2779 Attribute Attr = Attribute::get(Func->getContext(), A, V);
2780 Func->addFnAttr(Attr);
2781}
2782
2783/*--.. Operations on parameters ............................................--*/
2784
2786 // This function is strictly redundant to
2787 // LLVMCountParamTypes(LLVMGlobalGetValueType(FnRef))
2788 return unwrap<Function>(FnRef)->arg_size();
2789}
2790
2791void LLVMGetParams(LLVMValueRef FnRef, LLVMValueRef *ParamRefs) {
2792 Function *Fn = unwrap<Function>(FnRef);
2793 for (Argument &A : Fn->args())
2794 *ParamRefs++ = wrap(&A);
2795}
2796
2798 Function *Fn = unwrap<Function>(FnRef);
2799 return wrap(&Fn->arg_begin()[index]);
2800}
2801
2805
2807 Function *Func = unwrap<Function>(Fn);
2808 Function::arg_iterator I = Func->arg_begin();
2809 if (I == Func->arg_end())
2810 return nullptr;
2811 return wrap(&*I);
2812}
2813
2815 Function *Func = unwrap<Function>(Fn);
2816 Function::arg_iterator I = Func->arg_end();
2817 if (I == Func->arg_begin())
2818 return nullptr;
2819 return wrap(&*--I);
2820}
2821
2823 Argument *A = unwrap<Argument>(Arg);
2824 Function *Fn = A->getParent();
2825 if (A->getArgNo() + 1 >= Fn->arg_size())
2826 return nullptr;
2827 return wrap(&Fn->arg_begin()[A->getArgNo() + 1]);
2828}
2829
2831 Argument *A = unwrap<Argument>(Arg);
2832 if (A->getArgNo() == 0)
2833 return nullptr;
2834 return wrap(&A->getParent()->arg_begin()[A->getArgNo() - 1]);
2835}
2836
2838 Argument *A = unwrap<Argument>(Arg);
2839 A->addAttr(Attribute::getWithAlignment(A->getContext(), Align(align)));
2840}
2841
2842/*--.. Operations on ifuncs ................................................--*/
2843
2845 const char *Name, size_t NameLen,
2846 LLVMTypeRef Ty, unsigned AddrSpace,
2848 return wrap(GlobalIFunc::create(unwrap(Ty), AddrSpace,
2850 StringRef(Name, NameLen),
2852}
2853
2855 const char *Name, size_t NameLen) {
2856 return wrap(unwrap(M)->getNamedIFunc(StringRef(Name, NameLen)));
2857}
2858
2860 Module *Mod = unwrap(M);
2861 Module::ifunc_iterator I = Mod->ifunc_begin();
2862 if (I == Mod->ifunc_end())
2863 return nullptr;
2864 return wrap(&*I);
2865}
2866
2868 Module *Mod = unwrap(M);
2869 Module::ifunc_iterator I = Mod->ifunc_end();
2870 if (I == Mod->ifunc_begin())
2871 return nullptr;
2872 return wrap(&*--I);
2873}
2874
2876 GlobalIFunc *GIF = unwrap<GlobalIFunc>(IFunc);
2878 if (++I == GIF->getParent()->ifunc_end())
2879 return nullptr;
2880 return wrap(&*I);
2881}
2882
2884 GlobalIFunc *GIF = unwrap<GlobalIFunc>(IFunc);
2886 if (I == GIF->getParent()->ifunc_begin())
2887 return nullptr;
2888 return wrap(&*--I);
2889}
2890
2892 return wrap(unwrap<GlobalIFunc>(IFunc)->getResolver());
2893}
2894
2898
2900 unwrap<GlobalIFunc>(IFunc)->eraseFromParent();
2901}
2902
2904 unwrap<GlobalIFunc>(IFunc)->removeFromParent();
2905}
2906
2907/*--.. Operations on operand bundles........................................--*/
2908
2909LLVMOperandBundleRef LLVMCreateOperandBundle(const char *Tag, size_t TagLen,
2910 LLVMValueRef *Args,
2911 unsigned NumArgs) {
2912 return wrap(new OperandBundleDef(std::string(Tag, TagLen),
2913 ArrayRef(unwrap(Args), NumArgs)));
2914}
2915
2917 delete unwrap(Bundle);
2918}
2919
2920const char *LLVMGetOperandBundleTag(LLVMOperandBundleRef Bundle, size_t *Len) {
2921 StringRef Str = unwrap(Bundle)->getTag();
2922 *Len = Str.size();
2923 return Str.data();
2924}
2925
2927 return unwrap(Bundle)->inputs().size();
2928}
2929
2931 unsigned Index) {
2932 return wrap(unwrap(Bundle)->inputs()[Index]);
2933}
2934
2935/*--.. Operations on basic blocks ..........................................--*/
2936
2938 return wrap(static_cast<Value*>(unwrap(BB)));
2939}
2940
2944
2948
2950 return unwrap(BB)->getName().data();
2951}
2952
2956
2958 return wrap(unwrap(BB)->getTerminatorOrNull());
2959}
2960
2962 return unwrap<Function>(FnRef)->size();
2963}
2964
2966 Function *Fn = unwrap<Function>(FnRef);
2967 for (BasicBlock &BB : *Fn)
2968 *BasicBlocksRefs++ = wrap(&BB);
2969}
2970
2972 return wrap(&unwrap<Function>(Fn)->getEntryBlock());
2973}
2974
2976 Function *Func = unwrap<Function>(Fn);
2977 Function::iterator I = Func->begin();
2978 if (I == Func->end())
2979 return nullptr;
2980 return wrap(&*I);
2981}
2982
2984 Function *Func = unwrap<Function>(Fn);
2985 Function::iterator I = Func->end();
2986 if (I == Func->begin())
2987 return nullptr;
2988 return wrap(&*--I);
2989}
2990
2992 BasicBlock *Block = unwrap(BB);
2994 if (++I == Block->getParent()->end())
2995 return nullptr;
2996 return wrap(&*I);
2997}
2998
3000 BasicBlock *Block = unwrap(BB);
3002 if (I == Block->getParent()->begin())
3003 return nullptr;
3004 return wrap(&*--I);
3005}
3006
3011
3013 LLVMBasicBlockRef BB) {
3014 BasicBlock *ToInsert = unwrap(BB);
3015 BasicBlock *CurBB = unwrap(Builder)->GetInsertBlock();
3016 assert(CurBB && "current insertion point is invalid!");
3017 CurBB->getParent()->insert(std::next(CurBB->getIterator()), ToInsert);
3018}
3019
3021 LLVMBasicBlockRef BB) {
3022 unwrap<Function>(Fn)->insert(unwrap<Function>(Fn)->end(), unwrap(BB));
3023}
3024
3026 LLVMValueRef FnRef,
3027 const char *Name) {
3028 return wrap(BasicBlock::Create(*unwrap(C), Name, unwrap<Function>(FnRef)));
3029}
3030
3034
3036 LLVMBasicBlockRef BBRef,
3037 const char *Name) {
3038 BasicBlock *BB = unwrap(BBRef);
3039 return wrap(BasicBlock::Create(*unwrap(C), Name, BB->getParent(), BB));
3040}
3041
3046
3048 unwrap(BBRef)->eraseFromParent();
3049}
3050
3052 unwrap(BBRef)->removeFromParent();
3053}
3054
3056 unwrap(BB)->moveBefore(unwrap(MovePos));
3057}
3058
3060 unwrap(BB)->moveAfter(unwrap(MovePos));
3061}
3062
3063/*--.. Operations on instructions ..........................................--*/
3064
3068
3070 BasicBlock *Block = unwrap(BB);
3071 BasicBlock::iterator I = Block->begin();
3072 if (I == Block->end())
3073 return nullptr;
3074 return wrap(&*I);
3075}
3076
3078 BasicBlock *Block = unwrap(BB);
3079 BasicBlock::iterator I = Block->end();
3080 if (I == Block->begin())
3081 return nullptr;
3082 return wrap(&*--I);
3083}
3084
3086 Instruction *Instr = unwrap<Instruction>(Inst);
3087 BasicBlock::iterator I(Instr);
3088 if (++I == Instr->getParent()->end())
3089 return nullptr;
3090 return wrap(&*I);
3091}
3092
3094 Instruction *Instr = unwrap<Instruction>(Inst);
3095 BasicBlock::iterator I(Instr);
3096 if (I == Instr->getParent()->begin())
3097 return nullptr;
3098 return wrap(&*--I);
3099}
3100
3102 unwrap<Instruction>(Inst)->removeFromParent();
3103}
3104
3106 unwrap<Instruction>(Inst)->eraseFromParent();
3107}
3108
3110 unwrap<Instruction>(Inst)->deleteValue();
3111}
3112
3114 if (ICmpInst *I = dyn_cast<ICmpInst>(unwrap(Inst)))
3115 return (LLVMIntPredicate)I->getPredicate();
3116 return (LLVMIntPredicate)0;
3117}
3118
3120 return unwrap<ICmpInst>(Inst)->hasSameSign();
3121}
3122
3124 unwrap<ICmpInst>(Inst)->setSameSign(SameSign);
3125}
3126
3128 if (FCmpInst *I = dyn_cast<FCmpInst>(unwrap(Inst)))
3129 return (LLVMRealPredicate)I->getPredicate();
3130 return (LLVMRealPredicate)0;
3131}
3132
3135 return map_to_llvmopcode(C->getOpcode());
3136 return (LLVMOpcode)0;
3137}
3138
3141 return wrap(C->clone());
3142 return nullptr;
3143}
3144
3147 return (I && I->isTerminator()) ? wrap(I) : nullptr;
3148}
3149
3151 Instruction *Instr = unwrap<Instruction>(Inst);
3152 if (!Instr->getDbgMarker())
3153 return nullptr;
3154 auto I = Instr->getDbgMarker()->StoredDbgRecords.begin();
3155 if (I == Instr->getDbgMarker()->StoredDbgRecords.end())
3156 return nullptr;
3157 return wrap(&*I);
3158}
3159
3161 Instruction *Instr = unwrap<Instruction>(Inst);
3162 if (!Instr->getDbgMarker())
3163 return nullptr;
3164 auto I = Instr->getDbgMarker()->StoredDbgRecords.rbegin();
3165 if (I == Instr->getDbgMarker()->StoredDbgRecords.rend())
3166 return nullptr;
3167 return wrap(&*I);
3168}
3169
3173 if (++I == Record->getInstruction()->getDbgMarker()->StoredDbgRecords.end())
3174 return nullptr;
3175 return wrap(&*I);
3176}
3177
3181 if (I == Record->getInstruction()->getDbgMarker()->StoredDbgRecords.begin())
3182 return nullptr;
3183 return wrap(&*--I);
3184}
3185
3189
3193 return LLVMDbgRecordLabel;
3195 assert(VariableRecord && "unexpected record");
3196 if (VariableRecord->isDbgDeclare())
3197 return LLVMDbgRecordDeclare;
3198 if (VariableRecord->isDbgValue())
3199 return LLVMDbgRecordValue;
3200 assert(VariableRecord->isDbgAssign() && "unexpected record");
3201 return LLVMDbgRecordAssign;
3202}
3203
3205 unsigned OpIdx) {
3206 return wrap(unwrap<DbgVariableRecord>(Rec)->getValue(OpIdx));
3207}
3208
3212
3216
3218 if (FuncletPadInst *FPI = dyn_cast<FuncletPadInst>(unwrap(Instr))) {
3219 return FPI->arg_size();
3220 }
3221 return unwrap<CallBase>(Instr)->arg_size();
3222}
3223
3224/*--.. Call and invoke instructions ........................................--*/
3225
3227 return unwrap<CallBase>(Instr)->getCallingConv();
3228}
3229
3231 return unwrap<CallBase>(Instr)->setCallingConv(
3232 static_cast<CallingConv::ID>(CC));
3233}
3234
3236 unsigned align) {
3237 auto *Call = unwrap<CallBase>(Instr);
3238 Attribute AlignAttr =
3240 Call->addAttributeAtIndex(Idx, AlignAttr);
3241}
3242
3245 unwrap<CallBase>(C)->addAttributeAtIndex(Idx, unwrap(A));
3246}
3247
3249 LLVMAttributeIndex Idx) {
3250 auto *Call = unwrap<CallBase>(C);
3251 auto AS = Call->getAttributes().getAttributes(Idx);
3252 return AS.getNumAttributes();
3253}
3254
3256 LLVMAttributeRef *Attrs) {
3257 auto *Call = unwrap<CallBase>(C);
3258 auto AS = Call->getAttributes().getAttributes(Idx);
3259 for (auto A : AS)
3260 *Attrs++ = wrap(A);
3261}
3262
3265 unsigned KindID) {
3266 return wrap(unwrap<CallBase>(C)->getAttributeAtIndex(
3267 Idx, (Attribute::AttrKind)KindID));
3268}
3269
3272 const char *K, unsigned KLen) {
3273 return wrap(
3274 unwrap<CallBase>(C)->getAttributeAtIndex(Idx, StringRef(K, KLen)));
3275}
3276
3278 unsigned KindID) {
3279 unwrap<CallBase>(C)->removeAttributeAtIndex(Idx, (Attribute::AttrKind)KindID);
3280}
3281
3283 const char *K, unsigned KLen) {
3284 unwrap<CallBase>(C)->removeAttributeAtIndex(Idx, StringRef(K, KLen));
3285}
3286
3288 return wrap(unwrap<CallBase>(Instr)->getCalledOperand());
3289}
3290
3292 return wrap(unwrap<CallBase>(Instr)->getFunctionType());
3293}
3294
3296 return unwrap<CallBase>(C)->getNumOperandBundles();
3297}
3298
3300 unsigned Index) {
3301 return wrap(
3302 new OperandBundleDef(unwrap<CallBase>(C)->getOperandBundleAt(Index)));
3303}
3304
3305/*--.. Operations on call instructions (only) ..............................--*/
3306
3308 return unwrap<CallInst>(Call)->isTailCall();
3309}
3310
3312 unwrap<CallInst>(Call)->setTailCall(isTailCall);
3313}
3314
3318
3322
3323/*--.. Operations on invoke instructions (only) ............................--*/
3324
3326 return wrap(unwrap<InvokeInst>(Invoke)->getNormalDest());
3327}
3328
3331 return wrap(CRI->getUnwindDest());
3332 } else if (CatchSwitchInst *CSI = dyn_cast<CatchSwitchInst>(unwrap(Invoke))) {
3333 return wrap(CSI->getUnwindDest());
3334 }
3335 return wrap(unwrap<InvokeInst>(Invoke)->getUnwindDest());
3336}
3337
3339 unwrap<InvokeInst>(Invoke)->setNormalDest(unwrap(B));
3340}
3341
3344 return CRI->setUnwindDest(unwrap(B));
3345 } else if (CatchSwitchInst *CSI = dyn_cast<CatchSwitchInst>(unwrap(Invoke))) {
3346 return CSI->setUnwindDest(unwrap(B));
3347 }
3348 unwrap<InvokeInst>(Invoke)->setUnwindDest(unwrap(B));
3349}
3350
3352 return wrap(unwrap<CallBrInst>(CallBr)->getDefaultDest());
3353}
3354
3356 return unwrap<CallBrInst>(CallBr)->getNumIndirectDests();
3357}
3358
3360 return wrap(unwrap<CallBrInst>(CallBr)->getIndirectDest(Idx));
3361}
3362
3363/*--.. Operations on terminators ...........................................--*/
3364
3366 return unwrap<Instruction>(Term)->getNumSuccessors();
3367}
3368
3370 return wrap(unwrap<Instruction>(Term)->getSuccessor(i));
3371}
3372
3374 return unwrap<Instruction>(Term)->setSuccessor(i, unwrap(block));
3375}
3376
3377/*--.. Operations on branch instructions (only) ............................--*/
3378
3382
3386
3388 return unwrap<CondBrInst>(Branch)->setCondition(unwrap(Cond));
3389}
3390
3391/*--.. Operations on switch instructions (only) ............................--*/
3392
3394 return wrap(unwrap<SwitchInst>(Switch)->getDefaultDest());
3395}
3396
3398 assert(i > 0 && i <= unwrap<SwitchInst>(Switch)->getNumCases());
3399 auto It = unwrap<SwitchInst>(Switch)->case_begin() + (i - 1);
3400 return wrap(It->getCaseValue());
3401}
3402
3403void LLVMSetSwitchCaseValue(LLVMValueRef Switch, unsigned i,
3404 LLVMValueRef CaseValue) {
3405 assert(i > 0 && i <= unwrap<SwitchInst>(Switch)->getNumCases());
3406 auto It = unwrap<SwitchInst>(Switch)->case_begin() + (i - 1);
3407 It->setValue(unwrap<ConstantInt>(CaseValue));
3408}
3409
3410/*--.. Operations on alloca instructions (only) ............................--*/
3411
3413 return wrap(unwrap<AllocaInst>(Alloca)->getAllocatedType());
3414}
3415
3416/*--.. Operations on gep instructions (only) ...............................--*/
3417
3419 return unwrap<GEPOperator>(GEP)->isInBounds();
3420}
3421
3423 return unwrap<GetElementPtrInst>(GEP)->setIsInBounds(InBounds);
3424}
3425
3429
3434
3439
3440/*--.. Operations on phi nodes .............................................--*/
3441
3442void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues,
3443 LLVMBasicBlockRef *IncomingBlocks, unsigned Count) {
3444 PHINode *PhiVal = unwrap<PHINode>(PhiNode);
3445 for (unsigned I = 0; I != Count; ++I)
3446 PhiVal->addIncoming(unwrap(IncomingValues[I]), unwrap(IncomingBlocks[I]));
3447}
3448
3450 return unwrap<PHINode>(PhiNode)->getNumIncomingValues();
3451}
3452
3454 return wrap(unwrap<PHINode>(PhiNode)->getIncomingValue(Index));
3455}
3456
3458 return wrap(unwrap<PHINode>(PhiNode)->getIncomingBlock(Index));
3459}
3460
3461/*--.. Operations on extractvalue and insertvalue nodes ....................--*/
3462
3464 auto *I = unwrap(Inst);
3465 if (auto *GEP = dyn_cast<GEPOperator>(I))
3466 return GEP->getNumIndices();
3467 if (auto *EV = dyn_cast<ExtractValueInst>(I))
3468 return EV->getNumIndices();
3469 if (auto *IV = dyn_cast<InsertValueInst>(I))
3470 return IV->getNumIndices();
3472 "LLVMGetNumIndices applies only to extractvalue and insertvalue!");
3473}
3474
3475const unsigned *LLVMGetIndices(LLVMValueRef Inst) {
3476 auto *I = unwrap(Inst);
3477 if (auto *EV = dyn_cast<ExtractValueInst>(I))
3478 return EV->getIndices().data();
3479 if (auto *IV = dyn_cast<InsertValueInst>(I))
3480 return IV->getIndices().data();
3482 "LLVMGetIndices applies only to extractvalue and insertvalue!");
3483}
3484
3485
3486/*===-- Instruction builders ----------------------------------------------===*/
3487
3488/// If the IRBuilder is created via LLVMCreateBuilderInContext(), the actual
3489/// creation is delayed until the insertion point is first set using
3490/// LLVMPositionBuilder() or similar, at which point we can use the Module of
3491/// the insertion point.
3493 std::optional<IRBuilder<>> Builder;
3494
3495 DelayedIRBuilder() = default;
3497 Builder.emplace(M);
3498 Builder->disableGEPCanonicalization();
3499 }
3500
3502 if (Builder)
3503 return;
3504
3505 if (BB) {
3506 if (Function *F = BB->getParent()) {
3507 if (Module *M = F->getParent()) {
3508 Builder.emplace(*M);
3509 Builder->disableGEPCanonicalization();
3510 return;
3511 }
3512 }
3513 }
3514
3516 "Cannot set insertion point that is not connected to a Module for a "
3517 "builder that has no known Module. Use LLVMCreateBuilderForModule "
3518 "instead of LLVMCreateBuilderInContext.");
3519 }
3520};
3521
3523 return reinterpret_cast<LLVMBuilderRef>(B);
3524}
3525
3527 return reinterpret_cast<DelayedIRBuilder *>(Ref);
3528}
3529
3532 if (!DB->Builder)
3534 "Cannot use Builder without known module. "
3535 "Use LLVMCreateBuilderForModule instead of LLVMCreateBuilderInContext, "
3536 "or make sure that the insertion point is set first.");
3537 return &*DB->Builder;
3538}
3539
3543
3549
3553
3555 Instruction *Instr, bool BeforeDbgRecords) {
3556 BasicBlock::iterator I = Instr ? Instr->getIterator() : Block->end();
3557 I.setHeadBit(BeforeDbgRecords);
3558 DB->initUsingInsertionBlock(I.getNodeParent());
3559 DB->Builder->SetInsertPoint(I);
3560}
3561
3567
3574
3577 return LLVMPositionBuilderImpl(unwrapDelayed(Builder), I->getParent(), I,
3578 false);
3579}
3580
3582 LLVMValueRef Instr) {
3584 return LLVMPositionBuilderImpl(unwrapDelayed(Builder), I->getParent(), I,
3585 true);
3586}
3587
3589 BasicBlock *BB = unwrap(Block);
3590 return LLVMPositionBuilderImpl(unwrapDelayed(Builder), BB, nullptr, false);
3591}
3592
3594 return wrap(unwrap(Builder)->GetInsertBlock());
3595}
3596
3598 unwrap(Builder)->ClearInsertionPoint();
3599}
3600
3602 unwrap(Builder)->Insert(unwrap<Instruction>(Instr));
3603}
3604
3606 const char *Name) {
3607 unwrap(Builder)->Insert(unwrap<Instruction>(Instr), Name);
3608}
3609
3611 delete unwrapDelayed(Builder);
3612}
3613
3614/*--.. Metadata builders ...................................................--*/
3615
3617 return wrap(unwrap(Builder)->getCurrentDebugLocation().getAsMDNode());
3618}
3619
3621 if (Loc)
3622 unwrap(Builder)->SetCurrentDebugLocation(DebugLoc(unwrap<DILocation>(Loc)));
3623 else
3624 unwrap(Builder)->SetCurrentDebugLocation(DebugLoc());
3625}
3626
3628 DILocation *Loc =
3629 L ? cast<DILocation>(unwrap<MetadataAsValue>(L)->getMetadata()) : nullptr;
3630 unwrap(Builder)->SetCurrentDebugLocation(DebugLoc(Loc));
3631}
3632
3634 LLVMContext &Context = unwrap(Builder)->getContext();
3636 Context, unwrap(Builder)->getCurrentDebugLocation().getAsMDNode()));
3637}
3638
3640 unwrap(Builder)->SetInstDebugLocation(unwrap<Instruction>(Inst));
3641}
3642
3644 unwrap(Builder)->SetInstDebugLocation(unwrap<Instruction>(Inst));
3645}
3646
3648 LLVMMetadataRef FPMathTag) {
3649
3650 unwrap(Builder)->setDefaultFPMathTag(FPMathTag
3651 ? unwrap<MDNode>(FPMathTag)
3652 : nullptr);
3653}
3654
3656 return wrap(&unwrap(Builder)->getContext());
3657}
3658
3660 return wrap(unwrap(Builder)->getDefaultFPMathTag());
3661}
3662
3663/*--.. Instruction builders ................................................--*/
3664
3666 return wrap(unwrap(B)->CreateRetVoid());
3667}
3668
3672
3674 unsigned N) {
3675 return wrap(unwrap(B)->CreateAggregateRet({unwrap(RetVals), N}));
3676}
3677
3679 return wrap(unwrap(B)->CreateBr(unwrap(Dest)));
3680}
3681
3684 return wrap(unwrap(B)->CreateCondBr(unwrap(If), unwrap(Then), unwrap(Else)));
3685}
3686
3688 LLVMBasicBlockRef Else, unsigned NumCases) {
3689 return wrap(unwrap(B)->CreateSwitch(unwrap(V), unwrap(Else), NumCases));
3690}
3691
3693 unsigned NumDests) {
3694 return wrap(unwrap(B)->CreateIndirectBr(unwrap(Addr), NumDests));
3695}
3696
3698 LLVMBasicBlockRef DefaultDest,
3699 LLVMBasicBlockRef *IndirectDests,
3700 unsigned NumIndirectDests, LLVMValueRef *Args,
3701 unsigned NumArgs, LLVMOperandBundleRef *Bundles,
3702 unsigned NumBundles, const char *Name) {
3703
3705 for (auto *Bundle : ArrayRef(Bundles, NumBundles)) {
3706 OperandBundleDef *OB = unwrap(Bundle);
3707 OBs.push_back(*OB);
3708 }
3709
3710 return wrap(unwrap(B)->CreateCallBr(
3711 unwrap<FunctionType>(Ty), unwrap(Fn), unwrap(DefaultDest),
3712 ArrayRef(unwrap(IndirectDests), NumIndirectDests),
3713 ArrayRef<Value *>(unwrap(Args), NumArgs), OBs, Name));
3714}
3715
3717 LLVMValueRef *Args, unsigned NumArgs,
3719 const char *Name) {
3720 return wrap(unwrap(B)->CreateInvoke(unwrap<FunctionType>(Ty), unwrap(Fn),
3721 unwrap(Then), unwrap(Catch),
3722 ArrayRef(unwrap(Args), NumArgs), Name));
3723}
3724
3727 unsigned NumArgs, LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch,
3728 LLVMOperandBundleRef *Bundles, unsigned NumBundles, const char *Name) {
3730 for (auto *Bundle : ArrayRef(Bundles, NumBundles)) {
3731 OperandBundleDef *OB = unwrap(Bundle);
3732 OBs.push_back(*OB);
3733 }
3734 return wrap(unwrap(B)->CreateInvoke(
3735 unwrap<FunctionType>(Ty), unwrap(Fn), unwrap(Then), unwrap(Catch),
3736 ArrayRef(unwrap(Args), NumArgs), OBs, Name));
3737}
3738
3740 LLVMValueRef PersFn, unsigned NumClauses,
3741 const char *Name) {
3742 // The personality used to live on the landingpad instruction, but now it
3743 // lives on the parent function. For compatibility, take the provided
3744 // personality and put it on the parent function.
3745 if (PersFn)
3746 unwrap(B)->GetInsertBlock()->getParent()->setPersonalityFn(
3747 unwrap<Function>(PersFn));
3748 return wrap(unwrap(B)->CreateLandingPad(unwrap(Ty), NumClauses, Name));
3749}
3750
3752 LLVMValueRef *Args, unsigned NumArgs,
3753 const char *Name) {
3754 return wrap(unwrap(B)->CreateCatchPad(unwrap(ParentPad),
3755 ArrayRef(unwrap(Args), NumArgs), Name));
3756}
3757
3759 LLVMValueRef *Args, unsigned NumArgs,
3760 const char *Name) {
3761 if (ParentPad == nullptr) {
3763 ParentPad = wrap(Constant::getNullValue(Ty));
3764 }
3765 return wrap(unwrap(B)->CreateCleanupPad(
3766 unwrap(ParentPad), ArrayRef(unwrap(Args), NumArgs), Name));
3767}
3768
3770 return wrap(unwrap(B)->CreateResume(unwrap(Exn)));
3771}
3772
3774 LLVMBasicBlockRef UnwindBB,
3775 unsigned NumHandlers, const char *Name) {
3776 if (ParentPad == nullptr) {
3778 ParentPad = wrap(Constant::getNullValue(Ty));
3779 }
3780 return wrap(unwrap(B)->CreateCatchSwitch(unwrap(ParentPad), unwrap(UnwindBB),
3781 NumHandlers, Name));
3782}
3783
3785 LLVMBasicBlockRef BB) {
3786 return wrap(unwrap(B)->CreateCatchRet(unwrap<CatchPadInst>(CatchPad),
3787 unwrap(BB)));
3788}
3789
3791 LLVMBasicBlockRef BB) {
3792 return wrap(unwrap(B)->CreateCleanupRet(unwrap<CleanupPadInst>(CatchPad),
3793 unwrap(BB)));
3794}
3795
3797 return wrap(unwrap(B)->CreateUnreachable());
3798}
3799
3801 LLVMBasicBlockRef Dest) {
3802 unwrap<SwitchInst>(Switch)->addCase(unwrap<ConstantInt>(OnVal), unwrap(Dest));
3803}
3804
3806 unwrap<IndirectBrInst>(IndirectBr)->addDestination(unwrap(Dest));
3807}
3808
3809unsigned LLVMGetNumClauses(LLVMValueRef LandingPad) {
3810 return unwrap<LandingPadInst>(LandingPad)->getNumClauses();
3811}
3812
3813LLVMValueRef LLVMGetClause(LLVMValueRef LandingPad, unsigned Idx) {
3814 return wrap(unwrap<LandingPadInst>(LandingPad)->getClause(Idx));
3815}
3816
3817void LLVMAddClause(LLVMValueRef LandingPad, LLVMValueRef ClauseVal) {
3818 unwrap<LandingPadInst>(LandingPad)->addClause(unwrap<Constant>(ClauseVal));
3819}
3820
3822 return unwrap<LandingPadInst>(LandingPad)->isCleanup();
3823}
3824
3825void LLVMSetCleanup(LLVMValueRef LandingPad, LLVMBool Val) {
3826 unwrap<LandingPadInst>(LandingPad)->setCleanup(Val);
3827}
3828
3830 unwrap<CatchSwitchInst>(CatchSwitch)->addHandler(unwrap(Dest));
3831}
3832
3833unsigned LLVMGetNumHandlers(LLVMValueRef CatchSwitch) {
3834 return unwrap<CatchSwitchInst>(CatchSwitch)->getNumHandlers();
3835}
3836
3837void LLVMGetHandlers(LLVMValueRef CatchSwitch, LLVMBasicBlockRef *Handlers) {
3838 CatchSwitchInst *CSI = unwrap<CatchSwitchInst>(CatchSwitch);
3839 for (const BasicBlock *H : CSI->handlers())
3840 *Handlers++ = wrap(H);
3841}
3842
3844 return wrap(unwrap<CatchPadInst>(CatchPad)->getCatchSwitch());
3845}
3846
3848 unwrap<CatchPadInst>(CatchPad)
3849 ->setCatchSwitch(unwrap<CatchSwitchInst>(CatchSwitch));
3850}
3851
3852/*--.. Funclets ...........................................................--*/
3853
3855 return wrap(unwrap<FuncletPadInst>(Funclet)->getArgOperand(i));
3856}
3857
3858void LLVMSetArgOperand(LLVMValueRef Funclet, unsigned i, LLVMValueRef value) {
3859 unwrap<FuncletPadInst>(Funclet)->setArgOperand(i, unwrap(value));
3860}
3861
3862/*--.. Arithmetic ..........................................................--*/
3863
3865 FastMathFlags NewFMF;
3866 NewFMF.setAllowReassoc((FMF & LLVMFastMathAllowReassoc) != 0);
3867 NewFMF.setNoNaNs((FMF & LLVMFastMathNoNaNs) != 0);
3868 NewFMF.setNoInfs((FMF & LLVMFastMathNoInfs) != 0);
3869 NewFMF.setNoSignedZeros((FMF & LLVMFastMathNoSignedZeros) != 0);
3871 NewFMF.setAllowContract((FMF & LLVMFastMathAllowContract) != 0);
3872 NewFMF.setApproxFunc((FMF & LLVMFastMathApproxFunc) != 0);
3873
3874 return NewFMF;
3875}
3876
3879 if (FMF.allowReassoc())
3880 NewFMF |= LLVMFastMathAllowReassoc;
3881 if (FMF.noNaNs())
3882 NewFMF |= LLVMFastMathNoNaNs;
3883 if (FMF.noInfs())
3884 NewFMF |= LLVMFastMathNoInfs;
3885 if (FMF.noSignedZeros())
3886 NewFMF |= LLVMFastMathNoSignedZeros;
3887 if (FMF.allowReciprocal())
3889 if (FMF.allowContract())
3890 NewFMF |= LLVMFastMathAllowContract;
3891 if (FMF.approxFunc())
3892 NewFMF |= LLVMFastMathApproxFunc;
3893
3894 return NewFMF;
3895}
3896
3898 const char *Name) {
3899 return wrap(unwrap(B)->CreateAdd(unwrap(LHS), unwrap(RHS), Name));
3900}
3901
3903 const char *Name) {
3904 return wrap(unwrap(B)->CreateNSWAdd(unwrap(LHS), unwrap(RHS), Name));
3905}
3906
3908 const char *Name) {
3909 return wrap(unwrap(B)->CreateNUWAdd(unwrap(LHS), unwrap(RHS), Name));
3910}
3911
3913 const char *Name) {
3914 return wrap(unwrap(B)->CreateFAdd(unwrap(LHS), unwrap(RHS), Name));
3915}
3916
3918 const char *Name) {
3919 return wrap(unwrap(B)->CreateSub(unwrap(LHS), unwrap(RHS), Name));
3920}
3921
3923 const char *Name) {
3924 return wrap(unwrap(B)->CreateNSWSub(unwrap(LHS), unwrap(RHS), Name));
3925}
3926
3928 const char *Name) {
3929 return wrap(unwrap(B)->CreateNUWSub(unwrap(LHS), unwrap(RHS), Name));
3930}
3931
3933 const char *Name) {
3934 return wrap(unwrap(B)->CreateFSub(unwrap(LHS), unwrap(RHS), Name));
3935}
3936
3938 const char *Name) {
3939 return wrap(unwrap(B)->CreateMul(unwrap(LHS), unwrap(RHS), Name));
3940}
3941
3943 const char *Name) {
3944 return wrap(unwrap(B)->CreateNSWMul(unwrap(LHS), unwrap(RHS), Name));
3945}
3946
3948 const char *Name) {
3949 return wrap(unwrap(B)->CreateNUWMul(unwrap(LHS), unwrap(RHS), Name));
3950}
3951
3953 const char *Name) {
3954 return wrap(unwrap(B)->CreateFMul(unwrap(LHS), unwrap(RHS), Name));
3955}
3956
3958 const char *Name) {
3959 return wrap(unwrap(B)->CreateUDiv(unwrap(LHS), unwrap(RHS), Name));
3960}
3961
3963 LLVMValueRef RHS, const char *Name) {
3964 return wrap(unwrap(B)->CreateExactUDiv(unwrap(LHS), unwrap(RHS), Name));
3965}
3966
3968 const char *Name) {
3969 return wrap(unwrap(B)->CreateSDiv(unwrap(LHS), unwrap(RHS), Name));
3970}
3971
3973 LLVMValueRef RHS, const char *Name) {
3974 return wrap(unwrap(B)->CreateExactSDiv(unwrap(LHS), unwrap(RHS), Name));
3975}
3976
3978 const char *Name) {
3979 return wrap(unwrap(B)->CreateFDiv(unwrap(LHS), unwrap(RHS), Name));
3980}
3981
3983 const char *Name) {
3984 return wrap(unwrap(B)->CreateURem(unwrap(LHS), unwrap(RHS), Name));
3985}
3986
3988 const char *Name) {
3989 return wrap(unwrap(B)->CreateSRem(unwrap(LHS), unwrap(RHS), Name));
3990}
3991
3993 const char *Name) {
3994 return wrap(unwrap(B)->CreateFRem(unwrap(LHS), unwrap(RHS), Name));
3995}
3996
3998 const char *Name) {
3999 return wrap(unwrap(B)->CreateShl(unwrap(LHS), unwrap(RHS), Name));
4000}
4001
4003 const char *Name) {
4004 return wrap(unwrap(B)->CreateLShr(unwrap(LHS), unwrap(RHS), Name));
4005}
4006
4008 const char *Name) {
4009 return wrap(unwrap(B)->CreateAShr(unwrap(LHS), unwrap(RHS), Name));
4010}
4011
4013 const char *Name) {
4014 return wrap(unwrap(B)->CreateAnd(unwrap(LHS), unwrap(RHS), Name));
4015}
4016
4018 const char *Name) {
4019 return wrap(unwrap(B)->CreateOr(unwrap(LHS), unwrap(RHS), Name));
4020}
4021
4023 const char *Name) {
4024 return wrap(unwrap(B)->CreateXor(unwrap(LHS), unwrap(RHS), Name));
4025}
4026
4033
4035 return wrap(unwrap(B)->CreateNeg(unwrap(V), Name));
4036}
4037
4039 const char *Name) {
4040 return wrap(unwrap(B)->CreateNSWNeg(unwrap(V), Name));
4041}
4042
4044 const char *Name) {
4045 Value *Neg = unwrap(B)->CreateNeg(unwrap(V), Name);
4046 if (auto *I = dyn_cast<BinaryOperator>(Neg))
4047 I->setHasNoUnsignedWrap();
4048 return wrap(Neg);
4049}
4050
4052 return wrap(unwrap(B)->CreateFNeg(unwrap(V), Name));
4053}
4054
4056 return wrap(unwrap(B)->CreateNot(unwrap(V), Name));
4057}
4058
4060 Value *P = unwrap<Value>(ArithInst);
4061 return cast<Instruction>(P)->hasNoUnsignedWrap();
4062}
4063
4064void LLVMSetNUW(LLVMValueRef ArithInst, LLVMBool HasNUW) {
4065 Value *P = unwrap<Value>(ArithInst);
4066 cast<Instruction>(P)->setHasNoUnsignedWrap(HasNUW);
4067}
4068
4070 Value *P = unwrap<Value>(ArithInst);
4071 return cast<Instruction>(P)->hasNoSignedWrap();
4072}
4073
4074void LLVMSetNSW(LLVMValueRef ArithInst, LLVMBool HasNSW) {
4075 Value *P = unwrap<Value>(ArithInst);
4076 cast<Instruction>(P)->setHasNoSignedWrap(HasNSW);
4077}
4078
4080 Value *P = unwrap<Value>(DivOrShrInst);
4081 return cast<Instruction>(P)->isExact();
4082}
4083
4084void LLVMSetExact(LLVMValueRef DivOrShrInst, LLVMBool IsExact) {
4085 Value *P = unwrap<Value>(DivOrShrInst);
4086 cast<Instruction>(P)->setIsExact(IsExact);
4087}
4088
4090 Value *P = unwrap<Value>(NonNegInst);
4091 return cast<Instruction>(P)->hasNonNeg();
4092}
4093
4094void LLVMSetNNeg(LLVMValueRef NonNegInst, LLVMBool IsNonNeg) {
4095 Value *P = unwrap<Value>(NonNegInst);
4096 cast<Instruction>(P)->setNonNeg(IsNonNeg);
4097}
4098
4100 Value *P = unwrap<Value>(FPMathInst);
4101 FastMathFlags FMF = cast<Instruction>(P)->getFastMathFlags();
4102 return mapToLLVMFastMathFlags(FMF);
4103}
4104
4106 Value *P = unwrap<Value>(FPMathInst);
4107 cast<Instruction>(P)->setFastMathFlags(mapFromLLVMFastMathFlags(FMF));
4108}
4109
4114
4116 Value *P = unwrap<Value>(Inst);
4117 return cast<PossiblyDisjointInst>(P)->isDisjoint();
4118}
4119
4121 Value *P = unwrap<Value>(Inst);
4122 cast<PossiblyDisjointInst>(P)->setIsDisjoint(IsDisjoint);
4123}
4124
4125/*--.. Memory ..............................................................--*/
4126
4128 const char *Name) {
4129 BasicBlock *BB = unwrap(B)->GetInsertBlock();
4130 const DataLayout &DL = BB->getDataLayout();
4131 Type *ITy = Type::getInt32Ty(BB->getContext());
4132 Value *AllocSize =
4133 unwrap(B)->CreateTypeSize(ITy, DL.getTypeAllocSize(unwrap(Ty)));
4134 return wrap(unwrap(B)->CreateMalloc(ITy, AllocSize, nullptr, nullptr, Name));
4135}
4136
4138 LLVMValueRef Val, const char *Name) {
4139 BasicBlock *BB = unwrap(B)->GetInsertBlock();
4140 const DataLayout &DL = BB->getDataLayout();
4141 Type *ITy = Type::getInt32Ty(BB->getContext());
4142 Value *AllocSize =
4143 unwrap(B)->CreateTypeSize(ITy, DL.getTypeAllocSize(unwrap(Ty)));
4144 return wrap(
4145 unwrap(B)->CreateMalloc(ITy, AllocSize, unwrap(Val), nullptr, Name));
4146}
4147
4149 LLVMValueRef Val, LLVMValueRef Len,
4150 unsigned Align) {
4151 return wrap(unwrap(B)->CreateMemSet(unwrap(Ptr), unwrap(Val), unwrap(Len),
4152 MaybeAlign(Align)));
4153}
4154
4156 LLVMValueRef Dst, unsigned DstAlign,
4157 LLVMValueRef Src, unsigned SrcAlign,
4159 return wrap(unwrap(B)->CreateMemCpy(unwrap(Dst), MaybeAlign(DstAlign),
4160 unwrap(Src), MaybeAlign(SrcAlign),
4161 unwrap(Size)));
4162}
4163
4165 LLVMValueRef Dst, unsigned DstAlign,
4166 LLVMValueRef Src, unsigned SrcAlign,
4168 return wrap(unwrap(B)->CreateMemMove(unwrap(Dst), MaybeAlign(DstAlign),
4169 unwrap(Src), MaybeAlign(SrcAlign),
4170 unwrap(Size)));
4171}
4172
4174 const char *Name) {
4175 return wrap(unwrap(B)->CreateAlloca(unwrap(Ty), nullptr, Name));
4176}
4177
4179 LLVMValueRef Val, const char *Name) {
4180 return wrap(unwrap(B)->CreateAlloca(unwrap(Ty), unwrap(Val), Name));
4181}
4182
4184 return wrap(unwrap(B)->CreateFree(unwrap(PointerVal)));
4185}
4186
4188 LLVMValueRef PointerVal, const char *Name) {
4189 return wrap(unwrap(B)->CreateLoad(unwrap(Ty), unwrap(PointerVal), Name));
4190}
4191
4193 LLVMValueRef PointerVal) {
4194 return wrap(unwrap(B)->CreateStore(unwrap(Val), unwrap(PointerVal)));
4195}
4196
4212
4228
4230 switch (BinOp) {
4262 }
4263
4264 llvm_unreachable("Invalid LLVMAtomicRMWBinOp value!");
4265}
4266
4268 switch (BinOp) {
4300 default: break;
4301 }
4302
4303 llvm_unreachable("Invalid AtomicRMWBinOp value!");
4304}
4305
4307 LLVMBool isSingleThread, const char *Name) {
4308 return wrap(
4309 unwrap(B)->CreateFence(mapFromLLVMOrdering(Ordering),
4310 isSingleThread ? SyncScope::SingleThread
4312 Name));
4313}
4314
4316 LLVMAtomicOrdering Ordering, unsigned SSID,
4317 const char *Name) {
4318 return wrap(
4319 unwrap(B)->CreateFence(mapFromLLVMOrdering(Ordering), SSID, Name));
4320}
4321
4323 LLVMValueRef Pointer, LLVMValueRef *Indices,
4324 unsigned NumIndices, const char *Name) {
4325 ArrayRef<Value *> IdxList(unwrap(Indices), NumIndices);
4326 return wrap(unwrap(B)->CreateGEP(unwrap(Ty), unwrap(Pointer), IdxList, Name));
4327}
4328
4330 LLVMValueRef Pointer, LLVMValueRef *Indices,
4331 unsigned NumIndices, const char *Name) {
4332 ArrayRef<Value *> IdxList(unwrap(Indices), NumIndices);
4333 return wrap(
4334 unwrap(B)->CreateInBoundsGEP(unwrap(Ty), unwrap(Pointer), IdxList, Name));
4335}
4336
4338 LLVMValueRef Pointer,
4339 LLVMValueRef *Indices,
4340 unsigned NumIndices, const char *Name,
4341 LLVMGEPNoWrapFlags NoWrapFlags) {
4342 ArrayRef<Value *> IdxList(unwrap(Indices), NumIndices);
4343 return wrap(unwrap(B)->CreateGEP(unwrap(Ty), unwrap(Pointer), IdxList, Name,
4344 mapFromLLVMGEPNoWrapFlags(NoWrapFlags)));
4345}
4346
4348 LLVMValueRef Pointer, unsigned Idx,
4349 const char *Name) {
4350 return wrap(
4351 unwrap(B)->CreateStructGEP(unwrap(Ty), unwrap(Pointer), Idx, Name));
4352}
4353
4355 const char *Name) {
4356 return wrap(unwrap(B)->CreateGlobalString(Str, Name));
4357}
4358
4360 const char *Name) {
4361 return wrap(unwrap(B)->CreateGlobalString(Str, Name));
4362}
4363
4365 return cast<Instruction>(unwrap(Inst))->isVolatile();
4366}
4367
4368void LLVMSetVolatile(LLVMValueRef MemAccessInst, LLVMBool isVolatile) {
4369 Value *P = unwrap(MemAccessInst);
4370 if (LoadInst *LI = dyn_cast<LoadInst>(P))
4371 return LI->setVolatile(isVolatile);
4373 return SI->setVolatile(isVolatile);
4375 return AI->setVolatile(isVolatile);
4376 return cast<AtomicCmpXchgInst>(P)->setVolatile(isVolatile);
4377}
4378
4380 return unwrap<AtomicCmpXchgInst>(CmpXchgInst)->isWeak();
4381}
4382
4383void LLVMSetWeak(LLVMValueRef CmpXchgInst, LLVMBool isWeak) {
4384 return unwrap<AtomicCmpXchgInst>(CmpXchgInst)->setWeak(isWeak);
4385}
4386
4388 Value *P = unwrap(MemAccessInst);
4390 if (LoadInst *LI = dyn_cast<LoadInst>(P))
4391 O = LI->getOrdering();
4392 else if (StoreInst *SI = dyn_cast<StoreInst>(P))
4393 O = SI->getOrdering();
4394 else if (FenceInst *FI = dyn_cast<FenceInst>(P))
4395 O = FI->getOrdering();
4396 else
4397 O = cast<AtomicRMWInst>(P)->getOrdering();
4398 return mapToLLVMOrdering(O);
4399}
4400
4401void LLVMSetOrdering(LLVMValueRef MemAccessInst, LLVMAtomicOrdering Ordering) {
4402 Value *P = unwrap(MemAccessInst);
4403 AtomicOrdering O = mapFromLLVMOrdering(Ordering);
4404
4405 if (LoadInst *LI = dyn_cast<LoadInst>(P))
4406 return LI->setOrdering(O);
4407 else if (FenceInst *FI = dyn_cast<FenceInst>(P))
4408 return FI->setOrdering(O);
4409 else if (AtomicRMWInst *ARWI = dyn_cast<AtomicRMWInst>(P))
4410 return ARWI->setOrdering(O);
4411 return cast<StoreInst>(P)->setOrdering(O);
4412}
4413
4417
4419 unwrap<AtomicRMWInst>(Inst)->setOperation(mapFromLLVMRMWBinOp(BinOp));
4420}
4421
4422/*--.. Casts ...............................................................--*/
4423
4425 LLVMTypeRef DestTy, const char *Name) {
4426 return wrap(unwrap(B)->CreateTrunc(unwrap(Val), unwrap(DestTy), Name));
4427}
4428
4430 LLVMTypeRef DestTy, const char *Name) {
4431 return wrap(unwrap(B)->CreateZExt(unwrap(Val), unwrap(DestTy), Name));
4432}
4433
4435 LLVMTypeRef DestTy, const char *Name) {
4436 return wrap(unwrap(B)->CreateSExt(unwrap(Val), unwrap(DestTy), Name));
4437}
4438
4440 LLVMTypeRef DestTy, const char *Name) {
4441 return wrap(unwrap(B)->CreateFPToUI(unwrap(Val), unwrap(DestTy), Name));
4442}
4443
4445 LLVMTypeRef DestTy, const char *Name) {
4446 return wrap(unwrap(B)->CreateFPToSI(unwrap(Val), unwrap(DestTy), Name));
4447}
4448
4450 LLVMTypeRef DestTy, const char *Name) {
4451 return wrap(unwrap(B)->CreateUIToFP(unwrap(Val), unwrap(DestTy), Name));
4452}
4453
4455 LLVMTypeRef DestTy, const char *Name) {
4456 return wrap(unwrap(B)->CreateSIToFP(unwrap(Val), unwrap(DestTy), Name));
4457}
4458
4460 LLVMTypeRef DestTy, const char *Name) {
4461 return wrap(unwrap(B)->CreateFPTrunc(unwrap(Val), unwrap(DestTy), Name));
4462}
4463
4465 LLVMTypeRef DestTy, const char *Name) {
4466 return wrap(unwrap(B)->CreateFPExt(unwrap(Val), unwrap(DestTy), Name));
4467}
4468
4470 LLVMTypeRef DestTy, const char *Name) {
4471 return wrap(unwrap(B)->CreatePtrToInt(unwrap(Val), unwrap(DestTy), Name));
4472}
4473
4475 LLVMTypeRef DestTy, const char *Name) {
4476 return wrap(unwrap(B)->CreateIntToPtr(unwrap(Val), unwrap(DestTy), Name));
4477}
4478
4480 LLVMTypeRef DestTy, const char *Name) {
4481 return wrap(unwrap(B)->CreateBitCast(unwrap(Val), unwrap(DestTy), Name));
4482}
4483
4485 LLVMTypeRef DestTy, const char *Name) {
4486 return wrap(unwrap(B)->CreateAddrSpaceCast(unwrap(Val), unwrap(DestTy), Name));
4487}
4488
4490 LLVMTypeRef DestTy, const char *Name) {
4491 return wrap(unwrap(B)->CreateZExtOrBitCast(unwrap(Val), unwrap(DestTy),
4492 Name));
4493}
4494
4496 LLVMTypeRef DestTy, const char *Name) {
4497 return wrap(unwrap(B)->CreateSExtOrBitCast(unwrap(Val), unwrap(DestTy),
4498 Name));
4499}
4500
4502 LLVMTypeRef DestTy, const char *Name) {
4503 return wrap(unwrap(B)->CreateTruncOrBitCast(unwrap(Val), unwrap(DestTy),
4504 Name));
4505}
4506
4508 LLVMTypeRef DestTy, const char *Name) {
4509 return wrap(unwrap(B)->CreateCast(Instruction::CastOps(map_from_llvmopcode(Op)), unwrap(Val),
4510 unwrap(DestTy), Name));
4511}
4512
4514 LLVMTypeRef DestTy, const char *Name) {
4515 return wrap(unwrap(B)->CreatePointerCast(unwrap(Val), unwrap(DestTy), Name));
4516}
4517
4519 LLVMTypeRef DestTy, LLVMBool IsSigned,
4520 const char *Name) {
4521 return wrap(
4522 unwrap(B)->CreateIntCast(unwrap(Val), unwrap(DestTy), IsSigned, Name));
4523}
4524
4526 LLVMTypeRef DestTy, const char *Name) {
4527 return wrap(unwrap(B)->CreateIntCast(unwrap(Val), unwrap(DestTy),
4528 /*isSigned*/true, Name));
4529}
4530
4532 LLVMTypeRef DestTy, const char *Name) {
4533 return wrap(unwrap(B)->CreateFPCast(unwrap(Val), unwrap(DestTy), Name));
4534}
4535
4537 LLVMTypeRef DestTy, LLVMBool DestIsSigned) {
4539 unwrap(Src), SrcIsSigned, unwrap(DestTy), DestIsSigned));
4540}
4541
4542/*--.. Comparisons .........................................................--*/
4543
4546 const char *Name) {
4547 return wrap(unwrap(B)->CreateICmp(static_cast<ICmpInst::Predicate>(Op),
4548 unwrap(LHS), unwrap(RHS), Name));
4549}
4550
4553 const char *Name) {
4554 return wrap(unwrap(B)->CreateFCmp(static_cast<FCmpInst::Predicate>(Op),
4555 unwrap(LHS), unwrap(RHS), Name));
4556}
4557
4558/*--.. Miscellaneous instructions ..........................................--*/
4559
4561 return wrap(unwrap(B)->CreatePHI(unwrap(Ty), 0, Name));
4562}
4563
4565 LLVMValueRef *Args, unsigned NumArgs,
4566 const char *Name) {
4568 return wrap(unwrap(B)->CreateCall(FTy, unwrap(Fn),
4569 ArrayRef(unwrap(Args), NumArgs), Name));
4570}
4571
4574 LLVMValueRef Fn, LLVMValueRef *Args,
4575 unsigned NumArgs, LLVMOperandBundleRef *Bundles,
4576 unsigned NumBundles, const char *Name) {
4579 for (auto *Bundle : ArrayRef(Bundles, NumBundles)) {
4580 OperandBundleDef *OB = unwrap(Bundle);
4581 OBs.push_back(*OB);
4582 }
4583 return wrap(unwrap(B)->CreateCall(
4584 FTy, unwrap(Fn), ArrayRef(unwrap(Args), NumArgs), OBs, Name));
4585}
4586
4588 LLVMValueRef Then, LLVMValueRef Else,
4589 const char *Name) {
4590 return wrap(unwrap(B)->CreateSelect(unwrap(If), unwrap(Then), unwrap(Else),
4591 Name));
4592}
4593
4595 LLVMTypeRef Ty, const char *Name) {
4596 return wrap(unwrap(B)->CreateVAArg(unwrap(List), unwrap(Ty), Name));
4597}
4598
4600 LLVMValueRef Index, const char *Name) {
4601 return wrap(unwrap(B)->CreateExtractElement(unwrap(VecVal), unwrap(Index),
4602 Name));
4603}
4604
4606 LLVMValueRef EltVal, LLVMValueRef Index,
4607 const char *Name) {
4608 return wrap(unwrap(B)->CreateInsertElement(unwrap(VecVal), unwrap(EltVal),
4609 unwrap(Index), Name));
4610}
4611
4613 LLVMValueRef V2, LLVMValueRef Mask,
4614 const char *Name) {
4615 return wrap(unwrap(B)->CreateShuffleVector(unwrap(V1), unwrap(V2),
4616 unwrap(Mask), Name));
4617}
4618
4620 unsigned Index, const char *Name) {
4621 return wrap(unwrap(B)->CreateExtractValue(unwrap(AggVal), Index, Name));
4622}
4623
4625 LLVMValueRef EltVal, unsigned Index,
4626 const char *Name) {
4627 return wrap(unwrap(B)->CreateInsertValue(unwrap(AggVal), unwrap(EltVal),
4628 Index, Name));
4629}
4630
4632 const char *Name) {
4633 return wrap(unwrap(B)->CreateFreeze(unwrap(Val), Name));
4634}
4635
4638 const char *Name) {
4639 return wrap(unwrap(B)->CreateBitInsert(unwrap(Base), unwrap(Val),
4640 unwrap(Offset), Name));
4641}
4642
4645 const char *Name) {
4646 return wrap(unwrap(B)->CreateBitExtract(unwrap(Ty), unwrap(Src),
4647 unwrap(Offset), Name));
4648}
4649
4651 const char *Name) {
4652 return wrap(unwrap(B)->CreateIsNull(unwrap(Val), Name));
4653}
4654
4656 const char *Name) {
4657 return wrap(unwrap(B)->CreateIsNotNull(unwrap(Val), Name));
4658}
4659
4662 const char *Name) {
4663 IRBuilderBase *Builder = unwrap(B);
4664 Value *Diff =
4665 Builder->CreatePtrDiff(unwrap(ElemTy), unwrap(LHS), unwrap(RHS), Name);
4666 return wrap(Builder->CreateSExtOrTrunc(Diff, Builder->getInt64Ty()));
4667}
4668
4670 LLVMValueRef PTR, LLVMValueRef Val,
4671 LLVMAtomicOrdering ordering,
4672 LLVMBool singleThread) {
4674 return wrap(unwrap(B)->CreateAtomicRMW(
4675 intop, unwrap(PTR), unwrap(Val), MaybeAlign(),
4676 mapFromLLVMOrdering(ordering),
4677 singleThread ? SyncScope::SingleThread : SyncScope::System));
4678}
4679
4682 LLVMValueRef PTR, LLVMValueRef Val,
4683 LLVMAtomicOrdering ordering,
4684 unsigned SSID) {
4686 return wrap(unwrap(B)->CreateAtomicRMW(intop, unwrap(PTR), unwrap(Val),
4687 MaybeAlign(),
4688 mapFromLLVMOrdering(ordering), SSID));
4689}
4690
4692 LLVMValueRef Cmp, LLVMValueRef New,
4693 LLVMAtomicOrdering SuccessOrdering,
4694 LLVMAtomicOrdering FailureOrdering,
4695 LLVMBool singleThread) {
4696
4697 return wrap(unwrap(B)->CreateAtomicCmpXchg(
4698 unwrap(Ptr), unwrap(Cmp), unwrap(New), MaybeAlign(),
4699 mapFromLLVMOrdering(SuccessOrdering),
4700 mapFromLLVMOrdering(FailureOrdering),
4701 singleThread ? SyncScope::SingleThread : SyncScope::System));
4702}
4703
4705 LLVMValueRef Cmp, LLVMValueRef New,
4706 LLVMAtomicOrdering SuccessOrdering,
4707 LLVMAtomicOrdering FailureOrdering,
4708 unsigned SSID) {
4709 return wrap(unwrap(B)->CreateAtomicCmpXchg(
4710 unwrap(Ptr), unwrap(Cmp), unwrap(New), MaybeAlign(),
4711 mapFromLLVMOrdering(SuccessOrdering),
4712 mapFromLLVMOrdering(FailureOrdering), SSID));
4713}
4714
4716 Value *P = unwrap(SVInst);
4718 return I->getShuffleMask().size();
4719}
4720
4721int LLVMGetMaskValue(LLVMValueRef SVInst, unsigned Elt) {
4722 Value *P = unwrap(SVInst);
4724 return I->getMaskValue(Elt);
4725}
4726
4728
4730 return unwrap<Instruction>(Inst)->isAtomic();
4731}
4732
4734 // Backwards compatibility: return false for non-atomic instructions
4735 Instruction *I = unwrap<Instruction>(AtomicInst);
4736 if (!I->isAtomic())
4737 return 0;
4738
4740}
4741
4743 // Backwards compatibility: ignore non-atomic instructions
4744 Instruction *I = unwrap<Instruction>(AtomicInst);
4745 if (!I->isAtomic())
4746 return;
4747
4749 setAtomicSyncScopeID(I, SSID);
4750}
4751
4753 Instruction *I = unwrap<Instruction>(AtomicInst);
4754 assert(I->isAtomic() && "Expected an atomic instruction");
4755 return *getAtomicSyncScopeID(I);
4756}
4757
4758void LLVMSetAtomicSyncScopeID(LLVMValueRef AtomicInst, unsigned SSID) {
4759 Instruction *I = unwrap<Instruction>(AtomicInst);
4760 assert(I->isAtomic() && "Expected an atomic instruction");
4761 setAtomicSyncScopeID(I, SSID);
4762}
4763
4765 Value *P = unwrap(CmpXchgInst);
4766 return mapToLLVMOrdering(cast<AtomicCmpXchgInst>(P)->getSuccessOrdering());
4767}
4768
4770 LLVMAtomicOrdering Ordering) {
4771 Value *P = unwrap(CmpXchgInst);
4772 AtomicOrdering O = mapFromLLVMOrdering(Ordering);
4773
4774 return cast<AtomicCmpXchgInst>(P)->setSuccessOrdering(O);
4775}
4776
4778 Value *P = unwrap(CmpXchgInst);
4779 return mapToLLVMOrdering(cast<AtomicCmpXchgInst>(P)->getFailureOrdering());
4780}
4781
4783 LLVMAtomicOrdering Ordering) {
4784 Value *P = unwrap(CmpXchgInst);
4785 AtomicOrdering O = mapFromLLVMOrdering(Ordering);
4786
4787 return cast<AtomicCmpXchgInst>(P)->setFailureOrdering(O);
4788}
4789
4790/*===-- Module providers --------------------------------------------------===*/
4791
4796
4800
4801
4802/*===-- Memory buffers ----------------------------------------------------===*/
4803
4805 const char *Path,
4806 LLVMMemoryBufferRef *OutMemBuf,
4807 char **OutMessage) {
4808
4810 if (std::error_code EC = MBOrErr.getError()) {
4811 *OutMessage = strdup(EC.message().c_str());
4812 return 1;
4813 }
4814 *OutMemBuf = wrap(MBOrErr.get().release());
4815 return 0;
4816}
4817
4819 char **OutMessage) {
4821 if (std::error_code EC = MBOrErr.getError()) {
4822 *OutMessage = strdup(EC.message().c_str());
4823 return 1;
4824 }
4825 *OutMemBuf = wrap(MBOrErr.get().release());
4826 return 0;
4827}
4828
4830 const char *InputData,
4831 size_t InputDataLength,
4832 const char *BufferName,
4833 LLVMBool RequiresNullTerminator) {
4834
4835 return wrap(MemoryBuffer::getMemBuffer(StringRef(InputData, InputDataLength),
4836 StringRef(BufferName),
4837 RequiresNullTerminator).release());
4838}
4839
4841 const char *InputData,
4842 size_t InputDataLength,
4843 const char *BufferName) {
4844
4845 return wrap(
4846 MemoryBuffer::getMemBufferCopy(StringRef(InputData, InputDataLength),
4847 StringRef(BufferName)).release());
4848}
4849
4851 return unwrap(MemBuf)->getBufferStart();
4852}
4853
4855 return unwrap(MemBuf)->getBufferSize();
4856}
4857
4859 delete unwrap(MemBuf);
4860}
4861
4862/*===-- Pass Manager ------------------------------------------------------===*/
4863
4867
4871
4876
4880
4884
4888
4892
4894 delete unwrap(PM);
4895}
4896
4897/*===-- Threading ------------------------------------------------------===*/
4898
4902
4905
4909
4910/*===-- Data Layout ----------------------------------------------------===*/
4911
4913 return wrap(&unwrap(M)->getDataLayout());
4914}
4915
4917 unwrap(M)->setDataLayout(*unwrap(DL));
4918}
4919
4921 return wrap(new DataLayout(StringRep));
4922}
4923
4925
4927 std::string StringRep = unwrap(TD)->getStringRepresentation();
4928 return strdup(StringRep.c_str());
4929}
4930
4934
4936 return unwrap(TD)->getPointerSize(0);
4937}
4938
4939unsigned LLVMPointerSizeForAS(LLVMTargetDataRef TD, unsigned AS) {
4940 return unwrap(TD)->getPointerSize(AS);
4941}
4942
4946
4948 return wrap(
4949 unwrap(TD)->getIntPtrType(*unwrap(getGlobalContextForCAPI()), AS));
4950}
4951
4955
4957 unsigned AS) {
4958 return wrap(unwrap(TD)->getIntPtrType(*unwrap(C), AS));
4959}
4960
4962 return unwrap(TD)->getTypeSizeInBits(unwrap(Ty));
4963}
4964
4966 return unwrap(TD)->getTypeStoreSize(unwrap(Ty));
4967}
4968
4970 return unwrap(TD)->getTypeAllocSize(unwrap(Ty));
4971}
4972
4974 return unwrap(TD)->getABITypeAlign(unwrap(Ty)).value();
4975}
4976
4978 return unwrap(TD)->getABITypeAlign(unwrap(Ty)).value();
4979}
4980
4982 return unwrap(TD)->getPrefTypeAlign(unwrap(Ty)).value();
4983}
4984
4986 LLVMValueRef GlobalVar) {
4987 return unwrap(TD)
4988 ->getPreferredAlign(unwrap<GlobalVariable>(GlobalVar))
4989 .value();
4990}
4991
4993 unsigned long long Offset) {
4994 StructType *STy = unwrap<StructType>(StructTy);
4995 return unwrap(TD)->getStructLayout(STy)->getElementContainingOffset(Offset);
4996}
4997
4999 LLVMTypeRef StructTy, unsigned Element) {
5000 StructType *STy = unwrap<StructType>(StructTy);
5001 return unwrap(TD)->getStructLayout(STy)->getElementOffset(Element);
5002}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
uint64_t uint64_t
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
always inline
This file contains the simple types necessary to represent the attributes associated with functions a...
static const Function * getParent(const Value *V)
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref)
#define LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_PUSH
Definition Compiler.h:276
#define LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_POP
Definition Compiler.h:277
#define LLVM_EXTENSION
LLVM_EXTENSION - Support compilers where we have a keyword to suppress pedantic diagnostics.
Definition Compiler.h:501
This file contains the declarations for the subclasses of Constant, which represent the different fla...
static uint64_t align(uint64_t Size)
DXIL Finalize Linkage
static char getTypeID(Type *Ty)
static Value * getCondition(Instruction *I)
#define op(i)
Hexagon Common GEP
Value * getPointer(Value *Ptr)
LLVMTypeRef LLVMFP128Type(void)
Definition Core.cpp:800
LLVMValueRef LLVMGetElementAsConstant(LLVMValueRef C, unsigned idx)
Definition Core.cpp:1734
LLVMTypeRef LLVMInt64Type(void)
Definition Core.cpp:744
static Module::ModFlagBehavior map_to_llvmModFlagBehavior(LLVMModuleFlagBehavior Behavior)
Definition Core.cpp:367
LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count, LLVMBool Packed)
Definition Core.cpp:1781
#define LLVM_DEFINE_VALUE_CAST(name)
Definition Core.cpp:1188
LLVMBasicBlockRef LLVMAppendBasicBlock(LLVMValueRef FnRef, const char *Name)
Definition Core.cpp:3031
LLVMTypeRef LLVMVoidType(void)
Definition Core.cpp:1003
static LLVMValueMetadataEntry * llvm_getMetadata(size_t *NumEntries, llvm::function_ref< void(MetadataEntries &)> AccessMD)
Definition Core.cpp:1160
static DelayedIRBuilder * unwrapDelayed(LLVMBuilderRef Ref)
Definition Core.cpp:3526
static GEPNoWrapFlags mapFromLLVMGEPNoWrapFlags(LLVMGEPNoWrapFlags GEPFlags)
Definition Core.cpp:1834
LLVMValueRef LLVMMDString(const char *Str, unsigned SLen)
Definition Core.cpp:1349
LLVMValueRef LLVMSizeOf(LLVMTypeRef Ty)
Definition Core.cpp:1870
static MDNode * extractMDNode(MetadataAsValue *MAV)
Definition Core.cpp:1136
SmallVectorImpl< std::pair< unsigned, MDNode * > > MetadataEntries
Definition Core.cpp:1158
static LLVMOpcode map_to_llvmopcode(int opcode)
Definition Core.cpp:1812
LLVMTypeRef LLVMBFloatType(void)
Definition Core.cpp:788
LLVMValueRef LLVMConstByteOfString(LLVMTypeRef ByteTy, const char Str[], uint8_t Radix)
Definition Core.cpp:1638
LLVMTypeRef LLVMInt32Type(void)
Definition Core.cpp:741
static LLVMFastMathFlags mapToLLVMFastMathFlags(FastMathFlags FMF)
Definition Core.cpp:3877
static FastMathFlags mapFromLLVMFastMathFlags(LLVMFastMathFlags FMF)
Definition Core.cpp:3864
LLVMTypeRef LLVMHalfType(void)
Definition Core.cpp:785
LLVMTypeRef LLVMIntType(unsigned NumBits)
Definition Core.cpp:750
LLVMTypeRef LLVMX86AMXType(void)
Definition Core.cpp:806
LLVMTypeRef LLVMIntPtrType(LLVMTargetDataRef TD)
Definition Core.cpp:4943
LLVMValueRef LLVMConstIntOfString(LLVMTypeRef IntTy, const char Str[], uint8_t Radix)
Definition Core.cpp:1614
LLVMBuilderRef LLVMCreateBuilderInContext(LLVMContextRef C)
Definition Core.cpp:3540
static void LLVMPositionBuilderImpl(DelayedIRBuilder *DB, BasicBlock *Block, Instruction *Instr, bool BeforeDbgRecords)
Definition Core.cpp:3554
LLVMTypeRef LLVMStructType(LLVMTypeRef *ElementTypes, unsigned ElementCount, LLVMBool Packed)
Definition Core.cpp:845
LLVMValueRef LLVMConstInBoundsGEP2(LLVMTypeRef Ty, LLVMValueRef ConstantVal, LLVMValueRef *ConstantIndices, unsigned NumIndices)
Definition Core.cpp:1942
static AtomicOrdering mapFromLLVMOrdering(LLVMAtomicOrdering Ordering)
Definition Core.cpp:4197
static Intrinsic::ID llvm_map_to_intrinsic_id(unsigned ID)
Definition Core.cpp:2622
static LLVMModuleFlagBehavior map_from_llvmModFlagBehavior(Module::ModFlagBehavior Behavior)
Definition Core.cpp:386
LLVMModuleRef LLVMModuleCreateWithName(const char *ModuleID)
Definition Core.cpp:303
static LLVMAtomicOrdering mapToLLVMOrdering(AtomicOrdering Ordering)
Definition Core.cpp:4213
LLVMValueRef LLVMAlignOf(LLVMTypeRef Ty)
Definition Core.cpp:1864
LLVMTypeRef LLVMX86FP80Type(void)
Definition Core.cpp:797
LLVMBasicBlockRef LLVMInsertBasicBlock(LLVMBasicBlockRef BBRef, const char *Name)
Definition Core.cpp:3042
LLVMValueRef LLVMBuildNUWNeg(LLVMBuilderRef B, LLVMValueRef V, const char *Name)
Definition Core.cpp:4043
static LLVMValueRef getMDNodeOperandImpl(LLVMContext &Context, const MDNode *N, unsigned Index)
Definition Core.cpp:1249
LLVMValueRef LLVMConstRealOfStringAndSize(LLVMTypeRef RealTy, const char Str[], unsigned SLen)
Definition Core.cpp:1658
LLVMTypeRef LLVMPPCFP128Type(void)
Definition Core.cpp:803
LLVMTypeRef LLVMFloatType(void)
Definition Core.cpp:791
static int map_from_llvmopcode(LLVMOpcode code)
Definition Core.cpp:1822
static LLVMAtomicRMWBinOp mapToLLVMRMWBinOp(AtomicRMWInst::BinOp BinOp)
Definition Core.cpp:4267
LLVMTypeRef LLVMLabelType(void)
Definition Core.cpp:1006
LLVMValueRef LLVMConstString(const char *Str, unsigned Length, LLVMBool DontNullTerminate)
Definition Core.cpp:1724
unsigned LLVMGetMDKindID(const char *Name, unsigned SLen)
Definition Core.cpp:160
LLVMTypeRef LLVMIntPtrTypeForAS(LLVMTargetDataRef TD, unsigned AS)
Definition Core.cpp:4947
LLVMTypeRef LLVMInt8Type(void)
Definition Core.cpp:735
LLVMTypeRef LLVMDoubleType(void)
Definition Core.cpp:794
LLVMValueRef LLVMConstByteOfStringAndSize(LLVMTypeRef ByteTy, const char Str[], size_t SLen, uint8_t Radix)
Definition Core.cpp:1644
LLVMTypeRef LLVMInt1Type(void)
Definition Core.cpp:732
LLVMBuilderRef LLVMCreateBuilder(void)
Definition Core.cpp:3544
LLVMTypeRef LLVMInt128Type(void)
Definition Core.cpp:747
LLVMValueRef LLVMConstGEPWithNoWrapFlags(LLVMTypeRef Ty, LLVMValueRef ConstantVal, LLVMValueRef *ConstantIndices, unsigned NumIndices, LLVMGEPNoWrapFlags NoWrapFlags)
Definition Core.cpp:1953
static AtomicRMWInst::BinOp mapFromLLVMRMWBinOp(LLVMAtomicRMWBinOp BinOp)
Definition Core.cpp:4229
LLVMValueRef LLVMIsABranchInst(LLVMValueRef Val)
Definition Core.cpp:1195
LLVMValueRef LLVMConstNUWNeg(LLVMValueRef ConstantVal)
Definition Core.cpp:1884
LLVMValueRef LLVMConstIntOfStringAndSize(LLVMTypeRef IntTy, const char Str[], unsigned SLen, uint8_t Radix)
Definition Core.cpp:1620
LLVMValueRef LLVMConstGEP2(LLVMTypeRef Ty, LLVMValueRef ConstantVal, LLVMValueRef *ConstantIndices, unsigned NumIndices)
Definition Core.cpp:1932
LLVMTypeRef LLVMInt16Type(void)
Definition Core.cpp:738
LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count)
Definition Core.cpp:1380
static LLVMContext & getGlobalContext()
Definition Core.cpp:97
static LLVMGEPNoWrapFlags mapToLLVMGEPNoWrapFlags(GEPNoWrapFlags GEPFlags)
Definition Core.cpp:1846
LLVMContextRef LLVMGetGlobalContext()
Definition Core.cpp:116
Module.h This file contains the declarations for the Module class.
static constexpr Value * getValue(Ty &ValueOrUse)
#define F(x, y, z)
Definition MD5.cpp:54
#define I(x, y, z)
Definition MD5.cpp:57
#define H(x, y, z)
Definition MD5.cpp:56
#define T
static constexpr StringLiteral Filename
#define P(N)
if(auto Err=PB.parsePassPipeline(MPM, Passes)) return wrap(std MPM run * Mod
SmallVector< MachineOperand, 4 > Cond
RISCVCC::CondCode CC
static BinaryOperator * CreateMul(Value *S1, Value *S2, const Twine &Name, BasicBlock::iterator InsertBefore, Value *FlagsOp)
static BinaryOperator * CreateAdd(Value *S1, Value *S2, const Twine &Name, BasicBlock::iterator InsertBefore, Value *FlagsOp)
static Instruction * CreateNeg(Value *S1, const Twine &Name, BasicBlock::iterator InsertBefore, Value *FlagsOp)
static cl::opt< RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode > Mode("regalloc-enable-advisor", cl::Hidden, cl::init(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default), cl::desc("Enable regalloc advisor mode"), cl::values(clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default, "default", "Default"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Release, "release", "precompiled"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Development, "development", "for training")))
Func MI getDebugLoc()))
Func getContext().diagnose(DiagnosticInfoUnsupported(Func
#define LLVM_DEBUG(...)
Definition Debug.h:119
static SymbolRef::Type getType(const Symbol *Sym)
Definition TapiFile.cpp:39
unify loop Fixup each natural loop to have a single exit block
static Function * getFunction(FunctionType *Ty, const Twine &Name, Module *M)
Value * RHS
Value * LHS
static const uint32_t IV[8]
Definition blake3_impl.h:83
static const fltSemantics & IEEEdouble()
Definition APFloat.h:305
static constexpr roundingMode rmNearestTiesToEven
Definition APFloat.h:361
LLVM_ABI opStatus convert(const fltSemantics &ToSemantics, roundingMode RM, bool *losesInfo)
Definition APFloat.cpp:6045
LLVM_ABI double convertToDouble() const
Converts this APFloat to host double value.
Definition APFloat.cpp:6278
Class for arbitrary precision integers.
Definition APInt.h:78
an instruction to allocate memory on the stack
This class represents an incoming formal argument to a Function.
Definition Argument.h:32
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
size_t size() const
Get the array size.
Definition ArrayRef.h:141
iterator begin() const
Definition ArrayRef.h:129
bool empty() const
Check if the array is empty.
Definition ArrayRef.h:136
static LLVM_ABI ArrayType * get(Type *ElementType, uint64_t NumElements)
This static method is the primary way to construct an ArrayType.
An instruction that atomically checks whether a specified value is in a memory location,...
an instruction that atomically reads a memory location, combines it with another value,...
BinOp
This enumeration lists the possible modifications atomicrmw can make.
@ Add
*p = old + v
@ FAdd
*p = old + v
@ USubCond
Subtract only if no unsigned overflow.
@ FMinimum
*p = minimum(old, v) minimum matches the behavior of llvm.minimum.
@ Min
*p = old <signed v ? old : v
@ Sub
*p = old - v
@ And
*p = old & v
@ Xor
*p = old ^ v
@ USubSat
*p = usub.sat(old, v) usub.sat matches the behavior of llvm.usub.sat.
@ FMaximum
*p = maximum(old, v) maximum matches the behavior of llvm.maximum.
@ FSub
*p = old - v
@ UIncWrap
Increment one up to a maximum value.
@ Max
*p = old >signed v ? old : v
@ UMin
*p = old <unsigned v ? old : v
@ FMin
*p = minnum(old, v) minnum matches the behavior of llvm.minnum.
@ UMax
*p = old >unsigned v ? old : v
@ FMaximumNum
*p = maximumnum(old, v) maximumnum matches the behavior of llvm.maximumnum.
@ FMax
*p = maxnum(old, v) maxnum matches the behavior of llvm.maxnum.
@ UDecWrap
Decrement one until a minimum value or zero.
@ FMinimumNum
*p = minimumnum(old, v) minimumnum matches the behavior of llvm.minimumnum.
@ Nand
*p = ~(old & v)
Functions, function parameters, and return types can have attributes to indicate how they should be t...
Definition Attributes.h:106
LLVM_ABI bool isStringAttribute() const
Return true if the attribute is a string (target-dependent) attribute.
static LLVM_ABI Attribute::AttrKind getAttrKindFromName(StringRef AttrName)
LLVM_ABI StringRef getKindAsString() const
Return the attribute's kind as a string.
static LLVM_ABI Attribute get(LLVMContext &Context, AttrKind Kind, uint64_t Val=0)
Return a uniquified Attribute object.
LLVM_ABI std::string getAsString(bool InAttrGrp=false) const
The Attribute is converted to a string of equivalent mnemonic.
LLVM_ABI Attribute::AttrKind getKindAsEnum() const
Return the attribute's kind as an enum (Attribute::AttrKind).
LLVM_ABI StringRef getValueAsString() const
Return the attribute's value as a string.
LLVM_ABI bool isTypeAttribute() const
Return true if the attribute is a type attribute.
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results,...
Definition Attributes.h:125
@ EndAttrKinds
Sentinel value useful for loops.
Definition Attributes.h:130
static LLVM_ABI Attribute getWithAlignment(LLVMContext &Context, Align Alignment)
Return a uniquified Attribute object that has the specific alignment set.
LLVM Basic Block Representation.
Definition BasicBlock.h:62
const Function * getParent() const
Return the enclosing method, or null if none.
Definition BasicBlock.h:213
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)
Creates a new BasicBlock.
Definition BasicBlock.h:206
LLVM_ABI const DataLayout & getDataLayout() const
Get the data layout of the module this basic block belongs to.
InstListType::iterator iterator
Instruction iterators...
Definition BasicBlock.h:170
LLVM_ABI LLVMContext & getContext() const
Get the context in which this basic block lives.
static LLVM_ABI BlockAddress * get(Function *F, BasicBlock *BB)
Return a BlockAddress for the specified function and basic block.
Class to represent byte types.
static LLVM_ABI ByteType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing a ByteType.
Definition Type.cpp:368
static LLVM_ABI Instruction::CastOps getCastOpcode(const Value *Val, bool SrcIsSigned, Type *Ty, bool DstIsSigned)
Returns the opcode necessary to cast Val into Ty using usual casting rules.
handler_range handlers()
iteration adapter for range-for loops.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Definition InstrTypes.h:740
static LLVM_ABI Constant * get(ArrayType *T, ArrayRef< Constant * > V)
static ConstantAsMetadata * get(Constant *C)
Definition Metadata.h:548
static LLVM_ABI Constant * getString(LLVMContext &Context, StringRef Initializer, bool AddNull=true, bool ByteString=false)
This method constructs a CDS and initializes it with a text string.
static Constant * getRaw(StringRef Data, uint64_t NumElements, Type *ElementTy)
getRaw() constructor - Return a constant with array type with an element count and element type match...
Definition Constants.h:897
static LLVM_ABI Constant * getIntToPtr(Constant *C, Type *Ty, bool OnlyIfReduced=false)
static LLVM_ABI Constant * getExtractElement(Constant *Vec, Constant *Idx, Type *OnlyIfReducedTy=nullptr)
static LLVM_ABI Constant * getAlignOf(Type *Ty)
getAlignOf constant expr - computes the alignment of a type in a target independent way (Note: the re...
static Constant * getNUWSub(Constant *C1, Constant *C2)
Definition Constants.h:1386
static Constant * getInBoundsGetElementPtr(Type *Ty, Constant *C, ArrayRef< Constant * > IdxList)
Create an "inbounds" getelementptr.
Definition Constants.h:1529
static LLVM_ABI Constant * getPointerCast(Constant *C, Type *Ty)
Create a BitCast, AddrSpaceCast, or a PtrToInt cast constant expression.
static LLVM_ABI Constant * getTruncOrBitCast(Constant *C, Type *Ty)
static Constant * getNSWAdd(Constant *C1, Constant *C2)
Definition Constants.h:1374
static LLVM_ABI Constant * getSub(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
static LLVM_ABI Constant * getNot(Constant *C)
static Constant * getPtrAdd(Constant *Ptr, Constant *Offset, GEPNoWrapFlags NW=GEPNoWrapFlags::none(), std::optional< ConstantRange > InRange=std::nullopt, Type *OnlyIfReduced=nullptr)
Create a getelementptr i8, ptr, offset constant expression.
Definition Constants.h:1518
static LLVM_ABI Constant * getInsertElement(Constant *Vec, Constant *Elt, Constant *Idx, Type *OnlyIfReducedTy=nullptr)
static LLVM_ABI Constant * getPtrToInt(Constant *C, Type *Ty, bool OnlyIfReduced=false)
static LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_PUSH Constant * getGetElementPtr(Type *Ty, Constant *C, ArrayRef< Constant * > IdxList, GEPNoWrapFlags NW=GEPNoWrapFlags::none(), std::optional< ConstantRange > InRange=std::nullopt, Type *OnlyIfReducedTy=nullptr)
Getelementptr form.
Definition Constants.h:1477
static LLVM_ABI Constant * getShuffleVector(Constant *V1, Constant *V2, ArrayRef< int > Mask, Type *OnlyIfReducedTy=nullptr)
static LLVM_ABI Constant * getSizeOf(Type *Ty)
getSizeOf constant expr - computes the (alloc) size of a type (in address-units, not bits) in a targe...
static LLVM_ABI Constant * getXor(Constant *C1, Constant *C2)
static Constant * getNSWNeg(Constant *C)
Definition Constants.h:1372
static Constant * getNSWSub(Constant *C1, Constant *C2)
Definition Constants.h:1382
static Constant * getNUWAdd(Constant *C1, Constant *C2)
Definition Constants.h:1378
static LLVM_ABI Constant * getAddrSpaceCast(Constant *C, Type *Ty, bool OnlyIfReduced=false)
static LLVM_ABI Constant * getAdd(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
static LLVM_ABI Constant * getBitCast(Constant *C, Type *Ty, bool OnlyIfReduced=false)
static LLVM_ABI Constant * getNeg(Constant *C, bool HasNSW=false)
static LLVM_ABI Constant * getTrunc(Constant *C, Type *Ty, bool OnlyIfReduced=false)
ConstantFP - Floating Point Values [float, double].
Definition Constants.h:420
const APFloat & getValueAPF() const
Definition Constants.h:463
static LLVM_ABI ConstantPointerNull * get(PointerType *T)
Static factory methods - Return objects of the specified value.
static LLVM_ABI ConstantPtrAuth * get(Constant *Ptr, ConstantInt *Key, ConstantInt *Disc, Constant *AddrDisc, Constant *DeactivationSymbol)
Return a pointer signed with the specified parameters.
This class represents a range of values.
static LLVM_ABI Constant * get(StructType *T, ArrayRef< Constant * > V)
static Constant * getAnon(ArrayRef< Constant * > V, bool Packed=false)
Return an anonymous struct that has the specified elements.
Definition Constants.h:643
static LLVM_ABI Constant * get(ArrayRef< Constant * > V)
This is an important base class in LLVM.
Definition Constant.h:44
static LLVM_ABI Constant * getAllOnesValue(Type *Ty)
static LLVM_ABI Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
Subprogram description. Uses SubclassData1.
A parsed version of the target data layout string in and methods for querying it.
Definition DataLayout.h:64
Base class for non-instruction debug metadata records that have positions within IR.
Record of a variable value-assignment, aka a non instruction representation of the dbg....
Basic diagnostic printer that uses an underlying raw_ostream.
Represents either an error or a value T.
Definition ErrorOr.h:56
reference get()
Definition ErrorOr.h:149
std::error_code getError() const
Definition ErrorOr.h:152
This instruction compares its operands according to the predicate given to the constructor.
Convenience struct for specifying and reasoning about fast-math flags.
Definition FMF.h:23
void setAllowContract(bool B=true)
Definition FMF.h:90
bool noSignedZeros() const
Definition FMF.h:67
bool noInfs() const
Definition FMF.h:66
void setAllowReciprocal(bool B=true)
Definition FMF.h:87
bool allowReciprocal() const
Definition FMF.h:68
void setNoSignedZeros(bool B=true)
Definition FMF.h:84
bool allowReassoc() const
Flag queries.
Definition FMF.h:64
bool approxFunc() const
Definition FMF.h:70
void setNoNaNs(bool B=true)
Definition FMF.h:78
void setAllowReassoc(bool B=true)
Flag setters.
Definition FMF.h:75
bool noNaNs() const
Definition FMF.h:65
void setApproxFunc(bool B=true)
Definition FMF.h:93
void setNoInfs(bool B=true)
Definition FMF.h:81
bool allowContract() const
Definition FMF.h:69
An instruction for ordering other memory operations.
static LLVM_ABI FixedVectorType * get(Type *ElementType, unsigned NumElts)
Definition Type.cpp:843
static LLVM_ABI FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace, const Twine &N="", Module *M=nullptr)
Definition Function.h:169
BasicBlockListType::iterator iterator
Definition Function.h:70
Argument * arg_iterator
Definition Function.h:73
iterator_range< arg_iterator > args()
Definition Function.h:886
arg_iterator arg_begin()
Definition Function.h:862
Function::iterator insert(Function::iterator Position, BasicBlock *BB)
Insert BB in the basic block list at Position.
Definition Function.h:749
size_t arg_size() const
Definition Function.h:895
Represents flags for the getelementptr instruction/expression.
static GEPNoWrapFlags inBounds()
static GEPNoWrapFlags noUnsignedWrap()
static GEPNoWrapFlags noUnsignedSignedWrap()
bool hasNoUnsignedSignedWrap() const
bool hasNoUnsignedWrap() const
bool isInBounds() const
GEPNoWrapFlags getNoWrapFlags() const
Definition Operator.h:385
an instruction for type-safe pointer arithmetic to access elements of arrays and structs
LLVM_ABI void setNoWrapFlags(GEPNoWrapFlags NW)
Set nowrap flags for GEP instruction.
static LLVM_ABI GlobalAlias * create(Type *Ty, unsigned AddressSpace, LinkageTypes Linkage, const Twine &Name, Constant *Aliasee, Module *Parent)
If a parent module is specified, the alias is automatically inserted into the end of the specified mo...
Definition Globals.cpp:692
static LLVM_ABI GlobalIFunc * create(Type *Ty, unsigned AddressSpace, LinkageTypes Linkage, const Twine &Name, Constant *Resolver, Module *Parent)
If a parent module is specified, the ifunc is automatically inserted into the end of the specified mo...
Definition Globals.cpp:749
void setUnnamedAddr(UnnamedAddr Val)
void setThreadLocalMode(ThreadLocalMode Val)
void setLinkage(LinkageTypes LT)
DLLStorageClassTypes
Storage classes of global values for PE targets.
Definition GlobalValue.h:74
Module * getParent()
Get the module that this global value is contained inside of...
VisibilityTypes
An enumeration for the kinds of visibility of global values.
Definition GlobalValue.h:67
@ PrivateLinkage
Like Internal, but omit from symbol table.
Definition GlobalValue.h:61
@ CommonLinkage
Tentative definitions.
Definition GlobalValue.h:63
@ InternalLinkage
Rename collisions when linking (static functions).
Definition GlobalValue.h:60
@ LinkOnceAnyLinkage
Keep one copy of function when linking (inline)
Definition GlobalValue.h:55
@ WeakODRLinkage
Same, but only replaced by something equivalent.
Definition GlobalValue.h:58
@ ExternalLinkage
Externally visible function.
Definition GlobalValue.h:53
@ WeakAnyLinkage
Keep one copy of named function when linking (weak)
Definition GlobalValue.h:57
@ AppendingLinkage
Special purpose, only applies to global arrays.
Definition GlobalValue.h:59
@ AvailableExternallyLinkage
Available for inspection, not emission.
Definition GlobalValue.h:54
@ ExternalWeakLinkage
ExternalWeak linkage description.
Definition GlobalValue.h:62
@ LinkOnceODRLinkage
Same, but only replaced by something equivalent.
Definition GlobalValue.h:56
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
bool hasInitializer() const
Definitions have initializers, declarations don't.
This instruction compares its operands according to the predicate given to the constructor.
Common base class shared among various IRBuilders.
Definition IRBuilder.h:111
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
Definition IRBuilder.h:2987
static LLVM_ABI InlineAsm * get(FunctionType *Ty, StringRef AsmString, StringRef Constraints, bool hasSideEffects, bool isAlignStack=false, AsmDialect asmDialect=AD_ATT, bool canThrow=false)
InlineAsm::get - Return the specified uniqued inline asm string.
Definition InlineAsm.cpp:43
Class to represent integer types.
static LLVM_ABI IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
Definition Type.cpp:338
This is an important class for using LLVM in a threaded context.
Definition LLVMContext.h:76
LLVM_ABI cl::LibraryOptionsContext & getLibraryOptions() const
The library options this context reads in place of their process-wide values.
void(*)(LLVMContext *Context, void *OpaqueHandle) YieldCallbackTy
Defines the type of a yield callback.
An instruction for reading from memory.
static LocalAsMetadata * get(Value *Local)
Definition Metadata.h:574
Metadata node.
Definition Metadata.h:1081
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition Metadata.h:1579
A single uniqued string.
Definition Metadata.h:733
static LLVM_ABI MDString * get(LLVMContext &Context, StringRef Str)
Definition Metadata.cpp:595
static std::unique_ptr< MemoryBuffer > getMemBuffer(StringRef InputData, StringRef BufferName="", bool RequiresNullTerminator=true)
Open the specified memory range as a MemoryBuffer.
static std::unique_ptr< MemoryBuffer > getMemBufferCopy(StringRef InputData, const Twine &BufferName="")
Open the specified memory range as a MemoryBuffer, copying the contents and taking ownership of it.
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFile(const Twine &Filename, bool IsText=false, bool RequiresNullTerminator=true, bool IsVolatile=false, std::optional< Align > Alignment=std::nullopt)
Open the specified file as a MemoryBuffer, returning a new MemoryBuffer if successful,...
static ErrorOr< std::unique_ptr< MemoryBuffer > > getSTDIN()
Read all of stdin into a file buffer, and return it.
Metadata wrapper in the Value hierarchy.
Definition Metadata.h:184
static LLVM_ABI MetadataAsValue * get(LLVMContext &Context, Metadata *MD)
Definition Metadata.cpp:105
Metadata * getMetadata() const
Definition Metadata.h:202
Root of the metadata hierarchy.
Definition Metadata.h:64
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:68
global_iterator global_begin()
Definition Module.h:795
ifunc_iterator ifunc_begin()
Definition Module.h:864
ModFlagBehavior
This enumeration defines the supported behaviors of module flags.
Definition Module.h:118
@ AppendUnique
Appends the two values, which are required to be metadata nodes.
Definition Module.h:147
@ Override
Uses the specified value, regardless of the behavior or value of the other module.
Definition Module.h:139
@ Warning
Emits a warning if two values disagree.
Definition Module.h:125
@ Error
Emits an error if two values disagree, otherwise the resulting value is that of the operands.
Definition Module.h:121
@ Append
Appends the two values, which are required to be metadata nodes.
Definition Module.h:142
@ Require
Adds a requirement that another module flag be present and have a specified value after linking is pe...
Definition Module.h:134
global_iterator global_end()
Definition Module.h:797
NamedMDListType::iterator named_metadata_iterator
The named metadata iterators.
Definition Module.h:113
IFuncListType::iterator ifunc_iterator
The Global IFunc iterators.
Definition Module.h:108
named_metadata_iterator named_metadata_begin()
Definition Module.h:905
ifunc_iterator ifunc_end()
Definition Module.h:866
alias_iterator alias_end()
Definition Module.h:848
alias_iterator alias_begin()
Definition Module.h:846
FunctionListType::iterator iterator
The Function iterators.
Definition Module.h:93
GlobalListType::iterator global_iterator
The Global Variable iterator.
Definition Module.h:88
AliasListType::iterator alias_iterator
The Global Alias iterators.
Definition Module.h:103
named_metadata_iterator named_metadata_end()
Definition Module.h:910
A tuple of MDNodes.
Definition Metadata.h:1797
LLVM_ABI StringRef getName() const
Module * getParent()
Get the module that holds this named metadata collection.
Definition Metadata.h:1867
void addIncoming(Value *V, BasicBlock *BB)
Add an incoming value to the end of the PHI list.
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
static LLVM_ABI PointerType * get(LLVMContext &C, unsigned AddressSpace)
This constructs an opaque pointer to an object in a numbered address space.
Definition Type.cpp:887
static LLVM_ABI PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
A global registry used in conjunction with static constructors to make pluggable components (like tar...
Definition Registry.h:116
Interface for looking up the initializer for a variable name, used by Init::resolveReferences.
Definition Record.h:2295
static LLVM_ABI ScalableVectorType * get(Type *ElementType, unsigned MinNumElts)
Definition Type.cpp:865
This instruction constructs a fixed permutation of two input vectors.
ArrayRef< int > getShuffleMask() const
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
An instruction for storing to memory.
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
constexpr size_t size() const
Get the string size.
Definition StringRef.h:144
constexpr const char * data() const
Get a pointer to the start of the string (which may not be null terminated).
Definition StringRef.h:138
Class to represent struct types.
static LLVM_ABI StructType * get(LLVMContext &Context, ArrayRef< Type * > Elements, bool isPacked=false)
This static method is the primary way to create a literal StructType.
Definition Type.cpp:467
static LLVM_ABI StructType * getTypeByName(LLVMContext &C, StringRef Name)
Return the type with the specified name, or null if there is none by that name.
Definition Type.cpp:778
static LLVM_ABI StructType * create(LLVMContext &Context, StringRef Name)
This creates an identified struct.
Definition Type.cpp:662
Class to represent target extensions types, which are generally unintrospectable from target-independ...
static LLVM_ABI TargetExtType * get(LLVMContext &Context, StringRef Name, ArrayRef< Type * > Types={}, ArrayRef< unsigned > Ints={})
Return a target extension type having the specified name and optional type and integer parameters.
Definition Type.cpp:936
Triple - Helper class for working with autoconf configuration names.
Definition Triple.h:48
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
static LLVM_ABI IntegerType * getInt64Ty(LLVMContext &C)
Definition Type.cpp:300
static LLVM_ABI Type * getX86_AMXTy(LLVMContext &C)
Definition Type.cpp:283
static LLVM_ABI Type * getMetadataTy(LLVMContext &C)
Definition Type.cpp:278
static LLVM_ABI Type * getTokenTy(LLVMContext &C)
Definition Type.cpp:279
static LLVM_ABI IntegerType * getInt128Ty(LLVMContext &C)
Definition Type.cpp:301
static LLVM_ABI IntegerType * getInt32Ty(LLVMContext &C)
Definition Type.cpp:299
static LLVM_ABI Type * getPPC_FP128Ty(LLVMContext &C)
Definition Type.cpp:282
static LLVM_ABI Type * getFP128Ty(LLVMContext &C)
Definition Type.cpp:281
static LLVM_ABI Type * getLabelTy(LLVMContext &C)
Definition Type.cpp:273
@ X86_AMXTyID
AMX vectors (8192 bits, X86 specific)
Definition Type.h:67
@ FunctionTyID
Functions.
Definition Type.h:73
@ ArrayTyID
Arrays.
Definition Type.h:76
@ TypedPointerTyID
Typed pointer used by some GPU targets.
Definition Type.h:79
@ HalfTyID
16-bit floating point type
Definition Type.h:57
@ TargetExtTyID
Target extension type.
Definition Type.h:80
@ VoidTyID
type with no size
Definition Type.h:64
@ ScalableVectorTyID
Scalable SIMD vector type.
Definition Type.h:78
@ LabelTyID
Labels.
Definition Type.h:65
@ FloatTyID
32-bit floating point type
Definition Type.h:59
@ StructTyID
Structures.
Definition Type.h:75
@ IntegerTyID
Arbitrary bit width integers.
Definition Type.h:71
@ FixedVectorTyID
Fixed width SIMD vector type.
Definition Type.h:77
@ BFloatTyID
16-bit floating point type (7-bit significand)
Definition Type.h:58
@ DoubleTyID
64-bit floating point type
Definition Type.h:60
@ X86_FP80TyID
80-bit floating point type (X87)
Definition Type.h:61
@ PPC_FP128TyID
128-bit floating point type (two 64-bits, PowerPC)
Definition Type.h:63
@ MetadataTyID
Metadata.
Definition Type.h:66
@ TokenTyID
Tokens.
Definition Type.h:68
@ ByteTyID
Arbitrary bit width bytes.
Definition Type.h:72
@ PointerTyID
Pointers.
Definition Type.h:74
@ FP128TyID
128-bit floating point type (112-bit significand)
Definition Type.h:62
static LLVM_ABI Type * getVoidTy(LLVMContext &C)
Definition Type.cpp:272
static LLVM_ABI IntegerType * getInt8Ty(LLVMContext &C)
Definition Type.cpp:297
static LLVM_ABI IntegerType * getInt16Ty(LLVMContext &C)
Definition Type.cpp:298
static LLVM_ABI IntegerType * getInt1Ty(LLVMContext &C)
Definition Type.cpp:296
static LLVM_ABI Type * getDoubleTy(LLVMContext &C)
Definition Type.cpp:277
static LLVM_ABI Type * getX86_FP80Ty(LLVMContext &C)
Definition Type.cpp:280
static LLVM_ABI Type * getFloatTy(LLVMContext &C)
Definition Type.cpp:276
static LLVM_ABI Type * getBFloatTy(LLVMContext &C)
Definition Type.cpp:275
static LLVM_ABI Type * getHalfTy(LLVMContext &C)
Definition Type.cpp:274
static LLVM_ABI UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
A Use represents the edge between a Value definition and its users.
Definition Use.h:35
static LLVM_ABI ValueAsMetadata * get(Value *V)
Definition Metadata.cpp:512
LLVM Value Representation.
Definition Value.h:75
Type * getType() const
All values are typed, get the type of this value.
Definition Value.h:257
LLVMContext & getContext() const
All values hold a context through their type.
Definition Value.h:260
use_iterator_impl< Use > use_iterator
Definition Value.h:355
void assign(const LibraryOptionsContext &Other)
An efficient, type-erasing, non-owning reference to a callable.
self_iterator getIterator()
Definition ilist_node.h:123
FunctionPassManager manages FunctionPasses.
PassManager manages ModulePassManagers.
A raw_ostream that writes to a file descriptor.
bool has_error() const
Return the value of the flag in this raw_fd_ostream indicating whether an output error has been encou...
std::error_code error() const
void close()
Manually flush the stream and close the file.
A raw_ostream that writes to an std::string.
ilist_select_iterator_type< OptionsT, false, false > iterator
CallInst * Call
LLVMTypeRef LLVMGetTypeByName2(LLVMContextRef C, const char *Name)
Obtain a Type from a context by its registered name.
Definition Core.cpp:901
LLVMBool LLVMIsEnumAttribute(LLVMAttributeRef A)
Check for the different types of attributes.
Definition Core.cpp:257
LLVMTypeRef LLVMGetTypeAttributeValue(LLVMAttributeRef A)
Get the type attribute's value.
Definition Core.cpp:201
void LLVMContextSetDiagnosticHandler(LLVMContextRef C, LLVMDiagnosticHandler Handler, void *DiagnosticContext)
Set the diagnostic handler for this context.
Definition Core.cpp:118
LLVMAttributeRef LLVMCreateDenormalFPEnvAttribute(LLVMContextRef C, LLVMDenormalModeKind DefaultModeOutput, LLVMDenormalModeKind DefaultModeInput, LLVMDenormalModeKind FloatModeOutput, LLVMDenormalModeKind FloatModeInput)
Create a DenormalFPEnv attribute.
Definition Core.cpp:220
const char * LLVMGetStringAttributeValue(LLVMAttributeRef A, unsigned *Length)
Get the string attribute's value.
Definition Core.cpp:250
uint64_t LLVMGetEnumAttributeValue(LLVMAttributeRef A)
Get the enum attribute's value.
Definition Core.cpp:187
LLVMDenormalModeKind
Represent different denormal handling kinds for use with LLVMCreateDenormalFPEnvAttribute.
Definition Core.h:753
LLVMBool LLVMIsStringAttribute(LLVMAttributeRef A)
Definition Core.cpp:262
LLVMAttributeRef LLVMCreateConstantRangeAttribute(LLVMContextRef C, unsigned KindID, unsigned NumBits, const uint64_t LowerWords[], const uint64_t UpperWords[])
Create a ConstantRange attribute.
Definition Core.cpp:206
unsigned LLVMGetEnumAttributeKindForName(const char *Name, size_t SLen)
Return an unique id given the name of a enum attribute, or 0 if no attribute by that name exists.
Definition Core.cpp:168
LLVMDiagnosticHandler LLVMContextGetDiagnosticHandler(LLVMContextRef C)
Get the diagnostic handler of this context.
Definition Core.cpp:127
void LLVMContextSetYieldCallback(LLVMContextRef C, LLVMYieldCallback Callback, void *OpaqueHandle)
Set the yield callback function for this context.
Definition Core.cpp:136
char * LLVMGetDiagInfoDescription(LLVMDiagnosticInfoRef DI)
Return a string representation of the DiagnosticInfo.
Definition Core.cpp:270
LLVMAttributeRef LLVMCreateStringAttribute(LLVMContextRef C, const char *K, unsigned KLength, const char *V, unsigned VLength)
Create a string attribute.
Definition Core.cpp:236
unsigned LLVMGetSyncScopeID(LLVMContextRef C, const char *Name, size_t SLen)
Maps a synchronization scope name to a ID unique within this context.
Definition Core.cpp:164
void LLVMContextSetDiscardValueNames(LLVMContextRef C, LLVMBool Discard)
Set whether the given context discards all value names.
Definition Core.cpp:147
unsigned LLVMGetMDKindIDInContext(LLVMContextRef C, const char *Name, unsigned SLen)
Definition Core.cpp:155
unsigned LLVMGetEnumAttributeKind(LLVMAttributeRef A)
Get the unique id corresponding to the enum attribute passed as argument.
Definition Core.cpp:183
void * LLVMContextGetDiagnosticContext(LLVMContextRef C)
Get the diagnostic context of this context.
Definition Core.cpp:132
LLVMAttributeRef LLVMCreateTypeAttribute(LLVMContextRef C, unsigned KindID, LLVMTypeRef type_ref)
Create a type attribute.
Definition Core.cpp:194
unsigned LLVMGetLastEnumAttributeKind(void)
Definition Core.cpp:172
LLVMBool LLVMContextShouldDiscardValueNames(LLVMContextRef C)
Retrieve whether the given context is set to discard all value names.
Definition Core.cpp:143
LLVMBool LLVMIsTypeAttribute(LLVMAttributeRef A)
Definition Core.cpp:266
void LLVMContextDispose(LLVMContextRef C)
Destroy a context instance.
Definition Core.cpp:151
void(* LLVMYieldCallback)(LLVMContextRef, void *)
Definition Core.h:594
LLVMAttributeRef LLVMCreateEnumAttribute(LLVMContextRef C, unsigned KindID, uint64_t Val)
Create an enum attribute.
Definition Core.cpp:176
const char * LLVMGetStringAttributeKind(LLVMAttributeRef A, unsigned *Length)
Get the string attribute's kind.
Definition Core.cpp:243
LLVMContextRef LLVMContextCreate()
Create a new context.
Definition Core.cpp:110
void(* LLVMDiagnosticHandler)(LLVMDiagnosticInfoRef, void *)
Definition Core.h:593
LLVMDiagnosticSeverity LLVMGetDiagInfoSeverity(LLVMDiagnosticInfoRef DI)
Return an enum LLVMDiagnosticSeverity.
Definition Core.cpp:280
LLVMTargetDataRef LLVMGetModuleDataLayout(LLVMModuleRef M)
Obtain the data layout for a module.
Definition Core.cpp:4912
LLVMTargetDataRef LLVMCreateTargetData(const char *StringRep)
Creates target data from a target layout string.
Definition Core.cpp:4920
unsigned LLVMPreferredAlignmentOfType(LLVMTargetDataRef TD, LLVMTypeRef Ty)
Computes the preferred alignment of a type in bytes for a target.
Definition Core.cpp:4981
unsigned LLVMCallFrameAlignmentOfType(LLVMTargetDataRef TD, LLVMTypeRef Ty)
Computes the call frame alignment of a type in bytes for a target.
Definition Core.cpp:4977
unsigned long long LLVMOffsetOfElement(LLVMTargetDataRef TD, LLVMTypeRef StructTy, unsigned Element)
Computes the byte offset of the indexed struct element for a target.
Definition Core.cpp:4998
void LLVMDisposeTargetData(LLVMTargetDataRef TD)
Deallocates a TargetData.
Definition Core.cpp:4924
LLVMByteOrdering LLVMByteOrder(LLVMTargetDataRef TD)
Returns the byte order of a target, either LLVMBigEndian or LLVMLittleEndian.
Definition Core.cpp:4931
unsigned LLVMPreferredAlignmentOfGlobal(LLVMTargetDataRef TD, LLVMValueRef GlobalVar)
Computes the preferred alignment of a global variable in bytes for a target.
Definition Core.cpp:4985
unsigned long long LLVMStoreSizeOfType(LLVMTargetDataRef TD, LLVMTypeRef Ty)
Computes the storage size of a type in bytes for a target.
Definition Core.cpp:4965
LLVMByteOrdering
Definition Core.h:5433
unsigned long long LLVMABISizeOfType(LLVMTargetDataRef TD, LLVMTypeRef Ty)
Computes the ABI size of a type in bytes for a target.
Definition Core.cpp:4969
unsigned LLVMPointerSizeForAS(LLVMTargetDataRef TD, unsigned AS)
Returns the pointer size in bytes for a target for a specified address space.
Definition Core.cpp:4939
unsigned LLVMABIAlignmentOfType(LLVMTargetDataRef TD, LLVMTypeRef Ty)
Computes the ABI alignment of a type in bytes for a target.
Definition Core.cpp:4973
unsigned LLVMElementAtOffset(LLVMTargetDataRef TD, LLVMTypeRef StructTy, unsigned long long Offset)
Computes the structure element that contains the byte offset for a target.
Definition Core.cpp:4992
LLVMTypeRef LLVMIntPtrTypeInContext(LLVMContextRef C, LLVMTargetDataRef TD)
Returns the integer type that is the same size as a pointer on a target.
Definition Core.cpp:4952
char * LLVMCopyStringRepOfTargetData(LLVMTargetDataRef TD)
Converts target data to a target layout string.
Definition Core.cpp:4926
unsigned LLVMPointerSize(LLVMTargetDataRef TD)
Returns the pointer size in bytes for a target.
Definition Core.cpp:4935
LLVMTypeRef LLVMIntPtrTypeForASInContext(LLVMContextRef C, LLVMTargetDataRef TD, unsigned AS)
Returns the integer type that is the same size as a pointer on a target.
Definition Core.cpp:4956
void LLVMSetModuleDataLayout(LLVMModuleRef M, LLVMTargetDataRef DL)
Set the data layout for a module.
Definition Core.cpp:4916
unsigned long long LLVMSizeOfTypeInBits(LLVMTargetDataRef TD, LLVMTypeRef Ty)
Computes the size of a type in bits for a target.
Definition Core.cpp:4961
@ LLVMBigEndian
Definition Core.h:5433
@ LLVMLittleEndian
Definition Core.h:5433
LLVMValueRef LLVMBuildAggregateRet(LLVMBuilderRef B, LLVMValueRef *RetVals, unsigned N)
Definition Core.cpp:3673
LLVMValueRef LLVMBuildMul(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:3937
LLVMValueRef LLVMBuildRetVoid(LLVMBuilderRef B)
Definition Core.cpp:3665
LLVMValueRef LLVMBuildSub(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:3917
LLVMValueRef LLVMBuildNUWMul(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:3947
LLVMBool LLVMGetWeak(LLVMValueRef CmpXchgInst)
Definition Core.cpp:4379
LLVMValueRef LLVMBuildCast(LLVMBuilderRef B, LLVMOpcode Op, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition Core.cpp:4507
LLVMValueRef LLVMBuildIsNull(LLVMBuilderRef B, LLVMValueRef Val, const char *Name)
Definition Core.cpp:4650
LLVMValueRef LLVMBuildGEPWithNoWrapFlags(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Pointer, LLVMValueRef *Indices, unsigned NumIndices, const char *Name, LLVMGEPNoWrapFlags NoWrapFlags)
Creates a GetElementPtr instruction.
Definition Core.cpp:4337
LLVMValueRef LLVMBuildAdd(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:3897
void LLVMSetWeak(LLVMValueRef CmpXchgInst, LLVMBool isWeak)
Definition Core.cpp:4383
LLVMValueRef LLVMBuildOr(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:4017
LLVMValueRef LLVMBuildBitCast(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition Core.cpp:4479
LLVMValueRef LLVMBuildExactUDiv(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:3962
LLVMValueRef LLVMBuildGEP2(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Pointer, LLVMValueRef *Indices, unsigned NumIndices, const char *Name)
Definition Core.cpp:4322
LLVMValueRef LLVMBuildNSWSub(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:3922
void LLVMPositionBuilderBeforeInstrAndDbgRecords(LLVMBuilderRef Builder, LLVMValueRef Instr)
Set the builder position before Instr and any attached debug records.
Definition Core.cpp:3581
LLVMValueRef LLVMBuildIsNotNull(LLVMBuilderRef B, LLVMValueRef Val, const char *Name)
Definition Core.cpp:4655
void LLVMDisposeBuilder(LLVMBuilderRef Builder)
Definition Core.cpp:3610
void LLVMClearInsertionPosition(LLVMBuilderRef Builder)
Definition Core.cpp:3597
LLVMValueRef LLVMBuildLandingPad(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef PersFn, unsigned NumClauses, const char *Name)
Definition Core.cpp:3739
void LLVMSetIsDisjoint(LLVMValueRef Inst, LLVMBool IsDisjoint)
Sets the disjoint flag for the instruction.
Definition Core.cpp:4120
LLVMBool LLVMIsAtomicSingleThread(LLVMValueRef AtomicInst)
Definition Core.cpp:4733
LLVMValueRef LLVMBuildResume(LLVMBuilderRef B, LLVMValueRef Exn)
Definition Core.cpp:3769
void LLVMSetAtomicRMWBinOp(LLVMValueRef Inst, LLVMAtomicRMWBinOp BinOp)
Definition Core.cpp:4418
LLVMValueRef LLVMBuildFDiv(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:3977
LLVMValueRef LLVMBuildInvokeWithOperandBundles(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Fn, LLVMValueRef *Args, unsigned NumArgs, LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch, LLVMOperandBundleRef *Bundles, unsigned NumBundles, const char *Name)
Definition Core.cpp:3725
LLVMValueRef LLVMBuildXor(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:4022
LLVMValueRef LLVMBuildBitExtract(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Src, LLVMValueRef Offset, const char *Name)
Definition Core.cpp:4643
LLVMBool LLVMGetExact(LLVMValueRef DivOrShrInst)
Definition Core.cpp:4079
LLVMValueRef LLVMBuildAddrSpaceCast(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition Core.cpp:4484
unsigned LLVMGetNumMaskElements(LLVMValueRef SVInst)
Get the number of elements in the mask of a ShuffleVector instruction.
Definition Core.cpp:4715
void LLVMInsertIntoBuilder(LLVMBuilderRef Builder, LLVMValueRef Instr)
Definition Core.cpp:3601
LLVMValueRef LLVMBuildCleanupRet(LLVMBuilderRef B, LLVMValueRef CatchPad, LLVMBasicBlockRef BB)
Definition Core.cpp:3790
LLVMValueRef LLVMBuildFPToSI(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition Core.cpp:4444
void LLVMGetHandlers(LLVMValueRef CatchSwitch, LLVMBasicBlockRef *Handlers)
Obtain the basic blocks acting as handlers for a catchswitch instruction.
Definition Core.cpp:3837
LLVMValueRef LLVMBuildTrunc(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition Core.cpp:4424
LLVMValueRef LLVMGetArgOperand(LLVMValueRef Funclet, unsigned i)
Definition Core.cpp:3854
LLVMValueRef LLVMBuildAnd(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:4012
unsigned LLVMGetNumHandlers(LLVMValueRef CatchSwitch)
Definition Core.cpp:3833
LLVMValueRef LLVMBuildCallBr(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Fn, LLVMBasicBlockRef DefaultDest, LLVMBasicBlockRef *IndirectDests, unsigned NumIndirectDests, LLVMValueRef *Args, unsigned NumArgs, LLVMOperandBundleRef *Bundles, unsigned NumBundles, const char *Name)
Definition Core.cpp:3697
LLVMBasicBlockRef LLVMGetInsertBlock(LLVMBuilderRef Builder)
Definition Core.cpp:3593
LLVMValueRef LLVMBuildSDiv(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:3967
LLVMValueRef LLVMBuildSExtOrBitCast(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition Core.cpp:4495
LLVMValueRef LLVMBuildCall2(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Fn, LLVMValueRef *Args, unsigned NumArgs, const char *Name)
Definition Core.cpp:4564
void LLVMSetNSW(LLVMValueRef ArithInst, LLVMBool HasNSW)
Definition Core.cpp:4074
LLVMMetadataRef LLVMGetCurrentDebugLocation2(LLVMBuilderRef Builder)
Get location information used by debugging information.
Definition Core.cpp:3616
LLVMValueRef LLVMBuildUDiv(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:3957
LLVMValueRef LLVMBuildSelect(LLVMBuilderRef B, LLVMValueRef If, LLVMValueRef Then, LLVMValueRef Else, const char *Name)
Definition Core.cpp:4587
void LLVMPositionBuilderBefore(LLVMBuilderRef Builder, LLVMValueRef Instr)
Set the builder position before Instr but after any attached debug records.
Definition Core.cpp:3575
LLVMBool LLVMCanValueUseFastMathFlags(LLVMValueRef V)
Check if a given value can potentially have fast math flags.
Definition Core.cpp:4110
void LLVMSetArgOperand(LLVMValueRef Funclet, unsigned i, LLVMValueRef value)
Definition Core.cpp:3858
LLVMValueRef LLVMBuildCondBr(LLVMBuilderRef B, LLVMValueRef If, LLVMBasicBlockRef Then, LLVMBasicBlockRef Else)
Definition Core.cpp:3682
LLVMBool LLVMGetNUW(LLVMValueRef ArithInst)
Definition Core.cpp:4059
LLVMOpcode LLVMGetCastOpcode(LLVMValueRef Src, LLVMBool SrcIsSigned, LLVMTypeRef DestTy, LLVMBool DestIsSigned)
Definition Core.cpp:4536
void LLVMInsertIntoBuilderWithName(LLVMBuilderRef Builder, LLVMValueRef Instr, const char *Name)
Definition Core.cpp:3605
LLVMValueRef LLVMBuildSRem(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:3987
LLVMValueRef LLVMBuildCleanupPad(LLVMBuilderRef B, LLVMValueRef ParentPad, LLVMValueRef *Args, unsigned NumArgs, const char *Name)
Definition Core.cpp:3758
LLVMValueRef LLVMBuildIntCast(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Deprecated: This cast is always signed.
Definition Core.cpp:4525
LLVMValueRef LLVMGetCurrentDebugLocation(LLVMBuilderRef Builder)
Deprecated: Returning the NULL location will crash.
Definition Core.cpp:3633
LLVMValueRef LLVMBuildExtractElement(LLVMBuilderRef B, LLVMValueRef VecVal, LLVMValueRef Index, const char *Name)
Definition Core.cpp:4599
LLVMValueRef LLVMBuildShl(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:3997
LLVMValueRef LLVMBuildCatchRet(LLVMBuilderRef B, LLVMValueRef CatchPad, LLVMBasicBlockRef BB)
Definition Core.cpp:3784
LLVMValueRef LLVMBuildMemMove(LLVMBuilderRef B, LLVMValueRef Dst, unsigned DstAlign, LLVMValueRef Src, unsigned SrcAlign, LLVMValueRef Size)
Creates and inserts a memmove between the specified pointers.
Definition Core.cpp:4164
LLVMAtomicOrdering LLVMGetOrdering(LLVMValueRef MemAccessInst)
Definition Core.cpp:4387
LLVMValueRef LLVMBuildStructGEP2(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Pointer, unsigned Idx, const char *Name)
Definition Core.cpp:4347
int LLVMGetMaskValue(LLVMValueRef SVInst, unsigned Elt)
Get the mask value at position Elt in the mask of a ShuffleVector instruction.
Definition Core.cpp:4721
void LLVMAddCase(LLVMValueRef Switch, LLVMValueRef OnVal, LLVMBasicBlockRef Dest)
Definition Core.cpp:3800
LLVMValueRef LLVMBuildBr(LLVMBuilderRef B, LLVMBasicBlockRef Dest)
Definition Core.cpp:3678
LLVMValueRef LLVMBuildInsertElement(LLVMBuilderRef B, LLVMValueRef VecVal, LLVMValueRef EltVal, LLVMValueRef Index, const char *Name)
Definition Core.cpp:4605
void LLVMPositionBuilderBeforeDbgRecords(LLVMBuilderRef Builder, LLVMBasicBlockRef Block, LLVMValueRef Instr)
Set the builder position before Instr and any attached debug records, or if Instr is null set the pos...
Definition Core.cpp:3568
void LLVMSetFastMathFlags(LLVMValueRef FPMathInst, LLVMFastMathFlags FMF)
Sets the flags for which fast-math-style optimizations are allowed for this value.
Definition Core.cpp:4105
LLVMValueRef LLVMBuildIntCast2(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, LLVMBool IsSigned, const char *Name)
Definition Core.cpp:4518
LLVMValueRef LLVMBuildNUWSub(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:3927
LLVMValueRef LLVMBuildFAdd(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:3912
LLVMValueRef LLVMBuildCatchPad(LLVMBuilderRef B, LLVMValueRef ParentPad, LLVMValueRef *Args, unsigned NumArgs, const char *Name)
Definition Core.cpp:3751
LLVMValueRef LLVMBuildCallWithOperandBundles(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Fn, LLVMValueRef *Args, unsigned NumArgs, LLVMOperandBundleRef *Bundles, unsigned NumBundles, const char *Name)
Definition Core.cpp:4573
LLVMBool LLVMIsCleanup(LLVMValueRef LandingPad)
Definition Core.cpp:3821
LLVMValueRef LLVMBuildZExtOrBitCast(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition Core.cpp:4489
LLVMBool LLVMGetVolatile(LLVMValueRef Inst)
Definition Core.cpp:4364
LLVMValueRef LLVMBuildFPCast(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition Core.cpp:4531
LLVMValueRef LLVMBuildPtrToInt(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition Core.cpp:4469
LLVMValueRef LLVMBuildPtrDiff2(LLVMBuilderRef B, LLVMTypeRef ElemTy, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:4660
LLVMValueRef LLVMBuildTruncOrBitCast(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition Core.cpp:4501
LLVMValueRef LLVMBuildArrayAlloca(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Val, const char *Name)
Definition Core.cpp:4178
LLVMValueRef LLVMGetClause(LLVMValueRef LandingPad, unsigned Idx)
Definition Core.cpp:3813
unsigned LLVMGetAtomicSyncScopeID(LLVMValueRef AtomicInst)
Returns the synchronization scope ID of an atomic instruction.
Definition Core.cpp:4752
LLVMValueRef LLVMBuildVAArg(LLVMBuilderRef B, LLVMValueRef List, LLVMTypeRef Ty, const char *Name)
Definition Core.cpp:4594
LLVMValueRef LLVMBuildAtomicCmpXchgSyncScope(LLVMBuilderRef B, LLVMValueRef Ptr, LLVMValueRef Cmp, LLVMValueRef New, LLVMAtomicOrdering SuccessOrdering, LLVMAtomicOrdering FailureOrdering, unsigned SSID)
Definition Core.cpp:4704
LLVMValueRef LLVMBuildBinOp(LLVMBuilderRef B, LLVMOpcode Op, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:4027
LLVMBool LLVMIsAtomic(LLVMValueRef Inst)
Returns whether an instruction is an atomic instruction, e.g., atomicrmw, cmpxchg,...
Definition Core.cpp:4729
void LLVMSetVolatile(LLVMValueRef MemAccessInst, LLVMBool isVolatile)
Definition Core.cpp:4368
void LLVMSetAtomicSingleThread(LLVMValueRef AtomicInst, LLVMBool NewValue)
Definition Core.cpp:4742
LLVMValueRef LLVMBuildFRem(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:3992
LLVMValueRef LLVMBuildURem(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:3982
LLVMValueRef LLVMBuildIntToPtr(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition Core.cpp:4474
LLVMBool LLVMGetNSW(LLVMValueRef ArithInst)
Definition Core.cpp:4069
LLVMValueRef LLVMBuildNSWMul(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:3942
LLVMValueRef LLVMBuildFree(LLVMBuilderRef B, LLVMValueRef PointerVal)
Definition Core.cpp:4183
LLVMValueRef LLVMBuildNeg(LLVMBuilderRef B, LLVMValueRef V, const char *Name)
Definition Core.cpp:4034
LLVMValueRef LLVMBuildFSub(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:3932
LLVMValueRef LLVMBuildCatchSwitch(LLVMBuilderRef B, LLVMValueRef ParentPad, LLVMBasicBlockRef UnwindBB, unsigned NumHandlers, const char *Name)
Definition Core.cpp:3773
LLVMValueRef LLVMBuildLoad2(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef PointerVal, const char *Name)
Definition Core.cpp:4187
LLVMValueRef LLVMBuildInBoundsGEP2(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Pointer, LLVMValueRef *Indices, unsigned NumIndices, const char *Name)
Definition Core.cpp:4329
LLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Val, const char *Name)
Definition Core.cpp:4137
LLVMValueRef LLVMBuildAtomicCmpXchg(LLVMBuilderRef B, LLVMValueRef Ptr, LLVMValueRef Cmp, LLVMValueRef New, LLVMAtomicOrdering SuccessOrdering, LLVMAtomicOrdering FailureOrdering, LLVMBool singleThread)
Definition Core.cpp:4691
LLVMValueRef LLVMBuildIndirectBr(LLVMBuilderRef B, LLVMValueRef Addr, unsigned NumDests)
Definition Core.cpp:3692
LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef B)
Definition Core.cpp:3796
LLVMValueRef LLVMBuildSIToFP(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition Core.cpp:4454
LLVMValueRef LLVMBuildSExt(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition Core.cpp:4434
LLVMValueRef LLVMBuildFPToUI(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition Core.cpp:4439
void LLVMSetInstDebugLocation(LLVMBuilderRef Builder, LLVMValueRef Inst)
Attempts to set the debug location for the given instruction using the current debug location for the...
Definition Core.cpp:3639
void LLVMSetCurrentDebugLocation2(LLVMBuilderRef Builder, LLVMMetadataRef Loc)
Set location information used by debugging information.
Definition Core.cpp:3620
LLVMBuilderRef LLVMCreateBuilderForModule(LLVMModuleRef M)
Definition Core.cpp:3550
LLVMValueRef LLVMBuildAlloca(LLVMBuilderRef B, LLVMTypeRef Ty, const char *Name)
Definition Core.cpp:4173
void LLVMSetCurrentDebugLocation(LLVMBuilderRef Builder, LLVMValueRef L)
Deprecated: Passing the NULL location will crash.
Definition Core.cpp:3627
LLVMValueRef LLVMBuildPhi(LLVMBuilderRef B, LLVMTypeRef Ty, const char *Name)
Definition Core.cpp:4560
void LLVMAddDestination(LLVMValueRef IndirectBr, LLVMBasicBlockRef Dest)
Definition Core.cpp:3805
LLVMBool LLVMGetNNeg(LLVMValueRef NonNegInst)
Gets if the instruction has the non-negative flag set.
Definition Core.cpp:4089
LLVMValueRef LLVMBuildAtomicRMWSyncScope(LLVMBuilderRef B, LLVMAtomicRMWBinOp op, LLVMValueRef PTR, LLVMValueRef Val, LLVMAtomicOrdering ordering, unsigned SSID)
Definition Core.cpp:4680
LLVMValueRef LLVMBuildRet(LLVMBuilderRef B, LLVMValueRef V)
Definition Core.cpp:3669
LLVMMetadataRef LLVMBuilderGetDefaultFPMathTag(LLVMBuilderRef Builder)
Get the dafult floating-point math metadata for a given builder.
Definition Core.cpp:3659
LLVMValueRef LLVMBuildExtractValue(LLVMBuilderRef B, LLVMValueRef AggVal, unsigned Index, const char *Name)
Definition Core.cpp:4619
LLVMValueRef LLVMBuildGlobalStringPtr(LLVMBuilderRef B, const char *Str, const char *Name)
Deprecated: Use LLVMBuildGlobalString instead, which has identical behavior.
Definition Core.cpp:4359
LLVMValueRef LLVMBuildNSWAdd(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:3902
void LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder, LLVMBasicBlockRef Block)
Definition Core.cpp:3588
LLVMValueRef LLVMBuildFMul(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:3952
LLVMValueRef LLVMBuildLShr(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:4002
LLVMAtomicRMWBinOp LLVMGetAtomicRMWBinOp(LLVMValueRef Inst)
Definition Core.cpp:4414
LLVMValueRef LLVMBuildFNeg(LLVMBuilderRef B, LLVMValueRef V, const char *Name)
Definition Core.cpp:4051
LLVMValueRef LLVMBuildMemSet(LLVMBuilderRef B, LLVMValueRef Ptr, LLVMValueRef Val, LLVMValueRef Len, unsigned Align)
Creates and inserts a memset to the specified pointer and the specified value.
Definition Core.cpp:4148
void LLVMSetAtomicSyncScopeID(LLVMValueRef AtomicInst, unsigned SSID)
Sets the synchronization scope ID of an atomic instruction.
Definition Core.cpp:4758
LLVMContextRef LLVMGetBuilderContext(LLVMBuilderRef Builder)
Obtain the context to which this builder is associated.
Definition Core.cpp:3655
LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef B, LLVMTypeRef Ty, const char *Name)
Definition Core.cpp:4127
LLVMValueRef LLVMBuildFreeze(LLVMBuilderRef B, LLVMValueRef Val, const char *Name)
Definition Core.cpp:4631
LLVMValueRef LLVMBuildGlobalString(LLVMBuilderRef B, const char *Str, const char *Name)
Definition Core.cpp:4354
void LLVMSetNUW(LLVMValueRef ArithInst, LLVMBool HasNUW)
Definition Core.cpp:4064
LLVMAtomicOrdering LLVMGetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst)
Definition Core.cpp:4764
LLVMValueRef LLVMBuildFCmp(LLVMBuilderRef B, LLVMRealPredicate Op, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:4551
LLVMValueRef LLVMBuildPointerCast(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition Core.cpp:4513
LLVMValueRef LLVMBuildExactSDiv(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:3972
LLVMValueRef LLVMBuildShuffleVector(LLVMBuilderRef B, LLVMValueRef V1, LLVMValueRef V2, LLVMValueRef Mask, const char *Name)
Definition Core.cpp:4612
LLVMValueRef LLVMBuildFPExt(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition Core.cpp:4464
void LLVMSetCleanup(LLVMValueRef LandingPad, LLVMBool Val)
Definition Core.cpp:3825
LLVMValueRef LLVMBuildICmp(LLVMBuilderRef B, LLVMIntPredicate Op, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:4544
void LLVMSetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst, LLVMAtomicOrdering Ordering)
Definition Core.cpp:4782
void LLVMAddClause(LLVMValueRef LandingPad, LLVMValueRef ClauseVal)
Definition Core.cpp:3817
LLVMValueRef LLVMBuildFence(LLVMBuilderRef B, LLVMAtomicOrdering Ordering, LLVMBool isSingleThread, const char *Name)
Definition Core.cpp:4306
void LLVMSetParentCatchSwitch(LLVMValueRef CatchPad, LLVMValueRef CatchSwitch)
Set the parent catchswitch instruction of a catchpad instruction.
Definition Core.cpp:3847
LLVMValueRef LLVMBuildFenceSyncScope(LLVMBuilderRef B, LLVMAtomicOrdering Ordering, unsigned SSID, const char *Name)
Definition Core.cpp:4315
LLVMValueRef LLVMBuildUIToFP(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition Core.cpp:4449
void LLVMPositionBuilder(LLVMBuilderRef Builder, LLVMBasicBlockRef Block, LLVMValueRef Instr)
Set the builder position before Instr but after any attached debug records, or if Instr is null set t...
Definition Core.cpp:3562
unsigned LLVMGetNumClauses(LLVMValueRef LandingPad)
Definition Core.cpp:3809
int LLVMGetUndefMaskElem(void)
Definition Core.cpp:4727
void LLVMSetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst, LLVMAtomicOrdering Ordering)
Definition Core.cpp:4769
LLVMValueRef LLVMGetParentCatchSwitch(LLVMValueRef CatchPad)
Get the parent catchswitch instruction of a catchpad instruction.
Definition Core.cpp:3843
LLVMFastMathFlags LLVMGetFastMathFlags(LLVMValueRef FPMathInst)
Get the flags for which fast-math-style optimizations are allowed for this value.
Definition Core.cpp:4099
LLVMBool LLVMGetIsDisjoint(LLVMValueRef Inst)
Gets whether the instruction has the disjoint flag set.
Definition Core.cpp:4115
LLVMValueRef LLVMBuildSwitch(LLVMBuilderRef B, LLVMValueRef V, LLVMBasicBlockRef Else, unsigned NumCases)
Definition Core.cpp:3687
void LLVMSetNNeg(LLVMValueRef NonNegInst, LLVMBool IsNonNeg)
Sets the non-negative flag for the instruction.
Definition Core.cpp:4094
LLVMValueRef LLVMBuildMemCpy(LLVMBuilderRef B, LLVMValueRef Dst, unsigned DstAlign, LLVMValueRef Src, unsigned SrcAlign, LLVMValueRef Size)
Creates and inserts a memcpy between the specified pointers.
Definition Core.cpp:4155
void LLVMAddHandler(LLVMValueRef CatchSwitch, LLVMBasicBlockRef Dest)
Definition Core.cpp:3829
void LLVMSetExact(LLVMValueRef DivOrShrInst, LLVMBool IsExact)
Definition Core.cpp:4084
LLVMValueRef LLVMBuildNSWNeg(LLVMBuilderRef B, LLVMValueRef V, const char *Name)
Definition Core.cpp:4038
LLVMValueRef LLVMBuildAShr(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:4007
LLVMValueRef LLVMBuildInvoke2(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Fn, LLVMValueRef *Args, unsigned NumArgs, LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch, const char *Name)
Definition Core.cpp:3716
LLVMValueRef LLVMBuildBitInsert(LLVMBuilderRef B, LLVMValueRef Base, LLVMValueRef Val, LLVMValueRef Offset, const char *Name)
Definition Core.cpp:4636
void LLVMSetOrdering(LLVMValueRef MemAccessInst, LLVMAtomicOrdering Ordering)
Definition Core.cpp:4401
LLVMValueRef LLVMBuildFPTrunc(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition Core.cpp:4459
LLVMValueRef LLVMBuildStore(LLVMBuilderRef B, LLVMValueRef Val, LLVMValueRef PointerVal)
Definition Core.cpp:4192
void LLVMAddMetadataToInst(LLVMBuilderRef Builder, LLVMValueRef Inst)
Same as LLVMSetInstDebugLocation.
Definition Core.cpp:3643
LLVMAtomicOrdering LLVMGetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst)
Definition Core.cpp:4777
LLVMValueRef LLVMBuildNUWAdd(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:3907
LLVMValueRef LLVMBuildInsertValue(LLVMBuilderRef B, LLVMValueRef AggVal, LLVMValueRef EltVal, unsigned Index, const char *Name)
Definition Core.cpp:4624
void LLVMBuilderSetDefaultFPMathTag(LLVMBuilderRef Builder, LLVMMetadataRef FPMathTag)
Set the default floating-point math metadata for the given builder.
Definition Core.cpp:3647
LLVMValueRef LLVMBuildZExt(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition Core.cpp:4429
LLVMValueRef LLVMBuildNot(LLVMBuilderRef B, LLVMValueRef V, const char *Name)
Definition Core.cpp:4055
LLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B, LLVMAtomicRMWBinOp op, LLVMValueRef PTR, LLVMValueRef Val, LLVMAtomicOrdering ordering, LLVMBool singleThread)
Definition Core.cpp:4669
LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRange(const char *InputData, size_t InputDataLength, const char *BufferName, LLVMBool RequiresNullTerminator)
Definition Core.cpp:4829
size_t LLVMGetBufferSize(LLVMMemoryBufferRef MemBuf)
Definition Core.cpp:4854
LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRangeCopy(const char *InputData, size_t InputDataLength, const char *BufferName)
Definition Core.cpp:4840
const char * LLVMGetBufferStart(LLVMMemoryBufferRef MemBuf)
Definition Core.cpp:4850
LLVMBool LLVMCreateMemoryBufferWithContentsOfFile(const char *Path, LLVMMemoryBufferRef *OutMemBuf, char **OutMessage)
Definition Core.cpp:4804
LLVMBool LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef *OutMemBuf, char **OutMessage)
Definition Core.cpp:4818
void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf)
Definition Core.cpp:4858
LLVMModuleProviderRef LLVMCreateModuleProviderForExistingModule(LLVMModuleRef M)
Changes the type of M so it can be passed to FunctionPassManagers and the JIT.
Definition Core.cpp:4793
void LLVMDisposeModuleProvider(LLVMModuleProviderRef MP)
Destroys the module M.
Definition Core.cpp:4797
char * LLVMPrintModuleToString(LLVMModuleRef M)
Return a string representation of the module.
Definition Core.cpp:499
LLVMNamedMDNodeRef LLVMGetOrInsertNamedMetadata(LLVMModuleRef M, const char *Name, size_t NameLen)
Retrieve a NamedMDNode with the given name, creating a new node if no such node exists.
Definition Core.cpp:1463
LLVMValueRef LLVMGetNamedFunctionWithLength(LLVMModuleRef M, const char *Name, size_t Length)
Obtain a Function value from a Module by its name.
Definition Core.cpp:2562
unsigned LLVMGetDebugLocColumn(LLVMValueRef Val)
Return the column number of the debug location for this value, which must be an llvm::Instruction.
Definition Core.cpp:1591
LLVMNamedMDNodeRef LLVMGetNamedMetadata(LLVMModuleRef M, const char *Name, size_t NameLen)
Retrieve a NamedMDNode with the given name, returning NULL if no such node exists.
Definition Core.cpp:1458
LLVMModuleRef LLVMModuleCreateWithNameInContext(const char *ModuleID, LLVMContextRef C)
Create a new, empty module in a specific context.
Definition Core.cpp:307
const char * LLVMGetTarget(LLVMModuleRef M)
Obtain the target triple for a module.
Definition Core.cpp:350
LLVMBool LLVMGetInlineAsmCanUnwind(LLVMValueRef InlineAsmVal)
Get if the inline asm snippet may unwind the stack.
Definition Core.cpp:608
const char * LLVMGetModuleInlineAsm(LLVMModuleRef M, size_t *Len)
Get inline assembly for a module.
Definition Core.cpp:522
LLVMBool LLVMGetInlineAsmNeedsAlignedStack(LLVMValueRef InlineAsmVal)
Get if the inline asm snippet needs an aligned stack.
Definition Core.cpp:603
LLVMBool LLVMGetInlineAsmHasSideEffects(LLVMValueRef InlineAsmVal)
Get if the inline asm snippet has side effects.
Definition Core.cpp:598
unsigned LLVMGetNamedMetadataNumOperands(LLVMModuleRef M, const char *Name)
Obtain the number of operands for named metadata in a module.
Definition Core.cpp:1494
void LLVMDumpModule(LLVMModuleRef M)
Dump a representation of a module to stderr.
Definition Core.cpp:471
void LLVMSetTarget(LLVMModuleRef M, const char *TripleStr)
Set the target triple for a module.
Definition Core.cpp:354
LLVMTypeRef LLVMGetInlineAsmFunctionType(LLVMValueRef InlineAsmVal)
Get the function type of the inline assembly snippet.
Definition Core.cpp:593
LLVMBool LLVMIsNewDbgInfoFormat(LLVMModuleRef M)
Soon to be deprecated.
Definition Core.cpp:461
LLVMContextRef LLVMGetModuleContext(LLVMModuleRef M)
Obtain the context to which this module is associated.
Definition Core.cpp:614
LLVMInlineAsmDialect LLVMGetInlineAsmDialect(LLVMValueRef InlineAsmVal)
Get the dialect used by the inline asm snippet.
Definition Core.cpp:577
void LLVMSetModuleInlineAsm(LLVMModuleRef M, const char *Asm)
Deprecated: Use LLVMSetModuleInlineAsm2 instead.
Definition Core.cpp:514
LLVMValueRef LLVMGetNextFunction(LLVMValueRef Fn)
Advance a Function iterator to the next Function.
Definition Core.cpp:2583
const char * LLVMGetModuleIdentifier(LLVMModuleRef M, size_t *Len)
Obtain the identifier of a module.
Definition Core.cpp:316
const char * LLVMGetSourceFileName(LLVMModuleRef M, size_t *Len)
Obtain the module's original source file name.
Definition Core.cpp:326
const char * LLVMGetDataLayoutStr(LLVMModuleRef M)
Obtain the data layout for a module.
Definition Core.cpp:337
LLVMModuleFlagBehavior LLVMModuleFlagEntriesGetFlagBehavior(LLVMModuleFlagEntry *Entries, unsigned Index)
Returns the flag behavior for a module flag entry at a specific index.
Definition Core.cpp:427
void LLVMSetIsNewDbgInfoFormat(LLVMModuleRef M, LLVMBool UseNewFormat)
Soon to be deprecated.
Definition Core.cpp:463
LLVMTypeRef LLVMGetTypeByName(LLVMModuleRef M, const char *Name)
Deprecated: Use LLVMGetTypeByName2 instead.
Definition Core.cpp:897
void LLVMSetModuleIdentifier(LLVMModuleRef M, const char *Ident, size_t Len)
Set the identifier of a module to a string Ident with length Len.
Definition Core.cpp:322
const char * LLVMGetInlineAsmAsmString(LLVMValueRef InlineAsmVal, size_t *Len)
Get the template string used for an inline assembly snippet.
Definition Core.cpp:559
LLVMValueRef LLVMGetInlineAsm(LLVMTypeRef Ty, const char *AsmString, size_t AsmStringSize, const char *Constraints, size_t ConstraintsSize, LLVMBool HasSideEffects, LLVMBool IsAlignStack, LLVMInlineAsmDialect Dialect, LLVMBool CanThrow)
Create the specified uniqued inline asm string.
Definition Core.cpp:539
LLVMValueRef LLVMGetOrInsertFunction(LLVMModuleRef M, const char *Name, size_t NameLen, LLVMTypeRef FunctionTy)
Obtain or insert a function into a module.
Definition Core.cpp:2550
const char * LLVMGetInlineAsmConstraintString(LLVMValueRef InlineAsmVal, size_t *Len)
Get the raw constraint string for an inline assembly snippet.
Definition Core.cpp:568
LLVMNamedMDNodeRef LLVMGetNextNamedMetadata(LLVMNamedMDNodeRef NMD)
Advance a NamedMDNode iterator to the next NamedMDNode.
Definition Core.cpp:1442
void LLVMGetNamedMetadataOperands(LLVMModuleRef M, const char *Name, LLVMValueRef *Dest)
Obtain the named metadata operands for a module.
Definition Core.cpp:1501
LLVMMetadataRef LLVMGetModuleFlag(LLVMModuleRef M, const char *Key, size_t KeyLen)
Add a module-level flag to the module-level flags metadata if it doesn't already exist.
Definition Core.cpp:449
LLVMValueRef LLVMAddFunction(LLVMModuleRef M, const char *Name, LLVMTypeRef FunctionTy)
Add a function to a module under a specified name.
Definition Core.cpp:2544
LLVMValueRef LLVMGetPreviousFunction(LLVMValueRef Fn)
Decrement a Function iterator to the previous Function.
Definition Core.cpp:2591
const char * LLVMGetDebugLocDirectory(LLVMValueRef Val, unsigned *Length)
Return the directory of the debug location for this value, which must be an llvm::Instruction,...
Definition Core.cpp:1521
void LLVMAddNamedMetadataOperand(LLVMModuleRef M, const char *Name, LLVMValueRef Val)
Add an operand to named metadata.
Definition Core.cpp:1511
unsigned LLVMGetDebugLocLine(LLVMValueRef Val)
Return the line number of the debug location for this value, which must be an llvm::Instruction,...
Definition Core.cpp:1569
LLVMMetadataRef LLVMModuleFlagEntriesGetMetadata(LLVMModuleFlagEntry *Entries, unsigned Index)
Returns the metadata for a module flag entry at a specific index.
Definition Core.cpp:442
void LLVMAddModuleFlag(LLVMModuleRef M, LLVMModuleFlagBehavior Behavior, const char *Key, size_t KeyLen, LLVMMetadataRef Val)
Add a module-level flag to the module-level flags metadata if it doesn't already exist.
Definition Core.cpp:454
LLVMValueRef LLVMGetLastFunction(LLVMModuleRef M)
Obtain an iterator to the last Function in a Module.
Definition Core.cpp:2575
LLVMNamedMDNodeRef LLVMGetPreviousNamedMetadata(LLVMNamedMDNodeRef NMD)
Decrement a NamedMDNode iterator to the previous NamedMDNode.
Definition Core.cpp:1450
const char * LLVMGetNamedMetadataName(LLVMNamedMDNodeRef NMD, size_t *NameLen)
Retrieve the name of a NamedMDNode.
Definition Core.cpp:1468
LLVMValueRef LLVMGetNamedFunction(LLVMModuleRef M, const char *Name)
Obtain a Function value from a Module by its name.
Definition Core.cpp:2558
const char * LLVMGetDebugLocFilename(LLVMValueRef Val, unsigned *Length)
Return the filename of the debug location for this value, which must be an llvm::Instruction,...
Definition Core.cpp:1545
void LLVMAppendModuleInlineAsm(LLVMModuleRef M, const char *Asm, size_t Len)
Append inline assembly to a module.
Definition Core.cpp:518
void LLVMSetDataLayout(LLVMModuleRef M, const char *DataLayoutStr)
Set the data layout for a module.
Definition Core.cpp:345
void LLVMDisposeModuleFlagsMetadata(LLVMModuleFlagEntry *Entries)
Destroys module flags metadata entries.
Definition Core.cpp:422
void LLVMDisposeModule(LLVMModuleRef M)
Destroy a module instance.
Definition Core.cpp:312
LLVMNamedMDNodeRef LLVMGetLastNamedMetadata(LLVMModuleRef M)
Obtain an iterator to the last NamedMDNode in a Module.
Definition Core.cpp:1434
void LLVMSetModuleInlineAsm2(LLVMModuleRef M, const char *Asm, size_t Len)
Set inline assembly for a module.
Definition Core.cpp:510
LLVMValueRef LLVMGetFirstFunction(LLVMModuleRef M)
Obtain an iterator to the first Function in a Module.
Definition Core.cpp:2567
LLVMNamedMDNodeRef LLVMGetFirstNamedMetadata(LLVMModuleRef M)
Obtain an iterator to the first NamedMDNode in a Module.
Definition Core.cpp:1426
const char * LLVMModuleFlagEntriesGetKey(LLVMModuleFlagEntry *Entries, unsigned Index, size_t *Len)
Returns the key for a module flag entry at a specific index.
Definition Core.cpp:434
void LLVMSetSourceFileName(LLVMModuleRef M, const char *Name, size_t Len)
Set the original source file name of a module to a string Name with length Len.
Definition Core.cpp:332
LLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename, char **ErrorMessage)
Print a representation of a module to a file.
Definition Core.cpp:476
const char * LLVMGetDataLayout(LLVMModuleRef M)
Definition Core.cpp:341
LLVMModuleFlagEntry * LLVMCopyModuleFlagsMetadata(LLVMModuleRef M, size_t *Len)
Returns the module flags as an array of flag-key-value triples.
Definition Core.cpp:405
LLVMOperandBundleRef LLVMCreateOperandBundle(const char *Tag, size_t TagLen, LLVMValueRef *Args, unsigned NumArgs)
Create a new operand bundle.
Definition Core.cpp:2909
unsigned LLVMGetNumOperandBundleArgs(LLVMOperandBundleRef Bundle)
Obtain the number of operands for an operand bundle.
Definition Core.cpp:2926
const char * LLVMGetOperandBundleTag(LLVMOperandBundleRef Bundle, size_t *Len)
Obtain the tag of an operand bundle as a string.
Definition Core.cpp:2920
void LLVMDisposeOperandBundle(LLVMOperandBundleRef Bundle)
Destroy an operand bundle.
Definition Core.cpp:2916
LLVMValueRef LLVMGetOperandBundleArgAtIndex(LLVMOperandBundleRef Bundle, unsigned Index)
Obtain the operand for an operand bundle at the given index.
Definition Core.cpp:2930
LLVMPassManagerRef LLVMCreateFunctionPassManager(LLVMModuleProviderRef P)
Deprecated: Use LLVMCreateFunctionPassManagerForModule instead.
Definition Core.cpp:4872
LLVMPassManagerRef LLVMCreateFunctionPassManagerForModule(LLVMModuleRef M)
Constructs a new function-by-function pass pipeline over the module provider.
Definition Core.cpp:4868
LLVMBool LLVMFinalizeFunctionPassManager(LLVMPassManagerRef FPM)
Finalizes all of the function passes scheduled in the function pass manager.
Definition Core.cpp:4889
void LLVMDisposePassManager(LLVMPassManagerRef PM)
Frees the memory of a pass pipeline.
Definition Core.cpp:4893
LLVMBool LLVMRunFunctionPassManager(LLVMPassManagerRef FPM, LLVMValueRef F)
Executes all of the function passes scheduled in the function pass manager on the provided function.
Definition Core.cpp:4885
LLVMBool LLVMInitializeFunctionPassManager(LLVMPassManagerRef FPM)
Initializes all of the function passes scheduled in the function pass manager.
Definition Core.cpp:4881
LLVMBool LLVMRunPassManager(LLVMPassManagerRef PM, LLVMModuleRef M)
Initializes, executes on the provided module, and finalizes all of the passes scheduled in the pass m...
Definition Core.cpp:4877
LLVMPassManagerRef LLVMCreatePassManager()
Constructs a new whole-module pass pipeline.
Definition Core.cpp:4864
void LLVMStopMultithreaded()
Deprecated: Multi-threading can only be enabled/disabled with the compile time define LLVM_ENABLE_THR...
Definition Core.cpp:4903
LLVMBool LLVMStartMultithreaded()
Deprecated: Multi-threading can only be enabled/disabled with the compile time define LLVM_ENABLE_THR...
Definition Core.cpp:4899
LLVMBool LLVMIsMultithreaded()
Check whether LLVM is executing in thread-safe mode or not.
Definition Core.cpp:4906
LLVMTypeRef LLVMByteTypeInContext(LLVMContextRef C, unsigned NumBits)
Obtain a byte type from a context with specified bit width.
Definition Core.cpp:700
unsigned LLVMGetByteTypeWidth(LLVMTypeRef ByteTy)
Definition Core.cpp:704
LLVMTypeRef LLVMHalfTypeInContext(LLVMContextRef C)
Obtain a 16-bit floating point type from a context.
Definition Core.cpp:760
LLVMTypeRef LLVMBFloatTypeInContext(LLVMContextRef C)
Obtain a 16-bit brain floating point type from a context.
Definition Core.cpp:763
LLVMTypeRef LLVMPPCFP128TypeInContext(LLVMContextRef C)
Obtain a 128-bit floating point type (two 64-bits) from a context.
Definition Core.cpp:778
LLVMTypeRef LLVMDoubleTypeInContext(LLVMContextRef C)
Obtain a 64-bit floating point type from a context.
Definition Core.cpp:769
LLVMTypeRef LLVMFloatTypeInContext(LLVMContextRef C)
Obtain a 32-bit floating point type from a context.
Definition Core.cpp:766
LLVMTypeRef LLVMFP128TypeInContext(LLVMContextRef C)
Obtain a 128-bit floating point type (112-bit mantissa) from a context.
Definition Core.cpp:775
LLVMTypeRef LLVMX86FP80TypeInContext(LLVMContextRef C)
Obtain a 80-bit floating point type (X87) from a context.
Definition Core.cpp:772
LLVMTypeRef LLVMGetReturnType(LLVMTypeRef FunctionTy)
Obtain the Type this function Type returns.
Definition Core.cpp:823
LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType, LLVMTypeRef *ParamTypes, unsigned ParamCount, LLVMBool IsVarArg)
Obtain a function type consisting of a specified signature.
Definition Core.cpp:812
LLVMBool LLVMIsFunctionVarArg(LLVMTypeRef FunctionTy)
Returns whether a function type is variadic.
Definition Core.cpp:819
unsigned LLVMCountParamTypes(LLVMTypeRef FunctionTy)
Obtain the number of parameters this function accepts.
Definition Core.cpp:827
void LLVMGetParamTypes(LLVMTypeRef FunctionTy, LLVMTypeRef *Dest)
Obtain the types of a function's parameters.
Definition Core.cpp:831
LLVMTypeRef LLVMInt1TypeInContext(LLVMContextRef C)
Obtain an integer type from a context with specified bit width.
Definition Core.cpp:710
LLVMTypeRef LLVMInt8TypeInContext(LLVMContextRef C)
Definition Core.cpp:713
LLVMTypeRef LLVMInt32TypeInContext(LLVMContextRef C)
Definition Core.cpp:719
LLVMTypeRef LLVMIntTypeInContext(LLVMContextRef C, unsigned NumBits)
Definition Core.cpp:728
LLVMTypeRef LLVMInt64TypeInContext(LLVMContextRef C)
Definition Core.cpp:722
LLVMTypeRef LLVMInt16TypeInContext(LLVMContextRef C)
Definition Core.cpp:716
unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy)
Definition Core.cpp:754
LLVMTypeRef LLVMInt128TypeInContext(LLVMContextRef C)
Definition Core.cpp:725
unsigned LLVMGetTargetExtTypeNumTypeParams(LLVMTypeRef TargetExtTy)
Obtain the number of type parameters for this target extension type.
Definition Core.cpp:1026
LLVMTypeRef LLVMX86AMXTypeInContext(LLVMContextRef C)
Create a X86 AMX type in a context.
Definition Core.cpp:781
const char * LLVMGetTargetExtTypeName(LLVMTypeRef TargetExtTy)
Obtain the name for this target extension type.
Definition Core.cpp:1021
LLVMTypeRef LLVMVoidTypeInContext(LLVMContextRef C)
Create a void type in a context.
Definition Core.cpp:990
LLVMTypeRef LLVMTokenTypeInContext(LLVMContextRef C)
Create a token type in a context.
Definition Core.cpp:996
unsigned LLVMGetTargetExtTypeNumIntParams(LLVMTypeRef TargetExtTy)
Obtain the number of int parameters for this target extension type.
Definition Core.cpp:1037
LLVMTypeRef LLVMLabelTypeInContext(LLVMContextRef C)
Create a label type in a context.
Definition Core.cpp:993
LLVMTypeRef LLVMMetadataTypeInContext(LLVMContextRef C)
Create a metadata type in a context.
Definition Core.cpp:999
LLVMTypeRef LLVMGetTargetExtTypeTypeParam(LLVMTypeRef TargetExtTy, unsigned Idx)
Get the type parameter at the given index for the target extension type.
Definition Core.cpp:1031
LLVMTypeRef LLVMTargetExtTypeInContext(LLVMContextRef C, const char *Name, LLVMTypeRef *TypeParams, unsigned TypeParamCount, unsigned *IntParams, unsigned IntParamCount)
Create a target extension type in LLVM context.
Definition Core.cpp:1010
unsigned LLVMGetTargetExtTypeIntParam(LLVMTypeRef TargetExtTy, unsigned Idx)
Get the int parameter at the given index for the target extension type.
Definition Core.cpp:1042
LLVMValueRef LLVMGetConstantPtrAuthAddrDiscriminator(LLVMValueRef PtrAuth)
Get the address discriminator value for the associated ConstantPtrAuth constant.
Definition Core.cpp:980
LLVMBool LLVMPointerTypeIsOpaque(LLVMTypeRef Ty)
Determine whether a pointer is opaque.
Definition Core.cpp:928
LLVMTypeRef LLVMPointerTypeInContext(LLVMContextRef C, unsigned AddressSpace)
Create an opaque pointer type in a context.
Definition Core.cpp:986
LLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType, unsigned ElementCount)
Create a vector type that contains a defined type and has a specific number of elements.
Definition Core.cpp:932
LLVMTypeRef LLVMGetElementType(LLVMTypeRef WrappedTy)
Obtain the element type of an array or vector type.
Definition Core.cpp:941
LLVMTypeRef LLVMScalableVectorType(LLVMTypeRef ElementType, unsigned ElementCount)
Create a vector type that contains a defined type and has a scalable number of elements.
Definition Core.cpp:936
LLVMValueRef LLVMGetConstantPtrAuthDiscriminator(LLVMValueRef PtrAuth)
Get the discriminator value for the associated ConstantPtrAuth constant.
Definition Core.cpp:976
uint64_t LLVMGetArrayLength2(LLVMTypeRef ArrayTy)
Obtain the length of an array type.
Definition Core.cpp:956
LLVMValueRef LLVMGetConstantPtrAuthKey(LLVMValueRef PtrAuth)
Get the key value for the associated ConstantPtrAuth constant.
Definition Core.cpp:972
unsigned LLVMGetArrayLength(LLVMTypeRef ArrayTy)
Obtain the length of an array type.
Definition Core.cpp:952
LLVMValueRef LLVMGetConstantPtrAuthPointer(LLVMValueRef PtrAuth)
Get the pointer value for the associated ConstantPtrAuth constant.
Definition Core.cpp:968
unsigned LLVMGetPointerAddressSpace(LLVMTypeRef PointerTy)
Obtain the address space of a pointer type.
Definition Core.cpp:960
LLVMTypeRef LLVMArrayType2(LLVMTypeRef ElementType, uint64_t ElementCount)
Create a fixed size array type that refers to a specific type.
Definition Core.cpp:919
unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy)
Obtain the (possibly scalable) number of elements in a vector type.
Definition Core.cpp:964
LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount)
Create a fixed size array type that refers to a specific type.
Definition Core.cpp:915
void LLVMGetSubtypes(LLVMTypeRef Tp, LLVMTypeRef *Arr)
Returns type's subtypes.
Definition Core.cpp:907
LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, unsigned AddressSpace)
Create a pointer type that points to a defined type.
Definition Core.cpp:923
unsigned LLVMGetNumContainedTypes(LLVMTypeRef Tp)
Return the number of types in the derived type.
Definition Core.cpp:948
LLVMTypeRef LLVMStructTypeInContext(LLVMContextRef C, LLVMTypeRef *ElementTypes, unsigned ElementCount, LLVMBool Packed)
Create a new structure type in a context.
Definition Core.cpp:839
void LLVMGetStructElementTypes(LLVMTypeRef StructTy, LLVMTypeRef *Dest)
Get the elements within a structure.
Definition Core.cpp:874
LLVMTypeRef LLVMStructGetTypeAtIndex(LLVMTypeRef StructTy, unsigned i)
Get the type of the element at a given index in the structure.
Definition Core.cpp:880
LLVMBool LLVMIsPackedStruct(LLVMTypeRef StructTy)
Determine whether a structure is packed.
Definition Core.cpp:885
LLVMTypeRef LLVMStructCreateNamed(LLVMContextRef C, const char *Name)
Create an empty structure in a context having a specified name.
Definition Core.cpp:851
void LLVMStructSetBody(LLVMTypeRef StructTy, LLVMTypeRef *ElementTypes, unsigned ElementCount, LLVMBool Packed)
Set the contents of a structure type.
Definition Core.cpp:864
LLVMBool LLVMIsOpaqueStruct(LLVMTypeRef StructTy)
Determine whether a structure is opaque.
Definition Core.cpp:889
unsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy)
Get the number of elements defined inside the structure.
Definition Core.cpp:870
const char * LLVMGetStructName(LLVMTypeRef Ty)
Obtain the name of a structure.
Definition Core.cpp:856
LLVMBool LLVMIsLiteralStruct(LLVMTypeRef StructTy)
Determine whether a structure is literal.
Definition Core.cpp:893
void LLVMDumpType(LLVMTypeRef Ty)
Dump a representation of a type to stderr.
Definition Core.cpp:682
LLVMBool LLVMTypeIsSized(LLVMTypeRef Ty)
Whether the type has a known size.
Definition Core.cpp:673
LLVMContextRef LLVMGetTypeContext(LLVMTypeRef Ty)
Obtain the context to which this type instance is associated.
Definition Core.cpp:678
char * LLVMPrintTypeToString(LLVMTypeRef Ty)
Return a string representation of the type.
Definition Core.cpp:686
LLVMTypeKind LLVMGetTypeKind(LLVMTypeRef Ty)
Obtain the enumerated type of a Type instance.
Definition Core.cpp:623
LLVMTailCallKind
Tail call kind for LLVMSetTailCallKind and LLVMGetTailCallKind.
Definition Core.h:505
LLVMLinkage
Definition Core.h:182
LLVMOpcode
External users depend on the following values being stable.
Definition Core.h:63
LLVMRealPredicate
Definition Core.h:316
LLVMTypeKind
Definition Core.h:157
LLVMDLLStorageClass
Definition Core.h:217
LLVMValueKind
Definition Core.h:267
unsigned LLVMAttributeIndex
Definition Core.h:496
LLVMDbgRecordKind
Definition Core.h:549
LLVMIntPredicate
Definition Core.h:303
unsigned LLVMFastMathFlags
Flags to indicate what fast-math-style optimizations are allowed on operations.
Definition Core.h:533
LLVMUnnamedAddr
Definition Core.h:211
LLVMModuleFlagBehavior
Definition Core.h:433
LLVMDiagnosticSeverity
Definition Core.h:421
LLVMVisibility
Definition Core.h:205
LLVMAtomicRMWBinOp
Definition Core.h:370
LLVMThreadLocalMode
Definition Core.h:335
unsigned LLVMGEPNoWrapFlags
Flags that constrain the allowed wrap semantics of a getelementptr instruction.
Definition Core.h:547
LLVMAtomicOrdering
Definition Core.h:343
LLVMInlineAsmDialect
Definition Core.h:428
@ LLVMDLLImportLinkage
Obsolete.
Definition Core.h:196
@ LLVMInternalLinkage
Rename collisions when linking (static functions)
Definition Core.h:193
@ LLVMLinkOnceAnyLinkage
Keep one copy of function when linking (inline)
Definition Core.h:185
@ LLVMExternalLinkage
Externally visible function.
Definition Core.h:183
@ LLVMExternalWeakLinkage
ExternalWeak linkage description.
Definition Core.h:198
@ LLVMLinkOnceODRLinkage
Same, but only replaced by something equivalent.
Definition Core.h:186
@ LLVMPrivateLinkage
Like Internal, but omit from symbol table.
Definition Core.h:195
@ LLVMDLLExportLinkage
Obsolete.
Definition Core.h:197
@ LLVMLinkerPrivateLinkage
Like Private, but linker removes.
Definition Core.h:201
@ LLVMWeakODRLinkage
Same, but only replaced by something equivalent.
Definition Core.h:190
@ LLVMGhostLinkage
Obsolete.
Definition Core.h:199
@ LLVMWeakAnyLinkage
Keep one copy of function when linking (weak)
Definition Core.h:189
@ LLVMAppendingLinkage
Special purpose, only applies to global arrays.
Definition Core.h:192
@ LLVMCommonLinkage
Tentative definitions.
Definition Core.h:200
@ LLVMLinkOnceODRAutoHideLinkage
Obsolete.
Definition Core.h:188
@ LLVMLinkerPrivateWeakLinkage
Like LinkerPrivate, but is weak.
Definition Core.h:202
@ LLVMAvailableExternallyLinkage
Definition Core.h:184
@ LLVMFastMathAllowReassoc
Definition Core.h:513
@ LLVMFastMathNoSignedZeros
Definition Core.h:516
@ LLVMFastMathApproxFunc
Definition Core.h:519
@ LLVMFastMathNoInfs
Definition Core.h:515
@ LLVMFastMathNoNaNs
Definition Core.h:514
@ LLVMFastMathNone
Definition Core.h:520
@ LLVMFastMathAllowContract
Definition Core.h:518
@ LLVMFastMathAllowReciprocal
Definition Core.h:517
@ LLVMGEPFlagInBounds
Definition Core.h:536
@ LLVMGEPFlagNUSW
Definition Core.h:537
@ LLVMGEPFlagNUW
Definition Core.h:538
@ LLVMHalfTypeKind
16 bit floating point type
Definition Core.h:159
@ LLVMFP128TypeKind
128 bit floating point type (112-bit mantissa)
Definition Core.h:163
@ LLVMIntegerTypeKind
Arbitrary bit width integers.
Definition Core.h:166
@ LLVMPointerTypeKind
Pointers.
Definition Core.h:170
@ LLVMX86_FP80TypeKind
80 bit floating point type (X87)
Definition Core.h:162
@ LLVMX86_AMXTypeKind
X86 AMX.
Definition Core.h:177
@ LLVMMetadataTypeKind
Metadata.
Definition Core.h:172
@ LLVMByteTypeKind
Arbitrary bit width bytes.
Definition Core.h:179
@ LLVMScalableVectorTypeKind
Scalable SIMD vector type.
Definition Core.h:175
@ LLVMArrayTypeKind
Arrays.
Definition Core.h:169
@ LLVMBFloatTypeKind
16 bit brain floating point type
Definition Core.h:176
@ LLVMStructTypeKind
Structures.
Definition Core.h:168
@ LLVMLabelTypeKind
Labels.
Definition Core.h:165
@ LLVMDoubleTypeKind
64 bit floating point type
Definition Core.h:161
@ LLVMVoidTypeKind
type with no size
Definition Core.h:158
@ LLVMTokenTypeKind
Tokens.
Definition Core.h:174
@ LLVMFloatTypeKind
32 bit floating point type
Definition Core.h:160
@ LLVMFunctionTypeKind
Functions.
Definition Core.h:167
@ LLVMVectorTypeKind
Fixed width SIMD vector type.
Definition Core.h:171
@ LLVMPPC_FP128TypeKind
128 bit floating point type (two 64-bits)
Definition Core.h:164
@ LLVMTargetExtTypeKind
Target extension type.
Definition Core.h:178
@ LLVMInstructionValueKind
Definition Core.h:297
@ LLVMDbgRecordValue
Definition Core.h:552
@ LLVMDbgRecordDeclare
Definition Core.h:551
@ LLVMDbgRecordLabel
Definition Core.h:550
@ LLVMDbgRecordAssign
Definition Core.h:553
@ LLVMGlobalUnnamedAddr
Address of the GV is globally insignificant.
Definition Core.h:214
@ LLVMLocalUnnamedAddr
Address of the GV is locally insignificant.
Definition Core.h:213
@ LLVMNoUnnamedAddr
Address of the GV is significant.
Definition Core.h:212
@ LLVMModuleFlagBehaviorRequire
Adds a requirement that another module flag be present and have a specified value after linking is pe...
Definition Core.h:459
@ LLVMModuleFlagBehaviorWarning
Emits a warning if two values disagree.
Definition Core.h:447
@ LLVMModuleFlagBehaviorOverride
Uses the specified value, regardless of the behavior or value of the other module.
Definition Core.h:467
@ LLVMModuleFlagBehaviorAppendUnique
Appends the two values, which are required to be metadata nodes.
Definition Core.h:481
@ LLVMModuleFlagBehaviorAppend
Appends the two values, which are required to be metadata nodes.
Definition Core.h:473
@ LLVMModuleFlagBehaviorError
Emits an error if two values disagree, otherwise the resulting value is that of the operands.
Definition Core.h:440
@ LLVMDSWarning
Definition Core.h:423
@ LLVMDSNote
Definition Core.h:425
@ LLVMDSError
Definition Core.h:422
@ LLVMDSRemark
Definition Core.h:424
@ LLVMAtomicRMWBinOpXor
Xor a value and return the old one.
Definition Core.h:377
@ LLVMAtomicRMWBinOpXchg
Set the new value and return the one old.
Definition Core.h:371
@ LLVMAtomicRMWBinOpSub
Subtract a value and return the old one.
Definition Core.h:373
@ LLVMAtomicRMWBinOpUMax
Sets the value if it's greater than the original using an unsigned comparison and return the old one.
Definition Core.h:384
@ LLVMAtomicRMWBinOpUSubSat
Subtracts the value, clamping to zero.
Definition Core.h:406
@ LLVMAtomicRMWBinOpAnd
And a value and return the old one.
Definition Core.h:374
@ LLVMAtomicRMWBinOpUDecWrap
Decrements the value, wrapping back to the input value when decremented below zero.
Definition Core.h:402
@ LLVMAtomicRMWBinOpFMax
Sets the value if it's greater than the original using an floating point comparison and return the ol...
Definition Core.h:394
@ LLVMAtomicRMWBinOpMin
Sets the value if it's Smaller than the original using a signed comparison and return the old one.
Definition Core.h:381
@ LLVMAtomicRMWBinOpOr
OR a value and return the old one.
Definition Core.h:376
@ LLVMAtomicRMWBinOpFMin
Sets the value if it's smaller than the original using an floating point comparison and return the ol...
Definition Core.h:397
@ LLVMAtomicRMWBinOpMax
Sets the value if it's greater than the original using a signed comparison and return the old one.
Definition Core.h:378
@ LLVMAtomicRMWBinOpFMaximum
Sets the value if it's greater than the original using an floating point comparison and return the ol...
Definition Core.h:407
@ LLVMAtomicRMWBinOpFMinimum
Sets the value if it's smaller than the original using an floating point comparison and return the ol...
Definition Core.h:410
@ LLVMAtomicRMWBinOpFMinimumNum
Sets the value if it's smaller than the original using an floating point comparison and return the ol...
Definition Core.h:416
@ LLVMAtomicRMWBinOpUIncWrap
Increments the value, wrapping back to zero when incremented above input value.
Definition Core.h:400
@ LLVMAtomicRMWBinOpFMaximumNum
Sets the value if it's greater than the original using an floating point comparison and return the ol...
Definition Core.h:413
@ LLVMAtomicRMWBinOpFAdd
Add a floating point value and return the old one.
Definition Core.h:390
@ LLVMAtomicRMWBinOpFSub
Subtract a floating point value and return the old one.
Definition Core.h:392
@ LLVMAtomicRMWBinOpAdd
Add a value and return the old one.
Definition Core.h:372
@ LLVMAtomicRMWBinOpUMin
Sets the value if it's greater than the original using an unsigned comparison and return the old one.
Definition Core.h:387
@ LLVMAtomicRMWBinOpNand
Not-And a value and return the old one.
Definition Core.h:375
@ LLVMAtomicRMWBinOpUSubCond
Subtracts the value only if no unsigned overflow.
Definition Core.h:404
@ LLVMGeneralDynamicTLSModel
Definition Core.h:337
@ LLVMLocalDynamicTLSModel
Definition Core.h:338
@ LLVMNotThreadLocal
Definition Core.h:336
@ LLVMInitialExecTLSModel
Definition Core.h:339
@ LLVMLocalExecTLSModel
Definition Core.h:340
@ LLVMAtomicOrderingAcquireRelease
provides both an Acquire and a Release barrier (for fences and operations which both read and write m...
Definition Core.h:356
@ LLVMAtomicOrderingRelease
Release is similar to Acquire, but with a barrier of the sort necessary to release a lock.
Definition Core.h:353
@ LLVMAtomicOrderingAcquire
Acquire provides a barrier of the sort necessary to acquire a lock to access other memory with normal...
Definition Core.h:350
@ LLVMAtomicOrderingMonotonic
guarantees that if you take all the operations affecting a specific address, a consistent ordering ex...
Definition Core.h:347
@ LLVMAtomicOrderingSequentiallyConsistent
provides Acquire semantics for loads and Release semantics for stores.
Definition Core.h:360
@ LLVMAtomicOrderingNotAtomic
A load or store which is not atomic.
Definition Core.h:344
@ LLVMAtomicOrderingUnordered
Lowest level of atomicity, guarantees somewhat sane results, lock free.
Definition Core.h:345
@ LLVMInlineAsmDialectATT
Definition Core.h:429
@ LLVMInlineAsmDialectIntel
Definition Core.h:430
LLVMValueRef LLVMGetLastInstruction(LLVMBasicBlockRef BB)
Obtain the last instruction in a basic block.
Definition Core.cpp:3077
void LLVMMoveBasicBlockAfter(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos)
Move a basic block to after another one.
Definition Core.cpp:3059
LLVMBasicBlockRef LLVMGetFirstBasicBlock(LLVMValueRef Fn)
Obtain the first basic block in a function.
Definition Core.cpp:2975
LLVMBasicBlockRef LLVMCreateBasicBlockInContext(LLVMContextRef C, const char *Name)
Create a new basic block without inserting it into a function.
Definition Core.cpp:3007
LLVMBasicBlockRef LLVMGetPreviousBasicBlock(LLVMBasicBlockRef BB)
Go backwards in a basic block iterator.
Definition Core.cpp:2999
LLVMBasicBlockRef LLVMGetLastBasicBlock(LLVMValueRef Fn)
Obtain the last basic block in a function.
Definition Core.cpp:2983
LLVMValueRef LLVMGetBasicBlockTerminator(LLVMBasicBlockRef BB)
Obtain the terminator instruction for a basic block.
Definition Core.cpp:2957
const char * LLVMGetBasicBlockName(LLVMBasicBlockRef BB)
Obtain the string name of a basic block.
Definition Core.cpp:2949
void LLVMAppendExistingBasicBlock(LLVMValueRef Fn, LLVMBasicBlockRef BB)
Append the given basic block to the basic block list of the given function.
Definition Core.cpp:3020
void LLVMDeleteBasicBlock(LLVMBasicBlockRef BBRef)
Remove a basic block from a function and delete it.
Definition Core.cpp:3047
LLVMBasicBlockRef LLVMInsertBasicBlockInContext(LLVMContextRef C, LLVMBasicBlockRef BBRef, const char *Name)
Insert a basic block in a function before another basic block.
Definition Core.cpp:3035
void LLVMGetBasicBlocks(LLVMValueRef FnRef, LLVMBasicBlockRef *BasicBlocksRefs)
Obtain all of the basic blocks in a function.
Definition Core.cpp:2965
void LLVMMoveBasicBlockBefore(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos)
Move a basic block to before another one.
Definition Core.cpp:3055
LLVMValueRef LLVMGetBasicBlockParent(LLVMBasicBlockRef BB)
Obtain the function to which a basic block belongs.
Definition Core.cpp:2953
LLVMBasicBlockRef LLVMGetEntryBasicBlock(LLVMValueRef Fn)
Obtain the basic block that corresponds to the entry point of a function.
Definition Core.cpp:2971
LLVMValueRef LLVMGetFirstInstruction(LLVMBasicBlockRef BB)
Obtain the first instruction in a basic block.
Definition Core.cpp:3069
void LLVMInsertExistingBasicBlockAfterInsertBlock(LLVMBuilderRef Builder, LLVMBasicBlockRef BB)
Insert the given basic block after the insertion point of the given builder.
Definition Core.cpp:3012
LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef BB)
Convert a basic block instance to a value type.
Definition Core.cpp:2937
LLVMBasicBlockRef LLVMValueAsBasicBlock(LLVMValueRef Val)
Convert an LLVMValueRef to an LLVMBasicBlockRef instance.
Definition Core.cpp:2945
void LLVMRemoveBasicBlockFromParent(LLVMBasicBlockRef BBRef)
Remove a basic block from a function.
Definition Core.cpp:3051
LLVMBasicBlockRef LLVMGetNextBasicBlock(LLVMBasicBlockRef BB)
Advance a basic block iterator.
Definition Core.cpp:2991
unsigned LLVMCountBasicBlocks(LLVMValueRef FnRef)
Obtain the number of basic blocks in a function.
Definition Core.cpp:2961
LLVMBasicBlockRef LLVMAppendBasicBlockInContext(LLVMContextRef C, LLVMValueRef FnRef, const char *Name)
Append a basic block to the end of a function.
Definition Core.cpp:3025
LLVMBool LLVMValueIsBasicBlock(LLVMValueRef Val)
Determine whether an LLVMValueRef is itself a basic block.
Definition Core.cpp:2941
LLVMValueRef LLVMConstantPtrAuth(LLVMValueRef Ptr, LLVMValueRef Key, LLVMValueRef Disc, LLVMValueRef AddrDisc)
Create a ConstantPtrAuth constant with the given values.
Definition Core.cpp:1801
LLVMValueRef LLVMGetAggregateElement(LLVMValueRef C, unsigned Idx)
Get element of a constant aggregate (struct, array or vector) at the specified index.
Definition Core.cpp:1730
LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size)
Create a ConstantVector from values.
Definition Core.cpp:1796
LLVMValueRef LLVMConstStringInContext2(LLVMContextRef C, const char *Str, size_t Length, LLVMBool DontNullTerminate)
Create a ConstantDataSequential and initialize it with a string.
Definition Core.cpp:1715
LLVMValueRef LLVMConstDataArray(LLVMTypeRef ElementTy, const char *Data, size_t SizeInBytes)
Create a ConstantDataArray from raw values.
Definition Core.cpp:1766
LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy, LLVMValueRef *ConstantVals, unsigned Length)
Create a ConstantArray from values.
Definition Core.cpp:1754
LLVMBool LLVMIsConstantString(LLVMValueRef C)
Returns true if the specified constant is an array of i8.
Definition Core.cpp:1738
LLVMValueRef LLVMConstStringInContext(LLVMContextRef C, const char *Str, unsigned Length, LLVMBool DontNullTerminate)
Create a ConstantDataSequential and initialize it with a string.
Definition Core.cpp:1706
LLVMValueRef LLVMConstArray2(LLVMTypeRef ElementTy, LLVMValueRef *ConstantVals, uint64_t Length)
Create a ConstantArray from values.
Definition Core.cpp:1760
const char * LLVMGetAsString(LLVMValueRef C, size_t *Length)
Get the given constant data sequential as a string.
Definition Core.cpp:1742
LLVMValueRef LLVMConstNamedStruct(LLVMTypeRef StructTy, LLVMValueRef *ConstantVals, unsigned Count)
Create a non-anonymous ConstantStruct from values.
Definition Core.cpp:1787
const char * LLVMGetRawDataValues(LLVMValueRef C, size_t *SizeInBytes)
Get the raw, underlying bytes of the given constant data sequential.
Definition Core.cpp:1748
LLVMValueRef LLVMConstStructInContext(LLVMContextRef C, LLVMValueRef *ConstantVals, unsigned Count, LLVMBool Packed)
Create an anonymous ConstantStruct with the specified values.
Definition Core.cpp:1773
LLVMValueRef LLVMConstAddrSpaceCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition Core.cpp:2008
LLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition Core.cpp:1893
LLVMValueRef LLVMConstSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition Core.cpp:1910
LLVMValueRef LLVMConstPtrAdd(LLVMValueRef ConstantVal, LLVMValueRef ConstantOffset, LLVMGEPNoWrapFlags NoWrapFlags)
Creates a constant ptradd expression (getelementptr i8).
Definition Core.cpp:1967
LLVMValueRef LLVMConstTruncOrBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition Core.cpp:2014
LLVMValueRef LLVMConstBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition Core.cpp:2003
LLVMValueRef LLVMConstNUWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition Core.cpp:1921
LLVMOpcode LLVMGetConstOpcode(LLVMValueRef ConstantVal)
Definition Core.cpp:1860
LLVMValueRef LLVMConstExtractElement(LLVMValueRef VectorConstant, LLVMValueRef IndexConstant)
Definition Core.cpp:2026
LLVMValueRef LLVMConstPtrAddFromIndices(LLVMTargetDataRef DataLayout, LLVMTypeRef Ty, LLVMValueRef ConstantVal, LLVMValueRef *ConstantIndices, unsigned NumIndices, LLVMGEPNoWrapFlags NoWrapFlags)
Creates a constant ptradd expression (getelementptr i8) by converting the provided GEP indices for th...
Definition Core.cpp:1975
LLVMValueRef LLVMConstNSWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition Core.cpp:1898
LLVMValueRef LLVMConstNeg(LLVMValueRef ConstantVal)
Definition Core.cpp:1876
LLVMValueRef LLVMConstPointerCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition Core.cpp:2020
LLVMValueRef LLVMConstInsertElement(LLVMValueRef VectorConstant, LLVMValueRef ElementValueConstant, LLVMValueRef IndexConstant)
Definition Core.cpp:2032
LLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition Core.cpp:1927
LLVMValueRef LLVMConstNSWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition Core.cpp:1915
LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant, LLVMValueRef VectorBConstant, LLVMValueRef MaskConstant)
Definition Core.cpp:2040
LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition Core.cpp:1988
LLVMValueRef LLVMBlockAddress(LLVMValueRef F, LLVMBasicBlockRef BB)
Definition Core.cpp:2058
LLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal)
Definition Core.cpp:1889
LLVMValueRef LLVMConstNUWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition Core.cpp:1904
LLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition Core.cpp:1993
LLVMValueRef LLVMConstIntToPtr(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition Core.cpp:1998
LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty, const char *AsmString, const char *Constraints, LLVMBool HasSideEffects, LLVMBool IsAlignStack)
Deprecated: Use LLVMGetInlineAsm instead.
Definition Core.cpp:2050
LLVMValueRef LLVMConstNSWNeg(LLVMValueRef ConstantVal)
Definition Core.cpp:1880
LLVMValueRef LLVMGetBlockAddressFunction(LLVMValueRef BlockAddr)
Gets the function associated with a given BlockAddress constant value.
Definition Core.cpp:2062
LLVMBasicBlockRef LLVMGetBlockAddressBasicBlock(LLVMValueRef BlockAddr)
Gets the basic block associated with a given BlockAddress constant value.
Definition Core.cpp:2066
void LLVMSetDSOLocal(LLVMValueRef Global, LLVMBool IsDSOLocal)
Sets whether the global value is marked as dso_local.
Definition Core.cpp:2233
LLVMUnnamedAddr LLVMGetUnnamedAddress(LLVMValueRef Global)
Definition Core.cpp:2204
LLVMTypeRef LLVMGlobalGetValueType(LLVMValueRef Global)
Returns the "value type" of a global value.
Definition Core.cpp:2247
unsigned LLVMGetAlignment(LLVMValueRef V)
Obtain the preferred alignment of the value.
Definition Core.cpp:2253
void LLVMSetSection(LLVMValueRef Global, const char *Section)
Definition Core.cpp:2180
void LLVMSetUnnamedAddress(LLVMValueRef Global, LLVMUnnamedAddr UnnamedAddr)
Definition Core.cpp:2216
void LLVMGlobalSetMetadata(LLVMValueRef Global, unsigned Kind, LLVMMetadataRef MD)
Sets a metadata attachment, erasing the existing metadata attachment if it already exists for the giv...
Definition Core.cpp:2328
void LLVMSetLinkage(LLVMValueRef Global, LLVMLinkage Linkage)
Definition Core.cpp:2109
void LLVMSetUnnamedAddr(LLVMValueRef Global, LLVMBool HasUnnamedAddr)
Deprecated: Use LLVMSetUnnamedAddress instead.
Definition Core.cpp:2241
LLVMModuleRef LLVMGetGlobalParent(LLVMValueRef Global)
Definition Core.cpp:2072
LLVMBool LLVMIsDSOLocal(LLVMValueRef Global)
Returns whether the global value is marked as dso_local, i.e.
Definition Core.cpp:2229
unsigned LLVMValueMetadataEntriesGetKind(LLVMValueMetadataEntry *Entries, unsigned Index)
Returns the kind of a value metadata entry at a specific index.
Definition Core.cpp:2309
void LLVMSetDLLStorageClass(LLVMValueRef Global, LLVMDLLStorageClass Class)
Definition Core.cpp:2199
LLVMVisibility LLVMGetVisibility(LLVMValueRef Global)
Definition Core.cpp:2184
LLVMValueMetadataEntry * LLVMGlobalCopyAllMetadata(LLVMValueRef Value, size_t *NumEntries)
Retrieves an array of metadata entries representing the metadata attached to this value.
Definition Core.cpp:2297
void LLVMSetAlignment(LLVMValueRef V, unsigned Bytes)
Set the preferred alignment of the value.
Definition Core.cpp:2275
const char * LLVMGetSection(LLVMValueRef Global)
Definition Core.cpp:2174
void LLVMSetVisibility(LLVMValueRef Global, LLVMVisibility Viz)
Definition Core.cpp:2189
LLVMLinkage LLVMGetLinkage(LLVMValueRef Global)
Definition Core.cpp:2080
void LLVMGlobalEraseMetadata(LLVMValueRef Global, unsigned Kind)
Erases a metadata attachment of the given kind if it exists.
Definition Core.cpp:2338
LLVMDLLStorageClass LLVMGetDLLStorageClass(LLVMValueRef Global)
Definition Core.cpp:2194
LLVMBool LLVMIsDeclaration(LLVMValueRef Global)
Definition Core.cpp:2076
void LLVMGlobalClearMetadata(LLVMValueRef Global)
Removes all metadata attachments from this value.
Definition Core.cpp:2342
void LLVMGlobalAddMetadata(LLVMValueRef Global, unsigned Kind, LLVMMetadataRef MD)
Adds a metadata attachment.
Definition Core.cpp:2333
LLVMBool LLVMHasUnnamedAddr(LLVMValueRef Global)
Deprecated: Use LLVMGetUnnamedAddress instead.
Definition Core.cpp:2237
LLVMMetadataRef LLVMValueMetadataEntriesGetMetadata(LLVMValueMetadataEntry *Entries, unsigned Index)
Returns the underlying metadata node of a value metadata entry at a specific index.
Definition Core.cpp:2317
void LLVMDisposeValueMetadataEntries(LLVMValueMetadataEntry *Entries)
Destroys value metadata entries.
Definition Core.cpp:2324
void LLVMGlobalAddDebugInfo(LLVMValueRef Global, LLVMMetadataRef GVE)
Add debuginfo metadata to this global.
Definition Core.cpp:2346
LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N, LLVMBool SignExtend)
Obtain a constant value for an integer type.
Definition Core.cpp:1601
LLVMValueRef LLVMConstFPFromBits(LLVMTypeRef Ty, const uint64_t N[])
Obtain a constant for a floating point value from array of 64 bit values.
Definition Core.cpp:1663
LLVMValueRef LLVMConstIntOfArbitraryPrecision(LLVMTypeRef IntTy, unsigned NumWords, const uint64_t Words[])
Obtain a constant value for an integer of arbitrary precision.
Definition Core.cpp:1606
long long LLVMConstIntGetSExtValue(LLVMValueRef ConstantVal)
Obtain the sign extended value for an integer constant value.
Definition Core.cpp:1675
unsigned long long LLVMConstByteGetZExtValue(LLVMValueRef ConstantVal)
Obtain the zero extended value for a byte constant value.
Definition Core.cpp:1679
LLVMValueRef LLVMConstRealOfString(LLVMTypeRef RealTy, const char *Text)
Obtain a constant for a floating point value parsed from a string.
Definition Core.cpp:1654
LLVMValueRef LLVMConstByteOfArbitraryPrecision(LLVMTypeRef ByteTy, unsigned NumWords, const uint64_t Words[])
Obtain a constant value for a byte of arbitrary precision.
Definition Core.cpp:1630
double LLVMConstRealGetDouble(LLVMValueRef ConstantVal, LLVMBool *LosesInfo)
Obtain the double value for an floating point constant value.
Definition Core.cpp:1687
LLVMValueRef LLVMConstByte(LLVMTypeRef ByteTy, unsigned long long N)
Obtain a constant value for a byte type.
Definition Core.cpp:1626
LLVMValueRef LLVMConstReal(LLVMTypeRef RealTy, double N)
Obtain a constant value referring to a double floating point value.
Definition Core.cpp:1650
long long LLVMConstByteGetSExtValue(LLVMValueRef ConstantVal)
Obtain the sign extended value for a byte constant value.
Definition Core.cpp:1683
unsigned long long LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal)
Obtain the zero extended value for an integer constant value.
Definition Core.cpp:1671
LLVMValueRef LLVMGetPoison(LLVMTypeRef Ty)
Obtain a constant value referring to a poison value of a type.
Definition Core.cpp:1304
LLVMValueRef LLVMConstPointerNull(LLVMTypeRef Ty)
Obtain a constant that is a constant pointer pointing to NULL for a specified type.
Definition Core.cpp:1326
LLVMValueRef LLVMGetUndef(LLVMTypeRef Ty)
Obtain a constant value referring to an undefined value of a type.
Definition Core.cpp:1300
LLVMBool LLVMIsNull(LLVMValueRef Val)
Determine whether a value instance is null.
Definition Core.cpp:1312
LLVMValueRef LLVMConstNull(LLVMTypeRef Ty)
Obtain a constant value referring to the null instance of a type.
Definition Core.cpp:1292
LLVMValueRef LLVMConstAllOnes(LLVMTypeRef Ty)
Obtain a constant value referring to the instance of a type consisting of all ones.
Definition Core.cpp:1296
LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg)
Obtain the previous parameter to a function.
Definition Core.cpp:2830
void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align)
Set the alignment for a function parameter.
Definition Core.cpp:2837
unsigned LLVMCountParams(LLVMValueRef FnRef)
Obtain the number of parameters in a function.
Definition Core.cpp:2785
void LLVMGetParams(LLVMValueRef FnRef, LLVMValueRef *ParamRefs)
Obtain the parameters in a function.
Definition Core.cpp:2791
LLVMValueRef LLVMGetFirstParam(LLVMValueRef Fn)
Obtain the first parameter to a function.
Definition Core.cpp:2806
LLVMValueRef LLVMGetLastParam(LLVMValueRef Fn)
Obtain the last parameter to a function.
Definition Core.cpp:2814
LLVMValueRef LLVMGetParam(LLVMValueRef FnRef, unsigned index)
Obtain the parameter at the specified index.
Definition Core.cpp:2797
LLVMValueRef LLVMGetNextParam(LLVMValueRef Arg)
Obtain the next parameter to a function.
Definition Core.cpp:2822
LLVMValueRef LLVMGetParamParent(LLVMValueRef V)
Obtain the function to which this argument belongs.
Definition Core.cpp:2802
char * LLVMIntrinsicCopyOverloadedName2(LLVMModuleRef Mod, unsigned ID, LLVMTypeRef *OverloadTypes, size_t OverloadCount, size_t *NameLength)
Copies the name of an overloaded intrinsic identified by a given list of overload types.
Definition Core.cpp:2661
void LLVMAddAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx, LLVMAttributeRef A)
Add an attribute to a function.
Definition Core.cpp:2735
LLVMValueRef LLVMGetPrefixData(LLVMValueRef Fn)
Gets the prefix data associated with a function.
Definition Core.cpp:2703
LLVMValueRef LLVMGetPrologueData(LLVMValueRef Fn)
Gets the prologue data associated with a function.
Definition Core.cpp:2719
unsigned LLVMGetIntrinsicID(LLVMValueRef Fn)
Obtain the ID number from a function instance.
Definition Core.cpp:2616
LLVMValueRef LLVMGetPersonalityFn(LLVMValueRef Fn)
Obtain the personality function attached to the function.
Definition Core.cpp:2607
unsigned LLVMGetAttributeCountAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx)
Definition Core.cpp:2740
LLVMBool LLVMHasPersonalityFn(LLVMValueRef Fn)
Check whether the given function has a personality function.
Definition Core.cpp:2603
void LLVMRemoveStringAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx, const char *K, unsigned KLen)
Definition Core.cpp:2771
void LLVMSetPrefixData(LLVMValueRef Fn, LLVMValueRef prefixData)
Sets the prefix data for the function.
Definition Core.cpp:2713
const char * LLVMGetGC(LLVMValueRef Fn)
Obtain the name of the garbage collector to use during code generation.
Definition Core.cpp:2690
char * LLVMIntrinsicCopyOverloadedName(unsigned ID, LLVMTypeRef *OverloadTypes, size_t OverloadCount, size_t *NameLength)
Deprecated: Use LLVMIntrinsicCopyOverloadedName2 instead.
Definition Core.cpp:2651
void LLVMSetGC(LLVMValueRef Fn, const char *GC)
Define the garbage collector to use during code generation.
Definition Core.cpp:2695
void LLVMSetPrologueData(LLVMValueRef Fn, LLVMValueRef prologueData)
Sets the prologue data for the function.
Definition Core.cpp:2729
void LLVMSetPersonalityFn(LLVMValueRef Fn, LLVMValueRef PersonalityFn)
Set the personality function attached to the function.
Definition Core.cpp:2611
void LLVMGetAttributesAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx, LLVMAttributeRef *Attrs)
Definition Core.cpp:2745
unsigned LLVMGetFunctionCallConv(LLVMValueRef Fn)
Obtain the calling function of a function.
Definition Core.cpp:2681
LLVMBool LLVMIntrinsicIsOverloaded(unsigned ID)
Obtain if the intrinsic identified by the given ID is overloaded.
Definition Core.cpp:2676
void LLVMDeleteFunction(LLVMValueRef Fn)
Remove a function from its containing module and deletes it.
Definition Core.cpp:2599
void LLVMRemoveEnumAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx, unsigned KindID)
Definition Core.cpp:2766
LLVMAttributeRef LLVMGetEnumAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx, unsigned KindID)
Definition Core.cpp:2752
unsigned LLVMLookupIntrinsicID(const char *Name, size_t NameLen)
Obtain the intrinsic ID number which matches the given function name.
Definition Core.cpp:2672
const char * LLVMIntrinsicGetName(unsigned ID, size_t *NameLength)
Retrieves the name of an intrinsic.
Definition Core.cpp:2636
LLVMValueRef LLVMGetIntrinsicDeclaration(LLVMModuleRef Mod, unsigned ID, LLVMTypeRef *OverloadTypes, size_t OverloadCount)
Get or insert the declaration of an intrinsic.
Definition Core.cpp:2627
LLVMBool LLVMHasPrologueData(LLVMValueRef Fn)
Check if a given function has prologue data.
Definition Core.cpp:2724
LLVMBool LLVMHasPrefixData(LLVMValueRef Fn)
Check if a given function has prefix data.
Definition Core.cpp:2708
void LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC)
Set the calling convention of a function.
Definition Core.cpp:2685
LLVMTypeRef LLVMIntrinsicGetType(LLVMContextRef Ctx, unsigned ID, LLVMTypeRef *OverloadTypes, size_t OverloadCount)
Retrieves the type of an intrinsic.
Definition Core.cpp:2643
void LLVMAddTargetDependentFunctionAttr(LLVMValueRef Fn, const char *A, const char *V)
Add a target-dependent attribute to a function.
Definition Core.cpp:2776
LLVMAttributeRef LLVMGetStringAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx, const char *K, unsigned KLen)
Definition Core.cpp:2759
LLVMValueRef LLVMIsAMDString(LLVMValueRef Val)
Definition Core.cpp:1216
LLVMBool LLVMIsPoison(LLVMValueRef Val)
Determine whether a value instance is poisonous.
Definition Core.cpp:1322
LLVMValueKind LLVMGetValueKind(LLVMValueRef Val)
Obtain the enumerated type of a Value instance.
Definition Core.cpp:1055
void LLVMDumpValue(LLVMValueRef Val)
Dump a representation of a value to stderr.
Definition Core.cpp:1085
const char * LLVMGetValueName(LLVMValueRef Val)
Deprecated: Use LLVMGetValueName2 instead.
Definition Core.cpp:1077
LLVMContextRef LLVMGetValueContext(LLVMValueRef Val)
Obtain the context to which this value is associated.
Definition Core.cpp:1101
void LLVMReplaceAllUsesWith(LLVMValueRef OldVal, LLVMValueRef NewVal)
Replace all uses of a value with another one.
Definition Core.cpp:1117
const char * LLVMGetValueName2(LLVMValueRef Val, size_t *Length)
Obtain the string name of a value.
Definition Core.cpp:1067
void LLVMSetValueName(LLVMValueRef Val, const char *Name)
Deprecated: Use LLVMSetValueName2 instead.
Definition Core.cpp:1081
LLVMValueRef LLVMIsAMDNode(LLVMValueRef Val)
Definition Core.cpp:1201
char * LLVMPrintDbgRecordToString(LLVMDbgRecordRef Record)
Return a string representation of the DbgRecord.
Definition Core.cpp:1105
LLVMBool LLVMIsUndef(LLVMValueRef Val)
Determine whether a value instance is undefined.
Definition Core.cpp:1318
LLVMTypeRef LLVMTypeOf(LLVMValueRef Val)
Obtain the type of a value.
Definition Core.cpp:1051
char * LLVMPrintValueToString(LLVMValueRef Val)
Return a string representation of the value.
Definition Core.cpp:1089
LLVMValueRef LLVMIsAValueAsMetadata(LLVMValueRef Val)
Definition Core.cpp:1209
LLVMBool LLVMIsConstant(LLVMValueRef Ty)
Determine whether the specified value instance is constant.
Definition Core.cpp:1308
void LLVMSetValueName2(LLVMValueRef Val, const char *Name, size_t NameLen)
Set the string name of a value.
Definition Core.cpp:1073
LLVMValueRef LLVMGetFirstGlobalIFunc(LLVMModuleRef M)
Obtain an iterator to the first GlobalIFunc in a Module.
Definition Core.cpp:2859
LLVMValueRef LLVMGetNamedGlobalIFunc(LLVMModuleRef M, const char *Name, size_t NameLen)
Obtain a GlobalIFunc value from a Module by its name.
Definition Core.cpp:2854
void LLVMRemoveGlobalIFunc(LLVMValueRef IFunc)
Remove a global indirect function from its parent module.
Definition Core.cpp:2903
LLVMValueRef LLVMAddGlobalIFunc(LLVMModuleRef M, const char *Name, size_t NameLen, LLVMTypeRef Ty, unsigned AddrSpace, LLVMValueRef Resolver)
Add a global indirect function to a module under a specified name.
Definition Core.cpp:2844
LLVMValueRef LLVMGetNextGlobalIFunc(LLVMValueRef IFunc)
Advance a GlobalIFunc iterator to the next GlobalIFunc.
Definition Core.cpp:2875
LLVMValueRef LLVMGetPreviousGlobalIFunc(LLVMValueRef IFunc)
Decrement a GlobalIFunc iterator to the previous GlobalIFunc.
Definition Core.cpp:2883
LLVMValueRef LLVMGetGlobalIFuncResolver(LLVMValueRef IFunc)
Retrieves the resolver function associated with this indirect function, or NULL if it doesn't not exi...
Definition Core.cpp:2891
void LLVMSetGlobalIFuncResolver(LLVMValueRef IFunc, LLVMValueRef Resolver)
Sets the resolver function associated with this indirect function.
Definition Core.cpp:2895
LLVMValueRef LLVMGetLastGlobalIFunc(LLVMModuleRef M)
Obtain an iterator to the last GlobalIFunc in a Module.
Definition Core.cpp:2867
void LLVMEraseGlobalIFunc(LLVMValueRef IFunc)
Remove a global indirect function from its parent module and delete it.
Definition Core.cpp:2899
LLVMTypeRef LLVMGetAllocatedType(LLVMValueRef Alloca)
Obtain the type that is being allocated by the alloca instruction.
Definition Core.cpp:3412
void LLVMSetTailCall(LLVMValueRef Call, LLVMBool isTailCall)
Set whether a call instruction is a tail call.
Definition Core.cpp:3311
void LLVMAddCallSiteAttribute(LLVMValueRef C, LLVMAttributeIndex Idx, LLVMAttributeRef A)
Definition Core.cpp:3243
unsigned LLVMGetNumOperandBundles(LLVMValueRef C)
Obtain the number of operand bundles attached to this instruction.
Definition Core.cpp:3295
void LLVMRemoveCallSiteEnumAttribute(LLVMValueRef C, LLVMAttributeIndex Idx, unsigned KindID)
Definition Core.cpp:3277
void LLVMRemoveCallSiteStringAttribute(LLVMValueRef C, LLVMAttributeIndex Idx, const char *K, unsigned KLen)
Definition Core.cpp:3282
LLVMAttributeRef LLVMGetCallSiteEnumAttribute(LLVMValueRef C, LLVMAttributeIndex Idx, unsigned KindID)
Definition Core.cpp:3263
unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr)
Obtain the calling convention for a call instruction.
Definition Core.cpp:3226
LLVMBasicBlockRef LLVMGetCallBrDefaultDest(LLVMValueRef CallBr)
Get the default destination of a CallBr instruction.
Definition Core.cpp:3351
LLVMValueRef LLVMGetCalledValue(LLVMValueRef Instr)
Obtain the pointer to the function invoked by this instruction.
Definition Core.cpp:3287
void LLVMSetNormalDest(LLVMValueRef Invoke, LLVMBasicBlockRef B)
Set the normal destination basic block.
Definition Core.cpp:3338
LLVMBool LLVMIsTailCall(LLVMValueRef Call)
Obtain whether a call instruction is a tail call.
Definition Core.cpp:3307
LLVMAttributeRef LLVMGetCallSiteStringAttribute(LLVMValueRef C, LLVMAttributeIndex Idx, const char *K, unsigned KLen)
Definition Core.cpp:3270
unsigned LLVMGetCallBrNumIndirectDests(LLVMValueRef CallBr)
Get the number of indirect destinations of a CallBr instruction.
Definition Core.cpp:3355
void LLVMGetCallSiteAttributes(LLVMValueRef C, LLVMAttributeIndex Idx, LLVMAttributeRef *Attrs)
Definition Core.cpp:3255
LLVMBasicBlockRef LLVMGetNormalDest(LLVMValueRef Invoke)
Return the normal destination basic block.
Definition Core.cpp:3325
unsigned LLVMGetNumArgOperands(LLVMValueRef Instr)
Obtain the argument count for a call instruction.
Definition Core.cpp:3217
void LLVMSetTailCallKind(LLVMValueRef Call, LLVMTailCallKind kind)
Set the call kind of the call instruction.
Definition Core.cpp:3319
LLVMOperandBundleRef LLVMGetOperandBundleAtIndex(LLVMValueRef C, unsigned Index)
Obtain the operand bundle attached to this instruction at the given index.
Definition Core.cpp:3299
LLVMBasicBlockRef LLVMGetCallBrIndirectDest(LLVMValueRef CallBr, unsigned Idx)
Get the indirect destination of a CallBr instruction at the given index.
Definition Core.cpp:3359
LLVMTailCallKind LLVMGetTailCallKind(LLVMValueRef Call)
Obtain a tail call kind of the call instruction.
Definition Core.cpp:3315
void LLVMSetUnwindDest(LLVMValueRef Invoke, LLVMBasicBlockRef B)
Set the unwind destination basic block.
Definition Core.cpp:3342
LLVMTypeRef LLVMGetCalledFunctionType(LLVMValueRef Instr)
Obtain the function type called by this instruction.
Definition Core.cpp:3291
LLVMBasicBlockRef LLVMGetUnwindDest(LLVMValueRef Invoke)
Return the unwind destination basic block.
Definition Core.cpp:3329
void LLVMSetInstrParamAlignment(LLVMValueRef Instr, LLVMAttributeIndex Idx, unsigned align)
Definition Core.cpp:3235
unsigned LLVMGetCallSiteAttributeCount(LLVMValueRef C, LLVMAttributeIndex Idx)
Definition Core.cpp:3248
void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC)
Set the calling convention for a call instruction.
Definition Core.cpp:3230
LLVMGEPNoWrapFlags LLVMGEPGetNoWrapFlags(LLVMValueRef GEP)
Get the no-wrap related flags for the given GEP instruction.
Definition Core.cpp:3430
LLVMBool LLVMIsInBounds(LLVMValueRef GEP)
Check whether the given GEP operator is inbounds.
Definition Core.cpp:3418
void LLVMSetIsInBounds(LLVMValueRef GEP, LLVMBool InBounds)
Set the given GEP instruction to be inbounds or not.
Definition Core.cpp:3422
LLVMTypeRef LLVMGetGEPSourceElementType(LLVMValueRef GEP)
Get the source element type of the given GEP operator.
Definition Core.cpp:3426
void LLVMGEPSetNoWrapFlags(LLVMValueRef GEP, LLVMGEPNoWrapFlags NoWrapFlags)
Set the no-wrap related flags for the given GEP instruction.
Definition Core.cpp:3435
unsigned LLVMGetNumIndices(LLVMValueRef Inst)
Obtain the number of indices.
Definition Core.cpp:3463
const unsigned * LLVMGetIndices(LLVMValueRef Inst)
Obtain the indices as an array.
Definition Core.cpp:3475
LLVMBasicBlockRef LLVMGetIncomingBlock(LLVMValueRef PhiNode, unsigned Index)
Obtain an incoming value to a PHI node as an LLVMBasicBlockRef.
Definition Core.cpp:3457
LLVMValueRef LLVMGetIncomingValue(LLVMValueRef PhiNode, unsigned Index)
Obtain an incoming value to a PHI node as an LLVMValueRef.
Definition Core.cpp:3453
void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues, LLVMBasicBlockRef *IncomingBlocks, unsigned Count)
Add an incoming value to the end of a PHI list.
Definition Core.cpp:3442
unsigned LLVMCountIncoming(LLVMValueRef PhiNode)
Obtain the number of incoming basic blocks to a PHI node.
Definition Core.cpp:3449
LLVMValueRef LLVMGetCondition(LLVMValueRef Branch)
Return the condition of a branch instruction.
Definition Core.cpp:3383
LLVMBasicBlockRef LLVMGetSuccessor(LLVMValueRef Term, unsigned i)
Return the specified successor.
Definition Core.cpp:3369
void LLVMSetCondition(LLVMValueRef Branch, LLVMValueRef Cond)
Set the condition of a branch instruction.
Definition Core.cpp:3387
void LLVMSetSuccessor(LLVMValueRef Term, unsigned i, LLVMBasicBlockRef block)
Update the specified successor to point at the provided block.
Definition Core.cpp:3373
LLVMValueRef LLVMGetSwitchCaseValue(LLVMValueRef Switch, unsigned i)
Obtain the case value for a successor of a switch instruction.
Definition Core.cpp:3397
LLVMBool LLVMIsConditional(LLVMValueRef Branch)
Return if an instruction is a conditional branch.
Definition Core.cpp:3379
LLVMBasicBlockRef LLVMGetSwitchDefaultDest(LLVMValueRef Switch)
Obtain the default destination basic block of a switch instruction.
Definition Core.cpp:3393
void LLVMSetSwitchCaseValue(LLVMValueRef Switch, unsigned i, LLVMValueRef CaseValue)
Set the case value for a successor of a switch instruction.
Definition Core.cpp:3403
unsigned LLVMGetNumSuccessors(LLVMValueRef Term)
Return the number of successors that this terminator has.
Definition Core.cpp:3365
LLVMRealPredicate LLVMGetFCmpPredicate(LLVMValueRef Inst)
Obtain the float predicate of an instruction.
Definition Core.cpp:3127
int LLVMHasMetadata(LLVMValueRef Inst)
Determine whether an instruction has any metadata attached.
Definition Core.cpp:1121
void LLVMInstructionRemoveFromParent(LLVMValueRef Inst)
Remove an instruction.
Definition Core.cpp:3101
LLVMValueRef LLVMGetPreviousInstruction(LLVMValueRef Inst)
Obtain the instruction that occurred before this one.
Definition Core.cpp:3093
LLVMDbgRecordRef LLVMGetPreviousDbgRecord(LLVMDbgRecordRef Rec)
Obtain the previous DbgRecord in the sequence or NULL if there are no more.
Definition Core.cpp:3178
LLVMMetadataRef LLVMDbgVariableRecordGetExpression(LLVMDbgRecordRef Rec)
Get the debug info expression of the DbgVariableRecord.
Definition Core.cpp:3213
LLVMDbgRecordRef LLVMGetFirstDbgRecord(LLVMValueRef Inst)
Obtain the first debug record attached to an instruction.
Definition Core.cpp:3150
LLVMOpcode LLVMGetInstructionOpcode(LLVMValueRef Inst)
Obtain the code opcode for an individual instruction.
Definition Core.cpp:3133
LLVMDbgRecordRef LLVMGetNextDbgRecord(LLVMDbgRecordRef Rec)
Obtain the next DbgRecord in the sequence or NULL if there are no more.
Definition Core.cpp:3170
LLVMDbgRecordRef LLVMGetLastDbgRecord(LLVMValueRef Inst)
Obtain the last debug record attached to an instruction.
Definition Core.cpp:3160
LLVMMetadataRef LLVMDbgVariableRecordGetVariable(LLVMDbgRecordRef Rec)
Get the debug info variable of the DbgVariableRecord.
Definition Core.cpp:3209
LLVMValueRef LLVMIsATerminatorInst(LLVMValueRef Inst)
Determine whether an instruction is a terminator.
Definition Core.cpp:3145
LLVMValueRef LLVMDbgVariableRecordGetValue(LLVMDbgRecordRef Rec, unsigned OpIdx)
Get the value of the DbgVariableRecord.
Definition Core.cpp:3204
LLVMDbgRecordKind LLVMDbgRecordGetKind(LLVMDbgRecordRef Rec)
Definition Core.cpp:3190
LLVMValueMetadataEntry * LLVMInstructionGetAllMetadataOtherThanDebugLoc(LLVMValueRef Value, size_t *NumEntries)
Returns the metadata associated with an instruction value, but filters out all the debug locations.
Definition Core.cpp:1178
void LLVMDeleteInstruction(LLVMValueRef Inst)
Delete an instruction.
Definition Core.cpp:3109
LLVMBasicBlockRef LLVMGetInstructionParent(LLVMValueRef Inst)
Obtain the basic block to which an instruction belongs.
Definition Core.cpp:3065
LLVMMetadataRef LLVMDbgRecordGetDebugLoc(LLVMDbgRecordRef Rec)
Get the debug location attached to the debug record.
Definition Core.cpp:3186
LLVMBool LLVMGetICmpSameSign(LLVMValueRef Inst)
Get whether or not an icmp instruction has the samesign flag.
Definition Core.cpp:3119
LLVMValueRef LLVMInstructionClone(LLVMValueRef Inst)
Create a copy of 'this' instruction that is identical in all ways except the following:
Definition Core.cpp:3139
void LLVMInstructionEraseFromParent(LLVMValueRef Inst)
Remove and delete an instruction.
Definition Core.cpp:3105
void LLVMSetMetadata(LLVMValueRef Inst, unsigned KindID, LLVMValueRef Val)
Set metadata associated with an instruction value.
Definition Core.cpp:1147
LLVMValueRef LLVMGetMetadata(LLVMValueRef Inst, unsigned KindID)
Return metadata associated with an instruction value.
Definition Core.cpp:1125
LLVMIntPredicate LLVMGetICmpPredicate(LLVMValueRef Inst)
Obtain the predicate of an instruction.
Definition Core.cpp:3113
LLVMValueRef LLVMGetNextInstruction(LLVMValueRef Inst)
Obtain the instruction that occurs after the one specified.
Definition Core.cpp:3085
void LLVMSetICmpSameSign(LLVMValueRef Inst, LLVMBool SameSign)
Set the samesign flag on an icmp instruction.
Definition Core.cpp:3123
LLVMMetadataRef LLVMMDNodeInContext2(LLVMContextRef C, LLVMMetadataRef *MDs, size_t Count)
Create an MDNode value with the given array of operands.
Definition Core.cpp:1337
const char * LLVMGetMDString(LLVMValueRef V, unsigned *Length)
Obtain the underlying string from a MDString value.
Definition Core.cpp:1409
LLVMValueRef LLVMMetadataAsValue(LLVMContextRef C, LLVMMetadataRef MD)
Obtain a Metadata as a Value.
Definition Core.cpp:1384
unsigned LLVMGetMDNodeNumOperands(LLVMValueRef V)
Obtain the number of operands from an MDNode value.
Definition Core.cpp:1419
LLVMValueRef LLVMMDStringInContext(LLVMContextRef C, const char *Str, unsigned SLen)
Deprecated: Use LLVMMDStringInContext2 instead.
Definition Core.cpp:1342
LLVMMetadataRef LLVMMDStringInContext2(LLVMContextRef C, const char *Str, size_t SLen)
Create an MDString value from a given string value.
Definition Core.cpp:1332
LLVMValueRef LLVMMDNodeInContext(LLVMContextRef C, LLVMValueRef *Vals, unsigned Count)
Deprecated: Use LLVMMDNodeInContext2 instead.
Definition Core.cpp:1353
void LLVMReplaceMDNodeOperandWith(LLVMValueRef V, unsigned Index, LLVMMetadataRef Replacement)
Replace an operand at a specific index in a llvm::MDNode value.
Definition Core.cpp:1487
char * LLVMPrintMetadataToString(LLVMMetadataRef MD)
Return a string representation of the metadata.
Definition Core.cpp:1397
LLVMMetadataRef LLVMValueAsMetadata(LLVMValueRef Val)
Obtain a Value as a Metadata.
Definition Core.cpp:1388
void LLVMGetMDNodeOperands(LLVMValueRef V, LLVMValueRef *Dest)
Obtain the given MDNode's operands.
Definition Core.cpp:1474
LLVMUseRef LLVMGetOperandUse(LLVMValueRef Val, unsigned Index)
Obtain the use of an operand at a specific index in a llvm::User value.
Definition Core.cpp:1273
int LLVMGetNumOperands(LLVMValueRef Val)
Obtain the number of operands in a llvm::User value.
Definition Core.cpp:1282
void LLVMSetOperand(LLVMValueRef Val, unsigned Index, LLVMValueRef Op)
Set an operand at a specific index in a llvm::User value.
Definition Core.cpp:1278
LLVMValueRef LLVMGetOperand(LLVMValueRef Val, unsigned Index)
Obtain an operand at a specific index in a llvm::User value.
Definition Core.cpp:1259
LLVMValueRef LLVMGetUser(LLVMUseRef U)
Obtain the user value for a user.
Definition Core.cpp:1239
LLVMValueRef LLVMGetUsedValue(LLVMUseRef U)
Obtain the value this use corresponds to.
Definition Core.cpp:1243
LLVMUseRef LLVMGetNextUse(LLVMUseRef U)
Obtain the next use of a value.
Definition Core.cpp:1232
LLVMUseRef LLVMGetFirstUse(LLVMValueRef Val)
Obtain the first use of a value.
Definition Core.cpp:1224
#define LLVM_FOR_EACH_VALUE_SUBCLASS(macro)
Definition Core.h:2035
void LLVMDisposeMessage(char *Message)
Definition Core.cpp:90
char * LLVMCreateMessage(const char *Message)
Definition Core.cpp:86
void LLVMGetVersion(unsigned *Major, unsigned *Minor, unsigned *Patch)
Return the major, minor, and patch version of LLVM.
Definition Core.cpp:75
void LLVMShutdown()
Deallocate and destroy all ManagedStatic variables.
Definition Core.cpp:69
struct LLVMOpaqueValue * LLVMValueRef
Represents an individual value in LLVM IR.
Definition Types.h:75
struct LLVMOpaqueAttributeRef * LLVMAttributeRef
Used to represent an attributes.
Definition Types.h:145
int LLVMBool
Definition Types.h:28
struct LLVMOpaqueModuleFlagEntry LLVMModuleFlagEntry
Definition Types.h:160
struct LLVMOpaqueNamedMDNode * LLVMNamedMDNodeRef
Represents an LLVM Named Metadata Node.
Definition Types.h:96
struct LLVMOpaquePassManager * LLVMPassManagerRef
Definition Types.h:127
struct LLVMOpaqueDbgRecord * LLVMDbgRecordRef
Definition Types.h:175
struct LLVMOpaqueDiagnosticInfo * LLVMDiagnosticInfoRef
Definition Types.h:150
struct LLVMOpaqueValueMetadataEntry LLVMValueMetadataEntry
Represents an entry in a Global Object's metadata attachments.
Definition Types.h:103
struct LLVMOpaqueMemoryBuffer * LLVMMemoryBufferRef
LLVM uses a polymorphic type hierarchy which C cannot represent, therefore parameters must be passed ...
Definition Types.h:48
struct LLVMOpaqueContext * LLVMContextRef
The top-level container for all LLVM global data.
Definition Types.h:53
struct LLVMOpaqueBuilder * LLVMBuilderRef
Represents an LLVM basic block builder.
Definition Types.h:110
struct LLVMOpaqueUse * LLVMUseRef
Used to get the users and usees of a Value.
Definition Types.h:133
struct LLVMOpaqueBasicBlock * LLVMBasicBlockRef
Represents a basic block of instructions in LLVM IR.
Definition Types.h:82
struct LLVMOpaqueType * LLVMTypeRef
Each value in the LLVM IR has a type, an LLVMTypeRef.
Definition Types.h:68
struct LLVMOpaqueMetadata * LLVMMetadataRef
Represents an LLVM Metadata.
Definition Types.h:89
struct LLVMOpaqueModule * LLVMModuleRef
The top-level container for all other LLVM Intermediate Representation (IR) objects.
Definition Types.h:61
struct LLVMOpaqueModuleProvider * LLVMModuleProviderRef
Interface used to provide a module to JIT or interpreter.
Definition Types.h:124
struct LLVMOpaqueOperandBundle * LLVMOperandBundleRef
Definition Types.h:138
struct LLVMOpaqueTargetData * LLVMTargetDataRef
Definition Core.h:34
LLVMValueRef LLVMAddAlias2(LLVMModuleRef M, LLVMTypeRef ValueTy, unsigned AddrSpace, LLVMValueRef Aliasee, const char *Name)
Add a GlobalAlias with the given value type, address space and aliasee.
Definition Core.cpp:2489
LLVMValueRef LLVMGetLastGlobalAlias(LLVMModuleRef M)
Obtain an iterator to the last GlobalAlias in a Module.
Definition Core.cpp:2510
LLVMValueRef LLVMGetPreviousGlobalAlias(LLVMValueRef GA)
Decrement a GlobalAlias iterator to the previous GlobalAlias.
Definition Core.cpp:2526
void LLVMAliasSetAliasee(LLVMValueRef Alias, LLVMValueRef Aliasee)
Set the target value of an alias.
Definition Core.cpp:2538
LLVMValueRef LLVMGetFirstGlobalAlias(LLVMModuleRef M)
Obtain an iterator to the first GlobalAlias in a Module.
Definition Core.cpp:2502
LLVMValueRef LLVMAliasGetAliasee(LLVMValueRef Alias)
Retrieve the target value of an alias.
Definition Core.cpp:2534
LLVMValueRef LLVMGetNamedGlobalAlias(LLVMModuleRef M, const char *Name, size_t NameLen)
Obtain a GlobalAlias value from a Module by its name.
Definition Core.cpp:2497
LLVMValueRef LLVMGetNextGlobalAlias(LLVMValueRef GA)
Advance a GlobalAlias iterator to the next GlobalAlias.
Definition Core.cpp:2518
LLVMBool LLVMIsThreadLocal(LLVMValueRef GlobalVar)
Definition Core.cpp:2424
LLVMThreadLocalMode LLVMGetThreadLocalMode(LLVMValueRef GlobalVar)
Definition Core.cpp:2440
LLVMBool LLVMIsGlobalConstant(LLVMValueRef GlobalVar)
Definition Core.cpp:2432
LLVMValueRef LLVMGetPreviousGlobal(LLVMValueRef GlobalVar)
Definition Core.cpp:2400
void LLVMSetThreadLocal(LLVMValueRef GlobalVar, LLVMBool IsThreadLocal)
Definition Core.cpp:2428
LLVMBool LLVMIsExternallyInitialized(LLVMValueRef GlobalVar)
Definition Core.cpp:2479
LLVMValueRef LLVMGetLastGlobal(LLVMModuleRef M)
Definition Core.cpp:2384
LLVMValueRef LLVMGetNamedGlobalWithLength(LLVMModuleRef M, const char *Name, size_t Length)
Definition Core.cpp:2371
LLVMValueRef LLVMGetFirstGlobal(LLVMModuleRef M)
Definition Core.cpp:2376
void LLVMSetThreadLocalMode(LLVMValueRef GlobalVar, LLVMThreadLocalMode Mode)
Definition Core.cpp:2457
LLVMValueRef LLVMGetNextGlobal(LLVMValueRef GlobalVar)
Definition Core.cpp:2392
void LLVMSetExternallyInitialized(LLVMValueRef GlobalVar, LLVMBool IsExtInit)
Definition Core.cpp:2483
LLVMValueRef LLVMGetNamedGlobal(LLVMModuleRef M, const char *Name)
Definition Core.cpp:2367
LLVMValueRef LLVMAddGlobalInAddressSpace(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name, unsigned AddressSpace)
Definition Core.cpp:2358
void LLVMDeleteGlobal(LLVMValueRef GlobalVar)
Definition Core.cpp:2408
void LLVMSetGlobalConstant(LLVMValueRef GlobalVar, LLVMBool IsConstant)
Definition Core.cpp:2436
LLVMValueRef LLVMAddGlobal(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name)
Definition Core.cpp:2353
LLVMValueRef LLVMGetInitializer(LLVMValueRef GlobalVar)
Definition Core.cpp:2412
void LLVMSetInitializer(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal)
Definition Core.cpp:2419
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition CallingConv.h:24
LLVM_ABI StringRef getName(ID id)
Return the LLVM name for an intrinsic, such as "llvm.ppc.altivec.lvx".
LLVM_ABI Function * getOrInsertDeclaration(Module *M, ID id, ArrayRef< Type * > OverloadTys={})
Look up the Function declaration of the intrinsic id in the Module M.
LLVM_ABI ID lookupIntrinsicID(StringRef Name)
This does the actual lookup of an intrinsic ID which matches the given function name.
LLVM_ABI bool isOverloaded(ID id)
Returns true if the intrinsic can be overloaded.
LLVM_ABI FunctionType * getType(LLVMContext &Context, ID id, ArrayRef< Type * > OverloadTys={})
Return the function type for an intrinsic.
LLVM_ABI std::string getNameNoUnnamedTypes(ID Id, ArrayRef< Type * > OverloadTys)
Return the LLVM name for an intrinsic.
@ SingleThread
Synchronized with respect to signal handlers executing in the same thread.
Definition LLVMContext.h:63
@ System
Synchronized with respect to all concurrently executing threads.
Definition LLVMContext.h:66
LLVM_ABI LibraryOptionsContext & getCAPILibraryOptions()
@ OF_TextWithCRLF
The file should be opened in text mode and use a carriage linefeed '\r '.
Definition FileSystem.h:802
This is an optimization pass for GlobalISel generic memory operations.
@ Offset
Definition DWP.cpp:577
@ Length
Definition DWP.cpp:577
constexpr bool llvm_is_multithreaded()
Returns true if LLVM is compiled with support for multi-threading, and false otherwise.
Definition Threading.h:52
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
LLVM_ABI void initializePrintModulePassWrapperPass(PassRegistry &)
void * PointerTy
void setAtomicSyncScopeID(Instruction *I, SyncScope::ID SSID)
A helper function that sets an atomic operation's sync scope.
auto dyn_cast_or_null(const Y &Val)
Definition Casting.h:753
LLVM_ABI LLVMContextRef getGlobalContextForCAPI()
Get the deprecated global context for use by the C API.
Definition Core.cpp:106
LLVM_ABI void initializeVerifierLegacyPassPass(PassRegistry &)
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
std::optional< SyncScope::ID > getAtomicSyncScopeID(const Instruction *I)
A helper function that returns an atomic operation's sync scope; returns std::nullopt if it is not an...
LLVM_ABI void initializeCore(PassRegistry &)
Initialize all passes linked into the Core library.
Definition Core.cpp:61
LLVM_ABI void initializeDominatorTreeWrapperPassPass(PassRegistry &)
LLVM_ATTRIBUTE_RETURNS_NONNULL void * safe_malloc(size_t Sz)
Definition MemAlloc.h:25
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
Definition Casting.h:547
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
LLVM_ABI void initializePrintFunctionPassWrapperPass(PassRegistry &)
constexpr int PoisonMaskElem
LLVM_ABI raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
@ Global
Append to llvm.global_dtors.
AtomicOrdering
Atomic ordering for LLVM's memory model.
@ Ref
The access may reference the value stored in memory.
Definition ModRef.h:32
constexpr T divideCeil(U Numerator, V Denominator)
Returns the integer ceil(Numerator / Denominator).
Definition MathExtras.h:389
Attribute unwrap(LLVMAttributeRef Attr)
Definition Attributes.h:396
OperandBundleDefT< Value * > OperandBundleDef
Definition AutoUpgrade.h:34
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Count
Definition InstrProf.h:145
DWARFExpression::Operation Op
ArrayRef(const T &OneElt) -> ArrayRef< T >
LLVM_ABI void llvm_shutdown()
llvm_shutdown - Deallocate and destroy all ManagedStatic variables.
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:559
LLVMAttributeRef wrap(Attribute Attr)
Definition Attributes.h:391
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Next
Definition InstrProf.h:147
LLVM_ABI void initializeSafepointIRVerifierPass(PassRegistry &)
LLVM_ABI void reportFatalUsageError(Error Err)
Report a fatal error that does not indicate a bug in LLVM.
Definition Error.cpp:177
#define N
If the IRBuilder is created via LLVMCreateBuilderInContext(), the actual creation is delayed until th...
Definition Core.cpp:3492
DelayedIRBuilder()=default
std::optional< IRBuilder<> > Builder
Definition Core.cpp:3493
DelayedIRBuilder(Module &M)
Definition Core.cpp:3496
void initUsingInsertionBlock(BasicBlock *BB)
Definition Core.cpp:3501
LLVMModuleFlagBehavior Behavior
Definition Core.cpp:360
LLVMMetadataRef Metadata
Definition Core.cpp:363
LLVMMetadataRef Metadata
Definition Core.cpp:1155
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition Alignment.h:39
Represents the full denormal controls for a function, including the default mode and the f32 specific...
constexpr uint32_t toIntValue() const
Represent subnormal handling kind for floating point instruction inputs and outputs.
DenormalModeKind
Represent handled modes for denormal (aka subnormal) modes in the floating point environment.
void(*)(const DiagnosticInfo *DI, void *Context) DiagnosticHandlerTy
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
Definition Alignment.h:111