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