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