LLVM  3.7.0
Core.cpp
Go to the documentation of this file.
1 //===-- Core.cpp ----------------------------------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements the common infrastructure (including the C bindings)
11 // for libLLVMCore.a, which implements the LLVM intermediate representation.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #include "llvm-c/Core.h"
17 #include "llvm/IR/Attributes.h"
18 #include "llvm/IR/CallSite.h"
19 #include "llvm/IR/Constants.h"
20 #include "llvm/IR/DerivedTypes.h"
21 #include "llvm/IR/DiagnosticInfo.h"
23 #include "llvm/IR/GlobalAlias.h"
24 #include "llvm/IR/GlobalVariable.h"
25 #include "llvm/IR/IRBuilder.h"
26 #include "llvm/IR/InlineAsm.h"
27 #include "llvm/IR/IntrinsicInst.h"
28 #include "llvm/IR/LLVMContext.h"
30 #include "llvm/IR/Module.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  return wrap(new LLVMContext());
78 }
79 
81  return wrap(&getGlobalContext());
82 }
83 
85  LLVMDiagnosticHandler Handler,
86  void *DiagnosticContext) {
87  unwrap(C)->setDiagnosticHandler(
88  LLVM_EXTENSION reinterpret_cast<LLVMContext::DiagnosticHandlerTy>(Handler),
89  DiagnosticContext);
90 }
91 
93  void *OpaqueHandle) {
94  auto YieldCallback =
95  LLVM_EXTENSION reinterpret_cast<LLVMContext::YieldCallbackTy>(Callback);
96  unwrap(C)->setYieldCallback(YieldCallback, OpaqueHandle);
97 }
98 
100  delete unwrap(C);
101 }
102 
104  unsigned SLen) {
105  return unwrap(C)->getMDKindID(StringRef(Name, SLen));
106 }
107 
108 unsigned LLVMGetMDKindID(const char* Name, unsigned SLen) {
109  return LLVMGetMDKindIDInContext(LLVMGetGlobalContext(), Name, SLen);
110 }
111 
113  std::string MsgStorage;
114  raw_string_ostream Stream(MsgStorage);
115  DiagnosticPrinterRawOStream DP(Stream);
116 
117  unwrap(DI)->print(DP);
118  Stream.flush();
119 
120  return LLVMCreateMessage(MsgStorage.c_str());
121 }
122 
124  LLVMDiagnosticSeverity severity;
125 
126  switch(unwrap(DI)->getSeverity()) {
127  default:
128  severity = LLVMDSError;
129  break;
130  case DS_Warning:
131  severity = LLVMDSWarning;
132  break;
133  case DS_Remark:
134  severity = LLVMDSRemark;
135  break;
136  case DS_Note:
137  severity = LLVMDSNote;
138  break;
139  }
140 
141  return severity;
142 }
143 
144 
145 
146 
147 /*===-- Operations on modules ---------------------------------------------===*/
148 
150  return wrap(new Module(ModuleID, getGlobalContext()));
151 }
152 
154  LLVMContextRef C) {
155  return wrap(new Module(ModuleID, *unwrap(C)));
156 }
157 
159  delete unwrap(M);
160 }
161 
162 /*--.. Data layout .........................................................--*/
164  return unwrap(M)->getDataLayoutStr().c_str();
165 }
166 
167 void LLVMSetDataLayout(LLVMModuleRef M, const char *Triple) {
168  unwrap(M)->setDataLayout(Triple);
169 }
170 
171 /*--.. Target triple .......................................................--*/
172 const char * LLVMGetTarget(LLVMModuleRef M) {
173  return unwrap(M)->getTargetTriple().c_str();
174 }
175 
176 void LLVMSetTarget(LLVMModuleRef M, const char *Triple) {
177  unwrap(M)->setTargetTriple(Triple);
178 }
179 
181  unwrap(M)->dump();
182 }
183 
185  char **ErrorMessage) {
186  std::error_code EC;
187  raw_fd_ostream dest(Filename, EC, sys::fs::F_Text);
188  if (EC) {
189  *ErrorMessage = strdup(EC.message().c_str());
190  return true;
191  }
192 
193  unwrap(M)->print(dest, nullptr);
194 
195  dest.close();
196 
197  if (dest.has_error()) {
198  *ErrorMessage = strdup("Error printing to file");
199  return true;
200  }
201 
202  return false;
203 }
204 
206  std::string buf;
207  raw_string_ostream os(buf);
208 
209  unwrap(M)->print(os, nullptr);
210  os.flush();
211 
212  return strdup(buf.c_str());
213 }
214 
215 /*--.. Operations on inline assembler ......................................--*/
217  unwrap(M)->setModuleInlineAsm(StringRef(Asm));
218 }
219 
220 
221 /*--.. Operations on module contexts ......................................--*/
223  return wrap(&unwrap(M)->getContext());
224 }
225 
226 
227 /*===-- Operations on types -----------------------------------------------===*/
228 
229 /*--.. Operations on all types (mostly) ....................................--*/
230 
232  switch (unwrap(Ty)->getTypeID()) {
233  case Type::VoidTyID:
234  return LLVMVoidTypeKind;
235  case Type::HalfTyID:
236  return LLVMHalfTypeKind;
237  case Type::FloatTyID:
238  return LLVMFloatTypeKind;
239  case Type::DoubleTyID:
240  return LLVMDoubleTypeKind;
241  case Type::X86_FP80TyID:
242  return LLVMX86_FP80TypeKind;
243  case Type::FP128TyID:
244  return LLVMFP128TypeKind;
245  case Type::PPC_FP128TyID:
246  return LLVMPPC_FP128TypeKind;
247  case Type::LabelTyID:
248  return LLVMLabelTypeKind;
249  case Type::MetadataTyID:
250  return LLVMMetadataTypeKind;
251  case Type::IntegerTyID:
252  return LLVMIntegerTypeKind;
253  case Type::FunctionTyID:
254  return LLVMFunctionTypeKind;
255  case Type::StructTyID:
256  return LLVMStructTypeKind;
257  case Type::ArrayTyID:
258  return LLVMArrayTypeKind;
259  case Type::PointerTyID:
260  return LLVMPointerTypeKind;
261  case Type::VectorTyID:
262  return LLVMVectorTypeKind;
263  case Type::X86_MMXTyID:
264  return LLVMX86_MMXTypeKind;
265  }
266  llvm_unreachable("Unhandled TypeID.");
267 }
268 
270 {
271  return unwrap(Ty)->isSized();
272 }
273 
275  return wrap(&unwrap(Ty)->getContext());
276 }
277 
279  return unwrap(Ty)->dump();
280 }
281 
283  std::string buf;
284  raw_string_ostream os(buf);
285 
286  if (unwrap(Ty))
287  unwrap(Ty)->print(os);
288  else
289  os << "Printing <null> Type";
290 
291  os.flush();
292 
293  return strdup(buf.c_str());
294 }
295 
296 /*--.. Operations on integer types .........................................--*/
297 
299  return (LLVMTypeRef) Type::getInt1Ty(*unwrap(C));
300 }
302  return (LLVMTypeRef) Type::getInt8Ty(*unwrap(C));
303 }
305  return (LLVMTypeRef) Type::getInt16Ty(*unwrap(C));
306 }
308  return (LLVMTypeRef) Type::getInt32Ty(*unwrap(C));
309 }
311  return (LLVMTypeRef) Type::getInt64Ty(*unwrap(C));
312 }
314  return (LLVMTypeRef) Type::getInt128Ty(*unwrap(C));
315 }
317  return wrap(IntegerType::get(*unwrap(C), NumBits));
318 }
319 
322 }
325 }
328 }
331 }
334 }
337 }
338 LLVMTypeRef LLVMIntType(unsigned NumBits) {
339  return LLVMIntTypeInContext(LLVMGetGlobalContext(), NumBits);
340 }
341 
342 unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy) {
343  return unwrap<IntegerType>(IntegerTy)->getBitWidth();
344 }
345 
346 /*--.. Operations on real types ............................................--*/
347 
349  return (LLVMTypeRef) Type::getHalfTy(*unwrap(C));
350 }
352  return (LLVMTypeRef) Type::getFloatTy(*unwrap(C));
353 }
355  return (LLVMTypeRef) Type::getDoubleTy(*unwrap(C));
356 }
358  return (LLVMTypeRef) Type::getX86_FP80Ty(*unwrap(C));
359 }
361  return (LLVMTypeRef) Type::getFP128Ty(*unwrap(C));
362 }
365 }
367  return (LLVMTypeRef) Type::getX86_MMXTy(*unwrap(C));
368 }
369 
372 }
375 }
378 }
381 }
384 }
387 }
390 }
391 
392 /*--.. Operations on function types ........................................--*/
393 
395  LLVMTypeRef *ParamTypes, unsigned ParamCount,
396  LLVMBool IsVarArg) {
397  ArrayRef<Type*> Tys(unwrap(ParamTypes), ParamCount);
398  return wrap(FunctionType::get(unwrap(ReturnType), Tys, IsVarArg != 0));
399 }
400 
402  return unwrap<FunctionType>(FunctionTy)->isVarArg();
403 }
404 
406  return wrap(unwrap<FunctionType>(FunctionTy)->getReturnType());
407 }
408 
409 unsigned LLVMCountParamTypes(LLVMTypeRef FunctionTy) {
410  return unwrap<FunctionType>(FunctionTy)->getNumParams();
411 }
412 
413 void LLVMGetParamTypes(LLVMTypeRef FunctionTy, LLVMTypeRef *Dest) {
414  FunctionType *Ty = unwrap<FunctionType>(FunctionTy);
416  E = Ty->param_end(); I != E; ++I)
417  *Dest++ = wrap(*I);
418 }
419 
420 /*--.. Operations on struct types ..........................................--*/
421 
423  unsigned ElementCount, LLVMBool Packed) {
424  ArrayRef<Type*> Tys(unwrap(ElementTypes), ElementCount);
425  return wrap(StructType::get(*unwrap(C), Tys, Packed != 0));
426 }
427 
429  unsigned ElementCount, LLVMBool Packed) {
430  return LLVMStructTypeInContext(LLVMGetGlobalContext(), ElementTypes,
431  ElementCount, Packed);
432 }
433 
435 {
436  return wrap(StructType::create(*unwrap(C), Name));
437 }
438 
440 {
441  StructType *Type = unwrap<StructType>(Ty);
442  if (!Type->hasName())
443  return nullptr;
444  return Type->getName().data();
445 }
446 
447 void LLVMStructSetBody(LLVMTypeRef StructTy, LLVMTypeRef *ElementTypes,
448  unsigned ElementCount, LLVMBool Packed) {
449  ArrayRef<Type*> Tys(unwrap(ElementTypes), ElementCount);
450  unwrap<StructType>(StructTy)->setBody(Tys, Packed != 0);
451 }
452 
454  return unwrap<StructType>(StructTy)->getNumElements();
455 }
456 
458  StructType *Ty = unwrap<StructType>(StructTy);
460  E = Ty->element_end(); I != E; ++I)
461  *Dest++ = wrap(*I);
462 }
463 
465  StructType *Ty = unwrap<StructType>(StructTy);
466  return wrap(Ty->getTypeAtIndex(i));
467 }
468 
470  return unwrap<StructType>(StructTy)->isPacked();
471 }
472 
474  return unwrap<StructType>(StructTy)->isOpaque();
475 }
476 
478  return wrap(unwrap(M)->getTypeByName(Name));
479 }
480 
481 /*--.. Operations on array, pointer, and vector types (sequence types) .....--*/
482 
483 LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount) {
484  return wrap(ArrayType::get(unwrap(ElementType), ElementCount));
485 }
486 
488  return wrap(PointerType::get(unwrap(ElementType), AddressSpace));
489 }
490 
491 LLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType, unsigned ElementCount) {
492  return wrap(VectorType::get(unwrap(ElementType), ElementCount));
493 }
494 
496  return wrap(unwrap<SequentialType>(Ty)->getElementType());
497 }
498 
499 unsigned LLVMGetArrayLength(LLVMTypeRef ArrayTy) {
500  return unwrap<ArrayType>(ArrayTy)->getNumElements();
501 }
502 
504  return unwrap<PointerType>(PointerTy)->getAddressSpace();
505 }
506 
507 unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy) {
508  return unwrap<VectorType>(VectorTy)->getNumElements();
509 }
510 
511 /*--.. Operations on other types ...........................................--*/
512 
514  return wrap(Type::getVoidTy(*unwrap(C)));
515 }
517  return wrap(Type::getLabelTy(*unwrap(C)));
518 }
519 
522 }
525 }
526 
527 /*===-- Operations on values ----------------------------------------------===*/
528 
529 /*--.. Operations on all values ............................................--*/
530 
532  return wrap(unwrap(Val)->getType());
533 }
534 
535 const char *LLVMGetValueName(LLVMValueRef Val) {
536  return unwrap(Val)->getName().data();
537 }
538 
539 void LLVMSetValueName(LLVMValueRef Val, const char *Name) {
540  unwrap(Val)->setName(Name);
541 }
542 
544  unwrap(Val)->dump();
545 }
546 
548  std::string buf;
549  raw_string_ostream os(buf);
550 
551  if (unwrap(Val))
552  unwrap(Val)->print(os);
553  else
554  os << "Printing <null> Value";
555 
556  os.flush();
557 
558  return strdup(buf.c_str());
559 }
560 
562  unwrap(OldVal)->replaceAllUsesWith(unwrap(NewVal));
563 }
564 
566  return unwrap<Instruction>(Inst)->hasMetadata();
567 }
568 
569 LLVMValueRef LLVMGetMetadata(LLVMValueRef Inst, unsigned KindID) {
570  auto *I = unwrap<Instruction>(Inst);
571  assert(I && "Expected instruction");
572  if (auto *MD = I->getMetadata(KindID))
573  return wrap(MetadataAsValue::get(I->getContext(), MD));
574  return nullptr;
575 }
576 
577 // MetadataAsValue uses a canonical format which strips the actual MDNode for
578 // MDNode with just a single constant value, storing just a ConstantAsMetadata
579 // This undoes this canonicalization, reconstructing the MDNode.
581  Metadata *MD = MAV->getMetadata();
582  assert((isa<MDNode>(MD) || isa<ConstantAsMetadata>(MD)) &&
583  "Expected a metadata node or a canonicalized constant");
584 
585  if (MDNode *N = dyn_cast<MDNode>(MD))
586  return N;
587 
588  return MDNode::get(MAV->getContext(), MD);
589 }
590 
591 void LLVMSetMetadata(LLVMValueRef Inst, unsigned KindID, LLVMValueRef Val) {
592  MDNode *N = Val ? extractMDNode(unwrap<MetadataAsValue>(Val)) : nullptr;
593 
594  unwrap<Instruction>(Inst)->setMetadata(KindID, N);
595 }
596 
597 /*--.. Conversion functions ................................................--*/
598 
599 #define LLVM_DEFINE_VALUE_CAST(name) \
600  LLVMValueRef LLVMIsA##name(LLVMValueRef Val) { \
601  return wrap(static_cast<Value*>(dyn_cast_or_null<name>(unwrap(Val)))); \
602  }
603 
605 
607  if (auto *MD = dyn_cast_or_null<MetadataAsValue>(unwrap(Val)))
608  if (isa<MDNode>(MD->getMetadata()) ||
609  isa<ValueAsMetadata>(MD->getMetadata()))
610  return Val;
611  return nullptr;
612 }
613 
615  if (auto *MD = dyn_cast_or_null<MetadataAsValue>(unwrap(Val)))
616  if (isa<MDString>(MD->getMetadata()))
617  return Val;
618  return nullptr;
619 }
620 
621 /*--.. Operations on Uses ..................................................--*/
623  Value *V = unwrap(Val);
625  if (I == V->use_end())
626  return nullptr;
627  return wrap(&*I);
628 }
629 
631  Use *Next = unwrap(U)->getNext();
632  if (Next)
633  return wrap(Next);
634  return nullptr;
635 }
636 
638  return wrap(unwrap(U)->getUser());
639 }
640 
642  return wrap(unwrap(U)->get());
643 }
644 
645 /*--.. Operations on Users .................................................--*/
646 
648  unsigned Index) {
649  Metadata *Op = N->getOperand(Index);
650  if (!Op)
651  return nullptr;
652  if (auto *C = dyn_cast<ConstantAsMetadata>(Op))
653  return wrap(C->getValue());
654  return wrap(MetadataAsValue::get(Context, Op));
655 }
656 
658  Value *V = unwrap(Val);
659  if (auto *MD = dyn_cast<MetadataAsValue>(V)) {
660  if (auto *L = dyn_cast<ValueAsMetadata>(MD->getMetadata())) {
661  assert(Index == 0 && "Function-local metadata can only have one operand");
662  return wrap(L->getValue());
663  }
664  return getMDNodeOperandImpl(V->getContext(),
665  cast<MDNode>(MD->getMetadata()), Index);
666  }
667 
668  return wrap(cast<User>(V)->getOperand(Index));
669 }
670 
672  Value *V = unwrap(Val);
673  return wrap(&cast<User>(V)->getOperandUse(Index));
674 }
675 
676 void LLVMSetOperand(LLVMValueRef Val, unsigned Index, LLVMValueRef Op) {
677  unwrap<User>(Val)->setOperand(Index, unwrap(Op));
678 }
679 
681  Value *V = unwrap(Val);
682  if (isa<MetadataAsValue>(V))
683  return LLVMGetMDNodeNumOperands(Val);
684 
685  return cast<User>(V)->getNumOperands();
686 }
687 
688 /*--.. Operations on constants of any type .................................--*/
689 
691  return wrap(Constant::getNullValue(unwrap(Ty)));
692 }
693 
696 }
697 
699  return wrap(UndefValue::get(unwrap(Ty)));
700 }
701 
703  return isa<Constant>(unwrap(Ty));
704 }
705 
707  if (Constant *C = dyn_cast<Constant>(unwrap(Val)))
708  return C->isNullValue();
709  return false;
710 }
711 
713  return isa<UndefValue>(unwrap(Val));
714 }
715 
717  return
718  wrap(ConstantPointerNull::get(unwrap<PointerType>(Ty)));
719 }
720 
721 /*--.. Operations on metadata nodes ........................................--*/
722 
724  unsigned SLen) {
725  LLVMContext &Context = *unwrap(C);
726  return wrap(MetadataAsValue::get(
727  Context, MDString::get(Context, StringRef(Str, SLen))));
728 }
729 
730 LLVMValueRef LLVMMDString(const char *Str, unsigned SLen) {
731  return LLVMMDStringInContext(LLVMGetGlobalContext(), Str, SLen);
732 }
733 
735  unsigned Count) {
736  LLVMContext &Context = *unwrap(C);
738  for (auto *OV : makeArrayRef(Vals, Count)) {
739  Value *V = unwrap(OV);
740  Metadata *MD;
741  if (!V)
742  MD = nullptr;
743  else if (auto *C = dyn_cast<Constant>(V))
744  MD = ConstantAsMetadata::get(C);
745  else if (auto *MDV = dyn_cast<MetadataAsValue>(V)) {
746  MD = MDV->getMetadata();
747  assert(!isa<LocalAsMetadata>(MD) && "Unexpected function-local metadata "
748  "outside of direct argument to call");
749  } else {
750  // This is function-local metadata. Pretend to make an MDNode.
751  assert(Count == 1 &&
752  "Expected only one operand to function-local metadata");
753  return wrap(MetadataAsValue::get(Context, LocalAsMetadata::get(V)));
754  }
755 
756  MDs.push_back(MD);
757  }
758  return wrap(MetadataAsValue::get(Context, MDNode::get(Context, MDs)));
759 }
760 
761 LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count) {
762  return LLVMMDNodeInContext(LLVMGetGlobalContext(), Vals, Count);
763 }
764 
765 const char *LLVMGetMDString(LLVMValueRef V, unsigned* Len) {
766  if (const auto *MD = dyn_cast<MetadataAsValue>(unwrap(V)))
767  if (const MDString *S = dyn_cast<MDString>(MD->getMetadata())) {
768  *Len = S->getString().size();
769  return S->getString().data();
770  }
771  *Len = 0;
772  return nullptr;
773 }
774 
776 {
777  auto *MD = cast<MetadataAsValue>(unwrap(V));
778  if (isa<ValueAsMetadata>(MD->getMetadata()))
779  return 1;
780  return cast<MDNode>(MD->getMetadata())->getNumOperands();
781 }
782 
784 {
785  auto *MD = cast<MetadataAsValue>(unwrap(V));
786  if (auto *MDV = dyn_cast<ValueAsMetadata>(MD->getMetadata())) {
787  *Dest = wrap(MDV->getValue());
788  return;
789  }
790  const auto *N = cast<MDNode>(MD->getMetadata());
791  const unsigned numOperands = N->getNumOperands();
792  LLVMContext &Context = unwrap(V)->getContext();
793  for (unsigned i = 0; i < numOperands; i++)
794  Dest[i] = getMDNodeOperandImpl(Context, N, i);
795 }
796 
798 {
799  if (NamedMDNode *N = unwrap(M)->getNamedMetadata(name)) {
800  return N->getNumOperands();
801  }
802  return 0;
803 }
804 
806 {
807  NamedMDNode *N = unwrap(M)->getNamedMetadata(name);
808  if (!N)
809  return;
810  LLVMContext &Context = unwrap(M)->getContext();
811  for (unsigned i=0;i<N->getNumOperands();i++)
812  Dest[i] = wrap(MetadataAsValue::get(Context, N->getOperand(i)));
813 }
814 
816  LLVMValueRef Val)
817 {
818  NamedMDNode *N = unwrap(M)->getOrInsertNamedMetadata(name);
819  if (!N)
820  return;
821  if (!Val)
822  return;
823  N->addOperand(extractMDNode(unwrap<MetadataAsValue>(Val)));
824 }
825 
826 /*--.. Operations on scalar constants ......................................--*/
827 
828 LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N,
829  LLVMBool SignExtend) {
830  return wrap(ConstantInt::get(unwrap<IntegerType>(IntTy), N, SignExtend != 0));
831 }
832 
834  unsigned NumWords,
835  const uint64_t Words[]) {
836  IntegerType *Ty = unwrap<IntegerType>(IntTy);
837  return wrap(ConstantInt::get(Ty->getContext(),
838  APInt(Ty->getBitWidth(),
839  makeArrayRef(Words, NumWords))));
840 }
841 
843  uint8_t Radix) {
844  return wrap(ConstantInt::get(unwrap<IntegerType>(IntTy), StringRef(Str),
845  Radix));
846 }
847 
849  unsigned SLen, uint8_t Radix) {
850  return wrap(ConstantInt::get(unwrap<IntegerType>(IntTy), StringRef(Str, SLen),
851  Radix));
852 }
853 
855  return wrap(ConstantFP::get(unwrap(RealTy), N));
856 }
857 
858 LLVMValueRef LLVMConstRealOfString(LLVMTypeRef RealTy, const char *Text) {
859  return wrap(ConstantFP::get(unwrap(RealTy), StringRef(Text)));
860 }
861 
863  unsigned SLen) {
864  return wrap(ConstantFP::get(unwrap(RealTy), StringRef(Str, SLen)));
865 }
866 
867 unsigned long long LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal) {
868  return unwrap<ConstantInt>(ConstantVal)->getZExtValue();
869 }
870 
871 long long LLVMConstIntGetSExtValue(LLVMValueRef ConstantVal) {
872  return unwrap<ConstantInt>(ConstantVal)->getSExtValue();
873 }
874 
875 double LLVMConstRealGetDouble(LLVMValueRef ConstantVal, LLVMBool *LosesInfo) {
876  ConstantFP *cFP = unwrap<ConstantFP>(ConstantVal) ;
877  Type *Ty = cFP->getType();
878 
879  if (Ty->isFloatTy()) {
880  *LosesInfo = false;
881  return cFP->getValueAPF().convertToFloat();
882  }
883 
884  if (Ty->isDoubleTy()) {
885  *LosesInfo = false;
886  return cFP->getValueAPF().convertToDouble();
887  }
888 
889  bool APFLosesInfo;
890  APFloat APF = cFP->getValueAPF();
892  *LosesInfo = APFLosesInfo;
893  return APF.convertToDouble();
894 }
895 
896 /*--.. Operations on composite constants ...................................--*/
897 
899  unsigned Length,
900  LLVMBool DontNullTerminate) {
901  /* Inverted the sense of AddNull because ', 0)' is a
902  better mnemonic for null termination than ', 1)'. */
903  return wrap(ConstantDataArray::getString(*unwrap(C), StringRef(Str, Length),
904  DontNullTerminate == 0));
905 }
907  LLVMValueRef *ConstantVals,
908  unsigned Count, LLVMBool Packed) {
909  Constant **Elements = unwrap<Constant>(ConstantVals, Count);
910  return wrap(ConstantStruct::getAnon(*unwrap(C), makeArrayRef(Elements, Count),
911  Packed != 0));
912 }
913 
914 LLVMValueRef LLVMConstString(const char *Str, unsigned Length,
915  LLVMBool DontNullTerminate) {
916  return LLVMConstStringInContext(LLVMGetGlobalContext(), Str, Length,
917  DontNullTerminate);
918 }
919 
921  return wrap(static_cast<ConstantDataSequential*>(unwrap(c))->getElementAsConstant(idx));
922 }
923 
925  return static_cast<ConstantDataSequential*>(unwrap(c))->isString();
926 }
927 
928 const char *LLVMGetAsString(LLVMValueRef c, size_t* Length) {
929  StringRef str = static_cast<ConstantDataSequential*>(unwrap(c))->getAsString();
930  *Length = str.size();
931  return str.data();
932 }
933 
935  LLVMValueRef *ConstantVals, unsigned Length) {
936  ArrayRef<Constant*> V(unwrap<Constant>(ConstantVals, Length), Length);
937  return wrap(ConstantArray::get(ArrayType::get(unwrap(ElementTy), Length), V));
938 }
939 
940 LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count,
941  LLVMBool Packed) {
942  return LLVMConstStructInContext(LLVMGetGlobalContext(), ConstantVals, Count,
943  Packed);
944 }
945 
947  LLVMValueRef *ConstantVals,
948  unsigned Count) {
949  Constant **Elements = unwrap<Constant>(ConstantVals, Count);
950  StructType *Ty = cast<StructType>(unwrap(StructTy));
951 
952  return wrap(ConstantStruct::get(Ty, makeArrayRef(Elements, Count)));
953 }
954 
955 LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size) {
957  unwrap<Constant>(ScalarConstantVals, Size), Size)));
958 }
959 
960 /*-- Opcode mapping */
961 
962 static LLVMOpcode map_to_llvmopcode(int opcode)
963 {
964  switch (opcode) {
965  default: llvm_unreachable("Unhandled Opcode.");
966 #define HANDLE_INST(num, opc, clas) case num: return LLVM##opc;
967 #include "llvm/IR/Instruction.def"
968 #undef HANDLE_INST
969  }
970 }
971 
973 {
974  switch (code) {
975 #define HANDLE_INST(num, opc, clas) case LLVM##opc: return num;
976 #include "llvm/IR/Instruction.def"
977 #undef HANDLE_INST
978  }
979  llvm_unreachable("Unhandled Opcode.");
980 }
981 
982 /*--.. Constant expressions ................................................--*/
983 
985  return map_to_llvmopcode(unwrap<ConstantExpr>(ConstantVal)->getOpcode());
986 }
987 
989  return wrap(ConstantExpr::getAlignOf(unwrap(Ty)));
990 }
991 
993  return wrap(ConstantExpr::getSizeOf(unwrap(Ty)));
994 }
995 
997  return wrap(ConstantExpr::getNeg(unwrap<Constant>(ConstantVal)));
998 }
999 
1001  return wrap(ConstantExpr::getNSWNeg(unwrap<Constant>(ConstantVal)));
1002 }
1003 
1005  return wrap(ConstantExpr::getNUWNeg(unwrap<Constant>(ConstantVal)));
1006 }
1007 
1008 
1010  return wrap(ConstantExpr::getFNeg(unwrap<Constant>(ConstantVal)));
1011 }
1012 
1014  return wrap(ConstantExpr::getNot(unwrap<Constant>(ConstantVal)));
1015 }
1016 
1018  return wrap(ConstantExpr::getAdd(unwrap<Constant>(LHSConstant),
1019  unwrap<Constant>(RHSConstant)));
1020 }
1021 
1023  LLVMValueRef RHSConstant) {
1024  return wrap(ConstantExpr::getNSWAdd(unwrap<Constant>(LHSConstant),
1025  unwrap<Constant>(RHSConstant)));
1026 }
1027 
1029  LLVMValueRef RHSConstant) {
1030  return wrap(ConstantExpr::getNUWAdd(unwrap<Constant>(LHSConstant),
1031  unwrap<Constant>(RHSConstant)));
1032 }
1033 
1035  return wrap(ConstantExpr::getFAdd(unwrap<Constant>(LHSConstant),
1036  unwrap<Constant>(RHSConstant)));
1037 }
1038 
1040  return wrap(ConstantExpr::getSub(unwrap<Constant>(LHSConstant),
1041  unwrap<Constant>(RHSConstant)));
1042 }
1043 
1045  LLVMValueRef RHSConstant) {
1046  return wrap(ConstantExpr::getNSWSub(unwrap<Constant>(LHSConstant),
1047  unwrap<Constant>(RHSConstant)));
1048 }
1049 
1051  LLVMValueRef RHSConstant) {
1052  return wrap(ConstantExpr::getNUWSub(unwrap<Constant>(LHSConstant),
1053  unwrap<Constant>(RHSConstant)));
1054 }
1055 
1057  return wrap(ConstantExpr::getFSub(unwrap<Constant>(LHSConstant),
1058  unwrap<Constant>(RHSConstant)));
1059 }
1060 
1062  return wrap(ConstantExpr::getMul(unwrap<Constant>(LHSConstant),
1063  unwrap<Constant>(RHSConstant)));
1064 }
1065 
1067  LLVMValueRef RHSConstant) {
1068  return wrap(ConstantExpr::getNSWMul(unwrap<Constant>(LHSConstant),
1069  unwrap<Constant>(RHSConstant)));
1070 }
1071 
1073  LLVMValueRef RHSConstant) {
1074  return wrap(ConstantExpr::getNUWMul(unwrap<Constant>(LHSConstant),
1075  unwrap<Constant>(RHSConstant)));
1076 }
1077 
1079  return wrap(ConstantExpr::getFMul(unwrap<Constant>(LHSConstant),
1080  unwrap<Constant>(RHSConstant)));
1081 }
1082 
1084  return wrap(ConstantExpr::getUDiv(unwrap<Constant>(LHSConstant),
1085  unwrap<Constant>(RHSConstant)));
1086 }
1087 
1089  return wrap(ConstantExpr::getSDiv(unwrap<Constant>(LHSConstant),
1090  unwrap<Constant>(RHSConstant)));
1091 }
1092 
1094  LLVMValueRef RHSConstant) {
1095  return wrap(ConstantExpr::getExactSDiv(unwrap<Constant>(LHSConstant),
1096  unwrap<Constant>(RHSConstant)));
1097 }
1098 
1100  return wrap(ConstantExpr::getFDiv(unwrap<Constant>(LHSConstant),
1101  unwrap<Constant>(RHSConstant)));
1102 }
1103 
1105  return wrap(ConstantExpr::getURem(unwrap<Constant>(LHSConstant),
1106  unwrap<Constant>(RHSConstant)));
1107 }
1108 
1110  return wrap(ConstantExpr::getSRem(unwrap<Constant>(LHSConstant),
1111  unwrap<Constant>(RHSConstant)));
1112 }
1113 
1115  return wrap(ConstantExpr::getFRem(unwrap<Constant>(LHSConstant),
1116  unwrap<Constant>(RHSConstant)));
1117 }
1118 
1120  return wrap(ConstantExpr::getAnd(unwrap<Constant>(LHSConstant),
1121  unwrap<Constant>(RHSConstant)));
1122 }
1123 
1125  return wrap(ConstantExpr::getOr(unwrap<Constant>(LHSConstant),
1126  unwrap<Constant>(RHSConstant)));
1127 }
1128 
1130  return wrap(ConstantExpr::getXor(unwrap<Constant>(LHSConstant),
1131  unwrap<Constant>(RHSConstant)));
1132 }
1133 
1135  LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
1136  return wrap(ConstantExpr::getICmp(Predicate,
1137  unwrap<Constant>(LHSConstant),
1138  unwrap<Constant>(RHSConstant)));
1139 }
1140 
1142  LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
1143  return wrap(ConstantExpr::getFCmp(Predicate,
1144  unwrap<Constant>(LHSConstant),
1145  unwrap<Constant>(RHSConstant)));
1146 }
1147 
1149  return wrap(ConstantExpr::getShl(unwrap<Constant>(LHSConstant),
1150  unwrap<Constant>(RHSConstant)));
1151 }
1152 
1154  return wrap(ConstantExpr::getLShr(unwrap<Constant>(LHSConstant),
1155  unwrap<Constant>(RHSConstant)));
1156 }
1157 
1159  return wrap(ConstantExpr::getAShr(unwrap<Constant>(LHSConstant),
1160  unwrap<Constant>(RHSConstant)));
1161 }
1162 
1164  LLVMValueRef *ConstantIndices, unsigned NumIndices) {
1165  ArrayRef<Constant *> IdxList(unwrap<Constant>(ConstantIndices, NumIndices),
1166  NumIndices);
1168  nullptr, unwrap<Constant>(ConstantVal), IdxList));
1169 }
1170 
1172  LLVMValueRef *ConstantIndices,
1173  unsigned NumIndices) {
1174  Constant* Val = unwrap<Constant>(ConstantVal);
1175  ArrayRef<Constant *> IdxList(unwrap<Constant>(ConstantIndices, NumIndices),
1176  NumIndices);
1177  return wrap(ConstantExpr::getInBoundsGetElementPtr(nullptr, Val, IdxList));
1178 }
1179 
1181  return wrap(ConstantExpr::getTrunc(unwrap<Constant>(ConstantVal),
1182  unwrap(ToType)));
1183 }
1184 
1186  return wrap(ConstantExpr::getSExt(unwrap<Constant>(ConstantVal),
1187  unwrap(ToType)));
1188 }
1189 
1191  return wrap(ConstantExpr::getZExt(unwrap<Constant>(ConstantVal),
1192  unwrap(ToType)));
1193 }
1194 
1196  return wrap(ConstantExpr::getFPTrunc(unwrap<Constant>(ConstantVal),
1197  unwrap(ToType)));
1198 }
1199 
1201  return wrap(ConstantExpr::getFPExtend(unwrap<Constant>(ConstantVal),
1202  unwrap(ToType)));
1203 }
1204 
1206  return wrap(ConstantExpr::getUIToFP(unwrap<Constant>(ConstantVal),
1207  unwrap(ToType)));
1208 }
1209 
1211  return wrap(ConstantExpr::getSIToFP(unwrap<Constant>(ConstantVal),
1212  unwrap(ToType)));
1213 }
1214 
1216  return wrap(ConstantExpr::getFPToUI(unwrap<Constant>(ConstantVal),
1217  unwrap(ToType)));
1218 }
1219 
1221  return wrap(ConstantExpr::getFPToSI(unwrap<Constant>(ConstantVal),
1222  unwrap(ToType)));
1223 }
1224 
1226  return wrap(ConstantExpr::getPtrToInt(unwrap<Constant>(ConstantVal),
1227  unwrap(ToType)));
1228 }
1229 
1231  return wrap(ConstantExpr::getIntToPtr(unwrap<Constant>(ConstantVal),
1232  unwrap(ToType)));
1233 }
1234 
1236  return wrap(ConstantExpr::getBitCast(unwrap<Constant>(ConstantVal),
1237  unwrap(ToType)));
1238 }
1239 
1241  LLVMTypeRef ToType) {
1242  return wrap(ConstantExpr::getAddrSpaceCast(unwrap<Constant>(ConstantVal),
1243  unwrap(ToType)));
1244 }
1245 
1247  LLVMTypeRef ToType) {
1248  return wrap(ConstantExpr::getZExtOrBitCast(unwrap<Constant>(ConstantVal),
1249  unwrap(ToType)));
1250 }
1251 
1253  LLVMTypeRef ToType) {
1254  return wrap(ConstantExpr::getSExtOrBitCast(unwrap<Constant>(ConstantVal),
1255  unwrap(ToType)));
1256 }
1257 
1259  LLVMTypeRef ToType) {
1260  return wrap(ConstantExpr::getTruncOrBitCast(unwrap<Constant>(ConstantVal),
1261  unwrap(ToType)));
1262 }
1263 
1265  LLVMTypeRef ToType) {
1266  return wrap(ConstantExpr::getPointerCast(unwrap<Constant>(ConstantVal),
1267  unwrap(ToType)));
1268 }
1269 
1271  LLVMBool isSigned) {
1272  return wrap(ConstantExpr::getIntegerCast(unwrap<Constant>(ConstantVal),
1273  unwrap(ToType), isSigned));
1274 }
1275 
1277  return wrap(ConstantExpr::getFPCast(unwrap<Constant>(ConstantVal),
1278  unwrap(ToType)));
1279 }
1280 
1282  LLVMValueRef ConstantIfTrue,
1283  LLVMValueRef ConstantIfFalse) {
1284  return wrap(ConstantExpr::getSelect(unwrap<Constant>(ConstantCondition),
1285  unwrap<Constant>(ConstantIfTrue),
1286  unwrap<Constant>(ConstantIfFalse)));
1287 }
1288 
1290  LLVMValueRef IndexConstant) {
1291  return wrap(ConstantExpr::getExtractElement(unwrap<Constant>(VectorConstant),
1292  unwrap<Constant>(IndexConstant)));
1293 }
1294 
1296  LLVMValueRef ElementValueConstant,
1297  LLVMValueRef IndexConstant) {
1298  return wrap(ConstantExpr::getInsertElement(unwrap<Constant>(VectorConstant),
1299  unwrap<Constant>(ElementValueConstant),
1300  unwrap<Constant>(IndexConstant)));
1301 }
1302 
1304  LLVMValueRef VectorBConstant,
1305  LLVMValueRef MaskConstant) {
1306  return wrap(ConstantExpr::getShuffleVector(unwrap<Constant>(VectorAConstant),
1307  unwrap<Constant>(VectorBConstant),
1308  unwrap<Constant>(MaskConstant)));
1309 }
1310 
1311 LLVMValueRef LLVMConstExtractValue(LLVMValueRef AggConstant, unsigned *IdxList,
1312  unsigned NumIdx) {
1313  return wrap(ConstantExpr::getExtractValue(unwrap<Constant>(AggConstant),
1314  makeArrayRef(IdxList, NumIdx)));
1315 }
1316 
1318  LLVMValueRef ElementValueConstant,
1319  unsigned *IdxList, unsigned NumIdx) {
1320  return wrap(ConstantExpr::getInsertValue(unwrap<Constant>(AggConstant),
1321  unwrap<Constant>(ElementValueConstant),
1322  makeArrayRef(IdxList, NumIdx)));
1323 }
1324 
1325 LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty, const char *AsmString,
1326  const char *Constraints,
1327  LLVMBool HasSideEffects,
1328  LLVMBool IsAlignStack) {
1329  return wrap(InlineAsm::get(dyn_cast<FunctionType>(unwrap(Ty)), AsmString,
1330  Constraints, HasSideEffects, IsAlignStack));
1331 }
1332 
1334  return wrap(BlockAddress::get(unwrap<Function>(F), unwrap(BB)));
1335 }
1336 
1337 /*--.. Operations on global variables, functions, and aliases (globals) ....--*/
1338 
1340  return wrap(unwrap<GlobalValue>(Global)->getParent());
1341 }
1342 
1344  return unwrap<GlobalValue>(Global)->isDeclaration();
1345 }
1346 
1348  switch (unwrap<GlobalValue>(Global)->getLinkage()) {
1350  return LLVMExternalLinkage;
1354  return LLVMLinkOnceAnyLinkage;
1356  return LLVMLinkOnceODRLinkage;
1358  return LLVMWeakAnyLinkage;
1360  return LLVMWeakODRLinkage;
1362  return LLVMAppendingLinkage;
1364  return LLVMInternalLinkage;
1366  return LLVMPrivateLinkage;
1368  return LLVMExternalWeakLinkage;
1370  return LLVMCommonLinkage;
1371  }
1372 
1373  llvm_unreachable("Invalid GlobalValue linkage!");
1374 }
1375 
1376 void LLVMSetLinkage(LLVMValueRef Global, LLVMLinkage Linkage) {
1377  GlobalValue *GV = unwrap<GlobalValue>(Global);
1378 
1379  switch (Linkage) {
1380  case LLVMExternalLinkage:
1382  break;
1385  break;
1388  break;
1391  break;
1393  DEBUG(errs() << "LLVMSetLinkage(): LLVMLinkOnceODRAutoHideLinkage is no "
1394  "longer supported.");
1395  break;
1396  case LLVMWeakAnyLinkage:
1398  break;
1399  case LLVMWeakODRLinkage:
1401  break;
1402  case LLVMAppendingLinkage:
1404  break;
1405  case LLVMInternalLinkage:
1407  break;
1408  case LLVMPrivateLinkage:
1410  break;
1413  break;
1416  break;
1417  case LLVMDLLImportLinkage:
1418  DEBUG(errs()
1419  << "LLVMSetLinkage(): LLVMDLLImportLinkage is no longer supported.");
1420  break;
1421  case LLVMDLLExportLinkage:
1422  DEBUG(errs()
1423  << "LLVMSetLinkage(): LLVMDLLExportLinkage is no longer supported.");
1424  break;
1427  break;
1428  case LLVMGhostLinkage:
1429  DEBUG(errs()
1430  << "LLVMSetLinkage(): LLVMGhostLinkage is no longer supported.");
1431  break;
1432  case LLVMCommonLinkage:
1434  break;
1435  }
1436 }
1437 
1438 const char *LLVMGetSection(LLVMValueRef Global) {
1439  return unwrap<GlobalValue>(Global)->getSection();
1440 }
1441 
1442 void LLVMSetSection(LLVMValueRef Global, const char *Section) {
1443  unwrap<GlobalObject>(Global)->setSection(Section);
1444 }
1445 
1447  return static_cast<LLVMVisibility>(
1448  unwrap<GlobalValue>(Global)->getVisibility());
1449 }
1450 
1452  unwrap<GlobalValue>(Global)
1453  ->setVisibility(static_cast<GlobalValue::VisibilityTypes>(Viz));
1454 }
1455 
1457  return static_cast<LLVMDLLStorageClass>(
1458  unwrap<GlobalValue>(Global)->getDLLStorageClass());
1459 }
1460 
1462  unwrap<GlobalValue>(Global)->setDLLStorageClass(
1463  static_cast<GlobalValue::DLLStorageClassTypes>(Class));
1464 }
1465 
1467  return unwrap<GlobalValue>(Global)->hasUnnamedAddr();
1468 }
1469 
1470 void LLVMSetUnnamedAddr(LLVMValueRef Global, LLVMBool HasUnnamedAddr) {
1471  unwrap<GlobalValue>(Global)->setUnnamedAddr(HasUnnamedAddr);
1472 }
1473 
1474 /*--.. Operations on global variables, load and store instructions .........--*/
1475 
1477  Value *P = unwrap<Value>(V);
1478  if (GlobalValue *GV = dyn_cast<GlobalValue>(P))
1479  return GV->getAlignment();
1480  if (AllocaInst *AI = dyn_cast<AllocaInst>(P))
1481  return AI->getAlignment();
1482  if (LoadInst *LI = dyn_cast<LoadInst>(P))
1483  return LI->getAlignment();
1484  if (StoreInst *SI = dyn_cast<StoreInst>(P))
1485  return SI->getAlignment();
1486 
1488  "only GlobalValue, AllocaInst, LoadInst and StoreInst have alignment");
1489 }
1490 
1491 void LLVMSetAlignment(LLVMValueRef V, unsigned Bytes) {
1492  Value *P = unwrap<Value>(V);
1493  if (GlobalObject *GV = dyn_cast<GlobalObject>(P))
1494  GV->setAlignment(Bytes);
1495  else if (AllocaInst *AI = dyn_cast<AllocaInst>(P))
1496  AI->setAlignment(Bytes);
1497  else if (LoadInst *LI = dyn_cast<LoadInst>(P))
1498  LI->setAlignment(Bytes);
1499  else if (StoreInst *SI = dyn_cast<StoreInst>(P))
1500  SI->setAlignment(Bytes);
1501  else
1503  "only GlobalValue, AllocaInst, LoadInst and StoreInst have alignment");
1504 }
1505 
1506 /*--.. Operations on global variables ......................................--*/
1507 
1509  return wrap(new GlobalVariable(*unwrap(M), unwrap(Ty), false,
1510  GlobalValue::ExternalLinkage, nullptr, Name));
1511 }
1512 
1514  const char *Name,
1515  unsigned AddressSpace) {
1516  return wrap(new GlobalVariable(*unwrap(M), unwrap(Ty), false,
1517  GlobalValue::ExternalLinkage, nullptr, Name,
1519  AddressSpace));
1520 }
1521 
1523  return wrap(unwrap(M)->getNamedGlobal(Name));
1524 }
1525 
1527  Module *Mod = unwrap(M);
1529  if (I == Mod->global_end())
1530  return nullptr;
1531  return wrap(I);
1532 }
1533 
1535  Module *Mod = unwrap(M);
1537  if (I == Mod->global_begin())
1538  return nullptr;
1539  return wrap(--I);
1540 }
1541 
1543  GlobalVariable *GV = unwrap<GlobalVariable>(GlobalVar);
1545  if (++I == GV->getParent()->global_end())
1546  return nullptr;
1547  return wrap(I);
1548 }
1549 
1551  GlobalVariable *GV = unwrap<GlobalVariable>(GlobalVar);
1553  if (I == GV->getParent()->global_begin())
1554  return nullptr;
1555  return wrap(--I);
1556 }
1557 
1559  unwrap<GlobalVariable>(GlobalVar)->eraseFromParent();
1560 }
1561 
1563  GlobalVariable* GV = unwrap<GlobalVariable>(GlobalVar);
1564  if ( !GV->hasInitializer() )
1565  return nullptr;
1566  return wrap(GV->getInitializer());
1567 }
1568 
1570  unwrap<GlobalVariable>(GlobalVar)
1571  ->setInitializer(unwrap<Constant>(ConstantVal));
1572 }
1573 
1575  return unwrap<GlobalVariable>(GlobalVar)->isThreadLocal();
1576 }
1577 
1579  unwrap<GlobalVariable>(GlobalVar)->setThreadLocal(IsThreadLocal != 0);
1580 }
1581 
1583  return unwrap<GlobalVariable>(GlobalVar)->isConstant();
1584 }
1585 
1587  unwrap<GlobalVariable>(GlobalVar)->setConstant(IsConstant != 0);
1588 }
1589 
1591  switch (unwrap<GlobalVariable>(GlobalVar)->getThreadLocalMode()) {
1593  return LLVMNotThreadLocal;
1597  return LLVMLocalDynamicTLSModel;
1599  return LLVMInitialExecTLSModel;
1601  return LLVMLocalExecTLSModel;
1602  }
1603 
1604  llvm_unreachable("Invalid GlobalVariable thread local mode");
1605 }
1606 
1608  GlobalVariable *GV = unwrap<GlobalVariable>(GlobalVar);
1609 
1610  switch (Mode) {
1611  case LLVMNotThreadLocal:
1613  break;
1616  break;
1619  break;
1622  break;
1623  case LLVMLocalExecTLSModel:
1625  break;
1626  }
1627 }
1628 
1630  return unwrap<GlobalVariable>(GlobalVar)->isExternallyInitialized();
1631 }
1632 
1634  unwrap<GlobalVariable>(GlobalVar)->setExternallyInitialized(IsExtInit);
1635 }
1636 
1637 /*--.. Operations on aliases ......................................--*/
1638 
1640  const char *Name) {
1641  auto *PTy = cast<PointerType>(unwrap(Ty));
1643  unwrap<Constant>(Aliasee), unwrap(M)));
1644 }
1645 
1646 /*--.. Operations on functions .............................................--*/
1647 
1649  LLVMTypeRef FunctionTy) {
1650  return wrap(Function::Create(unwrap<FunctionType>(FunctionTy),
1652 }
1653 
1655  return wrap(unwrap(M)->getFunction(Name));
1656 }
1657 
1659  Module *Mod = unwrap(M);
1660  Module::iterator I = Mod->begin();
1661  if (I == Mod->end())
1662  return nullptr;
1663  return wrap(I);
1664 }
1665 
1667  Module *Mod = unwrap(M);
1668  Module::iterator I = Mod->end();
1669  if (I == Mod->begin())
1670  return nullptr;
1671  return wrap(--I);
1672 }
1673 
1675  Function *Func = unwrap<Function>(Fn);
1677  if (++I == Func->getParent()->end())
1678  return nullptr;
1679  return wrap(I);
1680 }
1681 
1683  Function *Func = unwrap<Function>(Fn);
1685  if (I == Func->getParent()->begin())
1686  return nullptr;
1687  return wrap(--I);
1688 }
1689 
1691  unwrap<Function>(Fn)->eraseFromParent();
1692 }
1693 
1695  return wrap(unwrap<Function>(Fn)->getPersonalityFn());
1696 }
1697 
1699  unwrap<Function>(Fn)->setPersonalityFn(unwrap<Constant>(PersonalityFn));
1700 }
1701 
1703  if (Function *F = dyn_cast<Function>(unwrap(Fn)))
1704  return F->getIntrinsicID();
1705  return 0;
1706 }
1707 
1709  return unwrap<Function>(Fn)->getCallingConv();
1710 }
1711 
1712 void LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC) {
1713  return unwrap<Function>(Fn)->setCallingConv(
1714  static_cast<CallingConv::ID>(CC));
1715 }
1716 
1717 const char *LLVMGetGC(LLVMValueRef Fn) {
1718  Function *F = unwrap<Function>(Fn);
1719  return F->hasGC()? F->getGC() : nullptr;
1720 }
1721 
1722 void LLVMSetGC(LLVMValueRef Fn, const char *GC) {
1723  Function *F = unwrap<Function>(Fn);
1724  if (GC)
1725  F->setGC(GC);
1726  else
1727  F->clearGC();
1728 }
1729 
1731  Function *Func = unwrap<Function>(Fn);
1732  const AttributeSet PAL = Func->getAttributes();
1733  AttrBuilder B(PA);
1734  const AttributeSet PALnew =
1736  AttributeSet::get(Func->getContext(),
1738  Func->setAttributes(PALnew);
1739 }
1740 
1742  const char *V) {
1743  Function *Func = unwrap<Function>(Fn);
1746  AttrBuilder B;
1747 
1748  B.addAttribute(A, V);
1749  AttributeSet Set = AttributeSet::get(Func->getContext(), Idx, B);
1750  Func->addAttributes(Idx, Set);
1751 }
1752 
1754  Function *Func = unwrap<Function>(Fn);
1755  const AttributeSet PAL = Func->getAttributes();
1756  AttrBuilder B(PA);
1757  const AttributeSet PALnew =
1759  AttributeSet::get(Func->getContext(),
1761  Func->setAttributes(PALnew);
1762 }
1763 
1765  Function *Func = unwrap<Function>(Fn);
1766  const AttributeSet PAL = Func->getAttributes();
1768 }
1769 
1770 /*--.. Operations on parameters ............................................--*/
1771 
1773  // This function is strictly redundant to
1774  // LLVMCountParamTypes(LLVMGetElementType(LLVMTypeOf(FnRef)))
1775  return unwrap<Function>(FnRef)->arg_size();
1776 }
1777 
1778 void LLVMGetParams(LLVMValueRef FnRef, LLVMValueRef *ParamRefs) {
1779  Function *Fn = unwrap<Function>(FnRef);
1780  for (Function::arg_iterator I = Fn->arg_begin(),
1781  E = Fn->arg_end(); I != E; I++)
1782  *ParamRefs++ = wrap(I);
1783 }
1784 
1785 LLVMValueRef LLVMGetParam(LLVMValueRef FnRef, unsigned index) {
1786  Function::arg_iterator AI = unwrap<Function>(FnRef)->arg_begin();
1787  while (index --> 0)
1788  AI++;
1789  return wrap(AI);
1790 }
1791 
1793  return wrap(unwrap<Argument>(V)->getParent());
1794 }
1795 
1797  Function *Func = unwrap<Function>(Fn);
1799  if (I == Func->arg_end())
1800  return nullptr;
1801  return wrap(I);
1802 }
1803 
1805  Function *Func = unwrap<Function>(Fn);
1806  Function::arg_iterator I = Func->arg_end();
1807  if (I == Func->arg_begin())
1808  return nullptr;
1809  return wrap(--I);
1810 }
1811 
1813  Argument *A = unwrap<Argument>(Arg);
1815  if (++I == A->getParent()->arg_end())
1816  return nullptr;
1817  return wrap(I);
1818 }
1819 
1821  Argument *A = unwrap<Argument>(Arg);
1823  if (I == A->getParent()->arg_begin())
1824  return nullptr;
1825  return wrap(--I);
1826 }
1827 
1829  Argument *A = unwrap<Argument>(Arg);
1830  AttrBuilder B(PA);
1831  A->addAttr(AttributeSet::get(A->getContext(), A->getArgNo() + 1, B));
1832 }
1833 
1835  Argument *A = unwrap<Argument>(Arg);
1836  AttrBuilder B(PA);
1837  A->removeAttr(AttributeSet::get(A->getContext(), A->getArgNo() + 1, B));
1838 }
1839 
1841  Argument *A = unwrap<Argument>(Arg);
1842  return (LLVMAttribute)A->getParent()->getAttributes().
1843  Raw(A->getArgNo()+1);
1844 }
1845 
1846 
1847 void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align) {
1848  Argument *A = unwrap<Argument>(Arg);
1849  AttrBuilder B;
1850  B.addAlignmentAttr(align);
1851  A->addAttr(AttributeSet::get(A->getContext(),A->getArgNo() + 1, B));
1852 }
1853 
1854 /*--.. Operations on basic blocks ..........................................--*/
1855 
1857  return wrap(static_cast<Value*>(unwrap(BB)));
1858 }
1859 
1861  return isa<BasicBlock>(unwrap(Val));
1862 }
1863 
1865  return wrap(unwrap<BasicBlock>(Val));
1866 }
1867 
1869  return wrap(unwrap(BB)->getParent());
1870 }
1871 
1873  return wrap(unwrap(BB)->getTerminator());
1874 }
1875 
1877  return unwrap<Function>(FnRef)->size();
1878 }
1879 
1880 void LLVMGetBasicBlocks(LLVMValueRef FnRef, LLVMBasicBlockRef *BasicBlocksRefs){
1881  Function *Fn = unwrap<Function>(FnRef);
1882  for (Function::iterator I = Fn->begin(), E = Fn->end(); I != E; I++)
1883  *BasicBlocksRefs++ = wrap(I);
1884 }
1885 
1887  return wrap(&unwrap<Function>(Fn)->getEntryBlock());
1888 }
1889 
1891  Function *Func = unwrap<Function>(Fn);
1892  Function::iterator I = Func->begin();
1893  if (I == Func->end())
1894  return nullptr;
1895  return wrap(I);
1896 }
1897 
1899  Function *Func = unwrap<Function>(Fn);
1900  Function::iterator I = Func->end();
1901  if (I == Func->begin())
1902  return nullptr;
1903  return wrap(--I);
1904 }
1905 
1907  BasicBlock *Block = unwrap(BB);
1908  Function::iterator I = Block;
1909  if (++I == Block->getParent()->end())
1910  return nullptr;
1911  return wrap(I);
1912 }
1913 
1915  BasicBlock *Block = unwrap(BB);
1916  Function::iterator I = Block;
1917  if (I == Block->getParent()->begin())
1918  return nullptr;
1919  return wrap(--I);
1920 }
1921 
1923  LLVMValueRef FnRef,
1924  const char *Name) {
1925  return wrap(BasicBlock::Create(*unwrap(C), Name, unwrap<Function>(FnRef)));
1926 }
1927 
1929  return LLVMAppendBasicBlockInContext(LLVMGetGlobalContext(), FnRef, Name);
1930 }
1931 
1933  LLVMBasicBlockRef BBRef,
1934  const char *Name) {
1935  BasicBlock *BB = unwrap(BBRef);
1936  return wrap(BasicBlock::Create(*unwrap(C), Name, BB->getParent(), BB));
1937 }
1938 
1940  const char *Name) {
1941  return LLVMInsertBasicBlockInContext(LLVMGetGlobalContext(), BBRef, Name);
1942 }
1943 
1945  unwrap(BBRef)->eraseFromParent();
1946 }
1947 
1949  unwrap(BBRef)->removeFromParent();
1950 }
1951 
1953  unwrap(BB)->moveBefore(unwrap(MovePos));
1954 }
1955 
1957  unwrap(BB)->moveAfter(unwrap(MovePos));
1958 }
1959 
1960 /*--.. Operations on instructions ..........................................--*/
1961 
1963  return wrap(unwrap<Instruction>(Inst)->getParent());
1964 }
1965 
1967  BasicBlock *Block = unwrap(BB);
1968  BasicBlock::iterator I = Block->begin();
1969  if (I == Block->end())
1970  return nullptr;
1971  return wrap(I);
1972 }
1973 
1975  BasicBlock *Block = unwrap(BB);
1976  BasicBlock::iterator I = Block->end();
1977  if (I == Block->begin())
1978  return nullptr;
1979  return wrap(--I);
1980 }
1981 
1983  Instruction *Instr = unwrap<Instruction>(Inst);
1984  BasicBlock::iterator I = Instr;
1985  if (++I == Instr->getParent()->end())
1986  return nullptr;
1987  return wrap(I);
1988 }
1989 
1991  Instruction *Instr = unwrap<Instruction>(Inst);
1992  BasicBlock::iterator I = Instr;
1993  if (I == Instr->getParent()->begin())
1994  return nullptr;
1995  return wrap(--I);
1996 }
1997 
1999  unwrap<Instruction>(Inst)->eraseFromParent();
2000 }
2001 
2003  if (ICmpInst *I = dyn_cast<ICmpInst>(unwrap(Inst)))
2004  return (LLVMIntPredicate)I->getPredicate();
2005  if (ConstantExpr *CE = dyn_cast<ConstantExpr>(unwrap(Inst)))
2006  if (CE->getOpcode() == Instruction::ICmp)
2007  return (LLVMIntPredicate)CE->getPredicate();
2008  return (LLVMIntPredicate)0;
2009 }
2010 
2012  if (FCmpInst *I = dyn_cast<FCmpInst>(unwrap(Inst)))
2013  return (LLVMRealPredicate)I->getPredicate();
2014  if (ConstantExpr *CE = dyn_cast<ConstantExpr>(unwrap(Inst)))
2015  if (CE->getOpcode() == Instruction::FCmp)
2016  return (LLVMRealPredicate)CE->getPredicate();
2017  return (LLVMRealPredicate)0;
2018 }
2019 
2021  if (Instruction *C = dyn_cast<Instruction>(unwrap(Inst)))
2022  return map_to_llvmopcode(C->getOpcode());
2023  return (LLVMOpcode)0;
2024 }
2025 
2027  if (Instruction *C = dyn_cast<Instruction>(unwrap(Inst)))
2028  return wrap(C->clone());
2029  return nullptr;
2030 }
2031 
2032 /*--.. Call and invoke instructions ........................................--*/
2033 
2035  Value *V = unwrap(Instr);
2036  if (CallInst *CI = dyn_cast<CallInst>(V))
2037  return CI->getCallingConv();
2038  if (InvokeInst *II = dyn_cast<InvokeInst>(V))
2039  return II->getCallingConv();
2040  llvm_unreachable("LLVMGetInstructionCallConv applies only to call and invoke!");
2041 }
2042 
2043 void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC) {
2044  Value *V = unwrap(Instr);
2045  if (CallInst *CI = dyn_cast<CallInst>(V))
2046  return CI->setCallingConv(static_cast<CallingConv::ID>(CC));
2047  else if (InvokeInst *II = dyn_cast<InvokeInst>(V))
2048  return II->setCallingConv(static_cast<CallingConv::ID>(CC));
2049  llvm_unreachable("LLVMSetInstructionCallConv applies only to call and invoke!");
2050 }
2051 
2052 void LLVMAddInstrAttribute(LLVMValueRef Instr, unsigned index,
2053  LLVMAttribute PA) {
2054  CallSite Call = CallSite(unwrap<Instruction>(Instr));
2055  AttrBuilder B(PA);
2056  Call.setAttributes(
2057  Call.getAttributes().addAttributes(Call->getContext(), index,
2058  AttributeSet::get(Call->getContext(),
2059  index, B)));
2060 }
2061 
2062 void LLVMRemoveInstrAttribute(LLVMValueRef Instr, unsigned index,
2063  LLVMAttribute PA) {
2064  CallSite Call = CallSite(unwrap<Instruction>(Instr));
2065  AttrBuilder B(PA);
2066  Call.setAttributes(Call.getAttributes()
2067  .removeAttributes(Call->getContext(), index,
2068  AttributeSet::get(Call->getContext(),
2069  index, B)));
2070 }
2071 
2072 void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index,
2073  unsigned align) {
2074  CallSite Call = CallSite(unwrap<Instruction>(Instr));
2075  AttrBuilder B;
2076  B.addAlignmentAttr(align);
2077  Call.setAttributes(Call.getAttributes()
2078  .addAttributes(Call->getContext(), index,
2079  AttributeSet::get(Call->getContext(),
2080  index, B)));
2081 }
2082 
2083 /*--.. Operations on call instructions (only) ..............................--*/
2084 
2086  return unwrap<CallInst>(Call)->isTailCall();
2087 }
2088 
2090  unwrap<CallInst>(Call)->setTailCall(isTailCall);
2091 }
2092 
2093 /*--.. Operations on terminators ...........................................--*/
2094 
2096  return unwrap<TerminatorInst>(Term)->getNumSuccessors();
2097 }
2098 
2100  return wrap(unwrap<TerminatorInst>(Term)->getSuccessor(i));
2101 }
2102 
2103 void LLVMSetSuccessor(LLVMValueRef Term, unsigned i, LLVMBasicBlockRef block) {
2104  return unwrap<TerminatorInst>(Term)->setSuccessor(i,unwrap(block));
2105 }
2106 
2107 /*--.. Operations on branch instructions (only) ............................--*/
2108 
2110  return unwrap<BranchInst>(Branch)->isConditional();
2111 }
2112 
2114  return wrap(unwrap<BranchInst>(Branch)->getCondition());
2115 }
2116 
2118  return unwrap<BranchInst>(Branch)->setCondition(unwrap(Cond));
2119 }
2120 
2121 /*--.. Operations on switch instructions (only) ............................--*/
2122 
2124  return wrap(unwrap<SwitchInst>(Switch)->getDefaultDest());
2125 }
2126 
2127 /*--.. Operations on phi nodes .............................................--*/
2128 
2129 void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues,
2130  LLVMBasicBlockRef *IncomingBlocks, unsigned Count) {
2131  PHINode *PhiVal = unwrap<PHINode>(PhiNode);
2132  for (unsigned I = 0; I != Count; ++I)
2133  PhiVal->addIncoming(unwrap(IncomingValues[I]), unwrap(IncomingBlocks[I]));
2134 }
2135 
2136 unsigned LLVMCountIncoming(LLVMValueRef PhiNode) {
2137  return unwrap<PHINode>(PhiNode)->getNumIncomingValues();
2138 }
2139 
2141  return wrap(unwrap<PHINode>(PhiNode)->getIncomingValue(Index));
2142 }
2143 
2145  return wrap(unwrap<PHINode>(PhiNode)->getIncomingBlock(Index));
2146 }
2147 
2148 
2149 /*===-- Instruction builders ----------------------------------------------===*/
2150 
2152  return wrap(new IRBuilder<>(*unwrap(C)));
2153 }
2154 
2157 }
2158 
2160  LLVMValueRef Instr) {
2161  BasicBlock *BB = unwrap(Block);
2162  Instruction *I = Instr? unwrap<Instruction>(Instr) : (Instruction*) BB->end();
2163  unwrap(Builder)->SetInsertPoint(BB, I);
2164 }
2165 
2167  Instruction *I = unwrap<Instruction>(Instr);
2168  unwrap(Builder)->SetInsertPoint(I->getParent(), I);
2169 }
2170 
2172  BasicBlock *BB = unwrap(Block);
2173  unwrap(Builder)->SetInsertPoint(BB);
2174 }
2175 
2177  return wrap(unwrap(Builder)->GetInsertBlock());
2178 }
2179 
2181  unwrap(Builder)->ClearInsertionPoint();
2182 }
2183 
2185  unwrap(Builder)->Insert(unwrap<Instruction>(Instr));
2186 }
2187 
2189  const char *Name) {
2190  unwrap(Builder)->Insert(unwrap<Instruction>(Instr), Name);
2191 }
2192 
2194  delete unwrap(Builder);
2195 }
2196 
2197 /*--.. Metadata builders ...................................................--*/
2198 
2200  MDNode *Loc =
2201  L ? cast<MDNode>(unwrap<MetadataAsValue>(L)->getMetadata()) : nullptr;
2202  unwrap(Builder)->SetCurrentDebugLocation(DebugLoc(Loc));
2203 }
2204 
2206  LLVMContext &Context = unwrap(Builder)->getContext();
2207  return wrap(MetadataAsValue::get(
2208  Context, unwrap(Builder)->getCurrentDebugLocation().getAsMDNode()));
2209 }
2210 
2212  unwrap(Builder)->SetInstDebugLocation(unwrap<Instruction>(Inst));
2213 }
2214 
2215 
2216 /*--.. Instruction builders ................................................--*/
2217 
2219  return wrap(unwrap(B)->CreateRetVoid());
2220 }
2221 
2223  return wrap(unwrap(B)->CreateRet(unwrap(V)));
2224 }
2225 
2227  unsigned N) {
2228  return wrap(unwrap(B)->CreateAggregateRet(unwrap(RetVals), N));
2229 }
2230 
2232  return wrap(unwrap(B)->CreateBr(unwrap(Dest)));
2233 }
2234 
2236  LLVMBasicBlockRef Then, LLVMBasicBlockRef Else) {
2237  return wrap(unwrap(B)->CreateCondBr(unwrap(If), unwrap(Then), unwrap(Else)));
2238 }
2239 
2241  LLVMBasicBlockRef Else, unsigned NumCases) {
2242  return wrap(unwrap(B)->CreateSwitch(unwrap(V), unwrap(Else), NumCases));
2243 }
2244 
2246  unsigned NumDests) {
2247  return wrap(unwrap(B)->CreateIndirectBr(unwrap(Addr), NumDests));
2248 }
2249 
2251  LLVMValueRef *Args, unsigned NumArgs,
2253  const char *Name) {
2254  return wrap(unwrap(B)->CreateInvoke(unwrap(Fn), unwrap(Then), unwrap(Catch),
2255  makeArrayRef(unwrap(Args), NumArgs),
2256  Name));
2257 }
2258 
2260  unsigned NumClauses, const char *Name) {
2261  return wrap(unwrap(B)->CreateLandingPad(unwrap(Ty), NumClauses, Name));
2262 }
2263 
2265  return wrap(unwrap(B)->CreateResume(unwrap(Exn)));
2266 }
2267 
2269  return wrap(unwrap(B)->CreateUnreachable());
2270 }
2271 
2273  LLVMBasicBlockRef Dest) {
2274  unwrap<SwitchInst>(Switch)->addCase(unwrap<ConstantInt>(OnVal), unwrap(Dest));
2275 }
2276 
2278  unwrap<IndirectBrInst>(IndirectBr)->addDestination(unwrap(Dest));
2279 }
2280 
2281 void LLVMAddClause(LLVMValueRef LandingPad, LLVMValueRef ClauseVal) {
2282  unwrap<LandingPadInst>(LandingPad)->
2283  addClause(cast<Constant>(unwrap(ClauseVal)));
2284 }
2285 
2286 void LLVMSetCleanup(LLVMValueRef LandingPad, LLVMBool Val) {
2287  unwrap<LandingPadInst>(LandingPad)->setCleanup(Val);
2288 }
2289 
2290 /*--.. Arithmetic ..........................................................--*/
2291 
2293  const char *Name) {
2294  return wrap(unwrap(B)->CreateAdd(unwrap(LHS), unwrap(RHS), Name));
2295 }
2296 
2298  const char *Name) {
2299  return wrap(unwrap(B)->CreateNSWAdd(unwrap(LHS), unwrap(RHS), Name));
2300 }
2301 
2303  const char *Name) {
2304  return wrap(unwrap(B)->CreateNUWAdd(unwrap(LHS), unwrap(RHS), Name));
2305 }
2306 
2308  const char *Name) {
2309  return wrap(unwrap(B)->CreateFAdd(unwrap(LHS), unwrap(RHS), Name));
2310 }
2311 
2313  const char *Name) {
2314  return wrap(unwrap(B)->CreateSub(unwrap(LHS), unwrap(RHS), Name));
2315 }
2316 
2318  const char *Name) {
2319  return wrap(unwrap(B)->CreateNSWSub(unwrap(LHS), unwrap(RHS), Name));
2320 }
2321 
2323  const char *Name) {
2324  return wrap(unwrap(B)->CreateNUWSub(unwrap(LHS), unwrap(RHS), Name));
2325 }
2326 
2328  const char *Name) {
2329  return wrap(unwrap(B)->CreateFSub(unwrap(LHS), unwrap(RHS), Name));
2330 }
2331 
2333  const char *Name) {
2334  return wrap(unwrap(B)->CreateMul(unwrap(LHS), unwrap(RHS), Name));
2335 }
2336 
2338  const char *Name) {
2339  return wrap(unwrap(B)->CreateNSWMul(unwrap(LHS), unwrap(RHS), Name));
2340 }
2341 
2343  const char *Name) {
2344  return wrap(unwrap(B)->CreateNUWMul(unwrap(LHS), unwrap(RHS), Name));
2345 }
2346 
2348  const char *Name) {
2349  return wrap(unwrap(B)->CreateFMul(unwrap(LHS), unwrap(RHS), Name));
2350 }
2351 
2353  const char *Name) {
2354  return wrap(unwrap(B)->CreateUDiv(unwrap(LHS), unwrap(RHS), Name));
2355 }
2356 
2358  const char *Name) {
2359  return wrap(unwrap(B)->CreateSDiv(unwrap(LHS), unwrap(RHS), Name));
2360 }
2361 
2363  LLVMValueRef RHS, const char *Name) {
2364  return wrap(unwrap(B)->CreateExactSDiv(unwrap(LHS), unwrap(RHS), Name));
2365 }
2366 
2368  const char *Name) {
2369  return wrap(unwrap(B)->CreateFDiv(unwrap(LHS), unwrap(RHS), Name));
2370 }
2371 
2373  const char *Name) {
2374  return wrap(unwrap(B)->CreateURem(unwrap(LHS), unwrap(RHS), Name));
2375 }
2376 
2378  const char *Name) {
2379  return wrap(unwrap(B)->CreateSRem(unwrap(LHS), unwrap(RHS), Name));
2380 }
2381 
2383  const char *Name) {
2384  return wrap(unwrap(B)->CreateFRem(unwrap(LHS), unwrap(RHS), Name));
2385 }
2386 
2388  const char *Name) {
2389  return wrap(unwrap(B)->CreateShl(unwrap(LHS), unwrap(RHS), Name));
2390 }
2391 
2393  const char *Name) {
2394  return wrap(unwrap(B)->CreateLShr(unwrap(LHS), unwrap(RHS), Name));
2395 }
2396 
2398  const char *Name) {
2399  return wrap(unwrap(B)->CreateAShr(unwrap(LHS), unwrap(RHS), Name));
2400 }
2401 
2403  const char *Name) {
2404  return wrap(unwrap(B)->CreateAnd(unwrap(LHS), unwrap(RHS), Name));
2405 }
2406 
2408  const char *Name) {
2409  return wrap(unwrap(B)->CreateOr(unwrap(LHS), unwrap(RHS), Name));
2410 }
2411 
2413  const char *Name) {
2414  return wrap(unwrap(B)->CreateXor(unwrap(LHS), unwrap(RHS), Name));
2415 }
2416 
2418  LLVMValueRef LHS, LLVMValueRef RHS,
2419  const char *Name) {
2420  return wrap(unwrap(B)->CreateBinOp(Instruction::BinaryOps(map_from_llvmopcode(Op)), unwrap(LHS),
2421  unwrap(RHS), Name));
2422 }
2423 
2425  return wrap(unwrap(B)->CreateNeg(unwrap(V), Name));
2426 }
2427 
2429  const char *Name) {
2430  return wrap(unwrap(B)->CreateNSWNeg(unwrap(V), Name));
2431 }
2432 
2434  const char *Name) {
2435  return wrap(unwrap(B)->CreateNUWNeg(unwrap(V), Name));
2436 }
2437 
2439  return wrap(unwrap(B)->CreateFNeg(unwrap(V), Name));
2440 }
2441 
2443  return wrap(unwrap(B)->CreateNot(unwrap(V), Name));
2444 }
2445 
2446 /*--.. Memory ..............................................................--*/
2447 
2449  const char *Name) {
2450  Type* ITy = Type::getInt32Ty(unwrap(B)->GetInsertBlock()->getContext());
2451  Constant* AllocSize = ConstantExpr::getSizeOf(unwrap(Ty));
2452  AllocSize = ConstantExpr::getTruncOrBitCast(AllocSize, ITy);
2453  Instruction* Malloc = CallInst::CreateMalloc(unwrap(B)->GetInsertBlock(),
2454  ITy, unwrap(Ty), AllocSize,
2455  nullptr, nullptr, "");
2456  return wrap(unwrap(B)->Insert(Malloc, Twine(Name)));
2457 }
2458 
2460  LLVMValueRef Val, const char *Name) {
2461  Type* ITy = Type::getInt32Ty(unwrap(B)->GetInsertBlock()->getContext());
2462  Constant* AllocSize = ConstantExpr::getSizeOf(unwrap(Ty));
2463  AllocSize = ConstantExpr::getTruncOrBitCast(AllocSize, ITy);
2464  Instruction* Malloc = CallInst::CreateMalloc(unwrap(B)->GetInsertBlock(),
2465  ITy, unwrap(Ty), AllocSize,
2466  unwrap(Val), nullptr, "");
2467  return wrap(unwrap(B)->Insert(Malloc, Twine(Name)));
2468 }
2469 
2471  const char *Name) {
2472  return wrap(unwrap(B)->CreateAlloca(unwrap(Ty), nullptr, Name));
2473 }
2474 
2476  LLVMValueRef Val, const char *Name) {
2477  return wrap(unwrap(B)->CreateAlloca(unwrap(Ty), unwrap(Val), Name));
2478 }
2479 
2481  return wrap(unwrap(B)->Insert(
2482  CallInst::CreateFree(unwrap(PointerVal), unwrap(B)->GetInsertBlock())));
2483 }
2484 
2485 
2487  const char *Name) {
2488  return wrap(unwrap(B)->CreateLoad(unwrap(PointerVal), Name));
2489 }
2490 
2492  LLVMValueRef PointerVal) {
2493  return wrap(unwrap(B)->CreateStore(unwrap(Val), unwrap(PointerVal)));
2494 }
2495 
2497  switch (Ordering) {
2501  case LLVMAtomicOrderingAcquire: return Acquire;
2502  case LLVMAtomicOrderingRelease: return Release;
2505  return SequentiallyConsistent;
2506  }
2507 
2508  llvm_unreachable("Invalid LLVMAtomicOrdering value!");
2509 }
2510 
2512  LLVMBool isSingleThread, const char *Name) {
2513  return wrap(
2514  unwrap(B)->CreateFence(mapFromLLVMOrdering(Ordering),
2515  isSingleThread ? SingleThread : CrossThread,
2516  Name));
2517 }
2518 
2520  LLVMValueRef *Indices, unsigned NumIndices,
2521  const char *Name) {
2522  ArrayRef<Value *> IdxList(unwrap(Indices), NumIndices);
2523  return wrap(unwrap(B)->CreateGEP(nullptr, unwrap(Pointer), IdxList, Name));
2524 }
2525 
2527  LLVMValueRef *Indices, unsigned NumIndices,
2528  const char *Name) {
2529  ArrayRef<Value *> IdxList(unwrap(Indices), NumIndices);
2530  return wrap(
2531  unwrap(B)->CreateInBoundsGEP(nullptr, unwrap(Pointer), IdxList, Name));
2532 }
2533 
2535  unsigned Idx, const char *Name) {
2536  return wrap(unwrap(B)->CreateStructGEP(nullptr, unwrap(Pointer), Idx, Name));
2537 }
2538 
2540  const char *Name) {
2541  return wrap(unwrap(B)->CreateGlobalString(Str, Name));
2542 }
2543 
2545  const char *Name) {
2546  return wrap(unwrap(B)->CreateGlobalStringPtr(Str, Name));
2547 }
2548 
2550  Value *P = unwrap<Value>(MemAccessInst);
2551  if (LoadInst *LI = dyn_cast<LoadInst>(P))
2552  return LI->isVolatile();
2553  return cast<StoreInst>(P)->isVolatile();
2554 }
2555 
2557  Value *P = unwrap<Value>(MemAccessInst);
2558  if (LoadInst *LI = dyn_cast<LoadInst>(P))
2559  return LI->setVolatile(isVolatile);
2560  return cast<StoreInst>(P)->setVolatile(isVolatile);
2561 }
2562 
2563 /*--.. Casts ...............................................................--*/
2564 
2566  LLVMTypeRef DestTy, const char *Name) {
2567  return wrap(unwrap(B)->CreateTrunc(unwrap(Val), unwrap(DestTy), Name));
2568 }
2569 
2571  LLVMTypeRef DestTy, const char *Name) {
2572  return wrap(unwrap(B)->CreateZExt(unwrap(Val), unwrap(DestTy), Name));
2573 }
2574 
2576  LLVMTypeRef DestTy, const char *Name) {
2577  return wrap(unwrap(B)->CreateSExt(unwrap(Val), unwrap(DestTy), Name));
2578 }
2579 
2581  LLVMTypeRef DestTy, const char *Name) {
2582  return wrap(unwrap(B)->CreateFPToUI(unwrap(Val), unwrap(DestTy), Name));
2583 }
2584 
2586  LLVMTypeRef DestTy, const char *Name) {
2587  return wrap(unwrap(B)->CreateFPToSI(unwrap(Val), unwrap(DestTy), Name));
2588 }
2589 
2591  LLVMTypeRef DestTy, const char *Name) {
2592  return wrap(unwrap(B)->CreateUIToFP(unwrap(Val), unwrap(DestTy), Name));
2593 }
2594 
2596  LLVMTypeRef DestTy, const char *Name) {
2597  return wrap(unwrap(B)->CreateSIToFP(unwrap(Val), unwrap(DestTy), Name));
2598 }
2599 
2601  LLVMTypeRef DestTy, const char *Name) {
2602  return wrap(unwrap(B)->CreateFPTrunc(unwrap(Val), unwrap(DestTy), Name));
2603 }
2604 
2606  LLVMTypeRef DestTy, const char *Name) {
2607  return wrap(unwrap(B)->CreateFPExt(unwrap(Val), unwrap(DestTy), Name));
2608 }
2609 
2611  LLVMTypeRef DestTy, const char *Name) {
2612  return wrap(unwrap(B)->CreatePtrToInt(unwrap(Val), unwrap(DestTy), Name));
2613 }
2614 
2616  LLVMTypeRef DestTy, const char *Name) {
2617  return wrap(unwrap(B)->CreateIntToPtr(unwrap(Val), unwrap(DestTy), Name));
2618 }
2619 
2621  LLVMTypeRef DestTy, const char *Name) {
2622  return wrap(unwrap(B)->CreateBitCast(unwrap(Val), unwrap(DestTy), Name));
2623 }
2624 
2626  LLVMTypeRef DestTy, const char *Name) {
2627  return wrap(unwrap(B)->CreateAddrSpaceCast(unwrap(Val), unwrap(DestTy), Name));
2628 }
2629 
2631  LLVMTypeRef DestTy, const char *Name) {
2632  return wrap(unwrap(B)->CreateZExtOrBitCast(unwrap(Val), unwrap(DestTy),
2633  Name));
2634 }
2635 
2637  LLVMTypeRef DestTy, const char *Name) {
2638  return wrap(unwrap(B)->CreateSExtOrBitCast(unwrap(Val), unwrap(DestTy),
2639  Name));
2640 }
2641 
2643  LLVMTypeRef DestTy, const char *Name) {
2644  return wrap(unwrap(B)->CreateTruncOrBitCast(unwrap(Val), unwrap(DestTy),
2645  Name));
2646 }
2647 
2649  LLVMTypeRef DestTy, const char *Name) {
2650  return wrap(unwrap(B)->CreateCast(Instruction::CastOps(map_from_llvmopcode(Op)), unwrap(Val),
2651  unwrap(DestTy), Name));
2652 }
2653 
2655  LLVMTypeRef DestTy, const char *Name) {
2656  return wrap(unwrap(B)->CreatePointerCast(unwrap(Val), unwrap(DestTy), Name));
2657 }
2658 
2660  LLVMTypeRef DestTy, const char *Name) {
2661  return wrap(unwrap(B)->CreateIntCast(unwrap(Val), unwrap(DestTy),
2662  /*isSigned*/true, Name));
2663 }
2664 
2666  LLVMTypeRef DestTy, const char *Name) {
2667  return wrap(unwrap(B)->CreateFPCast(unwrap(Val), unwrap(DestTy), Name));
2668 }
2669 
2670 /*--.. Comparisons .........................................................--*/
2671 
2673  LLVMValueRef LHS, LLVMValueRef RHS,
2674  const char *Name) {
2675  return wrap(unwrap(B)->CreateICmp(static_cast<ICmpInst::Predicate>(Op),
2676  unwrap(LHS), unwrap(RHS), Name));
2677 }
2678 
2680  LLVMValueRef LHS, LLVMValueRef RHS,
2681  const char *Name) {
2682  return wrap(unwrap(B)->CreateFCmp(static_cast<FCmpInst::Predicate>(Op),
2683  unwrap(LHS), unwrap(RHS), Name));
2684 }
2685 
2686 /*--.. Miscellaneous instructions ..........................................--*/
2687 
2689  return wrap(unwrap(B)->CreatePHI(unwrap(Ty), 0, Name));
2690 }
2691 
2693  LLVMValueRef *Args, unsigned NumArgs,
2694  const char *Name) {
2695  return wrap(unwrap(B)->CreateCall(unwrap(Fn),
2696  makeArrayRef(unwrap(Args), NumArgs),
2697  Name));
2698 }
2699 
2701  LLVMValueRef Then, LLVMValueRef Else,
2702  const char *Name) {
2703  return wrap(unwrap(B)->CreateSelect(unwrap(If), unwrap(Then), unwrap(Else),
2704  Name));
2705 }
2706 
2708  LLVMTypeRef Ty, const char *Name) {
2709  return wrap(unwrap(B)->CreateVAArg(unwrap(List), unwrap(Ty), Name));
2710 }
2711 
2713  LLVMValueRef Index, const char *Name) {
2714  return wrap(unwrap(B)->CreateExtractElement(unwrap(VecVal), unwrap(Index),
2715  Name));
2716 }
2717 
2719  LLVMValueRef EltVal, LLVMValueRef Index,
2720  const char *Name) {
2721  return wrap(unwrap(B)->CreateInsertElement(unwrap(VecVal), unwrap(EltVal),
2722  unwrap(Index), Name));
2723 }
2724 
2727  const char *Name) {
2728  return wrap(unwrap(B)->CreateShuffleVector(unwrap(V1), unwrap(V2),
2729  unwrap(Mask), Name));
2730 }
2731 
2733  unsigned Index, const char *Name) {
2734  return wrap(unwrap(B)->CreateExtractValue(unwrap(AggVal), Index, Name));
2735 }
2736 
2738  LLVMValueRef EltVal, unsigned Index,
2739  const char *Name) {
2740  return wrap(unwrap(B)->CreateInsertValue(unwrap(AggVal), unwrap(EltVal),
2741  Index, Name));
2742 }
2743 
2745  const char *Name) {
2746  return wrap(unwrap(B)->CreateIsNull(unwrap(Val), Name));
2747 }
2748 
2750  const char *Name) {
2751  return wrap(unwrap(B)->CreateIsNotNull(unwrap(Val), Name));
2752 }
2753 
2755  LLVMValueRef RHS, const char *Name) {
2756  return wrap(unwrap(B)->CreatePtrDiff(unwrap(LHS), unwrap(RHS), Name));
2757 }
2758 
2760  LLVMValueRef PTR, LLVMValueRef Val,
2761  LLVMAtomicOrdering ordering,
2762  LLVMBool singleThread) {
2763  AtomicRMWInst::BinOp intop;
2764  switch (op) {
2765  case LLVMAtomicRMWBinOpXchg: intop = AtomicRMWInst::Xchg; break;
2766  case LLVMAtomicRMWBinOpAdd: intop = AtomicRMWInst::Add; break;
2767  case LLVMAtomicRMWBinOpSub: intop = AtomicRMWInst::Sub; break;
2768  case LLVMAtomicRMWBinOpAnd: intop = AtomicRMWInst::And; break;
2769  case LLVMAtomicRMWBinOpNand: intop = AtomicRMWInst::Nand; break;
2770  case LLVMAtomicRMWBinOpOr: intop = AtomicRMWInst::Or; break;
2771  case LLVMAtomicRMWBinOpXor: intop = AtomicRMWInst::Xor; break;
2772  case LLVMAtomicRMWBinOpMax: intop = AtomicRMWInst::Max; break;
2773  case LLVMAtomicRMWBinOpMin: intop = AtomicRMWInst::Min; break;
2774  case LLVMAtomicRMWBinOpUMax: intop = AtomicRMWInst::UMax; break;
2775  case LLVMAtomicRMWBinOpUMin: intop = AtomicRMWInst::UMin; break;
2776  }
2777  return wrap(unwrap(B)->CreateAtomicRMW(intop, unwrap(PTR), unwrap(Val),
2778  mapFromLLVMOrdering(ordering), singleThread ? SingleThread : CrossThread));
2779 }
2780 
2781 
2782 /*===-- Module providers --------------------------------------------------===*/
2783 
2786  return reinterpret_cast<LLVMModuleProviderRef>(M);
2787 }
2788 
2790  delete unwrap(MP);
2791 }
2792 
2793 
2794 /*===-- Memory buffers ----------------------------------------------------===*/
2795 
2797  const char *Path,
2798  LLVMMemoryBufferRef *OutMemBuf,
2799  char **OutMessage) {
2800 
2802  if (std::error_code EC = MBOrErr.getError()) {
2803  *OutMessage = strdup(EC.message().c_str());
2804  return 1;
2805  }
2806  *OutMemBuf = wrap(MBOrErr.get().release());
2807  return 0;
2808 }
2809 
2811  char **OutMessage) {
2813  if (std::error_code EC = MBOrErr.getError()) {
2814  *OutMessage = strdup(EC.message().c_str());
2815  return 1;
2816  }
2817  *OutMemBuf = wrap(MBOrErr.get().release());
2818  return 0;
2819 }
2820 
2822  const char *InputData,
2823  size_t InputDataLength,
2824  const char *BufferName,
2825  LLVMBool RequiresNullTerminator) {
2826 
2827  return wrap(MemoryBuffer::getMemBuffer(StringRef(InputData, InputDataLength),
2828  StringRef(BufferName),
2829  RequiresNullTerminator).release());
2830 }
2831 
2833  const char *InputData,
2834  size_t InputDataLength,
2835  const char *BufferName) {
2836 
2837  return wrap(
2838  MemoryBuffer::getMemBufferCopy(StringRef(InputData, InputDataLength),
2839  StringRef(BufferName)).release());
2840 }
2841 
2843  return unwrap(MemBuf)->getBufferStart();
2844 }
2845 
2847  return unwrap(MemBuf)->getBufferSize();
2848 }
2849 
2851  delete unwrap(MemBuf);
2852 }
2853 
2854 /*===-- Pass Registry -----------------------------------------------------===*/
2855 
2858 }
2859 
2860 /*===-- Pass Manager ------------------------------------------------------===*/
2861 
2863  return wrap(new legacy::PassManager());
2864 }
2865 
2867  return wrap(new legacy::FunctionPassManager(unwrap(M)));
2868 }
2869 
2872  reinterpret_cast<LLVMModuleRef>(P));
2873 }
2874 
2876  return unwrap<legacy::PassManager>(PM)->run(*unwrap(M));
2877 }
2878 
2880  return unwrap<legacy::FunctionPassManager>(FPM)->doInitialization();
2881 }
2882 
2884  return unwrap<legacy::FunctionPassManager>(FPM)->run(*unwrap<Function>(F));
2885 }
2886 
2888  return unwrap<legacy::FunctionPassManager>(FPM)->doFinalization();
2889 }
2890 
2892  delete unwrap(PM);
2893 }
2894 
2895 /*===-- Threading ------------------------------------------------------===*/
2896 
2898  return LLVMIsMultithreaded();
2899 }
2900 
2902 }
2903 
2905  return llvm_is_multithreaded();
2906 }
LLVMValueRef LLVMConstExactSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1093
LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty, const char *AsmString, const char *Constraints, LLVMBool HasSideEffects, LLVMBool IsAlignStack)
Definition: Core.cpp:1325
Subtract a value and return the old one.
Definition: Core.h:394
static unsigned getBitWidth(Type *Ty, const DataLayout &DL)
Returns the bitwidth of the given scalar or pointer type (if unknown returns 0).
const char * LLVMGetBufferStart(LLVMMemoryBufferRef MemBuf)
Definition: Core.cpp:2842
static Constant * getFPTrunc(Constant *C, Type *Ty, bool OnlyIfReduced=false)
Definition: Constants.cpp:1741
void LLVMDisposeBuilder(LLVMBuilderRef Builder)
Definition: Core.cpp:2193
unsigned LLVMGetMDNodeNumOperands(LLVMValueRef V)
Obtain the number of operands from an MDNode value.
Definition: Core.cpp:775
X86 MMX.
Definition: Core.h:271
use_iterator use_end()
Definition: Value.h:281
LLVMValueRef LLVMConstNamedStruct(LLVMTypeRef StructTy, LLVMValueRef *ConstantVals, unsigned Count)
Create a non-anonymous ConstantStruct from values.
Definition: Core.cpp:946
use_iterator_impl< Use > use_iterator
Definition: Value.h:277
7: Labels
Definition: Type.h:63
LLVMValueRef LLVMInstructionClone(LLVMValueRef Inst)
Create a copy of 'this' instruction that is identical in all ways except the following: ...
Definition: Core.cpp:2026
LLVMRealPredicate LLVMGetFCmpPredicate(LLVMValueRef Inst)
Obtain the float predicate of an instruction.
Definition: Core.cpp:2011
std::error_code getError() const
Definition: ErrorOr.h:178
struct LLVMOpaqueType * LLVMTypeRef
Each value in the LLVM IR has a type, an LLVMTypeRef.
Definition: Core.h:85
LLVMBasicBlockRef LLVMInsertBasicBlockInContext(LLVMContextRef C, LLVMBasicBlockRef BBRef, const char *Name)
Insert a basic block in a function before another basic block.
Definition: Core.cpp:1932
Represents either an error or a value T.
Definition: ErrorOr.h:82
void LLVMGetStructElementTypes(LLVMTypeRef StructTy, LLVMTypeRef *Dest)
Get the elements within a structure.
Definition: Core.cpp:457
void LLVMGetParams(LLVMValueRef FnRef, LLVMValueRef *ParamRefs)
Obtain the parameters in a function.
Definition: Core.cpp:1778
LLVMValueRef LLVMGetInitializer(LLVMValueRef GlobalVar)
Definition: Core.cpp:1562
LLVMValueRef LLVMBuildICmp(LLVMBuilderRef B, LLVMIntPredicate Op, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:2672
static Constant * getString(LLVMContext &Context, StringRef Initializer, bool AddNull=true)
getString - This method constructs a CDS and initializes it with a text string.
Definition: Constants.cpp:2612
static Type * getDoubleTy(LLVMContext &C)
Definition: Type.cpp:229
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
static IntegerType * getInt1Ty(LLVMContext &C)
Definition: Type.cpp:236
unsigned LLVMGetPointerAddressSpace(LLVMTypeRef PointerTy)
Obtain the address space of a pointer type.
Definition: Core.cpp:503
static Constant * getFAdd(Constant *C1, Constant *C2)
Definition: Constants.cpp:2265
void addIncoming(Value *V, BasicBlock *BB)
addIncoming - Add an incoming value to the end of the PHI list
Special purpose, only applies to global arrays.
Definition: GlobalValue.h:46
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
static MDNode * extractMDNode(MetadataAsValue *MAV)
Definition: Core.cpp:580
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
Definition: Function.cpp:223
*p = old <signed v ? old : v
Definition: Instructions.h:704
LLVMValueRef LLVMBuildArrayAlloca(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Val, const char *Name)
Definition: Core.cpp:2475
LLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1129
LLVMValueRef LLVMBuildZExt(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:2570
static LLVMValueRef getMDNodeOperandImpl(LLVMContext &Context, const MDNode *N, unsigned Index)
Definition: Core.cpp:647
LLVMBasicBlockRef LLVMGetEntryBasicBlock(LLVMValueRef Fn)
Obtain the basic block that corresponds to the entry point of a function.
Definition: Core.cpp:1886
LLVMValueRef LLVMGetLastFunction(LLVMModuleRef M)
Obtain an iterator to the last Function in a Module.
Definition: Core.cpp:1666
LLVMValueRef LLVMConstBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition: Core.cpp:1235
LLVM Argument representation.
Definition: Argument.h:35
Not-And a value and return the old one.
Definition: Core.h:396
LLVMValueRef LLVMConstUDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1083
Externally visible function.
Definition: Core.h:275
LLVMBool LLVMTypeIsSized(LLVMTypeRef Ty)
Whether the type has a known size.
Definition: Core.cpp:269
LLVMValueRef LLVMConstSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1088
void LLVMSetSection(LLVMValueRef Global, const char *Section)
Definition: Core.cpp:1442
void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align)
Set the alignment for a function parameter.
Definition: Core.cpp:1847
size_t size() const
size - Get the string size.
Definition: StringRef.h:113
LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRangeCopy(const char *InputData, size_t InputDataLength, const char *BufferName)
Definition: Core.cpp:2832
LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count)
Obtain a MDNode value from the global context.
Definition: Core.cpp:761
provides both an Acquire and a Release barrier (for fences and operations which both read and write m...
Definition: Core.h:377
LLVMValueRef LLVMGetIncomingValue(LLVMValueRef PhiNode, unsigned Index)
Obtain an incoming value to a PHI node as an LLVMValueRef.
Definition: Core.cpp:2140
static Constant * getNSWAdd(Constant *C1, Constant *C2)
Definition: Constants.h:939
static const fltSemantics IEEEdouble
Definition: APFloat.h:133
void initializePrintModulePassWrapperPass(PassRegistry &)
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:114
struct LLVMOpaqueMemoryBuffer * LLVMMemoryBufferRef
Used to pass regions of memory through LLVM interfaces.
Definition: Support.h:36
void LLVMSetSuccessor(LLVMValueRef Term, unsigned i, LLVMBasicBlockRef block)
Update the specified successor to point at the provided block.
Definition: Core.cpp:2103
LLVMValueRef LLVMBuildAdd(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:2292
LLVMBuilderRef LLVMCreateBuilder(void)
Definition: Core.cpp:2155
Obsolete.
Definition: Core.h:288
LLVMValueRef LLVMGetNextParam(LLVMValueRef Arg)
Obtain the next parameter to a function.
Definition: Core.cpp:1812
2: 32-bit floating point type
Definition: Type.h:58
iterator end()
Definition: Function.h:459
Same, but only replaced by something equivalent.
Definition: GlobalValue.h:45
LLVMValueRef LLVMBuildNUWAdd(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:2302
static MDString * get(LLVMContext &Context, StringRef Str)
Definition: Metadata.cpp:360
LLVMValueRef LLVMBuildStructGEP(LLVMBuilderRef B, LLVMValueRef Pointer, unsigned Idx, const char *Name)
Definition: Core.cpp:2534
LLVMValueRef LLVMGetNamedGlobal(LLVMModuleRef M, const char *Name)
Definition: Core.cpp:1522
LLVMBool LLVMIsOpaqueStruct(LLVMTypeRef StructTy)
Determine whether a structure is opaque.
Definition: Core.cpp:473
LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRange(const char *InputData, size_t InputDataLength, const char *BufferName, LLVMBool RequiresNullTerminator)
Definition: Core.cpp:2821
static Constant * getAnon(ArrayRef< Constant * > V, bool Packed=false)
getAnon - Return an anonymous struct that has the specified elements.
Definition: Constants.h:418
LLVMValueRef LLVMGetFirstParam(LLVMValueRef Fn)
Obtain the first parameter to a function.
Definition: Core.cpp:1796
LLVMValueRef LLVMBuildSExt(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:2575
LLVMValueRef LLVMAddAlias(LLVMModuleRef M, LLVMTypeRef Ty, LLVMValueRef Aliasee, const char *Name)
Definition: Core.cpp:1639
LLVMValueRef LLVMAlignOf(LLVMTypeRef Ty)
Definition: Core.cpp:988
LLVMBool LLVMHasUnnamedAddr(LLVMValueRef Global)
Definition: Core.cpp:1466
Available for inspection, not emission.
Definition: GlobalValue.h:41
void LLVMStopMultithreaded()
Deprecated: Multi-threading can only be enabled/disabled with the compile time define LLVM_ENABLE_THR...
Definition: Core.cpp:2901
LLVMOpcode
Definition: Core.h:176
LLVMValueRef LLVMConstRealOfStringAndSize(LLVMTypeRef RealTy, const char Str[], unsigned SLen)
Definition: Core.cpp:862
void LLVMSetValueName(LLVMValueRef Val, const char *Name)
Set the string name of a value.
Definition: Core.cpp:539
static Constant * getAddrSpaceCast(Constant *C, Type *Ty, bool OnlyIfReduced=false)
Definition: Constants.cpp:1847
LLVMValueRef LLVMConstFPToUI(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition: Core.cpp:1215
void clearGC()
Definition: Function.cpp:399
Type::subtype_iterator param_iterator
Definition: DerivedTypes.h:123
const char * LLVMGetGC(LLVMValueRef Fn)
Obtain the name of the garbage collector to use during code generation.
Definition: Core.cpp:1717
LLVMPassManagerRef LLVMCreateFunctionPassManager(LLVMModuleProviderRef P)
Deprecated: Use LLVMCreateFunctionPassManagerForModule instead.
Definition: Core.cpp:2870
LLVMValueRef LLVMAddGlobal(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name)
Definition: Core.cpp:1508
void LLVMAddAttribute(LLVMValueRef Arg, LLVMAttribute PA)
Add an attribute to a function argument.
Definition: Core.cpp:1828
LLVMTypeRef LLVMHalfType(void)
Obtain a floating point type from the global context.
Definition: Core.cpp:370
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:2222
LLVMBasicBlockRef LLVMGetNextBasicBlock(LLVMBasicBlockRef BB)
Advance a basic block iterator.
Definition: Core.cpp:1906
LLVMBool LLVMCreateMemoryBufferWithContentsOfFile(const char *Path, LLVMMemoryBufferRef *OutMemBuf, char **OutMessage)
Definition: Core.cpp:2796
A global registry used in conjunction with static constructors to make pluggable components (like tar...
Definition: Registry.h:61
char * LLVMCreateMessage(const char *Message)
Definition: Core.cpp:65
LLVMPassManagerRef LLVMCreatePassManager()
Constructs a new whole-module pass pipeline.
Definition: Core.cpp:2862
const char * getGC() const
Definition: Function.cpp:384
void addOperand(MDNode *M)
Definition: Metadata.cpp:971
LLVMTypeRef LLVMFP128Type(void)
Definition: Core.cpp:382
CallInst - This class represents a function call, abstracting a target machine's calling convention...
static Constant * getExactSDiv(Constant *C1, Constant *C2)
Definition: Constants.h:963
LLVMValueRef LLVMBuildFPToUI(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:2580
static PointerType * get(Type *ElementType, unsigned AddressSpace)
PointerType::get - This constructs a pointer to an object of the specified type in a numbered address...
Definition: Type.cpp:738
#define LLVM_FOR_EACH_VALUE_SUBCLASS(macro)
Definition: Core.h:1164
unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy)
Obtain the number of elements in a vector type.
Definition: Core.cpp:507
void(* LLVMDiagnosticHandler)(LLVMDiagnosticInfoRef, void *)
Definition: Core.h:473
LLVMDiagnosticSeverity LLVMGetDiagInfoSeverity(LLVMDiagnosticInfoRef DI)
Return an enum LLVMDiagnosticSeverity.
Definition: Core.cpp:123
*p = old <unsigned v ? old : v
Definition: Instructions.h:708
static Constant * getIntToPtr(Constant *C, Type *Ty, bool OnlyIfReduced=false)
Definition: Constants.cpp:1822
static Constant * getGetElementPtr(Type *Ty, Constant *C, ArrayRef< Constant * > IdxList, bool InBounds=false, Type *OnlyIfReducedTy=nullptr)
Getelementptr form.
Definition: Constants.h:1092
static Constant * getExtractElement(Constant *Vec, Constant *Idx, Type *OnlyIfReducedTy=nullptr)
Definition: Constants.cpp:2123
LLVMValueRef LLVMBuildCondBr(LLVMBuilderRef B, LLVMValueRef If, LLVMBasicBlockRef Then, LLVMBasicBlockRef Else)
Definition: Core.cpp:2235
Like Internal, but omit from symbol table.
Definition: GlobalValue.h:48
LLVMTypeRef LLVMX86MMXType(void)
Definition: Core.cpp:388
*p = old >unsigned v ? old : v
Definition: Instructions.h:706
Externally visible function.
Definition: GlobalValue.h:40
LLVMValueRef LLVMBuildFNeg(LLVMBuilderRef B, LLVMValueRef V, const char *Name)
Definition: Core.cpp:2438
LLVMValueRef LLVMBuildTruncOrBitCast(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:2642
void setAttributes(const AttributeSet &PAL)
Definition: CallSite.h:232
const Function * getParent() const
Return the enclosing method, or null if none.
Definition: BasicBlock.h:111
LLVMValueRef LLVMBuildSDiv(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:2357
arg_iterator arg_end()
Definition: Function.h:480
12: Structures
Definition: Type.h:71
LLVMTypeRef LLVMX86FP80Type(void)
Definition: Core.cpp:379
LLVMUseRef LLVMGetFirstUse(LLVMValueRef Val)
Obtain the first use of a value.
Definition: Core.cpp:622
A debug info location.
Definition: DebugLoc.h:34
Metadata node.
Definition: Metadata.h:740
void LLVMClearInsertionPosition(LLVMBuilderRef Builder)
Definition: Core.cpp:2180
LLVMValueRef LLVMGetNextGlobal(LLVMValueRef GlobalVar)
Definition: Core.cpp:1542
F(f)
4: 80-bit floating point type (X87)
Definition: Type.h:60
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:491
LLVMValueRef LLVMConstAnd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1119
unsigned LLVMGetMDKindIDInContext(LLVMContextRef C, const char *Name, unsigned SLen)
Definition: Core.cpp:103
LLVMPassRegistryRef LLVMGetGlobalPassRegistry(void)
Return the global pass registry, for use with initialization functions.
Definition: Core.cpp:2856
LLVMValueRef LLVMBuildCast(LLVMBuilderRef B, LLVMOpcode Op, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:2648
LLVMValueRef LLVMBuildFRem(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:2382
LoadInst - an instruction for reading from memory.
Definition: Instructions.h:177
LLVMValueRef LLVMConstSelect(LLVMValueRef ConstantCondition, LLVMValueRef ConstantIfTrue, LLVMValueRef ConstantIfFalse)
Definition: Core.cpp:1281
1: 16-bit floating point type
Definition: Type.h:57
LLVMAttribute
Definition: Core.h:133
LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition: Core.cpp:1180
unsigned getBitWidth() const
Get the number of bits in this IntegerType.
Definition: DerivedTypes.h:61
LLVMBool LLVMValueIsBasicBlock(LLVMValueRef Val)
Determine whether an LLVMValueRef is itself a basic block.
Definition: Core.cpp:1860
static IntegerType * getInt64Ty(LLVMContext &C)
Definition: Type.cpp:240
FunctionType * getType(LLVMContext &Context, ID id, ArrayRef< Type * > Tys=None)
Return the function type for an intrinsic.
Definition: Function.cpp:822
LLVMTypeRef LLVMStructTypeInContext(LLVMContextRef C, LLVMTypeRef *ElementTypes, unsigned ElementCount, LLVMBool Packed)
Create a new structure type in a context.
Definition: Core.cpp:422
AttrBuilder & addAttribute(Attribute::AttrKind Val)
Add an attribute to the builder.
LLVMBasicBlockRef LLVMInsertBasicBlock(LLVMBasicBlockRef BBRef, const char *Name)
Insert a basic block in a function using the global context.
Definition: Core.cpp:1939
int LLVMHasMetadata(LLVMValueRef Inst)
Determine whether an instruction has any metadata attached.
Definition: Core.cpp:565
static Constant * getSub(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
Definition: Constants.cpp:2269
const char * LLVMGetSection(LLVMValueRef Global)
Definition: Core.cpp:1438
static Instruction * CreateFree(Value *Source, Instruction *InsertBefore)
CreateFree - Generate the IR for a call to the builtin free function.
LLVMTypeRef LLVMInt16TypeInContext(LLVMContextRef C)
Definition: Core.cpp:304
LLVMValueRef LLVMMDNodeInContext(LLVMContextRef C, LLVMValueRef *Vals, unsigned Count)
Obtain a MDNode value from a context.
Definition: Core.cpp:734
#define op(i)
LLVMValueRef LLVMBuildFence(LLVMBuilderRef B, LLVMAtomicOrdering Ordering, LLVMBool isSingleThread, const char *Name)
Definition: Core.cpp:2511
14: Pointers
Definition: Type.h:73
void initializeCore(PassRegistry &)
initializeCore - Initialize all passes linked into the TransformUtils library.
Definition: Core.cpp:47
static IntegerType * getInt16Ty(LLVMContext &C)
Definition: Type.cpp:238
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
static Type * getX86_MMXTy(LLVMContext &C)
Definition: Type.cpp:234
LLVMAtomicRMWBinOp
Definition: Core.h:391
11: Functions
Definition: Type.h:70
LLVMValueRef LLVMConstIntOfString(LLVMTypeRef IntTy, const char Str[], uint8_t Radix)
Definition: Core.cpp:842
*p = old >signed v ? old : v
Definition: Instructions.h:702
void LLVMGetNamedMetadataOperands(LLVMModuleRef M, const char *name, LLVMValueRef *Dest)
Obtain the named metadata operands for a module.
Definition: Core.cpp:805
LLVMValueRef LLVMConstAddrSpaceCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition: Core.cpp:1240
Lowest level of atomicity, guarantees somewhat sane results, lock free.
Definition: Core.h:366
Tentative definitions.
Definition: GlobalValue.h:50
void LLVMRemoveFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA)
Remove an attribute from a function.
Definition: Core.cpp:1753
static Type * getX86_FP80Ty(LLVMContext &C)
Definition: Type.cpp:231
void LLVMContextDispose(LLVMContextRef C)
Destroy a context instance.
Definition: Core.cpp:99
128 bit floating point type (112-bit mantissa)
Definition: Core.h:261
void LLVMSetGlobalConstant(LLVMValueRef GlobalVar, LLVMBool IsConstant)
Definition: Core.cpp:1586
void LLVMSetThreadLocal(LLVMValueRef GlobalVar, LLVMBool IsThreadLocal)
Definition: Core.cpp:1578
static Constant * getInsertElement(Constant *Vec, Constant *Elt, Constant *Idx, Type *OnlyIfReducedTy=nullptr)
Definition: Constants.cpp:2145
ExternalWeak linkage description.
Definition: Core.h:290
LLVMValueRef LLVMConstNull(LLVMTypeRef Ty)
Obtain a constant value referring to the null instance of a type.
Definition: Core.cpp:690
LLVMValueRef LLVMConstReal(LLVMTypeRef RealTy, double N)
Obtain a constant value referring to a double floating point value.
Definition: Core.cpp:854
LLVMValueRef LLVMBuildPointerCast(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:2654
static Constant * getNullValue(Type *Ty)
Definition: Constants.cpp:178
LLVMBool LLVMInitializeFunctionPassManager(LLVMPassManagerRef FPM)
Initializes all of the function passes scheduled in the function pass manager.
Definition: Core.cpp:2879
void LLVMSetOperand(LLVMValueRef Val, unsigned Index, LLVMValueRef Op)
Set an operand at a specific index in a llvm::User value.
Definition: Core.cpp:676
iterator begin()
Instruction iterator methods.
Definition: BasicBlock.h:231
long long LLVMConstIntGetSExtValue(LLVMValueRef ConstantVal)
Obtain the sign extended value for an integer constant value.
Definition: Core.cpp:871
static Constant * getAdd(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
Definition: Constants.cpp:2258
static Constant * getFMul(Constant *C1, Constant *C2)
Definition: Constants.cpp:2287
void addAttr(AttributeSet AS)
Add a Attribute to an argument.
Definition: Function.cpp:192
element_iterator element_end() const
Definition: DerivedTypes.h:280
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:464
LLVMOpcode LLVMGetInstructionOpcode(LLVMValueRef Inst)
Obtain the code opcode for an individual instruction.
Definition: Core.cpp:2020
LLVMTypeRef LLVMFP128TypeInContext(LLVMContextRef C)
Obtain a 128-bit floating point type (112-bit mantissa) from a context.
Definition: Core.cpp:360
const char * LLVMGetStructName(LLVMTypeRef Ty)
Obtain the name of a structure.
Definition: Core.cpp:439
LLVMBasicBlockRef LLVMGetLastBasicBlock(LLVMValueRef Fn)
Obtain the last basic block in a function.
Definition: Core.cpp:1898
Same, but only replaced by something equivalent.
Definition: Core.h:282
LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef BB)
Convert a basic block instance to a value type.
Definition: Core.cpp:1856
A tuple of MDNodes.
Definition: Metadata.h:1127
void LLVMAddFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA)
Add an attribute to a function.
Definition: Core.cpp:1730
static Constant * getIntegerCast(Constant *C, Type *Ty, bool isSigned)
Create a ZExt, Bitcast or Trunc for integer -> integer casts.
Definition: Constants.cpp:1674
LLVMTypeRef LLVMLabelTypeInContext(LLVMContextRef C)
Create a label type in a context.
Definition: Core.cpp:516
LLVMTypeRef LLVMDoubleTypeInContext(LLVMContextRef C)
Obtain a 64-bit floating point type from a context.
Definition: Core.cpp:354
LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size)
Create a ConstantVector from values.
Definition: Core.cpp:955
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:430
Set the new value and return the one old.
Definition: Core.h:392
LLVMValueRef LLVMBuildExactSDiv(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:2362
void(* LLVMYieldCallback)(LLVMContextRef, void *)
Definition: Core.h:474
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:79
Type::subtype_iterator element_iterator
Definition: DerivedTypes.h:278
LLVMValueRef LLVMSizeOf(LLVMTypeRef Ty)
Definition: Core.cpp:992
LLVMBool LLVMIsNull(LLVMValueRef Val)
Determine whether a value instance is null.
Definition: Core.cpp:706
static Type * getFloatTy(LLVMContext &C)
Definition: Type.cpp:228
LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant, LLVMValueRef VectorBConstant, LLVMValueRef MaskConstant)
Definition: Core.cpp:1303
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
Definition: ArrayRef.h:308
LLVMBasicBlockRef LLVMGetSwitchDefaultDest(LLVMValueRef Switch)
Obtain the default destination basic block of a switch instruction.
Definition: Core.cpp:2123
LLVMValueRef LLVMConstRealOfString(LLVMTypeRef RealTy, const char *Text)
Obtain a constant for a floating point value parsed from a string.
Definition: Core.cpp:858
LLVMValueRef LLVMBuildAggregateRet(LLVMBuilderRef B, LLVMValueRef *RetVals, unsigned N)
Definition: Core.cpp:2226
StructType - Class to represent struct types.
Definition: DerivedTypes.h:191
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:98
Sets the value if it's greater than the original using an unsigned comparison and return the old one...
Definition: Core.h:405
A Use represents the edge between a Value definition and its users.
Definition: Use.h:69
static Constant * getLShr(Constant *C1, Constant *C2, bool isExact=false)
Definition: Constants.cpp:2336
param_iterator param_end() const
Definition: DerivedTypes.h:125
static Constant * getNUWNeg(Constant *C)
Definition: Constants.h:938
LLVMValueRef LLVMConstIntOfStringAndSize(LLVMTypeRef IntTy, const char Str[], unsigned SLen, uint8_t Radix)
Definition: Core.cpp:848
Add a value and return the old one.
Definition: Core.h:393
void LLVMPositionBuilder(LLVMBuilderRef Builder, LLVMBasicBlockRef Block, LLVMValueRef Instr)
Definition: Core.cpp:2159
LLVMTypeRef LLVMInt8TypeInContext(LLVMContextRef C)
Definition: Core.cpp:301
unsigned LLVMGetFunctionCallConv(LLVMValueRef Fn)
Obtain the calling function of a function.
Definition: Core.cpp:1708
LLVMValueRef LLVMConstIntCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType, LLVMBool isSigned)
Definition: Core.cpp:1270
LLVMValueRef LLVMConstNUWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1028
static Constant * get(ArrayRef< Constant * > V)
Definition: Constants.cpp:1057
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
Definition: IRBuilder.h:517
void setThreadLocalMode(ThreadLocalMode Val)
Definition: GlobalValue.h:156
LLVMValueRef LLVMConstFSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1056
unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy)
Definition: Core.cpp:342
This file contains the simple types necessary to represent the attributes associated with functions a...
LLVMBool LLVMIsExternallyInitialized(LLVMValueRef GlobalVar)
Definition: Core.cpp:1629
Pointers.
Definition: Core.h:268
static Constant * getSExt(Constant *C, Type *Ty, bool OnlyIfReduced=false)
Definition: Constants.cpp:1713
LLVMValueRef LLVMConstAShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1158
LLVMValueRef LLVMGetBasicBlockParent(LLVMBasicBlockRef BB)
Obtain the function to which a basic block belongs.
Definition: Core.cpp:1868
void LLVMSetCondition(LLVMValueRef Branch, LLVMValueRef Cond)
Set the condition of a branch instruction.
Definition: Core.cpp:2117
LLVMValueRef LLVMGetLastParam(LLVMValueRef Fn)
Obtain the last parameter to a function.
Definition: Core.cpp:1804
LLVMValueRef LLVMConstICmp(LLVMIntPredicate Predicate, LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1134
element_iterator element_begin() const
Definition: DerivedTypes.h:279
LLVMValueRef LLVMGetUndef(LLVMTypeRef Ty)
Obtain a constant value referring to an undefined value of a type.
Definition: Core.cpp:698
Rename collisions when linking (static functions)
Definition: Core.h:285
Arrays.
Definition: Core.h:267
void LLVMSetVisibility(LLVMValueRef Global, LLVMVisibility Viz)
Definition: Core.cpp:1451
void LLVMAddNamedMetadataOperand(LLVMModuleRef M, const char *name, LLVMValueRef Val)
Add an operand to named metadata.
Definition: Core.cpp:815
static Type * getPPC_FP128Ty(LLVMContext &C)
Definition: Type.cpp:233
LLVMValueRef LLVMConstSExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition: Core.cpp:1185
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:1550
LLVMValueRef LLVMBuildNSWAdd(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:2297
LLVMValueRef LLVMGetElementAsConstant(LLVMValueRef c, unsigned idx)
Get an element at specified index as a constant.
Definition: Core.cpp:920
void removeAttr(AttributeSet AS)
Remove a Attribute from an argument.
Definition: Function.cpp:202
SIMD 'packed' format, or other vector type.
Definition: Core.h:269
LLVMValueRef LLVMGetFirstInstruction(LLVMBasicBlockRef BB)
Obtain the first instruction in a basic block.
Definition: Core.cpp:1966
LLVMTypeRef LLVMFloatType(void)
Definition: Core.cpp:373
AtomicOrdering
Definition: Instructions.h:38
Number of individual test Apply this number of consecutive mutations to each input If
global_iterator global_begin()
Definition: Module.h:552
void LLVMDisposeMessage(char *Message)
Definition: Core.cpp:69
A load or store which is not atomic.
Definition: Core.h:365
LLVMValueRef LLVMConstFPCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition: Core.cpp:1276
struct LLVMOpaqueModuleProvider * LLVMModuleProviderRef
Interface used to provide a module to JIT or interpreter.
Definition: Core.h:113
LLVMValueRef LLVMBuildSRem(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:2377
LLVMValueRef LLVMGetPreviousInstruction(LLVMValueRef Inst)
Obtain the instruction that occurred before this one.
Definition: Core.cpp:1990
LLVMTargetDataRef wrap(const DataLayout *P)
Definition: DataLayout.h:469
void LLVMContextSetYieldCallback(LLVMContextRef C, LLVMYieldCallback Callback, void *OpaqueHandle)
Set the yield callback function for this context.
Definition: Core.cpp:92
static Constant * getZExt(Constant *C, Type *Ty, bool OnlyIfReduced=false)
Definition: Constants.cpp:1727
void LLVMMoveBasicBlockBefore(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos)
Move a basic block to before another one.
Definition: Core.cpp:1952
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:1948
LLVMValueRef LLVMConstInsertElement(LLVMValueRef VectorConstant, LLVMValueRef ElementValueConstant, LLVMValueRef IndexConstant)
Definition: Core.cpp:1295
void LLVMGetParamTypes(LLVMTypeRef FunctionTy, LLVMTypeRef *Dest)
Obtain the types of a function's parameters.
Definition: Core.cpp:413
ConstantExpr - a constant value that is initialized with an expression using other constant values...
Definition: Constants.h:852
FunctionType - Class to represent function types.
Definition: DerivedTypes.h:96
char * LLVMPrintModuleToString(LLVMModuleRef M)
Return a string representation of the module.
Definition: Core.cpp:205
static Type * getLabelTy(LLVMContext &C)
Definition: Type.cpp:226
void LLVMDisposeModule(LLVMModuleRef M)
Destroy a module instance.
Definition: Core.cpp:158
void LLVMSetInstDebugLocation(LLVMBuilderRef Builder, LLVMValueRef Inst)
Definition: Core.cpp:2211
LLVMBool LLVMIsGlobalConstant(LLVMValueRef GlobalVar)
Definition: Core.cpp:1582
LLVMContext & getContext() const
getContext - Return the LLVMContext in which this type was uniqued.
Definition: Type.h:125
LLVMValueRef LLVMConstStructInContext(LLVMContextRef C, LLVMValueRef *ConstantVals, unsigned Count, LLVMBool Packed)
Create an anonymous ConstantStruct with the specified values.
Definition: Core.cpp:906
static Constant * getFPCast(Constant *C, Type *Ty)
Create a FPExt, Bitcast or FPTrunc for fp -> fp casts.
Definition: Constants.cpp:1687
LLVMBool LLVMIsTailCall(LLVMValueRef Call)
Obtain whether a call instruction is a tail call.
Definition: Core.cpp:2085
LLVMValueRef LLVMBlockAddress(LLVMValueRef F, LLVMBasicBlockRef BB)
Definition: Core.cpp:1333
ConstantDataSequential - A vector or array constant whose element type is a simple 1/2/4/8-byte integ...
Definition: Constants.h:557
void llvm_shutdown()
llvm_shutdown - Deallocate and destroy all ManagedStatic variables.
LLVMValueRef LLVMConstZExtOrBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition: Core.cpp:1246
BinOp
This enumeration lists the possible modifications atomicrmw can make.
Definition: Instructions.h:686
const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
Definition: StringRef.h:107
LLVMValueRef LLVMConstGEP(LLVMValueRef ConstantVal, LLVMValueRef *ConstantIndices, unsigned NumIndices)
Definition: Core.cpp:1163
LLVMValueRef LLVMConstInBoundsGEP(LLVMValueRef ConstantVal, LLVMValueRef *ConstantIndices, unsigned NumIndices)
Definition: Core.cpp:1171
Keep one copy of function when linking (inline)
Definition: Core.h:277
static Constant * getAShr(Constant *C1, Constant *C2, bool isExact=false)
Definition: Constants.cpp:2341
LLVMValueRef LLVMBuildOr(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:2407
void LLVMDeleteFunction(LLVMValueRef Fn)
Remove a function from its containing module and deletes it.
Definition: Core.cpp:1690
LLVMValueRef LLVMBuildFDiv(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:2367
LLVMValueRef LLVMConstFPToSI(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition: Core.cpp:1220
OR a value and return the old one.
Definition: Core.h:397
LLVMBasicBlockRef LLVMGetPreviousBasicBlock(LLVMBasicBlockRef BB)
Go backwards in a basic block iterator.
Definition: Core.cpp:1914
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:2012
LLVMValueRef LLVMGetFirstGlobal(LLVMModuleRef M)
Definition: Core.cpp:1526
void LLVMDumpModule(LLVMModuleRef M)
Dump a representation of a module to stderr.
Definition: Core.cpp:180
static FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)
FunctionType::get - This static method is the primary way of constructing a FunctionType.
Definition: Type.cpp:361
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: ArrayRef.h:31
unsigned LLVMCountIncoming(LLVMValueRef PhiNode)
Obtain the number of incoming basic blocks to a PHI node.
Definition: Core.cpp:2136
double convertToDouble() const
Definition: APFloat.cpp:3116
LLVMValueRef LLVMBuildIntCast(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:2659
LLVMTypeRef LLVMFloatTypeInContext(LLVMContextRef C)
Obtain a 32-bit floating point type from a context.
Definition: Core.cpp:351
unsigned long long LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal)
Obtain the zero extended value for an integer constant value.
Definition: Core.cpp:867
static int map_from_llvmopcode(LLVMOpcode code)
Definition: Core.cpp:972
StoreInst - an instruction for storing to memory.
Definition: Instructions.h:316
void LLVMGetMDNodeOperands(LLVMValueRef V, LLVMValueRef *Dest)
Obtain the given MDNode's operands.
Definition: Core.cpp:783
LLVMValueRef LLVMConstFMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1078
LLVMValueRef LLVMGetLastInstruction(LLVMBasicBlockRef BB)
Obtain the last instruction in a basic block.
Definition: Core.cpp:1974
LLVMValueRef LLVMBuildSub(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:2312
#define LLVM_EXTENSION
LLVM_EXTENSION - Support compilers where we have a keyword to suppress pedantic diagnostics.
Definition: Compiler.h:228
LLVMUseRef LLVMGetNextUse(LLVMUseRef U)
Obtain the next use of a value.
Definition: Core.cpp:630
LLVMValueRef LLVMAddFunction(LLVMModuleRef M, const char *Name, LLVMTypeRef FunctionTy)
Add a function to a module under a specified name.
Definition: Core.cpp:1648
LLVMValueRef LLVMBuildFAdd(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:2307
static Constant * getUDiv(Constant *C1, Constant *C2, bool isExact=false)
Definition: Constants.cpp:2291
static Constant * getNSWNeg(Constant *C)
Definition: Constants.h:937
Keep one copy of function when linking (weak)
Definition: Core.h:281
unsigned LLVMCountParamTypes(LLVMTypeRef FunctionTy)
Obtain the number of parameters this function accepts.
Definition: Core.cpp:409
LLVMIntPredicate
Definition: Core.h:319
LLVMValueRef LLVMBuildNUWSub(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:2322
iterator begin()
Definition: Function.h:457
static ConstantAsMetadata * get(Constant *C)
Definition: Metadata.h:318
LLVMValueRef LLVMBuildPtrToInt(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:2610
LLVMDiagnosticSeverity
Definition: Core.h:413
static Constant * getFDiv(Constant *C1, Constant *C2)
Definition: Constants.cpp:2301
LLVMTypeRef LLVMStructCreateNamed(LLVMContextRef C, const char *Name)
Create an empty structure in a context having a specified name.
Definition: Core.cpp:434
LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N, LLVMBool SignExtend)
Obtain a constant value for an integer type.
Definition: Core.cpp:828
static BinaryOperator * CreateAdd(Value *S1, Value *S2, const Twine &Name, Instruction *InsertBefore, Value *FlagsOp)
size_t LLVMGetBufferSize(LLVMMemoryBufferRef MemBuf)
Definition: Core.cpp:2846
LLVMValueRef LLVMBuildAnd(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:2402
void LLVMSetLinkage(LLVMValueRef Global, LLVMLinkage Linkage)
Definition: Core.cpp:1376
void initializePrintBasicBlockPassPass(PassRegistry &)
unsigned LLVMGetIntrinsicID(LLVMValueRef Fn)
Obtain the ID number from a function instance.
Definition: Core.cpp:1702
void LLVMAddTargetDependentFunctionAttr(LLVMValueRef Fn, const char *A, const char *V)
Add a target-dependent attribute to a fuction.
Definition: Core.cpp:1741
LLVMBasicBlockRef LLVMGetInstructionParent(LLVMValueRef Inst)
Obtain the basic block to which an instruction belongs.
Definition: Core.cpp:1962
LLVMTypeRef LLVMInt64TypeInContext(LLVMContextRef C)
Definition: Core.cpp:310
LLVMValueRef LLVMGetLastGlobal(LLVMModuleRef M)
Definition: Core.cpp:1534
LLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1017
unsigned LLVMGetArrayLength(LLVMTypeRef ArrayTy)
Obtain the length of an array type.
Definition: Core.cpp:499
void LLVMDisposePassManager(LLVMPassManagerRef PM)
Frees the memory of a pass pipeline.
Definition: Core.cpp:2891
LLVMValueRef LLVMBuildIsNull(LLVMBuilderRef B, LLVMValueRef Val, const char *Name)
Definition: Core.cpp:2744
void LLVMSetVolatile(LLVMValueRef MemAccessInst, LLVMBool isVolatile)
Definition: Core.cpp:2556
LLVMTypeRef LLVMVoidTypeInContext(LLVMContextRef C)
Create a void type in a context.
Definition: Core.cpp:513
10: Arbitrary bit width integers
Definition: Type.h:69
static MetadataAsValue * get(LLVMContext &Context, Metadata *MD)
Definition: Metadata.cpp:75
PassManager manages ModulePassManagers.
static Constant * getBitCast(Constant *C, Type *Ty, bool OnlyIfReduced=false)
Definition: Constants.cpp:1835
#define LLVM_DEFINE_VALUE_CAST(name)
Definition: Core.cpp:599
ExternalWeak linkage description.
Definition: GlobalValue.h:49
void LLVMSetUnnamedAddr(LLVMValueRef Global, LLVMBool HasUnnamedAddr)
Definition: Core.cpp:1470
A self-contained host- and target-independent arbitrary-precision floating-point software implementat...
Definition: APFloat.h:122
LLVMValueRef LLVMConstNSWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1022
LLVMValueRef LLVMConstNSWNeg(LLVMValueRef ConstantVal)
Definition: Core.cpp:1000
void LLVMSetTarget(LLVMModuleRef M, const char *Triple)
Set the target triple for a module.
Definition: Core.cpp:176
static Constant * getInsertValue(Constant *Agg, Constant *Val, ArrayRef< unsigned > Idxs, Type *OnlyIfReducedTy=nullptr)
Definition: Constants.cpp:2191
0: type with no size
Definition: Type.h:56
#define P(N)
Same, but only replaced by something equivalent.
Definition: GlobalValue.h:43
static Constant * getFNeg(Constant *C)
Definition: Constants.cpp:2246
LLVMBasicBlockRef LLVMGetFirstBasicBlock(LLVMValueRef Fn)
Obtain the first basic block in a function.
Definition: Core.cpp:1890
LLVMValueRef LLVMBuildNUWNeg(LLVMBuilderRef B, LLVMValueRef V, const char *Name)
Definition: Core.cpp:2433
void LLVMSetCurrentDebugLocation(LLVMBuilderRef Builder, LLVMValueRef L)
Definition: Core.cpp:2199
static Constant * getFRem(Constant *C1, Constant *C2)
Definition: Constants.cpp:2313
void LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder, LLVMBasicBlockRef Block)
Definition: Core.cpp:2171
void LLVMStructSetBody(LLVMTypeRef StructTy, LLVMTypeRef *ElementTypes, unsigned ElementCount, LLVMBool Packed)
Set the contents of a structure type.
Definition: Core.cpp:447
LLVMValueRef LLVMBuildShl(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:2387
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:241
Acquire provides a barrier of the sort necessary to acquire a lock to access other memory with normal...
Definition: Core.h:371
DataLayout * unwrap(LLVMTargetDataRef P)
Definition: DataLayout.h:465
static Constant * getInBoundsGetElementPtr(Type *Ty, Constant *C, ArrayRef< Constant * > IdxList)
Create an "inbounds" getelementptr.
Definition: Constants.h:1115
LLVMTypeKind
Definition: Core.h:255
LLVMValueRef LLVMBuildInsertElement(LLVMBuilderRef B, LLVMValueRef VecVal, LLVMValueRef EltVal, LLVMValueRef Index, const char *Name)
Definition: Core.cpp:2718
static ConstantPointerNull * get(PointerType *T)
get() - Static factory methods - Return objects of the specified value
Definition: Constants.cpp:1455
LLVMValueRef LLVMBuildAlloca(LLVMBuilderRef B, LLVMTypeRef Ty, const char *Name)
Definition: Core.cpp:2470
LLVMAtomicOrdering
Definition: Core.h:364
LLVMTypeRef LLVMInt32Type(void)
Definition: Core.cpp:329
LLVMValueRef LLVMBuildPhi(LLVMBuilderRef B, LLVMTypeRef Ty, const char *Name)
Definition: Core.cpp:2688
LLVM Basic Block Representation.
Definition: BasicBlock.h:65
LLVMValueRef LLVMIsAMDString(LLVMValueRef Val)
Definition: Core.cpp:614
Sets the value if it's greater than the original using an unsigned comparison and return the old one...
Definition: Core.h:408
LLVMValueRef LLVMGetMetadata(LLVMValueRef Inst, unsigned KindID)
Return metadata associated with an instruction value.
Definition: Core.cpp:569
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:45
void LLVMAddClause(LLVMValueRef LandingPad, LLVMValueRef ClauseVal)
Definition: Core.cpp:2281
unsigned LLVMCountBasicBlocks(LLVMValueRef FnRef)
Obtain the number of basic blocks in a function.
Definition: Core.cpp:1876
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:41
const Function * getParent() const
Definition: Argument.h:49
LLVMBool LLVMIsPackedStruct(LLVMTypeRef StructTy)
Determine whether a structure is packed.
Definition: Core.cpp:469
void LLVMReplaceAllUsesWith(LLVMValueRef OldVal, LLVMValueRef NewVal)
Replace all uses of a value with another one.
Definition: Core.cpp:561
LLVMValueRef LLVMBuildFPToSI(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:2585
LLVMBool LLVMStartMultithreaded()
Deprecated: Multi-threading can only be enabled/disabled with the compile time define LLVM_ENABLE_THR...
Definition: Core.cpp:2897
static GlobalAlias * create(PointerType *Ty, 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:243
LLVMContextRef LLVMGetModuleContext(LLVMModuleRef M)
Obtain the context to which this module is associated.
Definition: Core.cpp:222
LLVMValueRef LLVMConstFDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1099
static BlockAddress * get(Function *F, BasicBlock *BB)
get - Return a BlockAddress for the specified function and basic block.
Definition: Constants.cpp:1496
This is an important base class in LLVM.
Definition: Constant.h:41
LLVMValueRef LLVMBuildNSWSub(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:2317
LLVMValueRef LLVMGetNamedFunction(LLVMModuleRef M, const char *Name)
Obtain a Function value from a Module by its name.
Definition: Core.cpp:1654
LLVMValueRef LLVMConstFNeg(LLVMValueRef ConstantVal)
Definition: Core.cpp:1009
This file contains the declarations for the subclasses of Constant, which represent the different fla...
unsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy)
Get the number of elements defined inside the structure.
Definition: Core.cpp:453
param_iterator param_begin() const
Definition: DerivedTypes.h:124
LLVMThreadLocalMode LLVMGetThreadLocalMode(LLVMValueRef GlobalVar)
Definition: Core.cpp:1590
LLVMValueRef LLVMBuildSIToFP(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:2595
char * LLVMPrintValueToString(LLVMValueRef Val)
Return a string representation of the value.
Definition: Core.cpp:547
LLVMValueRef LLVMBuildExtractElement(LLVMBuilderRef B, LLVMValueRef VecVal, LLVMValueRef Index, const char *Name)
Definition: Core.cpp:2712
LLVMValueRef LLVMBuildFMul(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:2347
static Constant * getAnd(Constant *C1, Constant *C2)
Definition: Constants.cpp:2317
void LLVMSetDLLStorageClass(LLVMValueRef Global, LLVMDLLStorageClass Class)
Definition: Core.cpp:1461
static Constant * get(ArrayType *T, ArrayRef< Constant * > V)
Definition: Constants.cpp:873
ConstantFP - Floating Point Values [float, double].
Definition: Constants.h:233
LLVMTypeRef LLVMPPCFP128TypeInContext(LLVMContextRef C)
Obtain a 128-bit floating point type (two 64-bits) from a context.
Definition: Core.cpp:363
80 bit floating point type (X87)
Definition: Core.h:260
LLVMValueRef LLVMBuildPtrDiff(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:2754
LLVMValueRef LLVMBuildInBoundsGEP(LLVMBuilderRef B, LLVMValueRef Pointer, LLVMValueRef *Indices, unsigned NumIndices, const char *Name)
Definition: Core.cpp:2526
static Constant * getSExtOrBitCast(Constant *C, Type *Ty)
Definition: Constants.cpp:1636
LLVMValueRef LLVMConstNUWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1072
bool llvm_is_multithreaded()
Returns true if LLVM is compiled with support for multi-threading, and false otherwise.
Definition: Threading.cpp:23
LLVMValueRef LLVMConstExtractValue(LLVMValueRef AggConstant, unsigned *IdxList, unsigned NumIdx)
Definition: Core.cpp:1311
void LLVMAddDestination(LLVMValueRef IndirectBr, LLVMBasicBlockRef Dest)
Definition: Core.cpp:2277
LLVMValueRef LLVMConstOr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1124
void LLVMInstructionEraseFromParent(LLVMValueRef Inst)
Remove and delete an instruction.
Definition: Core.cpp:1998
static Constant * getShuffleVector(Constant *V1, Constant *V2, Constant *Mask, Type *OnlyIfReducedTy=nullptr)
Definition: Constants.cpp:2168
void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index, unsigned align)
Definition: Core.cpp:2072
LLVMUseRef LLVMGetOperandUse(LLVMValueRef Val, unsigned Index)
Obtain the use of an operand at a specific index in a llvm::User value.
Definition: Core.cpp:671
void LLVMMoveBasicBlockAfter(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos)
Move a basic block to after another one.
Definition: Core.cpp:1956
LLVMValueRef LLVMGetUsedValue(LLVMUseRef U)
Obtain the value this use corresponds to.
Definition: Core.cpp:641
static Type * getVoidTy(LLVMContext &C)
Definition: Type.cpp:225
LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount)
Create a fixed size array type that refers to a specific type.
Definition: Core.cpp:483
LLVMBool LLVMIsUndef(LLVMValueRef Val)
Determine whether a value instance is undefined.
Definition: Core.cpp:712
char * LLVMGetDiagInfoDescription(LLVMDiagnosticInfoRef DI)
Return a string representation of the DiagnosticInfo.
Definition: Core.cpp:112
LLVMValueRef LLVMMDStringInContext(LLVMContextRef C, const char *Str, unsigned SLen)
Obtain a MDString value from a context.
Definition: Core.cpp:723
LLVMValueRef LLVMBuildResume(LLVMBuilderRef B, LLVMValueRef Exn)
Definition: Core.cpp:2264
Type * getTypeAtIndex(const Value *V)
getTypeAtIndex - Given an index value into the type, return the type of the element.
Definition: Type.cpp:634
struct LLVMOpaqueContext * LLVMContextRef
The top-level container for all LLVM global data.
Definition: Core.h:70
LLVMValueRef LLVMConstString(const char *Str, unsigned Length, LLVMBool DontNullTerminate)
Create a ConstantDataSequential with string content in the global context.
Definition: Core.cpp:914
This instruction compares its operands according to the predicate given to the constructor.
LLVMTypeRef LLVMIntTypeInContext(LLVMContextRef C, unsigned NumBits)
Definition: Core.cpp:316
MDNode * getOperand(unsigned i) const
Definition: Metadata.cpp:965
Functions.
Definition: Core.h:265
opStatus convert(const fltSemantics &, roundingMode, bool *)
APFloat::convert - convert a value of one floating point type to another.
Definition: APFloat.cpp:1972
LLVMBasicBlockRef LLVMGetSuccessor(LLVMValueRef Term, unsigned i)
Return the specified successor.
Definition: Core.cpp:2099
LLVMValueRef LLVMMDString(const char *Str, unsigned SLen)
Obtain a MDString value from the global context.
Definition: Core.cpp:730
6: 128-bit floating point type (two 64-bits, PowerPC)
Definition: Type.h:62
LLVMValueRef LLVMConstSRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1109
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)
Creates a new BasicBlock.
Definition: BasicBlock.h:103
arg_iterator arg_begin()
Definition: Function.h:472
LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef B)
Definition: Core.cpp:2268
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:2074
LLVMValueRef LLVMBuildInvoke(LLVMBuilderRef B, LLVMValueRef Fn, LLVMValueRef *Args, unsigned NumArgs, LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch, const char *Name)
Definition: Core.cpp:2250
void LLVMShutdown()
Deallocate and destroy all ManagedStatic variables.
Definition: Core.cpp:59
LLVMTypeRef LLVMPPCFP128Type(void)
Definition: Core.cpp:385
Class to represent integer types.
Definition: DerivedTypes.h:37
const char * LLVMGetMDString(LLVMValueRef V, unsigned *Len)
Obtain the underlying string from a MDString value.
Definition: Core.cpp:765
LLVMValueRef LLVMConstIntToPtr(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition: Core.cpp:1230
And a value and return the old one.
Definition: Core.h:395
LLVMValueRef LLVMConstPointerCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition: Core.cpp:1264
LLVMValueRef LLVMBuildNot(LLVMBuilderRef B, LLVMValueRef V, const char *Name)
Definition: Core.cpp:2442
LLVMBasicBlockRef LLVMGetInsertBlock(LLVMBuilderRef Builder)
Definition: Core.cpp:2176
const char * LLVMGetTarget(LLVMModuleRef M)
Obtain the target triple for a module.
Definition: Core.cpp:172
static Constant * get(StructType *T, ArrayRef< Constant * > V)
Definition: Constants.cpp:1008
LLVMTypeRef LLVMInt16Type(void)
Definition: Core.cpp:326
Sets the value if it's greater than the original using a signed comparison and return the old one...
Definition: Core.h:399
Metadata wrapper in the Value hierarchy.
Definition: Metadata.h:172
static Constant * getNot(Constant *C)
Definition: Constants.cpp:2252
void LLVMPositionBuilderBefore(LLVMBuilderRef Builder, LLVMValueRef Instr)
Definition: Core.cpp:2166
void LLVMSetPersonalityFn(LLVMValueRef Fn, LLVMValueRef PersonalityFn)
Set the personality function attached to the function.
Definition: Core.cpp:1698
static Constant * getAllOnesValue(Type *Ty)
Get the all ones value.
Definition: Constants.cpp:230
LLVMTypeRef LLVMGetTypeByName(LLVMModuleRef M, const char *Name)
Obtain a Type from a module by its registered name.
Definition: Core.cpp:477
LLVMValueRef LLVMGetPersonalityFn(LLVMValueRef Fn)
Obtain the personality function attached to the function.
Definition: Core.cpp:1694
LLVMOpcode LLVMGetConstOpcode(LLVMValueRef ConstantVal)
Definition: Core.cpp:984
static LocalAsMetadata * get(Value *Local)
Definition: Metadata.h:343
unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr)
Obtain the calling convention for a call instruction.
Definition: Core.cpp:2034
void LLVMDumpValue(LLVMValueRef Val)
Dump a representation of a value to stderr.
Definition: Core.cpp:543
LLVMValueRef LLVMConstSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1039
FunctionPassManager manages FunctionPasses and BasicBlockPassManagers.
LLVMValueRef LLVMConstUIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition: Core.cpp:1205
int LLVMBool
Definition: Support.h:29
int LLVMGetNumOperands(LLVMValueRef Val)
Obtain the number of operands in a llvm::User value.
Definition: Core.cpp:680
static UndefValue * get(Type *T)
get() - Static factory methods - Return an 'undef' object of the specified type.
Definition: Constants.cpp:1473
LLVMValueRef LLVMBuildGEP(LLVMBuilderRef B, LLVMValueRef Pointer, LLVMValueRef *Indices, unsigned NumIndices, const char *Name)
Definition: Core.cpp:2519
LLVMValueRef LLVMAddGlobalInAddressSpace(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name, unsigned AddressSpace)
Definition: Core.cpp:1513
LLVMContext & getContext() const
All values hold a context through their type.
Definition: Value.cpp:519
type with no size
Definition: Core.h:256
LLVMValueRef LLVMBuildTrunc(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:2565
const char * LLVMGetDataLayout(LLVMModuleRef M)
Obtain the data layout for a module.
Definition: Core.cpp:163
Like Private, but linker removes.
Definition: Core.h:293
LLVMValueRef LLVMGetParam(LLVMValueRef FnRef, unsigned index)
Obtain the parameter at the specified index.
Definition: Core.cpp:1785
struct LLVMOpaqueValue * LLVMValueRef
Represents an individual value in LLVM IR.
Definition: Core.h:92
LLVMValueRef LLVMConstStringInContext(LLVMContextRef C, const char *Str, unsigned Length, LLVMBool DontNullTerminate)
Create a ConstantDataSequential and initialize it with a string.
Definition: Core.cpp:898
LLVMValueRef LLVMConstURem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1104
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
LLVMTypeRef LLVMVoidType(void)
These are similar to the above functions except they operate on the global context.
Definition: Core.cpp:520
LLVMValueRef LLVMBuildCall(LLVMBuilderRef B, LLVMValueRef Fn, LLVMValueRef *Args, unsigned NumArgs, const char *Name)
Definition: Core.cpp:2692
static Type * getFP128Ty(LLVMContext &C)
Definition: Type.cpp:232
LLVMBasicBlockRef LLVMAppendBasicBlockInContext(LLVMContextRef C, LLVMValueRef FnRef, const char *Name)
Append a basic block to the end of a function.
Definition: Core.cpp:1922
LLVMTypeRef LLVMGetElementType(LLVMTypeRef Ty)
Obtain the type of elements within a sequential type.
Definition: Core.cpp:495
LLVMValueRef LLVMBuildNeg(LLVMBuilderRef B, LLVMValueRef V, const char *Name)
Definition: Core.cpp:2424
void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf)
Definition: Core.cpp:2850
LLVMValueRef LLVMBuildUIToFP(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:2590
void LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC)
Set the calling convention of a function.
Definition: Core.cpp:1712
Like Internal, but omit from symbol table.
Definition: Core.h:287
void LLVMGetBasicBlocks(LLVMValueRef FnRef, LLVMBasicBlockRef *BasicBlocksRefs)
Obtain all of the basic blocks in a function.
Definition: Core.cpp:1880
Sets the value if it's Smaller than the original using a signed comparison and return the old one...
Definition: Core.h:402
static AtomicOrdering mapFromLLVMOrdering(LLVMAtomicOrdering Ordering)
Definition: Core.cpp:2496
global_iterator global_end()
Definition: Module.h:554
unsigned LLVMGetNamedMetadataNumOperands(LLVMModuleRef M, const char *name)
Obtain the number of operands for named metadata in a module.
Definition: Core.cpp:797
13: Arrays
Definition: Type.h:72
static Constant * getFCmp(unsigned short pred, Constant *LHS, Constant *RHS, bool OnlyIfReduced=false)
Definition: Constants.cpp:2099
LLVMContextRef LLVMGetTypeContext(LLVMTypeRef Ty)
Obtain the context to which this type instance is associated.
Definition: Core.cpp:274
static Constant * getPointerCast(Constant *C, Type *Ty)
Create a BitCast, AddrSpaceCast, or a PtrToInt cast constant expression.
Definition: Constants.cpp:1648
static Constant * getSIToFP(Constant *C, Type *Ty, bool OnlyIfReduced=false)
Definition: Constants.cpp:1776
LLVMValueRef LLVMGetOperand(LLVMValueRef Val, unsigned Index)
Obtain an operand at a specific index in a llvm::User value.
Definition: Core.cpp:657
LLVMValueRef LLVMConstTruncOrBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition: Core.cpp:1258
static Type * getHalfTy(LLVMContext &C)
Definition: Type.cpp:227
unsigned LLVMCountParams(LLVMValueRef FnRef)
Obtain the number of parameters in a function.
Definition: Core.cpp:1772
static IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
Definition: Type.cpp:304
const MDOperand & getOperand(unsigned I) const
Definition: Metadata.h:936
LLVMModuleProviderRef LLVMCreateModuleProviderForExistingModule(LLVMModuleRef M)
Changes the type of M so it can be passed to FunctionPassManagers and the JIT.
Definition: Core.cpp:2785
void LLVMInsertIntoBuilder(LLVMBuilderRef Builder, LLVMValueRef Instr)
Definition: Core.cpp:2184
LLVMValueRef LLVMBuildFPCast(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:2665
LLVMValueRef LLVMBuildRetVoid(LLVMBuilderRef B)
Definition: Core.cpp:2218
LLVMValueRef LLVMBuildGlobalString(LLVMBuilderRef B, const char *Str, const char *Name)
Definition: Core.cpp:2539
LLVMValueRef LLVMConstPointerNull(LLVMTypeRef Ty)
Obtain a constant that is a constant pointer pointing to NULL for a specified type.
Definition: Core.cpp:716
void LLVMSetInitializer(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal)
Definition: Core.cpp:1569
LLVMThreadLocalMode
Definition: Core.h:356
LLVMVisibility LLVMGetVisibility(LLVMValueRef Global)
Definition: Core.cpp:1446
LLVMValueRef LLVMConstNUWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1050
Metadata * getMetadata() const
Definition: Metadata.h:187
void LLVMInitializeCore(LLVMPassRegistryRef R)
Definition: Core.cpp:55
LLVMContextRef LLVMContextCreate()
Create a new context.
Definition: Core.cpp:76
struct LLVMOpaquePassRegistry * LLVMPassRegistryRef
Definition: Core.h:119
Labels.
Definition: Core.h:263
LLVMTypeKind LLVMGetTypeKind(LLVMTypeRef Ty)
Obtain the enumerated type of a Type instance.
Definition: Core.cpp:231
LLVMTypeRef LLVMTypeOf(LLVMValueRef Val)
Obtain the type of a value.
Definition: Core.cpp:531
LLVMValueRef LLVMConstAllOnes(LLVMTypeRef Ty)
Obtain a constant value referring to the instance of a type consisting of all ones.
Definition: Core.cpp:694
15: SIMD 'packed' format, or other vector type
Definition: Type.h:74
LLVMValueRef LLVMConstFPTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition: Core.cpp:1195
static StructType * get(LLVMContext &Context, ArrayRef< Type * > Elements, bool isPacked=false)
StructType::get - This static method is the primary way to create a literal StructType.
Definition: Type.cpp:404
static Constant * getSDiv(Constant *C1, Constant *C2, bool isExact=false)
Definition: Constants.cpp:2296
struct LLVMOpaqueBasicBlock * LLVMBasicBlockRef
Represents a basic block of instructions in LLVM IR.
Definition: Core.h:99
iterator end()
Definition: BasicBlock.h:233
LLVMValueRef LLVMConstInsertValue(LLVMValueRef AggConstant, LLVMValueRef ElementValueConstant, unsigned *IdxList, unsigned NumIdx)
Definition: Core.cpp:1317
LLVMValueRef LLVMBuildURem(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:2372
bool hasName() const
hasName - Return true if this is a named struct that has a non-empty name.
Definition: DerivedTypes.h:256
LLVMTypeRef LLVMLabelType(void)
Definition: Core.cpp:523
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:861
Keep one copy of function when linking (inline)
Definition: GlobalValue.h:42
Arbitrary bit width integers.
Definition: Core.h:264
Module.h This file contains the declarations for the Module class.
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:222
LLVMValueRef LLVMGetCondition(LLVMValueRef Branch)
Return the condition of a branch instruction.
Definition: Core.cpp:2113
AddressSpace
Definition: NVPTXBaseInfo.h:22
LLVMValueRef LLVMBuildFCmp(LLVMBuilderRef B, LLVMRealPredicate Op, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:2679
static Constant * getNUWMul(Constant *C1, Constant *C2)
Definition: Constants.h:954
Structures.
Definition: Core.h:266
LLVMValueRef LLVMGetNextInstruction(LLVMValueRef Inst)
Obtain the instruction that occurs after the one specified.
Definition: Core.cpp:1982
void LLVMDeleteGlobal(LLVMValueRef GlobalVar)
Definition: Core.cpp:1558
Xor a value and return the old one.
Definition: Core.h:398
LLVMValueRef LLVMConstSExtOrBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition: Core.cpp:1252
LLVMValueRef LLVMBuildXor(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:2412
LLVMValueRef LLVMBuildUDiv(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:2352
static Constant * getNSWSub(Constant *C1, Constant *C2)
Definition: Constants.h:945
void LLVMRemoveInstrAttribute(LLVMValueRef Instr, unsigned index, LLVMAttribute PA)
Definition: Core.cpp:2062
static Constant * getTrunc(Constant *C, Type *Ty, bool OnlyIfReduced=false)
Definition: Constants.cpp:1699
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:582
LLVMBool LLVMIsFunctionVarArg(LLVMTypeRef FunctionTy)
Returns whether a function type is variadic.
Definition: Core.cpp:401
LLVMValueRef LLVMGetCurrentDebugLocation(LLVMBuilderRef Builder)
Definition: Core.cpp:2205
LLVMLinkage
Definition: Core.h:274
static Constant * get(Type *Ty, double V)
get() - This returns a ConstantFP, or a vector containing a splat of a ConstantFP, for the specified value in the specified type.
Definition: Constants.cpp:652
LLVMTypeRef LLVMDoubleType(void)
Definition: Core.cpp:376
void LLVMSetDataLayout(LLVMModuleRef M, const char *Triple)
Set the data layout for a module.
Definition: Core.cpp:167
32 bit floating point type
Definition: Core.h:258
LLVMValueRef LLVMBuildInsertValue(LLVMBuilderRef B, LLVMValueRef AggVal, LLVMValueRef EltVal, unsigned Index, const char *Name)
Definition: Core.cpp:2737
LLVMValueRef LLVMGetUser(LLVMUseRef U)
Obtain the user value for a user.
Definition: Core.cpp:637
void setLinkage(LinkageTypes LT)
Definition: GlobalValue.h:284
LLVMValueRef LLVMConstFPExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition: Core.cpp:1200
8: Metadata
Definition: Type.h:64
provides Acquire semantics for loads and Release semantics for stores.
Definition: Core.h:381
AttributeSet getAttributes() const
Return the attribute list for this Function.
Definition: Function.h:181
static LLVMOpcode map_to_llvmopcode(int opcode)
Definition: Core.cpp:962
AttributeSet removeAttributes(LLVMContext &C, unsigned Index, AttributeSet Attrs) const
Remove the specified attributes at the specified index from this attribute list.
Definition: Attributes.cpp:828
LLVMTypeRef LLVMStructType(LLVMTypeRef *ElementTypes, unsigned ElementCount, LLVMBool Packed)
Create a new structure type in the global context.
Definition: Core.cpp:428
LLVMValueRef LLVMBuildShuffleVector(LLVMBuilderRef B, LLVMValueRef V1, LLVMValueRef V2, LLVMValueRef Mask, const char *Name)
Definition: Core.cpp:2725
double LLVMConstRealGetDouble(LLVMValueRef ConstantVal, LLVMBool *LosesInfo)
Obtain the double value for an floating point constant value.
Definition: Core.cpp:875
LLVMValueRef LLVMBuildGlobalStringPtr(LLVMBuilderRef B, const char *Str, const char *Name)
Definition: Core.cpp:2544
void LLVMSetExternallyInitialized(LLVMValueRef GlobalVar, LLVMBool IsExtInit)
Definition: Core.cpp:1633
bool hasInitializer() const
Definitions have initializers, declarations don't.
Class for arbitrary precision integers.
Definition: APInt.h:73
void LLVMRemoveAttribute(LLVMValueRef Arg, LLVMAttribute PA)
Remove an attribute from a function argument.
Definition: Core.cpp:1834
LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef B, LLVMTypeRef Ty, const char *Name)
Definition: Core.cpp:2448
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:606
Same, but only replaced by something equivalent.
Definition: Core.h:278
LLVMValueRef LLVMBuildFree(LLVMBuilderRef B, LLVMValueRef PointerVal)
Definition: Core.cpp:2480
LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType, LLVMTypeRef *ParamTypes, unsigned ParamCount, LLVMBool IsVarArg)
Obtain a function type consisting of a specified signature.
Definition: Core.cpp:394
StringRef getName() const
getName - Return the name for this struct type if it has an identity.
Definition: Type.cpp:583
LLVMValueRef LLVMBuildBitCast(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:2620
LLVMBool LLVMIsThreadLocal(LLVMValueRef GlobalVar)
Definition: Core.cpp:1574
static Constant * getFPToUI(Constant *C, Type *Ty, bool OnlyIfReduced=false)
Definition: Constants.cpp:1787
bool hasGC() const
hasGC/getGC/setGC/clearGC - The name of the garbage collection algorithm to use during code generatio...
Definition: Function.cpp:379
LLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition: Core.cpp:1225
static char getTypeID(Type *Ty)
void setGC(const char *Str)
Definition: Function.cpp:390
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:2875
LLVMValueRef LLVMGetBasicBlockTerminator(LLVMBasicBlockRef BB)
Obtain the terminator instruction for a basic block.
Definition: Core.cpp:1872
Metadata.
Definition: Core.h:270
The file should be opened in text mode on platforms that make this distinction.
Definition: FileSystem.h:592
LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count, LLVMBool Packed)
Create a ConstantStruct in the global Context.
Definition: Core.cpp:940
static Constant * getZExtOrBitCast(Constant *C, Type *Ty)
Definition: Constants.cpp:1630
LLVMBool LLVMIsConstantString(LLVMValueRef c)
Returns true if the specified constant is an array of i8.
Definition: Core.cpp:924
LLVMValueRef LLVMConstFCmp(LLVMRealPredicate Predicate, LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1141
LLVMTypeRef LLVMX86MMXTypeInContext(LLVMContextRef C)
Create a X86 MMX type in a context.
Definition: Core.cpp:366
LLVMValueRef LLVMConstMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1061
LLVMBool LLVMIsDeclaration(LLVMValueRef Global)
Definition: Core.cpp:1343
static Instruction * CreateMalloc(Instruction *InsertBefore, Type *IntPtrTy, Type *AllocTy, Value *AllocSize, Value *ArraySize=nullptr, Function *MallocF=nullptr, const Twine &Name="")
CreateMalloc - Generate the IR for a call to malloc:
LLVMValueRef LLVMBuildFPExt(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:2605
Basic diagnostic printer that uses an underlying raw_ostream.
LLVMValueRef LLVMConstNeg(LLVMValueRef ConstantVal)
Definition: Core.cpp:996
void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues, LLVMBasicBlockRef *IncomingBlocks, unsigned Count)
Add an incoming value to the end of a PHI list.
Definition: Core.cpp:2129
static Constant * getFSub(Constant *C1, Constant *C2)
Definition: Constants.cpp:2276
LLVMValueRef LLVMBuildExtractValue(LLVMBuilderRef B, LLVMValueRef AggVal, unsigned Index, const char *Name)
Definition: Core.cpp:2732
LLVMValueRef LLVMBuildAShr(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:2397
static Constant * getTruncOrBitCast(Constant *C, Type *Ty)
Definition: Constants.cpp:1642
void LLVMRemoveBasicBlockFromParent(LLVMBasicBlockRef BBRef)
Remove a basic block from a function.
Definition: Core.cpp:1948
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition: Metadata.h:1030
LLVMValueRef LLVMConstFAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1034
static Constant * getNeg(Constant *C, bool HasNUW=false, bool HasNSW=false)
Definition: Constants.cpp:2239
use_iterator use_begin()
Definition: Value.h:279
LLVMValueRef LLVMConstNSWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1044
LLVMValueRef LLVMBuildMul(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:2332
LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg)
Obtain the previous parameter to a function.
Definition: Core.cpp:1820
LLVMModuleRef LLVMModuleCreateWithName(const char *ModuleID)
Create a new, empty module in the global context.
Definition: Core.cpp:149
Obsolete.
Definition: Core.h:291
void LLVMAddCase(LLVMValueRef Switch, LLVMValueRef OnVal, LLVMBasicBlockRef Dest)
Definition: Core.cpp:2272
static Constant * getNSWMul(Constant *C1, Constant *C2)
Definition: Constants.h:951
LLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Val, const char *Name)
Definition: Core.cpp:2459
struct LLVMOpaquePassManager * LLVMPassManagerRef
Definition: Core.h:116
A raw_ostream that writes to a file descriptor.
Definition: raw_ostream.h:345
char * LLVMPrintTypeToString(LLVMTypeRef Ty)
Return a string representation of the type.
Definition: Core.cpp:282
iterator end()
Definition: Module.h:571
LLVMBool LLVMIsConditional(LLVMValueRef Branch)
Return if a branch is conditional.
Definition: Core.cpp:2109
Tentative definitions.
Definition: Core.h:292
LLVMValueRef LLVMBuildIntToPtr(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:2615
static IntegerType * getInt32Ty(LLVMContext &C)
Definition: Type.cpp:239
LLVMValueRef LLVMConstIntOfArbitraryPrecision(LLVMTypeRef IntTy, unsigned NumWords, const uint64_t Words[])
Obtain a constant value for an integer of arbitrary precision.
Definition: Core.cpp:833
LLVMTypeRef LLVMInt64Type(void)
Definition: Core.cpp:332
16 bit floating point type
Definition: Core.h:257
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFile(const Twine &Filename, int64_t FileSize=-1, bool RequiresNullTerminator=true, bool IsVolatileSize=false)
Open the specified file as a MemoryBuffer, returning a new MemoryBuffer if successful, otherwise returning null.
LLVMVisibility
Definition: Core.h:297
LLVMTypeRef LLVMHalfTypeInContext(LLVMContextRef C)
Obtain a 16-bit floating point type from a context.
Definition: Core.cpp:348
LLVMBasicBlockRef LLVMAppendBasicBlock(LLVMValueRef FnRef, const char *Name)
Append a basic block to the end of a function using the global context.
Definition: Core.cpp:1928
guarantees that if you take all the operations affecting a specific address, a consistent ordering ex...
Definition: Core.h:368
LLVMValueRef LLVMConstNUWNeg(LLVMValueRef ConstantVal)
Definition: Core.cpp:1004
LLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B, LLVMAtomicRMWBinOp op, LLVMValueRef PTR, LLVMValueRef Val, LLVMAtomicOrdering ordering, LLVMBool singleThread)
Definition: Core.cpp:2759
void LLVMDeleteBasicBlock(LLVMBasicBlockRef BBRef)
Remove a basic block from a function and delete it.
Definition: Core.cpp:1944
void * PointerTy
Definition: GenericValue.h:23
LLVMValueRef LLVMBuildLShr(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:2392
unsigned LLVMGetNumSuccessors(LLVMValueRef Term)
Return the number of successors that this terminator has.
Definition: Core.cpp:2095
LLVMValueRef LLVMBuildIsNotNull(LLVMBuilderRef B, LLVMValueRef Val, const char *Name)
Definition: Core.cpp:2749
unsigned LLVMGetMDKindID(const char *Name, unsigned SLen)
Definition: Core.cpp:108
LLVMBool LLVMIsConstant(LLVMValueRef Ty)
Determine whether the specified constant instance is constant.
Definition: Core.cpp:702
static Constant * getPtrToInt(Constant *C, Type *Ty, bool OnlyIfReduced=false)
Definition: Constants.cpp:1809
#define I(x, y, z)
Definition: MD5.cpp:54
#define N
LLVMValueRef LLVMBuildFSub(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:2327
static Constant * getOr(Constant *C1, Constant *C2)
Definition: Constants.cpp:2321
LLVMBasicBlockRef LLVMGetIncomingBlock(LLVMValueRef PhiNode, unsigned Index)
Obtain an incoming value to a PHI node as an LLVMBasicBlockRef.
Definition: Core.cpp:2144
LLVMTypeRef LLVMInt1TypeInContext(LLVMContextRef C)
Obtain an integer type from a context with specified bit width.
Definition: Core.cpp:298
LLVMBool LLVMGetVolatile(LLVMValueRef MemAccessInst)
Definition: Core.cpp:2549
LLVMTypeRef LLVMInt1Type(void)
Obtain an integer type from the global context with a specified bit width.
Definition: Core.cpp:320
void initializeVerifierLegacyPassPass(PassRegistry &)
LLVMTypeRef LLVMIntType(unsigned NumBits)
Definition: Core.cpp:338
void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC)
Set the calling convention for a call instruction.
Definition: Core.cpp:2043
iterator begin()
Definition: Module.h:569
LLVMPassManagerRef LLVMCreateFunctionPassManagerForModule(LLVMModuleRef M)
Constructs a new function-by-function pass pipeline over the module provider.
Definition: Core.cpp:2866
LLVMModuleRef LLVMModuleCreateWithNameInContext(const char *ModuleID, LLVMContextRef C)
Create a new, empty module in a specific context.
Definition: Core.cpp:153
LLVMValueRef LLVMBuildSwitch(LLVMBuilderRef B, LLVMValueRef V, LLVMBasicBlockRef Else, unsigned NumCases)
Definition: Core.cpp:2240
LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy, LLVMValueRef *ConstantVals, unsigned Length)
Create a ConstantArray from values.
Definition: Core.cpp:934
float convertToFloat() const
Definition: APFloat.cpp:3107
128 bit floating point type (two 64-bits)
Definition: Core.h:262
struct LLVMOpaqueUse * LLVMUseRef
Used to get the users and usees of a Value.
Definition: Core.h:125
static ArrayType * get(Type *ElementType, uint64_t NumElements)
ArrayType::get - This static method is the primary way to construct an ArrayType. ...
Definition: Type.cpp:686
void size_t size
void LLVMDumpType(LLVMTypeRef Ty)
Dump a representation of a type to stderr.
Definition: Core.cpp:278
const AttributeSet & getAttributes() const
getAttributes/setAttributes - get or set the parameter attributes of the call.
Definition: CallSite.h:229
static Constant * getShl(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
Definition: Constants.cpp:2329
Keep one copy of named function when linking (weak)
Definition: GlobalValue.h:44
static BinaryOperator * CreateNeg(Value *S1, const Twine &Name, Instruction *InsertBefore, Value *FlagsOp)
Rename collisions when linking (static functions).
Definition: GlobalValue.h:47
LLVMTypeRef LLVMInt8Type(void)
Definition: Core.cpp:323
Special purpose, only applies to global arrays.
Definition: Core.h:284
LLVMValueRef LLVMBuildLandingPad(LLVMBuilderRef B, LLVMTypeRef Ty, unsigned NumClauses, const char *Name)
Definition: Core.cpp:2259
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:28
LLVMValueRef LLVMConstSIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition: Core.cpp:1210
const char * LLVMGetAsString(LLVMValueRef c, size_t *Length)
Get the given constant data sequential as a string.
Definition: Core.cpp:928
void setAttributes(AttributeSet attrs)
Set the attribute list for this Function.
Definition: Function.h:184
LLVMValueRef LLVMConstLShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1153
LLVMBool LLVMFinalizeFunctionPassManager(LLVMPassManagerRef FPM)
Finalizes all of the function passes scheduled in in the function pass manager.
Definition: Core.cpp:2887
void close()
Manually flush the stream and close the file.
LLVMIntPredicate LLVMGetICmpPredicate(LLVMValueRef Inst)
Obtain the predicate of an instruction.
Definition: Core.cpp:2002
void LLVMSetCleanup(LLVMValueRef LandingPad, LLVMBool Val)
Definition: Core.cpp:2286
LLVMValueRef LLVMConstShl(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1148
LLVMTypeRef LLVMInt128TypeInContext(LLVMContextRef C)
Definition: Core.cpp:313
struct LLVMOpaqueModule * LLVMModuleRef
The top-level container for all other LLVM Intermediate Representation (IR) objects.
Definition: Core.h:78
LLVMValueRef LLVMBuildNUWMul(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:2342
Like LinkerPrivate, but is weak.
Definition: Core.h:294
LLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal)
Definition: Core.cpp:1013
const APFloat & getValueAPF() const
Definition: Constants.h:270
3: 64-bit floating point type
Definition: Type.h:59
LLVMValueRef LLVMGetFirstFunction(LLVMModuleRef M)
Obtain an iterator to the first Function in a Module.
Definition: Core.cpp:1658
LLVMAttribute LLVMGetAttribute(LLVMValueRef Arg)
Get an attribute from a function argument.
Definition: Core.cpp:1840
LLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename, char **ErrorMessage)
Print a representation of a module to a file.
Definition: Core.cpp:184
LLVMValueRef LLVMBuildVAArg(LLVMBuilderRef B, LLVMValueRef List, LLVMTypeRef Ty, const char *Name)
Definition: Core.cpp:2707
void LLVMSetThreadLocalMode(LLVMValueRef GlobalVar, LLVMThreadLocalMode Mode)
Definition: Core.cpp:1607
static Constant * getSRem(Constant *C1, Constant *C2)
Definition: Constants.cpp:2309
Release is similar to Acquire, but with a barrier of the sort necessary to release a lock...
Definition: Core.h:374
LLVMBuilderRef LLVMCreateBuilderInContext(LLVMContextRef C)
Definition: Core.cpp:2151
void LLVMSetMetadata(LLVMValueRef Inst, unsigned KindID, LLVMValueRef Val)
Set metadata associated with an instruction value.
Definition: Core.cpp:591
LLVMValueRef LLVMGetParamParent(LLVMValueRef V)
Obtain the function to which this argument belongs.
Definition: Core.cpp:1792
A raw_ostream that writes to an std::string.
Definition: raw_ostream.h:465
const char * LLVMGetValueName(LLVMValueRef Val)
Obtain the string name of a value.
Definition: Core.cpp:535
LLVMValueRef LLVMBuildSExtOrBitCast(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:2636
LLVMValueRef LLVMBuildBr(LLVMBuilderRef B, LLVMBasicBlockRef Dest)
Definition: Core.cpp:2231
Module * getParent()
Get the module that this global value is contained inside of...
Definition: GlobalValue.h:365
LLVM Value Representation.
Definition: Value.h:69
static const char * name
uint64_t Raw(unsigned Index) const
LLVMValueRef LLVMBuildZExtOrBitCast(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:2630
LLVMBool LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef *OutMemBuf, char **OutMessage)
Definition: Core.cpp:2810
LLVMLinkage LLVMGetLinkage(LLVMValueRef Global)
Definition: Core.cpp:1347
static Constant * getURem(Constant *C1, Constant *C2)
Definition: Constants.cpp:2305
unsigned getArgNo() const
Return the index of this formal argument in its containing function.
Definition: Function.cpp:62
static VectorType * get(Type *ElementType, unsigned NumElements)
VectorType::get - This static method is the primary way to construct an VectorType.
Definition: Type.cpp:713
static StructType * create(LLVMContext &Context, StringRef Name)
StructType::create - This creates an identified struct.
Definition: Type.cpp:490
LLVMDLLStorageClass
Definition: Core.h:303
LLVMBasicBlockRef LLVMValueAsBasicBlock(LLVMValueRef Val)
Convert an LLVMValueRef to an LLVMBasicBlockRef instance.
Definition: Core.cpp:1864
LLVMValueRef LLVMGetPreviousFunction(LLVMValueRef Fn)
Decrement a Function iterator to the previous Function.
Definition: Core.cpp:1682
static const Function * getParent(const Value *V)
LLVMValueRef LLVMBuildIndirectBr(LLVMBuilderRef B, LLVMValueRef Addr, unsigned NumDests)
Definition: Core.cpp:2245
void LLVMSetGC(LLVMValueRef Fn, const char *GC)
Define the garbage collector to use during code generation.
Definition: Core.cpp:1722
LLVMDLLStorageClass LLVMGetDLLStorageClass(LLVMValueRef Global)
Definition: Core.cpp:1456
static Constant * getUIToFP(Constant *C, Type *Ty, bool OnlyIfReduced=false)
Definition: Constants.cpp:1765
LLVMValueRef LLVMBuildNSWNeg(LLVMBuilderRef B, LLVMValueRef V, const char *Name)
Definition: Core.cpp:2428
static Constant * getFPToSI(Constant *C, Type *Ty, bool OnlyIfReduced=false)
Definition: Constants.cpp:1798
Obsolete.
Definition: Core.h:289
LLVMTypeRef LLVMGetReturnType(LLVMTypeRef FunctionTy)
Obtain the Type this function Type returns.
Definition: Core.cpp:405
unsigned getNumOperands() const
Definition: Metadata.cpp:961
LLVMValueRef LLVMBuildNSWMul(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:2337
LLVMValueRef LLVMBuildStore(LLVMBuilderRef B, LLVMValueRef Val, LLVMValueRef PointerVal)
Definition: Core.cpp:2491
InvokeInst - Invoke instruction.
#define DEBUG(X)
Definition: Debug.h:92
struct LLVMOpaqueDiagnosticInfo * LLVMDiagnosticInfoRef
Definition: Core.h:131
LLVMValueRef LLVMBuildBinOp(LLVMBuilderRef B, LLVMOpcode Op, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:2417
void(* YieldCallbackTy)(LLVMContext *Context, void *OpaqueHandle)
Defines the type of a yield callback.
Definition: LLVMContext.h:85
struct LLVMOpaqueBuilder * LLVMBuilderRef
Represents an LLVM basic block builder.
Definition: Core.h:106
static Constant * getExtractValue(Constant *Agg, ArrayRef< unsigned > Idxs, Type *OnlyIfReducedTy=nullptr)
Definition: Constants.cpp:2215
LLVMValueRef LLVMConstZExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition: Core.cpp:1190
LLVMTypeRef LLVMInt128Type(void)
Definition: Core.cpp:335
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:40
LLVMBool LLVMIsMultithreaded()
Check whether LLVM is executing in thread-safe mode or not.
Definition: Core.cpp:2904
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
Definition: PassRegistry.h:41
A single uniqued string.
Definition: Metadata.h:508
AttrBuilder & addAlignmentAttr(unsigned Align)
This turns an int alignment (which must be a power of 2) into the form used internally in Attribute...
LLVMContextRef LLVMGetGlobalContext()
Obtain the global context instance.
Definition: Core.cpp:80
LLVMValueRef LLVMConstNSWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1066
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, const Twine &N="", Module *M=nullptr)
Definition: Function.h:121
LLVMTypeRef LLVMInt32TypeInContext(LLVMContextRef C)
Definition: Core.cpp:307
void initializePrintFunctionPassWrapperPass(PassRegistry &)
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:2883
void addAttributes(unsigned i, AttributeSet attrs)
adds the attributes to the list of attributes.
Definition: Function.cpp:347
static bool isVolatile(Instruction *Inst)
64 bit floating point type
Definition: Core.h:259
9: MMX vectors (64 bits, X86 specific)
Definition: Type.h:65
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:1958
LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, unsigned AddressSpace)
Create a pointer type that points to a defined type.
Definition: Core.cpp:487
static Constant * getMul(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
Definition: Constants.cpp:2280
LLVMValueRef LLVMBuildLoad(LLVMBuilderRef B, LLVMValueRef PointerVal, const char *Name)
Definition: Core.cpp:2486
void LLVMAddInstrAttribute(LLVMValueRef Instr, unsigned index, LLVMAttribute PA)
Definition: Core.cpp:2052
LLVMValueRef LLVMConstExtractElement(LLVMValueRef VectorConstant, LLVMValueRef IndexConstant)
Definition: Core.cpp:1289
void LLVMSetTailCall(LLVMValueRef Call, LLVMBool isTailCall)
Set whether a call instruction is a tail call.
Definition: Core.cpp:2089
static Constant * getNUWSub(Constant *C1, Constant *C2)
Definition: Constants.h:948
static BinaryOperator * CreateMul(Value *S1, Value *S2, const Twine &Name, Instruction *InsertBefore, Value *FlagsOp)
void LLVMSetModuleInlineAsm(LLVMModuleRef M, const char *Asm)
Set inline assembly for a module.
Definition: Core.cpp:216
LLVMValueRef LLVMBuildAddrSpaceCast(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:2625
AttributeSet addAttributes(LLVMContext &C, unsigned Index, AttributeSet Attrs) const
Add attributes to the attribute set at the given index.
Definition: Attributes.cpp:773
static Constant * getFPExtend(Constant *C, Type *Ty, bool OnlyIfReduced=false)
Definition: Constants.cpp:1753
LLVMValueRef LLVMConstFRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:1114
static Constant * getNUWAdd(Constant *C1, Constant *C2)
Definition: Constants.h:942
unsigned LLVMGetAlignment(LLVMValueRef V)
Obtain the preferred alignment of the value.
Definition: Core.cpp:1476
LLVMValueRef LLVMGetNextFunction(LLVMValueRef Fn)
Advance a Function iterator to the next Function.
Definition: Core.cpp:1674
Root of the metadata hierarchy.
Definition: Metadata.h:45
static IntegerType * getInt8Ty(LLVMContext &C)
Definition: Type.cpp:237
void LLVMDisposeModuleProvider(LLVMModuleProviderRef MP)
Destroys the module M.
Definition: Core.cpp:2789
LLVMValueRef LLVMBuildSelect(LLVMBuilderRef B, LLVMValueRef If, LLVMValueRef Then, LLVMValueRef Else, const char *Name)
Definition: Core.cpp:2700
const BasicBlock * getParent() const
Definition: Instruction.h:72
LLVMContext & getGlobalContext()
getGlobalContext - Returns a global context.
Definition: LLVMContext.cpp:30
LLVMRealPredicate
Definition: Core.h:332
LLVMTypeRef LLVMX86FP80TypeInContext(LLVMContextRef C)
Obtain a 80-bit floating point type (X87) from a context.
Definition: Core.cpp:357
LLVMAttribute LLVMGetFunctionAttr(LLVMValueRef Fn)
Obtain an attribute from a function.
Definition: Core.cpp:1764
reference get()
Definition: ErrorOr.h:175
void LLVMInsertIntoBuilderWithName(LLVMBuilderRef Builder, LLVMValueRef Instr, const char *Name)
Definition: Core.cpp:2188
AllocaInst - an instruction to allocate memory on the stack.
Definition: Instructions.h:76
static Constant * getXor(Constant *C1, Constant *C2)
Definition: Constants.cpp:2325
LLVMValueRef LLVMBuildFPTrunc(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:2600
5: 128-bit floating point type (112-bit mantissa)
Definition: Type.h:61
void LLVMSetAlignment(LLVMValueRef V, unsigned Bytes)
Set the preferred alignment of the value.
Definition: Core.cpp:1491
LLVMModuleRef LLVMGetGlobalParent(LLVMValueRef Global)
Definition: Core.cpp:1339