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