LLVM API Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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/Constants.h"
19 #include "llvm/IR/DerivedTypes.h"
20 #include "llvm/IR/GlobalAlias.h"
21 #include "llvm/IR/GlobalVariable.h"
22 #include "llvm/IR/InlineAsm.h"
23 #include "llvm/IR/IntrinsicInst.h"
24 #include "llvm/IR/IRBuilder.h"
25 #include "llvm/IR/LLVMContext.h"
26 #include "llvm/IR/Module.h"
27 #include "llvm/PassManager.h"
28 #include "llvm/Support/CallSite.h"
29 #include "llvm/Support/Debug.h"
35 #include "llvm/Support/Threading.h"
36 #include <cassert>
37 #include <cstdlib>
38 #include <cstring>
39 
40 using namespace llvm;
41 
47  initializeVerifierPass(Registry);
48  initializePreVerifierPass(Registry);
49 }
50 
53 }
54 
55 void LLVMShutdown() {
56  llvm_shutdown();
57 }
58 
59 /*===-- Error handling ----------------------------------------------------===*/
60 
61 char *LLVMCreateMessage(const char *Message) {
62  return strdup(Message);
63 }
64 
65 void LLVMDisposeMessage(char *Message) {
66  free(Message);
67 }
68 
69 
70 /*===-- Operations on contexts --------------------------------------------===*/
71 
73  return wrap(new LLVMContext());
74 }
75 
77  return wrap(&getGlobalContext());
78 }
79 
81  delete unwrap(C);
82 }
83 
85  unsigned SLen) {
86  return unwrap(C)->getMDKindID(StringRef(Name, SLen));
87 }
88 
89 unsigned LLVMGetMDKindID(const char* Name, unsigned SLen) {
90  return LLVMGetMDKindIDInContext(LLVMGetGlobalContext(), Name, SLen);
91 }
92 
93 
94 /*===-- Operations on modules ---------------------------------------------===*/
95 
96 LLVMModuleRef LLVMModuleCreateWithName(const char *ModuleID) {
97  return wrap(new Module(ModuleID, getGlobalContext()));
98 }
99 
101  LLVMContextRef C) {
102  return wrap(new Module(ModuleID, *unwrap(C)));
103 }
104 
106  delete unwrap(M);
107 }
108 
109 /*--.. Data layout .........................................................--*/
111  return unwrap(M)->getDataLayout().c_str();
112 }
113 
114 void LLVMSetDataLayout(LLVMModuleRef M, const char *Triple) {
115  unwrap(M)->setDataLayout(Triple);
116 }
117 
118 /*--.. Target triple .......................................................--*/
119 const char * LLVMGetTarget(LLVMModuleRef M) {
120  return unwrap(M)->getTargetTriple().c_str();
121 }
122 
123 void LLVMSetTarget(LLVMModuleRef M, const char *Triple) {
124  unwrap(M)->setTargetTriple(Triple);
125 }
126 
128  unwrap(M)->dump();
129 }
130 
132  char **ErrorMessage) {
133  std::string error;
134  raw_fd_ostream dest(Filename, error);
135  if (!error.empty()) {
136  *ErrorMessage = strdup(error.c_str());
137  return true;
138  }
139 
140  unwrap(M)->print(dest, NULL);
141 
142  if (!error.empty()) {
143  *ErrorMessage = strdup(error.c_str());
144  return true;
145  }
146  dest.flush();
147  return false;
148 }
149 
151  std::string buf;
152  raw_string_ostream os(buf);
153 
154  unwrap(M)->print(os, NULL);
155  os.flush();
156 
157  return strdup(buf.c_str());
158 }
159 
160 /*--.. Operations on inline assembler ......................................--*/
162  unwrap(M)->setModuleInlineAsm(StringRef(Asm));
163 }
164 
165 
166 /*--.. Operations on module contexts ......................................--*/
168  return wrap(&unwrap(M)->getContext());
169 }
170 
171 
172 /*===-- Operations on types -----------------------------------------------===*/
173 
174 /*--.. Operations on all types (mostly) ....................................--*/
175 
177  switch (unwrap(Ty)->getTypeID()) {
178  default: llvm_unreachable("Unhandled TypeID.");
179  case Type::VoidTyID:
180  return LLVMVoidTypeKind;
181  case Type::HalfTyID:
182  return LLVMHalfTypeKind;
183  case Type::FloatTyID:
184  return LLVMFloatTypeKind;
185  case Type::DoubleTyID:
186  return LLVMDoubleTypeKind;
187  case Type::X86_FP80TyID:
188  return LLVMX86_FP80TypeKind;
189  case Type::FP128TyID:
190  return LLVMFP128TypeKind;
191  case Type::PPC_FP128TyID:
192  return LLVMPPC_FP128TypeKind;
193  case Type::LabelTyID:
194  return LLVMLabelTypeKind;
195  case Type::MetadataTyID:
196  return LLVMMetadataTypeKind;
197  case Type::IntegerTyID:
198  return LLVMIntegerTypeKind;
199  case Type::FunctionTyID:
200  return LLVMFunctionTypeKind;
201  case Type::StructTyID:
202  return LLVMStructTypeKind;
203  case Type::ArrayTyID:
204  return LLVMArrayTypeKind;
205  case Type::PointerTyID:
206  return LLVMPointerTypeKind;
207  case Type::VectorTyID:
208  return LLVMVectorTypeKind;
209  case Type::X86_MMXTyID:
210  return LLVMX86_MMXTypeKind;
211  }
212 }
213 
215 {
216  return unwrap(Ty)->isSized();
217 }
218 
220  return wrap(&unwrap(Ty)->getContext());
221 }
222 
224  return unwrap(Ty)->dump();
225 }
226 
228  std::string buf;
229  raw_string_ostream os(buf);
230 
231  unwrap(Ty)->print(os);
232  os.flush();
233 
234  return strdup(buf.c_str());
235 }
236 
237 /*--.. Operations on integer types .........................................--*/
238 
240  return (LLVMTypeRef) Type::getInt1Ty(*unwrap(C));
241 }
243  return (LLVMTypeRef) Type::getInt8Ty(*unwrap(C));
244 }
246  return (LLVMTypeRef) Type::getInt16Ty(*unwrap(C));
247 }
249  return (LLVMTypeRef) Type::getInt32Ty(*unwrap(C));
250 }
252  return (LLVMTypeRef) Type::getInt64Ty(*unwrap(C));
253 }
255  return wrap(IntegerType::get(*unwrap(C), NumBits));
256 }
257 
260 }
263 }
266 }
269 }
272 }
273 LLVMTypeRef LLVMIntType(unsigned NumBits) {
274  return LLVMIntTypeInContext(LLVMGetGlobalContext(), NumBits);
275 }
276 
277 unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy) {
278  return unwrap<IntegerType>(IntegerTy)->getBitWidth();
279 }
280 
281 /*--.. Operations on real types ............................................--*/
282 
284  return (LLVMTypeRef) Type::getHalfTy(*unwrap(C));
285 }
287  return (LLVMTypeRef) Type::getFloatTy(*unwrap(C));
288 }
290  return (LLVMTypeRef) Type::getDoubleTy(*unwrap(C));
291 }
293  return (LLVMTypeRef) Type::getX86_FP80Ty(*unwrap(C));
294 }
296  return (LLVMTypeRef) Type::getFP128Ty(*unwrap(C));
297 }
300 }
302  return (LLVMTypeRef) Type::getX86_MMXTy(*unwrap(C));
303 }
304 
307 }
310 }
313 }
316 }
319 }
322 }
325 }
326 
327 /*--.. Operations on function types ........................................--*/
328 
330  LLVMTypeRef *ParamTypes, unsigned ParamCount,
331  LLVMBool IsVarArg) {
332  ArrayRef<Type*> Tys(unwrap(ParamTypes), ParamCount);
333  return wrap(FunctionType::get(unwrap(ReturnType), Tys, IsVarArg != 0));
334 }
335 
337  return unwrap<FunctionType>(FunctionTy)->isVarArg();
338 }
339 
341  return wrap(unwrap<FunctionType>(FunctionTy)->getReturnType());
342 }
343 
344 unsigned LLVMCountParamTypes(LLVMTypeRef FunctionTy) {
345  return unwrap<FunctionType>(FunctionTy)->getNumParams();
346 }
347 
348 void LLVMGetParamTypes(LLVMTypeRef FunctionTy, LLVMTypeRef *Dest) {
349  FunctionType *Ty = unwrap<FunctionType>(FunctionTy);
351  E = Ty->param_end(); I != E; ++I)
352  *Dest++ = wrap(*I);
353 }
354 
355 /*--.. Operations on struct types ..........................................--*/
356 
358  unsigned ElementCount, LLVMBool Packed) {
359  ArrayRef<Type*> Tys(unwrap(ElementTypes), ElementCount);
360  return wrap(StructType::get(*unwrap(C), Tys, Packed != 0));
361 }
362 
364  unsigned ElementCount, LLVMBool Packed) {
365  return LLVMStructTypeInContext(LLVMGetGlobalContext(), ElementTypes,
366  ElementCount, Packed);
367 }
368 
370 {
371  return wrap(StructType::create(*unwrap(C), Name));
372 }
373 
375 {
376  StructType *Type = unwrap<StructType>(Ty);
377  if (!Type->hasName())
378  return 0;
379  return Type->getName().data();
380 }
381 
382 void LLVMStructSetBody(LLVMTypeRef StructTy, LLVMTypeRef *ElementTypes,
383  unsigned ElementCount, LLVMBool Packed) {
384  ArrayRef<Type*> Tys(unwrap(ElementTypes), ElementCount);
385  unwrap<StructType>(StructTy)->setBody(Tys, Packed != 0);
386 }
387 
389  return unwrap<StructType>(StructTy)->getNumElements();
390 }
391 
393  StructType *Ty = unwrap<StructType>(StructTy);
395  E = Ty->element_end(); I != E; ++I)
396  *Dest++ = wrap(*I);
397 }
398 
400  return unwrap<StructType>(StructTy)->isPacked();
401 }
402 
404  return unwrap<StructType>(StructTy)->isOpaque();
405 }
406 
408  return wrap(unwrap(M)->getTypeByName(Name));
409 }
410 
411 /*--.. Operations on array, pointer, and vector types (sequence types) .....--*/
412 
413 LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount) {
414  return wrap(ArrayType::get(unwrap(ElementType), ElementCount));
415 }
416 
418  return wrap(PointerType::get(unwrap(ElementType), AddressSpace));
419 }
420 
421 LLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType, unsigned ElementCount) {
422  return wrap(VectorType::get(unwrap(ElementType), ElementCount));
423 }
424 
426  return wrap(unwrap<SequentialType>(Ty)->getElementType());
427 }
428 
429 unsigned LLVMGetArrayLength(LLVMTypeRef ArrayTy) {
430  return unwrap<ArrayType>(ArrayTy)->getNumElements();
431 }
432 
434  return unwrap<PointerType>(PointerTy)->getAddressSpace();
435 }
436 
437 unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy) {
438  return unwrap<VectorType>(VectorTy)->getNumElements();
439 }
440 
441 /*--.. Operations on other types ...........................................--*/
442 
444  return wrap(Type::getVoidTy(*unwrap(C)));
445 }
447  return wrap(Type::getLabelTy(*unwrap(C)));
448 }
449 
452 }
455 }
456 
457 /*===-- Operations on values ----------------------------------------------===*/
458 
459 /*--.. Operations on all values ............................................--*/
460 
462  return wrap(unwrap(Val)->getType());
463 }
464 
465 const char *LLVMGetValueName(LLVMValueRef Val) {
466  return unwrap(Val)->getName().data();
467 }
468 
469 void LLVMSetValueName(LLVMValueRef Val, const char *Name) {
470  unwrap(Val)->setName(Name);
471 }
472 
474  unwrap(Val)->dump();
475 }
476 
478  std::string buf;
479  raw_string_ostream os(buf);
480 
481  unwrap(Val)->print(os);
482  os.flush();
483 
484  return strdup(buf.c_str());
485 }
486 
488  unwrap(OldVal)->replaceAllUsesWith(unwrap(NewVal));
489 }
490 
492  return unwrap<Instruction>(Inst)->hasMetadata();
493 }
494 
495 LLVMValueRef LLVMGetMetadata(LLVMValueRef Inst, unsigned KindID) {
496  return wrap(unwrap<Instruction>(Inst)->getMetadata(KindID));
497 }
498 
499 void LLVMSetMetadata(LLVMValueRef Inst, unsigned KindID, LLVMValueRef MD) {
500  unwrap<Instruction>(Inst)->setMetadata(KindID, MD? unwrap<MDNode>(MD) : NULL);
501 }
502 
503 /*--.. Conversion functions ................................................--*/
504 
505 #define LLVM_DEFINE_VALUE_CAST(name) \
506  LLVMValueRef LLVMIsA##name(LLVMValueRef Val) { \
507  return wrap(static_cast<Value*>(dyn_cast_or_null<name>(unwrap(Val)))); \
508  }
509 
511 
512 /*--.. Operations on Uses ..................................................--*/
514  Value *V = unwrap(Val);
516  if (I == V->use_end())
517  return 0;
518  return wrap(&(I.getUse()));
519 }
520 
522  Use *Next = unwrap(U)->getNext();
523  if (Next)
524  return wrap(Next);
525  return 0;
526 }
527 
529  return wrap(unwrap(U)->getUser());
530 }
531 
533  return wrap(unwrap(U)->get());
534 }
535 
536 /*--.. Operations on Users .................................................--*/
538  Value *V = unwrap(Val);
539  if (MDNode *MD = dyn_cast<MDNode>(V))
540  return wrap(MD->getOperand(Index));
541  return wrap(cast<User>(V)->getOperand(Index));
542 }
543 
544 void LLVMSetOperand(LLVMValueRef Val, unsigned Index, LLVMValueRef Op) {
545  unwrap<User>(Val)->setOperand(Index, unwrap(Op));
546 }
547 
549  Value *V = unwrap(Val);
550  if (MDNode *MD = dyn_cast<MDNode>(V))
551  return MD->getNumOperands();
552  return cast<User>(V)->getNumOperands();
553 }
554 
555 /*--.. Operations on constants of any type .................................--*/
556 
558  return wrap(Constant::getNullValue(unwrap(Ty)));
559 }
560 
563 }
564 
566  return wrap(UndefValue::get(unwrap(Ty)));
567 }
568 
570  return isa<Constant>(unwrap(Ty));
571 }
572 
574  if (Constant *C = dyn_cast<Constant>(unwrap(Val)))
575  return C->isNullValue();
576  return false;
577 }
578 
580  return isa<UndefValue>(unwrap(Val));
581 }
582 
584  return
585  wrap(ConstantPointerNull::get(unwrap<PointerType>(Ty)));
586 }
587 
588 /*--.. Operations on metadata nodes ........................................--*/
589 
591  unsigned SLen) {
592  return wrap(MDString::get(*unwrap(C), StringRef(Str, SLen)));
593 }
594 
595 LLVMValueRef LLVMMDString(const char *Str, unsigned SLen) {
596  return LLVMMDStringInContext(LLVMGetGlobalContext(), Str, SLen);
597 }
598 
600  unsigned Count) {
601  return wrap(MDNode::get(*unwrap(C),
602  makeArrayRef(unwrap<Value>(Vals, Count), Count)));
603 }
604 
605 LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count) {
606  return LLVMMDNodeInContext(LLVMGetGlobalContext(), Vals, Count);
607 }
608 
609 const char *LLVMGetMDString(LLVMValueRef V, unsigned* Len) {
610  if (const MDString *S = dyn_cast<MDString>(unwrap(V))) {
611  *Len = S->getString().size();
612  return S->getString().data();
613  }
614  *Len = 0;
615  return 0;
616 }
617 
619 {
620  return cast<MDNode>(unwrap(V))->getNumOperands();
621 }
622 
624 {
625  const MDNode *N = cast<MDNode>(unwrap(V));
626  const unsigned numOperands = N->getNumOperands();
627  for (unsigned i = 0; i < numOperands; i++)
628  Dest[i] = wrap(N->getOperand(i));
629 }
630 
631 unsigned LLVMGetNamedMetadataNumOperands(LLVMModuleRef M, const char* name)
632 {
633  if (NamedMDNode *N = unwrap(M)->getNamedMetadata(name)) {
634  return N->getNumOperands();
635  }
636  return 0;
637 }
638 
640 {
641  NamedMDNode *N = unwrap(M)->getNamedMetadata(name);
642  if (!N)
643  return;
644  for (unsigned i=0;i<N->getNumOperands();i++)
645  Dest[i] = wrap(N->getOperand(i));
646 }
647 
649  LLVMValueRef Val)
650 {
651  NamedMDNode *N = unwrap(M)->getOrInsertNamedMetadata(name);
652  if (!N)
653  return;
654  MDNode *Op = Val ? unwrap<MDNode>(Val) : NULL;
655  if (Op)
656  N->addOperand(Op);
657 }
658 
659 /*--.. Operations on scalar constants ......................................--*/
660 
661 LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N,
662  LLVMBool SignExtend) {
663  return wrap(ConstantInt::get(unwrap<IntegerType>(IntTy), N, SignExtend != 0));
664 }
665 
667  unsigned NumWords,
668  const uint64_t Words[]) {
669  IntegerType *Ty = unwrap<IntegerType>(IntTy);
670  return wrap(ConstantInt::get(Ty->getContext(),
671  APInt(Ty->getBitWidth(),
672  makeArrayRef(Words, NumWords))));
673 }
674 
676  uint8_t Radix) {
677  return wrap(ConstantInt::get(unwrap<IntegerType>(IntTy), StringRef(Str),
678  Radix));
679 }
680 
682  unsigned SLen, uint8_t Radix) {
683  return wrap(ConstantInt::get(unwrap<IntegerType>(IntTy), StringRef(Str, SLen),
684  Radix));
685 }
686 
688  return wrap(ConstantFP::get(unwrap(RealTy), N));
689 }
690 
691 LLVMValueRef LLVMConstRealOfString(LLVMTypeRef RealTy, const char *Text) {
692  return wrap(ConstantFP::get(unwrap(RealTy), StringRef(Text)));
693 }
694 
696  unsigned SLen) {
697  return wrap(ConstantFP::get(unwrap(RealTy), StringRef(Str, SLen)));
698 }
699 
700 unsigned long long LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal) {
701  return unwrap<ConstantInt>(ConstantVal)->getZExtValue();
702 }
703 
704 long long LLVMConstIntGetSExtValue(LLVMValueRef ConstantVal) {
705  return unwrap<ConstantInt>(ConstantVal)->getSExtValue();
706 }
707 
708 /*--.. Operations on composite constants ...................................--*/
709 
711  unsigned Length,
712  LLVMBool DontNullTerminate) {
713  /* Inverted the sense of AddNull because ', 0)' is a
714  better mnemonic for null termination than ', 1)'. */
715  return wrap(ConstantDataArray::getString(*unwrap(C), StringRef(Str, Length),
716  DontNullTerminate == 0));
717 }
719  LLVMValueRef *ConstantVals,
720  unsigned Count, LLVMBool Packed) {
721  Constant **Elements = unwrap<Constant>(ConstantVals, Count);
722  return wrap(ConstantStruct::getAnon(*unwrap(C), makeArrayRef(Elements, Count),
723  Packed != 0));
724 }
725 
726 LLVMValueRef LLVMConstString(const char *Str, unsigned Length,
727  LLVMBool DontNullTerminate) {
728  return LLVMConstStringInContext(LLVMGetGlobalContext(), Str, Length,
729  DontNullTerminate);
730 }
732  LLVMValueRef *ConstantVals, unsigned Length) {
733  ArrayRef<Constant*> V(unwrap<Constant>(ConstantVals, Length), Length);
734  return wrap(ConstantArray::get(ArrayType::get(unwrap(ElementTy), Length), V));
735 }
736 LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count,
737  LLVMBool Packed) {
738  return LLVMConstStructInContext(LLVMGetGlobalContext(), ConstantVals, Count,
739  Packed);
740 }
741 
743  LLVMValueRef *ConstantVals,
744  unsigned Count) {
745  Constant **Elements = unwrap<Constant>(ConstantVals, Count);
746  StructType *Ty = cast<StructType>(unwrap(StructTy));
747 
748  return wrap(ConstantStruct::get(Ty, makeArrayRef(Elements, Count)));
749 }
750 
751 LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size) {
753  unwrap<Constant>(ScalarConstantVals, Size), Size)));
754 }
755 
756 /*-- Opcode mapping */
757 
758 static LLVMOpcode map_to_llvmopcode(int opcode)
759 {
760  switch (opcode) {
761  default: llvm_unreachable("Unhandled Opcode.");
762 #define HANDLE_INST(num, opc, clas) case num: return LLVM##opc;
763 #include "llvm/IR/Instruction.def"
764 #undef HANDLE_INST
765  }
766 }
767 
769 {
770  switch (code) {
771 #define HANDLE_INST(num, opc, clas) case LLVM##opc: return num;
772 #include "llvm/IR/Instruction.def"
773 #undef HANDLE_INST
774  }
775  llvm_unreachable("Unhandled Opcode.");
776 }
777 
778 /*--.. Constant expressions ................................................--*/
779 
781  return map_to_llvmopcode(unwrap<ConstantExpr>(ConstantVal)->getOpcode());
782 }
783 
785  return wrap(ConstantExpr::getAlignOf(unwrap(Ty)));
786 }
787 
789  return wrap(ConstantExpr::getSizeOf(unwrap(Ty)));
790 }
791 
793  return wrap(ConstantExpr::getNeg(unwrap<Constant>(ConstantVal)));
794 }
795 
797  return wrap(ConstantExpr::getNSWNeg(unwrap<Constant>(ConstantVal)));
798 }
799 
801  return wrap(ConstantExpr::getNUWNeg(unwrap<Constant>(ConstantVal)));
802 }
803 
804 
806  return wrap(ConstantExpr::getFNeg(unwrap<Constant>(ConstantVal)));
807 }
808 
810  return wrap(ConstantExpr::getNot(unwrap<Constant>(ConstantVal)));
811 }
812 
814  return wrap(ConstantExpr::getAdd(unwrap<Constant>(LHSConstant),
815  unwrap<Constant>(RHSConstant)));
816 }
817 
819  LLVMValueRef RHSConstant) {
820  return wrap(ConstantExpr::getNSWAdd(unwrap<Constant>(LHSConstant),
821  unwrap<Constant>(RHSConstant)));
822 }
823 
825  LLVMValueRef RHSConstant) {
826  return wrap(ConstantExpr::getNUWAdd(unwrap<Constant>(LHSConstant),
827  unwrap<Constant>(RHSConstant)));
828 }
829 
831  return wrap(ConstantExpr::getFAdd(unwrap<Constant>(LHSConstant),
832  unwrap<Constant>(RHSConstant)));
833 }
834 
836  return wrap(ConstantExpr::getSub(unwrap<Constant>(LHSConstant),
837  unwrap<Constant>(RHSConstant)));
838 }
839 
841  LLVMValueRef RHSConstant) {
842  return wrap(ConstantExpr::getNSWSub(unwrap<Constant>(LHSConstant),
843  unwrap<Constant>(RHSConstant)));
844 }
845 
847  LLVMValueRef RHSConstant) {
848  return wrap(ConstantExpr::getNUWSub(unwrap<Constant>(LHSConstant),
849  unwrap<Constant>(RHSConstant)));
850 }
851 
853  return wrap(ConstantExpr::getFSub(unwrap<Constant>(LHSConstant),
854  unwrap<Constant>(RHSConstant)));
855 }
856 
858  return wrap(ConstantExpr::getMul(unwrap<Constant>(LHSConstant),
859  unwrap<Constant>(RHSConstant)));
860 }
861 
863  LLVMValueRef RHSConstant) {
864  return wrap(ConstantExpr::getNSWMul(unwrap<Constant>(LHSConstant),
865  unwrap<Constant>(RHSConstant)));
866 }
867 
869  LLVMValueRef RHSConstant) {
870  return wrap(ConstantExpr::getNUWMul(unwrap<Constant>(LHSConstant),
871  unwrap<Constant>(RHSConstant)));
872 }
873 
875  return wrap(ConstantExpr::getFMul(unwrap<Constant>(LHSConstant),
876  unwrap<Constant>(RHSConstant)));
877 }
878 
880  return wrap(ConstantExpr::getUDiv(unwrap<Constant>(LHSConstant),
881  unwrap<Constant>(RHSConstant)));
882 }
883 
885  return wrap(ConstantExpr::getSDiv(unwrap<Constant>(LHSConstant),
886  unwrap<Constant>(RHSConstant)));
887 }
888 
890  LLVMValueRef RHSConstant) {
891  return wrap(ConstantExpr::getExactSDiv(unwrap<Constant>(LHSConstant),
892  unwrap<Constant>(RHSConstant)));
893 }
894 
896  return wrap(ConstantExpr::getFDiv(unwrap<Constant>(LHSConstant),
897  unwrap<Constant>(RHSConstant)));
898 }
899 
901  return wrap(ConstantExpr::getURem(unwrap<Constant>(LHSConstant),
902  unwrap<Constant>(RHSConstant)));
903 }
904 
906  return wrap(ConstantExpr::getSRem(unwrap<Constant>(LHSConstant),
907  unwrap<Constant>(RHSConstant)));
908 }
909 
911  return wrap(ConstantExpr::getFRem(unwrap<Constant>(LHSConstant),
912  unwrap<Constant>(RHSConstant)));
913 }
914 
916  return wrap(ConstantExpr::getAnd(unwrap<Constant>(LHSConstant),
917  unwrap<Constant>(RHSConstant)));
918 }
919 
921  return wrap(ConstantExpr::getOr(unwrap<Constant>(LHSConstant),
922  unwrap<Constant>(RHSConstant)));
923 }
924 
926  return wrap(ConstantExpr::getXor(unwrap<Constant>(LHSConstant),
927  unwrap<Constant>(RHSConstant)));
928 }
929 
931  LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
932  return wrap(ConstantExpr::getICmp(Predicate,
933  unwrap<Constant>(LHSConstant),
934  unwrap<Constant>(RHSConstant)));
935 }
936 
938  LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
939  return wrap(ConstantExpr::getFCmp(Predicate,
940  unwrap<Constant>(LHSConstant),
941  unwrap<Constant>(RHSConstant)));
942 }
943 
945  return wrap(ConstantExpr::getShl(unwrap<Constant>(LHSConstant),
946  unwrap<Constant>(RHSConstant)));
947 }
948 
950  return wrap(ConstantExpr::getLShr(unwrap<Constant>(LHSConstant),
951  unwrap<Constant>(RHSConstant)));
952 }
953 
955  return wrap(ConstantExpr::getAShr(unwrap<Constant>(LHSConstant),
956  unwrap<Constant>(RHSConstant)));
957 }
958 
960  LLVMValueRef *ConstantIndices, unsigned NumIndices) {
961  ArrayRef<Constant *> IdxList(unwrap<Constant>(ConstantIndices, NumIndices),
962  NumIndices);
963  return wrap(ConstantExpr::getGetElementPtr(unwrap<Constant>(ConstantVal),
964  IdxList));
965 }
966 
968  LLVMValueRef *ConstantIndices,
969  unsigned NumIndices) {
970  Constant* Val = unwrap<Constant>(ConstantVal);
971  ArrayRef<Constant *> IdxList(unwrap<Constant>(ConstantIndices, NumIndices),
972  NumIndices);
973  return wrap(ConstantExpr::getInBoundsGetElementPtr(Val, IdxList));
974 }
975 
977  return wrap(ConstantExpr::getTrunc(unwrap<Constant>(ConstantVal),
978  unwrap(ToType)));
979 }
980 
982  return wrap(ConstantExpr::getSExt(unwrap<Constant>(ConstantVal),
983  unwrap(ToType)));
984 }
985 
987  return wrap(ConstantExpr::getZExt(unwrap<Constant>(ConstantVal),
988  unwrap(ToType)));
989 }
990 
992  return wrap(ConstantExpr::getFPTrunc(unwrap<Constant>(ConstantVal),
993  unwrap(ToType)));
994 }
995 
997  return wrap(ConstantExpr::getFPExtend(unwrap<Constant>(ConstantVal),
998  unwrap(ToType)));
999 }
1000 
1002  return wrap(ConstantExpr::getUIToFP(unwrap<Constant>(ConstantVal),
1003  unwrap(ToType)));
1004 }
1005 
1007  return wrap(ConstantExpr::getSIToFP(unwrap<Constant>(ConstantVal),
1008  unwrap(ToType)));
1009 }
1010 
1012  return wrap(ConstantExpr::getFPToUI(unwrap<Constant>(ConstantVal),
1013  unwrap(ToType)));
1014 }
1015 
1017  return wrap(ConstantExpr::getFPToSI(unwrap<Constant>(ConstantVal),
1018  unwrap(ToType)));
1019 }
1020 
1022  return wrap(ConstantExpr::getPtrToInt(unwrap<Constant>(ConstantVal),
1023  unwrap(ToType)));
1024 }
1025 
1027  return wrap(ConstantExpr::getIntToPtr(unwrap<Constant>(ConstantVal),
1028  unwrap(ToType)));
1029 }
1030 
1032  return wrap(ConstantExpr::getBitCast(unwrap<Constant>(ConstantVal),
1033  unwrap(ToType)));
1034 }
1035 
1037  LLVMTypeRef ToType) {
1038  return wrap(ConstantExpr::getAddrSpaceCast(unwrap<Constant>(ConstantVal),
1039  unwrap(ToType)));
1040 }
1041 
1043  LLVMTypeRef ToType) {
1044  return wrap(ConstantExpr::getZExtOrBitCast(unwrap<Constant>(ConstantVal),
1045  unwrap(ToType)));
1046 }
1047 
1049  LLVMTypeRef ToType) {
1050  return wrap(ConstantExpr::getSExtOrBitCast(unwrap<Constant>(ConstantVal),
1051  unwrap(ToType)));
1052 }
1053 
1055  LLVMTypeRef ToType) {
1056  return wrap(ConstantExpr::getTruncOrBitCast(unwrap<Constant>(ConstantVal),
1057  unwrap(ToType)));
1058 }
1059 
1061  LLVMTypeRef ToType) {
1062  return wrap(ConstantExpr::getPointerCast(unwrap<Constant>(ConstantVal),
1063  unwrap(ToType)));
1064 }
1065 
1067  LLVMBool isSigned) {
1068  return wrap(ConstantExpr::getIntegerCast(unwrap<Constant>(ConstantVal),
1069  unwrap(ToType), isSigned));
1070 }
1071 
1073  return wrap(ConstantExpr::getFPCast(unwrap<Constant>(ConstantVal),
1074  unwrap(ToType)));
1075 }
1076 
1078  LLVMValueRef ConstantIfTrue,
1079  LLVMValueRef ConstantIfFalse) {
1080  return wrap(ConstantExpr::getSelect(unwrap<Constant>(ConstantCondition),
1081  unwrap<Constant>(ConstantIfTrue),
1082  unwrap<Constant>(ConstantIfFalse)));
1083 }
1084 
1086  LLVMValueRef IndexConstant) {
1087  return wrap(ConstantExpr::getExtractElement(unwrap<Constant>(VectorConstant),
1088  unwrap<Constant>(IndexConstant)));
1089 }
1090 
1092  LLVMValueRef ElementValueConstant,
1093  LLVMValueRef IndexConstant) {
1094  return wrap(ConstantExpr::getInsertElement(unwrap<Constant>(VectorConstant),
1095  unwrap<Constant>(ElementValueConstant),
1096  unwrap<Constant>(IndexConstant)));
1097 }
1098 
1100  LLVMValueRef VectorBConstant,
1101  LLVMValueRef MaskConstant) {
1102  return wrap(ConstantExpr::getShuffleVector(unwrap<Constant>(VectorAConstant),
1103  unwrap<Constant>(VectorBConstant),
1104  unwrap<Constant>(MaskConstant)));
1105 }
1106 
1107 LLVMValueRef LLVMConstExtractValue(LLVMValueRef AggConstant, unsigned *IdxList,
1108  unsigned NumIdx) {
1109  return wrap(ConstantExpr::getExtractValue(unwrap<Constant>(AggConstant),
1110  makeArrayRef(IdxList, NumIdx)));
1111 }
1112 
1114  LLVMValueRef ElementValueConstant,
1115  unsigned *IdxList, unsigned NumIdx) {
1116  return wrap(ConstantExpr::getInsertValue(unwrap<Constant>(AggConstant),
1117  unwrap<Constant>(ElementValueConstant),
1118  makeArrayRef(IdxList, NumIdx)));
1119 }
1120 
1121 LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty, const char *AsmString,
1122  const char *Constraints,
1123  LLVMBool HasSideEffects,
1124  LLVMBool IsAlignStack) {
1125  return wrap(InlineAsm::get(dyn_cast<FunctionType>(unwrap(Ty)), AsmString,
1126  Constraints, HasSideEffects, IsAlignStack));
1127 }
1128 
1130  return wrap(BlockAddress::get(unwrap<Function>(F), unwrap(BB)));
1131 }
1132 
1133 /*--.. Operations on global variables, functions, and aliases (globals) ....--*/
1134 
1136  return wrap(unwrap<GlobalValue>(Global)->getParent());
1137 }
1138 
1140  return unwrap<GlobalValue>(Global)->isDeclaration();
1141 }
1142 
1144  switch (unwrap<GlobalValue>(Global)->getLinkage()) {
1146  return LLVMExternalLinkage;
1150  return LLVMLinkOnceAnyLinkage;
1152  return LLVMLinkOnceODRLinkage;
1154  return LLVMWeakAnyLinkage;
1156  return LLVMWeakODRLinkage;
1158  return LLVMAppendingLinkage;
1160  return LLVMInternalLinkage;
1162  return LLVMPrivateLinkage;
1164  return LLVMLinkerPrivateLinkage;
1168  return LLVMDLLImportLinkage;
1170  return LLVMDLLExportLinkage;
1172  return LLVMExternalWeakLinkage;
1174  return LLVMCommonLinkage;
1175  }
1176 
1177  llvm_unreachable("Invalid GlobalValue linkage!");
1178 }
1179 
1180 void LLVMSetLinkage(LLVMValueRef Global, LLVMLinkage Linkage) {
1181  GlobalValue *GV = unwrap<GlobalValue>(Global);
1182 
1183  switch (Linkage) {
1184  case LLVMExternalLinkage:
1186  break;
1189  break;
1192  break;
1195  break;
1197  DEBUG(errs() << "LLVMSetLinkage(): LLVMLinkOnceODRAutoHideLinkage is no "
1198  "longer supported.");
1199  break;
1200  case LLVMWeakAnyLinkage:
1202  break;
1203  case LLVMWeakODRLinkage:
1205  break;
1206  case LLVMAppendingLinkage:
1208  break;
1209  case LLVMInternalLinkage:
1211  break;
1212  case LLVMPrivateLinkage:
1214  break;
1217  break;
1220  break;
1221  case LLVMDLLImportLinkage:
1223  break;
1224  case LLVMDLLExportLinkage:
1226  break;
1229  break;
1230  case LLVMGhostLinkage:
1231  DEBUG(errs()
1232  << "LLVMSetLinkage(): LLVMGhostLinkage is no longer supported.");
1233  break;
1234  case LLVMCommonLinkage:
1236  break;
1237  }
1238 }
1239 
1240 const char *LLVMGetSection(LLVMValueRef Global) {
1241  return unwrap<GlobalValue>(Global)->getSection().c_str();
1242 }
1243 
1244 void LLVMSetSection(LLVMValueRef Global, const char *Section) {
1245  unwrap<GlobalValue>(Global)->setSection(Section);
1246 }
1247 
1249  return static_cast<LLVMVisibility>(
1250  unwrap<GlobalValue>(Global)->getVisibility());
1251 }
1252 
1254  unwrap<GlobalValue>(Global)
1255  ->setVisibility(static_cast<GlobalValue::VisibilityTypes>(Viz));
1256 }
1257 
1258 /*--.. Operations on global variables, load and store instructions .........--*/
1259 
1261  Value *P = unwrap<Value>(V);
1262  if (GlobalValue *GV = dyn_cast<GlobalValue>(P))
1263  return GV->getAlignment();
1264  if (LoadInst *LI = dyn_cast<LoadInst>(P))
1265  return LI->getAlignment();
1266  if (StoreInst *SI = dyn_cast<StoreInst>(P))
1267  return SI->getAlignment();
1268 
1269  llvm_unreachable("only GlobalValue, LoadInst and StoreInst have alignment");
1270 }
1271 
1272 void LLVMSetAlignment(LLVMValueRef V, unsigned Bytes) {
1273  Value *P = unwrap<Value>(V);
1274  if (GlobalValue *GV = dyn_cast<GlobalValue>(P))
1275  GV->setAlignment(Bytes);
1276  else if (LoadInst *LI = dyn_cast<LoadInst>(P))
1277  LI->setAlignment(Bytes);
1278  else if (StoreInst *SI = dyn_cast<StoreInst>(P))
1279  SI->setAlignment(Bytes);
1280  else
1281  llvm_unreachable("only GlobalValue, LoadInst and StoreInst have alignment");
1282 }
1283 
1284 /*--.. Operations on global variables ......................................--*/
1285 
1287  return wrap(new GlobalVariable(*unwrap(M), unwrap(Ty), false,
1288  GlobalValue::ExternalLinkage, 0, Name));
1289 }
1290 
1292  const char *Name,
1293  unsigned AddressSpace) {
1294  return wrap(new GlobalVariable(*unwrap(M), unwrap(Ty), false,
1295  GlobalValue::ExternalLinkage, 0, Name, 0,
1296  GlobalVariable::NotThreadLocal, AddressSpace));
1297 }
1298 
1300  return wrap(unwrap(M)->getNamedGlobal(Name));
1301 }
1302 
1304  Module *Mod = unwrap(M);
1306  if (I == Mod->global_end())
1307  return 0;
1308  return wrap(I);
1309 }
1310 
1312  Module *Mod = unwrap(M);
1314  if (I == Mod->global_begin())
1315  return 0;
1316  return wrap(--I);
1317 }
1318 
1320  GlobalVariable *GV = unwrap<GlobalVariable>(GlobalVar);
1322  if (++I == GV->getParent()->global_end())
1323  return 0;
1324  return wrap(I);
1325 }
1326 
1328  GlobalVariable *GV = unwrap<GlobalVariable>(GlobalVar);
1330  if (I == GV->getParent()->global_begin())
1331  return 0;
1332  return wrap(--I);
1333 }
1334 
1336  unwrap<GlobalVariable>(GlobalVar)->eraseFromParent();
1337 }
1338 
1340  GlobalVariable* GV = unwrap<GlobalVariable>(GlobalVar);
1341  if ( !GV->hasInitializer() )
1342  return 0;
1343  return wrap(GV->getInitializer());
1344 }
1345 
1347  unwrap<GlobalVariable>(GlobalVar)
1348  ->setInitializer(unwrap<Constant>(ConstantVal));
1349 }
1350 
1352  return unwrap<GlobalVariable>(GlobalVar)->isThreadLocal();
1353 }
1354 
1356  unwrap<GlobalVariable>(GlobalVar)->setThreadLocal(IsThreadLocal != 0);
1357 }
1358 
1360  return unwrap<GlobalVariable>(GlobalVar)->isConstant();
1361 }
1362 
1364  unwrap<GlobalVariable>(GlobalVar)->setConstant(IsConstant != 0);
1365 }
1366 
1368  switch (unwrap<GlobalVariable>(GlobalVar)->getThreadLocalMode()) {
1370  return LLVMNotThreadLocal;
1374  return LLVMLocalDynamicTLSModel;
1376  return LLVMInitialExecTLSModel;
1378  return LLVMLocalExecTLSModel;
1379  }
1380 
1381  llvm_unreachable("Invalid GlobalVariable thread local mode");
1382 }
1383 
1385  GlobalVariable *GV = unwrap<GlobalVariable>(GlobalVar);
1386 
1387  switch (Mode) {
1388  case LLVMNotThreadLocal:
1390  break;
1393  break;
1396  break;
1399  break;
1400  case LLVMLocalExecTLSModel:
1402  break;
1403  }
1404 }
1405 
1407  return unwrap<GlobalVariable>(GlobalVar)->isExternallyInitialized();
1408 }
1409 
1411  unwrap<GlobalVariable>(GlobalVar)->setExternallyInitialized(IsExtInit);
1412 }
1413 
1414 /*--.. Operations on aliases ......................................--*/
1415 
1417  const char *Name) {
1418  return wrap(new GlobalAlias(unwrap(Ty), GlobalValue::ExternalLinkage, Name,
1419  unwrap<Constant>(Aliasee), unwrap (M)));
1420 }
1421 
1422 /*--.. Operations on functions .............................................--*/
1423 
1425  LLVMTypeRef FunctionTy) {
1426  return wrap(Function::Create(unwrap<FunctionType>(FunctionTy),
1428 }
1429 
1431  return wrap(unwrap(M)->getFunction(Name));
1432 }
1433 
1435  Module *Mod = unwrap(M);
1436  Module::iterator I = Mod->begin();
1437  if (I == Mod->end())
1438  return 0;
1439  return wrap(I);
1440 }
1441 
1443  Module *Mod = unwrap(M);
1444  Module::iterator I = Mod->end();
1445  if (I == Mod->begin())
1446  return 0;
1447  return wrap(--I);
1448 }
1449 
1451  Function *Func = unwrap<Function>(Fn);
1453  if (++I == Func->getParent()->end())
1454  return 0;
1455  return wrap(I);
1456 }
1457 
1459  Function *Func = unwrap<Function>(Fn);
1461  if (I == Func->getParent()->begin())
1462  return 0;
1463  return wrap(--I);
1464 }
1465 
1467  unwrap<Function>(Fn)->eraseFromParent();
1468 }
1469 
1471  if (Function *F = dyn_cast<Function>(unwrap(Fn)))
1472  return F->getIntrinsicID();
1473  return 0;
1474 }
1475 
1477  return unwrap<Function>(Fn)->getCallingConv();
1478 }
1479 
1480 void LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC) {
1481  return unwrap<Function>(Fn)->setCallingConv(
1482  static_cast<CallingConv::ID>(CC));
1483 }
1484 
1485 const char *LLVMGetGC(LLVMValueRef Fn) {
1486  Function *F = unwrap<Function>(Fn);
1487  return F->hasGC()? F->getGC() : 0;
1488 }
1489 
1490 void LLVMSetGC(LLVMValueRef Fn, const char *GC) {
1491  Function *F = unwrap<Function>(Fn);
1492  if (GC)
1493  F->setGC(GC);
1494  else
1495  F->clearGC();
1496 }
1497 
1499  Function *Func = unwrap<Function>(Fn);
1500  const AttributeSet PAL = Func->getAttributes();
1501  AttrBuilder B(PA);
1502  const AttributeSet PALnew =
1503  PAL.addAttributes(Func->getContext(), AttributeSet::FunctionIndex,
1504  AttributeSet::get(Func->getContext(),
1505  AttributeSet::FunctionIndex, B));
1506  Func->setAttributes(PALnew);
1507 }
1508 
1510  const char *V) {
1511  Function *Func = unwrap<Function>(Fn);
1512  AttributeSet::AttrIndex Idx =
1513  AttributeSet::AttrIndex(AttributeSet::FunctionIndex);
1514  AttrBuilder B;
1515 
1516  B.addAttribute(A, V);
1517  AttributeSet Set = AttributeSet::get(Func->getContext(), Idx, B);
1518  Func->addAttributes(Idx, Set);
1519 }
1520 
1522  Function *Func = unwrap<Function>(Fn);
1523  const AttributeSet PAL = Func->getAttributes();
1524  AttrBuilder B(PA);
1525  const AttributeSet PALnew =
1526  PAL.removeAttributes(Func->getContext(), AttributeSet::FunctionIndex,
1527  AttributeSet::get(Func->getContext(),
1528  AttributeSet::FunctionIndex, B));
1529  Func->setAttributes(PALnew);
1530 }
1531 
1533  Function *Func = unwrap<Function>(Fn);
1534  const AttributeSet PAL = Func->getAttributes();
1535  return (LLVMAttribute)PAL.Raw(AttributeSet::FunctionIndex);
1536 }
1537 
1538 /*--.. Operations on parameters ............................................--*/
1539 
1541  // This function is strictly redundant to
1542  // LLVMCountParamTypes(LLVMGetElementType(LLVMTypeOf(FnRef)))
1543  return unwrap<Function>(FnRef)->arg_size();
1544 }
1545 
1546 void LLVMGetParams(LLVMValueRef FnRef, LLVMValueRef *ParamRefs) {
1547  Function *Fn = unwrap<Function>(FnRef);
1548  for (Function::arg_iterator I = Fn->arg_begin(),
1549  E = Fn->arg_end(); I != E; I++)
1550  *ParamRefs++ = wrap(I);
1551 }
1552 
1553 LLVMValueRef LLVMGetParam(LLVMValueRef FnRef, unsigned index) {
1554  Function::arg_iterator AI = unwrap<Function>(FnRef)->arg_begin();
1555  while (index --> 0)
1556  AI++;
1557  return wrap(AI);
1558 }
1559 
1561  return wrap(unwrap<Argument>(V)->getParent());
1562 }
1563 
1565  Function *Func = unwrap<Function>(Fn);
1567  if (I == Func->arg_end())
1568  return 0;
1569  return wrap(I);
1570 }
1571 
1573  Function *Func = unwrap<Function>(Fn);
1574  Function::arg_iterator I = Func->arg_end();
1575  if (I == Func->arg_begin())
1576  return 0;
1577  return wrap(--I);
1578 }
1579 
1581  Argument *A = unwrap<Argument>(Arg);
1583  if (++I == A->getParent()->arg_end())
1584  return 0;
1585  return wrap(I);
1586 }
1587 
1589  Argument *A = unwrap<Argument>(Arg);
1591  if (I == A->getParent()->arg_begin())
1592  return 0;
1593  return wrap(--I);
1594 }
1595 
1597  Argument *A = unwrap<Argument>(Arg);
1598  AttrBuilder B(PA);
1599  A->addAttr(AttributeSet::get(A->getContext(), A->getArgNo() + 1, B));
1600 }
1601 
1603  Argument *A = unwrap<Argument>(Arg);
1604  AttrBuilder B(PA);
1605  A->removeAttr(AttributeSet::get(A->getContext(), A->getArgNo() + 1, B));
1606 }
1607 
1609  Argument *A = unwrap<Argument>(Arg);
1610  return (LLVMAttribute)A->getParent()->getAttributes().
1611  Raw(A->getArgNo()+1);
1612 }
1613 
1614 
1615 void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align) {
1616  Argument *A = unwrap<Argument>(Arg);
1617  AttrBuilder B;
1618  B.addAlignmentAttr(align);
1619  A->addAttr(AttributeSet::get(A->getContext(),A->getArgNo() + 1, B));
1620 }
1621 
1622 /*--.. Operations on basic blocks ..........................................--*/
1623 
1625  return wrap(static_cast<Value*>(unwrap(BB)));
1626 }
1627 
1629  return isa<BasicBlock>(unwrap(Val));
1630 }
1631 
1633  return wrap(unwrap<BasicBlock>(Val));
1634 }
1635 
1637  return wrap(unwrap(BB)->getParent());
1638 }
1639 
1641  return wrap(unwrap(BB)->getTerminator());
1642 }
1643 
1645  return unwrap<Function>(FnRef)->size();
1646 }
1647 
1648 void LLVMGetBasicBlocks(LLVMValueRef FnRef, LLVMBasicBlockRef *BasicBlocksRefs){
1649  Function *Fn = unwrap<Function>(FnRef);
1650  for (Function::iterator I = Fn->begin(), E = Fn->end(); I != E; I++)
1651  *BasicBlocksRefs++ = wrap(I);
1652 }
1653 
1655  return wrap(&unwrap<Function>(Fn)->getEntryBlock());
1656 }
1657 
1659  Function *Func = unwrap<Function>(Fn);
1660  Function::iterator I = Func->begin();
1661  if (I == Func->end())
1662  return 0;
1663  return wrap(I);
1664 }
1665 
1667  Function *Func = unwrap<Function>(Fn);
1668  Function::iterator I = Func->end();
1669  if (I == Func->begin())
1670  return 0;
1671  return wrap(--I);
1672 }
1673 
1675  BasicBlock *Block = unwrap(BB);
1676  Function::iterator I = Block;
1677  if (++I == Block->getParent()->end())
1678  return 0;
1679  return wrap(I);
1680 }
1681 
1683  BasicBlock *Block = unwrap(BB);
1684  Function::iterator I = Block;
1685  if (I == Block->getParent()->begin())
1686  return 0;
1687  return wrap(--I);
1688 }
1689 
1691  LLVMValueRef FnRef,
1692  const char *Name) {
1693  return wrap(BasicBlock::Create(*unwrap(C), Name, unwrap<Function>(FnRef)));
1694 }
1695 
1697  return LLVMAppendBasicBlockInContext(LLVMGetGlobalContext(), FnRef, Name);
1698 }
1699 
1701  LLVMBasicBlockRef BBRef,
1702  const char *Name) {
1703  BasicBlock *BB = unwrap(BBRef);
1704  return wrap(BasicBlock::Create(*unwrap(C), Name, BB->getParent(), BB));
1705 }
1706 
1708  const char *Name) {
1709  return LLVMInsertBasicBlockInContext(LLVMGetGlobalContext(), BBRef, Name);
1710 }
1711 
1713  unwrap(BBRef)->eraseFromParent();
1714 }
1715 
1717  unwrap(BBRef)->removeFromParent();
1718 }
1719 
1721  unwrap(BB)->moveBefore(unwrap(MovePos));
1722 }
1723 
1725  unwrap(BB)->moveAfter(unwrap(MovePos));
1726 }
1727 
1728 /*--.. Operations on instructions ..........................................--*/
1729 
1731  return wrap(unwrap<Instruction>(Inst)->getParent());
1732 }
1733 
1735  BasicBlock *Block = unwrap(BB);
1736  BasicBlock::iterator I = Block->begin();
1737  if (I == Block->end())
1738  return 0;
1739  return wrap(I);
1740 }
1741 
1743  BasicBlock *Block = unwrap(BB);
1744  BasicBlock::iterator I = Block->end();
1745  if (I == Block->begin())
1746  return 0;
1747  return wrap(--I);
1748 }
1749 
1751  Instruction *Instr = unwrap<Instruction>(Inst);
1752  BasicBlock::iterator I = Instr;
1753  if (++I == Instr->getParent()->end())
1754  return 0;
1755  return wrap(I);
1756 }
1757 
1759  Instruction *Instr = unwrap<Instruction>(Inst);
1760  BasicBlock::iterator I = Instr;
1761  if (I == Instr->getParent()->begin())
1762  return 0;
1763  return wrap(--I);
1764 }
1765 
1767  unwrap<Instruction>(Inst)->eraseFromParent();
1768 }
1769 
1771  if (ICmpInst *I = dyn_cast<ICmpInst>(unwrap(Inst)))
1772  return (LLVMIntPredicate)I->getPredicate();
1773  if (ConstantExpr *CE = dyn_cast<ConstantExpr>(unwrap(Inst)))
1774  if (CE->getOpcode() == Instruction::ICmp)
1775  return (LLVMIntPredicate)CE->getPredicate();
1776  return (LLVMIntPredicate)0;
1777 }
1778 
1780  if (Instruction *C = dyn_cast<Instruction>(unwrap(Inst)))
1781  return map_to_llvmopcode(C->getOpcode());
1782  return (LLVMOpcode)0;
1783 }
1784 
1785 /*--.. Call and invoke instructions ........................................--*/
1786 
1788  Value *V = unwrap(Instr);
1789  if (CallInst *CI = dyn_cast<CallInst>(V))
1790  return CI->getCallingConv();
1791  if (InvokeInst *II = dyn_cast<InvokeInst>(V))
1792  return II->getCallingConv();
1793  llvm_unreachable("LLVMGetInstructionCallConv applies only to call and invoke!");
1794 }
1795 
1796 void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC) {
1797  Value *V = unwrap(Instr);
1798  if (CallInst *CI = dyn_cast<CallInst>(V))
1799  return CI->setCallingConv(static_cast<CallingConv::ID>(CC));
1800  else if (InvokeInst *II = dyn_cast<InvokeInst>(V))
1801  return II->setCallingConv(static_cast<CallingConv::ID>(CC));
1802  llvm_unreachable("LLVMSetInstructionCallConv applies only to call and invoke!");
1803 }
1804 
1805 void LLVMAddInstrAttribute(LLVMValueRef Instr, unsigned index,
1806  LLVMAttribute PA) {
1807  CallSite Call = CallSite(unwrap<Instruction>(Instr));
1808  AttrBuilder B(PA);
1809  Call.setAttributes(
1810  Call.getAttributes().addAttributes(Call->getContext(), index,
1811  AttributeSet::get(Call->getContext(),
1812  index, B)));
1813 }
1814 
1815 void LLVMRemoveInstrAttribute(LLVMValueRef Instr, unsigned index,
1816  LLVMAttribute PA) {
1817  CallSite Call = CallSite(unwrap<Instruction>(Instr));
1818  AttrBuilder B(PA);
1819  Call.setAttributes(Call.getAttributes()
1820  .removeAttributes(Call->getContext(), index,
1821  AttributeSet::get(Call->getContext(),
1822  index, B)));
1823 }
1824 
1825 void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index,
1826  unsigned align) {
1827  CallSite Call = CallSite(unwrap<Instruction>(Instr));
1828  AttrBuilder B;
1829  B.addAlignmentAttr(align);
1830  Call.setAttributes(Call.getAttributes()
1831  .addAttributes(Call->getContext(), index,
1832  AttributeSet::get(Call->getContext(),
1833  index, B)));
1834 }
1835 
1836 /*--.. Operations on call instructions (only) ..............................--*/
1837 
1839  return unwrap<CallInst>(Call)->isTailCall();
1840 }
1841 
1843  unwrap<CallInst>(Call)->setTailCall(isTailCall);
1844 }
1845 
1846 /*--.. Operations on switch instructions (only) ............................--*/
1847 
1849  return wrap(unwrap<SwitchInst>(Switch)->getDefaultDest());
1850 }
1851 
1852 /*--.. Operations on phi nodes .............................................--*/
1853 
1854 void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues,
1855  LLVMBasicBlockRef *IncomingBlocks, unsigned Count) {
1856  PHINode *PhiVal = unwrap<PHINode>(PhiNode);
1857  for (unsigned I = 0; I != Count; ++I)
1858  PhiVal->addIncoming(unwrap(IncomingValues[I]), unwrap(IncomingBlocks[I]));
1859 }
1860 
1861 unsigned LLVMCountIncoming(LLVMValueRef PhiNode) {
1862  return unwrap<PHINode>(PhiNode)->getNumIncomingValues();
1863 }
1864 
1866  return wrap(unwrap<PHINode>(PhiNode)->getIncomingValue(Index));
1867 }
1868 
1870  return wrap(unwrap<PHINode>(PhiNode)->getIncomingBlock(Index));
1871 }
1872 
1873 
1874 /*===-- Instruction builders ----------------------------------------------===*/
1875 
1877  return wrap(new IRBuilder<>(*unwrap(C)));
1878 }
1879 
1882 }
1883 
1885  LLVMValueRef Instr) {
1886  BasicBlock *BB = unwrap(Block);
1887  Instruction *I = Instr? unwrap<Instruction>(Instr) : (Instruction*) BB->end();
1888  unwrap(Builder)->SetInsertPoint(BB, I);
1889 }
1890 
1892  Instruction *I = unwrap<Instruction>(Instr);
1893  unwrap(Builder)->SetInsertPoint(I->getParent(), I);
1894 }
1895 
1897  BasicBlock *BB = unwrap(Block);
1898  unwrap(Builder)->SetInsertPoint(BB);
1899 }
1900 
1902  return wrap(unwrap(Builder)->GetInsertBlock());
1903 }
1904 
1906  unwrap(Builder)->ClearInsertionPoint();
1907 }
1908 
1910  unwrap(Builder)->Insert(unwrap<Instruction>(Instr));
1911 }
1912 
1914  const char *Name) {
1915  unwrap(Builder)->Insert(unwrap<Instruction>(Instr), Name);
1916 }
1917 
1919  delete unwrap(Builder);
1920 }
1921 
1922 /*--.. Metadata builders ...................................................--*/
1923 
1925  MDNode *Loc = L ? unwrap<MDNode>(L) : NULL;
1926  unwrap(Builder)->SetCurrentDebugLocation(DebugLoc::getFromDILocation(Loc));
1927 }
1928 
1930  return wrap(unwrap(Builder)->getCurrentDebugLocation()
1931  .getAsMDNode(unwrap(Builder)->getContext()));
1932 }
1933 
1935  unwrap(Builder)->SetInstDebugLocation(unwrap<Instruction>(Inst));
1936 }
1937 
1938 
1939 /*--.. Instruction builders ................................................--*/
1940 
1942  return wrap(unwrap(B)->CreateRetVoid());
1943 }
1944 
1946  return wrap(unwrap(B)->CreateRet(unwrap(V)));
1947 }
1948 
1950  unsigned N) {
1951  return wrap(unwrap(B)->CreateAggregateRet(unwrap(RetVals), N));
1952 }
1953 
1955  return wrap(unwrap(B)->CreateBr(unwrap(Dest)));
1956 }
1957 
1959  LLVMBasicBlockRef Then, LLVMBasicBlockRef Else) {
1960  return wrap(unwrap(B)->CreateCondBr(unwrap(If), unwrap(Then), unwrap(Else)));
1961 }
1962 
1964  LLVMBasicBlockRef Else, unsigned NumCases) {
1965  return wrap(unwrap(B)->CreateSwitch(unwrap(V), unwrap(Else), NumCases));
1966 }
1967 
1969  unsigned NumDests) {
1970  return wrap(unwrap(B)->CreateIndirectBr(unwrap(Addr), NumDests));
1971 }
1972 
1974  LLVMValueRef *Args, unsigned NumArgs,
1976  const char *Name) {
1977  return wrap(unwrap(B)->CreateInvoke(unwrap(Fn), unwrap(Then), unwrap(Catch),
1978  makeArrayRef(unwrap(Args), NumArgs),
1979  Name));
1980 }
1981 
1983  LLVMValueRef PersFn, unsigned NumClauses,
1984  const char *Name) {
1985  return wrap(unwrap(B)->CreateLandingPad(unwrap(Ty),
1986  cast<Function>(unwrap(PersFn)),
1987  NumClauses, Name));
1988 }
1989 
1991  return wrap(unwrap(B)->CreateResume(unwrap(Exn)));
1992 }
1993 
1995  return wrap(unwrap(B)->CreateUnreachable());
1996 }
1997 
1999  LLVMBasicBlockRef Dest) {
2000  unwrap<SwitchInst>(Switch)->addCase(unwrap<ConstantInt>(OnVal), unwrap(Dest));
2001 }
2002 
2004  unwrap<IndirectBrInst>(IndirectBr)->addDestination(unwrap(Dest));
2005 }
2006 
2007 void LLVMAddClause(LLVMValueRef LandingPad, LLVMValueRef ClauseVal) {
2008  unwrap<LandingPadInst>(LandingPad)->
2009  addClause(cast<Constant>(unwrap(ClauseVal)));
2010 }
2011 
2012 void LLVMSetCleanup(LLVMValueRef LandingPad, LLVMBool Val) {
2013  unwrap<LandingPadInst>(LandingPad)->setCleanup(Val);
2014 }
2015 
2016 /*--.. Arithmetic ..........................................................--*/
2017 
2019  const char *Name) {
2020  return wrap(unwrap(B)->CreateAdd(unwrap(LHS), unwrap(RHS), Name));
2021 }
2022 
2024  const char *Name) {
2025  return wrap(unwrap(B)->CreateNSWAdd(unwrap(LHS), unwrap(RHS), Name));
2026 }
2027 
2029  const char *Name) {
2030  return wrap(unwrap(B)->CreateNUWAdd(unwrap(LHS), unwrap(RHS), Name));
2031 }
2032 
2034  const char *Name) {
2035  return wrap(unwrap(B)->CreateFAdd(unwrap(LHS), unwrap(RHS), Name));
2036 }
2037 
2039  const char *Name) {
2040  return wrap(unwrap(B)->CreateSub(unwrap(LHS), unwrap(RHS), Name));
2041 }
2042 
2044  const char *Name) {
2045  return wrap(unwrap(B)->CreateNSWSub(unwrap(LHS), unwrap(RHS), Name));
2046 }
2047 
2049  const char *Name) {
2050  return wrap(unwrap(B)->CreateNUWSub(unwrap(LHS), unwrap(RHS), Name));
2051 }
2052 
2054  const char *Name) {
2055  return wrap(unwrap(B)->CreateFSub(unwrap(LHS), unwrap(RHS), Name));
2056 }
2057 
2059  const char *Name) {
2060  return wrap(unwrap(B)->CreateMul(unwrap(LHS), unwrap(RHS), Name));
2061 }
2062 
2064  const char *Name) {
2065  return wrap(unwrap(B)->CreateNSWMul(unwrap(LHS), unwrap(RHS), Name));
2066 }
2067 
2069  const char *Name) {
2070  return wrap(unwrap(B)->CreateNUWMul(unwrap(LHS), unwrap(RHS), Name));
2071 }
2072 
2074  const char *Name) {
2075  return wrap(unwrap(B)->CreateFMul(unwrap(LHS), unwrap(RHS), Name));
2076 }
2077 
2079  const char *Name) {
2080  return wrap(unwrap(B)->CreateUDiv(unwrap(LHS), unwrap(RHS), Name));
2081 }
2082 
2084  const char *Name) {
2085  return wrap(unwrap(B)->CreateSDiv(unwrap(LHS), unwrap(RHS), Name));
2086 }
2087 
2089  LLVMValueRef RHS, const char *Name) {
2090  return wrap(unwrap(B)->CreateExactSDiv(unwrap(LHS), unwrap(RHS), Name));
2091 }
2092 
2094  const char *Name) {
2095  return wrap(unwrap(B)->CreateFDiv(unwrap(LHS), unwrap(RHS), Name));
2096 }
2097 
2099  const char *Name) {
2100  return wrap(unwrap(B)->CreateURem(unwrap(LHS), unwrap(RHS), Name));
2101 }
2102 
2104  const char *Name) {
2105  return wrap(unwrap(B)->CreateSRem(unwrap(LHS), unwrap(RHS), Name));
2106 }
2107 
2109  const char *Name) {
2110  return wrap(unwrap(B)->CreateFRem(unwrap(LHS), unwrap(RHS), Name));
2111 }
2112 
2114  const char *Name) {
2115  return wrap(unwrap(B)->CreateShl(unwrap(LHS), unwrap(RHS), Name));
2116 }
2117 
2119  const char *Name) {
2120  return wrap(unwrap(B)->CreateLShr(unwrap(LHS), unwrap(RHS), Name));
2121 }
2122 
2124  const char *Name) {
2125  return wrap(unwrap(B)->CreateAShr(unwrap(LHS), unwrap(RHS), Name));
2126 }
2127 
2129  const char *Name) {
2130  return wrap(unwrap(B)->CreateAnd(unwrap(LHS), unwrap(RHS), Name));
2131 }
2132 
2134  const char *Name) {
2135  return wrap(unwrap(B)->CreateOr(unwrap(LHS), unwrap(RHS), Name));
2136 }
2137 
2139  const char *Name) {
2140  return wrap(unwrap(B)->CreateXor(unwrap(LHS), unwrap(RHS), Name));
2141 }
2142 
2144  LLVMValueRef LHS, LLVMValueRef RHS,
2145  const char *Name) {
2146  return wrap(unwrap(B)->CreateBinOp(Instruction::BinaryOps(map_from_llvmopcode(Op)), unwrap(LHS),
2147  unwrap(RHS), Name));
2148 }
2149 
2151  return wrap(unwrap(B)->CreateNeg(unwrap(V), Name));
2152 }
2153 
2155  const char *Name) {
2156  return wrap(unwrap(B)->CreateNSWNeg(unwrap(V), Name));
2157 }
2158 
2160  const char *Name) {
2161  return wrap(unwrap(B)->CreateNUWNeg(unwrap(V), Name));
2162 }
2163 
2165  return wrap(unwrap(B)->CreateFNeg(unwrap(V), Name));
2166 }
2167 
2169  return wrap(unwrap(B)->CreateNot(unwrap(V), Name));
2170 }
2171 
2172 /*--.. Memory ..............................................................--*/
2173 
2175  const char *Name) {
2176  Type* ITy = Type::getInt32Ty(unwrap(B)->GetInsertBlock()->getContext());
2177  Constant* AllocSize = ConstantExpr::getSizeOf(unwrap(Ty));
2178  AllocSize = ConstantExpr::getTruncOrBitCast(AllocSize, ITy);
2179  Instruction* Malloc = CallInst::CreateMalloc(unwrap(B)->GetInsertBlock(),
2180  ITy, unwrap(Ty), AllocSize,
2181  0, 0, "");
2182  return wrap(unwrap(B)->Insert(Malloc, Twine(Name)));
2183 }
2184 
2186  LLVMValueRef Val, const char *Name) {
2187  Type* ITy = Type::getInt32Ty(unwrap(B)->GetInsertBlock()->getContext());
2188  Constant* AllocSize = ConstantExpr::getSizeOf(unwrap(Ty));
2189  AllocSize = ConstantExpr::getTruncOrBitCast(AllocSize, ITy);
2190  Instruction* Malloc = CallInst::CreateMalloc(unwrap(B)->GetInsertBlock(),
2191  ITy, unwrap(Ty), AllocSize,
2192  unwrap(Val), 0, "");
2193  return wrap(unwrap(B)->Insert(Malloc, Twine(Name)));
2194 }
2195 
2197  const char *Name) {
2198  return wrap(unwrap(B)->CreateAlloca(unwrap(Ty), 0, Name));
2199 }
2200 
2202  LLVMValueRef Val, const char *Name) {
2203  return wrap(unwrap(B)->CreateAlloca(unwrap(Ty), unwrap(Val), Name));
2204 }
2205 
2207  return wrap(unwrap(B)->Insert(
2208  CallInst::CreateFree(unwrap(PointerVal), unwrap(B)->GetInsertBlock())));
2209 }
2210 
2211 
2213  const char *Name) {
2214  return wrap(unwrap(B)->CreateLoad(unwrap(PointerVal), Name));
2215 }
2216 
2218  LLVMValueRef PointerVal) {
2219  return wrap(unwrap(B)->CreateStore(unwrap(Val), unwrap(PointerVal)));
2220 }
2221 
2223  LLVMValueRef *Indices, unsigned NumIndices,
2224  const char *Name) {
2225  ArrayRef<Value *> IdxList(unwrap(Indices), NumIndices);
2226  return wrap(unwrap(B)->CreateGEP(unwrap(Pointer), IdxList, Name));
2227 }
2228 
2230  LLVMValueRef *Indices, unsigned NumIndices,
2231  const char *Name) {
2232  ArrayRef<Value *> IdxList(unwrap(Indices), NumIndices);
2233  return wrap(unwrap(B)->CreateInBoundsGEP(unwrap(Pointer), IdxList, Name));
2234 }
2235 
2237  unsigned Idx, const char *Name) {
2238  return wrap(unwrap(B)->CreateStructGEP(unwrap(Pointer), Idx, Name));
2239 }
2240 
2242  const char *Name) {
2243  return wrap(unwrap(B)->CreateGlobalString(Str, Name));
2244 }
2245 
2247  const char *Name) {
2248  return wrap(unwrap(B)->CreateGlobalStringPtr(Str, Name));
2249 }
2250 
2252  Value *P = unwrap<Value>(MemAccessInst);
2253  if (LoadInst *LI = dyn_cast<LoadInst>(P))
2254  return LI->isVolatile();
2255  return cast<StoreInst>(P)->isVolatile();
2256 }
2257 
2258 void LLVMSetVolatile(LLVMValueRef MemAccessInst, LLVMBool isVolatile) {
2259  Value *P = unwrap<Value>(MemAccessInst);
2260  if (LoadInst *LI = dyn_cast<LoadInst>(P))
2261  return LI->setVolatile(isVolatile);
2262  return cast<StoreInst>(P)->setVolatile(isVolatile);
2263 }
2264 
2265 /*--.. Casts ...............................................................--*/
2266 
2268  LLVMTypeRef DestTy, const char *Name) {
2269  return wrap(unwrap(B)->CreateTrunc(unwrap(Val), unwrap(DestTy), Name));
2270 }
2271 
2273  LLVMTypeRef DestTy, const char *Name) {
2274  return wrap(unwrap(B)->CreateZExt(unwrap(Val), unwrap(DestTy), Name));
2275 }
2276 
2278  LLVMTypeRef DestTy, const char *Name) {
2279  return wrap(unwrap(B)->CreateSExt(unwrap(Val), unwrap(DestTy), Name));
2280 }
2281 
2283  LLVMTypeRef DestTy, const char *Name) {
2284  return wrap(unwrap(B)->CreateFPToUI(unwrap(Val), unwrap(DestTy), Name));
2285 }
2286 
2288  LLVMTypeRef DestTy, const char *Name) {
2289  return wrap(unwrap(B)->CreateFPToSI(unwrap(Val), unwrap(DestTy), Name));
2290 }
2291 
2293  LLVMTypeRef DestTy, const char *Name) {
2294  return wrap(unwrap(B)->CreateUIToFP(unwrap(Val), unwrap(DestTy), Name));
2295 }
2296 
2298  LLVMTypeRef DestTy, const char *Name) {
2299  return wrap(unwrap(B)->CreateSIToFP(unwrap(Val), unwrap(DestTy), Name));
2300 }
2301 
2303  LLVMTypeRef DestTy, const char *Name) {
2304  return wrap(unwrap(B)->CreateFPTrunc(unwrap(Val), unwrap(DestTy), Name));
2305 }
2306 
2308  LLVMTypeRef DestTy, const char *Name) {
2309  return wrap(unwrap(B)->CreateFPExt(unwrap(Val), unwrap(DestTy), Name));
2310 }
2311 
2313  LLVMTypeRef DestTy, const char *Name) {
2314  return wrap(unwrap(B)->CreatePtrToInt(unwrap(Val), unwrap(DestTy), Name));
2315 }
2316 
2318  LLVMTypeRef DestTy, const char *Name) {
2319  return wrap(unwrap(B)->CreateIntToPtr(unwrap(Val), unwrap(DestTy), Name));
2320 }
2321 
2323  LLVMTypeRef DestTy, const char *Name) {
2324  return wrap(unwrap(B)->CreateBitCast(unwrap(Val), unwrap(DestTy), Name));
2325 }
2326 
2328  LLVMTypeRef DestTy, const char *Name) {
2329  return wrap(unwrap(B)->CreateAddrSpaceCast(unwrap(Val), unwrap(DestTy), Name));
2330 }
2331 
2333  LLVMTypeRef DestTy, const char *Name) {
2334  return wrap(unwrap(B)->CreateZExtOrBitCast(unwrap(Val), unwrap(DestTy),
2335  Name));
2336 }
2337 
2339  LLVMTypeRef DestTy, const char *Name) {
2340  return wrap(unwrap(B)->CreateSExtOrBitCast(unwrap(Val), unwrap(DestTy),
2341  Name));
2342 }
2343 
2345  LLVMTypeRef DestTy, const char *Name) {
2346  return wrap(unwrap(B)->CreateTruncOrBitCast(unwrap(Val), unwrap(DestTy),
2347  Name));
2348 }
2349 
2351  LLVMTypeRef DestTy, const char *Name) {
2352  return wrap(unwrap(B)->CreateCast(Instruction::CastOps(map_from_llvmopcode(Op)), unwrap(Val),
2353  unwrap(DestTy), Name));
2354 }
2355 
2357  LLVMTypeRef DestTy, const char *Name) {
2358  return wrap(unwrap(B)->CreatePointerCast(unwrap(Val), unwrap(DestTy), Name));
2359 }
2360 
2362  LLVMTypeRef DestTy, const char *Name) {
2363  return wrap(unwrap(B)->CreateIntCast(unwrap(Val), unwrap(DestTy),
2364  /*isSigned*/true, Name));
2365 }
2366 
2368  LLVMTypeRef DestTy, const char *Name) {
2369  return wrap(unwrap(B)->CreateFPCast(unwrap(Val), unwrap(DestTy), Name));
2370 }
2371 
2372 /*--.. Comparisons .........................................................--*/
2373 
2375  LLVMValueRef LHS, LLVMValueRef RHS,
2376  const char *Name) {
2377  return wrap(unwrap(B)->CreateICmp(static_cast<ICmpInst::Predicate>(Op),
2378  unwrap(LHS), unwrap(RHS), Name));
2379 }
2380 
2382  LLVMValueRef LHS, LLVMValueRef RHS,
2383  const char *Name) {
2384  return wrap(unwrap(B)->CreateFCmp(static_cast<FCmpInst::Predicate>(Op),
2385  unwrap(LHS), unwrap(RHS), Name));
2386 }
2387 
2388 /*--.. Miscellaneous instructions ..........................................--*/
2389 
2391  return wrap(unwrap(B)->CreatePHI(unwrap(Ty), 0, Name));
2392 }
2393 
2395  LLVMValueRef *Args, unsigned NumArgs,
2396  const char *Name) {
2397  return wrap(unwrap(B)->CreateCall(unwrap(Fn),
2398  makeArrayRef(unwrap(Args), NumArgs),
2399  Name));
2400 }
2401 
2403  LLVMValueRef Then, LLVMValueRef Else,
2404  const char *Name) {
2405  return wrap(unwrap(B)->CreateSelect(unwrap(If), unwrap(Then), unwrap(Else),
2406  Name));
2407 }
2408 
2410  LLVMTypeRef Ty, const char *Name) {
2411  return wrap(unwrap(B)->CreateVAArg(unwrap(List), unwrap(Ty), Name));
2412 }
2413 
2415  LLVMValueRef Index, const char *Name) {
2416  return wrap(unwrap(B)->CreateExtractElement(unwrap(VecVal), unwrap(Index),
2417  Name));
2418 }
2419 
2421  LLVMValueRef EltVal, LLVMValueRef Index,
2422  const char *Name) {
2423  return wrap(unwrap(B)->CreateInsertElement(unwrap(VecVal), unwrap(EltVal),
2424  unwrap(Index), Name));
2425 }
2426 
2429  const char *Name) {
2430  return wrap(unwrap(B)->CreateShuffleVector(unwrap(V1), unwrap(V2),
2431  unwrap(Mask), Name));
2432 }
2433 
2435  unsigned Index, const char *Name) {
2436  return wrap(unwrap(B)->CreateExtractValue(unwrap(AggVal), Index, Name));
2437 }
2438 
2440  LLVMValueRef EltVal, unsigned Index,
2441  const char *Name) {
2442  return wrap(unwrap(B)->CreateInsertValue(unwrap(AggVal), unwrap(EltVal),
2443  Index, Name));
2444 }
2445 
2447  const char *Name) {
2448  return wrap(unwrap(B)->CreateIsNull(unwrap(Val), Name));
2449 }
2450 
2452  const char *Name) {
2453  return wrap(unwrap(B)->CreateIsNotNull(unwrap(Val), Name));
2454 }
2455 
2457  LLVMValueRef RHS, const char *Name) {
2458  return wrap(unwrap(B)->CreatePtrDiff(unwrap(LHS), unwrap(RHS), Name));
2459 }
2460 
2462  LLVMValueRef PTR, LLVMValueRef Val,
2463  LLVMAtomicOrdering ordering,
2464  LLVMBool singleThread) {
2465  AtomicRMWInst::BinOp intop;
2466  switch (op) {
2467  case LLVMAtomicRMWBinOpXchg: intop = AtomicRMWInst::Xchg; break;
2468  case LLVMAtomicRMWBinOpAdd: intop = AtomicRMWInst::Add; break;
2469  case LLVMAtomicRMWBinOpSub: intop = AtomicRMWInst::Sub; break;
2470  case LLVMAtomicRMWBinOpAnd: intop = AtomicRMWInst::And; break;
2471  case LLVMAtomicRMWBinOpNand: intop = AtomicRMWInst::Nand; break;
2472  case LLVMAtomicRMWBinOpOr: intop = AtomicRMWInst::Or; break;
2473  case LLVMAtomicRMWBinOpXor: intop = AtomicRMWInst::Xor; break;
2474  case LLVMAtomicRMWBinOpMax: intop = AtomicRMWInst::Max; break;
2475  case LLVMAtomicRMWBinOpMin: intop = AtomicRMWInst::Min; break;
2476  case LLVMAtomicRMWBinOpUMax: intop = AtomicRMWInst::UMax; break;
2477  case LLVMAtomicRMWBinOpUMin: intop = AtomicRMWInst::UMin; break;
2478  }
2479  AtomicOrdering intordering;
2480  switch (ordering) {
2481  case LLVMAtomicOrderingNotAtomic: intordering = NotAtomic; break;
2482  case LLVMAtomicOrderingUnordered: intordering = Unordered; break;
2483  case LLVMAtomicOrderingMonotonic: intordering = Monotonic; break;
2484  case LLVMAtomicOrderingAcquire: intordering = Acquire; break;
2485  case LLVMAtomicOrderingRelease: intordering = Release; break;
2487  intordering = AcquireRelease;
2488  break;
2490  intordering = SequentiallyConsistent;
2491  break;
2492  }
2493  return wrap(unwrap(B)->CreateAtomicRMW(intop, unwrap(PTR), unwrap(Val),
2494  intordering, singleThread ? SingleThread : CrossThread));
2495 }
2496 
2497 
2498 /*===-- Module providers --------------------------------------------------===*/
2499 
2502  return reinterpret_cast<LLVMModuleProviderRef>(M);
2503 }
2504 
2506  delete unwrap(MP);
2507 }
2508 
2509 
2510 /*===-- Memory buffers ----------------------------------------------------===*/
2511 
2513  const char *Path,
2514  LLVMMemoryBufferRef *OutMemBuf,
2515  char **OutMessage) {
2516 
2518  error_code ec;
2519  if (!(ec = MemoryBuffer::getFile(Path, MB))) {
2520  *OutMemBuf = wrap(MB.take());
2521  return 0;
2522  }
2523 
2524  *OutMessage = strdup(ec.message().c_str());
2525  return 1;
2526 }
2527 
2529  char **OutMessage) {
2531  error_code ec;
2532  if (!(ec = MemoryBuffer::getSTDIN(MB))) {
2533  *OutMemBuf = wrap(MB.take());
2534  return 0;
2535  }
2536 
2537  *OutMessage = strdup(ec.message().c_str());
2538  return 1;
2539 }
2540 
2542  const char *InputData,
2543  size_t InputDataLength,
2544  const char *BufferName,
2545  LLVMBool RequiresNullTerminator) {
2546 
2548  StringRef(InputData, InputDataLength),
2549  StringRef(BufferName),
2550  RequiresNullTerminator));
2551 }
2552 
2554  const char *InputData,
2555  size_t InputDataLength,
2556  const char *BufferName) {
2557 
2559  StringRef(InputData, InputDataLength),
2560  StringRef(BufferName)));
2561 }
2562 
2564  return unwrap(MemBuf)->getBufferStart();
2565 }
2566 
2568  return unwrap(MemBuf)->getBufferSize();
2569 }
2570 
2572  delete unwrap(MemBuf);
2573 }
2574 
2575 /*===-- Pass Registry -----------------------------------------------------===*/
2576 
2579 }
2580 
2581 /*===-- Pass Manager ------------------------------------------------------===*/
2582 
2584  return wrap(new PassManager());
2585 }
2586 
2588  return wrap(new FunctionPassManager(unwrap(M)));
2589 }
2590 
2593  reinterpret_cast<LLVMModuleRef>(P));
2594 }
2595 
2597  return unwrap<PassManager>(PM)->run(*unwrap(M));
2598 }
2599 
2601  return unwrap<FunctionPassManager>(FPM)->doInitialization();
2602 }
2603 
2605  return unwrap<FunctionPassManager>(FPM)->run(*unwrap<Function>(F));
2606 }
2607 
2609  return unwrap<FunctionPassManager>(FPM)->doFinalization();
2610 }
2611 
2613  delete unwrap(PM);
2614 }
2615 
2616 /*===-- Threading ------------------------------------------------------===*/
2617 
2619  return llvm_start_multithreaded();
2620 }
2621 
2624 }
2625 
2627  return llvm_is_multithreaded();
2628 }
LLVMValueRef LLVMConstExactSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:889
LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty, const char *AsmString, const char *Constraints, LLVMBool HasSideEffects, LLVMBool IsAlignStack)
Definition: Core.cpp:1121
const char * LLVMGetBufferStart(LLVMMemoryBufferRef MemBuf)
Definition: Core.cpp:2563
static MemoryBuffer * getMemBuffer(StringRef InputData, StringRef BufferName="", bool RequiresNullTerminator=true)
void LLVMDisposeBuilder(LLVMBuilderRef Builder)
Definition: Core.cpp:1918
unsigned LLVMGetMDNodeNumOperands(LLVMValueRef V)
Definition: Core.cpp:618
use_iterator use_end()
Definition: Value.h:152
LLVMValueRef LLVMConstNamedStruct(LLVMTypeRef StructTy, LLVMValueRef *ConstantVals, unsigned Count)
Definition: Core.cpp:742
7: Labels
Definition: Type.h:62
struct LLVMOpaqueType * LLVMTypeRef
Definition: Core.h:87
LLVMBasicBlockRef LLVMInsertBasicBlockInContext(LLVMContextRef C, LLVMBasicBlockRef BBRef, const char *Name)
Definition: Core.cpp:1700
void LLVMGetStructElementTypes(LLVMTypeRef StructTy, LLVMTypeRef *Dest)
Definition: Core.cpp:392
void LLVMGetParams(LLVMValueRef FnRef, LLVMValueRef *ParamRefs)
Definition: Core.cpp:1546
LLVMValueRef LLVMGetInitializer(LLVMValueRef GlobalVar)
Definition: Core.cpp:1339
LLVMValueRef LLVMBuildICmp(LLVMBuilderRef B, LLVMIntPredicate Op, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:2374
static Constant * getString(LLVMContext &Context, StringRef Initializer, bool AddNull=true)
Definition: Constants.cpp:2357
static Constant * getSIToFP(Constant *C, Type *Ty)
Definition: Constants.cpp:1604
Like Private, but linker removes.
Definition: GlobalValue.h:43
static Type * getDoubleTy(LLVMContext &C)
Definition: Type.cpp:231
raw_ostream & errs()
static IntegerType * getInt1Ty(LLVMContext &C)
Definition: Type.cpp:238
unsigned LLVMGetPointerAddressSpace(LLVMTypeRef PointerTy)
Definition: Core.cpp:433
static Constant * getFAdd(Constant *C1, Constant *C2)
Definition: Constants.cpp:2036
static Constant * getShuffleVector(Constant *V1, Constant *V2, Constant *Mask)
Definition: Constants.cpp:1949
void addIncoming(Value *V, BasicBlock *BB)
Special purpose, only applies to global arrays.
Definition: GlobalValue.h:40
static PassRegistry * getPassRegistry()
LLVMContext & getContext() const
Definition: Function.cpp:167
*p = old <signed v ? old : v
Definition: Instructions.h:583
LLVMValueRef LLVMBuildArrayAlloca(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Val, const char *Name)
Definition: Core.cpp:2201
LLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:925
LLVMValueRef LLVMBuildZExt(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:2272
const AttributeSet & getAttributes() const
Definition: CallSite.h:179
LLVMBasicBlockRef LLVMGetEntryBasicBlock(LLVMValueRef Fn)
Definition: Core.cpp:1654
LLVMValueRef LLVMGetLastFunction(LLVMModuleRef M)
Definition: Core.cpp:1442
LLVMValueRef LLVMConstBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition: Core.cpp:1031
LLVM Argument representation.
Definition: Argument.h:35
LLVMValueRef LLVMConstUDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:879
void initializeVerifierPass(PassRegistry &)
LLVMBool LLVMTypeIsSized(LLVMTypeRef Ty)
Definition: Core.cpp:214
LLVMValueRef LLVMConstSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:884
void LLVMSetSection(LLVMValueRef Global, const char *Section)
Definition: Core.cpp:1244
void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align)
Definition: Core.cpp:1615
LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRangeCopy(const char *InputData, size_t InputDataLength, const char *BufferName)
Definition: Core.cpp:2553
LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count)
Definition: Core.cpp:605
LLVMValueRef LLVMGetIncomingValue(LLVMValueRef PhiNode, unsigned Index)
Definition: Core.cpp:1865
static Constant * getNSWAdd(Constant *C1, Constant *C2)
Definition: Constants.h:869
The main container class for the LLVM Intermediate Representation.
Definition: Module.h:112
LLVMValueRef LLVMBuildAdd(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:2018
LLVMBuilderRef LLVMCreateBuilder(void)
Definition: Core.cpp:1880
LLVMValueRef LLVMGetNextParam(LLVMValueRef Arg)
Definition: Core.cpp:1580
2: 32-bit floating point type
Definition: Type.h:57
iterator end()
Definition: Function.h:397
Same, but only replaced by something equivalent.
Definition: GlobalValue.h:39
LLVMValueRef LLVMBuildNUWAdd(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:2028
int LLVMBool
Definition: Core.h:65
static MDString * get(LLVMContext &Context, StringRef Str)
Definition: Metadata.cpp:38
LLVMValueRef LLVMBuildStructGEP(LLVMBuilderRef B, LLVMValueRef Pointer, unsigned Idx, const char *Name)
Definition: Core.cpp:2236
LLVMValueRef LLVMGetNamedGlobal(LLVMModuleRef M, const char *Name)
Definition: Core.cpp:1299
static Constant * getSelect(Constant *C, Constant *V1, Constant *V2)
Definition: Constants.cpp:1820
LLVMBool LLVMIsOpaqueStruct(LLVMTypeRef StructTy)
Definition: Core.cpp:403
LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRange(const char *InputData, size_t InputDataLength, const char *BufferName, LLVMBool RequiresNullTerminator)
Definition: Core.cpp:2541
static Constant * getAnon(ArrayRef< Constant * > V, bool Packed=false)
Definition: Constants.h:391
LLVMValueRef LLVMGetFirstParam(LLVMValueRef Fn)
Definition: Core.cpp:1564
LLVMValueRef LLVMBuildSExt(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:2277
LLVMValueRef LLVMAddAlias(LLVMModuleRef M, LLVMTypeRef Ty, LLVMValueRef Aliasee, const char *Name)
Definition: Core.cpp:1416
LLVMValueRef LLVMAlignOf(LLVMTypeRef Ty)
Definition: Core.cpp:784
Available for inspection, not emission.
Definition: GlobalValue.h:35
unsigned getNumOperands() const
getNumOperands - Return number of MDNode operands.
Definition: Metadata.h:142
void LLVMStopMultithreaded()
Definition: Core.cpp:2622
LLVMOpcode
Definition: Core.h:174
LLVMValueRef LLVMConstRealOfStringAndSize(LLVMTypeRef RealTy, const char Str[], unsigned SLen)
Definition: Core.cpp:695
void LLVMSetValueName(LLVMValueRef Val, const char *Name)
Definition: Core.cpp:469
LLVMValueRef LLVMConstFPToUI(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition: Core.cpp:1011
static Constant * getFPToUI(Constant *C, Type *Ty)
Definition: Constants.cpp:1615
void clearGC()
Definition: Function.cpp:330
Type::subtype_iterator param_iterator
Definition: DerivedTypes.h:123
const char * LLVMGetGC(LLVMValueRef Fn)
Definition: Core.cpp:1485
LLVMPassManagerRef LLVMCreateFunctionPassManager(LLVMModuleProviderRef P)
Definition: Core.cpp:2591
LLVMValueRef LLVMAddGlobal(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name)
Definition: Core.cpp:1286
static Constant * getGetElementPtr(Constant *C, ArrayRef< Constant * > IdxList, bool InBounds=false)
Definition: Constants.h:1004
void LLVMAddAttribute(LLVMValueRef Arg, LLVMAttribute PA)
Definition: Core.cpp:1596
LLVMTypeRef LLVMHalfType(void)
Definition: Core.cpp:305
LLVMValueRef LLVMBuildRet(LLVMBuilderRef B, LLVMValueRef V)
Definition: Core.cpp:1945
LLVMBasicBlockRef LLVMGetNextBasicBlock(LLVMBasicBlockRef BB)
Definition: Core.cpp:1674
LLVMBool LLVMCreateMemoryBufferWithContentsOfFile(const char *Path, LLVMMemoryBufferRef *OutMemBuf, char **OutMessage)
Definition: Core.cpp:2512
char * LLVMCreateMessage(const char *Message)
Definition: Core.cpp:61
LLVMPassManagerRef LLVMCreatePassManager()
Definition: Core.cpp:2583
const char * getGC() const
Definition: Function.cpp:315
void addOperand(MDNode *M)
addOperand - Add metadata operand.
Definition: Metadata.cpp:551
LLVMTypeRef LLVMFP128Type(void)
Definition: Core.cpp:317
static Constant * getExactSDiv(Constant *C1, Constant *C2)
Definition: Constants.h:893
LLVMValueRef LLVMBuildFPToUI(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:2282
static PointerType * get(Type *ElementType, unsigned AddressSpace)
Definition: Type.cpp:730
#define LLVM_FOR_EACH_VALUE_SUBCLASS(macro)
Definition: Core.h:1105
unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy)
Definition: Core.cpp:437
*p = old <unsigned v ? old : v
Definition: Instructions.h:587
static Constant * getExtractElement(Constant *Vec, Constant *Idx)
Definition: Constants.cpp:1912
LLVMValueRef LLVMBuildCondBr(LLVMBuilderRef B, LLVMValueRef If, LLVMBasicBlockRef Then, LLVMBasicBlockRef Else)
Definition: Core.cpp:1958
Like Internal, but omit from symbol table.
Definition: GlobalValue.h:42
LLVMTypeRef LLVMX86MMXType(void)
Definition: Core.cpp:323
*p = old >unsigned v ? old : v
Definition: Instructions.h:585
Externally visible function.
Definition: GlobalValue.h:34
LLVMValueRef LLVMBuildFNeg(LLVMBuilderRef B, LLVMValueRef V, const char *Name)
Definition: Core.cpp:2164
LLVMValueRef LLVMBuildTruncOrBitCast(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:2344
const Function * getParent() const
Return the enclosing method, or null if none.
Definition: BasicBlock.h:116
LLVMValueRef LLVMBuildSDiv(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:2083
arg_iterator arg_end()
Definition: Function.h:418
12: Structures
Definition: Type.h:70
LLVMTypeRef LLVMX86FP80Type(void)
Definition: Core.cpp:314
LLVMUseRef LLVMGetFirstUse(LLVMValueRef Val)
Definition: Core.cpp:513
static Constant * getUIToFP(Constant *C, Type *Ty)
Definition: Constants.cpp:1593
MDNode - a tuple of other values.
Definition: Metadata.h:69
void LLVMClearInsertionPosition(LLVMBuilderRef Builder)
Definition: Core.cpp:1905
LLVMValueRef LLVMGetNextGlobal(LLVMValueRef GlobalVar)
Definition: Core.cpp:1319
F(f)
4: 80-bit floating point type (X87)
Definition: Type.h:59
LLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType, unsigned ElementCount)
Definition: Core.cpp:421
LLVMValueRef LLVMConstAnd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:915
unsigned LLVMGetMDKindIDInContext(LLVMContextRef C, const char *Name, unsigned SLen)
Definition: Core.cpp:84
LLVMPassRegistryRef LLVMGetGlobalPassRegistry(void)
Definition: Core.cpp:2577
LLVMValueRef LLVMBuildCast(LLVMBuilderRef B, LLVMOpcode Op, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:2350
LLVMValueRef LLVMBuildFRem(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:2108
LLVMContext ** unwrap(LLVMContextRef *Tys)
Definition: LLVMContext.h:119
LLVMValueRef LLVMConstSelect(LLVMValueRef ConstantCondition, LLVMValueRef ConstantIfTrue, LLVMValueRef ConstantIfFalse)
Definition: Core.cpp:1077
1: 16-bit floating point type
Definition: Type.h:56
LLVMAttribute
Definition: Core.h:136
LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition: Core.cpp:976
unsigned getBitWidth() const
Get the number of bits in this IntegerType.
Definition: DerivedTypes.h:61
LLVMBool LLVMValueIsBasicBlock(LLVMValueRef Val)
Definition: Core.cpp:1628
static IntegerType * getInt64Ty(LLVMContext &C)
Definition: Type.cpp:242
FunctionType * getType(LLVMContext &Context, ID id, ArrayRef< Type * > Tys=None)
Definition: Function.cpp:657
LLVMTypeRef LLVMStructTypeInContext(LLVMContextRef C, LLVMTypeRef *ElementTypes, unsigned ElementCount, LLVMBool Packed)
Definition: Core.cpp:357
AttrBuilder & addAttribute(Attribute::AttrKind Val)
Add an attribute to the builder.
Definition: Attributes.cpp:968
static Constant * getFCmp(unsigned short pred, Constant *LHS, Constant *RHS)
Definition: Constants.cpp:1892
LLVMBasicBlockRef LLVMInsertBasicBlock(LLVMBasicBlockRef BBRef, const char *Name)
Definition: Core.cpp:1707
int LLVMHasMetadata(LLVMValueRef Inst)
Definition: Core.cpp:491
static Constant * getSub(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
Definition: Constants.cpp:2040
const char * LLVMGetSection(LLVMValueRef Global)
Definition: Core.cpp:1240
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:245
LLVMValueRef LLVMMDNodeInContext(LLVMContextRef C, LLVMValueRef *Vals, unsigned Count)
Definition: Core.cpp:599
14: Pointers
Definition: Type.h:72
void initializeDominatorTreePass(PassRegistry &)
void initializeCore(PassRegistry &)
Definition: Core.cpp:42
static IntegerType * getInt16Ty(LLVMContext &C)
Definition: Type.cpp:240
const Constant * getInitializer() const
static Type * getX86_MMXTy(LLVMContext &C)
Definition: Type.cpp:236
LLVMAtomicRMWBinOp
Definition: Core.h:383
11: Functions
Definition: Type.h:69
LLVMValueRef LLVMConstIntOfString(LLVMTypeRef IntTy, const char Str[], uint8_t Radix)
Definition: Core.cpp:675
*p = old >signed v ? old : v
Definition: Instructions.h:581
void LLVMGetNamedMetadataOperands(LLVMModuleRef M, const char *name, LLVMValueRef *Dest)
Definition: Core.cpp:639
LLVMValueRef LLVMConstAddrSpaceCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition: Core.cpp:1036
Tentative definitions.
Definition: GlobalValue.h:48
void LLVMRemoveFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA)
Definition: Core.cpp:1521
bool llvm_start_multithreaded()
Definition: Threading.cpp:26
static Type * getX86_FP80Ty(LLVMContext &C)
Definition: Type.cpp:233
void LLVMContextDispose(LLVMContextRef C)
Definition: Core.cpp:80
void LLVMSetGlobalConstant(LLVMValueRef GlobalVar, LLVMBool IsConstant)
Definition: Core.cpp:1363
void LLVMSetThreadLocal(LLVMValueRef GlobalVar, LLVMBool IsThreadLocal)
Definition: Core.cpp:1355
LoopInfoBase< BlockT, LoopT > * LI
Definition: LoopInfoImpl.h:411
LLVMValueRef LLVMConstNull(LLVMTypeRef Ty)
Definition: Core.cpp:557
static MDNode * get(LLVMContext &Context, ArrayRef< Value * > Vals)
Definition: Metadata.cpp:268
LLVMValueRef LLVMConstReal(LLVMTypeRef RealTy, double N)
Definition: Core.cpp:687
LLVMValueRef LLVMBuildPointerCast(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:2356
static Constant * getNullValue(Type *Ty)
Definition: Constants.cpp:111
LLVMBool LLVMInitializeFunctionPassManager(LLVMPassManagerRef FPM)
Definition: Core.cpp:2600
void LLVMSetOperand(LLVMValueRef Val, unsigned Index, LLVMValueRef Op)
Definition: Core.cpp:544
iterator begin()
Definition: BasicBlock.h:193
long long LLVMConstIntGetSExtValue(LLVMValueRef ConstantVal)
Definition: Core.cpp:704
static Constant * getAdd(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
Definition: Constants.cpp:2029
static Constant * getFMul(Constant *C1, Constant *C2)
Definition: Constants.cpp:2058
void addAttr(AttributeSet AS)
Add a Attribute to an argument.
Definition: Function.cpp:144
Value * getOperand(unsigned i) const LLVM_READONLY
getOperand - Return specified operand.
Definition: Metadata.cpp:307
element_iterator element_end() const
Definition: DerivedTypes.h:279
LLVMOpcode LLVMGetInstructionOpcode(LLVMValueRef Inst)
Definition: Core.cpp:1779
LLVMTypeRef LLVMFP128TypeInContext(LLVMContextRef C)
Definition: Core.cpp:295
const char * LLVMGetStructName(LLVMTypeRef Ty)
Definition: Core.cpp:374
LLVMBasicBlockRef LLVMGetLastBasicBlock(LLVMValueRef Fn)
Definition: Core.cpp:1666
LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef BB)
Definition: Core.cpp:1624
void LLVMAddFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA)
Definition: Core.cpp:1498
static Constant * getIntegerCast(Constant *C, Type *Ty, bool isSigned)
Create a ZExt, Bitcast or Trunc for integer -> integer casts.
Definition: Constants.cpp:1502
LLVMTypeRef LLVMLabelTypeInContext(LLVMContextRef C)
Definition: Core.cpp:446
LLVMTypeRef LLVMDoubleTypeInContext(LLVMContextRef C)
Definition: Core.cpp:289
static unsigned getBitWidth(Type *Ty, const DataLayout *TD)
LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size)
Definition: Core.cpp:751
void initializePrintFunctionPassPass(PassRegistry &)
LLVMValueRef LLVMBuildExactSDiv(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:2088
Type::subtype_iterator element_iterator
Definition: DerivedTypes.h:277
LLVMValueRef LLVMSizeOf(LLVMTypeRef Ty)
Definition: Core.cpp:788
LLVMBool LLVMIsNull(LLVMValueRef Val)
Definition: Core.cpp:573
static Type * getFloatTy(LLVMContext &C)
Definition: Type.cpp:230
LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant, LLVMValueRef VectorBConstant, LLVMValueRef MaskConstant)
Definition: Core.cpp:1099
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
Definition: ArrayRef.h:261
LLVMValueRef LLVMConstRealOfString(LLVMTypeRef RealTy, const char *Text)
Definition: Core.cpp:691
LLVMValueRef LLVMBuildAggregateRet(LLVMBuilderRef B, LLVMValueRef *RetVals, unsigned N)
Definition: Core.cpp:1949
#define llvm_unreachable(msg)
Definition: Use.h:60
static Constant * getLShr(Constant *C1, Constant *C2, bool isExact=false)
Definition: Constants.cpp:2107
static bool isDeclaration(const GlobalValue &V)
isDeclaration - Return 'true' if the global value is a declaration.
Definition: LTOModule.cpp:739
param_iterator param_end() const
Definition: DerivedTypes.h:125
static Constant * getNUWNeg(Constant *C)
Definition: Constants.h:868
LLVMValueRef LLVMConstIntOfStringAndSize(LLVMTypeRef IntTy, const char Str[], unsigned SLen, uint8_t Radix)
Definition: Core.cpp:681
void LLVMPositionBuilder(LLVMBuilderRef Builder, LLVMBasicBlockRef Block, LLVMValueRef Instr)
Definition: Core.cpp:1884
LLVMTypeRef LLVMInt8TypeInContext(LLVMContextRef C)
Definition: Core.cpp:242
unsigned LLVMGetFunctionCallConv(LLVMValueRef Fn)
Definition: Core.cpp:1476
LLVMValueRef LLVMConstIntCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType, LLVMBool isSigned)
Definition: Core.cpp:1066
LLVMValueRef LLVMConstNUWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:824
static Constant * get(ArrayRef< Constant * > V)
Definition: Constants.cpp:923
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
Definition: IRBuilder.h:421
LLVMValueRef LLVMConstFSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:852
unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy)
Definition: Core.cpp:277
This file contains the simple types necessary to represent the attributes associated with functions a...
LLVMBool LLVMIsExternallyInitialized(LLVMValueRef GlobalVar)
Definition: Core.cpp:1406
LLVMValueRef LLVMConstAShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:954
LLVMValueRef LLVMGetBasicBlockParent(LLVMBasicBlockRef BB)
Definition: Core.cpp:1636
LLVMValueRef LLVMGetLastParam(LLVMValueRef Fn)
Definition: Core.cpp:1572
static Constant * getExtractValue(Constant *Agg, ArrayRef< unsigned > Idxs)
Definition: Constants.cpp:1989
LLVMValueRef LLVMConstICmp(LLVMIntPredicate Predicate, LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:930
struct LLVMOpaqueMemoryBuffer * LLVMMemoryBufferRef
Definition: Core.h:122
element_iterator element_begin() const
Definition: DerivedTypes.h:278
LLVMValueRef LLVMGetUndef(LLVMTypeRef Ty)
Definition: Core.cpp:565
void LLVMSetVisibility(LLVMValueRef Global, LLVMVisibility Viz)
Definition: Core.cpp:1253
void LLVMAddNamedMetadataOperand(LLVMModuleRef M, const char *name, LLVMValueRef Val)
Definition: Core.cpp:648
static Type * getPPC_FP128Ty(LLVMContext &C)
Definition: Type.cpp:235
LLVMValueRef LLVMConstSExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition: Core.cpp:981
LLVMValueRef LLVMGetPreviousGlobal(LLVMValueRef GlobalVar)
Definition: Core.cpp:1327
LLVMValueRef LLVMBuildNSWAdd(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:2023
void removeAttr(AttributeSet AS)
Remove a Attribute from an argument.
Definition: Function.cpp:154
LLVMValueRef LLVMGetFirstInstruction(LLVMBasicBlockRef BB)
Definition: Core.cpp:1734
LLVMTypeRef LLVMFloatType(void)
Definition: Core.cpp:308
AtomicOrdering
Definition: Instructions.h:36
global_iterator global_begin()
Definition: Module.h:521
void LLVMDisposeMessage(char *Message)
Definition: Core.cpp:65
LLVMValueRef LLVMConstFPCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition: Core.cpp:1072
struct LLVMOpaqueModuleProvider * LLVMModuleProviderRef
Definition: Core.h:115
LLVMValueRef LLVMBuildSRem(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:2103
LLVMValueRef LLVMGetPreviousInstruction(LLVMValueRef Inst)
Definition: Core.cpp:1758
void LLVMMoveBasicBlockBefore(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos)
Definition: Core.cpp:1720
static Constant * getSizeOf(Type *Ty)
Definition: Constants.cpp:1756
LLVMValueRef LLVMConstInsertElement(LLVMValueRef VectorConstant, LLVMValueRef ElementValueConstant, LLVMValueRef IndexConstant)
Definition: Core.cpp:1091
void LLVMGetParamTypes(LLVMTypeRef FunctionTy, LLVMTypeRef *Dest)
Definition: Core.cpp:348
char * LLVMPrintModuleToString(LLVMModuleRef M)
Definition: Core.cpp:150
static Type * getLabelTy(LLVMContext &C)
Definition: Type.cpp:228
void LLVMDisposeModule(LLVMModuleRef M)
Definition: Core.cpp:105
void LLVMSetInstDebugLocation(LLVMBuilderRef Builder, LLVMValueRef Inst)
Definition: Core.cpp:1934
LLVMBool LLVMIsGlobalConstant(LLVMValueRef GlobalVar)
Definition: Core.cpp:1359
LLVMContext & getContext() const
getContext - Return the LLVMContext in which this type was uniqued.
Definition: Type.h:128
LLVMValueRef LLVMConstStructInContext(LLVMContextRef C, LLVMValueRef *ConstantVals, unsigned Count, LLVMBool Packed)
Definition: Core.cpp:718
static Constant * getFPCast(Constant *C, Type *Ty)
Create a FPExt, Bitcast or FPTrunc for fp -> fp casts.
Definition: Constants.cpp:1515
LLVMBool LLVMIsTailCall(LLVMValueRef Call)
Definition: Core.cpp:1838
LLVMValueRef LLVMBlockAddress(LLVMValueRef F, LLVMBasicBlockRef BB)
Definition: Core.cpp:1129
void llvm_shutdown()
llvm_shutdown - Deallocate and destroy all ManagedStatic variables.
LLVMValueRef LLVMConstZExtOrBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition: Core.cpp:1042
const char * data() const
Definition: StringRef.h:107
LLVMValueRef LLVMConstGEP(LLVMValueRef ConstantVal, LLVMValueRef *ConstantIndices, unsigned NumIndices)
Definition: Core.cpp:959
LLVMValueRef LLVMConstInBoundsGEP(LLVMValueRef ConstantVal, LLVMValueRef *ConstantIndices, unsigned NumIndices)
Definition: Core.cpp:967
static Constant * getAShr(Constant *C1, Constant *C2, bool isExact=false)
Definition: Constants.cpp:2112
LLVMValueRef LLVMBuildOr(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:2133
void LLVMDeleteFunction(LLVMValueRef Fn)
Definition: Core.cpp:1466
LLVMValueRef LLVMBuildFDiv(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:2093
static Constant * getICmp(unsigned short pred, Constant *LHS, Constant *RHS)
Definition: Constants.cpp:1870
Function to be imported from DLL.
Definition: GlobalValue.h:45
LLVMValueRef LLVMConstFPToSI(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition: Core.cpp:1016
static Constant * getAddrSpaceCast(Constant *C, Type *Ty)
Definition: Constants.cpp:1672
LLVMBasicBlockRef LLVMGetPreviousBasicBlock(LLVMBasicBlockRef BB)
Definition: Core.cpp:1682
LLVMValueRef LLVMGetFirstGlobal(LLVMModuleRef M)
Definition: Core.cpp:1303
void LLVMDumpModule(LLVMModuleRef M)
Definition: Core.cpp:127
static Constant * getPtrToInt(Constant *C, Type *Ty)
Definition: Constants.cpp:1637
static FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)
Definition: Type.cpp:361
unsigned LLVMCountIncoming(LLVMValueRef PhiNode)
Definition: Core.cpp:1861
LLVMValueRef LLVMBuildIntCast(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:2361
LLVMTypeRef LLVMFloatTypeInContext(LLVMContextRef C)
Definition: Core.cpp:286
unsigned long long LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal)
Definition: Core.cpp:700
static int map_from_llvmopcode(LLVMOpcode code)
Definition: Core.cpp:768
void LLVMGetMDNodeOperands(LLVMValueRef V, LLVMValueRef *Dest)
Definition: Core.cpp:623
LLVMValueRef LLVMConstFMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:874
LLVMValueRef LLVMGetLastInstruction(LLVMBasicBlockRef BB)
Definition: Core.cpp:1742
LLVMValueRef LLVMBuildSub(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:2038
void initializePrintModulePassPass(PassRegistry &)
LLVMUseRef LLVMGetNextUse(LLVMUseRef U)
Definition: Core.cpp:521
LLVMValueRef LLVMAddFunction(LLVMModuleRef M, const char *Name, LLVMTypeRef FunctionTy)
Definition: Core.cpp:1424
LLVMValueRef LLVMBuildFAdd(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:2033
static Constant * getUDiv(Constant *C1, Constant *C2, bool isExact=false)
Definition: Constants.cpp:2062
static Constant * getNSWNeg(Constant *C)
Definition: Constants.h:867
unsigned LLVMCountParamTypes(LLVMTypeRef FunctionTy)
Definition: Core.cpp:344
LLVMIntPredicate
Definition: Core.h:311
static Constant * getIntToPtr(Constant *C, Type *Ty)
Definition: Constants.cpp:1649
LLVMValueRef LLVMBuildNUWSub(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:2048
iterator begin()
Definition: Function.h:395
LLVMValueRef LLVMBuildPtrToInt(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:2312
static Constant * getFDiv(Constant *C1, Constant *C2)
Definition: Constants.cpp:2072
LLVMTypeRef LLVMStructCreateNamed(LLVMContextRef C, const char *Name)
Definition: Core.cpp:369
LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N, LLVMBool SignExtend)
Definition: Core.cpp:661
size_t LLVMGetBufferSize(LLVMMemoryBufferRef MemBuf)
Definition: Core.cpp:2567
LLVMValueRef LLVMBuildAnd(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:2128
void LLVMSetLinkage(LLVMValueRef Global, LLVMLinkage Linkage)
Definition: Core.cpp:1180
void initializePrintBasicBlockPassPass(PassRegistry &)
unsigned LLVMGetIntrinsicID(LLVMValueRef Fn)
Definition: Core.cpp:1470
void LLVMAddTargetDependentFunctionAttr(LLVMValueRef Fn, const char *A, const char *V)
Definition: Core.cpp:1509
LLVMBasicBlockRef LLVMGetInstructionParent(LLVMValueRef Inst)
Definition: Core.cpp:1730
LLVMTypeRef LLVMInt64TypeInContext(LLVMContextRef C)
Definition: Core.cpp:251
LLVMValueRef LLVMGetLastGlobal(LLVMModuleRef M)
Definition: Core.cpp:1311
LLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:813
unsigned LLVMGetArrayLength(LLVMTypeRef ArrayTy)
Definition: Core.cpp:429
void LLVMDisposePassManager(LLVMPassManagerRef PM)
Definition: Core.cpp:2612
LLVMValueRef LLVMBuildIsNull(LLVMBuilderRef B, LLVMValueRef Val, const char *Name)
Definition: Core.cpp:2446
void LLVMSetVolatile(LLVMValueRef MemAccessInst, LLVMBool isVolatile)
Definition: Core.cpp:2258
LLVMTypeRef LLVMVoidTypeInContext(LLVMContextRef C)
Definition: Core.cpp:443
10: Arbitrary bit width integers
Definition: Type.h:68
#define LLVM_DEFINE_VALUE_CAST(name)
Definition: Core.cpp:505
ExternalWeak linkage description.
Definition: GlobalValue.h:47
LLVMValueRef LLVMConstNSWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:818
LLVMValueRef LLVMConstNSWNeg(LLVMValueRef ConstantVal)
Definition: Core.cpp:796
void LLVMSetTarget(LLVMModuleRef M, const char *Triple)
Definition: Core.cpp:123
0: type with no size
Definition: Type.h:55
#define P(N)
Same, but only replaced by something equivalent.
Definition: GlobalValue.h:37
static Constant * getFNeg(Constant *C)
Definition: Constants.cpp:2017
LLVMBasicBlockRef LLVMGetFirstBasicBlock(LLVMValueRef Fn)
Definition: Core.cpp:1658
LLVMValueRef LLVMBuildNUWNeg(LLVMBuilderRef B, LLVMValueRef V, const char *Name)
Definition: Core.cpp:2159
void LLVMSetCurrentDebugLocation(LLVMBuilderRef Builder, LLVMValueRef L)
Definition: Core.cpp:1924
static Constant * getFRem(Constant *C1, Constant *C2)
Definition: Constants.cpp:2084
void LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder, LLVMBasicBlockRef Block)
Definition: Core.cpp:1896
void LLVMStructSetBody(LLVMTypeRef StructTy, LLVMTypeRef *ElementTypes, unsigned ElementCount, LLVMBool Packed)
Definition: Core.cpp:382
LLVMValueRef LLVMBuildShl(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:2113
LLVMTypeKind
Definition: Core.h:253
LLVMValueRef LLVMBuildInsertElement(LLVMBuilderRef B, LLVMValueRef VecVal, LLVMValueRef EltVal, LLVMValueRef Index, const char *Name)
Definition: Core.cpp:2420
static ConstantPointerNull * get(PointerType *T)
get() - Static factory methods - Return objects of the specified value
Definition: Constants.cpp:1314
LLVMValueRef LLVMBuildAlloca(LLVMBuilderRef B, LLVMTypeRef Ty, const char *Name)
Definition: Core.cpp:2196
LLVMAtomicOrdering
Definition: Core.h:356
LLVMTypeRef LLVMInt32Type(void)
Definition: Core.cpp:267
LLVMValueRef LLVMBuildPhi(LLVMBuilderRef B, LLVMTypeRef Ty, const char *Name)
Definition: Core.cpp:2390
LLVM Basic Block Representation.
Definition: BasicBlock.h:72
LLVMValueRef LLVMGetMetadata(LLVMValueRef Inst, unsigned KindID)
Definition: Core.cpp:495
void LLVMAddClause(LLVMValueRef LandingPad, LLVMValueRef ClauseVal)
Definition: Core.cpp:2007
unsigned LLVMCountBasicBlocks(LLVMValueRef FnRef)
Definition: Core.cpp:1644
const Function * getParent() const
Definition: Argument.h:49
LLVMBool LLVMIsPackedStruct(LLVMTypeRef StructTy)
Definition: Core.cpp:399
void LLVMReplaceAllUsesWith(LLVMValueRef OldVal, LLVMValueRef NewVal)
Definition: Core.cpp:487
LLVMValueRef LLVMBuildFPToSI(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:2287
LLVMBool LLVMStartMultithreaded()
Definition: Core.cpp:2618
void initializePreVerifierPass(PassRegistry &)
LLVMContextRef LLVMGetModuleContext(LLVMModuleRef M)
Definition: Core.cpp:167
LLVMValueRef LLVMConstFDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:895
static BlockAddress * get(Function *F, BasicBlock *BB)
get - Return a BlockAddress for the specified function and basic block.
Definition: Constants.cpp:1358
LLVM Constant Representation.
Definition: Constant.h:41
LLVMValueRef LLVMBuildNSWSub(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:2043
LLVMValueRef LLVMGetNamedFunction(LLVMModuleRef M, const char *Name)
Definition: Core.cpp:1430
LLVMValueRef LLVMConstFNeg(LLVMValueRef ConstantVal)
Definition: Core.cpp:805
unsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy)
Definition: Core.cpp:388
param_iterator param_begin() const
Definition: DerivedTypes.h:124
LLVMThreadLocalMode LLVMGetThreadLocalMode(LLVMValueRef GlobalVar)
Definition: Core.cpp:1367
LLVMValueRef LLVMBuildSIToFP(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:2297
char * LLVMPrintValueToString(LLVMValueRef Val)
Definition: Core.cpp:477
LLVMValueRef LLVMBuildExtractElement(LLVMBuilderRef B, LLVMValueRef VecVal, LLVMValueRef Index, const char *Name)
Definition: Core.cpp:2414
LLVMValueRef LLVMBuildFMul(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:2073
static Constant * getAnd(Constant *C1, Constant *C2)
Definition: Constants.cpp:2088
static Constant * get(ArrayType *T, ArrayRef< Constant * > V)
Definition: Constants.cpp:745
LLVMTypeRef LLVMPPCFP128TypeInContext(LLVMContextRef C)
Definition: Core.cpp:298
void free(void *ptr);
LLVMValueRef LLVMBuildPtrDiff(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:2456
LLVMValueRef LLVMBuildInBoundsGEP(LLVMBuilderRef B, LLVMValueRef Pointer, LLVMValueRef *Indices, unsigned NumIndices, const char *Name)
Definition: Core.cpp:2229
static Constant * getSExtOrBitCast(Constant *C, Type *Ty)
Definition: Constants.cpp:1475
LLVMValueRef LLVMConstNUWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:868
bool llvm_is_multithreaded()
Definition: Threading.cpp:54
LLVMValueRef LLVMConstExtractValue(LLVMValueRef AggConstant, unsigned *IdxList, unsigned NumIdx)
Definition: Core.cpp:1107
void LLVMAddDestination(LLVMValueRef IndirectBr, LLVMBasicBlockRef Dest)
Definition: Core.cpp:2003
LLVMValueRef LLVMConstOr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:920
void LLVMInstructionEraseFromParent(LLVMValueRef Inst)
Definition: Core.cpp:1766
void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index, unsigned align)
Definition: Core.cpp:1825
void LLVMMoveBasicBlockAfter(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos)
Definition: Core.cpp:1724
LLVMValueRef LLVMGetUsedValue(LLVMUseRef U)
Definition: Core.cpp:532
static Type * getVoidTy(LLVMContext &C)
Definition: Type.cpp:227
LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount)
Definition: Core.cpp:413
LLVMBool LLVMIsUndef(LLVMValueRef Val)
Definition: Core.cpp:579
LLVMValueRef LLVMMDStringInContext(LLVMContextRef C, const char *Str, unsigned SLen)
Definition: Core.cpp:590
LLVMValueRef LLVMBuildResume(LLVMBuilderRef B, LLVMValueRef Exn)
Definition: Core.cpp:1990
struct LLVMOpaqueContext * LLVMContextRef
Definition: Core.h:72
LLVMValueRef LLVMConstString(const char *Str, unsigned Length, LLVMBool DontNullTerminate)
Definition: Core.cpp:726
Represent an integer comparison operator.
Definition: Instructions.h:911
LLVMTypeRef LLVMIntTypeInContext(LLVMContextRef C, unsigned NumBits)
Definition: Core.cpp:254
MDNode * getOperand(unsigned i) const
getOperand - Return specified operand.
Definition: Metadata.cpp:545
LLVMValueRef LLVMMDString(const char *Str, unsigned SLen)
Definition: Core.cpp:595
6: 128-bit floating point type (two 64-bits, PowerPC)
Definition: Type.h:61
unsigned getMDKindID(StringRef Name) const
getMDKindID - Return a unique non-zero ID for the specified metadata kind.
LLVMValueRef LLVMConstSRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:905
arg_iterator arg_begin()
Definition: Function.h:410
LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef B)
Definition: Core.cpp:1994
LLVMValueRef LLVMBuildInvoke(LLVMBuilderRef B, LLVMValueRef Fn, LLVMValueRef *Args, unsigned NumArgs, LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch, const char *Name)
Definition: Core.cpp:1973
void LLVMShutdown()
Definition: Core.cpp:55
LLVMTypeRef LLVMPPCFP128Type(void)
Definition: Core.cpp:320
Function to be accessible from DLL.
Definition: GlobalValue.h:46
Integer representation type.
Definition: DerivedTypes.h:37
const char * LLVMGetMDString(LLVMValueRef V, unsigned *Len)
Definition: Core.cpp:609
static Constant * getFPTrunc(Constant *C, Type *Ty)
Definition: Constants.cpp:1569
LLVMValueRef LLVMConstIntToPtr(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition: Core.cpp:1026
LLVMValueRef LLVMConstPointerCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition: Core.cpp:1060
LLVMValueRef LLVMBuildNot(LLVMBuilderRef B, LLVMValueRef V, const char *Name)
Definition: Core.cpp:2168
LLVMBasicBlockRef LLVMGetInsertBlock(LLVMBuilderRef Builder)
Definition: Core.cpp:1901
const char * LLVMGetTarget(LLVMModuleRef M)
Definition: Core.cpp:119
static Constant * get(StructType *T, ArrayRef< Constant * > V)
Definition: Constants.cpp:874
LLVMTypeRef LLVMInt16Type(void)
Definition: Core.cpp:264
static Constant * getNot(Constant *C)
Definition: Constants.cpp:2023
void LLVMPositionBuilderBefore(LLVMBuilderRef Builder, LLVMValueRef Instr)
Definition: Core.cpp:1891
static Constant * getAllOnesValue(Type *Ty)
Get the all ones value.
Definition: Constants.cpp:163
LLVMTypeRef LLVMGetTypeByName(LLVMModuleRef M, const char *Name)
Definition: Core.cpp:407
LLVMOpcode LLVMGetConstOpcode(LLVMValueRef ConstantVal)
Definition: Core.cpp:780
unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr)
Definition: Core.cpp:1787
void LLVMDumpValue(LLVMValueRef Val)
Definition: Core.cpp:473
LLVMValueRef LLVMConstSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:835
LLVMValueRef LLVMConstUIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition: Core.cpp:1001
int LLVMGetNumOperands(LLVMValueRef Val)
Definition: Core.cpp:548
static UndefValue * get(Type *T)
Definition: Constants.cpp:1334
static Constant * getFPExtend(Constant *C, Type *Ty)
Definition: Constants.cpp:1581
LLVMValueRef LLVMBuildGEP(LLVMBuilderRef B, LLVMValueRef Pointer, LLVMValueRef *Indices, unsigned NumIndices, const char *Name)
Definition: Core.cpp:2222
LLVMValueRef LLVMAddGlobalInAddressSpace(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name, unsigned AddressSpace)
Definition: Core.cpp:1291
LLVMContext & getContext() const
All values hold a context through their type.
Definition: Value.cpp:517
LLVMValueRef LLVMBuildTrunc(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:2267
const char * LLVMGetDataLayout(LLVMModuleRef M)
Definition: Core.cpp:110
void setThreadLocalMode(ThreadLocalMode Val)
LLVMValueRef LLVMGetParam(LLVMValueRef FnRef, unsigned index)
Definition: Core.cpp:1553
struct LLVMOpaqueValue * LLVMValueRef
Definition: Core.h:94
LLVMValueRef LLVMConstStringInContext(LLVMContextRef C, const char *Str, unsigned Length, LLVMBool DontNullTerminate)
Definition: Core.cpp:710
LLVMValueRef LLVMConstURem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:900
LLVMTypeRef LLVMVoidType(void)
Definition: Core.cpp:450
LLVMValueRef LLVMBuildCall(LLVMBuilderRef B, LLVMValueRef Fn, LLVMValueRef *Args, unsigned NumArgs, const char *Name)
Definition: Core.cpp:2394
static Type * getFP128Ty(LLVMContext &C)
Definition: Type.cpp:234
LLVMBasicBlockRef LLVMAppendBasicBlockInContext(LLVMContextRef C, LLVMValueRef FnRef, const char *Name)
Definition: Core.cpp:1690
LLVMTypeRef LLVMGetElementType(LLVMTypeRef Ty)
Definition: Core.cpp:425
LLVMValueRef LLVMBuildNeg(LLVMBuilderRef B, LLVMValueRef V, const char *Name)
Definition: Core.cpp:2150
void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf)
Definition: Core.cpp:2571
LLVMValueRef LLVMBuildUIToFP(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:2292
void LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC)
Definition: Core.cpp:1480
char *strdup(const char *s1);
void LLVMGetBasicBlocks(LLVMValueRef FnRef, LLVMBasicBlockRef *BasicBlocksRefs)
Definition: Core.cpp:1648
global_iterator global_end()
Definition: Module.h:523
unsigned LLVMGetNamedMetadataNumOperands(LLVMModuleRef M, const char *name)
Definition: Core.cpp:631
13: Arrays
Definition: Type.h:71
LLVMContextRef LLVMGetTypeContext(LLVMTypeRef Ty)
Definition: Core.cpp:219
static Constant * getPointerCast(Constant *C, Type *Ty)
Create a BitCast or a PtrToInt cast constant expression.
Definition: Constants.cpp:1487
LLVMValueRef LLVMGetOperand(LLVMValueRef Val, unsigned Index)
Definition: Core.cpp:537
LLVMValueRef LLVMConstTruncOrBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition: Core.cpp:1054
static Type * getHalfTy(LLVMContext &C)
Definition: Type.cpp:229
unsigned LLVMCountParams(LLVMValueRef FnRef)
Definition: Core.cpp:1540
static IntegerType * get(LLVMContext &C, unsigned NumBits)
Get or create an IntegerType instance.
Definition: Type.cpp:305
static Constant * getBitCast(Constant *C, Type *Ty)
Definition: Constants.cpp:1661
static error_code getFile(Twine Filename, OwningPtr< MemoryBuffer > &result, int64_t FileSize=-1, bool RequiresNullTerminator=true)
LLVMModuleProviderRef LLVMCreateModuleProviderForExistingModule(LLVMModuleRef M)
Definition: Core.cpp:2501
void LLVMInsertIntoBuilder(LLVMBuilderRef Builder, LLVMValueRef Instr)
Definition: Core.cpp:1909
LLVMValueRef LLVMBuildFPCast(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:2367
LLVMBasicBlockRef LLVMGetSwitchDefaultDest(LLVMValueRef Switch)
Definition: Core.cpp:1848
LLVMValueRef LLVMBuildRetVoid(LLVMBuilderRef B)
Definition: Core.cpp:1941
LLVMValueRef LLVMBuildGlobalString(LLVMBuilderRef B, const char *Str, const char *Name)
Definition: Core.cpp:2241
LLVMValueRef LLVMConstPointerNull(LLVMTypeRef Ty)
Definition: Core.cpp:583
void LLVMSetInitializer(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal)
Definition: Core.cpp:1346
LLVMThreadLocalMode
Definition: Core.h:348
LLVMVisibility LLVMGetVisibility(LLVMValueRef Global)
Definition: Core.cpp:1248
LLVMValueRef LLVMConstNUWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:846
static MemoryBuffer * getMemBufferCopy(StringRef InputData, StringRef BufferName="")
void LLVMInitializeCore(LLVMPassRegistryRef R)
Definition: Core.cpp:51
LLVMContextRef LLVMContextCreate()
Definition: Core.cpp:72
struct LLVMOpaquePassRegistry * LLVMPassRegistryRef
Definition: Core.h:128
LLVMTypeKind LLVMGetTypeKind(LLVMTypeRef Ty)
Definition: Core.cpp:176
LLVMTypeRef LLVMTypeOf(LLVMValueRef Val)
Definition: Core.cpp:461
LLVMValueRef LLVMConstAllOnes(LLVMTypeRef Ty)
Definition: Core.cpp:561
15: SIMD 'packed' format, or other vector type
Definition: Type.h:73
LLVMValueRef LLVMConstFPTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition: Core.cpp:991
static StructType * get(LLVMContext &Context, ArrayRef< Type * > Elements, bool isPacked=false)
Definition: Type.cpp:405
static Constant * getSDiv(Constant *C1, Constant *C2, bool isExact=false)
Definition: Constants.cpp:2067
struct LLVMOpaqueBasicBlock * LLVMBasicBlockRef
Definition: Core.h:101
iterator end()
Definition: BasicBlock.h:195
LLVMValueRef LLVMConstInsertValue(LLVMValueRef AggConstant, LLVMValueRef ElementValueConstant, unsigned *IdxList, unsigned NumIdx)
Definition: Core.cpp:1113
LLVMValueRef LLVMBuildURem(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:2098
bool hasName() const
hasName - Return true if this is a named struct that has a non-empty name.
Definition: DerivedTypes.h:255
LLVMTypeRef LLVMLabelType(void)
Definition: Core.cpp:453
Keep one copy of function when linking (inline)
Definition: GlobalValue.h:36
AddressSpace
Definition: NVPTXBaseInfo.h:22
LLVMValueRef LLVMBuildFCmp(LLVMBuilderRef B, LLVMRealPredicate Op, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:2381
LLVMContextRef * wrap(const LLVMContext **Tys)
Definition: LLVMContext.h:123
static Constant * getNUWMul(Constant *C1, Constant *C2)
Definition: Constants.h:884
LLVMValueRef LLVMGetNextInstruction(LLVMValueRef Inst)
Definition: Core.cpp:1750
void LLVMDeleteGlobal(LLVMValueRef GlobalVar)
Definition: Core.cpp:1335
LLVMValueRef LLVMConstSExtOrBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition: Core.cpp:1048
LLVMValueRef LLVMBuildXor(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:2138
LLVMValueRef LLVMBuildUDiv(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:2078
static Constant * getNSWSub(Constant *C1, Constant *C2)
Definition: Constants.h:875
void LLVMRemoveInstrAttribute(LLVMValueRef Instr, unsigned index, LLVMAttribute PA)
Definition: Core.cpp:1815
static Constant * get(Type *Ty, uint64_t V, bool isSigned=false)
Definition: Constants.cpp:492
LLVMBool LLVMIsFunctionVarArg(LLVMTypeRef FunctionTy)
Definition: Core.cpp:336
LLVMValueRef LLVMGetCurrentDebugLocation(LLVMBuilderRef Builder)
Definition: Core.cpp:1929
static Constant * getTrunc(Constant *C, Type *Ty)
Definition: Constants.cpp:1527
LLVMLinkage
Definition: Core.h:272
static Constant * get(Type *Ty, double V)
Definition: Constants.cpp:557
LLVMTypeRef LLVMDoubleType(void)
Definition: Core.cpp:311
void LLVMSetDataLayout(LLVMModuleRef M, const char *Triple)
Definition: Core.cpp:114
LLVMValueRef LLVMBuildInsertValue(LLVMBuilderRef B, LLVMValueRef AggVal, LLVMValueRef EltVal, unsigned Index, const char *Name)
Definition: Core.cpp:2439
LLVMValueRef LLVMGetUser(LLVMUseRef U)
Definition: Core.cpp:528
void setLinkage(LinkageTypes LT)
Definition: GlobalValue.h:217
LLVMValueRef LLVMConstFPExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition: Core.cpp:996
static Constant * getFPToSI(Constant *C, Type *Ty)
Definition: Constants.cpp:1626
8: Metadata
Definition: Type.h:63
AttributeSet getAttributes() const
Return the attribute list for this Function.
Definition: Function.h:170
static LLVMOpcode map_to_llvmopcode(int opcode)
Definition: Core.cpp:758
AttributeSet removeAttributes(LLVMContext &C, unsigned Index, AttributeSet Attrs) const
Remove the specified attributes at the specified index from this attribute list. Since attribute list...
Definition: Attributes.cpp:739
LLVMTypeRef LLVMStructType(LLVMTypeRef *ElementTypes, unsigned ElementCount, LLVMBool Packed)
Definition: Core.cpp:363
std::string message() const
LLVMValueRef LLVMBuildShuffleVector(LLVMBuilderRef B, LLVMValueRef V1, LLVMValueRef V2, LLVMValueRef Mask, const char *Name)
Definition: Core.cpp:2427
LLVMValueRef LLVMBuildGlobalStringPtr(LLVMBuilderRef B, const char *Str, const char *Name)
Definition: Core.cpp:2246
void LLVMSetExternallyInitialized(LLVMValueRef GlobalVar, LLVMBool IsExtInit)
Definition: Core.cpp:1410
bool hasInitializer() const
Class for arbitrary precision integers.
Definition: APInt.h:75
void LLVMRemoveAttribute(LLVMValueRef Arg, LLVMAttribute PA)
Definition: Core.cpp:1602
LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef B, LLVMTypeRef Ty, const char *Name)
Definition: Core.cpp:2174
LLVMValueRef LLVMBuildFree(LLVMBuilderRef B, LLVMValueRef PointerVal)
Definition: Core.cpp:2206
LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType, LLVMTypeRef *ParamTypes, unsigned ParamCount, LLVMBool IsVarArg)
Definition: Core.cpp:329
StringRef getName() const
Definition: Type.cpp:580
LLVMValueRef LLVMBuildBitCast(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:2322
LLVMBool LLVMIsThreadLocal(LLVMValueRef GlobalVar)
Definition: Core.cpp:1351
bool hasGC() const
Definition: Function.cpp:310
LLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition: Core.cpp:1021
static char getTypeID(Type *Ty)
void setGC(const char *Str)
Definition: Function.cpp:321
LLVMBool LLVMRunPassManager(LLVMPassManagerRef PM, LLVMModuleRef M)
Definition: Core.cpp:2596
LLVMValueRef LLVMGetBasicBlockTerminator(LLVMBasicBlockRef BB)
Definition: Core.cpp:1640
LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count, LLVMBool Packed)
Definition: Core.cpp:736
Use & getUse() const
Definition: Use.h:210
static Constant * getZExtOrBitCast(Constant *C, Type *Ty)
Definition: Constants.cpp:1469
LLVMValueRef LLVMConstFCmp(LLVMRealPredicate Predicate, LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:937
LLVMTypeRef LLVMX86MMXTypeInContext(LLVMContextRef C)
Definition: Core.cpp:301
LLVMValueRef LLVMConstMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:857
LLVMBool LLVMIsDeclaration(LLVMValueRef Global)
Definition: Core.cpp:1139
Like LinkerPrivate, but weak.
Definition: GlobalValue.h:44
LLVMValueRef LLVMBuildFPExt(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:2307
LLVMValueRef LLVMConstNeg(LLVMValueRef ConstantVal)
Definition: Core.cpp:792
void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues, LLVMBasicBlockRef *IncomingBlocks, unsigned Count)
Definition: Core.cpp:1854
static Constant * getFSub(Constant *C1, Constant *C2)
Definition: Constants.cpp:2047
LLVMValueRef LLVMBuildExtractValue(LLVMBuilderRef B, LLVMValueRef AggVal, unsigned Index, const char *Name)
Definition: Core.cpp:2434
LLVMValueRef LLVMBuildAShr(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:2123
static Constant * getTruncOrBitCast(Constant *C, Type *Ty)
Definition: Constants.cpp:1481
void LLVMRemoveBasicBlockFromParent(LLVMBasicBlockRef BBRef)
Definition: Core.cpp:1716
LLVMValueRef LLVMConstFAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:830
static Constant * getNeg(Constant *C, bool HasNUW=false, bool HasNSW=false)
Definition: Constants.cpp:2010
use_iterator use_begin()
Definition: Value.h:150
LLVMValueRef LLVMConstNSWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:840
LLVMValueRef LLVMBuildMul(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:2058
LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg)
Definition: Core.cpp:1588
LLVMModuleRef LLVMModuleCreateWithName(const char *ModuleID)
Definition: Core.cpp:96
void LLVMAddCase(LLVMValueRef Switch, LLVMValueRef OnVal, LLVMBasicBlockRef Dest)
Definition: Core.cpp:1998
static Constant * getNSWMul(Constant *C1, Constant *C2)
Definition: Constants.h:881
LLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Val, const char *Name)
Definition: Core.cpp:2185
static Constant * getSExt(Constant *C, Type *Ty)
Definition: Constants.cpp:1541
static Constant * getInBoundsGetElementPtr(Constant *C, ArrayRef< Constant * > IdxList)
Definition: Constants.h:1025
struct LLVMOpaquePassManager * LLVMPassManagerRef
Definition: Core.h:125
char * LLVMPrintTypeToString(LLVMTypeRef Ty)
Definition: Core.cpp:227
iterator end()
Definition: Module.h:533
LLVMValueRef LLVMBuildIntToPtr(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:2317
static IntegerType * getInt32Ty(LLVMContext &C)
Definition: Type.cpp:241
LLVMValueRef LLVMConstIntOfArbitraryPrecision(LLVMTypeRef IntTy, unsigned NumWords, const uint64_t Words[])
Definition: Core.cpp:666
LLVMTypeRef LLVMInt64Type(void)
Definition: Core.cpp:270
static Constant * getZExt(Constant *C, Type *Ty)
Definition: Constants.cpp:1555
LLVMVisibility
Definition: Core.h:295
LLVMTypeRef LLVMHalfTypeInContext(LLVMContextRef C)
Definition: Core.cpp:283
LLVMBasicBlockRef LLVMAppendBasicBlock(LLVMValueRef FnRef, const char *Name)
Definition: Core.cpp:1696
LLVMValueRef LLVMConstNUWNeg(LLVMValueRef ConstantVal)
Definition: Core.cpp:800
LLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B, LLVMAtomicRMWBinOp op, LLVMValueRef PTR, LLVMValueRef Val, LLVMAtomicOrdering ordering, LLVMBool singleThread)
Definition: Core.cpp:2461
void LLVMDeleteBasicBlock(LLVMBasicBlockRef BBRef)
Definition: Core.cpp:1712
void * PointerTy
Definition: GenericValue.h:23
LLVMValueRef LLVMBuildLShr(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:2118
LLVMValueRef LLVMBuildIsNotNull(LLVMBuilderRef B, LLVMValueRef Val, const char *Name)
Definition: Core.cpp:2451
unsigned LLVMGetMDKindID(const char *Name, unsigned SLen)
Definition: Core.cpp:89
LLVMBool LLVMIsConstant(LLVMValueRef Ty)
Definition: Core.cpp:569
void setAttributes(const AttributeSet &PAL)
Definition: CallSite.h:182
#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:2053
static Constant * getOr(Constant *C1, Constant *C2)
Definition: Constants.cpp:2092
LLVMBasicBlockRef LLVMGetIncomingBlock(LLVMValueRef PhiNode, unsigned Index)
Definition: Core.cpp:1869
LLVMTypeRef LLVMInt1TypeInContext(LLVMContextRef C)
Definition: Core.cpp:239
LLVMBool LLVMGetVolatile(LLVMValueRef MemAccessInst)
Definition: Core.cpp:2251
LLVMTypeRef LLVMInt1Type(void)
Definition: Core.cpp:258
LLVMTypeRef LLVMIntType(unsigned NumBits)
Definition: Core.cpp:273
void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC)
Definition: Core.cpp:1796
iterator begin()
Definition: Module.h:531
LLVMPassManagerRef LLVMCreateFunctionPassManagerForModule(LLVMModuleRef M)
Definition: Core.cpp:2587
LLVMModuleRef LLVMModuleCreateWithNameInContext(const char *ModuleID, LLVMContextRef C)
Definition: Core.cpp:100
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=0, BasicBlock *InsertBefore=0)
Creates a new BasicBlock.
Definition: BasicBlock.h:109
LLVMValueRef LLVMBuildSwitch(LLVMBuilderRef B, LLVMValueRef V, LLVMBasicBlockRef Else, unsigned NumCases)
Definition: Core.cpp:1963
LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy, LLVMValueRef *ConstantVals, unsigned Length)
Definition: Core.cpp:731
static DebugLoc getFromDILocation(MDNode *N)
getFromDILocation - Translate the DILocation quad into a DebugLoc.
Definition: DebugLoc.cpp:117
struct LLVMOpaqueUse * LLVMUseRef
Definition: Core.h:134
static ArrayType * get(Type *ElementType, uint64_t NumElements)
Definition: Type.cpp:679
void LLVMDumpType(LLVMTypeRef Ty)
Definition: Core.cpp:223
static Constant * getShl(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
Definition: Constants.cpp:2100
Keep one copy of named function when linking (weak)
Definition: GlobalValue.h:38
Rename collisions when linking (static functions).
Definition: GlobalValue.h:41
LLVMTypeRef LLVMInt8Type(void)
Definition: Core.cpp:261
static Constant * getInsertValue(Constant *Agg, Constant *Val, ArrayRef< unsigned > Idxs)
Definition: Constants.cpp:1969
static InlineAsm * get(FunctionType *Ty, StringRef AsmString, StringRef Constraints, bool hasSideEffects, bool isAlignStack=false, AsmDialect asmDialect=AD_ATT)
Definition: InlineAsm.cpp:28
LLVMValueRef LLVMConstSIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition: Core.cpp:1006
void setAttributes(AttributeSet attrs)
Set the attribute list for this Function.
Definition: Function.h:173
LLVMValueRef LLVMConstLShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:949
LLVMBool LLVMFinalizeFunctionPassManager(LLVMPassManagerRef FPM)
Definition: Core.cpp:2608
LLVMIntPredicate LLVMGetICmpPredicate(LLVMValueRef Inst)
Definition: Core.cpp:1770
void LLVMSetCleanup(LLVMValueRef LandingPad, LLVMBool Val)
Definition: Core.cpp:2012
LLVMValueRef LLVMConstShl(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:944
struct LLVMOpaqueModule * LLVMModuleRef
Definition: Core.h:80
LLVMValueRef LLVMBuildNUWMul(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:2068
LLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal)
Definition: Core.cpp:809
LLVMValueRef LLVMBuildLandingPad(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef PersFn, unsigned NumClauses, const char *Name)
Definition: Core.cpp:1982
3: 64-bit floating point type
Definition: Type.h:58
LLVMValueRef LLVMGetFirstFunction(LLVMModuleRef M)
Definition: Core.cpp:1434
LLVMAttribute LLVMGetAttribute(LLVMValueRef Arg)
Definition: Core.cpp:1608
LLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename, char **ErrorMessage)
Definition: Core.cpp:131
LLVMValueRef LLVMBuildVAArg(LLVMBuilderRef B, LLVMValueRef List, LLVMTypeRef Ty, const char *Name)
Definition: Core.cpp:2409
void LLVMSetThreadLocalMode(LLVMValueRef GlobalVar, LLVMThreadLocalMode Mode)
Definition: Core.cpp:1384
static Constant * getSRem(Constant *C1, Constant *C2)
Definition: Constants.cpp:2080
LLVMBuilderRef LLVMCreateBuilderInContext(LLVMContextRef C)
Definition: Core.cpp:1876
void LLVMSetMetadata(LLVMValueRef Inst, unsigned KindID, LLVMValueRef MD)
Definition: Core.cpp:499
LLVMValueRef LLVMGetParamParent(LLVMValueRef V)
Definition: Core.cpp:1560
const char * LLVMGetValueName(LLVMValueRef Val)
Definition: Core.cpp:465
LLVMValueRef LLVMBuildSExtOrBitCast(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:2338
LLVMValueRef LLVMBuildBr(LLVMBuilderRef B, LLVMBasicBlockRef Dest)
Definition: Core.cpp:1954
void llvm_stop_multithreaded()
Definition: Threading.cpp:41
Module * getParent()
Definition: GlobalValue.h:286
LLVM Value Representation.
Definition: Value.h:66
uint64_t Raw(unsigned Index) const
Definition: Attributes.cpp:922
LLVMValueRef LLVMBuildZExtOrBitCast(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:2332
LLVMBool LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef *OutMemBuf, char **OutMessage)
Definition: Core.cpp:2528
LLVMLinkage LLVMGetLinkage(LLVMValueRef Global)
Definition: Core.cpp:1143
static Constant * getURem(Constant *C1, Constant *C2)
Definition: Constants.cpp:2076
unsigned getArgNo() const
Return the index of this formal argument in its containing function.
Definition: Function.cpp:67
static VectorType * get(Type *ElementType, unsigned NumElements)
Definition: Type.cpp:706
static StructType * create(LLVMContext &Context, StringRef Name)
StructType::create - This creates an identified struct.
Definition: Type.cpp:494
LLVMBasicBlockRef LLVMValueAsBasicBlock(LLVMValueRef Val)
Definition: Core.cpp:1632
LLVMValueRef LLVMGetPreviousFunction(LLVMValueRef Fn)
Definition: Core.cpp:1458
static const Function * getParent(const Value *V)
LLVMValueRef LLVMBuildIndirectBr(LLVMBuilderRef B, LLVMValueRef Addr, unsigned NumDests)
Definition: Core.cpp:1968
void LLVMSetGC(LLVMValueRef Fn, const char *GC)
Definition: Core.cpp:1490
LLVMValueRef LLVMBuildNSWNeg(LLVMBuilderRef B, LLVMValueRef V, const char *Name)
Definition: Core.cpp:2154
LLVMTypeRef LLVMGetReturnType(LLVMTypeRef FunctionTy)
Definition: Core.cpp:340
unsigned getNumOperands() const
getNumOperands - Return the number of NamedMDNode operands.
Definition: Metadata.cpp:540
LLVMValueRef LLVMBuildNSWMul(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:2063
LLVMValueRef LLVMBuildStore(LLVMBuilderRef B, LLVMValueRef Val, LLVMValueRef PointerVal)
Definition: Core.cpp:2217
#define DEBUG(X)
Definition: Debug.h:97
LLVMValueRef LLVMBuildBinOp(LLVMBuilderRef B, LLVMOpcode Op, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:2143
struct LLVMOpaqueBuilder * LLVMBuilderRef
Definition: Core.h:108
LLVMValueRef LLVMConstZExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType)
Definition: Core.cpp:986
LLVMBool LLVMIsMultithreaded()
Definition: Core.cpp:2626
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()
Definition: Core.cpp:76
LLVMValueRef LLVMConstNSWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:862
LLVMTypeRef LLVMInt32TypeInContext(LLVMContextRef C)
Definition: Core.cpp:248
LLVMBool LLVMRunFunctionPassManager(LLVMPassManagerRef FPM, LLVMValueRef F)
Definition: Core.cpp:2604
void addAttributes(unsigned i, AttributeSet attrs)
adds the attributes to the list of attributes.
Definition: Function.cpp:290
9: MMX vectors (64 bits, X86 specific)
Definition: Type.h:64
static Constant * getAlignOf(Type *Ty)
Definition: Constants.cpp:1766
LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, unsigned AddressSpace)
Definition: Core.cpp:417
static Constant * getMul(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
Definition: Constants.cpp:2051
LLVMValueRef LLVMBuildLoad(LLVMBuilderRef B, LLVMValueRef PointerVal, const char *Name)
Definition: Core.cpp:2212
void LLVMAddInstrAttribute(LLVMValueRef Instr, unsigned index, LLVMAttribute PA)
Definition: Core.cpp:1805
LLVMValueRef LLVMConstExtractElement(LLVMValueRef VectorConstant, LLVMValueRef IndexConstant)
Definition: Core.cpp:1085
void LLVMSetTailCall(LLVMValueRef Call, LLVMBool isTailCall)
Definition: Core.cpp:1842
static Constant * getNUWSub(Constant *C1, Constant *C2)
Definition: Constants.h:878
void LLVMSetModuleInlineAsm(LLVMModuleRef M, const char *Asm)
Definition: Core.cpp:161
LLVMValueRef LLVMBuildAddrSpaceCast(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:2327
AttributeSet addAttributes(LLVMContext &C, unsigned Index, AttributeSet Attrs) const
Add attributes to the attribute set at the given index. Since attribute sets are immutable, this returns a new set.
Definition: Attributes.cpp:684
LLVMValueRef LLVMConstFRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant)
Definition: Core.cpp:910
static Constant * getNUWAdd(Constant *C1, Constant *C2)
Definition: Constants.h:872
unsigned LLVMGetAlignment(LLVMValueRef V)
Definition: Core.cpp:1260
LLVMValueRef LLVMGetNextFunction(LLVMValueRef Fn)
Definition: Core.cpp:1450
static IntegerType * getInt8Ty(LLVMContext &C)
Definition: Type.cpp:239
void LLVMDisposeModuleProvider(LLVMModuleProviderRef MP)
Definition: Core.cpp:2505
LLVMValueRef LLVMBuildSelect(LLVMBuilderRef B, LLVMValueRef If, LLVMValueRef Then, LLVMValueRef Else, const char *Name)
Definition: Core.cpp:2402
const BasicBlock * getParent() const
Definition: Instruction.h:52
static Instruction * CreateMalloc(Instruction *InsertBefore, Type *IntPtrTy, Type *AllocTy, Value *AllocSize, Value *ArraySize=0, Function *MallocF=0, const Twine &Name="")
LLVMContext & getGlobalContext()
Definition: LLVMContext.cpp:27
static error_code getSTDIN(OwningPtr< MemoryBuffer > &result)
LLVMRealPredicate
Definition: Core.h:324
LLVMTypeRef LLVMX86FP80TypeInContext(LLVMContextRef C)
Definition: Core.cpp:292
static Constant * getInsertElement(Constant *Vec, Constant *Elt, Constant *Idx)
Definition: Constants.cpp:1930
LLVMAttribute LLVMGetFunctionAttr(LLVMValueRef Fn)
Definition: Core.cpp:1532
void LLVMInsertIntoBuilderWithName(LLVMBuilderRef Builder, LLVMValueRef Instr, const char *Name)
Definition: Core.cpp:1913
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, const Twine &N="", Module *M=0)
Definition: Function.h:128
static Constant * getXor(Constant *C1, Constant *C2)
Definition: Constants.cpp:2096
LLVMValueRef LLVMBuildFPTrunc(LLVMBuilderRef B, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:2302
5: 128-bit floating point type (112-bit mantissa)
Definition: Type.h:60
void LLVMSetAlignment(LLVMValueRef V, unsigned Bytes)
Definition: Core.cpp:1272
LLVMModuleRef LLVMGetGlobalParent(LLVMValueRef Global)
Definition: Core.cpp:1135