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