LLVM 20.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/IR/Attributes.h"
16#include "llvm/IR/BasicBlock.h"
18#include "llvm/IR/Constants.h"
23#include "llvm/IR/GlobalAlias.h"
25#include "llvm/IR/IRBuilder.h"
26#include "llvm/IR/InlineAsm.h"
29#include "llvm/IR/LLVMContext.h"
31#include "llvm/IR/Module.h"
33#include "llvm/PassRegistry.h"
34#include "llvm/Support/Debug.h"
42#include <cassert>
43#include <cstdlib>
44#include <cstring>
45#include <system_error>
46
47using namespace llvm;
48
50
52 return reinterpret_cast<BasicBlock **>(BBs);
53}
54
55#define DEBUG_TYPE "ir"
56
63}
64
67}
68
69/*===-- Version query -----------------------------------------------------===*/
70
71void LLVMGetVersion(unsigned *Major, unsigned *Minor, unsigned *Patch) {
72 if (Major)
73 *Major = LLVM_VERSION_MAJOR;
74 if (Minor)
75 *Minor = LLVM_VERSION_MINOR;
76 if (Patch)
77 *Patch = LLVM_VERSION_PATCH;
78}
79
80/*===-- Error handling ----------------------------------------------------===*/
81
82char *LLVMCreateMessage(const char *Message) {
83 return strdup(Message);
84}
85
86void LLVMDisposeMessage(char *Message) {
87 free(Message);
88}
89
90
91/*===-- Operations on contexts --------------------------------------------===*/
92
94 static LLVMContext GlobalContext;
95 return GlobalContext;
96}
97
99 return wrap(new LLVMContext());
100}
101
103
105 LLVMDiagnosticHandler Handler,
106 void *DiagnosticContext) {
107 unwrap(C)->setDiagnosticHandlerCallBack(
109 Handler),
110 DiagnosticContext);
111}
112
114 return LLVM_EXTENSION reinterpret_cast<LLVMDiagnosticHandler>(
115 unwrap(C)->getDiagnosticHandlerCallBack());
116}
117
119 return unwrap(C)->getDiagnosticContext();
120}
121
123 void *OpaqueHandle) {
124 auto YieldCallback =
125 LLVM_EXTENSION reinterpret_cast<LLVMContext::YieldCallbackTy>(Callback);
126 unwrap(C)->setYieldCallback(YieldCallback, OpaqueHandle);
127}
128
130 return unwrap(C)->shouldDiscardValueNames();
131}
132
134 unwrap(C)->setDiscardValueNames(Discard);
135}
136
138 delete unwrap(C);
139}
140
142 unsigned SLen) {
143 return unwrap(C)->getMDKindID(StringRef(Name, SLen));
144}
145
146unsigned LLVMGetMDKindID(const char *Name, unsigned SLen) {
148}
149
150unsigned LLVMGetSyncScopeID(LLVMContextRef C, const char *Name, size_t SLen) {
151 return unwrap(C)->getOrInsertSyncScopeID(StringRef(Name, SLen));
152}
153
154unsigned LLVMGetEnumAttributeKindForName(const char *Name, size_t SLen) {
156}
157
159 return Attribute::AttrKind::EndAttrKinds;
160}
161
163 uint64_t Val) {
164 auto &Ctx = *unwrap(C);
165 auto AttrKind = (Attribute::AttrKind)KindID;
166 return wrap(Attribute::get(Ctx, AttrKind, Val));
167}
168
170 return unwrap(A).getKindAsEnum();
171}
172
174 auto Attr = unwrap(A);
175 if (Attr.isEnumAttribute())
176 return 0;
177 return Attr.getValueAsInt();
178}
179
181 LLVMTypeRef type_ref) {
182 auto &Ctx = *unwrap(C);
183 auto AttrKind = (Attribute::AttrKind)KindID;
184 return wrap(Attribute::get(Ctx, AttrKind, unwrap(type_ref)));
185}
186
188 auto Attr = unwrap(A);
189 return wrap(Attr.getValueAsType());
190}
191
193 unsigned KindID,
194 unsigned NumBits,
195 const uint64_t LowerWords[],
196 const uint64_t UpperWords[]) {
197 auto &Ctx = *unwrap(C);
198 auto AttrKind = (Attribute::AttrKind)KindID;
199 unsigned NumWords = divideCeil(NumBits, 64);
200 return wrap(Attribute::get(
201 Ctx, AttrKind,
202 ConstantRange(APInt(NumBits, ArrayRef(LowerWords, NumWords)),
203 APInt(NumBits, ArrayRef(UpperWords, NumWords)))));
204}
205
207 const char *K, unsigned KLength,
208 const char *V, unsigned VLength) {
209 return wrap(Attribute::get(*unwrap(C), StringRef(K, KLength),
210 StringRef(V, VLength)));
211}
212
214 unsigned *Length) {
215 auto S = unwrap(A).getKindAsString();
216 *Length = S.size();
217 return S.data();
218}
219
221 unsigned *Length) {
222 auto S = unwrap(A).getValueAsString();
223 *Length = S.size();
224 return S.data();
225}
226
228 auto Attr = unwrap(A);
229 return Attr.isEnumAttribute() || Attr.isIntAttribute();
230}
231
233 return unwrap(A).isStringAttribute();
234}
235
237 return unwrap(A).isTypeAttribute();
238}
239
241 std::string MsgStorage;
242 raw_string_ostream Stream(MsgStorage);
244
245 unwrap(DI)->print(DP);
246 Stream.flush();
247
248 return LLVMCreateMessage(MsgStorage.c_str());
249}
250
252 LLVMDiagnosticSeverity severity;
253
254 switch(unwrap(DI)->getSeverity()) {
255 default:
256 severity = LLVMDSError;
257 break;
258 case DS_Warning:
259 severity = LLVMDSWarning;
260 break;
261 case DS_Remark:
262 severity = LLVMDSRemark;
263 break;
264 case DS_Note:
265 severity = LLVMDSNote;
266 break;
267 }
268
269 return severity;
270}
271
272/*===-- Operations on modules ---------------------------------------------===*/
273
275 return wrap(new Module(ModuleID, getGlobalContext()));
276}
277
280 return wrap(new Module(ModuleID, *unwrap(C)));
281}
282
284 delete unwrap(M);
285}
286
287const char *LLVMGetModuleIdentifier(LLVMModuleRef M, size_t *Len) {
288 auto &Str = unwrap(M)->getModuleIdentifier();
289 *Len = Str.length();
290 return Str.c_str();
291}
292
293void LLVMSetModuleIdentifier(LLVMModuleRef M, const char *Ident, size_t Len) {
294 unwrap(M)->setModuleIdentifier(StringRef(Ident, Len));
295}
296
297const char *LLVMGetSourceFileName(LLVMModuleRef M, size_t *Len) {
298 auto &Str = unwrap(M)->getSourceFileName();
299 *Len = Str.length();
300 return Str.c_str();
301}
302
303void LLVMSetSourceFileName(LLVMModuleRef M, const char *Name, size_t Len) {
304 unwrap(M)->setSourceFileName(StringRef(Name, Len));
305}
306
307/*--.. Data layout .........................................................--*/
309 return unwrap(M)->getDataLayoutStr().c_str();
310}
311
313 return LLVMGetDataLayoutStr(M);
314}
315
316void LLVMSetDataLayout(LLVMModuleRef M, const char *DataLayoutStr) {
317 unwrap(M)->setDataLayout(DataLayoutStr);
318}
319
320/*--.. Target triple .......................................................--*/
322 return unwrap(M)->getTargetTriple().c_str();
323}
324
325void LLVMSetTarget(LLVMModuleRef M, const char *Triple) {
326 unwrap(M)->setTargetTriple(Triple);
327}
328
329/*--.. Module flags ........................................................--*/
332 const char *Key;
333 size_t KeyLen;
335};
336
339 switch (Behavior) {
341 return Module::ModFlagBehavior::Error;
343 return Module::ModFlagBehavior::Warning;
345 return Module::ModFlagBehavior::Require;
347 return Module::ModFlagBehavior::Override;
349 return Module::ModFlagBehavior::Append;
351 return Module::ModFlagBehavior::AppendUnique;
352 }
353 llvm_unreachable("Unknown LLVMModuleFlagBehavior");
354}
355
358 switch (Behavior) {
359 case Module::ModFlagBehavior::Error:
361 case Module::ModFlagBehavior::Warning:
363 case Module::ModFlagBehavior::Require:
365 case Module::ModFlagBehavior::Override:
367 case Module::ModFlagBehavior::Append:
369 case Module::ModFlagBehavior::AppendUnique:
371 default:
372 llvm_unreachable("Unhandled Flag Behavior");
373 }
374}
375
378 unwrap(M)->getModuleFlagsMetadata(MFEs);
379
381 safe_malloc(MFEs.size() * sizeof(LLVMOpaqueModuleFlagEntry)));
382 for (unsigned i = 0; i < MFEs.size(); ++i) {
383 const auto &ModuleFlag = MFEs[i];
384 Result[i].Behavior = map_from_llvmModFlagBehavior(ModuleFlag.Behavior);
385 Result[i].Key = ModuleFlag.Key->getString().data();
386 Result[i].KeyLen = ModuleFlag.Key->getString().size();
387 Result[i].Metadata = wrap(ModuleFlag.Val);
388 }
389 *Len = MFEs.size();
390 return Result;
391}
392
394 free(Entries);
395}
396
399 unsigned Index) {
401 static_cast<LLVMOpaqueModuleFlagEntry>(Entries[Index]);
402 return MFE.Behavior;
403}
404
406 unsigned Index, size_t *Len) {
408 static_cast<LLVMOpaqueModuleFlagEntry>(Entries[Index]);
409 *Len = MFE.KeyLen;
410 return MFE.Key;
411}
412
414 unsigned Index) {
416 static_cast<LLVMOpaqueModuleFlagEntry>(Entries[Index]);
417 return MFE.Metadata;
418}
419
421 const char *Key, size_t KeyLen) {
422 return wrap(unwrap(M)->getModuleFlag({Key, KeyLen}));
423}
424
426 const char *Key, size_t KeyLen,
427 LLVMMetadataRef Val) {
428 unwrap(M)->addModuleFlag(map_to_llvmModFlagBehavior(Behavior),
429 {Key, KeyLen}, unwrap(Val));
430}
431
433 return unwrap(M)->IsNewDbgInfoFormat;
434}
435
437 unwrap(M)->setIsNewDbgInfoFormat(UseNewFormat);
438}
439
440/*--.. Printing modules ....................................................--*/
441
443 unwrap(M)->print(errs(), nullptr,
444 /*ShouldPreserveUseListOrder=*/false, /*IsForDebug=*/true);
445}
446
448 char **ErrorMessage) {
449 std::error_code EC;
450 raw_fd_ostream dest(Filename, EC, sys::fs::OF_TextWithCRLF);
451 if (EC) {
452 *ErrorMessage = strdup(EC.message().c_str());
453 return true;
454 }
455
456 unwrap(M)->print(dest, nullptr);
457
458 dest.close();
459
460 if (dest.has_error()) {
461 std::string E = "Error printing to file: " + dest.error().message();
462 *ErrorMessage = strdup(E.c_str());
463 return true;
464 }
465
466 return false;
467}
468
470 std::string buf;
471 raw_string_ostream os(buf);
472
473 unwrap(M)->print(os, nullptr);
474 os.flush();
475
476 return strdup(buf.c_str());
477}
478
479/*--.. Operations on inline assembler ......................................--*/
480void LLVMSetModuleInlineAsm2(LLVMModuleRef M, const char *Asm, size_t Len) {
481 unwrap(M)->setModuleInlineAsm(StringRef(Asm, Len));
482}
483
484void LLVMSetModuleInlineAsm(LLVMModuleRef M, const char *Asm) {
485 unwrap(M)->setModuleInlineAsm(StringRef(Asm));
486}
487
488void LLVMAppendModuleInlineAsm(LLVMModuleRef M, const char *Asm, size_t Len) {
489 unwrap(M)->appendModuleInlineAsm(StringRef(Asm, Len));
490}
491
492const char *LLVMGetModuleInlineAsm(LLVMModuleRef M, size_t *Len) {
493 auto &Str = unwrap(M)->getModuleInlineAsm();
494 *Len = Str.length();
495 return Str.c_str();
496}
497
498LLVMValueRef LLVMGetInlineAsm(LLVMTypeRef Ty, const char *AsmString,
499 size_t AsmStringSize, const char *Constraints,
500 size_t ConstraintsSize, LLVMBool HasSideEffects,
501 LLVMBool IsAlignStack,
502 LLVMInlineAsmDialect Dialect, LLVMBool CanThrow) {
504 switch (Dialect) {
507 break;
510 break;
511 }
512 return wrap(InlineAsm::get(unwrap<FunctionType>(Ty),
513 StringRef(AsmString, AsmStringSize),
514 StringRef(Constraints, ConstraintsSize),
515 HasSideEffects, IsAlignStack, AD, CanThrow));
516}
517
518const char *LLVMGetInlineAsmAsmString(LLVMValueRef InlineAsmVal, size_t *Len) {
519
520 Value *Val = unwrap<Value>(InlineAsmVal);
521 const std::string &AsmString = cast<InlineAsm>(Val)->getAsmString();
522
523 *Len = AsmString.length();
524 return AsmString.c_str();
525}
526
528 size_t *Len) {
529 Value *Val = unwrap<Value>(InlineAsmVal);
530 const std::string &ConstraintString =
531 cast<InlineAsm>(Val)->getConstraintString();
532
533 *Len = ConstraintString.length();
534 return ConstraintString.c_str();
535}
536
538
539 Value *Val = unwrap<Value>(InlineAsmVal);
540 InlineAsm::AsmDialect Dialect = cast<InlineAsm>(Val)->getDialect();
541
542 switch (Dialect) {
547 }
548
549 llvm_unreachable("Unrecognized inline assembly dialect");
551}
552
554 Value *Val = unwrap<Value>(InlineAsmVal);
555 return (LLVMTypeRef)cast<InlineAsm>(Val)->getFunctionType();
556}
557
559 Value *Val = unwrap<Value>(InlineAsmVal);
560 return cast<InlineAsm>(Val)->hasSideEffects();
561}
562
564 Value *Val = unwrap<Value>(InlineAsmVal);
565 return cast<InlineAsm>(Val)->isAlignStack();
566}
567
569 Value *Val = unwrap<Value>(InlineAsmVal);
570 return cast<InlineAsm>(Val)->canThrow();
571}
572
573/*--.. Operations on module contexts ......................................--*/
575 return wrap(&unwrap(M)->getContext());
576}
577
578
579/*===-- Operations on types -----------------------------------------------===*/
580
581/*--.. Operations on all types (mostly) ....................................--*/
582
584 switch (unwrap(Ty)->getTypeID()) {
585 case Type::VoidTyID:
586 return LLVMVoidTypeKind;
587 case Type::HalfTyID:
588 return LLVMHalfTypeKind;
589 case Type::BFloatTyID:
590 return LLVMBFloatTypeKind;
591 case Type::FloatTyID:
592 return LLVMFloatTypeKind;
593 case Type::DoubleTyID:
594 return LLVMDoubleTypeKind;
597 case Type::FP128TyID:
598 return LLVMFP128TypeKind;
601 case Type::LabelTyID:
602 return LLVMLabelTypeKind;
606 return LLVMIntegerTypeKind;
609 case Type::StructTyID:
610 return LLVMStructTypeKind;
611 case Type::ArrayTyID:
612 return LLVMArrayTypeKind;
614 return LLVMPointerTypeKind;
616 return LLVMVectorTypeKind;
618 return LLVMX86_AMXTypeKind;
619 case Type::TokenTyID:
620 return LLVMTokenTypeKind;
626 llvm_unreachable("Typed pointers are unsupported via the C API");
627 }
628 llvm_unreachable("Unhandled TypeID.");
629}
630
632{
633 return unwrap(Ty)->isSized();
634}
635
637 return wrap(&unwrap(Ty)->getContext());
638}
639
641 return unwrap(Ty)->print(errs(), /*IsForDebug=*/true);
642}
643
645 std::string buf;
646 raw_string_ostream os(buf);
647
648 if (unwrap(Ty))
649 unwrap(Ty)->print(os);
650 else
651 os << "Printing <null> Type";
652
653 os.flush();
654
655 return strdup(buf.c_str());
656}
657
658/*--.. Operations on integer types .........................................--*/
659
662}
665}
668}
671}
674}
677}
679 return wrap(IntegerType::get(*unwrap(C), NumBits));
680}
681
684}
687}
690}
693}
696}
699}
700LLVMTypeRef LLVMIntType(unsigned NumBits) {
702}
703
704unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy) {
705 return unwrap<IntegerType>(IntegerTy)->getBitWidth();
706}
707
708/*--.. Operations on real types ............................................--*/
709
712}
715}
718}
721}
724}
727}
730}
733}
734
737}
740}
743}
746}
749}
752}
755}
758}
759
760/*--.. Operations on function types ........................................--*/
761
763 LLVMTypeRef *ParamTypes, unsigned ParamCount,
764 LLVMBool IsVarArg) {
765 ArrayRef<Type*> Tys(unwrap(ParamTypes), ParamCount);
766 return wrap(FunctionType::get(unwrap(ReturnType), Tys, IsVarArg != 0));
767}
768
770 return unwrap<FunctionType>(FunctionTy)->isVarArg();
771}
772
774 return wrap(unwrap<FunctionType>(FunctionTy)->getReturnType());
775}
776
777unsigned LLVMCountParamTypes(LLVMTypeRef FunctionTy) {
778 return unwrap<FunctionType>(FunctionTy)->getNumParams();
779}
780
782 FunctionType *Ty = unwrap<FunctionType>(FunctionTy);
783 for (Type *T : Ty->params())
784 *Dest++ = wrap(T);
785}
786
787/*--.. Operations on struct types ..........................................--*/
788
790 unsigned ElementCount, LLVMBool Packed) {
791 ArrayRef<Type*> Tys(unwrap(ElementTypes), ElementCount);
792 return wrap(StructType::get(*unwrap(C), Tys, Packed != 0));
793}
794
796 unsigned ElementCount, LLVMBool Packed) {
797 return LLVMStructTypeInContext(LLVMGetGlobalContext(), ElementTypes,
798 ElementCount, Packed);
799}
800
802{
803 return wrap(StructType::create(*unwrap(C), Name));
804}
805
807{
808 StructType *Type = unwrap<StructType>(Ty);
809 if (!Type->hasName())
810 return nullptr;
811 return Type->getName().data();
812}
813
814void LLVMStructSetBody(LLVMTypeRef StructTy, LLVMTypeRef *ElementTypes,
815 unsigned ElementCount, LLVMBool Packed) {
816 ArrayRef<Type*> Tys(unwrap(ElementTypes), ElementCount);
817 unwrap<StructType>(StructTy)->setBody(Tys, Packed != 0);
818}
819
821 return unwrap<StructType>(StructTy)->getNumElements();
822}
823
825 StructType *Ty = unwrap<StructType>(StructTy);
826 for (Type *T : Ty->elements())
827 *Dest++ = wrap(T);
828}
829
831 StructType *Ty = unwrap<StructType>(StructTy);
832 return wrap(Ty->getTypeAtIndex(i));
833}
834
836 return unwrap<StructType>(StructTy)->isPacked();
837}
838
840 return unwrap<StructType>(StructTy)->isOpaque();
841}
842
844 return unwrap<StructType>(StructTy)->isLiteral();
845}
846
848 return wrap(StructType::getTypeByName(unwrap(M)->getContext(), Name));
849}
850
853}
854
855/*--.. Operations on array, pointer, and vector types (sequence types) .....--*/
856
858 int i = 0;
859 for (auto *T : unwrap(Tp)->subtypes()) {
860 Arr[i] = wrap(T);
861 i++;
862 }
863}
864
866 return wrap(ArrayType::get(unwrap(ElementType), ElementCount));
867}
868
870 return wrap(ArrayType::get(unwrap(ElementType), ElementCount));
871}
872
874 return wrap(PointerType::get(unwrap(ElementType), AddressSpace));
875}
876
878 return true;
879}
880
882 return wrap(FixedVectorType::get(unwrap(ElementType), ElementCount));
883}
884
886 unsigned ElementCount) {
887 return wrap(ScalableVectorType::get(unwrap(ElementType), ElementCount));
888}
889
891 auto *Ty = unwrap(WrappedTy);
892 if (auto *ATy = dyn_cast<ArrayType>(Ty))
893 return wrap(ATy->getElementType());
894 return wrap(cast<VectorType>(Ty)->getElementType());
895}
896
898 return unwrap(Tp)->getNumContainedTypes();
899}
900
902 return unwrap<ArrayType>(ArrayTy)->getNumElements();
903}
904
906 return unwrap<ArrayType>(ArrayTy)->getNumElements();
907}
908
910 return unwrap<PointerType>(PointerTy)->getAddressSpace();
911}
912
913unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy) {
914 return unwrap<VectorType>(VectorTy)->getElementCount().getKnownMinValue();
915}
916
918 return wrap(unwrap<ConstantPtrAuth>(PtrAuth)->getPointer());
919}
920
922 return wrap(unwrap<ConstantPtrAuth>(PtrAuth)->getKey());
923}
924
926 return wrap(unwrap<ConstantPtrAuth>(PtrAuth)->getDiscriminator());
927}
928
930 return wrap(unwrap<ConstantPtrAuth>(PtrAuth)->getAddrDiscriminator());
931}
932
933/*--.. Operations on other types ...........................................--*/
934
936 return wrap(PointerType::get(*unwrap(C), AddressSpace));
937}
938
940 return wrap(Type::getVoidTy(*unwrap(C)));
941}
943 return wrap(Type::getLabelTy(*unwrap(C)));
944}
946 return wrap(Type::getTokenTy(*unwrap(C)));
947}
949 return wrap(Type::getMetadataTy(*unwrap(C)));
950}
951
954}
957}
958
960 LLVMTypeRef *TypeParams,
961 unsigned TypeParamCount,
962 unsigned *IntParams,
963 unsigned IntParamCount) {
964 ArrayRef<Type *> TypeParamArray(unwrap(TypeParams), TypeParamCount);
965 ArrayRef<unsigned> IntParamArray(IntParams, IntParamCount);
966 return wrap(
967 TargetExtType::get(*unwrap(C), Name, TypeParamArray, IntParamArray));
968}
969
970const char *LLVMGetTargetExtTypeName(LLVMTypeRef TargetExtTy) {
971 TargetExtType *Type = unwrap<TargetExtType>(TargetExtTy);
972 return Type->getName().data();
973}
974
976 TargetExtType *Type = unwrap<TargetExtType>(TargetExtTy);
977 return Type->getNumTypeParameters();
978}
979
981 unsigned Idx) {
982 TargetExtType *Type = unwrap<TargetExtType>(TargetExtTy);
983 return wrap(Type->getTypeParameter(Idx));
984}
985
987 TargetExtType *Type = unwrap<TargetExtType>(TargetExtTy);
988 return Type->getNumIntParameters();
989}
990
991unsigned LLVMGetTargetExtTypeIntParam(LLVMTypeRef TargetExtTy, unsigned Idx) {
992 TargetExtType *Type = unwrap<TargetExtType>(TargetExtTy);
993 return Type->getIntParameter(Idx);
994}
995
996/*===-- Operations on values ----------------------------------------------===*/
997
998/*--.. Operations on all values ............................................--*/
999
1001 return wrap(unwrap(Val)->getType());
1002}
1003
1005 switch(unwrap(Val)->getValueID()) {
1006#define LLVM_C_API 1
1007#define HANDLE_VALUE(Name) \
1008 case Value::Name##Val: \
1009 return LLVM##Name##ValueKind;
1010#include "llvm/IR/Value.def"
1011 default:
1013 }
1014}
1015
1016const char *LLVMGetValueName2(LLVMValueRef Val, size_t *Length) {
1017 auto *V = unwrap(Val);
1018 *Length = V->getName().size();
1019 return V->getName().data();
1020}
1021
1022void LLVMSetValueName2(LLVMValueRef Val, const char *Name, size_t NameLen) {
1023 unwrap(Val)->setName(StringRef(Name, NameLen));
1024}
1025
1027 return unwrap(Val)->getName().data();
1028}
1029
1030void LLVMSetValueName(LLVMValueRef Val, const char *Name) {
1031 unwrap(Val)->setName(Name);
1032}
1033
1035 unwrap(Val)->print(errs(), /*IsForDebug=*/true);
1036}
1037
1039 std::string buf;
1040 raw_string_ostream os(buf);
1041
1042 if (unwrap(Val))
1043 unwrap(Val)->print(os);
1044 else
1045 os << "Printing <null> Value";
1046
1047 os.flush();
1048
1049 return strdup(buf.c_str());
1050}
1051
1053 return wrap(&unwrap(Val)->getContext());
1054}
1055
1057 std::string buf;
1058 raw_string_ostream os(buf);
1059
1060 if (unwrap(Record))
1061 unwrap(Record)->print(os);
1062 else
1063 os << "Printing <null> DbgRecord";
1064
1065 os.flush();
1066
1067 return strdup(buf.c_str());
1068}
1069
1071 unwrap(OldVal)->replaceAllUsesWith(unwrap(NewVal));
1072}
1073
1075 return unwrap<Instruction>(Inst)->hasMetadata();
1076}
1077
1079 auto *I = unwrap<Instruction>(Inst);
1080 assert(I && "Expected instruction");
1081 if (auto *MD = I->getMetadata(KindID))
1082 return wrap(MetadataAsValue::get(I->getContext(), MD));
1083 return nullptr;
1084}
1085
1086// MetadataAsValue uses a canonical format which strips the actual MDNode for
1087// MDNode with just a single constant value, storing just a ConstantAsMetadata
1088// This undoes this canonicalization, reconstructing the MDNode.
1090 Metadata *MD = MAV->getMetadata();
1091 assert((isa<MDNode>(MD) || isa<ConstantAsMetadata>(MD)) &&
1092 "Expected a metadata node or a canonicalized constant");
1093
1094 if (MDNode *N = dyn_cast<MDNode>(MD))
1095 return N;
1096
1097 return MDNode::get(MAV->getContext(), MD);
1098}
1099
1100void LLVMSetMetadata(LLVMValueRef Inst, unsigned KindID, LLVMValueRef Val) {
1101 MDNode *N = Val ? extractMDNode(unwrap<MetadataAsValue>(Val)) : nullptr;
1102
1103 unwrap<Instruction>(Inst)->setMetadata(KindID, N);
1104}
1105
1107 unsigned Kind;
1109};
1110
1113llvm_getMetadata(size_t *NumEntries,
1114 llvm::function_ref<void(MetadataEntries &)> AccessMD) {
1116 AccessMD(MVEs);
1117
1119 static_cast<LLVMOpaqueValueMetadataEntry *>(
1121 for (unsigned i = 0; i < MVEs.size(); ++i) {
1122 const auto &ModuleFlag = MVEs[i];
1123 Result[i].Kind = ModuleFlag.first;
1124 Result[i].Metadata = wrap(ModuleFlag.second);
1125 }
1126 *NumEntries = MVEs.size();
1127 return Result;
1128}
1129
1132 size_t *NumEntries) {
1133 return llvm_getMetadata(NumEntries, [&Value](MetadataEntries &Entries) {
1134 Entries.clear();
1135 unwrap<Instruction>(Value)->getAllMetadata(Entries);
1136 });
1137}
1138
1139/*--.. Conversion functions ................................................--*/
1140
1141#define LLVM_DEFINE_VALUE_CAST(name) \
1142 LLVMValueRef LLVMIsA##name(LLVMValueRef Val) { \
1143 return wrap(static_cast<Value*>(dyn_cast_or_null<name>(unwrap(Val)))); \
1144 }
1145
1147
1149 if (auto *MD = dyn_cast_or_null<MetadataAsValue>(unwrap(Val)))
1150 if (isa<MDNode>(MD->getMetadata()) ||
1151 isa<ValueAsMetadata>(MD->getMetadata()))
1152 return Val;
1153 return nullptr;
1154}
1155
1157 if (auto *MD = dyn_cast_or_null<MetadataAsValue>(unwrap(Val)))
1158 if (isa<ValueAsMetadata>(MD->getMetadata()))
1159 return Val;
1160 return nullptr;
1161}
1162
1164 if (auto *MD = dyn_cast_or_null<MetadataAsValue>(unwrap(Val)))
1165 if (isa<MDString>(MD->getMetadata()))
1166 return Val;
1167 return nullptr;
1168}
1169
1170/*--.. Operations on Uses ..................................................--*/
1172 Value *V = unwrap(Val);
1173 Value::use_iterator I = V->use_begin();
1174 if (I == V->use_end())
1175 return nullptr;
1176 return wrap(&*I);
1177}
1178
1180 Use *Next = unwrap(U)->getNext();
1181 if (Next)
1182 return wrap(Next);
1183 return nullptr;
1184}
1185
1187 return wrap(unwrap(U)->getUser());
1188}
1189
1191 return wrap(unwrap(U)->get());
1192}
1193
1194/*--.. Operations on Users .................................................--*/
1195
1197 unsigned Index) {
1198 Metadata *Op = N->getOperand(Index);
1199 if (!Op)
1200 return nullptr;
1201 if (auto *C = dyn_cast<ConstantAsMetadata>(Op))
1202 return wrap(C->getValue());
1203 return wrap(MetadataAsValue::get(Context, Op));
1204}
1205
1207 Value *V = unwrap(Val);
1208 if (auto *MD = dyn_cast<MetadataAsValue>(V)) {
1209 if (auto *L = dyn_cast<ValueAsMetadata>(MD->getMetadata())) {
1210 assert(Index == 0 && "Function-local metadata can only have one operand");
1211 return wrap(L->getValue());
1212 }
1213 return getMDNodeOperandImpl(V->getContext(),
1214 cast<MDNode>(MD->getMetadata()), Index);
1215 }
1216
1217 return wrap(cast<User>(V)->getOperand(Index));
1218}
1219
1221 Value *V = unwrap(Val);
1222 return wrap(&cast<User>(V)->getOperandUse(Index));
1223}
1224
1226 unwrap<User>(Val)->setOperand(Index, unwrap(Op));
1227}
1228
1230 Value *V = unwrap(Val);
1231 if (isa<MetadataAsValue>(V))
1232 return LLVMGetMDNodeNumOperands(Val);
1233
1234 return cast<User>(V)->getNumOperands();
1235}
1236
1237/*--.. Operations on constants of any type .................................--*/
1238
1240 return wrap(Constant::getNullValue(unwrap(Ty)));
1241}
1242
1245}
1246
1248 return wrap(UndefValue::get(unwrap(Ty)));
1249}
1250
1252 return wrap(PoisonValue::get(unwrap(Ty)));
1253}
1254
1256 return isa<Constant>(unwrap(Ty));
1257}
1258
1260 if (Constant *C = dyn_cast<Constant>(unwrap(Val)))
1261 return C->isNullValue();
1262 return false;
1263}
1264
1266 return isa<UndefValue>(unwrap(Val));
1267}
1268
1270 return isa<PoisonValue>(unwrap(Val));
1271}
1272
1274 return wrap(ConstantPointerNull::get(unwrap<PointerType>(Ty)));
1275}
1276
1277/*--.. Operations on metadata nodes ........................................--*/
1278
1280 size_t SLen) {
1281 return wrap(MDString::get(*unwrap(C), StringRef(Str, SLen)));
1282}
1283
1285 size_t Count) {
1286 return wrap(MDNode::get(*unwrap(C), ArrayRef<Metadata*>(unwrap(MDs), Count)));
1287}
1288
1290 unsigned SLen) {
1291 LLVMContext &Context = *unwrap(C);
1293 Context, MDString::get(Context, StringRef(Str, SLen))));
1294}
1295
1296LLVMValueRef LLVMMDString(const char *Str, unsigned SLen) {
1297 return LLVMMDStringInContext(LLVMGetGlobalContext(), Str, SLen);
1298}
1299
1301 unsigned Count) {
1302 LLVMContext &Context = *unwrap(C);
1304 for (auto *OV : ArrayRef(Vals, Count)) {
1305 Value *V = unwrap(OV);
1306 Metadata *MD;
1307 if (!V)
1308 MD = nullptr;
1309 else if (auto *C = dyn_cast<Constant>(V))
1311 else if (auto *MDV = dyn_cast<MetadataAsValue>(V)) {
1312 MD = MDV->getMetadata();
1313 assert(!isa<LocalAsMetadata>(MD) && "Unexpected function-local metadata "
1314 "outside of direct argument to call");
1315 } else {
1316 // This is function-local metadata. Pretend to make an MDNode.
1317 assert(Count == 1 &&
1318 "Expected only one operand to function-local metadata");
1319 return wrap(MetadataAsValue::get(Context, LocalAsMetadata::get(V)));
1320 }
1321
1322 MDs.push_back(MD);
1323 }
1324 return wrap(MetadataAsValue::get(Context, MDNode::get(Context, MDs)));
1325}
1326
1327LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count) {
1328 return LLVMMDNodeInContext(LLVMGetGlobalContext(), Vals, Count);
1329}
1330
1332 return wrap(MetadataAsValue::get(*unwrap(C), unwrap(MD)));
1333}
1334
1336 auto *V = unwrap(Val);
1337 if (auto *C = dyn_cast<Constant>(V))
1339 if (auto *MAV = dyn_cast<MetadataAsValue>(V))
1340 return wrap(MAV->getMetadata());
1341 return wrap(ValueAsMetadata::get(V));
1342}
1343
1344const char *LLVMGetMDString(LLVMValueRef V, unsigned *Length) {
1345 if (const auto *MD = dyn_cast<MetadataAsValue>(unwrap(V)))
1346 if (const MDString *S = dyn_cast<MDString>(MD->getMetadata())) {
1347 *Length = S->getString().size();
1348 return S->getString().data();
1349 }
1350 *Length = 0;
1351 return nullptr;
1352}
1353
1355 auto *MD = unwrap<MetadataAsValue>(V);
1356 if (isa<ValueAsMetadata>(MD->getMetadata()))
1357 return 1;
1358 return cast<MDNode>(MD->getMetadata())->getNumOperands();
1359}
1360
1362 Module *Mod = unwrap(M);
1363 Module::named_metadata_iterator I = Mod->named_metadata_begin();
1364 if (I == Mod->named_metadata_end())
1365 return nullptr;
1366 return wrap(&*I);
1367}
1368
1370 Module *Mod = unwrap(M);
1371 Module::named_metadata_iterator I = Mod->named_metadata_end();
1372 if (I == Mod->named_metadata_begin())
1373 return nullptr;
1374 return wrap(&*--I);
1375}
1376
1378 NamedMDNode *NamedNode = unwrap(NMD);
1380 if (++I == NamedNode->getParent()->named_metadata_end())
1381 return nullptr;
1382 return wrap(&*I);
1383}
1384
1386 NamedMDNode *NamedNode = unwrap(NMD);
1388 if (I == NamedNode->getParent()->named_metadata_begin())
1389 return nullptr;
1390 return wrap(&*--I);
1391}
1392
1394 const char *Name, size_t NameLen) {
1395 return wrap(unwrap(M)->getNamedMetadata(StringRef(Name, NameLen)));
1396}
1397
1399 const char *Name, size_t NameLen) {
1400 return wrap(unwrap(M)->getOrInsertNamedMetadata({Name, NameLen}));
1401}
1402
1403const char *LLVMGetNamedMetadataName(LLVMNamedMDNodeRef NMD, size_t *NameLen) {
1404 NamedMDNode *NamedNode = unwrap(NMD);
1405 *NameLen = NamedNode->getName().size();
1406 return NamedNode->getName().data();
1407}
1408
1410 auto *MD = unwrap<MetadataAsValue>(V);
1411 if (auto *MDV = dyn_cast<ValueAsMetadata>(MD->getMetadata())) {
1412 *Dest = wrap(MDV->getValue());
1413 return;
1414 }
1415 const auto *N = cast<MDNode>(MD->getMetadata());
1416 const unsigned numOperands = N->getNumOperands();
1417 LLVMContext &Context = unwrap(V)->getContext();
1418 for (unsigned i = 0; i < numOperands; i++)
1419 Dest[i] = getMDNodeOperandImpl(Context, N, i);
1420}
1421
1423 LLVMMetadataRef Replacement) {
1424 auto *MD = cast<MetadataAsValue>(unwrap(V));
1425 auto *N = cast<MDNode>(MD->getMetadata());
1426 N->replaceOperandWith(Index, unwrap<Metadata>(Replacement));
1427}
1428
1430 if (NamedMDNode *N = unwrap(M)->getNamedMetadata(Name)) {
1431 return N->getNumOperands();
1432 }
1433 return 0;
1434}
1435
1437 LLVMValueRef *Dest) {
1438 NamedMDNode *N = unwrap(M)->getNamedMetadata(Name);
1439 if (!N)
1440 return;
1441 LLVMContext &Context = unwrap(M)->getContext();
1442 for (unsigned i=0;i<N->getNumOperands();i++)
1443 Dest[i] = wrap(MetadataAsValue::get(Context, N->getOperand(i)));
1444}
1445
1447 LLVMValueRef Val) {
1448 NamedMDNode *N = unwrap(M)->getOrInsertNamedMetadata(Name);
1449 if (!N)
1450 return;
1451 if (!Val)
1452 return;
1453 N->addOperand(extractMDNode(unwrap<MetadataAsValue>(Val)));
1454}
1455
1456const char *LLVMGetDebugLocDirectory(LLVMValueRef Val, unsigned *Length) {
1457 if (!Length) return nullptr;
1458 StringRef S;
1459 if (const auto *I = dyn_cast<Instruction>(unwrap(Val))) {
1460 if (const auto &DL = I->getDebugLoc()) {
1461 S = DL->getDirectory();
1462 }
1463 } else if (const auto *GV = dyn_cast<GlobalVariable>(unwrap(Val))) {
1465 GV->getDebugInfo(GVEs);
1466 if (GVEs.size())
1467 if (const DIGlobalVariable *DGV = GVEs[0]->getVariable())
1468 S = DGV->getDirectory();
1469 } else if (const auto *F = dyn_cast<Function>(unwrap(Val))) {
1470 if (const DISubprogram *DSP = F->getSubprogram())
1471 S = DSP->getDirectory();
1472 } else {
1473 assert(0 && "Expected Instruction, GlobalVariable or Function");
1474 return nullptr;
1475 }
1476 *Length = S.size();
1477 return S.data();
1478}
1479
1480const char *LLVMGetDebugLocFilename(LLVMValueRef Val, unsigned *Length) {
1481 if (!Length) return nullptr;
1482 StringRef S;
1483 if (const auto *I = dyn_cast<Instruction>(unwrap(Val))) {
1484 if (const auto &DL = I->getDebugLoc()) {
1485 S = DL->getFilename();
1486 }
1487 } else if (const auto *GV = dyn_cast<GlobalVariable>(unwrap(Val))) {
1489 GV->getDebugInfo(GVEs);
1490 if (GVEs.size())
1491 if (const DIGlobalVariable *DGV = GVEs[0]->getVariable())
1492 S = DGV->getFilename();
1493 } else if (const auto *F = dyn_cast<Function>(unwrap(Val))) {
1494 if (const DISubprogram *DSP = F->getSubprogram())
1495 S = DSP->getFilename();
1496 } else {
1497 assert(0 && "Expected Instruction, GlobalVariable or Function");
1498 return nullptr;
1499 }
1500 *Length = S.size();
1501 return S.data();
1502}
1503
1505 unsigned L = 0;
1506 if (const auto *I = dyn_cast<Instruction>(unwrap(Val))) {
1507 if (const auto &DL = I->getDebugLoc()) {
1508 L = DL->getLine();
1509 }
1510 } else if (const auto *GV = dyn_cast<GlobalVariable>(unwrap(Val))) {
1512 GV->getDebugInfo(GVEs);
1513 if (GVEs.size())
1514 if (const DIGlobalVariable *DGV = GVEs[0]->getVariable())
1515 L = DGV->getLine();
1516 } else if (const auto *F = dyn_cast<Function>(unwrap(Val))) {
1517 if (const DISubprogram *DSP = F->getSubprogram())
1518 L = DSP->getLine();
1519 } else {
1520 assert(0 && "Expected Instruction, GlobalVariable or Function");
1521 return -1;
1522 }
1523 return L;
1524}
1525
1527 unsigned C = 0;
1528 if (const auto *I = dyn_cast<Instruction>(unwrap(Val)))
1529 if (const auto &DL = I->getDebugLoc())
1530 C = DL->getColumn();
1531 return C;
1532}
1533
1534/*--.. Operations on scalar constants ......................................--*/
1535
1536LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N,
1537 LLVMBool SignExtend) {
1538 return wrap(ConstantInt::get(unwrap<IntegerType>(IntTy), N, SignExtend != 0));
1539}
1540
1542 unsigned NumWords,
1543 const uint64_t Words[]) {
1544 IntegerType *Ty = unwrap<IntegerType>(IntTy);
1545 return wrap(ConstantInt::get(
1546 Ty->getContext(), APInt(Ty->getBitWidth(), ArrayRef(Words, NumWords))));
1547}
1548
1550 uint8_t Radix) {
1551 return wrap(ConstantInt::get(unwrap<IntegerType>(IntTy), StringRef(Str),
1552 Radix));
1553}
1554
1556 unsigned SLen, uint8_t Radix) {
1557 return wrap(ConstantInt::get(unwrap<IntegerType>(IntTy), StringRef(Str, SLen),
1558 Radix));
1559}
1560
1562 return wrap(ConstantFP::get(unwrap(RealTy), N));
1563}
1564
1566 return wrap(ConstantFP::get(unwrap(RealTy), StringRef(Text)));
1567}
1568
1570 unsigned SLen) {
1571 return wrap(ConstantFP::get(unwrap(RealTy), StringRef(Str, SLen)));
1572}
1573
1574unsigned long long LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal) {
1575 return unwrap<ConstantInt>(ConstantVal)->getZExtValue();
1576}
1577
1579 return unwrap<ConstantInt>(ConstantVal)->getSExtValue();
1580}
1581
1582double LLVMConstRealGetDouble(LLVMValueRef ConstantVal, LLVMBool *LosesInfo) {
1583 ConstantFP *cFP = unwrap<ConstantFP>(ConstantVal) ;
1584 Type *Ty = cFP->getType();
1585
1586 if (Ty->isHalfTy() || Ty->isBFloatTy() || Ty->isFloatTy() ||
1587 Ty->isDoubleTy()) {
1588 *LosesInfo = false;
1589 return cFP->getValueAPF().convertToDouble();
1590 }
1591
1592 bool APFLosesInfo;
1593 APFloat APF = cFP->getValueAPF();
1594 APF.convert(APFloat::IEEEdouble(), APFloat::rmNearestTiesToEven, &APFLosesInfo);
1595 *LosesInfo = APFLosesInfo;
1596 return APF.convertToDouble();
1597}
1598
1599/*--.. Operations on composite constants ...................................--*/
1600
1602 unsigned Length,
1603 LLVMBool DontNullTerminate) {
1604 /* Inverted the sense of AddNull because ', 0)' is a
1605 better mnemonic for null termination than ', 1)'. */
1607 DontNullTerminate == 0));
1608}
1609
1611 size_t Length,
1612 LLVMBool DontNullTerminate) {
1613 /* Inverted the sense of AddNull because ', 0)' is a
1614 better mnemonic for null termination than ', 1)'. */
1616 DontNullTerminate == 0));
1617}
1618
1619LLVMValueRef LLVMConstString(const char *Str, unsigned Length,
1620 LLVMBool DontNullTerminate) {
1622 DontNullTerminate);
1623}
1624
1626 return wrap(unwrap<Constant>(C)->getAggregateElement(Idx));
1627}
1628
1630 return wrap(unwrap<ConstantDataSequential>(C)->getElementAsConstant(idx));
1631}
1632
1634 return unwrap<ConstantDataSequential>(C)->isString();
1635}
1636
1637const char *LLVMGetAsString(LLVMValueRef C, size_t *Length) {
1638 StringRef Str = unwrap<ConstantDataSequential>(C)->getAsString();
1639 *Length = Str.size();
1640 return Str.data();
1641}
1642
1644 LLVMValueRef *ConstantVals, unsigned Length) {
1645 ArrayRef<Constant*> V(unwrap<Constant>(ConstantVals, Length), Length);
1646 return wrap(ConstantArray::get(ArrayType::get(unwrap(ElementTy), Length), V));
1647}
1648
1650 uint64_t Length) {
1651 ArrayRef<Constant *> V(unwrap<Constant>(ConstantVals, Length), Length);
1652 return wrap(ConstantArray::get(ArrayType::get(unwrap(ElementTy), Length), V));
1653}
1654
1656 LLVMValueRef *ConstantVals,
1657 unsigned Count, LLVMBool Packed) {
1658 Constant **Elements = unwrap<Constant>(ConstantVals, Count);
1659 return wrap(ConstantStruct::getAnon(*unwrap(C), ArrayRef(Elements, Count),
1660 Packed != 0));
1661}
1662
1663LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count,
1664 LLVMBool Packed) {
1665 return LLVMConstStructInContext(LLVMGetGlobalContext(), ConstantVals, Count,
1666 Packed);
1667}
1668
1670 LLVMValueRef *ConstantVals,
1671 unsigned Count) {
1672 Constant **Elements = unwrap<Constant>(ConstantVals, Count);
1673 StructType *Ty = unwrap<StructType>(StructTy);
1674
1675 return wrap(ConstantStruct::get(Ty, ArrayRef(Elements, Count)));
1676}
1677
1678LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size) {
1680 ArrayRef(unwrap<Constant>(ScalarConstantVals, Size), Size)));
1681}
1682
1684 LLVMValueRef Disc, LLVMValueRef AddrDisc) {
1686 unwrap<Constant>(Ptr), unwrap<ConstantInt>(Key),
1687 unwrap<ConstantInt>(Disc), unwrap<Constant>(AddrDisc)));
1688}
1689
1690/*-- Opcode mapping */
1691
1693{
1694 switch (opcode) {
1695 default: llvm_unreachable("Unhandled Opcode.");
1696#define HANDLE_INST(num, opc, clas) case num: return LLVM##opc;
1697#include "llvm/IR/Instruction.def"
1698#undef HANDLE_INST
1699 }
1700}
1701
1703{
1704 switch (code) {
1705#define HANDLE_INST(num, opc, clas) case LLVM##opc: return num;
1706#include "llvm/IR/Instruction.def"
1707#undef HANDLE_INST
1708 }
1709 llvm_unreachable("Unhandled Opcode.");
1710}
1711
1712/*-- GEP wrap flag conversions */
1713
1715 GEPNoWrapFlags NewGEPFlags;
1716 if ((GEPFlags & LLVMGEPFlagInBounds) != 0)
1717 NewGEPFlags |= GEPNoWrapFlags::inBounds();
1718 if ((GEPFlags & LLVMGEPFlagNUSW) != 0)
1719 NewGEPFlags |= GEPNoWrapFlags::noUnsignedSignedWrap();
1720 if ((GEPFlags & LLVMGEPFlagNUW) != 0)
1721 NewGEPFlags |= GEPNoWrapFlags::noUnsignedWrap();
1722
1723 return NewGEPFlags;
1724}
1725
1727 LLVMGEPNoWrapFlags NewGEPFlags = 0;
1728 if (GEPFlags.isInBounds())
1729 NewGEPFlags |= LLVMGEPFlagInBounds;
1730 if (GEPFlags.hasNoUnsignedSignedWrap())
1731 NewGEPFlags |= LLVMGEPFlagNUSW;
1732 if (GEPFlags.hasNoUnsignedWrap())
1733 NewGEPFlags |= LLVMGEPFlagNUW;
1734
1735 return NewGEPFlags;
1736}
1737
1738/*--.. Constant expressions ................................................--*/
1739
1741 return map_to_llvmopcode(unwrap<ConstantExpr>(ConstantVal)->getOpcode());
1742}
1743
1746}
1747
1749 return wrap(ConstantExpr::getSizeOf(unwrap(Ty)));
1750}
1751
1753 return wrap(ConstantExpr::getNeg(unwrap<Constant>(ConstantVal)));
1754}
1755
1757 return wrap(ConstantExpr::getNSWNeg(unwrap<Constant>(ConstantVal)));
1758}
1759
1761 return wrap(ConstantExpr::getNeg(unwrap<Constant>(ConstantVal)));
1762}
1763
1764
1766 return wrap(ConstantExpr::getNot(unwrap<Constant>(ConstantVal)));
1767}
1768
1770 return wrap(ConstantExpr::getAdd(unwrap<Constant>(LHSConstant),
1771 unwrap<Constant>(RHSConstant)));
1772}
1773
1775 LLVMValueRef RHSConstant) {
1776 return wrap(ConstantExpr::getNSWAdd(unwrap<Constant>(LHSConstant),
1777 unwrap<Constant>(RHSConstant)));
1778}
1779
1781 LLVMValueRef RHSConstant) {
1782 return wrap(ConstantExpr::getNUWAdd(unwrap<Constant>(LHSConstant),
1783 unwrap<Constant>(RHSConstant)));
1784}
1785
1787 return wrap(ConstantExpr::getSub(unwrap<Constant>(LHSConstant),
1788 unwrap<Constant>(RHSConstant)));
1789}
1790
1792 LLVMValueRef RHSConstant) {
1793 return wrap(ConstantExpr::getNSWSub(unwrap<Constant>(LHSConstant),
1794 unwrap<Constant>(RHSConstant)));
1795}
1796
1798 LLVMValueRef RHSConstant) {
1799 return wrap(ConstantExpr::getNUWSub(unwrap<Constant>(LHSConstant),
1800 unwrap<Constant>(RHSConstant)));
1801}
1802
1804 return wrap(ConstantExpr::getMul(unwrap<Constant>(LHSConstant),
1805 unwrap<Constant>(RHSConstant)));
1806}
1807
1809 LLVMValueRef RHSConstant) {
1810 return wrap(ConstantExpr::getNSWMul(unwrap<Constant>(LHSConstant),
1811 unwrap<Constant>(RHSConstant)));
1812}
1813
1815 LLVMValueRef RHSConstant) {
1816 return wrap(ConstantExpr::getNUWMul(unwrap<Constant>(LHSConstant),
1817 unwrap<Constant>(RHSConstant)));
1818}
1819
1821 return wrap(ConstantExpr::getXor(unwrap<Constant>(LHSConstant),
1822 unwrap<Constant>(RHSConstant)));
1823}
1824
1826 LLVMValueRef *ConstantIndices, unsigned NumIndices) {
1827 ArrayRef<Constant *> IdxList(unwrap<Constant>(ConstantIndices, NumIndices),
1828 NumIndices);
1829 Constant *Val = unwrap<Constant>(ConstantVal);
1830 return wrap(ConstantExpr::getGetElementPtr(unwrap(Ty), Val, IdxList));
1831}
1832
1834 LLVMValueRef *ConstantIndices,
1835 unsigned NumIndices) {
1836 ArrayRef<Constant *> IdxList(unwrap<Constant>(ConstantIndices, NumIndices),
1837 NumIndices);
1838 Constant *Val = unwrap<Constant>(ConstantVal);
1839 return wrap(ConstantExpr::getInBoundsGetElementPtr(unwrap(Ty), Val, IdxList));
1840}
1841
1843 LLVMValueRef ConstantVal,
1844 LLVMValueRef *ConstantIndices,
1845 unsigned NumIndices,
1846 LLVMGEPNoWrapFlags NoWrapFlags) {
1847 ArrayRef<Constant *> IdxList(unwrap<Constant>(ConstantIndices, NumIndices),
1848 NumIndices);
1849 Constant *Val = unwrap<Constant>(ConstantVal);
1851 unwrap(Ty), Val, IdxList, mapFromLLVMGEPNoWrapFlags(NoWrapFlags)));
1852}
1853
1855 return wrap(ConstantExpr::getTrunc(unwrap<Constant>(ConstantVal),
1856 unwrap(ToType)));
1857}
1858
1860 return wrap(ConstantExpr::getPtrToInt(unwrap<Constant>(ConstantVal),
1861 unwrap(ToType)));
1862}
1863
1865 return wrap(ConstantExpr::getIntToPtr(unwrap<Constant>(ConstantVal),
1866 unwrap(ToType)));
1867}
1868
1870 return wrap(ConstantExpr::getBitCast(unwrap<Constant>(ConstantVal),
1871 unwrap(ToType)));
1872}
1873
1875 LLVMTypeRef ToType) {
1876 return wrap(ConstantExpr::getAddrSpaceCast(unwrap<Constant>(ConstantVal),
1877 unwrap(ToType)));
1878}
1879
1881 LLVMTypeRef ToType) {
1882 return wrap(ConstantExpr::getTruncOrBitCast(unwrap<Constant>(ConstantVal),
1883 unwrap(ToType)));
1884}
1885
1887 LLVMTypeRef ToType) {
1888 return wrap(ConstantExpr::getPointerCast(unwrap<Constant>(ConstantVal),
1889 unwrap(ToType)));
1890}
1891
1893 LLVMValueRef IndexConstant) {
1894 return wrap(ConstantExpr::getExtractElement(unwrap<Constant>(VectorConstant),
1895 unwrap<Constant>(IndexConstant)));
1896}
1897
1899 LLVMValueRef ElementValueConstant,
1900 LLVMValueRef IndexConstant) {
1901 return wrap(ConstantExpr::getInsertElement(unwrap<Constant>(VectorConstant),
1902 unwrap<Constant>(ElementValueConstant),
1903 unwrap<Constant>(IndexConstant)));
1904}
1905
1907 LLVMValueRef VectorBConstant,
1908 LLVMValueRef MaskConstant) {
1909 SmallVector<int, 16> IntMask;
1910 ShuffleVectorInst::getShuffleMask(unwrap<Constant>(MaskConstant), IntMask);
1911 return wrap(ConstantExpr::getShuffleVector(unwrap<Constant>(VectorAConstant),
1912 unwrap<Constant>(VectorBConstant),
1913 IntMask));
1914}
1915
1917 const char *Constraints,
1918 LLVMBool HasSideEffects,
1919 LLVMBool IsAlignStack) {
1920 return wrap(InlineAsm::get(dyn_cast<FunctionType>(unwrap(Ty)), AsmString,
1921 Constraints, HasSideEffects, IsAlignStack));
1922}
1923
1925 return wrap(BlockAddress::get(unwrap<Function>(F), unwrap(BB)));
1926}
1927
1929 return wrap(unwrap<BlockAddress>(BlockAddr)->getFunction());
1930}
1931
1933 return wrap(unwrap<BlockAddress>(BlockAddr)->getBasicBlock());
1934}
1935
1936/*--.. Operations on global variables, functions, and aliases (globals) ....--*/
1937
1939 return wrap(unwrap<GlobalValue>(Global)->getParent());
1940}
1941
1943 return unwrap<GlobalValue>(Global)->isDeclaration();
1944}
1945
1947 switch (unwrap<GlobalValue>(Global)->getLinkage()) {
1949 return LLVMExternalLinkage;
1957 return LLVMWeakAnyLinkage;
1959 return LLVMWeakODRLinkage;
1961 return LLVMAppendingLinkage;
1963 return LLVMInternalLinkage;
1965 return LLVMPrivateLinkage;
1969 return LLVMCommonLinkage;
1970 }
1971
1972 llvm_unreachable("Invalid GlobalValue linkage!");
1973}
1974
1976 GlobalValue *GV = unwrap<GlobalValue>(Global);
1977
1978 switch (Linkage) {
1981 break;
1984 break;
1987 break;
1990 break;
1992 LLVM_DEBUG(
1993 errs() << "LLVMSetLinkage(): LLVMLinkOnceODRAutoHideLinkage is no "
1994 "longer supported.");
1995 break;
1996 case LLVMWeakAnyLinkage:
1998 break;
1999 case LLVMWeakODRLinkage:
2001 break;
2004 break;
2007 break;
2008 case LLVMPrivateLinkage:
2010 break;
2013 break;
2016 break;
2018 LLVM_DEBUG(
2019 errs()
2020 << "LLVMSetLinkage(): LLVMDLLImportLinkage is no longer supported.");
2021 break;
2023 LLVM_DEBUG(
2024 errs()
2025 << "LLVMSetLinkage(): LLVMDLLExportLinkage is no longer supported.");
2026 break;
2029 break;
2030 case LLVMGhostLinkage:
2031 LLVM_DEBUG(
2032 errs() << "LLVMSetLinkage(): LLVMGhostLinkage is no longer supported.");
2033 break;
2034 case LLVMCommonLinkage:
2036 break;
2037 }
2038}
2039
2041 // Using .data() is safe because of how GlobalObject::setSection is
2042 // implemented.
2043 return unwrap<GlobalValue>(Global)->getSection().data();
2044}
2045
2046void LLVMSetSection(LLVMValueRef Global, const char *Section) {
2047 unwrap<GlobalObject>(Global)->setSection(Section);
2048}
2049
2051 return static_cast<LLVMVisibility>(
2052 unwrap<GlobalValue>(Global)->getVisibility());
2053}
2054
2056 unwrap<GlobalValue>(Global)
2057 ->setVisibility(static_cast<GlobalValue::VisibilityTypes>(Viz));
2058}
2059
2061 return static_cast<LLVMDLLStorageClass>(
2062 unwrap<GlobalValue>(Global)->getDLLStorageClass());
2063}
2064
2066 unwrap<GlobalValue>(Global)->setDLLStorageClass(
2067 static_cast<GlobalValue::DLLStorageClassTypes>(Class));
2068}
2069
2071 switch (unwrap<GlobalValue>(Global)->getUnnamedAddr()) {
2072 case GlobalVariable::UnnamedAddr::None:
2073 return LLVMNoUnnamedAddr;
2074 case GlobalVariable::UnnamedAddr::Local:
2075 return LLVMLocalUnnamedAddr;
2076 case GlobalVariable::UnnamedAddr::Global:
2077 return LLVMGlobalUnnamedAddr;
2078 }
2079 llvm_unreachable("Unknown UnnamedAddr kind!");
2080}
2081
2083 GlobalValue *GV = unwrap<GlobalValue>(Global);
2084
2085 switch (UnnamedAddr) {
2086 case LLVMNoUnnamedAddr:
2087 return GV->setUnnamedAddr(GlobalVariable::UnnamedAddr::None);
2089 return GV->setUnnamedAddr(GlobalVariable::UnnamedAddr::Local);
2091 return GV->setUnnamedAddr(GlobalVariable::UnnamedAddr::Global);
2092 }
2093}
2094
2096 return unwrap<GlobalValue>(Global)->hasGlobalUnnamedAddr();
2097}
2098
2100 unwrap<GlobalValue>(Global)->setUnnamedAddr(
2101 HasUnnamedAddr ? GlobalValue::UnnamedAddr::Global
2102 : GlobalValue::UnnamedAddr::None);
2103}
2104
2106 return wrap(unwrap<GlobalValue>(Global)->getValueType());
2107}
2108
2109/*--.. Operations on global variables, load and store instructions .........--*/
2110
2112 Value *P = unwrap(V);
2113 if (GlobalObject *GV = dyn_cast<GlobalObject>(P))
2114 return GV->getAlign() ? GV->getAlign()->value() : 0;
2115 if (AllocaInst *AI = dyn_cast<AllocaInst>(P))
2116 return AI->getAlign().value();
2117 if (LoadInst *LI = dyn_cast<LoadInst>(P))
2118 return LI->getAlign().value();
2119 if (StoreInst *SI = dyn_cast<StoreInst>(P))
2120 return SI->getAlign().value();
2121 if (AtomicRMWInst *RMWI = dyn_cast<AtomicRMWInst>(P))
2122 return RMWI->getAlign().value();
2123 if (AtomicCmpXchgInst *CXI = dyn_cast<AtomicCmpXchgInst>(P))
2124 return CXI->getAlign().value();
2125
2127 "only GlobalValue, AllocaInst, LoadInst, StoreInst, AtomicRMWInst, "
2128 "and AtomicCmpXchgInst have alignment");
2129}
2130
2131void LLVMSetAlignment(LLVMValueRef V, unsigned Bytes) {
2132 Value *P = unwrap(V);
2133 if (GlobalObject *GV = dyn_cast<GlobalObject>(P))
2134 GV->setAlignment(MaybeAlign(Bytes));
2135 else if (AllocaInst *AI = dyn_cast<AllocaInst>(P))
2136 AI->setAlignment(Align(Bytes));
2137 else if (LoadInst *LI = dyn_cast<LoadInst>(P))
2138 LI->setAlignment(Align(Bytes));
2139 else if (StoreInst *SI = dyn_cast<StoreInst>(P))
2140 SI->setAlignment(Align(Bytes));
2141 else if (AtomicRMWInst *RMWI = dyn_cast<AtomicRMWInst>(P))
2142 RMWI->setAlignment(Align(Bytes));
2143 else if (AtomicCmpXchgInst *CXI = dyn_cast<AtomicCmpXchgInst>(P))
2144 CXI->setAlignment(Align(Bytes));
2145 else
2147 "only GlobalValue, AllocaInst, LoadInst, StoreInst, AtomicRMWInst, and "
2148 "and AtomicCmpXchgInst have alignment");
2149}
2150
2152 size_t *NumEntries) {
2153 return llvm_getMetadata(NumEntries, [&Value](MetadataEntries &Entries) {
2154 Entries.clear();
2155 if (Instruction *Instr = dyn_cast<Instruction>(unwrap(Value))) {
2156 Instr->getAllMetadata(Entries);
2157 } else {
2158 unwrap<GlobalObject>(Value)->getAllMetadata(Entries);
2159 }
2160 });
2161}
2162
2164 unsigned Index) {
2166 static_cast<LLVMOpaqueValueMetadataEntry>(Entries[Index]);
2167 return MVE.Kind;
2168}
2169
2172 unsigned Index) {
2174 static_cast<LLVMOpaqueValueMetadataEntry>(Entries[Index]);
2175 return MVE.Metadata;
2176}
2177
2179 free(Entries);
2180}
2181
2183 LLVMMetadataRef MD) {
2184 unwrap<GlobalObject>(Global)->setMetadata(Kind, unwrap<MDNode>(MD));
2185}
2186
2188 unwrap<GlobalObject>(Global)->eraseMetadata(Kind);
2189}
2190
2192 unwrap<GlobalObject>(Global)->clearMetadata();
2193}
2194
2195/*--.. Operations on global variables ......................................--*/
2196
2198 return wrap(new GlobalVariable(*unwrap(M), unwrap(Ty), false,
2200}
2201
2203 const char *Name,
2204 unsigned AddressSpace) {
2205 return wrap(new GlobalVariable(*unwrap(M), unwrap(Ty), false,
2207 nullptr, GlobalVariable::NotThreadLocal,
2208 AddressSpace));
2209}
2210
2212 return wrap(unwrap(M)->getNamedGlobal(Name));
2213}
2214
2216 size_t Length) {
2217 return wrap(unwrap(M)->getNamedGlobal(StringRef(Name, Length)));
2218}
2219
2221 Module *Mod = unwrap(M);
2222 Module::global_iterator I = Mod->global_begin();
2223 if (I == Mod->global_end())
2224 return nullptr;
2225 return wrap(&*I);
2226}
2227
2229 Module *Mod = unwrap(M);
2230 Module::global_iterator I = Mod->global_end();
2231 if (I == Mod->global_begin())
2232 return nullptr;
2233 return wrap(&*--I);
2234}
2235
2237 GlobalVariable *GV = unwrap<GlobalVariable>(GlobalVar);
2239 if (++I == GV->getParent()->global_end())
2240 return nullptr;
2241 return wrap(&*I);
2242}
2243
2245 GlobalVariable *GV = unwrap<GlobalVariable>(GlobalVar);
2247 if (I == GV->getParent()->global_begin())
2248 return nullptr;
2249 return wrap(&*--I);
2250}
2251
2253 unwrap<GlobalVariable>(GlobalVar)->eraseFromParent();
2254}
2255
2257 GlobalVariable* GV = unwrap<GlobalVariable>(GlobalVar);
2258 if ( !GV->hasInitializer() )
2259 return nullptr;
2260 return wrap(GV->getInitializer());
2261}
2262
2263void LLVMSetInitializer(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal) {
2264 unwrap<GlobalVariable>(GlobalVar)
2265 ->setInitializer(unwrap<Constant>(ConstantVal));
2266}
2267
2269 return unwrap<GlobalVariable>(GlobalVar)->isThreadLocal();
2270}
2271
2272void LLVMSetThreadLocal(LLVMValueRef GlobalVar, LLVMBool IsThreadLocal) {
2273 unwrap<GlobalVariable>(GlobalVar)->setThreadLocal(IsThreadLocal != 0);
2274}
2275
2277 return unwrap<GlobalVariable>(GlobalVar)->isConstant();
2278}
2279
2280void LLVMSetGlobalConstant(LLVMValueRef GlobalVar, LLVMBool IsConstant) {
2281 unwrap<GlobalVariable>(GlobalVar)->setConstant(IsConstant != 0);
2282}
2283
2285 switch (unwrap<GlobalVariable>(GlobalVar)->getThreadLocalMode()) {
2286 case GlobalVariable::NotThreadLocal:
2287 return LLVMNotThreadLocal;
2288 case GlobalVariable::GeneralDynamicTLSModel:
2290 case GlobalVariable::LocalDynamicTLSModel:
2292 case GlobalVariable::InitialExecTLSModel:
2294 case GlobalVariable::LocalExecTLSModel:
2295 return LLVMLocalExecTLSModel;
2296 }
2297
2298 llvm_unreachable("Invalid GlobalVariable thread local mode");
2299}
2300
2302 GlobalVariable *GV = unwrap<GlobalVariable>(GlobalVar);
2303
2304 switch (Mode) {
2305 case LLVMNotThreadLocal:
2306 GV->setThreadLocalMode(GlobalVariable::NotThreadLocal);
2307 break;
2309 GV->setThreadLocalMode(GlobalVariable::GeneralDynamicTLSModel);
2310 break;
2312 GV->setThreadLocalMode(GlobalVariable::LocalDynamicTLSModel);
2313 break;
2315 GV->setThreadLocalMode(GlobalVariable::InitialExecTLSModel);
2316 break;
2318 GV->setThreadLocalMode(GlobalVariable::LocalExecTLSModel);
2319 break;
2320 }
2321}
2322
2324 return unwrap<GlobalVariable>(GlobalVar)->isExternallyInitialized();
2325}
2326
2328 unwrap<GlobalVariable>(GlobalVar)->setExternallyInitialized(IsExtInit);
2329}
2330
2331/*--.. Operations on aliases ......................................--*/
2332
2334 unsigned AddrSpace, LLVMValueRef Aliasee,
2335 const char *Name) {
2336 return wrap(GlobalAlias::create(unwrap(ValueTy), AddrSpace,
2338 unwrap<Constant>(Aliasee), unwrap(M)));
2339}
2340
2342 const char *Name, size_t NameLen) {
2343 return wrap(unwrap(M)->getNamedAlias(StringRef(Name, NameLen)));
2344}
2345
2347 Module *Mod = unwrap(M);
2348 Module::alias_iterator I = Mod->alias_begin();
2349 if (I == Mod->alias_end())
2350 return nullptr;
2351 return wrap(&*I);
2352}
2353
2355 Module *Mod = unwrap(M);
2356 Module::alias_iterator I = Mod->alias_end();
2357 if (I == Mod->alias_begin())
2358 return nullptr;
2359 return wrap(&*--I);
2360}
2361
2363 GlobalAlias *Alias = unwrap<GlobalAlias>(GA);
2365 if (++I == Alias->getParent()->alias_end())
2366 return nullptr;
2367 return wrap(&*I);
2368}
2369
2371 GlobalAlias *Alias = unwrap<GlobalAlias>(GA);
2373 if (I == Alias->getParent()->alias_begin())
2374 return nullptr;
2375 return wrap(&*--I);
2376}
2377
2379 return wrap(unwrap<GlobalAlias>(Alias)->getAliasee());
2380}
2381
2383 unwrap<GlobalAlias>(Alias)->setAliasee(unwrap<Constant>(Aliasee));
2384}
2385
2386/*--.. Operations on functions .............................................--*/
2387
2389 LLVMTypeRef FunctionTy) {
2390 return wrap(Function::Create(unwrap<FunctionType>(FunctionTy),
2392}
2393
2395 return wrap(unwrap(M)->getFunction(Name));
2396}
2397
2399 size_t Length) {
2400 return wrap(unwrap(M)->getFunction(StringRef(Name, Length)));
2401}
2402
2404 Module *Mod = unwrap(M);
2405 Module::iterator I = Mod->begin();
2406 if (I == Mod->end())
2407 return nullptr;
2408 return wrap(&*I);
2409}
2410
2412 Module *Mod = unwrap(M);
2413 Module::iterator I = Mod->end();
2414 if (I == Mod->begin())
2415 return nullptr;
2416 return wrap(&*--I);
2417}
2418
2420 Function *Func = unwrap<Function>(Fn);
2421 Module::iterator I(Func);
2422 if (++I == Func->getParent()->end())
2423 return nullptr;
2424 return wrap(&*I);
2425}
2426
2428 Function *Func = unwrap<Function>(Fn);
2429 Module::iterator I(Func);
2430 if (I == Func->getParent()->begin())
2431 return nullptr;
2432 return wrap(&*--I);
2433}
2434
2436 unwrap<Function>(Fn)->eraseFromParent();
2437}
2438
2440 return unwrap<Function>(Fn)->hasPersonalityFn();
2441}
2442
2444 return wrap(unwrap<Function>(Fn)->getPersonalityFn());
2445}
2446
2448 unwrap<Function>(Fn)->setPersonalityFn(unwrap<Constant>(PersonalityFn));
2449}
2450
2452 if (Function *F = dyn_cast<Function>(unwrap(Fn)))
2453 return F->getIntrinsicID();
2454 return 0;
2455}
2456
2458 assert(ID < llvm::Intrinsic::num_intrinsics && "Intrinsic ID out of range");
2459 return llvm::Intrinsic::ID(ID);
2460}
2461
2463 unsigned ID,
2464 LLVMTypeRef *ParamTypes,
2465 size_t ParamCount) {
2466 ArrayRef<Type*> Tys(unwrap(ParamTypes), ParamCount);
2467 auto IID = llvm_map_to_intrinsic_id(ID);
2468 return wrap(llvm::Intrinsic::getDeclaration(unwrap(Mod), IID, Tys));
2469}
2470
2471const char *LLVMIntrinsicGetName(unsigned ID, size_t *NameLength) {
2472 auto IID = llvm_map_to_intrinsic_id(ID);
2473 auto Str = llvm::Intrinsic::getName(IID);
2474 *NameLength = Str.size();
2475 return Str.data();
2476}
2477
2479 LLVMTypeRef *ParamTypes, size_t ParamCount) {
2480 auto IID = llvm_map_to_intrinsic_id(ID);
2481 ArrayRef<Type*> Tys(unwrap(ParamTypes), ParamCount);
2482 return wrap(llvm::Intrinsic::getType(*unwrap(Ctx), IID, Tys));
2483}
2484
2486 LLVMTypeRef *ParamTypes,
2487 size_t ParamCount,
2488 size_t *NameLength) {
2489 auto IID = llvm_map_to_intrinsic_id(ID);
2490 ArrayRef<Type*> Tys(unwrap(ParamTypes), ParamCount);
2491 auto Str = llvm::Intrinsic::getNameNoUnnamedTypes(IID, Tys);
2492 *NameLength = Str.length();
2493 return strdup(Str.c_str());
2494}
2495
2497 LLVMTypeRef *ParamTypes,
2498 size_t ParamCount,
2499 size_t *NameLength) {
2500 auto IID = llvm_map_to_intrinsic_id(ID);
2501 ArrayRef<Type *> Tys(unwrap(ParamTypes), ParamCount);
2502 auto Str = llvm::Intrinsic::getName(IID, Tys, unwrap(Mod));
2503 *NameLength = Str.length();
2504 return strdup(Str.c_str());
2505}
2506
2507unsigned LLVMLookupIntrinsicID(const char *Name, size_t NameLen) {
2508 return Function::lookupIntrinsicID({Name, NameLen});
2509}
2510
2512 auto IID = llvm_map_to_intrinsic_id(ID);
2514}
2515
2517 return unwrap<Function>(Fn)->getCallingConv();
2518}
2519
2521 return unwrap<Function>(Fn)->setCallingConv(
2522 static_cast<CallingConv::ID>(CC));
2523}
2524
2525const char *LLVMGetGC(LLVMValueRef Fn) {
2526 Function *F = unwrap<Function>(Fn);
2527 return F->hasGC()? F->getGC().c_str() : nullptr;
2528}
2529
2530void LLVMSetGC(LLVMValueRef Fn, const char *GC) {
2531 Function *F = unwrap<Function>(Fn);
2532 if (GC)
2533 F->setGC(GC);
2534 else
2535 F->clearGC();
2536}
2537
2539 Function *F = unwrap<Function>(Fn);
2540 return wrap(F->getPrefixData());
2541}
2542
2544 Function *F = unwrap<Function>(Fn);
2545 return F->hasPrefixData();
2546}
2547
2549 Function *F = unwrap<Function>(Fn);
2550 Constant *prefix = unwrap<Constant>(prefixData);
2551 F->setPrefixData(prefix);
2552}
2553
2555 Function *F = unwrap<Function>(Fn);
2556 return wrap(F->getPrologueData());
2557}
2558
2560 Function *F = unwrap<Function>(Fn);
2561 return F->hasPrologueData();
2562}
2563
2565 Function *F = unwrap<Function>(Fn);
2566 Constant *prologue = unwrap<Constant>(prologueData);
2567 F->setPrologueData(prologue);
2568}
2569
2572 unwrap<Function>(F)->addAttributeAtIndex(Idx, unwrap(A));
2573}
2574
2576 auto AS = unwrap<Function>(F)->getAttributes().getAttributes(Idx);
2577 return AS.getNumAttributes();
2578}
2579
2581 LLVMAttributeRef *Attrs) {
2582 auto AS = unwrap<Function>(F)->getAttributes().getAttributes(Idx);
2583 for (auto A : AS)
2584 *Attrs++ = wrap(A);
2585}
2586
2589 unsigned KindID) {
2590 return wrap(unwrap<Function>(F)->getAttributeAtIndex(
2591 Idx, (Attribute::AttrKind)KindID));
2592}
2593
2596 const char *K, unsigned KLen) {
2597 return wrap(
2598 unwrap<Function>(F)->getAttributeAtIndex(Idx, StringRef(K, KLen)));
2599}
2600
2602 unsigned KindID) {
2603 unwrap<Function>(F)->removeAttributeAtIndex(Idx, (Attribute::AttrKind)KindID);
2604}
2605
2607 const char *K, unsigned KLen) {
2608 unwrap<Function>(F)->removeAttributeAtIndex(Idx, StringRef(K, KLen));
2609}
2610
2612 const char *V) {
2613 Function *Func = unwrap<Function>(Fn);
2614 Attribute Attr = Attribute::get(Func->getContext(), A, V);
2615 Func->addFnAttr(Attr);
2616}
2617
2618/*--.. Operations on parameters ............................................--*/
2619
2621 // This function is strictly redundant to
2622 // LLVMCountParamTypes(LLVMGlobalGetValueType(FnRef))
2623 return unwrap<Function>(FnRef)->arg_size();
2624}
2625
2626void LLVMGetParams(LLVMValueRef FnRef, LLVMValueRef *ParamRefs) {
2627 Function *Fn = unwrap<Function>(FnRef);
2628 for (Argument &A : Fn->args())
2629 *ParamRefs++ = wrap(&A);
2630}
2631
2633 Function *Fn = unwrap<Function>(FnRef);
2634 return wrap(&Fn->arg_begin()[index]);
2635}
2636
2638 return wrap(unwrap<Argument>(V)->getParent());
2639}
2640
2642 Function *Func = unwrap<Function>(Fn);
2643 Function::arg_iterator I = Func->arg_begin();
2644 if (I == Func->arg_end())
2645 return nullptr;
2646 return wrap(&*I);
2647}
2648
2650 Function *Func = unwrap<Function>(Fn);
2651 Function::arg_iterator I = Func->arg_end();
2652 if (I == Func->arg_begin())
2653 return nullptr;
2654 return wrap(&*--I);
2655}
2656
2658 Argument *A = unwrap<Argument>(Arg);
2659 Function *Fn = A->getParent();
2660 if (A->getArgNo() + 1 >= Fn->arg_size())
2661 return nullptr;
2662 return wrap(&Fn->arg_begin()[A->getArgNo() + 1]);
2663}
2664
2666 Argument *A = unwrap<Argument>(Arg);
2667 if (A->getArgNo() == 0)
2668 return nullptr;
2669 return wrap(&A->getParent()->arg_begin()[A->getArgNo() - 1]);
2670}
2671
2672void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align) {
2673 Argument *A = unwrap<Argument>(Arg);
2674 A->addAttr(Attribute::getWithAlignment(A->getContext(), Align(align)));
2675}
2676
2677/*--.. Operations on ifuncs ................................................--*/
2678
2680 const char *Name, size_t NameLen,
2681 LLVMTypeRef Ty, unsigned AddrSpace,
2683 return wrap(GlobalIFunc::create(unwrap(Ty), AddrSpace,
2685 StringRef(Name, NameLen),
2686 unwrap<Constant>(Resolver), unwrap(M)));
2687}
2688
2690 const char *Name, size_t NameLen) {
2691 return wrap(unwrap(M)->getNamedIFunc(StringRef(Name, NameLen)));
2692}
2693
2695 Module *Mod = unwrap(M);
2696 Module::ifunc_iterator I = Mod->ifunc_begin();
2697 if (I == Mod->ifunc_end())
2698 return nullptr;
2699 return wrap(&*I);
2700}
2701
2703 Module *Mod = unwrap(M);
2704 Module::ifunc_iterator I = Mod->ifunc_end();
2705 if (I == Mod->ifunc_begin())
2706 return nullptr;
2707 return wrap(&*--I);
2708}
2709
2711 GlobalIFunc *GIF = unwrap<GlobalIFunc>(IFunc);
2713 if (++I == GIF->getParent()->ifunc_end())
2714 return nullptr;
2715 return wrap(&*I);
2716}
2717
2719 GlobalIFunc *GIF = unwrap<GlobalIFunc>(IFunc);
2721 if (I == GIF->getParent()->ifunc_begin())
2722 return nullptr;
2723 return wrap(&*--I);
2724}
2725
2727 return wrap(unwrap<GlobalIFunc>(IFunc)->getResolver());
2728}
2729
2731 unwrap<GlobalIFunc>(IFunc)->setResolver(unwrap<Constant>(Resolver));
2732}
2733
2735 unwrap<GlobalIFunc>(IFunc)->eraseFromParent();
2736}
2737
2739 unwrap<GlobalIFunc>(IFunc)->removeFromParent();
2740}
2741
2742/*--.. Operations on operand bundles........................................--*/
2743
2745 LLVMValueRef *Args,
2746 unsigned NumArgs) {
2747 return wrap(new OperandBundleDef(std::string(Tag, TagLen),
2748 ArrayRef(unwrap(Args), NumArgs)));
2749}
2750
2752 delete unwrap(Bundle);
2753}
2754
2755const char *LLVMGetOperandBundleTag(LLVMOperandBundleRef Bundle, size_t *Len) {
2756 StringRef Str = unwrap(Bundle)->getTag();
2757 *Len = Str.size();
2758 return Str.data();
2759}
2760
2762 return unwrap(Bundle)->inputs().size();
2763}
2764
2766 unsigned Index) {
2767 return wrap(unwrap(Bundle)->inputs()[Index]);
2768}
2769
2770/*--.. Operations on basic blocks ..........................................--*/
2771
2773 return wrap(static_cast<Value*>(unwrap(BB)));
2774}
2775
2777 return isa<BasicBlock>(unwrap(Val));
2778}
2779
2781 return wrap(unwrap<BasicBlock>(Val));
2782}
2783
2785 return unwrap(BB)->getName().data();
2786}
2787
2789 return wrap(unwrap(BB)->getParent());
2790}
2791
2793 return wrap(unwrap(BB)->getTerminator());
2794}
2795
2797 return unwrap<Function>(FnRef)->size();
2798}
2799
2801 Function *Fn = unwrap<Function>(FnRef);
2802 for (BasicBlock &BB : *Fn)
2803 *BasicBlocksRefs++ = wrap(&BB);
2804}
2805
2807 return wrap(&unwrap<Function>(Fn)->getEntryBlock());
2808}
2809
2811 Function *Func = unwrap<Function>(Fn);
2812 Function::iterator I = Func->begin();
2813 if (I == Func->end())
2814 return nullptr;
2815 return wrap(&*I);
2816}
2817
2819 Function *Func = unwrap<Function>(Fn);
2820 Function::iterator I = Func->end();
2821 if (I == Func->begin())
2822 return nullptr;
2823 return wrap(&*--I);
2824}
2825
2827 BasicBlock *Block = unwrap(BB);
2829 if (++I == Block->getParent()->end())
2830 return nullptr;
2831 return wrap(&*I);
2832}
2833
2835 BasicBlock *Block = unwrap(BB);
2837 if (I == Block->getParent()->begin())
2838 return nullptr;
2839 return wrap(&*--I);
2840}
2841
2843 const char *Name) {
2845}
2846
2848 LLVMBasicBlockRef BB) {
2849 BasicBlock *ToInsert = unwrap(BB);
2850 BasicBlock *CurBB = unwrap(Builder)->GetInsertBlock();
2851 assert(CurBB && "current insertion point is invalid!");
2852 CurBB->getParent()->insert(std::next(CurBB->getIterator()), ToInsert);
2853}
2854
2856 LLVMBasicBlockRef BB) {
2857 unwrap<Function>(Fn)->insert(unwrap<Function>(Fn)->end(), unwrap(BB));
2858}
2859
2861 LLVMValueRef FnRef,
2862 const char *Name) {
2863 return wrap(BasicBlock::Create(*unwrap(C), Name, unwrap<Function>(FnRef)));
2864}
2865
2868}
2869
2871 LLVMBasicBlockRef BBRef,
2872 const char *Name) {
2873 BasicBlock *BB = unwrap(BBRef);
2874 return wrap(BasicBlock::Create(*unwrap(C), Name, BB->getParent(), BB));
2875}
2876
2878 const char *Name) {
2880}
2881
2883 unwrap(BBRef)->eraseFromParent();
2884}
2885
2887 unwrap(BBRef)->removeFromParent();
2888}
2889
2891 unwrap(BB)->moveBefore(unwrap(MovePos));
2892}
2893
2895 unwrap(BB)->moveAfter(unwrap(MovePos));
2896}
2897
2898/*--.. Operations on instructions ..........................................--*/
2899
2901 return wrap(unwrap<Instruction>(Inst)->getParent());
2902}
2903
2905 BasicBlock *Block = unwrap(BB);
2906 BasicBlock::iterator I = Block->begin();
2907 if (I == Block->end())
2908 return nullptr;
2909 return wrap(&*I);
2910}
2911
2913 BasicBlock *Block = unwrap(BB);
2914 BasicBlock::iterator I = Block->end();
2915 if (I == Block->begin())
2916 return nullptr;
2917 return wrap(&*--I);
2918}
2919
2921 Instruction *Instr = unwrap<Instruction>(Inst);
2922 BasicBlock::iterator I(Instr);
2923 if (++I == Instr->getParent()->end())
2924 return nullptr;
2925 return wrap(&*I);
2926}
2927
2929 Instruction *Instr = unwrap<Instruction>(Inst);
2930 BasicBlock::iterator I(Instr);
2931 if (I == Instr->getParent()->begin())
2932 return nullptr;
2933 return wrap(&*--I);
2934}
2935
2937 unwrap<Instruction>(Inst)->removeFromParent();
2938}
2939
2941 unwrap<Instruction>(Inst)->eraseFromParent();
2942}
2943
2945 unwrap<Instruction>(Inst)->deleteValue();
2946}
2947
2949 if (ICmpInst *I = dyn_cast<ICmpInst>(unwrap(Inst)))
2950 return (LLVMIntPredicate)I->getPredicate();
2951 return (LLVMIntPredicate)0;
2952}
2953
2955 if (FCmpInst *I = dyn_cast<FCmpInst>(unwrap(Inst)))
2956 return (LLVMRealPredicate)I->getPredicate();
2957 return (LLVMRealPredicate)0;
2958}
2959
2961 if (Instruction *C = dyn_cast<Instruction>(unwrap(Inst)))
2962 return map_to_llvmopcode(C->getOpcode());
2963 return (LLVMOpcode)0;
2964}
2965
2967 if (Instruction *C = dyn_cast<Instruction>(unwrap(Inst)))
2968 return wrap(C->clone());
2969 return nullptr;
2970}
2971
2973 Instruction *I = dyn_cast<Instruction>(unwrap(Inst));
2974 return (I && I->isTerminator()) ? wrap(I) : nullptr;
2975}
2976
2978 if (FuncletPadInst *FPI = dyn_cast<FuncletPadInst>(unwrap(Instr))) {
2979 return FPI->arg_size();
2980 }
2981 return unwrap<CallBase>(Instr)->arg_size();
2982}
2983
2984/*--.. Call and invoke instructions ........................................--*/
2985
2987 return unwrap<CallBase>(Instr)->getCallingConv();
2988}
2989
2991 return unwrap<CallBase>(Instr)->setCallingConv(
2992 static_cast<CallingConv::ID>(CC));
2993}
2994
2996 unsigned align) {
2997 auto *Call = unwrap<CallBase>(Instr);
2998 Attribute AlignAttr =
2999 Attribute::getWithAlignment(Call->getContext(), Align(align));
3000 Call->addAttributeAtIndex(Idx, AlignAttr);
3001}
3002
3005 unwrap<CallBase>(C)->addAttributeAtIndex(Idx, unwrap(A));
3006}
3007
3010 auto *Call = unwrap<CallBase>(C);
3011 auto AS = Call->getAttributes().getAttributes(Idx);
3012 return AS.getNumAttributes();
3013}
3014
3016 LLVMAttributeRef *Attrs) {
3017 auto *Call = unwrap<CallBase>(C);
3018 auto AS = Call->getAttributes().getAttributes(Idx);
3019 for (auto A : AS)
3020 *Attrs++ = wrap(A);
3021}
3022
3025 unsigned KindID) {
3026 return wrap(unwrap<CallBase>(C)->getAttributeAtIndex(
3027 Idx, (Attribute::AttrKind)KindID));
3028}
3029
3032 const char *K, unsigned KLen) {
3033 return wrap(
3034 unwrap<CallBase>(C)->getAttributeAtIndex(Idx, StringRef(K, KLen)));
3035}
3036
3038 unsigned KindID) {
3039 unwrap<CallBase>(C)->removeAttributeAtIndex(Idx, (Attribute::AttrKind)KindID);
3040}
3041
3043 const char *K, unsigned KLen) {
3044 unwrap<CallBase>(C)->removeAttributeAtIndex(Idx, StringRef(K, KLen));
3045}
3046
3048 return wrap(unwrap<CallBase>(Instr)->getCalledOperand());
3049}
3050
3052 return wrap(unwrap<CallBase>(Instr)->getFunctionType());
3053}
3054
3056 return unwrap<CallBase>(C)->getNumOperandBundles();
3057}
3058
3060 unsigned Index) {
3061 return wrap(
3062 new OperandBundleDef(unwrap<CallBase>(C)->getOperandBundleAt(Index)));
3063}
3064
3065/*--.. Operations on call instructions (only) ..............................--*/
3066
3068 return unwrap<CallInst>(Call)->isTailCall();
3069}
3070
3071void LLVMSetTailCall(LLVMValueRef Call, LLVMBool isTailCall) {
3072 unwrap<CallInst>(Call)->setTailCall(isTailCall);
3073}
3074
3076 return (LLVMTailCallKind)unwrap<CallInst>(Call)->getTailCallKind();
3077}
3078
3080 unwrap<CallInst>(Call)->setTailCallKind((CallInst::TailCallKind)kind);
3081}
3082
3083/*--.. Operations on invoke instructions (only) ............................--*/
3084
3086 return wrap(unwrap<InvokeInst>(Invoke)->getNormalDest());
3087}
3088
3090 if (CleanupReturnInst *CRI = dyn_cast<CleanupReturnInst>(unwrap(Invoke))) {
3091 return wrap(CRI->getUnwindDest());
3092 } else if (CatchSwitchInst *CSI = dyn_cast<CatchSwitchInst>(unwrap(Invoke))) {
3093 return wrap(CSI->getUnwindDest());
3094 }
3095 return wrap(unwrap<InvokeInst>(Invoke)->getUnwindDest());
3096}
3097
3099 unwrap<InvokeInst>(Invoke)->setNormalDest(unwrap(B));
3100}
3101
3103 if (CleanupReturnInst *CRI = dyn_cast<CleanupReturnInst>(unwrap(Invoke))) {
3104 return CRI->setUnwindDest(unwrap(B));
3105 } else if (CatchSwitchInst *CSI = dyn_cast<CatchSwitchInst>(unwrap(Invoke))) {
3106 return CSI->setUnwindDest(unwrap(B));
3107 }
3108 unwrap<InvokeInst>(Invoke)->setUnwindDest(unwrap(B));
3109}
3110
3112 return wrap(unwrap<CallBrInst>(CallBr)->getDefaultDest());
3113}
3114
3116 return unwrap<CallBrInst>(CallBr)->getNumIndirectDests();
3117}
3118
3120 return wrap(unwrap<CallBrInst>(CallBr)->getIndirectDest(Idx));
3121}
3122
3123/*--.. Operations on terminators ...........................................--*/
3124
3126 return unwrap<Instruction>(Term)->getNumSuccessors();
3127}
3128
3130 return wrap(unwrap<Instruction>(Term)->getSuccessor(i));
3131}
3132
3134 return unwrap<Instruction>(Term)->setSuccessor(i, unwrap(block));
3135}
3136
3137/*--.. Operations on branch instructions (only) ............................--*/
3138
3140 return unwrap<BranchInst>(Branch)->isConditional();
3141}
3142
3144 return wrap(unwrap<BranchInst>(Branch)->getCondition());
3145}
3146
3148 return unwrap<BranchInst>(Branch)->setCondition(unwrap(Cond));
3149}
3150
3151/*--.. Operations on switch instructions (only) ............................--*/
3152
3154 return wrap(unwrap<SwitchInst>(Switch)->getDefaultDest());
3155}
3156
3157/*--.. Operations on alloca instructions (only) ............................--*/
3158
3160 return wrap(unwrap<AllocaInst>(Alloca)->getAllocatedType());
3161}
3162
3163/*--.. Operations on gep instructions (only) ...............................--*/
3164
3166 return unwrap<GEPOperator>(GEP)->isInBounds();
3167}
3168
3170 return unwrap<GetElementPtrInst>(GEP)->setIsInBounds(InBounds);
3171}
3172
3174 return wrap(unwrap<GEPOperator>(GEP)->getSourceElementType());
3175}
3176
3178 GEPOperator *GEPOp = unwrap<GEPOperator>(GEP);
3179 return mapToLLVMGEPNoWrapFlags(GEPOp->getNoWrapFlags());
3180}
3181
3183 GetElementPtrInst *GEPInst = unwrap<GetElementPtrInst>(GEP);
3184 GEPInst->setNoWrapFlags(mapFromLLVMGEPNoWrapFlags(NoWrapFlags));
3185}
3186
3187/*--.. Operations on phi nodes .............................................--*/
3188
3189void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues,
3190 LLVMBasicBlockRef *IncomingBlocks, unsigned Count) {
3191 PHINode *PhiVal = unwrap<PHINode>(PhiNode);
3192 for (unsigned I = 0; I != Count; ++I)
3193 PhiVal->addIncoming(unwrap(IncomingValues[I]), unwrap(IncomingBlocks[I]));
3194}
3195
3197 return unwrap<PHINode>(PhiNode)->getNumIncomingValues();
3198}
3199
3201 return wrap(unwrap<PHINode>(PhiNode)->getIncomingValue(Index));
3202}
3203
3205 return wrap(unwrap<PHINode>(PhiNode)->getIncomingBlock(Index));
3206}
3207
3208/*--.. Operations on extractvalue and insertvalue nodes ....................--*/
3209
3211 auto *I = unwrap(Inst);
3212 if (auto *GEP = dyn_cast<GEPOperator>(I))
3213 return GEP->getNumIndices();
3214 if (auto *EV = dyn_cast<ExtractValueInst>(I))
3215 return EV->getNumIndices();
3216 if (auto *IV = dyn_cast<InsertValueInst>(I))
3217 return IV->getNumIndices();
3219 "LLVMGetNumIndices applies only to extractvalue and insertvalue!");
3220}
3221
3222const unsigned *LLVMGetIndices(LLVMValueRef Inst) {
3223 auto *I = unwrap(Inst);
3224 if (auto *EV = dyn_cast<ExtractValueInst>(I))
3225 return EV->getIndices().data();
3226 if (auto *IV = dyn_cast<InsertValueInst>(I))
3227 return IV->getIndices().data();
3229 "LLVMGetIndices applies only to extractvalue and insertvalue!");
3230}
3231
3232
3233/*===-- Instruction builders ----------------------------------------------===*/
3234
3236 return wrap(new IRBuilder<>(*unwrap(C)));
3237}
3238
3241}
3242
3244 Instruction *Instr, bool BeforeDbgRecords) {
3245 BasicBlock::iterator I = Instr ? Instr->getIterator() : Block->end();
3246 I.setHeadBit(BeforeDbgRecords);
3247 Builder->SetInsertPoint(Block, I);
3248}
3249
3251 LLVMValueRef Instr) {
3252 return LLVMPositionBuilderImpl(unwrap(Builder), unwrap(Block),
3253 unwrap<Instruction>(Instr), false);
3254}
3255
3258 LLVMValueRef Instr) {
3259 return LLVMPositionBuilderImpl(unwrap(Builder), unwrap(Block),
3260 unwrap<Instruction>(Instr), true);
3261}
3262
3264 Instruction *I = unwrap<Instruction>(Instr);
3265 return LLVMPositionBuilderImpl(unwrap(Builder), I->getParent(), I, false);
3266}
3267
3269 LLVMValueRef Instr) {
3270 Instruction *I = unwrap<Instruction>(Instr);
3271 return LLVMPositionBuilderImpl(unwrap(Builder), I->getParent(), I, true);
3272}
3273
3275 BasicBlock *BB = unwrap(Block);
3276 unwrap(Builder)->SetInsertPoint(BB);
3277}
3278
3280 return wrap(unwrap(Builder)->GetInsertBlock());
3281}
3282
3284 unwrap(Builder)->ClearInsertionPoint();
3285}
3286
3288 unwrap(Builder)->Insert(unwrap<Instruction>(Instr));
3289}
3290
3292 const char *Name) {
3293 unwrap(Builder)->Insert(unwrap<Instruction>(Instr), Name);
3294}
3295
3297 delete unwrap(Builder);
3298}
3299
3300/*--.. Metadata builders ...................................................--*/
3301
3303 return wrap(unwrap(Builder)->getCurrentDebugLocation().getAsMDNode());
3304}
3305
3307 if (Loc)
3308 unwrap(Builder)->SetCurrentDebugLocation(DebugLoc(unwrap<MDNode>(Loc)));
3309 else
3310 unwrap(Builder)->SetCurrentDebugLocation(DebugLoc());
3311}
3312
3314 MDNode *Loc =
3315 L ? cast<MDNode>(unwrap<MetadataAsValue>(L)->getMetadata()) : nullptr;
3316 unwrap(Builder)->SetCurrentDebugLocation(DebugLoc(Loc));
3317}
3318
3320 LLVMContext &Context = unwrap(Builder)->getContext();
3322 Context, unwrap(Builder)->getCurrentDebugLocation().getAsMDNode()));
3323}
3324
3326 unwrap(Builder)->SetInstDebugLocation(unwrap<Instruction>(Inst));
3327}
3328
3330 unwrap(Builder)->AddMetadataToInst(unwrap<Instruction>(Inst));
3331}
3332
3334 LLVMMetadataRef FPMathTag) {
3335
3336 unwrap(Builder)->setDefaultFPMathTag(FPMathTag
3337 ? unwrap<MDNode>(FPMathTag)
3338 : nullptr);
3339}
3340
3342 return wrap(&unwrap(Builder)->getContext());
3343}
3344
3346 return wrap(unwrap(Builder)->getDefaultFPMathTag());
3347}
3348
3349/*--.. Instruction builders ................................................--*/
3350
3352 return wrap(unwrap(B)->CreateRetVoid());
3353}
3354
3356 return wrap(unwrap(B)->CreateRet(unwrap(V)));
3357}
3358
3360 unsigned N) {
3361 return wrap(unwrap(B)->CreateAggregateRet(unwrap(RetVals), N));
3362}
3363
3365 return wrap(unwrap(B)->CreateBr(unwrap(Dest)));
3366}
3367
3370 return wrap(unwrap(B)->CreateCondBr(unwrap(If), unwrap(Then), unwrap(Else)));
3371}
3372
3374 LLVMBasicBlockRef Else, unsigned NumCases) {
3375 return wrap(unwrap(B)->CreateSwitch(unwrap(V), unwrap(Else), NumCases));
3376}
3377
3379 unsigned NumDests) {
3380 return wrap(unwrap(B)->CreateIndirectBr(unwrap(Addr), NumDests));
3381}
3382
3384 LLVMBasicBlockRef DefaultDest,
3385 LLVMBasicBlockRef *IndirectDests,
3386 unsigned NumIndirectDests, LLVMValueRef *Args,
3387 unsigned NumArgs, LLVMOperandBundleRef *Bundles,
3388 unsigned NumBundles, const char *Name) {
3389
3391 for (auto *Bundle : ArrayRef(Bundles, NumBundles)) {
3392 OperandBundleDef *OB = unwrap(Bundle);
3393 OBs.push_back(*OB);
3394 }
3395
3396 return wrap(unwrap(B)->CreateCallBr(
3397 unwrap<FunctionType>(Ty), unwrap(Fn), unwrap(DefaultDest),
3398 ArrayRef(unwrap(IndirectDests), NumIndirectDests),
3399 ArrayRef<Value *>(unwrap(Args), NumArgs), OBs, Name));
3400}
3401
3403 LLVMValueRef *Args, unsigned NumArgs,
3405 const char *Name) {
3406 return wrap(unwrap(B)->CreateInvoke(unwrap<FunctionType>(Ty), unwrap(Fn),
3407 unwrap(Then), unwrap(Catch),
3408 ArrayRef(unwrap(Args), NumArgs), Name));
3409}
3410
3413 unsigned NumArgs, LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch,
3414 LLVMOperandBundleRef *Bundles, unsigned NumBundles, const char *Name) {
3416 for (auto *Bundle : ArrayRef(Bundles, NumBundles)) {
3417 OperandBundleDef *OB = unwrap(Bundle);
3418 OBs.push_back(*OB);
3419 }
3420 return wrap(unwrap(B)->CreateInvoke(
3421 unwrap<FunctionType>(Ty), unwrap(Fn), unwrap(Then), unwrap(Catch),
3422 ArrayRef(unwrap(Args), NumArgs), OBs, Name));
3423}
3424
3426 LLVMValueRef PersFn, unsigned NumClauses,
3427 const char *Name) {
3428 // The personality used to live on the landingpad instruction, but now it
3429 // lives on the parent function. For compatibility, take the provided
3430 // personality and put it on the parent function.
3431 if (PersFn)
3432 unwrap(B)->GetInsertBlock()->getParent()->setPersonalityFn(
3433 unwrap<Function>(PersFn));
3434 return wrap(unwrap(B)->CreateLandingPad(unwrap(Ty), NumClauses, Name));
3435}
3436
3438 LLVMValueRef *Args, unsigned NumArgs,
3439 const char *Name) {
3440 return wrap(unwrap(B)->CreateCatchPad(unwrap(ParentPad),
3441 ArrayRef(unwrap(Args), NumArgs), Name));
3442}
3443
3445 LLVMValueRef *Args, unsigned NumArgs,
3446 const char *Name) {
3447 if (ParentPad == nullptr) {
3448 Type *Ty = Type::getTokenTy(unwrap(B)->getContext());
3449 ParentPad = wrap(Constant::getNullValue(Ty));
3450 }
3451 return wrap(unwrap(B)->CreateCleanupPad(
3452 unwrap(ParentPad), ArrayRef(unwrap(Args), NumArgs), Name));
3453}
3454
3456 return wrap(unwrap(B)->CreateResume(unwrap(Exn)));
3457}
3458
3460 LLVMBasicBlockRef UnwindBB,
3461 unsigned NumHandlers, const char *Name) {
3462 if (ParentPad == nullptr) {
3463 Type *Ty = Type::getTokenTy(unwrap(B)->getContext());
3464 ParentPad = wrap(Constant::getNullValue(Ty));
3465 }
3466 return wrap(unwrap(B)->CreateCatchSwitch(unwrap(ParentPad), unwrap(UnwindBB),
3467 NumHandlers, Name));
3468}
3469
3471 LLVMBasicBlockRef BB) {
3472 return wrap(unwrap(B)->CreateCatchRet(unwrap<CatchPadInst>(CatchPad),
3473 unwrap(BB)));
3474}
3475
3477 LLVMBasicBlockRef BB) {
3478 return wrap(unwrap(B)->CreateCleanupRet(unwrap<CleanupPadInst>(CatchPad),
3479 unwrap(BB)));
3480}
3481
3483 return wrap(unwrap(B)->CreateUnreachable());
3484}
3485
3487 LLVMBasicBlockRef Dest) {
3488 unwrap<SwitchInst>(Switch)->addCase(unwrap<ConstantInt>(OnVal), unwrap(Dest));
3489}
3490
3492 unwrap<IndirectBrInst>(IndirectBr)->addDestination(unwrap(Dest));
3493}
3494
3495unsigned LLVMGetNumClauses(LLVMValueRef LandingPad) {
3496 return unwrap<LandingPadInst>(LandingPad)->getNumClauses();
3497}
3498
3500 return wrap(unwrap<LandingPadInst>(LandingPad)->getClause(Idx));
3501}
3502
3504 unwrap<LandingPadInst>(LandingPad)->addClause(unwrap<Constant>(ClauseVal));
3505}
3506
3508 return unwrap<LandingPadInst>(LandingPad)->isCleanup();
3509}
3510
3511void LLVMSetCleanup(LLVMValueRef LandingPad, LLVMBool Val) {
3512 unwrap<LandingPadInst>(LandingPad)->setCleanup(Val);
3513}
3514
3516 unwrap<CatchSwitchInst>(CatchSwitch)->addHandler(unwrap(Dest));
3517}
3518
3519unsigned LLVMGetNumHandlers(LLVMValueRef CatchSwitch) {
3520 return unwrap<CatchSwitchInst>(CatchSwitch)->getNumHandlers();
3521}
3522
3523void LLVMGetHandlers(LLVMValueRef CatchSwitch, LLVMBasicBlockRef *Handlers) {
3524 CatchSwitchInst *CSI = unwrap<CatchSwitchInst>(CatchSwitch);
3525 for (const BasicBlock *H : CSI->handlers())
3526 *Handlers++ = wrap(H);
3527}
3528
3530 return wrap(unwrap<CatchPadInst>(CatchPad)->getCatchSwitch());
3531}
3532
3534 unwrap<CatchPadInst>(CatchPad)
3535 ->setCatchSwitch(unwrap<CatchSwitchInst>(CatchSwitch));
3536}
3537
3538/*--.. Funclets ...........................................................--*/
3539
3541 return wrap(unwrap<FuncletPadInst>(Funclet)->getArgOperand(i));
3542}
3543
3545 unwrap<FuncletPadInst>(Funclet)->setArgOperand(i, unwrap(value));
3546}
3547
3548/*--.. Arithmetic ..........................................................--*/
3549
3551 FastMathFlags NewFMF;
3552 NewFMF.setAllowReassoc((FMF & LLVMFastMathAllowReassoc) != 0);
3553 NewFMF.setNoNaNs((FMF & LLVMFastMathNoNaNs) != 0);
3554 NewFMF.setNoInfs((FMF & LLVMFastMathNoInfs) != 0);
3555 NewFMF.setNoSignedZeros((FMF & LLVMFastMathNoSignedZeros) != 0);
3557 NewFMF.setAllowContract((FMF & LLVMFastMathAllowContract) != 0);
3558 NewFMF.setApproxFunc((FMF & LLVMFastMathApproxFunc) != 0);
3559
3560 return NewFMF;
3561}
3562
3565 if (FMF.allowReassoc())
3566 NewFMF |= LLVMFastMathAllowReassoc;
3567 if (FMF.noNaNs())
3568 NewFMF |= LLVMFastMathNoNaNs;
3569 if (FMF.noInfs())
3570 NewFMF |= LLVMFastMathNoInfs;
3571 if (FMF.noSignedZeros())
3572 NewFMF |= LLVMFastMathNoSignedZeros;
3573 if (FMF.allowReciprocal())
3575 if (FMF.allowContract())
3576 NewFMF |= LLVMFastMathAllowContract;
3577 if (FMF.approxFunc())
3578 NewFMF |= LLVMFastMathApproxFunc;
3579
3580 return NewFMF;
3581}
3582
3584 const char *Name) {
3585 return wrap(unwrap(B)->CreateAdd(unwrap(LHS), unwrap(RHS), Name));
3586}
3587
3589 const char *Name) {
3590 return wrap(unwrap(B)->CreateNSWAdd(unwrap(LHS), unwrap(RHS), Name));
3591}
3592
3594 const char *Name) {
3595 return wrap(unwrap(B)->CreateNUWAdd(unwrap(LHS), unwrap(RHS), Name));
3596}
3597
3599 const char *Name) {
3600 return wrap(unwrap(B)->CreateFAdd(unwrap(LHS), unwrap(RHS), Name));
3601}
3602
3604 const char *Name) {
3605 return wrap(unwrap(B)->CreateSub(unwrap(LHS), unwrap(RHS), Name));
3606}
3607
3609 const char *Name) {
3610 return wrap(unwrap(B)->CreateNSWSub(unwrap(LHS), unwrap(RHS), Name));
3611}
3612
3614 const char *Name) {
3615 return wrap(unwrap(B)->CreateNUWSub(unwrap(LHS), unwrap(RHS), Name));
3616}
3617
3619 const char *Name) {
3620 return wrap(unwrap(B)->CreateFSub(unwrap(LHS), unwrap(RHS), Name));
3621}
3622
3624 const char *Name) {
3625 return wrap(unwrap(B)->CreateMul(unwrap(LHS), unwrap(RHS), Name));
3626}
3627
3629 const char *Name) {
3630 return wrap(unwrap(B)->CreateNSWMul(unwrap(LHS), unwrap(RHS), Name));
3631}
3632
3634 const char *Name) {
3635 return wrap(unwrap(B)->CreateNUWMul(unwrap(LHS), unwrap(RHS), Name));
3636}
3637
3639 const char *Name) {
3640 return wrap(unwrap(B)->CreateFMul(unwrap(LHS), unwrap(RHS), Name));
3641}
3642
3644 const char *Name) {
3645 return wrap(unwrap(B)->CreateUDiv(unwrap(LHS), unwrap(RHS), Name));
3646}
3647
3649 LLVMValueRef RHS, const char *Name) {
3650 return wrap(unwrap(B)->CreateExactUDiv(unwrap(LHS), unwrap(RHS), Name));
3651}
3652
3654 const char *Name) {
3655 return wrap(unwrap(B)->CreateSDiv(unwrap(LHS), unwrap(RHS), Name));
3656}
3657
3659 LLVMValueRef RHS, const char *Name) {
3660 return wrap(unwrap(B)->CreateExactSDiv(unwrap(LHS), unwrap(RHS), Name));
3661}
3662
3664 const char *Name) {
3665 return wrap(unwrap(B)->CreateFDiv(unwrap(LHS), unwrap(RHS), Name));
3666}
3667
3669 const char *Name) {
3670 return wrap(unwrap(B)->CreateURem(unwrap(LHS), unwrap(RHS), Name));
3671}
3672
3674 const char *Name) {
3675 return wrap(unwrap(B)->CreateSRem(unwrap(LHS), unwrap(RHS), Name));
3676}
3677
3679 const char *Name) {
3680 return wrap(unwrap(B)->CreateFRem(unwrap(LHS), unwrap(RHS), Name));
3681}
3682
3684 const char *Name) {
3685 return wrap(unwrap(B)->CreateShl(unwrap(LHS), unwrap(RHS), Name));
3686}
3687
3689 const char *Name) {
3690 return wrap(unwrap(B)->CreateLShr(unwrap(LHS), unwrap(RHS), Name));
3691}
3692
3694 const char *Name) {
3695 return wrap(unwrap(B)->CreateAShr(unwrap(LHS), unwrap(RHS), Name));
3696}
3697
3699 const char *Name) {
3700 return wrap(unwrap(B)->CreateAnd(unwrap(LHS), unwrap(RHS), Name));
3701}
3702
3704 const char *Name) {
3705 return wrap(unwrap(B)->CreateOr(unwrap(LHS), unwrap(RHS), Name));
3706}
3707
3709 const char *Name) {
3710 return wrap(unwrap(B)->CreateXor(unwrap(LHS), unwrap(RHS), Name));
3711}
3712
3714 LLVMValueRef LHS, LLVMValueRef RHS,
3715 const char *Name) {
3717 unwrap(RHS), Name));
3718}
3719
3721 return wrap(unwrap(B)->CreateNeg(unwrap(V), Name));
3722}
3723
3725 const char *Name) {
3726 return wrap(unwrap(B)->CreateNSWNeg(unwrap(V), Name));
3727}
3728
3730 const char *Name) {
3731 Value *Neg = unwrap(B)->CreateNeg(unwrap(V), Name);
3732 if (auto *I = dyn_cast<BinaryOperator>(Neg))
3733 I->setHasNoUnsignedWrap();
3734 return wrap(Neg);
3735}
3736
3738 return wrap(unwrap(B)->CreateFNeg(unwrap(V), Name));
3739}
3740
3742 return wrap(unwrap(B)->CreateNot(unwrap(V), Name));
3743}
3744
3746 Value *P = unwrap<Value>(ArithInst);
3747 return cast<Instruction>(P)->hasNoUnsignedWrap();
3748}
3749
3750void LLVMSetNUW(LLVMValueRef ArithInst, LLVMBool HasNUW) {
3751 Value *P = unwrap<Value>(ArithInst);
3752 cast<Instruction>(P)->setHasNoUnsignedWrap(HasNUW);
3753}
3754
3756 Value *P = unwrap<Value>(ArithInst);
3757 return cast<Instruction>(P)->hasNoSignedWrap();
3758}
3759
3760void LLVMSetNSW(LLVMValueRef ArithInst, LLVMBool HasNSW) {
3761 Value *P = unwrap<Value>(ArithInst);
3762 cast<Instruction>(P)->setHasNoSignedWrap(HasNSW);
3763}
3764
3766 Value *P = unwrap<Value>(DivOrShrInst);
3767 return cast<Instruction>(P)->isExact();
3768}
3769
3770void LLVMSetExact(LLVMValueRef DivOrShrInst, LLVMBool IsExact) {
3771 Value *P = unwrap<Value>(DivOrShrInst);
3772 cast<Instruction>(P)->setIsExact(IsExact);
3773}
3774
3776 Value *P = unwrap<Value>(NonNegInst);
3777 return cast<Instruction>(P)->hasNonNeg();
3778}
3779
3780void LLVMSetNNeg(LLVMValueRef NonNegInst, LLVMBool IsNonNeg) {
3781 Value *P = unwrap<Value>(NonNegInst);
3782 cast<Instruction>(P)->setNonNeg(IsNonNeg);
3783}
3784
3786 Value *P = unwrap<Value>(FPMathInst);
3787 FastMathFlags FMF = cast<Instruction>(P)->getFastMathFlags();
3788 return mapToLLVMFastMathFlags(FMF);
3789}
3790
3792 Value *P = unwrap<Value>(FPMathInst);
3793 cast<Instruction>(P)->setFastMathFlags(mapFromLLVMFastMathFlags(FMF));
3794}
3795
3797 Value *Val = unwrap<Value>(V);
3798 return isa<FPMathOperator>(Val);
3799}
3800
3802 Value *P = unwrap<Value>(Inst);
3803 return cast<PossiblyDisjointInst>(P)->isDisjoint();
3804}
3805
3807 Value *P = unwrap<Value>(Inst);
3808 cast<PossiblyDisjointInst>(P)->setIsDisjoint(IsDisjoint);
3809}
3810
3811/*--.. Memory ..............................................................--*/
3812
3814 const char *Name) {
3815 Type* ITy = Type::getInt32Ty(unwrap(B)->GetInsertBlock()->getContext());
3816 Constant* AllocSize = ConstantExpr::getSizeOf(unwrap(Ty));
3817 AllocSize = ConstantExpr::getTruncOrBitCast(AllocSize, ITy);
3818 return wrap(unwrap(B)->CreateMalloc(ITy, unwrap(Ty), AllocSize, nullptr,
3819 nullptr, Name));
3820}
3821
3823 LLVMValueRef Val, const char *Name) {
3824 Type* ITy = Type::getInt32Ty(unwrap(B)->GetInsertBlock()->getContext());
3825 Constant* AllocSize = ConstantExpr::getSizeOf(unwrap(Ty));
3826 AllocSize = ConstantExpr::getTruncOrBitCast(AllocSize, ITy);
3827 return wrap(unwrap(B)->CreateMalloc(ITy, unwrap(Ty), AllocSize, unwrap(Val),
3828 nullptr, Name));
3829}
3830
3832 LLVMValueRef Val, LLVMValueRef Len,
3833 unsigned Align) {
3834 return wrap(unwrap(B)->CreateMemSet(unwrap(Ptr), unwrap(Val), unwrap(Len),
3835 MaybeAlign(Align)));
3836}
3837
3839 LLVMValueRef Dst, unsigned DstAlign,
3840 LLVMValueRef Src, unsigned SrcAlign,
3842 return wrap(unwrap(B)->CreateMemCpy(unwrap(Dst), MaybeAlign(DstAlign),
3843 unwrap(Src), MaybeAlign(SrcAlign),
3844 unwrap(Size)));
3845}
3846
3848 LLVMValueRef Dst, unsigned DstAlign,
3849 LLVMValueRef Src, unsigned SrcAlign,
3851 return wrap(unwrap(B)->CreateMemMove(unwrap(Dst), MaybeAlign(DstAlign),
3852 unwrap(Src), MaybeAlign(SrcAlign),
3853 unwrap(Size)));
3854}
3855
3857 const char *Name) {
3858 return wrap(unwrap(B)->CreateAlloca(unwrap(Ty), nullptr, Name));
3859}
3860
3862 LLVMValueRef Val, const char *Name) {
3863 return wrap(unwrap(B)->CreateAlloca(unwrap(Ty), unwrap(Val), Name));
3864}
3865
3867 return wrap(unwrap(B)->CreateFree(unwrap(PointerVal)));
3868}
3869
3871 LLVMValueRef PointerVal, const char *Name) {
3872 return wrap(unwrap(B)->CreateLoad(unwrap(Ty), unwrap(PointerVal), Name));
3873}
3874
3876 LLVMValueRef PointerVal) {
3877 return wrap(unwrap(B)->CreateStore(unwrap(Val), unwrap(PointerVal)));
3878}
3879
3881 switch (Ordering) {
3882 case LLVMAtomicOrderingNotAtomic: return AtomicOrdering::NotAtomic;
3883 case LLVMAtomicOrderingUnordered: return AtomicOrdering::Unordered;
3884 case LLVMAtomicOrderingMonotonic: return AtomicOrdering::Monotonic;
3885 case LLVMAtomicOrderingAcquire: return AtomicOrdering::Acquire;
3886 case LLVMAtomicOrderingRelease: return AtomicOrdering::Release;
3888 return AtomicOrdering::AcquireRelease;
3890 return AtomicOrdering::SequentiallyConsistent;
3891 }
3892
3893 llvm_unreachable("Invalid LLVMAtomicOrdering value!");
3894}
3895
3897 switch (Ordering) {
3898 case AtomicOrdering::NotAtomic: return LLVMAtomicOrderingNotAtomic;
3899 case AtomicOrdering::Unordered: return LLVMAtomicOrderingUnordered;
3900 case AtomicOrdering::Monotonic: return LLVMAtomicOrderingMonotonic;
3901 case AtomicOrdering::Acquire: return LLVMAtomicOrderingAcquire;
3902 case AtomicOrdering::Release: return LLVMAtomicOrderingRelease;
3903 case AtomicOrdering::AcquireRelease:
3905 case AtomicOrdering::SequentiallyConsistent:
3907 }
3908
3909 llvm_unreachable("Invalid AtomicOrdering value!");
3910}
3911
3913 switch (BinOp) {
3933 }
3934
3935 llvm_unreachable("Invalid LLVMAtomicRMWBinOp value!");
3936}
3937
3939 switch (BinOp) {
3959 default: break;
3960 }
3961
3962 llvm_unreachable("Invalid AtomicRMWBinOp value!");
3963}
3964
3966 LLVMBool isSingleThread, const char *Name) {
3967 return wrap(
3968 unwrap(B)->CreateFence(mapFromLLVMOrdering(Ordering),
3969 isSingleThread ? SyncScope::SingleThread
3971 Name));
3972}
3973
3975 LLVMAtomicOrdering Ordering, unsigned SSID,
3976 const char *Name) {
3977 return wrap(
3978 unwrap(B)->CreateFence(mapFromLLVMOrdering(Ordering), SSID, Name));
3979}
3980
3982 LLVMValueRef Pointer, LLVMValueRef *Indices,
3983 unsigned NumIndices, const char *Name) {
3984 ArrayRef<Value *> IdxList(unwrap(Indices), NumIndices);
3985 return wrap(unwrap(B)->CreateGEP(unwrap(Ty), unwrap(Pointer), IdxList, Name));
3986}
3987
3989 LLVMValueRef Pointer, LLVMValueRef *Indices,
3990 unsigned NumIndices, const char *Name) {
3991 ArrayRef<Value *> IdxList(unwrap(Indices), NumIndices);
3992 return wrap(
3993 unwrap(B)->CreateInBoundsGEP(unwrap(Ty), unwrap(Pointer), IdxList, Name));
3994}
3995
3997 LLVMValueRef Pointer,
3998 LLVMValueRef *Indices,
3999 unsigned NumIndices, const char *Name,
4000 LLVMGEPNoWrapFlags NoWrapFlags) {
4001 ArrayRef<Value *> IdxList(unwrap(Indices), NumIndices);
4002 return wrap(unwrap(B)->CreateGEP(unwrap(Ty), unwrap(Pointer), IdxList, Name,
4003 mapFromLLVMGEPNoWrapFlags(NoWrapFlags)));
4004}
4005
4007 LLVMValueRef Pointer, unsigned Idx,
4008 const char *Name) {
4009 return wrap(
4010 unwrap(B)->CreateStructGEP(unwrap(Ty), unwrap(Pointer), Idx, Name));
4011}
4012
4014 const char *Name) {
4015 return wrap(unwrap(B)->CreateGlobalString(Str, Name));
4016}
4017
4019 const char *Name) {
4020 return wrap(unwrap(B)->CreateGlobalStringPtr(Str, Name));
4021}
4022
4024 Value *P = unwrap(MemAccessInst);
4025 if (LoadInst *LI = dyn_cast<LoadInst>(P))
4026 return LI->isVolatile();
4027 if (StoreInst *SI = dyn_cast<StoreInst>(P))
4028 return SI->isVolatile();
4029 if (AtomicRMWInst *AI = dyn_cast<AtomicRMWInst>(P))
4030 return AI->isVolatile();
4031 return cast<AtomicCmpXchgInst>(P)->isVolatile();
4032}
4033
4034void LLVMSetVolatile(LLVMValueRef MemAccessInst, LLVMBool isVolatile) {
4035 Value *P = unwrap(MemAccessInst);
4036 if (LoadInst *LI = dyn_cast<LoadInst>(P))
4037 return LI->setVolatile(isVolatile);
4038 if (StoreInst *SI = dyn_cast<StoreInst>(P))
4039 return SI->setVolatile(isVolatile);
4040 if (AtomicRMWInst *AI = dyn_cast<AtomicRMWInst>(P))
4041 return AI->setVolatile(isVolatile);
4042 return cast<AtomicCmpXchgInst>(P)->setVolatile(isVolatile);
4043}
4044
4046 return unwrap<AtomicCmpXchgInst>(CmpXchgInst)->isWeak();
4047}
4048
4049void LLVMSetWeak(LLVMValueRef CmpXchgInst, LLVMBool isWeak) {
4050 return unwrap<AtomicCmpXchgInst>(CmpXchgInst)->setWeak(isWeak);
4051}
4052
4054 Value *P = unwrap(MemAccessInst);
4056 if (LoadInst *LI = dyn_cast<LoadInst>(P))
4057 O = LI->getOrdering();
4058 else if (StoreInst *SI = dyn_cast<StoreInst>(P))
4059 O = SI->getOrdering();
4060 else if (FenceInst *FI = dyn_cast<FenceInst>(P))
4061 O = FI->getOrdering();
4062 else
4063 O = cast<AtomicRMWInst>(P)->getOrdering();
4064 return mapToLLVMOrdering(O);
4065}
4066
4067void LLVMSetOrdering(LLVMValueRef MemAccessInst, LLVMAtomicOrdering Ordering) {
4068 Value *P = unwrap(MemAccessInst);
4069 AtomicOrdering O = mapFromLLVMOrdering(Ordering);
4070
4071 if (LoadInst *LI = dyn_cast<LoadInst>(P))
4072 return LI->setOrdering(O);
4073 else if (FenceInst *FI = dyn_cast<FenceInst>(P))
4074 return FI->setOrdering(O);
4075 else if (AtomicRMWInst *ARWI = dyn_cast<AtomicRMWInst>(P))
4076 return ARWI->setOrdering(O);
4077 return cast<StoreInst>(P)->setOrdering(O);
4078}
4079
4081 return mapToLLVMRMWBinOp(unwrap<AtomicRMWInst>(Inst)->getOperation());
4082}
4083
4085 unwrap<AtomicRMWInst>(Inst)->setOperation(mapFromLLVMRMWBinOp(BinOp));
4086}
4087
4088/*--.. Casts ...............................................................--*/
4089
4091 LLVMTypeRef DestTy, const char *Name) {
4092 return wrap(unwrap(B)->CreateTrunc(unwrap(Val), unwrap(DestTy), Name));
4093}
4094
4096 LLVMTypeRef DestTy, const char *Name) {
4097 return wrap(unwrap(B)->CreateZExt(unwrap(Val), unwrap(DestTy), Name));
4098}
4099
4101 LLVMTypeRef DestTy, const char *Name) {
4102 return wrap(unwrap(B)->CreateSExt(unwrap(Val), unwrap(DestTy), Name));
4103}
4104
4106 LLVMTypeRef DestTy, const char *Name) {
4107 return wrap(unwrap(B)->CreateFPToUI(unwrap(Val), unwrap(DestTy), Name));
4108}
4109
4111 LLVMTypeRef DestTy, const char *Name) {
4112 return wrap(unwrap(B)->CreateFPToSI(unwrap(Val), unwrap(DestTy), Name));
4113}
4114
4116 LLVMTypeRef DestTy, const char *Name) {
4117 return wrap(unwrap(B)->CreateUIToFP(unwrap(Val), unwrap(DestTy), Name));
4118}
4119
4121 LLVMTypeRef DestTy, const char *Name) {
4122 return wrap(unwrap(B)->CreateSIToFP(unwrap(Val), unwrap(DestTy), Name));
4123}
4124
4126 LLVMTypeRef DestTy, const char *Name) {
4127 return wrap(unwrap(B)->CreateFPTrunc(unwrap(Val), unwrap(DestTy), Name));
4128}
4129
4131 LLVMTypeRef DestTy, const char *Name) {
4132 return wrap(unwrap(B)->CreateFPExt(unwrap(Val), unwrap(DestTy), Name));
4133}
4134
4136 LLVMTypeRef DestTy, const char *Name) {
4137 return wrap(unwrap(B)->CreatePtrToInt(unwrap(Val), unwrap(DestTy), Name));
4138}
4139
4141 LLVMTypeRef DestTy, const char *Name) {
4142 return wrap(unwrap(B)->CreateIntToPtr(unwrap(Val), unwrap(DestTy), Name));
4143}
4144
4146 LLVMTypeRef DestTy, const char *Name) {
4147 return wrap(unwrap(B)->CreateBitCast(unwrap(Val), unwrap(DestTy), Name));
4148}
4149
4151 LLVMTypeRef DestTy, const char *Name) {
4152 return wrap(unwrap(B)->CreateAddrSpaceCast(unwrap(Val), unwrap(DestTy), Name));
4153}
4154
4156 LLVMTypeRef DestTy, const char *Name) {
4157 return wrap(unwrap(B)->CreateZExtOrBitCast(unwrap(Val), unwrap(DestTy),
4158 Name));
4159}
4160
4162 LLVMTypeRef DestTy, const char *Name) {
4163 return wrap(unwrap(B)->CreateSExtOrBitCast(unwrap(Val), unwrap(DestTy),
4164 Name));
4165}
4166
4168 LLVMTypeRef DestTy, const char *Name) {
4169 return wrap(unwrap(B)->CreateTruncOrBitCast(unwrap(Val), unwrap(DestTy),
4170 Name));
4171}
4172
4174 LLVMTypeRef DestTy, const char *Name) {
4175 return wrap(unwrap(B)->CreateCast(Instruction::CastOps(map_from_llvmopcode(Op)), unwrap(Val),
4176 unwrap(DestTy), Name));
4177}
4178
4180 LLVMTypeRef DestTy, const char *Name) {
4181 return wrap(unwrap(B)->CreatePointerCast(unwrap(Val), unwrap(DestTy), Name));
4182}
4183
4185 LLVMTypeRef DestTy, LLVMBool IsSigned,
4186 const char *Name) {
4187 return wrap(
4188 unwrap(B)->CreateIntCast(unwrap(Val), unwrap(DestTy), IsSigned, Name));
4189}
4190
4192 LLVMTypeRef DestTy, const char *Name) {
4193 return wrap(unwrap(B)->CreateIntCast(unwrap(Val), unwrap(DestTy),
4194 /*isSigned*/true, Name));
4195}
4196
4198 LLVMTypeRef DestTy, const char *Name) {
4199 return wrap(unwrap(B)->CreateFPCast(unwrap(Val), unwrap(DestTy), Name));
4200}
4201
4203 LLVMTypeRef DestTy, LLVMBool DestIsSigned) {
4205 unwrap(Src), SrcIsSigned, unwrap(DestTy), DestIsSigned));
4206}
4207
4208/*--.. Comparisons .........................................................--*/
4209
4211 LLVMValueRef LHS, LLVMValueRef RHS,
4212 const char *Name) {
4213 return wrap(unwrap(B)->CreateICmp(static_cast<ICmpInst::Predicate>(Op),
4214 unwrap(LHS), unwrap(RHS), Name));
4215}
4216
4218 LLVMValueRef LHS, LLVMValueRef RHS,
4219 const char *Name) {
4220 return wrap(unwrap(B)->CreateFCmp(static_cast<FCmpInst::Predicate>(Op),
4221 unwrap(LHS), unwrap(RHS), Name));
4222}
4223
4224/*--.. Miscellaneous instructions ..........................................--*/
4225
4227 return wrap(unwrap(B)->CreatePHI(unwrap(Ty), 0, Name));
4228}
4229
4231 LLVMValueRef *Args, unsigned NumArgs,
4232 const char *Name) {
4233 FunctionType *FTy = unwrap<FunctionType>(Ty);
4234 return wrap(unwrap(B)->CreateCall(FTy, unwrap(Fn),
4235 ArrayRef(unwrap(Args), NumArgs), Name));
4236}
4237
4240 LLVMValueRef Fn, LLVMValueRef *Args,
4241 unsigned NumArgs, LLVMOperandBundleRef *Bundles,
4242 unsigned NumBundles, const char *Name) {
4243 FunctionType *FTy = unwrap<FunctionType>(Ty);
4245 for (auto *Bundle : ArrayRef(Bundles, NumBundles)) {
4246 OperandBundleDef *OB = unwrap(Bundle);
4247 OBs.push_back(*OB);
4248 }
4249 return wrap(unwrap(B)->CreateCall(
4250 FTy, unwrap(Fn), ArrayRef(unwrap(Args), NumArgs), OBs, Name));
4251}
4252
4254 LLVMValueRef Then, LLVMValueRef Else,
4255 const char *Name) {
4256 return wrap(unwrap(B)->CreateSelect(unwrap(If), unwrap(Then), unwrap(Else),
4257 Name));
4258}
4259
4261 LLVMTypeRef Ty, const char *Name) {
4262 return wrap(unwrap(B)->CreateVAArg(unwrap(List), unwrap(Ty), Name));
4263}
4264
4266 LLVMValueRef Index, const char *Name) {
4267 return wrap(unwrap(B)->CreateExtractElement(unwrap(VecVal), unwrap(Index),
4268 Name));
4269}
4270
4273 const char *Name) {
4274 return wrap(unwrap(B)->CreateInsertElement(unwrap(VecVal), unwrap(EltVal),
4275 unwrap(Index), Name));
4276}
4277
4279 LLVMValueRef V2, LLVMValueRef Mask,
4280 const char *Name) {
4281 return wrap(unwrap(B)->CreateShuffleVector(unwrap(V1), unwrap(V2),
4282 unwrap(Mask), Name));
4283}
4284
4286 unsigned Index, const char *Name) {
4287 return wrap(unwrap(B)->CreateExtractValue(unwrap(AggVal), Index, Name));
4288}
4289
4291 LLVMValueRef EltVal, unsigned Index,
4292 const char *Name) {
4293 return wrap(unwrap(B)->CreateInsertValue(unwrap(AggVal), unwrap(EltVal),
4294 Index, Name));
4295}
4296
4298 const char *Name) {
4299 return wrap(unwrap(B)->CreateFreeze(unwrap(Val), Name));
4300}
4301
4303 const char *Name) {
4304 return wrap(unwrap(B)->CreateIsNull(unwrap(Val), Name));
4305}
4306
4308 const char *Name) {
4309 return wrap(unwrap(B)->CreateIsNotNull(unwrap(Val), Name));
4310}
4311
4313 LLVMValueRef LHS, LLVMValueRef RHS,
4314 const char *Name) {
4315 return wrap(unwrap(B)->CreatePtrDiff(unwrap(ElemTy), unwrap(LHS),
4316 unwrap(RHS), Name));
4317}
4318
4320 LLVMValueRef PTR, LLVMValueRef Val,
4321 LLVMAtomicOrdering ordering,
4322 LLVMBool singleThread) {
4324 return wrap(unwrap(B)->CreateAtomicRMW(
4325 intop, unwrap(PTR), unwrap(Val), MaybeAlign(),
4326 mapFromLLVMOrdering(ordering),
4327 singleThread ? SyncScope::SingleThread : SyncScope::System));
4328}
4329
4332 LLVMValueRef PTR, LLVMValueRef Val,
4333 LLVMAtomicOrdering ordering,
4334 unsigned SSID) {
4336 return wrap(unwrap(B)->CreateAtomicRMW(intop, unwrap(PTR), unwrap(Val),
4337 MaybeAlign(),
4338 mapFromLLVMOrdering(ordering), SSID));
4339}
4340
4342 LLVMValueRef Cmp, LLVMValueRef New,
4343 LLVMAtomicOrdering SuccessOrdering,
4344 LLVMAtomicOrdering FailureOrdering,
4345 LLVMBool singleThread) {
4346
4347 return wrap(unwrap(B)->CreateAtomicCmpXchg(
4348 unwrap(Ptr), unwrap(Cmp), unwrap(New), MaybeAlign(),
4349 mapFromLLVMOrdering(SuccessOrdering),
4350 mapFromLLVMOrdering(FailureOrdering),
4351 singleThread ? SyncScope::SingleThread : SyncScope::System));
4352}
4353
4355 LLVMValueRef Cmp, LLVMValueRef New,
4356 LLVMAtomicOrdering SuccessOrdering,
4357 LLVMAtomicOrdering FailureOrdering,
4358 unsigned SSID) {
4359 return wrap(unwrap(B)->CreateAtomicCmpXchg(
4360 unwrap(Ptr), unwrap(Cmp), unwrap(New), MaybeAlign(),
4361 mapFromLLVMOrdering(SuccessOrdering),
4362 mapFromLLVMOrdering(FailureOrdering), SSID));
4363}
4364
4366 Value *P = unwrap(SVInst);
4367 ShuffleVectorInst *I = cast<ShuffleVectorInst>(P);
4368 return I->getShuffleMask().size();
4369}
4370
4371int LLVMGetMaskValue(LLVMValueRef SVInst, unsigned Elt) {
4372 Value *P = unwrap(SVInst);
4373 ShuffleVectorInst *I = cast<ShuffleVectorInst>(P);
4374 return I->getMaskValue(Elt);
4375}
4376
4378
4380 return unwrap<Instruction>(Inst)->isAtomic();
4381}
4382
4384 // Backwards compatibility: return false for non-atomic instructions
4385 Instruction *I = unwrap<Instruction>(AtomicInst);
4386 if (!I->isAtomic())
4387 return 0;
4388
4390}
4391
4393 // Backwards compatibility: ignore non-atomic instructions
4394 Instruction *I = unwrap<Instruction>(AtomicInst);
4395 if (!I->isAtomic())
4396 return;
4397
4399 setAtomicSyncScopeID(I, SSID);
4400}
4401
4403 Instruction *I = unwrap<Instruction>(AtomicInst);
4404 assert(I->isAtomic() && "Expected an atomic instruction");
4405 return *getAtomicSyncScopeID(I);
4406}
4407
4408void LLVMSetAtomicSyncScopeID(LLVMValueRef AtomicInst, unsigned SSID) {
4409 Instruction *I = unwrap<Instruction>(AtomicInst);
4410 assert(I->isAtomic() && "Expected an atomic instruction");
4411 setAtomicSyncScopeID(I, SSID);
4412}
4413
4415 Value *P = unwrap(CmpXchgInst);
4416 return mapToLLVMOrdering(cast<AtomicCmpXchgInst>(P)->getSuccessOrdering());
4417}
4418
4420 LLVMAtomicOrdering Ordering) {
4421 Value *P = unwrap(CmpXchgInst);
4422 AtomicOrdering O = mapFromLLVMOrdering(Ordering);
4423
4424 return cast<AtomicCmpXchgInst>(P)->setSuccessOrdering(O);
4425}
4426
4428 Value *P = unwrap(CmpXchgInst);
4429 return mapToLLVMOrdering(cast<AtomicCmpXchgInst>(P)->getFailureOrdering());
4430}
4431
4433 LLVMAtomicOrdering Ordering) {
4434 Value *P = unwrap(CmpXchgInst);
4435 AtomicOrdering O = mapFromLLVMOrdering(Ordering);
4436
4437 return cast<AtomicCmpXchgInst>(P)->setFailureOrdering(O);
4438}
4439
4440/*===-- Module providers --------------------------------------------------===*/
4441
4444 return reinterpret_cast<LLVMModuleProviderRef>(M);
4445}
4446
4448 delete unwrap(MP);
4449}
4450
4451
4452/*===-- Memory buffers ----------------------------------------------------===*/
4453
4455 const char *Path,
4456 LLVMMemoryBufferRef *OutMemBuf,
4457 char **OutMessage) {
4458
4460 if (std::error_code EC = MBOrErr.getError()) {
4461 *OutMessage = strdup(EC.message().c_str());
4462 return 1;
4463 }
4464 *OutMemBuf = wrap(MBOrErr.get().release());
4465 return 0;
4466}
4467
4469 char **OutMessage) {
4471 if (std::error_code EC = MBOrErr.getError()) {
4472 *OutMessage = strdup(EC.message().c_str());
4473 return 1;
4474 }
4475 *OutMemBuf = wrap(MBOrErr.get().release());
4476 return 0;
4477}
4478
4480 const char *InputData,
4481 size_t InputDataLength,
4482 const char *BufferName,
4483 LLVMBool RequiresNullTerminator) {
4484
4485 return wrap(MemoryBuffer::getMemBuffer(StringRef(InputData, InputDataLength),
4486 StringRef(BufferName),
4487 RequiresNullTerminator).release());
4488}
4489
4491 const char *InputData,
4492 size_t InputDataLength,
4493 const char *BufferName) {
4494
4495 return wrap(
4496 MemoryBuffer::getMemBufferCopy(StringRef(InputData, InputDataLength),
4497 StringRef(BufferName)).release());
4498}
4499
4501 return unwrap(MemBuf)->getBufferStart();
4502}
4503
4505 return unwrap(MemBuf)->getBufferSize();
4506}
4507
4509 delete unwrap(MemBuf);
4510}
4511
4512/*===-- Pass Manager ------------------------------------------------------===*/
4513
4515 return wrap(new legacy::PassManager());
4516}
4517
4519 return wrap(new legacy::FunctionPassManager(unwrap(M)));
4520}
4521
4524 reinterpret_cast<LLVMModuleRef>(P));
4525}
4526
4528 return unwrap<legacy::PassManager>(PM)->run(*unwrap(M));
4529}
4530
4532 return unwrap<legacy::FunctionPassManager>(FPM)->doInitialization();
4533}
4534
4536 return unwrap<legacy::FunctionPassManager>(FPM)->run(*unwrap<Function>(F));
4537}
4538
4540 return unwrap<legacy::FunctionPassManager>(FPM)->doFinalization();
4541}
4542
4544 delete unwrap(PM);
4545}
4546
4547/*===-- Threading ------------------------------------------------------===*/
4548
4550 return LLVMIsMultithreaded();
4551}
4552
4554}
4555
4557 return llvm_is_multithreaded();
4558}
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< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
#define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref)
#define LLVM_EXTENSION
LLVM_EXTENSION - Support compilers where we have a keyword to suppress pedantic diagnostics.
Definition: Compiler.h:344
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
Given that RA is a live value
#define LLVM_DEBUG(X)
Definition: Debug.h:101
uint64_t Addr
std::string Name
uint64_t Size
static Function * getFunction(Constant *C)
Definition: Evaluator.cpp:236
static char getTypeID(Type *Ty)
#define op(i)
Hexagon Common GEP
LLVMValueRef LLVMGetElementAsConstant(LLVMValueRef C, unsigned idx)
Definition: Core.cpp:1629
static Module::ModFlagBehavior map_to_llvmModFlagBehavior(LLVMModuleFlagBehavior Behavior)
Definition: Core.cpp:338
#define LLVM_DEFINE_VALUE_CAST(name)
Definition: Core.cpp:1141
static LLVMValueMetadataEntry * llvm_getMetadata(size_t *NumEntries, llvm::function_ref< void(MetadataEntries &)> AccessMD)
Definition: Core.cpp:1113
static GEPNoWrapFlags mapFromLLVMGEPNoWrapFlags(LLVMGEPNoWrapFlags GEPFlags)
Definition: Core.cpp:1714
static MDNode * extractMDNode(MetadataAsValue *MAV)
Definition: Core.cpp:1089
static void LLVMPositionBuilderImpl(IRBuilder<> *Builder, BasicBlock *Block, Instruction *Instr, bool BeforeDbgRecords)
Definition: Core.cpp:3243
static LLVMOpcode map_to_llvmopcode(int opcode)
Definition: Core.cpp:1692
static LLVMFastMathFlags mapToLLVMFastMathFlags(FastMathFlags FMF)
Definition: Core.cpp:3563
static FastMathFlags mapFromLLVMFastMathFlags(LLVMFastMathFlags FMF)
Definition: Core.cpp:3550
LLVMValueRef LLVMConstIntOfString(LLVMTypeRef IntTy, const char Str[], uint8_t Radix)
Definition: Core.cpp:1549
static AtomicOrdering mapFromLLVMOrdering(LLVMAtomicOrdering Ordering)
Definition: Core.cpp:3880
static Intrinsic::ID llvm_map_to_intrinsic_id(unsigned ID)
Definition: Core.cpp:2457
static LLVMModuleFlagBehavior map_from_llvmModFlagBehavior(Module::ModFlagBehavior Behavior)
Definition: Core.cpp:357
static LLVMAtomicOrdering mapToLLVMOrdering(AtomicOrdering Ordering)
Definition: Core.cpp:3896
LLVMValueRef LLVMBuildNUWNeg(LLVMBuilderRef B, LLVMValueRef V, const char *Name)
Definition: Core.cpp:3729
static LLVMValueRef getMDNodeOperandImpl(LLVMContext &Context, const MDNode *N, unsigned Index)
Definition: Core.cpp:1196
LLVMValueRef LLVMConstRealOfStringAndSize(LLVMTypeRef RealTy, const char Str[], unsigned SLen)
Definition: Core.cpp:1569
static int map_from_llvmopcode(LLVMOpcode code)
Definition: Core.cpp:1702
static LLVMAtomicRMWBinOp mapToLLVMRMWBinOp(AtomicRMWInst::BinOp BinOp)
Definition: Core.cpp:3938
static AtomicRMWInst::BinOp mapFromLLVMRMWBinOp(LLVMAtomicRMWBinOp BinOp)
Definition: Core.cpp:3912
LLVMValueRef LLVMConstNUWNeg(LLVMValueRef ConstantVal)
Definition: Core.cpp:1760
LLVMValueRef LLVMConstIntOfStringAndSize(LLVMTypeRef IntTy, const char Str[], unsigned SLen, uint8_t Radix)
Definition: Core.cpp:1555
static LLVMContext & getGlobalContext()
Definition: Core.cpp:93
static LLVMGEPNoWrapFlags mapToLLVMGEPNoWrapFlags(GEPNoWrapFlags GEPFlags)
Definition: Core.cpp:1726
BasicBlock ** unwrap(LLVMBasicBlockRef *BBs)
Definition: Core.cpp:51
#define F(x, y, z)
Definition: MD5.cpp:55
#define I(x, y, z)
Definition: MD5.cpp:58
#define H(x, y, z)
Definition: MD5.cpp:57
Module.h This file contains the declarations for the Module class.
#define P(N)
if(auto Err=PB.parsePassPipeline(MPM, Passes)) return wrap(std MPM run * Mod
const NodeList & List
Definition: RDFGraph.cpp:201
const SmallVectorImpl< MachineOperand > & Cond
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)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static SymbolRef::Type getType(const Symbol *Sym)
Definition: TapiFile.cpp:40
unify loop Fixup each natural loop to have a single exit block
static std::optional< unsigned > getOpcode(ArrayRef< VPValue * > Values)
Returns the opcode of Values or ~0 if they do not all agree.
Definition: VPlanSLP.cpp:191
Value * RHS
Value * LHS
static const uint32_t IV[8]
Definition: blake3_impl.h:78
opStatus convert(const fltSemantics &ToSemantics, roundingMode RM, bool *losesInfo)
Definition: APFloat.cpp:5337
double convertToDouble() const
Converts this APFloat to host double value.
Definition: APFloat.cpp:5396
Class for arbitrary precision integers.
Definition: APInt.h:78
an instruction to allocate memory on the stack
Definition: Instructions.h:61
This class represents an incoming formal argument to a Function.
Definition: Argument.h:31
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
An instruction that atomically checks whether a specified value is in a memory location,...
Definition: Instructions.h:495
an instruction that atomically reads a memory location, combines it with another value,...
Definition: Instructions.h:696
BinOp
This enumeration lists the possible modifications atomicrmw can make.
Definition: Instructions.h:708
@ Add
*p = old + v
Definition: Instructions.h:712
@ FAdd
*p = old + v
Definition: Instructions.h:733
@ Min
*p = old <signed v ? old : v
Definition: Instructions.h:726
@ Or
*p = old | v
Definition: Instructions.h:720
@ Sub
*p = old - v
Definition: Instructions.h:714
@ And
*p = old & v
Definition: Instructions.h:716
@ Xor
*p = old ^ v
Definition: Instructions.h:722
@ FSub
*p = old - v
Definition: Instructions.h:736
@ UIncWrap
Increment one up to a maximum value.
Definition: Instructions.h:748
@ Max
*p = old >signed v ? old : v
Definition: Instructions.h:724
@ UMin
*p = old <unsigned v ? old : v
Definition: Instructions.h:730
@ FMin
*p = minnum(old, v) minnum matches the behavior of llvm.minnum.
Definition: Instructions.h:744
@ UMax
*p = old >unsigned v ? old : v
Definition: Instructions.h:728
@ FMax
*p = maxnum(old, v) maxnum matches the behavior of llvm.maxnum.
Definition: Instructions.h:740
@ UDecWrap
Decrement one until a minimum value or zero.
Definition: Instructions.h:752
@ Nand
*p = ~(old & v)
Definition: Instructions.h:718
static Attribute::AttrKind getAttrKindFromName(StringRef AttrName)
Definition: Attributes.cpp:304
static Attribute get(LLVMContext &Context, AttrKind Kind, uint64_t Val=0)
Return a uniquified Attribute object.
Definition: Attributes.cpp:94
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results,...
Definition: Attributes.h:86
static Attribute getWithAlignment(LLVMContext &Context, Align Alignment)
Return a uniquified Attribute object that has the specific alignment set.
Definition: Attributes.cpp:233
LLVM Basic Block Representation.
Definition: BasicBlock.h:61
void print(raw_ostream &OS, AssemblyAnnotationWriter *AAW=nullptr, bool ShouldPreserveUseListOrder=false, bool IsForDebug=false) const
Print the basic block to an output stream with an optional AssemblyAnnotationWriter.
Definition: AsmWriter.cpp:4863
void setIsNewDbgInfoFormat(bool NewFlag)
Ensure the block is in "old" dbg.value format (NewFlag == false) or in the new format (NewFlag == tru...
Definition: BasicBlock.cpp:152
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)
Creates a new BasicBlock.
Definition: BasicBlock.h:212
void moveAfter(BasicBlock *MovePos)
Unlink this basic block from its current function and insert it right after MovePos in the function M...
Definition: BasicBlock.cpp:287
void removeFromParent()
Unlink 'this' from the containing function, but do not delete it.
Definition: BasicBlock.cpp:275
const Function * getParent() const
Return the enclosing method, or null if none.
Definition: BasicBlock.h:219
SymbolTableList< BasicBlock >::iterator eraseFromParent()
Unlink 'this' from the containing function and delete it.
Definition: BasicBlock.cpp:279
InstListType::iterator iterator
Instruction iterators...
Definition: BasicBlock.h:177
LLVMContext & getContext() const
Get the context in which this basic block lives.
Definition: BasicBlock.cpp:168
bool IsNewDbgInfoFormat
Flag recording whether or not this block stores debug-info in the form of intrinsic instructions (fal...
Definition: BasicBlock.h:67
size_t size() const
Definition: BasicBlock.h:469
void moveBefore(BasicBlock *MovePos)
Unlink this basic block from its current function and insert it into the function that MovePos lives ...
Definition: BasicBlock.h:376
static BlockAddress * get(Function *F, BasicBlock *BB)
Return a BlockAddress for the specified function and basic block.
Definition: Constants.cpp:1871
static 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:757
static Constant * get(ArrayType *T, ArrayRef< Constant * > V)
Definition: Constants.cpp:1292
static ConstantAsMetadata * get(Constant *C)
Definition: Metadata.h:528
static Constant * getString(LLVMContext &Context, StringRef Initializer, bool AddNull=true)
This method constructs a CDS and initializes it with a text string.
Definition: Constants.cpp:2950
static Constant * getIntToPtr(Constant *C, Type *Ty, bool OnlyIfReduced=false)
Definition: Constants.cpp:2281
static Constant * getExtractElement(Constant *Vec, Constant *Idx, Type *OnlyIfReducedTy=nullptr)
Definition: Constants.cpp:2528
static Constant * getAlignOf(Type *Ty)
getAlignOf constant expr - computes the alignment of a type in a target independent way (Note: the re...
Definition: Constants.cpp:2464
static Constant * getNUWSub(Constant *C1, Constant *C2)
Definition: Constants.h:1162
static Constant * getInBoundsGetElementPtr(Type *Ty, Constant *C, ArrayRef< Constant * > IdxList)
Create an "inbounds" getelementptr.
Definition: Constants.h:1280
static Constant * getPointerCast(Constant *C, Type *Ty)
Create a BitCast, AddrSpaceCast, or a PtrToInt cast constant expression.
Definition: Constants.cpp:2227
static Constant * getTruncOrBitCast(Constant *C, Type *Ty)
Definition: Constants.cpp:2221
static Constant * getNSWAdd(Constant *C1, Constant *C2)
Definition: Constants.h:1150
static Constant * getSub(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
Definition: Constants.cpp:2618
static Constant * getNot(Constant *C)
Definition: Constants.cpp:2605
static Constant * getInsertElement(Constant *Vec, Constant *Elt, Constant *Idx, Type *OnlyIfReducedTy=nullptr)
Definition: Constants.cpp:2550
static Constant * getPtrToInt(Constant *C, Type *Ty, bool OnlyIfReduced=false)
Definition: Constants.cpp:2267
static Constant * getShuffleVector(Constant *V1, Constant *V2, ArrayRef< int > Mask, Type *OnlyIfReducedTy=nullptr)
Definition: Constants.cpp:2573
static Constant * getSizeOf(Type *Ty)
getSizeOf constant expr - computes the (alloc) size of a type (in address-units, not bits) in a targe...
Definition: Constants.cpp:2454
static Constant * getXor(Constant *C1, Constant *C2)
Definition: Constants.cpp:2632
static Constant * getMul(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
Definition: Constants.cpp:2625
static Constant * getNSWNeg(Constant *C)
Definition: Constants.h:1148
static Constant * getNSWSub(Constant *C1, Constant *C2)
Definition: Constants.h:1158
static Constant * getNUWAdd(Constant *C1, Constant *C2)
Definition: Constants.h:1154
static Constant * getAddrSpaceCast(Constant *C, Type *Ty, bool OnlyIfReduced=false)
Definition: Constants.cpp:2307
static 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:1253
static Constant * getAdd(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
Definition: Constants.cpp:2611
static Constant * getBitCast(Constant *C, Type *Ty, bool OnlyIfReduced=false)
Definition: Constants.cpp:2295
static Constant * getNSWMul(Constant *C1, Constant *C2)
Definition: Constants.h:1166
static Constant * getNeg(Constant *C, bool HasNSW=false)
Definition: Constants.cpp:2599
static Constant * getTrunc(Constant *C, Type *Ty, bool OnlyIfReduced=false)
Definition: Constants.cpp:2253
static Constant * getNUWMul(Constant *C1, Constant *C2)
Definition: Constants.h:1170
ConstantFP - Floating Point Values [float, double].
Definition: Constants.h:269
const APFloat & getValueAPF() const
Definition: Constants.h:312
static ConstantPointerNull * get(PointerType *T)
Static factory methods - Return objects of the specified value.
Definition: Constants.cpp:1800
static ConstantPtrAuth * get(Constant *Ptr, ConstantInt *Key, ConstantInt *Disc, Constant *AddrDisc)
Return a pointer signed with the specified parameters.
Definition: Constants.cpp:2046
This class represents a range of values.
Definition: ConstantRange.h:47
static Constant * get(StructType *T, ArrayRef< Constant * > V)
Definition: Constants.cpp:1357
static Constant * getAnon(ArrayRef< Constant * > V, bool Packed=false)
Return an anonymous struct that has the specified elements.
Definition: Constants.h:477
static Constant * get(ArrayRef< Constant * > V)
Definition: Constants.cpp:1399
This is an important base class in LLVM.
Definition: Constant.h:42
static Constant * getAllOnesValue(Type *Ty)
Definition: Constants.cpp:417
static Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
Definition: Constants.cpp:370
Subprogram description.
This class represents an Operation in the Expression.
A debug info location.
Definition: DebugLoc.h:33
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:20
void setAllowContract(bool B=true)
Definition: FMF.h:91
bool noSignedZeros() const
Definition: FMF.h:68
bool noInfs() const
Definition: FMF.h:67
void setAllowReciprocal(bool B=true)
Definition: FMF.h:88
bool allowReciprocal() const
Definition: FMF.h:69
void setNoSignedZeros(bool B=true)
Definition: FMF.h:85
bool allowReassoc() const
Flag queries.
Definition: FMF.h:65
bool approxFunc() const
Definition: FMF.h:71
void setNoNaNs(bool B=true)
Definition: FMF.h:79
void setAllowReassoc(bool B=true)
Flag setters.
Definition: FMF.h:76
bool noNaNs() const
Definition: FMF.h:66
void setApproxFunc(bool B=true)
Definition: FMF.h:94
void setNoInfs(bool B=true)
Definition: FMF.h:82
bool allowContract() const
Definition: FMF.h:70
An instruction for ordering other memory operations.
Definition: Instructions.h:420
static FixedVectorType * get(Type *ElementType, unsigned NumElts)
Definition: Type.cpp:680
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace, const Twine &N="", Module *M=nullptr)
Definition: Function.h:172
BasicBlockListType::iterator iterator
Definition: Function.h:69
static Intrinsic::ID lookupIntrinsicID(StringRef Name)
This does the actual lookup of an intrinsic ID which matches the given function name.
Definition: Function.cpp:980
iterator_range< arg_iterator > args()
Definition: Function.h:890
void setPersonalityFn(Constant *Fn)
Definition: Function.cpp:1998
arg_iterator arg_begin()
Definition: Function.h:866
Function::iterator insert(Function::iterator Position, BasicBlock *BB)
Insert BB in the basic block list at Position.
Definition: Function.h:752
size_t arg_size() const
Definition: Function.h:899
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:406
an instruction for type-safe pointer arithmetic to access elements of arrays and structs
Definition: Instructions.h:915
void setNoWrapFlags(GEPNoWrapFlags NW)
Set nowrap flags for GEP instruction.
static 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:550
static 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:607
void setUnnamedAddr(UnnamedAddr Val)
Definition: GlobalValue.h:231
void setThreadLocalMode(ThreadLocalMode Val)
Definition: GlobalValue.h:267
void setLinkage(LinkageTypes LT)
Definition: GlobalValue.h:537
DLLStorageClassTypes
Storage classes of global values for PE targets.
Definition: GlobalValue.h:73
Module * getParent()
Get the module that this global value is contained inside of...
Definition: GlobalValue.h:656
VisibilityTypes
An enumeration for the kinds of visibility of global values.
Definition: GlobalValue.h:66
@ PrivateLinkage
Like Internal, but omit from symbol table.
Definition: GlobalValue.h:60
@ CommonLinkage
Tentative definitions.
Definition: GlobalValue.h:62
@ InternalLinkage
Rename collisions when linking (static functions).
Definition: GlobalValue.h:59
@ LinkOnceAnyLinkage
Keep one copy of function when linking (inline)
Definition: GlobalValue.h:54
@ WeakODRLinkage
Same, but only replaced by something equivalent.
Definition: GlobalValue.h:57
@ ExternalLinkage
Externally visible function.
Definition: GlobalValue.h:52
@ WeakAnyLinkage
Keep one copy of named function when linking (weak)
Definition: GlobalValue.h:56
@ AppendingLinkage
Special purpose, only applies to global arrays.
Definition: GlobalValue.h:58
@ AvailableExternallyLinkage
Available for inspection, not emission.
Definition: GlobalValue.h:53
@ ExternalWeakLinkage
ExternalWeak linkage description.
Definition: GlobalValue.h:61
@ LinkOnceODRLinkage
Same, but only replaced by something equivalent.
Definition: GlobalValue.h:55
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.
void SetInsertPoint(BasicBlock *TheBB)
This specifies that created instructions should be appended to the end of the specified block.
Definition: IRBuilder.h:177
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
Definition: IRBuilder.h:2686
static 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.
Definition: DerivedTypes.h:40
static IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
Definition: Type.cpp:266
unsigned getBitWidth() const
Get the number of bits in this IntegerType.
Definition: DerivedTypes.h:72
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:67
void(*)(LLVMContext *Context, void *OpaqueHandle) YieldCallbackTy
Defines the type of a yield callback.
Definition: LLVMContext.h:164
An instruction for reading from memory.
Definition: Instructions.h:174
static LocalAsMetadata * get(Value *Local)
Definition: Metadata.h:554
Metadata node.
Definition: Metadata.h:1069
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition: Metadata.h:1542
A single uniqued string.
Definition: Metadata.h:720
static MDString * get(LLVMContext &Context, StringRef Str)
Definition: Metadata.cpp:606
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:176
static MetadataAsValue * get(LLVMContext &Context, Metadata *MD)
Definition: Metadata.cpp:103
Metadata * getMetadata() const
Definition: Metadata.h:193
Root of the metadata hierarchy.
Definition: Metadata.h:62
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
global_iterator global_begin()
Definition: Module.h:692
ifunc_iterator ifunc_begin()
Definition: Module.h:750
ModFlagBehavior
This enumeration defines the supported behaviors of module flags.
Definition: Module.h:115
global_iterator global_end()
Definition: Module.h:694
NamedMDListType::iterator named_metadata_iterator
The named metadata iterators.
Definition: Module.h:110
IFuncListType::iterator ifunc_iterator
The Global IFunc iterators.
Definition: Module.h:105
named_metadata_iterator named_metadata_begin()
Definition: Module.h:791
ifunc_iterator ifunc_end()
Definition: Module.h:752
alias_iterator alias_end()
Definition: Module.h:734
alias_iterator alias_begin()
Definition: Module.h:732
FunctionListType::iterator iterator
The Function iterators.
Definition: Module.h:90
GlobalListType::iterator global_iterator
The Global Variable iterator.
Definition: Module.h:85
AliasListType::iterator alias_iterator
The Global Alias iterators.
Definition: Module.h:100
named_metadata_iterator named_metadata_end()
Definition: Module.h:796
A tuple of MDNodes.
Definition: Metadata.h:1730
StringRef getName() const
Definition: Metadata.cpp:1405
Module * getParent()
Get the module that holds this named metadata collection.
Definition: Metadata.h:1800
A container for an operand bundle being viewed as a set of values rather than a set of uses.
Definition: InstrTypes.h:1189
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...
Definition: PassRegistry.h:37
static PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
Definition: Constants.cpp:1852
A global registry used in conjunction with static constructors to make pluggable components (like tar...
Definition: Registry.h:44
Interface for looking up the initializer for a variable name, used by Init::resolveReferences.
Definition: Record.h:2212
static ScalableVectorType * get(Type *ElementType, unsigned MinNumElts)
Definition: Type.cpp:701
This instruction constructs a fixed permutation of two input vectors.
ArrayRef< int > getShuffleMask() const
size_t size() const
Definition: SmallVector.h:91
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: SmallVector.h:586
void push_back(const T &Elt)
Definition: SmallVector.h:426
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1209
An instruction for storing to memory.
Definition: Instructions.h:290
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
constexpr size_t size() const
size - Get the string size.
Definition: StringRef.h:137
constexpr const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
Definition: StringRef.h:131
Class to represent struct types.
Definition: DerivedTypes.h:216
static 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:361
ArrayRef< Type * > elements() const
Definition: DerivedTypes.h:333
static 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:620
static StructType * create(LLVMContext &Context, StringRef Name)
This creates an identified struct.
Definition: Type.cpp:501
Type * getTypeAtIndex(const Value *V) const
Given an index value into the type, return the type of the element.
Definition: Type.cpp:600
Class to represent target extensions types, which are generally unintrospectable from target-independ...
Definition: DerivedTypes.h:720
static TargetExtType * get(LLVMContext &Context, StringRef Name, ArrayRef< Type * > Types=std::nullopt, ArrayRef< unsigned > Ints=std::nullopt)
Return a target extension type having the specified name and optional type and integer parameters.
Definition: Type.cpp:784
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
static Type * getHalfTy(LLVMContext &C)
static Type * getDoubleTy(LLVMContext &C)
static Type * getX86_FP80Ty(LLVMContext &C)
static Type * getBFloatTy(LLVMContext &C)
static IntegerType * getInt1Ty(LLVMContext &C)
bool isFloatTy() const
Return true if this is 'float', a 32-bit IEEE fp type.
Definition: Type.h:153
static Type * getX86_AMXTy(LLVMContext &C)
bool isBFloatTy() const
Return true if this is 'bfloat', a 16-bit bfloat type.
Definition: Type.h:145
static Type * getMetadataTy(LLVMContext &C)
@ X86_AMXTyID
AMX vectors (8192 bits, X86 specific)
Definition: Type.h:66
@ FunctionTyID
Functions.
Definition: Type.h:71
@ ArrayTyID
Arrays.
Definition: Type.h:74
@ TypedPointerTyID
Typed pointer used by some GPU targets.
Definition: Type.h:77
@ HalfTyID
16-bit floating point type
Definition: Type.h:56
@ TargetExtTyID
Target extension type.
Definition: Type.h:78
@ VoidTyID
type with no size
Definition: Type.h:63
@ ScalableVectorTyID
Scalable SIMD vector type.
Definition: Type.h:76
@ LabelTyID
Labels.
Definition: Type.h:64
@ FloatTyID
32-bit floating point type
Definition: Type.h:58
@ StructTyID
Structures.
Definition: Type.h:73
@ IntegerTyID
Arbitrary bit width integers.
Definition: Type.h:70
@ FixedVectorTyID
Fixed width SIMD vector type.
Definition: Type.h:75
@ BFloatTyID
16-bit floating point type (7-bit significand)
Definition: Type.h:57
@ DoubleTyID
64-bit floating point type
Definition: Type.h:59
@ X86_FP80TyID
80-bit floating point type (X87)
Definition: Type.h:60
@ PPC_FP128TyID
128-bit floating point type (two 64-bits, PowerPC)
Definition: Type.h:62
@ MetadataTyID
Metadata.
Definition: Type.h:65
@ TokenTyID
Tokens.
Definition: Type.h:67
@ PointerTyID
Pointers.
Definition: Type.h:72
@ FP128TyID
128-bit floating point type (112-bit significand)
Definition: Type.h:61
static Type * getVoidTy(LLVMContext &C)
static Type * getLabelTy(LLVMContext &C)
static Type * getFP128Ty(LLVMContext &C)
static IntegerType * getInt16Ty(LLVMContext &C)
bool isHalfTy() const
Return true if this is 'half', a 16-bit IEEE fp type.
Definition: Type.h:142
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
Definition: Type.h:128
static IntegerType * getInt8Ty(LLVMContext &C)
static IntegerType * getInt128Ty(LLVMContext &C)
bool isDoubleTy() const
Return true if this is 'double', a 64-bit IEEE fp type.
Definition: Type.h:156
static Type * getTokenTy(LLVMContext &C)
static IntegerType * getInt32Ty(LLVMContext &C)
static IntegerType * getInt64Ty(LLVMContext &C)
static Type * getFloatTy(LLVMContext &C)
static Type * getPPC_FP128Ty(LLVMContext &C)
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
Definition: Constants.cpp:1833
A Use represents the edge between a Value definition and its users.
Definition: Use.h:43
static ValueAsMetadata * get(Value *V)
Definition: Metadata.cpp:501
LLVM Value Representation.
Definition: Value.h:74
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:255
void setName(const Twine &Name)
Change the name of the value.
Definition: Value.cpp:377
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
Definition: Value.cpp:534
use_iterator_impl< Use > use_iterator
Definition: Value.h:353
LLVMContext & getContext() const
All values hold a context through their type.
Definition: Value.cpp:1075
StringRef getName() const
Return a constant reference to the value's name.
Definition: Value.cpp:309
An efficient, type-erasing, non-owning reference to a callable.
self_iterator getIterator()
Definition: ilist_node.h:132
FunctionPassManager manages FunctionPasses.
PassManager manages ModulePassManagers.
A raw_ostream that writes to a file descriptor.
Definition: raw_ostream.h:460
bool has_error() const
Return the value of the flag in this raw_fd_ostream indicating whether an output error has been encou...
Definition: raw_ostream.h:562
std::error_code error() const
Definition: raw_ostream.h:556
void close()
Manually flush the stream and close the file.
A raw_ostream that writes to an std::string.
Definition: raw_ostream.h:661
LLVMContextRef LLVMGetGlobalContext()
Obtain the global context instance.
Definition: Core.cpp:102
unsigned LLVMGetEnumAttributeKind(LLVMAttributeRef A)
Get the unique id corresponding to the enum attribute passed as argument.
Definition: Core.cpp:169
void LLVMContextSetDiscardValueNames(LLVMContextRef C, LLVMBool Discard)
Set whether the given context discards all value names.
Definition: Core.cpp:133
uint64_t LLVMGetEnumAttributeValue(LLVMAttributeRef A)
Get the enum attribute's value.
Definition: Core.cpp:173
LLVMTypeRef LLVMGetTypeAttributeValue(LLVMAttributeRef A)
Get the type attribute's value.
Definition: Core.cpp:187
unsigned LLVMGetMDKindIDInContext(LLVMContextRef C, const char *Name, unsigned SLen)
Definition: Core.cpp:141
LLVMDiagnosticSeverity LLVMGetDiagInfoSeverity(LLVMDiagnosticInfoRef DI)
Return an enum LLVMDiagnosticSeverity.
Definition: Core.cpp:251
char * LLVMGetDiagInfoDescription(LLVMDiagnosticInfoRef DI)
Return a string representation of the DiagnosticInfo.
Definition: Core.cpp:240
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:154
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:150
LLVMDiagnosticHandler LLVMContextGetDiagnosticHandler(LLVMContextRef C)
Get the diagnostic handler of this context.
Definition: Core.cpp:113
LLVMBool LLVMContextShouldDiscardValueNames(LLVMContextRef C)
Retrieve whether the given context is set to discard all value names.
Definition: Core.cpp:129
LLVMAttributeRef LLVMCreateTypeAttribute(LLVMContextRef C, unsigned KindID, LLVMTypeRef type_ref)
Create a type attribute.
Definition: Core.cpp:180
LLVMAttributeRef LLVMCreateStringAttribute(LLVMContextRef C, const char *K, unsigned KLength, const char *V, unsigned VLength)
Create a string attribute.
Definition: Core.cpp:206
LLVMAttributeRef LLVMCreateConstantRangeAttribute(LLVMContextRef C, unsigned KindID, unsigned NumBits, const uint64_t LowerWords[], const uint64_t UpperWords[])
Create a ConstantRange attribute.
Definition: Core.cpp:192
void LLVMContextDispose(LLVMContextRef C)
Destroy a context instance.
Definition: Core.cpp:137
LLVMAttributeRef LLVMCreateEnumAttribute(LLVMContextRef C, unsigned KindID, uint64_t Val)
Create an enum attribute.
Definition: Core.cpp:162
const char * LLVMGetStringAttributeKind(LLVMAttributeRef A, unsigned *Length)
Get the string attribute's kind.
Definition: Core.cpp:213
LLVMTypeRef LLVMGetTypeByName2(LLVMContextRef C, const char *Name)
Obtain a Type from a context by its registered name.
Definition: Core.cpp:851
LLVMContextRef LLVMContextCreate()
Create a new context.
Definition: Core.cpp:98
void(* LLVMYieldCallback)(LLVMContextRef, void *)
Definition: Core.h:565
unsigned LLVMGetLastEnumAttributeKind(void)
Definition: Core.cpp:158
LLVMBool LLVMIsStringAttribute(LLVMAttributeRef A)
Definition: Core.cpp:232
LLVMBool LLVMIsTypeAttribute(LLVMAttributeRef A)
Definition: Core.cpp:236
const char * LLVMGetStringAttributeValue(LLVMAttributeRef A, unsigned *Length)
Get the string attribute's value.
Definition: Core.cpp:220
void LLVMContextSetYieldCallback(LLVMContextRef C, LLVMYieldCallback Callback, void *OpaqueHandle)
Set the yield callback function for this context.
Definition: Core.cpp:122
unsigned LLVMGetMDKindID(const char *Name, unsigned SLen)
Definition: Core.cpp:146
void LLVMContextSetDiagnosticHandler(LLVMContextRef C, LLVMDiagnosticHandler Handler, void *DiagnosticContext)
Set the diagnostic handler for this context.
Definition: Core.cpp:104
void(* LLVMDiagnosticHandler)(LLVMDiagnosticInfoRef, void *)
Definition: Core.h:564
void * LLVMContextGetDiagnosticContext(LLVMContextRef C)
Get the diagnostic context of this context.
Definition: Core.cpp:118
LLVMBool LLVMIsEnumAttribute(LLVMAttributeRef A)
Check for the different types of attributes.
Definition: Core.cpp:227
LLVMValueRef LLVMBuildLoad2(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef PointerVal, const char *Name)
Definition: Core.cpp:3870
LLVMValueRef LLVMBuildGlobalStringPtr(LLVMBuilderRef B, const char *Str, const char *Name)
Definition: Core.cpp:4018
LLVMValueRef LLVMBuildFence(LLVMBuilderRef B, LLVMAtomicOrdering Ordering, LLVMBool isSingleThread, const char *Name)
Definition: Core.cpp:3965
LLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B, LLVMAtomicRMWBinOp op, LLVMValueRef PTR, LLVMValueRef Val, LLVMAtomicOrdering ordering, LLVMBool singleThread)
Definition: Core.cpp:4319
LLVMBool LLVMGetIsDisjoint(LLVMValueRef Inst)
Gets whether the instruction has the disjoint flag set.
Definition: Core.cpp:3801
LLVMValueRef LLVMBuildNot(LLVMBuilderRef B, LLVMValueRef V, const char *Name)
Definition: Core.cpp:3741
void LLVMSetAtomicSyncScopeID(LLVMValueRef AtomicInst, unsigned SSID)
Sets the synchronization scope ID of an atomic instruction.
Definition: Core.cpp:4408
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:3411
LLVMValueRef LLVMBuildNSWSub(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3608
LLVMValueRef LLVMBuildAnd(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3698
LLVMValueRef LLVMBuildFPExt(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:4130
void LLVMClearInsertionPosition(LLVMBuilderRef Builder)
Definition: Core.cpp:3283
LLVMValueRef LLVMBuildFDiv(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3663
void LLVMSetWeak(LLVMValueRef CmpXchgInst, LLVMBool isWeak)
Definition: Core.cpp:4049
void LLVMSetNSW(LLVMValueRef ArithInst, LLVMBool HasNSW)
Definition: Core.cpp:3760
LLVMValueRef LLVMBuildFreeze(LLVMBuilderRef B, LLVMValueRef Val, const char *Name)
Definition: Core.cpp:4297
LLVMValueRef LLVMBuildFAdd(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3598
LLVMValueRef LLVMBuildFMul(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3638
LLVMValueRef LLVMBuildZExt(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:4095
LLVMValueRef LLVMBuildSExt(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:4100
LLVMValueRef LLVMBuildTruncOrBitCast(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:4167
LLVMValueRef LLVMBuildSExtOrBitCast(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:4161
LLVMValueRef LLVMBuildBitCast(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:4145
void LLVMBuilderSetDefaultFPMathTag(LLVMBuilderRef Builder, LLVMMetadataRef FPMathTag)
Set the default floating-point math metadata for the given builder.
Definition: Core.cpp:3333
LLVMValueRef LLVMBuildExtractValue(LLVMBuilderRef B, LLVMValueRef AggVal, unsigned Index, const char *Name)
Definition: Core.cpp:4285
LLVMValueRef LLVMBuildFCmp(LLVMBuilderRef B, LLVMRealPredicate Op, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:4217
void LLVMSetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst, LLVMAtomicOrdering Ordering)
Definition: Core.cpp:4432
LLVMValueRef LLVMBuildAtomicCmpXchgSyncScope(LLVMBuilderRef B, LLVMValueRef Ptr, LLVMValueRef Cmp, LLVMValueRef New, LLVMAtomicOrdering SuccessOrdering, LLVMAtomicOrdering FailureOrdering, unsigned SSID)
Definition: Core.cpp:4354
LLVMValueRef LLVMBuildFPTrunc(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:4125
LLVMAtomicOrdering LLVMGetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst)
Definition: Core.cpp:4427
LLVMOpcode LLVMGetCastOpcode(LLVMValueRef Src, LLVMBool SrcIsSigned, LLVMTypeRef DestTy, LLVMBool DestIsSigned)
Definition: Core.cpp:4202
LLVMAtomicRMWBinOp LLVMGetAtomicRMWBinOp(LLVMValueRef Inst)
Definition: Core.cpp:4080
void LLVMSetNUW(LLVMValueRef ArithInst, LLVMBool HasNUW)
Definition: Core.cpp:3750
LLVMValueRef LLVMBuildSIToFP(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:4120
LLVMValueRef LLVMBuildShl(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3683
void LLVMSetCurrentDebugLocation2(LLVMBuilderRef Builder, LLVMMetadataRef Loc)
Set location information used by debugging information.
Definition: Core.cpp:3306
int LLVMGetUndefMaskElem(void)
Definition: Core.cpp:4377
LLVMBool LLVMGetWeak(LLVMValueRef CmpXchgInst)
Definition: Core.cpp:4045
LLVMValueRef LLVMBuildFRem(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3678
LLVMValueRef LLVMBuildAlloca(LLVMBuilderRef B, LLVMTypeRef Ty, const char *Name)
Definition: Core.cpp:3856
LLVMValueRef LLVMBuildSelect(LLVMBuilderRef B, LLVMValueRef If, LLVMValueRef Then, LLVMValueRef Else, const char *Name)
Definition: Core.cpp:4253
LLVMValueRef LLVMBuildCatchPad(LLVMBuilderRef B, LLVMValueRef ParentPad, LLVMValueRef *Args, unsigned NumArgs, const char *Name)
Definition: Core.cpp:3437
void LLVMSetIsDisjoint(LLVMValueRef Inst, LLVMBool IsDisjoint)
Sets the disjoint flag for the instruction.
Definition: Core.cpp:3806
LLVMValueRef LLVMBuildMul(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3623
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:3256
LLVMValueRef LLVMBuildExactSDiv(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3658
LLVMValueRef LLVMBuildNUWSub(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3613
LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef B, LLVMTypeRef Ty, const char *Name)
Definition: Core.cpp:3813
LLVMValueRef LLVMBuildIsNull(LLVMBuilderRef B, LLVMValueRef Val, const char *Name)
Definition: Core.cpp:4302
LLVMValueRef LLVMBuildLandingPad(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef PersFn, unsigned NumClauses, const char *Name)
Definition: Core.cpp:3425
LLVMValueRef LLVMBuildAggregateRet(LLVMBuilderRef B, LLVMValueRef *RetVals, unsigned N)
Definition: Core.cpp:3359
LLVMValueRef LLVMBuildAShr(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3693
LLVMValueRef LLVMBuildInvoke2(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Fn, LLVMValueRef *Args, unsigned NumArgs, LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch, const char *Name)
Definition: Core.cpp:3402
LLVMValueRef LLVMBuildCallWithOperandBundles(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Fn, LLVMValueRef *Args, unsigned NumArgs, LLVMOperandBundleRef *Bundles, unsigned NumBundles, const char *Name)
Definition: Core.cpp:4239
LLVMValueRef LLVMBuildExactUDiv(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3648
void LLVMSetOrdering(LLVMValueRef MemAccessInst, LLVMAtomicOrdering Ordering)
Definition: Core.cpp:4067
void LLVMSetCleanup(LLVMValueRef LandingPad, LLVMBool Val)
Definition: Core.cpp:3511
LLVMValueRef LLVMGetArgOperand(LLVMValueRef Funclet, unsigned i)
Definition: Core.cpp:3540
unsigned LLVMGetAtomicSyncScopeID(LLVMValueRef AtomicInst)
Returns the synchronization scope ID of an atomic instruction.
Definition: Core.cpp:4402
LLVMValueRef LLVMBuildInsertValue(LLVMBuilderRef B, LLVMValueRef AggVal, LLVMValueRef EltVal, unsigned Index, const char *Name)
Definition: Core.cpp:4290
LLVMValueRef LLVMBuildAdd(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3583
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:3831
LLVMValueRef LLVMBuildBr(LLVMBuilderRef B, LLVMBasicBlockRef Dest)
Definition: Core.cpp:3364
LLVMValueRef LLVMBuildNSWMul(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3628
LLVMValueRef LLVMBuildBinOp(LLVMBuilderRef B, LLVMOpcode Op, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3713
LLVMValueRef LLVMBuildSRem(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3673
void LLVMDisposeBuilder(LLVMBuilderRef Builder)
Definition: Core.cpp:3296
int LLVMGetMaskValue(LLVMValueRef SVInst, unsigned Elt)
Get the mask value at position Elt in the mask of a ShuffleVector instruction.
Definition: Core.cpp:4371
LLVMValueRef LLVMBuildFSub(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3618
LLVMValueRef LLVMGetClause(LLVMValueRef LandingPad, unsigned Idx)
Definition: Core.cpp:3499
LLVMMetadataRef LLVMGetCurrentDebugLocation2(LLVMBuilderRef Builder)
Get location information used by debugging information.
Definition: Core.cpp:3302
LLVMValueRef LLVMBuildArrayAlloca(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Val, const char *Name)
Definition: Core.cpp:3861
LLVMValueRef LLVMBuildVAArg(LLVMBuilderRef B, LLVMValueRef List, LLVMTypeRef Ty, const char *Name)
Definition: Core.cpp:4260
LLVMBuilderRef LLVMCreateBuilderInContext(LLVMContextRef C)
Definition: Core.cpp:3235
LLVMValueRef LLVMBuildAtomicCmpXchg(LLVMBuilderRef B, LLVMValueRef Ptr, LLVMValueRef Cmp, LLVMValueRef New, LLVMAtomicOrdering SuccessOrdering, LLVMAtomicOrdering FailureOrdering, LLVMBool singleThread)
Definition: Core.cpp:4341
LLVMValueRef LLVMBuildICmp(LLVMBuilderRef B, LLVMIntPredicate Op, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:4210
LLVMValueRef LLVMBuildPointerCast(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:4179
LLVMValueRef LLVMGetParentCatchSwitch(LLVMValueRef CatchPad)
Get the parent catchswitch instruction of a catchpad instruction.
Definition: Core.cpp:3529
void LLVMSetAtomicSingleThread(LLVMValueRef AtomicInst, LLVMBool NewValue)
Definition: Core.cpp:4392
LLVMValueRef LLVMBuildCast(LLVMBuilderRef B, LLVMOpcode Op, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:4173
LLVMValueRef LLVMBuildTrunc(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:4090
LLVMValueRef LLVMBuildURem(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3668
void LLVMSetAtomicRMWBinOp(LLVMValueRef Inst, LLVMAtomicRMWBinOp BinOp)
Definition: Core.cpp:4084
LLVMValueRef LLVMBuildCall2(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Fn, LLVMValueRef *Args, unsigned NumArgs, const char *Name)
Definition: Core.cpp:4230
void LLVMAddClause(LLVMValueRef LandingPad, LLVMValueRef ClauseVal)
Definition: Core.cpp:3503
LLVMValueRef LLVMBuildOr(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3703
LLVMBool LLVMGetNUW(LLVMValueRef ArithInst)
Definition: Core.cpp:3745
LLVMValueRef LLVMBuildAddrSpaceCast(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:4150
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:3383
LLVMValueRef LLVMBuildFPToUI(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:4105
void LLVMSetCurrentDebugLocation(LLVMBuilderRef Builder, LLVMValueRef L)
Deprecated: Passing the NULL location will crash.
Definition: Core.cpp:3313
LLVMValueRef LLVMBuildFPToSI(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:4110
LLVMBool LLVMIsAtomic(LLVMValueRef Inst)
Returns whether an instruction is an atomic instruction, e.g., atomicrmw, cmpxchg,...
Definition: Core.cpp:4379
LLVMValueRef LLVMBuildIntCast2(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, LLVMBool IsSigned, const char *Name)
Definition: Core.cpp:4184
LLVMValueRef LLVMBuildNSWAdd(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3588
LLVMValueRef LLVMBuildFNeg(LLVMBuilderRef B, LLVMValueRef V, const char *Name)
Definition: Core.cpp:3737
LLVMMetadataRef LLVMBuilderGetDefaultFPMathTag(LLVMBuilderRef Builder)
Get the dafult floating-point math metadata for a given builder.
Definition: Core.cpp:3345
LLVMValueRef LLVMBuildAtomicRMWSyncScope(LLVMBuilderRef B, LLVMAtomicRMWBinOp op, LLVMValueRef PTR, LLVMValueRef Val, LLVMAtomicOrdering ordering, unsigned SSID)
Definition: Core.cpp:4330
LLVMValueRef LLVMBuildUDiv(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3643
void LLVMSetParentCatchSwitch(LLVMValueRef CatchPad, LLVMValueRef CatchSwitch)
Set the parent catchswitch instruction of a catchpad instruction.
Definition: Core.cpp:3533
LLVMValueRef LLVMBuildCatchRet(LLVMBuilderRef B, LLVMValueRef CatchPad, LLVMBasicBlockRef BB)
Definition: Core.cpp:3470
LLVMValueRef LLVMBuildStructGEP2(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Pointer, unsigned Idx, const char *Name)
Definition: Core.cpp:4006
unsigned LLVMGetNumClauses(LLVMValueRef LandingPad)
Definition: Core.cpp:3495
LLVMBool LLVMGetNNeg(LLVMValueRef NonNegInst)
Gets if the instruction has the non-negative flag set.
Definition: Core.cpp:3775
LLVMValueRef LLVMBuildSDiv(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3653
LLVMValueRef LLVMBuildStore(LLVMBuilderRef B, LLVMValueRef Val, LLVMValueRef PointerVal)
Definition: Core.cpp:3875
LLVMValueRef LLVMBuildCatchSwitch(LLVMBuilderRef B, LLVMValueRef ParentPad, LLVMBasicBlockRef UnwindBB, unsigned NumHandlers, const char *Name)
Definition: Core.cpp:3459
LLVMValueRef LLVMBuildFenceSyncScope(LLVMBuilderRef B, LLVMAtomicOrdering Ordering, unsigned SSID, const char *Name)
Definition: Core.cpp:3974
LLVMValueRef LLVMBuildIntCast(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Deprecated: This cast is always signed.
Definition: Core.cpp:4191
LLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Val, const char *Name)
Definition: Core.cpp:3822
LLVMValueRef LLVMBuildZExtOrBitCast(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:4155
LLVMValueRef LLVMBuildInBoundsGEP2(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Pointer, LLVMValueRef *Indices, unsigned NumIndices, const char *Name)
Definition: Core.cpp:3988
void LLVMGetHandlers(LLVMValueRef CatchSwitch, LLVMBasicBlockRef *Handlers)
Obtain the basic blocks acting as handlers for a catchswitch instruction.
Definition: Core.cpp:3523
LLVMAtomicOrdering LLVMGetOrdering(LLVMValueRef MemAccessInst)
Definition: Core.cpp:4053
LLVMValueRef LLVMBuildUIToFP(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:4115
LLVMValueRef LLVMBuildIntToPtr(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:4140
LLVMValueRef LLVMBuildCondBr(LLVMBuilderRef B, LLVMValueRef If, LLVMBasicBlockRef Then, LLVMBasicBlockRef Else)
Definition: Core.cpp:3368
LLVMValueRef LLVMBuildIndirectBr(LLVMBuilderRef B, LLVMValueRef Addr, unsigned NumDests)
Definition: Core.cpp:3378
void LLVMAddDestination(LLVMValueRef IndirectBr, LLVMBasicBlockRef Dest)
Definition: Core.cpp:3491
LLVMValueRef LLVMBuildNSWNeg(LLVMBuilderRef B, LLVMValueRef V, const char *Name)
Definition: Core.cpp:3724
LLVMValueRef LLVMBuildXor(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3708
LLVMValueRef LLVMBuildGlobalString(LLVMBuilderRef B, const char *Str, const char *Name)
Definition: Core.cpp:4013
LLVMBool LLVMGetExact(LLVMValueRef DivOrShrInst)
Definition: Core.cpp:3765
LLVMValueRef LLVMBuildIsNotNull(LLVMBuilderRef B, LLVMValueRef Val, const char *Name)
Definition: Core.cpp:4307
void LLVMSetArgOperand(LLVMValueRef Funclet, unsigned i, LLVMValueRef value)
Definition: Core.cpp:3544
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:3838
LLVMValueRef LLVMBuildPtrDiff2(LLVMBuilderRef B, LLVMTypeRef ElemTy, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:4312
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:3325
void LLVMAddMetadataToInst(LLVMBuilderRef Builder, LLVMValueRef Inst)
Adds the metadata registered with the given builder to the given instruction.
Definition: Core.cpp:3329
LLVMValueRef LLVMBuildSub(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3603
LLVMValueRef LLVMBuildNUWAdd(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3593
LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef B)
Definition: Core.cpp:3482
LLVMValueRef LLVMBuildShuffleVector(LLVMBuilderRef B, LLVMValueRef V1, LLVMValueRef V2, LLVMValueRef Mask, const char *Name)
Definition: Core.cpp:4278
void LLVMSetVolatile(LLVMValueRef MemAccessInst, LLVMBool isVolatile)
Definition: Core.cpp:4034
LLVMValueRef LLVMBuildFree(LLVMBuilderRef B, LLVMValueRef PointerVal)
Definition: Core.cpp:3866
LLVMValueRef LLVMBuildGEP2(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Pointer, LLVMValueRef *Indices, unsigned NumIndices, const char *Name)
Definition: Core.cpp:3981
unsigned LLVMGetNumHandlers(LLVMValueRef CatchSwitch)
Definition: Core.cpp:3519
LLVMValueRef LLVMBuildFPCast(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:4197
LLVMBuilderRef LLVMCreateBuilder(void)
Definition: Core.cpp:3239
void LLVMSetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst, LLVMAtomicOrdering Ordering)
Definition: Core.cpp:4419
LLVMValueRef LLVMBuildPhi(LLVMBuilderRef B, LLVMTypeRef Ty, const char *Name)
Definition: Core.cpp:4226
LLVMBool LLVMCanValueUseFastMathFlags(LLVMValueRef V)
Check if a given value can potentially have fast math flags.
Definition: Core.cpp:3796
void LLVMAddCase(LLVMValueRef Switch, LLVMValueRef OnVal, LLVMBasicBlockRef Dest)
Definition: Core.cpp:3486
LLVMBool LLVMIsAtomicSingleThread(LLVMValueRef AtomicInst)
Definition: Core.cpp:4383
LLVMValueRef LLVMBuildResume(LLVMBuilderRef B, LLVMValueRef Exn)
Definition: Core.cpp:3455
LLVMValueRef LLVMBuildSwitch(LLVMBuilderRef B, LLVMValueRef V, LLVMBasicBlockRef Else, unsigned NumCases)
Definition: Core.cpp:3373
void LLVMInsertIntoBuilder(LLVMBuilderRef Builder, LLVMValueRef Instr)
Definition: Core.cpp:3287
LLVMValueRef LLVMBuildPtrToInt(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:4135
LLVMBool LLVMIsCleanup(LLVMValueRef LandingPad)
Definition: Core.cpp:3507
LLVMBool LLVMGetNSW(LLVMValueRef ArithInst)
Definition: Core.cpp:3755
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:3847
LLVMValueRef LLVMBuildLShr(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3688
unsigned LLVMGetNumMaskElements(LLVMValueRef SVInst)
Get the number of elements in the mask of a ShuffleVector instruction.
Definition: Core.cpp:4365
LLVMValueRef LLVMBuildRetVoid(LLVMBuilderRef B)
Definition: Core.cpp:3351
LLVMValueRef LLVMBuildRet(LLVMBuilderRef B, LLVMValueRef V)
Definition: Core.cpp:3355
void LLVMAddHandler(LLVMValueRef CatchSwitch, LLVMBasicBlockRef Dest)
Definition: Core.cpp:3515
void LLVMPositionBuilderBeforeInstrAndDbgRecords(LLVMBuilderRef Builder, LLVMValueRef Instr)
Set the builder position before Instr and any attached debug records.
Definition: Core.cpp:3268
LLVMValueRef LLVMBuildExtractElement(LLVMBuilderRef B, LLVMValueRef VecVal, LLVMValueRef Index, const char *Name)
Definition: Core.cpp:4265
void LLVMPositionBuilderBefore(LLVMBuilderRef Builder, LLVMValueRef Instr)
Set the builder position before Instr but after any attached debug records.
Definition: Core.cpp:3263
LLVMValueRef LLVMGetCurrentDebugLocation(LLVMBuilderRef Builder)
Deprecated: Returning the NULL location will crash.
Definition: Core.cpp:3319
LLVMAtomicOrdering LLVMGetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst)
Definition: Core.cpp:4414
void LLVMSetNNeg(LLVMValueRef NonNegInst, LLVMBool IsNonNeg)
Sets the non-negative flag for the instruction.
Definition: Core.cpp:3780
LLVMContextRef LLVMGetBuilderContext(LLVMBuilderRef Builder)
Obtain the context to which this builder is associated.
Definition: Core.cpp:3341
void LLVMSetExact(LLVMValueRef DivOrShrInst, LLVMBool IsExact)
Definition: Core.cpp:3770
LLVMBasicBlockRef LLVMGetInsertBlock(LLVMBuilderRef Builder)
Definition: Core.cpp:3279
LLVMValueRef LLVMBuildCleanupPad(LLVMBuilderRef B, LLVMValueRef ParentPad, LLVMValueRef *Args, unsigned NumArgs, const char *Name)
Definition: Core.cpp:3444
void LLVMInsertIntoBuilderWithName(LLVMBuilderRef Builder, LLVMValueRef Instr, const char *Name)
Definition: Core.cpp:3291
void LLVMSetFastMathFlags(LLVMValueRef FPMathInst, LLVMFastMathFlags FMF)
Sets the flags for which fast-math-style optimizations are allowed for this value.
Definition: Core.cpp:3791
LLVMValueRef LLVMBuildGEPWithNoWrapFlags(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Pointer, LLVMValueRef *Indices, unsigned NumIndices, const char *Name, LLVMGEPNoWrapFlags NoWrapFlags)
Creates a GetElementPtr instruction.
Definition: Core.cpp:3996
LLVMFastMathFlags LLVMGetFastMathFlags(LLVMValueRef FPMathInst)
Get the flags for which fast-math-style optimizations are allowed for this value.
Definition: Core.cpp:3785
LLVMValueRef LLVMBuildNeg(LLVMBuilderRef B, LLVMValueRef V, const char *Name)
Definition: Core.cpp:3720
LLVMBool LLVMGetVolatile(LLVMValueRef MemAccessInst)
Definition: Core.cpp:4023
LLVMValueRef LLVMBuildNUWMul(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3633
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:3250
void LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder, LLVMBasicBlockRef Block)
Definition: Core.cpp:3274
LLVMValueRef LLVMBuildInsertElement(LLVMBuilderRef B, LLVMValueRef VecVal, LLVMValueRef EltVal, LLVMValueRef Index, const char *Name)
Definition: Core.cpp:4271
LLVMValueRef LLVMBuildCleanupRet(LLVMBuilderRef B, LLVMValueRef CatchPad, LLVMBasicBlockRef BB)
Definition: Core.cpp:3476
void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf)
Definition: Core.cpp:4508
size_t LLVMGetBufferSize(LLVMMemoryBufferRef MemBuf)
Definition: Core.cpp:4504
LLVMBool LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef *OutMemBuf, char **OutMessage)
Definition: Core.cpp:4468
LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRange(const char *InputData, size_t InputDataLength, const char *BufferName, LLVMBool RequiresNullTerminator)
Definition: Core.cpp:4479
LLVMBool LLVMCreateMemoryBufferWithContentsOfFile(const char *Path, LLVMMemoryBufferRef *OutMemBuf, char **OutMessage)
Definition: Core.cpp:4454
const char * LLVMGetBufferStart(LLVMMemoryBufferRef MemBuf)
Definition: Core.cpp:4500
LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRangeCopy(const char *InputData, size_t InputDataLength, const char *BufferName)
Definition: Core.cpp:4490
LLVMModuleProviderRef LLVMCreateModuleProviderForExistingModule(LLVMModuleRef M)
Changes the type of M so it can be passed to FunctionPassManagers and the JIT.
Definition: Core.cpp:4443
void LLVMDisposeModuleProvider(LLVMModuleProviderRef MP)
Destroys the module M.
Definition: Core.cpp:4447
const char * LLVMGetModuleIdentifier(LLVMModuleRef M, size_t *Len)
Obtain the identifier of a module.
Definition: Core.cpp:287
void LLVMSetDataLayout(LLVMModuleRef M, const char *DataLayoutStr)
Set the data layout for a module.
Definition: Core.cpp:316
LLVMValueRef LLVMAddFunction(LLVMModuleRef M, const char *Name, LLVMTypeRef FunctionTy)
Add a function to a module under a specified name.
Definition: Core.cpp:2388
LLVMBool LLVMIsNewDbgInfoFormat(LLVMModuleRef M)
Soon to be deprecated.
Definition: Core.cpp:432
LLVMNamedMDNodeRef LLVMGetPreviousNamedMetadata(LLVMNamedMDNodeRef NMD)
Decrement a NamedMDNode iterator to the previous NamedMDNode.
Definition: Core.cpp:1385
LLVMValueRef LLVMGetNamedFunctionWithLength(LLVMModuleRef M, const char *Name, size_t Length)
Obtain a Function value from a Module by its name.
Definition: Core.cpp:2398
LLVMTypeRef LLVMGetTypeByName(LLVMModuleRef M, const char *Name)
Deprecated: Use LLVMGetTypeByName2 instead.
Definition: Core.cpp:847
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:303
void LLVMDumpModule(LLVMModuleRef M)
Dump a representation of a module to stderr.
Definition: Core.cpp:442
void LLVMAppendModuleInlineAsm(LLVMModuleRef M, const char *Asm, size_t Len)
Append inline assembly to a module.
Definition: Core.cpp:488
LLVMValueRef LLVMGetFirstFunction(LLVMModuleRef M)
Obtain an iterator to the first Function in a Module.
Definition: Core.cpp:2403
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:1480
LLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename, char **ErrorMessage)
Print a representation of a module to a file.
Definition: Core.cpp:447
void LLVMDisposeModule(LLVMModuleRef M)
Destroy a module instance.
Definition: Core.cpp:283
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:498
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:1456
const char * LLVMGetModuleInlineAsm(LLVMModuleRef M, size_t *Len)
Get inline assembly for a module.
Definition: Core.cpp:492
const char * LLVMGetSourceFileName(LLVMModuleRef M, size_t *Len)
Obtain the module's original source file name.
Definition: Core.cpp:297
const char * LLVMGetNamedMetadataName(LLVMNamedMDNodeRef NMD, size_t *NameLen)
Retrieve the name of a NamedMDNode.
Definition: Core.cpp:1403
LLVMContextRef LLVMGetModuleContext(LLVMModuleRef M)
Obtain the context to which this module is associated.
Definition: Core.cpp:574
const char * LLVMGetInlineAsmConstraintString(LLVMValueRef InlineAsmVal, size_t *Len)
Get the raw constraint string for an inline assembly snippet.
Definition: Core.cpp:527
LLVMModuleRef LLVMModuleCreateWithNameInContext(const char *ModuleID, LLVMContextRef C)
Create a new, empty module in a specific context.
Definition: Core.cpp:278
LLVMMetadataRef LLVMModuleFlagEntriesGetMetadata(LLVMModuleFlagEntry *Entries, unsigned Index)
Returns the metadata for a module flag entry at a specific index.
Definition: Core.cpp:413
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:405
LLVMValueRef LLVMGetLastFunction(LLVMModuleRef M)
Obtain an iterator to the last Function in a Module.
Definition: Core.cpp:2411
void LLVMSetTarget(LLVMModuleRef M, const char *Triple)
Set the target triple for a module.
Definition: Core.cpp:325
const char * LLVMGetDataLayoutStr(LLVMModuleRef M)
Obtain the data layout for a module.
Definition: Core.cpp:308
const char * LLVMGetInlineAsmAsmString(LLVMValueRef InlineAsmVal, size_t *Len)
Get the template string used for an inline assembly snippet.
Definition: Core.cpp:518
LLVMModuleFlagBehavior LLVMModuleFlagEntriesGetFlagBehavior(LLVMModuleFlagEntry *Entries, unsigned Index)
Returns the flag behavior for a module flag entry at a specific index.
Definition: Core.cpp:398
unsigned LLVMGetDebugLocColumn(LLVMValueRef Val)
Return the column number of the debug location for this value, which must be an llvm::Instruction.
Definition: Core.cpp:1526
unsigned LLVMGetDebugLocLine(LLVMValueRef Val)
Return the line number of the debug location for this value, which must be an llvm::Instruction,...
Definition: Core.cpp:1504
LLVMBool LLVMGetInlineAsmNeedsAlignedStack(LLVMValueRef InlineAsmVal)
Get if the inline asm snippet needs an aligned stack.
Definition: Core.cpp:563
LLVMModuleRef LLVMModuleCreateWithName(const char *ModuleID)
Create a new, empty module in the global context.
Definition: Core.cpp:274
LLVMModuleFlagEntry * LLVMCopyModuleFlagsMetadata(LLVMModuleRef M, size_t *Len)
Returns the module flags as an array of flag-key-value triples.
Definition: Core.cpp:376
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:425
void LLVMSetModuleInlineAsm(LLVMModuleRef M, const char *Asm)
Deprecated: Use LLVMSetModuleInlineAsm2 instead.
Definition: Core.cpp:484
LLVMBool LLVMGetInlineAsmHasSideEffects(LLVMValueRef InlineAsmVal)
Get if the inline asm snippet has side effects.
Definition: Core.cpp:558
void LLVMDisposeModuleFlagsMetadata(LLVMModuleFlagEntry *Entries)
Destroys module flags metadata entries.
Definition: Core.cpp:393
LLVMInlineAsmDialect LLVMGetInlineAsmDialect(LLVMValueRef InlineAsmVal)
Get the dialect used by the inline asm snippet.
Definition: Core.cpp:537
unsigned LLVMGetNamedMetadataNumOperands(LLVMModuleRef M, const char *Name)
Obtain the number of operands for named metadata in a module.
Definition: Core.cpp:1429
const char * LLVMGetTarget(LLVMModuleRef M)
Obtain the target triple for a module.
Definition: Core.cpp:321
LLVMNamedMDNodeRef LLVMGetNextNamedMetadata(LLVMNamedMDNodeRef NMD)
Advance a NamedMDNode iterator to the next NamedMDNode.
Definition: Core.cpp:1377
void LLVMSetModuleInlineAsm2(LLVMModuleRef M, const char *Asm, size_t Len)
Set inline assembly for a module.
Definition: Core.cpp:480
LLVMNamedMDNodeRef LLVMGetLastNamedMetadata(LLVMModuleRef M)
Obtain an iterator to the last NamedMDNode in a Module.
Definition: Core.cpp:1369
LLVMBool LLVMGetInlineAsmCanUnwind(LLVMValueRef InlineAsmVal)
Get if the inline asm snippet may unwind the stack.
Definition: Core.cpp:568
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:420
const char * LLVMGetDataLayout(LLVMModuleRef M)
Definition: Core.cpp:312
LLVMValueRef LLVMGetNamedFunction(LLVMModuleRef M, const char *Name)
Obtain a Function value from a Module by its name.
Definition: Core.cpp:2394
void LLVMSetIsNewDbgInfoFormat(LLVMModuleRef M, LLVMBool UseNewFormat)
Soon to be deprecated.
Definition: Core.cpp:436
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:1393
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:1398
LLVMValueRef LLVMGetPreviousFunction(LLVMValueRef Fn)
Decrement a Function iterator to the previous Function.
Definition: Core.cpp:2427
char * LLVMPrintModuleToString(LLVMModuleRef M)
Return a string representation of the module.
Definition: Core.cpp:469
void LLVMGetNamedMetadataOperands(LLVMModuleRef M, const char *Name, LLVMValueRef *Dest)
Obtain the named metadata operands for a module.
Definition: Core.cpp:1436
LLVMValueRef LLVMGetNextFunction(LLVMValueRef Fn)
Advance a Function iterator to the next Function.
Definition: Core.cpp:2419
LLVMTypeRef LLVMGetInlineAsmFunctionType(LLVMValueRef InlineAsmVal)
Get the function type of the inline assembly snippet.
Definition: Core.cpp:553
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:293
void LLVMAddNamedMetadataOperand(LLVMModuleRef M, const char *Name, LLVMValueRef Val)
Add an operand to named metadata.
Definition: Core.cpp:1446
LLVMNamedMDNodeRef LLVMGetFirstNamedMetadata(LLVMModuleRef M)
Obtain an iterator to the first NamedMDNode in a Module.
Definition: Core.cpp:1361
LLVMValueRef LLVMGetOperandBundleArgAtIndex(LLVMOperandBundleRef Bundle, unsigned Index)
Obtain the operand for an operand bundle at the given index.
Definition: Core.cpp:2765
unsigned LLVMGetNumOperandBundleArgs(LLVMOperandBundleRef Bundle)
Obtain the number of operands for an operand bundle.
Definition: Core.cpp:2761
LLVMOperandBundleRef LLVMCreateOperandBundle(const char *Tag, size_t TagLen, LLVMValueRef *Args, unsigned NumArgs)
Create a new operand bundle.
Definition: Core.cpp:2744
void LLVMDisposeOperandBundle(LLVMOperandBundleRef Bundle)
Destroy an operand bundle.
Definition: Core.cpp:2751
const char * LLVMGetOperandBundleTag(LLVMOperandBundleRef Bundle, size_t *Len)
Obtain the tag of an operand bundle as a string.
Definition: Core.cpp:2755
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:4527
LLVMPassManagerRef LLVMCreateFunctionPassManager(LLVMModuleProviderRef P)
Deprecated: Use LLVMCreateFunctionPassManagerForModule instead.
Definition: Core.cpp:4522
LLVMPassManagerRef LLVMCreatePassManager()
Constructs a new whole-module pass pipeline.
Definition: Core.cpp:4514
void LLVMDisposePassManager(LLVMPassManagerRef PM)
Frees the memory of a pass pipeline.
Definition: Core.cpp:4543
LLVMBool LLVMFinalizeFunctionPassManager(LLVMPassManagerRef FPM)
Finalizes all of the function passes scheduled in the function pass manager.
Definition: Core.cpp:4539
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:4535
LLVMBool LLVMInitializeFunctionPassManager(LLVMPassManagerRef FPM)
Initializes all of the function passes scheduled in the function pass manager.
Definition: Core.cpp:4531
LLVMPassManagerRef LLVMCreateFunctionPassManagerForModule(LLVMModuleRef M)
Constructs a new function-by-function pass pipeline over the module provider.
Definition: Core.cpp:4518
LLVMBool LLVMIsMultithreaded()
Check whether LLVM is executing in thread-safe mode or not.
Definition: Core.cpp:4556
LLVMBool LLVMStartMultithreaded()
Deprecated: Multi-threading can only be enabled/disabled with the compile time define LLVM_ENABLE_THR...
Definition: Core.cpp:4549
void LLVMStopMultithreaded()
Deprecated: Multi-threading can only be enabled/disabled with the compile time define LLVM_ENABLE_THR...
Definition: Core.cpp:4553
LLVMTypeRef LLVMFP128Type(void)
Definition: Core.cpp:750
LLVMTypeRef LLVMFP128TypeInContext(LLVMContextRef C)
Obtain a 128-bit floating point type (112-bit mantissa) from a context.
Definition: Core.cpp:725
LLVMTypeRef LLVMDoubleTypeInContext(LLVMContextRef C)
Obtain a 64-bit floating point type from a context.
Definition: Core.cpp:719
LLVMTypeRef LLVMX86FP80TypeInContext(LLVMContextRef C)
Obtain a 80-bit floating point type (X87) from a context.
Definition: Core.cpp:722
LLVMTypeRef LLVMHalfTypeInContext(LLVMContextRef C)
Obtain a 16-bit floating point type from a context.
Definition: Core.cpp:710
LLVMTypeRef LLVMBFloatTypeInContext(LLVMContextRef C)
Obtain a 16-bit brain floating point type from a context.
Definition: Core.cpp:713
LLVMTypeRef LLVMBFloatType(void)
Definition: Core.cpp:738
LLVMTypeRef LLVMFloatTypeInContext(LLVMContextRef C)
Obtain a 32-bit floating point type from a context.
Definition: Core.cpp:716
LLVMTypeRef LLVMHalfType(void)
Obtain a floating point type from the global context.
Definition: Core.cpp:735
LLVMTypeRef LLVMX86FP80Type(void)
Definition: Core.cpp:747
LLVMTypeRef LLVMPPCFP128Type(void)
Definition: Core.cpp:753
LLVMTypeRef LLVMFloatType(void)
Definition: Core.cpp:741
LLVMTypeRef LLVMDoubleType(void)
Definition: Core.cpp:744
LLVMTypeRef LLVMPPCFP128TypeInContext(LLVMContextRef C)
Obtain a 128-bit floating point type (two 64-bits) from a context.
Definition: Core.cpp:728
LLVMBool LLVMIsFunctionVarArg(LLVMTypeRef FunctionTy)
Returns whether a function type is variadic.
Definition: Core.cpp:769
unsigned LLVMCountParamTypes(LLVMTypeRef FunctionTy)
Obtain the number of parameters this function accepts.
Definition: Core.cpp:777
void LLVMGetParamTypes(LLVMTypeRef FunctionTy, LLVMTypeRef *Dest)
Obtain the types of a function's parameters.
Definition: Core.cpp:781
LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType, LLVMTypeRef *ParamTypes, unsigned ParamCount, LLVMBool IsVarArg)
Obtain a function type consisting of a specified signature.
Definition: Core.cpp:762
LLVMTypeRef LLVMGetReturnType(LLVMTypeRef FunctionTy)
Obtain the Type this function Type returns.
Definition: Core.cpp:773
LLVMTypeRef LLVMInt64Type(void)
Definition: Core.cpp:694
LLVMTypeRef LLVMInt64TypeInContext(LLVMContextRef C)
Definition: Core.cpp:672
LLVMTypeRef LLVMInt16TypeInContext(LLVMContextRef C)
Definition: Core.cpp:666
LLVMTypeRef LLVMIntTypeInContext(LLVMContextRef C, unsigned NumBits)
Definition: Core.cpp:678
LLVMTypeRef LLVMInt1TypeInContext(LLVMContextRef C)
Obtain an integer type from a context with specified bit width.
Definition: Core.cpp:660
LLVMTypeRef LLVMInt32Type(void)
Definition: Core.cpp:691
LLVMTypeRef LLVMInt32TypeInContext(LLVMContextRef C)
Definition: Core.cpp:669
LLVMTypeRef LLVMInt128TypeInContext(LLVMContextRef C)
Definition: Core.cpp:675
LLVMTypeRef LLVMIntType(unsigned NumBits)
Definition: Core.cpp:700
LLVMTypeRef LLVMInt8TypeInContext(LLVMContextRef C)
Definition: Core.cpp:663
LLVMTypeRef LLVMInt8Type(void)
Definition: Core.cpp:685
LLVMTypeRef LLVMInt1Type(void)
Obtain an integer type from the global context with a specified bit width.
Definition: Core.cpp:682
LLVMTypeRef LLVMInt128Type(void)
Definition: Core.cpp:697
unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy)
Definition: Core.cpp:704
LLVMTypeRef LLVMInt16Type(void)
Definition: Core.cpp:688
LLVMTypeRef LLVMVoidType(void)
These are similar to the above functions except they operate on the global context.
Definition: Core.cpp:952
const char * LLVMGetTargetExtTypeName(LLVMTypeRef TargetExtTy)
Obtain the name for this target extension type.
Definition: Core.cpp:970
LLVMTypeRef LLVMGetTargetExtTypeTypeParam(LLVMTypeRef TargetExtTy, unsigned Idx)
Get the type parameter at the given index for the target extension type.
Definition: Core.cpp:980
unsigned LLVMGetTargetExtTypeNumTypeParams(LLVMTypeRef TargetExtTy)
Obtain the number of type parameters for this target extension type.
Definition: Core.cpp:975
LLVMTypeRef LLVMX86AMXTypeInContext(LLVMContextRef C)
Create a X86 AMX type in a context.
Definition: Core.cpp:731
LLVMTypeRef LLVMMetadataTypeInContext(LLVMContextRef C)
Create a metadata type in a context.
Definition: Core.cpp:948
LLVMTypeRef LLVMTokenTypeInContext(LLVMContextRef C)
Create a token type in a context.
Definition: Core.cpp:945
LLVMTypeRef LLVMX86AMXType(void)
Definition: Core.cpp:756
LLVMTypeRef LLVMLabelTypeInContext(LLVMContextRef C)
Create a label type in a context.
Definition: Core.cpp:942
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:959
unsigned LLVMGetTargetExtTypeNumIntParams(LLVMTypeRef TargetExtTy)
Obtain the number of int parameters for this target extension type.
Definition: Core.cpp:986
unsigned LLVMGetTargetExtTypeIntParam(LLVMTypeRef TargetExtTy, unsigned Idx)
Get the int parameter at the given index for the target extension type.
Definition: Core.cpp:991
LLVMTypeRef LLVMLabelType(void)
Definition: Core.cpp:955
LLVMTypeRef LLVMVoidTypeInContext(LLVMContextRef C)
Create a void type in a context.
Definition: Core.cpp:939
unsigned LLVMGetArrayLength(LLVMTypeRef ArrayTy)
Obtain the length of an array type.
Definition: Core.cpp:901
LLVMTypeRef LLVMGetElementType(LLVMTypeRef WrappedTy)
Obtain the element type of an array or vector type.
Definition: Core.cpp:890
unsigned LLVMGetPointerAddressSpace(LLVMTypeRef PointerTy)
Obtain the address space of a pointer type.
Definition: Core.cpp:909
uint64_t LLVMGetArrayLength2(LLVMTypeRef ArrayTy)
Obtain the length of an array type.
Definition: Core.cpp:905
LLVMValueRef LLVMGetConstantPtrAuthPointer(LLVMValueRef PtrAuth)
Get the pointer value for the associated ConstantPtrAuth constant.
Definition: Core.cpp:917
LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, unsigned AddressSpace)
Create a pointer type that points to a defined type.
Definition: Core.cpp:873
unsigned LLVMGetNumContainedTypes(LLVMTypeRef Tp)
Return the number of types in the derived type.
Definition: Core.cpp:897
LLVMValueRef LLVMGetConstantPtrAuthDiscriminator(LLVMValueRef PtrAuth)
Get the discriminator value for the associated ConstantPtrAuth constant.
Definition: Core.cpp:925
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:881
LLVMBool LLVMPointerTypeIsOpaque(LLVMTypeRef Ty)
Determine whether a pointer is opaque.
Definition: Core.cpp:877
LLVMTypeRef LLVMPointerTypeInContext(LLVMContextRef C, unsigned AddressSpace)
Create an opaque pointer type in a context.
Definition: Core.cpp:935
LLVMValueRef LLVMGetConstantPtrAuthKey(LLVMValueRef PtrAuth)
Get the key value for the associated ConstantPtrAuth constant.
Definition: Core.cpp:921
LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount)
Create a fixed size array type that refers to a specific type.
Definition: Core.cpp:865
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:885
LLVMTypeRef LLVMArrayType2(LLVMTypeRef ElementType, uint64_t ElementCount)
Create a fixed size array type that refers to a specific type.
Definition: Core.cpp:869
void LLVMGetSubtypes(LLVMTypeRef Tp, LLVMTypeRef *Arr)
Returns type's subtypes.
Definition: Core.cpp:857
LLVMValueRef LLVMGetConstantPtrAuthAddrDiscriminator(LLVMValueRef PtrAuth)
Get the address discriminator value for the associated ConstantPtrAuth constant.
Definition: Core.cpp:929
unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy)
Obtain the (possibly scalable) number of elements in a vector type.
Definition: Core.cpp:913
void LLVMStructSetBody(LLVMTypeRef StructTy, LLVMTypeRef *ElementTypes, unsigned ElementCount, LLVMBool Packed)
Set the contents of a structure type.
Definition: Core.cpp:814
LLVMBool LLVMIsPackedStruct(LLVMTypeRef StructTy)
Determine whether a structure is packed.
Definition: Core.cpp:835
LLVMTypeRef LLVMStructGetTypeAtIndex(LLVMTypeRef StructTy, unsigned i)
Get the type of the element at a given index in the structure.
Definition: Core.cpp:830
LLVMTypeRef LLVMStructType(LLVMTypeRef *ElementTypes, unsigned ElementCount, LLVMBool Packed)
Create a new structure type in the global context.
Definition: Core.cpp:795
const char * LLVMGetStructName(LLVMTypeRef Ty)
Obtain the name of a structure.
Definition: Core.cpp:806
void LLVMGetStructElementTypes(LLVMTypeRef StructTy, LLVMTypeRef *Dest)
Get the elements within a structure.
Definition: Core.cpp:824
LLVMBool LLVMIsOpaqueStruct(LLVMTypeRef StructTy)
Determine whether a structure is opaque.
Definition: Core.cpp:839
unsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy)
Get the number of elements defined inside the structure.
Definition: Core.cpp:820
LLVMTypeRef LLVMStructCreateNamed(LLVMContextRef C, const char *Name)
Create an empty structure in a context having a specified name.
Definition: Core.cpp:801
LLVMBool LLVMIsLiteralStruct(LLVMTypeRef StructTy)
Determine whether a structure is literal.
Definition: Core.cpp:843
LLVMTypeRef LLVMStructTypeInContext(LLVMContextRef C, LLVMTypeRef *ElementTypes, unsigned ElementCount, LLVMBool Packed)
Create a new structure type in a context.
Definition: Core.cpp:789
LLVMBool LLVMTypeIsSized(LLVMTypeRef Ty)
Whether the type has a known size.
Definition: Core.cpp:631
LLVMTypeKind LLVMGetTypeKind(LLVMTypeRef Ty)
Obtain the enumerated type of a Type instance.
Definition: Core.cpp:583
char * LLVMPrintTypeToString(LLVMTypeRef Ty)
Return a string representation of the type.
Definition: Core.cpp:644
void LLVMDumpType(LLVMTypeRef Ty)
Dump a representation of a type to stderr.
Definition: Core.cpp:640
LLVMContextRef LLVMGetTypeContext(LLVMTypeRef Ty)
Obtain the context to which this type instance is associated.
Definition: Core.cpp:636
LLVMTailCallKind
Tail call kind for LLVMSetTailCallKind and LLVMGetTailCallKind.
Definition: Core.h:484
LLVMLinkage
Definition: Core.h:172
LLVMOpcode
External users depend on the following values being stable.
Definition: Core.h:60
LLVMRealPredicate
Definition: Core.h:305
LLVMTypeKind
Definition: Core.h:148
LLVMDLLStorageClass
Definition: Core.h:207
LLVMValueKind
Definition: Core.h:257
unsigned LLVMAttributeIndex
Definition: Core.h:475
LLVMIntPredicate
Definition: Core.h:292
unsigned LLVMFastMathFlags
Flags to indicate what fast-math-style optimizations are allowed on operations.
Definition: Core.h:512
LLVMUnnamedAddr
Definition: Core.h:201
LLVMModuleFlagBehavior
Definition: Core.h:412
LLVMDiagnosticSeverity
Definition: Core.h:400
LLVMVisibility
Definition: Core.h:195
LLVMAtomicRMWBinOp
Definition: Core.h:364
LLVMThreadLocalMode
Definition: Core.h:329
unsigned LLVMGEPNoWrapFlags
Flags that constrain the allowed wrap semantics of a getelementptr instruction.
Definition: Core.h:526
LLVMAtomicOrdering
Definition: Core.h:337
LLVMInlineAsmDialect
Definition: Core.h:407
@ LLVMDLLImportLinkage
Obsolete.
Definition: Core.h:186
@ LLVMInternalLinkage
Rename collisions when linking (static functions)
Definition: Core.h:183
@ LLVMLinkOnceAnyLinkage
Keep one copy of function when linking (inline)
Definition: Core.h:175
@ LLVMExternalLinkage
Externally visible function.
Definition: Core.h:173
@ LLVMExternalWeakLinkage
ExternalWeak linkage description.
Definition: Core.h:188
@ LLVMLinkOnceODRLinkage
Same, but only replaced by something equivalent.
Definition: Core.h:176
@ LLVMPrivateLinkage
Like Internal, but omit from symbol table.
Definition: Core.h:185
@ LLVMDLLExportLinkage
Obsolete.
Definition: Core.h:187
@ LLVMLinkerPrivateLinkage
Like Private, but linker removes.
Definition: Core.h:191
@ LLVMWeakODRLinkage
Same, but only replaced by something equivalent.
Definition: Core.h:180
@ LLVMGhostLinkage
Obsolete.
Definition: Core.h:189
@ LLVMWeakAnyLinkage
Keep one copy of function when linking (weak)
Definition: Core.h:179
@ LLVMAppendingLinkage
Special purpose, only applies to global arrays.
Definition: Core.h:182
@ LLVMCommonLinkage
Tentative definitions.
Definition: Core.h:190
@ LLVMLinkOnceODRAutoHideLinkage
Obsolete.
Definition: Core.h:178
@ LLVMLinkerPrivateWeakLinkage
Like LinkerPrivate, but is weak.
Definition: Core.h:192
@ LLVMAvailableExternallyLinkage
Definition: Core.h:174
@ LLVMHalfTypeKind
16 bit floating point type
Definition: Core.h:150
@ LLVMFP128TypeKind
128 bit floating point type (112-bit mantissa)
Definition: Core.h:154
@ LLVMIntegerTypeKind
Arbitrary bit width integers.
Definition: Core.h:157
@ LLVMPointerTypeKind
Pointers.
Definition: Core.h:161
@ LLVMX86_FP80TypeKind
80 bit floating point type (X87)
Definition: Core.h:153
@ LLVMX86_AMXTypeKind
X86 AMX.
Definition: Core.h:168
@ LLVMMetadataTypeKind
Metadata.
Definition: Core.h:163
@ LLVMScalableVectorTypeKind
Scalable SIMD vector type.
Definition: Core.h:166
@ LLVMArrayTypeKind
Arrays.
Definition: Core.h:160
@ LLVMBFloatTypeKind
16 bit brain floating point type
Definition: Core.h:167
@ LLVMStructTypeKind
Structures.
Definition: Core.h:159
@ LLVMLabelTypeKind
Labels.
Definition: Core.h:156
@ LLVMDoubleTypeKind
64 bit floating point type
Definition: Core.h:152
@ LLVMVoidTypeKind
type with no size
Definition: Core.h:149
@ LLVMTokenTypeKind
Tokens.
Definition: Core.h:165
@ LLVMFloatTypeKind
32 bit floating point type
Definition: Core.h:151
@ LLVMFunctionTypeKind
Functions.
Definition: Core.h:158
@ LLVMVectorTypeKind
Fixed width SIMD vector type.
Definition: Core.h:162
@ LLVMPPC_FP128TypeKind
128 bit floating point type (two 64-bits)
Definition: Core.h:155
@ LLVMTargetExtTypeKind
Target extension type.
Definition: Core.h:169
@ LLVMInstructionValueKind
Definition: Core.h:286
@ LLVMGEPFlagInBounds
Definition: Core.h:515
@ LLVMGEPFlagNUSW
Definition: Core.h:516
@ LLVMGEPFlagNUW
Definition: Core.h:517
@ LLVMGlobalUnnamedAddr
Address of the GV is globally insignificant.
Definition: Core.h:204
@ LLVMLocalUnnamedAddr
Address of the GV is locally insignificant.
Definition: Core.h:203
@ LLVMNoUnnamedAddr
Address of the GV is significant.
Definition: Core.h:202
@ LLVMModuleFlagBehaviorRequire
Adds a requirement that another module flag be present and have a specified value after linking is pe...
Definition: Core.h:438
@ LLVMModuleFlagBehaviorWarning
Emits a warning if two values disagree.
Definition: Core.h:426
@ LLVMModuleFlagBehaviorOverride
Uses the specified value, regardless of the behavior or value of the other module.
Definition: Core.h:446
@ LLVMModuleFlagBehaviorAppendUnique
Appends the two values, which are required to be metadata nodes.
Definition: Core.h:460
@ LLVMModuleFlagBehaviorAppend
Appends the two values, which are required to be metadata nodes.
Definition: Core.h:452
@ LLVMModuleFlagBehaviorError
Emits an error if two values disagree, otherwise the resulting value is that of the operands.
Definition: Core.h:419
@ LLVMDSWarning
Definition: Core.h:402
@ LLVMDSNote
Definition: Core.h:404
@ LLVMDSError
Definition: Core.h:401
@ LLVMDSRemark
Definition: Core.h:403
@ LLVMAtomicRMWBinOpXor
Xor a value and return the old one.
Definition: Core.h:371
@ LLVMAtomicRMWBinOpXchg
Set the new value and return the one old.
Definition: Core.h:365
@ LLVMAtomicRMWBinOpSub
Subtract a value and return the old one.
Definition: Core.h:367
@ LLVMAtomicRMWBinOpUMax
Sets the value if it's greater than the original using an unsigned comparison and return the old one.
Definition: Core.h:378
@ LLVMAtomicRMWBinOpAnd
And a value and return the old one.
Definition: Core.h:368
@ LLVMAtomicRMWBinOpUDecWrap
Decrements the value, wrapping back to the input value when decremented below zero.
Definition: Core.h:396
@ LLVMAtomicRMWBinOpFMax
Sets the value if it's greater than the original using an floating point comparison and return the ol...
Definition: Core.h:388
@ LLVMAtomicRMWBinOpMin
Sets the value if it's Smaller than the original using a signed comparison and return the old one.
Definition: Core.h:375
@ LLVMAtomicRMWBinOpOr
OR a value and return the old one.
Definition: Core.h:370
@ LLVMAtomicRMWBinOpFMin
Sets the value if it's smaller than the original using an floating point comparison and return the ol...
Definition: Core.h:391
@ LLVMAtomicRMWBinOpMax
Sets the value if it's greater than the original using a signed comparison and return the old one.
Definition: Core.h:372
@ LLVMAtomicRMWBinOpUIncWrap
Increments the value, wrapping back to zero when incremented above input value.
Definition: Core.h:394
@ LLVMAtomicRMWBinOpFAdd
Add a floating point value and return the old one.
Definition: Core.h:384
@ LLVMAtomicRMWBinOpFSub
Subtract a floating point value and return the old one.
Definition: Core.h:386
@ LLVMAtomicRMWBinOpAdd
Add a value and return the old one.
Definition: Core.h:366
@ LLVMAtomicRMWBinOpUMin
Sets the value if it's greater than the original using an unsigned comparison and return the old one.
Definition: Core.h:381
@ LLVMAtomicRMWBinOpNand
Not-And a value and return the old one.
Definition: Core.h:369
@ LLVMFastMathAllowReassoc
Definition: Core.h:492
@ LLVMFastMathNoSignedZeros
Definition: Core.h:495
@ LLVMFastMathApproxFunc
Definition: Core.h:498
@ LLVMFastMathNoInfs
Definition: Core.h:494
@ LLVMFastMathNoNaNs
Definition: Core.h:493
@ LLVMFastMathNone
Definition: Core.h:499
@ LLVMFastMathAllowContract
Definition: Core.h:497
@ LLVMFastMathAllowReciprocal
Definition: Core.h:496
@ LLVMGeneralDynamicTLSModel
Definition: Core.h:331
@ LLVMLocalDynamicTLSModel
Definition: Core.h:332
@ LLVMNotThreadLocal
Definition: Core.h:330
@ LLVMInitialExecTLSModel
Definition: Core.h:333
@ LLVMLocalExecTLSModel
Definition: Core.h:334
@ LLVMAtomicOrderingAcquireRelease
provides both an Acquire and a Release barrier (for fences and operations which both read and write m...
Definition: Core.h:350
@ LLVMAtomicOrderingRelease
Release is similar to Acquire, but with a barrier of the sort necessary to release a lock.
Definition: Core.h:347
@ LLVMAtomicOrderingAcquire
Acquire provides a barrier of the sort necessary to acquire a lock to access other memory with normal...
Definition: Core.h:344
@ LLVMAtomicOrderingMonotonic
guarantees that if you take all the operations affecting a specific address, a consistent ordering ex...
Definition: Core.h:341
@ LLVMAtomicOrderingSequentiallyConsistent
provides Acquire semantics for loads and Release semantics for stores.
Definition: Core.h:354
@ LLVMAtomicOrderingNotAtomic
A load or store which is not atomic.
Definition: Core.h:338
@ LLVMAtomicOrderingUnordered
Lowest level of atomicity, guarantees somewhat sane results, lock free.
Definition: Core.h:339
@ LLVMInlineAsmDialectATT
Definition: Core.h:408
@ LLVMInlineAsmDialectIntel
Definition: Core.h:409
LLVMBasicBlockRef LLVMGetNextBasicBlock(LLVMBasicBlockRef BB)
Advance a basic block iterator.
Definition: Core.cpp:2826
void LLVMAppendExistingBasicBlock(LLVMValueRef Fn, LLVMBasicBlockRef BB)
Append the given basic block to the basic block list of the given function.
Definition: Core.cpp:2855
void LLVMDeleteBasicBlock(LLVMBasicBlockRef BBRef)
Remove a basic block from a function and delete it.
Definition: Core.cpp:2882
LLVMBasicBlockRef LLVMGetFirstBasicBlock(LLVMValueRef Fn)
Obtain the first basic block in a function.
Definition: Core.cpp:2810
LLVMBasicBlockRef LLVMValueAsBasicBlock(LLVMValueRef Val)
Convert an LLVMValueRef to an LLVMBasicBlockRef instance.
Definition: Core.cpp:2780
LLVMBasicBlockRef LLVMCreateBasicBlockInContext(LLVMContextRef C, const char *Name)
Create a new basic block without inserting it into a function.
Definition: Core.cpp:2842
void LLVMRemoveBasicBlockFromParent(LLVMBasicBlockRef BBRef)
Remove a basic block from a function.
Definition: Core.cpp:2886
void LLVMMoveBasicBlockBefore(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos)
Move a basic block to before another one.
Definition: Core.cpp:2890
LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef BB)
Convert a basic block instance to a value type.
Definition: Core.cpp:2772
void LLVMInsertExistingBasicBlockAfterInsertBlock(LLVMBuilderRef Builder, LLVMBasicBlockRef BB)
Insert the given basic block after the insertion point of the given builder.
Definition: Core.cpp:2847
void LLVMGetBasicBlocks(LLVMValueRef FnRef, LLVMBasicBlockRef *BasicBlocksRefs)
Obtain all of the basic blocks in a function.
Definition: Core.cpp:2800
LLVMBasicBlockRef LLVMAppendBasicBlock(LLVMValueRef FnRef, const char *Name)
Append a basic block to the end of a function using the global context.
Definition: Core.cpp:2866
LLVMValueRef LLVMGetBasicBlockTerminator(LLVMBasicBlockRef BB)
Obtain the terminator instruction for a basic block.
Definition: Core.cpp:2792
unsigned LLVMCountBasicBlocks(LLVMValueRef FnRef)
Obtain the number of basic blocks in a function.
Definition: Core.cpp:2796
void LLVMMoveBasicBlockAfter(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos)
Move a basic block to after another one.
Definition: Core.cpp:2894
LLVMBasicBlockRef LLVMGetLastBasicBlock(LLVMValueRef Fn)
Obtain the last basic block in a function.
Definition: Core.cpp:2818
LLVMBasicBlockRef LLVMAppendBasicBlockInContext(LLVMContextRef C, LLVMValueRef FnRef, const char *Name)
Append a basic block to the end of a function.
Definition: Core.cpp:2860
LLVMValueRef LLVMGetBasicBlockParent(LLVMBasicBlockRef BB)
Obtain the function to which a basic block belongs.
Definition: Core.cpp:2788
LLVMValueRef LLVMGetFirstInstruction(LLVMBasicBlockRef BB)
Obtain the first instruction in a basic block.
Definition: Core.cpp:2904
LLVMValueRef LLVMGetLastInstruction(LLVMBasicBlockRef BB)
Obtain the last instruction in a basic block.
Definition: Core.cpp:2912
LLVMBasicBlockRef LLVMInsertBasicBlockInContext(LLVMContextRef C, LLVMBasicBlockRef BBRef, const char *Name)
Insert a basic block in a function before another basic block.
Definition: Core.cpp:2870
LLVMBasicBlockRef LLVMInsertBasicBlock(LLVMBasicBlockRef BBRef, const char *Name)
Insert a basic block in a function using the global context.
Definition: Core.cpp:2877
LLVMBasicBlockRef LLVMGetEntryBasicBlock(LLVMValueRef Fn)
Obtain the basic block that corresponds to the entry point of a function.
Definition: Core.cpp:2806
LLVMBool LLVMValueIsBasicBlock(LLVMValueRef Val)
Determine whether an LLVMValueRef is itself a basic block.
Definition: Core.cpp:2776
const char * LLVMGetBasicBlockName(LLVMBasicBlockRef BB)
Obtain the string name of a basic block.
Definition: Core.cpp:2784
LLVMBasicBlockRef LLVMGetPreviousBasicBlock(LLVMBasicBlockRef BB)
Go backwards in a basic block iterator.
Definition: Core.cpp:2834
LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count, LLVMBool Packed)
Create a ConstantStruct in the global Context.
Definition: Core.cpp:1663
LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy, LLVMValueRef *ConstantVals, unsigned Length)
Create a ConstantArray from values.
Definition: Core.cpp:1643
LLVMValueRef LLVMConstArray2(LLVMTypeRef ElementTy, LLVMValueRef *ConstantVals, uint64_t Length)
Create a ConstantArray from values.
Definition: Core.cpp:1649
LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size)
Create a ConstantVector from values.
Definition: Core.cpp:1678
LLVMValueRef LLVMConstStringInContext(LLVMContextRef C, const char *Str, unsigned Length, LLVMBool DontNullTerminate)
Create a ConstantDataSequential and initialize it with a string.
Definition: Core.cpp:1601
LLVMValueRef LLVMConstNamedStruct(LLVMTypeRef StructTy, LLVMValueRef *ConstantVals, unsigned Count)
Create a non-anonymous ConstantStruct from values.
Definition: Core.cpp:1669
LLVMBool LLVMIsConstantString(LLVMValueRef C)
Returns true if the specified constant is an array of i8.
Definition: Core.cpp:1633
LLVMValueRef LLVMConstantPtrAuth(LLVMValueRef Ptr, LLVMValueRef Key, LLVMValueRef Disc, LLVMValueRef AddrDisc)
Create a ConstantPtrAuth constant with the given values.
Definition: Core.cpp:1683
LLVMValueRef LLVMGetAggregateElement(LLVMValueRef C, unsigned Idx)
Get element of a constant aggregate (struct, array or vector) at the specified index.
Definition: Core.cpp:1625
LLVMValueRef LLVMConstString(const char *Str, unsigned Length, LLVMBool DontNullTerminate)
Create a ConstantDataSequential with string content in the global context.
Definition: Core.cpp:1619
const char * LLVMGetAsString(LLVMValueRef C, size_t *Length)
Get the given constant data sequential as a string.
Definition: Core.cpp:1637
LLVMValueRef LLVMConstStringInContext2(LLVMContextRef C, const char *Str, size_t Length, LLVMBool DontNullTerminate)
Create a ConstantDataSequential and initialize it with a string.
Definition: Core.cpp:1610
LLVMValueRef LLVMConstStructInContext(LLVMContextRef C, LLVMValueRef *ConstantVals, unsigned Count, LLVMBool Packed)
Create an anonymous ConstantStruct with the specified values.
Definition: Core.cpp:1655
LLVMValueRef LLVMConstPointerCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition: Core.cpp:1886
LLVMValueRef LLVMConstMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1803
LLVMValueRef LLVMConstTruncOrBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition: Core.cpp:1880
LLVMValueRef LLVMSizeOf(LLVMTypeRef Ty)
Definition: Core.cpp:1748
LLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition: Core.cpp:1859
LLVMValueRef LLVMConstNUWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1797
LLVMValueRef LLVMConstNUWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1780
LLVMValueRef LLVMConstIntToPtr(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition: Core.cpp:1864
LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition: Core.cpp:1854
LLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal)
Definition: Core.cpp:1765
LLVMValueRef LLVMGetBlockAddressFunction(LLVMValueRef BlockAddr)
Gets the function associated with a given BlockAddress constant value.
Definition: Core.cpp:1928
LLVMValueRef LLVMConstNSWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1808
LLVMValueRef LLVMConstExtractElement(LLVMValueRef VectorConstant, LLVMValueRef IndexConstant)
Definition: Core.cpp:1892
LLVMValueRef LLVMConstInsertElement(LLVMValueRef VectorConstant, LLVMValueRef ElementValueConstant, LLVMValueRef IndexConstant)
Definition: Core.cpp:1898
LLVMValueRef LLVMConstInBoundsGEP2(LLVMTypeRef Ty, LLVMValueRef ConstantVal, LLVMValueRef *ConstantIndices, unsigned NumIndices)
Definition: Core.cpp:1833
LLVMValueRef LLVMConstAddrSpaceCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition: Core.cpp:1874
LLVMBasicBlockRef LLVMGetBlockAddressBasicBlock(LLVMValueRef BlockAddr)
Gets the basic block associated with a given BlockAddress constant value.
Definition: Core.cpp:1932
LLVMValueRef LLVMConstNSWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1774
LLVMValueRef LLVMAlignOf(LLVMTypeRef Ty)
Definition: Core.cpp:1744
LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty, const char *AsmString, const char *Constraints, LLVMBool HasSideEffects, LLVMBool IsAlignStack)
Deprecated: Use LLVMGetInlineAsm instead.
Definition: Core.cpp:1916
LLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1820
LLVMValueRef LLVMConstBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition: Core.cpp:1869
LLVMValueRef LLVMConstNSWNeg(LLVMValueRef ConstantVal)
Definition: Core.cpp:1756
LLVMValueRef LLVMConstNUWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1814
LLVMValueRef LLVMConstGEPWithNoWrapFlags(LLVMTypeRef Ty, LLVMValueRef ConstantVal, LLVMValueRef *ConstantIndices, unsigned NumIndices, LLVMGEPNoWrapFlags NoWrapFlags)
Creates a constant GetElementPtr expression.
Definition: Core.cpp:1842
LLVMValueRef LLVMConstGEP2(LLVMTypeRef Ty, LLVMValueRef ConstantVal, LLVMValueRef *ConstantIndices, unsigned NumIndices)
Definition: Core.cpp:1825
LLVMValueRef LLVMConstSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1786
LLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1769
LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant, LLVMValueRef VectorBConstant, LLVMValueRef MaskConstant)
Definition: Core.cpp:1906
LLVMValueRef LLVMConstNeg(LLVMValueRef ConstantVal)
Definition: Core.cpp:1752
LLVMValueRef LLVMBlockAddress(LLVMValueRef F, LLVMBasicBlockRef BB)
Definition: Core.cpp:1924
LLVMOpcode LLVMGetConstOpcode(LLVMValueRef ConstantVal)
Definition: Core.cpp:1740
LLVMValueRef LLVMConstNSWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1791
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:2182
unsigned LLVMValueMetadataEntriesGetKind(LLVMValueMetadataEntry *Entries, unsigned Index)
Returns the kind of a value metadata entry at a specific index.
Definition: Core.cpp:2163
void LLVMDisposeValueMetadataEntries(LLVMValueMetadataEntry *Entries)
Destroys value metadata entries.
Definition: Core.cpp:2178
void LLVMSetVisibility(LLVMValueRef Global, LLVMVisibility Viz)
Definition: Core.cpp:2055
LLVMDLLStorageClass LLVMGetDLLStorageClass(LLVMValueRef Global)
Definition: Core.cpp:2060
void LLVMSetAlignment(LLVMValueRef V, unsigned Bytes)
Set the preferred alignment of the value.
Definition: Core.cpp:2131
LLVMModuleRef LLVMGetGlobalParent(LLVMValueRef Global)
Definition: Core.cpp:1938
const char * LLVMGetSection(LLVMValueRef Global)
Definition: Core.cpp:2040
LLVMTypeRef LLVMGlobalGetValueType(LLVMValueRef Global)
Returns the "value type" of a global value.
Definition: Core.cpp:2105
LLVMBool LLVMIsDeclaration(LLVMValueRef Global)
Definition: Core.cpp:1942
LLVMVisibility LLVMGetVisibility(LLVMValueRef Global)
Definition: Core.cpp:2050
void LLVMSetDLLStorageClass(LLVMValueRef Global, LLVMDLLStorageClass Class)
Definition: Core.cpp:2065
LLVMBool LLVMHasUnnamedAddr(LLVMValueRef Global)
Deprecated: Use LLVMGetUnnamedAddress instead.
Definition: Core.cpp:2095
LLVMLinkage LLVMGetLinkage(LLVMValueRef Global)
Definition: Core.cpp:1946
LLVMUnnamedAddr LLVMGetUnnamedAddress(LLVMValueRef Global)
Definition: Core.cpp:2070
LLVMMetadataRef LLVMValueMetadataEntriesGetMetadata(LLVMValueMetadataEntry *Entries, unsigned Index)
Returns the underlying metadata node of a value metadata entry at a specific index.
Definition: Core.cpp:2171
void LLVMSetUnnamedAddress(LLVMValueRef Global, LLVMUnnamedAddr UnnamedAddr)
Definition: Core.cpp:2082
void LLVMSetLinkage(LLVMValueRef Global, LLVMLinkage Linkage)
Definition: Core.cpp:1975
void LLVMSetUnnamedAddr(LLVMValueRef Global, LLVMBool HasUnnamedAddr)
Deprecated: Use LLVMSetUnnamedAddress instead.
Definition: Core.cpp:2099
void LLVMGlobalClearMetadata(LLVMValueRef Global)
Removes all metadata attachments from this value.
Definition: Core.cpp:2191
unsigned LLVMGetAlignment(LLVMValueRef V)
Obtain the preferred alignment of the value.
Definition: Core.cpp:2111
void LLVMSetSection(LLVMValueRef Global, const char *Section)
Definition: Core.cpp:2046
void LLVMGlobalEraseMetadata(LLVMValueRef Global, unsigned Kind)
Erases a metadata attachment of the given kind if it exists.
Definition: Core.cpp:2187
LLVMValueMetadataEntry * LLVMGlobalCopyAllMetadata(LLVMValueRef Value, size_t *NumEntries)
Retrieves an array of metadata entries representing the metadata attached to this value.
Definition: Core.cpp:2151
LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N, LLVMBool SignExtend)
Obtain a constant value for an integer type.
Definition: Core.cpp:1536
LLVMValueRef LLVMConstIntOfArbitraryPrecision(LLVMTypeRef IntTy, unsigned NumWords, const uint64_t Words[])
Obtain a constant value for an integer of arbitrary precision.
Definition: Core.cpp:1541
LLVMValueRef LLVMConstRealOfString(LLVMTypeRef RealTy, const char *Text)
Obtain a constant for a floating point value parsed from a string.
Definition: Core.cpp:1565
double LLVMConstRealGetDouble(LLVMValueRef ConstantVal, LLVMBool *LosesInfo)
Obtain the double value for an floating point constant value.
Definition: Core.cpp:1582
long long LLVMConstIntGetSExtValue(LLVMValueRef ConstantVal)
Obtain the sign extended value for an integer constant value.
Definition: Core.cpp:1578
unsigned long long LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal)
Obtain the zero extended value for an integer constant value.
Definition: Core.cpp:1574
LLVMValueRef LLVMConstReal(LLVMTypeRef RealTy, double N)
Obtain a constant value referring to a double floating point value.
Definition: Core.cpp:1561
LLVMBool LLVMIsNull(LLVMValueRef Val)
Determine whether a value instance is null.
Definition: Core.cpp:1259
LLVMValueRef LLVMGetUndef(LLVMTypeRef Ty)
Obtain a constant value referring to an undefined value of a type.
Definition: Core.cpp:1247
LLVMValueRef LLVMGetPoison(LLVMTypeRef Ty)
Obtain a constant value referring to a poison value of a type.
Definition: Core.cpp:1251
LLVMValueRef LLVMConstAllOnes(LLVMTypeRef Ty)
Obtain a constant value referring to the instance of a type consisting of all ones.
Definition: Core.cpp:1243
LLVMValueRef LLVMConstPointerNull(LLVMTypeRef Ty)
Obtain a constant that is a constant pointer pointing to NULL for a specified type.
Definition: Core.cpp:1273
LLVMValueRef LLVMConstNull(LLVMTypeRef Ty)
Obtain a constant value referring to the null instance of a type.
Definition: Core.cpp:1239
unsigned LLVMCountParams(LLVMValueRef FnRef)
Obtain the number of parameters in a function.
Definition: Core.cpp:2620
LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg)
Obtain the previous parameter to a function.
Definition: Core.cpp:2665
LLVMValueRef LLVMGetNextParam(LLVMValueRef Arg)
Obtain the next parameter to a function.
Definition: Core.cpp:2657
LLVMValueRef LLVMGetParamParent(LLVMValueRef V)
Obtain the function to which this argument belongs.
Definition: Core.cpp:2637
LLVMValueRef LLVMGetFirstParam(LLVMValueRef Fn)
Obtain the first parameter to a function.
Definition: Core.cpp:2641
void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align)
Set the alignment for a function parameter.
Definition: Core.cpp:2672
LLVMValueRef LLVMGetParam(LLVMValueRef FnRef, unsigned index)
Obtain the parameter at the specified index.
Definition: Core.cpp:2632
LLVMValueRef LLVMGetLastParam(LLVMValueRef Fn)
Obtain the last parameter to a function.
Definition: Core.cpp:2649
void LLVMGetParams(LLVMValueRef FnRef, LLVMValueRef *ParamRefs)
Obtain the parameters in a function.
Definition: Core.cpp:2626
void LLVMSetGC(LLVMValueRef Fn, const char *GC)
Define the garbage collector to use during code generation.
Definition: Core.cpp:2530
const char * LLVMGetGC(LLVMValueRef Fn)
Obtain the name of the garbage collector to use during code generation.
Definition: Core.cpp:2525
LLVMValueRef LLVMGetPrologueData(LLVMValueRef Fn)
Gets the prologue data associated with a function.
Definition: Core.cpp:2554
void LLVMRemoveEnumAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx, unsigned KindID)
Definition: Core.cpp:2601
unsigned LLVMGetAttributeCountAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx)
Definition: Core.cpp:2575
LLVMBool LLVMHasPersonalityFn(LLVMValueRef Fn)
Check whether the given function has a personality function.
Definition: Core.cpp:2439
unsigned LLVMLookupIntrinsicID(const char *Name, size_t NameLen)
Obtain the intrinsic ID number which matches the given function name.
Definition: Core.cpp:2507
const char * LLVMIntrinsicGetName(unsigned ID, size_t *NameLength)
Retrieves the name of an intrinsic.
Definition: Core.cpp:2471
unsigned LLVMGetFunctionCallConv(LLVMValueRef Fn)
Obtain the calling function of a function.
Definition: Core.cpp:2516
LLVMValueRef LLVMGetPrefixData(LLVMValueRef Fn)
Gets the prefix data associated with a function.
Definition: Core.cpp:2538
void LLVMRemoveStringAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx, const char *K, unsigned KLen)
Definition: Core.cpp:2606
void LLVMSetPrefixData(LLVMValueRef Fn, LLVMValueRef prefixData)
Sets the prefix data for the function.
Definition: Core.cpp:2548
LLVMAttributeRef LLVMGetStringAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx, const char *K, unsigned KLen)
Definition: Core.cpp:2594
LLVMValueRef LLVMGetPersonalityFn(LLVMValueRef Fn)
Obtain the personality function attached to the function.
Definition: Core.cpp:2443
void LLVMSetPersonalityFn(LLVMValueRef Fn, LLVMValueRef PersonalityFn)
Set the personality function attached to the function.
Definition: Core.cpp:2447
LLVMBool LLVMIntrinsicIsOverloaded(unsigned ID)
Obtain if the intrinsic identified by the given ID is overloaded.
Definition: Core.cpp:2511
void LLVMAddAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx, LLVMAttributeRef A)
Add an attribute to a function.
Definition: Core.cpp:2570
void LLVMDeleteFunction(LLVMValueRef Fn)
Remove a function from its containing module and deletes it.
Definition: Core.cpp:2435
const char * LLVMIntrinsicCopyOverloadedName2(LLVMModuleRef Mod, unsigned ID, LLVMTypeRef *ParamTypes, size_t ParamCount, size_t *NameLength)
Copies the name of an overloaded intrinsic identified by a given list of parameter types.
Definition: Core.cpp:2496
void LLVMSetPrologueData(LLVMValueRef Fn, LLVMValueRef prologueData)
Sets the prologue data for the function.
Definition: Core.cpp:2564
const char * LLVMIntrinsicCopyOverloadedName(unsigned ID, LLVMTypeRef *ParamTypes, size_t ParamCount, size_t *NameLength)
Deprecated: Use LLVMIntrinsicCopyOverloadedName2 instead.
Definition: Core.cpp:2485
LLVMBool LLVMHasPrologueData(LLVMValueRef Fn)
Check if a given function has prologue data.
Definition: Core.cpp:2559
LLVMBool LLVMHasPrefixData(LLVMValueRef Fn)
Check if a given function has prefix data.
Definition: Core.cpp:2543
void LLVMGetAttributesAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx, LLVMAttributeRef *Attrs)
Definition: Core.cpp:2580
void LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC)
Set the calling convention of a function.
Definition: Core.cpp:2520
LLVMValueRef LLVMGetIntrinsicDeclaration(LLVMModuleRef Mod, unsigned ID, LLVMTypeRef *ParamTypes, size_t ParamCount)
Create or insert the declaration of an intrinsic.
Definition: Core.cpp:2462
LLVMAttributeRef LLVMGetEnumAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx, unsigned KindID)
Definition: Core.cpp:2587
void LLVMAddTargetDependentFunctionAttr(LLVMValueRef Fn, const char *A, const char *V)
Add a target-dependent attribute to a function.
Definition: Core.cpp:2611
LLVMTypeRef LLVMIntrinsicGetType(LLVMContextRef Ctx, unsigned ID, LLVMTypeRef *ParamTypes, size_t ParamCount)
Retrieves the type of an intrinsic.
Definition: Core.cpp:2478
unsigned LLVMGetIntrinsicID(LLVMValueRef Fn)
Obtain the ID number from a function instance.
Definition: Core.cpp:2451
LLVMValueKind LLVMGetValueKind(LLVMValueRef Val)
Obtain the enumerated type of a Value instance.
Definition: Core.cpp:1004
const char * LLVMGetValueName(LLVMValueRef Val)
Deprecated: Use LLVMGetValueName2 instead.
Definition: Core.cpp:1026
LLVMTypeRef LLVMTypeOf(LLVMValueRef Val)
Obtain the type of a value.
Definition: Core.cpp:1000
LLVMBool LLVMIsConstant(LLVMValueRef Ty)
Determine whether the specified value instance is constant.
Definition: Core.cpp:1255
void LLVMReplaceAllUsesWith(LLVMValueRef OldVal, LLVMValueRef NewVal)
Replace all uses of a value with another one.
Definition: Core.cpp:1070
const char * LLVMGetValueName2(LLVMValueRef Val, size_t *Length)
Obtain the string name of a value.
Definition: Core.cpp:1016
LLVMContextRef LLVMGetValueContext(LLVMValueRef Val)
Obtain the context to which this value is associated.
Definition: Core.cpp:1052
char * LLVMPrintDbgRecordToString(LLVMDbgRecordRef Record)
Return a string representation of the DbgRecord.
Definition: Core.cpp:1056
void LLVMSetValueName(LLVMValueRef Val, const char *Name)
Deprecated: Use LLVMSetValueName2 instead.
Definition: Core.cpp:1030
void LLVMDumpValue(LLVMValueRef Val)
Dump a representation of a value to stderr.
Definition: Core.cpp:1034
LLVMBool LLVMIsUndef(LLVMValueRef Val)
Determine whether a value instance is undefined.
Definition: Core.cpp:1265
LLVMValueRef LLVMIsAMDNode(LLVMValueRef Val)
Definition: Core.cpp:1148
LLVMBool LLVMIsPoison(LLVMValueRef Val)
Determine whether a value instance is poisonous.
Definition: Core.cpp:1269
LLVMValueRef LLVMIsAMDString(LLVMValueRef Val)
Definition: Core.cpp:1163
void LLVMSetValueName2(LLVMValueRef Val, const char *Name, size_t NameLen)
Set the string name of a value.
Definition: Core.cpp:1022
LLVMValueRef LLVMIsAValueAsMetadata(LLVMValueRef Val)
Definition: Core.cpp:1156
char * LLVMPrintValueToString(LLVMValueRef Val)
Return a string representation of the value.
Definition: Core.cpp:1038
void LLVMEraseGlobalIFunc(LLVMValueRef IFunc)
Remove a global indirect function from its parent module and delete it.
Definition: Core.cpp:2734
void LLVMRemoveGlobalIFunc(LLVMValueRef IFunc)
Remove a global indirect function from its parent module.
Definition: Core.cpp:2738
LLVMValueRef LLVMGetNextGlobalIFunc(LLVMValueRef IFunc)
Advance a GlobalIFunc iterator to the next GlobalIFunc.
Definition: Core.cpp:2710
LLVMValueRef LLVMGetNamedGlobalIFunc(LLVMModuleRef M, const char *Name, size_t NameLen)
Obtain a GlobalIFunc value from a Module by its name.
Definition: Core.cpp:2689
LLVMValueRef LLVMGetLastGlobalIFunc(LLVMModuleRef M)
Obtain an iterator to the last GlobalIFunc in a Module.
Definition: Core.cpp:2702
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:2679
void LLVMSetGlobalIFuncResolver(LLVMValueRef IFunc, LLVMValueRef Resolver)
Sets the resolver function associated with this indirect function.
Definition: Core.cpp:2730
LLVMValueRef LLVMGetFirstGlobalIFunc(LLVMModuleRef M)
Obtain an iterator to the first GlobalIFunc in a Module.
Definition: Core.cpp:2694
LLVMValueRef LLVMGetGlobalIFuncResolver(LLVMValueRef IFunc)
Retrieves the resolver function associated with this indirect function, or NULL if it doesn't not exi...
Definition: Core.cpp:2726
LLVMValueRef LLVMGetPreviousGlobalIFunc(LLVMValueRef IFunc)
Decrement a GlobalIFunc iterator to the previous GlobalIFunc.
Definition: Core.cpp:2718
LLVMTypeRef LLVMGetAllocatedType(LLVMValueRef Alloca)
Obtain the type that is being allocated by the alloca instruction.
Definition: Core.cpp:3159
LLVMOperandBundleRef LLVMGetOperandBundleAtIndex(LLVMValueRef C, unsigned Index)
Obtain the operand bundle attached to this instruction at the given index.
Definition: Core.cpp:3059
LLVMValueRef LLVMGetCalledValue(LLVMValueRef Instr)
Obtain the pointer to the function invoked by this instruction.
Definition: Core.cpp:3047
void LLVMGetCallSiteAttributes(LLVMValueRef C, LLVMAttributeIndex Idx, LLVMAttributeRef *Attrs)
Definition: Core.cpp:3015
unsigned LLVMGetNumArgOperands(LLVMValueRef Instr)
Obtain the argument count for a call instruction.
Definition: Core.cpp:2977
void LLVMSetNormalDest(LLVMValueRef Invoke, LLVMBasicBlockRef B)
Set the normal destination basic block.
Definition: Core.cpp:3098
unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr)
Obtain the calling convention for a call instruction.
Definition: Core.cpp:2986
LLVMTypeRef LLVMGetCalledFunctionType(LLVMValueRef Instr)
Obtain the function type called by this instruction.
Definition: Core.cpp:3051
unsigned LLVMGetCallSiteAttributeCount(LLVMValueRef C, LLVMAttributeIndex Idx)
Definition: Core.cpp:3008
void LLVMAddCallSiteAttribute(LLVMValueRef C, LLVMAttributeIndex Idx, LLVMAttributeRef A)
Definition: Core.cpp:3003
unsigned LLVMGetNumOperandBundles(LLVMValueRef C)
Obtain the number of operand bundles attached to this instruction.
Definition: Core.cpp:3055
LLVMBasicBlockRef LLVMGetCallBrIndirectDest(LLVMValueRef CallBr, unsigned Idx)
Get the indirect destination of a CallBr instruction at the given index.
Definition: Core.cpp:3119
void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC)
Set the calling convention for a call instruction.
Definition: Core.cpp:2990
LLVMAttributeRef LLVMGetCallSiteEnumAttribute(LLVMValueRef C, LLVMAttributeIndex Idx, unsigned KindID)
Definition: Core.cpp:3023
LLVMBasicBlockRef LLVMGetNormalDest(LLVMValueRef Invoke)
Return the normal destination basic block.
Definition: Core.cpp:3085
void LLVMRemoveCallSiteEnumAttribute(LLVMValueRef C, LLVMAttributeIndex Idx, unsigned KindID)
Definition: Core.cpp:3037
unsigned LLVMGetCallBrNumIndirectDests(LLVMValueRef CallBr)
Get the number of indirect destinations of a CallBr instruction.
Definition: Core.cpp:3115
void LLVMSetUnwindDest(LLVMValueRef Invoke, LLVMBasicBlockRef B)
Set the unwind destination basic block.
Definition: Core.cpp:3102
void LLVMSetTailCall(LLVMValueRef Call, LLVMBool isTailCall)
Set whether a call instruction is a tail call.
Definition: Core.cpp:3071
LLVMBool LLVMIsTailCall(LLVMValueRef Call)
Obtain whether a call instruction is a tail call.
Definition: Core.cpp:3067
void LLVMSetInstrParamAlignment(LLVMValueRef Instr, LLVMAttributeIndex Idx, unsigned align)
Definition: Core.cpp:2995
LLVMBasicBlockRef LLVMGetCallBrDefaultDest(LLVMValueRef CallBr)
Get the default destination of a CallBr instruction.
Definition: Core.cpp:3111
void LLVMRemoveCallSiteStringAttribute(LLVMValueRef C, LLVMAttributeIndex Idx, const char *K, unsigned KLen)
Definition: Core.cpp:3042
LLVMTailCallKind LLVMGetTailCallKind(LLVMValueRef Call)
Obtain a tail call kind of the call instruction.
Definition: Core.cpp:3075
void LLVMSetTailCallKind(LLVMValueRef Call, LLVMTailCallKind kind)
Set the call kind of the call instruction.
Definition: Core.cpp:3079
LLVMAttributeRef LLVMGetCallSiteStringAttribute(LLVMValueRef C, LLVMAttributeIndex Idx, const char *K, unsigned KLen)
Definition: Core.cpp:3030
LLVMBasicBlockRef LLVMGetUnwindDest(LLVMValueRef Invoke)
Return the unwind destination basic block.
Definition: Core.cpp:3089
LLVMTypeRef LLVMGetGEPSourceElementType(LLVMValueRef GEP)
Get the source element type of the given GEP operator.
Definition: Core.cpp:3173
LLVMBool LLVMIsInBounds(LLVMValueRef GEP)
Check whether the given GEP operator is inbounds.
Definition: Core.cpp:3165
void LLVMSetIsInBounds(LLVMValueRef GEP, LLVMBool InBounds)
Set the given GEP instruction to be inbounds or not.
Definition: Core.cpp:3169
void LLVMGEPSetNoWrapFlags(LLVMValueRef GEP, LLVMGEPNoWrapFlags NoWrapFlags)
Set the no-wrap related flags for the given GEP instruction.
Definition: Core.cpp:3182
LLVMGEPNoWrapFlags LLVMGEPGetNoWrapFlags(LLVMValueRef GEP)
Get the no-wrap related flags for the given GEP instruction.
Definition: Core.cpp:3177
const unsigned * LLVMGetIndices(LLVMValueRef Inst)
Obtain the indices as an array.
Definition: Core.cpp:3222
unsigned LLVMGetNumIndices(LLVMValueRef Inst)
Obtain the number of indices.
Definition: Core.cpp:3210
void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues, LLVMBasicBlockRef *IncomingBlocks, unsigned Count)
Add an incoming value to the end of a PHI list.
Definition: Core.cpp:3189
LLVMValueRef LLVMGetIncomingValue(LLVMValueRef PhiNode, unsigned Index)
Obtain an incoming value to a PHI node as an LLVMValueRef.
Definition: Core.cpp:3200
unsigned LLVMCountIncoming(LLVMValueRef PhiNode)
Obtain the number of incoming basic blocks to a PHI node.
Definition: Core.cpp:3196
LLVMBasicBlockRef LLVMGetIncomingBlock(LLVMValueRef PhiNode, unsigned Index)
Obtain an incoming value to a PHI node as an LLVMBasicBlockRef.
Definition: Core.cpp:3204
unsigned LLVMGetNumSuccessors(LLVMValueRef Term)
Return the number of successors that this terminator has.
Definition: Core.cpp:3125
LLVMBasicBlockRef LLVMGetSwitchDefaultDest(LLVMValueRef Switch)
Obtain the default destination basic block of a switch instruction.
Definition: Core.cpp:3153
void LLVMSetSuccessor(LLVMValueRef Term, unsigned i, LLVMBasicBlockRef block)
Update the specified successor to point at the provided block.
Definition: Core.cpp:3133
void LLVMSetCondition(LLVMValueRef Branch, LLVMValueRef Cond)
Set the condition of a branch instruction.
Definition: Core.cpp:3147
LLVMValueRef LLVMGetCondition(LLVMValueRef Branch)
Return the condition of a branch instruction.
Definition: Core.cpp:3143
LLVMBool LLVMIsConditional(LLVMValueRef Branch)
Return if a branch is conditional.
Definition: Core.cpp:3139
LLVMBasicBlockRef LLVMGetSuccessor(LLVMValueRef Term, unsigned i)
Return the specified successor.
Definition: Core.cpp:3129
LLVMValueRef LLVMInstructionClone(LLVMValueRef Inst)
Create a copy of 'this' instruction that is identical in all ways except the following:
Definition: Core.cpp:2966
LLVMValueRef LLVMGetNextInstruction(LLVMValueRef Inst)
Obtain the instruction that occurs after the one specified.
Definition: Core.cpp:2920
void LLVMDeleteInstruction(LLVMValueRef Inst)
Delete an instruction.
Definition: Core.cpp:2944
LLVMValueRef LLVMIsATerminatorInst(LLVMValueRef Inst)
Determine whether an instruction is a terminator.
Definition: Core.cpp:2972
LLVMOpcode LLVMGetInstructionOpcode(LLVMValueRef Inst)
Obtain the code opcode for an individual instruction.
Definition: Core.cpp:2960
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:1131
LLVMRealPredicate LLVMGetFCmpPredicate(LLVMValueRef Inst)
Obtain the float predicate of an instruction.
Definition: Core.cpp:2954
int LLVMHasMetadata(LLVMValueRef Inst)
Determine whether an instruction has any metadata attached.
Definition: Core.cpp:1074
void LLVMInstructionEraseFromParent(LLVMValueRef Inst)
Remove and delete an instruction.
Definition: Core.cpp:2940
void LLVMInstructionRemoveFromParent(LLVMValueRef Inst)
Remove an instruction.
Definition: Core.cpp:2936
LLVMValueRef LLVMGetMetadata(LLVMValueRef Inst, unsigned KindID)
Return metadata associated with an instruction value.
Definition: Core.cpp:1078
LLVMIntPredicate LLVMGetICmpPredicate(LLVMValueRef Inst)
Obtain the predicate of an instruction.
Definition: Core.cpp:2948
void LLVMSetMetadata(LLVMValueRef Inst, unsigned KindID, LLVMValueRef Val)
Set metadata associated with an instruction value.
Definition: Core.cpp:1100
LLVMBasicBlockRef LLVMGetInstructionParent(LLVMValueRef Inst)
Obtain the basic block to which an instruction belongs.
Definition: Core.cpp:2900
LLVMValueRef LLVMGetPreviousInstruction(LLVMValueRef Inst)
Obtain the instruction that occurred before this one.
Definition: Core.cpp:2928
LLVMValueRef LLVMMetadataAsValue(LLVMContextRef C, LLVMMetadataRef MD)
Obtain a Metadata as a Value.
Definition: Core.cpp:1331
LLVMValueRef LLVMMDString(const char *Str, unsigned SLen)
Deprecated: Use LLVMMDStringInContext2 instead.
Definition: Core.cpp:1296
void LLVMReplaceMDNodeOperandWith(LLVMValueRef V, unsigned Index, LLVMMetadataRef Replacement)
Replace an operand at a specific index in a llvm::MDNode value.
Definition: Core.cpp:1422
LLVMMetadataRef LLVMMDStringInContext2(LLVMContextRef C, const char *Str, size_t SLen)
Create an MDString value from a given string value.
Definition: Core.cpp:1279
LLVMMetadataRef LLVMMDNodeInContext2(LLVMContextRef C, LLVMMetadataRef *MDs, size_t Count)
Create an MDNode value with the given array of operands.
Definition: Core.cpp:1284
LLVMValueRef LLVMMDStringInContext(LLVMContextRef C, const char *Str, unsigned SLen)
Deprecated: Use LLVMMDStringInContext2 instead.
Definition: Core.cpp:1289
LLVMMetadataRef LLVMValueAsMetadata(LLVMValueRef Val)
Obtain a Value as a Metadata.
Definition: Core.cpp:1335
LLVMValueRef LLVMMDNodeInContext(LLVMContextRef C, LLVMValueRef *Vals, unsigned Count)
Deprecated: Use LLVMMDNodeInContext2 instead.
Definition: Core.cpp:1300
const char * LLVMGetMDString(LLVMValueRef V, unsigned *Length)
Obtain the underlying string from a MDString value.
Definition: Core.cpp:1344
unsigned LLVMGetMDNodeNumOperands(LLVMValueRef V)
Obtain the number of operands from an MDNode value.
Definition: Core.cpp:1354
void LLVMGetMDNodeOperands(LLVMValueRef V, LLVMValueRef *Dest)
Obtain the given MDNode's operands.
Definition: Core.cpp:1409
LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count)
Deprecated: Use LLVMMDNodeInContext2 instead.
Definition: Core.cpp:1327
int LLVMGetNumOperands(LLVMValueRef Val)
Obtain the number of operands in a llvm::User value.
Definition: Core.cpp:1229
void LLVMSetOperand(LLVMValueRef Val, unsigned Index, LLVMValueRef Op)
Set an operand at a specific index in a llvm::User value.
Definition: Core.cpp:1225
LLVMUseRef LLVMGetOperandUse(LLVMValueRef Val, unsigned Index)
Obtain the use of an operand at a specific index in a llvm::User value.
Definition: Core.cpp:1220
LLVMValueRef LLVMGetOperand(LLVMValueRef Val, unsigned Index)
Obtain an operand at a specific index in a llvm::User value.
Definition: Core.cpp:1206
LLVMValueRef LLVMGetUser(LLVMUseRef U)
Obtain the user value for a user.
Definition: Core.cpp:1186
LLVMUseRef LLVMGetFirstUse(LLVMValueRef Val)
Obtain the first use of a value.
Definition: Core.cpp:1171
LLVMUseRef LLVMGetNextUse(LLVMUseRef U)
Obtain the next use of a value.
Definition: Core.cpp:1179
LLVMValueRef LLVMGetUsedValue(LLVMUseRef U)
Obtain the value this use corresponds to.
Definition: Core.cpp:1190
#define LLVM_FOR_EACH_VALUE_SUBCLASS(macro)
Definition: Core.h:1835
void LLVMShutdown()
Deallocate and destroy all ManagedStatic variables.
Definition: Core.cpp:65
void LLVMGetVersion(unsigned *Major, unsigned *Minor, unsigned *Patch)
Return the major, minor, and patch version of LLVM.
Definition: Core.cpp:71
void LLVMDisposeMessage(char *Message)
Definition: Core.cpp:86
char * LLVMCreateMessage(const char *Message)
Definition: Core.cpp:82
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 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 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
void LLVMAliasSetAliasee(LLVMValueRef Alias, LLVMValueRef Aliasee)
Set the target value of an alias.
Definition: Core.cpp:2382
LLVMValueRef LLVMGetLastGlobalAlias(LLVMModuleRef M)
Obtain an iterator to the last GlobalAlias in a Module.
Definition: Core.cpp:2354
LLVMValueRef LLVMGetNextGlobalAlias(LLVMValueRef GA)
Advance a GlobalAlias iterator to the next GlobalAlias.
Definition: Core.cpp:2362
LLVMValueRef LLVMAliasGetAliasee(LLVMValueRef Alias)
Retrieve the target value of an alias.
Definition: Core.cpp:2378
LLVMValueRef LLVMGetPreviousGlobalAlias(LLVMValueRef GA)
Decrement a GlobalAlias iterator to the previous GlobalAlias.
Definition: Core.cpp:2370
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:2333
LLVMValueRef LLVMGetFirstGlobalAlias(LLVMModuleRef M)
Obtain an iterator to the first GlobalAlias in a Module.
Definition: Core.cpp:2346
LLVMValueRef LLVMGetNamedGlobalAlias(LLVMModuleRef M, const char *Name, size_t NameLen)
Obtain a GlobalAlias value from a Module by its name.
Definition: Core.cpp:2341
void LLVMSetGlobalConstant(LLVMValueRef GlobalVar, LLVMBool IsConstant)
Definition: Core.cpp:2280
void LLVMSetThreadLocalMode(LLVMValueRef GlobalVar, LLVMThreadLocalMode Mode)
Definition: Core.cpp:2301
LLVMThreadLocalMode LLVMGetThreadLocalMode(LLVMValueRef GlobalVar)
Definition: Core.cpp:2284
LLVMValueRef LLVMGetNamedGlobalWithLength(LLVMModuleRef M, const char *Name, size_t Length)
Definition: Core.cpp:2215
LLVMValueRef LLVMGetFirstGlobal(LLVMModuleRef M)
Definition: Core.cpp:2220
LLVMValueRef LLVMGetNextGlobal(LLVMValueRef GlobalVar)
Definition: Core.cpp:2236
LLVMBool LLVMIsExternallyInitialized(LLVMValueRef GlobalVar)
Definition: Core.cpp:2323
LLVMValueRef LLVMAddGlobal(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name)
Definition: Core.cpp:2197
LLVMValueRef LLVMGetLastGlobal(LLVMModuleRef M)
Definition: Core.cpp:2228
void LLVMSetExternallyInitialized(LLVMValueRef GlobalVar, LLVMBool IsExtInit)
Definition: Core.cpp:2327
LLVMValueRef LLVMGetPreviousGlobal(LLVMValueRef GlobalVar)
Definition: Core.cpp:2244
void LLVMSetThreadLocal(LLVMValueRef GlobalVar, LLVMBool IsThreadLocal)
Definition: Core.cpp:2272
LLVMValueRef LLVMGetInitializer(LLVMValueRef GlobalVar)
Definition: Core.cpp:2256
void LLVMDeleteGlobal(LLVMValueRef GlobalVar)
Definition: Core.cpp:2252
LLVMBool LLVMIsThreadLocal(LLVMValueRef GlobalVar)
Definition: Core.cpp:2268
LLVMBool LLVMIsGlobalConstant(LLVMValueRef GlobalVar)
Definition: Core.cpp:2276
LLVMValueRef LLVMAddGlobalInAddressSpace(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name, unsigned AddressSpace)
Definition: Core.cpp:2202
void LLVMSetInitializer(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal)
Definition: Core.cpp:2263
LLVMValueRef LLVMGetNamedGlobal(LLVMModuleRef M, const char *Name)
Definition: Core.cpp:2211
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ C
The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34
FunctionType * getType(LLVMContext &Context, ID id, ArrayRef< Type * > Tys=std::nullopt)
Return the function type for an intrinsic.
Definition: Function.cpp:1507
std::string getNameNoUnnamedTypes(ID Id, ArrayRef< Type * > Tys)
Return the LLVM name for an intrinsic.
Definition: Function.cpp:1136
StringRef getName(ID id)
Return the LLVM name for an intrinsic, such as "llvm.ppc.altivec.lvx".
Definition: Function.cpp:1096
bool isOverloaded(ID id)
Returns true if the intrinsic can be overloaded.
Definition: Function.cpp:1528
Function * getDeclaration(Module *M, ID id, ArrayRef< Type * > Tys=std::nullopt)
Create or insert an LLVM Function declaration for an intrinsic, and return it.
Definition: Function.cpp:1539
@ SingleThread
Synchronized with respect to signal handlers executing in the same thread.
Definition: LLVMContext.h:54
@ System
Synchronized with respect to all concurrently executing threads.
Definition: LLVMContext.h:57
@ OF_TextWithCRLF
The file should be opened in text mode and use a carriage linefeed '\r '.
Definition: FileSystem.h:767
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ Length
Definition: DWP.cpp:480
constexpr bool llvm_is_multithreaded()
Returns true if LLVM is compiled with support for multi-threading, and false otherwise.
Definition: Threading.h:53
void initializeSafepointIRVerifierPass(PassRegistry &)
AddressSpace
Definition: NVPTXBaseInfo.h:21
void * PointerTy
Definition: GenericValue.h:21
void initializeVerifierLegacyPassPass(PassRegistry &)
void setAtomicSyncScopeID(Instruction *I, SyncScope::ID SSID)
A helper function that sets an atomic operation's sync scope.
OperandBundleDefT< Value * > OperandBundleDef
Definition: AutoUpgrade.h:33
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...
void initializeCore(PassRegistry &)
Initialize all passes linked into the Core library.
Definition: Core.cpp:57
LLVM_ATTRIBUTE_RETURNS_NONNULL void * safe_malloc(size_t Sz)
Definition: MemAlloc.h:25
constexpr int PoisonMaskElem
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.
constexpr T divideCeil(U Numerator, V Denominator)
Returns the integer ceil(Numerator / Denominator).
Definition: MathExtras.h:403
void initializeDominatorTreeWrapperPassPass(PassRegistry &)
void initializePrintModulePassWrapperPass(PassRegistry &)
@ DS_Remark
@ DS_Warning
void llvm_shutdown()
llvm_shutdown - Deallocate and destroy all ManagedStatic variables.
LLVMAttributeRef wrap(Attribute Attr)
Definition: Attributes.h:315
void initializePrintFunctionPassWrapperPass(PassRegistry &)
#define N
LLVMModuleFlagBehavior Behavior
Definition: Core.cpp:331
const char * Key
Definition: Core.cpp:332
LLVMMetadataRef Metadata
Definition: Core.cpp:334
LLVMMetadataRef Metadata
Definition: Core.cpp:1108
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
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:117