LLVM 22.0.0git
Core.cpp
Go to the documentation of this file.
1//===-- Core.cpp ----------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file implements the common infrastructure (including the C bindings)
10// for libLLVMCore.a, which implements the LLVM intermediate representation.
11//
12//===----------------------------------------------------------------------===//
13
14#include "llvm-c/Core.h"
15#include "llvm-c/Types.h"
16#include "llvm/IR/Attributes.h"
17#include "llvm/IR/BasicBlock.h"
19#include "llvm/IR/Constants.h"
25#include "llvm/IR/GlobalAlias.h"
27#include "llvm/IR/IRBuilder.h"
28#include "llvm/IR/InlineAsm.h"
31#include "llvm/IR/LLVMContext.h"
33#include "llvm/IR/Module.h"
35#include "llvm/PassRegistry.h"
36#include "llvm/Support/Debug.h"
44#include <cassert>
45#include <cstdlib>
46#include <cstring>
47#include <system_error>
48
49using namespace llvm;
50
52
54 return reinterpret_cast<BasicBlock **>(BBs);
55}
56
57#define DEBUG_TYPE "ir"
58
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 const char *K, unsigned KLength,
214 const char *V, unsigned VLength) {
215 return wrap(Attribute::get(*unwrap(C), StringRef(K, KLength),
216 StringRef(V, VLength)));
217}
218
220 unsigned *Length) {
221 auto S = unwrap(A).getKindAsString();
222 *Length = S.size();
223 return S.data();
224}
225
227 unsigned *Length) {
228 auto S = unwrap(A).getValueAsString();
229 *Length = S.size();
230 return S.data();
231}
232
234 auto Attr = unwrap(A);
235 return Attr.isEnumAttribute() || Attr.isIntAttribute();
236}
237
241
245
247 std::string MsgStorage;
248 raw_string_ostream Stream(MsgStorage);
250
251 unwrap(DI)->print(DP);
252 Stream.flush();
253
254 return LLVMCreateMessage(MsgStorage.c_str());
255}
256
258 LLVMDiagnosticSeverity severity;
259
260 switch(unwrap(DI)->getSeverity()) {
261 default:
262 severity = LLVMDSError;
263 break;
264 case DS_Warning:
265 severity = LLVMDSWarning;
266 break;
267 case DS_Remark:
268 severity = LLVMDSRemark;
269 break;
270 case DS_Note:
271 severity = LLVMDSNote;
272 break;
273 }
274
275 return severity;
276}
277
278/*===-- Operations on modules ---------------------------------------------===*/
279
281 return wrap(new Module(ModuleID, getGlobalContext()));
282}
283
286 return wrap(new Module(ModuleID, *unwrap(C)));
287}
288
290 delete unwrap(M);
291}
292
293const char *LLVMGetModuleIdentifier(LLVMModuleRef M, size_t *Len) {
294 auto &Str = unwrap(M)->getModuleIdentifier();
295 *Len = Str.length();
296 return Str.c_str();
297}
298
299void LLVMSetModuleIdentifier(LLVMModuleRef M, const char *Ident, size_t Len) {
300 unwrap(M)->setModuleIdentifier(StringRef(Ident, Len));
301}
302
303const char *LLVMGetSourceFileName(LLVMModuleRef M, size_t *Len) {
304 auto &Str = unwrap(M)->getSourceFileName();
305 *Len = Str.length();
306 return Str.c_str();
307}
308
309void LLVMSetSourceFileName(LLVMModuleRef M, const char *Name, size_t Len) {
310 unwrap(M)->setSourceFileName(StringRef(Name, Len));
311}
312
313/*--.. Data layout .........................................................--*/
315 return unwrap(M)->getDataLayoutStr().c_str();
316}
317
319 return LLVMGetDataLayoutStr(M);
320}
321
322void LLVMSetDataLayout(LLVMModuleRef M, const char *DataLayoutStr) {
323 unwrap(M)->setDataLayout(DataLayoutStr);
324}
325
326/*--.. Target triple .......................................................--*/
328 return unwrap(M)->getTargetTriple().str().c_str();
329}
330
331void LLVMSetTarget(LLVMModuleRef M, const char *TripleStr) {
332 unwrap(M)->setTargetTriple(Triple(TripleStr));
333}
334
335/*--.. Module flags ........................................................--*/
337 LLVMModuleFlagBehavior Behavior;
338 const char *Key;
339 size_t KeyLen;
341};
342
361
381
384 unwrap(M)->getModuleFlagsMetadata(MFEs);
385
387 safe_malloc(MFEs.size() * sizeof(LLVMOpaqueModuleFlagEntry)));
388 for (unsigned i = 0; i < MFEs.size(); ++i) {
389 const auto &ModuleFlag = MFEs[i];
390 Result[i].Behavior = map_from_llvmModFlagBehavior(ModuleFlag.Behavior);
391 Result[i].Key = ModuleFlag.Key->getString().data();
392 Result[i].KeyLen = ModuleFlag.Key->getString().size();
393 Result[i].Metadata = wrap(ModuleFlag.Val);
394 }
395 *Len = MFEs.size();
396 return Result;
397}
398
400 free(Entries);
401}
402
405 unsigned Index) {
407 static_cast<LLVMOpaqueModuleFlagEntry>(Entries[Index]);
408 return MFE.Behavior;
409}
410
412 unsigned Index, size_t *Len) {
414 static_cast<LLVMOpaqueModuleFlagEntry>(Entries[Index]);
415 *Len = MFE.KeyLen;
416 return MFE.Key;
417}
418
420 unsigned Index) {
422 static_cast<LLVMOpaqueModuleFlagEntry>(Entries[Index]);
423 return MFE.Metadata;
424}
425
427 const char *Key, size_t KeyLen) {
428 return wrap(unwrap(M)->getModuleFlag({Key, KeyLen}));
429}
430
432 const char *Key, size_t KeyLen,
433 LLVMMetadataRef Val) {
434 unwrap(M)->addModuleFlag(map_to_llvmModFlagBehavior(Behavior),
435 {Key, KeyLen}, unwrap(Val));
436}
437
439
441 if (!UseNewFormat)
442 llvm_unreachable("LLVM no longer supports intrinsic based debug-info");
443 (void)M;
444}
445
446/*--.. Printing modules ....................................................--*/
447
449 unwrap(M)->print(errs(), nullptr,
450 /*ShouldPreserveUseListOrder=*/false, /*IsForDebug=*/true);
451}
452
454 char **ErrorMessage) {
455 std::error_code EC;
456 raw_fd_ostream dest(Filename, EC, sys::fs::OF_TextWithCRLF);
457 if (EC) {
458 *ErrorMessage = strdup(EC.message().c_str());
459 return true;
460 }
461
462 unwrap(M)->print(dest, nullptr);
463
464 dest.close();
465
466 if (dest.has_error()) {
467 std::string E = "Error printing to file: " + dest.error().message();
468 *ErrorMessage = strdup(E.c_str());
469 return true;
470 }
471
472 return false;
473}
474
476 std::string buf;
477 raw_string_ostream os(buf);
478
479 unwrap(M)->print(os, nullptr);
480 os.flush();
481
482 return strdup(buf.c_str());
483}
484
485/*--.. Operations on inline assembler ......................................--*/
486void LLVMSetModuleInlineAsm2(LLVMModuleRef M, const char *Asm, size_t Len) {
487 unwrap(M)->setModuleInlineAsm(StringRef(Asm, Len));
488}
489
490void LLVMSetModuleInlineAsm(LLVMModuleRef M, const char *Asm) {
491 unwrap(M)->setModuleInlineAsm(StringRef(Asm));
492}
493
494void LLVMAppendModuleInlineAsm(LLVMModuleRef M, const char *Asm, size_t Len) {
495 unwrap(M)->appendModuleInlineAsm(StringRef(Asm, Len));
496}
497
498const char *LLVMGetModuleInlineAsm(LLVMModuleRef M, size_t *Len) {
499 auto &Str = unwrap(M)->getModuleInlineAsm();
500 *Len = Str.length();
501 return Str.c_str();
502}
503
504LLVMValueRef LLVMGetInlineAsm(LLVMTypeRef Ty, const char *AsmString,
505 size_t AsmStringSize, const char *Constraints,
506 size_t ConstraintsSize, LLVMBool HasSideEffects,
507 LLVMBool IsAlignStack,
508 LLVMInlineAsmDialect Dialect, LLVMBool CanThrow) {
510 switch (Dialect) {
513 break;
516 break;
517 }
519 StringRef(AsmString, AsmStringSize),
520 StringRef(Constraints, ConstraintsSize),
521 HasSideEffects, IsAlignStack, AD, CanThrow));
522}
523
524const char *LLVMGetInlineAsmAsmString(LLVMValueRef InlineAsmVal, size_t *Len) {
525
526 Value *Val = unwrap<Value>(InlineAsmVal);
527 StringRef AsmString = cast<InlineAsm>(Val)->getAsmString();
528
529 *Len = AsmString.size();
530 return AsmString.data();
531}
532
534 size_t *Len) {
535 Value *Val = unwrap<Value>(InlineAsmVal);
536 StringRef ConstraintString = cast<InlineAsm>(Val)->getConstraintString();
537
538 *Len = ConstraintString.size();
539 return ConstraintString.data();
540}
541
543
544 Value *Val = unwrap<Value>(InlineAsmVal);
545 InlineAsm::AsmDialect Dialect = cast<InlineAsm>(Val)->getDialect();
546
547 switch (Dialect) {
552 }
553
554 llvm_unreachable("Unrecognized inline assembly dialect");
556}
557
559 Value *Val = unwrap<Value>(InlineAsmVal);
560 return (LLVMTypeRef)cast<InlineAsm>(Val)->getFunctionType();
561}
562
564 Value *Val = unwrap<Value>(InlineAsmVal);
565 return cast<InlineAsm>(Val)->hasSideEffects();
566}
567
569 Value *Val = unwrap<Value>(InlineAsmVal);
570 return cast<InlineAsm>(Val)->isAlignStack();
571}
572
574 Value *Val = unwrap<Value>(InlineAsmVal);
575 return cast<InlineAsm>(Val)->canThrow();
576}
577
578/*--.. Operations on module contexts ......................................--*/
580 return wrap(&unwrap(M)->getContext());
581}
582
583
584/*===-- Operations on types -----------------------------------------------===*/
585
586/*--.. Operations on all types (mostly) ....................................--*/
587
589 switch (unwrap(Ty)->getTypeID()) {
590 case Type::VoidTyID:
591 return LLVMVoidTypeKind;
592 case Type::HalfTyID:
593 return LLVMHalfTypeKind;
594 case Type::BFloatTyID:
595 return LLVMBFloatTypeKind;
596 case Type::FloatTyID:
597 return LLVMFloatTypeKind;
598 case Type::DoubleTyID:
599 return LLVMDoubleTypeKind;
602 case Type::FP128TyID:
603 return LLVMFP128TypeKind;
606 case Type::LabelTyID:
607 return LLVMLabelTypeKind;
611 return LLVMIntegerTypeKind;
614 case Type::StructTyID:
615 return LLVMStructTypeKind;
616 case Type::ArrayTyID:
617 return LLVMArrayTypeKind;
619 return LLVMPointerTypeKind;
621 return LLVMVectorTypeKind;
623 return LLVMX86_AMXTypeKind;
624 case Type::TokenTyID:
625 return LLVMTokenTypeKind;
631 llvm_unreachable("Typed pointers are unsupported via the C API");
632 }
633 llvm_unreachable("Unhandled TypeID.");
634}
635
637{
638 return unwrap(Ty)->isSized();
639}
640
642 return wrap(&unwrap(Ty)->getContext());
643}
644
646 return unwrap(Ty)->print(errs(), /*IsForDebug=*/true);
647}
648
650 std::string buf;
651 raw_string_ostream os(buf);
652
653 if (unwrap(Ty))
654 unwrap(Ty)->print(os);
655 else
656 os << "Printing <null> Type";
657
658 os.flush();
659
660 return strdup(buf.c_str());
661}
662
663/*--.. Operations on integer types .........................................--*/
664
684 return wrap(IntegerType::get(*unwrap(C), NumBits));
685}
686
705LLVMTypeRef LLVMIntType(unsigned NumBits) {
707}
708
709unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy) {
710 return unwrap<IntegerType>(IntegerTy)->getBitWidth();
711}
712
713/*--.. Operations on real types ............................................--*/
714
739
764
765/*--.. Operations on function types ........................................--*/
766
768 LLVMTypeRef *ParamTypes, unsigned ParamCount,
769 LLVMBool IsVarArg) {
770 ArrayRef<Type*> Tys(unwrap(ParamTypes), ParamCount);
771 return wrap(FunctionType::get(unwrap(ReturnType), Tys, IsVarArg != 0));
772}
773
775 return unwrap<FunctionType>(FunctionTy)->isVarArg();
776}
777
779 return wrap(unwrap<FunctionType>(FunctionTy)->getReturnType());
780}
781
782unsigned LLVMCountParamTypes(LLVMTypeRef FunctionTy) {
783 return unwrap<FunctionType>(FunctionTy)->getNumParams();
784}
785
787 FunctionType *Ty = unwrap<FunctionType>(FunctionTy);
788 for (Type *T : Ty->params())
789 *Dest++ = wrap(T);
790}
791
792/*--.. Operations on struct types ..........................................--*/
793
795 unsigned ElementCount, LLVMBool Packed) {
796 ArrayRef<Type*> Tys(unwrap(ElementTypes), ElementCount);
797 return wrap(StructType::get(*unwrap(C), Tys, Packed != 0));
798}
799
801 unsigned ElementCount, LLVMBool Packed) {
803 ElementCount, Packed);
804}
805
807{
808 return wrap(StructType::create(*unwrap(C), Name));
809}
810
812{
814 if (!Type->hasName())
815 return nullptr;
816 return Type->getName().data();
817}
818
819void LLVMStructSetBody(LLVMTypeRef StructTy, LLVMTypeRef *ElementTypes,
820 unsigned ElementCount, LLVMBool Packed) {
821 ArrayRef<Type*> Tys(unwrap(ElementTypes), ElementCount);
822 unwrap<StructType>(StructTy)->setBody(Tys, Packed != 0);
823}
824
826 return unwrap<StructType>(StructTy)->getNumElements();
827}
828
830 StructType *Ty = unwrap<StructType>(StructTy);
831 for (Type *T : Ty->elements())
832 *Dest++ = wrap(T);
833}
834
836 StructType *Ty = unwrap<StructType>(StructTy);
837 return wrap(Ty->getTypeAtIndex(i));
838}
839
841 return unwrap<StructType>(StructTy)->isPacked();
842}
843
845 return unwrap<StructType>(StructTy)->isOpaque();
846}
847
849 return unwrap<StructType>(StructTy)->isLiteral();
850}
851
853 return wrap(StructType::getTypeByName(unwrap(M)->getContext(), Name));
854}
855
857 return wrap(StructType::getTypeByName(*unwrap(C), Name));
858}
859
860/*--.. Operations on array, pointer, and vector types (sequence types) .....--*/
861
863 int i = 0;
864 for (auto *T : unwrap(Tp)->subtypes()) {
865 Arr[i] = wrap(T);
866 i++;
867 }
868}
869
871 return wrap(ArrayType::get(unwrap(ElementType), ElementCount));
872}
873
877
879 return wrap(
880 PointerType::get(unwrap(ElementType)->getContext(), AddressSpace));
881}
882
884 return true;
885}
886
888 return wrap(FixedVectorType::get(unwrap(ElementType), ElementCount));
889}
890
892 unsigned ElementCount) {
893 return wrap(ScalableVectorType::get(unwrap(ElementType), ElementCount));
894}
895
897 auto *Ty = unwrap(WrappedTy);
898 if (auto *ATy = dyn_cast<ArrayType>(Ty))
899 return wrap(ATy->getElementType());
900 return wrap(cast<VectorType>(Ty)->getElementType());
901}
902
904 return unwrap(Tp)->getNumContainedTypes();
905}
906
908 return unwrap<ArrayType>(ArrayTy)->getNumElements();
909}
910
912 return unwrap<ArrayType>(ArrayTy)->getNumElements();
913}
914
916 return unwrap<PointerType>(PointerTy)->getAddressSpace();
917}
918
919unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy) {
920 return unwrap<VectorType>(VectorTy)->getElementCount().getKnownMinValue();
921}
922
926
930
932 return wrap(unwrap<ConstantPtrAuth>(PtrAuth)->getDiscriminator());
933}
934
936 return wrap(unwrap<ConstantPtrAuth>(PtrAuth)->getAddrDiscriminator());
937}
938
939/*--.. Operations on other types ...........................................--*/
940
944
957
964
966 LLVMTypeRef *TypeParams,
967 unsigned TypeParamCount,
968 unsigned *IntParams,
969 unsigned IntParamCount) {
970 ArrayRef<Type *> TypeParamArray(unwrap(TypeParams), TypeParamCount);
971 ArrayRef<unsigned> IntParamArray(IntParams, IntParamCount);
972 return wrap(
973 TargetExtType::get(*unwrap(C), Name, TypeParamArray, IntParamArray));
974}
975
976const char *LLVMGetTargetExtTypeName(LLVMTypeRef TargetExtTy) {
978 return Type->getName().data();
979}
980
983 return Type->getNumTypeParameters();
984}
985
987 unsigned Idx) {
989 return wrap(Type->getTypeParameter(Idx));
990}
991
994 return Type->getNumIntParameters();
995}
996
997unsigned LLVMGetTargetExtTypeIntParam(LLVMTypeRef TargetExtTy, unsigned Idx) {
999 return Type->getIntParameter(Idx);
1000}
1001
1002/*===-- Operations on values ----------------------------------------------===*/
1003
1004/*--.. Operations on all values ............................................--*/
1005
1007 return wrap(unwrap(Val)->getType());
1008}
1009
1011 switch(unwrap(Val)->getValueID()) {
1012#define LLVM_C_API 1
1013#define HANDLE_VALUE(Name) \
1014 case Value::Name##Val: \
1015 return LLVM##Name##ValueKind;
1016#include "llvm/IR/Value.def"
1017 default:
1019 }
1020}
1021
1022const char *LLVMGetValueName2(LLVMValueRef Val, size_t *Length) {
1023 auto *V = unwrap(Val);
1024 *Length = V->getName().size();
1025 return V->getName().data();
1026}
1027
1028void LLVMSetValueName2(LLVMValueRef Val, const char *Name, size_t NameLen) {
1029 unwrap(Val)->setName(StringRef(Name, NameLen));
1030}
1031
1033 return unwrap(Val)->getName().data();
1034}
1035
1036void LLVMSetValueName(LLVMValueRef Val, const char *Name) {
1037 unwrap(Val)->setName(Name);
1038}
1039
1041 unwrap(Val)->print(errs(), /*IsForDebug=*/true);
1042}
1043
1045 std::string buf;
1046 raw_string_ostream os(buf);
1047
1048 if (unwrap(Val))
1049 unwrap(Val)->print(os);
1050 else
1051 os << "Printing <null> Value";
1052
1053 os.flush();
1054
1055 return strdup(buf.c_str());
1056}
1057
1059 return wrap(&unwrap(Val)->getContext());
1060}
1061
1063 std::string buf;
1064 raw_string_ostream os(buf);
1065
1066 if (unwrap(Record))
1067 unwrap(Record)->print(os);
1068 else
1069 os << "Printing <null> DbgRecord";
1070
1071 os.flush();
1072
1073 return strdup(buf.c_str());
1074}
1075
1077 unwrap(OldVal)->replaceAllUsesWith(unwrap(NewVal));
1078}
1079
1081 return unwrap<Instruction>(Inst)->hasMetadata();
1082}
1083
1085 auto *I = unwrap<Instruction>(Inst);
1086 assert(I && "Expected instruction");
1087 if (auto *MD = I->getMetadata(KindID))
1088 return wrap(MetadataAsValue::get(I->getContext(), MD));
1089 return nullptr;
1090}
1091
1092// MetadataAsValue uses a canonical format which strips the actual MDNode for
1093// MDNode with just a single constant value, storing just a ConstantAsMetadata
1094// This undoes this canonicalization, reconstructing the MDNode.
1096 Metadata *MD = MAV->getMetadata();
1098 "Expected a metadata node or a canonicalized constant");
1099
1100 if (MDNode *N = dyn_cast<MDNode>(MD))
1101 return N;
1102
1103 return MDNode::get(MAV->getContext(), MD);
1104}
1105
1106void LLVMSetMetadata(LLVMValueRef Inst, unsigned KindID, LLVMValueRef Val) {
1107 MDNode *N = Val ? extractMDNode(unwrap<MetadataAsValue>(Val)) : nullptr;
1108
1109 unwrap<Instruction>(Inst)->setMetadata(KindID, N);
1110}
1111
1116
1119llvm_getMetadata(size_t *NumEntries,
1120 llvm::function_ref<void(MetadataEntries &)> AccessMD) {
1122 AccessMD(MVEs);
1123
1125 static_cast<LLVMOpaqueValueMetadataEntry *>(
1127 for (unsigned i = 0; i < MVEs.size(); ++i) {
1128 const auto &ModuleFlag = MVEs[i];
1129 Result[i].Kind = ModuleFlag.first;
1130 Result[i].Metadata = wrap(ModuleFlag.second);
1131 }
1132 *NumEntries = MVEs.size();
1133 return Result;
1134}
1135
1138 size_t *NumEntries) {
1139 return llvm_getMetadata(NumEntries, [&Value](MetadataEntries &Entries) {
1140 Entries.clear();
1141 unwrap<Instruction>(Value)->getAllMetadata(Entries);
1142 });
1143}
1144
1145/*--.. Conversion functions ................................................--*/
1146
1147#define LLVM_DEFINE_VALUE_CAST(name) \
1148 LLVMValueRef LLVMIsA##name(LLVMValueRef Val) { \
1149 return wrap(static_cast<Value*>(dyn_cast_or_null<name>(unwrap(Val)))); \
1150 }
1151
1153
1155 if (auto *MD = dyn_cast_or_null<MetadataAsValue>(unwrap(Val)))
1156 if (isa<MDNode>(MD->getMetadata()) ||
1157 isa<ValueAsMetadata>(MD->getMetadata()))
1158 return Val;
1159 return nullptr;
1160}
1161
1163 if (auto *MD = dyn_cast_or_null<MetadataAsValue>(unwrap(Val)))
1164 if (isa<ValueAsMetadata>(MD->getMetadata()))
1165 return Val;
1166 return nullptr;
1167}
1168
1170 if (auto *MD = dyn_cast_or_null<MetadataAsValue>(unwrap(Val)))
1171 if (isa<MDString>(MD->getMetadata()))
1172 return Val;
1173 return nullptr;
1174}
1175
1176/*--.. Operations on Uses ..................................................--*/
1178 Value *V = unwrap(Val);
1179 Value::use_iterator I = V->use_begin();
1180 if (I == V->use_end())
1181 return nullptr;
1182 return wrap(&*I);
1183}
1184
1186 Use *Next = unwrap(U)->getNext();
1187 if (Next)
1188 return wrap(Next);
1189 return nullptr;
1190}
1191
1193 return wrap(unwrap(U)->getUser());
1194}
1195
1199
1200/*--.. Operations on Users .................................................--*/
1201
1203 unsigned Index) {
1204 Metadata *Op = N->getOperand(Index);
1205 if (!Op)
1206 return nullptr;
1207 if (auto *C = dyn_cast<ConstantAsMetadata>(Op))
1208 return wrap(C->getValue());
1209 return wrap(MetadataAsValue::get(Context, Op));
1210}
1211
1213 Value *V = unwrap(Val);
1214 if (auto *MD = dyn_cast<MetadataAsValue>(V)) {
1215 if (auto *L = dyn_cast<ValueAsMetadata>(MD->getMetadata())) {
1216 assert(Index == 0 && "Function-local metadata can only have one operand");
1217 return wrap(L->getValue());
1218 }
1219 return getMDNodeOperandImpl(V->getContext(),
1220 cast<MDNode>(MD->getMetadata()), Index);
1221 }
1222
1223 return wrap(cast<User>(V)->getOperand(Index));
1224}
1225
1227 Value *V = unwrap(Val);
1228 return wrap(&cast<User>(V)->getOperandUse(Index));
1229}
1230
1231void LLVMSetOperand(LLVMValueRef Val, unsigned Index, LLVMValueRef Op) {
1232 unwrap<User>(Val)->setOperand(Index, unwrap(Op));
1233}
1234
1236 Value *V = unwrap(Val);
1237 if (isa<MetadataAsValue>(V))
1238 return LLVMGetMDNodeNumOperands(Val);
1239
1240 return cast<User>(V)->getNumOperands();
1241}
1242
1243/*--.. Operations on constants of any type .................................--*/
1244
1248
1252
1256
1260
1264
1266 if (Constant *C = dyn_cast<Constant>(unwrap(Val)))
1267 return C->isNullValue();
1268 return false;
1269}
1270
1274
1278
1282
1283/*--.. Operations on metadata nodes ........................................--*/
1284
1286 size_t SLen) {
1287 return wrap(MDString::get(*unwrap(C), StringRef(Str, SLen)));
1288}
1289
1294
1296 unsigned SLen) {
1297 LLVMContext &Context = *unwrap(C);
1299 Context, MDString::get(Context, StringRef(Str, SLen))));
1300}
1301
1302LLVMValueRef LLVMMDString(const char *Str, unsigned SLen) {
1304}
1305
1307 unsigned Count) {
1308 LLVMContext &Context = *unwrap(C);
1310 for (auto *OV : ArrayRef(Vals, Count)) {
1311 Value *V = unwrap(OV);
1312 Metadata *MD;
1313 if (!V)
1314 MD = nullptr;
1315 else if (auto *C = dyn_cast<Constant>(V))
1317 else if (auto *MDV = dyn_cast<MetadataAsValue>(V)) {
1318 MD = MDV->getMetadata();
1319 assert(!isa<LocalAsMetadata>(MD) && "Unexpected function-local metadata "
1320 "outside of direct argument to call");
1321 } else {
1322 // This is function-local metadata. Pretend to make an MDNode.
1323 assert(Count == 1 &&
1324 "Expected only one operand to function-local metadata");
1325 return wrap(MetadataAsValue::get(Context, LocalAsMetadata::get(V)));
1326 }
1327
1328 MDs.push_back(MD);
1329 }
1330 return wrap(MetadataAsValue::get(Context, MDNode::get(Context, MDs)));
1331}
1332
1336
1340
1342 auto *V = unwrap(Val);
1343 if (auto *C = dyn_cast<Constant>(V))
1345 if (auto *MAV = dyn_cast<MetadataAsValue>(V))
1346 return wrap(MAV->getMetadata());
1347 return wrap(ValueAsMetadata::get(V));
1348}
1349
1350const char *LLVMGetMDString(LLVMValueRef V, unsigned *Length) {
1351 if (const auto *MD = dyn_cast<MetadataAsValue>(unwrap(V)))
1352 if (const MDString *S = dyn_cast<MDString>(MD->getMetadata())) {
1353 *Length = S->getString().size();
1354 return S->getString().data();
1355 }
1356 *Length = 0;
1357 return nullptr;
1358}
1359
1361 auto *MD = unwrap<MetadataAsValue>(V);
1362 if (isa<ValueAsMetadata>(MD->getMetadata()))
1363 return 1;
1364 return cast<MDNode>(MD->getMetadata())->getNumOperands();
1365}
1366
1368 Module *Mod = unwrap(M);
1369 Module::named_metadata_iterator I = Mod->named_metadata_begin();
1370 if (I == Mod->named_metadata_end())
1371 return nullptr;
1372 return wrap(&*I);
1373}
1374
1376 Module *Mod = unwrap(M);
1377 Module::named_metadata_iterator I = Mod->named_metadata_end();
1378 if (I == Mod->named_metadata_begin())
1379 return nullptr;
1380 return wrap(&*--I);
1381}
1382
1384 NamedMDNode *NamedNode = unwrap(NMD);
1386 if (++I == NamedNode->getParent()->named_metadata_end())
1387 return nullptr;
1388 return wrap(&*I);
1389}
1390
1392 NamedMDNode *NamedNode = unwrap(NMD);
1394 if (I == NamedNode->getParent()->named_metadata_begin())
1395 return nullptr;
1396 return wrap(&*--I);
1397}
1398
1400 const char *Name, size_t NameLen) {
1401 return wrap(unwrap(M)->getNamedMetadata(StringRef(Name, NameLen)));
1402}
1403
1405 const char *Name, size_t NameLen) {
1406 return wrap(unwrap(M)->getOrInsertNamedMetadata({Name, NameLen}));
1407}
1408
1409const char *LLVMGetNamedMetadataName(LLVMNamedMDNodeRef NMD, size_t *NameLen) {
1410 NamedMDNode *NamedNode = unwrap(NMD);
1411 *NameLen = NamedNode->getName().size();
1412 return NamedNode->getName().data();
1413}
1414
1416 auto *MD = unwrap<MetadataAsValue>(V);
1417 if (auto *MDV = dyn_cast<ValueAsMetadata>(MD->getMetadata())) {
1418 *Dest = wrap(MDV->getValue());
1419 return;
1420 }
1421 const auto *N = cast<MDNode>(MD->getMetadata());
1422 const unsigned numOperands = N->getNumOperands();
1423 LLVMContext &Context = unwrap(V)->getContext();
1424 for (unsigned i = 0; i < numOperands; i++)
1425 Dest[i] = getMDNodeOperandImpl(Context, N, i);
1426}
1427
1429 LLVMMetadataRef Replacement) {
1430 auto *MD = cast<MetadataAsValue>(unwrap(V));
1431 auto *N = cast<MDNode>(MD->getMetadata());
1432 N->replaceOperandWith(Index, unwrap<Metadata>(Replacement));
1433}
1434
1435unsigned LLVMGetNamedMetadataNumOperands(LLVMModuleRef M, const char *Name) {
1436 if (NamedMDNode *N = unwrap(M)->getNamedMetadata(Name)) {
1437 return N->getNumOperands();
1438 }
1439 return 0;
1440}
1441
1443 LLVMValueRef *Dest) {
1444 NamedMDNode *N = unwrap(M)->getNamedMetadata(Name);
1445 if (!N)
1446 return;
1447 LLVMContext &Context = unwrap(M)->getContext();
1448 for (unsigned i=0;i<N->getNumOperands();i++)
1449 Dest[i] = wrap(MetadataAsValue::get(Context, N->getOperand(i)));
1450}
1451
1453 LLVMValueRef Val) {
1454 NamedMDNode *N = unwrap(M)->getOrInsertNamedMetadata(Name);
1455 if (!N)
1456 return;
1457 if (!Val)
1458 return;
1459 N->addOperand(extractMDNode(unwrap<MetadataAsValue>(Val)));
1460}
1461
1462const char *LLVMGetDebugLocDirectory(LLVMValueRef Val, unsigned *Length) {
1463 if (!Length) return nullptr;
1464 StringRef S;
1465 if (const auto *I = dyn_cast<Instruction>(unwrap(Val))) {
1466 if (const auto &DL = I->getDebugLoc()) {
1467 S = DL->getDirectory();
1468 }
1469 } else if (const auto *GV = dyn_cast<GlobalVariable>(unwrap(Val))) {
1471 GV->getDebugInfo(GVEs);
1472 if (GVEs.size())
1473 if (const DIGlobalVariable *DGV = GVEs[0]->getVariable())
1474 S = DGV->getDirectory();
1475 } else if (const auto *F = dyn_cast<Function>(unwrap(Val))) {
1476 if (const DISubprogram *DSP = F->getSubprogram())
1477 S = DSP->getDirectory();
1478 } else {
1479 assert(0 && "Expected Instruction, GlobalVariable or Function");
1480 return nullptr;
1481 }
1482 *Length = S.size();
1483 return S.data();
1484}
1485
1486const char *LLVMGetDebugLocFilename(LLVMValueRef Val, unsigned *Length) {
1487 if (!Length) return nullptr;
1488 StringRef S;
1489 if (const auto *I = dyn_cast<Instruction>(unwrap(Val))) {
1490 if (const auto &DL = I->getDebugLoc()) {
1491 S = DL->getFilename();
1492 }
1493 } else if (const auto *GV = dyn_cast<GlobalVariable>(unwrap(Val))) {
1495 GV->getDebugInfo(GVEs);
1496 if (GVEs.size())
1497 if (const DIGlobalVariable *DGV = GVEs[0]->getVariable())
1498 S = DGV->getFilename();
1499 } else if (const auto *F = dyn_cast<Function>(unwrap(Val))) {
1500 if (const DISubprogram *DSP = F->getSubprogram())
1501 S = DSP->getFilename();
1502 } else {
1503 assert(0 && "Expected Instruction, GlobalVariable or Function");
1504 return nullptr;
1505 }
1506 *Length = S.size();
1507 return S.data();
1508}
1509
1511 unsigned L = 0;
1512 if (const auto *I = dyn_cast<Instruction>(unwrap(Val))) {
1513 if (const auto &DL = I->getDebugLoc()) {
1514 L = DL->getLine();
1515 }
1516 } else if (const auto *GV = dyn_cast<GlobalVariable>(unwrap(Val))) {
1518 GV->getDebugInfo(GVEs);
1519 if (GVEs.size())
1520 if (const DIGlobalVariable *DGV = GVEs[0]->getVariable())
1521 L = DGV->getLine();
1522 } else if (const auto *F = dyn_cast<Function>(unwrap(Val))) {
1523 if (const DISubprogram *DSP = F->getSubprogram())
1524 L = DSP->getLine();
1525 } else {
1526 assert(0 && "Expected Instruction, GlobalVariable or Function");
1527 return -1;
1528 }
1529 return L;
1530}
1531
1533 unsigned C = 0;
1534 if (const auto *I = dyn_cast<Instruction>(unwrap(Val)))
1535 if (const auto &DL = I->getDebugLoc())
1536 C = DL->getColumn();
1537 return C;
1538}
1539
1540/*--.. Operations on scalar constants ......................................--*/
1541
1542LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N,
1543 LLVMBool SignExtend) {
1544 return wrap(ConstantInt::get(unwrap<IntegerType>(IntTy), N, SignExtend != 0));
1545}
1546
1548 unsigned NumWords,
1549 const uint64_t Words[]) {
1550 IntegerType *Ty = unwrap<IntegerType>(IntTy);
1551 return wrap(ConstantInt::get(
1552 Ty->getContext(), APInt(Ty->getBitWidth(), ArrayRef(Words, NumWords))));
1553}
1554
1556 uint8_t Radix) {
1557 return wrap(ConstantInt::get(unwrap<IntegerType>(IntTy), StringRef(Str),
1558 Radix));
1559}
1560
1562 unsigned SLen, uint8_t Radix) {
1563 return wrap(ConstantInt::get(unwrap<IntegerType>(IntTy), StringRef(Str, SLen),
1564 Radix));
1565}
1566
1568 return wrap(ConstantFP::get(unwrap(RealTy), N));
1569}
1570
1572 return wrap(ConstantFP::get(unwrap(RealTy), StringRef(Text)));
1573}
1574
1576 unsigned SLen) {
1577 return wrap(ConstantFP::get(unwrap(RealTy), StringRef(Str, SLen)));
1578}
1579
1581 Type *T = unwrap(Ty);
1582 unsigned SB = T->getScalarSizeInBits();
1583 APInt AI(SB, ArrayRef<uint64_t>(N, divideCeil(SB, 64)));
1584 APFloat Quad(T->getFltSemantics(), AI);
1585 return wrap(ConstantFP::get(T, Quad));
1586}
1587
1588unsigned long long LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal) {
1589 return unwrap<ConstantInt>(ConstantVal)->getZExtValue();
1590}
1591
1593 return unwrap<ConstantInt>(ConstantVal)->getSExtValue();
1594}
1595
1596double LLVMConstRealGetDouble(LLVMValueRef ConstantVal, LLVMBool *LosesInfo) {
1597 ConstantFP *cFP = unwrap<ConstantFP>(ConstantVal) ;
1598 Type *Ty = cFP->getType();
1599
1600 if (Ty->isHalfTy() || Ty->isBFloatTy() || Ty->isFloatTy() ||
1601 Ty->isDoubleTy()) {
1602 *LosesInfo = false;
1603 return cFP->getValueAPF().convertToDouble();
1604 }
1605
1606 bool APFLosesInfo;
1607 APFloat APF = cFP->getValueAPF();
1609 *LosesInfo = APFLosesInfo;
1610 return APF.convertToDouble();
1611}
1612
1613/*--.. Operations on composite constants ...................................--*/
1614
1616 unsigned Length,
1617 LLVMBool DontNullTerminate) {
1618 /* Inverted the sense of AddNull because ', 0)' is a
1619 better mnemonic for null termination than ', 1)'. */
1621 DontNullTerminate == 0));
1622}
1623
1625 size_t Length,
1626 LLVMBool DontNullTerminate) {
1627 /* Inverted the sense of AddNull because ', 0)' is a
1628 better mnemonic for null termination than ', 1)'. */
1630 DontNullTerminate == 0));
1631}
1632
1633LLVMValueRef LLVMConstString(const char *Str, unsigned Length,
1634 LLVMBool DontNullTerminate) {
1636 DontNullTerminate);
1637}
1638
1640 return wrap(unwrap<Constant>(C)->getAggregateElement(Idx));
1641}
1642
1644 return wrap(unwrap<ConstantDataSequential>(C)->getElementAsConstant(idx));
1645}
1646
1650
1651const char *LLVMGetAsString(LLVMValueRef C, size_t *Length) {
1653 *Length = Str.size();
1654 return Str.data();
1655}
1656
1657const char *LLVMGetRawDataValues(LLVMValueRef C, size_t *SizeInBytes) {
1658 StringRef Str = unwrap<ConstantDataSequential>(C)->getRawDataValues();
1659 *SizeInBytes = Str.size();
1660 return Str.data();
1661}
1662
1664 LLVMValueRef *ConstantVals, unsigned Length) {
1666 return wrap(ConstantArray::get(ArrayType::get(unwrap(ElementTy), Length), V));
1667}
1668
1670 uint64_t Length) {
1672 return wrap(ConstantArray::get(ArrayType::get(unwrap(ElementTy), Length), V));
1673}
1674
1676 size_t SizeInBytes) {
1677 Type *Ty = unwrap(ElementTy);
1678 size_t Len = SizeInBytes / (Ty->getPrimitiveSizeInBits() / 8);
1679 return wrap(ConstantDataArray::getRaw(StringRef(Data, SizeInBytes), Len, Ty));
1680}
1681
1683 LLVMValueRef *ConstantVals,
1684 unsigned Count, LLVMBool Packed) {
1685 Constant **Elements = unwrap<Constant>(ConstantVals, Count);
1686 return wrap(ConstantStruct::getAnon(*unwrap(C), ArrayRef(Elements, Count),
1687 Packed != 0));
1688}
1689
1691 LLVMBool Packed) {
1693 Count, Packed);
1694}
1695
1697 LLVMValueRef *ConstantVals,
1698 unsigned Count) {
1699 Constant **Elements = unwrap<Constant>(ConstantVals, Count);
1700 StructType *Ty = unwrap<StructType>(StructTy);
1701
1702 return wrap(ConstantStruct::get(Ty, ArrayRef(Elements, Count)));
1703}
1704
1705LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size) {
1707 ArrayRef(unwrap<Constant>(ScalarConstantVals, Size), Size)));
1708}
1709
1718
1719/*-- Opcode mapping */
1720
1722{
1723 switch (opcode) {
1724 default: llvm_unreachable("Unhandled Opcode.");
1725#define HANDLE_INST(num, opc, clas) case num: return LLVM##opc;
1726#include "llvm/IR/Instruction.def"
1727#undef HANDLE_INST
1728 }
1729}
1730
1732{
1733 switch (code) {
1734#define HANDLE_INST(num, opc, clas) case LLVM##opc: return num;
1735#include "llvm/IR/Instruction.def"
1736#undef HANDLE_INST
1737 }
1738 llvm_unreachable("Unhandled Opcode.");
1739}
1740
1741/*-- GEP wrap flag conversions */
1742
1744 GEPNoWrapFlags NewGEPFlags;
1745 if ((GEPFlags & LLVMGEPFlagInBounds) != 0)
1746 NewGEPFlags |= GEPNoWrapFlags::inBounds();
1747 if ((GEPFlags & LLVMGEPFlagNUSW) != 0)
1748 NewGEPFlags |= GEPNoWrapFlags::noUnsignedSignedWrap();
1749 if ((GEPFlags & LLVMGEPFlagNUW) != 0)
1750 NewGEPFlags |= GEPNoWrapFlags::noUnsignedWrap();
1751
1752 return NewGEPFlags;
1753}
1754
1756 LLVMGEPNoWrapFlags NewGEPFlags = 0;
1757 if (GEPFlags.isInBounds())
1758 NewGEPFlags |= LLVMGEPFlagInBounds;
1759 if (GEPFlags.hasNoUnsignedSignedWrap())
1760 NewGEPFlags |= LLVMGEPFlagNUSW;
1761 if (GEPFlags.hasNoUnsignedWrap())
1762 NewGEPFlags |= LLVMGEPFlagNUW;
1763
1764 return NewGEPFlags;
1765}
1766
1767/*--.. Constant expressions ................................................--*/
1768
1772
1776
1780
1782 return wrap(ConstantExpr::getNeg(unwrap<Constant>(ConstantVal)));
1783}
1784
1788
1792
1793
1795 return wrap(ConstantExpr::getNot(unwrap<Constant>(ConstantVal)));
1796}
1797
1799 return wrap(ConstantExpr::getAdd(unwrap<Constant>(LHSConstant),
1800 unwrap<Constant>(RHSConstant)));
1801}
1802
1804 LLVMValueRef RHSConstant) {
1805 return wrap(ConstantExpr::getNSWAdd(unwrap<Constant>(LHSConstant),
1806 unwrap<Constant>(RHSConstant)));
1807}
1808
1810 LLVMValueRef RHSConstant) {
1811 return wrap(ConstantExpr::getNUWAdd(unwrap<Constant>(LHSConstant),
1812 unwrap<Constant>(RHSConstant)));
1813}
1814
1816 return wrap(ConstantExpr::getSub(unwrap<Constant>(LHSConstant),
1817 unwrap<Constant>(RHSConstant)));
1818}
1819
1821 LLVMValueRef RHSConstant) {
1822 return wrap(ConstantExpr::getNSWSub(unwrap<Constant>(LHSConstant),
1823 unwrap<Constant>(RHSConstant)));
1824}
1825
1827 LLVMValueRef RHSConstant) {
1828 return wrap(ConstantExpr::getNUWSub(unwrap<Constant>(LHSConstant),
1829 unwrap<Constant>(RHSConstant)));
1830}
1831
1833 return wrap(ConstantExpr::getXor(unwrap<Constant>(LHSConstant),
1834 unwrap<Constant>(RHSConstant)));
1835}
1836
1838 LLVMValueRef *ConstantIndices, unsigned NumIndices) {
1839 ArrayRef<Constant *> IdxList(unwrap<Constant>(ConstantIndices, NumIndices),
1840 NumIndices);
1841 Constant *Val = unwrap<Constant>(ConstantVal);
1842 return wrap(ConstantExpr::getGetElementPtr(unwrap(Ty), Val, IdxList));
1843}
1844
1846 LLVMValueRef *ConstantIndices,
1847 unsigned NumIndices) {
1848 ArrayRef<Constant *> IdxList(unwrap<Constant>(ConstantIndices, NumIndices),
1849 NumIndices);
1850 Constant *Val = unwrap<Constant>(ConstantVal);
1851 return wrap(ConstantExpr::getInBoundsGetElementPtr(unwrap(Ty), Val, IdxList));
1852}
1853
1855 LLVMValueRef ConstantVal,
1856 LLVMValueRef *ConstantIndices,
1857 unsigned NumIndices,
1858 LLVMGEPNoWrapFlags NoWrapFlags) {
1859 ArrayRef<Constant *> IdxList(unwrap<Constant>(ConstantIndices, NumIndices),
1860 NumIndices);
1861 Constant *Val = unwrap<Constant>(ConstantVal);
1863 unwrap(Ty), Val, IdxList, mapFromLLVMGEPNoWrapFlags(NoWrapFlags)));
1864}
1865
1867 return wrap(ConstantExpr::getTrunc(unwrap<Constant>(ConstantVal),
1868 unwrap(ToType)));
1869}
1870
1873 unwrap(ToType)));
1874}
1875
1878 unwrap(ToType)));
1879}
1880
1883 unwrap(ToType)));
1884}
1885
1887 LLVMTypeRef ToType) {
1889 unwrap(ToType)));
1890}
1891
1893 LLVMTypeRef ToType) {
1895 unwrap(ToType)));
1896}
1897
1899 LLVMTypeRef ToType) {
1901 unwrap(ToType)));
1902}
1903
1905 LLVMValueRef IndexConstant) {
1907 unwrap<Constant>(IndexConstant)));
1908}
1909
1911 LLVMValueRef ElementValueConstant,
1912 LLVMValueRef IndexConstant) {
1914 unwrap<Constant>(ElementValueConstant),
1915 unwrap<Constant>(IndexConstant)));
1916}
1917
1919 LLVMValueRef VectorBConstant,
1920 LLVMValueRef MaskConstant) {
1921 SmallVector<int, 16> IntMask;
1924 unwrap<Constant>(VectorBConstant),
1925 IntMask));
1926}
1927
1929 const char *Constraints,
1930 LLVMBool HasSideEffects,
1931 LLVMBool IsAlignStack) {
1932 return wrap(InlineAsm::get(dyn_cast<FunctionType>(unwrap(Ty)), AsmString,
1933 Constraints, HasSideEffects, IsAlignStack));
1934}
1935
1939
1943
1945 return wrap(unwrap<BlockAddress>(BlockAddr)->getBasicBlock());
1946}
1947
1948/*--.. Operations on global variables, functions, and aliases (globals) ....--*/
1949
1953
1957
1986
1989
1990 switch (Linkage) {
1993 break;
1996 break;
1999 break;
2002 break;
2004 LLVM_DEBUG(
2005 errs() << "LLVMSetLinkage(): LLVMLinkOnceODRAutoHideLinkage is no "
2006 "longer supported.");
2007 break;
2008 case LLVMWeakAnyLinkage:
2010 break;
2011 case LLVMWeakODRLinkage:
2013 break;
2016 break;
2019 break;
2020 case LLVMPrivateLinkage:
2022 break;
2025 break;
2028 break;
2030 LLVM_DEBUG(
2031 errs()
2032 << "LLVMSetLinkage(): LLVMDLLImportLinkage is no longer supported.");
2033 break;
2035 LLVM_DEBUG(
2036 errs()
2037 << "LLVMSetLinkage(): LLVMDLLExportLinkage is no longer supported.");
2038 break;
2041 break;
2042 case LLVMGhostLinkage:
2043 LLVM_DEBUG(
2044 errs() << "LLVMSetLinkage(): LLVMGhostLinkage is no longer supported.");
2045 break;
2046 case LLVMCommonLinkage:
2048 break;
2049 }
2050}
2051
2053 // Using .data() is safe because of how GlobalObject::setSection is
2054 // implemented.
2055 return unwrap<GlobalValue>(Global)->getSection().data();
2056}
2057
2058void LLVMSetSection(LLVMValueRef Global, const char *Section) {
2059 unwrap<GlobalObject>(Global)->setSection(Section);
2060}
2061
2063 return static_cast<LLVMVisibility>(
2064 unwrap<GlobalValue>(Global)->getVisibility());
2065}
2066
2069 ->setVisibility(static_cast<GlobalValue::VisibilityTypes>(Viz));
2070}
2071
2073 return static_cast<LLVMDLLStorageClass>(
2074 unwrap<GlobalValue>(Global)->getDLLStorageClass());
2075}
2076
2078 unwrap<GlobalValue>(Global)->setDLLStorageClass(
2079 static_cast<GlobalValue::DLLStorageClassTypes>(Class));
2080}
2081
2093
2106
2108 return unwrap<GlobalValue>(Global)->hasGlobalUnnamedAddr();
2109}
2110
2112 unwrap<GlobalValue>(Global)->setUnnamedAddr(
2113 HasUnnamedAddr ? GlobalValue::UnnamedAddr::Global
2115}
2116
2120
2121/*--.. Operations on global variables, load and store instructions .........--*/
2122
2124 Value *P = unwrap(V);
2126 return GV->getAlign() ? GV->getAlign()->value() : 0;
2128 return F->getAlign() ? F->getAlign()->value() : 0;
2130 return AI->getAlign().value();
2131 if (LoadInst *LI = dyn_cast<LoadInst>(P))
2132 return LI->getAlign().value();
2134 return SI->getAlign().value();
2136 return RMWI->getAlign().value();
2138 return CXI->getAlign().value();
2139
2141 "only GlobalValue, AllocaInst, LoadInst, StoreInst, AtomicRMWInst, "
2142 "and AtomicCmpXchgInst have alignment");
2143}
2144
2145void LLVMSetAlignment(LLVMValueRef V, unsigned Bytes) {
2146 Value *P = unwrap(V);
2148 GV->setAlignment(MaybeAlign(Bytes));
2149 else if (Function *F = dyn_cast<Function>(P))
2150 F->setAlignment(MaybeAlign(Bytes));
2151 else if (AllocaInst *AI = dyn_cast<AllocaInst>(P))
2152 AI->setAlignment(Align(Bytes));
2153 else if (LoadInst *LI = dyn_cast<LoadInst>(P))
2154 LI->setAlignment(Align(Bytes));
2155 else if (StoreInst *SI = dyn_cast<StoreInst>(P))
2156 SI->setAlignment(Align(Bytes));
2157 else if (AtomicRMWInst *RMWI = dyn_cast<AtomicRMWInst>(P))
2158 RMWI->setAlignment(Align(Bytes));
2160 CXI->setAlignment(Align(Bytes));
2161 else
2163 "only GlobalValue, AllocaInst, LoadInst, StoreInst, AtomicRMWInst, and "
2164 "and AtomicCmpXchgInst have alignment");
2165}
2166
2168 size_t *NumEntries) {
2169 return llvm_getMetadata(NumEntries, [&Value](MetadataEntries &Entries) {
2170 Entries.clear();
2172 Instr->getAllMetadata(Entries);
2173 } else {
2174 unwrap<GlobalObject>(Value)->getAllMetadata(Entries);
2175 }
2176 });
2177}
2178
2180 unsigned Index) {
2182 static_cast<LLVMOpaqueValueMetadataEntry>(Entries[Index]);
2183 return MVE.Kind;
2184}
2185
2188 unsigned Index) {
2190 static_cast<LLVMOpaqueValueMetadataEntry>(Entries[Index]);
2191 return MVE.Metadata;
2192}
2193
2195 free(Entries);
2196}
2197
2199 LLVMMetadataRef MD) {
2200 unwrap<GlobalObject>(Global)->setMetadata(Kind, unwrap<MDNode>(MD));
2201}
2202
2204 LLVMMetadataRef MD) {
2205 unwrap<GlobalObject>(Global)->addMetadata(Kind, *unwrap<MDNode>(MD));
2206}
2207
2209 unwrap<GlobalObject>(Global)->eraseMetadata(Kind);
2210}
2211
2215
2220
2221/*--.. Operations on global variables ......................................--*/
2222
2224 return wrap(new GlobalVariable(*unwrap(M), unwrap(Ty), false,
2225 GlobalValue::ExternalLinkage, nullptr, Name));
2226}
2227
2229 const char *Name,
2230 unsigned AddressSpace) {
2231 return wrap(new GlobalVariable(*unwrap(M), unwrap(Ty), false,
2232 GlobalValue::ExternalLinkage, nullptr, Name,
2234 AddressSpace));
2235}
2236
2238 return wrap(unwrap(M)->getNamedGlobal(Name));
2239}
2240
2242 size_t Length) {
2243 return wrap(unwrap(M)->getNamedGlobal(StringRef(Name, Length)));
2244}
2245
2247 Module *Mod = unwrap(M);
2248 Module::global_iterator I = Mod->global_begin();
2249 if (I == Mod->global_end())
2250 return nullptr;
2251 return wrap(&*I);
2252}
2253
2255 Module *Mod = unwrap(M);
2256 Module::global_iterator I = Mod->global_end();
2257 if (I == Mod->global_begin())
2258 return nullptr;
2259 return wrap(&*--I);
2260}
2261
2263 GlobalVariable *GV = unwrap<GlobalVariable>(GlobalVar);
2265 if (++I == GV->getParent()->global_end())
2266 return nullptr;
2267 return wrap(&*I);
2268}
2269
2271 GlobalVariable *GV = unwrap<GlobalVariable>(GlobalVar);
2273 if (I == GV->getParent()->global_begin())
2274 return nullptr;
2275 return wrap(&*--I);
2276}
2277
2279 unwrap<GlobalVariable>(GlobalVar)->eraseFromParent();
2280}
2281
2283 GlobalVariable* GV = unwrap<GlobalVariable>(GlobalVar);
2284 if ( !GV->hasInitializer() )
2285 return nullptr;
2286 return wrap(GV->getInitializer());
2287}
2288
2289void LLVMSetInitializer(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal) {
2290 unwrap<GlobalVariable>(GlobalVar)->setInitializer(
2291 ConstantVal ? unwrap<Constant>(ConstantVal) : nullptr);
2292}
2293
2295 return unwrap<GlobalVariable>(GlobalVar)->isThreadLocal();
2296}
2297
2298void LLVMSetThreadLocal(LLVMValueRef GlobalVar, LLVMBool IsThreadLocal) {
2299 unwrap<GlobalVariable>(GlobalVar)->setThreadLocal(IsThreadLocal != 0);
2300}
2301
2303 return unwrap<GlobalVariable>(GlobalVar)->isConstant();
2304}
2305
2306void LLVMSetGlobalConstant(LLVMValueRef GlobalVar, LLVMBool IsConstant) {
2307 unwrap<GlobalVariable>(GlobalVar)->setConstant(IsConstant != 0);
2308}
2309
2311 switch (unwrap<GlobalVariable>(GlobalVar)->getThreadLocalMode()) {
2313 return LLVMNotThreadLocal;
2321 return LLVMLocalExecTLSModel;
2322 }
2323
2324 llvm_unreachable("Invalid GlobalVariable thread local mode");
2325}
2326
2348
2350 return unwrap<GlobalVariable>(GlobalVar)->isExternallyInitialized();
2351}
2352
2354 unwrap<GlobalVariable>(GlobalVar)->setExternallyInitialized(IsExtInit);
2355}
2356
2357/*--.. Operations on aliases ......................................--*/
2358
2360 unsigned AddrSpace, LLVMValueRef Aliasee,
2361 const char *Name) {
2362 return wrap(GlobalAlias::create(unwrap(ValueTy), AddrSpace,
2364 unwrap<Constant>(Aliasee), unwrap(M)));
2365}
2366
2368 const char *Name, size_t NameLen) {
2369 return wrap(unwrap(M)->getNamedAlias(StringRef(Name, NameLen)));
2370}
2371
2373 Module *Mod = unwrap(M);
2374 Module::alias_iterator I = Mod->alias_begin();
2375 if (I == Mod->alias_end())
2376 return nullptr;
2377 return wrap(&*I);
2378}
2379
2381 Module *Mod = unwrap(M);
2382 Module::alias_iterator I = Mod->alias_end();
2383 if (I == Mod->alias_begin())
2384 return nullptr;
2385 return wrap(&*--I);
2386}
2387
2389 GlobalAlias *Alias = unwrap<GlobalAlias>(GA);
2391 if (++I == Alias->getParent()->alias_end())
2392 return nullptr;
2393 return wrap(&*I);
2394}
2395
2397 GlobalAlias *Alias = unwrap<GlobalAlias>(GA);
2399 if (I == Alias->getParent()->alias_begin())
2400 return nullptr;
2401 return wrap(&*--I);
2402}
2403
2405 return wrap(unwrap<GlobalAlias>(Alias)->getAliasee());
2406}
2407
2409 unwrap<GlobalAlias>(Alias)->setAliasee(unwrap<Constant>(Aliasee));
2410}
2411
2412/*--.. Operations on functions .............................................--*/
2413
2415 LLVMTypeRef FunctionTy) {
2416 return wrap(Function::Create(unwrap<FunctionType>(FunctionTy),
2418}
2419
2421 size_t NameLen, LLVMTypeRef FunctionTy) {
2422 return wrap(unwrap(M)
2423 ->getOrInsertFunction(StringRef(Name, NameLen),
2424 unwrap<FunctionType>(FunctionTy))
2425 .getCallee());
2426}
2427
2429 return wrap(unwrap(M)->getFunction(Name));
2430}
2431
2433 size_t Length) {
2434 return wrap(unwrap(M)->getFunction(StringRef(Name, Length)));
2435}
2436
2438 Module *Mod = unwrap(M);
2439 Module::iterator I = Mod->begin();
2440 if (I == Mod->end())
2441 return nullptr;
2442 return wrap(&*I);
2443}
2444
2446 Module *Mod = unwrap(M);
2447 Module::iterator I = Mod->end();
2448 if (I == Mod->begin())
2449 return nullptr;
2450 return wrap(&*--I);
2451}
2452
2454 Function *Func = unwrap<Function>(Fn);
2455 Module::iterator I(Func);
2456 if (++I == Func->getParent()->end())
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()->begin())
2465 return nullptr;
2466 return wrap(&*--I);
2467}
2468
2470 unwrap<Function>(Fn)->eraseFromParent();
2471}
2472
2474 return unwrap<Function>(Fn)->hasPersonalityFn();
2475}
2476
2478 return wrap(unwrap<Function>(Fn)->getPersonalityFn());
2479}
2480
2482 unwrap<Function>(Fn)->setPersonalityFn(
2483 PersonalityFn ? unwrap<Constant>(PersonalityFn) : nullptr);
2484}
2485
2487 if (Function *F = dyn_cast<Function>(unwrap(Fn)))
2488 return F->getIntrinsicID();
2489 return 0;
2490}
2491
2493 assert(ID < llvm::Intrinsic::num_intrinsics && "Intrinsic ID out of range");
2494 return llvm::Intrinsic::ID(ID);
2495}
2496
2498 unsigned ID,
2499 LLVMTypeRef *ParamTypes,
2500 size_t ParamCount) {
2501 ArrayRef<Type*> Tys(unwrap(ParamTypes), ParamCount);
2502 auto IID = llvm_map_to_intrinsic_id(ID);
2504}
2505
2506const char *LLVMIntrinsicGetName(unsigned ID, size_t *NameLength) {
2507 auto IID = llvm_map_to_intrinsic_id(ID);
2508 auto Str = llvm::Intrinsic::getName(IID);
2509 *NameLength = Str.size();
2510 return Str.data();
2511}
2512
2514 LLVMTypeRef *ParamTypes, size_t ParamCount) {
2515 auto IID = llvm_map_to_intrinsic_id(ID);
2516 ArrayRef<Type*> Tys(unwrap(ParamTypes), ParamCount);
2517 return wrap(llvm::Intrinsic::getType(*unwrap(Ctx), IID, Tys));
2518}
2519
2521 size_t ParamCount, size_t *NameLength) {
2522 auto IID = llvm_map_to_intrinsic_id(ID);
2523 ArrayRef<Type*> Tys(unwrap(ParamTypes), ParamCount);
2524 auto Str = llvm::Intrinsic::getNameNoUnnamedTypes(IID, Tys);
2525 *NameLength = Str.length();
2526 return strdup(Str.c_str());
2527}
2528
2530 LLVMTypeRef *ParamTypes,
2531 size_t ParamCount, size_t *NameLength) {
2532 auto IID = llvm_map_to_intrinsic_id(ID);
2533 ArrayRef<Type *> Tys(unwrap(ParamTypes), ParamCount);
2534 auto Str = llvm::Intrinsic::getName(IID, Tys, unwrap(Mod));
2535 *NameLength = Str.length();
2536 return strdup(Str.c_str());
2537}
2538
2539unsigned LLVMLookupIntrinsicID(const char *Name, size_t NameLen) {
2540 return Intrinsic::lookupIntrinsicID({Name, NameLen});
2541}
2542
2547
2549 return unwrap<Function>(Fn)->getCallingConv();
2550}
2551
2553 return unwrap<Function>(Fn)->setCallingConv(
2554 static_cast<CallingConv::ID>(CC));
2555}
2556
2557const char *LLVMGetGC(LLVMValueRef Fn) {
2559 return F->hasGC()? F->getGC().c_str() : nullptr;
2560}
2561
2562void LLVMSetGC(LLVMValueRef Fn, const char *GC) {
2564 if (GC)
2565 F->setGC(GC);
2566 else
2567 F->clearGC();
2568}
2569
2572 return wrap(F->getPrefixData());
2573}
2574
2577 return F->hasPrefixData();
2578}
2579
2582 Constant *prefix = unwrap<Constant>(prefixData);
2583 F->setPrefixData(prefix);
2584}
2585
2588 return wrap(F->getPrologueData());
2589}
2590
2593 return F->hasPrologueData();
2594}
2595
2598 Constant *prologue = unwrap<Constant>(prologueData);
2599 F->setPrologueData(prologue);
2600}
2601
2604 unwrap<Function>(F)->addAttributeAtIndex(Idx, unwrap(A));
2605}
2606
2608 auto AS = unwrap<Function>(F)->getAttributes().getAttributes(Idx);
2609 return AS.getNumAttributes();
2610}
2611
2613 LLVMAttributeRef *Attrs) {
2614 auto AS = unwrap<Function>(F)->getAttributes().getAttributes(Idx);
2615 for (auto A : AS)
2616 *Attrs++ = wrap(A);
2617}
2618
2621 unsigned KindID) {
2622 return wrap(unwrap<Function>(F)->getAttributeAtIndex(
2623 Idx, (Attribute::AttrKind)KindID));
2624}
2625
2628 const char *K, unsigned KLen) {
2629 return wrap(
2630 unwrap<Function>(F)->getAttributeAtIndex(Idx, StringRef(K, KLen)));
2631}
2632
2634 unsigned KindID) {
2635 unwrap<Function>(F)->removeAttributeAtIndex(Idx, (Attribute::AttrKind)KindID);
2636}
2637
2639 const char *K, unsigned KLen) {
2640 unwrap<Function>(F)->removeAttributeAtIndex(Idx, StringRef(K, KLen));
2641}
2642
2644 const char *V) {
2645 Function *Func = unwrap<Function>(Fn);
2646 Attribute Attr = Attribute::get(Func->getContext(), A, V);
2647 Func->addFnAttr(Attr);
2648}
2649
2650/*--.. Operations on parameters ............................................--*/
2651
2653 // This function is strictly redundant to
2654 // LLVMCountParamTypes(LLVMGlobalGetValueType(FnRef))
2655 return unwrap<Function>(FnRef)->arg_size();
2656}
2657
2658void LLVMGetParams(LLVMValueRef FnRef, LLVMValueRef *ParamRefs) {
2659 Function *Fn = unwrap<Function>(FnRef);
2660 for (Argument &A : Fn->args())
2661 *ParamRefs++ = wrap(&A);
2662}
2663
2665 Function *Fn = unwrap<Function>(FnRef);
2666 return wrap(&Fn->arg_begin()[index]);
2667}
2668
2672
2674 Function *Func = unwrap<Function>(Fn);
2675 Function::arg_iterator I = Func->arg_begin();
2676 if (I == Func->arg_end())
2677 return nullptr;
2678 return wrap(&*I);
2679}
2680
2682 Function *Func = unwrap<Function>(Fn);
2683 Function::arg_iterator I = Func->arg_end();
2684 if (I == Func->arg_begin())
2685 return nullptr;
2686 return wrap(&*--I);
2687}
2688
2690 Argument *A = unwrap<Argument>(Arg);
2691 Function *Fn = A->getParent();
2692 if (A->getArgNo() + 1 >= Fn->arg_size())
2693 return nullptr;
2694 return wrap(&Fn->arg_begin()[A->getArgNo() + 1]);
2695}
2696
2698 Argument *A = unwrap<Argument>(Arg);
2699 if (A->getArgNo() == 0)
2700 return nullptr;
2701 return wrap(&A->getParent()->arg_begin()[A->getArgNo() - 1]);
2702}
2703
2704void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align) {
2705 Argument *A = unwrap<Argument>(Arg);
2706 A->addAttr(Attribute::getWithAlignment(A->getContext(), Align(align)));
2707}
2708
2709/*--.. Operations on ifuncs ................................................--*/
2710
2712 const char *Name, size_t NameLen,
2713 LLVMTypeRef Ty, unsigned AddrSpace,
2715 return wrap(GlobalIFunc::create(unwrap(Ty), AddrSpace,
2717 StringRef(Name, NameLen),
2719}
2720
2722 const char *Name, size_t NameLen) {
2723 return wrap(unwrap(M)->getNamedIFunc(StringRef(Name, NameLen)));
2724}
2725
2727 Module *Mod = unwrap(M);
2728 Module::ifunc_iterator I = Mod->ifunc_begin();
2729 if (I == Mod->ifunc_end())
2730 return nullptr;
2731 return wrap(&*I);
2732}
2733
2735 Module *Mod = unwrap(M);
2736 Module::ifunc_iterator I = Mod->ifunc_end();
2737 if (I == Mod->ifunc_begin())
2738 return nullptr;
2739 return wrap(&*--I);
2740}
2741
2743 GlobalIFunc *GIF = unwrap<GlobalIFunc>(IFunc);
2745 if (++I == GIF->getParent()->ifunc_end())
2746 return nullptr;
2747 return wrap(&*I);
2748}
2749
2751 GlobalIFunc *GIF = unwrap<GlobalIFunc>(IFunc);
2753 if (I == GIF->getParent()->ifunc_begin())
2754 return nullptr;
2755 return wrap(&*--I);
2756}
2757
2759 return wrap(unwrap<GlobalIFunc>(IFunc)->getResolver());
2760}
2761
2765
2767 unwrap<GlobalIFunc>(IFunc)->eraseFromParent();
2768}
2769
2771 unwrap<GlobalIFunc>(IFunc)->removeFromParent();
2772}
2773
2774/*--.. Operations on operand bundles........................................--*/
2775
2776LLVMOperandBundleRef LLVMCreateOperandBundle(const char *Tag, size_t TagLen,
2777 LLVMValueRef *Args,
2778 unsigned NumArgs) {
2779 return wrap(new OperandBundleDef(std::string(Tag, TagLen),
2780 ArrayRef(unwrap(Args), NumArgs)));
2781}
2782
2784 delete unwrap(Bundle);
2785}
2786
2787const char *LLVMGetOperandBundleTag(LLVMOperandBundleRef Bundle, size_t *Len) {
2788 StringRef Str = unwrap(Bundle)->getTag();
2789 *Len = Str.size();
2790 return Str.data();
2791}
2792
2794 return unwrap(Bundle)->inputs().size();
2795}
2796
2798 unsigned Index) {
2799 return wrap(unwrap(Bundle)->inputs()[Index]);
2800}
2801
2802/*--.. Operations on basic blocks ..........................................--*/
2803
2805 return wrap(static_cast<Value*>(unwrap(BB)));
2806}
2807
2811
2815
2817 return unwrap(BB)->getName().data();
2818}
2819
2823
2825 return wrap(unwrap(BB)->getTerminator());
2826}
2827
2829 return unwrap<Function>(FnRef)->size();
2830}
2831
2833 Function *Fn = unwrap<Function>(FnRef);
2834 for (BasicBlock &BB : *Fn)
2835 *BasicBlocksRefs++ = wrap(&BB);
2836}
2837
2839 return wrap(&unwrap<Function>(Fn)->getEntryBlock());
2840}
2841
2843 Function *Func = unwrap<Function>(Fn);
2844 Function::iterator I = Func->begin();
2845 if (I == Func->end())
2846 return nullptr;
2847 return wrap(&*I);
2848}
2849
2851 Function *Func = unwrap<Function>(Fn);
2852 Function::iterator I = Func->end();
2853 if (I == Func->begin())
2854 return nullptr;
2855 return wrap(&*--I);
2856}
2857
2859 BasicBlock *Block = unwrap(BB);
2861 if (++I == Block->getParent()->end())
2862 return nullptr;
2863 return wrap(&*I);
2864}
2865
2867 BasicBlock *Block = unwrap(BB);
2869 if (I == Block->getParent()->begin())
2870 return nullptr;
2871 return wrap(&*--I);
2872}
2873
2878
2880 LLVMBasicBlockRef BB) {
2881 BasicBlock *ToInsert = unwrap(BB);
2882 BasicBlock *CurBB = unwrap(Builder)->GetInsertBlock();
2883 assert(CurBB && "current insertion point is invalid!");
2884 CurBB->getParent()->insert(std::next(CurBB->getIterator()), ToInsert);
2885}
2886
2888 LLVMBasicBlockRef BB) {
2889 unwrap<Function>(Fn)->insert(unwrap<Function>(Fn)->end(), unwrap(BB));
2890}
2891
2893 LLVMValueRef FnRef,
2894 const char *Name) {
2895 return wrap(BasicBlock::Create(*unwrap(C), Name, unwrap<Function>(FnRef)));
2896}
2897
2901
2903 LLVMBasicBlockRef BBRef,
2904 const char *Name) {
2905 BasicBlock *BB = unwrap(BBRef);
2906 return wrap(BasicBlock::Create(*unwrap(C), Name, BB->getParent(), BB));
2907}
2908
2913
2915 unwrap(BBRef)->eraseFromParent();
2916}
2917
2919 unwrap(BBRef)->removeFromParent();
2920}
2921
2923 unwrap(BB)->moveBefore(unwrap(MovePos));
2924}
2925
2927 unwrap(BB)->moveAfter(unwrap(MovePos));
2928}
2929
2930/*--.. Operations on instructions ..........................................--*/
2931
2935
2937 BasicBlock *Block = unwrap(BB);
2938 BasicBlock::iterator I = Block->begin();
2939 if (I == Block->end())
2940 return nullptr;
2941 return wrap(&*I);
2942}
2943
2945 BasicBlock *Block = unwrap(BB);
2946 BasicBlock::iterator I = Block->end();
2947 if (I == Block->begin())
2948 return nullptr;
2949 return wrap(&*--I);
2950}
2951
2953 Instruction *Instr = unwrap<Instruction>(Inst);
2954 BasicBlock::iterator I(Instr);
2955 if (++I == Instr->getParent()->end())
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()->begin())
2964 return nullptr;
2965 return wrap(&*--I);
2966}
2967
2969 unwrap<Instruction>(Inst)->removeFromParent();
2970}
2971
2973 unwrap<Instruction>(Inst)->eraseFromParent();
2974}
2975
2977 unwrap<Instruction>(Inst)->deleteValue();
2978}
2979
2981 if (ICmpInst *I = dyn_cast<ICmpInst>(unwrap(Inst)))
2982 return (LLVMIntPredicate)I->getPredicate();
2983 return (LLVMIntPredicate)0;
2984}
2985
2987 return unwrap<ICmpInst>(Inst)->hasSameSign();
2988}
2989
2991 unwrap<ICmpInst>(Inst)->setSameSign(SameSign);
2992}
2993
2995 if (FCmpInst *I = dyn_cast<FCmpInst>(unwrap(Inst)))
2996 return (LLVMRealPredicate)I->getPredicate();
2997 return (LLVMRealPredicate)0;
2998}
2999
3002 return map_to_llvmopcode(C->getOpcode());
3003 return (LLVMOpcode)0;
3004}
3005
3008 return wrap(C->clone());
3009 return nullptr;
3010}
3011
3014 return (I && I->isTerminator()) ? wrap(I) : nullptr;
3015}
3016
3018 Instruction *Instr = unwrap<Instruction>(Inst);
3019 if (!Instr->DebugMarker)
3020 return nullptr;
3021 auto I = Instr->DebugMarker->StoredDbgRecords.begin();
3022 if (I == Instr->DebugMarker->StoredDbgRecords.end())
3023 return nullptr;
3024 return wrap(&*I);
3025}
3026
3028 Instruction *Instr = unwrap<Instruction>(Inst);
3029 if (!Instr->DebugMarker)
3030 return nullptr;
3031 auto I = Instr->DebugMarker->StoredDbgRecords.rbegin();
3032 if (I == Instr->DebugMarker->StoredDbgRecords.rend())
3033 return nullptr;
3034 return wrap(&*I);
3035}
3036
3040 if (++I == Record->getInstruction()->DebugMarker->StoredDbgRecords.end())
3041 return nullptr;
3042 return wrap(&*I);
3043}
3044
3048 if (I == Record->getInstruction()->DebugMarker->StoredDbgRecords.begin())
3049 return nullptr;
3050 return wrap(&*--I);
3051}
3052
3056
3060 return LLVMDbgRecordLabel;
3062 assert(VariableRecord && "unexpected record");
3063 if (VariableRecord->isDbgDeclare())
3064 return LLVMDbgRecordDeclare;
3065 if (VariableRecord->isDbgValue())
3066 return LLVMDbgRecordValue;
3067 assert(VariableRecord->isDbgAssign() && "unexpected record");
3068 return LLVMDbgRecordAssign;
3069}
3070
3075
3079
3083
3085 if (FuncletPadInst *FPI = dyn_cast<FuncletPadInst>(unwrap(Instr))) {
3086 return FPI->arg_size();
3087 }
3088 return unwrap<CallBase>(Instr)->arg_size();
3089}
3090
3091/*--.. Call and invoke instructions ........................................--*/
3092
3094 return unwrap<CallBase>(Instr)->getCallingConv();
3095}
3096
3098 return unwrap<CallBase>(Instr)->setCallingConv(
3099 static_cast<CallingConv::ID>(CC));
3100}
3101
3103 unsigned align) {
3104 auto *Call = unwrap<CallBase>(Instr);
3105 Attribute AlignAttr =
3106 Attribute::getWithAlignment(Call->getContext(), Align(align));
3107 Call->addAttributeAtIndex(Idx, AlignAttr);
3108}
3109
3112 unwrap<CallBase>(C)->addAttributeAtIndex(Idx, unwrap(A));
3113}
3114
3116 LLVMAttributeIndex Idx) {
3117 auto *Call = unwrap<CallBase>(C);
3118 auto AS = Call->getAttributes().getAttributes(Idx);
3119 return AS.getNumAttributes();
3120}
3121
3123 LLVMAttributeRef *Attrs) {
3124 auto *Call = unwrap<CallBase>(C);
3125 auto AS = Call->getAttributes().getAttributes(Idx);
3126 for (auto A : AS)
3127 *Attrs++ = wrap(A);
3128}
3129
3132 unsigned KindID) {
3133 return wrap(unwrap<CallBase>(C)->getAttributeAtIndex(
3134 Idx, (Attribute::AttrKind)KindID));
3135}
3136
3139 const char *K, unsigned KLen) {
3140 return wrap(
3141 unwrap<CallBase>(C)->getAttributeAtIndex(Idx, StringRef(K, KLen)));
3142}
3143
3145 unsigned KindID) {
3146 unwrap<CallBase>(C)->removeAttributeAtIndex(Idx, (Attribute::AttrKind)KindID);
3147}
3148
3150 const char *K, unsigned KLen) {
3151 unwrap<CallBase>(C)->removeAttributeAtIndex(Idx, StringRef(K, KLen));
3152}
3153
3155 return wrap(unwrap<CallBase>(Instr)->getCalledOperand());
3156}
3157
3159 return wrap(unwrap<CallBase>(Instr)->getFunctionType());
3160}
3161
3163 return unwrap<CallBase>(C)->getNumOperandBundles();
3164}
3165
3167 unsigned Index) {
3168 return wrap(
3169 new OperandBundleDef(unwrap<CallBase>(C)->getOperandBundleAt(Index)));
3170}
3171
3172/*--.. Operations on call instructions (only) ..............................--*/
3173
3175 return unwrap<CallInst>(Call)->isTailCall();
3176}
3177
3179 unwrap<CallInst>(Call)->setTailCall(isTailCall);
3180}
3181
3185
3189
3190/*--.. Operations on invoke instructions (only) ............................--*/
3191
3193 return wrap(unwrap<InvokeInst>(Invoke)->getNormalDest());
3194}
3195
3198 return wrap(CRI->getUnwindDest());
3199 } else if (CatchSwitchInst *CSI = dyn_cast<CatchSwitchInst>(unwrap(Invoke))) {
3200 return wrap(CSI->getUnwindDest());
3201 }
3202 return wrap(unwrap<InvokeInst>(Invoke)->getUnwindDest());
3203}
3204
3206 unwrap<InvokeInst>(Invoke)->setNormalDest(unwrap(B));
3207}
3208
3211 return CRI->setUnwindDest(unwrap(B));
3212 } else if (CatchSwitchInst *CSI = dyn_cast<CatchSwitchInst>(unwrap(Invoke))) {
3213 return CSI->setUnwindDest(unwrap(B));
3214 }
3215 unwrap<InvokeInst>(Invoke)->setUnwindDest(unwrap(B));
3216}
3217
3219 return wrap(unwrap<CallBrInst>(CallBr)->getDefaultDest());
3220}
3221
3223 return unwrap<CallBrInst>(CallBr)->getNumIndirectDests();
3224}
3225
3227 return wrap(unwrap<CallBrInst>(CallBr)->getIndirectDest(Idx));
3228}
3229
3230/*--.. Operations on terminators ...........................................--*/
3231
3233 return unwrap<Instruction>(Term)->getNumSuccessors();
3234}
3235
3237 return wrap(unwrap<Instruction>(Term)->getSuccessor(i));
3238}
3239
3241 return unwrap<Instruction>(Term)->setSuccessor(i, unwrap(block));
3242}
3243
3244/*--.. Operations on branch instructions (only) ............................--*/
3245
3247 return unwrap<BranchInst>(Branch)->isConditional();
3248}
3249
3253
3255 return unwrap<BranchInst>(Branch)->setCondition(unwrap(Cond));
3256}
3257
3258/*--.. Operations on switch instructions (only) ............................--*/
3259
3261 return wrap(unwrap<SwitchInst>(Switch)->getDefaultDest());
3262}
3263
3264/*--.. Operations on alloca instructions (only) ............................--*/
3265
3267 return wrap(unwrap<AllocaInst>(Alloca)->getAllocatedType());
3268}
3269
3270/*--.. Operations on gep instructions (only) ...............................--*/
3271
3273 return unwrap<GEPOperator>(GEP)->isInBounds();
3274}
3275
3277 return unwrap<GetElementPtrInst>(GEP)->setIsInBounds(InBounds);
3278}
3279
3283
3288
3293
3294/*--.. Operations on phi nodes .............................................--*/
3295
3296void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues,
3297 LLVMBasicBlockRef *IncomingBlocks, unsigned Count) {
3298 PHINode *PhiVal = unwrap<PHINode>(PhiNode);
3299 for (unsigned I = 0; I != Count; ++I)
3300 PhiVal->addIncoming(unwrap(IncomingValues[I]), unwrap(IncomingBlocks[I]));
3301}
3302
3304 return unwrap<PHINode>(PhiNode)->getNumIncomingValues();
3305}
3306
3308 return wrap(unwrap<PHINode>(PhiNode)->getIncomingValue(Index));
3309}
3310
3312 return wrap(unwrap<PHINode>(PhiNode)->getIncomingBlock(Index));
3313}
3314
3315/*--.. Operations on extractvalue and insertvalue nodes ....................--*/
3316
3318 auto *I = unwrap(Inst);
3319 if (auto *GEP = dyn_cast<GEPOperator>(I))
3320 return GEP->getNumIndices();
3321 if (auto *EV = dyn_cast<ExtractValueInst>(I))
3322 return EV->getNumIndices();
3323 if (auto *IV = dyn_cast<InsertValueInst>(I))
3324 return IV->getNumIndices();
3326 "LLVMGetNumIndices applies only to extractvalue and insertvalue!");
3327}
3328
3329const unsigned *LLVMGetIndices(LLVMValueRef Inst) {
3330 auto *I = unwrap(Inst);
3331 if (auto *EV = dyn_cast<ExtractValueInst>(I))
3332 return EV->getIndices().data();
3333 if (auto *IV = dyn_cast<InsertValueInst>(I))
3334 return IV->getIndices().data();
3336 "LLVMGetIndices applies only to extractvalue and insertvalue!");
3337}
3338
3339
3340/*===-- Instruction builders ----------------------------------------------===*/
3341
3345
3349
3351 Instruction *Instr, bool BeforeDbgRecords) {
3352 BasicBlock::iterator I = Instr ? Instr->getIterator() : Block->end();
3353 I.setHeadBit(BeforeDbgRecords);
3354 Builder->SetInsertPoint(Block, I);
3355}
3356
3358 LLVMValueRef Instr) {
3359 return LLVMPositionBuilderImpl(unwrap(Builder), unwrap(Block),
3360 unwrap<Instruction>(Instr), false);
3361}
3362
3369
3372 return LLVMPositionBuilderImpl(unwrap(Builder), I->getParent(), I, false);
3373}
3374
3376 LLVMValueRef Instr) {
3378 return LLVMPositionBuilderImpl(unwrap(Builder), I->getParent(), I, true);
3379}
3380
3382 BasicBlock *BB = unwrap(Block);
3383 unwrap(Builder)->SetInsertPoint(BB);
3384}
3385
3387 return wrap(unwrap(Builder)->GetInsertBlock());
3388}
3389
3391 unwrap(Builder)->ClearInsertionPoint();
3392}
3393
3395 unwrap(Builder)->Insert(unwrap<Instruction>(Instr));
3396}
3397
3399 const char *Name) {
3400 unwrap(Builder)->Insert(unwrap<Instruction>(Instr), Name);
3401}
3402
3404 delete unwrap(Builder);
3405}
3406
3407/*--.. Metadata builders ...................................................--*/
3408
3410 return wrap(unwrap(Builder)->getCurrentDebugLocation().getAsMDNode());
3411}
3412
3414 if (Loc)
3415 unwrap(Builder)->SetCurrentDebugLocation(DebugLoc(unwrap<MDNode>(Loc)));
3416 else
3417 unwrap(Builder)->SetCurrentDebugLocation(DebugLoc());
3418}
3419
3421 MDNode *Loc =
3422 L ? cast<MDNode>(unwrap<MetadataAsValue>(L)->getMetadata()) : nullptr;
3423 unwrap(Builder)->SetCurrentDebugLocation(DebugLoc(Loc));
3424}
3425
3427 LLVMContext &Context = unwrap(Builder)->getContext();
3429 Context, unwrap(Builder)->getCurrentDebugLocation().getAsMDNode()));
3430}
3431
3433 unwrap(Builder)->SetInstDebugLocation(unwrap<Instruction>(Inst));
3434}
3435
3437 unwrap(Builder)->AddMetadataToInst(unwrap<Instruction>(Inst));
3438}
3439
3441 LLVMMetadataRef FPMathTag) {
3442
3443 unwrap(Builder)->setDefaultFPMathTag(FPMathTag
3444 ? unwrap<MDNode>(FPMathTag)
3445 : nullptr);
3446}
3447
3449 return wrap(&unwrap(Builder)->getContext());
3450}
3451
3453 return wrap(unwrap(Builder)->getDefaultFPMathTag());
3454}
3455
3456/*--.. Instruction builders ................................................--*/
3457
3459 return wrap(unwrap(B)->CreateRetVoid());
3460}
3461
3463 return wrap(unwrap(B)->CreateRet(unwrap(V)));
3464}
3465
3467 unsigned N) {
3468 return wrap(unwrap(B)->CreateAggregateRet(unwrap(RetVals), N));
3469}
3470
3472 return wrap(unwrap(B)->CreateBr(unwrap(Dest)));
3473}
3474
3477 return wrap(unwrap(B)->CreateCondBr(unwrap(If), unwrap(Then), unwrap(Else)));
3478}
3479
3481 LLVMBasicBlockRef Else, unsigned NumCases) {
3482 return wrap(unwrap(B)->CreateSwitch(unwrap(V), unwrap(Else), NumCases));
3483}
3484
3486 unsigned NumDests) {
3487 return wrap(unwrap(B)->CreateIndirectBr(unwrap(Addr), NumDests));
3488}
3489
3491 LLVMBasicBlockRef DefaultDest,
3492 LLVMBasicBlockRef *IndirectDests,
3493 unsigned NumIndirectDests, LLVMValueRef *Args,
3494 unsigned NumArgs, LLVMOperandBundleRef *Bundles,
3495 unsigned NumBundles, const char *Name) {
3496
3498 for (auto *Bundle : ArrayRef(Bundles, NumBundles)) {
3499 OperandBundleDef *OB = unwrap(Bundle);
3500 OBs.push_back(*OB);
3501 }
3502
3503 return wrap(unwrap(B)->CreateCallBr(
3504 unwrap<FunctionType>(Ty), unwrap(Fn), unwrap(DefaultDest),
3505 ArrayRef(unwrap(IndirectDests), NumIndirectDests),
3506 ArrayRef<Value *>(unwrap(Args), NumArgs), OBs, Name));
3507}
3508
3510 LLVMValueRef *Args, unsigned NumArgs,
3512 const char *Name) {
3513 return wrap(unwrap(B)->CreateInvoke(unwrap<FunctionType>(Ty), unwrap(Fn),
3514 unwrap(Then), unwrap(Catch),
3515 ArrayRef(unwrap(Args), NumArgs), Name));
3516}
3517
3520 unsigned NumArgs, LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch,
3521 LLVMOperandBundleRef *Bundles, unsigned NumBundles, const char *Name) {
3523 for (auto *Bundle : ArrayRef(Bundles, NumBundles)) {
3524 OperandBundleDef *OB = unwrap(Bundle);
3525 OBs.push_back(*OB);
3526 }
3527 return wrap(unwrap(B)->CreateInvoke(
3528 unwrap<FunctionType>(Ty), unwrap(Fn), unwrap(Then), unwrap(Catch),
3529 ArrayRef(unwrap(Args), NumArgs), OBs, Name));
3530}
3531
3533 LLVMValueRef PersFn, unsigned NumClauses,
3534 const char *Name) {
3535 // The personality used to live on the landingpad instruction, but now it
3536 // lives on the parent function. For compatibility, take the provided
3537 // personality and put it on the parent function.
3538 if (PersFn)
3539 unwrap(B)->GetInsertBlock()->getParent()->setPersonalityFn(
3540 unwrap<Function>(PersFn));
3541 return wrap(unwrap(B)->CreateLandingPad(unwrap(Ty), NumClauses, Name));
3542}
3543
3545 LLVMValueRef *Args, unsigned NumArgs,
3546 const char *Name) {
3547 return wrap(unwrap(B)->CreateCatchPad(unwrap(ParentPad),
3548 ArrayRef(unwrap(Args), NumArgs), Name));
3549}
3550
3552 LLVMValueRef *Args, unsigned NumArgs,
3553 const char *Name) {
3554 if (ParentPad == nullptr) {
3555 Type *Ty = Type::getTokenTy(unwrap(B)->getContext());
3556 ParentPad = wrap(Constant::getNullValue(Ty));
3557 }
3558 return wrap(unwrap(B)->CreateCleanupPad(
3559 unwrap(ParentPad), ArrayRef(unwrap(Args), NumArgs), Name));
3560}
3561
3563 return wrap(unwrap(B)->CreateResume(unwrap(Exn)));
3564}
3565
3567 LLVMBasicBlockRef UnwindBB,
3568 unsigned NumHandlers, const char *Name) {
3569 if (ParentPad == nullptr) {
3570 Type *Ty = Type::getTokenTy(unwrap(B)->getContext());
3571 ParentPad = wrap(Constant::getNullValue(Ty));
3572 }
3573 return wrap(unwrap(B)->CreateCatchSwitch(unwrap(ParentPad), unwrap(UnwindBB),
3574 NumHandlers, Name));
3575}
3576
3578 LLVMBasicBlockRef BB) {
3579 return wrap(unwrap(B)->CreateCatchRet(unwrap<CatchPadInst>(CatchPad),
3580 unwrap(BB)));
3581}
3582
3584 LLVMBasicBlockRef BB) {
3585 return wrap(unwrap(B)->CreateCleanupRet(unwrap<CleanupPadInst>(CatchPad),
3586 unwrap(BB)));
3587}
3588
3590 return wrap(unwrap(B)->CreateUnreachable());
3591}
3592
3594 LLVMBasicBlockRef Dest) {
3595 unwrap<SwitchInst>(Switch)->addCase(unwrap<ConstantInt>(OnVal), unwrap(Dest));
3596}
3597
3599 unwrap<IndirectBrInst>(IndirectBr)->addDestination(unwrap(Dest));
3600}
3601
3602unsigned LLVMGetNumClauses(LLVMValueRef LandingPad) {
3603 return unwrap<LandingPadInst>(LandingPad)->getNumClauses();
3604}
3605
3606LLVMValueRef LLVMGetClause(LLVMValueRef LandingPad, unsigned Idx) {
3607 return wrap(unwrap<LandingPadInst>(LandingPad)->getClause(Idx));
3608}
3609
3610void LLVMAddClause(LLVMValueRef LandingPad, LLVMValueRef ClauseVal) {
3611 unwrap<LandingPadInst>(LandingPad)->addClause(unwrap<Constant>(ClauseVal));
3612}
3613
3615 return unwrap<LandingPadInst>(LandingPad)->isCleanup();
3616}
3617
3618void LLVMSetCleanup(LLVMValueRef LandingPad, LLVMBool Val) {
3619 unwrap<LandingPadInst>(LandingPad)->setCleanup(Val);
3620}
3621
3623 unwrap<CatchSwitchInst>(CatchSwitch)->addHandler(unwrap(Dest));
3624}
3625
3626unsigned LLVMGetNumHandlers(LLVMValueRef CatchSwitch) {
3627 return unwrap<CatchSwitchInst>(CatchSwitch)->getNumHandlers();
3628}
3629
3630void LLVMGetHandlers(LLVMValueRef CatchSwitch, LLVMBasicBlockRef *Handlers) {
3631 CatchSwitchInst *CSI = unwrap<CatchSwitchInst>(CatchSwitch);
3632 for (const BasicBlock *H : CSI->handlers())
3633 *Handlers++ = wrap(H);
3634}
3635
3637 return wrap(unwrap<CatchPadInst>(CatchPad)->getCatchSwitch());
3638}
3639
3641 unwrap<CatchPadInst>(CatchPad)
3642 ->setCatchSwitch(unwrap<CatchSwitchInst>(CatchSwitch));
3643}
3644
3645/*--.. Funclets ...........................................................--*/
3646
3648 return wrap(unwrap<FuncletPadInst>(Funclet)->getArgOperand(i));
3649}
3650
3651void LLVMSetArgOperand(LLVMValueRef Funclet, unsigned i, LLVMValueRef value) {
3652 unwrap<FuncletPadInst>(Funclet)->setArgOperand(i, unwrap(value));
3653}
3654
3655/*--.. Arithmetic ..........................................................--*/
3656
3658 FastMathFlags NewFMF;
3659 NewFMF.setAllowReassoc((FMF & LLVMFastMathAllowReassoc) != 0);
3660 NewFMF.setNoNaNs((FMF & LLVMFastMathNoNaNs) != 0);
3661 NewFMF.setNoInfs((FMF & LLVMFastMathNoInfs) != 0);
3662 NewFMF.setNoSignedZeros((FMF & LLVMFastMathNoSignedZeros) != 0);
3664 NewFMF.setAllowContract((FMF & LLVMFastMathAllowContract) != 0);
3665 NewFMF.setApproxFunc((FMF & LLVMFastMathApproxFunc) != 0);
3666
3667 return NewFMF;
3668}
3669
3672 if (FMF.allowReassoc())
3673 NewFMF |= LLVMFastMathAllowReassoc;
3674 if (FMF.noNaNs())
3675 NewFMF |= LLVMFastMathNoNaNs;
3676 if (FMF.noInfs())
3677 NewFMF |= LLVMFastMathNoInfs;
3678 if (FMF.noSignedZeros())
3679 NewFMF |= LLVMFastMathNoSignedZeros;
3680 if (FMF.allowReciprocal())
3682 if (FMF.allowContract())
3683 NewFMF |= LLVMFastMathAllowContract;
3684 if (FMF.approxFunc())
3685 NewFMF |= LLVMFastMathApproxFunc;
3686
3687 return NewFMF;
3688}
3689
3691 const char *Name) {
3692 return wrap(unwrap(B)->CreateAdd(unwrap(LHS), unwrap(RHS), Name));
3693}
3694
3696 const char *Name) {
3697 return wrap(unwrap(B)->CreateNSWAdd(unwrap(LHS), unwrap(RHS), Name));
3698}
3699
3701 const char *Name) {
3702 return wrap(unwrap(B)->CreateNUWAdd(unwrap(LHS), unwrap(RHS), Name));
3703}
3704
3706 const char *Name) {
3707 return wrap(unwrap(B)->CreateFAdd(unwrap(LHS), unwrap(RHS), Name));
3708}
3709
3711 const char *Name) {
3712 return wrap(unwrap(B)->CreateSub(unwrap(LHS), unwrap(RHS), Name));
3713}
3714
3716 const char *Name) {
3717 return wrap(unwrap(B)->CreateNSWSub(unwrap(LHS), unwrap(RHS), Name));
3718}
3719
3721 const char *Name) {
3722 return wrap(unwrap(B)->CreateNUWSub(unwrap(LHS), unwrap(RHS), Name));
3723}
3724
3726 const char *Name) {
3727 return wrap(unwrap(B)->CreateFSub(unwrap(LHS), unwrap(RHS), Name));
3728}
3729
3731 const char *Name) {
3732 return wrap(unwrap(B)->CreateMul(unwrap(LHS), unwrap(RHS), Name));
3733}
3734
3736 const char *Name) {
3737 return wrap(unwrap(B)->CreateNSWMul(unwrap(LHS), unwrap(RHS), Name));
3738}
3739
3741 const char *Name) {
3742 return wrap(unwrap(B)->CreateNUWMul(unwrap(LHS), unwrap(RHS), Name));
3743}
3744
3746 const char *Name) {
3747 return wrap(unwrap(B)->CreateFMul(unwrap(LHS), unwrap(RHS), Name));
3748}
3749
3751 const char *Name) {
3752 return wrap(unwrap(B)->CreateUDiv(unwrap(LHS), unwrap(RHS), Name));
3753}
3754
3756 LLVMValueRef RHS, const char *Name) {
3757 return wrap(unwrap(B)->CreateExactUDiv(unwrap(LHS), unwrap(RHS), Name));
3758}
3759
3761 const char *Name) {
3762 return wrap(unwrap(B)->CreateSDiv(unwrap(LHS), unwrap(RHS), Name));
3763}
3764
3766 LLVMValueRef RHS, const char *Name) {
3767 return wrap(unwrap(B)->CreateExactSDiv(unwrap(LHS), unwrap(RHS), Name));
3768}
3769
3771 const char *Name) {
3772 return wrap(unwrap(B)->CreateFDiv(unwrap(LHS), unwrap(RHS), Name));
3773}
3774
3776 const char *Name) {
3777 return wrap(unwrap(B)->CreateURem(unwrap(LHS), unwrap(RHS), Name));
3778}
3779
3781 const char *Name) {
3782 return wrap(unwrap(B)->CreateSRem(unwrap(LHS), unwrap(RHS), Name));
3783}
3784
3786 const char *Name) {
3787 return wrap(unwrap(B)->CreateFRem(unwrap(LHS), unwrap(RHS), Name));
3788}
3789
3791 const char *Name) {
3792 return wrap(unwrap(B)->CreateShl(unwrap(LHS), unwrap(RHS), Name));
3793}
3794
3796 const char *Name) {
3797 return wrap(unwrap(B)->CreateLShr(unwrap(LHS), unwrap(RHS), Name));
3798}
3799
3801 const char *Name) {
3802 return wrap(unwrap(B)->CreateAShr(unwrap(LHS), unwrap(RHS), Name));
3803}
3804
3806 const char *Name) {
3807 return wrap(unwrap(B)->CreateAnd(unwrap(LHS), unwrap(RHS), Name));
3808}
3809
3811 const char *Name) {
3812 return wrap(unwrap(B)->CreateOr(unwrap(LHS), unwrap(RHS), Name));
3813}
3814
3816 const char *Name) {
3817 return wrap(unwrap(B)->CreateXor(unwrap(LHS), unwrap(RHS), Name));
3818}
3819
3826
3828 return wrap(unwrap(B)->CreateNeg(unwrap(V), Name));
3829}
3830
3832 const char *Name) {
3833 return wrap(unwrap(B)->CreateNSWNeg(unwrap(V), Name));
3834}
3835
3837 const char *Name) {
3838 Value *Neg = unwrap(B)->CreateNeg(unwrap(V), Name);
3839 if (auto *I = dyn_cast<BinaryOperator>(Neg))
3840 I->setHasNoUnsignedWrap();
3841 return wrap(Neg);
3842}
3843
3845 return wrap(unwrap(B)->CreateFNeg(unwrap(V), Name));
3846}
3847
3849 return wrap(unwrap(B)->CreateNot(unwrap(V), Name));
3850}
3851
3853 Value *P = unwrap<Value>(ArithInst);
3854 return cast<Instruction>(P)->hasNoUnsignedWrap();
3855}
3856
3857void LLVMSetNUW(LLVMValueRef ArithInst, LLVMBool HasNUW) {
3858 Value *P = unwrap<Value>(ArithInst);
3859 cast<Instruction>(P)->setHasNoUnsignedWrap(HasNUW);
3860}
3861
3863 Value *P = unwrap<Value>(ArithInst);
3864 return cast<Instruction>(P)->hasNoSignedWrap();
3865}
3866
3867void LLVMSetNSW(LLVMValueRef ArithInst, LLVMBool HasNSW) {
3868 Value *P = unwrap<Value>(ArithInst);
3869 cast<Instruction>(P)->setHasNoSignedWrap(HasNSW);
3870}
3871
3873 Value *P = unwrap<Value>(DivOrShrInst);
3874 return cast<Instruction>(P)->isExact();
3875}
3876
3877void LLVMSetExact(LLVMValueRef DivOrShrInst, LLVMBool IsExact) {
3878 Value *P = unwrap<Value>(DivOrShrInst);
3879 cast<Instruction>(P)->setIsExact(IsExact);
3880}
3881
3883 Value *P = unwrap<Value>(NonNegInst);
3884 return cast<Instruction>(P)->hasNonNeg();
3885}
3886
3887void LLVMSetNNeg(LLVMValueRef NonNegInst, LLVMBool IsNonNeg) {
3888 Value *P = unwrap<Value>(NonNegInst);
3889 cast<Instruction>(P)->setNonNeg(IsNonNeg);
3890}
3891
3893 Value *P = unwrap<Value>(FPMathInst);
3894 FastMathFlags FMF = cast<Instruction>(P)->getFastMathFlags();
3895 return mapToLLVMFastMathFlags(FMF);
3896}
3897
3899 Value *P = unwrap<Value>(FPMathInst);
3900 cast<Instruction>(P)->setFastMathFlags(mapFromLLVMFastMathFlags(FMF));
3901}
3902
3907
3909 Value *P = unwrap<Value>(Inst);
3910 return cast<PossiblyDisjointInst>(P)->isDisjoint();
3911}
3912
3914 Value *P = unwrap<Value>(Inst);
3915 cast<PossiblyDisjointInst>(P)->setIsDisjoint(IsDisjoint);
3916}
3917
3918/*--.. Memory ..............................................................--*/
3919
3921 const char *Name) {
3922 Type* ITy = Type::getInt32Ty(unwrap(B)->GetInsertBlock()->getContext());
3923 Constant* AllocSize = ConstantExpr::getSizeOf(unwrap(Ty));
3924 AllocSize = ConstantExpr::getTruncOrBitCast(AllocSize, ITy);
3925 return wrap(unwrap(B)->CreateMalloc(ITy, unwrap(Ty), AllocSize, nullptr,
3926 nullptr, Name));
3927}
3928
3930 LLVMValueRef Val, const char *Name) {
3931 Type* ITy = Type::getInt32Ty(unwrap(B)->GetInsertBlock()->getContext());
3932 Constant* AllocSize = ConstantExpr::getSizeOf(unwrap(Ty));
3933 AllocSize = ConstantExpr::getTruncOrBitCast(AllocSize, ITy);
3934 return wrap(unwrap(B)->CreateMalloc(ITy, unwrap(Ty), AllocSize, unwrap(Val),
3935 nullptr, Name));
3936}
3937
3939 LLVMValueRef Val, LLVMValueRef Len,
3940 unsigned Align) {
3941 return wrap(unwrap(B)->CreateMemSet(unwrap(Ptr), unwrap(Val), unwrap(Len),
3942 MaybeAlign(Align)));
3943}
3944
3946 LLVMValueRef Dst, unsigned DstAlign,
3947 LLVMValueRef Src, unsigned SrcAlign,
3949 return wrap(unwrap(B)->CreateMemCpy(unwrap(Dst), MaybeAlign(DstAlign),
3950 unwrap(Src), MaybeAlign(SrcAlign),
3951 unwrap(Size)));
3952}
3953
3955 LLVMValueRef Dst, unsigned DstAlign,
3956 LLVMValueRef Src, unsigned SrcAlign,
3958 return wrap(unwrap(B)->CreateMemMove(unwrap(Dst), MaybeAlign(DstAlign),
3959 unwrap(Src), MaybeAlign(SrcAlign),
3960 unwrap(Size)));
3961}
3962
3964 const char *Name) {
3965 return wrap(unwrap(B)->CreateAlloca(unwrap(Ty), nullptr, Name));
3966}
3967
3969 LLVMValueRef Val, const char *Name) {
3970 return wrap(unwrap(B)->CreateAlloca(unwrap(Ty), unwrap(Val), Name));
3971}
3972
3974 return wrap(unwrap(B)->CreateFree(unwrap(PointerVal)));
3975}
3976
3978 LLVMValueRef PointerVal, const char *Name) {
3979 return wrap(unwrap(B)->CreateLoad(unwrap(Ty), unwrap(PointerVal), Name));
3980}
3981
3983 LLVMValueRef PointerVal) {
3984 return wrap(unwrap(B)->CreateStore(unwrap(Val), unwrap(PointerVal)));
3985}
3986
4002
4018
4020 switch (BinOp) {
4048 }
4049
4050 llvm_unreachable("Invalid LLVMAtomicRMWBinOp value!");
4051}
4052
4054 switch (BinOp) {
4082 default: break;
4083 }
4084
4085 llvm_unreachable("Invalid AtomicRMWBinOp value!");
4086}
4087
4089 LLVMBool isSingleThread, const char *Name) {
4090 return wrap(
4091 unwrap(B)->CreateFence(mapFromLLVMOrdering(Ordering),
4092 isSingleThread ? SyncScope::SingleThread
4094 Name));
4095}
4096
4098 LLVMAtomicOrdering Ordering, unsigned SSID,
4099 const char *Name) {
4100 return wrap(
4101 unwrap(B)->CreateFence(mapFromLLVMOrdering(Ordering), SSID, Name));
4102}
4103
4105 LLVMValueRef Pointer, LLVMValueRef *Indices,
4106 unsigned NumIndices, const char *Name) {
4107 ArrayRef<Value *> IdxList(unwrap(Indices), NumIndices);
4108 return wrap(unwrap(B)->CreateGEP(unwrap(Ty), unwrap(Pointer), IdxList, Name));
4109}
4110
4112 LLVMValueRef Pointer, LLVMValueRef *Indices,
4113 unsigned NumIndices, const char *Name) {
4114 ArrayRef<Value *> IdxList(unwrap(Indices), NumIndices);
4115 return wrap(
4116 unwrap(B)->CreateInBoundsGEP(unwrap(Ty), unwrap(Pointer), IdxList, Name));
4117}
4118
4120 LLVMValueRef Pointer,
4121 LLVMValueRef *Indices,
4122 unsigned NumIndices, const char *Name,
4123 LLVMGEPNoWrapFlags NoWrapFlags) {
4124 ArrayRef<Value *> IdxList(unwrap(Indices), NumIndices);
4125 return wrap(unwrap(B)->CreateGEP(unwrap(Ty), unwrap(Pointer), IdxList, Name,
4126 mapFromLLVMGEPNoWrapFlags(NoWrapFlags)));
4127}
4128
4130 LLVMValueRef Pointer, unsigned Idx,
4131 const char *Name) {
4132 return wrap(
4133 unwrap(B)->CreateStructGEP(unwrap(Ty), unwrap(Pointer), Idx, Name));
4134}
4135
4137 const char *Name) {
4138 return wrap(unwrap(B)->CreateGlobalString(Str, Name));
4139}
4140
4142 const char *Name) {
4143 return wrap(unwrap(B)->CreateGlobalString(Str, Name));
4144}
4145
4147 return cast<Instruction>(unwrap(Inst))->isVolatile();
4148}
4149
4150void LLVMSetVolatile(LLVMValueRef MemAccessInst, LLVMBool isVolatile) {
4151 Value *P = unwrap(MemAccessInst);
4152 if (LoadInst *LI = dyn_cast<LoadInst>(P))
4153 return LI->setVolatile(isVolatile);
4155 return SI->setVolatile(isVolatile);
4157 return AI->setVolatile(isVolatile);
4158 return cast<AtomicCmpXchgInst>(P)->setVolatile(isVolatile);
4159}
4160
4162 return unwrap<AtomicCmpXchgInst>(CmpXchgInst)->isWeak();
4163}
4164
4165void LLVMSetWeak(LLVMValueRef CmpXchgInst, LLVMBool isWeak) {
4166 return unwrap<AtomicCmpXchgInst>(CmpXchgInst)->setWeak(isWeak);
4167}
4168
4170 Value *P = unwrap(MemAccessInst);
4172 if (LoadInst *LI = dyn_cast<LoadInst>(P))
4173 O = LI->getOrdering();
4174 else if (StoreInst *SI = dyn_cast<StoreInst>(P))
4175 O = SI->getOrdering();
4176 else if (FenceInst *FI = dyn_cast<FenceInst>(P))
4177 O = FI->getOrdering();
4178 else
4179 O = cast<AtomicRMWInst>(P)->getOrdering();
4180 return mapToLLVMOrdering(O);
4181}
4182
4183void LLVMSetOrdering(LLVMValueRef MemAccessInst, LLVMAtomicOrdering Ordering) {
4184 Value *P = unwrap(MemAccessInst);
4185 AtomicOrdering O = mapFromLLVMOrdering(Ordering);
4186
4187 if (LoadInst *LI = dyn_cast<LoadInst>(P))
4188 return LI->setOrdering(O);
4189 else if (FenceInst *FI = dyn_cast<FenceInst>(P))
4190 return FI->setOrdering(O);
4191 else if (AtomicRMWInst *ARWI = dyn_cast<AtomicRMWInst>(P))
4192 return ARWI->setOrdering(O);
4193 return cast<StoreInst>(P)->setOrdering(O);
4194}
4195
4199
4201 unwrap<AtomicRMWInst>(Inst)->setOperation(mapFromLLVMRMWBinOp(BinOp));
4202}
4203
4204/*--.. Casts ...............................................................--*/
4205
4207 LLVMTypeRef DestTy, const char *Name) {
4208 return wrap(unwrap(B)->CreateTrunc(unwrap(Val), unwrap(DestTy), Name));
4209}
4210
4212 LLVMTypeRef DestTy, const char *Name) {
4213 return wrap(unwrap(B)->CreateZExt(unwrap(Val), unwrap(DestTy), Name));
4214}
4215
4217 LLVMTypeRef DestTy, const char *Name) {
4218 return wrap(unwrap(B)->CreateSExt(unwrap(Val), unwrap(DestTy), Name));
4219}
4220
4222 LLVMTypeRef DestTy, const char *Name) {
4223 return wrap(unwrap(B)->CreateFPToUI(unwrap(Val), unwrap(DestTy), Name));
4224}
4225
4227 LLVMTypeRef DestTy, const char *Name) {
4228 return wrap(unwrap(B)->CreateFPToSI(unwrap(Val), unwrap(DestTy), Name));
4229}
4230
4232 LLVMTypeRef DestTy, const char *Name) {
4233 return wrap(unwrap(B)->CreateUIToFP(unwrap(Val), unwrap(DestTy), Name));
4234}
4235
4237 LLVMTypeRef DestTy, const char *Name) {
4238 return wrap(unwrap(B)->CreateSIToFP(unwrap(Val), unwrap(DestTy), Name));
4239}
4240
4242 LLVMTypeRef DestTy, const char *Name) {
4243 return wrap(unwrap(B)->CreateFPTrunc(unwrap(Val), unwrap(DestTy), Name));
4244}
4245
4247 LLVMTypeRef DestTy, const char *Name) {
4248 return wrap(unwrap(B)->CreateFPExt(unwrap(Val), unwrap(DestTy), Name));
4249}
4250
4252 LLVMTypeRef DestTy, const char *Name) {
4253 return wrap(unwrap(B)->CreatePtrToInt(unwrap(Val), unwrap(DestTy), Name));
4254}
4255
4257 LLVMTypeRef DestTy, const char *Name) {
4258 return wrap(unwrap(B)->CreateIntToPtr(unwrap(Val), unwrap(DestTy), Name));
4259}
4260
4262 LLVMTypeRef DestTy, const char *Name) {
4263 return wrap(unwrap(B)->CreateBitCast(unwrap(Val), unwrap(DestTy), Name));
4264}
4265
4267 LLVMTypeRef DestTy, const char *Name) {
4268 return wrap(unwrap(B)->CreateAddrSpaceCast(unwrap(Val), unwrap(DestTy), Name));
4269}
4270
4272 LLVMTypeRef DestTy, const char *Name) {
4273 return wrap(unwrap(B)->CreateZExtOrBitCast(unwrap(Val), unwrap(DestTy),
4274 Name));
4275}
4276
4278 LLVMTypeRef DestTy, const char *Name) {
4279 return wrap(unwrap(B)->CreateSExtOrBitCast(unwrap(Val), unwrap(DestTy),
4280 Name));
4281}
4282
4284 LLVMTypeRef DestTy, const char *Name) {
4285 return wrap(unwrap(B)->CreateTruncOrBitCast(unwrap(Val), unwrap(DestTy),
4286 Name));
4287}
4288
4290 LLVMTypeRef DestTy, const char *Name) {
4291 return wrap(unwrap(B)->CreateCast(Instruction::CastOps(map_from_llvmopcode(Op)), unwrap(Val),
4292 unwrap(DestTy), Name));
4293}
4294
4296 LLVMTypeRef DestTy, const char *Name) {
4297 return wrap(unwrap(B)->CreatePointerCast(unwrap(Val), unwrap(DestTy), Name));
4298}
4299
4301 LLVMTypeRef DestTy, LLVMBool IsSigned,
4302 const char *Name) {
4303 return wrap(
4304 unwrap(B)->CreateIntCast(unwrap(Val), unwrap(DestTy), IsSigned, Name));
4305}
4306
4308 LLVMTypeRef DestTy, const char *Name) {
4309 return wrap(unwrap(B)->CreateIntCast(unwrap(Val), unwrap(DestTy),
4310 /*isSigned*/true, Name));
4311}
4312
4314 LLVMTypeRef DestTy, const char *Name) {
4315 return wrap(unwrap(B)->CreateFPCast(unwrap(Val), unwrap(DestTy), Name));
4316}
4317
4319 LLVMTypeRef DestTy, LLVMBool DestIsSigned) {
4321 unwrap(Src), SrcIsSigned, unwrap(DestTy), DestIsSigned));
4322}
4323
4324/*--.. Comparisons .........................................................--*/
4325
4328 const char *Name) {
4329 return wrap(unwrap(B)->CreateICmp(static_cast<ICmpInst::Predicate>(Op),
4330 unwrap(LHS), unwrap(RHS), Name));
4331}
4332
4335 const char *Name) {
4336 return wrap(unwrap(B)->CreateFCmp(static_cast<FCmpInst::Predicate>(Op),
4337 unwrap(LHS), unwrap(RHS), Name));
4338}
4339
4340/*--.. Miscellaneous instructions ..........................................--*/
4341
4343 return wrap(unwrap(B)->CreatePHI(unwrap(Ty), 0, Name));
4344}
4345
4347 LLVMValueRef *Args, unsigned NumArgs,
4348 const char *Name) {
4350 return wrap(unwrap(B)->CreateCall(FTy, unwrap(Fn),
4351 ArrayRef(unwrap(Args), NumArgs), Name));
4352}
4353
4356 LLVMValueRef Fn, LLVMValueRef *Args,
4357 unsigned NumArgs, LLVMOperandBundleRef *Bundles,
4358 unsigned NumBundles, const char *Name) {
4361 for (auto *Bundle : ArrayRef(Bundles, NumBundles)) {
4362 OperandBundleDef *OB = unwrap(Bundle);
4363 OBs.push_back(*OB);
4364 }
4365 return wrap(unwrap(B)->CreateCall(
4366 FTy, unwrap(Fn), ArrayRef(unwrap(Args), NumArgs), OBs, Name));
4367}
4368
4370 LLVMValueRef Then, LLVMValueRef Else,
4371 const char *Name) {
4372 return wrap(unwrap(B)->CreateSelect(unwrap(If), unwrap(Then), unwrap(Else),
4373 Name));
4374}
4375
4377 LLVMTypeRef Ty, const char *Name) {
4378 return wrap(unwrap(B)->CreateVAArg(unwrap(List), unwrap(Ty), Name));
4379}
4380
4382 LLVMValueRef Index, const char *Name) {
4383 return wrap(unwrap(B)->CreateExtractElement(unwrap(VecVal), unwrap(Index),
4384 Name));
4385}
4386
4388 LLVMValueRef EltVal, LLVMValueRef Index,
4389 const char *Name) {
4390 return wrap(unwrap(B)->CreateInsertElement(unwrap(VecVal), unwrap(EltVal),
4391 unwrap(Index), Name));
4392}
4393
4395 LLVMValueRef V2, LLVMValueRef Mask,
4396 const char *Name) {
4397 return wrap(unwrap(B)->CreateShuffleVector(unwrap(V1), unwrap(V2),
4398 unwrap(Mask), Name));
4399}
4400
4402 unsigned Index, const char *Name) {
4403 return wrap(unwrap(B)->CreateExtractValue(unwrap(AggVal), Index, Name));
4404}
4405
4407 LLVMValueRef EltVal, unsigned Index,
4408 const char *Name) {
4409 return wrap(unwrap(B)->CreateInsertValue(unwrap(AggVal), unwrap(EltVal),
4410 Index, Name));
4411}
4412
4414 const char *Name) {
4415 return wrap(unwrap(B)->CreateFreeze(unwrap(Val), Name));
4416}
4417
4419 const char *Name) {
4420 return wrap(unwrap(B)->CreateIsNull(unwrap(Val), Name));
4421}
4422
4424 const char *Name) {
4425 return wrap(unwrap(B)->CreateIsNotNull(unwrap(Val), Name));
4426}
4427
4430 const char *Name) {
4431 return wrap(unwrap(B)->CreatePtrDiff(unwrap(ElemTy), unwrap(LHS),
4432 unwrap(RHS), Name));
4433}
4434
4436 LLVMValueRef PTR, LLVMValueRef Val,
4437 LLVMAtomicOrdering ordering,
4438 LLVMBool singleThread) {
4440 return wrap(unwrap(B)->CreateAtomicRMW(
4441 intop, unwrap(PTR), unwrap(Val), MaybeAlign(),
4442 mapFromLLVMOrdering(ordering),
4443 singleThread ? SyncScope::SingleThread : SyncScope::System));
4444}
4445
4448 LLVMValueRef PTR, LLVMValueRef Val,
4449 LLVMAtomicOrdering ordering,
4450 unsigned SSID) {
4452 return wrap(unwrap(B)->CreateAtomicRMW(intop, unwrap(PTR), unwrap(Val),
4453 MaybeAlign(),
4454 mapFromLLVMOrdering(ordering), SSID));
4455}
4456
4458 LLVMValueRef Cmp, LLVMValueRef New,
4459 LLVMAtomicOrdering SuccessOrdering,
4460 LLVMAtomicOrdering FailureOrdering,
4461 LLVMBool singleThread) {
4462
4463 return wrap(unwrap(B)->CreateAtomicCmpXchg(
4464 unwrap(Ptr), unwrap(Cmp), unwrap(New), MaybeAlign(),
4465 mapFromLLVMOrdering(SuccessOrdering),
4466 mapFromLLVMOrdering(FailureOrdering),
4467 singleThread ? SyncScope::SingleThread : SyncScope::System));
4468}
4469
4471 LLVMValueRef Cmp, LLVMValueRef New,
4472 LLVMAtomicOrdering SuccessOrdering,
4473 LLVMAtomicOrdering FailureOrdering,
4474 unsigned SSID) {
4475 return wrap(unwrap(B)->CreateAtomicCmpXchg(
4476 unwrap(Ptr), unwrap(Cmp), unwrap(New), MaybeAlign(),
4477 mapFromLLVMOrdering(SuccessOrdering),
4478 mapFromLLVMOrdering(FailureOrdering), SSID));
4479}
4480
4482 Value *P = unwrap(SVInst);
4484 return I->getShuffleMask().size();
4485}
4486
4487int LLVMGetMaskValue(LLVMValueRef SVInst, unsigned Elt) {
4488 Value *P = unwrap(SVInst);
4490 return I->getMaskValue(Elt);
4491}
4492
4494
4496 return unwrap<Instruction>(Inst)->isAtomic();
4497}
4498
4500 // Backwards compatibility: return false for non-atomic instructions
4501 Instruction *I = unwrap<Instruction>(AtomicInst);
4502 if (!I->isAtomic())
4503 return 0;
4504
4506}
4507
4509 // Backwards compatibility: ignore non-atomic instructions
4510 Instruction *I = unwrap<Instruction>(AtomicInst);
4511 if (!I->isAtomic())
4512 return;
4513
4515 setAtomicSyncScopeID(I, SSID);
4516}
4517
4519 Instruction *I = unwrap<Instruction>(AtomicInst);
4520 assert(I->isAtomic() && "Expected an atomic instruction");
4521 return *getAtomicSyncScopeID(I);
4522}
4523
4524void LLVMSetAtomicSyncScopeID(LLVMValueRef AtomicInst, unsigned SSID) {
4525 Instruction *I = unwrap<Instruction>(AtomicInst);
4526 assert(I->isAtomic() && "Expected an atomic instruction");
4527 setAtomicSyncScopeID(I, SSID);
4528}
4529
4531 Value *P = unwrap(CmpXchgInst);
4532 return mapToLLVMOrdering(cast<AtomicCmpXchgInst>(P)->getSuccessOrdering());
4533}
4534
4536 LLVMAtomicOrdering Ordering) {
4537 Value *P = unwrap(CmpXchgInst);
4538 AtomicOrdering O = mapFromLLVMOrdering(Ordering);
4539
4540 return cast<AtomicCmpXchgInst>(P)->setSuccessOrdering(O);
4541}
4542
4544 Value *P = unwrap(CmpXchgInst);
4545 return mapToLLVMOrdering(cast<AtomicCmpXchgInst>(P)->getFailureOrdering());
4546}
4547
4549 LLVMAtomicOrdering Ordering) {
4550 Value *P = unwrap(CmpXchgInst);
4551 AtomicOrdering O = mapFromLLVMOrdering(Ordering);
4552
4553 return cast<AtomicCmpXchgInst>(P)->setFailureOrdering(O);
4554}
4555
4556/*===-- Module providers --------------------------------------------------===*/
4557
4562
4566
4567
4568/*===-- Memory buffers ----------------------------------------------------===*/
4569
4571 const char *Path,
4572 LLVMMemoryBufferRef *OutMemBuf,
4573 char **OutMessage) {
4574
4576 if (std::error_code EC = MBOrErr.getError()) {
4577 *OutMessage = strdup(EC.message().c_str());
4578 return 1;
4579 }
4580 *OutMemBuf = wrap(MBOrErr.get().release());
4581 return 0;
4582}
4583
4585 char **OutMessage) {
4587 if (std::error_code EC = MBOrErr.getError()) {
4588 *OutMessage = strdup(EC.message().c_str());
4589 return 1;
4590 }
4591 *OutMemBuf = wrap(MBOrErr.get().release());
4592 return 0;
4593}
4594
4596 const char *InputData,
4597 size_t InputDataLength,
4598 const char *BufferName,
4599 LLVMBool RequiresNullTerminator) {
4600
4601 return wrap(MemoryBuffer::getMemBuffer(StringRef(InputData, InputDataLength),
4602 StringRef(BufferName),
4603 RequiresNullTerminator).release());
4604}
4605
4607 const char *InputData,
4608 size_t InputDataLength,
4609 const char *BufferName) {
4610
4611 return wrap(
4612 MemoryBuffer::getMemBufferCopy(StringRef(InputData, InputDataLength),
4613 StringRef(BufferName)).release());
4614}
4615
4617 return unwrap(MemBuf)->getBufferStart();
4618}
4619
4621 return unwrap(MemBuf)->getBufferSize();
4622}
4623
4625 delete unwrap(MemBuf);
4626}
4627
4628/*===-- Pass Manager ------------------------------------------------------===*/
4629
4633
4637
4642
4646
4650
4654
4658
4660 delete unwrap(PM);
4661}
4662
4663/*===-- Threading ------------------------------------------------------===*/
4664
4668
4671
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:449
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:755
LLVMValueRef LLVMGetElementAsConstant(LLVMValueRef C, unsigned idx)
Definition Core.cpp:1643
LLVMTypeRef LLVMInt64Type(void)
Definition Core.cpp:699
static Module::ModFlagBehavior map_to_llvmModFlagBehavior(LLVMModuleFlagBehavior Behavior)
Definition Core.cpp:344
LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count, LLVMBool Packed)
Definition Core.cpp:1690
#define LLVM_DEFINE_VALUE_CAST(name)
Definition Core.cpp:1147
LLVMBasicBlockRef LLVMAppendBasicBlock(LLVMValueRef FnRef, const char *Name)
Definition Core.cpp:2898
LLVMTypeRef LLVMVoidType(void)
Definition Core.cpp:958
static LLVMValueMetadataEntry * llvm_getMetadata(size_t *NumEntries, llvm::function_ref< void(MetadataEntries &)> AccessMD)
Definition Core.cpp:1119
static GEPNoWrapFlags mapFromLLVMGEPNoWrapFlags(LLVMGEPNoWrapFlags GEPFlags)
Definition Core.cpp:1743
LLVMValueRef LLVMMDString(const char *Str, unsigned SLen)
Definition Core.cpp:1302
static MDNode * extractMDNode(MetadataAsValue *MAV)
Definition Core.cpp:1095
SmallVectorImpl< std::pair< unsigned, MDNode * > > MetadataEntries
Definition Core.cpp:1117
static void LLVMPositionBuilderImpl(IRBuilder<> *Builder, BasicBlock *Block, Instruction *Instr, bool BeforeDbgRecords)
Definition Core.cpp:3350
static LLVMOpcode map_to_llvmopcode(int opcode)
Definition Core.cpp:1721
LLVMTypeRef LLVMBFloatType(void)
Definition Core.cpp:743
LLVMTypeRef LLVMInt32Type(void)
Definition Core.cpp:696
static LLVMFastMathFlags mapToLLVMFastMathFlags(FastMathFlags FMF)
Definition Core.cpp:3670
static FastMathFlags mapFromLLVMFastMathFlags(LLVMFastMathFlags FMF)
Definition Core.cpp:3657
LLVMTypeRef LLVMHalfType(void)
Definition Core.cpp:740
LLVMTypeRef LLVMIntType(unsigned NumBits)
Definition Core.cpp:705
LLVMTypeRef LLVMX86AMXType(void)
Definition Core.cpp:761
LLVMValueRef LLVMConstIntOfString(LLVMTypeRef IntTy, const char Str[], uint8_t Radix)
Definition Core.cpp:1555
LLVMTypeRef LLVMStructType(LLVMTypeRef *ElementTypes, unsigned ElementCount, LLVMBool Packed)
Definition Core.cpp:800
static AtomicOrdering mapFromLLVMOrdering(LLVMAtomicOrdering Ordering)
Definition Core.cpp:3987
static Intrinsic::ID llvm_map_to_intrinsic_id(unsigned ID)
Definition Core.cpp:2492
static LLVMModuleFlagBehavior map_from_llvmModFlagBehavior(Module::ModFlagBehavior Behavior)
Definition Core.cpp:363
LLVMModuleRef LLVMModuleCreateWithName(const char *ModuleID)
Definition Core.cpp:280
static LLVMAtomicOrdering mapToLLVMOrdering(AtomicOrdering Ordering)
Definition Core.cpp:4003
LLVMTypeRef LLVMX86FP80Type(void)
Definition Core.cpp:752
LLVMBasicBlockRef LLVMInsertBasicBlock(LLVMBasicBlockRef BBRef, const char *Name)
Definition Core.cpp:2909
LLVMValueRef LLVMBuildNUWNeg(LLVMBuilderRef B, LLVMValueRef V, const char *Name)
Definition Core.cpp:3836
static LLVMValueRef getMDNodeOperandImpl(LLVMContext &Context, const MDNode *N, unsigned Index)
Definition Core.cpp:1202
LLVMValueRef LLVMConstRealOfStringAndSize(LLVMTypeRef RealTy, const char Str[], unsigned SLen)
Definition Core.cpp:1575
LLVMTypeRef LLVMPPCFP128Type(void)
Definition Core.cpp:758
LLVMTypeRef LLVMFloatType(void)
Definition Core.cpp:746
static int map_from_llvmopcode(LLVMOpcode code)
Definition Core.cpp:1731
static LLVMAtomicRMWBinOp mapToLLVMRMWBinOp(AtomicRMWInst::BinOp BinOp)
Definition Core.cpp:4053
LLVMTypeRef LLVMLabelType(void)
Definition Core.cpp:961
LLVMValueRef LLVMConstString(const char *Str, unsigned Length, LLVMBool DontNullTerminate)
Definition Core.cpp:1633
unsigned LLVMGetMDKindID(const char *Name, unsigned SLen)
Definition Core.cpp:152
LLVMTypeRef LLVMInt8Type(void)
Definition Core.cpp:690
LLVMTypeRef LLVMDoubleType(void)
Definition Core.cpp:749
LLVMTypeRef LLVMInt1Type(void)
Definition Core.cpp:687
LLVMBuilderRef LLVMCreateBuilder(void)
Definition Core.cpp:3346
LLVMTypeRef LLVMInt128Type(void)
Definition Core.cpp:702
static AtomicRMWInst::BinOp mapFromLLVMRMWBinOp(LLVMAtomicRMWBinOp BinOp)
Definition Core.cpp:4019
LLVMValueRef LLVMConstNUWNeg(LLVMValueRef ConstantVal)
Definition Core.cpp:1789
LLVMValueRef LLVMConstIntOfStringAndSize(LLVMTypeRef IntTy, const char Str[], unsigned SLen, uint8_t Radix)
Definition Core.cpp:1561
LLVMTypeRef LLVMInt16Type(void)
Definition Core.cpp:693
LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count)
Definition Core.cpp:1333
static LLVMContext & getGlobalContext()
Definition Core.cpp:95
static LLVMGEPNoWrapFlags mapToLLVMGEPNoWrapFlags(GEPNoWrapFlags GEPFlags)
Definition Core.cpp:1755
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
#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:6053
LLVM_ABI double convertToDouble() const
Converts this APFloat to host double value.
Definition APFloat.cpp:6112
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:69
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:88
@ EndAttrKinds
Sentinel value useful for loops.
Definition Attributes.h:93
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:536
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:1311
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:166
BasicBlockListType::iterator iterator
Definition Function.h:69
Argument * arg_iterator
Definition Function.h:72
iterator_range< arg_iterator > args()
Definition Function.h:890
arg_iterator arg_begin()
Definition Function.h:866
Function::iterator insert(Function::iterator Position, BasicBlock *BB)
Insert BB in the basic block list at Position.
Definition Function.h:753
size_t arg_size() const
Definition Function.h:899
Represents flags for the getelementptr instruction/expression.
static GEPNoWrapFlags inBounds()
static GEPNoWrapFlags noUnsignedWrap()
static GEPNoWrapFlags noUnsignedSignedWrap()
bool hasNoUnsignedSignedWrap() const
bool hasNoUnsignedWrap() const
bool isInBounds() const
GEPNoWrapFlags getNoWrapFlags() const
Definition Operator.h:425
an instruction for type-safe pointer arithmetic to access elements of arrays and structs
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:598
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:655
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.
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
Definition IRBuilder.h:2788
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:562
Metadata node.
Definition Metadata.h:1078
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition Metadata.h:1569
A single uniqued string.
Definition Metadata.h:721
static LLVM_ABI MDString * get(LLVMContext &Context, StringRef Str)
Definition Metadata.cpp:608
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:183
static LLVM_ABI MetadataAsValue * get(LLVMContext &Context, Metadata *MD)
Definition Metadata.cpp:104
Metadata * getMetadata() const
Definition Metadata.h:201
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:1757
LLVM_ABI StringRef getName() const
Module * getParent()
Get the module that holds this named metadata collection.
Definition Metadata.h:1827
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:44
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:146
constexpr const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
Definition StringRef.h:140
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:503
LLVM Value Representation.
Definition Value.h:75
Type * getType() const
All values are typed, get the type of this value.
Definition Value.h:256
use_iterator_impl< Use > use_iterator
Definition Value.h:353
LLVM_ABI LLVMContext & getContext() const
All values hold a context through their type.
Definition Value.cpp:1099
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:856
LLVMBool LLVMIsEnumAttribute(LLVMAttributeRef A)
Check for the different types of attributes.
Definition Core.cpp:233
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
const char * LLVMGetStringAttributeValue(LLVMAttributeRef A, unsigned *Length)
Get the string attribute's value.
Definition Core.cpp:226
uint64_t LLVMGetEnumAttributeValue(LLVMAttributeRef A)
Get the enum attribute's value.
Definition Core.cpp:179
LLVMBool LLVMIsStringAttribute(LLVMAttributeRef A)
Definition Core.cpp:238
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:246
LLVMAttributeRef LLVMCreateStringAttribute(LLVMContextRef C, const char *K, unsigned KLength, const char *V, unsigned VLength)
Create a string attribute.
Definition Core.cpp:212
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:242
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:219
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:257
LLVMValueRef LLVMBuildAggregateRet(LLVMBuilderRef B, LLVMValueRef *RetVals, unsigned N)
Definition Core.cpp:3466
LLVMValueRef LLVMBuildMul(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:3730
LLVMValueRef LLVMBuildRetVoid(LLVMBuilderRef B)
Definition Core.cpp:3458
LLVMValueRef LLVMBuildSub(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:3710
LLVMValueRef LLVMBuildNUWMul(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:3740
LLVMBool LLVMGetWeak(LLVMValueRef CmpXchgInst)
Definition Core.cpp:4161
LLVMValueRef LLVMBuildCast(LLVMBuilderRef B, LLVMOpcode Op, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition Core.cpp:4289
LLVMValueRef LLVMBuildIsNull(LLVMBuilderRef B, LLVMValueRef Val, const char *Name)
Definition Core.cpp:4418
LLVMValueRef LLVMBuildGEPWithNoWrapFlags(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Pointer, LLVMValueRef *Indices, unsigned NumIndices, const char *Name, LLVMGEPNoWrapFlags NoWrapFlags)
Creates a GetElementPtr instruction.
Definition Core.cpp:4119
LLVMValueRef LLVMBuildAdd(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:3690
void LLVMSetWeak(LLVMValueRef CmpXchgInst, LLVMBool isWeak)
Definition Core.cpp:4165
LLVMValueRef LLVMBuildOr(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:3810
LLVMValueRef LLVMBuildBitCast(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition Core.cpp:4261
LLVMValueRef LLVMBuildExactUDiv(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:3755
LLVMValueRef LLVMBuildGEP2(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Pointer, LLVMValueRef *Indices, unsigned NumIndices, const char *Name)
Definition Core.cpp:4104
LLVMValueRef LLVMBuildNSWSub(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:3715
void LLVMPositionBuilderBeforeInstrAndDbgRecords(LLVMBuilderRef Builder, LLVMValueRef Instr)
Set the builder position before Instr and any attached debug records.
Definition Core.cpp:3375
LLVMValueRef LLVMBuildIsNotNull(LLVMBuilderRef B, LLVMValueRef Val, const char *Name)
Definition Core.cpp:4423
void LLVMDisposeBuilder(LLVMBuilderRef Builder)
Definition Core.cpp:3403
void LLVMClearInsertionPosition(LLVMBuilderRef Builder)
Definition Core.cpp:3390
LLVMValueRef LLVMBuildLandingPad(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef PersFn, unsigned NumClauses, const char *Name)
Definition Core.cpp:3532
void LLVMSetIsDisjoint(LLVMValueRef Inst, LLVMBool IsDisjoint)
Sets the disjoint flag for the instruction.
Definition Core.cpp:3913
LLVMBool LLVMIsAtomicSingleThread(LLVMValueRef AtomicInst)
Definition Core.cpp:4499
LLVMValueRef LLVMBuildResume(LLVMBuilderRef B, LLVMValueRef Exn)
Definition Core.cpp:3562
void LLVMSetAtomicRMWBinOp(LLVMValueRef Inst, LLVMAtomicRMWBinOp BinOp)
Definition Core.cpp:4200
LLVMValueRef LLVMBuildFDiv(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:3770
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:3518
LLVMValueRef LLVMBuildXor(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:3815
LLVMBool LLVMGetExact(LLVMValueRef DivOrShrInst)
Definition Core.cpp:3872
LLVMValueRef LLVMBuildAddrSpaceCast(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition Core.cpp:4266
unsigned LLVMGetNumMaskElements(LLVMValueRef SVInst)
Get the number of elements in the mask of a ShuffleVector instruction.
Definition Core.cpp:4481
void LLVMInsertIntoBuilder(LLVMBuilderRef Builder, LLVMValueRef Instr)
Definition Core.cpp:3394
LLVMValueRef LLVMBuildCleanupRet(LLVMBuilderRef B, LLVMValueRef CatchPad, LLVMBasicBlockRef BB)
Definition Core.cpp:3583
LLVMValueRef LLVMBuildFPToSI(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition Core.cpp:4226
void LLVMGetHandlers(LLVMValueRef CatchSwitch, LLVMBasicBlockRef *Handlers)
Obtain the basic blocks acting as handlers for a catchswitch instruction.
Definition Core.cpp:3630
LLVMValueRef LLVMBuildTrunc(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition Core.cpp:4206
LLVMValueRef LLVMGetArgOperand(LLVMValueRef Funclet, unsigned i)
Definition Core.cpp:3647
LLVMValueRef LLVMBuildAnd(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:3805
unsigned LLVMGetNumHandlers(LLVMValueRef CatchSwitch)
Definition Core.cpp:3626
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:3490
LLVMBasicBlockRef LLVMGetInsertBlock(LLVMBuilderRef Builder)
Definition Core.cpp:3386
LLVMValueRef LLVMBuildSDiv(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:3760
LLVMValueRef LLVMBuildSExtOrBitCast(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition Core.cpp:4277
LLVMValueRef LLVMBuildCall2(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Fn, LLVMValueRef *Args, unsigned NumArgs, const char *Name)
Definition Core.cpp:4346
void LLVMSetNSW(LLVMValueRef ArithInst, LLVMBool HasNSW)
Definition Core.cpp:3867
LLVMMetadataRef LLVMGetCurrentDebugLocation2(LLVMBuilderRef Builder)
Get location information used by debugging information.
Definition Core.cpp:3409
LLVMValueRef LLVMBuildUDiv(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:3750
LLVMValueRef LLVMBuildSelect(LLVMBuilderRef B, LLVMValueRef If, LLVMValueRef Then, LLVMValueRef Else, const char *Name)
Definition Core.cpp:4369
void LLVMPositionBuilderBefore(LLVMBuilderRef Builder, LLVMValueRef Instr)
Set the builder position before Instr but after any attached debug records.
Definition Core.cpp:3370
LLVMBool LLVMCanValueUseFastMathFlags(LLVMValueRef V)
Check if a given value can potentially have fast math flags.
Definition Core.cpp:3903
void LLVMSetArgOperand(LLVMValueRef Funclet, unsigned i, LLVMValueRef value)
Definition Core.cpp:3651
LLVMValueRef LLVMBuildCondBr(LLVMBuilderRef B, LLVMValueRef If, LLVMBasicBlockRef Then, LLVMBasicBlockRef Else)
Definition Core.cpp:3475
LLVMBool LLVMGetNUW(LLVMValueRef ArithInst)
Definition Core.cpp:3852
LLVMOpcode LLVMGetCastOpcode(LLVMValueRef Src, LLVMBool SrcIsSigned, LLVMTypeRef DestTy, LLVMBool DestIsSigned)
Definition Core.cpp:4318
void LLVMInsertIntoBuilderWithName(LLVMBuilderRef Builder, LLVMValueRef Instr, const char *Name)
Definition Core.cpp:3398
LLVMValueRef LLVMBuildSRem(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:3780
LLVMValueRef LLVMBuildCleanupPad(LLVMBuilderRef B, LLVMValueRef ParentPad, LLVMValueRef *Args, unsigned NumArgs, const char *Name)
Definition Core.cpp:3551
LLVMValueRef LLVMBuildIntCast(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Deprecated: This cast is always signed.
Definition Core.cpp:4307
LLVMValueRef LLVMGetCurrentDebugLocation(LLVMBuilderRef Builder)
Deprecated: Returning the NULL location will crash.
Definition Core.cpp:3426
LLVMValueRef LLVMBuildExtractElement(LLVMBuilderRef B, LLVMValueRef VecVal, LLVMValueRef Index, const char *Name)
Definition Core.cpp:4381
LLVMValueRef LLVMBuildShl(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:3790
LLVMBuilderRef LLVMCreateBuilderInContext(LLVMContextRef C)
Definition Core.cpp:3342
LLVMValueRef LLVMBuildCatchRet(LLVMBuilderRef B, LLVMValueRef CatchPad, LLVMBasicBlockRef BB)
Definition Core.cpp:3577
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:3954
LLVMAtomicOrdering LLVMGetOrdering(LLVMValueRef MemAccessInst)
Definition Core.cpp:4169
LLVMValueRef LLVMBuildStructGEP2(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Pointer, unsigned Idx, const char *Name)
Definition Core.cpp:4129
int LLVMGetMaskValue(LLVMValueRef SVInst, unsigned Elt)
Get the mask value at position Elt in the mask of a ShuffleVector instruction.
Definition Core.cpp:4487
void LLVMAddCase(LLVMValueRef Switch, LLVMValueRef OnVal, LLVMBasicBlockRef Dest)
Definition Core.cpp:3593
LLVMValueRef LLVMBuildBr(LLVMBuilderRef B, LLVMBasicBlockRef Dest)
Definition Core.cpp:3471
LLVMValueRef LLVMBuildInsertElement(LLVMBuilderRef B, LLVMValueRef VecVal, LLVMValueRef EltVal, LLVMValueRef Index, const char *Name)
Definition Core.cpp:4387
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:3363
void LLVMSetFastMathFlags(LLVMValueRef FPMathInst, LLVMFastMathFlags FMF)
Sets the flags for which fast-math-style optimizations are allowed for this value.
Definition Core.cpp:3898
LLVMValueRef LLVMBuildIntCast2(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, LLVMBool IsSigned, const char *Name)
Definition Core.cpp:4300
LLVMValueRef LLVMBuildNUWSub(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:3720
LLVMValueRef LLVMBuildFAdd(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:3705
LLVMValueRef LLVMBuildCatchPad(LLVMBuilderRef B, LLVMValueRef ParentPad, LLVMValueRef *Args, unsigned NumArgs, const char *Name)
Definition Core.cpp:3544
LLVMValueRef LLVMBuildCallWithOperandBundles(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Fn, LLVMValueRef *Args, unsigned NumArgs, LLVMOperandBundleRef *Bundles, unsigned NumBundles, const char *Name)
Definition Core.cpp:4355
LLVMBool LLVMIsCleanup(LLVMValueRef LandingPad)
Definition Core.cpp:3614
LLVMValueRef LLVMBuildZExtOrBitCast(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition Core.cpp:4271
LLVMBool LLVMGetVolatile(LLVMValueRef Inst)
Definition Core.cpp:4146
LLVMValueRef LLVMBuildFPCast(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition Core.cpp:4313
LLVMValueRef LLVMBuildPtrToInt(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition Core.cpp:4251
LLVMValueRef LLVMBuildPtrDiff2(LLVMBuilderRef B, LLVMTypeRef ElemTy, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:4428
LLVMValueRef LLVMBuildTruncOrBitCast(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition Core.cpp:4283
LLVMValueRef LLVMBuildArrayAlloca(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Val, const char *Name)
Definition Core.cpp:3968
LLVMValueRef LLVMGetClause(LLVMValueRef LandingPad, unsigned Idx)
Definition Core.cpp:3606
unsigned LLVMGetAtomicSyncScopeID(LLVMValueRef AtomicInst)
Returns the synchronization scope ID of an atomic instruction.
Definition Core.cpp:4518
LLVMValueRef LLVMBuildVAArg(LLVMBuilderRef B, LLVMValueRef List, LLVMTypeRef Ty, const char *Name)
Definition Core.cpp:4376
LLVMValueRef LLVMBuildAtomicCmpXchgSyncScope(LLVMBuilderRef B, LLVMValueRef Ptr, LLVMValueRef Cmp, LLVMValueRef New, LLVMAtomicOrdering SuccessOrdering, LLVMAtomicOrdering FailureOrdering, unsigned SSID)
Definition Core.cpp:4470
LLVMValueRef LLVMBuildBinOp(LLVMBuilderRef B, LLVMOpcode Op, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:3820
LLVMBool LLVMIsAtomic(LLVMValueRef Inst)
Returns whether an instruction is an atomic instruction, e.g., atomicrmw, cmpxchg,...
Definition Core.cpp:4495
void LLVMSetVolatile(LLVMValueRef MemAccessInst, LLVMBool isVolatile)
Definition Core.cpp:4150
void LLVMSetAtomicSingleThread(LLVMValueRef AtomicInst, LLVMBool NewValue)
Definition Core.cpp:4508
LLVMValueRef LLVMBuildFRem(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:3785
LLVMValueRef LLVMBuildURem(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:3775
LLVMValueRef LLVMBuildIntToPtr(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition Core.cpp:4256
LLVMBool LLVMGetNSW(LLVMValueRef ArithInst)
Definition Core.cpp:3862
LLVMValueRef LLVMBuildNSWMul(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:3735
LLVMValueRef LLVMBuildFree(LLVMBuilderRef B, LLVMValueRef PointerVal)
Definition Core.cpp:3973
LLVMValueRef LLVMBuildNeg(LLVMBuilderRef B, LLVMValueRef V, const char *Name)
Definition Core.cpp:3827
LLVMValueRef LLVMBuildFSub(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:3725
LLVMValueRef LLVMBuildCatchSwitch(LLVMBuilderRef B, LLVMValueRef ParentPad, LLVMBasicBlockRef UnwindBB, unsigned NumHandlers, const char *Name)
Definition Core.cpp:3566
LLVMValueRef LLVMBuildLoad2(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef PointerVal, const char *Name)
Definition Core.cpp:3977
LLVMValueRef LLVMBuildInBoundsGEP2(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Pointer, LLVMValueRef *Indices, unsigned NumIndices, const char *Name)
Definition Core.cpp:4111
LLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Val, const char *Name)
Definition Core.cpp:3929
LLVMValueRef LLVMBuildAtomicCmpXchg(LLVMBuilderRef B, LLVMValueRef Ptr, LLVMValueRef Cmp, LLVMValueRef New, LLVMAtomicOrdering SuccessOrdering, LLVMAtomicOrdering FailureOrdering, LLVMBool singleThread)
Definition Core.cpp:4457
LLVMValueRef LLVMBuildIndirectBr(LLVMBuilderRef B, LLVMValueRef Addr, unsigned NumDests)
Definition Core.cpp:3485
LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef B)
Definition Core.cpp:3589
LLVMValueRef LLVMBuildSIToFP(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition Core.cpp:4236
LLVMValueRef LLVMBuildSExt(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition Core.cpp:4216
LLVMValueRef LLVMBuildFPToUI(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition Core.cpp:4221
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:3432
void LLVMSetCurrentDebugLocation2(LLVMBuilderRef Builder, LLVMMetadataRef Loc)
Set location information used by debugging information.
Definition Core.cpp:3413
LLVMValueRef LLVMBuildAlloca(LLVMBuilderRef B, LLVMTypeRef Ty, const char *Name)
Definition Core.cpp:3963
void LLVMSetCurrentDebugLocation(LLVMBuilderRef Builder, LLVMValueRef L)
Deprecated: Passing the NULL location will crash.
Definition Core.cpp:3420
LLVMValueRef LLVMBuildPhi(LLVMBuilderRef B, LLVMTypeRef Ty, const char *Name)
Definition Core.cpp:4342
void LLVMAddDestination(LLVMValueRef IndirectBr, LLVMBasicBlockRef Dest)
Definition Core.cpp:3598
LLVMBool LLVMGetNNeg(LLVMValueRef NonNegInst)
Gets if the instruction has the non-negative flag set.
Definition Core.cpp:3882
LLVMValueRef LLVMBuildAtomicRMWSyncScope(LLVMBuilderRef B, LLVMAtomicRMWBinOp op, LLVMValueRef PTR, LLVMValueRef Val, LLVMAtomicOrdering ordering, unsigned SSID)
Definition Core.cpp:4446
LLVMValueRef LLVMBuildRet(LLVMBuilderRef B, LLVMValueRef V)
Definition Core.cpp:3462
LLVMMetadataRef LLVMBuilderGetDefaultFPMathTag(LLVMBuilderRef Builder)
Get the dafult floating-point math metadata for a given builder.
Definition Core.cpp:3452
LLVMValueRef LLVMBuildExtractValue(LLVMBuilderRef B, LLVMValueRef AggVal, unsigned Index, const char *Name)
Definition Core.cpp:4401
LLVMValueRef LLVMBuildGlobalStringPtr(LLVMBuilderRef B, const char *Str, const char *Name)
Deprecated: Use LLVMBuildGlobalString instead, which has identical behavior.
Definition Core.cpp:4141
LLVMValueRef LLVMBuildNSWAdd(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:3695
void LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder, LLVMBasicBlockRef Block)
Definition Core.cpp:3381
LLVMValueRef LLVMBuildFMul(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:3745
LLVMValueRef LLVMBuildLShr(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:3795
LLVMAtomicRMWBinOp LLVMGetAtomicRMWBinOp(LLVMValueRef Inst)
Definition Core.cpp:4196
LLVMValueRef LLVMBuildFNeg(LLVMBuilderRef B, LLVMValueRef V, const char *Name)
Definition Core.cpp:3844
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:3938
void LLVMSetAtomicSyncScopeID(LLVMValueRef AtomicInst, unsigned SSID)
Sets the synchronization scope ID of an atomic instruction.
Definition Core.cpp:4524
LLVMContextRef LLVMGetBuilderContext(LLVMBuilderRef Builder)
Obtain the context to which this builder is associated.
Definition Core.cpp:3448
LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef B, LLVMTypeRef Ty, const char *Name)
Definition Core.cpp:3920
LLVMValueRef LLVMBuildFreeze(LLVMBuilderRef B, LLVMValueRef Val, const char *Name)
Definition Core.cpp:4413
LLVMValueRef LLVMBuildGlobalString(LLVMBuilderRef B, const char *Str, const char *Name)
Definition Core.cpp:4136
void LLVMSetNUW(LLVMValueRef ArithInst, LLVMBool HasNUW)
Definition Core.cpp:3857
LLVMAtomicOrdering LLVMGetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst)
Definition Core.cpp:4530
LLVMValueRef LLVMBuildFCmp(LLVMBuilderRef B, LLVMRealPredicate Op, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:4333
LLVMValueRef LLVMBuildPointerCast(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition Core.cpp:4295
LLVMValueRef LLVMBuildExactSDiv(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:3765
LLVMValueRef LLVMBuildShuffleVector(LLVMBuilderRef B, LLVMValueRef V1, LLVMValueRef V2, LLVMValueRef Mask, const char *Name)
Definition Core.cpp:4394
LLVMValueRef LLVMBuildFPExt(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition Core.cpp:4246
void LLVMSetCleanup(LLVMValueRef LandingPad, LLVMBool Val)
Definition Core.cpp:3618
LLVMValueRef LLVMBuildICmp(LLVMBuilderRef B, LLVMIntPredicate Op, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:4326
void LLVMSetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst, LLVMAtomicOrdering Ordering)
Definition Core.cpp:4548
void LLVMAddClause(LLVMValueRef LandingPad, LLVMValueRef ClauseVal)
Definition Core.cpp:3610
LLVMValueRef LLVMBuildFence(LLVMBuilderRef B, LLVMAtomicOrdering Ordering, LLVMBool isSingleThread, const char *Name)
Definition Core.cpp:4088
void LLVMSetParentCatchSwitch(LLVMValueRef CatchPad, LLVMValueRef CatchSwitch)
Set the parent catchswitch instruction of a catchpad instruction.
Definition Core.cpp:3640
LLVMValueRef LLVMBuildFenceSyncScope(LLVMBuilderRef B, LLVMAtomicOrdering Ordering, unsigned SSID, const char *Name)
Definition Core.cpp:4097
LLVMValueRef LLVMBuildUIToFP(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition Core.cpp:4231
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:3357
unsigned LLVMGetNumClauses(LLVMValueRef LandingPad)
Definition Core.cpp:3602
int LLVMGetUndefMaskElem(void)
Definition Core.cpp:4493
void LLVMSetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst, LLVMAtomicOrdering Ordering)
Definition Core.cpp:4535
LLVMValueRef LLVMGetParentCatchSwitch(LLVMValueRef CatchPad)
Get the parent catchswitch instruction of a catchpad instruction.
Definition Core.cpp:3636
LLVMFastMathFlags LLVMGetFastMathFlags(LLVMValueRef FPMathInst)
Get the flags for which fast-math-style optimizations are allowed for this value.
Definition Core.cpp:3892
LLVMBool LLVMGetIsDisjoint(LLVMValueRef Inst)
Gets whether the instruction has the disjoint flag set.
Definition Core.cpp:3908
LLVMValueRef LLVMBuildSwitch(LLVMBuilderRef B, LLVMValueRef V, LLVMBasicBlockRef Else, unsigned NumCases)
Definition Core.cpp:3480
void LLVMSetNNeg(LLVMValueRef NonNegInst, LLVMBool IsNonNeg)
Sets the non-negative flag for the instruction.
Definition Core.cpp:3887
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:3945
void LLVMAddHandler(LLVMValueRef CatchSwitch, LLVMBasicBlockRef Dest)
Definition Core.cpp:3622
void LLVMSetExact(LLVMValueRef DivOrShrInst, LLVMBool IsExact)
Definition Core.cpp:3877
LLVMValueRef LLVMBuildNSWNeg(LLVMBuilderRef B, LLVMValueRef V, const char *Name)
Definition Core.cpp:3831
LLVMValueRef LLVMBuildAShr(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:3800
LLVMValueRef LLVMBuildInvoke2(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Fn, LLVMValueRef *Args, unsigned NumArgs, LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch, const char *Name)
Definition Core.cpp:3509
void LLVMSetOrdering(LLVMValueRef MemAccessInst, LLVMAtomicOrdering Ordering)
Definition Core.cpp:4183
LLVMValueRef LLVMBuildFPTrunc(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition Core.cpp:4241
LLVMValueRef LLVMBuildStore(LLVMBuilderRef B, LLVMValueRef Val, LLVMValueRef PointerVal)
Definition Core.cpp:3982
void LLVMAddMetadataToInst(LLVMBuilderRef Builder, LLVMValueRef Inst)
Adds the metadata registered with the given builder to the given instruction.
Definition Core.cpp:3436
LLVMAtomicOrdering LLVMGetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst)
Definition Core.cpp:4543
LLVMValueRef LLVMBuildNUWAdd(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition Core.cpp:3700
LLVMValueRef LLVMBuildInsertValue(LLVMBuilderRef B, LLVMValueRef AggVal, LLVMValueRef EltVal, unsigned Index, const char *Name)
Definition Core.cpp:4406
void LLVMBuilderSetDefaultFPMathTag(LLVMBuilderRef Builder, LLVMMetadataRef FPMathTag)
Set the default floating-point math metadata for the given builder.
Definition Core.cpp:3440
LLVMValueRef LLVMBuildZExt(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition Core.cpp:4211
LLVMValueRef LLVMBuildNot(LLVMBuilderRef B, LLVMValueRef V, const char *Name)
Definition Core.cpp:3848
LLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B, LLVMAtomicRMWBinOp op, LLVMValueRef PTR, LLVMValueRef Val, LLVMAtomicOrdering ordering, LLVMBool singleThread)
Definition Core.cpp:4435
LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRange(const char *InputData, size_t InputDataLength, const char *BufferName, LLVMBool RequiresNullTerminator)
Definition Core.cpp:4595
size_t LLVMGetBufferSize(LLVMMemoryBufferRef MemBuf)
Definition Core.cpp:4620
LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRangeCopy(const char *InputData, size_t InputDataLength, const char *BufferName)
Definition Core.cpp:4606
const char * LLVMGetBufferStart(LLVMMemoryBufferRef MemBuf)
Definition Core.cpp:4616
LLVMBool LLVMCreateMemoryBufferWithContentsOfFile(const char *Path, LLVMMemoryBufferRef *OutMemBuf, char **OutMessage)
Definition Core.cpp:4570
LLVMBool LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef *OutMemBuf, char **OutMessage)
Definition Core.cpp:4584
void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf)
Definition Core.cpp:4624
LLVMModuleProviderRef LLVMCreateModuleProviderForExistingModule(LLVMModuleRef M)
Changes the type of M so it can be passed to FunctionPassManagers and the JIT.
Definition Core.cpp:4559
void LLVMDisposeModuleProvider(LLVMModuleProviderRef MP)
Destroys the module M.
Definition Core.cpp:4563
char * LLVMPrintModuleToString(LLVMModuleRef M)
Return a string representation of the module.
Definition Core.cpp:475
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:1404
LLVMValueRef LLVMGetNamedFunctionWithLength(LLVMModuleRef M, const char *Name, size_t Length)
Obtain a Function value from a Module by its name.
Definition Core.cpp:2432
unsigned LLVMGetDebugLocColumn(LLVMValueRef Val)
Return the column number of the debug location for this value, which must be an llvm::Instruction.
Definition Core.cpp:1532
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:1399
LLVMModuleRef LLVMModuleCreateWithNameInContext(const char *ModuleID, LLVMContextRef C)
Create a new, empty module in a specific context.
Definition Core.cpp:284
const char * LLVMGetTarget(LLVMModuleRef M)
Obtain the target triple for a module.
Definition Core.cpp:327
LLVMBool LLVMGetInlineAsmCanUnwind(LLVMValueRef InlineAsmVal)
Get if the inline asm snippet may unwind the stack.
Definition Core.cpp:573
const char * LLVMGetModuleInlineAsm(LLVMModuleRef M, size_t *Len)
Get inline assembly for a module.
Definition Core.cpp:498
LLVMBool LLVMGetInlineAsmNeedsAlignedStack(LLVMValueRef InlineAsmVal)
Get if the inline asm snippet needs an aligned stack.
Definition Core.cpp:568
LLVMBool LLVMGetInlineAsmHasSideEffects(LLVMValueRef InlineAsmVal)
Get if the inline asm snippet has side effects.
Definition Core.cpp:563
unsigned LLVMGetNamedMetadataNumOperands(LLVMModuleRef M, const char *Name)
Obtain the number of operands for named metadata in a module.
Definition Core.cpp:1435
void LLVMDumpModule(LLVMModuleRef M)
Dump a representation of a module to stderr.
Definition Core.cpp:448
void LLVMSetTarget(LLVMModuleRef M, const char *TripleStr)
Set the target triple for a module.
Definition Core.cpp:331
LLVMTypeRef LLVMGetInlineAsmFunctionType(LLVMValueRef InlineAsmVal)
Get the function type of the inline assembly snippet.
Definition Core.cpp:558
LLVMBool LLVMIsNewDbgInfoFormat(LLVMModuleRef M)
Soon to be deprecated.
Definition Core.cpp:438
LLVMContextRef LLVMGetModuleContext(LLVMModuleRef M)
Obtain the context to which this module is associated.
Definition Core.cpp:579
LLVMInlineAsmDialect LLVMGetInlineAsmDialect(LLVMValueRef InlineAsmVal)
Get the dialect used by the inline asm snippet.
Definition Core.cpp:542
void LLVMSetModuleInlineAsm(LLVMModuleRef M, const char *Asm)
Deprecated: Use LLVMSetModuleInlineAsm2 instead.
Definition Core.cpp:490
LLVMValueRef LLVMGetNextFunction(LLVMValueRef Fn)
Advance a Function iterator to the next Function.
Definition Core.cpp:2453
const char * LLVMGetModuleIdentifier(LLVMModuleRef M, size_t *Len)
Obtain the identifier of a module.
Definition Core.cpp:293
const char * LLVMGetSourceFileName(LLVMModuleRef M, size_t *Len)
Obtain the module's original source file name.
Definition Core.cpp:303
const char * LLVMGetDataLayoutStr(LLVMModuleRef M)
Obtain the data layout for a module.
Definition Core.cpp:314
LLVMModuleFlagBehavior LLVMModuleFlagEntriesGetFlagBehavior(LLVMModuleFlagEntry *Entries, unsigned Index)
Returns the flag behavior for a module flag entry at a specific index.
Definition Core.cpp:404
void LLVMSetIsNewDbgInfoFormat(LLVMModuleRef M, LLVMBool UseNewFormat)
Soon to be deprecated.
Definition Core.cpp:440
LLVMTypeRef LLVMGetTypeByName(LLVMModuleRef M, const char *Name)
Deprecated: Use LLVMGetTypeByName2 instead.
Definition Core.cpp:852
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:299
const char * LLVMGetInlineAsmAsmString(LLVMValueRef InlineAsmVal, size_t *Len)
Get the template string used for an inline assembly snippet.
Definition Core.cpp:524
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:504
LLVMValueRef LLVMGetOrInsertFunction(LLVMModuleRef M, const char *Name, size_t NameLen, LLVMTypeRef FunctionTy)
Obtain or insert a function into a module.
Definition Core.cpp:2420
const char * LLVMGetInlineAsmConstraintString(LLVMValueRef InlineAsmVal, size_t *Len)
Get the raw constraint string for an inline assembly snippet.
Definition Core.cpp:533
LLVMNamedMDNodeRef LLVMGetNextNamedMetadata(LLVMNamedMDNodeRef NMD)
Advance a NamedMDNode iterator to the next NamedMDNode.
Definition Core.cpp:1383
void LLVMGetNamedMetadataOperands(LLVMModuleRef M, const char *Name, LLVMValueRef *Dest)
Obtain the named metadata operands for a module.
Definition Core.cpp:1442
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:426
LLVMValueRef LLVMAddFunction(LLVMModuleRef M, const char *Name, LLVMTypeRef FunctionTy)
Add a function to a module under a specified name.
Definition Core.cpp:2414
LLVMValueRef LLVMGetPreviousFunction(LLVMValueRef Fn)
Decrement a Function iterator to the previous Function.
Definition Core.cpp:2461
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:1462
void LLVMAddNamedMetadataOperand(LLVMModuleRef M, const char *Name, LLVMValueRef Val)
Add an operand to named metadata.
Definition Core.cpp:1452
unsigned LLVMGetDebugLocLine(LLVMValueRef Val)
Return the line number of the debug location for this value, which must be an llvm::Instruction,...
Definition Core.cpp:1510
LLVMMetadataRef LLVMModuleFlagEntriesGetMetadata(LLVMModuleFlagEntry *Entries, unsigned Index)
Returns the metadata for a module flag entry at a specific index.
Definition Core.cpp:419
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:431
LLVMValueRef LLVMGetLastFunction(LLVMModuleRef M)
Obtain an iterator to the last Function in a Module.
Definition Core.cpp:2445
LLVMNamedMDNodeRef LLVMGetPreviousNamedMetadata(LLVMNamedMDNodeRef NMD)
Decrement a NamedMDNode iterator to the previous NamedMDNode.
Definition Core.cpp:1391
const char * LLVMGetNamedMetadataName(LLVMNamedMDNodeRef NMD, size_t *NameLen)
Retrieve the name of a NamedMDNode.
Definition Core.cpp:1409
LLVMValueRef LLVMGetNamedFunction(LLVMModuleRef M, const char *Name)
Obtain a Function value from a Module by its name.
Definition Core.cpp:2428
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:1486
void LLVMAppendModuleInlineAsm(LLVMModuleRef M, const char *Asm, size_t Len)
Append inline assembly to a module.
Definition Core.cpp:494
void LLVMSetDataLayout(LLVMModuleRef M, const char *DataLayoutStr)
Set the data layout for a module.
Definition Core.cpp:322
void LLVMDisposeModuleFlagsMetadata(LLVMModuleFlagEntry *Entries)
Destroys module flags metadata entries.
Definition Core.cpp:399
void LLVMDisposeModule(LLVMModuleRef M)
Destroy a module instance.
Definition Core.cpp:289
LLVMNamedMDNodeRef LLVMGetLastNamedMetadata(LLVMModuleRef M)
Obtain an iterator to the last NamedMDNode in a Module.
Definition Core.cpp:1375
void LLVMSetModuleInlineAsm2(LLVMModuleRef M, const char *Asm, size_t Len)
Set inline assembly for a module.
Definition Core.cpp:486
LLVMValueRef LLVMGetFirstFunction(LLVMModuleRef M)
Obtain an iterator to the first Function in a Module.
Definition Core.cpp:2437
LLVMNamedMDNodeRef LLVMGetFirstNamedMetadata(LLVMModuleRef M)
Obtain an iterator to the first NamedMDNode in a Module.
Definition Core.cpp:1367
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:411
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:309
LLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename, char **ErrorMessage)
Print a representation of a module to a file.
Definition Core.cpp:453
const char * LLVMGetDataLayout(LLVMModuleRef M)
Definition Core.cpp:318
LLVMModuleFlagEntry * LLVMCopyModuleFlagsMetadata(LLVMModuleRef M, size_t *Len)
Returns the module flags as an array of flag-key-value triples.
Definition Core.cpp:382
LLVMOperandBundleRef LLVMCreateOperandBundle(const char *Tag, size_t TagLen, LLVMValueRef *Args, unsigned NumArgs)
Create a new operand bundle.
Definition Core.cpp:2776
unsigned LLVMGetNumOperandBundleArgs(LLVMOperandBundleRef Bundle)
Obtain the number of operands for an operand bundle.
Definition Core.cpp:2793
const char * LLVMGetOperandBundleTag(LLVMOperandBundleRef Bundle, size_t *Len)
Obtain the tag of an operand bundle as a string.
Definition Core.cpp:2787
void LLVMDisposeOperandBundle(LLVMOperandBundleRef Bundle)
Destroy an operand bundle.
Definition Core.cpp:2783
LLVMValueRef LLVMGetOperandBundleArgAtIndex(LLVMOperandBundleRef Bundle, unsigned Index)
Obtain the operand for an operand bundle at the given index.
Definition Core.cpp:2797
LLVMPassManagerRef LLVMCreateFunctionPassManager(LLVMModuleProviderRef P)
Deprecated: Use LLVMCreateFunctionPassManagerForModule instead.
Definition Core.cpp:4638
LLVMPassManagerRef LLVMCreateFunctionPassManagerForModule(LLVMModuleRef M)
Constructs a new function-by-function pass pipeline over the module provider.
Definition Core.cpp:4634
LLVMBool LLVMFinalizeFunctionPassManager(LLVMPassManagerRef FPM)
Finalizes all of the function passes scheduled in the function pass manager.
Definition Core.cpp:4655
void LLVMDisposePassManager(LLVMPassManagerRef PM)
Frees the memory of a pass pipeline.
Definition Core.cpp:4659
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:4651
LLVMBool LLVMInitializeFunctionPassManager(LLVMPassManagerRef FPM)
Initializes all of the function passes scheduled in the function pass manager.
Definition Core.cpp:4647
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:4643
LLVMPassManagerRef LLVMCreatePassManager()
Constructs a new whole-module pass pipeline.
Definition Core.cpp:4630
void LLVMStopMultithreaded()
Deprecated: Multi-threading can only be enabled/disabled with the compile time define LLVM_ENABLE_THR...
Definition Core.cpp:4669
LLVMBool LLVMStartMultithreaded()
Deprecated: Multi-threading can only be enabled/disabled with the compile time define LLVM_ENABLE_THR...
Definition Core.cpp:4665
LLVMBool LLVMIsMultithreaded()
Check whether LLVM is executing in thread-safe mode or not.
Definition Core.cpp:4672
LLVMTypeRef LLVMHalfTypeInContext(LLVMContextRef C)
Obtain a 16-bit floating point type from a context.
Definition Core.cpp:715
LLVMTypeRef LLVMBFloatTypeInContext(LLVMContextRef C)
Obtain a 16-bit brain floating point type from a context.
Definition Core.cpp:718
LLVMTypeRef LLVMPPCFP128TypeInContext(LLVMContextRef C)
Obtain a 128-bit floating point type (two 64-bits) from a context.
Definition Core.cpp:733
LLVMTypeRef LLVMDoubleTypeInContext(LLVMContextRef C)
Obtain a 64-bit floating point type from a context.
Definition Core.cpp:724
LLVMTypeRef LLVMFloatTypeInContext(LLVMContextRef C)
Obtain a 32-bit floating point type from a context.
Definition Core.cpp:721
LLVMTypeRef LLVMFP128TypeInContext(LLVMContextRef C)
Obtain a 128-bit floating point type (112-bit mantissa) from a context.
Definition Core.cpp:730
LLVMTypeRef LLVMX86FP80TypeInContext(LLVMContextRef C)
Obtain a 80-bit floating point type (X87) from a context.
Definition Core.cpp:727
LLVMTypeRef LLVMGetReturnType(LLVMTypeRef FunctionTy)
Obtain the Type this function Type returns.
Definition Core.cpp:778
LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType, LLVMTypeRef *ParamTypes, unsigned ParamCount, LLVMBool IsVarArg)
Obtain a function type consisting of a specified signature.
Definition Core.cpp:767
LLVMBool LLVMIsFunctionVarArg(LLVMTypeRef FunctionTy)
Returns whether a function type is variadic.
Definition Core.cpp:774
unsigned LLVMCountParamTypes(LLVMTypeRef FunctionTy)
Obtain the number of parameters this function accepts.
Definition Core.cpp:782
void LLVMGetParamTypes(LLVMTypeRef FunctionTy, LLVMTypeRef *Dest)
Obtain the types of a function's parameters.
Definition Core.cpp:786
LLVMTypeRef LLVMInt1TypeInContext(LLVMContextRef C)
Obtain an integer type from a context with specified bit width.
Definition Core.cpp:665
LLVMTypeRef LLVMInt8TypeInContext(LLVMContextRef C)
Definition Core.cpp:668
LLVMTypeRef LLVMInt32TypeInContext(LLVMContextRef C)
Definition Core.cpp:674
LLVMTypeRef LLVMIntTypeInContext(LLVMContextRef C, unsigned NumBits)
Definition Core.cpp:683
LLVMTypeRef LLVMInt64TypeInContext(LLVMContextRef C)
Definition Core.cpp:677
LLVMTypeRef LLVMInt16TypeInContext(LLVMContextRef C)
Definition Core.cpp:671
unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy)
Definition Core.cpp:709
LLVMTypeRef LLVMInt128TypeInContext(LLVMContextRef C)
Definition Core.cpp:680
unsigned LLVMGetTargetExtTypeNumTypeParams(LLVMTypeRef TargetExtTy)
Obtain the number of type parameters for this target extension type.
Definition Core.cpp:981
LLVMTypeRef LLVMX86AMXTypeInContext(LLVMContextRef C)
Create a X86 AMX type in a context.
Definition Core.cpp:736
const char * LLVMGetTargetExtTypeName(LLVMTypeRef TargetExtTy)
Obtain the name for this target extension type.
Definition Core.cpp:976
LLVMTypeRef LLVMVoidTypeInContext(LLVMContextRef C)
Create a void type in a context.
Definition Core.cpp:945
LLVMTypeRef LLVMTokenTypeInContext(LLVMContextRef C)
Create a token type in a context.
Definition Core.cpp:951
unsigned LLVMGetTargetExtTypeNumIntParams(LLVMTypeRef TargetExtTy)
Obtain the number of int parameters for this target extension type.
Definition Core.cpp:992
LLVMTypeRef LLVMLabelTypeInContext(LLVMContextRef C)
Create a label type in a context.
Definition Core.cpp:948
LLVMTypeRef LLVMMetadataTypeInContext(LLVMContextRef C)
Create a metadata type in a context.
Definition Core.cpp:954
LLVMTypeRef LLVMGetTargetExtTypeTypeParam(LLVMTypeRef TargetExtTy, unsigned Idx)
Get the type parameter at the given index for the target extension type.
Definition Core.cpp:986
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:965
unsigned LLVMGetTargetExtTypeIntParam(LLVMTypeRef TargetExtTy, unsigned Idx)
Get the int parameter at the given index for the target extension type.
Definition Core.cpp:997
LLVMValueRef LLVMGetConstantPtrAuthAddrDiscriminator(LLVMValueRef PtrAuth)
Get the address discriminator value for the associated ConstantPtrAuth constant.
Definition Core.cpp:935
LLVMBool LLVMPointerTypeIsOpaque(LLVMTypeRef Ty)
Determine whether a pointer is opaque.
Definition Core.cpp:883
LLVMTypeRef LLVMPointerTypeInContext(LLVMContextRef C, unsigned AddressSpace)
Create an opaque pointer type in a context.
Definition Core.cpp:941
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:887
LLVMTypeRef LLVMGetElementType(LLVMTypeRef WrappedTy)
Obtain the element type of an array or vector type.
Definition Core.cpp:896
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:891
LLVMValueRef LLVMGetConstantPtrAuthDiscriminator(LLVMValueRef PtrAuth)
Get the discriminator value for the associated ConstantPtrAuth constant.
Definition Core.cpp:931
uint64_t LLVMGetArrayLength2(LLVMTypeRef ArrayTy)
Obtain the length of an array type.
Definition Core.cpp:911
LLVMValueRef LLVMGetConstantPtrAuthKey(LLVMValueRef PtrAuth)
Get the key value for the associated ConstantPtrAuth constant.
Definition Core.cpp:927
unsigned LLVMGetArrayLength(LLVMTypeRef ArrayTy)
Obtain the length of an array type.
Definition Core.cpp:907
LLVMValueRef LLVMGetConstantPtrAuthPointer(LLVMValueRef PtrAuth)
Get the pointer value for the associated ConstantPtrAuth constant.
Definition Core.cpp:923
unsigned LLVMGetPointerAddressSpace(LLVMTypeRef PointerTy)
Obtain the address space of a pointer type.
Definition Core.cpp:915
LLVMTypeRef LLVMArrayType2(LLVMTypeRef ElementType, uint64_t ElementCount)
Create a fixed size array type that refers to a specific type.
Definition Core.cpp:874
unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy)
Obtain the (possibly scalable) number of elements in a vector type.
Definition Core.cpp:919
LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount)
Create a fixed size array type that refers to a specific type.
Definition Core.cpp:870
void LLVMGetSubtypes(LLVMTypeRef Tp, LLVMTypeRef *Arr)
Returns type's subtypes.
Definition Core.cpp:862
LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, unsigned AddressSpace)
Create a pointer type that points to a defined type.
Definition Core.cpp:878
unsigned LLVMGetNumContainedTypes(LLVMTypeRef Tp)
Return the number of types in the derived type.
Definition Core.cpp:903
LLVMTypeRef LLVMStructTypeInContext(LLVMContextRef C, LLVMTypeRef *ElementTypes, unsigned ElementCount, LLVMBool Packed)
Create a new structure type in a context.
Definition Core.cpp:794
void LLVMGetStructElementTypes(LLVMTypeRef StructTy, LLVMTypeRef *Dest)
Get the elements within a structure.
Definition Core.cpp:829
LLVMTypeRef LLVMStructGetTypeAtIndex(LLVMTypeRef StructTy, unsigned i)
Get the type of the element at a given index in the structure.
Definition Core.cpp:835
LLVMBool LLVMIsPackedStruct(LLVMTypeRef StructTy)
Determine whether a structure is packed.
Definition Core.cpp:840
LLVMTypeRef LLVMStructCreateNamed(LLVMContextRef C, const char *Name)
Create an empty structure in a context having a specified name.
Definition Core.cpp:806
void LLVMStructSetBody(LLVMTypeRef StructTy, LLVMTypeRef *ElementTypes, unsigned ElementCount, LLVMBool Packed)
Set the contents of a structure type.
Definition Core.cpp:819
LLVMBool LLVMIsOpaqueStruct(LLVMTypeRef StructTy)
Determine whether a structure is opaque.
Definition Core.cpp:844
unsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy)
Get the number of elements defined inside the structure.
Definition Core.cpp:825
const char * LLVMGetStructName(LLVMTypeRef Ty)
Obtain the name of a structure.
Definition Core.cpp:811
LLVMBool LLVMIsLiteralStruct(LLVMTypeRef StructTy)
Determine whether a structure is literal.
Definition Core.cpp:848
void LLVMDumpType(LLVMTypeRef Ty)
Dump a representation of a type to stderr.
Definition Core.cpp:645
LLVMBool LLVMTypeIsSized(LLVMTypeRef Ty)
Whether the type has a known size.
Definition Core.cpp:636
LLVMContextRef LLVMGetTypeContext(LLVMTypeRef Ty)
Obtain the context to which this type instance is associated.
Definition Core.cpp:641
char * LLVMPrintTypeToString(LLVMTypeRef Ty)
Return a string representation of the type.
Definition Core.cpp:649
LLVMTypeKind LLVMGetTypeKind(LLVMTypeRef Ty)
Obtain the enumerated type of a Type instance.
Definition Core.cpp:588
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:2944
void LLVMMoveBasicBlockAfter(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos)
Move a basic block to after another one.
Definition Core.cpp:2926
LLVMBasicBlockRef LLVMGetFirstBasicBlock(LLVMValueRef Fn)
Obtain the first basic block in a function.
Definition Core.cpp:2842
LLVMBasicBlockRef LLVMCreateBasicBlockInContext(LLVMContextRef C, const char *Name)
Create a new basic block without inserting it into a function.
Definition Core.cpp:2874
LLVMBasicBlockRef LLVMGetPreviousBasicBlock(LLVMBasicBlockRef BB)
Go backwards in a basic block iterator.
Definition Core.cpp:2866
LLVMBasicBlockRef LLVMGetLastBasicBlock(LLVMValueRef Fn)
Obtain the last basic block in a function.
Definition Core.cpp:2850
LLVMValueRef LLVMGetBasicBlockTerminator(LLVMBasicBlockRef BB)
Obtain the terminator instruction for a basic block.
Definition Core.cpp:2824
const char * LLVMGetBasicBlockName(LLVMBasicBlockRef BB)
Obtain the string name of a basic block.
Definition Core.cpp:2816
void LLVMAppendExistingBasicBlock(LLVMValueRef Fn, LLVMBasicBlockRef BB)
Append the given basic block to the basic block list of the given function.
Definition Core.cpp:2887
void LLVMDeleteBasicBlock(LLVMBasicBlockRef BBRef)
Remove a basic block from a function and delete it.
Definition Core.cpp:2914
LLVMBasicBlockRef LLVMInsertBasicBlockInContext(LLVMContextRef C, LLVMBasicBlockRef BBRef, const char *Name)
Insert a basic block in a function before another basic block.
Definition Core.cpp:2902
void LLVMGetBasicBlocks(LLVMValueRef FnRef, LLVMBasicBlockRef *BasicBlocksRefs)
Obtain all of the basic blocks in a function.
Definition Core.cpp:2832
void LLVMMoveBasicBlockBefore(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos)
Move a basic block to before another one.
Definition Core.cpp:2922
LLVMValueRef LLVMGetBasicBlockParent(LLVMBasicBlockRef BB)
Obtain the function to which a basic block belongs.
Definition Core.cpp:2820
LLVMBasicBlockRef LLVMGetEntryBasicBlock(LLVMValueRef Fn)
Obtain the basic block that corresponds to the entry point of a function.
Definition Core.cpp:2838
LLVMValueRef LLVMGetFirstInstruction(LLVMBasicBlockRef BB)
Obtain the first instruction in a basic block.
Definition Core.cpp:2936
void LLVMInsertExistingBasicBlockAfterInsertBlock(LLVMBuilderRef Builder, LLVMBasicBlockRef BB)
Insert the given basic block after the insertion point of the given builder.
Definition Core.cpp:2879
LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef BB)
Convert a basic block instance to a value type.
Definition Core.cpp:2804
LLVMBasicBlockRef LLVMValueAsBasicBlock(LLVMValueRef Val)
Convert an LLVMValueRef to an LLVMBasicBlockRef instance.
Definition Core.cpp:2812
void LLVMRemoveBasicBlockFromParent(LLVMBasicBlockRef BBRef)
Remove a basic block from a function.
Definition Core.cpp:2918
LLVMBasicBlockRef LLVMGetNextBasicBlock(LLVMBasicBlockRef BB)
Advance a basic block iterator.
Definition Core.cpp:2858
unsigned LLVMCountBasicBlocks(LLVMValueRef FnRef)
Obtain the number of basic blocks in a function.
Definition Core.cpp:2828
LLVMBasicBlockRef LLVMAppendBasicBlockInContext(LLVMContextRef C, LLVMValueRef FnRef, const char *Name)
Append a basic block to the end of a function.
Definition Core.cpp:2892
LLVMBool LLVMValueIsBasicBlock(LLVMValueRef Val)
Determine whether an LLVMValueRef is itself a basic block.
Definition Core.cpp:2808
LLVMValueRef LLVMConstantPtrAuth(LLVMValueRef Ptr, LLVMValueRef Key, LLVMValueRef Disc, LLVMValueRef AddrDisc)
Create a ConstantPtrAuth constant with the given values.
Definition Core.cpp:1710
LLVMValueRef LLVMGetAggregateElement(LLVMValueRef C, unsigned Idx)
Get element of a constant aggregate (struct, array or vector) at the specified index.
Definition Core.cpp:1639
LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size)
Create a ConstantVector from values.
Definition Core.cpp:1705
LLVMValueRef LLVMConstStringInContext2(LLVMContextRef C, const char *Str, size_t Length, LLVMBool DontNullTerminate)
Create a ConstantDataSequential and initialize it with a string.
Definition Core.cpp:1624
LLVMValueRef LLVMConstDataArray(LLVMTypeRef ElementTy, const char *Data, size_t SizeInBytes)
Create a ConstantDataArray from raw values.
Definition Core.cpp:1675
LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy, LLVMValueRef *ConstantVals, unsigned Length)
Create a ConstantArray from values.
Definition Core.cpp:1663
LLVMBool LLVMIsConstantString(LLVMValueRef C)
Returns true if the specified constant is an array of i8.
Definition Core.cpp:1647
LLVMValueRef LLVMConstStringInContext(LLVMContextRef C, const char *Str, unsigned Length, LLVMBool DontNullTerminate)
Create a ConstantDataSequential and initialize it with a string.
Definition Core.cpp:1615
LLVMValueRef LLVMConstArray2(LLVMTypeRef ElementTy, LLVMValueRef *ConstantVals, uint64_t Length)
Create a ConstantArray from values.
Definition Core.cpp:1669
const char * LLVMGetAsString(LLVMValueRef C, size_t *Length)
Get the given constant data sequential as a string.
Definition Core.cpp:1651
LLVMValueRef LLVMConstNamedStruct(LLVMTypeRef StructTy, LLVMValueRef *ConstantVals, unsigned Count)
Create a non-anonymous ConstantStruct from values.
Definition Core.cpp:1696
const char * LLVMGetRawDataValues(LLVMValueRef C, size_t *SizeInBytes)
Get the raw, underlying bytes of the given constant data sequential.
Definition Core.cpp:1657
LLVMValueRef LLVMConstStructInContext(LLVMContextRef C, LLVMValueRef *ConstantVals, unsigned Count, LLVMBool Packed)
Create an anonymous ConstantStruct with the specified values.
Definition Core.cpp:1682
LLVMValueRef LLVMConstAddrSpaceCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition Core.cpp:1886
LLVMValueRef LLVMSizeOf(LLVMTypeRef Ty)
Definition Core.cpp:1777
LLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition Core.cpp:1798
LLVMValueRef LLVMConstSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition Core.cpp:1815
LLVMValueRef LLVMConstTruncOrBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition Core.cpp:1892
LLVMValueRef LLVMAlignOf(LLVMTypeRef Ty)
Definition Core.cpp:1773
LLVMValueRef LLVMConstBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition Core.cpp:1881
LLVMValueRef LLVMConstNUWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition Core.cpp:1826
LLVMValueRef LLVMConstGEPWithNoWrapFlags(LLVMTypeRef Ty, LLVMValueRef ConstantVal, LLVMValueRef *ConstantIndices, unsigned NumIndices, LLVMGEPNoWrapFlags NoWrapFlags)
Creates a constant GetElementPtr expression.
Definition Core.cpp:1854
LLVMOpcode LLVMGetConstOpcode(LLVMValueRef ConstantVal)
Definition Core.cpp:1769
LLVMValueRef LLVMConstExtractElement(LLVMValueRef VectorConstant, LLVMValueRef IndexConstant)
Definition Core.cpp:1904
LLVMValueRef LLVMConstNSWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition Core.cpp:1803
LLVMValueRef LLVMConstNeg(LLVMValueRef ConstantVal)
Definition Core.cpp:1781
LLVMValueRef LLVMConstPointerCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition Core.cpp:1898
LLVMValueRef LLVMConstInsertElement(LLVMValueRef VectorConstant, LLVMValueRef ElementValueConstant, LLVMValueRef IndexConstant)
Definition Core.cpp:1910
LLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition Core.cpp:1832
LLVMValueRef LLVMConstNSWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition Core.cpp:1820
LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant, LLVMValueRef VectorBConstant, LLVMValueRef MaskConstant)
Definition Core.cpp:1918
LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition Core.cpp:1866
LLVMValueRef LLVMConstGEP2(LLVMTypeRef Ty, LLVMValueRef ConstantVal, LLVMValueRef *ConstantIndices, unsigned NumIndices)
Definition Core.cpp:1837
LLVMValueRef LLVMBlockAddress(LLVMValueRef F, LLVMBasicBlockRef BB)
Definition Core.cpp:1936
LLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal)
Definition Core.cpp:1794
LLVMValueRef LLVMConstNUWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition Core.cpp:1809
LLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition Core.cpp:1871
LLVMValueRef LLVMConstIntToPtr(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition Core.cpp:1876
LLVMValueRef LLVMConstInBoundsGEP2(LLVMTypeRef Ty, LLVMValueRef ConstantVal, LLVMValueRef *ConstantIndices, unsigned NumIndices)
Definition Core.cpp:1845
LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty, const char *AsmString, const char *Constraints, LLVMBool HasSideEffects, LLVMBool IsAlignStack)
Deprecated: Use LLVMGetInlineAsm instead.
Definition Core.cpp:1928
LLVMValueRef LLVMConstNSWNeg(LLVMValueRef ConstantVal)
Definition Core.cpp:1785
LLVMValueRef LLVMGetBlockAddressFunction(LLVMValueRef BlockAddr)
Gets the function associated with a given BlockAddress constant value.
Definition Core.cpp:1940
LLVMBasicBlockRef LLVMGetBlockAddressBasicBlock(LLVMValueRef BlockAddr)
Gets the basic block associated with a given BlockAddress constant value.
Definition Core.cpp:1944
LLVMUnnamedAddr LLVMGetUnnamedAddress(LLVMValueRef Global)
Definition Core.cpp:2082
LLVMTypeRef LLVMGlobalGetValueType(LLVMValueRef Global)
Returns the "value type" of a global value.
Definition Core.cpp:2117
unsigned LLVMGetAlignment(LLVMValueRef V)
Obtain the preferred alignment of the value.
Definition Core.cpp:2123
void LLVMSetSection(LLVMValueRef Global, const char *Section)
Definition Core.cpp:2058
void LLVMSetUnnamedAddress(LLVMValueRef Global, LLVMUnnamedAddr UnnamedAddr)
Definition Core.cpp:2094
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:2198
void LLVMSetLinkage(LLVMValueRef Global, LLVMLinkage Linkage)
Definition Core.cpp:1987
void LLVMSetUnnamedAddr(LLVMValueRef Global, LLVMBool HasUnnamedAddr)
Deprecated: Use LLVMSetUnnamedAddress instead.
Definition Core.cpp:2111
LLVMModuleRef LLVMGetGlobalParent(LLVMValueRef Global)
Definition Core.cpp:1950
unsigned LLVMValueMetadataEntriesGetKind(LLVMValueMetadataEntry *Entries, unsigned Index)
Returns the kind of a value metadata entry at a specific index.
Definition Core.cpp:2179
void LLVMSetDLLStorageClass(LLVMValueRef Global, LLVMDLLStorageClass Class)
Definition Core.cpp:2077
LLVMVisibility LLVMGetVisibility(LLVMValueRef Global)
Definition Core.cpp:2062
LLVMValueMetadataEntry * LLVMGlobalCopyAllMetadata(LLVMValueRef Value, size_t *NumEntries)
Retrieves an array of metadata entries representing the metadata attached to this value.
Definition Core.cpp:2167
void LLVMSetAlignment(LLVMValueRef V, unsigned Bytes)
Set the preferred alignment of the value.
Definition Core.cpp:2145
const char * LLVMGetSection(LLVMValueRef Global)
Definition Core.cpp:2052
void LLVMSetVisibility(LLVMValueRef Global, LLVMVisibility Viz)
Definition Core.cpp:2067
LLVMLinkage LLVMGetLinkage(LLVMValueRef Global)
Definition Core.cpp:1958
void LLVMGlobalEraseMetadata(LLVMValueRef Global, unsigned Kind)
Erases a metadata attachment of the given kind if it exists.
Definition Core.cpp:2208
LLVMDLLStorageClass LLVMGetDLLStorageClass(LLVMValueRef Global)
Definition Core.cpp:2072
LLVMBool LLVMIsDeclaration(LLVMValueRef Global)
Definition Core.cpp:1954
void LLVMGlobalClearMetadata(LLVMValueRef Global)
Removes all metadata attachments from this value.
Definition Core.cpp:2212
void LLVMGlobalAddMetadata(LLVMValueRef Global, unsigned Kind, LLVMMetadataRef MD)
Adds a metadata attachment.
Definition Core.cpp:2203
LLVMBool LLVMHasUnnamedAddr(LLVMValueRef Global)
Deprecated: Use LLVMGetUnnamedAddress instead.
Definition Core.cpp:2107
LLVMMetadataRef LLVMValueMetadataEntriesGetMetadata(LLVMValueMetadataEntry *Entries, unsigned Index)
Returns the underlying metadata node of a value metadata entry at a specific index.
Definition Core.cpp:2187
void LLVMDisposeValueMetadataEntries(LLVMValueMetadataEntry *Entries)
Destroys value metadata entries.
Definition Core.cpp:2194
void LLVMGlobalAddDebugInfo(LLVMValueRef Global, LLVMMetadataRef GVE)
Add debuginfo metadata to this global.
Definition Core.cpp:2216
LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N, LLVMBool SignExtend)
Obtain a constant value for an integer type.
Definition Core.cpp:1542
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:1580
LLVMValueRef LLVMConstIntOfArbitraryPrecision(LLVMTypeRef IntTy, unsigned NumWords, const uint64_t Words[])
Obtain a constant value for an integer of arbitrary precision.
Definition Core.cpp:1547
long long LLVMConstIntGetSExtValue(LLVMValueRef ConstantVal)
Obtain the sign extended value for an integer constant value.
Definition Core.cpp:1592
LLVMValueRef LLVMConstRealOfString(LLVMTypeRef RealTy, const char *Text)
Obtain a constant for a floating point value parsed from a string.
Definition Core.cpp:1571
double LLVMConstRealGetDouble(LLVMValueRef ConstantVal, LLVMBool *LosesInfo)
Obtain the double value for an floating point constant value.
Definition Core.cpp:1596
LLVMValueRef LLVMConstReal(LLVMTypeRef RealTy, double N)
Obtain a constant value referring to a double floating point value.
Definition Core.cpp:1567
unsigned long long LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal)
Obtain the zero extended value for an integer constant value.
Definition Core.cpp:1588
LLVMValueRef LLVMGetPoison(LLVMTypeRef Ty)
Obtain a constant value referring to a poison value of a type.
Definition Core.cpp:1257
LLVMValueRef LLVMConstPointerNull(LLVMTypeRef Ty)
Obtain a constant that is a constant pointer pointing to NULL for a specified type.
Definition Core.cpp:1279
LLVMValueRef LLVMGetUndef(LLVMTypeRef Ty)
Obtain a constant value referring to an undefined value of a type.
Definition Core.cpp:1253
LLVMBool LLVMIsNull(LLVMValueRef Val)
Determine whether a value instance is null.
Definition Core.cpp:1265
LLVMValueRef LLVMConstNull(LLVMTypeRef Ty)
Obtain a constant value referring to the null instance of a type.
Definition Core.cpp:1245
LLVMValueRef LLVMConstAllOnes(LLVMTypeRef Ty)
Obtain a constant value referring to the instance of a type consisting of all ones.
Definition Core.cpp:1249
LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg)
Obtain the previous parameter to a function.
Definition Core.cpp:2697
void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align)
Set the alignment for a function parameter.
Definition Core.cpp:2704
unsigned LLVMCountParams(LLVMValueRef FnRef)
Obtain the number of parameters in a function.
Definition Core.cpp:2652
void LLVMGetParams(LLVMValueRef FnRef, LLVMValueRef *ParamRefs)
Obtain the parameters in a function.
Definition Core.cpp:2658
LLVMValueRef LLVMGetFirstParam(LLVMValueRef Fn)
Obtain the first parameter to a function.
Definition Core.cpp:2673
LLVMValueRef LLVMGetLastParam(LLVMValueRef Fn)
Obtain the last parameter to a function.
Definition Core.cpp:2681
LLVMValueRef LLVMGetParam(LLVMValueRef FnRef, unsigned index)
Obtain the parameter at the specified index.
Definition Core.cpp:2664
LLVMValueRef LLVMGetNextParam(LLVMValueRef Arg)
Obtain the next parameter to a function.
Definition Core.cpp:2689
LLVMValueRef LLVMGetParamParent(LLVMValueRef V)
Obtain the function to which this argument belongs.
Definition Core.cpp:2669
void LLVMAddAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx, LLVMAttributeRef A)
Add an attribute to a function.
Definition Core.cpp:2602
LLVMValueRef LLVMGetPrefixData(LLVMValueRef Fn)
Gets the prefix data associated with a function.
Definition Core.cpp:2570
LLVMValueRef LLVMGetPrologueData(LLVMValueRef Fn)
Gets the prologue data associated with a function.
Definition Core.cpp:2586
LLVMTypeRef LLVMIntrinsicGetType(LLVMContextRef Ctx, unsigned ID, LLVMTypeRef *ParamTypes, size_t ParamCount)
Retrieves the type of an intrinsic.
Definition Core.cpp:2513
unsigned LLVMGetIntrinsicID(LLVMValueRef Fn)
Obtain the ID number from a function instance.
Definition Core.cpp:2486
LLVMValueRef LLVMGetPersonalityFn(LLVMValueRef Fn)
Obtain the personality function attached to the function.
Definition Core.cpp:2477
unsigned LLVMGetAttributeCountAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx)
Definition Core.cpp:2607
LLVMBool LLVMHasPersonalityFn(LLVMValueRef Fn)
Check whether the given function has a personality function.
Definition Core.cpp:2473
void LLVMRemoveStringAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx, const char *K, unsigned KLen)
Definition Core.cpp:2638
void LLVMSetPrefixData(LLVMValueRef Fn, LLVMValueRef prefixData)
Sets the prefix data for the function.
Definition Core.cpp:2580
char * LLVMIntrinsicCopyOverloadedName(unsigned ID, LLVMTypeRef *ParamTypes, size_t ParamCount, size_t *NameLength)
Deprecated: Use LLVMIntrinsicCopyOverloadedName2 instead.
Definition Core.cpp:2520
const char * LLVMGetGC(LLVMValueRef Fn)
Obtain the name of the garbage collector to use during code generation.
Definition Core.cpp:2557
void LLVMSetGC(LLVMValueRef Fn, const char *GC)
Define the garbage collector to use during code generation.
Definition Core.cpp:2562
void LLVMSetPrologueData(LLVMValueRef Fn, LLVMValueRef prologueData)
Sets the prologue data for the function.
Definition Core.cpp:2596
void LLVMSetPersonalityFn(LLVMValueRef Fn, LLVMValueRef PersonalityFn)
Set the personality function attached to the function.
Definition Core.cpp:2481
void LLVMGetAttributesAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx, LLVMAttributeRef *Attrs)
Definition Core.cpp:2612
unsigned LLVMGetFunctionCallConv(LLVMValueRef Fn)
Obtain the calling function of a function.
Definition Core.cpp:2548
LLVMBool LLVMIntrinsicIsOverloaded(unsigned ID)
Obtain if the intrinsic identified by the given ID is overloaded.
Definition Core.cpp:2543
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:2529
void LLVMDeleteFunction(LLVMValueRef Fn)
Remove a function from its containing module and deletes it.
Definition Core.cpp:2469
void LLVMRemoveEnumAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx, unsigned KindID)
Definition Core.cpp:2633
LLVMAttributeRef LLVMGetEnumAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx, unsigned KindID)
Definition Core.cpp:2619
unsigned LLVMLookupIntrinsicID(const char *Name, size_t NameLen)
Obtain the intrinsic ID number which matches the given function name.
Definition Core.cpp:2539
const char * LLVMIntrinsicGetName(unsigned ID, size_t *NameLength)
Retrieves the name of an intrinsic.
Definition Core.cpp:2506
LLVMValueRef LLVMGetIntrinsicDeclaration(LLVMModuleRef Mod, unsigned ID, LLVMTypeRef *ParamTypes, size_t ParamCount)
Get or insert the declaration of an intrinsic.
Definition Core.cpp:2497
LLVMBool LLVMHasPrologueData(LLVMValueRef Fn)
Check if a given function has prologue data.
Definition Core.cpp:2591
LLVMBool LLVMHasPrefixData(LLVMValueRef Fn)
Check if a given function has prefix data.
Definition Core.cpp:2575
void LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC)
Set the calling convention of a function.
Definition Core.cpp:2552
void LLVMAddTargetDependentFunctionAttr(LLVMValueRef Fn, const char *A, const char *V)
Add a target-dependent attribute to a function.
Definition Core.cpp:2643
LLVMAttributeRef LLVMGetStringAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx, const char *K, unsigned KLen)
Definition Core.cpp:2626
LLVMValueRef LLVMIsAMDString(LLVMValueRef Val)
Definition Core.cpp:1169
LLVMBool LLVMIsPoison(LLVMValueRef Val)
Determine whether a value instance is poisonous.
Definition Core.cpp:1275
LLVMValueKind LLVMGetValueKind(LLVMValueRef Val)
Obtain the enumerated type of a Value instance.
Definition Core.cpp:1010
void LLVMDumpValue(LLVMValueRef Val)
Dump a representation of a value to stderr.
Definition Core.cpp:1040
const char * LLVMGetValueName(LLVMValueRef Val)
Deprecated: Use LLVMGetValueName2 instead.
Definition Core.cpp:1032
LLVMContextRef LLVMGetValueContext(LLVMValueRef Val)
Obtain the context to which this value is associated.
Definition Core.cpp:1058
void LLVMReplaceAllUsesWith(LLVMValueRef OldVal, LLVMValueRef NewVal)
Replace all uses of a value with another one.
Definition Core.cpp:1076
const char * LLVMGetValueName2(LLVMValueRef Val, size_t *Length)
Obtain the string name of a value.
Definition Core.cpp:1022
void LLVMSetValueName(LLVMValueRef Val, const char *Name)
Deprecated: Use LLVMSetValueName2 instead.
Definition Core.cpp:1036
LLVM_C_ABI LLVMValueRef LLVMIsAMDNode(LLVMValueRef Val)
Definition Core.cpp:1154
char * LLVMPrintDbgRecordToString(LLVMDbgRecordRef Record)
Return a string representation of the DbgRecord.
Definition Core.cpp:1062
LLVMBool LLVMIsUndef(LLVMValueRef Val)
Determine whether a value instance is undefined.
Definition Core.cpp:1271
LLVMTypeRef LLVMTypeOf(LLVMValueRef Val)
Obtain the type of a value.
Definition Core.cpp:1006
char * LLVMPrintValueToString(LLVMValueRef Val)
Return a string representation of the value.
Definition Core.cpp:1044
LLVMValueRef LLVMIsAValueAsMetadata(LLVMValueRef Val)
Definition Core.cpp:1162
LLVMBool LLVMIsConstant(LLVMValueRef Ty)
Determine whether the specified value instance is constant.
Definition Core.cpp:1261
void LLVMSetValueName2(LLVMValueRef Val, const char *Name, size_t NameLen)
Set the string name of a value.
Definition Core.cpp:1028
LLVMValueRef LLVMGetFirstGlobalIFunc(LLVMModuleRef M)
Obtain an iterator to the first GlobalIFunc in a Module.
Definition Core.cpp:2726
LLVMValueRef LLVMGetNamedGlobalIFunc(LLVMModuleRef M, const char *Name, size_t NameLen)
Obtain a GlobalIFunc value from a Module by its name.
Definition Core.cpp:2721
void LLVMRemoveGlobalIFunc(LLVMValueRef IFunc)
Remove a global indirect function from its parent module.
Definition Core.cpp:2770
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:2711
LLVMValueRef LLVMGetNextGlobalIFunc(LLVMValueRef IFunc)
Advance a GlobalIFunc iterator to the next GlobalIFunc.
Definition Core.cpp:2742
LLVMValueRef LLVMGetPreviousGlobalIFunc(LLVMValueRef IFunc)
Decrement a GlobalIFunc iterator to the previous GlobalIFunc.
Definition Core.cpp:2750
LLVMValueRef LLVMGetGlobalIFuncResolver(LLVMValueRef IFunc)
Retrieves the resolver function associated with this indirect function, or NULL if it doesn't not exi...
Definition Core.cpp:2758
void LLVMSetGlobalIFuncResolver(LLVMValueRef IFunc, LLVMValueRef Resolver)
Sets the resolver function associated with this indirect function.
Definition Core.cpp:2762
LLVMValueRef LLVMGetLastGlobalIFunc(LLVMModuleRef M)
Obtain an iterator to the last GlobalIFunc in a Module.
Definition Core.cpp:2734
void LLVMEraseGlobalIFunc(LLVMValueRef IFunc)
Remove a global indirect function from its parent module and delete it.
Definition Core.cpp:2766
LLVMTypeRef LLVMGetAllocatedType(LLVMValueRef Alloca)
Obtain the type that is being allocated by the alloca instruction.
Definition Core.cpp:3266
void LLVMSetTailCall(LLVMValueRef Call, LLVMBool isTailCall)
Set whether a call instruction is a tail call.
Definition Core.cpp:3178
void LLVMAddCallSiteAttribute(LLVMValueRef C, LLVMAttributeIndex Idx, LLVMAttributeRef A)
Definition Core.cpp:3110
unsigned LLVMGetNumOperandBundles(LLVMValueRef C)
Obtain the number of operand bundles attached to this instruction.
Definition Core.cpp:3162
void LLVMRemoveCallSiteEnumAttribute(LLVMValueRef C, LLVMAttributeIndex Idx, unsigned KindID)
Definition Core.cpp:3144
void LLVMRemoveCallSiteStringAttribute(LLVMValueRef C, LLVMAttributeIndex Idx, const char *K, unsigned KLen)
Definition Core.cpp:3149
LLVMAttributeRef LLVMGetCallSiteEnumAttribute(LLVMValueRef C, LLVMAttributeIndex Idx, unsigned KindID)
Definition Core.cpp:3130
unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr)
Obtain the calling convention for a call instruction.
Definition Core.cpp:3093
LLVMBasicBlockRef LLVMGetCallBrDefaultDest(LLVMValueRef CallBr)
Get the default destination of a CallBr instruction.
Definition Core.cpp:3218
LLVMValueRef LLVMGetCalledValue(LLVMValueRef Instr)
Obtain the pointer to the function invoked by this instruction.
Definition Core.cpp:3154
void LLVMSetNormalDest(LLVMValueRef Invoke, LLVMBasicBlockRef B)
Set the normal destination basic block.
Definition Core.cpp:3205
LLVMBool LLVMIsTailCall(LLVMValueRef Call)
Obtain whether a call instruction is a tail call.
Definition Core.cpp:3174
LLVMAttributeRef LLVMGetCallSiteStringAttribute(LLVMValueRef C, LLVMAttributeIndex Idx, const char *K, unsigned KLen)
Definition Core.cpp:3137
unsigned LLVMGetCallBrNumIndirectDests(LLVMValueRef CallBr)
Get the number of indirect destinations of a CallBr instruction.
Definition Core.cpp:3222
void LLVMGetCallSiteAttributes(LLVMValueRef C, LLVMAttributeIndex Idx, LLVMAttributeRef *Attrs)
Definition Core.cpp:3122
LLVMBasicBlockRef LLVMGetNormalDest(LLVMValueRef Invoke)
Return the normal destination basic block.
Definition Core.cpp:3192
unsigned LLVMGetNumArgOperands(LLVMValueRef Instr)
Obtain the argument count for a call instruction.
Definition Core.cpp:3084
void LLVMSetTailCallKind(LLVMValueRef Call, LLVMTailCallKind kind)
Set the call kind of the call instruction.
Definition Core.cpp:3186
LLVMOperandBundleRef LLVMGetOperandBundleAtIndex(LLVMValueRef C, unsigned Index)
Obtain the operand bundle attached to this instruction at the given index.
Definition Core.cpp:3166
LLVMBasicBlockRef LLVMGetCallBrIndirectDest(LLVMValueRef CallBr, unsigned Idx)
Get the indirect destination of a CallBr instruction at the given index.
Definition Core.cpp:3226
LLVMTailCallKind LLVMGetTailCallKind(LLVMValueRef Call)
Obtain a tail call kind of the call instruction.
Definition Core.cpp:3182
void LLVMSetUnwindDest(LLVMValueRef Invoke, LLVMBasicBlockRef B)
Set the unwind destination basic block.
Definition Core.cpp:3209
LLVMTypeRef LLVMGetCalledFunctionType(LLVMValueRef Instr)
Obtain the function type called by this instruction.
Definition Core.cpp:3158
LLVMBasicBlockRef LLVMGetUnwindDest(LLVMValueRef Invoke)
Return the unwind destination basic block.
Definition Core.cpp:3196
void LLVMSetInstrParamAlignment(LLVMValueRef Instr, LLVMAttributeIndex Idx, unsigned align)
Definition Core.cpp:3102
unsigned LLVMGetCallSiteAttributeCount(LLVMValueRef C, LLVMAttributeIndex Idx)
Definition Core.cpp:3115
void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC)
Set the calling convention for a call instruction.
Definition Core.cpp:3097
LLVMGEPNoWrapFlags LLVMGEPGetNoWrapFlags(LLVMValueRef GEP)
Get the no-wrap related flags for the given GEP instruction.
Definition Core.cpp:3284
LLVMBool LLVMIsInBounds(LLVMValueRef GEP)
Check whether the given GEP operator is inbounds.
Definition Core.cpp:3272
void LLVMSetIsInBounds(LLVMValueRef GEP, LLVMBool InBounds)
Set the given GEP instruction to be inbounds or not.
Definition Core.cpp:3276
LLVMTypeRef LLVMGetGEPSourceElementType(LLVMValueRef GEP)
Get the source element type of the given GEP operator.
Definition Core.cpp:3280
void LLVMGEPSetNoWrapFlags(LLVMValueRef GEP, LLVMGEPNoWrapFlags NoWrapFlags)
Set the no-wrap related flags for the given GEP instruction.
Definition Core.cpp:3289
unsigned LLVMGetNumIndices(LLVMValueRef Inst)
Obtain the number of indices.
Definition Core.cpp:3317
const unsigned * LLVMGetIndices(LLVMValueRef Inst)
Obtain the indices as an array.
Definition Core.cpp:3329
LLVMBasicBlockRef LLVMGetIncomingBlock(LLVMValueRef PhiNode, unsigned Index)
Obtain an incoming value to a PHI node as an LLVMBasicBlockRef.
Definition Core.cpp:3311
LLVMValueRef LLVMGetIncomingValue(LLVMValueRef PhiNode, unsigned Index)
Obtain an incoming value to a PHI node as an LLVMValueRef.
Definition Core.cpp:3307
void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues, LLVMBasicBlockRef *IncomingBlocks, unsigned Count)
Add an incoming value to the end of a PHI list.
Definition Core.cpp:3296
unsigned LLVMCountIncoming(LLVMValueRef PhiNode)
Obtain the number of incoming basic blocks to a PHI node.
Definition Core.cpp:3303
LLVMValueRef LLVMGetCondition(LLVMValueRef Branch)
Return the condition of a branch instruction.
Definition Core.cpp:3250
LLVMBasicBlockRef LLVMGetSuccessor(LLVMValueRef Term, unsigned i)
Return the specified successor.
Definition Core.cpp:3236
void LLVMSetCondition(LLVMValueRef Branch, LLVMValueRef Cond)
Set the condition of a branch instruction.
Definition Core.cpp:3254
void LLVMSetSuccessor(LLVMValueRef Term, unsigned i, LLVMBasicBlockRef block)
Update the specified successor to point at the provided block.
Definition Core.cpp:3240
LLVMBool LLVMIsConditional(LLVMValueRef Branch)
Return if a branch is conditional.
Definition Core.cpp:3246
LLVMBasicBlockRef LLVMGetSwitchDefaultDest(LLVMValueRef Switch)
Obtain the default destination basic block of a switch instruction.
Definition Core.cpp:3260
unsigned LLVMGetNumSuccessors(LLVMValueRef Term)
Return the number of successors that this terminator has.
Definition Core.cpp:3232
LLVMRealPredicate LLVMGetFCmpPredicate(LLVMValueRef Inst)
Obtain the float predicate of an instruction.
Definition Core.cpp:2994
int LLVMHasMetadata(LLVMValueRef Inst)
Determine whether an instruction has any metadata attached.
Definition Core.cpp:1080
void LLVMInstructionRemoveFromParent(LLVMValueRef Inst)
Remove an instruction.
Definition Core.cpp:2968
LLVMValueRef LLVMGetPreviousInstruction(LLVMValueRef Inst)
Obtain the instruction that occurred before this one.
Definition Core.cpp:2960
LLVMDbgRecordRef LLVMGetPreviousDbgRecord(LLVMDbgRecordRef Rec)
Obtain the previous DbgRecord in the sequence or NULL if there are no more.
Definition Core.cpp:3045
LLVMDbgRecordRef LLVMGetFirstDbgRecord(LLVMValueRef Inst)
Obtain the first debug record attached to an instruction.
Definition Core.cpp:3017
LLVMOpcode LLVMGetInstructionOpcode(LLVMValueRef Inst)
Obtain the code opcode for an individual instruction.
Definition Core.cpp:3000
LLVMDbgRecordRef LLVMGetNextDbgRecord(LLVMDbgRecordRef Rec)
Obtain the next DbgRecord in the sequence or NULL if there are no more.
Definition Core.cpp:3037
LLVMDbgRecordRef LLVMGetLastDbgRecord(LLVMValueRef Inst)
Obtain the last debug record attached to an instruction.
Definition Core.cpp:3027
LLVMValueRef LLVMIsATerminatorInst(LLVMValueRef Inst)
Determine whether an instruction is a terminator.
Definition Core.cpp:3012
LLVMMetadataRef LLVMDbgVariableRecordGetExpression(LLVMDbgRecordRef Rec)
Get the debug info expression of the DbgVariableRecord.
Definition Core.cpp:3080
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:1137
void LLVMDeleteInstruction(LLVMValueRef Inst)
Delete an instruction.
Definition Core.cpp:2976
LLVMMetadataRef LLVMDbgRecordGetDebugLoc(LLVMDbgRecordRef Rec)
Get the debug location attached to the debug record.
Definition Core.cpp:3053
LLVMBasicBlockRef LLVMGetInstructionParent(LLVMValueRef Inst)
Obtain the basic block to which an instruction belongs.
Definition Core.cpp:2932
LLVMValueRef LLVMDbgVariableRecordGetValue(LLVMDbgRecordRef Rec, unsigned OpIdx)
Get the value of the DbgVariableRecord.
Definition Core.cpp:3071
LLVMBool LLVMGetICmpSameSign(LLVMValueRef Inst)
Get whether or not an icmp instruction has the samesign flag.
Definition Core.cpp:2986
LLVMValueRef LLVMInstructionClone(LLVMValueRef Inst)
Create a copy of 'this' instruction that is identical in all ways except the following:
Definition Core.cpp:3006
void LLVMInstructionEraseFromParent(LLVMValueRef Inst)
Remove and delete an instruction.
Definition Core.cpp:2972
void LLVMSetMetadata(LLVMValueRef Inst, unsigned KindID, LLVMValueRef Val)
Set metadata associated with an instruction value.
Definition Core.cpp:1106
LLVMValueRef LLVMGetMetadata(LLVMValueRef Inst, unsigned KindID)
Return metadata associated with an instruction value.
Definition Core.cpp:1084
LLVMIntPredicate LLVMGetICmpPredicate(LLVMValueRef Inst)
Obtain the predicate of an instruction.
Definition Core.cpp:2980
LLVMValueRef LLVMGetNextInstruction(LLVMValueRef Inst)
Obtain the instruction that occurs after the one specified.
Definition Core.cpp:2952
LLVMMetadataRef LLVMDbgVariableRecordGetVariable(LLVMDbgRecordRef Rec)
Get the debug info variable of the DbgVariableRecord.
Definition Core.cpp:3076
LLVMDbgRecordKind LLVMDbgRecordGetKind(LLVMDbgRecordRef Rec)
Definition Core.cpp:3057
void LLVMSetICmpSameSign(LLVMValueRef Inst, LLVMBool SameSign)
Set the samesign flag on an icmp instruction.
Definition Core.cpp:2990
LLVMMetadataRef LLVMMDNodeInContext2(LLVMContextRef C, LLVMMetadataRef *MDs, size_t Count)
Create an MDNode value with the given array of operands.
Definition Core.cpp:1290
const char * LLVMGetMDString(LLVMValueRef V, unsigned *Length)
Obtain the underlying string from a MDString value.
Definition Core.cpp:1350
LLVMValueRef LLVMMetadataAsValue(LLVMContextRef C, LLVMMetadataRef MD)
Obtain a Metadata as a Value.
Definition Core.cpp:1337
unsigned LLVMGetMDNodeNumOperands(LLVMValueRef V)
Obtain the number of operands from an MDNode value.
Definition Core.cpp:1360
LLVMValueRef LLVMMDStringInContext(LLVMContextRef C, const char *Str, unsigned SLen)
Deprecated: Use LLVMMDStringInContext2 instead.
Definition Core.cpp:1295
LLVMMetadataRef LLVMMDStringInContext2(LLVMContextRef C, const char *Str, size_t SLen)
Create an MDString value from a given string value.
Definition Core.cpp:1285
LLVMValueRef LLVMMDNodeInContext(LLVMContextRef C, LLVMValueRef *Vals, unsigned Count)
Deprecated: Use LLVMMDNodeInContext2 instead.
Definition Core.cpp:1306
void LLVMReplaceMDNodeOperandWith(LLVMValueRef V, unsigned Index, LLVMMetadataRef Replacement)
Replace an operand at a specific index in a llvm::MDNode value.
Definition Core.cpp:1428
LLVMMetadataRef LLVMValueAsMetadata(LLVMValueRef Val)
Obtain a Value as a Metadata.
Definition Core.cpp:1341
void LLVMGetMDNodeOperands(LLVMValueRef V, LLVMValueRef *Dest)
Obtain the given MDNode's operands.
Definition Core.cpp:1415
LLVMUseRef LLVMGetOperandUse(LLVMValueRef Val, unsigned Index)
Obtain the use of an operand at a specific index in a llvm::User value.
Definition Core.cpp:1226
int LLVMGetNumOperands(LLVMValueRef Val)
Obtain the number of operands in a llvm::User value.
Definition Core.cpp:1235
void LLVMSetOperand(LLVMValueRef Val, unsigned Index, LLVMValueRef Op)
Set an operand at a specific index in a llvm::User value.
Definition Core.cpp:1231
LLVMValueRef LLVMGetOperand(LLVMValueRef Val, unsigned Index)
Obtain an operand at a specific index in a llvm::User value.
Definition Core.cpp:1212
LLVMValueRef LLVMGetUser(LLVMUseRef U)
Obtain the user value for a user.
Definition Core.cpp:1192
LLVMValueRef LLVMGetUsedValue(LLVMUseRef U)
Obtain the value this use corresponds to.
Definition Core.cpp:1196
LLVMUseRef LLVMGetNextUse(LLVMUseRef U)
Obtain the next use of a value.
Definition Core.cpp:1185
LLVMUseRef LLVMGetFirstUse(LLVMValueRef Val)
Obtain the first use of a value.
Definition Core.cpp:1177
#define LLVM_FOR_EACH_VALUE_SUBCLASS(macro)
Definition Core.h:1966
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:2359
LLVMValueRef LLVMGetLastGlobalAlias(LLVMModuleRef M)
Obtain an iterator to the last GlobalAlias in a Module.
Definition Core.cpp:2380
LLVMValueRef LLVMGetPreviousGlobalAlias(LLVMValueRef GA)
Decrement a GlobalAlias iterator to the previous GlobalAlias.
Definition Core.cpp:2396
void LLVMAliasSetAliasee(LLVMValueRef Alias, LLVMValueRef Aliasee)
Set the target value of an alias.
Definition Core.cpp:2408
LLVMValueRef LLVMGetFirstGlobalAlias(LLVMModuleRef M)
Obtain an iterator to the first GlobalAlias in a Module.
Definition Core.cpp:2372
LLVMValueRef LLVMAliasGetAliasee(LLVMValueRef Alias)
Retrieve the target value of an alias.
Definition Core.cpp:2404
LLVMValueRef LLVMGetNamedGlobalAlias(LLVMModuleRef M, const char *Name, size_t NameLen)
Obtain a GlobalAlias value from a Module by its name.
Definition Core.cpp:2367
LLVMValueRef LLVMGetNextGlobalAlias(LLVMValueRef GA)
Advance a GlobalAlias iterator to the next GlobalAlias.
Definition Core.cpp:2388
LLVMBool LLVMIsThreadLocal(LLVMValueRef GlobalVar)
Definition Core.cpp:2294
LLVMThreadLocalMode LLVMGetThreadLocalMode(LLVMValueRef GlobalVar)
Definition Core.cpp:2310
LLVMBool LLVMIsGlobalConstant(LLVMValueRef GlobalVar)
Definition Core.cpp:2302
LLVMValueRef LLVMGetPreviousGlobal(LLVMValueRef GlobalVar)
Definition Core.cpp:2270
void LLVMSetThreadLocal(LLVMValueRef GlobalVar, LLVMBool IsThreadLocal)
Definition Core.cpp:2298
LLVMBool LLVMIsExternallyInitialized(LLVMValueRef GlobalVar)
Definition Core.cpp:2349
LLVMValueRef LLVMGetLastGlobal(LLVMModuleRef M)
Definition Core.cpp:2254
LLVMValueRef LLVMGetNamedGlobalWithLength(LLVMModuleRef M, const char *Name, size_t Length)
Definition Core.cpp:2241
LLVMValueRef LLVMGetFirstGlobal(LLVMModuleRef M)
Definition Core.cpp:2246
void LLVMSetThreadLocalMode(LLVMValueRef GlobalVar, LLVMThreadLocalMode Mode)
Definition Core.cpp:2327
LLVMValueRef LLVMGetNextGlobal(LLVMValueRef GlobalVar)
Definition Core.cpp:2262
void LLVMSetExternallyInitialized(LLVMValueRef GlobalVar, LLVMBool IsExtInit)
Definition Core.cpp:2353
LLVMValueRef LLVMGetNamedGlobal(LLVMModuleRef M, const char *Name)
Definition Core.cpp:2237
LLVMValueRef LLVMAddGlobalInAddressSpace(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name, unsigned AddressSpace)
Definition Core.cpp:2228
void LLVMDeleteGlobal(LLVMValueRef GlobalVar)
Definition Core.cpp:2278
void LLVMSetGlobalConstant(LLVMValueRef GlobalVar, LLVMBool IsConstant)
Definition Core.cpp:2306
LLVMValueRef LLVMAddGlobal(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name)
Definition Core.cpp:2223
LLVMValueRef LLVMGetInitializer(LLVMValueRef GlobalVar)
Definition Core.cpp:2282
void LLVMSetInitializer(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal)
Definition Core.cpp:2289
#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.
@ 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:351
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:346
LLVM_ABI void initializeSafepointIRVerifierPass(PassRegistry &)
#define N
LLVMModuleFlagBehavior Behavior
Definition Core.cpp:337
LLVMMetadataRef Metadata
Definition Core.cpp:340
LLVMMetadataRef Metadata
Definition Core.cpp:1114
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition Alignment.h:39
void(*)(const DiagnosticInfo *DI, void *Context) DiagnosticHandlerTy
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
Definition Alignment.h:106