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