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