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
407/*--.. Printing modules ....................................................--*/
408
410 unwrap(M)->print(errs(), nullptr,
411 /*ShouldPreserveUseListOrder=*/false, /*IsForDebug=*/true);
412}
413
415 char **ErrorMessage) {
416 std::error_code EC;
417 raw_fd_ostream dest(Filename, EC, sys::fs::OF_TextWithCRLF);
418 if (EC) {
419 *ErrorMessage = strdup(EC.message().c_str());
420 return true;
421 }
422
423 unwrap(M)->print(dest, nullptr);
424
425 dest.close();
426
427 if (dest.has_error()) {
428 std::string E = "Error printing to file: " + dest.error().message();
429 *ErrorMessage = strdup(E.c_str());
430 return true;
431 }
432
433 return false;
434}
435
437 std::string buf;
438 raw_string_ostream os(buf);
439
440 unwrap(M)->print(os, nullptr);
441 os.flush();
442
443 return strdup(buf.c_str());
444}
445
446/*--.. Operations on inline assembler ......................................--*/
447void LLVMSetModuleInlineAsm2(LLVMModuleRef M, const char *Asm, size_t Len) {
448 unwrap(M)->setModuleInlineAsm(StringRef(Asm, Len));
449}
450
451void LLVMSetModuleInlineAsm(LLVMModuleRef M, const char *Asm) {
452 unwrap(M)->setModuleInlineAsm(StringRef(Asm));
453}
454
455void LLVMAppendModuleInlineAsm(LLVMModuleRef M, const char *Asm, size_t Len) {
456 unwrap(M)->appendModuleInlineAsm(StringRef(Asm, Len));
457}
458
459const char *LLVMGetModuleInlineAsm(LLVMModuleRef M, size_t *Len) {
460 auto &Str = unwrap(M)->getModuleInlineAsm();
461 *Len = Str.length();
462 return Str.c_str();
463}
464
465LLVMValueRef LLVMGetInlineAsm(LLVMTypeRef Ty, const char *AsmString,
466 size_t AsmStringSize, const char *Constraints,
467 size_t ConstraintsSize, LLVMBool HasSideEffects,
468 LLVMBool IsAlignStack,
469 LLVMInlineAsmDialect Dialect, LLVMBool CanThrow) {
471 switch (Dialect) {
474 break;
477 break;
478 }
479 return wrap(InlineAsm::get(unwrap<FunctionType>(Ty),
480 StringRef(AsmString, AsmStringSize),
481 StringRef(Constraints, ConstraintsSize),
482 HasSideEffects, IsAlignStack, AD, CanThrow));
483}
484
485const char *LLVMGetInlineAsmAsmString(LLVMValueRef InlineAsmVal, size_t *Len) {
486
487 Value *Val = unwrap<Value>(InlineAsmVal);
488 const std::string &AsmString = cast<InlineAsm>(Val)->getAsmString();
489
490 *Len = AsmString.length();
491 return AsmString.c_str();
492}
493
495 size_t *Len) {
496 Value *Val = unwrap<Value>(InlineAsmVal);
497 const std::string &ConstraintString =
498 cast<InlineAsm>(Val)->getConstraintString();
499
500 *Len = ConstraintString.length();
501 return ConstraintString.c_str();
502}
503
505
506 Value *Val = unwrap<Value>(InlineAsmVal);
507 InlineAsm::AsmDialect Dialect = cast<InlineAsm>(Val)->getDialect();
508
509 switch (Dialect) {
514 }
515
516 llvm_unreachable("Unrecognized inline assembly dialect");
518}
519
521 Value *Val = unwrap<Value>(InlineAsmVal);
522 return (LLVMTypeRef)cast<InlineAsm>(Val)->getFunctionType();
523}
524
526 Value *Val = unwrap<Value>(InlineAsmVal);
527 return cast<InlineAsm>(Val)->hasSideEffects();
528}
529
531 Value *Val = unwrap<Value>(InlineAsmVal);
532 return cast<InlineAsm>(Val)->isAlignStack();
533}
534
536 Value *Val = unwrap<Value>(InlineAsmVal);
537 return cast<InlineAsm>(Val)->canThrow();
538}
539
540/*--.. Operations on module contexts ......................................--*/
542 return wrap(&unwrap(M)->getContext());
543}
544
545
546/*===-- Operations on types -----------------------------------------------===*/
547
548/*--.. Operations on all types (mostly) ....................................--*/
549
551 switch (unwrap(Ty)->getTypeID()) {
552 case Type::VoidTyID:
553 return LLVMVoidTypeKind;
554 case Type::HalfTyID:
555 return LLVMHalfTypeKind;
556 case Type::BFloatTyID:
557 return LLVMBFloatTypeKind;
558 case Type::FloatTyID:
559 return LLVMFloatTypeKind;
560 case Type::DoubleTyID:
561 return LLVMDoubleTypeKind;
564 case Type::FP128TyID:
565 return LLVMFP128TypeKind;
568 case Type::LabelTyID:
569 return LLVMLabelTypeKind;
573 return LLVMIntegerTypeKind;
576 case Type::StructTyID:
577 return LLVMStructTypeKind;
578 case Type::ArrayTyID:
579 return LLVMArrayTypeKind;
581 return LLVMPointerTypeKind;
583 return LLVMVectorTypeKind;
585 return LLVMX86_MMXTypeKind;
587 return LLVMX86_AMXTypeKind;
588 case Type::TokenTyID:
589 return LLVMTokenTypeKind;
595 llvm_unreachable("Typed pointers are unsupported via the C API");
596 }
597 llvm_unreachable("Unhandled TypeID.");
598}
599
601{
602 return unwrap(Ty)->isSized();
603}
604
606 return wrap(&unwrap(Ty)->getContext());
607}
608
610 return unwrap(Ty)->print(errs(), /*IsForDebug=*/true);
611}
612
614 std::string buf;
615 raw_string_ostream os(buf);
616
617 if (unwrap(Ty))
618 unwrap(Ty)->print(os);
619 else
620 os << "Printing <null> Type";
621
622 os.flush();
623
624 return strdup(buf.c_str());
625}
626
627/*--.. Operations on integer types .........................................--*/
628
631}
634}
637}
640}
643}
646}
648 return wrap(IntegerType::get(*unwrap(C), NumBits));
649}
650
653}
656}
659}
662}
665}
668}
669LLVMTypeRef LLVMIntType(unsigned NumBits) {
671}
672
673unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy) {
674 return unwrap<IntegerType>(IntegerTy)->getBitWidth();
675}
676
677/*--.. Operations on real types ............................................--*/
678
681}
684}
687}
690}
693}
696}
699}
702}
705}
706
709}
712}
715}
718}
721}
724}
727}
730}
733}
734
735/*--.. Operations on function types ........................................--*/
736
738 LLVMTypeRef *ParamTypes, unsigned ParamCount,
739 LLVMBool IsVarArg) {
740 ArrayRef<Type*> Tys(unwrap(ParamTypes), ParamCount);
741 return wrap(FunctionType::get(unwrap(ReturnType), Tys, IsVarArg != 0));
742}
743
745 return unwrap<FunctionType>(FunctionTy)->isVarArg();
746}
747
749 return wrap(unwrap<FunctionType>(FunctionTy)->getReturnType());
750}
751
752unsigned LLVMCountParamTypes(LLVMTypeRef FunctionTy) {
753 return unwrap<FunctionType>(FunctionTy)->getNumParams();
754}
755
757 FunctionType *Ty = unwrap<FunctionType>(FunctionTy);
758 for (Type *T : Ty->params())
759 *Dest++ = wrap(T);
760}
761
762/*--.. Operations on struct types ..........................................--*/
763
765 unsigned ElementCount, LLVMBool Packed) {
766 ArrayRef<Type*> Tys(unwrap(ElementTypes), ElementCount);
767 return wrap(StructType::get(*unwrap(C), Tys, Packed != 0));
768}
769
771 unsigned ElementCount, LLVMBool Packed) {
772 return LLVMStructTypeInContext(LLVMGetGlobalContext(), ElementTypes,
773 ElementCount, Packed);
774}
775
777{
778 return wrap(StructType::create(*unwrap(C), Name));
779}
780
782{
783 StructType *Type = unwrap<StructType>(Ty);
784 if (!Type->hasName())
785 return nullptr;
786 return Type->getName().data();
787}
788
789void LLVMStructSetBody(LLVMTypeRef StructTy, LLVMTypeRef *ElementTypes,
790 unsigned ElementCount, LLVMBool Packed) {
791 ArrayRef<Type*> Tys(unwrap(ElementTypes), ElementCount);
792 unwrap<StructType>(StructTy)->setBody(Tys, Packed != 0);
793}
794
796 return unwrap<StructType>(StructTy)->getNumElements();
797}
798
800 StructType *Ty = unwrap<StructType>(StructTy);
801 for (Type *T : Ty->elements())
802 *Dest++ = wrap(T);
803}
804
806 StructType *Ty = unwrap<StructType>(StructTy);
807 return wrap(Ty->getTypeAtIndex(i));
808}
809
811 return unwrap<StructType>(StructTy)->isPacked();
812}
813
815 return unwrap<StructType>(StructTy)->isOpaque();
816}
817
819 return unwrap<StructType>(StructTy)->isLiteral();
820}
821
823 return wrap(StructType::getTypeByName(unwrap(M)->getContext(), Name));
824}
825
828}
829
830/*--.. Operations on array, pointer, and vector types (sequence types) .....--*/
831
833 int i = 0;
834 for (auto *T : unwrap(Tp)->subtypes()) {
835 Arr[i] = wrap(T);
836 i++;
837 }
838}
839
841 return wrap(ArrayType::get(unwrap(ElementType), ElementCount));
842}
843
845 return wrap(ArrayType::get(unwrap(ElementType), ElementCount));
846}
847
849 return wrap(PointerType::get(unwrap(ElementType), AddressSpace));
850}
851
853 return true;
854}
855
857 return wrap(FixedVectorType::get(unwrap(ElementType), ElementCount));
858}
859
861 unsigned ElementCount) {
862 return wrap(ScalableVectorType::get(unwrap(ElementType), ElementCount));
863}
864
866 auto *Ty = unwrap(WrappedTy);
867 if (auto *ATy = dyn_cast<ArrayType>(Ty))
868 return wrap(ATy->getElementType());
869 return wrap(cast<VectorType>(Ty)->getElementType());
870}
871
873 return unwrap(Tp)->getNumContainedTypes();
874}
875
877 return unwrap<ArrayType>(ArrayTy)->getNumElements();
878}
879
881 return unwrap<ArrayType>(ArrayTy)->getNumElements();
882}
883
885 return unwrap<PointerType>(PointerTy)->getAddressSpace();
886}
887
888unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy) {
889 return unwrap<VectorType>(VectorTy)->getElementCount().getKnownMinValue();
890}
891
892/*--.. Operations on other types ...........................................--*/
893
895 return wrap(PointerType::get(*unwrap(C), AddressSpace));
896}
897
899 return wrap(Type::getVoidTy(*unwrap(C)));
900}
902 return wrap(Type::getLabelTy(*unwrap(C)));
903}
905 return wrap(Type::getTokenTy(*unwrap(C)));
906}
908 return wrap(Type::getMetadataTy(*unwrap(C)));
909}
910
913}
916}
917
919 LLVMTypeRef *TypeParams,
920 unsigned TypeParamCount,
921 unsigned *IntParams,
922 unsigned IntParamCount) {
923 ArrayRef<Type *> TypeParamArray(unwrap(TypeParams), TypeParamCount);
924 ArrayRef<unsigned> IntParamArray(IntParams, IntParamCount);
925 return wrap(
926 TargetExtType::get(*unwrap(C), Name, TypeParamArray, IntParamArray));
927}
928
929/*===-- Operations on values ----------------------------------------------===*/
930
931/*--.. Operations on all values ............................................--*/
932
934 return wrap(unwrap(Val)->getType());
935}
936
938 switch(unwrap(Val)->getValueID()) {
939#define LLVM_C_API 1
940#define HANDLE_VALUE(Name) \
941 case Value::Name##Val: \
942 return LLVM##Name##ValueKind;
943#include "llvm/IR/Value.def"
944 default:
946 }
947}
948
949const char *LLVMGetValueName2(LLVMValueRef Val, size_t *Length) {
950 auto *V = unwrap(Val);
951 *Length = V->getName().size();
952 return V->getName().data();
953}
954
955void LLVMSetValueName2(LLVMValueRef Val, const char *Name, size_t NameLen) {
956 unwrap(Val)->setName(StringRef(Name, NameLen));
957}
958
960 return unwrap(Val)->getName().data();
961}
962
963void LLVMSetValueName(LLVMValueRef Val, const char *Name) {
964 unwrap(Val)->setName(Name);
965}
966
968 unwrap(Val)->print(errs(), /*IsForDebug=*/true);
969}
970
972 std::string buf;
973 raw_string_ostream os(buf);
974
975 if (unwrap(Val))
976 unwrap(Val)->print(os);
977 else
978 os << "Printing <null> Value";
979
980 os.flush();
981
982 return strdup(buf.c_str());
983}
984
986 unwrap(OldVal)->replaceAllUsesWith(unwrap(NewVal));
987}
988
990 return unwrap<Instruction>(Inst)->hasMetadata();
991}
992
994 auto *I = unwrap<Instruction>(Inst);
995 assert(I && "Expected instruction");
996 if (auto *MD = I->getMetadata(KindID))
997 return wrap(MetadataAsValue::get(I->getContext(), MD));
998 return nullptr;
999}
1000
1001// MetadataAsValue uses a canonical format which strips the actual MDNode for
1002// MDNode with just a single constant value, storing just a ConstantAsMetadata
1003// This undoes this canonicalization, reconstructing the MDNode.
1005 Metadata *MD = MAV->getMetadata();
1006 assert((isa<MDNode>(MD) || isa<ConstantAsMetadata>(MD)) &&
1007 "Expected a metadata node or a canonicalized constant");
1008
1009 if (MDNode *N = dyn_cast<MDNode>(MD))
1010 return N;
1011
1012 return MDNode::get(MAV->getContext(), MD);
1013}
1014
1015void LLVMSetMetadata(LLVMValueRef Inst, unsigned KindID, LLVMValueRef Val) {
1016 MDNode *N = Val ? extractMDNode(unwrap<MetadataAsValue>(Val)) : nullptr;
1017
1018 unwrap<Instruction>(Inst)->setMetadata(KindID, N);
1019}
1020
1022 unsigned Kind;
1024};
1025
1028llvm_getMetadata(size_t *NumEntries,
1029 llvm::function_ref<void(MetadataEntries &)> AccessMD) {
1031 AccessMD(MVEs);
1032
1034 static_cast<LLVMOpaqueValueMetadataEntry *>(
1036 for (unsigned i = 0; i < MVEs.size(); ++i) {
1037 const auto &ModuleFlag = MVEs[i];
1038 Result[i].Kind = ModuleFlag.first;
1039 Result[i].Metadata = wrap(ModuleFlag.second);
1040 }
1041 *NumEntries = MVEs.size();
1042 return Result;
1043}
1044
1047 size_t *NumEntries) {
1048 return llvm_getMetadata(NumEntries, [&Value](MetadataEntries &Entries) {
1049 Entries.clear();
1050 unwrap<Instruction>(Value)->getAllMetadata(Entries);
1051 });
1052}
1053
1054/*--.. Conversion functions ................................................--*/
1055
1056#define LLVM_DEFINE_VALUE_CAST(name) \
1057 LLVMValueRef LLVMIsA##name(LLVMValueRef Val) { \
1058 return wrap(static_cast<Value*>(dyn_cast_or_null<name>(unwrap(Val)))); \
1059 }
1060
1062
1064 if (auto *MD = dyn_cast_or_null<MetadataAsValue>(unwrap(Val)))
1065 if (isa<MDNode>(MD->getMetadata()) ||
1066 isa<ValueAsMetadata>(MD->getMetadata()))
1067 return Val;
1068 return nullptr;
1069}
1070
1072 if (auto *MD = dyn_cast_or_null<MetadataAsValue>(unwrap(Val)))
1073 if (isa<ValueAsMetadata>(MD->getMetadata()))
1074 return Val;
1075 return nullptr;
1076}
1077
1079 if (auto *MD = dyn_cast_or_null<MetadataAsValue>(unwrap(Val)))
1080 if (isa<MDString>(MD->getMetadata()))
1081 return Val;
1082 return nullptr;
1083}
1084
1085/*--.. Operations on Uses ..................................................--*/
1087 Value *V = unwrap(Val);
1088 Value::use_iterator I = V->use_begin();
1089 if (I == V->use_end())
1090 return nullptr;
1091 return wrap(&*I);
1092}
1093
1095 Use *Next = unwrap(U)->getNext();
1096 if (Next)
1097 return wrap(Next);
1098 return nullptr;
1099}
1100
1102 return wrap(unwrap(U)->getUser());
1103}
1104
1106 return wrap(unwrap(U)->get());
1107}
1108
1109/*--.. Operations on Users .................................................--*/
1110
1112 unsigned Index) {
1113 Metadata *Op = N->getOperand(Index);
1114 if (!Op)
1115 return nullptr;
1116 if (auto *C = dyn_cast<ConstantAsMetadata>(Op))
1117 return wrap(C->getValue());
1119}
1120
1122 Value *V = unwrap(Val);
1123 if (auto *MD = dyn_cast<MetadataAsValue>(V)) {
1124 if (auto *L = dyn_cast<ValueAsMetadata>(MD->getMetadata())) {
1125 assert(Index == 0 && "Function-local metadata can only have one operand");
1126 return wrap(L->getValue());
1127 }
1128 return getMDNodeOperandImpl(V->getContext(),
1129 cast<MDNode>(MD->getMetadata()), Index);
1130 }
1131
1132 return wrap(cast<User>(V)->getOperand(Index));
1133}
1134
1136 Value *V = unwrap(Val);
1137 return wrap(&cast<User>(V)->getOperandUse(Index));
1138}
1139
1141 unwrap<User>(Val)->setOperand(Index, unwrap(Op));
1142}
1143
1145 Value *V = unwrap(Val);
1146 if (isa<MetadataAsValue>(V))
1147 return LLVMGetMDNodeNumOperands(Val);
1148
1149 return cast<User>(V)->getNumOperands();
1150}
1151
1152/*--.. Operations on constants of any type .................................--*/
1153
1155 return wrap(Constant::getNullValue(unwrap(Ty)));
1156}
1157
1160}
1161
1163 return wrap(UndefValue::get(unwrap(Ty)));
1164}
1165
1167 return wrap(PoisonValue::get(unwrap(Ty)));
1168}
1169
1171 return isa<Constant>(unwrap(Ty));
1172}
1173
1175 if (Constant *C = dyn_cast<Constant>(unwrap(Val)))
1176 return C->isNullValue();
1177 return false;
1178}
1179
1181 return isa<UndefValue>(unwrap(Val));
1182}
1183
1185 return isa<PoisonValue>(unwrap(Val));
1186}
1187
1189 return wrap(ConstantPointerNull::get(unwrap<PointerType>(Ty)));
1190}
1191
1192/*--.. Operations on metadata nodes ........................................--*/
1193
1195 size_t SLen) {
1196 return wrap(MDString::get(*unwrap(C), StringRef(Str, SLen)));
1197}
1198
1200 size_t Count) {
1201 return wrap(MDNode::get(*unwrap(C), ArrayRef<Metadata*>(unwrap(MDs), Count)));
1202}
1203
1205 unsigned SLen) {
1208 Context, MDString::get(Context, StringRef(Str, SLen))));
1209}
1210
1211LLVMValueRef LLVMMDString(const char *Str, unsigned SLen) {
1212 return LLVMMDStringInContext(LLVMGetGlobalContext(), Str, SLen);
1213}
1214
1216 unsigned Count) {
1219 for (auto *OV : ArrayRef(Vals, Count)) {
1220 Value *V = unwrap(OV);
1221 Metadata *MD;
1222 if (!V)
1223 MD = nullptr;
1224 else if (auto *C = dyn_cast<Constant>(V))
1226 else if (auto *MDV = dyn_cast<MetadataAsValue>(V)) {
1227 MD = MDV->getMetadata();
1228 assert(!isa<LocalAsMetadata>(MD) && "Unexpected function-local metadata "
1229 "outside of direct argument to call");
1230 } else {
1231 // This is function-local metadata. Pretend to make an MDNode.
1232 assert(Count == 1 &&
1233 "Expected only one operand to function-local metadata");
1235 }
1236
1237 MDs.push_back(MD);
1238 }
1240}
1241
1242LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count) {
1243 return LLVMMDNodeInContext(LLVMGetGlobalContext(), Vals, Count);
1244}
1245
1247 return wrap(MetadataAsValue::get(*unwrap(C), unwrap(MD)));
1248}
1249
1251 auto *V = unwrap(Val);
1252 if (auto *C = dyn_cast<Constant>(V))
1254 if (auto *MAV = dyn_cast<MetadataAsValue>(V))
1255 return wrap(MAV->getMetadata());
1256 return wrap(ValueAsMetadata::get(V));
1257}
1258
1259const char *LLVMGetMDString(LLVMValueRef V, unsigned *Length) {
1260 if (const auto *MD = dyn_cast<MetadataAsValue>(unwrap(V)))
1261 if (const MDString *S = dyn_cast<MDString>(MD->getMetadata())) {
1262 *Length = S->getString().size();
1263 return S->getString().data();
1264 }
1265 *Length = 0;
1266 return nullptr;
1267}
1268
1270 auto *MD = unwrap<MetadataAsValue>(V);
1271 if (isa<ValueAsMetadata>(MD->getMetadata()))
1272 return 1;
1273 return cast<MDNode>(MD->getMetadata())->getNumOperands();
1274}
1275
1277 Module *Mod = unwrap(M);
1279 if (I == Mod->named_metadata_end())
1280 return nullptr;
1281 return wrap(&*I);
1282}
1283
1285 Module *Mod = unwrap(M);
1287 if (I == Mod->named_metadata_begin())
1288 return nullptr;
1289 return wrap(&*--I);
1290}
1291
1293 NamedMDNode *NamedNode = unwrap(NMD);
1295 if (++I == NamedNode->getParent()->named_metadata_end())
1296 return nullptr;
1297 return wrap(&*I);
1298}
1299
1301 NamedMDNode *NamedNode = unwrap(NMD);
1303 if (I == NamedNode->getParent()->named_metadata_begin())
1304 return nullptr;
1305 return wrap(&*--I);
1306}
1307
1309 const char *Name, size_t NameLen) {
1310 return wrap(unwrap(M)->getNamedMetadata(StringRef(Name, NameLen)));
1311}
1312
1314 const char *Name, size_t NameLen) {
1315 return wrap(unwrap(M)->getOrInsertNamedMetadata({Name, NameLen}));
1316}
1317
1318const char *LLVMGetNamedMetadataName(LLVMNamedMDNodeRef NMD, size_t *NameLen) {
1319 NamedMDNode *NamedNode = unwrap(NMD);
1320 *NameLen = NamedNode->getName().size();
1321 return NamedNode->getName().data();
1322}
1323
1325 auto *MD = unwrap<MetadataAsValue>(V);
1326 if (auto *MDV = dyn_cast<ValueAsMetadata>(MD->getMetadata())) {
1327 *Dest = wrap(MDV->getValue());
1328 return;
1329 }
1330 const auto *N = cast<MDNode>(MD->getMetadata());
1331 const unsigned numOperands = N->getNumOperands();
1332 LLVMContext &Context = unwrap(V)->getContext();
1333 for (unsigned i = 0; i < numOperands; i++)
1334 Dest[i] = getMDNodeOperandImpl(Context, N, i);
1335}
1336
1338 LLVMMetadataRef Replacement) {
1339 auto *MD = cast<MetadataAsValue>(unwrap(V));
1340 auto *N = cast<MDNode>(MD->getMetadata());
1341 N->replaceOperandWith(Index, unwrap<Metadata>(Replacement));
1342}
1343
1345 if (NamedMDNode *N = unwrap(M)->getNamedMetadata(Name)) {
1346 return N->getNumOperands();
1347 }
1348 return 0;
1349}
1350
1352 LLVMValueRef *Dest) {
1353 NamedMDNode *N = unwrap(M)->getNamedMetadata(Name);
1354 if (!N)
1355 return;
1356 LLVMContext &Context = unwrap(M)->getContext();
1357 for (unsigned i=0;i<N->getNumOperands();i++)
1358 Dest[i] = wrap(MetadataAsValue::get(Context, N->getOperand(i)));
1359}
1360
1362 LLVMValueRef Val) {
1363 NamedMDNode *N = unwrap(M)->getOrInsertNamedMetadata(Name);
1364 if (!N)
1365 return;
1366 if (!Val)
1367 return;
1368 N->addOperand(extractMDNode(unwrap<MetadataAsValue>(Val)));
1369}
1370
1371const char *LLVMGetDebugLocDirectory(LLVMValueRef Val, unsigned *Length) {
1372 if (!Length) return nullptr;
1373 StringRef S;
1374 if (const auto *I = dyn_cast<Instruction>(unwrap(Val))) {
1375 if (const auto &DL = I->getDebugLoc()) {
1376 S = DL->getDirectory();
1377 }
1378 } else if (const auto *GV = dyn_cast<GlobalVariable>(unwrap(Val))) {
1380 GV->getDebugInfo(GVEs);
1381 if (GVEs.size())
1382 if (const DIGlobalVariable *DGV = GVEs[0]->getVariable())
1383 S = DGV->getDirectory();
1384 } else if (const auto *F = dyn_cast<Function>(unwrap(Val))) {
1385 if (const DISubprogram *DSP = F->getSubprogram())
1386 S = DSP->getDirectory();
1387 } else {
1388 assert(0 && "Expected Instruction, GlobalVariable or Function");
1389 return nullptr;
1390 }
1391 *Length = S.size();
1392 return S.data();
1393}
1394
1395const char *LLVMGetDebugLocFilename(LLVMValueRef Val, unsigned *Length) {
1396 if (!Length) return nullptr;
1397 StringRef S;
1398 if (const auto *I = dyn_cast<Instruction>(unwrap(Val))) {
1399 if (const auto &DL = I->getDebugLoc()) {
1400 S = DL->getFilename();
1401 }
1402 } else if (const auto *GV = dyn_cast<GlobalVariable>(unwrap(Val))) {
1404 GV->getDebugInfo(GVEs);
1405 if (GVEs.size())
1406 if (const DIGlobalVariable *DGV = GVEs[0]->getVariable())
1407 S = DGV->getFilename();
1408 } else if (const auto *F = dyn_cast<Function>(unwrap(Val))) {
1409 if (const DISubprogram *DSP = F->getSubprogram())
1410 S = DSP->getFilename();
1411 } else {
1412 assert(0 && "Expected Instruction, GlobalVariable or Function");
1413 return nullptr;
1414 }
1415 *Length = S.size();
1416 return S.data();
1417}
1418
1420 unsigned L = 0;
1421 if (const auto *I = dyn_cast<Instruction>(unwrap(Val))) {
1422 if (const auto &DL = I->getDebugLoc()) {
1423 L = DL->getLine();
1424 }
1425 } else if (const auto *GV = dyn_cast<GlobalVariable>(unwrap(Val))) {
1427 GV->getDebugInfo(GVEs);
1428 if (GVEs.size())
1429 if (const DIGlobalVariable *DGV = GVEs[0]->getVariable())
1430 L = DGV->getLine();
1431 } else if (const auto *F = dyn_cast<Function>(unwrap(Val))) {
1432 if (const DISubprogram *DSP = F->getSubprogram())
1433 L = DSP->getLine();
1434 } else {
1435 assert(0 && "Expected Instruction, GlobalVariable or Function");
1436 return -1;
1437 }
1438 return L;
1439}
1440
1442 unsigned C = 0;
1443 if (const auto *I = dyn_cast<Instruction>(unwrap(Val)))
1444 if (const auto &DL = I->getDebugLoc())
1445 C = DL->getColumn();
1446 return C;
1447}
1448
1449/*--.. Operations on scalar constants ......................................--*/
1450
1451LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N,
1452 LLVMBool SignExtend) {
1453 return wrap(ConstantInt::get(unwrap<IntegerType>(IntTy), N, SignExtend != 0));
1454}
1455
1457 unsigned NumWords,
1458 const uint64_t Words[]) {
1459 IntegerType *Ty = unwrap<IntegerType>(IntTy);
1460 return wrap(ConstantInt::get(
1461 Ty->getContext(), APInt(Ty->getBitWidth(), ArrayRef(Words, NumWords))));
1462}
1463
1465 uint8_t Radix) {
1466 return wrap(ConstantInt::get(unwrap<IntegerType>(IntTy), StringRef(Str),
1467 Radix));
1468}
1469
1471 unsigned SLen, uint8_t Radix) {
1472 return wrap(ConstantInt::get(unwrap<IntegerType>(IntTy), StringRef(Str, SLen),
1473 Radix));
1474}
1475
1477 return wrap(ConstantFP::get(unwrap(RealTy), N));
1478}
1479
1481 return wrap(ConstantFP::get(unwrap(RealTy), StringRef(Text)));
1482}
1483
1485 unsigned SLen) {
1486 return wrap(ConstantFP::get(unwrap(RealTy), StringRef(Str, SLen)));
1487}
1488
1489unsigned long long LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal) {
1490 return unwrap<ConstantInt>(ConstantVal)->getZExtValue();
1491}
1492
1494 return unwrap<ConstantInt>(ConstantVal)->getSExtValue();
1495}
1496
1497double LLVMConstRealGetDouble(LLVMValueRef ConstantVal, LLVMBool *LosesInfo) {
1498 ConstantFP *cFP = unwrap<ConstantFP>(ConstantVal) ;
1499 Type *Ty = cFP->getType();
1500
1501 if (Ty->isHalfTy() || Ty->isBFloatTy() || Ty->isFloatTy() ||
1502 Ty->isDoubleTy()) {
1503 *LosesInfo = false;
1504 return cFP->getValueAPF().convertToDouble();
1505 }
1506
1507 bool APFLosesInfo;
1508 APFloat APF = cFP->getValueAPF();
1509 APF.convert(APFloat::IEEEdouble(), APFloat::rmNearestTiesToEven, &APFLosesInfo);
1510 *LosesInfo = APFLosesInfo;
1511 return APF.convertToDouble();
1512}
1513
1514/*--.. Operations on composite constants ...................................--*/
1515
1517 unsigned Length,
1518 LLVMBool DontNullTerminate) {
1519 /* Inverted the sense of AddNull because ', 0)' is a
1520 better mnemonic for null termination than ', 1)'. */
1522 DontNullTerminate == 0));
1523}
1524
1526 size_t Length,
1527 LLVMBool DontNullTerminate) {
1528 /* Inverted the sense of AddNull because ', 0)' is a
1529 better mnemonic for null termination than ', 1)'. */
1531 DontNullTerminate == 0));
1532}
1533
1534LLVMValueRef LLVMConstString(const char *Str, unsigned Length,
1535 LLVMBool DontNullTerminate) {
1537 DontNullTerminate);
1538}
1539
1541 return wrap(unwrap<Constant>(C)->getAggregateElement(Idx));
1542}
1543
1545 return wrap(unwrap<ConstantDataSequential>(C)->getElementAsConstant(idx));
1546}
1547
1549 return unwrap<ConstantDataSequential>(C)->isString();
1550}
1551
1552const char *LLVMGetAsString(LLVMValueRef C, size_t *Length) {
1553 StringRef Str = unwrap<ConstantDataSequential>(C)->getAsString();
1554 *Length = Str.size();
1555 return Str.data();
1556}
1557
1559 LLVMValueRef *ConstantVals, unsigned Length) {
1560 ArrayRef<Constant*> V(unwrap<Constant>(ConstantVals, Length), Length);
1561 return wrap(ConstantArray::get(ArrayType::get(unwrap(ElementTy), Length), V));
1562}
1563
1565 uint64_t Length) {
1566 ArrayRef<Constant *> V(unwrap<Constant>(ConstantVals, Length), Length);
1567 return wrap(ConstantArray::get(ArrayType::get(unwrap(ElementTy), Length), V));
1568}
1569
1571 LLVMValueRef *ConstantVals,
1572 unsigned Count, LLVMBool Packed) {
1573 Constant **Elements = unwrap<Constant>(ConstantVals, Count);
1574 return wrap(ConstantStruct::getAnon(*unwrap(C), ArrayRef(Elements, Count),
1575 Packed != 0));
1576}
1577
1578LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count,
1579 LLVMBool Packed) {
1580 return LLVMConstStructInContext(LLVMGetGlobalContext(), ConstantVals, Count,
1581 Packed);
1582}
1583
1585 LLVMValueRef *ConstantVals,
1586 unsigned Count) {
1587 Constant **Elements = unwrap<Constant>(ConstantVals, Count);
1588 StructType *Ty = unwrap<StructType>(StructTy);
1589
1590 return wrap(ConstantStruct::get(Ty, ArrayRef(Elements, Count)));
1591}
1592
1593LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size) {
1595 ArrayRef(unwrap<Constant>(ScalarConstantVals, Size), Size)));
1596}
1597
1598/*-- Opcode mapping */
1599
1601{
1602 switch (opcode) {
1603 default: llvm_unreachable("Unhandled Opcode.");
1604#define HANDLE_INST(num, opc, clas) case num: return LLVM##opc;
1605#include "llvm/IR/Instruction.def"
1606#undef HANDLE_INST
1607 }
1608}
1609
1611{
1612 switch (code) {
1613#define HANDLE_INST(num, opc, clas) case LLVM##opc: return num;
1614#include "llvm/IR/Instruction.def"
1615#undef HANDLE_INST
1616 }
1617 llvm_unreachable("Unhandled Opcode.");
1618}
1619
1620/*--.. Constant expressions ................................................--*/
1621
1623 return map_to_llvmopcode(unwrap<ConstantExpr>(ConstantVal)->getOpcode());
1624}
1625
1628}
1629
1631 return wrap(ConstantExpr::getSizeOf(unwrap(Ty)));
1632}
1633
1635 return wrap(ConstantExpr::getNeg(unwrap<Constant>(ConstantVal)));
1636}
1637
1639 return wrap(ConstantExpr::getNSWNeg(unwrap<Constant>(ConstantVal)));
1640}
1641
1643 return wrap(ConstantExpr::getNUWNeg(unwrap<Constant>(ConstantVal)));
1644}
1645
1646
1648 return wrap(ConstantExpr::getNot(unwrap<Constant>(ConstantVal)));
1649}
1650
1652 return wrap(ConstantExpr::getAdd(unwrap<Constant>(LHSConstant),
1653 unwrap<Constant>(RHSConstant)));
1654}
1655
1657 LLVMValueRef RHSConstant) {
1658 return wrap(ConstantExpr::getNSWAdd(unwrap<Constant>(LHSConstant),
1659 unwrap<Constant>(RHSConstant)));
1660}
1661
1663 LLVMValueRef RHSConstant) {
1664 return wrap(ConstantExpr::getNUWAdd(unwrap<Constant>(LHSConstant),
1665 unwrap<Constant>(RHSConstant)));
1666}
1667
1669 return wrap(ConstantExpr::getSub(unwrap<Constant>(LHSConstant),
1670 unwrap<Constant>(RHSConstant)));
1671}
1672
1674 LLVMValueRef RHSConstant) {
1675 return wrap(ConstantExpr::getNSWSub(unwrap<Constant>(LHSConstant),
1676 unwrap<Constant>(RHSConstant)));
1677}
1678
1680 LLVMValueRef RHSConstant) {
1681 return wrap(ConstantExpr::getNUWSub(unwrap<Constant>(LHSConstant),
1682 unwrap<Constant>(RHSConstant)));
1683}
1684
1686 return wrap(ConstantExpr::getMul(unwrap<Constant>(LHSConstant),
1687 unwrap<Constant>(RHSConstant)));
1688}
1689
1691 LLVMValueRef RHSConstant) {
1692 return wrap(ConstantExpr::getNSWMul(unwrap<Constant>(LHSConstant),
1693 unwrap<Constant>(RHSConstant)));
1694}
1695
1697 LLVMValueRef RHSConstant) {
1698 return wrap(ConstantExpr::getNUWMul(unwrap<Constant>(LHSConstant),
1699 unwrap<Constant>(RHSConstant)));
1700}
1701
1703 return wrap(ConstantExpr::getXor(unwrap<Constant>(LHSConstant),
1704 unwrap<Constant>(RHSConstant)));
1705}
1706
1708 LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
1709 return wrap(ConstantExpr::getICmp(Predicate,
1710 unwrap<Constant>(LHSConstant),
1711 unwrap<Constant>(RHSConstant)));
1712}
1713
1715 LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
1716 return wrap(ConstantExpr::getFCmp(Predicate,
1717 unwrap<Constant>(LHSConstant),
1718 unwrap<Constant>(RHSConstant)));
1719}
1720
1722 return wrap(ConstantExpr::getShl(unwrap<Constant>(LHSConstant),
1723 unwrap<Constant>(RHSConstant)));
1724}
1725
1727 LLVMValueRef *ConstantIndices, unsigned NumIndices) {
1728 ArrayRef<Constant *> IdxList(unwrap<Constant>(ConstantIndices, NumIndices),
1729 NumIndices);
1730 Constant *Val = unwrap<Constant>(ConstantVal);
1731 return wrap(ConstantExpr::getGetElementPtr(unwrap(Ty), Val, IdxList));
1732}
1733
1735 LLVMValueRef *ConstantIndices,
1736 unsigned NumIndices) {
1737 ArrayRef<Constant *> IdxList(unwrap<Constant>(ConstantIndices, NumIndices),
1738 NumIndices);
1739 Constant *Val = unwrap<Constant>(ConstantVal);
1740 return wrap(ConstantExpr::getInBoundsGetElementPtr(unwrap(Ty), Val, IdxList));
1741}
1742
1744 return wrap(ConstantExpr::getTrunc(unwrap<Constant>(ConstantVal),
1745 unwrap(ToType)));
1746}
1747
1749 return wrap(ConstantExpr::getPtrToInt(unwrap<Constant>(ConstantVal),
1750 unwrap(ToType)));
1751}
1752
1754 return wrap(ConstantExpr::getIntToPtr(unwrap<Constant>(ConstantVal),
1755 unwrap(ToType)));
1756}
1757
1759 return wrap(ConstantExpr::getBitCast(unwrap<Constant>(ConstantVal),
1760 unwrap(ToType)));
1761}
1762
1764 LLVMTypeRef ToType) {
1765 return wrap(ConstantExpr::getAddrSpaceCast(unwrap<Constant>(ConstantVal),
1766 unwrap(ToType)));
1767}
1768
1770 LLVMTypeRef ToType) {
1771 return wrap(ConstantExpr::getTruncOrBitCast(unwrap<Constant>(ConstantVal),
1772 unwrap(ToType)));
1773}
1774
1776 LLVMTypeRef ToType) {
1777 return wrap(ConstantExpr::getPointerCast(unwrap<Constant>(ConstantVal),
1778 unwrap(ToType)));
1779}
1780
1782 LLVMValueRef IndexConstant) {
1783 return wrap(ConstantExpr::getExtractElement(unwrap<Constant>(VectorConstant),
1784 unwrap<Constant>(IndexConstant)));
1785}
1786
1788 LLVMValueRef ElementValueConstant,
1789 LLVMValueRef IndexConstant) {
1790 return wrap(ConstantExpr::getInsertElement(unwrap<Constant>(VectorConstant),
1791 unwrap<Constant>(ElementValueConstant),
1792 unwrap<Constant>(IndexConstant)));
1793}
1794
1796 LLVMValueRef VectorBConstant,
1797 LLVMValueRef MaskConstant) {
1798 SmallVector<int, 16> IntMask;
1799 ShuffleVectorInst::getShuffleMask(unwrap<Constant>(MaskConstant), IntMask);
1800 return wrap(ConstantExpr::getShuffleVector(unwrap<Constant>(VectorAConstant),
1801 unwrap<Constant>(VectorBConstant),
1802 IntMask));
1803}
1804
1806 const char *Constraints,
1807 LLVMBool HasSideEffects,
1808 LLVMBool IsAlignStack) {
1809 return wrap(InlineAsm::get(dyn_cast<FunctionType>(unwrap(Ty)), AsmString,
1810 Constraints, HasSideEffects, IsAlignStack));
1811}
1812
1814 return wrap(BlockAddress::get(unwrap<Function>(F), unwrap(BB)));
1815}
1816
1818 return wrap(unwrap<BlockAddress>(BlockAddr)->getFunction());
1819}
1820
1822 return wrap(unwrap<BlockAddress>(BlockAddr)->getBasicBlock());
1823}
1824
1825/*--.. Operations on global variables, functions, and aliases (globals) ....--*/
1826
1828 return wrap(unwrap<GlobalValue>(Global)->getParent());
1829}
1830
1832 return unwrap<GlobalValue>(Global)->isDeclaration();
1833}
1834
1836 switch (unwrap<GlobalValue>(Global)->getLinkage()) {
1838 return LLVMExternalLinkage;
1846 return LLVMWeakAnyLinkage;
1848 return LLVMWeakODRLinkage;
1850 return LLVMAppendingLinkage;
1852 return LLVMInternalLinkage;
1854 return LLVMPrivateLinkage;
1858 return LLVMCommonLinkage;
1859 }
1860
1861 llvm_unreachable("Invalid GlobalValue linkage!");
1862}
1863
1865 GlobalValue *GV = unwrap<GlobalValue>(Global);
1866
1867 switch (Linkage) {
1870 break;
1873 break;
1876 break;
1879 break;
1881 LLVM_DEBUG(
1882 errs() << "LLVMSetLinkage(): LLVMLinkOnceODRAutoHideLinkage is no "
1883 "longer supported.");
1884 break;
1885 case LLVMWeakAnyLinkage:
1887 break;
1888 case LLVMWeakODRLinkage:
1890 break;
1893 break;
1896 break;
1897 case LLVMPrivateLinkage:
1899 break;
1902 break;
1905 break;
1907 LLVM_DEBUG(
1908 errs()
1909 << "LLVMSetLinkage(): LLVMDLLImportLinkage is no longer supported.");
1910 break;
1912 LLVM_DEBUG(
1913 errs()
1914 << "LLVMSetLinkage(): LLVMDLLExportLinkage is no longer supported.");
1915 break;
1918 break;
1919 case LLVMGhostLinkage:
1920 LLVM_DEBUG(
1921 errs() << "LLVMSetLinkage(): LLVMGhostLinkage is no longer supported.");
1922 break;
1923 case LLVMCommonLinkage:
1925 break;
1926 }
1927}
1928
1930 // Using .data() is safe because of how GlobalObject::setSection is
1931 // implemented.
1932 return unwrap<GlobalValue>(Global)->getSection().data();
1933}
1934
1935void LLVMSetSection(LLVMValueRef Global, const char *Section) {
1936 unwrap<GlobalObject>(Global)->setSection(Section);
1937}
1938
1940 return static_cast<LLVMVisibility>(
1941 unwrap<GlobalValue>(Global)->getVisibility());
1942}
1943
1945 unwrap<GlobalValue>(Global)
1946 ->setVisibility(static_cast<GlobalValue::VisibilityTypes>(Viz));
1947}
1948
1950 return static_cast<LLVMDLLStorageClass>(
1951 unwrap<GlobalValue>(Global)->getDLLStorageClass());
1952}
1953
1955 unwrap<GlobalValue>(Global)->setDLLStorageClass(
1956 static_cast<GlobalValue::DLLStorageClassTypes>(Class));
1957}
1958
1960 switch (unwrap<GlobalValue>(Global)->getUnnamedAddr()) {
1961 case GlobalVariable::UnnamedAddr::None:
1962 return LLVMNoUnnamedAddr;
1963 case GlobalVariable::UnnamedAddr::Local:
1964 return LLVMLocalUnnamedAddr;
1965 case GlobalVariable::UnnamedAddr::Global:
1966 return LLVMGlobalUnnamedAddr;
1967 }
1968 llvm_unreachable("Unknown UnnamedAddr kind!");
1969}
1970
1972 GlobalValue *GV = unwrap<GlobalValue>(Global);
1973
1974 switch (UnnamedAddr) {
1975 case LLVMNoUnnamedAddr:
1976 return GV->setUnnamedAddr(GlobalVariable::UnnamedAddr::None);
1978 return GV->setUnnamedAddr(GlobalVariable::UnnamedAddr::Local);
1980 return GV->setUnnamedAddr(GlobalVariable::UnnamedAddr::Global);
1981 }
1982}
1983
1985 return unwrap<GlobalValue>(Global)->hasGlobalUnnamedAddr();
1986}
1987
1989 unwrap<GlobalValue>(Global)->setUnnamedAddr(
1990 HasUnnamedAddr ? GlobalValue::UnnamedAddr::Global
1991 : GlobalValue::UnnamedAddr::None);
1992}
1993
1995 return wrap(unwrap<GlobalValue>(Global)->getValueType());
1996}
1997
1998/*--.. Operations on global variables, load and store instructions .........--*/
1999
2001 Value *P = unwrap(V);
2002 if (GlobalObject *GV = dyn_cast<GlobalObject>(P))
2003 return GV->getAlign() ? GV->getAlign()->value() : 0;
2004 if (AllocaInst *AI = dyn_cast<AllocaInst>(P))
2005 return AI->getAlign().value();
2006 if (LoadInst *LI = dyn_cast<LoadInst>(P))
2007 return LI->getAlign().value();
2008 if (StoreInst *SI = dyn_cast<StoreInst>(P))
2009 return SI->getAlign().value();
2010 if (AtomicRMWInst *RMWI = dyn_cast<AtomicRMWInst>(P))
2011 return RMWI->getAlign().value();
2012 if (AtomicCmpXchgInst *CXI = dyn_cast<AtomicCmpXchgInst>(P))
2013 return CXI->getAlign().value();
2014
2016 "only GlobalValue, AllocaInst, LoadInst, StoreInst, AtomicRMWInst, "
2017 "and AtomicCmpXchgInst have alignment");
2018}
2019
2020void LLVMSetAlignment(LLVMValueRef V, unsigned Bytes) {
2021 Value *P = unwrap(V);
2022 if (GlobalObject *GV = dyn_cast<GlobalObject>(P))
2023 GV->setAlignment(MaybeAlign(Bytes));
2024 else if (AllocaInst *AI = dyn_cast<AllocaInst>(P))
2025 AI->setAlignment(Align(Bytes));
2026 else if (LoadInst *LI = dyn_cast<LoadInst>(P))
2027 LI->setAlignment(Align(Bytes));
2028 else if (StoreInst *SI = dyn_cast<StoreInst>(P))
2029 SI->setAlignment(Align(Bytes));
2030 else if (AtomicRMWInst *RMWI = dyn_cast<AtomicRMWInst>(P))
2031 RMWI->setAlignment(Align(Bytes));
2032 else if (AtomicCmpXchgInst *CXI = dyn_cast<AtomicCmpXchgInst>(P))
2033 CXI->setAlignment(Align(Bytes));
2034 else
2036 "only GlobalValue, AllocaInst, LoadInst, StoreInst, AtomicRMWInst, and "
2037 "and AtomicCmpXchgInst have alignment");
2038}
2039
2041 size_t *NumEntries) {
2042 return llvm_getMetadata(NumEntries, [&Value](MetadataEntries &Entries) {
2043 Entries.clear();
2044 if (Instruction *Instr = dyn_cast<Instruction>(unwrap(Value))) {
2045 Instr->getAllMetadata(Entries);
2046 } else {
2047 unwrap<GlobalObject>(Value)->getAllMetadata(Entries);
2048 }
2049 });
2050}
2051
2053 unsigned Index) {
2055 static_cast<LLVMOpaqueValueMetadataEntry>(Entries[Index]);
2056 return MVE.Kind;
2057}
2058
2061 unsigned Index) {
2063 static_cast<LLVMOpaqueValueMetadataEntry>(Entries[Index]);
2064 return MVE.Metadata;
2065}
2066
2068 free(Entries);
2069}
2070
2072 LLVMMetadataRef MD) {
2073 unwrap<GlobalObject>(Global)->setMetadata(Kind, unwrap<MDNode>(MD));
2074}
2075
2077 unwrap<GlobalObject>(Global)->eraseMetadata(Kind);
2078}
2079
2081 unwrap<GlobalObject>(Global)->clearMetadata();
2082}
2083
2084/*--.. Operations on global variables ......................................--*/
2085
2087 return wrap(new GlobalVariable(*unwrap(M), unwrap(Ty), false,
2089}
2090
2092 const char *Name,
2093 unsigned AddressSpace) {
2094 return wrap(new GlobalVariable(*unwrap(M), unwrap(Ty), false,
2096 nullptr, GlobalVariable::NotThreadLocal,
2097 AddressSpace));
2098}
2099
2101 return wrap(unwrap(M)->getNamedGlobal(Name));
2102}
2103
2105 Module *Mod = unwrap(M);
2107 if (I == Mod->global_end())
2108 return nullptr;
2109 return wrap(&*I);
2110}
2111
2113 Module *Mod = unwrap(M);
2115 if (I == Mod->global_begin())
2116 return nullptr;
2117 return wrap(&*--I);
2118}
2119
2121 GlobalVariable *GV = unwrap<GlobalVariable>(GlobalVar);
2123 if (++I == GV->getParent()->global_end())
2124 return nullptr;
2125 return wrap(&*I);
2126}
2127
2129 GlobalVariable *GV = unwrap<GlobalVariable>(GlobalVar);
2131 if (I == GV->getParent()->global_begin())
2132 return nullptr;
2133 return wrap(&*--I);
2134}
2135
2137 unwrap<GlobalVariable>(GlobalVar)->eraseFromParent();
2138}
2139
2141 GlobalVariable* GV = unwrap<GlobalVariable>(GlobalVar);
2142 if ( !GV->hasInitializer() )
2143 return nullptr;
2144 return wrap(GV->getInitializer());
2145}
2146
2147void LLVMSetInitializer(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal) {
2148 unwrap<GlobalVariable>(GlobalVar)
2149 ->setInitializer(unwrap<Constant>(ConstantVal));
2150}
2151
2153 return unwrap<GlobalVariable>(GlobalVar)->isThreadLocal();
2154}
2155
2156void LLVMSetThreadLocal(LLVMValueRef GlobalVar, LLVMBool IsThreadLocal) {
2157 unwrap<GlobalVariable>(GlobalVar)->setThreadLocal(IsThreadLocal != 0);
2158}
2159
2161 return unwrap<GlobalVariable>(GlobalVar)->isConstant();
2162}
2163
2164void LLVMSetGlobalConstant(LLVMValueRef GlobalVar, LLVMBool IsConstant) {
2165 unwrap<GlobalVariable>(GlobalVar)->setConstant(IsConstant != 0);
2166}
2167
2169 switch (unwrap<GlobalVariable>(GlobalVar)->getThreadLocalMode()) {
2170 case GlobalVariable::NotThreadLocal:
2171 return LLVMNotThreadLocal;
2172 case GlobalVariable::GeneralDynamicTLSModel:
2174 case GlobalVariable::LocalDynamicTLSModel:
2176 case GlobalVariable::InitialExecTLSModel:
2178 case GlobalVariable::LocalExecTLSModel:
2179 return LLVMLocalExecTLSModel;
2180 }
2181
2182 llvm_unreachable("Invalid GlobalVariable thread local mode");
2183}
2184
2186 GlobalVariable *GV = unwrap<GlobalVariable>(GlobalVar);
2187
2188 switch (Mode) {
2189 case LLVMNotThreadLocal:
2190 GV->setThreadLocalMode(GlobalVariable::NotThreadLocal);
2191 break;
2193 GV->setThreadLocalMode(GlobalVariable::GeneralDynamicTLSModel);
2194 break;
2196 GV->setThreadLocalMode(GlobalVariable::LocalDynamicTLSModel);
2197 break;
2199 GV->setThreadLocalMode(GlobalVariable::InitialExecTLSModel);
2200 break;
2202 GV->setThreadLocalMode(GlobalVariable::LocalExecTLSModel);
2203 break;
2204 }
2205}
2206
2208 return unwrap<GlobalVariable>(GlobalVar)->isExternallyInitialized();
2209}
2210
2212 unwrap<GlobalVariable>(GlobalVar)->setExternallyInitialized(IsExtInit);
2213}
2214
2215/*--.. Operations on aliases ......................................--*/
2216
2218 unsigned AddrSpace, LLVMValueRef Aliasee,
2219 const char *Name) {
2220 return wrap(GlobalAlias::create(unwrap(ValueTy), AddrSpace,
2222 unwrap<Constant>(Aliasee), unwrap(M)));
2223}
2224
2226 const char *Name, size_t NameLen) {
2227 return wrap(unwrap(M)->getNamedAlias(StringRef(Name, NameLen)));
2228}
2229
2231 Module *Mod = unwrap(M);
2233 if (I == Mod->alias_end())
2234 return nullptr;
2235 return wrap(&*I);
2236}
2237
2239 Module *Mod = unwrap(M);
2241 if (I == Mod->alias_begin())
2242 return nullptr;
2243 return wrap(&*--I);
2244}
2245
2247 GlobalAlias *Alias = unwrap<GlobalAlias>(GA);
2249 if (++I == Alias->getParent()->alias_end())
2250 return nullptr;
2251 return wrap(&*I);
2252}
2253
2255 GlobalAlias *Alias = unwrap<GlobalAlias>(GA);
2257 if (I == Alias->getParent()->alias_begin())
2258 return nullptr;
2259 return wrap(&*--I);
2260}
2261
2263 return wrap(unwrap<GlobalAlias>(Alias)->getAliasee());
2264}
2265
2267 unwrap<GlobalAlias>(Alias)->setAliasee(unwrap<Constant>(Aliasee));
2268}
2269
2270/*--.. Operations on functions .............................................--*/
2271
2273 LLVMTypeRef FunctionTy) {
2274 return wrap(Function::Create(unwrap<FunctionType>(FunctionTy),
2276}
2277
2279 return wrap(unwrap(M)->getFunction(Name));
2280}
2281
2283 Module *Mod = unwrap(M);
2285 if (I == Mod->end())
2286 return nullptr;
2287 return wrap(&*I);
2288}
2289
2291 Module *Mod = unwrap(M);
2293 if (I == Mod->begin())
2294 return nullptr;
2295 return wrap(&*--I);
2296}
2297
2299 Function *Func = unwrap<Function>(Fn);
2300 Module::iterator I(Func);
2301 if (++I == Func->getParent()->end())
2302 return nullptr;
2303 return wrap(&*I);
2304}
2305
2307 Function *Func = unwrap<Function>(Fn);
2308 Module::iterator I(Func);
2309 if (I == Func->getParent()->begin())
2310 return nullptr;
2311 return wrap(&*--I);
2312}
2313
2315 unwrap<Function>(Fn)->eraseFromParent();
2316}
2317
2319 return unwrap<Function>(Fn)->hasPersonalityFn();
2320}
2321
2323 return wrap(unwrap<Function>(Fn)->getPersonalityFn());
2324}
2325
2327 unwrap<Function>(Fn)->setPersonalityFn(unwrap<Constant>(PersonalityFn));
2328}
2329
2331 if (Function *F = dyn_cast<Function>(unwrap(Fn)))
2332 return F->getIntrinsicID();
2333 return 0;
2334}
2335
2337 assert(ID < llvm::Intrinsic::num_intrinsics && "Intrinsic ID out of range");
2338 return llvm::Intrinsic::ID(ID);
2339}
2340
2342 unsigned ID,
2343 LLVMTypeRef *ParamTypes,
2344 size_t ParamCount) {
2345 ArrayRef<Type*> Tys(unwrap(ParamTypes), ParamCount);
2346 auto IID = llvm_map_to_intrinsic_id(ID);
2347 return wrap(llvm::Intrinsic::getDeclaration(unwrap(Mod), IID, Tys));
2348}
2349
2350const char *LLVMIntrinsicGetName(unsigned ID, size_t *NameLength) {
2351 auto IID = llvm_map_to_intrinsic_id(ID);
2352 auto Str = llvm::Intrinsic::getName(IID);
2353 *NameLength = Str.size();
2354 return Str.data();
2355}
2356
2358 LLVMTypeRef *ParamTypes, size_t ParamCount) {
2359 auto IID = llvm_map_to_intrinsic_id(ID);
2360 ArrayRef<Type*> Tys(unwrap(ParamTypes), ParamCount);
2361 return wrap(llvm::Intrinsic::getType(*unwrap(Ctx), IID, Tys));
2362}
2363
2365 LLVMTypeRef *ParamTypes,
2366 size_t ParamCount,
2367 size_t *NameLength) {
2368 auto IID = llvm_map_to_intrinsic_id(ID);
2369 ArrayRef<Type*> Tys(unwrap(ParamTypes), ParamCount);
2370 auto Str = llvm::Intrinsic::getNameNoUnnamedTypes(IID, Tys);
2371 *NameLength = Str.length();
2372 return strdup(Str.c_str());
2373}
2374
2376 LLVMTypeRef *ParamTypes,
2377 size_t ParamCount,
2378 size_t *NameLength) {
2379 auto IID = llvm_map_to_intrinsic_id(ID);
2380 ArrayRef<Type *> Tys(unwrap(ParamTypes), ParamCount);
2381 auto Str = llvm::Intrinsic::getName(IID, Tys, unwrap(Mod));
2382 *NameLength = Str.length();
2383 return strdup(Str.c_str());
2384}
2385
2386unsigned LLVMLookupIntrinsicID(const char *Name, size_t NameLen) {
2387 return Function::lookupIntrinsicID({Name, NameLen});
2388}
2389
2391 auto IID = llvm_map_to_intrinsic_id(ID);
2393}
2394
2396 return unwrap<Function>(Fn)->getCallingConv();
2397}
2398
2400 return unwrap<Function>(Fn)->setCallingConv(
2401 static_cast<CallingConv::ID>(CC));
2402}
2403
2404const char *LLVMGetGC(LLVMValueRef Fn) {
2405 Function *F = unwrap<Function>(Fn);
2406 return F->hasGC()? F->getGC().c_str() : nullptr;
2407}
2408
2409void LLVMSetGC(LLVMValueRef Fn, const char *GC) {
2410 Function *F = unwrap<Function>(Fn);
2411 if (GC)
2412 F->setGC(GC);
2413 else
2414 F->clearGC();
2415}
2416
2419 unwrap<Function>(F)->addAttributeAtIndex(Idx, unwrap(A));
2420}
2421
2423 auto AS = unwrap<Function>(F)->getAttributes().getAttributes(Idx);
2424 return AS.getNumAttributes();
2425}
2426
2428 LLVMAttributeRef *Attrs) {
2429 auto AS = unwrap<Function>(F)->getAttributes().getAttributes(Idx);
2430 for (auto A : AS)
2431 *Attrs++ = wrap(A);
2432}
2433
2436 unsigned KindID) {
2437 return wrap(unwrap<Function>(F)->getAttributeAtIndex(
2438 Idx, (Attribute::AttrKind)KindID));
2439}
2440
2443 const char *K, unsigned KLen) {
2444 return wrap(
2445 unwrap<Function>(F)->getAttributeAtIndex(Idx, StringRef(K, KLen)));
2446}
2447
2449 unsigned KindID) {
2450 unwrap<Function>(F)->removeAttributeAtIndex(Idx, (Attribute::AttrKind)KindID);
2451}
2452
2454 const char *K, unsigned KLen) {
2455 unwrap<Function>(F)->removeAttributeAtIndex(Idx, StringRef(K, KLen));
2456}
2457
2459 const char *V) {
2460 Function *Func = unwrap<Function>(Fn);
2461 Attribute Attr = Attribute::get(Func->getContext(), A, V);
2462 Func->addFnAttr(Attr);
2463}
2464
2465/*--.. Operations on parameters ............................................--*/
2466
2468 // This function is strictly redundant to
2469 // LLVMCountParamTypes(LLVMGlobalGetValueType(FnRef))
2470 return unwrap<Function>(FnRef)->arg_size();
2471}
2472
2473void LLVMGetParams(LLVMValueRef FnRef, LLVMValueRef *ParamRefs) {
2474 Function *Fn = unwrap<Function>(FnRef);
2475 for (Argument &A : Fn->args())
2476 *ParamRefs++ = wrap(&A);
2477}
2478
2480 Function *Fn = unwrap<Function>(FnRef);
2481 return wrap(&Fn->arg_begin()[index]);
2482}
2483
2485 return wrap(unwrap<Argument>(V)->getParent());
2486}
2487
2489 Function *Func = unwrap<Function>(Fn);
2490 Function::arg_iterator I = Func->arg_begin();
2491 if (I == Func->arg_end())
2492 return nullptr;
2493 return wrap(&*I);
2494}
2495
2497 Function *Func = unwrap<Function>(Fn);
2498 Function::arg_iterator I = Func->arg_end();
2499 if (I == Func->arg_begin())
2500 return nullptr;
2501 return wrap(&*--I);
2502}
2503
2505 Argument *A = unwrap<Argument>(Arg);
2506 Function *Fn = A->getParent();
2507 if (A->getArgNo() + 1 >= Fn->arg_size())
2508 return nullptr;
2509 return wrap(&Fn->arg_begin()[A->getArgNo() + 1]);
2510}
2511
2513 Argument *A = unwrap<Argument>(Arg);
2514 if (A->getArgNo() == 0)
2515 return nullptr;
2516 return wrap(&A->getParent()->arg_begin()[A->getArgNo() - 1]);
2517}
2518
2519void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align) {
2520 Argument *A = unwrap<Argument>(Arg);
2521 A->addAttr(Attribute::getWithAlignment(A->getContext(), Align(align)));
2522}
2523
2524/*--.. Operations on ifuncs ................................................--*/
2525
2527 const char *Name, size_t NameLen,
2528 LLVMTypeRef Ty, unsigned AddrSpace,
2530 return wrap(GlobalIFunc::create(unwrap(Ty), AddrSpace,
2532 StringRef(Name, NameLen),
2533 unwrap<Constant>(Resolver), unwrap(M)));
2534}
2535
2537 const char *Name, size_t NameLen) {
2538 return wrap(unwrap(M)->getNamedIFunc(StringRef(Name, NameLen)));
2539}
2540
2542 Module *Mod = unwrap(M);
2544 if (I == Mod->ifunc_end())
2545 return nullptr;
2546 return wrap(&*I);
2547}
2548
2550 Module *Mod = unwrap(M);
2552 if (I == Mod->ifunc_begin())
2553 return nullptr;
2554 return wrap(&*--I);
2555}
2556
2558 GlobalIFunc *GIF = unwrap<GlobalIFunc>(IFunc);
2560 if (++I == GIF->getParent()->ifunc_end())
2561 return nullptr;
2562 return wrap(&*I);
2563}
2564
2566 GlobalIFunc *GIF = unwrap<GlobalIFunc>(IFunc);
2568 if (I == GIF->getParent()->ifunc_begin())
2569 return nullptr;
2570 return wrap(&*--I);
2571}
2572
2574 return wrap(unwrap<GlobalIFunc>(IFunc)->getResolver());
2575}
2576
2578 unwrap<GlobalIFunc>(IFunc)->setResolver(unwrap<Constant>(Resolver));
2579}
2580
2582 unwrap<GlobalIFunc>(IFunc)->eraseFromParent();
2583}
2584
2586 unwrap<GlobalIFunc>(IFunc)->removeFromParent();
2587}
2588
2589/*--.. Operations on operand bundles........................................--*/
2590
2592 LLVMValueRef *Args,
2593 unsigned NumArgs) {
2594 return wrap(new OperandBundleDef(std::string(Tag, TagLen),
2595 ArrayRef(unwrap(Args), NumArgs)));
2596}
2597
2599 delete unwrap(Bundle);
2600}
2601
2602const char *LLVMGetOperandBundleTag(LLVMOperandBundleRef Bundle, size_t *Len) {
2603 StringRef Str = unwrap(Bundle)->getTag();
2604 *Len = Str.size();
2605 return Str.data();
2606}
2607
2609 return unwrap(Bundle)->inputs().size();
2610}
2611
2613 unsigned Index) {
2614 return wrap(unwrap(Bundle)->inputs()[Index]);
2615}
2616
2617/*--.. Operations on basic blocks ..........................................--*/
2618
2620 return wrap(static_cast<Value*>(unwrap(BB)));
2621}
2622
2624 return isa<BasicBlock>(unwrap(Val));
2625}
2626
2628 return wrap(unwrap<BasicBlock>(Val));
2629}
2630
2632 return unwrap(BB)->getName().data();
2633}
2634
2636 return wrap(unwrap(BB)->getParent());
2637}
2638
2640 return wrap(unwrap(BB)->getTerminator());
2641}
2642
2644 return unwrap<Function>(FnRef)->size();
2645}
2646
2648 Function *Fn = unwrap<Function>(FnRef);
2649 for (BasicBlock &BB : *Fn)
2650 *BasicBlocksRefs++ = wrap(&BB);
2651}
2652
2654 return wrap(&unwrap<Function>(Fn)->getEntryBlock());
2655}
2656
2658 Function *Func = unwrap<Function>(Fn);
2659 Function::iterator I = Func->begin();
2660 if (I == Func->end())
2661 return nullptr;
2662 return wrap(&*I);
2663}
2664
2666 Function *Func = unwrap<Function>(Fn);
2667 Function::iterator I = Func->end();
2668 if (I == Func->begin())
2669 return nullptr;
2670 return wrap(&*--I);
2671}
2672
2674 BasicBlock *Block = unwrap(BB);
2676 if (++I == Block->getParent()->end())
2677 return nullptr;
2678 return wrap(&*I);
2679}
2680
2682 BasicBlock *Block = unwrap(BB);
2684 if (I == Block->getParent()->begin())
2685 return nullptr;
2686 return wrap(&*--I);
2687}
2688
2690 const char *Name) {
2692}
2693
2695 LLVMBasicBlockRef BB) {
2696 BasicBlock *ToInsert = unwrap(BB);
2697 BasicBlock *CurBB = unwrap(Builder)->GetInsertBlock();
2698 assert(CurBB && "current insertion point is invalid!");
2699 CurBB->getParent()->insert(std::next(CurBB->getIterator()), ToInsert);
2700}
2701
2703 LLVMBasicBlockRef BB) {
2704 unwrap<Function>(Fn)->insert(unwrap<Function>(Fn)->end(), unwrap(BB));
2705}
2706
2708 LLVMValueRef FnRef,
2709 const char *Name) {
2710 return wrap(BasicBlock::Create(*unwrap(C), Name, unwrap<Function>(FnRef)));
2711}
2712
2715}
2716
2718 LLVMBasicBlockRef BBRef,
2719 const char *Name) {
2720 BasicBlock *BB = unwrap(BBRef);
2721 return wrap(BasicBlock::Create(*unwrap(C), Name, BB->getParent(), BB));
2722}
2723
2725 const char *Name) {
2727}
2728
2730 unwrap(BBRef)->eraseFromParent();
2731}
2732
2734 unwrap(BBRef)->removeFromParent();
2735}
2736
2738 unwrap(BB)->moveBefore(unwrap(MovePos));
2739}
2740
2742 unwrap(BB)->moveAfter(unwrap(MovePos));
2743}
2744
2745/*--.. Operations on instructions ..........................................--*/
2746
2748 return wrap(unwrap<Instruction>(Inst)->getParent());
2749}
2750
2752 BasicBlock *Block = unwrap(BB);
2753 BasicBlock::iterator I = Block->begin();
2754 if (I == Block->end())
2755 return nullptr;
2756 return wrap(&*I);
2757}
2758
2760 BasicBlock *Block = unwrap(BB);
2761 BasicBlock::iterator I = Block->end();
2762 if (I == Block->begin())
2763 return nullptr;
2764 return wrap(&*--I);
2765}
2766
2768 Instruction *Instr = unwrap<Instruction>(Inst);
2769 BasicBlock::iterator I(Instr);
2770 if (++I == Instr->getParent()->end())
2771 return nullptr;
2772 return wrap(&*I);
2773}
2774
2776 Instruction *Instr = unwrap<Instruction>(Inst);
2777 BasicBlock::iterator I(Instr);
2778 if (I == Instr->getParent()->begin())
2779 return nullptr;
2780 return wrap(&*--I);
2781}
2782
2784 unwrap<Instruction>(Inst)->removeFromParent();
2785}
2786
2788 unwrap<Instruction>(Inst)->eraseFromParent();
2789}
2790
2792 unwrap<Instruction>(Inst)->deleteValue();
2793}
2794
2796 if (ICmpInst *I = dyn_cast<ICmpInst>(unwrap(Inst)))
2797 return (LLVMIntPredicate)I->getPredicate();
2798 if (ConstantExpr *CE = dyn_cast<ConstantExpr>(unwrap(Inst)))
2799 if (CE->getOpcode() == Instruction::ICmp)
2800 return (LLVMIntPredicate)CE->getPredicate();
2801 return (LLVMIntPredicate)0;
2802}
2803
2805 if (FCmpInst *I = dyn_cast<FCmpInst>(unwrap(Inst)))
2806 return (LLVMRealPredicate)I->getPredicate();
2807 if (ConstantExpr *CE = dyn_cast<ConstantExpr>(unwrap(Inst)))
2808 if (CE->getOpcode() == Instruction::FCmp)
2809 return (LLVMRealPredicate)CE->getPredicate();
2810 return (LLVMRealPredicate)0;
2811}
2812
2814 if (Instruction *C = dyn_cast<Instruction>(unwrap(Inst)))
2815 return map_to_llvmopcode(C->getOpcode());
2816 return (LLVMOpcode)0;
2817}
2818
2820 if (Instruction *C = dyn_cast<Instruction>(unwrap(Inst)))
2821 return wrap(C->clone());
2822 return nullptr;
2823}
2824
2826 Instruction *I = dyn_cast<Instruction>(unwrap(Inst));
2827 return (I && I->isTerminator()) ? wrap(I) : nullptr;
2828}
2829
2831 if (FuncletPadInst *FPI = dyn_cast<FuncletPadInst>(unwrap(Instr))) {
2832 return FPI->arg_size();
2833 }
2834 return unwrap<CallBase>(Instr)->arg_size();
2835}
2836
2837/*--.. Call and invoke instructions ........................................--*/
2838
2840 return unwrap<CallBase>(Instr)->getCallingConv();
2841}
2842
2844 return unwrap<CallBase>(Instr)->setCallingConv(
2845 static_cast<CallingConv::ID>(CC));
2846}
2847
2849 unsigned align) {
2850 auto *Call = unwrap<CallBase>(Instr);
2851 Attribute AlignAttr =
2852 Attribute::getWithAlignment(Call->getContext(), Align(align));
2853 Call->addAttributeAtIndex(Idx, AlignAttr);
2854}
2855
2858 unwrap<CallBase>(C)->addAttributeAtIndex(Idx, unwrap(A));
2859}
2860
2863 auto *Call = unwrap<CallBase>(C);
2864 auto AS = Call->getAttributes().getAttributes(Idx);
2865 return AS.getNumAttributes();
2866}
2867
2869 LLVMAttributeRef *Attrs) {
2870 auto *Call = unwrap<CallBase>(C);
2871 auto AS = Call->getAttributes().getAttributes(Idx);
2872 for (auto A : AS)
2873 *Attrs++ = wrap(A);
2874}
2875
2878 unsigned KindID) {
2879 return wrap(unwrap<CallBase>(C)->getAttributeAtIndex(
2880 Idx, (Attribute::AttrKind)KindID));
2881}
2882
2885 const char *K, unsigned KLen) {
2886 return wrap(
2887 unwrap<CallBase>(C)->getAttributeAtIndex(Idx, StringRef(K, KLen)));
2888}
2889
2891 unsigned KindID) {
2892 unwrap<CallBase>(C)->removeAttributeAtIndex(Idx, (Attribute::AttrKind)KindID);
2893}
2894
2896 const char *K, unsigned KLen) {
2897 unwrap<CallBase>(C)->removeAttributeAtIndex(Idx, StringRef(K, KLen));
2898}
2899
2901 return wrap(unwrap<CallBase>(Instr)->getCalledOperand());
2902}
2903
2905 return wrap(unwrap<CallBase>(Instr)->getFunctionType());
2906}
2907
2909 return unwrap<CallBase>(C)->getNumOperandBundles();
2910}
2911
2913 unsigned Index) {
2914 return wrap(
2915 new OperandBundleDef(unwrap<CallBase>(C)->getOperandBundleAt(Index)));
2916}
2917
2918/*--.. Operations on call instructions (only) ..............................--*/
2919
2921 return unwrap<CallInst>(Call)->isTailCall();
2922}
2923
2924void LLVMSetTailCall(LLVMValueRef Call, LLVMBool isTailCall) {
2925 unwrap<CallInst>(Call)->setTailCall(isTailCall);
2926}
2927
2929 return (LLVMTailCallKind)unwrap<CallInst>(Call)->getTailCallKind();
2930}
2931
2933 unwrap<CallInst>(Call)->setTailCallKind((CallInst::TailCallKind)kind);
2934}
2935
2936/*--.. Operations on invoke instructions (only) ............................--*/
2937
2939 return wrap(unwrap<InvokeInst>(Invoke)->getNormalDest());
2940}
2941
2943 if (CleanupReturnInst *CRI = dyn_cast<CleanupReturnInst>(unwrap(Invoke))) {
2944 return wrap(CRI->getUnwindDest());
2945 } else if (CatchSwitchInst *CSI = dyn_cast<CatchSwitchInst>(unwrap(Invoke))) {
2946 return wrap(CSI->getUnwindDest());
2947 }
2948 return wrap(unwrap<InvokeInst>(Invoke)->getUnwindDest());
2949}
2950
2952 unwrap<InvokeInst>(Invoke)->setNormalDest(unwrap(B));
2953}
2954
2956 if (CleanupReturnInst *CRI = dyn_cast<CleanupReturnInst>(unwrap(Invoke))) {
2957 return CRI->setUnwindDest(unwrap(B));
2958 } else if (CatchSwitchInst *CSI = dyn_cast<CatchSwitchInst>(unwrap(Invoke))) {
2959 return CSI->setUnwindDest(unwrap(B));
2960 }
2961 unwrap<InvokeInst>(Invoke)->setUnwindDest(unwrap(B));
2962}
2963
2964/*--.. Operations on terminators ...........................................--*/
2965
2967 return unwrap<Instruction>(Term)->getNumSuccessors();
2968}
2969
2971 return wrap(unwrap<Instruction>(Term)->getSuccessor(i));
2972}
2973
2975 return unwrap<Instruction>(Term)->setSuccessor(i, unwrap(block));
2976}
2977
2978/*--.. Operations on branch instructions (only) ............................--*/
2979
2981 return unwrap<BranchInst>(Branch)->isConditional();
2982}
2983
2985 return wrap(unwrap<BranchInst>(Branch)->getCondition());
2986}
2987
2989 return unwrap<BranchInst>(Branch)->setCondition(unwrap(Cond));
2990}
2991
2992/*--.. Operations on switch instructions (only) ............................--*/
2993
2995 return wrap(unwrap<SwitchInst>(Switch)->getDefaultDest());
2996}
2997
2998/*--.. Operations on alloca instructions (only) ............................--*/
2999
3001 return wrap(unwrap<AllocaInst>(Alloca)->getAllocatedType());
3002}
3003
3004/*--.. Operations on gep instructions (only) ...............................--*/
3005
3007 return unwrap<GEPOperator>(GEP)->isInBounds();
3008}
3009
3011 return unwrap<GetElementPtrInst>(GEP)->setIsInBounds(InBounds);
3012}
3013
3015 return wrap(unwrap<GEPOperator>(GEP)->getSourceElementType());
3016}
3017
3018/*--.. Operations on phi nodes .............................................--*/
3019
3020void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues,
3021 LLVMBasicBlockRef *IncomingBlocks, unsigned Count) {
3022 PHINode *PhiVal = unwrap<PHINode>(PhiNode);
3023 for (unsigned I = 0; I != Count; ++I)
3024 PhiVal->addIncoming(unwrap(IncomingValues[I]), unwrap(IncomingBlocks[I]));
3025}
3026
3028 return unwrap<PHINode>(PhiNode)->getNumIncomingValues();
3029}
3030
3032 return wrap(unwrap<PHINode>(PhiNode)->getIncomingValue(Index));
3033}
3034
3036 return wrap(unwrap<PHINode>(PhiNode)->getIncomingBlock(Index));
3037}
3038
3039/*--.. Operations on extractvalue and insertvalue nodes ....................--*/
3040
3042 auto *I = unwrap(Inst);
3043 if (auto *GEP = dyn_cast<GEPOperator>(I))
3044 return GEP->getNumIndices();
3045 if (auto *EV = dyn_cast<ExtractValueInst>(I))
3046 return EV->getNumIndices();
3047 if (auto *IV = dyn_cast<InsertValueInst>(I))
3048 return IV->getNumIndices();
3050 "LLVMGetNumIndices applies only to extractvalue and insertvalue!");
3051}
3052
3053const unsigned *LLVMGetIndices(LLVMValueRef Inst) {
3054 auto *I = unwrap(Inst);
3055 if (auto *EV = dyn_cast<ExtractValueInst>(I))
3056 return EV->getIndices().data();
3057 if (auto *IV = dyn_cast<InsertValueInst>(I))
3058 return IV->getIndices().data();
3060 "LLVMGetIndices applies only to extractvalue and insertvalue!");
3061}
3062
3063
3064/*===-- Instruction builders ----------------------------------------------===*/
3065
3067 return wrap(new IRBuilder<>(*unwrap(C)));
3068}
3069
3072}
3073
3075 LLVMValueRef Instr) {
3076 BasicBlock *BB = unwrap(Block);
3077 auto I = Instr ? unwrap<Instruction>(Instr)->getIterator() : BB->end();
3078 unwrap(Builder)->SetInsertPoint(BB, I);
3079}
3080
3082 Instruction *I = unwrap<Instruction>(Instr);
3083 unwrap(Builder)->SetInsertPoint(I->getParent(), I->getIterator());
3084}
3085
3087 BasicBlock *BB = unwrap(Block);
3088 unwrap(Builder)->SetInsertPoint(BB);
3089}
3090
3092 return wrap(unwrap(Builder)->GetInsertBlock());
3093}
3094
3096 unwrap(Builder)->ClearInsertionPoint();
3097}
3098
3100 unwrap(Builder)->Insert(unwrap<Instruction>(Instr));
3101}
3102
3104 const char *Name) {
3105 unwrap(Builder)->Insert(unwrap<Instruction>(Instr), Name);
3106}
3107
3109 delete unwrap(Builder);
3110}
3111
3112/*--.. Metadata builders ...................................................--*/
3113
3115 return wrap(unwrap(Builder)->getCurrentDebugLocation().getAsMDNode());
3116}
3117
3119 if (Loc)
3120 unwrap(Builder)->SetCurrentDebugLocation(DebugLoc(unwrap<MDNode>(Loc)));
3121 else
3122 unwrap(Builder)->SetCurrentDebugLocation(DebugLoc());
3123}
3124
3126 MDNode *Loc =
3127 L ? cast<MDNode>(unwrap<MetadataAsValue>(L)->getMetadata()) : nullptr;
3128 unwrap(Builder)->SetCurrentDebugLocation(DebugLoc(Loc));
3129}
3130
3132 LLVMContext &Context = unwrap(Builder)->getContext();
3134 Context, unwrap(Builder)->getCurrentDebugLocation().getAsMDNode()));
3135}
3136
3138 unwrap(Builder)->SetInstDebugLocation(unwrap<Instruction>(Inst));
3139}
3140
3142 unwrap(Builder)->AddMetadataToInst(unwrap<Instruction>(Inst));
3143}
3144
3146 LLVMMetadataRef FPMathTag) {
3147
3148 unwrap(Builder)->setDefaultFPMathTag(FPMathTag
3149 ? unwrap<MDNode>(FPMathTag)
3150 : nullptr);
3151}
3152
3154 return wrap(unwrap(Builder)->getDefaultFPMathTag());
3155}
3156
3157/*--.. Instruction builders ................................................--*/
3158
3160 return wrap(unwrap(B)->CreateRetVoid());
3161}
3162
3164 return wrap(unwrap(B)->CreateRet(unwrap(V)));
3165}
3166
3168 unsigned N) {
3169 return wrap(unwrap(B)->CreateAggregateRet(unwrap(RetVals), N));
3170}
3171
3173 return wrap(unwrap(B)->CreateBr(unwrap(Dest)));
3174}
3175
3178 return wrap(unwrap(B)->CreateCondBr(unwrap(If), unwrap(Then), unwrap(Else)));
3179}
3180
3182 LLVMBasicBlockRef Else, unsigned NumCases) {
3183 return wrap(unwrap(B)->CreateSwitch(unwrap(V), unwrap(Else), NumCases));
3184}
3185
3187 unsigned NumDests) {
3188 return wrap(unwrap(B)->CreateIndirectBr(unwrap(Addr), NumDests));
3189}
3190
3192 LLVMValueRef *Args, unsigned NumArgs,
3194 const char *Name) {
3195 return wrap(unwrap(B)->CreateInvoke(unwrap<FunctionType>(Ty), unwrap(Fn),
3196 unwrap(Then), unwrap(Catch),
3197 ArrayRef(unwrap(Args), NumArgs), Name));
3198}
3199
3202 unsigned NumArgs, LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch,
3203 LLVMOperandBundleRef *Bundles, unsigned NumBundles, const char *Name) {
3205 for (auto *Bundle : ArrayRef(Bundles, NumBundles)) {
3206 OperandBundleDef *OB = unwrap(Bundle);
3207 OBs.push_back(*OB);
3208 }
3209 return wrap(unwrap(B)->CreateInvoke(
3210 unwrap<FunctionType>(Ty), unwrap(Fn), unwrap(Then), unwrap(Catch),
3211 ArrayRef(unwrap(Args), NumArgs), OBs, Name));
3212}
3213
3215 LLVMValueRef PersFn, unsigned NumClauses,
3216 const char *Name) {
3217 // The personality used to live on the landingpad instruction, but now it
3218 // lives on the parent function. For compatibility, take the provided
3219 // personality and put it on the parent function.
3220 if (PersFn)
3221 unwrap(B)->GetInsertBlock()->getParent()->setPersonalityFn(
3222 unwrap<Function>(PersFn));
3223 return wrap(unwrap(B)->CreateLandingPad(unwrap(Ty), NumClauses, Name));
3224}
3225
3227 LLVMValueRef *Args, unsigned NumArgs,
3228 const char *Name) {
3229 return wrap(unwrap(B)->CreateCatchPad(unwrap(ParentPad),
3230 ArrayRef(unwrap(Args), NumArgs), Name));
3231}
3232
3234 LLVMValueRef *Args, unsigned NumArgs,
3235 const char *Name) {
3236 if (ParentPad == nullptr) {
3237 Type *Ty = Type::getTokenTy(unwrap(B)->getContext());
3238 ParentPad = wrap(Constant::getNullValue(Ty));
3239 }
3240 return wrap(unwrap(B)->CreateCleanupPad(
3241 unwrap(ParentPad), ArrayRef(unwrap(Args), NumArgs), Name));
3242}
3243
3245 return wrap(unwrap(B)->CreateResume(unwrap(Exn)));
3246}
3247
3249 LLVMBasicBlockRef UnwindBB,
3250 unsigned NumHandlers, const char *Name) {
3251 if (ParentPad == nullptr) {
3252 Type *Ty = Type::getTokenTy(unwrap(B)->getContext());
3253 ParentPad = wrap(Constant::getNullValue(Ty));
3254 }
3255 return wrap(unwrap(B)->CreateCatchSwitch(unwrap(ParentPad), unwrap(UnwindBB),
3256 NumHandlers, Name));
3257}
3258
3260 LLVMBasicBlockRef BB) {
3261 return wrap(unwrap(B)->CreateCatchRet(unwrap<CatchPadInst>(CatchPad),
3262 unwrap(BB)));
3263}
3264
3266 LLVMBasicBlockRef BB) {
3267 return wrap(unwrap(B)->CreateCleanupRet(unwrap<CleanupPadInst>(CatchPad),
3268 unwrap(BB)));
3269}
3270
3272 return wrap(unwrap(B)->CreateUnreachable());
3273}
3274
3276 LLVMBasicBlockRef Dest) {
3277 unwrap<SwitchInst>(Switch)->addCase(unwrap<ConstantInt>(OnVal), unwrap(Dest));
3278}
3279
3281 unwrap<IndirectBrInst>(IndirectBr)->addDestination(unwrap(Dest));
3282}
3283
3284unsigned LLVMGetNumClauses(LLVMValueRef LandingPad) {
3285 return unwrap<LandingPadInst>(LandingPad)->getNumClauses();
3286}
3287
3289 return wrap(unwrap<LandingPadInst>(LandingPad)->getClause(Idx));
3290}
3291
3293 unwrap<LandingPadInst>(LandingPad)->addClause(unwrap<Constant>(ClauseVal));
3294}
3295
3297 return unwrap<LandingPadInst>(LandingPad)->isCleanup();
3298}
3299
3300void LLVMSetCleanup(LLVMValueRef LandingPad, LLVMBool Val) {
3301 unwrap<LandingPadInst>(LandingPad)->setCleanup(Val);
3302}
3303
3305 unwrap<CatchSwitchInst>(CatchSwitch)->addHandler(unwrap(Dest));
3306}
3307
3308unsigned LLVMGetNumHandlers(LLVMValueRef CatchSwitch) {
3309 return unwrap<CatchSwitchInst>(CatchSwitch)->getNumHandlers();
3310}
3311
3312void LLVMGetHandlers(LLVMValueRef CatchSwitch, LLVMBasicBlockRef *Handlers) {
3313 CatchSwitchInst *CSI = unwrap<CatchSwitchInst>(CatchSwitch);
3314 for (const BasicBlock *H : CSI->handlers())
3315 *Handlers++ = wrap(H);
3316}
3317
3319 return wrap(unwrap<CatchPadInst>(CatchPad)->getCatchSwitch());
3320}
3321
3323 unwrap<CatchPadInst>(CatchPad)
3324 ->setCatchSwitch(unwrap<CatchSwitchInst>(CatchSwitch));
3325}
3326
3327/*--.. Funclets ...........................................................--*/
3328
3330 return wrap(unwrap<FuncletPadInst>(Funclet)->getArgOperand(i));
3331}
3332
3334 unwrap<FuncletPadInst>(Funclet)->setArgOperand(i, unwrap(value));
3335}
3336
3337/*--.. Arithmetic ..........................................................--*/
3338
3340 FastMathFlags NewFMF;
3341 NewFMF.setAllowReassoc((FMF & LLVMFastMathAllowReassoc) != 0);
3342 NewFMF.setNoNaNs((FMF & LLVMFastMathNoNaNs) != 0);
3343 NewFMF.setNoInfs((FMF & LLVMFastMathNoInfs) != 0);
3344 NewFMF.setNoSignedZeros((FMF & LLVMFastMathNoSignedZeros) != 0);
3346 NewFMF.setAllowContract((FMF & LLVMFastMathAllowContract) != 0);
3347 NewFMF.setApproxFunc((FMF & LLVMFastMathApproxFunc) != 0);
3348
3349 return NewFMF;
3350}
3351
3354 if (FMF.allowReassoc())
3355 NewFMF |= LLVMFastMathAllowReassoc;
3356 if (FMF.noNaNs())
3357 NewFMF |= LLVMFastMathNoNaNs;
3358 if (FMF.noInfs())
3359 NewFMF |= LLVMFastMathNoInfs;
3360 if (FMF.noSignedZeros())
3361 NewFMF |= LLVMFastMathNoSignedZeros;
3362 if (FMF.allowReciprocal())
3364 if (FMF.allowContract())
3365 NewFMF |= LLVMFastMathAllowContract;
3366 if (FMF.approxFunc())
3367 NewFMF |= LLVMFastMathApproxFunc;
3368
3369 return NewFMF;
3370}
3371
3373 const char *Name) {
3374 return wrap(unwrap(B)->CreateAdd(unwrap(LHS), unwrap(RHS), Name));
3375}
3376
3378 const char *Name) {
3379 return wrap(unwrap(B)->CreateNSWAdd(unwrap(LHS), unwrap(RHS), Name));
3380}
3381
3383 const char *Name) {
3384 return wrap(unwrap(B)->CreateNUWAdd(unwrap(LHS), unwrap(RHS), Name));
3385}
3386
3388 const char *Name) {
3389 return wrap(unwrap(B)->CreateFAdd(unwrap(LHS), unwrap(RHS), Name));
3390}
3391
3393 const char *Name) {
3394 return wrap(unwrap(B)->CreateSub(unwrap(LHS), unwrap(RHS), Name));
3395}
3396
3398 const char *Name) {
3399 return wrap(unwrap(B)->CreateNSWSub(unwrap(LHS), unwrap(RHS), Name));
3400}
3401
3403 const char *Name) {
3404 return wrap(unwrap(B)->CreateNUWSub(unwrap(LHS), unwrap(RHS), Name));
3405}
3406
3408 const char *Name) {
3409 return wrap(unwrap(B)->CreateFSub(unwrap(LHS), unwrap(RHS), Name));
3410}
3411
3413 const char *Name) {
3414 return wrap(unwrap(B)->CreateMul(unwrap(LHS), unwrap(RHS), Name));
3415}
3416
3418 const char *Name) {
3419 return wrap(unwrap(B)->CreateNSWMul(unwrap(LHS), unwrap(RHS), Name));
3420}
3421
3423 const char *Name) {
3424 return wrap(unwrap(B)->CreateNUWMul(unwrap(LHS), unwrap(RHS), Name));
3425}
3426
3428 const char *Name) {
3429 return wrap(unwrap(B)->CreateFMul(unwrap(LHS), unwrap(RHS), Name));
3430}
3431
3433 const char *Name) {
3434 return wrap(unwrap(B)->CreateUDiv(unwrap(LHS), unwrap(RHS), Name));
3435}
3436
3438 LLVMValueRef RHS, const char *Name) {
3439 return wrap(unwrap(B)->CreateExactUDiv(unwrap(LHS), unwrap(RHS), Name));
3440}
3441
3443 const char *Name) {
3444 return wrap(unwrap(B)->CreateSDiv(unwrap(LHS), unwrap(RHS), Name));
3445}
3446
3448 LLVMValueRef RHS, const char *Name) {
3449 return wrap(unwrap(B)->CreateExactSDiv(unwrap(LHS), unwrap(RHS), Name));
3450}
3451
3453 const char *Name) {
3454 return wrap(unwrap(B)->CreateFDiv(unwrap(LHS), unwrap(RHS), Name));
3455}
3456
3458 const char *Name) {
3459 return wrap(unwrap(B)->CreateURem(unwrap(LHS), unwrap(RHS), Name));
3460}
3461
3463 const char *Name) {
3464 return wrap(unwrap(B)->CreateSRem(unwrap(LHS), unwrap(RHS), Name));
3465}
3466
3468 const char *Name) {
3469 return wrap(unwrap(B)->CreateFRem(unwrap(LHS), unwrap(RHS), Name));
3470}
3471
3473 const char *Name) {
3474 return wrap(unwrap(B)->CreateShl(unwrap(LHS), unwrap(RHS), Name));
3475}
3476
3478 const char *Name) {
3479 return wrap(unwrap(B)->CreateLShr(unwrap(LHS), unwrap(RHS), Name));
3480}
3481
3483 const char *Name) {
3484 return wrap(unwrap(B)->CreateAShr(unwrap(LHS), unwrap(RHS), Name));
3485}
3486
3488 const char *Name) {
3489 return wrap(unwrap(B)->CreateAnd(unwrap(LHS), unwrap(RHS), Name));
3490}
3491
3493 const char *Name) {
3494 return wrap(unwrap(B)->CreateOr(unwrap(LHS), unwrap(RHS), Name));
3495}
3496
3498 const char *Name) {
3499 return wrap(unwrap(B)->CreateXor(unwrap(LHS), unwrap(RHS), Name));
3500}
3501
3503 LLVMValueRef LHS, LLVMValueRef RHS,
3504 const char *Name) {
3506 unwrap(RHS), Name));
3507}
3508
3510 return wrap(unwrap(B)->CreateNeg(unwrap(V), Name));
3511}
3512
3514 const char *Name) {
3515 return wrap(unwrap(B)->CreateNSWNeg(unwrap(V), Name));
3516}
3517
3519 const char *Name) {
3520 return wrap(unwrap(B)->CreateNUWNeg(unwrap(V), Name));
3521}
3522
3524 return wrap(unwrap(B)->CreateFNeg(unwrap(V), Name));
3525}
3526
3528 return wrap(unwrap(B)->CreateNot(unwrap(V), Name));
3529}
3530
3532 Value *P = unwrap<Value>(ArithInst);
3533 return cast<Instruction>(P)->hasNoUnsignedWrap();
3534}
3535
3536void LLVMSetNUW(LLVMValueRef ArithInst, LLVMBool HasNUW) {
3537 Value *P = unwrap<Value>(ArithInst);
3538 cast<Instruction>(P)->setHasNoUnsignedWrap(HasNUW);
3539}
3540
3542 Value *P = unwrap<Value>(ArithInst);
3543 return cast<Instruction>(P)->hasNoSignedWrap();
3544}
3545
3546void LLVMSetNSW(LLVMValueRef ArithInst, LLVMBool HasNSW) {
3547 Value *P = unwrap<Value>(ArithInst);
3548 cast<Instruction>(P)->setHasNoSignedWrap(HasNSW);
3549}
3550
3552 Value *P = unwrap<Value>(DivOrShrInst);
3553 return cast<Instruction>(P)->isExact();
3554}
3555
3556void LLVMSetExact(LLVMValueRef DivOrShrInst, LLVMBool IsExact) {
3557 Value *P = unwrap<Value>(DivOrShrInst);
3558 cast<Instruction>(P)->setIsExact(IsExact);
3559}
3560
3562 Value *P = unwrap<Value>(NonNegInst);
3563 return cast<Instruction>(P)->hasNonNeg();
3564}
3565
3566void LLVMSetNNeg(LLVMValueRef NonNegInst, LLVMBool IsNonNeg) {
3567 Value *P = unwrap<Value>(NonNegInst);
3568 cast<Instruction>(P)->setNonNeg(IsNonNeg);
3569}
3570
3572 Value *P = unwrap<Value>(FPMathInst);
3573 FastMathFlags FMF = cast<Instruction>(P)->getFastMathFlags();
3574 return mapToLLVMFastMathFlags(FMF);
3575}
3576
3578 Value *P = unwrap<Value>(FPMathInst);
3579 cast<Instruction>(P)->setFastMathFlags(mapFromLLVMFastMathFlags(FMF));
3580}
3581
3583 Value *Val = unwrap<Value>(V);
3584 return isa<FPMathOperator>(Val);
3585}
3586
3588 Value *P = unwrap<Value>(Inst);
3589 return cast<PossiblyDisjointInst>(P)->isDisjoint();
3590}
3591
3593 Value *P = unwrap<Value>(Inst);
3594 cast<PossiblyDisjointInst>(P)->setIsDisjoint(IsDisjoint);
3595}
3596
3597/*--.. Memory ..............................................................--*/
3598
3600 const char *Name) {
3601 Type* ITy = Type::getInt32Ty(unwrap(B)->GetInsertBlock()->getContext());
3602 Constant* AllocSize = ConstantExpr::getSizeOf(unwrap(Ty));
3603 AllocSize = ConstantExpr::getTruncOrBitCast(AllocSize, ITy);
3604 return wrap(unwrap(B)->CreateMalloc(ITy, unwrap(Ty), AllocSize, nullptr,
3605 nullptr, Name));
3606}
3607
3609 LLVMValueRef Val, const char *Name) {
3610 Type* ITy = Type::getInt32Ty(unwrap(B)->GetInsertBlock()->getContext());
3611 Constant* AllocSize = ConstantExpr::getSizeOf(unwrap(Ty));
3612 AllocSize = ConstantExpr::getTruncOrBitCast(AllocSize, ITy);
3613 return wrap(unwrap(B)->CreateMalloc(ITy, unwrap(Ty), AllocSize, unwrap(Val),
3614 nullptr, Name));
3615}
3616
3618 LLVMValueRef Val, LLVMValueRef Len,
3619 unsigned Align) {
3620 return wrap(unwrap(B)->CreateMemSet(unwrap(Ptr), unwrap(Val), unwrap(Len),
3621 MaybeAlign(Align)));
3622}
3623
3625 LLVMValueRef Dst, unsigned DstAlign,
3626 LLVMValueRef Src, unsigned SrcAlign,
3628 return wrap(unwrap(B)->CreateMemCpy(unwrap(Dst), MaybeAlign(DstAlign),
3629 unwrap(Src), MaybeAlign(SrcAlign),
3630 unwrap(Size)));
3631}
3632
3634 LLVMValueRef Dst, unsigned DstAlign,
3635 LLVMValueRef Src, unsigned SrcAlign,
3637 return wrap(unwrap(B)->CreateMemMove(unwrap(Dst), MaybeAlign(DstAlign),
3638 unwrap(Src), MaybeAlign(SrcAlign),
3639 unwrap(Size)));
3640}
3641
3643 const char *Name) {
3644 return wrap(unwrap(B)->CreateAlloca(unwrap(Ty), nullptr, Name));
3645}
3646
3648 LLVMValueRef Val, const char *Name) {
3649 return wrap(unwrap(B)->CreateAlloca(unwrap(Ty), unwrap(Val), Name));
3650}
3651
3653 return wrap(unwrap(B)->CreateFree(unwrap(PointerVal)));
3654}
3655
3657 LLVMValueRef PointerVal, const char *Name) {
3658 return wrap(unwrap(B)->CreateLoad(unwrap(Ty), unwrap(PointerVal), Name));
3659}
3660
3662 LLVMValueRef PointerVal) {
3663 return wrap(unwrap(B)->CreateStore(unwrap(Val), unwrap(PointerVal)));
3664}
3665
3667 switch (Ordering) {
3668 case LLVMAtomicOrderingNotAtomic: return AtomicOrdering::NotAtomic;
3669 case LLVMAtomicOrderingUnordered: return AtomicOrdering::Unordered;
3670 case LLVMAtomicOrderingMonotonic: return AtomicOrdering::Monotonic;
3671 case LLVMAtomicOrderingAcquire: return AtomicOrdering::Acquire;
3672 case LLVMAtomicOrderingRelease: return AtomicOrdering::Release;
3674 return AtomicOrdering::AcquireRelease;
3676 return AtomicOrdering::SequentiallyConsistent;
3677 }
3678
3679 llvm_unreachable("Invalid LLVMAtomicOrdering value!");
3680}
3681
3683 switch (Ordering) {
3684 case AtomicOrdering::NotAtomic: return LLVMAtomicOrderingNotAtomic;
3685 case AtomicOrdering::Unordered: return LLVMAtomicOrderingUnordered;
3686 case AtomicOrdering::Monotonic: return LLVMAtomicOrderingMonotonic;
3687 case AtomicOrdering::Acquire: return LLVMAtomicOrderingAcquire;
3688 case AtomicOrdering::Release: return LLVMAtomicOrderingRelease;
3689 case AtomicOrdering::AcquireRelease:
3691 case AtomicOrdering::SequentiallyConsistent:
3693 }
3694
3695 llvm_unreachable("Invalid AtomicOrdering value!");
3696}
3697
3699 switch (BinOp) {
3715 }
3716
3717 llvm_unreachable("Invalid LLVMAtomicRMWBinOp value!");
3718}
3719
3721 switch (BinOp) {
3737 default: break;
3738 }
3739
3740 llvm_unreachable("Invalid AtomicRMWBinOp value!");
3741}
3742
3743// TODO: Should this and other atomic instructions support building with
3744// "syncscope"?
3746 LLVMBool isSingleThread, const char *Name) {
3747 return wrap(
3748 unwrap(B)->CreateFence(mapFromLLVMOrdering(Ordering),
3749 isSingleThread ? SyncScope::SingleThread
3751 Name));
3752}
3753
3755 LLVMValueRef Pointer, LLVMValueRef *Indices,
3756 unsigned NumIndices, const char *Name) {
3757 ArrayRef<Value *> IdxList(unwrap(Indices), NumIndices);
3758 return wrap(unwrap(B)->CreateGEP(unwrap(Ty), unwrap(Pointer), IdxList, Name));
3759}
3760
3762 LLVMValueRef Pointer, LLVMValueRef *Indices,
3763 unsigned NumIndices, const char *Name) {
3764 ArrayRef<Value *> IdxList(unwrap(Indices), NumIndices);
3765 return wrap(
3766 unwrap(B)->CreateInBoundsGEP(unwrap(Ty), unwrap(Pointer), IdxList, Name));
3767}
3768
3770 LLVMValueRef Pointer, unsigned Idx,
3771 const char *Name) {
3772 return wrap(
3773 unwrap(B)->CreateStructGEP(unwrap(Ty), unwrap(Pointer), Idx, Name));
3774}
3775
3777 const char *Name) {
3778 return wrap(unwrap(B)->CreateGlobalString(Str, Name));
3779}
3780
3782 const char *Name) {
3783 return wrap(unwrap(B)->CreateGlobalStringPtr(Str, Name));
3784}
3785
3787 Value *P = unwrap(MemAccessInst);
3788 if (LoadInst *LI = dyn_cast<LoadInst>(P))
3789 return LI->isVolatile();
3790 if (StoreInst *SI = dyn_cast<StoreInst>(P))
3791 return SI->isVolatile();
3792 if (AtomicRMWInst *AI = dyn_cast<AtomicRMWInst>(P))
3793 return AI->isVolatile();
3794 return cast<AtomicCmpXchgInst>(P)->isVolatile();
3795}
3796
3797void LLVMSetVolatile(LLVMValueRef MemAccessInst, LLVMBool isVolatile) {
3798 Value *P = unwrap(MemAccessInst);
3799 if (LoadInst *LI = dyn_cast<LoadInst>(P))
3800 return LI->setVolatile(isVolatile);
3801 if (StoreInst *SI = dyn_cast<StoreInst>(P))
3802 return SI->setVolatile(isVolatile);
3803 if (AtomicRMWInst *AI = dyn_cast<AtomicRMWInst>(P))
3804 return AI->setVolatile(isVolatile);
3805 return cast<AtomicCmpXchgInst>(P)->setVolatile(isVolatile);
3806}
3807
3809 return unwrap<AtomicCmpXchgInst>(CmpXchgInst)->isWeak();
3810}
3811
3812void LLVMSetWeak(LLVMValueRef CmpXchgInst, LLVMBool isWeak) {
3813 return unwrap<AtomicCmpXchgInst>(CmpXchgInst)->setWeak(isWeak);
3814}
3815
3817 Value *P = unwrap(MemAccessInst);
3819 if (LoadInst *LI = dyn_cast<LoadInst>(P))
3820 O = LI->getOrdering();
3821 else if (StoreInst *SI = dyn_cast<StoreInst>(P))
3822 O = SI->getOrdering();
3823 else if (FenceInst *FI = dyn_cast<FenceInst>(P))
3824 O = FI->getOrdering();
3825 else
3826 O = cast<AtomicRMWInst>(P)->getOrdering();
3827 return mapToLLVMOrdering(O);
3828}
3829
3830void LLVMSetOrdering(LLVMValueRef MemAccessInst, LLVMAtomicOrdering Ordering) {
3831 Value *P = unwrap(MemAccessInst);
3832 AtomicOrdering O = mapFromLLVMOrdering(Ordering);
3833
3834 if (LoadInst *LI = dyn_cast<LoadInst>(P))
3835 return LI->setOrdering(O);
3836 else if (FenceInst *FI = dyn_cast<FenceInst>(P))
3837 return FI->setOrdering(O);
3838 else if (AtomicRMWInst *ARWI = dyn_cast<AtomicRMWInst>(P))
3839 return ARWI->setOrdering(O);
3840 return cast<StoreInst>(P)->setOrdering(O);
3841}
3842
3844 return mapToLLVMRMWBinOp(unwrap<AtomicRMWInst>(Inst)->getOperation());
3845}
3846
3848 unwrap<AtomicRMWInst>(Inst)->setOperation(mapFromLLVMRMWBinOp(BinOp));
3849}
3850
3851/*--.. Casts ...............................................................--*/
3852
3854 LLVMTypeRef DestTy, const char *Name) {
3855 return wrap(unwrap(B)->CreateTrunc(unwrap(Val), unwrap(DestTy), Name));
3856}
3857
3859 LLVMTypeRef DestTy, const char *Name) {
3860 return wrap(unwrap(B)->CreateZExt(unwrap(Val), unwrap(DestTy), Name));
3861}
3862
3864 LLVMTypeRef DestTy, const char *Name) {
3865 return wrap(unwrap(B)->CreateSExt(unwrap(Val), unwrap(DestTy), Name));
3866}
3867
3869 LLVMTypeRef DestTy, const char *Name) {
3870 return wrap(unwrap(B)->CreateFPToUI(unwrap(Val), unwrap(DestTy), Name));
3871}
3872
3874 LLVMTypeRef DestTy, const char *Name) {
3875 return wrap(unwrap(B)->CreateFPToSI(unwrap(Val), unwrap(DestTy), Name));
3876}
3877
3879 LLVMTypeRef DestTy, const char *Name) {
3880 return wrap(unwrap(B)->CreateUIToFP(unwrap(Val), unwrap(DestTy), Name));
3881}
3882
3884 LLVMTypeRef DestTy, const char *Name) {
3885 return wrap(unwrap(B)->CreateSIToFP(unwrap(Val), unwrap(DestTy), Name));
3886}
3887
3889 LLVMTypeRef DestTy, const char *Name) {
3890 return wrap(unwrap(B)->CreateFPTrunc(unwrap(Val), unwrap(DestTy), Name));
3891}
3892
3894 LLVMTypeRef DestTy, const char *Name) {
3895 return wrap(unwrap(B)->CreateFPExt(unwrap(Val), unwrap(DestTy), Name));
3896}
3897
3899 LLVMTypeRef DestTy, const char *Name) {
3900 return wrap(unwrap(B)->CreatePtrToInt(unwrap(Val), unwrap(DestTy), Name));
3901}
3902
3904 LLVMTypeRef DestTy, const char *Name) {
3905 return wrap(unwrap(B)->CreateIntToPtr(unwrap(Val), unwrap(DestTy), Name));
3906}
3907
3909 LLVMTypeRef DestTy, const char *Name) {
3910 return wrap(unwrap(B)->CreateBitCast(unwrap(Val), unwrap(DestTy), Name));
3911}
3912
3914 LLVMTypeRef DestTy, const char *Name) {
3915 return wrap(unwrap(B)->CreateAddrSpaceCast(unwrap(Val), unwrap(DestTy), Name));
3916}
3917
3919 LLVMTypeRef DestTy, const char *Name) {
3920 return wrap(unwrap(B)->CreateZExtOrBitCast(unwrap(Val), unwrap(DestTy),
3921 Name));
3922}
3923
3925 LLVMTypeRef DestTy, const char *Name) {
3926 return wrap(unwrap(B)->CreateSExtOrBitCast(unwrap(Val), unwrap(DestTy),
3927 Name));
3928}
3929
3931 LLVMTypeRef DestTy, const char *Name) {
3932 return wrap(unwrap(B)->CreateTruncOrBitCast(unwrap(Val), unwrap(DestTy),
3933 Name));
3934}
3935
3937 LLVMTypeRef DestTy, const char *Name) {
3938 return wrap(unwrap(B)->CreateCast(Instruction::CastOps(map_from_llvmopcode(Op)), unwrap(Val),
3939 unwrap(DestTy), Name));
3940}
3941
3943 LLVMTypeRef DestTy, const char *Name) {
3944 return wrap(unwrap(B)->CreatePointerCast(unwrap(Val), unwrap(DestTy), Name));
3945}
3946
3948 LLVMTypeRef DestTy, LLVMBool IsSigned,
3949 const char *Name) {
3950 return wrap(
3951 unwrap(B)->CreateIntCast(unwrap(Val), unwrap(DestTy), IsSigned, Name));
3952}
3953
3955 LLVMTypeRef DestTy, const char *Name) {
3956 return wrap(unwrap(B)->CreateIntCast(unwrap(Val), unwrap(DestTy),
3957 /*isSigned*/true, Name));
3958}
3959
3961 LLVMTypeRef DestTy, const char *Name) {
3962 return wrap(unwrap(B)->CreateFPCast(unwrap(Val), unwrap(DestTy), Name));
3963}
3964
3966 LLVMTypeRef DestTy, LLVMBool DestIsSigned) {
3968 unwrap(Src), SrcIsSigned, unwrap(DestTy), DestIsSigned));
3969}
3970
3971/*--.. Comparisons .........................................................--*/
3972
3974 LLVMValueRef LHS, LLVMValueRef RHS,
3975 const char *Name) {
3976 return wrap(unwrap(B)->CreateICmp(static_cast<ICmpInst::Predicate>(Op),
3977 unwrap(LHS), unwrap(RHS), Name));
3978}
3979
3981 LLVMValueRef LHS, LLVMValueRef RHS,
3982 const char *Name) {
3983 return wrap(unwrap(B)->CreateFCmp(static_cast<FCmpInst::Predicate>(Op),
3984 unwrap(LHS), unwrap(RHS), Name));
3985}
3986
3987/*--.. Miscellaneous instructions ..........................................--*/
3988
3990 return wrap(unwrap(B)->CreatePHI(unwrap(Ty), 0, Name));
3991}
3992
3994 LLVMValueRef *Args, unsigned NumArgs,
3995 const char *Name) {
3996 FunctionType *FTy = unwrap<FunctionType>(Ty);
3997 return wrap(unwrap(B)->CreateCall(FTy, unwrap(Fn),
3998 ArrayRef(unwrap(Args), NumArgs), Name));
3999}
4000
4003 LLVMValueRef Fn, LLVMValueRef *Args,
4004 unsigned NumArgs, LLVMOperandBundleRef *Bundles,
4005 unsigned NumBundles, const char *Name) {
4006 FunctionType *FTy = unwrap<FunctionType>(Ty);
4008 for (auto *Bundle : ArrayRef(Bundles, NumBundles)) {
4009 OperandBundleDef *OB = unwrap(Bundle);
4010 OBs.push_back(*OB);
4011 }
4012 return wrap(unwrap(B)->CreateCall(
4013 FTy, unwrap(Fn), ArrayRef(unwrap(Args), NumArgs), OBs, Name));
4014}
4015
4017 LLVMValueRef Then, LLVMValueRef Else,
4018 const char *Name) {
4019 return wrap(unwrap(B)->CreateSelect(unwrap(If), unwrap(Then), unwrap(Else),
4020 Name));
4021}
4022
4024 LLVMTypeRef Ty, const char *Name) {
4025 return wrap(unwrap(B)->CreateVAArg(unwrap(List), unwrap(Ty), Name));
4026}
4027
4029 LLVMValueRef Index, const char *Name) {
4030 return wrap(unwrap(B)->CreateExtractElement(unwrap(VecVal), unwrap(Index),
4031 Name));
4032}
4033
4036 const char *Name) {
4037 return wrap(unwrap(B)->CreateInsertElement(unwrap(VecVal), unwrap(EltVal),
4038 unwrap(Index), Name));
4039}
4040
4042 LLVMValueRef V2, LLVMValueRef Mask,
4043 const char *Name) {
4044 return wrap(unwrap(B)->CreateShuffleVector(unwrap(V1), unwrap(V2),
4045 unwrap(Mask), Name));
4046}
4047
4049 unsigned Index, const char *Name) {
4050 return wrap(unwrap(B)->CreateExtractValue(unwrap(AggVal), Index, Name));
4051}
4052
4054 LLVMValueRef EltVal, unsigned Index,
4055 const char *Name) {
4056 return wrap(unwrap(B)->CreateInsertValue(unwrap(AggVal), unwrap(EltVal),
4057 Index, Name));
4058}
4059
4061 const char *Name) {
4062 return wrap(unwrap(B)->CreateFreeze(unwrap(Val), Name));
4063}
4064
4066 const char *Name) {
4067 return wrap(unwrap(B)->CreateIsNull(unwrap(Val), Name));
4068}
4069
4071 const char *Name) {
4072 return wrap(unwrap(B)->CreateIsNotNull(unwrap(Val), Name));
4073}
4074
4076 LLVMValueRef LHS, LLVMValueRef RHS,
4077 const char *Name) {
4078 return wrap(unwrap(B)->CreatePtrDiff(unwrap(ElemTy), unwrap(LHS),
4079 unwrap(RHS), Name));
4080}
4081
4083 LLVMValueRef PTR, LLVMValueRef Val,
4084 LLVMAtomicOrdering ordering,
4085 LLVMBool singleThread) {
4087 return wrap(unwrap(B)->CreateAtomicRMW(
4088 intop, unwrap(PTR), unwrap(Val), MaybeAlign(),
4089 mapFromLLVMOrdering(ordering),
4090 singleThread ? SyncScope::SingleThread : SyncScope::System));
4091}
4092
4094 LLVMValueRef Cmp, LLVMValueRef New,
4095 LLVMAtomicOrdering SuccessOrdering,
4096 LLVMAtomicOrdering FailureOrdering,
4097 LLVMBool singleThread) {
4098
4099 return wrap(unwrap(B)->CreateAtomicCmpXchg(
4100 unwrap(Ptr), unwrap(Cmp), unwrap(New), MaybeAlign(),
4101 mapFromLLVMOrdering(SuccessOrdering),
4102 mapFromLLVMOrdering(FailureOrdering),
4103 singleThread ? SyncScope::SingleThread : SyncScope::System));
4104}
4105
4107 Value *P = unwrap(SVInst);
4108 ShuffleVectorInst *I = cast<ShuffleVectorInst>(P);
4109 return I->getShuffleMask().size();
4110}
4111
4112int LLVMGetMaskValue(LLVMValueRef SVInst, unsigned Elt) {
4113 Value *P = unwrap(SVInst);
4114 ShuffleVectorInst *I = cast<ShuffleVectorInst>(P);
4115 return I->getMaskValue(Elt);
4116}
4117
4119
4121 Value *P = unwrap(AtomicInst);
4122
4123 if (AtomicRMWInst *I = dyn_cast<AtomicRMWInst>(P))
4124 return I->getSyncScopeID() == SyncScope::SingleThread;
4125 else if (FenceInst *FI = dyn_cast<FenceInst>(P))
4126 return FI->getSyncScopeID() == SyncScope::SingleThread;
4127 else if (StoreInst *SI = dyn_cast<StoreInst>(P))
4128 return SI->getSyncScopeID() == SyncScope::SingleThread;
4129 else if (LoadInst *LI = dyn_cast<LoadInst>(P))
4130 return LI->getSyncScopeID() == SyncScope::SingleThread;
4131 return cast<AtomicCmpXchgInst>(P)->getSyncScopeID() ==
4133}
4134
4136 Value *P = unwrap(AtomicInst);
4138
4139 if (AtomicRMWInst *I = dyn_cast<AtomicRMWInst>(P))
4140 return I->setSyncScopeID(SSID);
4141 else if (FenceInst *FI = dyn_cast<FenceInst>(P))
4142 return FI->setSyncScopeID(SSID);
4143 else if (StoreInst *SI = dyn_cast<StoreInst>(P))
4144 return SI->setSyncScopeID(SSID);
4145 else if (LoadInst *LI = dyn_cast<LoadInst>(P))
4146 return LI->setSyncScopeID(SSID);
4147 return cast<AtomicCmpXchgInst>(P)->setSyncScopeID(SSID);
4148}
4149
4151 Value *P = unwrap(CmpXchgInst);
4152 return mapToLLVMOrdering(cast<AtomicCmpXchgInst>(P)->getSuccessOrdering());
4153}
4154
4156 LLVMAtomicOrdering Ordering) {
4157 Value *P = unwrap(CmpXchgInst);
4158 AtomicOrdering O = mapFromLLVMOrdering(Ordering);
4159
4160 return cast<AtomicCmpXchgInst>(P)->setSuccessOrdering(O);
4161}
4162
4164 Value *P = unwrap(CmpXchgInst);
4165 return mapToLLVMOrdering(cast<AtomicCmpXchgInst>(P)->getFailureOrdering());
4166}
4167
4169 LLVMAtomicOrdering Ordering) {
4170 Value *P = unwrap(CmpXchgInst);
4171 AtomicOrdering O = mapFromLLVMOrdering(Ordering);
4172
4173 return cast<AtomicCmpXchgInst>(P)->setFailureOrdering(O);
4174}
4175
4176/*===-- Module providers --------------------------------------------------===*/
4177
4180 return reinterpret_cast<LLVMModuleProviderRef>(M);
4181}
4182
4184 delete unwrap(MP);
4185}
4186
4187
4188/*===-- Memory buffers ----------------------------------------------------===*/
4189
4191 const char *Path,
4192 LLVMMemoryBufferRef *OutMemBuf,
4193 char **OutMessage) {
4194
4196 if (std::error_code EC = MBOrErr.getError()) {
4197 *OutMessage = strdup(EC.message().c_str());
4198 return 1;
4199 }
4200 *OutMemBuf = wrap(MBOrErr.get().release());
4201 return 0;
4202}
4203
4205 char **OutMessage) {
4207 if (std::error_code EC = MBOrErr.getError()) {
4208 *OutMessage = strdup(EC.message().c_str());
4209 return 1;
4210 }
4211 *OutMemBuf = wrap(MBOrErr.get().release());
4212 return 0;
4213}
4214
4216 const char *InputData,
4217 size_t InputDataLength,
4218 const char *BufferName,
4219 LLVMBool RequiresNullTerminator) {
4220
4221 return wrap(MemoryBuffer::getMemBuffer(StringRef(InputData, InputDataLength),
4222 StringRef(BufferName),
4223 RequiresNullTerminator).release());
4224}
4225
4227 const char *InputData,
4228 size_t InputDataLength,
4229 const char *BufferName) {
4230
4231 return wrap(
4232 MemoryBuffer::getMemBufferCopy(StringRef(InputData, InputDataLength),
4233 StringRef(BufferName)).release());
4234}
4235
4237 return unwrap(MemBuf)->getBufferStart();
4238}
4239
4241 return unwrap(MemBuf)->getBufferSize();
4242}
4243
4245 delete unwrap(MemBuf);
4246}
4247
4248/*===-- Pass Manager ------------------------------------------------------===*/
4249
4251 return wrap(new legacy::PassManager());
4252}
4253
4255 return wrap(new legacy::FunctionPassManager(unwrap(M)));
4256}
4257
4260 reinterpret_cast<LLVMModuleRef>(P));
4261}
4262
4264 return unwrap<legacy::PassManager>(PM)->run(*unwrap(M));
4265}
4266
4268 return unwrap<legacy::FunctionPassManager>(FPM)->doInitialization();
4269}
4270
4272 return unwrap<legacy::FunctionPassManager>(FPM)->run(*unwrap<Function>(F));
4273}
4274
4276 return unwrap<legacy::FunctionPassManager>(FPM)->doFinalization();
4277}
4278
4280 delete unwrap(PM);
4281}
4282
4283/*===-- Threading ------------------------------------------------------===*/
4284
4286 return LLVMIsMultithreaded();
4287}
4288
4290}
4291
4293 return llvm_is_multithreaded();
4294}
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")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref)
#define LLVM_EXTENSION
LLVM_EXTENSION - Support compilers where we have a keyword to suppress pedantic diagnostics.
Definition: Compiler.h: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:1544
static Module::ModFlagBehavior map_to_llvmModFlagBehavior(LLVMModuleFlagBehavior Behavior)
Definition: Core.cpp:313
#define LLVM_DEFINE_VALUE_CAST(name)
Definition: Core.cpp:1056
static LLVMValueMetadataEntry * llvm_getMetadata(size_t *NumEntries, llvm::function_ref< void(MetadataEntries &)> AccessMD)
Definition: Core.cpp:1028
static MDNode * extractMDNode(MetadataAsValue *MAV)
Definition: Core.cpp:1004
static LLVMOpcode map_to_llvmopcode(int opcode)
Definition: Core.cpp:1600
static LLVMFastMathFlags mapToLLVMFastMathFlags(FastMathFlags FMF)
Definition: Core.cpp:3352
static FastMathFlags mapFromLLVMFastMathFlags(LLVMFastMathFlags FMF)
Definition: Core.cpp:3339
LLVMValueRef LLVMConstIntOfString(LLVMTypeRef IntTy, const char Str[], uint8_t Radix)
Definition: Core.cpp:1464
static AtomicOrdering mapFromLLVMOrdering(LLVMAtomicOrdering Ordering)
Definition: Core.cpp:3666
static Intrinsic::ID llvm_map_to_intrinsic_id(unsigned ID)
Definition: Core.cpp:2336
static LLVMModuleFlagBehavior map_from_llvmModFlagBehavior(Module::ModFlagBehavior Behavior)
Definition: Core.cpp:332
static LLVMAtomicOrdering mapToLLVMOrdering(AtomicOrdering Ordering)
Definition: Core.cpp:3682
static LLVMValueRef getMDNodeOperandImpl(LLVMContext &Context, const MDNode *N, unsigned Index)
Definition: Core.cpp:1111
LLVMValueRef LLVMConstRealOfStringAndSize(LLVMTypeRef RealTy, const char Str[], unsigned SLen)
Definition: Core.cpp:1484
static int map_from_llvmopcode(LLVMOpcode code)
Definition: Core.cpp:1610
static LLVMAtomicRMWBinOp mapToLLVMRMWBinOp(AtomicRMWInst::BinOp BinOp)
Definition: Core.cpp:3720
static AtomicRMWInst::BinOp mapFromLLVMRMWBinOp(LLVMAtomicRMWBinOp BinOp)
Definition: Core.cpp:3698
LLVMValueRef LLVMConstIntOfStringAndSize(LLVMTypeRef IntTy, const char Str[], unsigned SLen, uint8_t Radix)
Definition: Core.cpp:1470
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:28
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
@ 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
@ 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:442
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)
Creates a new BasicBlock.
Definition: BasicBlock.h:198
const Function * getParent() const
Return the enclosing method, or null if none.
Definition: BasicBlock.h:205
InstListType::iterator iterator
Instruction iterators...
Definition: BasicBlock.h:164
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:965
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:2877
A constant value that is initialized with an expression using other constant values.
Definition: Constants.h:1016
static Constant * getFCmp(unsigned short pred, Constant *LHS, Constant *RHS, bool OnlyIfReduced=false)
Definition: Constants.cpp:2429
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:2454
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:1085
static Constant * getInBoundsGetElementPtr(Type *Ty, Constant *C, ArrayRef< Constant * > IdxList)
Create an "inbounds" getelementptr.
Definition: Constants.h:1227
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:1073
static Constant * getSub(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
Definition: Constants.cpp:2544
static Constant * getNot(Constant *C)
Definition: Constants.cpp:2531
static Constant * getInsertElement(Constant *Vec, Constant *Elt, Constant *Idx, Type *OnlyIfReducedTy=nullptr)
Definition: Constants.cpp:2476
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:2404
static Constant * getShuffleVector(Constant *V1, Constant *V2, ArrayRef< int > Mask, Type *OnlyIfReducedTy=nullptr)
Definition: Constants.cpp:2499
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 * getGetElementPtr(Type *Ty, Constant *C, ArrayRef< Constant * > IdxList, bool InBounds=false, std::optional< unsigned > InRangeIndex=std::nullopt, Type *OnlyIfReducedTy=nullptr)
Getelementptr form.
Definition: Constants.h:1201
static Constant * getXor(Constant *C1, Constant *C2)
Definition: Constants.cpp:2558
static Constant * getMul(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
Definition: Constants.cpp:2551
static Constant * getNSWNeg(Constant *C)
Definition: Constants.h:1070
static Constant * getNSWSub(Constant *C1, Constant *C2)
Definition: Constants.h:1081
static Constant * getShl(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
Definition: Constants.cpp:2562
static Constant * getNUWAdd(Constant *C1, Constant *C2)
Definition: Constants.h:1077
static Constant * getNUWNeg(Constant *C)
Definition: Constants.h:1071
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:2537
static Constant * getBitCast(Constant *C, Type *Ty, bool OnlyIfReduced=false)
Definition: Constants.cpp:2140
static Constant * getNSWMul(Constant *C1, Constant *C2)
Definition: Constants.h:1089
static Constant * getTrunc(Constant *C, Type *Ty, bool OnlyIfReduced=false)
Definition: Constants.cpp:2098
static Constant * getNUWMul(Constant *C1, Constant *C2)
Definition: Constants.h:1093
static Constant * getNeg(Constant *C, bool HasNUW=false, bool HasNSW=false)
Definition: Constants.cpp:2525
ConstantFP - Floating Point Values [float, double].
Definition: Constants.h:267
const APFloat & getValueAPF() const
Definition: Constants.h:310
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:475
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:162
BasicBlockListType::iterator iterator
Definition: Function.h:67
static Intrinsic::ID lookupIntrinsicID(StringRef Name)
This does the actual lookup of an intrinsic ID which matches the given function name.
Definition: Function.cpp:902
iterator_range< arg_iterator > args()
Definition: Function.h:837
arg_iterator arg_begin()
Definition: Function.h:813
Function::iterator insert(Function::iterator Position, BasicBlock *BB)
Insert BB in the basic block list at Position.
Definition: Function.h:727
size_t arg_size() const
Definition: Function.h:846
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:518
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:575
void setUnnamedAddr(UnnamedAddr Val)
Definition: GlobalValue.h:231
void setThreadLocalMode(ThreadLocalMode Val)
Definition: GlobalValue.h:267
void setLinkage(LinkageTypes LT)
Definition: GlobalValue.h:536
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:655
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:2649
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:597
static std::unique_ptr< MemoryBuffer > getMemBuffer(StringRef InputData, StringRef BufferName="", bool RequiresNullTerminator=true)
Open the specified memory range as a MemoryBuffer.
static std::unique_ptr< MemoryBuffer > getMemBufferCopy(StringRef InputData, const Twine &BufferName="")
Open the specified memory range as a MemoryBuffer, copying the contents and taking ownership of it.
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFile(const Twine &Filename, bool IsText=false, bool RequiresNullTerminator=true, bool IsVolatile=false, std::optional< Align > Alignment=std::nullopt)
Open the specified file as a MemoryBuffer, returning a new MemoryBuffer if successful,...
static ErrorOr< std::unique_ptr< MemoryBuffer > > getSTDIN()
Read all of stdin into a file buffer, and return it.
Metadata wrapper in the Value hierarchy.
Definition: Metadata.h: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:686
ifunc_iterator ifunc_begin()
Definition: Module.h:744
ModFlagBehavior
This enumeration defines the supported behaviors of module flags.
Definition: Module.h:115
global_iterator global_end()
Definition: Module.h:688
NamedMDListType::iterator named_metadata_iterator
The named metadata iterators.
Definition: Module.h:110
iterator begin()
Definition: Module.h:704
IFuncListType::iterator ifunc_iterator
The Global IFunc iterators.
Definition: Module.h:105
named_metadata_iterator named_metadata_begin()
Definition: Module.h:785
ifunc_iterator ifunc_end()
Definition: Module.h:746
alias_iterator alias_end()
Definition: Module.h:728
alias_iterator alias_begin()
Definition: Module.h:726
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:706
named_metadata_iterator named_metadata_end()
Definition: Module.h:790
A tuple of MDNodes.
Definition: Metadata.h:1729
StringRef getName() const
Definition: Metadata.cpp:1396
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:1408
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:492
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:826
LLVMContextRef LLVMContextCreate()
Create a new context.
Definition: Core.cpp:91
void(* LLVMYieldCallback)(LLVMContextRef, void *)
Definition: Core.h:546
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:545
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:3656
LLVMValueRef LLVMBuildGlobalStringPtr(LLVMBuilderRef B, const char *Str, const char *Name)
Definition: Core.cpp:3781
LLVMValueRef LLVMBuildFence(LLVMBuilderRef B, LLVMAtomicOrdering Ordering, LLVMBool isSingleThread, const char *Name)
Definition: Core.cpp:3745
LLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B, LLVMAtomicRMWBinOp op, LLVMValueRef PTR, LLVMValueRef Val, LLVMAtomicOrdering ordering, LLVMBool singleThread)
Definition: Core.cpp:4082
LLVMBool LLVMGetIsDisjoint(LLVMValueRef Inst)
Gets whether the instruction has the disjoint flag set.
Definition: Core.cpp:3587
LLVMValueRef LLVMBuildNot(LLVMBuilderRef B, LLVMValueRef V, const char *Name)
Definition: Core.cpp:3527
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:3200
LLVMValueRef LLVMBuildNSWSub(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3397
LLVMValueRef LLVMBuildAnd(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3487
LLVMValueRef LLVMBuildFPExt(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:3893
void LLVMClearInsertionPosition(LLVMBuilderRef Builder)
Definition: Core.cpp:3095
LLVMValueRef LLVMBuildFDiv(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3452
void LLVMSetWeak(LLVMValueRef CmpXchgInst, LLVMBool isWeak)
Definition: Core.cpp:3812
void LLVMSetNSW(LLVMValueRef ArithInst, LLVMBool HasNSW)
Definition: Core.cpp:3546
LLVMValueRef LLVMBuildFreeze(LLVMBuilderRef B, LLVMValueRef Val, const char *Name)
Definition: Core.cpp:4060
LLVMValueRef LLVMBuildFAdd(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3387
LLVMValueRef LLVMBuildFMul(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3427
LLVMValueRef LLVMBuildZExt(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:3858
LLVMValueRef LLVMBuildSExt(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:3863
LLVMValueRef LLVMBuildTruncOrBitCast(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:3930
LLVMValueRef LLVMBuildSExtOrBitCast(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:3924
LLVMValueRef LLVMBuildBitCast(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:3908
void LLVMBuilderSetDefaultFPMathTag(LLVMBuilderRef Builder, LLVMMetadataRef FPMathTag)
Set the default floating-point math metadata for the given builder.
Definition: Core.cpp:3145
LLVMValueRef LLVMBuildExtractValue(LLVMBuilderRef B, LLVMValueRef AggVal, unsigned Index, const char *Name)
Definition: Core.cpp:4048
LLVMValueRef LLVMBuildFCmp(LLVMBuilderRef B, LLVMRealPredicate Op, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3980
void LLVMSetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst, LLVMAtomicOrdering Ordering)
Definition: Core.cpp:4168
LLVMValueRef LLVMBuildFPTrunc(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:3888
LLVMAtomicOrdering LLVMGetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst)
Definition: Core.cpp:4163
LLVMOpcode LLVMGetCastOpcode(LLVMValueRef Src, LLVMBool SrcIsSigned, LLVMTypeRef DestTy, LLVMBool DestIsSigned)
Definition: Core.cpp:3965
LLVMAtomicRMWBinOp LLVMGetAtomicRMWBinOp(LLVMValueRef Inst)
Definition: Core.cpp:3843
void LLVMSetNUW(LLVMValueRef ArithInst, LLVMBool HasNUW)
Definition: Core.cpp:3536
LLVMValueRef LLVMBuildSIToFP(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:3883
LLVMValueRef LLVMBuildShl(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3472
void LLVMSetCurrentDebugLocation2(LLVMBuilderRef Builder, LLVMMetadataRef Loc)
Set location information used by debugging information.
Definition: Core.cpp:3118
int LLVMGetUndefMaskElem(void)
Definition: Core.cpp:4118
LLVMBool LLVMGetWeak(LLVMValueRef CmpXchgInst)
Definition: Core.cpp:3808
LLVMValueRef LLVMBuildFRem(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3467
LLVMValueRef LLVMBuildAlloca(LLVMBuilderRef B, LLVMTypeRef Ty, const char *Name)
Definition: Core.cpp:3642
LLVMValueRef LLVMBuildSelect(LLVMBuilderRef B, LLVMValueRef If, LLVMValueRef Then, LLVMValueRef Else, const char *Name)
Definition: Core.cpp:4016
LLVMValueRef LLVMBuildCatchPad(LLVMBuilderRef B, LLVMValueRef ParentPad, LLVMValueRef *Args, unsigned NumArgs, const char *Name)
Definition: Core.cpp:3226
void LLVMSetIsDisjoint(LLVMValueRef Inst, LLVMBool IsDisjoint)
Sets the disjoint flag for the instruction.
Definition: Core.cpp:3592
LLVMValueRef LLVMBuildMul(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3412
LLVMValueRef LLVMBuildExactSDiv(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3447
LLVMValueRef LLVMBuildNUWSub(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3402
LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef B, LLVMTypeRef Ty, const char *Name)
Definition: Core.cpp:3599
LLVMValueRef LLVMBuildIsNull(LLVMBuilderRef B, LLVMValueRef Val, const char *Name)
Definition: Core.cpp:4065
LLVMValueRef LLVMBuildLandingPad(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef PersFn, unsigned NumClauses, const char *Name)
Definition: Core.cpp:3214
LLVMValueRef LLVMBuildAggregateRet(LLVMBuilderRef B, LLVMValueRef *RetVals, unsigned N)
Definition: Core.cpp:3167
LLVMValueRef LLVMBuildAShr(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3482
LLVMValueRef LLVMBuildInvoke2(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Fn, LLVMValueRef *Args, unsigned NumArgs, LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch, const char *Name)
Definition: Core.cpp:3191
LLVMValueRef LLVMBuildCallWithOperandBundles(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Fn, LLVMValueRef *Args, unsigned NumArgs, LLVMOperandBundleRef *Bundles, unsigned NumBundles, const char *Name)
Definition: Core.cpp:4002
LLVMValueRef LLVMBuildExactUDiv(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3437
void LLVMSetOrdering(LLVMValueRef MemAccessInst, LLVMAtomicOrdering Ordering)
Definition: Core.cpp:3830
void LLVMSetCleanup(LLVMValueRef LandingPad, LLVMBool Val)
Definition: Core.cpp:3300
LLVMValueRef LLVMGetArgOperand(LLVMValueRef Funclet, unsigned i)
Definition: Core.cpp:3329
LLVMValueRef LLVMBuildInsertValue(LLVMBuilderRef B, LLVMValueRef AggVal, LLVMValueRef EltVal, unsigned Index, const char *Name)
Definition: Core.cpp:4053
LLVMValueRef LLVMBuildAdd(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3372
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:3617
LLVMValueRef LLVMBuildBr(LLVMBuilderRef B, LLVMBasicBlockRef Dest)
Definition: Core.cpp:3172
LLVMValueRef LLVMBuildNSWMul(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3417
LLVMValueRef LLVMBuildBinOp(LLVMBuilderRef B, LLVMOpcode Op, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3502
LLVMValueRef LLVMBuildSRem(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3462
void LLVMDisposeBuilder(LLVMBuilderRef Builder)
Definition: Core.cpp:3108
int LLVMGetMaskValue(LLVMValueRef SVInst, unsigned Elt)
Get the mask value at position Elt in the mask of a ShuffleVector instruction.
Definition: Core.cpp:4112
LLVMValueRef LLVMBuildFSub(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3407
LLVMValueRef LLVMGetClause(LLVMValueRef LandingPad, unsigned Idx)
Definition: Core.cpp:3288
LLVMMetadataRef LLVMGetCurrentDebugLocation2(LLVMBuilderRef Builder)
Get location information used by debugging information.
Definition: Core.cpp:3114
LLVMValueRef LLVMBuildArrayAlloca(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Val, const char *Name)
Definition: Core.cpp:3647
LLVMValueRef LLVMBuildVAArg(LLVMBuilderRef B, LLVMValueRef List, LLVMTypeRef Ty, const char *Name)
Definition: Core.cpp:4023
LLVMBuilderRef LLVMCreateBuilderInContext(LLVMContextRef C)
Definition: Core.cpp:3066
LLVMValueRef LLVMBuildAtomicCmpXchg(LLVMBuilderRef B, LLVMValueRef Ptr, LLVMValueRef Cmp, LLVMValueRef New, LLVMAtomicOrdering SuccessOrdering, LLVMAtomicOrdering FailureOrdering, LLVMBool singleThread)
Definition: Core.cpp:4093
LLVMValueRef LLVMBuildICmp(LLVMBuilderRef B, LLVMIntPredicate Op, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3973
LLVMValueRef LLVMBuildPointerCast(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:3942
LLVMValueRef LLVMGetParentCatchSwitch(LLVMValueRef CatchPad)
Get the parent catchswitch instruction of a catchpad instruction.
Definition: Core.cpp:3318
void LLVMSetAtomicSingleThread(LLVMValueRef AtomicInst, LLVMBool NewValue)
Definition: Core.cpp:4135
LLVMValueRef LLVMBuildCast(LLVMBuilderRef B, LLVMOpcode Op, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:3936
LLVMValueRef LLVMBuildTrunc(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:3853
LLVMValueRef LLVMBuildURem(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3457
void LLVMSetAtomicRMWBinOp(LLVMValueRef Inst, LLVMAtomicRMWBinOp BinOp)
Definition: Core.cpp:3847
LLVMValueRef LLVMBuildCall2(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Fn, LLVMValueRef *Args, unsigned NumArgs, const char *Name)
Definition: Core.cpp:3993
void LLVMAddClause(LLVMValueRef LandingPad, LLVMValueRef ClauseVal)
Definition: Core.cpp:3292
LLVMValueRef LLVMBuildOr(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3492
LLVMBool LLVMGetNUW(LLVMValueRef ArithInst)
Definition: Core.cpp:3531
LLVMValueRef LLVMBuildAddrSpaceCast(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:3913
LLVMValueRef LLVMBuildFPToUI(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:3868
void LLVMSetCurrentDebugLocation(LLVMBuilderRef Builder, LLVMValueRef L)
Deprecated: Passing the NULL location will crash.
Definition: Core.cpp:3125
LLVMValueRef LLVMBuildFPToSI(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:3873
LLVMValueRef LLVMBuildIntCast2(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, LLVMBool IsSigned, const char *Name)
Definition: Core.cpp:3947
LLVMValueRef LLVMBuildNSWAdd(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3377
LLVMValueRef LLVMBuildFNeg(LLVMBuilderRef B, LLVMValueRef V, const char *Name)
Definition: Core.cpp:3523
LLVMMetadataRef LLVMBuilderGetDefaultFPMathTag(LLVMBuilderRef Builder)
Get the dafult floating-point math metadata for a given builder.
Definition: Core.cpp:3153
LLVMValueRef LLVMBuildUDiv(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3432
void LLVMSetParentCatchSwitch(LLVMValueRef CatchPad, LLVMValueRef CatchSwitch)
Set the parent catchswitch instruction of a catchpad instruction.
Definition: Core.cpp:3322
LLVMValueRef LLVMBuildCatchRet(LLVMBuilderRef B, LLVMValueRef CatchPad, LLVMBasicBlockRef BB)
Definition: Core.cpp:3259
LLVMValueRef LLVMBuildStructGEP2(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Pointer, unsigned Idx, const char *Name)
Definition: Core.cpp:3769
unsigned LLVMGetNumClauses(LLVMValueRef LandingPad)
Definition: Core.cpp:3284
LLVMBool LLVMGetNNeg(LLVMValueRef NonNegInst)
Gets if the instruction has the non-negative flag set.
Definition: Core.cpp:3561
LLVMValueRef LLVMBuildSDiv(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3442
LLVMValueRef LLVMBuildStore(LLVMBuilderRef B, LLVMValueRef Val, LLVMValueRef PointerVal)
Definition: Core.cpp:3661
LLVMValueRef LLVMBuildCatchSwitch(LLVMBuilderRef B, LLVMValueRef ParentPad, LLVMBasicBlockRef UnwindBB, unsigned NumHandlers, const char *Name)
Definition: Core.cpp:3248
LLVMValueRef LLVMBuildIntCast(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Deprecated: This cast is always signed.
Definition: Core.cpp:3954
LLVMValueRef LLVMBuildNUWNeg(LLVMBuilderRef B, LLVMValueRef V, const char *Name)
Definition: Core.cpp:3518
LLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Val, const char *Name)
Definition: Core.cpp:3608
LLVMValueRef LLVMBuildZExtOrBitCast(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:3918
LLVMValueRef LLVMBuildInBoundsGEP2(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Pointer, LLVMValueRef *Indices, unsigned NumIndices, const char *Name)
Definition: Core.cpp:3761
void LLVMGetHandlers(LLVMValueRef CatchSwitch, LLVMBasicBlockRef *Handlers)
Obtain the basic blocks acting as handlers for a catchswitch instruction.
Definition: Core.cpp:3312
LLVMAtomicOrdering LLVMGetOrdering(LLVMValueRef MemAccessInst)
Definition: Core.cpp:3816
LLVMValueRef LLVMBuildUIToFP(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:3878
LLVMValueRef LLVMBuildIntToPtr(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:3903
LLVMValueRef LLVMBuildCondBr(LLVMBuilderRef B, LLVMValueRef If, LLVMBasicBlockRef Then, LLVMBasicBlockRef Else)
Definition: Core.cpp:3176
LLVMValueRef LLVMBuildIndirectBr(LLVMBuilderRef B, LLVMValueRef Addr, unsigned NumDests)
Definition: Core.cpp:3186
void LLVMAddDestination(LLVMValueRef IndirectBr, LLVMBasicBlockRef Dest)
Definition: Core.cpp:3280
LLVMValueRef LLVMBuildNSWNeg(LLVMBuilderRef B, LLVMValueRef V, const char *Name)
Definition: Core.cpp:3513
LLVMValueRef LLVMBuildXor(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3497
LLVMValueRef LLVMBuildGlobalString(LLVMBuilderRef B, const char *Str, const char *Name)
Definition: Core.cpp:3776
LLVMBool LLVMGetExact(LLVMValueRef DivOrShrInst)
Definition: Core.cpp:3551
LLVMValueRef LLVMBuildIsNotNull(LLVMBuilderRef B, LLVMValueRef Val, const char *Name)
Definition: Core.cpp:4070
void LLVMSetArgOperand(LLVMValueRef Funclet, unsigned i, LLVMValueRef value)
Definition: Core.cpp:3333
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:3624
LLVMValueRef LLVMBuildPtrDiff2(LLVMBuilderRef B, LLVMTypeRef ElemTy, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:4075
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:3137
void LLVMAddMetadataToInst(LLVMBuilderRef Builder, LLVMValueRef Inst)
Adds the metadata registered with the given builder to the given instruction.
Definition: Core.cpp:3141
LLVMValueRef LLVMBuildSub(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3392
LLVMValueRef LLVMBuildNUWAdd(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3382
LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef B)
Definition: Core.cpp:3271
LLVMValueRef LLVMBuildShuffleVector(LLVMBuilderRef B, LLVMValueRef V1, LLVMValueRef V2, LLVMValueRef Mask, const char *Name)
Definition: Core.cpp:4041
void LLVMSetVolatile(LLVMValueRef MemAccessInst, LLVMBool isVolatile)
Definition: Core.cpp:3797
LLVMValueRef LLVMBuildFree(LLVMBuilderRef B, LLVMValueRef PointerVal)
Definition: Core.cpp:3652
LLVMValueRef LLVMBuildGEP2(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Pointer, LLVMValueRef *Indices, unsigned NumIndices, const char *Name)
Definition: Core.cpp:3754
unsigned LLVMGetNumHandlers(LLVMValueRef CatchSwitch)
Definition: Core.cpp:3308
LLVMValueRef LLVMBuildFPCast(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:3960
LLVMBuilderRef LLVMCreateBuilder(void)
Definition: Core.cpp:3070
void LLVMSetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst, LLVMAtomicOrdering Ordering)
Definition: Core.cpp:4155
LLVMValueRef LLVMBuildPhi(LLVMBuilderRef B, LLVMTypeRef Ty, const char *Name)
Definition: Core.cpp:3989
LLVMBool LLVMCanValueUseFastMathFlags(LLVMValueRef V)
Check if a given value can potentially have fast math flags.
Definition: Core.cpp:3582
void LLVMAddCase(LLVMValueRef Switch, LLVMValueRef OnVal, LLVMBasicBlockRef Dest)
Definition: Core.cpp:3275
LLVMBool LLVMIsAtomicSingleThread(LLVMValueRef AtomicInst)
Definition: Core.cpp:4120
LLVMValueRef LLVMBuildResume(LLVMBuilderRef B, LLVMValueRef Exn)
Definition: Core.cpp:3244
LLVMValueRef LLVMBuildSwitch(LLVMBuilderRef B, LLVMValueRef V, LLVMBasicBlockRef Else, unsigned NumCases)
Definition: Core.cpp:3181
void LLVMInsertIntoBuilder(LLVMBuilderRef Builder, LLVMValueRef Instr)
Definition: Core.cpp:3099
LLVMValueRef LLVMBuildPtrToInt(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:3898
LLVMBool LLVMIsCleanup(LLVMValueRef LandingPad)
Definition: Core.cpp:3296
LLVMBool LLVMGetNSW(LLVMValueRef ArithInst)
Definition: Core.cpp:3541
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:3633
LLVMValueRef LLVMBuildLShr(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3477
unsigned LLVMGetNumMaskElements(LLVMValueRef SVInst)
Get the number of elements in the mask of a ShuffleVector instruction.
Definition: Core.cpp:4106
LLVMValueRef LLVMBuildRetVoid(LLVMBuilderRef B)
Definition: Core.cpp:3159
LLVMValueRef LLVMBuildRet(LLVMBuilderRef B, LLVMValueRef V)
Definition: Core.cpp:3163
void LLVMAddHandler(LLVMValueRef CatchSwitch, LLVMBasicBlockRef Dest)
Definition: Core.cpp:3304
LLVMValueRef LLVMBuildExtractElement(LLVMBuilderRef B, LLVMValueRef VecVal, LLVMValueRef Index, const char *Name)
Definition: Core.cpp:4028
void LLVMPositionBuilderBefore(LLVMBuilderRef Builder, LLVMValueRef Instr)
Definition: Core.cpp:3081
LLVMValueRef LLVMGetCurrentDebugLocation(LLVMBuilderRef Builder)
Deprecated: Returning the NULL location will crash.
Definition: Core.cpp:3131
LLVMAtomicOrdering LLVMGetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst)
Definition: Core.cpp:4150
void LLVMSetNNeg(LLVMValueRef NonNegInst, LLVMBool IsNonNeg)
Sets the non-negative flag for the instruction.
Definition: Core.cpp:3566
void LLVMSetExact(LLVMValueRef DivOrShrInst, LLVMBool IsExact)
Definition: Core.cpp:3556
LLVMBasicBlockRef LLVMGetInsertBlock(LLVMBuilderRef Builder)
Definition: Core.cpp:3091
LLVMValueRef LLVMBuildCleanupPad(LLVMBuilderRef B, LLVMValueRef ParentPad, LLVMValueRef *Args, unsigned NumArgs, const char *Name)
Definition: Core.cpp:3233
void LLVMInsertIntoBuilderWithName(LLVMBuilderRef Builder, LLVMValueRef Instr, const char *Name)
Definition: Core.cpp:3103
void LLVMSetFastMathFlags(LLVMValueRef FPMathInst, LLVMFastMathFlags FMF)
Sets the flags for which fast-math-style optimizations are allowed for this value.
Definition: Core.cpp:3577
LLVMFastMathFlags LLVMGetFastMathFlags(LLVMValueRef FPMathInst)
Get the flags for which fast-math-style optimizations are allowed for this value.
Definition: Core.cpp:3571
LLVMValueRef LLVMBuildNeg(LLVMBuilderRef B, LLVMValueRef V, const char *Name)
Definition: Core.cpp:3509
LLVMBool LLVMGetVolatile(LLVMValueRef MemAccessInst)
Definition: Core.cpp:3786
LLVMValueRef LLVMBuildNUWMul(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3422
void LLVMPositionBuilder(LLVMBuilderRef Builder, LLVMBasicBlockRef Block, LLVMValueRef Instr)
Definition: Core.cpp:3074
void LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder, LLVMBasicBlockRef Block)
Definition: Core.cpp:3086
LLVMValueRef LLVMBuildInsertElement(LLVMBuilderRef B, LLVMValueRef VecVal, LLVMValueRef EltVal, LLVMValueRef Index, const char *Name)
Definition: Core.cpp:4034
LLVMValueRef LLVMBuildCleanupRet(LLVMBuilderRef B, LLVMValueRef CatchPad, LLVMBasicBlockRef BB)
Definition: Core.cpp:3265
void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf)
Definition: Core.cpp:4244
size_t LLVMGetBufferSize(LLVMMemoryBufferRef MemBuf)
Definition: Core.cpp:4240
LLVMBool LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef *OutMemBuf, char **OutMessage)
Definition: Core.cpp:4204
LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRange(const char *InputData, size_t InputDataLength, const char *BufferName, LLVMBool RequiresNullTerminator)
Definition: Core.cpp:4215
LLVMBool LLVMCreateMemoryBufferWithContentsOfFile(const char *Path, LLVMMemoryBufferRef *OutMemBuf, char **OutMessage)
Definition: Core.cpp:4190
const char * LLVMGetBufferStart(LLVMMemoryBufferRef MemBuf)
Definition: Core.cpp:4236
LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRangeCopy(const char *InputData, size_t InputDataLength, const char *BufferName)
Definition: Core.cpp:4226
LLVMModuleProviderRef LLVMCreateModuleProviderForExistingModule(LLVMModuleRef M)
Changes the type of M so it can be passed to FunctionPassManagers and the JIT.
Definition: Core.cpp:4179
void LLVMDisposeModuleProvider(LLVMModuleProviderRef MP)
Destroys the module M.
Definition: Core.cpp:4183
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:2272
LLVMNamedMDNodeRef LLVMGetPreviousNamedMetadata(LLVMNamedMDNodeRef NMD)
Decrement a NamedMDNode iterator to the previous NamedMDNode.
Definition: Core.cpp:1300
LLVMTypeRef LLVMGetTypeByName(LLVMModuleRef M, const char *Name)
Deprecated: Use LLVMGetTypeByName2 instead.
Definition: Core.cpp:822
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:409
void LLVMAppendModuleInlineAsm(LLVMModuleRef M, const char *Asm, size_t Len)
Append inline assembly to a module.
Definition: Core.cpp:455
LLVMValueRef LLVMGetFirstFunction(LLVMModuleRef M)
Obtain an iterator to the first Function in a Module.
Definition: Core.cpp:2282
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:1395
LLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename, char **ErrorMessage)
Print a representation of a module to a file.
Definition: Core.cpp:414
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:465
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:1371
const char * LLVMGetModuleInlineAsm(LLVMModuleRef M, size_t *Len)
Get inline assembly for a module.
Definition: Core.cpp:459
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:1318
LLVMContextRef LLVMGetModuleContext(LLVMModuleRef M)
Obtain the context to which this module is associated.
Definition: Core.cpp:541
const char * LLVMGetInlineAsmConstraintString(LLVMValueRef InlineAsmVal, size_t *Len)
Get the raw constraint string for an inline assembly snippet.
Definition: Core.cpp:494
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:2290
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:485
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:1441
unsigned LLVMGetDebugLocLine(LLVMValueRef Val)
Return the line number of the debug location for this value, which must be an llvm::Instruction,...
Definition: Core.cpp:1419
LLVMBool LLVMGetInlineAsmNeedsAlignedStack(LLVMValueRef InlineAsmVal)
Get if the inline asm snippet needs an aligned stack.
Definition: Core.cpp:530
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:451
LLVMBool LLVMGetInlineAsmHasSideEffects(LLVMValueRef InlineAsmVal)
Get if the inline asm snippet has side effects.
Definition: Core.cpp:525
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:504
unsigned LLVMGetNamedMetadataNumOperands(LLVMModuleRef M, const char *Name)
Obtain the number of operands for named metadata in a module.
Definition: Core.cpp:1344
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:1292
void LLVMSetModuleInlineAsm2(LLVMModuleRef M, const char *Asm, size_t Len)
Set inline assembly for a module.
Definition: Core.cpp:447
LLVMNamedMDNodeRef LLVMGetLastNamedMetadata(LLVMModuleRef M)
Obtain an iterator to the last NamedMDNode in a Module.
Definition: Core.cpp:1284
LLVMBool LLVMGetInlineAsmCanUnwind(LLVMValueRef InlineAsmVal)
Get if the inline asm snippet may unwind the stack.
Definition: Core.cpp:535
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:2278
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:1308
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:1313
LLVMValueRef LLVMGetPreviousFunction(LLVMValueRef Fn)
Decrement a Function iterator to the previous Function.
Definition: Core.cpp:2306
char * LLVMPrintModuleToString(LLVMModuleRef M)
Return a string representation of the module.
Definition: Core.cpp:436
void LLVMGetNamedMetadataOperands(LLVMModuleRef M, const char *Name, LLVMValueRef *Dest)
Obtain the named metadata operands for a module.
Definition: Core.cpp:1351
LLVMValueRef LLVMGetNextFunction(LLVMValueRef Fn)
Advance a Function iterator to the next Function.
Definition: Core.cpp:2298
LLVMTypeRef LLVMGetInlineAsmFunctionType(LLVMValueRef InlineAsmVal)
Get the function type of the inline assembly snippet.
Definition: Core.cpp:520
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:1361
LLVMNamedMDNodeRef LLVMGetFirstNamedMetadata(LLVMModuleRef M)
Obtain an iterator to the first NamedMDNode in a Module.
Definition: Core.cpp:1276
LLVMValueRef LLVMGetOperandBundleArgAtIndex(LLVMOperandBundleRef Bundle, unsigned Index)
Obtain the operand for an operand bundle at the given index.
Definition: Core.cpp:2612
unsigned LLVMGetNumOperandBundleArgs(LLVMOperandBundleRef Bundle)
Obtain the number of operands for an operand bundle.
Definition: Core.cpp:2608
LLVMOperandBundleRef LLVMCreateOperandBundle(const char *Tag, size_t TagLen, LLVMValueRef *Args, unsigned NumArgs)
Create a new operand bundle.
Definition: Core.cpp:2591
void LLVMDisposeOperandBundle(LLVMOperandBundleRef Bundle)
Destroy an operand bundle.
Definition: Core.cpp:2598
const char * LLVMGetOperandBundleTag(LLVMOperandBundleRef Bundle, size_t *Len)
Obtain the tag of an operand bundle as a string.
Definition: Core.cpp:2602
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:4263
LLVMPassManagerRef LLVMCreateFunctionPassManager(LLVMModuleProviderRef P)
Deprecated: Use LLVMCreateFunctionPassManagerForModule instead.
Definition: Core.cpp:4258
LLVMPassManagerRef LLVMCreatePassManager()
Constructs a new whole-module pass pipeline.
Definition: Core.cpp:4250
void LLVMDisposePassManager(LLVMPassManagerRef PM)
Frees the memory of a pass pipeline.
Definition: Core.cpp:4279
LLVMBool LLVMFinalizeFunctionPassManager(LLVMPassManagerRef FPM)
Finalizes all of the function passes scheduled in the function pass manager.
Definition: Core.cpp:4275
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:4271
LLVMBool LLVMInitializeFunctionPassManager(LLVMPassManagerRef FPM)
Initializes all of the function passes scheduled in the function pass manager.
Definition: Core.cpp:4267
LLVMPassManagerRef LLVMCreateFunctionPassManagerForModule(LLVMModuleRef M)
Constructs a new function-by-function pass pipeline over the module provider.
Definition: Core.cpp:4254
LLVMBool LLVMIsMultithreaded()
Check whether LLVM is executing in thread-safe mode or not.
Definition: Core.cpp:4292
LLVMBool LLVMStartMultithreaded()
Deprecated: Multi-threading can only be enabled/disabled with the compile time define LLVM_ENABLE_THR...
Definition: Core.cpp:4285
void LLVMStopMultithreaded()
Deprecated: Multi-threading can only be enabled/disabled with the compile time define LLVM_ENABLE_THR...
Definition: Core.cpp:4289
LLVMTypeRef LLVMFP128Type(void)
Definition: Core.cpp:722
LLVMTypeRef LLVMFP128TypeInContext(LLVMContextRef C)
Obtain a 128-bit floating point type (112-bit mantissa) from a context.
Definition: Core.cpp:694
LLVMTypeRef LLVMDoubleTypeInContext(LLVMContextRef C)
Obtain a 64-bit floating point type from a context.
Definition: Core.cpp:688
LLVMTypeRef LLVMX86FP80TypeInContext(LLVMContextRef C)
Obtain a 80-bit floating point type (X87) from a context.
Definition: Core.cpp:691
LLVMTypeRef LLVMHalfTypeInContext(LLVMContextRef C)
Obtain a 16-bit floating point type from a context.
Definition: Core.cpp:679
LLVMTypeRef LLVMBFloatTypeInContext(LLVMContextRef C)
Obtain a 16-bit brain floating point type from a context.
Definition: Core.cpp:682
LLVMTypeRef LLVMBFloatType(void)
Definition: Core.cpp:710
LLVMTypeRef LLVMFloatTypeInContext(LLVMContextRef C)
Obtain a 32-bit floating point type from a context.
Definition: Core.cpp:685
LLVMTypeRef LLVMHalfType(void)
Obtain a floating point type from the global context.
Definition: Core.cpp:707
LLVMTypeRef LLVMX86FP80Type(void)
Definition: Core.cpp:719
LLVMTypeRef LLVMPPCFP128Type(void)
Definition: Core.cpp:725
LLVMTypeRef LLVMFloatType(void)
Definition: Core.cpp:713
LLVMTypeRef LLVMDoubleType(void)
Definition: Core.cpp:716
LLVMTypeRef LLVMPPCFP128TypeInContext(LLVMContextRef C)
Obtain a 128-bit floating point type (two 64-bits) from a context.
Definition: Core.cpp:697
LLVMBool LLVMIsFunctionVarArg(LLVMTypeRef FunctionTy)
Returns whether a function type is variadic.
Definition: Core.cpp:744
unsigned LLVMCountParamTypes(LLVMTypeRef FunctionTy)
Obtain the number of parameters this function accepts.
Definition: Core.cpp:752
void LLVMGetParamTypes(LLVMTypeRef FunctionTy, LLVMTypeRef *Dest)
Obtain the types of a function's parameters.
Definition: Core.cpp:756
LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType, LLVMTypeRef *ParamTypes, unsigned ParamCount, LLVMBool IsVarArg)
Obtain a function type consisting of a specified signature.
Definition: Core.cpp:737
LLVMTypeRef LLVMGetReturnType(LLVMTypeRef FunctionTy)
Obtain the Type this function Type returns.
Definition: Core.cpp:748
LLVMTypeRef LLVMInt64Type(void)
Definition: Core.cpp:663
LLVMTypeRef LLVMInt64TypeInContext(LLVMContextRef C)
Definition: Core.cpp:641
LLVMTypeRef LLVMInt16TypeInContext(LLVMContextRef C)
Definition: Core.cpp:635
LLVMTypeRef LLVMIntTypeInContext(LLVMContextRef C, unsigned NumBits)
Definition: Core.cpp:647
LLVMTypeRef LLVMInt1TypeInContext(LLVMContextRef C)
Obtain an integer type from a context with specified bit width.
Definition: Core.cpp:629
LLVMTypeRef LLVMInt32Type(void)
Definition: Core.cpp:660
LLVMTypeRef LLVMInt32TypeInContext(LLVMContextRef C)
Definition: Core.cpp:638
LLVMTypeRef LLVMInt128TypeInContext(LLVMContextRef C)
Definition: Core.cpp:644
LLVMTypeRef LLVMIntType(unsigned NumBits)
Definition: Core.cpp:669
LLVMTypeRef LLVMInt8TypeInContext(LLVMContextRef C)
Definition: Core.cpp:632
LLVMTypeRef LLVMInt8Type(void)
Definition: Core.cpp:654
LLVMTypeRef LLVMInt1Type(void)
Obtain an integer type from the global context with a specified bit width.
Definition: Core.cpp:651
LLVMTypeRef LLVMInt128Type(void)
Definition: Core.cpp:666
unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy)
Definition: Core.cpp:673
LLVMTypeRef LLVMInt16Type(void)
Definition: Core.cpp:657
LLVMTypeRef LLVMX86MMXTypeInContext(LLVMContextRef C)
Create a X86 MMX type in a context.
Definition: Core.cpp:700
LLVMTypeRef LLVMVoidType(void)
These are similar to the above functions except they operate on the global context.
Definition: Core.cpp:911
LLVMTypeRef LLVMX86AMXTypeInContext(LLVMContextRef C)
Create a X86 AMX type in a context.
Definition: Core.cpp:703
LLVMTypeRef LLVMMetadataTypeInContext(LLVMContextRef C)
Create a metadata type in a context.
Definition: Core.cpp:907
LLVMTypeRef LLVMTokenTypeInContext(LLVMContextRef C)
Create a token type in a context.
Definition: Core.cpp:904
LLVMTypeRef LLVMX86AMXType(void)
Definition: Core.cpp:731
LLVMTypeRef LLVMLabelTypeInContext(LLVMContextRef C)
Create a label type in a context.
Definition: Core.cpp:901
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:918
LLVMTypeRef LLVMX86MMXType(void)
Definition: Core.cpp:728
LLVMTypeRef LLVMLabelType(void)
Definition: Core.cpp:914
LLVMTypeRef LLVMVoidTypeInContext(LLVMContextRef C)
Create a void type in a context.
Definition: Core.cpp:898
unsigned LLVMGetArrayLength(LLVMTypeRef ArrayTy)
Obtain the length of an array type.
Definition: Core.cpp:876
LLVMTypeRef LLVMGetElementType(LLVMTypeRef WrappedTy)
Obtain the element type of an array or vector type.
Definition: Core.cpp:865
unsigned LLVMGetPointerAddressSpace(LLVMTypeRef PointerTy)
Obtain the address space of a pointer type.
Definition: Core.cpp:884
uint64_t LLVMGetArrayLength2(LLVMTypeRef ArrayTy)
Obtain the length of an array type.
Definition: Core.cpp:880
LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, unsigned AddressSpace)
Create a pointer type that points to a defined type.
Definition: Core.cpp:848
unsigned LLVMGetNumContainedTypes(LLVMTypeRef Tp)
Return the number of types in the derived type.
Definition: Core.cpp:872
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:856
LLVMBool LLVMPointerTypeIsOpaque(LLVMTypeRef Ty)
Determine whether a pointer is opaque.
Definition: Core.cpp:852
LLVMTypeRef LLVMPointerTypeInContext(LLVMContextRef C, unsigned AddressSpace)
Create an opaque pointer type in a context.
Definition: Core.cpp:894
LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount)
Create a fixed size array type that refers to a specific type.
Definition: Core.cpp:840
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:860
LLVMTypeRef LLVMArrayType2(LLVMTypeRef ElementType, uint64_t ElementCount)
Create a fixed size array type that refers to a specific type.
Definition: Core.cpp:844
void LLVMGetSubtypes(LLVMTypeRef Tp, LLVMTypeRef *Arr)
Returns type's subtypes.
Definition: Core.cpp:832
unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy)
Obtain the (possibly scalable) number of elements in a vector type.
Definition: Core.cpp:888
void LLVMStructSetBody(LLVMTypeRef StructTy, LLVMTypeRef *ElementTypes, unsigned ElementCount, LLVMBool Packed)
Set the contents of a structure type.
Definition: Core.cpp:789
LLVMBool LLVMIsPackedStruct(LLVMTypeRef StructTy)
Determine whether a structure is packed.
Definition: Core.cpp:810
LLVMTypeRef LLVMStructGetTypeAtIndex(LLVMTypeRef StructTy, unsigned i)
Get the type of the element at a given index in the structure.
Definition: Core.cpp:805
LLVMTypeRef LLVMStructType(LLVMTypeRef *ElementTypes, unsigned ElementCount, LLVMBool Packed)
Create a new structure type in the global context.
Definition: Core.cpp:770
const char * LLVMGetStructName(LLVMTypeRef Ty)
Obtain the name of a structure.
Definition: Core.cpp:781
void LLVMGetStructElementTypes(LLVMTypeRef StructTy, LLVMTypeRef *Dest)
Get the elements within a structure.
Definition: Core.cpp:799
LLVMBool LLVMIsOpaqueStruct(LLVMTypeRef StructTy)
Determine whether a structure is opaque.
Definition: Core.cpp:814
unsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy)
Get the number of elements defined inside the structure.
Definition: Core.cpp:795
LLVMTypeRef LLVMStructCreateNamed(LLVMContextRef C, const char *Name)
Create an empty structure in a context having a specified name.
Definition: Core.cpp:776
LLVMBool LLVMIsLiteralStruct(LLVMTypeRef StructTy)
Determine whether a structure is literal.
Definition: Core.cpp:818
LLVMTypeRef LLVMStructTypeInContext(LLVMContextRef C, LLVMTypeRef *ElementTypes, unsigned ElementCount, LLVMBool Packed)
Create a new structure type in a context.
Definition: Core.cpp:764
LLVMBool LLVMTypeIsSized(LLVMTypeRef Ty)
Whether the type has a known size.
Definition: Core.cpp:600
LLVMTypeKind LLVMGetTypeKind(LLVMTypeRef Ty)
Obtain the enumerated type of a Type instance.
Definition: Core.cpp:550
char * LLVMPrintTypeToString(LLVMTypeRef Ty)
Return a string representation of the type.
Definition: Core.cpp:613
void LLVMDumpType(LLVMTypeRef Ty)
Dump a representation of a type to stderr.
Definition: Core.cpp:609
LLVMContextRef LLVMGetTypeContext(LLVMTypeRef Ty)
Obtain the context to which this type instance is associated.
Definition: Core.cpp:605
LLVMTailCallKind
Tail call kind for LLVMSetTailCallKind and LLVMGetTailCallKind.
Definition: Core.h:477
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:484
LLVMIntPredicate
Definition: Core.h:291
unsigned LLVMFastMathFlags
Flags to indicate what fast-math-style optimizations are allowed on operations.
Definition: Core.h:507
LLVMUnnamedAddr
Definition: Core.h:201
LLVMModuleFlagBehavior
Definition: Core.h:407
LLVMDiagnosticSeverity
Definition: Core.h:395
LLVMVisibility
Definition: Core.h:195
LLVMAtomicRMWBinOp
Definition: Core.h:363
LLVMThreadLocalMode
Definition: Core.h:328
LLVMAtomicOrdering
Definition: Core.h:336
LLVMInlineAsmDialect
Definition: Core.h:402
@ 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:433
@ LLVMModuleFlagBehaviorWarning
Emits a warning if two values disagree.
Definition: Core.h:421
@ LLVMModuleFlagBehaviorOverride
Uses the specified value, regardless of the behavior or value of the other module.
Definition: Core.h:441
@ LLVMModuleFlagBehaviorAppendUnique
Appends the two values, which are required to be metadata nodes.
Definition: Core.h:455
@ LLVMModuleFlagBehaviorAppend
Appends the two values, which are required to be metadata nodes.
Definition: Core.h:447
@ LLVMModuleFlagBehaviorError
Emits an error if two values disagree, otherwise the resulting value is that of the operands.
Definition: Core.h:414
@ LLVMDSWarning
Definition: Core.h:397
@ LLVMDSNote
Definition: Core.h:399
@ LLVMDSError
Definition: Core.h:396
@ LLVMDSRemark
Definition: Core.h:398
@ 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
@ 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
@ 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:487
@ LLVMFastMathNoSignedZeros
Definition: Core.h:490
@ LLVMFastMathApproxFunc
Definition: Core.h:493
@ LLVMFastMathNoInfs
Definition: Core.h:489
@ LLVMFastMathNoNaNs
Definition: Core.h:488
@ LLVMFastMathNone
Definition: Core.h:494
@ LLVMFastMathAllowContract
Definition: Core.h:492
@ LLVMFastMathAllowReciprocal
Definition: Core.h:491
@ 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:403
@ LLVMInlineAsmDialectIntel
Definition: Core.h:404
LLVMBasicBlockRef LLVMGetNextBasicBlock(LLVMBasicBlockRef BB)
Advance a basic block iterator.
Definition: Core.cpp:2673
void LLVMAppendExistingBasicBlock(LLVMValueRef Fn, LLVMBasicBlockRef BB)
Append the given basic block to the basic block list of the given function.
Definition: Core.cpp:2702
void LLVMDeleteBasicBlock(LLVMBasicBlockRef BBRef)
Remove a basic block from a function and delete it.
Definition: Core.cpp:2729
LLVMBasicBlockRef LLVMGetFirstBasicBlock(LLVMValueRef Fn)
Obtain the first basic block in a function.
Definition: Core.cpp:2657
LLVMBasicBlockRef LLVMValueAsBasicBlock(LLVMValueRef Val)
Convert an LLVMValueRef to an LLVMBasicBlockRef instance.
Definition: Core.cpp:2627
LLVMBasicBlockRef LLVMCreateBasicBlockInContext(LLVMContextRef C, const char *Name)
Create a new basic block without inserting it into a function.
Definition: Core.cpp:2689
void LLVMRemoveBasicBlockFromParent(LLVMBasicBlockRef BBRef)
Remove a basic block from a function.
Definition: Core.cpp:2733
void LLVMMoveBasicBlockBefore(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos)
Move a basic block to before another one.
Definition: Core.cpp:2737
LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef BB)
Convert a basic block instance to a value type.
Definition: Core.cpp:2619
void LLVMInsertExistingBasicBlockAfterInsertBlock(LLVMBuilderRef Builder, LLVMBasicBlockRef BB)
Insert the given basic block after the insertion point of the given builder.
Definition: Core.cpp:2694
void LLVMGetBasicBlocks(LLVMValueRef FnRef, LLVMBasicBlockRef *BasicBlocksRefs)
Obtain all of the basic blocks in a function.
Definition: Core.cpp:2647
LLVMBasicBlockRef LLVMAppendBasicBlock(LLVMValueRef FnRef, const char *Name)
Append a basic block to the end of a function using the global context.
Definition: Core.cpp:2713
LLVMValueRef LLVMGetBasicBlockTerminator(LLVMBasicBlockRef BB)
Obtain the terminator instruction for a basic block.
Definition: Core.cpp:2639
unsigned LLVMCountBasicBlocks(LLVMValueRef FnRef)
Obtain the number of basic blocks in a function.
Definition: Core.cpp:2643
void LLVMMoveBasicBlockAfter(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos)
Move a basic block to after another one.
Definition: Core.cpp:2741
LLVMBasicBlockRef LLVMGetLastBasicBlock(LLVMValueRef Fn)
Obtain the last basic block in a function.
Definition: Core.cpp:2665
LLVMBasicBlockRef LLVMAppendBasicBlockInContext(LLVMContextRef C, LLVMValueRef FnRef, const char *Name)
Append a basic block to the end of a function.
Definition: Core.cpp:2707
LLVMValueRef LLVMGetBasicBlockParent(LLVMBasicBlockRef BB)
Obtain the function to which a basic block belongs.
Definition: Core.cpp:2635
LLVMValueRef LLVMGetFirstInstruction(LLVMBasicBlockRef BB)
Obtain the first instruction in a basic block.
Definition: Core.cpp:2751
LLVMValueRef LLVMGetLastInstruction(LLVMBasicBlockRef BB)
Obtain the last instruction in a basic block.
Definition: Core.cpp:2759
LLVMBasicBlockRef LLVMInsertBasicBlockInContext(LLVMContextRef C, LLVMBasicBlockRef BBRef, const char *Name)
Insert a basic block in a function before another basic block.
Definition: Core.cpp:2717
LLVMBasicBlockRef LLVMInsertBasicBlock(LLVMBasicBlockRef BBRef, const char *Name)
Insert a basic block in a function using the global context.
Definition: Core.cpp:2724
LLVMBasicBlockRef LLVMGetEntryBasicBlock(LLVMValueRef Fn)
Obtain the basic block that corresponds to the entry point of a function.
Definition: Core.cpp:2653
LLVMBool LLVMValueIsBasicBlock(LLVMValueRef Val)
Determine whether an LLVMValueRef is itself a basic block.
Definition: Core.cpp:2623
const char * LLVMGetBasicBlockName(LLVMBasicBlockRef BB)
Obtain the string name of a basic block.
Definition: Core.cpp:2631
LLVMBasicBlockRef LLVMGetPreviousBasicBlock(LLVMBasicBlockRef BB)
Go backwards in a basic block iterator.
Definition: Core.cpp:2681
LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count, LLVMBool Packed)
Create a ConstantStruct in the global Context.
Definition: Core.cpp:1578
LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy, LLVMValueRef *ConstantVals, unsigned Length)
Create a ConstantArray from values.
Definition: Core.cpp:1558
LLVMValueRef LLVMConstArray2(LLVMTypeRef ElementTy, LLVMValueRef *ConstantVals, uint64_t Length)
Create a ConstantArray from values.
Definition: Core.cpp:1564
LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size)
Create a ConstantVector from values.
Definition: Core.cpp:1593
LLVMValueRef LLVMConstStringInContext(LLVMContextRef C, const char *Str, unsigned Length, LLVMBool DontNullTerminate)
Create a ConstantDataSequential and initialize it with a string.
Definition: Core.cpp:1516
LLVMValueRef LLVMConstNamedStruct(LLVMTypeRef StructTy, LLVMValueRef *ConstantVals, unsigned Count)
Create a non-anonymous ConstantStruct from values.
Definition: Core.cpp:1584
LLVMBool LLVMIsConstantString(LLVMValueRef C)
Returns true if the specified constant is an array of i8.
Definition: Core.cpp:1548
LLVMValueRef LLVMGetAggregateElement(LLVMValueRef C, unsigned Idx)
Get element of a constant aggregate (struct, array or vector) at the specified index.
Definition: Core.cpp:1540
LLVMValueRef LLVMConstString(const char *Str, unsigned Length, LLVMBool DontNullTerminate)
Create a ConstantDataSequential with string content in the global context.
Definition: Core.cpp:1534
const char * LLVMGetAsString(LLVMValueRef C, size_t *Length)
Get the given constant data sequential as a string.
Definition: Core.cpp:1552
LLVMValueRef LLVMConstStringInContext2(LLVMContextRef C, const char *Str, size_t Length, LLVMBool DontNullTerminate)
Create a ConstantDataSequential and initialize it with a string.
Definition: Core.cpp:1525
LLVMValueRef LLVMConstStructInContext(LLVMContextRef C, LLVMValueRef *ConstantVals, unsigned Count, LLVMBool Packed)
Create an anonymous ConstantStruct with the specified values.
Definition: Core.cpp:1570
LLVMValueRef LLVMConstPointerCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition: Core.cpp:1775
LLVMValueRef LLVMConstMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1685
LLVMValueRef LLVMConstTruncOrBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition: Core.cpp:1769
LLVMValueRef LLVMSizeOf(LLVMTypeRef Ty)
Definition: Core.cpp:1630
LLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition: Core.cpp:1748
LLVMValueRef LLVMConstNUWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1679
LLVMValueRef LLVMConstNUWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1662
LLVMValueRef LLVMConstIntToPtr(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition: Core.cpp:1753
LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition: Core.cpp:1743
LLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal)
Definition: Core.cpp:1647
LLVMValueRef LLVMGetBlockAddressFunction(LLVMValueRef BlockAddr)
Gets the function associated with a given BlockAddress constant value.
Definition: Core.cpp:1817
LLVMValueRef LLVMConstNSWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1690
LLVMValueRef LLVMConstExtractElement(LLVMValueRef VectorConstant, LLVMValueRef IndexConstant)
Definition: Core.cpp:1781
LLVMValueRef LLVMConstInsertElement(LLVMValueRef VectorConstant, LLVMValueRef ElementValueConstant, LLVMValueRef IndexConstant)
Definition: Core.cpp:1787
LLVMValueRef LLVMConstInBoundsGEP2(LLVMTypeRef Ty, LLVMValueRef ConstantVal, LLVMValueRef *ConstantIndices, unsigned NumIndices)
Definition: Core.cpp:1734
LLVMValueRef LLVMConstAddrSpaceCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition: Core.cpp:1763
LLVMValueRef LLVMConstICmp(LLVMIntPredicate Predicate, LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1707
LLVMBasicBlockRef LLVMGetBlockAddressBasicBlock(LLVMValueRef BlockAddr)
Gets the basic block associated with a given BlockAddress constant value.
Definition: Core.cpp:1821
LLVMValueRef LLVMConstNSWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1656
LLVMValueRef LLVMAlignOf(LLVMTypeRef Ty)
Definition: Core.cpp:1626
LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty, const char *AsmString, const char *Constraints, LLVMBool HasSideEffects, LLVMBool IsAlignStack)
Deprecated: Use LLVMGetInlineAsm instead.
Definition: Core.cpp:1805
LLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1702
LLVMValueRef LLVMConstBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition: Core.cpp:1758
LLVMValueRef LLVMConstNSWNeg(LLVMValueRef ConstantVal)
Definition: Core.cpp:1638
LLVMValueRef LLVMConstNUWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1696
LLVMValueRef LLVMConstShl(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1721
LLVMValueRef LLVMConstFCmp(LLVMRealPredicate Predicate, LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1714
LLVMValueRef LLVMConstNUWNeg(LLVMValueRef ConstantVal)
Definition: Core.cpp:1642
LLVMValueRef LLVMConstGEP2(LLVMTypeRef Ty, LLVMValueRef ConstantVal, LLVMValueRef *ConstantIndices, unsigned NumIndices)
Definition: Core.cpp:1726
LLVMValueRef LLVMConstSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1668
LLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1651
LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant, LLVMValueRef VectorBConstant, LLVMValueRef MaskConstant)
Definition: Core.cpp:1795
LLVMValueRef LLVMConstNeg(LLVMValueRef ConstantVal)
Definition: Core.cpp:1634
LLVMValueRef LLVMBlockAddress(LLVMValueRef F, LLVMBasicBlockRef BB)
Definition: Core.cpp:1813
LLVMOpcode LLVMGetConstOpcode(LLVMValueRef ConstantVal)
Definition: Core.cpp:1622
LLVMValueRef LLVMConstNSWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1673
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:2071
unsigned LLVMValueMetadataEntriesGetKind(LLVMValueMetadataEntry *Entries, unsigned Index)
Returns the kind of a value metadata entry at a specific index.
Definition: Core.cpp:2052
void LLVMDisposeValueMetadataEntries(LLVMValueMetadataEntry *Entries)
Destroys value metadata entries.
Definition: Core.cpp:2067
void LLVMSetVisibility(LLVMValueRef Global, LLVMVisibility Viz)
Definition: Core.cpp:1944
LLVMDLLStorageClass LLVMGetDLLStorageClass(LLVMValueRef Global)
Definition: Core.cpp:1949
void LLVMSetAlignment(LLVMValueRef V, unsigned Bytes)
Set the preferred alignment of the value.
Definition: Core.cpp:2020
LLVMModuleRef LLVMGetGlobalParent(LLVMValueRef Global)
Definition: Core.cpp:1827
const char * LLVMGetSection(LLVMValueRef Global)
Definition: Core.cpp:1929
LLVMTypeRef LLVMGlobalGetValueType(LLVMValueRef Global)
Returns the "value type" of a global value.
Definition: Core.cpp:1994
LLVMBool LLVMIsDeclaration(LLVMValueRef Global)
Definition: Core.cpp:1831
LLVMVisibility LLVMGetVisibility(LLVMValueRef Global)
Definition: Core.cpp:1939
void LLVMSetDLLStorageClass(LLVMValueRef Global, LLVMDLLStorageClass Class)
Definition: Core.cpp:1954
LLVMBool LLVMHasUnnamedAddr(LLVMValueRef Global)
Deprecated: Use LLVMGetUnnamedAddress instead.
Definition: Core.cpp:1984
LLVMLinkage LLVMGetLinkage(LLVMValueRef Global)
Definition: Core.cpp:1835
LLVMUnnamedAddr LLVMGetUnnamedAddress(LLVMValueRef Global)
Definition: Core.cpp:1959
LLVMMetadataRef LLVMValueMetadataEntriesGetMetadata(LLVMValueMetadataEntry *Entries, unsigned Index)
Returns the underlying metadata node of a value metadata entry at a specific index.
Definition: Core.cpp:2060
void LLVMSetUnnamedAddress(LLVMValueRef Global, LLVMUnnamedAddr UnnamedAddr)
Definition: Core.cpp:1971
void LLVMSetLinkage(LLVMValueRef Global, LLVMLinkage Linkage)
Definition: Core.cpp:1864
void LLVMSetUnnamedAddr(LLVMValueRef Global, LLVMBool HasUnnamedAddr)
Deprecated: Use LLVMSetUnnamedAddress instead.
Definition: Core.cpp:1988
void LLVMGlobalClearMetadata(LLVMValueRef Global)
Removes all metadata attachments from this value.
Definition: Core.cpp:2080
unsigned LLVMGetAlignment(LLVMValueRef V)
Obtain the preferred alignment of the value.
Definition: Core.cpp:2000
void LLVMSetSection(LLVMValueRef Global, const char *Section)
Definition: Core.cpp:1935
void LLVMGlobalEraseMetadata(LLVMValueRef Global, unsigned Kind)
Erases a metadata attachment of the given kind if it exists.
Definition: Core.cpp:2076
LLVMValueMetadataEntry * LLVMGlobalCopyAllMetadata(LLVMValueRef Value, size_t *NumEntries)
Retrieves an array of metadata entries representing the metadata attached to this value.
Definition: Core.cpp:2040
LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N, LLVMBool SignExtend)
Obtain a constant value for an integer type.
Definition: Core.cpp:1451
LLVMValueRef LLVMConstIntOfArbitraryPrecision(LLVMTypeRef IntTy, unsigned NumWords, const uint64_t Words[])
Obtain a constant value for an integer of arbitrary precision.
Definition: Core.cpp:1456
LLVMValueRef LLVMConstRealOfString(LLVMTypeRef RealTy, const char *Text)
Obtain a constant for a floating point value parsed from a string.
Definition: Core.cpp:1480
double LLVMConstRealGetDouble(LLVMValueRef ConstantVal, LLVMBool *LosesInfo)
Obtain the double value for an floating point constant value.
Definition: Core.cpp:1497
long long LLVMConstIntGetSExtValue(LLVMValueRef ConstantVal)
Obtain the sign extended value for an integer constant value.
Definition: Core.cpp:1493
unsigned long long LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal)
Obtain the zero extended value for an integer constant value.
Definition: Core.cpp:1489
LLVMValueRef LLVMConstReal(LLVMTypeRef RealTy, double N)
Obtain a constant value referring to a double floating point value.
Definition: Core.cpp:1476
LLVMBool LLVMIsNull(LLVMValueRef Val)
Determine whether a value instance is null.
Definition: Core.cpp:1174
LLVMValueRef LLVMGetUndef(LLVMTypeRef Ty)
Obtain a constant value referring to an undefined value of a type.
Definition: Core.cpp:1162
LLVMValueRef LLVMGetPoison(LLVMTypeRef Ty)
Obtain a constant value referring to a poison value of a type.
Definition: Core.cpp:1166
LLVMValueRef LLVMConstAllOnes(LLVMTypeRef Ty)
Obtain a constant value referring to the instance of a type consisting of all ones.
Definition: Core.cpp:1158
LLVMValueRef LLVMConstPointerNull(LLVMTypeRef Ty)
Obtain a constant that is a constant pointer pointing to NULL for a specified type.
Definition: Core.cpp:1188
LLVMValueRef LLVMConstNull(LLVMTypeRef Ty)
Obtain a constant value referring to the null instance of a type.
Definition: Core.cpp:1154
unsigned LLVMCountParams(LLVMValueRef FnRef)
Obtain the number of parameters in a function.
Definition: Core.cpp:2467
LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg)
Obtain the previous parameter to a function.
Definition: Core.cpp:2512
LLVMValueRef LLVMGetNextParam(LLVMValueRef Arg)
Obtain the next parameter to a function.
Definition: Core.cpp:2504
LLVMValueRef LLVMGetParamParent(LLVMValueRef V)
Obtain the function to which this argument belongs.
Definition: Core.cpp:2484
LLVMValueRef LLVMGetFirstParam(LLVMValueRef Fn)
Obtain the first parameter to a function.
Definition: Core.cpp:2488
void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align)
Set the alignment for a function parameter.
Definition: Core.cpp:2519
LLVMValueRef LLVMGetParam(LLVMValueRef FnRef, unsigned index)
Obtain the parameter at the specified index.
Definition: Core.cpp:2479
LLVMValueRef LLVMGetLastParam(LLVMValueRef Fn)
Obtain the last parameter to a function.
Definition: Core.cpp:2496
void LLVMGetParams(LLVMValueRef FnRef, LLVMValueRef *ParamRefs)
Obtain the parameters in a function.
Definition: Core.cpp:2473
void LLVMSetGC(LLVMValueRef Fn, const char *GC)
Define the garbage collector to use during code generation.
Definition: Core.cpp:2409
const char * LLVMGetGC(LLVMValueRef Fn)
Obtain the name of the garbage collector to use during code generation.
Definition: Core.cpp:2404
void LLVMRemoveEnumAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx, unsigned KindID)
Definition: Core.cpp:2448
unsigned LLVMGetAttributeCountAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx)
Definition: Core.cpp:2422
LLVMBool LLVMHasPersonalityFn(LLVMValueRef Fn)
Check whether the given function has a personality function.
Definition: Core.cpp:2318
unsigned LLVMLookupIntrinsicID(const char *Name, size_t NameLen)
Obtain the intrinsic ID number which matches the given function name.
Definition: Core.cpp:2386
const char * LLVMIntrinsicGetName(unsigned ID, size_t *NameLength)
Retrieves the name of an intrinsic.
Definition: Core.cpp:2350
unsigned LLVMGetFunctionCallConv(LLVMValueRef Fn)
Obtain the calling function of a function.
Definition: Core.cpp:2395
void LLVMRemoveStringAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx, const char *K, unsigned KLen)
Definition: Core.cpp:2453
LLVMAttributeRef LLVMGetStringAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx, const char *K, unsigned KLen)
Definition: Core.cpp:2441
LLVMValueRef LLVMGetPersonalityFn(LLVMValueRef Fn)
Obtain the personality function attached to the function.
Definition: Core.cpp:2322
void LLVMSetPersonalityFn(LLVMValueRef Fn, LLVMValueRef PersonalityFn)
Set the personality function attached to the function.
Definition: Core.cpp:2326
LLVMBool LLVMIntrinsicIsOverloaded(unsigned ID)
Obtain if the intrinsic identified by the given ID is overloaded.
Definition: Core.cpp:2390
void LLVMAddAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx, LLVMAttributeRef A)
Add an attribute to a function.
Definition: Core.cpp:2417
void LLVMDeleteFunction(LLVMValueRef Fn)
Remove a function from its containing module and deletes it.
Definition: Core.cpp:2314
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:2375
const char * LLVMIntrinsicCopyOverloadedName(unsigned ID, LLVMTypeRef *ParamTypes, size_t ParamCount, size_t *NameLength)
Deprecated: Use LLVMIntrinsicCopyOverloadedName2 instead.
Definition: Core.cpp:2364
void LLVMGetAttributesAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx, LLVMAttributeRef *Attrs)
Definition: Core.cpp:2427
void LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC)
Set the calling convention of a function.
Definition: Core.cpp:2399
LLVMValueRef LLVMGetIntrinsicDeclaration(LLVMModuleRef Mod, unsigned ID, LLVMTypeRef *ParamTypes, size_t ParamCount)
Create or insert the declaration of an intrinsic.
Definition: Core.cpp:2341
LLVMAttributeRef LLVMGetEnumAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx, unsigned KindID)
Definition: Core.cpp:2434
void LLVMAddTargetDependentFunctionAttr(LLVMValueRef Fn, const char *A, const char *V)
Add a target-dependent attribute to a function.
Definition: Core.cpp:2458
LLVMTypeRef LLVMIntrinsicGetType(LLVMContextRef Ctx, unsigned ID, LLVMTypeRef *ParamTypes, size_t ParamCount)
Retrieves the type of an intrinsic.
Definition: Core.cpp:2357
unsigned LLVMGetIntrinsicID(LLVMValueRef Fn)
Obtain the ID number from a function instance.
Definition: Core.cpp:2330
LLVMValueKind LLVMGetValueKind(LLVMValueRef Val)
Obtain the enumerated type of a Value instance.
Definition: Core.cpp:937
const char * LLVMGetValueName(LLVMValueRef Val)
Deprecated: Use LLVMGetValueName2 instead.
Definition: Core.cpp:959
LLVMTypeRef LLVMTypeOf(LLVMValueRef Val)
Obtain the type of a value.
Definition: Core.cpp:933
LLVMBool LLVMIsConstant(LLVMValueRef Ty)
Determine whether the specified value instance is constant.
Definition: Core.cpp:1170
void LLVMReplaceAllUsesWith(LLVMValueRef OldVal, LLVMValueRef NewVal)
Replace all uses of a value with another one.
Definition: Core.cpp:985
const char * LLVMGetValueName2(LLVMValueRef Val, size_t *Length)
Obtain the string name of a value.
Definition: Core.cpp:949
void LLVMSetValueName(LLVMValueRef Val, const char *Name)
Deprecated: Use LLVMSetValueName2 instead.
Definition: Core.cpp:963
void LLVMDumpValue(LLVMValueRef Val)
Dump a representation of a value to stderr.
Definition: Core.cpp:967
LLVMBool LLVMIsUndef(LLVMValueRef Val)
Determine whether a value instance is undefined.
Definition: Core.cpp:1180
LLVMValueRef LLVMIsAMDNode(LLVMValueRef Val)
Definition: Core.cpp:1063
LLVMBool LLVMIsPoison(LLVMValueRef Val)
Determine whether a value instance is poisonous.
Definition: Core.cpp:1184
LLVMValueRef LLVMIsAMDString(LLVMValueRef Val)
Definition: Core.cpp:1078
void LLVMSetValueName2(LLVMValueRef Val, const char *Name, size_t NameLen)
Set the string name of a value.
Definition: Core.cpp:955
LLVMValueRef LLVMIsAValueAsMetadata(LLVMValueRef Val)
Definition: Core.cpp:1071
char * LLVMPrintValueToString(LLVMValueRef Val)
Return a string representation of the value.
Definition: Core.cpp:971
void LLVMEraseGlobalIFunc(LLVMValueRef IFunc)
Remove a global indirect function from its parent module and delete it.
Definition: Core.cpp:2581
void LLVMRemoveGlobalIFunc(LLVMValueRef IFunc)
Remove a global indirect function from its parent module.
Definition: Core.cpp:2585
LLVMValueRef LLVMGetNextGlobalIFunc(LLVMValueRef IFunc)
Advance a GlobalIFunc iterator to the next GlobalIFunc.
Definition: Core.cpp:2557
LLVMValueRef LLVMGetNamedGlobalIFunc(LLVMModuleRef M, const char *Name, size_t NameLen)
Obtain a GlobalIFunc value from a Module by its name.
Definition: Core.cpp:2536
LLVMValueRef LLVMGetLastGlobalIFunc(LLVMModuleRef M)
Obtain an iterator to the last GlobalIFunc in a Module.
Definition: Core.cpp:2549
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:2526
void LLVMSetGlobalIFuncResolver(LLVMValueRef IFunc, LLVMValueRef Resolver)
Sets the resolver function associated with this indirect function.
Definition: Core.cpp:2577
LLVMValueRef LLVMGetFirstGlobalIFunc(LLVMModuleRef M)
Obtain an iterator to the first GlobalIFunc in a Module.
Definition: Core.cpp:2541
LLVMValueRef LLVMGetGlobalIFuncResolver(LLVMValueRef IFunc)
Retrieves the resolver function associated with this indirect function, or NULL if it doesn't not exi...
Definition: Core.cpp:2573
LLVMValueRef LLVMGetPreviousGlobalIFunc(LLVMValueRef IFunc)
Decrement a GlobalIFunc iterator to the previous GlobalIFunc.
Definition: Core.cpp:2565
LLVMTypeRef LLVMGetAllocatedType(LLVMValueRef Alloca)
Obtain the type that is being allocated by the alloca instruction.
Definition: Core.cpp:3000
LLVMOperandBundleRef LLVMGetOperandBundleAtIndex(LLVMValueRef C, unsigned Index)
Obtain the operand bundle attached to this instruction at the given index.
Definition: Core.cpp:2912
LLVMValueRef LLVMGetCalledValue(LLVMValueRef Instr)
Obtain the pointer to the function invoked by this instruction.
Definition: Core.cpp:2900
void LLVMGetCallSiteAttributes(LLVMValueRef C, LLVMAttributeIndex Idx, LLVMAttributeRef *Attrs)
Definition: Core.cpp:2868
unsigned LLVMGetNumArgOperands(LLVMValueRef Instr)
Obtain the argument count for a call instruction.
Definition: Core.cpp:2830
void LLVMSetNormalDest(LLVMValueRef Invoke, LLVMBasicBlockRef B)
Set the normal destination basic block.
Definition: Core.cpp:2951
unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr)
Obtain the calling convention for a call instruction.
Definition: Core.cpp:2839
LLVMTypeRef LLVMGetCalledFunctionType(LLVMValueRef Instr)
Obtain the function type called by this instruction.
Definition: Core.cpp:2904
unsigned LLVMGetCallSiteAttributeCount(LLVMValueRef C, LLVMAttributeIndex Idx)
Definition: Core.cpp:2861
void LLVMAddCallSiteAttribute(LLVMValueRef C, LLVMAttributeIndex Idx, LLVMAttributeRef A)
Definition: Core.cpp:2856
unsigned LLVMGetNumOperandBundles(LLVMValueRef C)
Obtain the number of operand bundles attached to this instruction.
Definition: Core.cpp:2908
void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC)
Set the calling convention for a call instruction.
Definition: Core.cpp:2843
LLVMAttributeRef LLVMGetCallSiteEnumAttribute(LLVMValueRef C, LLVMAttributeIndex Idx, unsigned KindID)
Definition: Core.cpp:2876
LLVMBasicBlockRef LLVMGetNormalDest(LLVMValueRef Invoke)
Return the normal destination basic block.
Definition: Core.cpp:2938
void LLVMRemoveCallSiteEnumAttribute(LLVMValueRef C, LLVMAttributeIndex Idx, unsigned KindID)
Definition: Core.cpp:2890
void LLVMSetUnwindDest(LLVMValueRef Invoke, LLVMBasicBlockRef B)
Set the unwind destination basic block.
Definition: Core.cpp:2955
void LLVMSetTailCall(LLVMValueRef Call, LLVMBool isTailCall)
Set whether a call instruction is a tail call.
Definition: Core.cpp:2924
LLVMBool LLVMIsTailCall(LLVMValueRef Call)
Obtain whether a call instruction is a tail call.
Definition: Core.cpp:2920
void LLVMSetInstrParamAlignment(LLVMValueRef Instr, LLVMAttributeIndex Idx, unsigned align)
Definition: Core.cpp:2848
void LLVMRemoveCallSiteStringAttribute(LLVMValueRef C, LLVMAttributeIndex Idx, const char *K, unsigned KLen)
Definition: Core.cpp:2895
LLVMTailCallKind LLVMGetTailCallKind(LLVMValueRef Call)
Obtain a tail call kind of the call instruction.
Definition: Core.cpp:2928
void LLVMSetTailCallKind(LLVMValueRef Call, LLVMTailCallKind kind)
Set the call kind of the call instruction.
Definition: Core.cpp:2932
LLVMAttributeRef LLVMGetCallSiteStringAttribute(LLVMValueRef C, LLVMAttributeIndex Idx, const char *K, unsigned KLen)
Definition: Core.cpp:2883
LLVMBasicBlockRef LLVMGetUnwindDest(LLVMValueRef Invoke)
Return the unwind destination basic block.
Definition: Core.cpp:2942
LLVMTypeRef LLVMGetGEPSourceElementType(LLVMValueRef GEP)
Get the source element type of the given GEP operator.
Definition: Core.cpp:3014
LLVMBool LLVMIsInBounds(LLVMValueRef GEP)
Check whether the given GEP operator is inbounds.
Definition: Core.cpp:3006
void LLVMSetIsInBounds(LLVMValueRef GEP, LLVMBool InBounds)
Set the given GEP instruction to be inbounds or not.
Definition: Core.cpp:3010
const unsigned * LLVMGetIndices(LLVMValueRef Inst)
Obtain the indices as an array.
Definition: Core.cpp:3053
unsigned LLVMGetNumIndices(LLVMValueRef Inst)
Obtain the number of indices.
Definition: Core.cpp:3041
void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues, LLVMBasicBlockRef *IncomingBlocks, unsigned Count)
Add an incoming value to the end of a PHI list.
Definition: Core.cpp:3020
LLVMValueRef LLVMGetIncomingValue(LLVMValueRef PhiNode, unsigned Index)
Obtain an incoming value to a PHI node as an LLVMValueRef.
Definition: Core.cpp:3031
unsigned LLVMCountIncoming(LLVMValueRef PhiNode)
Obtain the number of incoming basic blocks to a PHI node.
Definition: Core.cpp:3027
LLVMBasicBlockRef LLVMGetIncomingBlock(LLVMValueRef PhiNode, unsigned Index)
Obtain an incoming value to a PHI node as an LLVMBasicBlockRef.
Definition: Core.cpp:3035
unsigned LLVMGetNumSuccessors(LLVMValueRef Term)
Return the number of successors that this terminator has.
Definition: Core.cpp:2966
LLVMBasicBlockRef LLVMGetSwitchDefaultDest(LLVMValueRef Switch)
Obtain the default destination basic block of a switch instruction.
Definition: Core.cpp:2994
void LLVMSetSuccessor(LLVMValueRef Term, unsigned i, LLVMBasicBlockRef block)
Update the specified successor to point at the provided block.
Definition: Core.cpp:2974
void LLVMSetCondition(LLVMValueRef Branch, LLVMValueRef Cond)
Set the condition of a branch instruction.
Definition: Core.cpp:2988
LLVMValueRef LLVMGetCondition(LLVMValueRef Branch)
Return the condition of a branch instruction.
Definition: Core.cpp:2984
LLVMBool LLVMIsConditional(LLVMValueRef Branch)
Return if a branch is conditional.
Definition: Core.cpp:2980
LLVMBasicBlockRef LLVMGetSuccessor(LLVMValueRef Term, unsigned i)
Return the specified successor.
Definition: Core.cpp:2970
LLVMValueRef LLVMInstructionClone(LLVMValueRef Inst)
Create a copy of 'this' instruction that is identical in all ways except the following:
Definition: Core.cpp:2819
LLVMValueRef LLVMGetNextInstruction(LLVMValueRef Inst)
Obtain the instruction that occurs after the one specified.
Definition: Core.cpp:2767
void LLVMDeleteInstruction(LLVMValueRef Inst)
Delete an instruction.
Definition: Core.cpp:2791
LLVMValueRef LLVMIsATerminatorInst(LLVMValueRef Inst)
Determine whether an instruction is a terminator.
Definition: Core.cpp:2825
LLVMOpcode LLVMGetInstructionOpcode(LLVMValueRef Inst)
Obtain the code opcode for an individual instruction.
Definition: Core.cpp:2813
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:1046
LLVMRealPredicate LLVMGetFCmpPredicate(LLVMValueRef Inst)
Obtain the float predicate of an instruction.
Definition: Core.cpp:2804
int LLVMHasMetadata(LLVMValueRef Inst)
Determine whether an instruction has any metadata attached.
Definition: Core.cpp:989
void LLVMInstructionEraseFromParent(LLVMValueRef Inst)
Remove and delete an instruction.
Definition: Core.cpp:2787
void LLVMInstructionRemoveFromParent(LLVMValueRef Inst)
Remove an instruction.
Definition: Core.cpp:2783
LLVMValueRef LLVMGetMetadata(LLVMValueRef Inst, unsigned KindID)
Return metadata associated with an instruction value.
Definition: Core.cpp:993
LLVMIntPredicate LLVMGetICmpPredicate(LLVMValueRef Inst)
Obtain the predicate of an instruction.
Definition: Core.cpp:2795
void LLVMSetMetadata(LLVMValueRef Inst, unsigned KindID, LLVMValueRef Val)
Set metadata associated with an instruction value.
Definition: Core.cpp:1015
LLVMBasicBlockRef LLVMGetInstructionParent(LLVMValueRef Inst)
Obtain the basic block to which an instruction belongs.
Definition: Core.cpp:2747
LLVMValueRef LLVMGetPreviousInstruction(LLVMValueRef Inst)
Obtain the instruction that occurred before this one.
Definition: Core.cpp:2775
LLVMValueRef LLVMMetadataAsValue(LLVMContextRef C, LLVMMetadataRef MD)
Obtain a Metadata as a Value.
Definition: Core.cpp:1246
LLVMValueRef LLVMMDString(const char *Str, unsigned SLen)
Deprecated: Use LLVMMDStringInContext2 instead.
Definition: Core.cpp:1211
void LLVMReplaceMDNodeOperandWith(LLVMValueRef V, unsigned Index, LLVMMetadataRef Replacement)
Replace an operand at a specific index in a llvm::MDNode value.
Definition: Core.cpp:1337
LLVMMetadataRef LLVMMDStringInContext2(LLVMContextRef C, const char *Str, size_t SLen)
Create an MDString value from a given string value.
Definition: Core.cpp:1194
LLVMMetadataRef LLVMMDNodeInContext2(LLVMContextRef C, LLVMMetadataRef *MDs, size_t Count)
Create an MDNode value with the given array of operands.
Definition: Core.cpp:1199
LLVMValueRef LLVMMDStringInContext(LLVMContextRef C, const char *Str, unsigned SLen)
Deprecated: Use LLVMMDStringInContext2 instead.
Definition: Core.cpp:1204
LLVMMetadataRef LLVMValueAsMetadata(LLVMValueRef Val)
Obtain a Value as a Metadata.
Definition: Core.cpp:1250
LLVMValueRef LLVMMDNodeInContext(LLVMContextRef C, LLVMValueRef *Vals, unsigned Count)
Deprecated: Use LLVMMDNodeInContext2 instead.
Definition: Core.cpp:1215
const char * LLVMGetMDString(LLVMValueRef V, unsigned *Length)
Obtain the underlying string from a MDString value.
Definition: Core.cpp:1259
unsigned LLVMGetMDNodeNumOperands(LLVMValueRef V)
Obtain the number of operands from an MDNode value.
Definition: Core.cpp:1269
void LLVMGetMDNodeOperands(LLVMValueRef V, LLVMValueRef *Dest)
Obtain the given MDNode's operands.
Definition: Core.cpp:1324
LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count)
Deprecated: Use LLVMMDNodeInContext2 instead.
Definition: Core.cpp:1242
int LLVMGetNumOperands(LLVMValueRef Val)
Obtain the number of operands in a llvm::User value.
Definition: Core.cpp:1144
void LLVMSetOperand(LLVMValueRef Val, unsigned Index, LLVMValueRef Op)
Set an operand at a specific index in a llvm::User value.
Definition: Core.cpp:1140
LLVMUseRef LLVMGetOperandUse(LLVMValueRef Val, unsigned Index)
Obtain the use of an operand at a specific index in a llvm::User value.
Definition: Core.cpp:1135
LLVMValueRef LLVMGetOperand(LLVMValueRef Val, unsigned Index)
Obtain an operand at a specific index in a llvm::User value.
Definition: Core.cpp:1121
LLVMValueRef LLVMGetUser(LLVMUseRef U)
Obtain the user value for a user.
Definition: Core.cpp:1101
LLVMUseRef LLVMGetFirstUse(LLVMValueRef Val)
Obtain the first use of a value.
Definition: Core.cpp:1086
LLVMUseRef LLVMGetNextUse(LLVMUseRef U)
Obtain the next use of a value.
Definition: Core.cpp:1094
LLVMValueRef LLVMGetUsedValue(LLVMUseRef U)
Obtain the value this use corresponds to.
Definition: Core.cpp:1105
#define LLVM_FOR_EACH_VALUE_SUBCLASS(macro)
Definition: Core.h:1708
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 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:2266
LLVMValueRef LLVMGetLastGlobalAlias(LLVMModuleRef M)
Obtain an iterator to the last GlobalAlias in a Module.
Definition: Core.cpp:2238
LLVMValueRef LLVMGetNextGlobalAlias(LLVMValueRef GA)
Advance a GlobalAlias iterator to the next GlobalAlias.
Definition: Core.cpp:2246
LLVMValueRef LLVMAliasGetAliasee(LLVMValueRef Alias)
Retrieve the target value of an alias.
Definition: Core.cpp:2262
LLVMValueRef LLVMGetPreviousGlobalAlias(LLVMValueRef GA)
Decrement a GlobalAlias iterator to the previous GlobalAlias.
Definition: Core.cpp:2254
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:2217
LLVMValueRef LLVMGetFirstGlobalAlias(LLVMModuleRef M)
Obtain an iterator to the first GlobalAlias in a Module.
Definition: Core.cpp:2230
LLVMValueRef LLVMGetNamedGlobalAlias(LLVMModuleRef M, const char *Name, size_t NameLen)
Obtain a GlobalAlias value from a Module by its name.
Definition: Core.cpp:2225
void LLVMSetGlobalConstant(LLVMValueRef GlobalVar, LLVMBool IsConstant)
Definition: Core.cpp:2164
void LLVMSetThreadLocalMode(LLVMValueRef GlobalVar, LLVMThreadLocalMode Mode)
Definition: Core.cpp:2185
LLVMThreadLocalMode LLVMGetThreadLocalMode(LLVMValueRef GlobalVar)
Definition: Core.cpp:2168
LLVMValueRef LLVMGetFirstGlobal(LLVMModuleRef M)
Definition: Core.cpp:2104
LLVMValueRef LLVMGetNextGlobal(LLVMValueRef GlobalVar)
Definition: Core.cpp:2120
LLVMBool LLVMIsExternallyInitialized(LLVMValueRef GlobalVar)
Definition: Core.cpp:2207
LLVMValueRef LLVMAddGlobal(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name)
Definition: Core.cpp:2086
LLVMValueRef LLVMGetLastGlobal(LLVMModuleRef M)
Definition: Core.cpp:2112
void LLVMSetExternallyInitialized(LLVMValueRef GlobalVar, LLVMBool IsExtInit)
Definition: Core.cpp:2211
LLVMValueRef LLVMGetPreviousGlobal(LLVMValueRef GlobalVar)
Definition: Core.cpp:2128
void LLVMSetThreadLocal(LLVMValueRef GlobalVar, LLVMBool IsThreadLocal)
Definition: Core.cpp:2156
LLVMValueRef LLVMGetInitializer(LLVMValueRef GlobalVar)
Definition: Core.cpp:2140
void LLVMDeleteGlobal(LLVMValueRef GlobalVar)
Definition: Core.cpp:2136
LLVMBool LLVMIsThreadLocal(LLVMValueRef GlobalVar)
Definition: Core.cpp:2152
LLVMBool LLVMIsGlobalConstant(LLVMValueRef GlobalVar)
Definition: Core.cpp:2160
LLVMValueRef LLVMAddGlobalInAddressSpace(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name, unsigned AddressSpace)
Definition: Core.cpp:2091
void LLVMSetInitializer(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal)
Definition: Core.cpp:2147
LLVMValueRef LLVMGetNamedGlobal(LLVMModuleRef M, const char *Name)
Definition: Core.cpp:2100
#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:1419
std::string getNameNoUnnamedTypes(ID Id, ArrayRef< Type * > Tys)
Return the LLVM name for an intrinsic.
Definition: Function.cpp:1057
StringRef getName(ID id)
Return the LLVM name for an intrinsic, such as "llvm.ppc.altivec.lvx".
Definition: Function.cpp:1017
bool isOverloaded(ID id)
Returns true if the intrinsic can be overloaded.
Definition: Function.cpp:1440
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:1451
@ 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:1023
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