LLVM 18.0.0git
Core.h
Go to the documentation of this file.
1/*===-- llvm-c/Core.h - Core Library C Interface ------------------*- C -*-===*\
2|* *|
3|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
4|* Exceptions. *|
5|* See https://llvm.org/LICENSE.txt for license information. *|
6|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
7|* *|
8|*===----------------------------------------------------------------------===*|
9|* *|
10|* This header declares the C interface to libLLVMCore.a, which implements *|
11|* the LLVM intermediate representation. *|
12|* *|
13\*===----------------------------------------------------------------------===*/
14
15#ifndef LLVM_C_CORE_H
16#define LLVM_C_CORE_H
17
18#include "llvm-c/Deprecated.h"
20#include "llvm-c/ExternC.h"
21
22#include "llvm-c/Types.h"
23
25
26/**
27 * @defgroup LLVMC LLVM-C: C interface to LLVM
28 *
29 * This module exposes parts of the LLVM library as a C API.
30 *
31 * @{
32 */
33
34/**
35 * @defgroup LLVMCTransforms Transforms
36 */
37
38/**
39 * @defgroup LLVMCCore Core
40 *
41 * This modules provide an interface to libLLVMCore, which implements
42 * the LLVM intermediate representation as well as other related types
43 * and utilities.
44 *
45 * Many exotic languages can interoperate with C code but have a harder time
46 * with C++ due to name mangling. So in addition to C, this interface enables
47 * tools written in such languages.
48 *
49 * @{
50 */
51
52/**
53 * @defgroup LLVMCCoreTypes Types and Enumerations
54 *
55 * @{
56 */
57
58/// External users depend on the following values being stable. It is not safe
59/// to reorder them.
60typedef enum {
61 /* Terminator Instructions */
63 LLVMBr = 2,
67 /* removed 6 due to API changes */
70
71 /* Standard Unary Operators */
73
74 /* Standard Binary Operators */
77 LLVMSub = 10,
79 LLVMMul = 12,
87
88 /* Logical Operators */
89 LLVMShl = 20,
92 LLVMAnd = 23,
93 LLVMOr = 24,
94 LLVMXor = 25,
95
96 /* Memory Operators */
101
102 /* Cast Operators */
116
117 /* Other Operators */
132
133 /* Atomic operators */
137
138 /* Exception Handling Operators */
145 LLVMCatchSwitch = 65
147
148typedef enum {
149 LLVMVoidTypeKind, /**< type with no size */
150 LLVMHalfTypeKind, /**< 16 bit floating point type */
151 LLVMFloatTypeKind, /**< 32 bit floating point type */
152 LLVMDoubleTypeKind, /**< 64 bit floating point type */
153 LLVMX86_FP80TypeKind, /**< 80 bit floating point type (X87) */
154 LLVMFP128TypeKind, /**< 128 bit floating point type (112-bit mantissa)*/
155 LLVMPPC_FP128TypeKind, /**< 128 bit floating point type (two 64-bits) */
156 LLVMLabelTypeKind, /**< Labels */
157 LLVMIntegerTypeKind, /**< Arbitrary bit width integers */
158 LLVMFunctionTypeKind, /**< Functions */
159 LLVMStructTypeKind, /**< Structures */
160 LLVMArrayTypeKind, /**< Arrays */
161 LLVMPointerTypeKind, /**< Pointers */
162 LLVMVectorTypeKind, /**< Fixed width SIMD vector type */
163 LLVMMetadataTypeKind, /**< Metadata */
164 LLVMX86_MMXTypeKind, /**< X86 MMX */
165 LLVMTokenTypeKind, /**< Tokens */
166 LLVMScalableVectorTypeKind, /**< Scalable SIMD vector type */
167 LLVMBFloatTypeKind, /**< 16 bit brain floating point type */
168 LLVMX86_AMXTypeKind, /**< X86 AMX */
169 LLVMTargetExtTypeKind, /**< Target extension type */
171
172typedef enum {
173 LLVMExternalLinkage, /**< Externally visible function */
175 LLVMLinkOnceAnyLinkage, /**< Keep one copy of function when linking (inline)*/
176 LLVMLinkOnceODRLinkage, /**< Same, but only replaced by something
177 equivalent. */
179 LLVMWeakAnyLinkage, /**< Keep one copy of function when linking (weak) */
180 LLVMWeakODRLinkage, /**< Same, but only replaced by something
181 equivalent. */
182 LLVMAppendingLinkage, /**< Special purpose, only applies to global arrays */
183 LLVMInternalLinkage, /**< Rename collisions when linking (static
184 functions) */
185 LLVMPrivateLinkage, /**< Like Internal, but omit from symbol table */
186 LLVMDLLImportLinkage, /**< Obsolete */
187 LLVMDLLExportLinkage, /**< Obsolete */
188 LLVMExternalWeakLinkage,/**< ExternalWeak linkage description */
189 LLVMGhostLinkage, /**< Obsolete */
190 LLVMCommonLinkage, /**< Tentative definitions */
191 LLVMLinkerPrivateLinkage, /**< Like Private, but linker removes. */
192 LLVMLinkerPrivateWeakLinkage /**< Like LinkerPrivate, but is weak. */
194
195typedef enum {
196 LLVMDefaultVisibility, /**< The GV is visible */
197 LLVMHiddenVisibility, /**< The GV is hidden */
198 LLVMProtectedVisibility /**< The GV is protected */
200
201typedef enum {
202 LLVMNoUnnamedAddr, /**< Address of the GV is significant. */
203 LLVMLocalUnnamedAddr, /**< Address of the GV is locally insignificant. */
204 LLVMGlobalUnnamedAddr /**< Address of the GV is globally insignificant. */
206
207typedef enum {
209 LLVMDLLImportStorageClass = 1, /**< Function to be imported from DLL. */
210 LLVMDLLExportStorageClass = 2 /**< Function to be accessible from DLL. */
212
213typedef enum {
256
257typedef enum {
263
273
282
285
290
291typedef enum {
292 LLVMIntEQ = 32, /**< equal */
293 LLVMIntNE, /**< not equal */
294 LLVMIntUGT, /**< unsigned greater than */
295 LLVMIntUGE, /**< unsigned greater or equal */
296 LLVMIntULT, /**< unsigned less than */
297 LLVMIntULE, /**< unsigned less or equal */
298 LLVMIntSGT, /**< signed greater than */
299 LLVMIntSGE, /**< signed greater or equal */
300 LLVMIntSLT, /**< signed less than */
301 LLVMIntSLE /**< signed less or equal */
303
304typedef enum {
305 LLVMRealPredicateFalse, /**< Always false (always folded) */
306 LLVMRealOEQ, /**< True if ordered and equal */
307 LLVMRealOGT, /**< True if ordered and greater than */
308 LLVMRealOGE, /**< True if ordered and greater than or equal */
309 LLVMRealOLT, /**< True if ordered and less than */
310 LLVMRealOLE, /**< True if ordered and less than or equal */
311 LLVMRealONE, /**< True if ordered and operands are unequal */
312 LLVMRealORD, /**< True if ordered (no nans) */
313 LLVMRealUNO, /**< True if unordered: isnan(X) | isnan(Y) */
314 LLVMRealUEQ, /**< True if unordered or equal */
315 LLVMRealUGT, /**< True if unordered or greater than */
316 LLVMRealUGE, /**< True if unordered, greater than, or equal */
317 LLVMRealULT, /**< True if unordered or less than */
318 LLVMRealULE, /**< True if unordered, less than, or equal */
319 LLVMRealUNE, /**< True if unordered or not equal */
320 LLVMRealPredicateTrue /**< Always true (always folded) */
322
323typedef enum {
324 LLVMLandingPadCatch, /**< A catch clause */
325 LLVMLandingPadFilter /**< A filter clause */
327
328typedef enum {
335
336typedef enum {
337 LLVMAtomicOrderingNotAtomic = 0, /**< A load or store which is not atomic */
338 LLVMAtomicOrderingUnordered = 1, /**< Lowest level of atomicity, guarantees
339 somewhat sane results, lock free. */
340 LLVMAtomicOrderingMonotonic = 2, /**< guarantees that if you take all the
341 operations affecting a specific address,
342 a consistent ordering exists */
343 LLVMAtomicOrderingAcquire = 4, /**< Acquire provides a barrier of the sort
344 necessary to acquire a lock to access other
345 memory with normal loads and stores. */
346 LLVMAtomicOrderingRelease = 5, /**< Release is similar to Acquire, but with
347 a barrier of the sort necessary to release
348 a lock. */
349 LLVMAtomicOrderingAcquireRelease = 6, /**< provides both an Acquire and a
350 Release barrier (for fences and
351 operations which both read and write
352 memory). */
353 LLVMAtomicOrderingSequentiallyConsistent = 7 /**< provides Acquire semantics
354 for loads and Release
355 semantics for stores.
356 Additionally, it guarantees
357 that a total ordering exists
358 between all
359 SequentiallyConsistent
360 operations. */
362
363typedef enum {
364 LLVMAtomicRMWBinOpXchg, /**< Set the new value and return the one old */
365 LLVMAtomicRMWBinOpAdd, /**< Add a value and return the old one */
366 LLVMAtomicRMWBinOpSub, /**< Subtract a value and return the old one */
367 LLVMAtomicRMWBinOpAnd, /**< And a value and return the old one */
368 LLVMAtomicRMWBinOpNand, /**< Not-And a value and return the old one */
369 LLVMAtomicRMWBinOpOr, /**< OR a value and return the old one */
370 LLVMAtomicRMWBinOpXor, /**< Xor a value and return the old one */
371 LLVMAtomicRMWBinOpMax, /**< Sets the value if it's greater than the
372 original using a signed comparison and return
373 the old one */
374 LLVMAtomicRMWBinOpMin, /**< Sets the value if it's Smaller than the
375 original using a signed comparison and return
376 the old one */
377 LLVMAtomicRMWBinOpUMax, /**< Sets the value if it's greater than the
378 original using an unsigned comparison and return
379 the old one */
380 LLVMAtomicRMWBinOpUMin, /**< Sets the value if it's greater than the
381 original using an unsigned comparison and return
382 the old one */
383 LLVMAtomicRMWBinOpFAdd, /**< Add a floating point value and return the
384 old one */
385 LLVMAtomicRMWBinOpFSub, /**< Subtract a floating point value and return the
386 old one */
387 LLVMAtomicRMWBinOpFMax, /**< Sets the value if it's greater than the
388 original using an floating point comparison and
389 return the old one */
390 LLVMAtomicRMWBinOpFMin, /**< Sets the value if it's smaller than the
391 original using an floating point comparison and
392 return the old one */
394
395typedef enum {
401
402typedef enum {
406
407typedef enum {
408 /**
409 * Emits an error if two values disagree, otherwise the resulting value is
410 * that of the operands.
411 *
412 * @see Module::ModFlagBehavior::Error
413 */
415 /**
416 * Emits a warning if two values disagree. The result value will be the
417 * operand for the flag from the first module being linked.
418 *
419 * @see Module::ModFlagBehavior::Warning
420 */
422 /**
423 * Adds a requirement that another module flag be present and have a
424 * specified value after linking is performed. The value must be a metadata
425 * pair, where the first element of the pair is the ID of the module flag
426 * to be restricted, and the second element of the pair is the value the
427 * module flag should be restricted to. This behavior can be used to
428 * restrict the allowable results (via triggering of an error) of linking
429 * IDs with the **Override** behavior.
430 *
431 * @see Module::ModFlagBehavior::Require
432 */
434 /**
435 * Uses the specified value, regardless of the behavior or value of the
436 * other module. If both modules specify **Override**, but the values
437 * differ, an error will be emitted.
438 *
439 * @see Module::ModFlagBehavior::Override
440 */
442 /**
443 * Appends the two values, which are required to be metadata nodes.
444 *
445 * @see Module::ModFlagBehavior::Append
446 */
448 /**
449 * Appends the two values, which are required to be metadata
450 * nodes. However, duplicate entries in the second list are dropped
451 * during the append operation.
452 *
453 * @see Module::ModFlagBehavior::AppendUnique
454 */
457
458/**
459 * Attribute index are either LLVMAttributeReturnIndex,
460 * LLVMAttributeFunctionIndex or a parameter number from 1 to N.
461 */
462enum {
464 // ISO C restricts enumerator values to range of 'int'
465 // (4294967295 is too large)
466 // LLVMAttributeFunctionIndex = ~0U,
468};
469
470/**
471 * Tail call kind for LLVMSetTailCallKind and LLVMGetTailCallKind.
472 *
473 * Note that 'musttail' implies 'tail'.
474 *
475 * @see CallInst::TailCallKind
476 */
477typedef enum {
483
484typedef unsigned LLVMAttributeIndex;
485
486/**
487 * @}
488 */
489
490/** Deallocate and destroy all ManagedStatic variables.
491 @see llvm::llvm_shutdown
492 @see ManagedStatic */
493void LLVMShutdown(void);
494
495/*===-- Version query -----------------------------------------------------===*/
496
497/**
498 * Return the major, minor, and patch version of LLVM
499 *
500 * The version components are returned via the function's three output
501 * parameters or skipped if a NULL pointer was supplied.
502 */
503void LLVMGetVersion(unsigned *Major, unsigned *Minor, unsigned *Patch);
504
505/*===-- Error handling ----------------------------------------------------===*/
506
507char *LLVMCreateMessage(const char *Message);
508void LLVMDisposeMessage(char *Message);
509
510/**
511 * @defgroup LLVMCCoreContext Contexts
512 *
513 * Contexts are execution states for the core LLVM IR system.
514 *
515 * Most types are tied to a context instance. Multiple contexts can
516 * exist simultaneously. A single context is not thread safe. However,
517 * different contexts can execute on different threads simultaneously.
518 *
519 * @{
520 */
521
523typedef void (*LLVMYieldCallback)(LLVMContextRef, void *);
524
525/**
526 * Create a new context.
527 *
528 * Every call to this function should be paired with a call to
529 * LLVMContextDispose() or the context will leak memory.
530 */
532
533/**
534 * Obtain the global context instance.
535 */
537
538/**
539 * Set the diagnostic handler for this context.
540 */
542 LLVMDiagnosticHandler Handler,
543 void *DiagnosticContext);
544
545/**
546 * Get the diagnostic handler of this context.
547 */
549
550/**
551 * Get the diagnostic context of this context.
552 */
554
555/**
556 * Set the yield callback function for this context.
557 *
558 * @see LLVMContext::setYieldCallback()
559 */
561 void *OpaqueHandle);
562
563/**
564 * Retrieve whether the given context is set to discard all value names.
565 *
566 * @see LLVMContext::shouldDiscardValueNames()
567 */
569
570/**
571 * Set whether the given context discards all value names.
572 *
573 * If true, only the names of GlobalValue objects will be available in the IR.
574 * This can be used to save memory and runtime, especially in release mode.
575 *
576 * @see LLVMContext::setDiscardValueNames()
577 */
579
580/**
581 * Destroy a context instance.
582 *
583 * This should be called for every call to LLVMContextCreate() or memory
584 * will be leaked.
585 */
587
588/**
589 * Return a string representation of the DiagnosticInfo. Use
590 * LLVMDisposeMessage to free the string.
591 *
592 * @see DiagnosticInfo::print()
593 */
595
596/**
597 * Return an enum LLVMDiagnosticSeverity.
598 *
599 * @see DiagnosticInfo::getSeverity()
600 */
602
603unsigned LLVMGetMDKindIDInContext(LLVMContextRef C, const char *Name,
604 unsigned SLen);
605unsigned LLVMGetMDKindID(const char *Name, unsigned SLen);
606
607/**
608 * Return an unique id given the name of a enum attribute,
609 * or 0 if no attribute by that name exists.
610 *
611 * See http://llvm.org/docs/LangRef.html#parameter-attributes
612 * and http://llvm.org/docs/LangRef.html#function-attributes
613 * for the list of available attributes.
614 *
615 * NB: Attribute names and/or id are subject to change without
616 * going through the C API deprecation cycle.
617 */
618unsigned LLVMGetEnumAttributeKindForName(const char *Name, size_t SLen);
619unsigned LLVMGetLastEnumAttributeKind(void);
620
621/**
622 * Create an enum attribute.
623 */
625 uint64_t Val);
626
627/**
628 * Get the unique id corresponding to the enum attribute
629 * passed as argument.
630 */
632
633/**
634 * Get the enum attribute's value. 0 is returned if none exists.
635 */
637
638/**
639 * Create a type attribute
640 */
642 LLVMTypeRef type_ref);
643
644/**
645 * Get the type attribute's value.
646 */
648
649/**
650 * Create a string attribute.
651 */
653 const char *K, unsigned KLength,
654 const char *V, unsigned VLength);
655
656/**
657 * Get the string attribute's kind.
658 */
659const char *LLVMGetStringAttributeKind(LLVMAttributeRef A, unsigned *Length);
660
661/**
662 * Get the string attribute's value.
663 */
664const char *LLVMGetStringAttributeValue(LLVMAttributeRef A, unsigned *Length);
665
666/**
667 * Check for the different types of attributes.
668 */
672
673/**
674 * Obtain a Type from a context by its registered name.
675 */
677
678/**
679 * @}
680 */
681
682/**
683 * @defgroup LLVMCCoreModule Modules
684 *
685 * Modules represent the top-level structure in an LLVM program. An LLVM
686 * module is effectively a translation unit or a collection of
687 * translation units merged together.
688 *
689 * @{
690 */
691
692/**
693 * Create a new, empty module in the global context.
694 *
695 * This is equivalent to calling LLVMModuleCreateWithNameInContext with
696 * LLVMGetGlobalContext() as the context parameter.
697 *
698 * Every invocation should be paired with LLVMDisposeModule() or memory
699 * will be leaked.
700 */
701LLVMModuleRef LLVMModuleCreateWithName(const char *ModuleID);
702
703/**
704 * Create a new, empty module in a specific context.
705 *
706 * Every invocation should be paired with LLVMDisposeModule() or memory
707 * will be leaked.
708 */
711/**
712 * Return an exact copy of the specified module.
713 */
715
716/**
717 * Destroy a module instance.
718 *
719 * This must be called for every created module or memory will be
720 * leaked.
721 */
723
724/**
725 * Obtain the identifier of a module.
726 *
727 * @param M Module to obtain identifier of
728 * @param Len Out parameter which holds the length of the returned string.
729 * @return The identifier of M.
730 * @see Module::getModuleIdentifier()
731 */
732const char *LLVMGetModuleIdentifier(LLVMModuleRef M, size_t *Len);
733
734/**
735 * Set the identifier of a module to a string Ident with length Len.
736 *
737 * @param M The module to set identifier
738 * @param Ident The string to set M's identifier to
739 * @param Len Length of Ident
740 * @see Module::setModuleIdentifier()
741 */
742void LLVMSetModuleIdentifier(LLVMModuleRef M, const char *Ident, size_t Len);
743
744/**
745 * Obtain the module's original source file name.
746 *
747 * @param M Module to obtain the name of
748 * @param Len Out parameter which holds the length of the returned string
749 * @return The original source file name of M
750 * @see Module::getSourceFileName()
751 */
752const char *LLVMGetSourceFileName(LLVMModuleRef M, size_t *Len);
753
754/**
755 * Set the original source file name of a module to a string Name with length
756 * Len.
757 *
758 * @param M The module to set the source file name of
759 * @param Name The string to set M's source file name to
760 * @param Len Length of Name
761 * @see Module::setSourceFileName()
762 */
763void LLVMSetSourceFileName(LLVMModuleRef M, const char *Name, size_t Len);
764
765/**
766 * Obtain the data layout for a module.
767 *
768 * @see Module::getDataLayoutStr()
769 *
770 * LLVMGetDataLayout is DEPRECATED, as the name is not only incorrect,
771 * but match the name of another method on the module. Prefer the use
772 * of LLVMGetDataLayoutStr, which is not ambiguous.
773 */
775const char *LLVMGetDataLayout(LLVMModuleRef M);
776
777/**
778 * Set the data layout for a module.
779 *
780 * @see Module::setDataLayout()
781 */
782void LLVMSetDataLayout(LLVMModuleRef M, const char *DataLayoutStr);
783
784/**
785 * Obtain the target triple for a module.
786 *
787 * @see Module::getTargetTriple()
788 */
789const char *LLVMGetTarget(LLVMModuleRef M);
790
791/**
792 * Set the target triple for a module.
793 *
794 * @see Module::setTargetTriple()
795 */
796void LLVMSetTarget(LLVMModuleRef M, const char *Triple);
797
798/**
799 * Returns the module flags as an array of flag-key-value triples. The caller
800 * is responsible for freeing this array by calling
801 * \c LLVMDisposeModuleFlagsMetadata.
802 *
803 * @see Module::getModuleFlagsMetadata()
804 */
806
807/**
808 * Destroys module flags metadata entries.
809 */
811
812/**
813 * Returns the flag behavior for a module flag entry at a specific index.
814 *
815 * @see Module::ModuleFlagEntry::Behavior
816 */
819 unsigned Index);
820
821/**
822 * Returns the key for a module flag entry at a specific index.
823 *
824 * @see Module::ModuleFlagEntry::Key
825 */
827 unsigned Index, size_t *Len);
828
829/**
830 * Returns the metadata for a module flag entry at a specific index.
831 *
832 * @see Module::ModuleFlagEntry::Val
833 */
835 unsigned Index);
836
837/**
838 * Add a module-level flag to the module-level flags metadata if it doesn't
839 * already exist.
840 *
841 * @see Module::getModuleFlag()
842 */
844 const char *Key, size_t KeyLen);
845
846/**
847 * Add a module-level flag to the module-level flags metadata if it doesn't
848 * already exist.
849 *
850 * @see Module::addModuleFlag()
851 */
853 const char *Key, size_t KeyLen,
854 LLVMMetadataRef Val);
855
856/**
857 * Dump a representation of a module to stderr.
858 *
859 * @see Module::dump()
860 */
862
863/**
864 * Print a representation of a module to a file. The ErrorMessage needs to be
865 * disposed with LLVMDisposeMessage. Returns 0 on success, 1 otherwise.
866 *
867 * @see Module::print()
868 */
869LLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename,
870 char **ErrorMessage);
871
872/**
873 * Return a string representation of the module. Use
874 * LLVMDisposeMessage to free the string.
875 *
876 * @see Module::print()
877 */
879
880/**
881 * Get inline assembly for a module.
882 *
883 * @see Module::getModuleInlineAsm()
884 */
885const char *LLVMGetModuleInlineAsm(LLVMModuleRef M, size_t *Len);
886
887/**
888 * Set inline assembly for a module.
889 *
890 * @see Module::setModuleInlineAsm()
891 */
892void LLVMSetModuleInlineAsm2(LLVMModuleRef M, const char *Asm, size_t Len);
893
894/**
895 * Append inline assembly to a module.
896 *
897 * @see Module::appendModuleInlineAsm()
898 */
899void LLVMAppendModuleInlineAsm(LLVMModuleRef M, const char *Asm, size_t Len);
900
901/**
902 * Create the specified uniqued inline asm string.
903 *
904 * @see InlineAsm::get()
905 */
906LLVMValueRef LLVMGetInlineAsm(LLVMTypeRef Ty, const char *AsmString,
907 size_t AsmStringSize, const char *Constraints,
908 size_t ConstraintsSize, LLVMBool HasSideEffects,
909 LLVMBool IsAlignStack,
910 LLVMInlineAsmDialect Dialect, LLVMBool CanThrow);
911
912/**
913 * Get the template string used for an inline assembly snippet
914 *
915 */
916const char *LLVMGetInlineAsmAsmString(LLVMValueRef InlineAsmVal, size_t *Len);
917
918/**
919 * Get the raw constraint string for an inline assembly snippet
920 *
921 */
922const char *LLVMGetInlineAsmConstraintString(LLVMValueRef InlineAsmVal,
923 size_t *Len);
924
925/**
926 * Get the dialect used by the inline asm snippet
927 *
928 */
930
931/**
932 * Get the function type of the inline assembly snippet. The same type that
933 * was passed into LLVMGetInlineAsm originally
934 *
935 * @see LLVMGetInlineAsm
936 *
937 */
939
940/**
941 * Get if the inline asm snippet has side effects
942 *
943 */
945
946/**
947 * Get if the inline asm snippet needs an aligned stack
948 *
949 */
951
952/**
953 * Get if the inline asm snippet may unwind the stack
954 *
955 */
957
958/**
959 * Obtain the context to which this module is associated.
960 *
961 * @see Module::getContext()
962 */
964
965/** Deprecated: Use LLVMGetTypeByName2 instead. */
967
968/**
969 * Obtain an iterator to the first NamedMDNode in a Module.
970 *
971 * @see llvm::Module::named_metadata_begin()
972 */
974
975/**
976 * Obtain an iterator to the last NamedMDNode in a Module.
977 *
978 * @see llvm::Module::named_metadata_end()
979 */
981
982/**
983 * Advance a NamedMDNode iterator to the next NamedMDNode.
984 *
985 * Returns NULL if the iterator was already at the end and there are no more
986 * named metadata nodes.
987 */
989
990/**
991 * Decrement a NamedMDNode iterator to the previous NamedMDNode.
992 *
993 * Returns NULL if the iterator was already at the beginning and there are
994 * no previous named metadata nodes.
995 */
997
998/**
999 * Retrieve a NamedMDNode with the given name, returning NULL if no such
1000 * node exists.
1001 *
1002 * @see llvm::Module::getNamedMetadata()
1003 */
1005 const char *Name, size_t NameLen);
1006
1007/**
1008 * Retrieve a NamedMDNode with the given name, creating a new node if no such
1009 * node exists.
1010 *
1011 * @see llvm::Module::getOrInsertNamedMetadata()
1012 */
1014 const char *Name,
1015 size_t NameLen);
1016
1017/**
1018 * Retrieve the name of a NamedMDNode.
1019 *
1020 * @see llvm::NamedMDNode::getName()
1021 */
1023 size_t *NameLen);
1024
1025/**
1026 * Obtain the number of operands for named metadata in a module.
1027 *
1028 * @see llvm::Module::getNamedMetadata()
1029 */
1030unsigned LLVMGetNamedMetadataNumOperands(LLVMModuleRef M, const char *Name);
1031
1032/**
1033 * Obtain the named metadata operands for a module.
1034 *
1035 * The passed LLVMValueRef pointer should refer to an array of
1036 * LLVMValueRef at least LLVMGetNamedMetadataNumOperands long. This
1037 * array will be populated with the LLVMValueRef instances. Each
1038 * instance corresponds to a llvm::MDNode.
1039 *
1040 * @see llvm::Module::getNamedMetadata()
1041 * @see llvm::MDNode::getOperand()
1042 */
1044 LLVMValueRef *Dest);
1045
1046/**
1047 * Add an operand to named metadata.
1048 *
1049 * @see llvm::Module::getNamedMetadata()
1050 * @see llvm::MDNode::addOperand()
1051 */
1053 LLVMValueRef Val);
1054
1055/**
1056 * Return the directory of the debug location for this value, which must be
1057 * an llvm::Instruction, llvm::GlobalVariable, or llvm::Function.
1058 *
1059 * @see llvm::Instruction::getDebugLoc()
1060 * @see llvm::GlobalVariable::getDebugInfo()
1061 * @see llvm::Function::getSubprogram()
1062 */
1063const char *LLVMGetDebugLocDirectory(LLVMValueRef Val, unsigned *Length);
1064
1065/**
1066 * Return the filename of the debug location for this value, which must be
1067 * an llvm::Instruction, llvm::GlobalVariable, or llvm::Function.
1068 *
1069 * @see llvm::Instruction::getDebugLoc()
1070 * @see llvm::GlobalVariable::getDebugInfo()
1071 * @see llvm::Function::getSubprogram()
1072 */
1073const char *LLVMGetDebugLocFilename(LLVMValueRef Val, unsigned *Length);
1074
1075/**
1076 * Return the line number of the debug location for this value, which must be
1077 * an llvm::Instruction, llvm::GlobalVariable, or llvm::Function.
1078 *
1079 * @see llvm::Instruction::getDebugLoc()
1080 * @see llvm::GlobalVariable::getDebugInfo()
1081 * @see llvm::Function::getSubprogram()
1082 */
1083unsigned LLVMGetDebugLocLine(LLVMValueRef Val);
1084
1085/**
1086 * Return the column number of the debug location for this value, which must be
1087 * an llvm::Instruction.
1088 *
1089 * @see llvm::Instruction::getDebugLoc()
1090 */
1092
1093/**
1094 * Add a function to a module under a specified name.
1095 *
1096 * @see llvm::Function::Create()
1097 */
1099 LLVMTypeRef FunctionTy);
1100
1101/**
1102 * Obtain a Function value from a Module by its name.
1103 *
1104 * The returned value corresponds to a llvm::Function value.
1105 *
1106 * @see llvm::Module::getFunction()
1107 */
1109
1110/**
1111 * Obtain an iterator to the first Function in a Module.
1112 *
1113 * @see llvm::Module::begin()
1114 */
1116
1117/**
1118 * Obtain an iterator to the last Function in a Module.
1119 *
1120 * @see llvm::Module::end()
1121 */
1123
1124/**
1125 * Advance a Function iterator to the next Function.
1126 *
1127 * Returns NULL if the iterator was already at the end and there are no more
1128 * functions.
1129 */
1131
1132/**
1133 * Decrement a Function iterator to the previous Function.
1134 *
1135 * Returns NULL if the iterator was already at the beginning and there are
1136 * no previous functions.
1137 */
1139
1140/** Deprecated: Use LLVMSetModuleInlineAsm2 instead. */
1141void LLVMSetModuleInlineAsm(LLVMModuleRef M, const char *Asm);
1142
1143/**
1144 * @}
1145 */
1146
1147/**
1148 * @defgroup LLVMCCoreType Types
1149 *
1150 * Types represent the type of a value.
1151 *
1152 * Types are associated with a context instance. The context internally
1153 * deduplicates types so there is only 1 instance of a specific type
1154 * alive at a time. In other words, a unique type is shared among all
1155 * consumers within a context.
1156 *
1157 * A Type in the C API corresponds to llvm::Type.
1158 *
1159 * Types have the following hierarchy:
1160 *
1161 * types:
1162 * integer type
1163 * real type
1164 * function type
1165 * sequence types:
1166 * array type
1167 * pointer type
1168 * vector type
1169 * void type
1170 * label type
1171 * opaque type
1172 *
1173 * @{
1174 */
1175
1176/**
1177 * Obtain the enumerated type of a Type instance.
1178 *
1179 * @see llvm::Type:getTypeID()
1180 */
1182
1183/**
1184 * Whether the type has a known size.
1185 *
1186 * Things that don't have a size are abstract types, labels, and void.a
1187 *
1188 * @see llvm::Type::isSized()
1189 */
1191
1192/**
1193 * Obtain the context to which this type instance is associated.
1194 *
1195 * @see llvm::Type::getContext()
1196 */
1198
1199/**
1200 * Dump a representation of a type to stderr.
1201 *
1202 * @see llvm::Type::dump()
1203 */
1204void LLVMDumpType(LLVMTypeRef Val);
1205
1206/**
1207 * Return a string representation of the type. Use
1208 * LLVMDisposeMessage to free the string.
1209 *
1210 * @see llvm::Type::print()
1211 */
1213
1214/**
1215 * @defgroup LLVMCCoreTypeInt Integer Types
1216 *
1217 * Functions in this section operate on integer types.
1218 *
1219 * @{
1220 */
1221
1222/**
1223 * Obtain an integer type from a context with specified bit width.
1224 */
1232
1233/**
1234 * Obtain an integer type from the global context with a specified bit
1235 * width.
1236 */
1243LLVMTypeRef LLVMIntType(unsigned NumBits);
1244unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy);
1245
1246/**
1247 * @}
1248 */
1249
1250/**
1251 * @defgroup LLVMCCoreTypeFloat Floating Point Types
1252 *
1253 * @{
1254 */
1255
1256/**
1257 * Obtain a 16-bit floating point type from a context.
1258 */
1260
1261/**
1262 * Obtain a 16-bit brain floating point type from a context.
1263 */
1265
1266/**
1267 * Obtain a 32-bit floating point type from a context.
1268 */
1270
1271/**
1272 * Obtain a 64-bit floating point type from a context.
1273 */
1275
1276/**
1277 * Obtain a 80-bit floating point type (X87) from a context.
1278 */
1280
1281/**
1282 * Obtain a 128-bit floating point type (112-bit mantissa) from a
1283 * context.
1284 */
1286
1287/**
1288 * Obtain a 128-bit floating point type (two 64-bits) from a context.
1289 */
1291
1292/**
1293 * Obtain a floating point type from the global context.
1294 *
1295 * These map to the functions in this group of the same name.
1296 */
1304
1305/**
1306 * @}
1307 */
1308
1309/**
1310 * @defgroup LLVMCCoreTypeFunction Function Types
1311 *
1312 * @{
1313 */
1314
1315/**
1316 * Obtain a function type consisting of a specified signature.
1317 *
1318 * The function is defined as a tuple of a return Type, a list of
1319 * parameter types, and whether the function is variadic.
1320 */
1322 LLVMTypeRef *ParamTypes, unsigned ParamCount,
1323 LLVMBool IsVarArg);
1324
1325/**
1326 * Returns whether a function type is variadic.
1327 */
1329
1330/**
1331 * Obtain the Type this function Type returns.
1332 */
1334
1335/**
1336 * Obtain the number of parameters this function accepts.
1337 */
1338unsigned LLVMCountParamTypes(LLVMTypeRef FunctionTy);
1339
1340/**
1341 * Obtain the types of a function's parameters.
1342 *
1343 * The Dest parameter should point to a pre-allocated array of
1344 * LLVMTypeRef at least LLVMCountParamTypes() large. On return, the
1345 * first LLVMCountParamTypes() entries in the array will be populated
1346 * with LLVMTypeRef instances.
1347 *
1348 * @param FunctionTy The function type to operate on.
1349 * @param Dest Memory address of an array to be filled with result.
1350 */
1351void LLVMGetParamTypes(LLVMTypeRef FunctionTy, LLVMTypeRef *Dest);
1352
1353/**
1354 * @}
1355 */
1356
1357/**
1358 * @defgroup LLVMCCoreTypeStruct Structure Types
1359 *
1360 * These functions relate to LLVMTypeRef instances.
1361 *
1362 * @see llvm::StructType
1363 *
1364 * @{
1365 */
1366
1367/**
1368 * Create a new structure type in a context.
1369 *
1370 * A structure is specified by a list of inner elements/types and
1371 * whether these can be packed together.
1372 *
1373 * @see llvm::StructType::create()
1374 */
1376 unsigned ElementCount, LLVMBool Packed);
1377
1378/**
1379 * Create a new structure type in the global context.
1380 *
1381 * @see llvm::StructType::create()
1382 */
1383LLVMTypeRef LLVMStructType(LLVMTypeRef *ElementTypes, unsigned ElementCount,
1384 LLVMBool Packed);
1385
1386/**
1387 * Create an empty structure in a context having a specified name.
1388 *
1389 * @see llvm::StructType::create()
1390 */
1392
1393/**
1394 * Obtain the name of a structure.
1395 *
1396 * @see llvm::StructType::getName()
1397 */
1398const char *LLVMGetStructName(LLVMTypeRef Ty);
1399
1400/**
1401 * Set the contents of a structure type.
1402 *
1403 * @see llvm::StructType::setBody()
1404 */
1405void LLVMStructSetBody(LLVMTypeRef StructTy, LLVMTypeRef *ElementTypes,
1406 unsigned ElementCount, LLVMBool Packed);
1407
1408/**
1409 * Get the number of elements defined inside the structure.
1410 *
1411 * @see llvm::StructType::getNumElements()
1412 */
1413unsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy);
1414
1415/**
1416 * Get the elements within a structure.
1417 *
1418 * The function is passed the address of a pre-allocated array of
1419 * LLVMTypeRef at least LLVMCountStructElementTypes() long. After
1420 * invocation, this array will be populated with the structure's
1421 * elements. The objects in the destination array will have a lifetime
1422 * of the structure type itself, which is the lifetime of the context it
1423 * is contained in.
1424 */
1426
1427/**
1428 * Get the type of the element at a given index in the structure.
1429 *
1430 * @see llvm::StructType::getTypeAtIndex()
1431 */
1433
1434/**
1435 * Determine whether a structure is packed.
1436 *
1437 * @see llvm::StructType::isPacked()
1438 */
1440
1441/**
1442 * Determine whether a structure is opaque.
1443 *
1444 * @see llvm::StructType::isOpaque()
1445 */
1447
1448/**
1449 * Determine whether a structure is literal.
1450 *
1451 * @see llvm::StructType::isLiteral()
1452 */
1454
1455/**
1456 * @}
1457 */
1458
1459/**
1460 * @defgroup LLVMCCoreTypeSequential Sequential Types
1461 *
1462 * Sequential types represents "arrays" of types. This is a super class
1463 * for array, vector, and pointer types.
1464 *
1465 * @{
1466 */
1467
1468/**
1469 * Obtain the element type of an array or vector type.
1470 *
1471 * @see llvm::SequentialType::getElementType()
1472 */
1474
1475/**
1476 * Returns type's subtypes
1477 *
1478 * @see llvm::Type::subtypes()
1479 */
1481
1482/**
1483 * Return the number of types in the derived type.
1484 *
1485 * @see llvm::Type::getNumContainedTypes()
1486 */
1488
1489/**
1490 * Create a fixed size array type that refers to a specific type.
1491 *
1492 * The created type will exist in the context that its element type
1493 * exists in.
1494 *
1495 * @deprecated LLVMArrayType is deprecated in favor of the API accurate
1496 * LLVMArrayType2
1497 * @see llvm::ArrayType::get()
1498 */
1499LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount);
1500
1501/**
1502 * Create a fixed size array type that refers to a specific type.
1503 *
1504 * The created type will exist in the context that its element type
1505 * exists in.
1506 *
1507 * @see llvm::ArrayType::get()
1508 */
1509LLVMTypeRef LLVMArrayType2(LLVMTypeRef ElementType, uint64_t ElementCount);
1510
1511/**
1512 * Obtain the length of an array type.
1513 *
1514 * This only works on types that represent arrays.
1515 *
1516 * @deprecated LLVMGetArrayLength is deprecated in favor of the API accurate
1517 * LLVMGetArrayLength2
1518 * @see llvm::ArrayType::getNumElements()
1519 */
1520unsigned LLVMGetArrayLength(LLVMTypeRef ArrayTy);
1521
1522/**
1523 * Obtain the length of an array type.
1524 *
1525 * This only works on types that represent arrays.
1526 *
1527 * @see llvm::ArrayType::getNumElements()
1528 */
1530
1531/**
1532 * Create a pointer type that points to a defined type.
1533 *
1534 * The created type will exist in the context that its pointee type
1535 * exists in.
1536 *
1537 * @see llvm::PointerType::get()
1538 */
1539LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, unsigned AddressSpace);
1540
1541/**
1542 * Determine whether a pointer is opaque.
1543 *
1544 * True if this is an instance of an opaque PointerType.
1545 *
1546 * @see llvm::Type::isOpaquePointerTy()
1547 */
1549
1550/**
1551 * Create an opaque pointer type in a context.
1552 *
1553 * @see llvm::PointerType::get()
1554 */
1556
1557/**
1558 * Obtain the address space of a pointer type.
1559 *
1560 * This only works on types that represent pointers.
1561 *
1562 * @see llvm::PointerType::getAddressSpace()
1563 */
1564unsigned LLVMGetPointerAddressSpace(LLVMTypeRef PointerTy);
1565
1566/**
1567 * Create a vector type that contains a defined type and has a specific
1568 * number of elements.
1569 *
1570 * The created type will exist in the context thats its element type
1571 * exists in.
1572 *
1573 * @see llvm::VectorType::get()
1574 */
1575LLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType, unsigned ElementCount);
1576
1577/**
1578 * Create a vector type that contains a defined type and has a scalable
1579 * number of elements.
1580 *
1581 * The created type will exist in the context thats its element type
1582 * exists in.
1583 *
1584 * @see llvm::ScalableVectorType::get()
1585 */
1587 unsigned ElementCount);
1588
1589/**
1590 * Obtain the (possibly scalable) number of elements in a vector type.
1591 *
1592 * This only works on types that represent vectors (fixed or scalable).
1593 *
1594 * @see llvm::VectorType::getNumElements()
1595 */
1596unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy);
1597
1598/**
1599 * @}
1600 */
1601
1602/**
1603 * @defgroup LLVMCCoreTypeOther Other Types
1604 *
1605 * @{
1606 */
1607
1608/**
1609 * Create a void type in a context.
1610 */
1612
1613/**
1614 * Create a label type in a context.
1615 */
1617
1618/**
1619 * Create a X86 MMX type in a context.
1620 */
1622
1623/**
1624 * Create a X86 AMX type in a context.
1625 */
1627
1628/**
1629 * Create a token type in a context.
1630 */
1632
1633/**
1634 * Create a metadata type in a context.
1635 */
1637
1638/**
1639 * These are similar to the above functions except they operate on the
1640 * global context.
1641 */
1646
1647/**
1648 * Create a target extension type in LLVM context.
1649 */
1651 LLVMTypeRef *TypeParams,
1652 unsigned TypeParamCount,
1653 unsigned *IntParams,
1654 unsigned IntParamCount);
1655
1656/**
1657 * @}
1658 */
1659
1660/**
1661 * @}
1662 */
1663
1664/**
1665 * @defgroup LLVMCCoreValues Values
1666 *
1667 * The bulk of LLVM's object model consists of values, which comprise a very
1668 * rich type hierarchy.
1669 *
1670 * LLVMValueRef essentially represents llvm::Value. There is a rich
1671 * hierarchy of classes within this type. Depending on the instance
1672 * obtained, not all APIs are available.
1673 *
1674 * Callers can determine the type of an LLVMValueRef by calling the
1675 * LLVMIsA* family of functions (e.g. LLVMIsAArgument()). These
1676 * functions are defined by a macro, so it isn't obvious which are
1677 * available by looking at the Doxygen source code. Instead, look at the
1678 * source definition of LLVM_FOR_EACH_VALUE_SUBCLASS and note the list
1679 * of value names given. These value names also correspond to classes in
1680 * the llvm::Value hierarchy.
1681 *
1682 * @{
1683 */
1684
1685#define LLVM_FOR_EACH_VALUE_SUBCLASS(macro) \
1686 macro(Argument) \
1687 macro(BasicBlock) \
1688 macro(InlineAsm) \
1689 macro(User) \
1690 macro(Constant) \
1691 macro(BlockAddress) \
1692 macro(ConstantAggregateZero) \
1693 macro(ConstantArray) \
1694 macro(ConstantDataSequential) \
1695 macro(ConstantDataArray) \
1696 macro(ConstantDataVector) \
1697 macro(ConstantExpr) \
1698 macro(ConstantFP) \
1699 macro(ConstantInt) \
1700 macro(ConstantPointerNull) \
1701 macro(ConstantStruct) \
1702 macro(ConstantTokenNone) \
1703 macro(ConstantVector) \
1704 macro(GlobalValue) \
1705 macro(GlobalAlias) \
1706 macro(GlobalObject) \
1707 macro(Function) \
1708 macro(GlobalVariable) \
1709 macro(GlobalIFunc) \
1710 macro(UndefValue) \
1711 macro(PoisonValue) \
1712 macro(Instruction) \
1713 macro(UnaryOperator) \
1714 macro(BinaryOperator) \
1715 macro(CallInst) \
1716 macro(IntrinsicInst) \
1717 macro(DbgInfoIntrinsic) \
1718 macro(DbgVariableIntrinsic) \
1719 macro(DbgDeclareInst) \
1720 macro(DbgLabelInst) \
1721 macro(MemIntrinsic) \
1722 macro(MemCpyInst) \
1723 macro(MemMoveInst) \
1724 macro(MemSetInst) \
1725 macro(CmpInst) \
1726 macro(FCmpInst) \
1727 macro(ICmpInst) \
1728 macro(ExtractElementInst) \
1729 macro(GetElementPtrInst) \
1730 macro(InsertElementInst) \
1731 macro(InsertValueInst) \
1732 macro(LandingPadInst) \
1733 macro(PHINode) \
1734 macro(SelectInst) \
1735 macro(ShuffleVectorInst) \
1736 macro(StoreInst) \
1737 macro(BranchInst) \
1738 macro(IndirectBrInst) \
1739 macro(InvokeInst) \
1740 macro(ReturnInst) \
1741 macro(SwitchInst) \
1742 macro(UnreachableInst) \
1743 macro(ResumeInst) \
1744 macro(CleanupReturnInst) \
1745 macro(CatchReturnInst) \
1746 macro(CatchSwitchInst) \
1747 macro(CallBrInst) \
1748 macro(FuncletPadInst) \
1749 macro(CatchPadInst) \
1750 macro(CleanupPadInst) \
1751 macro(UnaryInstruction) \
1752 macro(AllocaInst) \
1753 macro(CastInst) \
1754 macro(AddrSpaceCastInst) \
1755 macro(BitCastInst) \
1756 macro(FPExtInst) \
1757 macro(FPToSIInst) \
1758 macro(FPToUIInst) \
1759 macro(FPTruncInst) \
1760 macro(IntToPtrInst) \
1761 macro(PtrToIntInst) \
1762 macro(SExtInst) \
1763 macro(SIToFPInst) \
1764 macro(TruncInst) \
1765 macro(UIToFPInst) \
1766 macro(ZExtInst) \
1767 macro(ExtractValueInst) \
1768 macro(LoadInst) \
1769 macro(VAArgInst) \
1770 macro(FreezeInst) \
1771 macro(AtomicCmpXchgInst) \
1772 macro(AtomicRMWInst) \
1773 macro(FenceInst)
1774
1775/**
1776 * @defgroup LLVMCCoreValueGeneral General APIs
1777 *
1778 * Functions in this section work on all LLVMValueRef instances,
1779 * regardless of their sub-type. They correspond to functions available
1780 * on llvm::Value.
1781 *
1782 * @{
1783 */
1784
1785/**
1786 * Obtain the type of a value.
1787 *
1788 * @see llvm::Value::getType()
1789 */
1791
1792/**
1793 * Obtain the enumerated type of a Value instance.
1794 *
1795 * @see llvm::Value::getValueID()
1796 */
1798
1799/**
1800 * Obtain the string name of a value.
1801 *
1802 * @see llvm::Value::getName()
1803 */
1804const char *LLVMGetValueName2(LLVMValueRef Val, size_t *Length);
1805
1806/**
1807 * Set the string name of a value.
1808 *
1809 * @see llvm::Value::setName()
1810 */
1811void LLVMSetValueName2(LLVMValueRef Val, const char *Name, size_t NameLen);
1812
1813/**
1814 * Dump a representation of a value to stderr.
1815 *
1816 * @see llvm::Value::dump()
1817 */
1818void LLVMDumpValue(LLVMValueRef Val);
1819
1820/**
1821 * Return a string representation of the value. Use
1822 * LLVMDisposeMessage to free the string.
1823 *
1824 * @see llvm::Value::print()
1825 */
1827
1828/**
1829 * Replace all uses of a value with another one.
1830 *
1831 * @see llvm::Value::replaceAllUsesWith()
1832 */
1834
1835/**
1836 * Determine whether the specified value instance is constant.
1837 */
1839
1840/**
1841 * Determine whether a value instance is undefined.
1842 */
1844
1845/**
1846 * Determine whether a value instance is poisonous.
1847 */
1849
1850/**
1851 * Convert value instances between types.
1852 *
1853 * Internally, an LLVMValueRef is "pinned" to a specific type. This
1854 * series of functions allows you to cast an instance to a specific
1855 * type.
1856 *
1857 * If the cast is not valid for the specified type, NULL is returned.
1858 *
1859 * @see llvm::dyn_cast_or_null<>
1860 */
1861#define LLVM_DECLARE_VALUE_CAST(name) \
1862 LLVMValueRef LLVMIsA##name(LLVMValueRef Val);
1864
1868
1869/** Deprecated: Use LLVMGetValueName2 instead. */
1870const char *LLVMGetValueName(LLVMValueRef Val);
1871/** Deprecated: Use LLVMSetValueName2 instead. */
1872void LLVMSetValueName(LLVMValueRef Val, const char *Name);
1873
1874/**
1875 * @}
1876 */
1877
1878/**
1879 * @defgroup LLVMCCoreValueUses Usage
1880 *
1881 * This module defines functions that allow you to inspect the uses of a
1882 * LLVMValueRef.
1883 *
1884 * It is possible to obtain an LLVMUseRef for any LLVMValueRef instance.
1885 * Each LLVMUseRef (which corresponds to a llvm::Use instance) holds a
1886 * llvm::User and llvm::Value.
1887 *
1888 * @{
1889 */
1890
1891/**
1892 * Obtain the first use of a value.
1893 *
1894 * Uses are obtained in an iterator fashion. First, call this function
1895 * to obtain a reference to the first use. Then, call LLVMGetNextUse()
1896 * on that instance and all subsequently obtained instances until
1897 * LLVMGetNextUse() returns NULL.
1898 *
1899 * @see llvm::Value::use_begin()
1900 */
1902
1903/**
1904 * Obtain the next use of a value.
1905 *
1906 * This effectively advances the iterator. It returns NULL if you are on
1907 * the final use and no more are available.
1908 */
1910
1911/**
1912 * Obtain the user value for a user.
1913 *
1914 * The returned value corresponds to a llvm::User type.
1915 *
1916 * @see llvm::Use::getUser()
1917 */
1919
1920/**
1921 * Obtain the value this use corresponds to.
1922 *
1923 * @see llvm::Use::get().
1924 */
1926
1927/**
1928 * @}
1929 */
1930
1931/**
1932 * @defgroup LLVMCCoreValueUser User value
1933 *
1934 * Function in this group pertain to LLVMValueRef instances that descent
1935 * from llvm::User. This includes constants, instructions, and
1936 * operators.
1937 *
1938 * @{
1939 */
1940
1941/**
1942 * Obtain an operand at a specific index in a llvm::User value.
1943 *
1944 * @see llvm::User::getOperand()
1945 */
1947
1948/**
1949 * Obtain the use of an operand at a specific index in a llvm::User value.
1950 *
1951 * @see llvm::User::getOperandUse()
1952 */
1954
1955/**
1956 * Set an operand at a specific index in a llvm::User value.
1957 *
1958 * @see llvm::User::setOperand()
1959 */
1960void LLVMSetOperand(LLVMValueRef User, unsigned Index, LLVMValueRef Val);
1961
1962/**
1963 * Obtain the number of operands in a llvm::User value.
1964 *
1965 * @see llvm::User::getNumOperands()
1966 */
1968
1969/**
1970 * @}
1971 */
1972
1973/**
1974 * @defgroup LLVMCCoreValueConstant Constants
1975 *
1976 * This section contains APIs for interacting with LLVMValueRef that
1977 * correspond to llvm::Constant instances.
1978 *
1979 * These functions will work for any LLVMValueRef in the llvm::Constant
1980 * class hierarchy.
1981 *
1982 * @{
1983 */
1984
1985/**
1986 * Obtain a constant value referring to the null instance of a type.
1987 *
1988 * @see llvm::Constant::getNullValue()
1989 */
1990LLVMValueRef LLVMConstNull(LLVMTypeRef Ty); /* all zeroes */
1991
1992/**
1993 * Obtain a constant value referring to the instance of a type
1994 * consisting of all ones.
1995 *
1996 * This is only valid for integer types.
1997 *
1998 * @see llvm::Constant::getAllOnesValue()
1999 */
2001
2002/**
2003 * Obtain a constant value referring to an undefined value of a type.
2004 *
2005 * @see llvm::UndefValue::get()
2006 */
2008
2009/**
2010 * Obtain a constant value referring to a poison value of a type.
2011 *
2012 * @see llvm::PoisonValue::get()
2013 */
2015
2016/**
2017 * Determine whether a value instance is null.
2018 *
2019 * @see llvm::Constant::isNullValue()
2020 */
2022
2023/**
2024 * Obtain a constant that is a constant pointer pointing to NULL for a
2025 * specified type.
2026 */
2028
2029/**
2030 * @defgroup LLVMCCoreValueConstantScalar Scalar constants
2031 *
2032 * Functions in this group model LLVMValueRef instances that correspond
2033 * to constants referring to scalar types.
2034 *
2035 * For integer types, the LLVMTypeRef parameter should correspond to a
2036 * llvm::IntegerType instance and the returned LLVMValueRef will
2037 * correspond to a llvm::ConstantInt.
2038 *
2039 * For floating point types, the LLVMTypeRef returned corresponds to a
2040 * llvm::ConstantFP.
2041 *
2042 * @{
2043 */
2044
2045/**
2046 * Obtain a constant value for an integer type.
2047 *
2048 * The returned value corresponds to a llvm::ConstantInt.
2049 *
2050 * @see llvm::ConstantInt::get()
2051 *
2052 * @param IntTy Integer type to obtain value of.
2053 * @param N The value the returned instance should refer to.
2054 * @param SignExtend Whether to sign extend the produced value.
2055 */
2056LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N,
2057 LLVMBool SignExtend);
2058
2059/**
2060 * Obtain a constant value for an integer of arbitrary precision.
2061 *
2062 * @see llvm::ConstantInt::get()
2063 */
2065 unsigned NumWords,
2066 const uint64_t Words[]);
2067
2068/**
2069 * Obtain a constant value for an integer parsed from a string.
2070 *
2071 * A similar API, LLVMConstIntOfStringAndSize is also available. If the
2072 * string's length is available, it is preferred to call that function
2073 * instead.
2074 *
2075 * @see llvm::ConstantInt::get()
2076 */
2078 uint8_t Radix);
2079
2080/**
2081 * Obtain a constant value for an integer parsed from a string with
2082 * specified length.
2083 *
2084 * @see llvm::ConstantInt::get()
2085 */
2087 unsigned SLen, uint8_t Radix);
2088
2089/**
2090 * Obtain a constant value referring to a double floating point value.
2091 */
2092LLVMValueRef LLVMConstReal(LLVMTypeRef RealTy, double N);
2093
2094/**
2095 * Obtain a constant for a floating point value parsed from a string.
2096 *
2097 * A similar API, LLVMConstRealOfStringAndSize is also available. It
2098 * should be used if the input string's length is known.
2099 */
2100LLVMValueRef LLVMConstRealOfString(LLVMTypeRef RealTy, const char *Text);
2101
2102/**
2103 * Obtain a constant for a floating point value parsed from a string.
2104 */
2106 unsigned SLen);
2107
2108/**
2109 * Obtain the zero extended value for an integer constant value.
2110 *
2111 * @see llvm::ConstantInt::getZExtValue()
2112 */
2113unsigned long long LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal);
2114
2115/**
2116 * Obtain the sign extended value for an integer constant value.
2117 *
2118 * @see llvm::ConstantInt::getSExtValue()
2119 */
2120long long LLVMConstIntGetSExtValue(LLVMValueRef ConstantVal);
2121
2122/**
2123 * Obtain the double value for an floating point constant value.
2124 * losesInfo indicates if some precision was lost in the conversion.
2125 *
2126 * @see llvm::ConstantFP::getDoubleValue
2127 */
2128double LLVMConstRealGetDouble(LLVMValueRef ConstantVal, LLVMBool *losesInfo);
2129
2130/**
2131 * @}
2132 */
2133
2134/**
2135 * @defgroup LLVMCCoreValueConstantComposite Composite Constants
2136 *
2137 * Functions in this group operate on composite constants.
2138 *
2139 * @{
2140 */
2141
2142/**
2143 * Create a ConstantDataSequential and initialize it with a string.
2144 *
2145 * @see llvm::ConstantDataArray::getString()
2146 */
2148 unsigned Length, LLVMBool DontNullTerminate);
2149
2150/**
2151 * Create a ConstantDataSequential with string content in the global context.
2152 *
2153 * This is the same as LLVMConstStringInContext except it operates on the
2154 * global context.
2155 *
2156 * @see LLVMConstStringInContext()
2157 * @see llvm::ConstantDataArray::getString()
2158 */
2159LLVMValueRef LLVMConstString(const char *Str, unsigned Length,
2160 LLVMBool DontNullTerminate);
2161
2162/**
2163 * Returns true if the specified constant is an array of i8.
2164 *
2165 * @see ConstantDataSequential::getAsString()
2166 */
2168
2169/**
2170 * Get the given constant data sequential as a string.
2171 *
2172 * @see ConstantDataSequential::getAsString()
2173 */
2174const char *LLVMGetAsString(LLVMValueRef c, size_t *Length);
2175
2176/**
2177 * Create an anonymous ConstantStruct with the specified values.
2178 *
2179 * @see llvm::ConstantStruct::getAnon()
2180 */
2182 LLVMValueRef *ConstantVals,
2183 unsigned Count, LLVMBool Packed);
2184
2185/**
2186 * Create a ConstantStruct in the global Context.
2187 *
2188 * This is the same as LLVMConstStructInContext except it operates on the
2189 * global Context.
2190 *
2191 * @see LLVMConstStructInContext()
2192 */
2193LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count,
2194 LLVMBool Packed);
2195
2196/**
2197 * Create a ConstantArray from values.
2198 *
2199 * @deprecated LLVMConstArray is deprecated in favor of the API accurate
2200 * LLVMConstArray2
2201 * @see llvm::ConstantArray::get()
2202 */
2204 LLVMValueRef *ConstantVals, unsigned Length);
2205
2206/**
2207 * Create a ConstantArray from values.
2208 *
2209 * @see llvm::ConstantArray::get()
2210 */
2211LLVMValueRef LLVMConstArray2(LLVMTypeRef ElementTy, LLVMValueRef *ConstantVals,
2212 uint64_t Length);
2213
2214/**
2215 * Create a non-anonymous ConstantStruct from values.
2216 *
2217 * @see llvm::ConstantStruct::get()
2218 */
2220 LLVMValueRef *ConstantVals,
2221 unsigned Count);
2222
2223/**
2224 * Get element of a constant aggregate (struct, array or vector) at the
2225 * specified index. Returns null if the index is out of range, or it's not
2226 * possible to determine the element (e.g., because the constant is a
2227 * constant expression.)
2228 *
2229 * @see llvm::Constant::getAggregateElement()
2230 */
2232
2233/**
2234 * Get an element at specified index as a constant.
2235 *
2236 * @see ConstantDataSequential::getElementAsConstant()
2237 */
2240 "Use LLVMGetAggregateElement instead");
2241
2242/**
2243 * Create a ConstantVector from values.
2244 *
2245 * @see llvm::ConstantVector::get()
2246 */
2247LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size);
2248
2249/**
2250 * @}
2251 */
2252
2253/**
2254 * @defgroup LLVMCCoreValueConstantExpressions Constant Expressions
2255 *
2256 * Functions in this group correspond to APIs on llvm::ConstantExpr.
2257 *
2258 * @see llvm::ConstantExpr.
2259 *
2260 * @{
2261 */
2269LLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2270LLVMValueRef LLVMConstNSWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2271LLVMValueRef LLVMConstNUWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2272LLVMValueRef LLVMConstSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2273LLVMValueRef LLVMConstNSWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2274LLVMValueRef LLVMConstNUWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2275LLVMValueRef LLVMConstMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2276LLVMValueRef LLVMConstNSWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2277LLVMValueRef LLVMConstNUWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2278LLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2280 LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2282 LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2283LLVMValueRef LLVMConstShl(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2285 LLVMValueRef *ConstantIndices, unsigned NumIndices);
2287 LLVMValueRef *ConstantIndices,
2288 unsigned NumIndices);
2295 LLVMTypeRef ToType);
2297 LLVMTypeRef ToType);
2299 LLVMValueRef IndexConstant);
2301 LLVMValueRef ElementValueConstant,
2302 LLVMValueRef IndexConstant);
2304 LLVMValueRef VectorBConstant,
2305 LLVMValueRef MaskConstant);
2307
2308/** Deprecated: Use LLVMGetInlineAsm instead. */
2310 const char *AsmString, const char *Constraints,
2311 LLVMBool HasSideEffects, LLVMBool IsAlignStack);
2312
2313/**
2314 * @}
2315 */
2316
2317/**
2318 * @defgroup LLVMCCoreValueConstantGlobals Global Values
2319 *
2320 * This group contains functions that operate on global values. Functions in
2321 * this group relate to functions in the llvm::GlobalValue class tree.
2322 *
2323 * @see llvm::GlobalValue
2324 *
2325 * @{
2326 */
2327
2331void LLVMSetLinkage(LLVMValueRef Global, LLVMLinkage Linkage);
2332const char *LLVMGetSection(LLVMValueRef Global);
2333void LLVMSetSection(LLVMValueRef Global, const char *Section);
2339void LLVMSetUnnamedAddress(LLVMValueRef Global, LLVMUnnamedAddr UnnamedAddr);
2340
2341/**
2342 * Returns the "value type" of a global value. This differs from the formal
2343 * type of a global value which is always a pointer type.
2344 *
2345 * @see llvm::GlobalValue::getValueType()
2346 */
2348
2349/** Deprecated: Use LLVMGetUnnamedAddress instead. */
2351/** Deprecated: Use LLVMSetUnnamedAddress instead. */
2352void LLVMSetUnnamedAddr(LLVMValueRef Global, LLVMBool HasUnnamedAddr);
2353
2354/**
2355 * @defgroup LLVMCCoreValueWithAlignment Values with alignment
2356 *
2357 * Functions in this group only apply to values with alignment, i.e.
2358 * global variables, load and store instructions.
2359 */
2360
2361/**
2362 * Obtain the preferred alignment of the value.
2363 * @see llvm::AllocaInst::getAlignment()
2364 * @see llvm::LoadInst::getAlignment()
2365 * @see llvm::StoreInst::getAlignment()
2366 * @see llvm::AtomicRMWInst::setAlignment()
2367 * @see llvm::AtomicCmpXchgInst::setAlignment()
2368 * @see llvm::GlobalValue::getAlignment()
2369 */
2370unsigned LLVMGetAlignment(LLVMValueRef V);
2371
2372/**
2373 * Set the preferred alignment of the value.
2374 * @see llvm::AllocaInst::setAlignment()
2375 * @see llvm::LoadInst::setAlignment()
2376 * @see llvm::StoreInst::setAlignment()
2377 * @see llvm::AtomicRMWInst::setAlignment()
2378 * @see llvm::AtomicCmpXchgInst::setAlignment()
2379 * @see llvm::GlobalValue::setAlignment()
2380 */
2381void LLVMSetAlignment(LLVMValueRef V, unsigned Bytes);
2382
2383/**
2384 * Sets a metadata attachment, erasing the existing metadata attachment if
2385 * it already exists for the given kind.
2386 *
2387 * @see llvm::GlobalObject::setMetadata()
2388 */
2389void LLVMGlobalSetMetadata(LLVMValueRef Global, unsigned Kind,
2390 LLVMMetadataRef MD);
2391
2392/**
2393 * Erases a metadata attachment of the given kind if it exists.
2394 *
2395 * @see llvm::GlobalObject::eraseMetadata()
2396 */
2397void LLVMGlobalEraseMetadata(LLVMValueRef Global, unsigned Kind);
2398
2399/**
2400 * Removes all metadata attachments from this value.
2401 *
2402 * @see llvm::GlobalObject::clearMetadata()
2403 */
2405
2406/**
2407 * Retrieves an array of metadata entries representing the metadata attached to
2408 * this value. The caller is responsible for freeing this array by calling
2409 * \c LLVMDisposeValueMetadataEntries.
2410 *
2411 * @see llvm::GlobalObject::getAllMetadata()
2412 */
2414 size_t *NumEntries);
2415
2416/**
2417 * Destroys value metadata entries.
2418 */
2420
2421/**
2422 * Returns the kind of a value metadata entry at a specific index.
2423 */
2425 unsigned Index);
2426
2427/**
2428 * Returns the underlying metadata node of a value metadata entry at a
2429 * specific index.
2430 */
2433 unsigned Index);
2434
2435/**
2436 * @}
2437 */
2438
2439/**
2440 * @defgroup LLVMCoreValueConstantGlobalVariable Global Variables
2441 *
2442 * This group contains functions that operate on global variable values.
2443 *
2444 * @see llvm::GlobalVariable
2445 *
2446 * @{
2447 */
2450 const char *Name,
2451 unsigned AddressSpace);
2457void LLVMDeleteGlobal(LLVMValueRef GlobalVar);
2459void LLVMSetInitializer(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal);
2461void LLVMSetThreadLocal(LLVMValueRef GlobalVar, LLVMBool IsThreadLocal);
2463void LLVMSetGlobalConstant(LLVMValueRef GlobalVar, LLVMBool IsConstant);
2467void LLVMSetExternallyInitialized(LLVMValueRef GlobalVar, LLVMBool IsExtInit);
2468
2469/**
2470 * @}
2471 */
2472
2473/**
2474 * @defgroup LLVMCoreValueConstantGlobalAlias Global Aliases
2475 *
2476 * This group contains function that operate on global alias values.
2477 *
2478 * @see llvm::GlobalAlias
2479 *
2480 * @{
2481 */
2482
2483/**
2484 * Add a GlobalAlias with the given value type, address space and aliasee.
2485 *
2486 * @see llvm::GlobalAlias::create()
2487 */
2489 unsigned AddrSpace, LLVMValueRef Aliasee,
2490 const char *Name);
2491
2492/**
2493 * Obtain a GlobalAlias value from a Module by its name.
2494 *
2495 * The returned value corresponds to a llvm::GlobalAlias value.
2496 *
2497 * @see llvm::Module::getNamedAlias()
2498 */
2500 const char *Name, size_t NameLen);
2501
2502/**
2503 * Obtain an iterator to the first GlobalAlias in a Module.
2504 *
2505 * @see llvm::Module::alias_begin()
2506 */
2508
2509/**
2510 * Obtain an iterator to the last GlobalAlias in a Module.
2511 *
2512 * @see llvm::Module::alias_end()
2513 */
2515
2516/**
2517 * Advance a GlobalAlias iterator to the next GlobalAlias.
2518 *
2519 * Returns NULL if the iterator was already at the end and there are no more
2520 * global aliases.
2521 */
2523
2524/**
2525 * Decrement a GlobalAlias iterator to the previous GlobalAlias.
2526 *
2527 * Returns NULL if the iterator was already at the beginning and there are
2528 * no previous global aliases.
2529 */
2531
2532/**
2533 * Retrieve the target value of an alias.
2534 */
2536
2537/**
2538 * Set the target value of an alias.
2539 */
2540void LLVMAliasSetAliasee(LLVMValueRef Alias, LLVMValueRef Aliasee);
2541
2542/**
2543 * @}
2544 */
2545
2546/**
2547 * @defgroup LLVMCCoreValueFunction Function values
2548 *
2549 * Functions in this group operate on LLVMValueRef instances that
2550 * correspond to llvm::Function instances.
2551 *
2552 * @see llvm::Function
2553 *
2554 * @{
2555 */
2556
2557/**
2558 * Remove a function from its containing module and deletes it.
2559 *
2560 * @see llvm::Function::eraseFromParent()
2561 */
2563
2564/**
2565 * Check whether the given function has a personality function.
2566 *
2567 * @see llvm::Function::hasPersonalityFn()
2568 */
2570
2571/**
2572 * Obtain the personality function attached to the function.
2573 *
2574 * @see llvm::Function::getPersonalityFn()
2575 */
2577
2578/**
2579 * Set the personality function attached to the function.
2580 *
2581 * @see llvm::Function::setPersonalityFn()
2582 */
2583void LLVMSetPersonalityFn(LLVMValueRef Fn, LLVMValueRef PersonalityFn);
2584
2585/**
2586 * Obtain the intrinsic ID number which matches the given function name.
2587 *
2588 * @see llvm::Function::lookupIntrinsicID()
2589 */
2590unsigned LLVMLookupIntrinsicID(const char *Name, size_t NameLen);
2591
2592/**
2593 * Obtain the ID number from a function instance.
2594 *
2595 * @see llvm::Function::getIntrinsicID()
2596 */
2597unsigned LLVMGetIntrinsicID(LLVMValueRef Fn);
2598
2599/**
2600 * Create or insert the declaration of an intrinsic. For overloaded intrinsics,
2601 * parameter types must be provided to uniquely identify an overload.
2602 *
2603 * @see llvm::Intrinsic::getDeclaration()
2604 */
2606 unsigned ID,
2607 LLVMTypeRef *ParamTypes,
2608 size_t ParamCount);
2609
2610/**
2611 * Retrieves the type of an intrinsic. For overloaded intrinsics, parameter
2612 * types must be provided to uniquely identify an overload.
2613 *
2614 * @see llvm::Intrinsic::getType()
2615 */
2617 LLVMTypeRef *ParamTypes, size_t ParamCount);
2618
2619/**
2620 * Retrieves the name of an intrinsic.
2621 *
2622 * @see llvm::Intrinsic::getName()
2623 */
2624const char *LLVMIntrinsicGetName(unsigned ID, size_t *NameLength);
2625
2626/** Deprecated: Use LLVMIntrinsicCopyOverloadedName2 instead. */
2627const char *LLVMIntrinsicCopyOverloadedName(unsigned ID,
2628 LLVMTypeRef *ParamTypes,
2629 size_t ParamCount,
2630 size_t *NameLength);
2631
2632/**
2633 * Copies the name of an overloaded intrinsic identified by a given list of
2634 * parameter types.
2635 *
2636 * Unlike LLVMIntrinsicGetName, the caller is responsible for freeing the
2637 * returned string.
2638 *
2639 * This version also supports unnamed types.
2640 *
2641 * @see llvm::Intrinsic::getName()
2642 */
2643const char *LLVMIntrinsicCopyOverloadedName2(LLVMModuleRef Mod, unsigned ID,
2644 LLVMTypeRef *ParamTypes,
2645 size_t ParamCount,
2646 size_t *NameLength);
2647
2648/**
2649 * Obtain if the intrinsic identified by the given ID is overloaded.
2650 *
2651 * @see llvm::Intrinsic::isOverloaded()
2652 */
2654
2655/**
2656 * Obtain the calling function of a function.
2657 *
2658 * The returned value corresponds to the LLVMCallConv enumeration.
2659 *
2660 * @see llvm::Function::getCallingConv()
2661 */
2663
2664/**
2665 * Set the calling convention of a function.
2666 *
2667 * @see llvm::Function::setCallingConv()
2668 *
2669 * @param Fn Function to operate on
2670 * @param CC LLVMCallConv to set calling convention to
2671 */
2672void LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC);
2673
2674/**
2675 * Obtain the name of the garbage collector to use during code
2676 * generation.
2677 *
2678 * @see llvm::Function::getGC()
2679 */
2680const char *LLVMGetGC(LLVMValueRef Fn);
2681
2682/**
2683 * Define the garbage collector to use during code generation.
2684 *
2685 * @see llvm::Function::setGC()
2686 */
2687void LLVMSetGC(LLVMValueRef Fn, const char *Name);
2688
2689/**
2690 * Add an attribute to a function.
2691 *
2692 * @see llvm::Function::addAttribute()
2693 */
2698 LLVMAttributeRef *Attrs);
2701 unsigned KindID);
2704 const char *K, unsigned KLen);
2706 unsigned KindID);
2708 const char *K, unsigned KLen);
2709
2710/**
2711 * Add a target-dependent attribute to a function
2712 * @see llvm::AttrBuilder::addAttribute()
2713 */
2715 const char *V);
2716
2717/**
2718 * @defgroup LLVMCCoreValueFunctionParameters Function Parameters
2719 *
2720 * Functions in this group relate to arguments/parameters on functions.
2721 *
2722 * Functions in this group expect LLVMValueRef instances that correspond
2723 * to llvm::Function instances.
2724 *
2725 * @{
2726 */
2727
2728/**
2729 * Obtain the number of parameters in a function.
2730 *
2731 * @see llvm::Function::arg_size()
2732 */
2733unsigned LLVMCountParams(LLVMValueRef Fn);
2734
2735/**
2736 * Obtain the parameters in a function.
2737 *
2738 * The takes a pointer to a pre-allocated array of LLVMValueRef that is
2739 * at least LLVMCountParams() long. This array will be filled with
2740 * LLVMValueRef instances which correspond to the parameters the
2741 * function receives. Each LLVMValueRef corresponds to a llvm::Argument
2742 * instance.
2743 *
2744 * @see llvm::Function::arg_begin()
2745 */
2746void LLVMGetParams(LLVMValueRef Fn, LLVMValueRef *Params);
2747
2748/**
2749 * Obtain the parameter at the specified index.
2750 *
2751 * Parameters are indexed from 0.
2752 *
2753 * @see llvm::Function::arg_begin()
2754 */
2756
2757/**
2758 * Obtain the function to which this argument belongs.
2759 *
2760 * Unlike other functions in this group, this one takes an LLVMValueRef
2761 * that corresponds to a llvm::Attribute.
2762 *
2763 * The returned LLVMValueRef is the llvm::Function to which this
2764 * argument belongs.
2765 */
2767
2768/**
2769 * Obtain the first parameter to a function.
2770 *
2771 * @see llvm::Function::arg_begin()
2772 */
2774
2775/**
2776 * Obtain the last parameter to a function.
2777 *
2778 * @see llvm::Function::arg_end()
2779 */
2781
2782/**
2783 * Obtain the next parameter to a function.
2784 *
2785 * This takes an LLVMValueRef obtained from LLVMGetFirstParam() (which is
2786 * actually a wrapped iterator) and obtains the next parameter from the
2787 * underlying iterator.
2788 */
2790
2791/**
2792 * Obtain the previous parameter to a function.
2793 *
2794 * This is the opposite of LLVMGetNextParam().
2795 */
2797
2798/**
2799 * Set the alignment for a function parameter.
2800 *
2801 * @see llvm::Argument::addAttr()
2802 * @see llvm::AttrBuilder::addAlignmentAttr()
2803 */
2804void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned Align);
2805
2806/**
2807 * @}
2808 */
2809
2810/**
2811 * @defgroup LLVMCCoreValueGlobalIFunc IFuncs
2812 *
2813 * Functions in this group relate to indirect functions.
2814 *
2815 * Functions in this group expect LLVMValueRef instances that correspond
2816 * to llvm::GlobalIFunc instances.
2817 *
2818 * @{
2819 */
2820
2821/**
2822 * Add a global indirect function to a module under a specified name.
2823 *
2824 * @see llvm::GlobalIFunc::create()
2825 */
2827 const char *Name, size_t NameLen,
2828 LLVMTypeRef Ty, unsigned AddrSpace,
2829 LLVMValueRef Resolver);
2830
2831/**
2832 * Obtain a GlobalIFunc value from a Module by its name.
2833 *
2834 * The returned value corresponds to a llvm::GlobalIFunc value.
2835 *
2836 * @see llvm::Module::getNamedIFunc()
2837 */
2839 const char *Name, size_t NameLen);
2840
2841/**
2842 * Obtain an iterator to the first GlobalIFunc in a Module.
2843 *
2844 * @see llvm::Module::ifunc_begin()
2845 */
2847
2848/**
2849 * Obtain an iterator to the last GlobalIFunc in a Module.
2850 *
2851 * @see llvm::Module::ifunc_end()
2852 */
2854
2855/**
2856 * Advance a GlobalIFunc iterator to the next GlobalIFunc.
2857 *
2858 * Returns NULL if the iterator was already at the end and there are no more
2859 * global aliases.
2860 */
2862
2863/**
2864 * Decrement a GlobalIFunc iterator to the previous GlobalIFunc.
2865 *
2866 * Returns NULL if the iterator was already at the beginning and there are
2867 * no previous global aliases.
2868 */
2870
2871/**
2872 * Retrieves the resolver function associated with this indirect function, or
2873 * NULL if it doesn't not exist.
2874 *
2875 * @see llvm::GlobalIFunc::getResolver()
2876 */
2878
2879/**
2880 * Sets the resolver function associated with this indirect function.
2881 *
2882 * @see llvm::GlobalIFunc::setResolver()
2883 */
2885
2886/**
2887 * Remove a global indirect function from its parent module and delete it.
2888 *
2889 * @see llvm::GlobalIFunc::eraseFromParent()
2890 */
2892
2893/**
2894 * Remove a global indirect function from its parent module.
2895 *
2896 * This unlinks the global indirect function from its containing module but
2897 * keeps it alive.
2898 *
2899 * @see llvm::GlobalIFunc::removeFromParent()
2900 */
2902
2903/**
2904 * @}
2905 */
2906
2907/**
2908 * @}
2909 */
2910
2911/**
2912 * @}
2913 */
2914
2915/**
2916 * @}
2917 */
2918
2919/**
2920 * @defgroup LLVMCCoreValueMetadata Metadata
2921 *
2922 * @{
2923 */
2924
2925/**
2926 * Create an MDString value from a given string value.
2927 *
2928 * The MDString value does not take ownership of the given string, it remains
2929 * the responsibility of the caller to free it.
2930 *
2931 * @see llvm::MDString::get()
2932 */
2934 size_t SLen);
2935
2936/**
2937 * Create an MDNode value with the given array of operands.
2938 *
2939 * @see llvm::MDNode::get()
2940 */
2942 size_t Count);
2943
2944/**
2945 * Obtain a Metadata as a Value.
2946 */
2948
2949/**
2950 * Obtain a Value as a Metadata.
2951 */
2953
2954/**
2955 * Obtain the underlying string from a MDString value.
2956 *
2957 * @param V Instance to obtain string from.
2958 * @param Length Memory address which will hold length of returned string.
2959 * @return String data in MDString.
2960 */
2961const char *LLVMGetMDString(LLVMValueRef V, unsigned *Length);
2962
2963/**
2964 * Obtain the number of operands from an MDNode value.
2965 *
2966 * @param V MDNode to get number of operands from.
2967 * @return Number of operands of the MDNode.
2968 */
2970
2971/**
2972 * Obtain the given MDNode's operands.
2973 *
2974 * The passed LLVMValueRef pointer should point to enough memory to hold all of
2975 * the operands of the given MDNode (see LLVMGetMDNodeNumOperands) as
2976 * LLVMValueRefs. This memory will be populated with the LLVMValueRefs of the
2977 * MDNode's operands.
2978 *
2979 * @param V MDNode to get the operands from.
2980 * @param Dest Destination array for operands.
2981 */
2983
2984/**
2985 * Replace an operand at a specific index in a llvm::MDNode value.
2986 *
2987 * @see llvm::MDNode::replaceOperandWith()
2988 */
2990 LLVMMetadataRef Replacement);
2991
2992/** Deprecated: Use LLVMMDStringInContext2 instead. */
2994 unsigned SLen);
2995/** Deprecated: Use LLVMMDStringInContext2 instead. */
2996LLVMValueRef LLVMMDString(const char *Str, unsigned SLen);
2997/** Deprecated: Use LLVMMDNodeInContext2 instead. */
2999 unsigned Count);
3000/** Deprecated: Use LLVMMDNodeInContext2 instead. */
3001LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count);
3002
3003/**
3004 * @}
3005 */
3006
3007/**
3008 * @defgroup LLVMCCoreValueBasicBlock Basic Block
3009 *
3010 * A basic block represents a single entry single exit section of code.
3011 * Basic blocks contain a list of instructions which form the body of
3012 * the block.
3013 *
3014 * Basic blocks belong to functions. They have the type of label.
3015 *
3016 * Basic blocks are themselves values. However, the C API models them as
3017 * LLVMBasicBlockRef.
3018 *
3019 * @see llvm::BasicBlock
3020 *
3021 * @{
3022 */
3023
3024/**
3025 * Convert a basic block instance to a value type.
3026 */
3028
3029/**
3030 * Determine whether an LLVMValueRef is itself a basic block.
3031 */
3033
3034/**
3035 * Convert an LLVMValueRef to an LLVMBasicBlockRef instance.
3036 */
3038
3039/**
3040 * Obtain the string name of a basic block.
3041 */
3043
3044/**
3045 * Obtain the function to which a basic block belongs.
3046 *
3047 * @see llvm::BasicBlock::getParent()
3048 */
3050
3051/**
3052 * Obtain the terminator instruction for a basic block.
3053 *
3054 * If the basic block does not have a terminator (it is not well-formed
3055 * if it doesn't), then NULL is returned.
3056 *
3057 * The returned LLVMValueRef corresponds to an llvm::Instruction.
3058 *
3059 * @see llvm::BasicBlock::getTerminator()
3060 */
3062
3063/**
3064 * Obtain the number of basic blocks in a function.
3065 *
3066 * @param Fn Function value to operate on.
3067 */
3069
3070/**
3071 * Obtain all of the basic blocks in a function.
3072 *
3073 * This operates on a function value. The BasicBlocks parameter is a
3074 * pointer to a pre-allocated array of LLVMBasicBlockRef of at least
3075 * LLVMCountBasicBlocks() in length. This array is populated with
3076 * LLVMBasicBlockRef instances.
3077 */
3079
3080/**
3081 * Obtain the first basic block in a function.
3082 *
3083 * The returned basic block can be used as an iterator. You will likely
3084 * eventually call into LLVMGetNextBasicBlock() with it.
3085 *
3086 * @see llvm::Function::begin()
3087 */
3089
3090/**
3091 * Obtain the last basic block in a function.
3092 *
3093 * @see llvm::Function::end()
3094 */
3096
3097/**
3098 * Advance a basic block iterator.
3099 */
3101
3102/**
3103 * Go backwards in a basic block iterator.
3104 */
3106
3107/**
3108 * Obtain the basic block that corresponds to the entry point of a
3109 * function.
3110 *
3111 * @see llvm::Function::getEntryBlock()
3112 */
3114
3115/**
3116 * Insert the given basic block after the insertion point of the given builder.
3117 *
3118 * The insertion point must be valid.
3119 *
3120 * @see llvm::Function::BasicBlockListType::insertAfter()
3121 */
3124
3125/**
3126 * Append the given basic block to the basic block list of the given function.
3127 *
3128 * @see llvm::Function::BasicBlockListType::push_back()
3129 */
3132
3133/**
3134 * Create a new basic block without inserting it into a function.
3135 *
3136 * @see llvm::BasicBlock::Create()
3137 */
3139 const char *Name);
3140
3141/**
3142 * Append a basic block to the end of a function.
3143 *
3144 * @see llvm::BasicBlock::Create()
3145 */
3147 LLVMValueRef Fn,
3148 const char *Name);
3149
3150/**
3151 * Append a basic block to the end of a function using the global
3152 * context.
3153 *
3154 * @see llvm::BasicBlock::Create()
3155 */
3157
3158/**
3159 * Insert a basic block in a function before another basic block.
3160 *
3161 * The function to add to is determined by the function of the
3162 * passed basic block.
3163 *
3164 * @see llvm::BasicBlock::Create()
3165 */
3168 const char *Name);
3169
3170/**
3171 * Insert a basic block in a function using the global context.
3172 *
3173 * @see llvm::BasicBlock::Create()
3174 */
3176 const char *Name);
3177
3178/**
3179 * Remove a basic block from a function and delete it.
3180 *
3181 * This deletes the basic block from its containing function and deletes
3182 * the basic block itself.
3183 *
3184 * @see llvm::BasicBlock::eraseFromParent()
3185 */
3187
3188/**
3189 * Remove a basic block from a function.
3190 *
3191 * This deletes the basic block from its containing function but keep
3192 * the basic block alive.
3193 *
3194 * @see llvm::BasicBlock::removeFromParent()
3195 */
3197
3198/**
3199 * Move a basic block to before another one.
3200 *
3201 * @see llvm::BasicBlock::moveBefore()
3202 */
3204
3205/**
3206 * Move a basic block to after another one.
3207 *
3208 * @see llvm::BasicBlock::moveAfter()
3209 */
3211
3212/**
3213 * Obtain the first instruction in a basic block.
3214 *
3215 * The returned LLVMValueRef corresponds to a llvm::Instruction
3216 * instance.
3217 */
3219
3220/**
3221 * Obtain the last instruction in a basic block.
3222 *
3223 * The returned LLVMValueRef corresponds to an LLVM:Instruction.
3224 */
3226
3227/**
3228 * @}
3229 */
3230
3231/**
3232 * @defgroup LLVMCCoreValueInstruction Instructions
3233 *
3234 * Functions in this group relate to the inspection and manipulation of
3235 * individual instructions.
3236 *
3237 * In the C++ API, an instruction is modeled by llvm::Instruction. This
3238 * class has a large number of descendents. llvm::Instruction is a
3239 * llvm::Value and in the C API, instructions are modeled by
3240 * LLVMValueRef.
3241 *
3242 * This group also contains sub-groups which operate on specific
3243 * llvm::Instruction types, e.g. llvm::CallInst.
3244 *
3245 * @{
3246 */
3247
3248/**
3249 * Determine whether an instruction has any metadata attached.
3250 */
3252
3253/**
3254 * Return metadata associated with an instruction value.
3255 */
3256LLVMValueRef LLVMGetMetadata(LLVMValueRef Val, unsigned KindID);
3257
3258/**
3259 * Set metadata associated with an instruction value.
3260 */
3261void LLVMSetMetadata(LLVMValueRef Val, unsigned KindID, LLVMValueRef Node);
3262
3263/**
3264 * Returns the metadata associated with an instruction value, but filters out
3265 * all the debug locations.
3266 *
3267 * @see llvm::Instruction::getAllMetadataOtherThanDebugLoc()
3268 */
3271 size_t *NumEntries);
3272
3273/**
3274 * Obtain the basic block to which an instruction belongs.
3275 *
3276 * @see llvm::Instruction::getParent()
3277 */
3279
3280/**
3281 * Obtain the instruction that occurs after the one specified.
3282 *
3283 * The next instruction will be from the same basic block.
3284 *
3285 * If this is the last instruction in a basic block, NULL will be
3286 * returned.
3287 */
3289
3290/**
3291 * Obtain the instruction that occurred before this one.
3292 *
3293 * If the instruction is the first instruction in a basic block, NULL
3294 * will be returned.
3295 */
3297
3298/**
3299 * Remove an instruction.
3300 *
3301 * The instruction specified is removed from its containing building
3302 * block but is kept alive.
3303 *
3304 * @see llvm::Instruction::removeFromParent()
3305 */
3307
3308/**
3309 * Remove and delete an instruction.
3310 *
3311 * The instruction specified is removed from its containing building
3312 * block and then deleted.
3313 *
3314 * @see llvm::Instruction::eraseFromParent()
3315 */
3317
3318/**
3319 * Delete an instruction.
3320 *
3321 * The instruction specified is deleted. It must have previously been
3322 * removed from its containing building block.
3323 *
3324 * @see llvm::Value::deleteValue()
3325 */
3327
3328/**
3329 * Obtain the code opcode for an individual instruction.
3330 *
3331 * @see llvm::Instruction::getOpCode()
3332 */
3334
3335/**
3336 * Obtain the predicate of an instruction.
3337 *
3338 * This is only valid for instructions that correspond to llvm::ICmpInst
3339 * or llvm::ConstantExpr whose opcode is llvm::Instruction::ICmp.
3340 *
3341 * @see llvm::ICmpInst::getPredicate()
3342 */
3344
3345/**
3346 * Obtain the float predicate of an instruction.
3347 *
3348 * This is only valid for instructions that correspond to llvm::FCmpInst
3349 * or llvm::ConstantExpr whose opcode is llvm::Instruction::FCmp.
3350 *
3351 * @see llvm::FCmpInst::getPredicate()
3352 */
3354
3355/**
3356 * Create a copy of 'this' instruction that is identical in all ways
3357 * except the following:
3358 * * The instruction has no parent
3359 * * The instruction has no name
3360 *
3361 * @see llvm::Instruction::clone()
3362 */
3364
3365/**
3366 * Determine whether an instruction is a terminator. This routine is named to
3367 * be compatible with historical functions that did this by querying the
3368 * underlying C++ type.
3369 *
3370 * @see llvm::Instruction::isTerminator()
3371 */
3373
3374/**
3375 * @defgroup LLVMCCoreValueInstructionCall Call Sites and Invocations
3376 *
3377 * Functions in this group apply to instructions that refer to call
3378 * sites and invocations. These correspond to C++ types in the
3379 * llvm::CallInst class tree.
3380 *
3381 * @{
3382 */
3383
3384/**
3385 * Obtain the argument count for a call instruction.
3386 *
3387 * This expects an LLVMValueRef that corresponds to a llvm::CallInst,
3388 * llvm::InvokeInst, or llvm:FuncletPadInst.
3389 *
3390 * @see llvm::CallInst::getNumArgOperands()
3391 * @see llvm::InvokeInst::getNumArgOperands()
3392 * @see llvm::FuncletPadInst::getNumArgOperands()
3393 */
3394unsigned LLVMGetNumArgOperands(LLVMValueRef Instr);
3395
3396/**
3397 * Set the calling convention for a call instruction.
3398 *
3399 * This expects an LLVMValueRef that corresponds to a llvm::CallInst or
3400 * llvm::InvokeInst.
3401 *
3402 * @see llvm::CallInst::setCallingConv()
3403 * @see llvm::InvokeInst::setCallingConv()
3404 */
3405void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC);
3406
3407/**
3408 * Obtain the calling convention for a call instruction.
3409 *
3410 * This is the opposite of LLVMSetInstructionCallConv(). Reads its
3411 * usage.
3412 *
3413 * @see LLVMSetInstructionCallConv()
3414 */
3416
3418 unsigned Align);
3419
3424 LLVMAttributeRef *Attrs);
3427 unsigned KindID);
3430 const char *K, unsigned KLen);
3432 unsigned KindID);
3434 const char *K, unsigned KLen);
3435
3436/**
3437 * Obtain the function type called by this instruction.
3438 *
3439 * @see llvm::CallBase::getFunctionType()
3440 */
3442
3443/**
3444 * Obtain the pointer to the function invoked by this instruction.
3445 *
3446 * This expects an LLVMValueRef that corresponds to a llvm::CallInst or
3447 * llvm::InvokeInst.
3448 *
3449 * @see llvm::CallInst::getCalledOperand()
3450 * @see llvm::InvokeInst::getCalledOperand()
3451 */
3453
3454/**
3455 * Obtain whether a call instruction is a tail call.
3456 *
3457 * This only works on llvm::CallInst instructions.
3458 *
3459 * @see llvm::CallInst::isTailCall()
3460 */
3462
3463/**
3464 * Set whether a call instruction is a tail call.
3465 *
3466 * This only works on llvm::CallInst instructions.
3467 *
3468 * @see llvm::CallInst::setTailCall()
3469 */
3470void LLVMSetTailCall(LLVMValueRef CallInst, LLVMBool IsTailCall);
3471
3472/**
3473 * Obtain a tail call kind of the call instruction.
3474 *
3475 * @see llvm::CallInst::setTailCallKind()
3476 */
3478
3479/**
3480 * Set the call kind of the call instruction.
3481 *
3482 * @see llvm::CallInst::getTailCallKind()
3483 */
3485
3486/**
3487 * Return the normal destination basic block.
3488 *
3489 * This only works on llvm::InvokeInst instructions.
3490 *
3491 * @see llvm::InvokeInst::getNormalDest()
3492 */
3494
3495/**
3496 * Return the unwind destination basic block.
3497 *
3498 * Works on llvm::InvokeInst, llvm::CleanupReturnInst, and
3499 * llvm::CatchSwitchInst instructions.
3500 *
3501 * @see llvm::InvokeInst::getUnwindDest()
3502 * @see llvm::CleanupReturnInst::getUnwindDest()
3503 * @see llvm::CatchSwitchInst::getUnwindDest()
3504 */
3506
3507/**
3508 * Set the normal destination basic block.
3509 *
3510 * This only works on llvm::InvokeInst instructions.
3511 *
3512 * @see llvm::InvokeInst::setNormalDest()
3513 */
3515
3516/**
3517 * Set the unwind destination basic block.
3518 *
3519 * Works on llvm::InvokeInst, llvm::CleanupReturnInst, and
3520 * llvm::CatchSwitchInst instructions.
3521 *
3522 * @see llvm::InvokeInst::setUnwindDest()
3523 * @see llvm::CleanupReturnInst::setUnwindDest()
3524 * @see llvm::CatchSwitchInst::setUnwindDest()
3525 */
3527
3528/**
3529 * @}
3530 */
3531
3532/**
3533 * @defgroup LLVMCCoreValueInstructionTerminator Terminators
3534 *
3535 * Functions in this group only apply to instructions for which
3536 * LLVMIsATerminatorInst returns true.
3537 *
3538 * @{
3539 */
3540
3541/**
3542 * Return the number of successors that this terminator has.
3543 *
3544 * @see llvm::Instruction::getNumSuccessors
3545 */
3546unsigned LLVMGetNumSuccessors(LLVMValueRef Term);
3547
3548/**
3549 * Return the specified successor.
3550 *
3551 * @see llvm::Instruction::getSuccessor
3552 */
3554
3555/**
3556 * Update the specified successor to point at the provided block.
3557 *
3558 * @see llvm::Instruction::setSuccessor
3559 */
3561
3562/**
3563 * Return if a branch is conditional.
3564 *
3565 * This only works on llvm::BranchInst instructions.
3566 *
3567 * @see llvm::BranchInst::isConditional
3568 */
3570
3571/**
3572 * Return the condition of a branch instruction.
3573 *
3574 * This only works on llvm::BranchInst instructions.
3575 *
3576 * @see llvm::BranchInst::getCondition
3577 */
3579
3580/**
3581 * Set the condition of a branch instruction.
3582 *
3583 * This only works on llvm::BranchInst instructions.
3584 *
3585 * @see llvm::BranchInst::setCondition
3586 */
3588
3589/**
3590 * Obtain the default destination basic block of a switch instruction.
3591 *
3592 * This only works on llvm::SwitchInst instructions.
3593 *
3594 * @see llvm::SwitchInst::getDefaultDest()
3595 */
3597
3598/**
3599 * @}
3600 */
3601
3602/**
3603 * @defgroup LLVMCCoreValueInstructionAlloca Allocas
3604 *
3605 * Functions in this group only apply to instructions that map to
3606 * llvm::AllocaInst instances.
3607 *
3608 * @{
3609 */
3610
3611/**
3612 * Obtain the type that is being allocated by the alloca instruction.
3613 */
3615
3616/**
3617 * @}
3618 */
3619
3620/**
3621 * @defgroup LLVMCCoreValueInstructionGetElementPointer GEPs
3622 *
3623 * Functions in this group only apply to instructions that map to
3624 * llvm::GetElementPtrInst instances.
3625 *
3626 * @{
3627 */
3628
3629/**
3630 * Check whether the given GEP operator is inbounds.
3631 */
3633
3634/**
3635 * Set the given GEP instruction to be inbounds or not.
3636 */
3638
3639/**
3640 * Get the source element type of the given GEP operator.
3641 */
3643
3644/**
3645 * @}
3646 */
3647
3648/**
3649 * @defgroup LLVMCCoreValueInstructionPHINode PHI Nodes
3650 *
3651 * Functions in this group only apply to instructions that map to
3652 * llvm::PHINode instances.
3653 *
3654 * @{
3655 */
3656
3657/**
3658 * Add an incoming value to the end of a PHI list.
3659 */
3660void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues,
3661 LLVMBasicBlockRef *IncomingBlocks, unsigned Count);
3662
3663/**
3664 * Obtain the number of incoming basic blocks to a PHI node.
3665 */
3666unsigned LLVMCountIncoming(LLVMValueRef PhiNode);
3667
3668/**
3669 * Obtain an incoming value to a PHI node as an LLVMValueRef.
3670 */
3672
3673/**
3674 * Obtain an incoming value to a PHI node as an LLVMBasicBlockRef.
3675 */
3677
3678/**
3679 * @}
3680 */
3681
3682/**
3683 * @defgroup LLVMCCoreValueInstructionExtractValue ExtractValue
3684 * @defgroup LLVMCCoreValueInstructionInsertValue InsertValue
3685 *
3686 * Functions in this group only apply to instructions that map to
3687 * llvm::ExtractValue and llvm::InsertValue instances.
3688 *
3689 * @{
3690 */
3691
3692/**
3693 * Obtain the number of indices.
3694 * NB: This also works on GEP operators.
3695 */
3696unsigned LLVMGetNumIndices(LLVMValueRef Inst);
3697
3698/**
3699 * Obtain the indices as an array.
3700 */
3701const unsigned *LLVMGetIndices(LLVMValueRef Inst);
3702
3703/**
3704 * @}
3705 */
3706
3707/**
3708 * @}
3709 */
3710
3711/**
3712 * @}
3713 */
3714
3715/**
3716 * @defgroup LLVMCCoreInstructionBuilder Instruction Builders
3717 *
3718 * An instruction builder represents a point within a basic block and is
3719 * the exclusive means of building instructions using the C interface.
3720 *
3721 * @{
3722 */
3723
3727 LLVMValueRef Instr);
3734 const char *Name);
3736
3737/* Metadata */
3738
3739/**
3740 * Get location information used by debugging information.
3741 *
3742 * @see llvm::IRBuilder::getCurrentDebugLocation()
3743 */
3745
3746/**
3747 * Set location information used by debugging information.
3748 *
3749 * To clear the location metadata of the given instruction, pass NULL to \p Loc.
3750 *
3751 * @see llvm::IRBuilder::SetCurrentDebugLocation()
3752 */
3754
3755/**
3756 * Attempts to set the debug location for the given instruction using the
3757 * current debug location for the given builder. If the builder has no current
3758 * debug location, this function is a no-op.
3759 *
3760 * @deprecated LLVMSetInstDebugLocation is deprecated in favor of the more general
3761 * LLVMAddMetadataToInst.
3762 *
3763 * @see llvm::IRBuilder::SetInstDebugLocation()
3764 */
3766
3767/**
3768 * Adds the metadata registered with the given builder to the given instruction.
3769 *
3770 * @see llvm::IRBuilder::AddMetadataToInst()
3771 */
3773
3774/**
3775 * Get the dafult floating-point math metadata for a given builder.
3776 *
3777 * @see llvm::IRBuilder::getDefaultFPMathTag()
3778 */
3780
3781/**
3782 * Set the default floating-point math metadata for the given builder.
3783 *
3784 * To clear the metadata, pass NULL to \p FPMathTag.
3785 *
3786 * @see llvm::IRBuilder::setDefaultFPMathTag()
3787 */
3789 LLVMMetadataRef FPMathTag);
3790
3791/**
3792 * Deprecated: Passing the NULL location will crash.
3793 * Use LLVMGetCurrentDebugLocation2 instead.
3794 */
3796/**
3797 * Deprecated: Returning the NULL location will crash.
3798 * Use LLVMGetCurrentDebugLocation2 instead.
3799 */
3801
3802/* Terminators */
3806 unsigned N);
3811 LLVMBasicBlockRef Else, unsigned NumCases);
3813 unsigned NumDests);
3815 LLVMValueRef *Args, unsigned NumArgs,
3817 const char *Name);
3819
3820/* Exception Handling */
3823 LLVMValueRef PersFn, unsigned NumClauses,
3824 const char *Name);
3830 LLVMValueRef *Args, unsigned NumArgs,
3831 const char *Name);
3833 LLVMValueRef *Args, unsigned NumArgs,
3834 const char *Name);
3836 LLVMBasicBlockRef UnwindBB,
3837 unsigned NumHandlers, const char *Name);
3838
3839/* Add a case to the switch instruction */
3840void LLVMAddCase(LLVMValueRef Switch, LLVMValueRef OnVal,
3841 LLVMBasicBlockRef Dest);
3842
3843/* Add a destination to the indirectbr instruction */
3845
3846/* Get the number of clauses on the landingpad instruction */
3847unsigned LLVMGetNumClauses(LLVMValueRef LandingPad);
3848
3849/* Get the value of the clause at index Idx on the landingpad instruction */
3850LLVMValueRef LLVMGetClause(LLVMValueRef LandingPad, unsigned Idx);
3851
3852/* Add a catch or filter clause to the landingpad instruction */
3853void LLVMAddClause(LLVMValueRef LandingPad, LLVMValueRef ClauseVal);
3854
3855/* Get the 'cleanup' flag in the landingpad instruction */
3857
3858/* Set the 'cleanup' flag in the landingpad instruction */
3859void LLVMSetCleanup(LLVMValueRef LandingPad, LLVMBool Val);
3860
3861/* Add a destination to the catchswitch instruction */
3862void LLVMAddHandler(LLVMValueRef CatchSwitch, LLVMBasicBlockRef Dest);
3863
3864/* Get the number of handlers on the catchswitch instruction */
3865unsigned LLVMGetNumHandlers(LLVMValueRef CatchSwitch);
3866
3867/**
3868 * Obtain the basic blocks acting as handlers for a catchswitch instruction.
3869 *
3870 * The Handlers parameter should point to a pre-allocated array of
3871 * LLVMBasicBlockRefs at least LLVMGetNumHandlers() large. On return, the
3872 * first LLVMGetNumHandlers() entries in the array will be populated
3873 * with LLVMBasicBlockRef instances.
3874 *
3875 * @param CatchSwitch The catchswitch instruction to operate on.
3876 * @param Handlers Memory address of an array to be filled with basic blocks.
3877 */
3878void LLVMGetHandlers(LLVMValueRef CatchSwitch, LLVMBasicBlockRef *Handlers);
3879
3880/* Funclets */
3881
3882/* Get the number of funcletpad arguments. */
3883LLVMValueRef LLVMGetArgOperand(LLVMValueRef Funclet, unsigned i);
3884
3885/* Set a funcletpad argument at the given index. */
3886void LLVMSetArgOperand(LLVMValueRef Funclet, unsigned i, LLVMValueRef value);
3887
3888/**
3889 * Get the parent catchswitch instruction of a catchpad instruction.
3890 *
3891 * This only works on llvm::CatchPadInst instructions.
3892 *
3893 * @see llvm::CatchPadInst::getCatchSwitch()
3894 */
3896
3897/**
3898 * Set the parent catchswitch instruction of a catchpad instruction.
3899 *
3900 * This only works on llvm::CatchPadInst instructions.
3901 *
3902 * @see llvm::CatchPadInst::setCatchSwitch()
3903 */
3904void LLVMSetParentCatchSwitch(LLVMValueRef CatchPad, LLVMValueRef CatchSwitch);
3905
3906/* Arithmetic */
3908 const char *Name);
3910 const char *Name);
3912 const char *Name);
3914 const char *Name);
3916 const char *Name);
3918 const char *Name);
3920 const char *Name);
3922 const char *Name);
3924 const char *Name);
3926 const char *Name);
3928 const char *Name);
3930 const char *Name);
3932 const char *Name);
3934 const char *Name);
3936 const char *Name);
3938 const char *Name);
3940 const char *Name);
3942 const char *Name);
3944 const char *Name);
3946 const char *Name);
3948 const char *Name);
3950 const char *Name);
3952 const char *Name);
3954 const char *Name);
3956 const char *Name);
3958 const char *Name);
3961 const char *Name);
3964 const char *Name);
3966 const char *Name);
3969
3971void LLVMSetNUW(LLVMValueRef ArithInst, LLVMBool HasNUW);
3973void LLVMSetNSW(LLVMValueRef ArithInst, LLVMBool HasNSW);
3974LLVMBool LLVMGetExact(LLVMValueRef DivOrShrInst);
3975void LLVMSetExact(LLVMValueRef DivOrShrInst, LLVMBool IsExact);
3976
3977/**
3978 * Gets if the instruction has the non-negative flag set.
3979 * Only valid for zext instructions.
3980 */
3982/**
3983 * Sets the non-negative flag for the instruction.
3984 * Only valid for zext instructions.
3985 */
3986void LLVMSetNNeg(LLVMValueRef NonNegInst, LLVMBool IsNonNeg);
3987
3988/**
3989 * Gets whether the instruction has the disjoint flag set.
3990 * Only valid for or instructions.
3991 */
3993/**
3994 * Sets the disjoint flag for the instruction.
3995 * Only valid for or instructions.
3996 */
3997void LLVMSetIsDisjoint(LLVMValueRef Inst, LLVMBool IsDisjoint);
3998
3999/* Memory */
4002 LLVMValueRef Val, const char *Name);
4003
4004/**
4005 * Creates and inserts a memset to the specified pointer and the
4006 * specified value.
4007 *
4008 * @see llvm::IRRBuilder::CreateMemSet()
4009 */
4011 LLVMValueRef Val, LLVMValueRef Len,
4012 unsigned Align);
4013/**
4014 * Creates and inserts a memcpy between the specified pointers.
4015 *
4016 * @see llvm::IRRBuilder::CreateMemCpy()
4017 */
4019 LLVMValueRef Dst, unsigned DstAlign,
4020 LLVMValueRef Src, unsigned SrcAlign,
4022/**
4023 * Creates and inserts a memmove between the specified pointers.
4024 *
4025 * @see llvm::IRRBuilder::CreateMemMove()
4026 */
4028 LLVMValueRef Dst, unsigned DstAlign,
4029 LLVMValueRef Src, unsigned SrcAlign,
4031
4034 LLVMValueRef Val, const char *Name);
4037 LLVMValueRef PointerVal, const char *Name);
4040 LLVMValueRef Pointer, LLVMValueRef *Indices,
4041 unsigned NumIndices, const char *Name);
4043 LLVMValueRef Pointer, LLVMValueRef *Indices,
4044 unsigned NumIndices, const char *Name);
4046 LLVMValueRef Pointer, unsigned Idx,
4047 const char *Name);
4049 const char *Name);
4051 const char *Name);
4052LLVMBool LLVMGetVolatile(LLVMValueRef MemoryAccessInst);
4053void LLVMSetVolatile(LLVMValueRef MemoryAccessInst, LLVMBool IsVolatile);
4054LLVMBool LLVMGetWeak(LLVMValueRef CmpXchgInst);
4055void LLVMSetWeak(LLVMValueRef CmpXchgInst, LLVMBool IsWeak);
4057void LLVMSetOrdering(LLVMValueRef MemoryAccessInst, LLVMAtomicOrdering Ordering);
4059void LLVMSetAtomicRMWBinOp(LLVMValueRef AtomicRMWInst, LLVMAtomicRMWBinOp BinOp);
4060
4061/* Casts */
4063 LLVMTypeRef DestTy, const char *Name);
4065 LLVMTypeRef DestTy, const char *Name);
4067 LLVMTypeRef DestTy, const char *Name);
4069 LLVMTypeRef DestTy, const char *Name);
4071 LLVMTypeRef DestTy, const char *Name);
4073 LLVMTypeRef DestTy, const char *Name);
4075 LLVMTypeRef DestTy, const char *Name);
4077 LLVMTypeRef DestTy, const char *Name);
4079 LLVMTypeRef DestTy, const char *Name);
4081 LLVMTypeRef DestTy, const char *Name);
4083 LLVMTypeRef DestTy, const char *Name);
4085 LLVMTypeRef DestTy, const char *Name);
4087 LLVMTypeRef DestTy, const char *Name);
4089 LLVMTypeRef DestTy, const char *Name);
4091 LLVMTypeRef DestTy, const char *Name);
4093 LLVMTypeRef DestTy, const char *Name);
4095 LLVMTypeRef DestTy, const char *Name);
4097 LLVMTypeRef DestTy, const char *Name);
4099 LLVMTypeRef DestTy, LLVMBool IsSigned,
4100 const char *Name);
4102 LLVMTypeRef DestTy, const char *Name);
4103
4104/** Deprecated: This cast is always signed. Use LLVMBuildIntCast2 instead. */
4106 LLVMTypeRef DestTy, const char *Name);
4107
4109 LLVMTypeRef DestTy, LLVMBool DestIsSigned);
4110
4111/* Comparisons */
4114 const char *Name);
4117 const char *Name);
4118
4119/* Miscellaneous instructions */
4122 LLVMValueRef *Args, unsigned NumArgs,
4123 const char *Name);
4125 LLVMValueRef Then, LLVMValueRef Else,
4126 const char *Name);
4128 const char *Name);
4130 LLVMValueRef Index, const char *Name);
4133 const char *Name);
4135 LLVMValueRef V2, LLVMValueRef Mask,
4136 const char *Name);
4138 unsigned Index, const char *Name);
4140 LLVMValueRef EltVal, unsigned Index,
4141 const char *Name);
4143 const char *Name);
4144
4146 const char *Name);
4148 const char *Name);
4151 const char *Name);
4153 LLVMBool singleThread, const char *Name);
4155 LLVMValueRef PTR, LLVMValueRef Val,
4156 LLVMAtomicOrdering ordering,
4157 LLVMBool singleThread);
4159 LLVMValueRef Cmp, LLVMValueRef New,
4160 LLVMAtomicOrdering SuccessOrdering,
4161 LLVMAtomicOrdering FailureOrdering,
4163
4164/**
4165 * Get the number of elements in the mask of a ShuffleVector instruction.
4166 */
4167unsigned LLVMGetNumMaskElements(LLVMValueRef ShuffleVectorInst);
4168
4169/**
4170 * \returns a constant that specifies that the result of a \c ShuffleVectorInst
4171 * is undefined.
4172 */
4173int LLVMGetUndefMaskElem(void);
4174
4175/**
4176 * Get the mask value at position Elt in the mask of a ShuffleVector
4177 * instruction.
4178 *
4179 * \Returns the result of \c LLVMGetUndefMaskElem() if the mask value is
4180 * poison at that position.
4181 */
4182int LLVMGetMaskValue(LLVMValueRef ShuffleVectorInst, unsigned Elt);
4183
4186
4189 LLVMAtomicOrdering Ordering);
4192 LLVMAtomicOrdering Ordering);
4193
4194/**
4195 * @}
4196 */
4197
4198/**
4199 * @defgroup LLVMCCoreModuleProvider Module Providers
4200 *
4201 * @{
4202 */
4203
4204/**
4205 * Changes the type of M so it can be passed to FunctionPassManagers and the
4206 * JIT. They take ModuleProviders for historical reasons.
4207 */
4210
4211/**
4212 * Destroys the module M.
4213 */
4215
4216/**
4217 * @}
4218 */
4219
4220/**
4221 * @defgroup LLVMCCoreMemoryBuffers Memory Buffers
4222 *
4223 * @{
4224 */
4225
4227 LLVMMemoryBufferRef *OutMemBuf,
4228 char **OutMessage);
4230 char **OutMessage);
4232 size_t InputDataLength,
4233 const char *BufferName,
4234 LLVMBool RequiresNullTerminator);
4236 size_t InputDataLength,
4237 const char *BufferName);
4238const char *LLVMGetBufferStart(LLVMMemoryBufferRef MemBuf);
4241
4242/**
4243 * @}
4244 */
4245
4246/**
4247 * @defgroup LLVMCCorePassManagers Pass Managers
4248 * @ingroup LLVMCCore
4249 *
4250 * @{
4251 */
4252
4253/** Constructs a new whole-module pass pipeline. This type of pipeline is
4254 suitable for link-time optimization and whole-module transformations.
4255 @see llvm::PassManager::PassManager */
4257
4258/** Constructs a new function-by-function pass pipeline over the module
4259 provider. It does not take ownership of the module provider. This type of
4260 pipeline is suitable for code generation and JIT compilation tasks.
4261 @see llvm::FunctionPassManager::FunctionPassManager */
4263
4264/** Deprecated: Use LLVMCreateFunctionPassManagerForModule instead. */
4266
4267/** Initializes, executes on the provided module, and finalizes all of the
4268 passes scheduled in the pass manager. Returns 1 if any of the passes
4269 modified the module, 0 otherwise.
4270 @see llvm::PassManager::run(Module&) */
4272
4273/** Initializes all of the function passes scheduled in the function pass
4274 manager. Returns 1 if any of the passes modified the module, 0 otherwise.
4275 @see llvm::FunctionPassManager::doInitialization */
4277
4278/** Executes all of the function passes scheduled in the function pass manager
4279 on the provided function. Returns 1 if any of the passes modified the
4280 function, false otherwise.
4281 @see llvm::FunctionPassManager::run(Function&) */
4283
4284/** Finalizes all of the function passes scheduled in the function pass
4285 manager. Returns 1 if any of the passes modified the module, 0 otherwise.
4286 @see llvm::FunctionPassManager::doFinalization */
4288
4289/** Frees the memory of a pass pipeline. For function pipelines, does not free
4290 the module provider.
4291 @see llvm::PassManagerBase::~PassManagerBase. */
4293
4294/**
4295 * @}
4296 */
4297
4298/**
4299 * @defgroup LLVMCCoreThreading Threading
4300 *
4301 * Handle the structures needed to make LLVM safe for multithreading.
4302 *
4303 * @{
4304 */
4305
4306/** Deprecated: Multi-threading can only be enabled/disabled with the compile
4307 time define LLVM_ENABLE_THREADS. This function always returns
4308 LLVMIsMultithreaded(). */
4310
4311/** Deprecated: Multi-threading can only be enabled/disabled with the compile
4312 time define LLVM_ENABLE_THREADS. */
4313void LLVMStopMultithreaded(void);
4314
4315/** Check whether LLVM is executing in thread-safe mode or not.
4316 @see llvm::llvm_is_multithreaded */
4318
4319/**
4320 * @}
4321 */
4322
4323/**
4324 * @}
4325 */
4326
4327/**
4328 * @}
4329 */
4330
4332
4333#endif /* LLVM_C_CORE_H */
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
Given that RA is a live value
#define LLVM_ATTRIBUTE_C_DEPRECATED(decl, message)
Definition: Deprecated.h:34
uint64_t Align
uint64_t Addr
std::string Name
uint32_t Index
uint64_t Size
#define LLVM_C_EXTERN_C_BEGIN
Definition: ExternC.h:35
#define LLVM_C_EXTERN_C_END
Definition: ExternC.h:36
#define op(i)
Hexagon Common GEP
LLVMValueRef LLVMGetElementAsConstant(LLVMValueRef C, unsigned idx)
Definition: Core.cpp:1533
static cl::opt< bool > SingleThread("licm-force-thread-model-single", cl::Hidden, cl::init(false), cl::desc("Force thread model single in LICM pass"))
#define F(x, y, z)
Definition: MD5.cpp:55
Module * Mod
const SmallVectorImpl< MachineOperand > & Cond
static cl::opt< RegAllocEvictionAdvisorAnalysis::AdvisorMode > Mode("regalloc-enable-advisor", cl::Hidden, cl::init(RegAllocEvictionAdvisorAnalysis::AdvisorMode::Default), cl::desc("Enable regalloc advisor mode"), cl::values(clEnumValN(RegAllocEvictionAdvisorAnalysis::AdvisorMode::Default, "default", "Default"), clEnumValN(RegAllocEvictionAdvisorAnalysis::AdvisorMode::Release, "release", "precompiled"), clEnumValN(RegAllocEvictionAdvisorAnalysis::AdvisorMode::Development, "development", "for training")))
unify loop Fixup each natural loop to have a single exit block
Value * RHS
Value * LHS
LLVMContextRef LLVMGetGlobalContext(void)
Obtain the global context instance.
Definition: Core.cpp:93
unsigned LLVMGetEnumAttributeKind(LLVMAttributeRef A)
Get the unique id corresponding to the enum attribute passed as argument.
Definition: Core.cpp:156
void LLVMContextSetDiscardValueNames(LLVMContextRef C, LLVMBool Discard)
Set whether the given context discards all value names.
Definition: Core.cpp:124
uint64_t LLVMGetEnumAttributeValue(LLVMAttributeRef A)
Get the enum attribute's value.
Definition: Core.cpp:160
LLVMTypeRef LLVMGetTypeAttributeValue(LLVMAttributeRef A)
Get the type attribute's value.
Definition: Core.cpp:174
unsigned LLVMGetMDKindIDInContext(LLVMContextRef C, const char *Name, unsigned SLen)
Definition: Core.cpp:132
LLVMDiagnosticSeverity LLVMGetDiagInfoSeverity(LLVMDiagnosticInfoRef DI)
Return an enum LLVMDiagnosticSeverity.
Definition: Core.cpp:224
char * LLVMGetDiagInfoDescription(LLVMDiagnosticInfoRef DI)
Return a string representation of the DiagnosticInfo.
Definition: Core.cpp:213
unsigned LLVMGetEnumAttributeKindForName(const char *Name, size_t SLen)
Return an unique id given the name of a enum attribute, or 0 if no attribute by that name exists.
Definition: Core.cpp:141
LLVMDiagnosticHandler LLVMContextGetDiagnosticHandler(LLVMContextRef C)
Get the diagnostic handler of this context.
Definition: Core.cpp:104
LLVMBool LLVMContextShouldDiscardValueNames(LLVMContextRef C)
Retrieve whether the given context is set to discard all value names.
Definition: Core.cpp:120
LLVMAttributeRef LLVMCreateTypeAttribute(LLVMContextRef C, unsigned KindID, LLVMTypeRef type_ref)
Create a type attribute.
Definition: Core.cpp:167
LLVMAttributeRef LLVMCreateStringAttribute(LLVMContextRef C, const char *K, unsigned KLength, const char *V, unsigned VLength)
Create a string attribute.
Definition: Core.cpp:179
void LLVMContextDispose(LLVMContextRef C)
Destroy a context instance.
Definition: Core.cpp:128
LLVMAttributeRef LLVMCreateEnumAttribute(LLVMContextRef C, unsigned KindID, uint64_t Val)
Create an enum attribute.
Definition: Core.cpp:149
const char * LLVMGetStringAttributeKind(LLVMAttributeRef A, unsigned *Length)
Get the string attribute's kind.
Definition: Core.cpp:186
LLVMTypeRef LLVMGetTypeByName2(LLVMContextRef C, const char *Name)
Obtain a Type from a context by its registered name.
Definition: Core.cpp:824
LLVMContextRef LLVMContextCreate(void)
Create a new context.
Definition: Core.cpp:89
void(* LLVMYieldCallback)(LLVMContextRef, void *)
Definition: Core.h:523
unsigned LLVMGetLastEnumAttributeKind(void)
Definition: Core.cpp:145
LLVMBool LLVMIsStringAttribute(LLVMAttributeRef A)
Definition: Core.cpp:205
LLVMBool LLVMIsTypeAttribute(LLVMAttributeRef A)
Definition: Core.cpp:209
const char * LLVMGetStringAttributeValue(LLVMAttributeRef A, unsigned *Length)
Get the string attribute's value.
Definition: Core.cpp:193
void LLVMContextSetYieldCallback(LLVMContextRef C, LLVMYieldCallback Callback, void *OpaqueHandle)
Set the yield callback function for this context.
Definition: Core.cpp:113
unsigned LLVMGetMDKindID(const char *Name, unsigned SLen)
Definition: Core.cpp:137
void LLVMContextSetDiagnosticHandler(LLVMContextRef C, LLVMDiagnosticHandler Handler, void *DiagnosticContext)
Set the diagnostic handler for this context.
Definition: Core.cpp:95
void(* LLVMDiagnosticHandler)(LLVMDiagnosticInfoRef, void *)
Definition: Core.h:522
void * LLVMContextGetDiagnosticContext(LLVMContextRef C)
Get the diagnostic context of this context.
Definition: Core.cpp:109
LLVMBool LLVMIsEnumAttribute(LLVMAttributeRef A)
Check for the different types of attributes.
Definition: Core.cpp:200
LLVMValueRef LLVMBuildLoad2(LLVMBuilderRef, LLVMTypeRef Ty, LLVMValueRef PointerVal, const char *Name)
Definition: Core.cpp:3536
LLVMValueRef LLVMBuildGlobalStringPtr(LLVMBuilderRef B, const char *Str, const char *Name)
Definition: Core.cpp:3661
LLVMValueRef LLVMBuildFence(LLVMBuilderRef B, LLVMAtomicOrdering ordering, LLVMBool singleThread, const char *Name)
Definition: Core.cpp:3625
LLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B, LLVMAtomicRMWBinOp op, LLVMValueRef PTR, LLVMValueRef Val, LLVMAtomicOrdering ordering, LLVMBool singleThread)
Definition: Core.cpp:3947
LLVMBool LLVMGetIsDisjoint(LLVMValueRef Inst)
Gets whether the instruction has the disjoint flag set.
Definition: Core.cpp:3467
LLVMValueRef LLVMBuildNot(LLVMBuilderRef, LLVMValueRef V, const char *Name)
Definition: Core.cpp:3423
LLVMValueRef LLVMBuildNSWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3293
LLVMValueRef LLVMBuildAnd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3383
LLVMValueRef LLVMBuildFPExt(LLVMBuilderRef, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:3773
void LLVMClearInsertionPosition(LLVMBuilderRef Builder)
Definition: Core.cpp:3038
LLVMValueRef LLVMBuildFDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3348
void LLVMSetWeak(LLVMValueRef CmpXchgInst, LLVMBool IsWeak)
Definition: Core.cpp:3692
void LLVMSetNSW(LLVMValueRef ArithInst, LLVMBool HasNSW)
Definition: Core.cpp:3442
LLVMValueRef LLVMBuildFreeze(LLVMBuilderRef, LLVMValueRef Val, const char *Name)
Definition: Core.cpp:3925
LLVMValueRef LLVMBuildFAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3283
LLVMValueRef LLVMBuildFMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3323
LLVMValueRef LLVMBuildZExt(LLVMBuilderRef, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:3738
LLVMValueRef LLVMBuildSExt(LLVMBuilderRef, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:3743
LLVMValueRef LLVMBuildTruncOrBitCast(LLVMBuilderRef, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:3810
LLVMValueRef LLVMBuildSExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:3804
LLVMValueRef LLVMBuildBitCast(LLVMBuilderRef, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:3788
void LLVMBuilderSetDefaultFPMathTag(LLVMBuilderRef Builder, LLVMMetadataRef FPMathTag)
Set the default floating-point math metadata for the given builder.
Definition: Core.cpp:3088
LLVMValueRef LLVMBuildExtractValue(LLVMBuilderRef, LLVMValueRef AggVal, unsigned Index, const char *Name)
Definition: Core.cpp:3913
LLVMValueRef LLVMBuildFCmp(LLVMBuilderRef, LLVMRealPredicate Op, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3860
void LLVMSetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst, LLVMAtomicOrdering Ordering)
Definition: Core.cpp:4033
LLVMValueRef LLVMBuildFPTrunc(LLVMBuilderRef, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:3768
LLVMAtomicOrdering LLVMGetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst)
Definition: Core.cpp:4028
LLVMOpcode LLVMGetCastOpcode(LLVMValueRef Src, LLVMBool SrcIsSigned, LLVMTypeRef DestTy, LLVMBool DestIsSigned)
Definition: Core.cpp:3845
LLVMAtomicRMWBinOp LLVMGetAtomicRMWBinOp(LLVMValueRef AtomicRMWInst)
Definition: Core.cpp:3723
void LLVMSetNUW(LLVMValueRef ArithInst, LLVMBool HasNUW)
Definition: Core.cpp:3432
LLVMValueRef LLVMBuildSIToFP(LLVMBuilderRef, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:3763
LLVMValueRef LLVMBuildShl(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3368
void LLVMSetCurrentDebugLocation2(LLVMBuilderRef Builder, LLVMMetadataRef Loc)
Set location information used by debugging information.
Definition: Core.cpp:3061
int LLVMGetUndefMaskElem(void)
Definition: Core.cpp:3983
LLVMBool LLVMGetWeak(LLVMValueRef CmpXchgInst)
Definition: Core.cpp:3688
LLVMValueRef LLVMBuildFRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3363
LLVMValueRef LLVMBuildAlloca(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name)
Definition: Core.cpp:3522
LLVMValueRef LLVMBuildSelect(LLVMBuilderRef, LLVMValueRef If, LLVMValueRef Then, LLVMValueRef Else, const char *Name)
Definition: Core.cpp:3881
LLVMValueRef LLVMBuildCatchPad(LLVMBuilderRef B, LLVMValueRef ParentPad, LLVMValueRef *Args, unsigned NumArgs, const char *Name)
Definition: Core.cpp:3155
void LLVMSetIsDisjoint(LLVMValueRef Inst, LLVMBool IsDisjoint)
Sets the disjoint flag for the instruction.
Definition: Core.cpp:3472
LLVMValueRef LLVMBuildMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3308
LLVMValueRef LLVMBuildExactSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3343
LLVMValueRef LLVMBuildNUWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3298
LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name)
Definition: Core.cpp:3479
LLVMValueRef LLVMBuildIsNull(LLVMBuilderRef, LLVMValueRef Val, const char *Name)
Definition: Core.cpp:3930
LLVMValueRef LLVMBuildLandingPad(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef PersFn, unsigned NumClauses, const char *Name)
Definition: Core.cpp:3143
LLVMValueRef LLVMBuildAggregateRet(LLVMBuilderRef, LLVMValueRef *RetVals, unsigned N)
Definition: Core.cpp:3110
LLVMValueRef LLVMBuildAShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3378
LLVMValueRef LLVMBuildInvoke2(LLVMBuilderRef, LLVMTypeRef Ty, LLVMValueRef Fn, LLVMValueRef *Args, unsigned NumArgs, LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch, const char *Name)
Definition: Core.cpp:3134
LLVMValueRef LLVMBuildExactUDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3333
void LLVMSetOrdering(LLVMValueRef MemoryAccessInst, LLVMAtomicOrdering Ordering)
Definition: Core.cpp:3710
void LLVMSetCleanup(LLVMValueRef LandingPad, LLVMBool Val)
Definition: Core.cpp:3229
LLVMValueRef LLVMGetArgOperand(LLVMValueRef Funclet, unsigned i)
Definition: Core.cpp:3258
LLVMValueRef LLVMBuildInsertValue(LLVMBuilderRef, LLVMValueRef AggVal, LLVMValueRef EltVal, unsigned Index, const char *Name)
Definition: Core.cpp:3918
LLVMValueRef LLVMBuildAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3268
LLVMValueRef LLVMBuildMemSet(LLVMBuilderRef B, LLVMValueRef Ptr, LLVMValueRef Val, LLVMValueRef Len, unsigned Align)
Creates and inserts a memset to the specified pointer and the specified value.
Definition: Core.cpp:3497
LLVMValueRef LLVMBuildBr(LLVMBuilderRef, LLVMBasicBlockRef Dest)
Definition: Core.cpp:3115
LLVMValueRef LLVMBuildNSWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3313
LLVMValueRef LLVMBuildBinOp(LLVMBuilderRef B, LLVMOpcode Op, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3398
LLVMValueRef LLVMBuildSRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3358
void LLVMDisposeBuilder(LLVMBuilderRef Builder)
Definition: Core.cpp:3051
int LLVMGetMaskValue(LLVMValueRef ShuffleVectorInst, unsigned Elt)
Get the mask value at position Elt in the mask of a ShuffleVector instruction.
Definition: Core.cpp:3977
LLVMValueRef LLVMBuildFSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3303
LLVMValueRef LLVMGetClause(LLVMValueRef LandingPad, unsigned Idx)
Definition: Core.cpp:3217
LLVMMetadataRef LLVMGetCurrentDebugLocation2(LLVMBuilderRef Builder)
Get location information used by debugging information.
Definition: Core.cpp:3057
LLVMValueRef LLVMBuildArrayAlloca(LLVMBuilderRef, LLVMTypeRef Ty, LLVMValueRef Val, const char *Name)
Definition: Core.cpp:3527
LLVMValueRef LLVMBuildVAArg(LLVMBuilderRef, LLVMValueRef List, LLVMTypeRef Ty, const char *Name)
Definition: Core.cpp:3888
LLVMBuilderRef LLVMCreateBuilderInContext(LLVMContextRef C)
Definition: Core.cpp:3009
LLVMValueRef LLVMBuildAtomicCmpXchg(LLVMBuilderRef B, LLVMValueRef Ptr, LLVMValueRef Cmp, LLVMValueRef New, LLVMAtomicOrdering SuccessOrdering, LLVMAtomicOrdering FailureOrdering, LLVMBool SingleThread)
Definition: Core.cpp:3958
LLVMValueRef LLVMBuildICmp(LLVMBuilderRef, LLVMIntPredicate Op, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3853
LLVMValueRef LLVMBuildPointerCast(LLVMBuilderRef, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:3822
LLVMValueRef LLVMGetParentCatchSwitch(LLVMValueRef CatchPad)
Get the parent catchswitch instruction of a catchpad instruction.
Definition: Core.cpp:3247
void LLVMSetAtomicSingleThread(LLVMValueRef AtomicInst, LLVMBool SingleThread)
Definition: Core.cpp:4000
LLVMValueRef LLVMBuildCast(LLVMBuilderRef B, LLVMOpcode Op, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:3816
LLVMValueRef LLVMBuildTrunc(LLVMBuilderRef, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:3733
LLVMValueRef LLVMBuildURem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3353
void LLVMSetAtomicRMWBinOp(LLVMValueRef AtomicRMWInst, LLVMAtomicRMWBinOp BinOp)
Definition: Core.cpp:3727
LLVMValueRef LLVMBuildCall2(LLVMBuilderRef, LLVMTypeRef, LLVMValueRef Fn, LLVMValueRef *Args, unsigned NumArgs, const char *Name)
Definition: Core.cpp:3873
void LLVMAddClause(LLVMValueRef LandingPad, LLVMValueRef ClauseVal)
Definition: Core.cpp:3221
LLVMValueRef LLVMBuildOr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3388
LLVMBool LLVMGetNUW(LLVMValueRef ArithInst)
Definition: Core.cpp:3427
LLVMValueRef LLVMBuildAddrSpaceCast(LLVMBuilderRef, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:3793
LLVMValueRef LLVMBuildFPToUI(LLVMBuilderRef, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:3748
void LLVMSetCurrentDebugLocation(LLVMBuilderRef Builder, LLVMValueRef L)
Deprecated: Passing the NULL location will crash.
Definition: Core.cpp:3068
LLVMValueRef LLVMBuildFPToSI(LLVMBuilderRef, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:3753
LLVMValueRef LLVMBuildIntCast2(LLVMBuilderRef, LLVMValueRef Val, LLVMTypeRef DestTy, LLVMBool IsSigned, const char *Name)
Definition: Core.cpp:3827
LLVMValueRef LLVMBuildNSWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3273
LLVMValueRef LLVMBuildFNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name)
Definition: Core.cpp:3419
LLVMMetadataRef LLVMBuilderGetDefaultFPMathTag(LLVMBuilderRef Builder)
Get the dafult floating-point math metadata for a given builder.
Definition: Core.cpp:3096
LLVMValueRef LLVMBuildUDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3328
void LLVMSetParentCatchSwitch(LLVMValueRef CatchPad, LLVMValueRef CatchSwitch)
Set the parent catchswitch instruction of a catchpad instruction.
Definition: Core.cpp:3251
LLVMValueRef LLVMBuildCatchRet(LLVMBuilderRef B, LLVMValueRef CatchPad, LLVMBasicBlockRef BB)
Definition: Core.cpp:3188
LLVMValueRef LLVMBuildStructGEP2(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Pointer, unsigned Idx, const char *Name)
Definition: Core.cpp:3649
unsigned LLVMGetNumClauses(LLVMValueRef LandingPad)
Definition: Core.cpp:3213
LLVMBool LLVMGetNNeg(LLVMValueRef NonNegInst)
Gets if the instruction has the non-negative flag set.
Definition: Core.cpp:3457
LLVMValueRef LLVMBuildSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3338
LLVMValueRef LLVMBuildStore(LLVMBuilderRef, LLVMValueRef Val, LLVMValueRef Ptr)
Definition: Core.cpp:3541
LLVMValueRef LLVMBuildCatchSwitch(LLVMBuilderRef B, LLVMValueRef ParentPad, LLVMBasicBlockRef UnwindBB, unsigned NumHandlers, const char *Name)
Definition: Core.cpp:3177
LLVMValueRef LLVMBuildIntCast(LLVMBuilderRef, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Deprecated: This cast is always signed.
Definition: Core.cpp:3834
LLVMValueRef LLVMBuildNUWNeg(LLVMBuilderRef B, LLVMValueRef V, const char *Name)
Definition: Core.cpp:3414
LLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef, LLVMTypeRef Ty, LLVMValueRef Val, const char *Name)
Definition: Core.cpp:3488
LLVMValueRef LLVMBuildZExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:3798
LLVMValueRef LLVMBuildInBoundsGEP2(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Pointer, LLVMValueRef *Indices, unsigned NumIndices, const char *Name)
Definition: Core.cpp:3641
void LLVMGetHandlers(LLVMValueRef CatchSwitch, LLVMBasicBlockRef *Handlers)
Obtain the basic blocks acting as handlers for a catchswitch instruction.
Definition: Core.cpp:3241
LLVMAtomicOrdering LLVMGetOrdering(LLVMValueRef MemoryAccessInst)
Definition: Core.cpp:3696
LLVMValueRef LLVMBuildUIToFP(LLVMBuilderRef, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:3758
LLVMValueRef LLVMBuildIntToPtr(LLVMBuilderRef, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:3783
LLVMValueRef LLVMBuildCondBr(LLVMBuilderRef, LLVMValueRef If, LLVMBasicBlockRef Then, LLVMBasicBlockRef Else)
Definition: Core.cpp:3119
LLVMValueRef LLVMBuildIndirectBr(LLVMBuilderRef B, LLVMValueRef Addr, unsigned NumDests)
Definition: Core.cpp:3129
void LLVMAddDestination(LLVMValueRef IndirectBr, LLVMBasicBlockRef Dest)
Definition: Core.cpp:3209
LLVMValueRef LLVMBuildNSWNeg(LLVMBuilderRef B, LLVMValueRef V, const char *Name)
Definition: Core.cpp:3409
LLVMValueRef LLVMBuildXor(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3393
LLVMValueRef LLVMBuildGlobalString(LLVMBuilderRef B, const char *Str, const char *Name)
Definition: Core.cpp:3656
LLVMBool LLVMGetExact(LLVMValueRef DivOrShrInst)
Definition: Core.cpp:3447
LLVMValueRef LLVMBuildIsNotNull(LLVMBuilderRef, LLVMValueRef Val, const char *Name)
Definition: Core.cpp:3935
void LLVMSetArgOperand(LLVMValueRef Funclet, unsigned i, LLVMValueRef value)
Definition: Core.cpp:3262
LLVMValueRef LLVMBuildMemCpy(LLVMBuilderRef B, LLVMValueRef Dst, unsigned DstAlign, LLVMValueRef Src, unsigned SrcAlign, LLVMValueRef Size)
Creates and inserts a memcpy between the specified pointers.
Definition: Core.cpp:3504
LLVMValueRef LLVMBuildPtrDiff2(LLVMBuilderRef, LLVMTypeRef ElemTy, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3940
void LLVMSetInstDebugLocation(LLVMBuilderRef Builder, LLVMValueRef Inst)
Attempts to set the debug location for the given instruction using the current debug location for the...
Definition: Core.cpp:3080
void LLVMAddMetadataToInst(LLVMBuilderRef Builder, LLVMValueRef Inst)
Adds the metadata registered with the given builder to the given instruction.
Definition: Core.cpp:3084
LLVMValueRef LLVMBuildSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3288
LLVMValueRef LLVMBuildNUWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name)
Definition: Core.cpp:3278
LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef)
Definition: Core.cpp:3200
LLVMValueRef LLVMBuildShuffleVector(LLVMBuilderRef, LLVMValueRef V1, LLVMValueRef V2, LLVMValueRef Mask, const char *Name)
Definition: Core.cpp:3906
void LLVMSetVolatile(LLVMValueRef MemoryAccessInst, LLVMBool IsVolatile)
Definition: Core.cpp:3677
LLVMValueRef LLVMBuildFree(LLVMBuilderRef, LLVMValueRef PointerVal)
Definition: Core.cpp:3532
LLVMValueRef LLVMBuildGEP2(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Pointer, LLVMValueRef *Indices, unsigned NumIndices, const char *Name)
Definition: Core.cpp:3634
unsigned LLVMGetNumHandlers(LLVMValueRef CatchSwitch)
Definition: Core.cpp:3237
LLVMValueRef LLVMBuildFPCast(LLVMBuilderRef, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name)
Definition: Core.cpp:3840
LLVMBuilderRef LLVMCreateBuilder(void)
Definition: Core.cpp:3013
void LLVMSetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst, LLVMAtomicOrdering Ordering)
Definition: Core.cpp:4020
LLVMValueRef LLVMBuildPhi(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name)
Definition: Core.cpp:3869
void LLVMAddCase(LLVMValueRef Switch, LLVMValueRef OnVal, LLVMBasicBlockRef Dest)
Definition: Core.cpp:3204
LLVMBool LLVMIsAtomicSingleThread(LLVMValueRef AtomicInst)
Definition: Core.cpp:3985
LLVMValueRef LLVMBuildResume(LLVMBuilderRef B, LLVMValueRef Exn)
Definition: Core.cpp:3173