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
957const char *LLVMGetTargetExtTypeName(LLVMTypeRef TargetExtTy) {
958 TargetExtType *Type = unwrap<TargetExtType>(TargetExtTy);
959 return Type->getName().data();
960}
961
963 TargetExtType *Type = unwrap<TargetExtType>(TargetExtTy);
964 return Type->getNumTypeParameters();
965}
966
968 unsigned Idx) {
969 TargetExtType *Type = unwrap<TargetExtType>(TargetExtTy);
970 return wrap(Type->getTypeParameter(Idx));
971}
972
974 TargetExtType *Type = unwrap<TargetExtType>(TargetExtTy);
975 return Type->getNumIntParameters();
976}
977
978unsigned LLVMGetTargetExtTypeIntParam(LLVMTypeRef TargetExtTy, unsigned Idx) {
979 TargetExtType *Type = unwrap<TargetExtType>(TargetExtTy);
980 return Type->getIntParameter(Idx);
981}
982
983/*===-- Operations on values ----------------------------------------------===*/
984
985/*--.. Operations on all values ............................................--*/
986
988 return wrap(unwrap(Val)->getType());
989}
990
992 switch(unwrap(Val)->getValueID()) {
993#define LLVM_C_API 1
994#define HANDLE_VALUE(Name) \
995 case Value::Name##Val: \
996 return LLVM##Name##ValueKind;
997#include "llvm/IR/Value.def"
998 default:
1000 }
1001}
1002
1003const char *LLVMGetValueName2(LLVMValueRef Val, size_t *Length) {
1004 auto *V = unwrap(Val);
1005 *Length = V->getName().size();
1006 return V->getName().data();
1007}
1008
1009void LLVMSetValueName2(LLVMValueRef Val, const char *Name, size_t NameLen) {
1010 unwrap(Val)->setName(StringRef(Name, NameLen));
1011}
1012
1014 return unwrap(Val)->getName().data();
1015}
1016
1017void LLVMSetValueName(LLVMValueRef Val, const char *Name) {
1018 unwrap(Val)->setName(Name);
1019}
1020
1022 unwrap(Val)->print(errs(), /*IsForDebug=*/true);
1023}
1024
1026 std::string buf;
1027 raw_string_ostream os(buf);
1028
1029 if (unwrap(Val))
1030 unwrap(Val)->print(os);
1031 else
1032 os << "Printing <null> Value";
1033
1034 os.flush();
1035
1036 return strdup(buf.c_str());
1037}
1038
1040 std::string buf;
1041 raw_string_ostream os(buf);
1042
1043 if (unwrap(Record))
1044 unwrap(Record)->print(os);
1045 else
1046 os << "Printing <null> DbgRecord";
1047
1048 os.flush();
1049
1050 return strdup(buf.c_str());
1051}
1052
1054 unwrap(OldVal)->replaceAllUsesWith(unwrap(NewVal));
1055}
1056
1058 return unwrap<Instruction>(Inst)->hasMetadata();
1059}
1060
1062 auto *I = unwrap<Instruction>(Inst);
1063 assert(I && "Expected instruction");
1064 if (auto *MD = I->getMetadata(KindID))
1065 return wrap(MetadataAsValue::get(I->getContext(), MD));
1066 return nullptr;
1067}
1068
1069// MetadataAsValue uses a canonical format which strips the actual MDNode for
1070// MDNode with just a single constant value, storing just a ConstantAsMetadata
1071// This undoes this canonicalization, reconstructing the MDNode.
1073 Metadata *MD = MAV->getMetadata();
1074 assert((isa<MDNode>(MD) || isa<ConstantAsMetadata>(MD)) &&
1075 "Expected a metadata node or a canonicalized constant");
1076
1077 if (MDNode *N = dyn_cast<MDNode>(MD))
1078 return N;
1079
1080 return MDNode::get(MAV->getContext(), MD);
1081}
1082
1083void LLVMSetMetadata(LLVMValueRef Inst, unsigned KindID, LLVMValueRef Val) {
1084 MDNode *N = Val ? extractMDNode(unwrap<MetadataAsValue>(Val)) : nullptr;
1085
1086 unwrap<Instruction>(Inst)->setMetadata(KindID, N);
1087}
1088
1090 unsigned Kind;
1092};
1093
1096llvm_getMetadata(size_t *NumEntries,
1097 llvm::function_ref<void(MetadataEntries &)> AccessMD) {
1099 AccessMD(MVEs);
1100
1102 static_cast<LLVMOpaqueValueMetadataEntry *>(
1104 for (unsigned i = 0; i < MVEs.size(); ++i) {
1105 const auto &ModuleFlag = MVEs[i];
1106 Result[i].Kind = ModuleFlag.first;
1107 Result[i].Metadata = wrap(ModuleFlag.second);
1108 }
1109 *NumEntries = MVEs.size();
1110 return Result;
1111}
1112
1115 size_t *NumEntries) {
1116 return llvm_getMetadata(NumEntries, [&Value](MetadataEntries &Entries) {
1117 Entries.clear();
1118 unwrap<Instruction>(Value)->getAllMetadata(Entries);
1119 });
1120}
1121
1122/*--.. Conversion functions ................................................--*/
1123
1124#define LLVM_DEFINE_VALUE_CAST(name) \
1125 LLVMValueRef LLVMIsA##name(LLVMValueRef Val) { \
1126 return wrap(static_cast<Value*>(dyn_cast_or_null<name>(unwrap(Val)))); \
1127 }
1128
1130
1132 if (auto *MD = dyn_cast_or_null<MetadataAsValue>(unwrap(Val)))
1133 if (isa<MDNode>(MD->getMetadata()) ||
1134 isa<ValueAsMetadata>(MD->getMetadata()))
1135 return Val;
1136 return nullptr;
1137}
1138
1140 if (auto *MD = dyn_cast_or_null<MetadataAsValue>(unwrap(Val)))
1141 if (isa<ValueAsMetadata>(MD->getMetadata()))
1142 return Val;
1143 return nullptr;
1144}
1145
1147 if (auto *MD = dyn_cast_or_null<MetadataAsValue>(unwrap(Val)))
1148 if (isa<MDString>(MD->getMetadata()))
1149 return Val;
1150 return nullptr;
1151}
1152
1153/*--.. Operations on Uses ..................................................--*/
1155 Value *V = unwrap(Val);
1156 Value::use_iterator I = V->use_begin();
1157 if (I == V->use_end())
1158 return nullptr;
1159 return wrap(&*I);
1160}
1161
1163 Use *Next = unwrap(U)->getNext();
1164 if (Next)
1165 return wrap(Next);
1166 return nullptr;
1167}
1168
1170 return wrap(unwrap(U)->getUser());
1171}
1172
1174 return wrap(unwrap(U)->get());
1175}
1176
1177/*--.. Operations on Users .................................................--*/
1178
1180 unsigned Index) {
1181 Metadata *Op = N->getOperand(Index);
1182 if (!Op)
1183 return nullptr;
1184 if (auto *C = dyn_cast<ConstantAsMetadata>(Op))
1185 return wrap(C->getValue());
1186 return wrap(MetadataAsValue::get(Context, Op));
1187}
1188
1190 Value *V = unwrap(Val);
1191 if (auto *MD = dyn_cast<MetadataAsValue>(V)) {
1192 if (auto *L = dyn_cast<ValueAsMetadata>(MD->getMetadata())) {
1193 assert(Index == 0 && "Function-local metadata can only have one operand");
1194 return wrap(L->getValue());
1195 }
1196 return getMDNodeOperandImpl(V->getContext(),
1197 cast<MDNode>(MD->getMetadata()), Index);
1198 }
1199
1200 return wrap(cast<User>(V)->getOperand(Index));
1201}
1202
1204 Value *V = unwrap(Val);
1205 return wrap(&cast<User>(V)->getOperandUse(Index));
1206}
1207
1209 unwrap<User>(Val)->setOperand(Index, unwrap(Op));
1210}
1211
1213 Value *V = unwrap(Val);
1214 if (isa<MetadataAsValue>(V))
1215 return LLVMGetMDNodeNumOperands(Val);
1216
1217 return cast<User>(V)->getNumOperands();
1218}
1219
1220/*--.. Operations on constants of any type .................................--*/
1221
1223 return wrap(Constant::getNullValue(unwrap(Ty)));
1224}
1225
1228}
1229
1231 return wrap(UndefValue::get(unwrap(Ty)));
1232}
1233
1235 return wrap(PoisonValue::get(unwrap(Ty)));
1236}
1237
1239 return isa<Constant>(unwrap(Ty));
1240}
1241
1243 if (Constant *C = dyn_cast<Constant>(unwrap(Val)))
1244 return C->isNullValue();
1245 return false;
1246}
1247
1249 return isa<UndefValue>(unwrap(Val));
1250}
1251
1253 return isa<PoisonValue>(unwrap(Val));
1254}
1255
1257 return wrap(ConstantPointerNull::get(unwrap<PointerType>(Ty)));
1258}
1259
1260/*--.. Operations on metadata nodes ........................................--*/
1261
1263 size_t SLen) {
1264 return wrap(MDString::get(*unwrap(C), StringRef(Str, SLen)));
1265}
1266
1268 size_t Count) {
1269 return wrap(MDNode::get(*unwrap(C), ArrayRef<Metadata*>(unwrap(MDs), Count)));
1270}
1271
1273 unsigned SLen) {
1274 LLVMContext &Context = *unwrap(C);
1276 Context, MDString::get(Context, StringRef(Str, SLen))));
1277}
1278
1279LLVMValueRef LLVMMDString(const char *Str, unsigned SLen) {
1280 return LLVMMDStringInContext(LLVMGetGlobalContext(), Str, SLen);
1281}
1282
1284 unsigned Count) {
1285 LLVMContext &Context = *unwrap(C);
1287 for (auto *OV : ArrayRef(Vals, Count)) {
1288 Value *V = unwrap(OV);
1289 Metadata *MD;
1290 if (!V)
1291 MD = nullptr;
1292 else if (auto *C = dyn_cast<Constant>(V))
1294 else if (auto *MDV = dyn_cast<MetadataAsValue>(V)) {
1295 MD = MDV->getMetadata();
1296 assert(!isa<LocalAsMetadata>(MD) && "Unexpected function-local metadata "
1297 "outside of direct argument to call");
1298 } else {
1299 // This is function-local metadata. Pretend to make an MDNode.
1300 assert(Count == 1 &&
1301 "Expected only one operand to function-local metadata");
1302 return wrap(MetadataAsValue::get(Context, LocalAsMetadata::get(V)));
1303 }
1304
1305 MDs.push_back(MD);
1306 }
1307 return wrap(MetadataAsValue::get(Context, MDNode::get(Context, MDs)));
1308}
1309
1310LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count) {
1311 return LLVMMDNodeInContext(LLVMGetGlobalContext(), Vals, Count);
1312}
1313
1315 return wrap(MetadataAsValue::get(*unwrap(C), unwrap(MD)));
1316}
1317
1319 auto *V = unwrap(Val);
1320 if (auto *C = dyn_cast<Constant>(V))
1322 if (auto *MAV = dyn_cast<MetadataAsValue>(V))
1323 return wrap(MAV->getMetadata());
1324 return wrap(ValueAsMetadata::get(V));
1325}
1326
1327const char *LLVMGetMDString(LLVMValueRef V, unsigned *Length) {
1328 if (const auto *MD = dyn_cast<MetadataAsValue>(unwrap(V)))
1329 if (const MDString *S = dyn_cast<MDString>(MD->getMetadata())) {
1330 *Length = S->getString().size();
1331 return S->getString().data();
1332 }
1333 *Length = 0;
1334 return nullptr;
1335}
1336
1338 auto *MD = unwrap<MetadataAsValue>(V);
1339 if (isa<ValueAsMetadata>(MD->getMetadata()))
1340 return 1;
1341 return cast<MDNode>(MD->getMetadata())->getNumOperands();
1342}
1343
1345 Module *Mod = unwrap(M);
1347 if (I == Mod->named_metadata_end())
1348 return nullptr;
1349 return wrap(&*I);
1350}
1351
1353 Module *Mod = unwrap(M);
1355 if (I == Mod->named_metadata_begin())
1356 return nullptr;
1357 return wrap(&*--I);
1358}
1359
1361 NamedMDNode *NamedNode = unwrap(NMD);
1363 if (++I == NamedNode->getParent()->named_metadata_end())
1364 return nullptr;
1365 return wrap(&*I);
1366}
1367
1369 NamedMDNode *NamedNode = unwrap(NMD);
1371 if (I == NamedNode->getParent()->named_metadata_begin())
1372 return nullptr;
1373 return wrap(&*--I);
1374}
1375
1377 const char *Name, size_t NameLen) {
1378 return wrap(unwrap(M)->getNamedMetadata(StringRef(Name, NameLen)));
1379}
1380
1382 const char *Name, size_t NameLen) {
1383 return wrap(unwrap(M)->getOrInsertNamedMetadata({Name, NameLen}));
1384}
1385
1386const char *LLVMGetNamedMetadataName(LLVMNamedMDNodeRef NMD, size_t *NameLen) {
1387 NamedMDNode *NamedNode = unwrap(NMD);
1388 *NameLen = NamedNode->getName().size();
1389 return NamedNode->getName().data();
1390}
1391
1393 auto *MD = unwrap<MetadataAsValue>(V);
1394 if (auto *MDV = dyn_cast<ValueAsMetadata>(MD->getMetadata())) {
1395 *Dest = wrap(MDV->getValue());
1396 return;
1397 }
1398 const auto *N = cast<MDNode>(MD->getMetadata());
1399 const unsigned numOperands = N->getNumOperands();
1400 LLVMContext &Context = unwrap(V)->getContext();
1401 for (unsigned i = 0; i < numOperands; i++)
1402 Dest[i] = getMDNodeOperandImpl(Context, N, i);
1403}
1404
1406 LLVMMetadataRef Replacement) {
1407 auto *MD = cast<MetadataAsValue>(unwrap(V));
1408 auto *N = cast<MDNode>(MD->getMetadata());
1409 N->replaceOperandWith(Index, unwrap<Metadata>(Replacement));
1410}
1411
1413 if (NamedMDNode *N = unwrap(M)->getNamedMetadata(Name)) {
1414 return N->getNumOperands();
1415 }
1416 return 0;
1417}
1418
1420 LLVMValueRef *Dest) {
1421 NamedMDNode *N = unwrap(M)->getNamedMetadata(Name);
1422 if (!N)
1423 return;
1424 LLVMContext &Context = unwrap(M)->getContext();
1425 for (unsigned i=0;i<N->getNumOperands();i++)
1426 Dest[i] = wrap(MetadataAsValue::get(Context, N->getOperand(i)));
1427}
1428
1430 LLVMValueRef Val) {
1431 NamedMDNode *N = unwrap(M)->getOrInsertNamedMetadata(Name);
1432 if (!N)
1433 return;
1434 if (!Val)
1435 return;
1436 N->addOperand(extractMDNode(unwrap<MetadataAsValue>(Val)));
1437}
1438
1439const char *LLVMGetDebugLocDirectory(LLVMValueRef Val, unsigned *Length) {
1440 if (!Length) return nullptr;
1441 StringRef S;
1442 if (const auto *I = dyn_cast<Instruction>(unwrap(Val))) {
1443 if (const auto &DL = I->getDebugLoc()) {
1444 S = DL->getDirectory();
1445 }
1446 } else if (const auto *GV = dyn_cast<GlobalVariable>(unwrap(Val))) {
1448 GV->getDebugInfo(GVEs);
1449 if (GVEs.size())
1450 if (const DIGlobalVariable *DGV = GVEs[0]->getVariable())
1451 S = DGV->getDirectory();
1452 } else if (const auto *F = dyn_cast<Function>(unwrap(Val))) {
1453 if (const DISubprogram *DSP = F->getSubprogram())
1454 S = DSP->getDirectory();
1455 } else {
1456 assert(0 && "Expected Instruction, GlobalVariable or Function");
1457 return nullptr;
1458 }
1459 *Length = S.size();
1460 return S.data();
1461}
1462
1463const char *LLVMGetDebugLocFilename(LLVMValueRef Val, unsigned *Length) {
1464 if (!Length) return nullptr;
1465 StringRef S;
1466 if (const auto *I = dyn_cast<Instruction>(unwrap(Val))) {
1467 if (const auto &DL = I->getDebugLoc()) {
1468 S = DL->getFilename();
1469 }
1470 } else if (const auto *GV = dyn_cast<GlobalVariable>(unwrap(Val))) {
1472 GV->getDebugInfo(GVEs);
1473 if (GVEs.size())
1474 if (const DIGlobalVariable *DGV = GVEs[0]->getVariable())
1475 S = DGV->getFilename();
1476 } else if (const auto *F = dyn_cast<Function>(unwrap(Val))) {
1477 if (const DISubprogram *DSP = F->getSubprogram())
1478 S = DSP->getFilename();
1479 } else {
1480 assert(0 && "Expected Instruction, GlobalVariable or Function");
1481 return nullptr;
1482 }
1483 *Length = S.size();
1484 return S.data();
1485}
1486
1488 unsigned L = 0;
1489 if (const auto *I = dyn_cast<Instruction>(unwrap(Val))) {
1490 if (const auto &DL = I->getDebugLoc()) {
1491 L = DL->getLine();
1492 }
1493 } else if (const auto *GV = dyn_cast<GlobalVariable>(unwrap(Val))) {
1495 GV->getDebugInfo(GVEs);
1496 if (GVEs.size())
1497 if (const DIGlobalVariable *DGV = GVEs[0]->getVariable())
1498 L = DGV->getLine();
1499 } else if (const auto *F = dyn_cast<Function>(unwrap(Val))) {
1500 if (const DISubprogram *DSP = F->getSubprogram())
1501 L = DSP->getLine();
1502 } else {
1503 assert(0 && "Expected Instruction, GlobalVariable or Function");
1504 return -1;
1505 }
1506 return L;
1507}
1508
1510 unsigned C = 0;
1511 if (const auto *I = dyn_cast<Instruction>(unwrap(Val)))
1512 if (const auto &DL = I->getDebugLoc())
1513 C = DL->getColumn();
1514 return C;
1515}
1516
1517/*--.. Operations on scalar constants ......................................--*/
1518
1519LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N,
1520 LLVMBool SignExtend) {
1521 return wrap(ConstantInt::get(unwrap<IntegerType>(IntTy), N, SignExtend != 0));
1522}
1523
1525 unsigned NumWords,
1526 const uint64_t Words[]) {
1527 IntegerType *Ty = unwrap<IntegerType>(IntTy);
1528 return wrap(ConstantInt::get(
1529 Ty->getContext(), APInt(Ty->getBitWidth(), ArrayRef(Words, NumWords))));
1530}
1531
1533 uint8_t Radix) {
1534 return wrap(ConstantInt::get(unwrap<IntegerType>(IntTy), StringRef(Str),
1535 Radix));
1536}
1537
1539 unsigned SLen, uint8_t Radix) {
1540 return wrap(ConstantInt::get(unwrap<IntegerType>(IntTy), StringRef(Str, SLen),
1541 Radix));
1542}
1543
1545 return wrap(ConstantFP::get(unwrap(RealTy), N));
1546}
1547
1549 return wrap(ConstantFP::get(unwrap(RealTy), StringRef(Text)));
1550}
1551
1553 unsigned SLen) {
1554 return wrap(ConstantFP::get(unwrap(RealTy), StringRef(Str, SLen)));
1555}
1556
1557unsigned long long LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal) {
1558 return unwrap<ConstantInt>(ConstantVal)->getZExtValue();
1559}
1560
1562 return unwrap<ConstantInt>(ConstantVal)->getSExtValue();
1563}
1564
1565double LLVMConstRealGetDouble(LLVMValueRef ConstantVal, LLVMBool *LosesInfo) {
1566 ConstantFP *cFP = unwrap<ConstantFP>(ConstantVal) ;
1567 Type *Ty = cFP->getType();
1568
1569 if (Ty->isHalfTy() || Ty->isBFloatTy() || Ty->isFloatTy() ||
1570 Ty->isDoubleTy()) {
1571 *LosesInfo = false;
1572 return cFP->getValueAPF().convertToDouble();
1573 }
1574
1575 bool APFLosesInfo;
1576 APFloat APF = cFP->getValueAPF();
1577 APF.convert(APFloat::IEEEdouble(), APFloat::rmNearestTiesToEven, &APFLosesInfo);
1578 *LosesInfo = APFLosesInfo;
1579 return APF.convertToDouble();
1580}
1581
1582/*--.. Operations on composite constants ...................................--*/
1583
1585 unsigned Length,
1586 LLVMBool DontNullTerminate) {
1587 /* Inverted the sense of AddNull because ', 0)' is a
1588 better mnemonic for null termination than ', 1)'. */
1590 DontNullTerminate == 0));
1591}
1592
1594 size_t Length,
1595 LLVMBool DontNullTerminate) {
1596 /* Inverted the sense of AddNull because ', 0)' is a
1597 better mnemonic for null termination than ', 1)'. */
1599 DontNullTerminate == 0));
1600}
1601
1602LLVMValueRef LLVMConstString(const char *Str, unsigned Length,
1603 LLVMBool DontNullTerminate) {
1605 DontNullTerminate);
1606}
1607
1609 return wrap(unwrap<Constant>(C)->getAggregateElement(Idx));
1610}
1611
1613 return wrap(unwrap<ConstantDataSequential>(C)->getElementAsConstant(idx));
1614}
1615
1617 return unwrap<ConstantDataSequential>(C)->isString();
1618}
1619
1620const char *LLVMGetAsString(LLVMValueRef C, size_t *Length) {
1621 StringRef Str = unwrap<ConstantDataSequential>(C)->getAsString();
1622 *Length = Str.size();
1623 return Str.data();
1624}
1625
1627 LLVMValueRef *ConstantVals, unsigned Length) {
1628 ArrayRef<Constant*> V(unwrap<Constant>(ConstantVals, Length), Length);
1629 return wrap(ConstantArray::get(ArrayType::get(unwrap(ElementTy), Length), V));
1630}
1631
1633 uint64_t Length) {
1634 ArrayRef<Constant *> V(unwrap<Constant>(ConstantVals, Length), Length);
1635 return wrap(ConstantArray::get(ArrayType::get(unwrap(ElementTy), Length), V));
1636}
1637
1639 LLVMValueRef *ConstantVals,
1640 unsigned Count, LLVMBool Packed) {
1641 Constant **Elements = unwrap<Constant>(ConstantVals, Count);
1642 return wrap(ConstantStruct::getAnon(*unwrap(C), ArrayRef(Elements, Count),
1643 Packed != 0));
1644}
1645
1646LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count,
1647 LLVMBool Packed) {
1648 return LLVMConstStructInContext(LLVMGetGlobalContext(), ConstantVals, Count,
1649 Packed);
1650}
1651
1653 LLVMValueRef *ConstantVals,
1654 unsigned Count) {
1655 Constant **Elements = unwrap<Constant>(ConstantVals, Count);
1656 StructType *Ty = unwrap<StructType>(StructTy);
1657
1658 return wrap(ConstantStruct::get(Ty, ArrayRef(Elements, Count)));
1659}
1660
1661LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size) {
1663 ArrayRef(unwrap<Constant>(ScalarConstantVals, Size), Size)));
1664}
1665
1666/*-- Opcode mapping */
1667
1669{
1670 switch (opcode) {
1671 default: llvm_unreachable("Unhandled Opcode.");
1672#define HANDLE_INST(num, opc, clas) case num: return LLVM##opc;
1673#include "llvm/IR/Instruction.def"
1674#undef HANDLE_INST
1675 }
1676}
1677
1679{
1680 switch (code) {
1681#define HANDLE_INST(num, opc, clas) case LLVM##opc: return num;
1682#include "llvm/IR/Instruction.def"
1683#undef HANDLE_INST
1684 }
1685 llvm_unreachable("Unhandled Opcode.");
1686}
1687
1688/*--.. Constant expressions ................................................--*/
1689
1691 return map_to_llvmopcode(unwrap<ConstantExpr>(ConstantVal)->getOpcode());
1692}
1693
1696}
1697
1699 return wrap(ConstantExpr::getSizeOf(unwrap(Ty)));
1700}
1701
1703 return wrap(ConstantExpr::getNeg(unwrap<Constant>(ConstantVal)));
1704}
1705
1707 return wrap(ConstantExpr::getNSWNeg(unwrap<Constant>(ConstantVal)));
1708}
1709
1711 return wrap(ConstantExpr::getNeg(unwrap<Constant>(ConstantVal)));
1712}
1713
1714
1716 return wrap(ConstantExpr::getNot(unwrap<Constant>(ConstantVal)));
1717}
1718
1720 return wrap(ConstantExpr::getAdd(unwrap<Constant>(LHSConstant),
1721 unwrap<Constant>(RHSConstant)));
1722}
1723
1725 LLVMValueRef RHSConstant) {
1726 return wrap(ConstantExpr::getNSWAdd(unwrap<Constant>(LHSConstant),
1727 unwrap<Constant>(RHSConstant)));
1728}
1729
1731 LLVMValueRef RHSConstant) {
1732 return wrap(ConstantExpr::getNUWAdd(unwrap<Constant>(LHSConstant),
1733 unwrap<Constant>(RHSConstant)));
1734}
1735
1737 return wrap(ConstantExpr::getSub(unwrap<Constant>(LHSConstant),
1738 unwrap<Constant>(RHSConstant)));
1739}
1740
1742 LLVMValueRef RHSConstant) {
1743 return wrap(ConstantExpr::getNSWSub(unwrap<Constant>(LHSConstant),
1744 unwrap<Constant>(RHSConstant)));
1745}
1746
1748 LLVMValueRef RHSConstant) {
1749 return wrap(ConstantExpr::getNUWSub(unwrap<Constant>(LHSConstant),
1750 unwrap<Constant>(RHSConstant)));
1751}
1752
1754 return wrap(ConstantExpr::getMul(unwrap<Constant>(LHSConstant),
1755 unwrap<Constant>(RHSConstant)));
1756}
1757
1759 LLVMValueRef RHSConstant) {
1760 return wrap(ConstantExpr::getNSWMul(unwrap<Constant>(LHSConstant),
1761 unwrap<Constant>(RHSConstant)));
1762}
1763
1765 LLVMValueRef RHSConstant) {
1766 return wrap(ConstantExpr::getNUWMul(unwrap<Constant>(LHSConstant),
1767 unwrap<Constant>(RHSConstant)));
1768}
1769
1771 return wrap(ConstantExpr::getXor(unwrap<Constant>(LHSConstant),
1772 unwrap<Constant>(RHSConstant)));
1773}
1774
1776 LLVMValueRef *ConstantIndices, unsigned NumIndices) {
1777 ArrayRef<Constant *> IdxList(unwrap<Constant>(ConstantIndices, NumIndices),
1778 NumIndices);
1779 Constant *Val = unwrap<Constant>(ConstantVal);
1780 return wrap(ConstantExpr::getGetElementPtr(unwrap(Ty), Val, IdxList));
1781}
1782
1784 LLVMValueRef *ConstantIndices,
1785 unsigned NumIndices) {
1786 ArrayRef<Constant *> IdxList(unwrap<Constant>(ConstantIndices, NumIndices),
1787 NumIndices);
1788 Constant *Val = unwrap<Constant>(ConstantVal);
1789 return wrap(ConstantExpr::getInBoundsGetElementPtr(unwrap(Ty), Val, IdxList));
1790}
1791
1793 return wrap(ConstantExpr::getTrunc(unwrap<Constant>(ConstantVal),
1794 unwrap(ToType)));
1795}
1796
1798 return wrap(ConstantExpr::getPtrToInt(unwrap<Constant>(ConstantVal),
1799 unwrap(ToType)));
1800}
1801
1803 return wrap(ConstantExpr::getIntToPtr(unwrap<Constant>(ConstantVal),
1804 unwrap(ToType)));
1805}
1806
1808 return wrap(ConstantExpr::getBitCast(unwrap<Constant>(ConstantVal),
1809 unwrap(ToType)));
1810}
1811
1813 LLVMTypeRef ToType) {
1814 return wrap(ConstantExpr::getAddrSpaceCast(unwrap<Constant>(ConstantVal),
1815 unwrap(ToType)));
1816}
1817
1819 LLVMTypeRef ToType) {
1820 return wrap(ConstantExpr::getTruncOrBitCast(unwrap<Constant>(ConstantVal),
1821 unwrap(ToType)));
1822}
1823
1825 LLVMTypeRef ToType) {
1826 return wrap(ConstantExpr::getPointerCast(unwrap<Constant>(ConstantVal),
1827 unwrap(ToType)));
1828}
1829
1831 LLVMValueRef IndexConstant) {
1832 return wrap(ConstantExpr::getExtractElement(unwrap<Constant>(VectorConstant),
1833 unwrap<Constant>(IndexConstant)));
1834}
1835
1837 LLVMValueRef ElementValueConstant,
1838 LLVMValueRef IndexConstant) {
1839 return wrap(ConstantExpr::getInsertElement(unwrap<Constant>(VectorConstant),
1840 unwrap<Constant>(ElementValueConstant),
1841 unwrap<Constant>(IndexConstant)));
1842}
1843
1845 LLVMValueRef VectorBConstant,
1846 LLVMValueRef MaskConstant) {
1847 SmallVector<int, 16> IntMask;
1848 ShuffleVectorInst::getShuffleMask(unwrap<Constant>(MaskConstant), IntMask);
1849 return wrap(ConstantExpr::getShuffleVector(unwrap<Constant>(VectorAConstant),
1850 unwrap<Constant>(VectorBConstant),
1851 IntMask));
1852}
1853
1855 const char *Constraints,
1856 LLVMBool HasSideEffects,
1857 LLVMBool IsAlignStack) {
1858 return wrap(InlineAsm::get(dyn_cast<FunctionType>(unwrap(Ty)), AsmString,
1859 Constraints, HasSideEffects, IsAlignStack));
1860}
1861
1863 return wrap(BlockAddress::get(unwrap<Function>(F), unwrap(BB)));
1864}
1865
1867 return wrap(unwrap<BlockAddress>(BlockAddr)->getFunction());
1868}
1869
1871 return wrap(unwrap<BlockAddress>(BlockAddr)->getBasicBlock());
1872}
1873
1874/*--.. Operations on global variables, functions, and aliases (globals) ....--*/
1875
1877 return wrap(unwrap<GlobalValue>(Global)->getParent());
1878}
1879
1881 return unwrap<GlobalValue>(Global)->isDeclaration();
1882}
1883
1885 switch (unwrap<GlobalValue>(Global)->getLinkage()) {
1887 return LLVMExternalLinkage;
1895 return LLVMWeakAnyLinkage;
1897 return LLVMWeakODRLinkage;
1899 return LLVMAppendingLinkage;
1901 return LLVMInternalLinkage;
1903 return LLVMPrivateLinkage;
1907 return LLVMCommonLinkage;
1908 }
1909
1910 llvm_unreachable("Invalid GlobalValue linkage!");
1911}
1912
1914 GlobalValue *GV = unwrap<GlobalValue>(Global);
1915
1916 switch (Linkage) {
1919 break;
1922 break;
1925 break;
1928 break;
1930 LLVM_DEBUG(
1931 errs() << "LLVMSetLinkage(): LLVMLinkOnceODRAutoHideLinkage is no "
1932 "longer supported.");
1933 break;
1934 case LLVMWeakAnyLinkage:
1936 break;
1937 case LLVMWeakODRLinkage:
1939 break;
1942 break;
1945 break;
1946 case LLVMPrivateLinkage:
1948 break;
1951 break;
1954 break;
1956 LLVM_DEBUG(
1957 errs()
1958 << "LLVMSetLinkage(): LLVMDLLImportLinkage is no longer supported.");
1959 break;
1961 LLVM_DEBUG(
1962 errs()
1963 << "LLVMSetLinkage(): LLVMDLLExportLinkage is no longer supported.");
1964 break;
1967 break;
1968 case LLVMGhostLinkage:
1969 LLVM_DEBUG(
1970 errs() << "LLVMSetLinkage(): LLVMGhostLinkage is no longer supported.");
1971 break;
1972 case LLVMCommonLinkage:
1974 break;
1975 }
1976}
1977
1979 // Using .data() is safe because of how GlobalObject::setSection is
1980 // implemented.
1981 return unwrap<GlobalValue>(Global)->getSection().data();
1982}
1983
1984void LLVMSetSection(LLVMValueRef Global, const char *Section) {
1985 unwrap<GlobalObject>(Global)->setSection(Section);
1986}
1987
1989 return static_cast<LLVMVisibility>(
1990 unwrap<GlobalValue>(Global)->getVisibility());
1991}
1992
1994 unwrap<GlobalValue>(Global)
1995 ->setVisibility(static_cast<GlobalValue::VisibilityTypes>(Viz));
1996}
1997
1999 return static_cast<LLVMDLLStorageClass>(
2000 unwrap<GlobalValue>(Global)->getDLLStorageClass());
2001}
2002
2004 unwrap<GlobalValue>(Global)->setDLLStorageClass(
2005 static_cast<GlobalValue::DLLStorageClassTypes>(Class));
2006}
2007
2009 switch (unwrap<GlobalValue>(Global)->getUnnamedAddr()) {
2010 case GlobalVariable::UnnamedAddr::None:
2011 return LLVMNoUnnamedAddr;
2012 case GlobalVariable::UnnamedAddr::Local:
2013 return LLVMLocalUnnamedAddr;
2014 case GlobalVariable::UnnamedAddr::Global:
2015 return LLVMGlobalUnnamedAddr;
2016 }
2017 llvm_unreachable("Unknown UnnamedAddr kind!");
2018}
2019
2021 GlobalValue *GV = unwrap<GlobalValue>(Global);
2022
2023 switch (UnnamedAddr) {
2024 case LLVMNoUnnamedAddr:
2025 return GV->setUnnamedAddr(GlobalVariable::UnnamedAddr::None);
2027 return GV->setUnnamedAddr(GlobalVariable::UnnamedAddr::Local);
2029 return GV->setUnnamedAddr(GlobalVariable::UnnamedAddr::Global);
2030 }
2031}
2032
2034 return unwrap<GlobalValue>(Global)->hasGlobalUnnamedAddr();
2035}
2036
2038 unwrap<GlobalValue>(Global)->setUnnamedAddr(
2039 HasUnnamedAddr ? GlobalValue::UnnamedAddr::Global
2040 : GlobalValue::UnnamedAddr::None);
2041}
2042
2044 return wrap(unwrap<GlobalValue>(Global)->getValueType());
2045}
2046
2047/*--.. Operations on global variables, load and store instructions .........--*/
2048
2050 Value *P = unwrap(V);
2051 if (GlobalObject *GV = dyn_cast<GlobalObject>(P))
2052 return GV->getAlign() ? GV->getAlign()->value() : 0;
2053 if (AllocaInst *AI = dyn_cast<AllocaInst>(P))
2054 return AI->getAlign().value();
2055 if (LoadInst *LI = dyn_cast<LoadInst>(P))
2056 return LI->getAlign().value();
2057 if (StoreInst *SI = dyn_cast<StoreInst>(P))
2058 return SI->getAlign().value();
2059 if (AtomicRMWInst *RMWI = dyn_cast<AtomicRMWInst>(P))
2060 return RMWI->getAlign().value();
2061 if (AtomicCmpXchgInst *CXI = dyn_cast<AtomicCmpXchgInst>(P))
2062 return CXI->getAlign().value();
2063
2065 "only GlobalValue, AllocaInst, LoadInst, StoreInst, AtomicRMWInst, "
2066 "and AtomicCmpXchgInst have alignment");
2067}
2068
2069void LLVMSetAlignment(LLVMValueRef V, unsigned Bytes) {
2070 Value *P = unwrap(V);
2071 if (GlobalObject *GV = dyn_cast<GlobalObject>(P))
2072 GV->setAlignment(MaybeAlign(Bytes));
2073 else if (AllocaInst *AI = dyn_cast<AllocaInst>(P))
2074 AI->setAlignment(Align(Bytes));
2075 else if (LoadInst *LI = dyn_cast<LoadInst>(P))
2076 LI->setAlignment(Align(Bytes));
2077 else if (StoreInst *SI = dyn_cast<StoreInst>(P))
2078 SI->setAlignment(Align(Bytes));
2079 else if (AtomicRMWInst *RMWI = dyn_cast<AtomicRMWInst>(P))
2080 RMWI->setAlignment(Align(Bytes));
2081 else if (AtomicCmpXchgInst *CXI = dyn_cast<AtomicCmpXchgInst>(P))
2082 CXI->setAlignment(Align(Bytes));
2083 else
2085 "only GlobalValue, AllocaInst, LoadInst, StoreInst, AtomicRMWInst, and "
2086 "and AtomicCmpXchgInst have alignment");
2087}
2088
2090 size_t *NumEntries) {
2091 return llvm_getMetadata(NumEntries, [&Value](MetadataEntries &Entries) {
2092 Entries.clear();
2093 if (Instruction *Instr = dyn_cast<Instruction>(unwrap(Value))) {
2094 Instr->getAllMetadata(Entries);
2095 } else {
2096 unwrap<GlobalObject>(Value)->getAllMetadata(Entries);
2097 }
2098 });
2099}
2100
2102 unsigned Index) {
2104 static_cast<LLVMOpaqueValueMetadataEntry>(Entries[Index]);
2105 return MVE.Kind;
2106}
2107
2110 unsigned Index) {
2112 static_cast<LLVMOpaqueValueMetadataEntry>(Entries[Index]);
2113 return MVE.Metadata;
2114}
2115
2117 free(Entries);
2118}
2119
2121 LLVMMetadataRef MD) {
2122 unwrap<GlobalObject>(Global)->setMetadata(Kind, unwrap<MDNode>(MD));
2123}
2124
2126 unwrap<GlobalObject>(Global)->eraseMetadata(Kind);
2127}
2128
2130 unwrap<GlobalObject>(Global)->clearMetadata();
2131}
2132
2133/*--.. Operations on global variables ......................................--*/
2134
2136 return wrap(new GlobalVariable(*unwrap(M), unwrap(Ty), false,
2138}
2139
2141 const char *Name,
2142 unsigned AddressSpace) {
2143 return wrap(new GlobalVariable(*unwrap(M), unwrap(Ty), false,
2145 nullptr, GlobalVariable::NotThreadLocal,
2146 AddressSpace));
2147}
2148
2150 return wrap(unwrap(M)->getNamedGlobal(Name));
2151}
2152
2154 Module *Mod = unwrap(M);
2156 if (I == Mod->global_end())
2157 return nullptr;
2158 return wrap(&*I);
2159}
2160
2162 Module *Mod = unwrap(M);
2164 if (I == Mod->global_begin())
2165 return nullptr;
2166 return wrap(&*--I);
2167}
2168
2170 GlobalVariable *GV = unwrap<GlobalVariable>(GlobalVar);
2172 if (++I == GV->getParent()->global_end())
2173 return nullptr;
2174 return wrap(&*I);
2175}
2176
2178 GlobalVariable *GV = unwrap<GlobalVariable>(GlobalVar);
2180 if (I == GV->getParent()->global_begin())
2181 return nullptr;
2182 return wrap(&*--I);
2183}
2184
2186 unwrap<GlobalVariable>(GlobalVar)->eraseFromParent();
2187}
2188
2190 GlobalVariable* GV = unwrap<GlobalVariable>(GlobalVar);
2191 if ( !GV->hasInitializer() )
2192 return nullptr;
2193 return wrap(GV->getInitializer());
2194}
2195
2196void LLVMSetInitializer(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal) {
2197 unwrap<GlobalVariable>(GlobalVar)
2198 ->setInitializer(unwrap<Constant>(ConstantVal));
2199}
2200
2202 return unwrap<GlobalVariable>(GlobalVar)->isThreadLocal();
2203}
2204
2205void LLVMSetThreadLocal(LLVMValueRef GlobalVar, LLVMBool IsThreadLocal) {
2206 unwrap<GlobalVariable>(GlobalVar)->setThreadLocal(IsThreadLocal != 0);
2207}
2208
2210 return unwrap<GlobalVariable>(GlobalVar)->isConstant();
2211}
2212
2213void LLVMSetGlobalConstant(LLVMValueRef GlobalVar, LLVMBool IsConstant) {
2214 unwrap<GlobalVariable>(GlobalVar)->setConstant(IsConstant != 0);
2215}
2216
2218 switch (unwrap<GlobalVariable>(GlobalVar)->getThreadLocalMode()) {
2219 case GlobalVariable::NotThreadLocal:
2220 return LLVMNotThreadLocal;
2221 case GlobalVariable::GeneralDynamicTLSModel:
2223 case GlobalVariable::LocalDynamicTLSModel:
2225 case GlobalVariable::InitialExecTLSModel:
2227 case GlobalVariable::LocalExecTLSModel:
2228 return LLVMLocalExecTLSModel;
2229 }
2230
2231 llvm_unreachable("Invalid GlobalVariable thread local mode");
2232}
2233
2235 GlobalVariable *GV = unwrap<GlobalVariable>(GlobalVar);
2236
2237 switch (Mode) {
2238 case LLVMNotThreadLocal:
2239 GV->setThreadLocalMode(GlobalVariable::NotThreadLocal);
2240 break;
2242 GV->setThreadLocalMode(GlobalVariable::GeneralDynamicTLSModel);
2243 break;
2245 GV->setThreadLocalMode(GlobalVariable::LocalDynamicTLSModel);
2246 break;
2248 GV->setThreadLocalMode(GlobalVariable::InitialExecTLSModel);
2249 break;
2251 GV->setThreadLocalMode(GlobalVariable::LocalExecTLSModel);
2252 break;
2253 }
2254}
2255
2257 return unwrap<GlobalVariable>(GlobalVar)->isExternallyInitialized();
2258}
2259
2261 unwrap<GlobalVariable>(GlobalVar)->setExternallyInitialized(IsExtInit);
2262}
2263
2264/*--.. Operations on aliases ......................................--*/
2265
2267 unsigned AddrSpace, LLVMValueRef Aliasee,
2268 const char *Name) {
2269 return wrap(GlobalAlias::create(unwrap(ValueTy), AddrSpace,
2271 unwrap<Constant>(Aliasee), unwrap(M)));
2272}
2273
2275 const char *Name, size_t NameLen) {
2276 return wrap(unwrap(M)->getNamedAlias(StringRef(Name, NameLen)));
2277}
2278
2280 Module *Mod = unwrap(M);
2282 if (I == Mod->alias_end())
2283 return nullptr;
2284 return wrap(&*I);
2285}
2286
2288 Module *Mod = unwrap(M);
2290 if (I == Mod->alias_begin())
2291 return nullptr;
2292 return wrap(&*--I);
2293}
2294
2296 GlobalAlias *Alias = unwrap<GlobalAlias>(GA);
2298 if (++I == Alias->getParent()->alias_end())
2299 return nullptr;
2300 return wrap(&*I);
2301}
2302
2304 GlobalAlias *Alias = unwrap<GlobalAlias>(GA);
2306 if (I == Alias->getParent()->alias_begin())
2307 return nullptr;
2308 return wrap(&*--I);
2309}
2310
2312 return wrap(unwrap<GlobalAlias>(Alias)->getAliasee());
2313}
2314
2316 unwrap<GlobalAlias>(Alias)->setAliasee(unwrap<Constant>(Aliasee));
2317}
2318
2319/*--.. Operations on functions .............................................--*/
2320
2322 LLVMTypeRef FunctionTy) {
2323 return wrap(Function::Create(unwrap<FunctionType>(FunctionTy),
2325}
2326
2328 return wrap(unwrap(M)->getFunction(Name));
2329}
2330
2332 Module *Mod = unwrap(M);
2334 if (I == Mod->end())
2335 return nullptr;
2336 return wrap(&*I);
2337}
2338
2340 Module *Mod = unwrap(M);
2342 if (I == Mod->begin())
2343 return nullptr;
2344 return wrap(&*--I);
2345}
2346
2348 Function *Func = unwrap<Function>(Fn);
2349 Module::iterator I(Func);
2350 if (++I == Func->getParent()->end())
2351 return nullptr;
2352 return wrap(&*I);
2353}
2354
2356 Function *Func = unwrap<Function>(Fn);
2357 Module::iterator I(Func);
2358 if (I == Func->getParent()->begin())
2359 return nullptr;
2360 return wrap(&*--I);
2361}
2362
2364 unwrap<Function>(Fn)->eraseFromParent();
2365}
2366
2368 return unwrap<Function>(Fn)->hasPersonalityFn();
2369}
2370
2372 return wrap(unwrap<Function>(Fn)->getPersonalityFn());
2373}
2374
2376 unwrap<Function>(Fn)->setPersonalityFn(unwrap<Constant>(PersonalityFn));
2377}
2378
2380 if (Function *F = dyn_cast<Function>(unwrap(Fn)))
2381 return F->getIntrinsicID();
2382 return 0;
2383}
2384
2386 assert(ID < llvm::Intrinsic::num_intrinsics && "Intrinsic ID out of range");
2387 return llvm::Intrinsic::ID(ID);
2388}
2389
2391 unsigned ID,
2392 LLVMTypeRef *ParamTypes,
2393 size_t ParamCount) {
2394 ArrayRef<Type*> Tys(unwrap(ParamTypes), ParamCount);
2395 auto IID = llvm_map_to_intrinsic_id(ID);
2396 return wrap(llvm::Intrinsic::getDeclaration(unwrap(Mod), IID, Tys));
2397}
2398
2399const char *LLVMIntrinsicGetName(unsigned ID, size_t *NameLength) {
2400 auto IID = llvm_map_to_intrinsic_id(ID);
2401 auto Str = llvm::Intrinsic::getName(IID);
2402 *NameLength = Str.size();
2403 return Str.data();
2404}
2405
2407 LLVMTypeRef *ParamTypes, size_t ParamCount) {
2408 auto IID = llvm_map_to_intrinsic_id(ID);
2409 ArrayRef<Type*> Tys(unwrap(ParamTypes), ParamCount);
2410 return wrap(llvm::Intrinsic::getType(*unwrap(Ctx), IID, Tys));
2411}
2412
2414 LLVMTypeRef *ParamTypes,
2415 size_t ParamCount,
2416 size_t *NameLength) {
2417 auto IID = llvm_map_to_intrinsic_id(ID);
2418 ArrayRef<Type*> Tys(unwrap(ParamTypes), ParamCount);
2419 auto Str = llvm::Intrinsic::getNameNoUnnamedTypes(IID, Tys);
2420 *NameLength = Str.length();
2421 return strdup(Str.c_str());
2422}
2423
2425 LLVMTypeRef *ParamTypes,
2426 size_t ParamCount,
2427 size_t *NameLength) {
2428 auto IID = llvm_map_to_intrinsic_id(ID);
2429 ArrayRef<Type *> Tys(unwrap(ParamTypes), ParamCount);
2430 auto Str = llvm::Intrinsic::getName(IID, Tys, unwrap(Mod));
2431 *NameLength = Str.length();
2432 return strdup(Str.c_str());
2433}
2434
2435unsigned LLVMLookupIntrinsicID(const char *Name, size_t NameLen) {
2436 return Function::lookupIntrinsicID({Name, NameLen});
2437}
2438
2440 auto IID = llvm_map_to_intrinsic_id(ID);
2442}
2443
2445 return unwrap<Function>(Fn)->getCallingConv();
2446}
2447
2449 return unwrap<Function>(Fn)->setCallingConv(
2450 static_cast<CallingConv::ID>(CC));
2451}
2452
2453const char *LLVMGetGC(LLVMValueRef Fn) {
2454 Function *F = unwrap<Function>(Fn);
2455 return F->hasGC()? F->getGC().c_str() : nullptr;
2456}
2457
2458void LLVMSetGC(LLVMValueRef Fn, const char *GC) {
2459 Function *F = unwrap<Function>(Fn);
2460 if (GC)
2461 F->setGC(GC);
2462 else
2463 F->clearGC();
2464}
2465
2467 Function *F = unwrap<Function>(Fn);
2468 return wrap(F->getPrefixData());
2469}
2470
2472 Function *F = unwrap<Function>(Fn);
2473 return F->hasPrefixData();
2474}
2475
2477 Function *F = unwrap<Function>(Fn);
2478 Constant *prefix = unwrap<Constant>(prefixData);
2479 F->setPrefixData(prefix);
2480}
2481
2483 Function *F = unwrap<Function>(Fn);
2484 return wrap(F->getPrologueData());
2485}
2486
2488 Function *F = unwrap<Function>(Fn);
2489 return F->hasPrologueData();
2490}
2491
2493 Function *F = unwrap<Function>(Fn);
2494 Constant *prologue = unwrap<Constant>(prologueData);
2495 F->setPrologueData(prologue);
2496}
2497
2500 unwrap<Function>(F)->addAttributeAtIndex(Idx, unwrap(A));
2501}
2502
2504 auto AS = unwrap<Function>(F)->getAttributes().getAttributes(Idx);
2505 return AS.getNumAttributes();
2506}
2507
2509 LLVMAttributeRef *Attrs) {
2510 auto AS = unwrap<Function>(F)->getAttributes().getAttributes(Idx);
2511 for (auto A : AS)
2512 *Attrs++ = wrap(A);
2513}
2514
2517 unsigned KindID) {
2518 return wrap(unwrap<Function>(F)->getAttributeAtIndex(
2519 Idx, (Attribute::AttrKind)KindID));
2520}
2521
2524 const char *K, unsigned KLen) {
2525 return wrap(
2526 unwrap<Function>(F)->getAttributeAtIndex(Idx, StringRef(K, KLen)));
2527}
2528
2530 unsigned KindID) {
2531 unwrap<Function>(F)->removeAttributeAtIndex(Idx, (Attribute::AttrKind)KindID);
2532}
2533
2535 const char *K, unsigned KLen) {
2536 unwrap<Function>(F)->removeAttributeAtIndex(Idx, StringRef(K, KLen));
2537}
2538
2540 const char *V) {
2541 Function *Func = unwrap<Function>(Fn);
2542 Attribute Attr = Attribute::get(Func->getContext(), A, V);
2543 Func->addFnAttr(Attr);
2544}
2545
2546/*--.. Operations on parameters ............................................--*/
2547
2549 // This function is strictly redundant to
2550 // LLVMCountParamTypes(LLVMGlobalGetValueType(FnRef))
2551 return unwrap<Function>(FnRef)->arg_size();
2552}
2553
2554void LLVMGetParams(LLVMValueRef FnRef, LLVMValueRef *ParamRefs) {
2555 Function *Fn = unwrap<Function>(FnRef);
2556 for (Argument &A : Fn->args())
2557 *ParamRefs++ = wrap(&A);
2558}
2559
2561 Function *Fn = unwrap<Function>(FnRef);
2562 return wrap(&Fn->arg_begin()[index]);
2563}
2564
2566 return wrap(unwrap<Argument>(V)->getParent());
2567}
2568
2570 Function *Func = unwrap<Function>(Fn);
2571 Function::arg_iterator I = Func->arg_begin();
2572 if (I == Func->arg_end())
2573 return nullptr;
2574 return wrap(&*I);
2575}
2576
2578 Function *Func = unwrap<Function>(Fn);
2579 Function::arg_iterator I = Func->arg_end();
2580 if (I == Func->arg_begin())
2581 return nullptr;
2582 return wrap(&*--I);
2583}
2584
2586 Argument *A = unwrap<Argument>(Arg);
2587 Function *Fn = A->getParent();
2588 if (A->getArgNo() + 1 >= Fn->arg_size())
2589 return nullptr;
2590 return wrap(&Fn->arg_begin()[A->getArgNo() + 1]);
2591}
2592
2594 Argument *A = unwrap<Argument>(Arg);
2595 if (A->getArgNo() == 0)
2596 return nullptr;
2597 return wrap(&A->getParent()->arg_begin()[A->getArgNo() - 1]);
2598}
2599
2600void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align) {
2601 Argument *A = unwrap<Argument>(Arg);
2602 A->addAttr(Attribute::getWithAlignment(A->getContext(), Align(align)));
2603}
2604
2605/*--.. Operations on ifuncs ................................................--*/
2606
2608 const char *Name, size_t NameLen,
2609 LLVMTypeRef Ty, unsigned AddrSpace,
2611 return wrap(GlobalIFunc::create(unwrap(Ty), AddrSpace,
2613 StringRef(Name, NameLen),
2614 unwrap<Constant>(Resolver), unwrap(M)));
2615}
2616
2618 const char *Name, size_t NameLen) {
2619 return wrap(unwrap(M)->getNamedIFunc(StringRef(Name, NameLen)));
2620}
2621
2623 Module *Mod = unwrap(M);
2625 if (I == Mod->ifunc_end())
2626 return nullptr;
2627 return wrap(&*I);
2628}
2629
2631 Module *Mod = unwrap(M);
2633 if (I == Mod->ifunc_begin())
2634 return nullptr;
2635 return wrap(&*--I);
2636}
2637
2639 GlobalIFunc *GIF = unwrap<GlobalIFunc>(IFunc);
2641 if (++I == GIF->getParent()->ifunc_end())
2642 return nullptr;
2643 return wrap(&*I);
2644}
2645
2647 GlobalIFunc *GIF = unwrap<GlobalIFunc>(IFunc);
2649 if (I == GIF->getParent()->ifunc_begin())
2650 return nullptr;
2651 return wrap(&*--I);
2652}
2653
2655 return wrap(unwrap<GlobalIFunc>(IFunc)->getResolver());
2656}
2657
2659 unwrap<GlobalIFunc>(IFunc)->setResolver(unwrap<Constant>(Resolver));
2660}
2661
2663 unwrap<GlobalIFunc>(IFunc)->eraseFromParent();
2664}
2665
2667 unwrap<GlobalIFunc>(IFunc)->removeFromParent();
2668}
2669
2670/*--.. Operations on operand bundles........................................--*/
2671
2673 LLVMValueRef *Args,
2674 unsigned NumArgs) {
2675 return wrap(new OperandBundleDef(std::string(Tag, TagLen),
2676 ArrayRef(unwrap(Args), NumArgs)));
2677}
2678
2680 delete unwrap(Bundle);
2681}
2682
2683const char *LLVMGetOperandBundleTag(LLVMOperandBundleRef Bundle, size_t *Len) {
2684 StringRef Str = unwrap(Bundle)->getTag();
2685 *Len = Str.size();
2686 return Str.data();
2687}
2688
2690 return unwrap(Bundle)->inputs().size();
2691}
2692
2694 unsigned Index) {
2695 return wrap(unwrap(Bundle)->inputs()[Index]);
2696}
2697
2698/*--.. Operations on basic blocks ..........................................--*/
2699
2701 return wrap(static_cast<Value*>(unwrap(BB)));
2702}
2703
2705 return isa<BasicBlock>(unwrap(Val));
2706}
2707
2709 return wrap(unwrap<BasicBlock>(Val));
2710}
2711
2713 return unwrap(BB)->getName().data();
2714}
2715
2717 return wrap(unwrap(BB)->getParent());
2718}
2719
2721 return wrap(unwrap(BB)->getTerminator());
2722}
2723
2725 return unwrap<Function>(FnRef)->size();
2726}
2727
2729 Function *Fn = unwrap<Function>(FnRef);
2730 for (BasicBlock &BB : *Fn)
2731 *BasicBlocksRefs++ = wrap(&BB);
2732}
2733
2735 return wrap(&unwrap<Function>(Fn)->getEntryBlock());
2736}
2737
2739 Function *Func = unwrap<Function>(Fn);
2740 Function::iterator I = Func->begin();
2741 if (I == Func->end())
2742 return nullptr;
2743 return wrap(&*I);
2744}
2745
2747 Function *Func = unwrap<Function>(Fn);
2748 Function::iterator I = Func->end();
2749 if (I == Func->begin())
2750 return nullptr;
2751 return wrap(&*--I);
2752}
2753
2755 BasicBlock *Block = unwrap(BB);
2757 if (++I == Block->getParent()->end())
2758 return nullptr;
2759 return wrap(&*I);
2760}
2761
2763 BasicBlock *Block = unwrap(BB);
2765 if (I == Block->getParent()->begin())
2766 return nullptr;
2767 return wrap(&*--I);
2768}
2769
2771 const char *Name) {
2773}
2774
2776 LLVMBasicBlockRef BB) {
2777 BasicBlock *ToInsert = unwrap(BB);
2778 BasicBlock *CurBB = unwrap(Builder)->GetInsertBlock();
2779 assert(CurBB && "current insertion point is invalid!");
2780 CurBB->getParent()->insert(std::next(CurBB->getIterator()), ToInsert);
2781}
2782
2784 LLVMBasicBlockRef BB) {
2785 unwrap<Function>(Fn)->insert(unwrap<Function>(Fn)->end(), unwrap(BB));
2786}
2787
2789 LLVMValueRef FnRef,
2790 const char *Name) {
2791 return wrap(BasicBlock::Create(*unwrap(C), Name, unwrap<Function>(FnRef)));
2792}
2793
2796}
2797
2799 LLVMBasicBlockRef BBRef,
2800 const char *Name) {
2801 BasicBlock *BB = unwrap(BBRef);
2802 return wrap(BasicBlock::Create(*unwrap(C), Name, BB->getParent(), BB));
2803}
2804
2806 const char *Name) {
2808}
2809
2811 unwrap(BBRef)->eraseFromParent();
2812}
2813
2815 unwrap(BBRef)->removeFromParent();
2816}
2817
2819 unwrap(BB)->moveBefore(unwrap(MovePos));
2820}
2821
2823 unwrap(BB)->moveAfter(unwrap(MovePos));
2824}
2825
2826/*--.. Operations on instructions ..........................................--*/
2827
2829 return wrap(unwrap<Instruction>(Inst)->getParent());
2830}
2831
2833 BasicBlock *Block = unwrap(BB);
2834 BasicBlock::iterator I = Block->begin();
2835 if (I == Block->end())
2836 return nullptr;
2837 return wrap(&*I);
2838}
2839
2841 BasicBlock *Block = unwrap(BB);
2842 BasicBlock::iterator I = Block->end();
2843 if (I == Block->begin())
2844 return nullptr;
2845 return wrap(&*--I);
2846}
2847
2849 Instruction *Instr = unwrap<Instruction>(Inst);
2850 BasicBlock::iterator I(Instr);
2851 if (++I == Instr->getParent()->end())
2852 return nullptr;
2853 return wrap(&*I);
2854}
2855
2857 Instruction *Instr = unwrap<Instruction>(Inst);
2858 BasicBlock::iterator I(Instr);
2859 if (I == Instr->getParent()->begin())
2860 return nullptr;
2861 return wrap(&*--I);
2862}
2863
2865 unwrap<Instruction>(Inst)->removeFromParent();
2866}
2867
2869 unwrap<Instruction>(Inst)->eraseFromParent();
2870}
2871
2873 unwrap<Instruction>(Inst)->deleteValue();
2874}
2875
2877 if (ICmpInst *I = dyn_cast<ICmpInst>(unwrap(Inst)))
2878 return (LLVMIntPredicate)I->getPredicate();
2879 return (LLVMIntPredicate)0;
2880}
2881
2883 if (FCmpInst *I = dyn_cast<FCmpInst>(unwrap(Inst)))
2884 return (LLVMRealPredicate)I->getPredicate();
2885 return (LLVMRealPredicate)0;
2886}
2887
2889 if (Instruction *C = dyn_cast<Instruction>(unwrap(Inst)))
2890 return map_to_llvmopcode(C->getOpcode());
2891 return (LLVMOpcode)0;
2892}
2893
2895 if (Instruction *C = dyn_cast<Instruction>(unwrap(Inst)))
2896 return wrap(C->clone());
2897 return nullptr;
2898}
2899
2901 Instruction *I = dyn_cast<Instruction>(unwrap(Inst));
2902 return (I && I->isTerminator()) ? wrap(I) : nullptr;
2903}
2904
2906 if (FuncletPadInst *FPI = dyn_cast<FuncletPadInst>(unwrap(Instr))) {
2907 return FPI->arg_size();
2908 }
2909 return unwrap<CallBase>(Instr)->arg_size();
2910}
2911
2912/*--.. Call and invoke instructions ........................................--*/
2913
2915 return unwrap<CallBase>(Instr)->getCallingConv();
2916}
2917
2919 return unwrap<CallBase>(Instr)->setCallingConv(
2920 static_cast<CallingConv::ID>(CC));
2921}
2922
2924 unsigned align) {
2925 auto *Call = unwrap<CallBase>(Instr);
2926 Attribute AlignAttr =
2927 Attribute::getWithAlignment(Call->getContext(), Align(align));
2928 Call->addAttributeAtIndex(Idx, AlignAttr);
2929}
2930
2933 unwrap<CallBase>(C)->addAttributeAtIndex(Idx, unwrap(A));
2934}
2935
2938 auto *Call = unwrap<CallBase>(C);
2939 auto AS = Call->getAttributes().getAttributes(Idx);
2940 return AS.getNumAttributes();
2941}
2942
2944 LLVMAttributeRef *Attrs) {
2945 auto *Call = unwrap<CallBase>(C);
2946 auto AS = Call->getAttributes().getAttributes(Idx);
2947 for (auto A : AS)
2948 *Attrs++ = wrap(A);
2949}
2950
2953 unsigned KindID) {
2954 return wrap(unwrap<CallBase>(C)->getAttributeAtIndex(
2955 Idx, (Attribute::AttrKind)KindID));
2956}
2957
2960 const char *K, unsigned KLen) {
2961 return wrap(
2962 unwrap<CallBase>(C)->getAttributeAtIndex(Idx, StringRef(K, KLen)));
2963}
2964
2966 unsigned KindID) {
2967 unwrap<CallBase>(C)->removeAttributeAtIndex(Idx, (Attribute::AttrKind)KindID);
2968}
2969
2971 const char *K, unsigned KLen) {
2972 unwrap<CallBase>(C)->removeAttributeAtIndex(Idx, StringRef(K, KLen));
2973}
2974
2976 return wrap(unwrap<CallBase>(Instr)->getCalledOperand());
2977}
2978
2980 return wrap(unwrap<CallBase>(Instr)->getFunctionType());
2981}
2982
2984 return unwrap<CallBase>(C)->getNumOperandBundles();
2985}
2986
2988 unsigned Index) {
2989 return wrap(
2990 new OperandBundleDef(unwrap<CallBase>(C)->getOperandBundleAt(Index)));
2991}
2992
2993/*--.. Operations on call instructions (only) ..............................--*/
2994
2996 return unwrap<CallInst>(Call)->isTailCall();
2997}
2998
2999void LLVMSetTailCall(LLVMValueRef Call, LLVMBool isTailCall) {
3000 unwrap<CallInst>(Call)->setTailCall(isTailCall);
3001}
3002
3004 return (LLVMTailCallKind)unwrap<CallInst>(Call)->getTailCallKind();
3005}
3006
3008 unwrap<CallInst>(Call)->setTailCallKind((CallInst::TailCallKind)kind);
3009}
3010
3011/*--.. Operations on invoke instructions (only) ............................--*/
3012
3014 return wrap(unwrap<InvokeInst>(Invoke)->getNormalDest());
3015}
3016
3018 if (CleanupReturnInst *CRI = dyn_cast<CleanupReturnInst>(unwrap(Invoke))) {
3019 return wrap(CRI->getUnwindDest());
3020 } else if (CatchSwitchInst *CSI = dyn_cast<CatchSwitchInst>(unwrap(Invoke))) {
3021 return wrap(CSI->getUnwindDest());
3022 }
3023 return wrap(unwrap<InvokeInst>(Invoke)->getUnwindDest());
3024}
3025
3027 unwrap<InvokeInst>(Invoke)->setNormalDest(unwrap(B));
3028}
3029
3031 if (CleanupReturnInst *CRI = dyn_cast<CleanupReturnInst>(unwrap(Invoke))) {
3032 return CRI->setUnwindDest(unwrap(B));
3033 } else if (CatchSwitchInst *CSI = dyn_cast<CatchSwitchInst>(unwrap(Invoke))) {
3034 return CSI->setUnwindDest(unwrap(B));
3035 }
3036 unwrap<InvokeInst>(Invoke)->setUnwindDest(unwrap(B));
3037}
3038
3040 return wrap(unwrap<CallBrInst>(CallBr)->getDefaultDest());
3041}
3042
3044 return unwrap<CallBrInst>(CallBr)->getNumIndirectDests();
3045}
3046
3048 return wrap(unwrap<CallBrInst>(CallBr)->getIndirectDest(Idx));
3049}
3050
3051/*--.. Operations on terminators ...........................................--*/
3052
3054 return unwrap<Instruction>(Term)->getNumSuccessors();
3055}
3056
3058 return wrap(unwrap<Instruction>(Term)->getSuccessor(i));
3059}
3060
3062 return unwrap<Instruction>(Term)->setSuccessor(i, unwrap(block));
3063}
3064
3065/*--.. Operations on branch instructions (only) ............................--*/
3066
3068 return unwrap<BranchInst>(Branch)->isConditional();
3069}
3070
3072 return wrap(unwrap<BranchInst>(Branch)->getCondition());
3073}
3074
3076 return unwrap<BranchInst>(Branch)->setCondition(unwrap(Cond));
3077}
3078
3079/*--.. Operations on switch instructions (only) ............................--*/
3080
3082 return wrap(unwrap<SwitchInst>(Switch)->getDefaultDest());
3083}
3084
3085/*--.. Operations on alloca instructions (only) ............................--*/
3086
3088 return wrap(unwrap<AllocaInst>(Alloca)->getAllocatedType());
3089}
3090
3091/*--.. Operations on gep instructions (only) ...............................--*/
3092
3094 return unwrap<GEPOperator>(GEP)->isInBounds();
3095}
3096
3098 return unwrap<GetElementPtrInst>(GEP)->setIsInBounds(InBounds);
3099}
3100
3102 return wrap(unwrap<GEPOperator>(GEP)->getSourceElementType());
3103}
3104
3105/*--.. Operations on phi nodes .............................................--*/
3106
3107void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues,
3108 LLVMBasicBlockRef *IncomingBlocks, unsigned Count) {
3109 PHINode *PhiVal = unwrap<PHINode>(PhiNode);
3110 for (unsigned I = 0; I != Count; ++I)
3111 PhiVal->addIncoming(unwrap(IncomingValues[I]), unwrap(IncomingBlocks[I]));
3112}
3113
3115 return unwrap<PHINode>(PhiNode)->getNumIncomingValues();
3116}
3117
3119 return wrap(unwrap<PHINode>(PhiNode)->getIncomingValue(Index));
3120}
3121
3123 return wrap(unwrap<PHINode>(PhiNode)->getIncomingBlock(Index));
3124}
3125
3126/*--.. Operations on extractvalue and insertvalue nodes ....................--*/
3127
3129 auto *I = unwrap(Inst);
3130 if (auto *GEP = dyn_cast<GEPOperator>(I))
3131 return GEP->getNumIndices();
3132 if (auto *EV = dyn_cast<ExtractValueInst>(I))
3133 return EV->getNumIndices();
3134 if (auto *IV = dyn_cast<InsertValueInst>(I))
3135 return IV->getNumIndices();
3137 "LLVMGetNumIndices applies only to extractvalue and insertvalue!");
3138}
3139
3140const unsigned *LLVMGetIndices(LLVMValueRef Inst) {
3141 auto *I = unwrap(Inst);
3142 if (auto *EV = dyn_cast<ExtractValueInst>(I))
3143 return EV->getIndices().data();
3144 if (auto *IV = dyn_cast<InsertValueInst>(I))
3145 return IV->getIndices().data();
3147 "LLVMGetIndices applies only to extractvalue and insertvalue!");
3148}
3149
3150
3151/*===-- Instruction builders ----------------------------------------------===*/
3152
3154 return wrap(new IRBuilder<>(*unwrap(C)));
3155}
3156
3159}
3160
3162 Instruction *Instr, bool BeforeDbgRecords) {
3163 BasicBlock::iterator I = Instr ? Instr->getIterator() : Block->end();
3164 I.setHeadBit(BeforeDbgRecords);
3165 Builder->SetInsertPoint(Block, I);
3166}
3167
3169 LLVMValueRef Instr) {
3170 return LLVMPositionBuilderImpl(unwrap(Builder), unwrap(Block),
3171 unwrap<Instruction>(Instr), false);
3172}
3173
3176 LLVMValueRef Instr) {
3177 return LLVMPositionBuilderImpl(unwrap(Builder), unwrap(Block),
3178 unwrap<Instruction>(Instr), true);
3179}
3180
3182 Instruction *I = unwrap<Instruction>(Instr);
3183 return LLVMPositionBuilderImpl(unwrap(Builder), I->getParent(), I, false);
3184}
3185
3187 LLVMValueRef Instr) {
3188 Instruction *I = unwrap<Instruction>(Instr);
3189 return LLVMPositionBuilderImpl(unwrap(Builder), I->getParent(), I, true);
3190}
3191
3193 BasicBlock *BB = unwrap(Block);
3194 unwrap(Builder)->SetInsertPoint(BB);
3195}
3196
3198 return wrap(unwrap(Builder)->GetInsertBlock());
3199}
3200
3202 unwrap(Builder)->ClearInsertionPoint();
3203}
3204
3206 unwrap(Builder)->Insert(unwrap<Instruction>(Instr));
3207}
3208
3210 const char *Name) {
3211 unwrap(Builder)->Insert(unwrap<Instruction>(Instr), Name);
3212}
3213
3215 delete unwrap(Builder);
3216}
3217
3218/*--.. Metadata builders ...................................................--*/
3219
3221 return wrap(unwrap(Builder)->getCurrentDebugLocation().getAsMDNode());
3222}
3223
3225 if (Loc)
3226 unwrap(Builder)->SetCurrentDebugLocation(DebugLoc(unwrap<MDNode>(Loc)));
3227 else
3228 unwrap(Builder)->SetCurrentDebugLocation(DebugLoc());
3229}
3230
3232 MDNode *Loc =
3233 L ? cast<MDNode>(unwrap<MetadataAsValue>(L)->getMetadata()) : nullptr;
3234 unwrap(Builder)->SetCurrentDebugLocation(DebugLoc(Loc));
3235}
3236
3238 LLVMContext &Context = unwrap(Builder)->getContext();
3240 Context, unwrap(Builder)->getCurrentDebugLocation().getAsMDNode()));
3241}
3242
3244 unwrap(Builder)->SetInstDebugLocation(unwrap<Instruction>(Inst));
3245}
3246
3248 unwrap(Builder)->AddMetadataToInst(unwrap<Instruction>(Inst));
3249}
3250
3252 LLVMMetadataRef FPMathTag) {
3253
3254 unwrap(Builder)->setDefaultFPMathTag(FPMathTag
3255 ? unwrap<MDNode>(FPMathTag)
3256 : nullptr);
3257}
3258
3260 return wrap(unwrap(Builder)->getDefaultFPMathTag());
3261}
3262
3263/*--.. Instruction builders ................................................--*/
3264
3266 return wrap(unwrap(B)->CreateRetVoid());
3267}
3268
3270 return wrap(unwrap(B)->CreateRet(unwrap(V)));
3271}
3272
3274 unsigned N) {
3275 return wrap(unwrap(B)->CreateAggregateRet(unwrap(RetVals), N));
3276}
3277
3279 return wrap(unwrap(B)->CreateBr(unwrap(Dest)));
3280}
3281
3284 return wrap(unwrap(B)->CreateCondBr(unwrap(If), unwrap(Then), unwrap(Else)));
3285}
3286
3288 LLVMBasicBlockRef Else, unsigned NumCases) {
3289 return wrap(unwrap(B)->CreateSwitch(unwrap(V), unwrap(Else), NumCases));
3290}
3291
3293 unsigned NumDests) {
3294 return wrap(unwrap(B)->CreateIndirectBr(unwrap(Addr), NumDests));
3295}
3296
3298 LLVMBasicBlockRef DefaultDest,
3299 LLVMBasicBlockRef *IndirectDests,
3300 unsigned NumIndirectDests, LLVMValueRef *Args,
3301 unsigned NumArgs, LLVMOperandBundleRef *Bundles,
3302 unsigned NumBundles, const char *Name) {
3303
3305 for (auto *Bundle : ArrayRef(Bundles, NumBundles)) {
3306 OperandBundleDef *OB = unwrap(Bundle);
3307 OBs.push_back(*OB);
3308 }
3309
3310 return wrap(unwrap(B)->CreateCallBr(
3311 unwrap<FunctionType>(Ty), unwrap(Fn), unwrap(DefaultDest),
3312 ArrayRef(unwrap(IndirectDests), NumIndirectDests),
3313 ArrayRef<Value *>(unwrap(Args), NumArgs), OBs, Name));
3314}
3315
3317 LLVMValueRef *Args, unsigned NumArgs,
3319 const char *Name) {
3320 return wrap(unwrap(B)->CreateInvoke(unwrap<FunctionType>(Ty), unwrap(Fn),
3321 unwrap(Then), unwrap(Catch),
3322 ArrayRef(unwrap(Args), NumArgs), Name));
3323}
3324
3327 unsigned NumArgs, LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch,
3328 LLVMOperandBundleRef *Bundles, unsigned NumBundles, const char *Name) {
3330 for (auto *Bundle : ArrayRef(Bundles, NumBundles)) {
3331 OperandBundleDef *OB = unwrap(Bundle);
3332 OBs.push_back(*OB);
3333 }
3334 return wrap(unwrap(B)->CreateInvoke(
3335 unwrap<FunctionType>(Ty), unwrap(Fn), unwrap(Then), unwrap(Catch),
3336 ArrayRef(unwrap(Args), NumArgs), OBs, Name));
3337}
3338
3340 LLVMValueRef PersFn, unsigned NumClauses,
3341 const char *Name) {
3342 // The personality used to live on the landingpad instruction, but now it
3343 // lives on the parent function. For compatibility, take the provided
3344 // personality and put it on the parent function.
3345 if (PersFn)
3346 unwrap(B)->GetInsertBlock()->getParent()->setPersonalityFn(
3347 unwrap<Function>(PersFn));
3348 return wrap(unwrap(B)->CreateLandingPad(unwrap(Ty), NumClauses, Name));
3349}
3350
3352 LLVMValueRef *Args, unsigned NumArgs,
3353 const char *Name) {
3354 return wrap(unwrap(B)->CreateCatchPad(unwrap(ParentPad),
3355 ArrayRef(unwrap(Args), NumArgs), Name));
3356}
3357
3359 LLVMValueRef *Args, unsigned NumArgs,
3360 const char *Name) {
3361 if (ParentPad == nullptr) {
3362 Type *Ty = Type::getTokenTy(unwrap(B)->getContext());
3363 ParentPad = wrap(Constant::getNullValue(Ty));
3364 }
3365 return wrap(unwrap(B)->CreateCleanupPad(
3366 unwrap(ParentPad), ArrayRef(unwrap(Args), NumArgs), Name));
3367}
3368
3370 return wrap(unwrap(B)->CreateResume(unwrap(Exn)));
3371}
3372
3374 LLVMBasicBlockRef UnwindBB,
3375 unsigned NumHandlers, const char *Name) {
3376 if (ParentPad == nullptr) {
3377 Type *Ty = Type::getTokenTy(unwrap(B)->getContext());
3378 ParentPad = wrap(Constant::getNullValue(Ty));
3379 }
3380 return wrap(unwrap(B)->CreateCatchSwitch(unwrap(ParentPad), unwrap(UnwindBB),
3381 NumHandlers, Name));
3382}
3383
3385 LLVMBasicBlockRef BB) {
3386 return wrap(unwrap(B)->CreateCatchRet(unwrap<CatchPadInst>(CatchPad),
3387 unwrap(BB)));
3388}
3389
3391 LLVMBasicBlockRef BB) {
3392 return wrap(unwrap(B)->CreateCleanupRet(unwrap<CleanupPadInst>(CatchPad),
3393 unwrap(BB)));
3394}
3395
3397 return wrap(unwrap(B)->CreateUnreachable());
3398}
3399
3401 LLVMBasicBlockRef Dest) {
3402 unwrap<SwitchInst>(Switch)->addCase(unwrap<ConstantInt>(OnVal), unwrap(Dest));
3403}
3404
3406 unwrap<IndirectBrInst>(IndirectBr)->addDestination(unwrap(Dest));
3407}
3408
3409unsigned LLVMGetNumClauses(LLVMValueRef LandingPad) {
3410 return unwrap<LandingPadInst>(LandingPad)->getNumClauses();
3411}
3412
3414 return wrap(unwrap<LandingPadInst>(LandingPad)->getClause(Idx));
3415}
3416
3418 unwrap<LandingPadInst>(LandingPad)->addClause(unwrap<Constant>(ClauseVal));
3419}
3420
3422 return unwrap<LandingPadInst>(LandingPad)->isCleanup();
3423}
3424
3425void LLVMSetCleanup(LLVMValueRef LandingPad, LLVMBool Val) {
3426 unwrap<LandingPadInst>(LandingPad)->setCleanup(Val);
3427}
3428
3430 unwrap<CatchSwitchInst>(CatchSwitch)->addHandler(unwrap(Dest));
3431}
3432
3433unsigned LLVMGetNumHandlers(LLVMValueRef CatchSwitch) {
3434 return unwrap<CatchSwitchInst>(CatchSwitch)->getNumHandlers();
3435}
3436
3437void LLVMGetHandlers(LLVMValueRef CatchSwitch, LLVMBasicBlockRef *Handlers) {
3438 CatchSwitchInst *CSI = unwrap<CatchSwitchInst>(CatchSwitch);
3439 for (const BasicBlock *H : CSI->handlers())
3440 *Handlers++ = wrap(H);
3441}
3442
3444 return wrap(unwrap<CatchPadInst>(CatchPad)->getCatchSwitch());
3445}
3446
3448 unwrap<CatchPadInst>(CatchPad)
3449 ->setCatchSwitch(unwrap<CatchSwitchInst>(CatchSwitch));
3450}
3451
3452/*--.. Funclets ...........................................................--*/
3453
3455 return wrap(unwrap<FuncletPadInst>(Funclet)->getArgOperand(i));
3456}
3457
3459 unwrap<FuncletPadInst>(Funclet)->setArgOperand(i, unwrap(value));
3460}
3461
3462/*--.. Arithmetic ..........................................................--*/
3463
3465 FastMathFlags NewFMF;
3466 NewFMF.setAllowReassoc((FMF & LLVMFastMathAllowReassoc) != 0);
3467 NewFMF.setNoNaNs((FMF & LLVMFastMathNoNaNs) != 0);
3468 NewFMF.setNoInfs((FMF & LLVMFastMathNoInfs) != 0);
3469 NewFMF.setNoSignedZeros((FMF & LLVMFastMathNoSignedZeros) != 0);
3471 NewFMF.setAllowContract((FMF & LLVMFastMathAllowContract) != 0);
3472 NewFMF.setApproxFunc((FMF & LLVMFastMathApproxFunc) != 0);
3473
3474 return NewFMF;
3475}
3476
3479 if (FMF.allowReassoc())
3480 NewFMF |= LLVMFastMathAllowReassoc;
3481 if (FMF.noNaNs())
3482 NewFMF |= LLVMFastMathNoNaNs;
3483 if (FMF.noInfs())
3484 NewFMF |= LLVMFastMathNoInfs;
3485 if (FMF.noSignedZeros())
3486 NewFMF |= LLVMFastMathNoSignedZeros;
3487 if (FMF.allowReciprocal())
3489 if (FMF.allowContract())
3490 NewFMF |= LLVMFastMathAllowContract;
3491 if (FMF.approxFunc())
3492 NewFMF |= LLVMFastMathApproxFunc;
3493
3494 return NewFMF;
3495}
3496
3498 const char *Name) {
3499 return wrap(unwrap(B)->CreateAdd(unwrap(LHS), unwrap(RHS), Name));
3500}
3501
3503 const char *Name) {
3504 return wrap(unwrap(B)->CreateNSWAdd(unwrap(LHS), unwrap(RHS), Name));
3505}
3506
3508 const char *Name) {
3509 return wrap(unwrap(B)->CreateNUWAdd(unwrap(LHS), unwrap(RHS), Name));
3510}
3511
3513 const char *Name) {
3514 return wrap(unwrap(B)->CreateFAdd(unwrap(LHS), unwrap(RHS), Name));
3515}
3516
3518 const char *Name) {
3519 return wrap(unwrap(B)->CreateSub(unwrap(LHS), unwrap(RHS), Name));
3520}
3521
3523 const char *Name) {
3524 return wrap(unwrap(B)->CreateNSWSub(unwrap(LHS), unwrap(RHS), Name));
3525}
3526
3528 const char *Name) {
3529 return wrap(unwrap(B)->CreateNUWSub(unwrap(LHS), unwrap(RHS), Name));
3530}
3531
3533 const char *Name) {
3534 return wrap(unwrap(B)->CreateFSub(unwrap(LHS), unwrap(RHS), Name));
3535}
3536
3538 const char *Name) {
3539 return wrap(unwrap(B)->CreateMul(unwrap(LHS), unwrap(RHS), Name));
3540}
3541
3543 const char *Name) {
3544 return wrap(unwrap(B)->CreateNSWMul(unwrap(LHS), unwrap(RHS), Name));
3545}
3546
3548 const char *Name) {
3549 return wrap(unwrap(B)->CreateNUWMul(unwrap(LHS), unwrap(RHS), Name));
3550}
3551
3553 const char *Name) {
3554 return wrap(unwrap(B)->CreateFMul(unwrap(LHS), unwrap(RHS), Name));
3555}
3556
3558 const char *Name) {
3559 return wrap(unwrap(B)->CreateUDiv(unwrap(LHS), unwrap(RHS), Name));
3560}
3561
3563 LLVMValueRef RHS, const char *Name) {
3564 return wrap(unwrap(B)->CreateExactUDiv(unwrap(LHS), unwrap(RHS), Name));
3565}
3566
3568 const char *Name) {
3569 return wrap(unwrap(B)->CreateSDiv(unwrap(LHS), unwrap(RHS), Name));
3570}
3571
3573 LLVMValueRef RHS, const char *Name) {
3574 return wrap(unwrap(B)->CreateExactSDiv(unwrap(LHS), unwrap(RHS), Name));
3575}
3576
3578 const char *Name) {
3579 return wrap(unwrap(B)->CreateFDiv(unwrap(LHS), unwrap(RHS), Name));
3580}
3581
3583 const char *Name) {
3584 return wrap(unwrap(B)->CreateURem(unwrap(LHS), unwrap(RHS), Name));
3585}
3586
3588 const char *Name) {
3589 return wrap(unwrap(B)->CreateSRem(unwrap(LHS), unwrap(RHS), Name));
3590}
3591
3593 const char *Name) {
3594 return wrap(unwrap(B)->CreateFRem(unwrap(LHS), unwrap(RHS), Name));
3595}
3596
3598 const char *Name) {
3599 return wrap(unwrap(B)->CreateShl(unwrap(LHS), unwrap(RHS), Name));
3600}
3601
3603 const char *Name) {
3604 return wrap(unwrap(B)->CreateLShr(unwrap(LHS), unwrap(RHS), Name));
3605}
3606
3608 const char *Name) {
3609 return wrap(unwrap(B)->CreateAShr(unwrap(LHS), unwrap(RHS), Name));
3610}
3611
3613 const char *Name) {
3614 return wrap(unwrap(B)->CreateAnd(unwrap(LHS), unwrap(RHS), Name));
3615}
3616
3618 const char *Name) {
3619 return wrap(unwrap(B)->CreateOr(unwrap(LHS), unwrap(RHS), Name));
3620}
3621
3623 const char *Name) {
3624 return wrap(unwrap(B)->CreateXor(unwrap(LHS), unwrap(RHS), Name));
3625}
3626
3628 LLVMValueRef LHS, LLVMValueRef RHS,
3629 const char *Name) {
3631 unwrap(RHS), Name));
3632}
3633
3635 return wrap(unwrap(B)->CreateNeg(unwrap(V), Name));
3636}
3637
3639 const char *Name) {
3640 return wrap(unwrap(B)->CreateNSWNeg(unwrap(V), Name));
3641}
3642
3644 const char *Name) {
3645 Value *Neg = unwrap(B)->CreateNeg(unwrap(V), Name);
3646 if (auto *I = dyn_cast<BinaryOperator>(Neg))
3647 I->setHasNoUnsignedWrap();
3648 return wrap(Neg);
3649}
3650
3652 return wrap(unwrap(B)->CreateFNeg(unwrap(V), Name));
3653}
3654
3656 return wrap(unwrap(B)->CreateNot(unwrap(V), Name));
3657}
3658
3660 Value *P = unwrap<Value>(ArithInst);
3661 return cast<Instruction>(P)->hasNoUnsignedWrap();
3662}
3663
3664void LLVMSetNUW(LLVMValueRef ArithInst, LLVMBool HasNUW) {
3665 Value *P = unwrap<Value>(ArithInst);
3666 cast<Instruction>(P)->setHasNoUnsignedWrap(HasNUW);
3667}
3668
3670 Value *P = unwrap<Value>(ArithInst);
3671 return cast<Instruction>(P)->hasNoSignedWrap();
3672}
3673
3674void LLVMSetNSW(LLVMValueRef ArithInst, LLVMBool HasNSW) {
3675 Value *P = unwrap<Value>(ArithInst);
3676 cast<Instruction>(P)->setHasNoSignedWrap(HasNSW);
3677}
3678
3680 Value *P = unwrap<Value>(DivOrShrInst);
3681 return cast<Instruction>(P)->isExact();
3682}
3683
3684void LLVMSetExact(LLVMValueRef DivOrShrInst, LLVMBool IsExact) {
3685 Value *P = unwrap<Value>(DivOrShrInst);
3686 cast<Instruction>(P)->setIsExact(IsExact);
3687}
3688
3690 Value *P = unwrap<Value>(NonNegInst);
3691 return cast<Instruction>(P)->hasNonNeg();
3692}
3693
3694void LLVMSetNNeg(LLVMValueRef NonNegInst, LLVMBool IsNonNeg) {
3695 Value *P = unwrap<Value>(NonNegInst);
3696 cast<Instruction>(P)->setNonNeg(IsNonNeg);
3697}
3698
3700 Value *P = unwrap<Value>(FPMathInst);
3701 FastMathFlags FMF = cast<Instruction>(P)->getFastMathFlags();
3702 return mapToLLVMFastMathFlags(FMF);
3703}
3704
3706 Value *P = unwrap<Value>(FPMathInst);
3707 cast<Instruction>(P)->setFastMathFlags(mapFromLLVMFastMathFlags(FMF));
3708}
3709
3711 Value *Val = unwrap<Value>(V);
3712 return isa<FPMathOperator>(Val);
3713}
3714
3716 Value *P = unwrap<Value>(Inst);
3717 return cast<PossiblyDisjointInst>(P)->isDisjoint();
3718}
3719
3721 Value *P = unwrap<Value>(Inst);
3722 cast<PossiblyDisjointInst>(P)->setIsDisjoint(IsDisjoint);
3723}
3724
3725/*--.. Memory ..............................................................--*/
3726
3728 const char *Name) {
3729 Type* ITy = Type::getInt32Ty(unwrap(B)->GetInsertBlock()->getContext());
3730 Constant* AllocSize = ConstantExpr::getSizeOf(unwrap(Ty));
3731 AllocSize = ConstantExpr::getTruncOrBitCast(AllocSize, ITy);
3732 return wrap(unwrap(B)->CreateMalloc(ITy, unwrap(Ty), AllocSize, nullptr,
3733 nullptr, Name));
3734}
3735
3737 LLVMValueRef Val, const char *Name) {
3738 Type* ITy = Type::getInt32Ty(unwrap(B)->GetInsertBlock()->getContext());
3739 Constant* AllocSize = ConstantExpr::getSizeOf(unwrap(Ty));
3740 AllocSize = ConstantExpr::getTruncOrBitCast(AllocSize, ITy);
3741 return wrap(unwrap(B)->CreateMalloc(ITy, unwrap(Ty), AllocSize, unwrap(Val),
3742 nullptr, Name));
3743}
3744
3746 LLVMValueRef Val, LLVMValueRef Len,
3747 unsigned Align) {
3748 return wrap(unwrap(B)->CreateMemSet(unwrap(Ptr), unwrap(Val), unwrap(Len),
3749 MaybeAlign(Align)));
3750}
3751
3753 LLVMValueRef Dst, unsigned DstAlign,
3754 LLVMValueRef Src, unsigned SrcAlign,
3756 return wrap(unwrap(B)->CreateMemCpy(unwrap(Dst), MaybeAlign(DstAlign),
3757 unwrap(Src), MaybeAlign(SrcAlign),
3758 unwrap(Size)));
3759}
3760
3762 LLVMValueRef Dst, unsigned DstAlign,
3763 LLVMValueRef Src, unsigned SrcAlign,
3765 return wrap(unwrap(B)->CreateMemMove(unwrap(Dst), MaybeAlign(DstAlign),
3766 unwrap(Src), MaybeAlign(SrcAlign),
3767 unwrap(Size)));
3768}
3769
3771 const char *Name) {
3772 return wrap(unwrap(B)->CreateAlloca(unwrap(Ty), nullptr, Name));
3773}
3774
3776 LLVMValueRef Val, const char *Name) {
3777 return wrap(unwrap(B)->CreateAlloca(unwrap(Ty), unwrap(Val), Name));
3778}
3779
3781 return wrap(unwrap(B)->CreateFree(unwrap(PointerVal)));
3782}
3783
3785 LLVMValueRef PointerVal, const char *Name) {
3786 return wrap(unwrap(B)->CreateLoad(unwrap(Ty), unwrap(PointerVal), Name));
3787}
3788
3790 LLVMValueRef PointerVal) {
3791 return wrap(unwrap(B)->CreateStore(unwrap(Val), unwrap(PointerVal)));
3792}
3793
3795 switch (Ordering) {
3796 case LLVMAtomicOrderingNotAtomic: return AtomicOrdering::NotAtomic;
3797 case LLVMAtomicOrderingUnordered: return AtomicOrdering::Unordered;
3798 case LLVMAtomicOrderingMonotonic: return AtomicOrdering::Monotonic;
3799 case LLVMAtomicOrderingAcquire: return AtomicOrdering::Acquire;
3800 case LLVMAtomicOrderingRelease: return AtomicOrdering::Release;
3802 return AtomicOrdering::AcquireRelease;
3804 return AtomicOrdering::SequentiallyConsistent;
3805 }
3806
3807 llvm_unreachable("Invalid LLVMAtomicOrdering value!");
3808}
3809
3811 switch (Ordering) {
3812 case AtomicOrdering::NotAtomic: return LLVMAtomicOrderingNotAtomic;
3813 case AtomicOrdering::Unordered: return LLVMAtomicOrderingUnordered;
3814 case AtomicOrdering::Monotonic: return LLVMAtomicOrderingMonotonic;
3815 case AtomicOrdering::Acquire: return LLVMAtomicOrderingAcquire;
3816 case AtomicOrdering::Release: return LLVMAtomicOrderingRelease;
3817 case AtomicOrdering::AcquireRelease:
3819 case AtomicOrdering::SequentiallyConsistent:
3821 }
3822
3823 llvm_unreachable("Invalid AtomicOrdering value!");
3824}
3825
3827 switch (BinOp) {
3847 }
3848
3849 llvm_unreachable("Invalid LLVMAtomicRMWBinOp value!");
3850}
3851
3853 switch (BinOp) {
3873 default: break;
3874 }
3875
3876 llvm_unreachable("Invalid AtomicRMWBinOp value!");
3877}
3878
3879// TODO: Should this and other atomic instructions support building with
3880// "syncscope"?
3882 LLVMBool isSingleThread, const char *Name) {
3883 return wrap(
3884 unwrap(B)->CreateFence(mapFromLLVMOrdering(Ordering),
3885 isSingleThread ? SyncScope::SingleThread
3887 Name));
3888}
3889
3891 LLVMValueRef Pointer, LLVMValueRef *Indices,
3892 unsigned NumIndices, const char *Name) {
3893 ArrayRef<Value *> IdxList(unwrap(Indices), NumIndices);
3894 return wrap(unwrap(B)->CreateGEP(unwrap(Ty), unwrap(Pointer), IdxList, Name));
3895}
3896
3898 LLVMValueRef Pointer, LLVMValueRef *Indices,
3899 unsigned NumIndices, const char *Name) {
3900 ArrayRef<Value *> IdxList(unwrap(Indices), NumIndices);
3901 return wrap(
3902 unwrap(B)->CreateInBoundsGEP(unwrap(Ty), unwrap(Pointer), IdxList, Name));
3903}
3904
3906 LLVMValueRef Pointer, unsigned Idx,
3907 const char *Name) {
3908 return wrap(
3909 unwrap(B)->CreateStructGEP(unwrap(Ty), unwrap(Pointer), Idx, Name));
3910}
3911
3913 const char *Name) {
3914 return wrap(unwrap(B)->CreateGlobalString(Str, Name));
3915}
3916
3918 const char *Name) {
3919 return wrap(unwrap(B)->CreateGlobalStringPtr(Str, Name));
3920}
3921
3923 Value *P = unwrap(MemAccessInst);
3924 if (LoadInst *LI = dyn_cast<LoadInst>(P))
3925 return LI->isVolatile();
3926 if (StoreInst *SI = dyn_cast<StoreInst>(P))
3927 return SI->isVolatile();
3928 if (AtomicRMWInst *AI = dyn_cast<AtomicRMWInst>(P))
3929 return AI->isVolatile();
3930 return cast<AtomicCmpXchgInst>(P)->isVolatile();
3931}
3932
3933void LLVMSetVolatile(LLVMValueRef MemAccessInst, LLVMBool isVolatile) {
3934 Value *P = unwrap(MemAccessInst);
3935 if (LoadInst *LI = dyn_cast<LoadInst>(P))
3936 return LI->setVolatile(isVolatile);
3937 if (StoreInst *SI = dyn_cast<StoreInst>(P))
3938 return SI->setVolatile(isVolatile);
3939 if (AtomicRMWInst *AI = dyn_cast<AtomicRMWInst>(P))
3940 return AI->setVolatile(isVolatile);
3941 return cast<AtomicCmpXchgInst>(P)->setVolatile(isVolatile);
3942}
3943
3945 return unwrap<AtomicCmpXchgInst>(CmpXchgInst)->isWeak();
3946}
3947
3948void LLVMSetWeak(LLVMValueRef CmpXchgInst, LLVMBool isWeak) {
3949 return unwrap<AtomicCmpXchgInst>(CmpXchgInst)->setWeak(isWeak);
3950}
3951
3953 Value *P = unwrap(MemAccessInst);
3955 if (LoadInst *LI = dyn_cast<LoadInst>(P))
3956 O = LI->getOrdering();
3957 else if (StoreInst *SI = dyn_cast<StoreInst>(P))
3958 O = SI->getOrdering();
3959 else if (FenceInst *FI = dyn_cast<FenceInst>(P))
3960 O = FI->getOrdering();
3961 else
3962 O = cast<AtomicRMWInst>(P)->getOrdering();
3963 return mapToLLVMOrdering(O);
3964}
3965
3966void LLVMSetOrdering(LLVMValueRef MemAccessInst, LLVMAtomicOrdering Ordering) {
3967 Value *P = unwrap(MemAccessInst);
3968 AtomicOrdering O = mapFromLLVMOrdering(Ordering);
3969
3970 if (LoadInst *LI = dyn_cast<LoadInst>(P))
3971 return LI->setOrdering(O);
3972 else if (FenceInst *FI = dyn_cast<FenceInst>(P))
3973 return FI->setOrdering(O);
3974 else if (AtomicRMWInst *ARWI = dyn_cast<AtomicRMWInst>(P))
3975 return ARWI->setOrdering(O);
3976 return cast<StoreInst>(P)->setOrdering(O);
3977}
3978
3980 return mapToLLVMRMWBinOp(unwrap<AtomicRMWInst>(Inst)->getOperation());
3981}
3982
3984 unwrap<AtomicRMWInst>(Inst)->setOperation(mapFromLLVMRMWBinOp(BinOp));
3985}
3986
3987/*--.. Casts ...............................................................--*/
3988
3990 LLVMTypeRef DestTy, const char *Name) {
3991 return wrap(unwrap(B)->CreateTrunc(unwrap(Val), unwrap(DestTy), Name));
3992}
3993
3995 LLVMTypeRef DestTy, const char *Name) {
3996 return wrap(unwrap(B)->CreateZExt(unwrap(Val), unwrap(DestTy), Name));
3997}
3998
4000 LLVMTypeRef DestTy, const char *Name) {
4001 return wrap(unwrap(B)->CreateSExt(unwrap(Val), unwrap(DestTy), Name));
4002}
4003
4005 LLVMTypeRef DestTy, const char *Name) {
4006 return wrap(unwrap(B)->CreateFPToUI(unwrap(Val), unwrap(DestTy), Name));
4007}
4008
4010 LLVMTypeRef DestTy, const char *Name) {
4011 return wrap(unwrap(B)->CreateFPToSI(unwrap(Val), unwrap(DestTy), Name));
4012}
4013
4015 LLVMTypeRef DestTy, const char *Name) {
4016 return wrap(unwrap(B)->CreateUIToFP(unwrap(Val), unwrap(DestTy), Name));
4017}
4018
4020 LLVMTypeRef DestTy, const char *Name) {
4021 return wrap(unwrap(B)->CreateSIToFP(unwrap(Val), unwrap(DestTy), Name));
4022}
4023
4025 LLVMTypeRef DestTy, const char *Name) {
4026 return wrap(unwrap(B)->CreateFPTrunc(unwrap(Val), unwrap(DestTy), Name));
4027}
4028
4030 LLVMTypeRef DestTy, const char *Name) {
4031 return wrap(unwrap(B)->CreateFPExt(unwrap(Val), unwrap(DestTy), Name));
4032}
4033
4035 LLVMTypeRef DestTy, const char *Name) {
4036 return wrap(unwrap(B)->CreatePtrToInt(unwrap(Val), unwrap(DestTy), Name));
4037}
4038
4040 LLVMTypeRef DestTy, const char *Name) {
4041 return wrap(unwrap(B)->CreateIntToPtr(unwrap(Val), unwrap(DestTy), Name));
4042}
4043
4045 LLVMTypeRef DestTy, const char *Name) {
4046 return wrap(unwrap(B)->CreateBitCast(unwrap(Val), unwrap(DestTy), Name));
4047}
4048
4050 LLVMTypeRef DestTy, const char *Name) {
4051 return wrap(unwrap(B)->CreateAddrSpaceCast(unwrap(Val), unwrap(DestTy), Name));
4052}
4053
4055 LLVMTypeRef DestTy, const char *Name) {
4056 return wrap(unwrap(B)->CreateZExtOrBitCast(unwrap(Val), unwrap(DestTy),
4057 Name));
4058}
4059
4061 LLVMTypeRef DestTy, const char *Name) {
4062 return wrap(unwrap(B)->CreateSExtOrBitCast(unwrap(Val), unwrap(DestTy),
4063 Name));
4064}
4065
4067 LLVMTypeRef DestTy, const char *Name) {
4068 return wrap(unwrap(B)->CreateTruncOrBitCast(unwrap(Val), unwrap(DestTy),
4069 Name));
4070}
4071
4073 LLVMTypeRef DestTy, const char *Name) {
4074 return wrap(unwrap(B)->CreateCast(Instruction::CastOps(map_from_llvmopcode(Op)), unwrap(Val),
4075 unwrap(DestTy), Name));
4076}
4077
4079 LLVMTypeRef DestTy, const char *Name) {
4080 return wrap(unwrap(B)->CreatePointerCast(unwrap(Val), unwrap(DestTy), Name));
4081}
4082
4084 LLVMTypeRef DestTy, LLVMBool IsSigned,
4085 const char *Name) {
4086 return wrap(
4087 unwrap(B)->CreateIntCast(unwrap(Val), unwrap(DestTy), IsSigned, Name));
4088}
4089
4091 LLVMTypeRef DestTy, const char *Name) {
4092 return wrap(unwrap(B)->CreateIntCast(unwrap(Val), unwrap(DestTy),
4093 /*isSigned*/true, Name));
4094}
4095
4097 LLVMTypeRef DestTy, const char *Name) {
4098 return wrap(unwrap(B)->CreateFPCast(unwrap(Val), unwrap(DestTy), Name));
4099}
4100
4102 LLVMTypeRef DestTy, LLVMBool DestIsSigned) {
4104 unwrap(Src), SrcIsSigned, unwrap(DestTy), DestIsSigned));
4105}
4106
4107/*--.. Comparisons .........................................................--*/
4108
4110 LLVMValueRef LHS, LLVMValueRef RHS,
4111 const char *Name) {
4112 return wrap(unwrap(B)->CreateICmp(static_cast<ICmpInst::Predicate>(Op),
4113 unwrap(LHS), unwrap(RHS), Name));
4114}
4115
4117 LLVMValueRef LHS, LLVMValueRef RHS,
4118 const char *Name) {
4119 return wrap(unwrap(B)->CreateFCmp(static_cast<FCmpInst::Predicate>(Op),
4120 unwrap(LHS), unwrap(RHS), Name));
4121}
4122
4123/*--.. Miscellaneous instructions ..........................................--*/
4124
4126 return wrap(unwrap(B)->CreatePHI(unwrap(Ty), 0, Name));
4127}
4128
4130 LLVMValueRef *Args, unsigned NumArgs,
4131 const char *Name) {
4132 FunctionType *FTy = unwrap<FunctionType>(Ty);
4133 return wrap(unwrap(B)->CreateCall(FTy, unwrap(Fn),
4134 ArrayRef(unwrap(Args), NumArgs), Name));
4135}
4136
4139 LLVMValueRef Fn, LLVMValueRef *Args,
4140 unsigned NumArgs, LLVMOperandBundleRef *Bundles,
4141 unsigned NumBundles, const char *Name) {
4142 FunctionType *FTy = unwrap<FunctionType>(Ty);
4144 for (auto *Bundle : ArrayRef(Bundles, NumBundles)) {
4145 OperandBundleDef *OB = unwrap(Bundle);
4146 OBs.push_back(*OB);
4147 }
4148 return wrap(unwrap(B)->CreateCall(
4149 FTy, unwrap(Fn), ArrayRef(unwrap(Args), NumArgs), OBs, Name));
4150}
4151
4153 LLVMValueRef Then, LLVMValueRef Else,
4154 const char *Name) {
4155 return wrap(unwrap(B)->CreateSelect(unwrap(If), unwrap(Then), unwrap(Else),
4156 Name));
4157}
4158
4160 LLVMTypeRef Ty, const char *Name) {
4161 return wrap(unwrap(B)->CreateVAArg(unwrap(List), unwrap(Ty), Name));
4162}
4163
4165 LLVMValueRef Index, const char *Name) {
4166 return wrap(unwrap(B)->CreateExtractElement(unwrap(VecVal), unwrap(Index),
4167 Name));
4168}
4169
4172 const char *Name) {
4173 return wrap(unwrap(B)->CreateInsertElement(unwrap(VecVal), unwrap(EltVal),
4174 unwrap(Index), Name));
4175}
4176
4178 LLVMValueRef V2, LLVMValueRef Mask,
4179 const char *Name) {
4180 return wrap(unwrap(B)->CreateShuffleVector(unwrap(V1), unwrap(V2),
4181 unwrap(Mask), Name));
4182}
4183
4185 unsigned Index, const char *Name) {
4186 return wrap(unwrap(B)->CreateExtractValue(unwrap(AggVal), Index, Name));
4187}
4188
4190 LLVMValueRef EltVal, unsigned Index,
4191 const char *Name) {
4192 return wrap(unwrap(B)->CreateInsertValue(unwrap(AggVal), unwrap(EltVal),
4193 Index, Name));
4194}
4195
4197 const char *Name) {
4198 return wrap(unwrap(B)->CreateFreeze(unwrap(Val), Name));
4199}
4200
4202 const char *Name) {
4203 return wrap(unwrap(B)->CreateIsNull(unwrap(Val), Name));
4204}
4205
4207 const char *Name) {
4208 return wrap(unwrap(B)->CreateIsNotNull(unwrap(Val), Name));
4209}
4210
4212 LLVMValueRef LHS, LLVMValueRef RHS,
4213 const char *Name) {
4214 return wrap(unwrap(B)->CreatePtrDiff(unwrap(ElemTy), unwrap(LHS),
4215 unwrap(RHS), Name));
4216}
4217
4219 LLVMValueRef PTR, LLVMValueRef Val,
4220 LLVMAtomicOrdering ordering,
4221 LLVMBool singleThread) {
4223 return wrap(unwrap(B)->CreateAtomicRMW(
4224 intop, unwrap(PTR), unwrap(Val), MaybeAlign(),
4225 mapFromLLVMOrdering(ordering),
4226 singleThread ? SyncScope::SingleThread : SyncScope::System));
4227}
4228
4230 LLVMValueRef Cmp, LLVMValueRef New,
4231 LLVMAtomicOrdering SuccessOrdering,
4232 LLVMAtomicOrdering FailureOrdering,
4233 LLVMBool singleThread) {
4234
4235 return wrap(unwrap(B)->CreateAtomicCmpXchg(
4236 unwrap(Ptr), unwrap(Cmp), unwrap(New), MaybeAlign(),
4237 mapFromLLVMOrdering(SuccessOrdering),
4238 mapFromLLVMOrdering(FailureOrdering),
4239 singleThread ? SyncScope::SingleThread : SyncScope::System));
4240}
4241
4243 Value *P = unwrap(SVInst);
4244 ShuffleVectorInst *I = cast<ShuffleVectorInst>(P);
4245 return I->getShuffleMask().size();
4246}
4247
4248int LLVMGetMaskValue(LLVMValueRef SVInst, unsigned Elt) {
4249 Value *P = unwrap(SVInst);
4250 ShuffleVectorInst *I = cast<ShuffleVectorInst>(P);
4251 return I->getMaskValue(Elt);
4252}
4253
4255
4257 Value *P = unwrap(AtomicInst);
4258
4259 if (AtomicRMWInst *I = dyn_cast<AtomicRMWInst>(P))
4260 return I->getSyncScopeID() == SyncScope::SingleThread;
4261 else if (FenceInst *FI = dyn_cast<FenceInst>(P))
4262 return FI->getSyncScopeID() == SyncScope::SingleThread;
4263 else if (StoreInst *SI = dyn_cast<StoreInst>(P))
4264 return SI->getSyncScopeID() == SyncScope::SingleThread;
4265 else if (LoadInst *LI = dyn_cast<LoadInst>(P))
4266 return LI->getSyncScopeID() == SyncScope::SingleThread;
4267 return cast<AtomicCmpXchgInst>(P)->getSyncScopeID() ==
4269}
4270
4272 Value *P = unwrap(AtomicInst);
4274
4275 if (AtomicRMWInst *I = dyn_cast<AtomicRMWInst>(P))
4276 return I->setSyncScopeID(SSID);
4277 else if (FenceInst *FI = dyn_cast<FenceInst>(P))
4278 return FI->setSyncScopeID(SSID);
4279 else if (StoreInst *SI = dyn_cast<StoreInst>(P))
4280 return SI->setSyncScopeID(SSID);
4281 else if (LoadInst *LI = dyn_cast<LoadInst>(P))
4282 return LI->setSyncScopeID(SSID);
4283 return cast<AtomicCmpXchgInst>(P)->setSyncScopeID(SSID);
4284}
4285
4287 Value *P = unwrap(CmpXchgInst);
4288 return mapToLLVMOrdering(cast<AtomicCmpXchgInst>(P)->getSuccessOrdering());
4289}
4290
4292 LLVMAtomicOrdering Ordering) {
4293 Value *P = unwrap(CmpXchgInst);
4294 AtomicOrdering O = mapFromLLVMOrdering(Ordering);
4295
4296 return cast<AtomicCmpXchgInst>(P)->setSuccessOrdering(O);
4297}
4298
4300 Value *P = unwrap(CmpXchgInst);
4301 return mapToLLVMOrdering(cast<AtomicCmpXchgInst>(P)->getFailureOrdering());
4302}
4303
4305 LLVMAtomicOrdering Ordering) {
4306 Value *P = unwrap(CmpXchgInst);
4307 AtomicOrdering O = mapFromLLVMOrdering(Ordering);
4308
4309 return cast<AtomicCmpXchgInst>(P)->setFailureOrdering(O);
4310}
4311
4312/*===-- Module providers --------------------------------------------------===*/
4313
4316 return reinterpret_cast<LLVMModuleProviderRef>(M);
4317}
4318
4320 delete unwrap(MP);
4321}
4322
4323
4324/*===-- Memory buffers ----------------------------------------------------===*/
4325
4327 const char *Path,
4328 LLVMMemoryBufferRef *OutMemBuf,
4329 char **OutMessage) {
4330
4332 if (std::error_code EC = MBOrErr.getError()) {
4333 *OutMessage = strdup(EC.message().c_str());
4334 return 1;
4335 }
4336 *OutMemBuf = wrap(MBOrErr.get().release());
4337 return 0;
4338}
4339
4341 char **OutMessage) {
4343 if (std::error_code EC = MBOrErr.getError()) {
4344 *OutMessage = strdup(EC.message().c_str());
4345 return 1;
4346 }
4347 *OutMemBuf = wrap(MBOrErr.get().release());
4348 return 0;
4349}
4350
4352 const char *InputData,
4353 size_t InputDataLength,
4354 const char *BufferName,
4355 LLVMBool RequiresNullTerminator) {
4356
4357 return wrap(MemoryBuffer::getMemBuffer(StringRef(InputData, InputDataLength),
4358 StringRef(BufferName),
4359 RequiresNullTerminator).release());
4360}
4361
4363 const char *InputData,
4364 size_t InputDataLength,
4365 const char *BufferName) {
4366
4367 return wrap(
4368 MemoryBuffer::getMemBufferCopy(StringRef(InputData, InputDataLength),
4369 StringRef(BufferName)).release());
4370}
4371
4373 return unwrap(MemBuf)->getBufferStart();
4374}
4375
4377 return unwrap(MemBuf)->getBufferSize();
4378}
4379
4381 delete unwrap(MemBuf);
4382}
4383
4384/*===-- Pass Manager ------------------------------------------------------===*/
4385
4387 return wrap(new legacy::PassManager());
4388}
4389
4391 return wrap(new legacy::FunctionPassManager(unwrap(M)));
4392}
4393
4396 reinterpret_cast<LLVMModuleRef>(P));
4397}
4398
4400 return unwrap<legacy::PassManager>(PM)->run(*unwrap(M));
4401}
4402
4404 return unwrap<legacy::FunctionPassManager>(FPM)->doInitialization();
4405}
4406
4408 return unwrap<legacy::FunctionPassManager>(FPM)->run(*unwrap<Function>(F));
4409}
4410
4412 return unwrap<legacy::FunctionPassManager>(FPM)->doFinalization();
4413}
4414
4416 delete unwrap(PM);
4417}
4418
4419/*===-- Threading ------------------------------------------------------===*/
4420
4422 return LLVMIsMultithreaded();
4423}
4424
4426}
4427
4429 return llvm_is_multithreaded();
4430}
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:1612
static Module::ModFlagBehavior map_to_llvmModFlagBehavior(LLVMModuleFlagBehavior Behavior)
Definition: Core.cpp:333
#define LLVM_DEFINE_VALUE_CAST(name)
Definition: Core.cpp:1124
static LLVMValueMetadataEntry * llvm_getMetadata(size_t *NumEntries, llvm::function_ref< void(MetadataEntries &)> AccessMD)
Definition: Core.cpp:1096
static MDNode * extractMDNode(MetadataAsValue *MAV)
Definition: Core.cpp:1072
static void LLVMPositionBuilderImpl(IRBuilder<> *Builder, BasicBlock *Block, Instruction *Instr, bool BeforeDbgRecords)
Definition: Core.cpp:3161
static LLVMOpcode map_to_llvmopcode(int opcode)
Definition: Core.cpp:1668
static LLVMFastMathFlags mapToLLVMFastMathFlags(FastMathFlags FMF)
Definition: Core.cpp:3477
static FastMathFlags mapFromLLVMFastMathFlags(LLVMFastMathFlags FMF)
Definition: Core.cpp:3464
LLVMValueRef LLVMConstIntOfString(LLVMTypeRef IntTy, const char Str[], uint8_t Radix)
Definition: Core.cpp:1532
static AtomicOrdering mapFromLLVMOrdering(LLVMAtomicOrdering Ordering)
Definition: Core.cpp:3794
static Intrinsic::ID llvm_map_to_intrinsic_id(unsigned ID)
Definition: Core.cpp:2385
static LLVMModuleFlagBehavior map_from_llvmModFlagBehavior(Module::ModFlagBehavior Behavior)
Definition: Core.cpp:352
static LLVMAtomicOrdering mapToLLVMOrdering(AtomicOrdering Ordering)
Definition: Core.cpp:3810
LLVMValueRef LLVMBuildNUWNeg(LLVMBuilderRef B, LLVMValueRef V, const char *Name)
Definition: Core.cpp:3643
static LLVMValueRef getMDNodeOperandImpl(LLVMContext &Context, const MDNode *N, unsigned Index)
Definition: Core.cpp:1179
LLVMValueRef LLVMConstRealOfStringAndSize(LLVMTypeRef RealTy, const char Str[], unsigned SLen)
Definition: Core.cpp:1552
static int map_from_llvmopcode(LLVMOpcode code)
Definition: Core.cpp:1678
static LLVMAtomicRMWBinOp mapToLLVMRMWBinOp(AtomicRMWInst::BinOp BinOp)
Definition: Core.cpp:3852
static AtomicRMWInst::BinOp mapFromLLVMRMWBinOp(LLVMAtomicRMWBinOp BinOp)
Definition: Core.cpp:3826
LLVMValueRef LLVMConstNUWNeg(LLVMValueRef ConstantVal)
Definition: Core.cpp:1710
LLVMValueRef LLVMConstIntOfStringAndSize(LLVMTypeRef IntTy, const char Str[], unsigned SLen, uint8_t Radix)
Definition: Core.cpp:1538
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.
#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:5282
double convertToDouble() const
Converts this APFloat to host double value.
Definition: APFloat.cpp:5341
Class for arbitrary precision integers.
Definition: APInt.h:77
an instruction to allocate memory on the stack
Definition: Instructions.h:60
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:494
an instruction that atomically reads a memory location, combines it with another value,...
Definition: Instructions.h:695
BinOp
This enumeration lists the possible modifications atomicrmw can make.
Definition: Instructions.h:707
@ Add
*p = old + v
Definition: Instructions.h:711
@ FAdd
*p = old + v
Definition: Instructions.h:732
@ Min
*p = old <signed v ? old : v
Definition: Instructions.h:725
@ Or
*p = old | v
Definition: Instructions.h:719
@ Sub
*p = old - v
Definition: Instructions.h:713
@ And
*p = old & v
Definition: Instructions.h:715
@ Xor
*p = old ^ v
Definition: Instructions.h:721
@ FSub
*p = old - v
Definition: Instructions.h:735
@ UIncWrap
Increment one up to a maximum value.
Definition: Instructions.h:747
@ Max
*p = old >signed v ? old : v
Definition: Instructions.h:723
@ UMin
*p = old <unsigned v ? old : v
Definition: Instructions.h:729
@ FMin
*p = minnum(old, v) minnum matches the behavior of llvm.minnum.
Definition: Instructions.h:743
@ UMax
*p = old >unsigned v ? old : v
Definition: Instructions.h:727
@ FMax
*p = maxnum(old, v) maxnum matches the behavior of llvm.maxnum.
Definition: Instructions.h:739
@ UDecWrap
Decrement one until a minimum value or zero.
Definition: Instructions.h:751
@ Nand
*p = ~(old & v)
Definition: Instructions.h:717
static Attribute::AttrKind getAttrKindFromName(StringRef AttrName)
Definition: Attributes.cpp:303
static Attribute get(LLVMContext &Context, AttrKind Kind, uint64_t Val=0)
Return a uniquified Attribute object.
Definition: Attributes.cpp:94
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results,...
Definition: Attributes.h:86
static Attribute getWithAlignment(LLVMContext &Context, Align Alignment)
Return a uniquified Attribute object that has the specific alignment set.
Definition: Attributes.cpp:232
LLVM Basic Block Representation.
Definition: BasicBlock.h:61
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:4862
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:202
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:285
void removeFromParent()
Unlink 'this' from the containing function, but do not delete it.
Definition: BasicBlock.cpp:273
const Function * getParent() const
Return the enclosing method, or null if none.
Definition: BasicBlock.h:209
SymbolTableList< BasicBlock >::iterator eraseFromParent()
Unlink 'this' from the containing function and delete it.
Definition: BasicBlock.cpp:277
InstListType::iterator iterator
Instruction iterators...
Definition: BasicBlock.h:167
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:67
size_t size() const
Definition: BasicBlock.h:459
void moveBefore(BasicBlock *MovePos)
Unlink this basic block from its current function and insert it into the function that MovePos lives ...
Definition: BasicBlock.h:366
static BlockAddress * get(Function *F, BasicBlock *BB)
Return a BlockAddress for the specified function and basic block.
Definition: Constants.cpp:1833
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:757
static Constant * get(ArrayType *T, ArrayRef< Constant * > V)
Definition: Constants.cpp:1292
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:2900
static Constant * getIntToPtr(Constant *C, Type *Ty, bool OnlyIfReduced=false)
Definition: Constants.cpp:2231
static Constant * getExtractElement(Constant *Vec, Constant *Idx, Type *OnlyIfReducedTy=nullptr)
Definition: Constants.cpp:2478
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:2414
static Constant * getNUWSub(Constant *C1, Constant *C2)
Definition: Constants.h:1149
static Constant * getInBoundsGetElementPtr(Type *Ty, Constant *C, ArrayRef< Constant * > IdxList)
Create an "inbounds" getelementptr.
Definition: Constants.h:1267
static Constant * getPointerCast(Constant *C, Type *Ty)
Create a BitCast, AddrSpaceCast, or a PtrToInt cast constant expression.
Definition: Constants.cpp:2177
static Constant * getTruncOrBitCast(Constant *C, Type *Ty)
Definition: Constants.cpp:2171
static Constant * getNSWAdd(Constant *C1, Constant *C2)
Definition: Constants.h:1137
static Constant * getSub(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
Definition: Constants.cpp:2568
static Constant * getNot(Constant *C)
Definition: Constants.cpp:2555
static Constant * getInsertElement(Constant *Vec, Constant *Elt, Constant *Idx, Type *OnlyIfReducedTy=nullptr)
Definition: Constants.cpp:2500
static Constant * getPtrToInt(Constant *C, Type *Ty, bool OnlyIfReduced=false)
Definition: Constants.cpp:2217
static Constant * getShuffleVector(Constant *V1, Constant *V2, ArrayRef< int > Mask, Type *OnlyIfReducedTy=nullptr)
Definition: Constants.cpp:2523
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:2404
static Constant * getXor(Constant *C1, Constant *C2)
Definition: Constants.cpp:2582
static Constant * getMul(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
Definition: Constants.cpp:2575
static Constant * getNSWNeg(Constant *C)
Definition: Constants.h:1135
static Constant * getNSWSub(Constant *C1, Constant *C2)
Definition: Constants.h:1145
static Constant * getNUWAdd(Constant *C1, Constant *C2)
Definition: Constants.h:1141
static Constant * getAddrSpaceCast(Constant *C, Type *Ty, bool OnlyIfReduced=false)
Definition: Constants.cpp:2257
static Constant * getGetElementPtr(Type *Ty, Constant *C, ArrayRef< Constant * > IdxList, GEPNoWrapFlags NW=GEPNoWrapFlags::none(), std::optional< ConstantRange > InRange=std::nullopt, Type *OnlyIfReducedTy=nullptr)
Getelementptr form.
Definition: Constants.h:1240
static Constant * getAdd(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
Definition: Constants.cpp:2561
static Constant * getBitCast(Constant *C, Type *Ty, bool OnlyIfReduced=false)
Definition: Constants.cpp:2245
static Constant * getNSWMul(Constant *C1, Constant *C2)
Definition: Constants.h:1153
static Constant * getNeg(Constant *C, bool HasNSW=false)
Definition: Constants.cpp:2549
static Constant * getTrunc(Constant *C, Type *Ty, bool OnlyIfReduced=false)
Definition: Constants.cpp:2203
static Constant * getNUWMul(Constant *C1, Constant *C2)
Definition: Constants.h:1157
ConstantFP - Floating Point Values [float, double].
Definition: Constants.h:269
const APFloat & getValueAPF() const
Definition: Constants.h:312
static ConstantPointerNull * get(PointerType *T)
Static factory methods - Return objects of the specified value.
Definition: Constants.cpp:1762
This class represents a range of values.
Definition: ConstantRange.h:47
static Constant * get(StructType *T, ArrayRef< Constant * > V)
Definition: Constants.cpp:1357
static Constant * getAnon(ArrayRef< Constant * > V, bool Packed=false)
Return an anonymous struct that has the specified elements.
Definition: Constants.h:477
static Constant * get(ArrayRef< Constant * > V)
Definition: Constants.cpp:1399
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:419
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:165
BasicBlockListType::iterator iterator
Definition: Function.h:69
static Intrinsic::ID lookupIntrinsicID(StringRef Name)
This does the actual lookup of an intrinsic ID which matches the given function name.
Definition: Function.cpp:927
iterator_range< arg_iterator > args()
Definition: Function.h:855
void setPersonalityFn(Constant *Fn)
Definition: Function.cpp:1939
arg_iterator arg_begin()
Definition: Function.h:831
Function::iterator insert(Function::iterator Position, BasicBlock *BB)
Insert BB in the basic block list at Position.
Definition: Function.h:745
size_t arg_size() const
Definition: Function.h:864
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:544
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:601
void setUnnamedAddr(UnnamedAddr Val)
Definition: GlobalValue.h:231
void setThreadLocalMode(ThreadLocalMode Val)
Definition: GlobalValue.h:267
void setLinkage(LinkageTypes LT)
Definition: GlobalValue.h:537
DLLStorageClassTypes
Storage classes of global values for PE targets.
Definition: GlobalValue.h:73
Module * getParent()
Get the module that this global value is contained inside of...
Definition: GlobalValue.h:656
VisibilityTypes
An enumeration for the kinds of visibility of global values.
Definition: GlobalValue.h:66
@ PrivateLinkage
Like Internal, but omit from symbol table.
Definition: GlobalValue.h:60
@ CommonLinkage
Tentative definitions.
Definition: GlobalValue.h:62
@ InternalLinkage
Rename collisions when linking (static functions).
Definition: GlobalValue.h:59
@ LinkOnceAnyLinkage
Keep one copy of function when linking (inline)
Definition: GlobalValue.h:54
@ WeakODRLinkage
Same, but only replaced by something equivalent.
Definition: GlobalValue.h:57
@ ExternalLinkage
Externally visible function.
Definition: GlobalValue.h:52
@ WeakAnyLinkage
Keep one copy of named function when linking (weak)
Definition: GlobalValue.h:56
@ AppendingLinkage
Special purpose, only applies to global arrays.
Definition: GlobalValue.h:58
@ AvailableExternallyLinkage
Available for inspection, not emission.
Definition: GlobalValue.h:53
@ ExternalWeakLinkage
ExternalWeak linkage description.
Definition: GlobalValue.h:61
@ LinkOnceODRLinkage
Same, but only replaced by something equivalent.
Definition: GlobalValue.h:55
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
bool hasInitializer() const
Definitions have initializers, declarations don't.
This instruction compares its operands according to the predicate given to the constructor.
void SetInsertPoint(BasicBlock *TheBB)
This specifies that created instructions should be appended to the end of the specified block.
Definition: IRBuilder.h:178
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
Definition: IRBuilder.h:2664
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:173
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:694
ifunc_iterator ifunc_begin()
Definition: Module.h:752
ModFlagBehavior
This enumeration defines the supported behaviors of module flags.
Definition: Module.h:115
global_iterator global_end()
Definition: Module.h:696
NamedMDListType::iterator named_metadata_iterator
The named metadata iterators.
Definition: Module.h:110
iterator begin()
Definition: Module.h:712
IFuncListType::iterator ifunc_iterator
The Global IFunc iterators.
Definition: Module.h:105
named_metadata_iterator named_metadata_begin()
Definition: Module.h:793
ifunc_iterator ifunc_end()
Definition: Module.h:754
alias_iterator alias_end()
Definition: Module.h:736
alias_iterator alias_begin()
Definition: Module.h:734
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:714
named_metadata_iterator named_metadata_end()
Definition: Module.h:798
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:1189
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:1814
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:289
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
Class to represent target extensions types, which are generally unintrospectable from target-independ...
Definition: DerivedTypes.h:720
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:1795
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:132
FunctionPassManager manages FunctionPasses.
PassManager manages ModulePassManagers.
A raw_ostream that writes to a file descriptor.
Definition: raw_ostream.h:471
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:562
std::error_code error() const
Definition: raw_ostream.h:556
void close()
Manually flush the stream and close the file.
A raw_ostream that writes to an std::string.
Definition: raw_ostream.h:661
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:3784
LLVMValueRef LLVMBuildGlobalStringPtr(LLVMBuilderRef B, const char *Str, const char *Name)
Definition: Core.cpp:3917
LLVMValueRef LLVMBuildFence(LLVMBuilderRef B, LLVMAtomicOrdering Ordering, LLVMBool isSingleThread, const char *Name)
Definition: Core.cpp:3881
LLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B, LLVMAtomicRMWBinOp op, LLVMValueRef PTR, LLVMValueRef Val, LLVMAtomicOrdering ordering, LLVMBool singleThread)
Definition: Core.cpp:4218
LLVMBool LLVMGetIsDisjoint(LLVMValueRef Inst)
Gets whether the instruction has the disjoint flag set.
Definition: Core.cpp:3715
LLVMValueRef LLVMBuildNot(LLVMBuilderRef B, LLVMValueRef V, const char *Name)
Definition: Core.cpp:3655
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:3325
LLVMValueRef LLVMBuildNSWSub(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3522
LLVMValueRef LLVMBuildAnd(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3612
LLVMValueRef LLVMBuildFPExt(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:4029
void LLVMClearInsertionPosition(LLVMBuilderRef Builder)
Definition: Core.cpp:3201
LLVMValueRef LLVMBuildFDiv(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3577
void LLVMSetWeak(LLVMValueRef CmpXchgInst, LLVMBool isWeak)
Definition: Core.cpp:3948
void LLVMSetNSW(LLVMValueRef ArithInst, LLVMBool HasNSW)
Definition: Core.cpp:3674
LLVMValueRef LLVMBuildFreeze(LLVMBuilderRef B, LLVMValueRef Val, const char *Name)
Definition: Core.cpp:4196
LLVMValueRef LLVMBuildFAdd(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3512
LLVMValueRef LLVMBuildFMul(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3552
LLVMValueRef LLVMBuildZExt(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:3994
LLVMValueRef LLVMBuildSExt(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:3999
LLVMValueRef LLVMBuildTruncOrBitCast(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:4066
LLVMValueRef LLVMBuildSExtOrBitCast(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:4060
LLVMValueRef LLVMBuildBitCast(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:4044
void LLVMBuilderSetDefaultFPMathTag(LLVMBuilderRef Builder, LLVMMetadataRef FPMathTag)
Set the default floating-point math metadata for the given builder.
Definition: Core.cpp:3251
LLVMValueRef LLVMBuildExtractValue(LLVMBuilderRef B, LLVMValueRef AggVal, unsigned Index, const char *Name)
Definition: Core.cpp:4184
LLVMValueRef LLVMBuildFCmp(LLVMBuilderRef B, LLVMRealPredicate Op, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:4116
void LLVMSetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst, LLVMAtomicOrdering Ordering)
Definition: Core.cpp:4304
LLVMValueRef LLVMBuildFPTrunc(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:4024
LLVMAtomicOrdering LLVMGetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst)
Definition: Core.cpp:4299
LLVMOpcode LLVMGetCastOpcode(LLVMValueRef Src, LLVMBool SrcIsSigned, LLVMTypeRef DestTy, LLVMBool DestIsSigned)
Definition: Core.cpp:4101
LLVMAtomicRMWBinOp LLVMGetAtomicRMWBinOp(LLVMValueRef Inst)
Definition: Core.cpp:3979
void LLVMSetNUW(LLVMValueRef ArithInst, LLVMBool HasNUW)
Definition: Core.cpp:3664
LLVMValueRef LLVMBuildSIToFP(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:4019
LLVMValueRef LLVMBuildShl(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3597
void LLVMSetCurrentDebugLocation2(LLVMBuilderRef Builder, LLVMMetadataRef Loc)
Set location information used by debugging information.
Definition: Core.cpp:3224
int LLVMGetUndefMaskElem(void)
Definition: Core.cpp:4254
LLVMBool LLVMGetWeak(LLVMValueRef CmpXchgInst)
Definition: Core.cpp:3944
LLVMValueRef LLVMBuildFRem(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3592
LLVMValueRef LLVMBuildAlloca(LLVMBuilderRef B, LLVMTypeRef Ty, const char *Name)
Definition: Core.cpp:3770
LLVMValueRef LLVMBuildSelect(LLVMBuilderRef B, LLVMValueRef If, LLVMValueRef Then, LLVMValueRef Else, const char *Name)
Definition: Core.cpp:4152
LLVMValueRef LLVMBuildCatchPad(LLVMBuilderRef B, LLVMValueRef ParentPad, LLVMValueRef *Args, unsigned NumArgs, const char *Name)
Definition: Core.cpp:3351
void LLVMSetIsDisjoint(LLVMValueRef Inst, LLVMBool IsDisjoint)
Sets the disjoint flag for the instruction.
Definition: Core.cpp:3720
LLVMValueRef LLVMBuildMul(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3537
void LLVMPositionBuilderBeforeDbgRecords(LLVMBuilderRef Builder, LLVMBasicBlockRef Block, LLVMValueRef Instr)
Set the builder position before Instr and any attached debug records, or if Instr is null set the pos...
Definition: Core.cpp:3174
LLVMValueRef LLVMBuildExactSDiv(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3572
LLVMValueRef LLVMBuildNUWSub(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3527
LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef B, LLVMTypeRef Ty, const char *Name)
Definition: Core.cpp:3727
LLVMValueRef LLVMBuildIsNull(LLVMBuilderRef B, LLVMValueRef Val, const char *Name)
Definition: Core.cpp:4201
LLVMValueRef LLVMBuildLandingPad(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef PersFn, unsigned NumClauses, const char *Name)
Definition: Core.cpp:3339
LLVMValueRef LLVMBuildAggregateRet(LLVMBuilderRef B, LLVMValueRef *RetVals, unsigned N)
Definition: Core.cpp:3273
LLVMValueRef LLVMBuildAShr(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3607
LLVMValueRef LLVMBuildInvoke2(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Fn, LLVMValueRef *Args, unsigned NumArgs, LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch, const char *Name)
Definition: Core.cpp:3316
LLVMValueRef LLVMBuildCallWithOperandBundles(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Fn, LLVMValueRef *Args, unsigned NumArgs, LLVMOperandBundleRef *Bundles, unsigned NumBundles, const char *Name)
Definition: Core.cpp:4138
LLVMValueRef LLVMBuildExactUDiv(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3562
void LLVMSetOrdering(LLVMValueRef MemAccessInst, LLVMAtomicOrdering Ordering)
Definition: Core.cpp:3966
void LLVMSetCleanup(LLVMValueRef LandingPad, LLVMBool Val)
Definition: Core.cpp:3425
LLVMValueRef LLVMGetArgOperand(LLVMValueRef Funclet, unsigned i)
Definition: Core.cpp:3454
LLVMValueRef LLVMBuildInsertValue(LLVMBuilderRef B, LLVMValueRef AggVal, LLVMValueRef EltVal, unsigned Index, const char *Name)
Definition: Core.cpp:4189
LLVMValueRef LLVMBuildAdd(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3497
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:3745
LLVMValueRef LLVMBuildBr(LLVMBuilderRef B, LLVMBasicBlockRef Dest)
Definition: Core.cpp:3278
LLVMValueRef LLVMBuildNSWMul(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3542
LLVMValueRef LLVMBuildBinOp(LLVMBuilderRef B, LLVMOpcode Op, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3627
LLVMValueRef LLVMBuildSRem(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3587
void LLVMDisposeBuilder(LLVMBuilderRef Builder)
Definition: Core.cpp:3214
int LLVMGetMaskValue(LLVMValueRef SVInst, unsigned Elt)
Get the mask value at position Elt in the mask of a ShuffleVector instruction.
Definition: Core.cpp:4248
LLVMValueRef LLVMBuildFSub(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3532
LLVMValueRef LLVMGetClause(LLVMValueRef LandingPad, unsigned Idx)
Definition: Core.cpp:3413
LLVMMetadataRef LLVMGetCurrentDebugLocation2(LLVMBuilderRef Builder)
Get location information used by debugging information.
Definition: Core.cpp:3220
LLVMValueRef LLVMBuildArrayAlloca(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Val, const char *Name)
Definition: Core.cpp:3775
LLVMValueRef LLVMBuildVAArg(LLVMBuilderRef B, LLVMValueRef List, LLVMTypeRef Ty, const char *Name)
Definition: Core.cpp:4159
LLVMBuilderRef LLVMCreateBuilderInContext(LLVMContextRef C)
Definition: Core.cpp:3153
LLVMValueRef LLVMBuildAtomicCmpXchg(LLVMBuilderRef B, LLVMValueRef Ptr, LLVMValueRef Cmp, LLVMValueRef New, LLVMAtomicOrdering SuccessOrdering, LLVMAtomicOrdering FailureOrdering, LLVMBool singleThread)
Definition: Core.cpp:4229
LLVMValueRef LLVMBuildICmp(LLVMBuilderRef B, LLVMIntPredicate Op, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:4109
LLVMValueRef LLVMBuildPointerCast(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:4078
LLVMValueRef LLVMGetParentCatchSwitch(LLVMValueRef CatchPad)
Get the parent catchswitch instruction of a catchpad instruction.
Definition: Core.cpp:3443
void LLVMSetAtomicSingleThread(LLVMValueRef AtomicInst, LLVMBool NewValue)
Definition: Core.cpp:4271
LLVMValueRef LLVMBuildCast(LLVMBuilderRef B, LLVMOpcode Op, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:4072
LLVMValueRef LLVMBuildTrunc(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:3989
LLVMValueRef LLVMBuildURem(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3582
void LLVMSetAtomicRMWBinOp(LLVMValueRef Inst, LLVMAtomicRMWBinOp BinOp)
Definition: Core.cpp:3983
LLVMValueRef LLVMBuildCall2(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Fn, LLVMValueRef *Args, unsigned NumArgs, const char *Name)
Definition: Core.cpp:4129
void LLVMAddClause(LLVMValueRef LandingPad, LLVMValueRef ClauseVal)
Definition: Core.cpp:3417
LLVMValueRef LLVMBuildOr(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3617
LLVMBool LLVMGetNUW(LLVMValueRef ArithInst)
Definition: Core.cpp:3659
LLVMValueRef LLVMBuildAddrSpaceCast(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:4049
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:3297
LLVMValueRef LLVMBuildFPToUI(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:4004
void LLVMSetCurrentDebugLocation(LLVMBuilderRef Builder, LLVMValueRef L)
Deprecated: Passing the NULL location will crash.
Definition: Core.cpp:3231
LLVMValueRef LLVMBuildFPToSI(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:4009
LLVMValueRef LLVMBuildIntCast2(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, LLVMBool IsSigned, const char *Name)
Definition: Core.cpp:4083
LLVMValueRef LLVMBuildNSWAdd(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3502
LLVMValueRef LLVMBuildFNeg(LLVMBuilderRef B, LLVMValueRef V, const char *Name)
Definition: Core.cpp:3651
LLVMMetadataRef LLVMBuilderGetDefaultFPMathTag(LLVMBuilderRef Builder)
Get the dafult floating-point math metadata for a given builder.
Definition: Core.cpp:3259
LLVMValueRef LLVMBuildUDiv(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3557
void LLVMSetParentCatchSwitch(LLVMValueRef CatchPad, LLVMValueRef CatchSwitch)
Set the parent catchswitch instruction of a catchpad instruction.
Definition: Core.cpp:3447
LLVMValueRef LLVMBuildCatchRet(LLVMBuilderRef B, LLVMValueRef CatchPad, LLVMBasicBlockRef BB)
Definition: Core.cpp:3384
LLVMValueRef LLVMBuildStructGEP2(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Pointer, unsigned Idx, const char *Name)
Definition: Core.cpp:3905
unsigned LLVMGetNumClauses(LLVMValueRef LandingPad)
Definition: Core.cpp:3409
LLVMBool LLVMGetNNeg(LLVMValueRef NonNegInst)
Gets if the instruction has the non-negative flag set.
Definition: Core.cpp:3689
LLVMValueRef LLVMBuildSDiv(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3567
LLVMValueRef LLVMBuildStore(LLVMBuilderRef B, LLVMValueRef Val, LLVMValueRef PointerVal)
Definition: Core.cpp:3789
LLVMValueRef LLVMBuildCatchSwitch(LLVMBuilderRef B, LLVMValueRef ParentPad, LLVMBasicBlockRef UnwindBB, unsigned NumHandlers, const char *Name)
Definition: Core.cpp:3373
LLVMValueRef LLVMBuildIntCast(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Deprecated: This cast is always signed.
Definition: Core.cpp:4090
LLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Val, const char *Name)
Definition: Core.cpp:3736
LLVMValueRef LLVMBuildZExtOrBitCast(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:4054
LLVMValueRef LLVMBuildInBoundsGEP2(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Pointer, LLVMValueRef *Indices, unsigned NumIndices, const char *Name)
Definition: Core.cpp:3897
void LLVMGetHandlers(LLVMValueRef CatchSwitch, LLVMBasicBlockRef *Handlers)
Obtain the basic blocks acting as handlers for a catchswitch instruction.
Definition: Core.cpp:3437
LLVMAtomicOrdering LLVMGetOrdering(LLVMValueRef MemAccessInst)
Definition: Core.cpp:3952
LLVMValueRef LLVMBuildUIToFP(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:4014
LLVMValueRef LLVMBuildIntToPtr(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:4039
LLVMValueRef LLVMBuildCondBr(LLVMBuilderRef B, LLVMValueRef If, LLVMBasicBlockRef Then, LLVMBasicBlockRef Else)
Definition: Core.cpp:3282
LLVMValueRef LLVMBuildIndirectBr(LLVMBuilderRef B, LLVMValueRef Addr, unsigned NumDests)
Definition: Core.cpp:3292
void LLVMAddDestination(LLVMValueRef IndirectBr, LLVMBasicBlockRef Dest)
Definition: Core.cpp:3405
LLVMValueRef LLVMBuildNSWNeg(LLVMBuilderRef B, LLVMValueRef V, const char *Name)
Definition: Core.cpp:3638
LLVMValueRef LLVMBuildXor(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3622
LLVMValueRef LLVMBuildGlobalString(LLVMBuilderRef B, const char *Str, const char *Name)
Definition: Core.cpp:3912
LLVMBool LLVMGetExact(LLVMValueRef DivOrShrInst)
Definition: Core.cpp:3679
LLVMValueRef LLVMBuildIsNotNull(LLVMBuilderRef B, LLVMValueRef Val, const char *Name)
Definition: Core.cpp:4206
void LLVMSetArgOperand(LLVMValueRef Funclet, unsigned i, LLVMValueRef value)
Definition: Core.cpp:3458
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:3752
LLVMValueRef LLVMBuildPtrDiff2(LLVMBuilderRef B, LLVMTypeRef ElemTy, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:4211
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:3243
void LLVMAddMetadataToInst(LLVMBuilderRef Builder, LLVMValueRef Inst)
Adds the metadata registered with the given builder to the given instruction.
Definition: Core.cpp:3247
LLVMValueRef LLVMBuildSub(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3517
LLVMValueRef LLVMBuildNUWAdd(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3507
LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef B)
Definition: Core.cpp:3396
LLVMValueRef LLVMBuildShuffleVector(LLVMBuilderRef B, LLVMValueRef V1, LLVMValueRef V2, LLVMValueRef Mask, const char *Name)
Definition: Core.cpp:4177
void LLVMSetVolatile(LLVMValueRef MemAccessInst, LLVMBool isVolatile)
Definition: Core.cpp:3933
LLVMValueRef LLVMBuildFree(LLVMBuilderRef B, LLVMValueRef PointerVal)
Definition: Core.cpp:3780
LLVMValueRef LLVMBuildGEP2(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Pointer, LLVMValueRef *Indices, unsigned NumIndices, const char *Name)
Definition: Core.cpp:3890
unsigned LLVMGetNumHandlers(LLVMValueRef CatchSwitch)
Definition: Core.cpp:3433
LLVMValueRef LLVMBuildFPCast(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:4096
LLVMBuilderRef LLVMCreateBuilder(void)
Definition: Core.cpp:3157
void LLVMSetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst, LLVMAtomicOrdering Ordering)
Definition: Core.cpp:4291
LLVMValueRef LLVMBuildPhi(LLVMBuilderRef B, LLVMTypeRef Ty, const char *Name)
Definition: Core.cpp:4125
LLVMBool LLVMCanValueUseFastMathFlags(LLVMValueRef V)
Check if a given value can potentially have fast math flags.
Definition: Core.cpp:3710
void LLVMAddCase(LLVMValueRef Switch, LLVMValueRef OnVal, LLVMBasicBlockRef Dest)
Definition: Core.cpp:3400
LLVMBool LLVMIsAtomicSingleThread(LLVMValueRef AtomicInst)
Definition: Core.cpp:4256
LLVMValueRef LLVMBuildResume(LLVMBuilderRef B, LLVMValueRef Exn)
Definition: Core.cpp:3369
LLVMValueRef LLVMBuildSwitch(LLVMBuilderRef B, LLVMValueRef V, LLVMBasicBlockRef Else, unsigned NumCases)
Definition: Core.cpp:3287
void LLVMInsertIntoBuilder(LLVMBuilderRef Builder, LLVMValueRef Instr)
Definition: Core.cpp:3205
LLVMValueRef LLVMBuildPtrToInt(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:4034
LLVMBool LLVMIsCleanup(LLVMValueRef LandingPad)
Definition: Core.cpp:3421
LLVMBool LLVMGetNSW(LLVMValueRef ArithInst)
Definition: Core.cpp:3669
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:3761
LLVMValueRef LLVMBuildLShr(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3602
unsigned LLVMGetNumMaskElements(LLVMValueRef SVInst)
Get the number of elements in the mask of a ShuffleVector instruction.
Definition: Core.cpp:4242
LLVMValueRef LLVMBuildRetVoid(LLVMBuilderRef B)
Definition: Core.cpp:3265
LLVMValueRef LLVMBuildRet(LLVMBuilderRef B, LLVMValueRef V)
Definition: Core.cpp:3269
void LLVMAddHandler(LLVMValueRef CatchSwitch, LLVMBasicBlockRef Dest)
Definition: Core.cpp:3429
void LLVMPositionBuilderBeforeInstrAndDbgRecords(LLVMBuilderRef Builder, LLVMValueRef Instr)
Set the builder position before Instr and any attached debug records.
Definition: Core.cpp:3186
LLVMValueRef LLVMBuildExtractElement(LLVMBuilderRef B, LLVMValueRef VecVal, LLVMValueRef Index, const char *Name)
Definition: Core.cpp:4164
void LLVMPositionBuilderBefore(LLVMBuilderRef Builder, LLVMValueRef Instr)
Set the builder position before Instr but after any attached debug records.
Definition: Core.cpp:3181
LLVMValueRef LLVMGetCurrentDebugLocation(LLVMBuilderRef Builder)
Deprecated: Returning the NULL location will crash.
Definition: Core.cpp:3237
LLVMAtomicOrdering LLVMGetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst)
Definition: Core.cpp:4286
void LLVMSetNNeg(LLVMValueRef NonNegInst, LLVMBool IsNonNeg)
Sets the non-negative flag for the instruction.
Definition: Core.cpp:3694
void LLVMSetExact(LLVMValueRef DivOrShrInst, LLVMBool IsExact)
Definition: Core.cpp:3684
LLVMBasicBlockRef LLVMGetInsertBlock(LLVMBuilderRef Builder)
Definition: Core.cpp:3197
LLVMValueRef LLVMBuildCleanupPad(LLVMBuilderRef B, LLVMValueRef ParentPad, LLVMValueRef *Args, unsigned NumArgs, const char *Name)
Definition: Core.cpp:3358
void LLVMInsertIntoBuilderWithName(LLVMBuilderRef Builder, LLVMValueRef Instr, const char *Name)
Definition: Core.cpp:3209
void LLVMSetFastMathFlags(LLVMValueRef FPMathInst, LLVMFastMathFlags FMF)
Sets the flags for which fast-math-style optimizations are allowed for this value.
Definition: Core.cpp:3705
LLVMFastMathFlags LLVMGetFastMathFlags(LLVMValueRef FPMathInst)
Get the flags for which fast-math-style optimizations are allowed for this value.
Definition: Core.cpp:3699
LLVMValueRef LLVMBuildNeg(LLVMBuilderRef B, LLVMValueRef V, const char *Name)
Definition: Core.cpp:3634
LLVMBool LLVMGetVolatile(LLVMValueRef MemAccessInst)
Definition: Core.cpp:3922
LLVMValueRef LLVMBuildNUWMul(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3547
void LLVMPositionBuilder(LLVMBuilderRef Builder, LLVMBasicBlockRef Block, LLVMValueRef Instr)
Set the builder position before Instr but after any attached debug records, or if Instr is null set t...
Definition: Core.cpp:3168
void LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder, LLVMBasicBlockRef Block)
Definition: Core.cpp:3192
LLVMValueRef LLVMBuildInsertElement(LLVMBuilderRef B, LLVMValueRef VecVal, LLVMValueRef EltVal, LLVMValueRef Index, const char *Name)
Definition: Core.cpp:4170
LLVMValueRef LLVMBuildCleanupRet(LLVMBuilderRef B, LLVMValueRef CatchPad, LLVMBasicBlockRef BB)
Definition: Core.cpp:3390
void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf)
Definition: Core.cpp:4380
size_t LLVMGetBufferSize(LLVMMemoryBufferRef MemBuf)
Definition: Core.cpp:4376
LLVMBool LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef *OutMemBuf, char **OutMessage)
Definition: Core.cpp:4340
LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRange(const char *InputData, size_t InputDataLength, const char *BufferName, LLVMBool RequiresNullTerminator)
Definition: Core.cpp:4351
LLVMBool LLVMCreateMemoryBufferWithContentsOfFile(const char *Path, LLVMMemoryBufferRef *OutMemBuf, char **OutMessage)
Definition: Core.cpp:4326
const char * LLVMGetBufferStart(LLVMMemoryBufferRef MemBuf)
Definition: Core.cpp:4372
LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRangeCopy(const char *InputData, size_t InputDataLength, const char *BufferName)
Definition: Core.cpp:4362
LLVMModuleProviderRef LLVMCreateModuleProviderForExistingModule(LLVMModuleRef M)
Changes the type of M so it can be passed to FunctionPassManagers and the JIT.
Definition: Core.cpp:4315
void LLVMDisposeModuleProvider(LLVMModuleProviderRef MP)
Destroys the module M.
Definition: Core.cpp:4319
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:2321
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:1368
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:2331
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:1463
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:1439
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:1386
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:2339
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:1509
unsigned LLVMGetDebugLocLine(LLVMValueRef Val)
Return the line number of the debug location for this value, which must be an llvm::Instruction,...
Definition: Core.cpp:1487
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:1412
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:1360
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:1352
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:2327
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:1376
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:1381
LLVMValueRef LLVMGetPreviousFunction(LLVMValueRef Fn)
Decrement a Function iterator to the previous Function.
Definition: Core.cpp:2355
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:1419
LLVMValueRef LLVMGetNextFunction(LLVMValueRef Fn)
Advance a Function iterator to the next Function.
Definition: Core.cpp:2347
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:1429
LLVMNamedMDNodeRef LLVMGetFirstNamedMetadata(LLVMModuleRef M)
Obtain an iterator to the first NamedMDNode in a Module.
Definition: Core.cpp:1344
LLVMValueRef LLVMGetOperandBundleArgAtIndex(LLVMOperandBundleRef Bundle, unsigned Index)
Obtain the operand for an operand bundle at the given index.
Definition: Core.cpp:2693
unsigned LLVMGetNumOperandBundleArgs(LLVMOperandBundleRef Bundle)
Obtain the number of operands for an operand bundle.
Definition: Core.cpp:2689
LLVMOperandBundleRef LLVMCreateOperandBundle(const char *Tag, size_t TagLen, LLVMValueRef *Args, unsigned NumArgs)
Create a new operand bundle.
Definition: Core.cpp:2672
void LLVMDisposeOperandBundle(LLVMOperandBundleRef Bundle)
Destroy an operand bundle.
Definition: Core.cpp:2679
const char * LLVMGetOperandBundleTag(LLVMOperandBundleRef Bundle, size_t *Len)
Obtain the tag of an operand bundle as a string.
Definition: Core.cpp:2683
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:4399
LLVMPassManagerRef LLVMCreateFunctionPassManager(LLVMModuleProviderRef P)
Deprecated: Use LLVMCreateFunctionPassManagerForModule instead.
Definition: Core.cpp:4394
LLVMPassManagerRef LLVMCreatePassManager()
Constructs a new whole-module pass pipeline.
Definition: Core.cpp:4386
void LLVMDisposePassManager(LLVMPassManagerRef PM)
Frees the memory of a pass pipeline.
Definition: Core.cpp:4415
LLVMBool LLVMFinalizeFunctionPassManager(LLVMPassManagerRef FPM)
Finalizes all of the function passes scheduled in the function pass manager.
Definition: Core.cpp:4411
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:4407
LLVMBool LLVMInitializeFunctionPassManager(LLVMPassManagerRef FPM)
Initializes all of the function passes scheduled in the function pass manager.
Definition: Core.cpp:4403
LLVMPassManagerRef LLVMCreateFunctionPassManagerForModule(LLVMModuleRef M)
Constructs a new function-by-function pass pipeline over the module provider.
Definition: Core.cpp:4390
LLVMBool LLVMIsMultithreaded()
Check whether LLVM is executing in thread-safe mode or not.
Definition: Core.cpp:4428
LLVMBool LLVMStartMultithreaded()
Deprecated: Multi-threading can only be enabled/disabled with the compile time define LLVM_ENABLE_THR...
Definition: Core.cpp:4421
void LLVMStopMultithreaded()
Deprecated: Multi-threading can only be enabled/disabled with the compile time define LLVM_ENABLE_THR...
Definition: Core.cpp:4425
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
const char * LLVMGetTargetExtTypeName(LLVMTypeRef TargetExtTy)
Obtain the name for this target extension type.
Definition: Core.cpp:957
LLVMTypeRef LLVMGetTargetExtTypeTypeParam(LLVMTypeRef TargetExtTy, unsigned Idx)
Get the type parameter at the given index for the target extension type.
Definition: Core.cpp:967
unsigned LLVMGetTargetExtTypeNumTypeParams(LLVMTypeRef TargetExtTy)
Obtain the number of type parameters for this target extension type.
Definition: Core.cpp:962
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
unsigned LLVMGetTargetExtTypeNumIntParams(LLVMTypeRef TargetExtTy)
Obtain the number of int parameters for this target extension type.
Definition: Core.cpp:973
unsigned LLVMGetTargetExtTypeIntParam(LLVMTypeRef TargetExtTy, unsigned Idx)
Get the int parameter at the given index for the target extension type.
Definition: Core.cpp:978
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:483
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:474
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:2754
void LLVMAppendExistingBasicBlock(LLVMValueRef Fn, LLVMBasicBlockRef BB)
Append the given basic block to the basic block list of the given function.
Definition: Core.cpp:2783
void LLVMDeleteBasicBlock(LLVMBasicBlockRef BBRef)
Remove a basic block from a function and delete it.
Definition: Core.cpp:2810
LLVMBasicBlockRef LLVMGetFirstBasicBlock(LLVMValueRef Fn)
Obtain the first basic block in a function.
Definition: Core.cpp:2738
LLVMBasicBlockRef LLVMValueAsBasicBlock(LLVMValueRef Val)
Convert an LLVMValueRef to an LLVMBasicBlockRef instance.
Definition: Core.cpp:2708
LLVMBasicBlockRef LLVMCreateBasicBlockInContext(LLVMContextRef C, const char *Name)
Create a new basic block without inserting it into a function.
Definition: Core.cpp:2770
void LLVMRemoveBasicBlockFromParent(LLVMBasicBlockRef BBRef)
Remove a basic block from a function.
Definition: Core.cpp:2814
void LLVMMoveBasicBlockBefore(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos)
Move a basic block to before another one.
Definition: Core.cpp:2818
LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef BB)
Convert a basic block instance to a value type.
Definition: Core.cpp:2700
void LLVMInsertExistingBasicBlockAfterInsertBlock(LLVMBuilderRef Builder, LLVMBasicBlockRef BB)
Insert the given basic block after the insertion point of the given builder.
Definition: Core.cpp:2775
void LLVMGetBasicBlocks(LLVMValueRef FnRef, LLVMBasicBlockRef *BasicBlocksRefs)
Obtain all of the basic blocks in a function.
Definition: Core.cpp:2728
LLVMBasicBlockRef LLVMAppendBasicBlock(LLVMValueRef FnRef, const char *Name)
Append a basic block to the end of a function using the global context.
Definition: Core.cpp:2794
LLVMValueRef LLVMGetBasicBlockTerminator(LLVMBasicBlockRef BB)
Obtain the terminator instruction for a basic block.
Definition: Core.cpp:2720
unsigned LLVMCountBasicBlocks(LLVMValueRef FnRef)
Obtain the number of basic blocks in a function.
Definition: Core.cpp:2724
void LLVMMoveBasicBlockAfter(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos)
Move a basic block to after another one.
Definition: Core.cpp:2822
LLVMBasicBlockRef LLVMGetLastBasicBlock(LLVMValueRef Fn)
Obtain the last basic block in a function.
Definition: Core.cpp:2746
LLVMBasicBlockRef LLVMAppendBasicBlockInContext(LLVMContextRef C, LLVMValueRef FnRef, const char *Name)
Append a basic block to the end of a function.
Definition: Core.cpp:2788
LLVMValueRef LLVMGetBasicBlockParent(LLVMBasicBlockRef BB)
Obtain the function to which a basic block belongs.
Definition: Core.cpp:2716
LLVMValueRef LLVMGetFirstInstruction(LLVMBasicBlockRef BB)
Obtain the first instruction in a basic block.
Definition: Core.cpp:2832
LLVMValueRef LLVMGetLastInstruction(LLVMBasicBlockRef BB)
Obtain the last instruction in a basic block.
Definition: Core.cpp:2840
LLVMBasicBlockRef LLVMInsertBasicBlockInContext(LLVMContextRef C, LLVMBasicBlockRef BBRef, const char *Name)
Insert a basic block in a function before another basic block.
Definition: Core.cpp:2798
LLVMBasicBlockRef LLVMInsertBasicBlock(LLVMBasicBlockRef BBRef, const char *Name)
Insert a basic block in a function using the global context.
Definition: Core.cpp:2805
LLVMBasicBlockRef LLVMGetEntryBasicBlock(LLVMValueRef Fn)
Obtain the basic block that corresponds to the entry point of a function.
Definition: Core.cpp:2734
LLVMBool LLVMValueIsBasicBlock(LLVMValueRef Val)
Determine whether an LLVMValueRef is itself a basic block.
Definition: Core.cpp:2704
const char * LLVMGetBasicBlockName(LLVMBasicBlockRef BB)
Obtain the string name of a basic block.
Definition: Core.cpp:2712
LLVMBasicBlockRef LLVMGetPreviousBasicBlock(LLVMBasicBlockRef BB)
Go backwards in a basic block iterator.
Definition: Core.cpp:2762
LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count, LLVMBool Packed)
Create a ConstantStruct in the global Context.
Definition: Core.cpp:1646
LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy, LLVMValueRef *ConstantVals, unsigned Length)
Create a ConstantArray from values.
Definition: Core.cpp:1626
LLVMValueRef LLVMConstArray2(LLVMTypeRef ElementTy, LLVMValueRef *ConstantVals, uint64_t Length)
Create a ConstantArray from values.
Definition: Core.cpp:1632
LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size)
Create a ConstantVector from values.
Definition: Core.cpp:1661
LLVMValueRef LLVMConstStringInContext(LLVMContextRef C, const char *Str, unsigned Length, LLVMBool DontNullTerminate)
Create a ConstantDataSequential and initialize it with a string.
Definition: Core.cpp:1584
LLVMValueRef LLVMConstNamedStruct(LLVMTypeRef StructTy, LLVMValueRef *ConstantVals, unsigned Count)
Create a non-anonymous ConstantStruct from values.
Definition: Core.cpp:1652
LLVMBool LLVMIsConstantString(LLVMValueRef C)
Returns true if the specified constant is an array of i8.
Definition: Core.cpp:1616
LLVMValueRef LLVMGetAggregateElement(LLVMValueRef C, unsigned Idx)
Get element of a constant aggregate (struct, array or vector) at the specified index.
Definition: Core.cpp:1608
LLVMValueRef LLVMConstString(const char *Str, unsigned Length, LLVMBool DontNullTerminate)
Create a ConstantDataSequential with string content in the global context.
Definition: Core.cpp:1602
const char * LLVMGetAsString(LLVMValueRef C, size_t *Length)
Get the given constant data sequential as a string.
Definition: Core.cpp:1620
LLVMValueRef LLVMConstStringInContext2(LLVMContextRef C, const char *Str, size_t Length, LLVMBool DontNullTerminate)
Create a ConstantDataSequential and initialize it with a string.
Definition: Core.cpp:1593
LLVMValueRef LLVMConstStructInContext(LLVMContextRef C, LLVMValueRef *ConstantVals, unsigned Count, LLVMBool Packed)
Create an anonymous ConstantStruct with the specified values.
Definition: Core.cpp:1638
LLVMValueRef LLVMConstPointerCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition: Core.cpp:1824
LLVMValueRef LLVMConstMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1753
LLVMValueRef LLVMConstTruncOrBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition: Core.cpp:1818
LLVMValueRef LLVMSizeOf(LLVMTypeRef Ty)
Definition: Core.cpp:1698
LLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition: Core.cpp:1797
LLVMValueRef LLVMConstNUWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1747
LLVMValueRef LLVMConstNUWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1730
LLVMValueRef LLVMConstIntToPtr(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition: Core.cpp:1802
LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition: Core.cpp:1792
LLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal)
Definition: Core.cpp:1715
LLVMValueRef LLVMGetBlockAddressFunction(LLVMValueRef BlockAddr)
Gets the function associated with a given BlockAddress constant value.
Definition: Core.cpp:1866
LLVMValueRef LLVMConstNSWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1758
LLVMValueRef LLVMConstExtractElement(LLVMValueRef VectorConstant, LLVMValueRef IndexConstant)
Definition: Core.cpp:1830
LLVMValueRef LLVMConstInsertElement(LLVMValueRef VectorConstant, LLVMValueRef ElementValueConstant, LLVMValueRef IndexConstant)
Definition: Core.cpp:1836
LLVMValueRef LLVMConstInBoundsGEP2(LLVMTypeRef Ty, LLVMValueRef ConstantVal, LLVMValueRef *ConstantIndices, unsigned NumIndices)
Definition: Core.cpp:1783
LLVMValueRef LLVMConstAddrSpaceCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition: Core.cpp:1812
LLVMBasicBlockRef LLVMGetBlockAddressBasicBlock(LLVMValueRef BlockAddr)
Gets the basic block associated with a given BlockAddress constant value.
Definition: Core.cpp:1870
LLVMValueRef LLVMConstNSWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1724
LLVMValueRef LLVMAlignOf(LLVMTypeRef Ty)
Definition: Core.cpp:1694
LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty, const char *AsmString, const char *Constraints, LLVMBool HasSideEffects, LLVMBool IsAlignStack)
Deprecated: Use LLVMGetInlineAsm instead.
Definition: Core.cpp:1854
LLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1770
LLVMValueRef LLVMConstBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition: Core.cpp:1807
LLVMValueRef LLVMConstNSWNeg(LLVMValueRef ConstantVal)
Definition: Core.cpp:1706
LLVMValueRef LLVMConstNUWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1764
LLVMValueRef LLVMConstGEP2(LLVMTypeRef Ty, LLVMValueRef ConstantVal, LLVMValueRef *ConstantIndices, unsigned NumIndices)
Definition: Core.cpp:1775
LLVMValueRef LLVMConstSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1736
LLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1719
LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant, LLVMValueRef VectorBConstant, LLVMValueRef MaskConstant)
Definition: Core.cpp:1844
LLVMValueRef LLVMConstNeg(LLVMValueRef ConstantVal)
Definition: Core.cpp:1702
LLVMValueRef LLVMBlockAddress(LLVMValueRef F, LLVMBasicBlockRef BB)
Definition: Core.cpp:1862
LLVMOpcode LLVMGetConstOpcode(LLVMValueRef ConstantVal)
Definition: Core.cpp:1690
LLVMValueRef LLVMConstNSWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1741
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:2120
unsigned LLVMValueMetadataEntriesGetKind(LLVMValueMetadataEntry *Entries, unsigned Index)
Returns the kind of a value metadata entry at a specific index.
Definition: Core.cpp:2101
void LLVMDisposeValueMetadataEntries(LLVMValueMetadataEntry *Entries)
Destroys value metadata entries.
Definition: Core.cpp:2116
void LLVMSetVisibility(LLVMValueRef Global, LLVMVisibility Viz)
Definition: Core.cpp:1993
LLVMDLLStorageClass LLVMGetDLLStorageClass(LLVMValueRef Global)
Definition: Core.cpp:1998
void LLVMSetAlignment(LLVMValueRef V, unsigned Bytes)
Set the preferred alignment of the value.
Definition: Core.cpp:2069
LLVMModuleRef LLVMGetGlobalParent(LLVMValueRef Global)
Definition: Core.cpp:1876
const char * LLVMGetSection(LLVMValueRef Global)
Definition: Core.cpp:1978
LLVMTypeRef LLVMGlobalGetValueType(LLVMValueRef Global)
Returns the "value type" of a global value.
Definition: Core.cpp:2043
LLVMBool LLVMIsDeclaration(LLVMValueRef Global)
Definition: Core.cpp:1880
LLVMVisibility LLVMGetVisibility(LLVMValueRef Global)
Definition: Core.cpp:1988
void LLVMSetDLLStorageClass(LLVMValueRef Global, LLVMDLLStorageClass Class)
Definition: Core.cpp:2003
LLVMBool LLVMHasUnnamedAddr(LLVMValueRef Global)
Deprecated: Use LLVMGetUnnamedAddress instead.
Definition: Core.cpp:2033
LLVMLinkage LLVMGetLinkage(LLVMValueRef Global)
Definition: Core.cpp:1884
LLVMUnnamedAddr LLVMGetUnnamedAddress(LLVMValueRef Global)
Definition: Core.cpp:2008
LLVMMetadataRef LLVMValueMetadataEntriesGetMetadata(LLVMValueMetadataEntry *Entries, unsigned Index)
Returns the underlying metadata node of a value metadata entry at a specific index.
Definition: Core.cpp:2109
void LLVMSetUnnamedAddress(LLVMValueRef Global, LLVMUnnamedAddr UnnamedAddr)
Definition: Core.cpp:2020
void LLVMSetLinkage(LLVMValueRef Global, LLVMLinkage Linkage)
Definition: Core.cpp:1913
void LLVMSetUnnamedAddr(LLVMValueRef Global, LLVMBool HasUnnamedAddr)
Deprecated: Use LLVMSetUnnamedAddress instead.
Definition: Core.cpp:2037
void LLVMGlobalClearMetadata(LLVMValueRef Global)
Removes all metadata attachments from this value.
Definition: Core.cpp:2129
unsigned LLVMGetAlignment(LLVMValueRef V)
Obtain the preferred alignment of the value.
Definition: Core.cpp:2049
void LLVMSetSection(LLVMValueRef Global, const char *Section)
Definition: Core.cpp:1984
void LLVMGlobalEraseMetadata(LLVMValueRef Global, unsigned Kind)
Erases a metadata attachment of the given kind if it exists.
Definition: Core.cpp:2125
LLVMValueMetadataEntry * LLVMGlobalCopyAllMetadata(LLVMValueRef Value, size_t *NumEntries)
Retrieves an array of metadata entries representing the metadata attached to this value.
Definition: Core.cpp:2089
LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N, LLVMBool SignExtend)
Obtain a constant value for an integer type.
Definition: Core.cpp:1519
LLVMValueRef LLVMConstIntOfArbitraryPrecision(LLVMTypeRef IntTy, unsigned NumWords, const uint64_t Words[])
Obtain a constant value for an integer of arbitrary precision.
Definition: Core.cpp:1524
LLVMValueRef LLVMConstRealOfString(LLVMTypeRef RealTy, const char *Text)
Obtain a constant for a floating point value parsed from a string.
Definition: Core.cpp:1548
double LLVMConstRealGetDouble(LLVMValueRef ConstantVal, LLVMBool *LosesInfo)
Obtain the double value for an floating point constant value.
Definition: Core.cpp:1565
long long LLVMConstIntGetSExtValue(LLVMValueRef ConstantVal)
Obtain the sign extended value for an integer constant value.
Definition: Core.cpp:1561
unsigned long long LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal)
Obtain the zero extended value for an integer constant value.
Definition: Core.cpp:1557
LLVMValueRef LLVMConstReal(LLVMTypeRef RealTy, double N)
Obtain a constant value referring to a double floating point value.
Definition: Core.cpp:1544
LLVMBool LLVMIsNull(LLVMValueRef Val)
Determine whether a value instance is null.
Definition: Core.cpp:1242
LLVMValueRef LLVMGetUndef(LLVMTypeRef Ty)
Obtain a constant value referring to an undefined value of a type.
Definition: Core.cpp:1230
LLVMValueRef LLVMGetPoison(LLVMTypeRef Ty)
Obtain a constant value referring to a poison value of a type.
Definition: Core.cpp:1234
LLVMValueRef LLVMConstAllOnes(LLVMTypeRef Ty)
Obtain a constant value referring to the instance of a type consisting of all ones.
Definition: Core.cpp:1226
LLVMValueRef LLVMConstPointerNull(LLVMTypeRef Ty)
Obtain a constant that is a constant pointer pointing to NULL for a specified type.
Definition: Core.cpp:1256
LLVMValueRef LLVMConstNull(LLVMTypeRef Ty)
Obtain a constant value referring to the null instance of a type.
Definition: Core.cpp:1222
unsigned LLVMCountParams(LLVMValueRef FnRef)
Obtain the number of parameters in a function.
Definition: Core.cpp:2548
LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg)
Obtain the previous parameter to a function.
Definition: Core.cpp:2593
LLVMValueRef LLVMGetNextParam(LLVMValueRef Arg)
Obtain the next parameter to a function.
Definition: Core.cpp:2585
LLVMValueRef LLVMGetParamParent(LLVMValueRef V)
Obtain the function to which this argument belongs.
Definition: Core.cpp:2565
LLVMValueRef LLVMGetFirstParam(LLVMValueRef Fn)
Obtain the first parameter to a function.
Definition: Core.cpp:2569
void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align)
Set the alignment for a function parameter.
Definition: Core.cpp:2600
LLVMValueRef LLVMGetParam(LLVMValueRef FnRef, unsigned index)
Obtain the parameter at the specified index.
Definition: Core.cpp:2560
LLVMValueRef LLVMGetLastParam(LLVMValueRef Fn)
Obtain the last parameter to a function.
Definition: Core.cpp:2577
void LLVMGetParams(LLVMValueRef FnRef, LLVMValueRef *ParamRefs)
Obtain the parameters in a function.
Definition: Core.cpp:2554
void LLVMSetGC(LLVMValueRef Fn, const char *GC)
Define the garbage collector to use during code generation.
Definition: Core.cpp:2458
const char * LLVMGetGC(LLVMValueRef Fn)
Obtain the name of the garbage collector to use during code generation.
Definition: Core.cpp:2453
LLVMValueRef LLVMGetPrologueData(LLVMValueRef Fn)
Gets the prologue data associated with a function.
Definition: Core.cpp:2482
void LLVMRemoveEnumAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx, unsigned KindID)
Definition: Core.cpp:2529
unsigned LLVMGetAttributeCountAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx)
Definition: Core.cpp:2503
LLVMBool LLVMHasPersonalityFn(LLVMValueRef Fn)
Check whether the given function has a personality function.
Definition: Core.cpp:2367
unsigned LLVMLookupIntrinsicID(const char *Name, size_t NameLen)
Obtain the intrinsic ID number which matches the given function name.
Definition: Core.cpp:2435
const char * LLVMIntrinsicGetName(unsigned ID, size_t *NameLength)
Retrieves the name of an intrinsic.
Definition: Core.cpp:2399
unsigned LLVMGetFunctionCallConv(LLVMValueRef Fn)
Obtain the calling function of a function.
Definition: Core.cpp:2444
LLVMValueRef LLVMGetPrefixData(LLVMValueRef Fn)
Gets the prefix data associated with a function.
Definition: Core.cpp:2466
void LLVMRemoveStringAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx, const char *K, unsigned KLen)
Definition: Core.cpp:2534
void LLVMSetPrefixData(LLVMValueRef Fn, LLVMValueRef prefixData)
Sets the prefix data for the function.
Definition: Core.cpp:2476
LLVMAttributeRef LLVMGetStringAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx, const char *K, unsigned KLen)
Definition: Core.cpp:2522
LLVMValueRef LLVMGetPersonalityFn(LLVMValueRef Fn)
Obtain the personality function attached to the function.
Definition: Core.cpp:2371
void LLVMSetPersonalityFn(LLVMValueRef Fn, LLVMValueRef PersonalityFn)
Set the personality function attached to the function.
Definition: Core.cpp:2375
LLVMBool LLVMIntrinsicIsOverloaded(unsigned ID)
Obtain if the intrinsic identified by the given ID is overloaded.
Definition: Core.cpp:2439
void LLVMAddAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx, LLVMAttributeRef A)
Add an attribute to a function.
Definition: Core.cpp:2498
void LLVMDeleteFunction(LLVMValueRef Fn)
Remove a function from its containing module and deletes it.
Definition: Core.cpp:2363
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:2424
void LLVMSetPrologueData(LLVMValueRef Fn, LLVMValueRef prologueData)
Sets the prologue data for the function.
Definition: Core.cpp:2492
const char * LLVMIntrinsicCopyOverloadedName(unsigned ID, LLVMTypeRef *ParamTypes, size_t ParamCount, size_t *NameLength)
Deprecated: Use LLVMIntrinsicCopyOverloadedName2 instead.
Definition: Core.cpp:2413
LLVMBool LLVMHasPrologueData(LLVMValueRef Fn)
Check if a given function has prologue data.
Definition: Core.cpp:2487
LLVMBool LLVMHasPrefixData(LLVMValueRef Fn)
Check if a given function has prefix data.
Definition: Core.cpp:2471
void LLVMGetAttributesAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx, LLVMAttributeRef *Attrs)
Definition: Core.cpp:2508
void LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC)
Set the calling convention of a function.
Definition: Core.cpp:2448
LLVMValueRef LLVMGetIntrinsicDeclaration(LLVMModuleRef Mod, unsigned ID, LLVMTypeRef *ParamTypes, size_t ParamCount)
Create or insert the declaration of an intrinsic.
Definition: Core.cpp:2390
LLVMAttributeRef LLVMGetEnumAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx, unsigned KindID)
Definition: Core.cpp:2515
void LLVMAddTargetDependentFunctionAttr(LLVMValueRef Fn, const char *A, const char *V)
Add a target-dependent attribute to a function.
Definition: Core.cpp:2539
LLVMTypeRef LLVMIntrinsicGetType(LLVMContextRef Ctx, unsigned ID, LLVMTypeRef *ParamTypes, size_t ParamCount)
Retrieves the type of an intrinsic.
Definition: Core.cpp:2406
unsigned LLVMGetIntrinsicID(LLVMValueRef Fn)
Obtain the ID number from a function instance.
Definition: Core.cpp:2379
LLVMValueKind LLVMGetValueKind(LLVMValueRef Val)
Obtain the enumerated type of a Value instance.
Definition: Core.cpp:991
const char * LLVMGetValueName(LLVMValueRef Val)
Deprecated: Use LLVMGetValueName2 instead.
Definition: Core.cpp:1013
LLVMTypeRef LLVMTypeOf(LLVMValueRef Val)
Obtain the type of a value.
Definition: Core.cpp:987
LLVMBool LLVMIsConstant(LLVMValueRef Ty)
Determine whether the specified value instance is constant.
Definition: Core.cpp:1238
void LLVMReplaceAllUsesWith(LLVMValueRef OldVal, LLVMValueRef NewVal)
Replace all uses of a value with another one.
Definition: Core.cpp:1053
const char * LLVMGetValueName2(LLVMValueRef Val, size_t *Length)
Obtain the string name of a value.
Definition: Core.cpp:1003
char * LLVMPrintDbgRecordToString(LLVMDbgRecordRef Record)
Return a string representation of the DbgRecord.
Definition: Core.cpp:1039
void LLVMSetValueName(LLVMValueRef Val, const char *Name)
Deprecated: Use LLVMSetValueName2 instead.
Definition: Core.cpp:1017
void LLVMDumpValue(LLVMValueRef Val)
Dump a representation of a value to stderr.
Definition: Core.cpp:1021
LLVMBool LLVMIsUndef(LLVMValueRef Val)
Determine whether a value instance is undefined.
Definition: Core.cpp:1248
LLVMValueRef LLVMIsAMDNode(LLVMValueRef Val)
Definition: Core.cpp:1131
LLVMBool LLVMIsPoison(LLVMValueRef Val)
Determine whether a value instance is poisonous.
Definition: Core.cpp:1252
LLVMValueRef LLVMIsAMDString(LLVMValueRef Val)
Definition: Core.cpp:1146
void LLVMSetValueName2(LLVMValueRef Val, const char *Name, size_t NameLen)
Set the string name of a value.
Definition: Core.cpp:1009
LLVMValueRef LLVMIsAValueAsMetadata(LLVMValueRef Val)
Definition: Core.cpp:1139
char * LLVMPrintValueToString(LLVMValueRef Val)
Return a string representation of the value.
Definition: Core.cpp:1025
void LLVMEraseGlobalIFunc(LLVMValueRef IFunc)
Remove a global indirect function from its parent module and delete it.
Definition: Core.cpp:2662
void LLVMRemoveGlobalIFunc(LLVMValueRef IFunc)
Remove a global indirect function from its parent module.
Definition: Core.cpp:2666
LLVMValueRef LLVMGetNextGlobalIFunc(LLVMValueRef IFunc)
Advance a GlobalIFunc iterator to the next GlobalIFunc.
Definition: Core.cpp:2638
LLVMValueRef LLVMGetNamedGlobalIFunc(LLVMModuleRef M, const char *Name, size_t NameLen)
Obtain a GlobalIFunc value from a Module by its name.
Definition: Core.cpp:2617
LLVMValueRef LLVMGetLastGlobalIFunc(LLVMModuleRef M)
Obtain an iterator to the last GlobalIFunc in a Module.
Definition: Core.cpp:2630
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:2607
void LLVMSetGlobalIFuncResolver(LLVMValueRef IFunc, LLVMValueRef Resolver)
Sets the resolver function associated with this indirect function.
Definition: Core.cpp:2658
LLVMValueRef LLVMGetFirstGlobalIFunc(LLVMModuleRef M)
Obtain an iterator to the first GlobalIFunc in a Module.
Definition: Core.cpp:2622
LLVMValueRef LLVMGetGlobalIFuncResolver(LLVMValueRef IFunc)
Retrieves the resolver function associated with this indirect function, or NULL if it doesn't not exi...
Definition: Core.cpp:2654
LLVMValueRef LLVMGetPreviousGlobalIFunc(LLVMValueRef IFunc)
Decrement a GlobalIFunc iterator to the previous GlobalIFunc.
Definition: Core.cpp:2646
LLVMTypeRef LLVMGetAllocatedType(LLVMValueRef Alloca)
Obtain the type that is being allocated by the alloca instruction.
Definition: Core.cpp:3087
LLVMOperandBundleRef LLVMGetOperandBundleAtIndex(LLVMValueRef C, unsigned Index)
Obtain the operand bundle attached to this instruction at the given index.
Definition: Core.cpp:2987
LLVMValueRef LLVMGetCalledValue(LLVMValueRef Instr)
Obtain the pointer to the function invoked by this instruction.
Definition: Core.cpp:2975
void LLVMGetCallSiteAttributes(LLVMValueRef C, LLVMAttributeIndex Idx, LLVMAttributeRef *Attrs)
Definition: Core.cpp:2943
unsigned LLVMGetNumArgOperands(LLVMValueRef Instr)
Obtain the argument count for a call instruction.
Definition: Core.cpp:2905
void LLVMSetNormalDest(LLVMValueRef Invoke, LLVMBasicBlockRef B)
Set the normal destination basic block.
Definition: Core.cpp:3026
unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr)
Obtain the calling convention for a call instruction.
Definition: Core.cpp:2914
LLVMTypeRef LLVMGetCalledFunctionType(LLVMValueRef Instr)
Obtain the function type called by this instruction.
Definition: Core.cpp:2979
unsigned LLVMGetCallSiteAttributeCount(LLVMValueRef C, LLVMAttributeIndex Idx)
Definition: Core.cpp:2936
void LLVMAddCallSiteAttribute(LLVMValueRef C, LLVMAttributeIndex Idx, LLVMAttributeRef A)
Definition: Core.cpp:2931
unsigned LLVMGetNumOperandBundles(LLVMValueRef C)
Obtain the number of operand bundles attached to this instruction.
Definition: Core.cpp:2983
LLVMBasicBlockRef LLVMGetCallBrIndirectDest(LLVMValueRef CallBr, unsigned Idx)
Get the indirect destination of a CallBr instruction at the given index.
Definition: Core.cpp:3047
void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC)
Set the calling convention for a call instruction.
Definition: Core.cpp:2918
LLVMAttributeRef LLVMGetCallSiteEnumAttribute(LLVMValueRef C, LLVMAttributeIndex Idx, unsigned KindID)
Definition: Core.cpp:2951
LLVMBasicBlockRef LLVMGetNormalDest(LLVMValueRef Invoke)
Return the normal destination basic block.
Definition: Core.cpp:3013
void LLVMRemoveCallSiteEnumAttribute(LLVMValueRef C, LLVMAttributeIndex Idx, unsigned KindID)
Definition: Core.cpp:2965
unsigned LLVMGetCallBrNumIndirectDests(LLVMValueRef CallBr)
Get the number of indirect destinations of a CallBr instruction.
Definition: Core.cpp:3043
void LLVMSetUnwindDest(LLVMValueRef Invoke, LLVMBasicBlockRef B)
Set the unwind destination basic block.
Definition: Core.cpp:3030
void LLVMSetTailCall(LLVMValueRef Call, LLVMBool isTailCall)
Set whether a call instruction is a tail call.
Definition: Core.cpp:2999
LLVMBool LLVMIsTailCall(LLVMValueRef Call)
Obtain whether a call instruction is a tail call.
Definition: Core.cpp:2995
void LLVMSetInstrParamAlignment(LLVMValueRef Instr, LLVMAttributeIndex Idx, unsigned align)
Definition: Core.cpp:2923
LLVMBasicBlockRef LLVMGetCallBrDefaultDest(LLVMValueRef CallBr)
Get the default destination of a CallBr instruction.
Definition: Core.cpp:3039
void LLVMRemoveCallSiteStringAttribute(LLVMValueRef C, LLVMAttributeIndex Idx, const char *K, unsigned KLen)
Definition: Core.cpp:2970
LLVMTailCallKind LLVMGetTailCallKind(LLVMValueRef Call)
Obtain a tail call kind of the call instruction.
Definition: Core.cpp:3003
void LLVMSetTailCallKind(LLVMValueRef Call, LLVMTailCallKind kind)
Set the call kind of the call instruction.
Definition: Core.cpp:3007
LLVMAttributeRef LLVMGetCallSiteStringAttribute(LLVMValueRef C, LLVMAttributeIndex Idx, const char *K, unsigned KLen)
Definition: Core.cpp:2958
LLVMBasicBlockRef LLVMGetUnwindDest(LLVMValueRef Invoke)
Return the unwind destination basic block.
Definition: Core.cpp:3017
LLVMTypeRef LLVMGetGEPSourceElementType(LLVMValueRef GEP)
Get the source element type of the given GEP operator.
Definition: Core.cpp:3101
LLVMBool LLVMIsInBounds(LLVMValueRef GEP)
Check whether the given GEP operator is inbounds.
Definition: Core.cpp:3093
void LLVMSetIsInBounds(LLVMValueRef GEP, LLVMBool InBounds)
Set the given GEP instruction to be inbounds or not.
Definition: Core.cpp:3097
const unsigned * LLVMGetIndices(LLVMValueRef Inst)
Obtain the indices as an array.
Definition: Core.cpp:3140
unsigned LLVMGetNumIndices(LLVMValueRef Inst)
Obtain the number of indices.
Definition: Core.cpp:3128
void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues, LLVMBasicBlockRef *IncomingBlocks, unsigned Count)
Add an incoming value to the end of a PHI list.
Definition: Core.cpp:3107
LLVMValueRef LLVMGetIncomingValue(LLVMValueRef PhiNode, unsigned Index)
Obtain an incoming value to a PHI node as an LLVMValueRef.
Definition: Core.cpp:3118
unsigned LLVMCountIncoming(LLVMValueRef PhiNode)
Obtain the number of incoming basic blocks to a PHI node.
Definition: Core.cpp:3114
LLVMBasicBlockRef LLVMGetIncomingBlock(LLVMValueRef PhiNode, unsigned Index)
Obtain an incoming value to a PHI node as an LLVMBasicBlockRef.
Definition: Core.cpp:3122
unsigned LLVMGetNumSuccessors(LLVMValueRef Term)
Return the number of successors that this terminator has.
Definition: Core.cpp:3053
LLVMBasicBlockRef LLVMGetSwitchDefaultDest(LLVMValueRef Switch)
Obtain the default destination basic block of a switch instruction.
Definition: Core.cpp:3081
void LLVMSetSuccessor(LLVMValueRef Term, unsigned i, LLVMBasicBlockRef block)
Update the specified successor to point at the provided block.
Definition: Core.cpp:3061
void LLVMSetCondition(LLVMValueRef Branch, LLVMValueRef Cond)
Set the condition of a branch instruction.
Definition: Core.cpp:3075
LLVMValueRef LLVMGetCondition(LLVMValueRef Branch)
Return the condition of a branch instruction.
Definition: Core.cpp:3071
LLVMBool LLVMIsConditional(LLVMValueRef Branch)
Return if a branch is conditional.
Definition: Core.cpp:3067
LLVMBasicBlockRef LLVMGetSuccessor(LLVMValueRef Term, unsigned i)
Return the specified successor.
Definition: Core.cpp:3057
LLVMValueRef LLVMInstructionClone(LLVMValueRef Inst)
Create a copy of 'this' instruction that is identical in all ways except the following:
Definition: Core.cpp:2894
LLVMValueRef LLVMGetNextInstruction(LLVMValueRef Inst)
Obtain the instruction that occurs after the one specified.
Definition: Core.cpp:2848
void LLVMDeleteInstruction(LLVMValueRef Inst)
Delete an instruction.
Definition: Core.cpp:2872
LLVMValueRef LLVMIsATerminatorInst(LLVMValueRef Inst)
Determine whether an instruction is a terminator.
Definition: Core.cpp:2900
LLVMOpcode LLVMGetInstructionOpcode(LLVMValueRef Inst)
Obtain the code opcode for an individual instruction.
Definition: Core.cpp:2888
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:1114
LLVMRealPredicate LLVMGetFCmpPredicate(LLVMValueRef Inst)
Obtain the float predicate of an instruction.
Definition: Core.cpp:2882
int LLVMHasMetadata(LLVMValueRef Inst)
Determine whether an instruction has any metadata attached.
Definition: Core.cpp:1057
void LLVMInstructionEraseFromParent(LLVMValueRef Inst)
Remove and delete an instruction.
Definition: Core.cpp:2868
void LLVMInstructionRemoveFromParent(LLVMValueRef Inst)
Remove an instruction.
Definition: Core.cpp:2864
LLVMValueRef LLVMGetMetadata(LLVMValueRef Inst, unsigned KindID)
Return metadata associated with an instruction value.
Definition: Core.cpp:1061
LLVMIntPredicate LLVMGetICmpPredicate(LLVMValueRef Inst)
Obtain the predicate of an instruction.
Definition: Core.cpp:2876
void LLVMSetMetadata(LLVMValueRef Inst, unsigned KindID, LLVMValueRef Val)
Set metadata associated with an instruction value.
Definition: Core.cpp:1083
LLVMBasicBlockRef LLVMGetInstructionParent(LLVMValueRef Inst)
Obtain the basic block to which an instruction belongs.
Definition: Core.cpp:2828
LLVMValueRef LLVMGetPreviousInstruction(LLVMValueRef Inst)
Obtain the instruction that occurred before this one.
Definition: Core.cpp:2856
LLVMValueRef LLVMMetadataAsValue(LLVMContextRef C, LLVMMetadataRef MD)
Obtain a Metadata as a Value.
Definition: Core.cpp:1314
LLVMValueRef LLVMMDString(const char *Str, unsigned SLen)
Deprecated: Use LLVMMDStringInContext2 instead.
Definition: Core.cpp:1279
void LLVMReplaceMDNodeOperandWith(LLVMValueRef V, unsigned Index, LLVMMetadataRef Replacement)
Replace an operand at a specific index in a llvm::MDNode value.
Definition: Core.cpp:1405
LLVMMetadataRef LLVMMDStringInContext2(LLVMContextRef C, const char *Str, size_t SLen)
Create an MDString value from a given string value.
Definition: Core.cpp:1262
LLVMMetadataRef LLVMMDNodeInContext2(LLVMContextRef C, LLVMMetadataRef *MDs, size_t Count)
Create an MDNode value with the given array of operands.
Definition: Core.cpp:1267
LLVMValueRef LLVMMDStringInContext(LLVMContextRef C, const char *Str, unsigned SLen)
Deprecated: Use LLVMMDStringInContext2 instead.
Definition: Core.cpp:1272
LLVMMetadataRef LLVMValueAsMetadata(LLVMValueRef Val)
Obtain a Value as a Metadata.
Definition: Core.cpp:1318
LLVMValueRef LLVMMDNodeInContext(LLVMContextRef C, LLVMValueRef *Vals, unsigned Count)
Deprecated: Use LLVMMDNodeInContext2 instead.
Definition: Core.cpp:1283
const char * LLVMGetMDString(LLVMValueRef V, unsigned *Length)
Obtain the underlying string from a MDString value.
Definition: Core.cpp:1327
unsigned LLVMGetMDNodeNumOperands(LLVMValueRef V)
Obtain the number of operands from an MDNode value.
Definition: Core.cpp:1337
void LLVMGetMDNodeOperands(LLVMValueRef V, LLVMValueRef *Dest)
Obtain the given MDNode's operands.
Definition: Core.cpp:1392
LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count)
Deprecated: Use LLVMMDNodeInContext2 instead.
Definition: Core.cpp:1310
int LLVMGetNumOperands(LLVMValueRef Val)
Obtain the number of operands in a llvm::User value.
Definition: Core.cpp:1212
void LLVMSetOperand(LLVMValueRef Val, unsigned Index, LLVMValueRef Op)
Set an operand at a specific index in a llvm::User value.
Definition: Core.cpp:1208
LLVMUseRef LLVMGetOperandUse(LLVMValueRef Val, unsigned Index)
Obtain the use of an operand at a specific index in a llvm::User value.
Definition: Core.cpp:1203
LLVMValueRef LLVMGetOperand(LLVMValueRef Val, unsigned Index)
Obtain an operand at a specific index in a llvm::User value.
Definition: Core.cpp:1189
LLVMValueRef LLVMGetUser(LLVMUseRef U)
Obtain the user value for a user.
Definition: Core.cpp:1169
LLVMUseRef LLVMGetFirstUse(LLVMValueRef Val)
Obtain the first use of a value.
Definition: Core.cpp:1154
LLVMUseRef LLVMGetNextUse(LLVMUseRef U)
Obtain the next use of a value.
Definition: Core.cpp:1162
LLVMValueRef LLVMGetUsedValue(LLVMUseRef U)
Obtain the value this use corresponds to.
Definition: Core.cpp:1173
#define LLVM_FOR_EACH_VALUE_SUBCLASS(macro)
Definition: Core.h:1778
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:2315
LLVMValueRef LLVMGetLastGlobalAlias(LLVMModuleRef M)
Obtain an iterator to the last GlobalAlias in a Module.
Definition: Core.cpp:2287
LLVMValueRef LLVMGetNextGlobalAlias(LLVMValueRef GA)
Advance a GlobalAlias iterator to the next GlobalAlias.
Definition: Core.cpp:2295
LLVMValueRef LLVMAliasGetAliasee(LLVMValueRef Alias)
Retrieve the target value of an alias.
Definition: Core.cpp:2311
LLVMValueRef LLVMGetPreviousGlobalAlias(LLVMValueRef GA)
Decrement a GlobalAlias iterator to the previous GlobalAlias.
Definition: Core.cpp:2303
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:2266
LLVMValueRef LLVMGetFirstGlobalAlias(LLVMModuleRef M)
Obtain an iterator to the first GlobalAlias in a Module.
Definition: Core.cpp:2279
LLVMValueRef LLVMGetNamedGlobalAlias(LLVMModuleRef M, const char *Name, size_t NameLen)
Obtain a GlobalAlias value from a Module by its name.
Definition: Core.cpp:2274
void LLVMSetGlobalConstant(LLVMValueRef GlobalVar, LLVMBool IsConstant)
Definition: Core.cpp:2213
void LLVMSetThreadLocalMode(LLVMValueRef GlobalVar, LLVMThreadLocalMode Mode)
Definition: Core.cpp:2234
LLVMThreadLocalMode LLVMGetThreadLocalMode(LLVMValueRef GlobalVar)
Definition: Core.cpp:2217
LLVMValueRef LLVMGetFirstGlobal(LLVMModuleRef M)
Definition: Core.cpp:2153
LLVMValueRef LLVMGetNextGlobal(LLVMValueRef GlobalVar)
Definition: Core.cpp:2169
LLVMBool LLVMIsExternallyInitialized(LLVMValueRef GlobalVar)
Definition: Core.cpp:2256
LLVMValueRef LLVMAddGlobal(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name)
Definition: Core.cpp:2135
LLVMValueRef LLVMGetLastGlobal(LLVMModuleRef M)
Definition: Core.cpp:2161
void LLVMSetExternallyInitialized(LLVMValueRef GlobalVar, LLVMBool IsExtInit)
Definition: Core.cpp:2260
LLVMValueRef LLVMGetPreviousGlobal(LLVMValueRef GlobalVar)
Definition: Core.cpp:2177
void LLVMSetThreadLocal(LLVMValueRef GlobalVar, LLVMBool IsThreadLocal)
Definition: Core.cpp:2205
LLVMValueRef LLVMGetInitializer(LLVMValueRef GlobalVar)
Definition: Core.cpp:2189
void LLVMDeleteGlobal(LLVMValueRef GlobalVar)
Definition: Core.cpp:2185
LLVMBool LLVMIsThreadLocal(LLVMValueRef GlobalVar)
Definition: Core.cpp:2201
LLVMBool LLVMIsGlobalConstant(LLVMValueRef GlobalVar)
Definition: Core.cpp:2209
LLVMValueRef LLVMAddGlobalInAddressSpace(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name, unsigned AddressSpace)
Definition: Core.cpp:2140
void LLVMSetInitializer(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal)
Definition: Core.cpp:2196
LLVMValueRef LLVMGetNamedGlobal(LLVMModuleRef M, const char *Name)
Definition: Core.cpp:2149
#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:1452
std::string getNameNoUnnamedTypes(ID Id, ArrayRef< Type * > Tys)
Return the LLVM name for an intrinsic.
Definition: Function.cpp:1082
StringRef getName(ID id)
Return the LLVM name for an intrinsic, such as "llvm.ppc.altivec.lvx".
Definition: Function.cpp:1042
bool isOverloaded(ID id)
Returns true if the intrinsic can be overloaded.
Definition: Function.cpp:1473
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:1484
@ 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:767
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ Length
Definition: DWP.cpp:480
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:431
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:315
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:1091
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