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