LLVM 20.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 = 0, /**< type with no size */
150 LLVMHalfTypeKind = 1, /**< 16 bit floating point type */
151 LLVMFloatTypeKind = 2, /**< 32 bit floating point type */
152 LLVMDoubleTypeKind = 3, /**< 64 bit floating point type */
153 LLVMX86_FP80TypeKind = 4, /**< 80 bit floating point type (X87) */
154 LLVMFP128TypeKind = 5, /**< 128 bit floating point type (112-bit mantissa)*/
155 LLVMPPC_FP128TypeKind = 6, /**< 128 bit floating point type (two 64-bits) */
156 LLVMLabelTypeKind = 7, /**< Labels */
157 LLVMIntegerTypeKind = 8, /**< Arbitrary bit width integers */
158 LLVMFunctionTypeKind = 9, /**< Functions */
159 LLVMStructTypeKind = 10, /**< Structures */
160 LLVMArrayTypeKind = 11, /**< Arrays */
161 LLVMPointerTypeKind = 12, /**< Pointers */
162 LLVMVectorTypeKind = 13, /**< Fixed width SIMD vector type */
163 LLVMMetadataTypeKind = 14, /**< Metadata */
164 /* 15 previously used by LLVMX86_MMXTypeKind */
165 LLVMTokenTypeKind = 16, /**< Tokens */
166 LLVMScalableVectorTypeKind = 17, /**< Scalable SIMD vector type */
167 LLVMBFloatTypeKind = 18, /**< 16 bit brain floating point type */
168 LLVMX86_AMXTypeKind = 19, /**< X86 AMX */
169 LLVMTargetExtTypeKind = 20, /**< 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
291
292typedef enum {
293 LLVMIntEQ = 32, /**< equal */
294 LLVMIntNE, /**< not equal */
295 LLVMIntUGT, /**< unsigned greater than */
296 LLVMIntUGE, /**< unsigned greater or equal */
297 LLVMIntULT, /**< unsigned less than */
298 LLVMIntULE, /**< unsigned less or equal */
299 LLVMIntSGT, /**< signed greater than */
300 LLVMIntSGE, /**< signed greater or equal */
301 LLVMIntSLT, /**< signed less than */
302 LLVMIntSLE /**< signed less or equal */
304
305typedef enum {
306 LLVMRealPredicateFalse, /**< Always false (always folded) */
307 LLVMRealOEQ, /**< True if ordered and equal */
308 LLVMRealOGT, /**< True if ordered and greater than */
309 LLVMRealOGE, /**< True if ordered and greater than or equal */
310 LLVMRealOLT, /**< True if ordered and less than */
311 LLVMRealOLE, /**< True if ordered and less than or equal */
312 LLVMRealONE, /**< True if ordered and operands are unequal */
313 LLVMRealORD, /**< True if ordered (no nans) */
314 LLVMRealUNO, /**< True if unordered: isnan(X) | isnan(Y) */
315 LLVMRealUEQ, /**< True if unordered or equal */
316 LLVMRealUGT, /**< True if unordered or greater than */
317 LLVMRealUGE, /**< True if unordered, greater than, or equal */
318 LLVMRealULT, /**< True if unordered or less than */
319 LLVMRealULE, /**< True if unordered, less than, or equal */
320 LLVMRealUNE, /**< True if unordered or not equal */
321 LLVMRealPredicateTrue /**< Always true (always folded) */
323
324typedef enum {
325 LLVMLandingPadCatch, /**< A catch clause */
326 LLVMLandingPadFilter /**< A filter clause */
328
329typedef enum {
336
337typedef enum {
338 LLVMAtomicOrderingNotAtomic = 0, /**< A load or store which is not atomic */
339 LLVMAtomicOrderingUnordered = 1, /**< Lowest level of atomicity, guarantees
340 somewhat sane results, lock free. */
341 LLVMAtomicOrderingMonotonic = 2, /**< guarantees that if you take all the
342 operations affecting a specific address,
343 a consistent ordering exists */
344 LLVMAtomicOrderingAcquire = 4, /**< Acquire provides a barrier of the sort
345 necessary to acquire a lock to access other
346 memory with normal loads and stores. */
347 LLVMAtomicOrderingRelease = 5, /**< Release is similar to Acquire, but with
348 a barrier of the sort necessary to release
349 a lock. */
350 LLVMAtomicOrderingAcquireRelease = 6, /**< provides both an Acquire and a
351 Release barrier (for fences and
352 operations which both read and write
353 memory). */
354 LLVMAtomicOrderingSequentiallyConsistent = 7 /**< provides Acquire semantics
355 for loads and Release
356 semantics for stores.
357 Additionally, it guarantees
358 that a total ordering exists
359 between all
360 SequentiallyConsistent
361 operations. */
363
364typedef enum {
365 LLVMAtomicRMWBinOpXchg, /**< Set the new value and return the one old */
366 LLVMAtomicRMWBinOpAdd, /**< Add a value and return the old one */
367 LLVMAtomicRMWBinOpSub, /**< Subtract a value and return the old one */
368 LLVMAtomicRMWBinOpAnd, /**< And a value and return the old one */
369 LLVMAtomicRMWBinOpNand, /**< Not-And a value and return the old one */
370 LLVMAtomicRMWBinOpOr, /**< OR a value and return the old one */
371 LLVMAtomicRMWBinOpXor, /**< Xor a value and return the old one */
372 LLVMAtomicRMWBinOpMax, /**< Sets the value if it's greater than the
373 original using a signed comparison and return
374 the old one */
375 LLVMAtomicRMWBinOpMin, /**< Sets the value if it's Smaller than the
376 original using a signed comparison and return
377 the old one */
378 LLVMAtomicRMWBinOpUMax, /**< Sets the value if it's greater than the
379 original using an unsigned comparison and return
380 the old one */
381 LLVMAtomicRMWBinOpUMin, /**< Sets the value if it's greater than the
382 original using an unsigned comparison and return
383 the old one */
384 LLVMAtomicRMWBinOpFAdd, /**< Add a floating point value and return the
385 old one */
386 LLVMAtomicRMWBinOpFSub, /**< Subtract a floating point value and return the
387 old one */
388 LLVMAtomicRMWBinOpFMax, /**< Sets the value if it's greater than the
389 original using an floating point comparison and
390 return the old one */
391 LLVMAtomicRMWBinOpFMin, /**< Sets the value if it's smaller than the
392 original using an floating point comparison and
393 return the old one */
394 LLVMAtomicRMWBinOpUIncWrap, /**< Increments the value, wrapping back to zero
395 when incremented above input value */
396 LLVMAtomicRMWBinOpUDecWrap, /**< Decrements the value, wrapping back to
397 the input value when decremented below zero */
398 LLVMAtomicRMWBinOpUSubCond, /**<Subtracts the value only if no unsigned
399 overflow */
400 LLVMAtomicRMWBinOpUSubSat, /**<Subtracts the value, clamping to zero */
402
403typedef enum {
409
410typedef enum {
414
415typedef enum {
416 /**
417 * Emits an error if two values disagree, otherwise the resulting value is
418 * that of the operands.
419 *
420 * @see Module::ModFlagBehavior::Error
421 */
423 /**
424 * Emits a warning if two values disagree. The result value will be the
425 * operand for the flag from the first module being linked.
426 *
427 * @see Module::ModFlagBehavior::Warning
428 */
430 /**
431 * Adds a requirement that another module flag be present and have a
432 * specified value after linking is performed. The value must be a metadata
433 * pair, where the first element of the pair is the ID of the module flag
434 * to be restricted, and the second element of the pair is the value the
435 * module flag should be restricted to. This behavior can be used to
436 * restrict the allowable results (via triggering of an error) of linking
437 * IDs with the **Override** behavior.
438 *
439 * @see Module::ModFlagBehavior::Require
440 */
442 /**
443 * Uses the specified value, regardless of the behavior or value of the
444 * other module. If both modules specify **Override**, but the values
445 * differ, an error will be emitted.
446 *
447 * @see Module::ModFlagBehavior::Override
448 */
450 /**
451 * Appends the two values, which are required to be metadata nodes.
452 *
453 * @see Module::ModFlagBehavior::Append
454 */
456 /**
457 * Appends the two values, which are required to be metadata
458 * nodes. However, duplicate entries in the second list are dropped
459 * during the append operation.
460 *
461 * @see Module::ModFlagBehavior::AppendUnique
462 */
465
466/**
467 * Attribute index are either LLVMAttributeReturnIndex,
468 * LLVMAttributeFunctionIndex or a parameter number from 1 to N.
469 */
470enum {
472 // ISO C restricts enumerator values to range of 'int'
473 // (4294967295 is too large)
474 // LLVMAttributeFunctionIndex = ~0U,
476};
477
478typedef unsigned LLVMAttributeIndex;
479
480/**
481 * Tail call kind for LLVMSetTailCallKind and LLVMGetTailCallKind.
482 *
483 * Note that 'musttail' implies 'tail'.
484 *
485 * @see CallInst::TailCallKind
486 */
487typedef enum {
493
494enum {
507};
508
509/**
510 * Flags to indicate what fast-math-style optimizations are allowed
511 * on operations.
512 *
513 * See https://llvm.org/docs/LangRef.html#fast-math-flags
514 */
515typedef unsigned LLVMFastMathFlags;
516
517enum {
519 LLVMGEPFlagNUSW = (1 << 1),
520 LLVMGEPFlagNUW = (1 << 2),
521};
522
523/**
524 * Flags that constrain the allowed wrap semantics of a getelementptr
525 * instruction.
526 *
527 * See https://llvm.org/docs/LangRef.html#getelementptr-instruction
528 */
529typedef unsigned LLVMGEPNoWrapFlags;
530
531/**
532 * @}
533 */
534
535/** Deallocate and destroy all ManagedStatic variables.
536 @see llvm::llvm_shutdown
537 @see ManagedStatic */
538void LLVMShutdown(void);
539
540/*===-- Version query -----------------------------------------------------===*/
541
542/**
543 * Return the major, minor, and patch version of LLVM
544 *
545 * The version components are returned via the function's three output
546 * parameters or skipped if a NULL pointer was supplied.
547 */
548void LLVMGetVersion(unsigned *Major, unsigned *Minor, unsigned *Patch);
549
550/*===-- Error handling ----------------------------------------------------===*/
551
552char *LLVMCreateMessage(const char *Message);
553void LLVMDisposeMessage(char *Message);
554
555/**
556 * @defgroup LLVMCCoreContext Contexts
557 *
558 * Contexts are execution states for the core LLVM IR system.
559 *
560 * Most types are tied to a context instance. Multiple contexts can
561 * exist simultaneously. A single context is not thread safe. However,
562 * different contexts can execute on different threads simultaneously.
563 *
564 * @{
565 */
566
568typedef void (*LLVMYieldCallback)(LLVMContextRef, void *);
569
570/**
571 * Create a new context.
572 *
573 * Every call to this function should be paired with a call to
574 * LLVMContextDispose() or the context will leak memory.
575 */
577
578/**
579 * Obtain the global context instance.
580 */
582
583/**
584 * Set the diagnostic handler for this context.
585 */
587 LLVMDiagnosticHandler Handler,
588 void *DiagnosticContext);
589
590/**
591 * Get the diagnostic handler of this context.
592 */
594
595/**
596 * Get the diagnostic context of this context.
597 */
599
600/**
601 * Set the yield callback function for this context.
602 *
603 * @see LLVMContext::setYieldCallback()
604 */
606 void *OpaqueHandle);
607
608/**
609 * Retrieve whether the given context is set to discard all value names.
610 *
611 * @see LLVMContext::shouldDiscardValueNames()
612 */
614
615/**
616 * Set whether the given context discards all value names.
617 *
618 * If true, only the names of GlobalValue objects will be available in the IR.
619 * This can be used to save memory and runtime, especially in release mode.
620 *
621 * @see LLVMContext::setDiscardValueNames()
622 */
624
625/**
626 * Destroy a context instance.
627 *
628 * This should be called for every call to LLVMContextCreate() or memory
629 * will be leaked.
630 */
632
633/**
634 * Return a string representation of the DiagnosticInfo. Use
635 * LLVMDisposeMessage to free the string.
636 *
637 * @see DiagnosticInfo::print()
638 */
640
641/**
642 * Return an enum LLVMDiagnosticSeverity.
643 *
644 * @see DiagnosticInfo::getSeverity()
645 */
647
648unsigned LLVMGetMDKindIDInContext(LLVMContextRef C, const char *Name,
649 unsigned SLen);
650unsigned LLVMGetMDKindID(const char *Name, unsigned SLen);
651
652/**
653 * Maps a synchronization scope name to a ID unique within this context.
654 */
655unsigned LLVMGetSyncScopeID(LLVMContextRef C, const char *Name, size_t SLen);
656
657/**
658 * Return an unique id given the name of a enum attribute,
659 * or 0 if no attribute by that name exists.
660 *
661 * See http://llvm.org/docs/LangRef.html#parameter-attributes
662 * and http://llvm.org/docs/LangRef.html#function-attributes
663 * for the list of available attributes.
664 *
665 * NB: Attribute names and/or id are subject to change without
666 * going through the C API deprecation cycle.
667 */
668unsigned LLVMGetEnumAttributeKindForName(const char *Name, size_t SLen);
669unsigned LLVMGetLastEnumAttributeKind(void);
670
671/**
672 * Create an enum attribute.
673 */
675 uint64_t Val);
676
677/**
678 * Get the unique id corresponding to the enum attribute
679 * passed as argument.
680 */
682
683/**
684 * Get the enum attribute's value. 0 is returned if none exists.
685 */
687
688/**
689 * Create a type attribute
690 */
692 LLVMTypeRef type_ref);
693
694/**
695 * Get the type attribute's value.
696 */
698
699/**
700 * Create a ConstantRange attribute.
701 *
702 * LowerWords and UpperWords need to be NumBits divided by 64 rounded up
703 * elements long.
704 */
706 unsigned KindID,
707 unsigned NumBits,
708 const uint64_t LowerWords[],
709 const uint64_t UpperWords[]);
710
711/**
712 * Create a string attribute.
713 */
715 const char *K, unsigned KLength,
716 const char *V, unsigned VLength);
717
718/**
719 * Get the string attribute's kind.
720 */
721const char *LLVMGetStringAttributeKind(LLVMAttributeRef A, unsigned *Length);
722
723/**
724 * Get the string attribute's value.
725 */
726const char *LLVMGetStringAttributeValue(LLVMAttributeRef A, unsigned *Length);
727
728/**
729 * Check for the different types of attributes.
730 */
734
735/**
736 * Obtain a Type from a context by its registered name.
737 */
739
740/**
741 * @}
742 */
743
744/**
745 * @defgroup LLVMCCoreModule Modules
746 *
747 * Modules represent the top-level structure in an LLVM program. An LLVM
748 * module is effectively a translation unit or a collection of
749 * translation units merged together.
750 *
751 * @{
752 */
753
754/**
755 * Create a new, empty module in the global context.
756 *
757 * This is equivalent to calling LLVMModuleCreateWithNameInContext with
758 * LLVMGetGlobalContext() as the context parameter.
759 *
760 * Every invocation should be paired with LLVMDisposeModule() or memory
761 * will be leaked.
762 */
763LLVMModuleRef LLVMModuleCreateWithName(const char *ModuleID);
764
765/**
766 * Create a new, empty module in a specific context.
767 *
768 * Every invocation should be paired with LLVMDisposeModule() or memory
769 * will be leaked.
770 */
773/**
774 * Return an exact copy of the specified module.
775 */
777
778/**
779 * Destroy a module instance.
780 *
781 * This must be called for every created module or memory will be
782 * leaked.
783 */
785
786/**
787 * Soon to be deprecated.
788 * See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
789 *
790 * Returns true if the module is in the new debug info mode which uses
791 * non-instruction debug records instead of debug intrinsics for variable
792 * location tracking.
793 */
795
796/**
797 * Soon to be deprecated.
798 * See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
799 *
800 * Convert module into desired debug info format.
801 */
803
804/**
805 * Obtain the identifier of a module.
806 *
807 * @param M Module to obtain identifier of
808 * @param Len Out parameter which holds the length of the returned string.
809 * @return The identifier of M.
810 * @see Module::getModuleIdentifier()
811 */
812const char *LLVMGetModuleIdentifier(LLVMModuleRef M, size_t *Len);
813
814/**
815 * Set the identifier of a module to a string Ident with length Len.
816 *
817 * @param M The module to set identifier
818 * @param Ident The string to set M's identifier to
819 * @param Len Length of Ident
820 * @see Module::setModuleIdentifier()
821 */
822void LLVMSetModuleIdentifier(LLVMModuleRef M, const char *Ident, size_t Len);
823
824/**
825 * Obtain the module's original source file name.
826 *
827 * @param M Module to obtain the name of
828 * @param Len Out parameter which holds the length of the returned string
829 * @return The original source file name of M
830 * @see Module::getSourceFileName()
831 */
832const char *LLVMGetSourceFileName(LLVMModuleRef M, size_t *Len);
833
834/**
835 * Set the original source file name of a module to a string Name with length
836 * Len.
837 *
838 * @param M The module to set the source file name of
839 * @param Name The string to set M's source file name to
840 * @param Len Length of Name
841 * @see Module::setSourceFileName()
842 */
843void LLVMSetSourceFileName(LLVMModuleRef M, const char *Name, size_t Len);
844
845/**
846 * Obtain the data layout for a module.
847 *
848 * @see Module::getDataLayoutStr()
849 *
850 * LLVMGetDataLayout is DEPRECATED, as the name is not only incorrect,
851 * but match the name of another method on the module. Prefer the use
852 * of LLVMGetDataLayoutStr, which is not ambiguous.
853 */
855const char *LLVMGetDataLayout(LLVMModuleRef M);
856
857/**
858 * Set the data layout for a module.
859 *
860 * @see Module::setDataLayout()
861 */
862void LLVMSetDataLayout(LLVMModuleRef M, const char *DataLayoutStr);
863
864/**
865 * Obtain the target triple for a module.
866 *
867 * @see Module::getTargetTriple()
868 */
869const char *LLVMGetTarget(LLVMModuleRef M);
870
871/**
872 * Set the target triple for a module.
873 *
874 * @see Module::setTargetTriple()
875 */
876void LLVMSetTarget(LLVMModuleRef M, const char *Triple);
877
878/**
879 * Returns the module flags as an array of flag-key-value triples. The caller
880 * is responsible for freeing this array by calling
881 * \c LLVMDisposeModuleFlagsMetadata.
882 *
883 * @see Module::getModuleFlagsMetadata()
884 */
886
887/**
888 * Destroys module flags metadata entries.
889 */
891
892/**
893 * Returns the flag behavior for a module flag entry at a specific index.
894 *
895 * @see Module::ModuleFlagEntry::Behavior
896 */
899 unsigned Index);
900
901/**
902 * Returns the key for a module flag entry at a specific index.
903 *
904 * @see Module::ModuleFlagEntry::Key
905 */
907 unsigned Index, size_t *Len);
908
909/**
910 * Returns the metadata for a module flag entry at a specific index.
911 *
912 * @see Module::ModuleFlagEntry::Val
913 */
915 unsigned Index);
916
917/**
918 * Add a module-level flag to the module-level flags metadata if it doesn't
919 * already exist.
920 *
921 * @see Module::getModuleFlag()
922 */
924 const char *Key, size_t KeyLen);
925
926/**
927 * Add a module-level flag to the module-level flags metadata if it doesn't
928 * already exist.
929 *
930 * @see Module::addModuleFlag()
931 */
933 const char *Key, size_t KeyLen,
934 LLVMMetadataRef Val);
935
936/**
937 * Dump a representation of a module to stderr.
938 *
939 * @see Module::dump()
940 */
942
943/**
944 * Print a representation of a module to a file. The ErrorMessage needs to be
945 * disposed with LLVMDisposeMessage. Returns 0 on success, 1 otherwise.
946 *
947 * @see Module::print()
948 */
949LLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename,
950 char **ErrorMessage);
951
952/**
953 * Return a string representation of the module. Use
954 * LLVMDisposeMessage to free the string.
955 *
956 * @see Module::print()
957 */
959
960/**
961 * Get inline assembly for a module.
962 *
963 * @see Module::getModuleInlineAsm()
964 */
965const char *LLVMGetModuleInlineAsm(LLVMModuleRef M, size_t *Len);
966
967/**
968 * Set inline assembly for a module.
969 *
970 * @see Module::setModuleInlineAsm()
971 */
972void LLVMSetModuleInlineAsm2(LLVMModuleRef M, const char *Asm, size_t Len);
973
974/**
975 * Append inline assembly to a module.
976 *
977 * @see Module::appendModuleInlineAsm()
978 */
979void LLVMAppendModuleInlineAsm(LLVMModuleRef M, const char *Asm, size_t Len);
980
981/**
982 * Create the specified uniqued inline asm string.
983 *
984 * @see InlineAsm::get()
985 */
986LLVMValueRef LLVMGetInlineAsm(LLVMTypeRef Ty, const char *AsmString,
987 size_t AsmStringSize, const char *Constraints,
988 size_t ConstraintsSize, LLVMBool HasSideEffects,
989 LLVMBool IsAlignStack,
990 LLVMInlineAsmDialect Dialect, LLVMBool CanThrow);
991
992/**
993 * Get the template string used for an inline assembly snippet
994 *
995 */
996const char *LLVMGetInlineAsmAsmString(LLVMValueRef InlineAsmVal, size_t *Len);
997
998/**
999 * Get the raw constraint string for an inline assembly snippet
1000 *
1001 */
1002const char *LLVMGetInlineAsmConstraintString(LLVMValueRef InlineAsmVal,
1003 size_t *Len);
1004
1005/**
1006 * Get the dialect used by the inline asm snippet
1007 *
1008 */
1010
1011/**
1012 * Get the function type of the inline assembly snippet. The same type that
1013 * was passed into LLVMGetInlineAsm originally
1014 *
1015 * @see LLVMGetInlineAsm
1016 *
1017 */
1019
1020/**
1021 * Get if the inline asm snippet has side effects
1022 *
1023 */
1025
1026/**
1027 * Get if the inline asm snippet needs an aligned stack
1028 *
1029 */
1031
1032/**
1033 * Get if the inline asm snippet may unwind the stack
1034 *
1035 */
1037
1038/**
1039 * Obtain the context to which this module is associated.
1040 *
1041 * @see Module::getContext()
1042 */
1044
1045/** Deprecated: Use LLVMGetTypeByName2 instead. */
1047
1048/**
1049 * Obtain an iterator to the first NamedMDNode in a Module.
1050 *
1051 * @see llvm::Module::named_metadata_begin()
1052 */
1054
1055/**
1056 * Obtain an iterator to the last NamedMDNode in a Module.
1057 *
1058 * @see llvm::Module::named_metadata_end()
1059 */
1061
1062/**
1063 * Advance a NamedMDNode iterator to the next NamedMDNode.
1064 *
1065 * Returns NULL if the iterator was already at the end and there are no more
1066 * named metadata nodes.
1067 */
1069
1070/**
1071 * Decrement a NamedMDNode iterator to the previous NamedMDNode.
1072 *
1073 * Returns NULL if the iterator was already at the beginning and there are
1074 * no previous named metadata nodes.
1075 */
1077
1078/**
1079 * Retrieve a NamedMDNode with the given name, returning NULL if no such
1080 * node exists.
1081 *
1082 * @see llvm::Module::getNamedMetadata()
1083 */
1085 const char *Name, size_t NameLen);
1086
1087/**
1088 * Retrieve a NamedMDNode with the given name, creating a new node if no such
1089 * node exists.
1090 *
1091 * @see llvm::Module::getOrInsertNamedMetadata()
1092 */
1094 const char *Name,
1095 size_t NameLen);
1096
1097/**
1098 * Retrieve the name of a NamedMDNode.
1099 *
1100 * @see llvm::NamedMDNode::getName()
1101 */
1103 size_t *NameLen);
1104
1105/**
1106 * Obtain the number of operands for named metadata in a module.
1107 *
1108 * @see llvm::Module::getNamedMetadata()
1109 */
1110unsigned LLVMGetNamedMetadataNumOperands(LLVMModuleRef M, const char *Name);
1111
1112/**
1113 * Obtain the named metadata operands for a module.
1114 *
1115 * The passed LLVMValueRef pointer should refer to an array of
1116 * LLVMValueRef at least LLVMGetNamedMetadataNumOperands long. This
1117 * array will be populated with the LLVMValueRef instances. Each
1118 * instance corresponds to a llvm::MDNode.
1119 *
1120 * @see llvm::Module::getNamedMetadata()
1121 * @see llvm::MDNode::getOperand()
1122 */
1124 LLVMValueRef *Dest);
1125
1126/**
1127 * Add an operand to named metadata.
1128 *
1129 * @see llvm::Module::getNamedMetadata()
1130 * @see llvm::MDNode::addOperand()
1131 */
1133 LLVMValueRef Val);
1134
1135/**
1136 * Return the directory of the debug location for this value, which must be
1137 * an llvm::Instruction, llvm::GlobalVariable, or llvm::Function.
1138 *
1139 * @see llvm::Instruction::getDebugLoc()
1140 * @see llvm::GlobalVariable::getDebugInfo()
1141 * @see llvm::Function::getSubprogram()
1142 */
1143const char *LLVMGetDebugLocDirectory(LLVMValueRef Val, unsigned *Length);
1144
1145/**
1146 * Return the filename of the debug location for this value, which must be
1147 * an llvm::Instruction, llvm::GlobalVariable, or llvm::Function.
1148 *
1149 * @see llvm::Instruction::getDebugLoc()
1150 * @see llvm::GlobalVariable::getDebugInfo()
1151 * @see llvm::Function::getSubprogram()
1152 */
1153const char *LLVMGetDebugLocFilename(LLVMValueRef Val, unsigned *Length);
1154
1155/**
1156 * Return the line number of the debug location for this value, which must be
1157 * an llvm::Instruction, llvm::GlobalVariable, or llvm::Function.
1158 *
1159 * @see llvm::Instruction::getDebugLoc()
1160 * @see llvm::GlobalVariable::getDebugInfo()
1161 * @see llvm::Function::getSubprogram()
1162 */
1163unsigned LLVMGetDebugLocLine(LLVMValueRef Val);
1164
1165/**
1166 * Return the column number of the debug location for this value, which must be
1167 * an llvm::Instruction.
1168 *
1169 * @see llvm::Instruction::getDebugLoc()
1170 */
1172
1173/**
1174 * Add a function to a module under a specified name.
1175 *
1176 * @see llvm::Function::Create()
1177 */
1179 LLVMTypeRef FunctionTy);
1180
1181/**
1182 * Obtain a Function value from a Module by its name.
1183 *
1184 * The returned value corresponds to a llvm::Function value.
1185 *
1186 * @see llvm::Module::getFunction()
1187 */
1189
1190/**
1191 * Obtain a Function value from a Module by its name.
1192 *
1193 * The returned value corresponds to a llvm::Function value.
1194 *
1195 * @see llvm::Module::getFunction()
1196 */
1198 size_t Length);
1199
1200/**
1201 * Obtain an iterator to the first Function in a Module.
1202 *
1203 * @see llvm::Module::begin()
1204 */
1206
1207/**
1208 * Obtain an iterator to the last Function in a Module.
1209 *
1210 * @see llvm::Module::end()
1211 */
1213
1214/**
1215 * Advance a Function iterator to the next Function.
1216 *
1217 * Returns NULL if the iterator was already at the end and there are no more
1218 * functions.
1219 */
1221
1222/**
1223 * Decrement a Function iterator to the previous Function.
1224 *
1225 * Returns NULL if the iterator was already at the beginning and there are
1226 * no previous functions.
1227 */
1229
1230/** Deprecated: Use LLVMSetModuleInlineAsm2 instead. */
1231void LLVMSetModuleInlineAsm(LLVMModuleRef M, const char *Asm);
1232
1233/**
1234 * @}
1235 */
1236
1237/**
1238 * @defgroup LLVMCCoreType Types
1239 *
1240 * Types represent the type of a value.
1241 *
1242 * Types are associated with a context instance. The context internally
1243 * deduplicates types so there is only 1 instance of a specific type
1244 * alive at a time. In other words, a unique type is shared among all
1245 * consumers within a context.
1246 *
1247 * A Type in the C API corresponds to llvm::Type.
1248 *
1249 * Types have the following hierarchy:
1250 *
1251 * types:
1252 * integer type
1253 * real type
1254 * function type
1255 * sequence types:
1256 * array type
1257 * pointer type
1258 * vector type
1259 * void type
1260 * label type
1261 * opaque type
1262 *
1263 * @{
1264 */
1265
1266/**
1267 * Obtain the enumerated type of a Type instance.
1268 *
1269 * @see llvm::Type:getTypeID()
1270 */
1272
1273/**
1274 * Whether the type has a known size.
1275 *
1276 * Things that don't have a size are abstract types, labels, and void.a
1277 *
1278 * @see llvm::Type::isSized()
1279 */
1281
1282/**
1283 * Obtain the context to which this type instance is associated.
1284 *
1285 * @see llvm::Type::getContext()
1286 */
1288
1289/**
1290 * Dump a representation of a type to stderr.
1291 *
1292 * @see llvm::Type::dump()
1293 */
1294void LLVMDumpType(LLVMTypeRef Val);
1295
1296/**
1297 * Return a string representation of the type. Use
1298 * LLVMDisposeMessage to free the string.
1299 *
1300 * @see llvm::Type::print()
1301 */
1303
1304/**
1305 * @defgroup LLVMCCoreTypeInt Integer Types
1306 *
1307 * Functions in this section operate on integer types.
1308 *
1309 * @{
1310 */
1311
1312/**
1313 * Obtain an integer type from a context with specified bit width.
1314 */
1322
1323/**
1324 * Obtain an integer type from the global context with a specified bit
1325 * width.
1326 */
1333LLVMTypeRef LLVMIntType(unsigned NumBits);
1334unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy);
1335
1336/**
1337 * @}
1338 */
1339
1340/**
1341 * @defgroup LLVMCCoreTypeFloat Floating Point Types
1342 *
1343 * @{
1344 */
1345
1346/**
1347 * Obtain a 16-bit floating point type from a context.
1348 */
1350
1351/**
1352 * Obtain a 16-bit brain floating point type from a context.
1353 */
1355
1356/**
1357 * Obtain a 32-bit floating point type from a context.
1358 */
1360
1361/**
1362 * Obtain a 64-bit floating point type from a context.
1363 */
1365
1366/**
1367 * Obtain a 80-bit floating point type (X87) from a context.
1368 */
1370
1371/**
1372 * Obtain a 128-bit floating point type (112-bit mantissa) from a
1373 * context.
1374 */
1376
1377/**
1378 * Obtain a 128-bit floating point type (two 64-bits) from a context.
1379 */
1381
1382/**
1383 * Obtain a floating point type from the global context.
1384 *
1385 * These map to the functions in this group of the same name.
1386 */
1394
1395/**
1396 * @}
1397 */
1398
1399/**
1400 * @defgroup LLVMCCoreTypeFunction Function Types
1401 *
1402 * @{
1403 */
1404
1405/**
1406 * Obtain a function type consisting of a specified signature.
1407 *
1408 * The function is defined as a tuple of a return Type, a list of
1409 * parameter types, and whether the function is variadic.
1410 */
1412 LLVMTypeRef *ParamTypes, unsigned ParamCount,
1413 LLVMBool IsVarArg);
1414
1415/**
1416 * Returns whether a function type is variadic.
1417 */
1419
1420/**
1421 * Obtain the Type this function Type returns.
1422 */
1424
1425/**
1426 * Obtain the number of parameters this function accepts.
1427 */
1428unsigned LLVMCountParamTypes(LLVMTypeRef FunctionTy);
1429
1430/**
1431 * Obtain the types of a function's parameters.
1432 *
1433 * The Dest parameter should point to a pre-allocated array of
1434 * LLVMTypeRef at least LLVMCountParamTypes() large. On return, the
1435 * first LLVMCountParamTypes() entries in the array will be populated
1436 * with LLVMTypeRef instances.
1437 *
1438 * @param FunctionTy The function type to operate on.
1439 * @param Dest Memory address of an array to be filled with result.
1440 */
1441void LLVMGetParamTypes(LLVMTypeRef FunctionTy, LLVMTypeRef *Dest);
1442
1443/**
1444 * @}
1445 */
1446
1447/**
1448 * @defgroup LLVMCCoreTypeStruct Structure Types
1449 *
1450 * These functions relate to LLVMTypeRef instances.
1451 *
1452 * @see llvm::StructType
1453 *
1454 * @{
1455 */
1456
1457/**
1458 * Create a new structure type in a context.
1459 *
1460 * A structure is specified by a list of inner elements/types and
1461 * whether these can be packed together.
1462 *
1463 * @see llvm::StructType::create()
1464 */
1466 unsigned ElementCount, LLVMBool Packed);
1467
1468/**
1469 * Create a new structure type in the global context.
1470 *
1471 * @see llvm::StructType::create()
1472 */
1473LLVMTypeRef LLVMStructType(LLVMTypeRef *ElementTypes, unsigned ElementCount,
1474 LLVMBool Packed);
1475
1476/**
1477 * Create an empty structure in a context having a specified name.
1478 *
1479 * @see llvm::StructType::create()
1480 */
1482
1483/**
1484 * Obtain the name of a structure.
1485 *
1486 * @see llvm::StructType::getName()
1487 */
1488const char *LLVMGetStructName(LLVMTypeRef Ty);
1489
1490/**
1491 * Set the contents of a structure type.
1492 *
1493 * @see llvm::StructType::setBody()
1494 */
1495void LLVMStructSetBody(LLVMTypeRef StructTy, LLVMTypeRef *ElementTypes,
1496 unsigned ElementCount, LLVMBool Packed);
1497
1498/**
1499 * Get the number of elements defined inside the structure.
1500 *
1501 * @see llvm::StructType::getNumElements()
1502 */
1503unsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy);
1504
1505/**
1506 * Get the elements within a structure.
1507 *
1508 * The function is passed the address of a pre-allocated array of
1509 * LLVMTypeRef at least LLVMCountStructElementTypes() long. After
1510 * invocation, this array will be populated with the structure's
1511 * elements. The objects in the destination array will have a lifetime
1512 * of the structure type itself, which is the lifetime of the context it
1513 * is contained in.
1514 */
1516
1517/**
1518 * Get the type of the element at a given index in the structure.
1519 *
1520 * @see llvm::StructType::getTypeAtIndex()
1521 */
1523
1524/**
1525 * Determine whether a structure is packed.
1526 *
1527 * @see llvm::StructType::isPacked()
1528 */
1530
1531/**
1532 * Determine whether a structure is opaque.
1533 *
1534 * @see llvm::StructType::isOpaque()
1535 */
1537
1538/**
1539 * Determine whether a structure is literal.
1540 *
1541 * @see llvm::StructType::isLiteral()
1542 */
1544
1545/**
1546 * @}
1547 */
1548
1549/**
1550 * @defgroup LLVMCCoreTypeSequential Sequential Types
1551 *
1552 * Sequential types represents "arrays" of types. This is a super class
1553 * for array, vector, and pointer types.
1554 *
1555 * @{
1556 */
1557
1558/**
1559 * Obtain the element type of an array or vector type.
1560 *
1561 * @see llvm::SequentialType::getElementType()
1562 */
1564
1565/**
1566 * Returns type's subtypes
1567 *
1568 * @see llvm::Type::subtypes()
1569 */
1571
1572/**
1573 * Return the number of types in the derived type.
1574 *
1575 * @see llvm::Type::getNumContainedTypes()
1576 */
1578
1579/**
1580 * Create a fixed size array type that refers to a specific type.
1581 *
1582 * The created type will exist in the context that its element type
1583 * exists in.
1584 *
1585 * @deprecated LLVMArrayType is deprecated in favor of the API accurate
1586 * LLVMArrayType2
1587 * @see llvm::ArrayType::get()
1588 */
1589LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount);
1590
1591/**
1592 * Create a fixed size array type that refers to a specific type.
1593 *
1594 * The created type will exist in the context that its element type
1595 * exists in.
1596 *
1597 * @see llvm::ArrayType::get()
1598 */
1599LLVMTypeRef LLVMArrayType2(LLVMTypeRef ElementType, uint64_t ElementCount);
1600
1601/**
1602 * Obtain the length of an array type.
1603 *
1604 * This only works on types that represent arrays.
1605 *
1606 * @deprecated LLVMGetArrayLength is deprecated in favor of the API accurate
1607 * LLVMGetArrayLength2
1608 * @see llvm::ArrayType::getNumElements()
1609 */
1610unsigned LLVMGetArrayLength(LLVMTypeRef ArrayTy);
1611
1612/**
1613 * Obtain the length of an array type.
1614 *
1615 * This only works on types that represent arrays.
1616 *
1617 * @see llvm::ArrayType::getNumElements()
1618 */
1620
1621/**
1622 * Create a pointer type that points to a defined type.
1623 *
1624 * The created type will exist in the context that its pointee type
1625 * exists in.
1626 *
1627 * @see llvm::PointerType::get()
1628 */
1629LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, unsigned AddressSpace);
1630
1631/**
1632 * Determine whether a pointer is opaque.
1633 *
1634 * True if this is an instance of an opaque PointerType.
1635 *
1636 * @see llvm::Type::isOpaquePointerTy()
1637 */
1639
1640/**
1641 * Create an opaque pointer type in a context.
1642 *
1643 * @see llvm::PointerType::get()
1644 */
1646
1647/**
1648 * Obtain the address space of a pointer type.
1649 *
1650 * This only works on types that represent pointers.
1651 *
1652 * @see llvm::PointerType::getAddressSpace()
1653 */
1654unsigned LLVMGetPointerAddressSpace(LLVMTypeRef PointerTy);
1655
1656/**
1657 * Create a vector type that contains a defined type and has a specific
1658 * number of elements.
1659 *
1660 * The created type will exist in the context thats its element type
1661 * exists in.
1662 *
1663 * @see llvm::VectorType::get()
1664 */
1665LLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType, unsigned ElementCount);
1666
1667/**
1668 * Create a vector type that contains a defined type and has a scalable
1669 * number of elements.
1670 *
1671 * The created type will exist in the context thats its element type
1672 * exists in.
1673 *
1674 * @see llvm::ScalableVectorType::get()
1675 */
1677 unsigned ElementCount);
1678
1679/**
1680 * Obtain the (possibly scalable) number of elements in a vector type.
1681 *
1682 * This only works on types that represent vectors (fixed or scalable).
1683 *
1684 * @see llvm::VectorType::getNumElements()
1685 */
1686unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy);
1687
1688/**
1689 * Get the pointer value for the associated ConstantPtrAuth constant.
1690 *
1691 * @see llvm::ConstantPtrAuth::getPointer
1692 */
1694
1695/**
1696 * Get the key value for the associated ConstantPtrAuth constant.
1697 *
1698 * @see llvm::ConstantPtrAuth::getKey
1699 */
1701
1702/**
1703 * Get the discriminator value for the associated ConstantPtrAuth constant.
1704 *
1705 * @see llvm::ConstantPtrAuth::getDiscriminator
1706 */
1708
1709/**
1710 * Get the address discriminator value for the associated ConstantPtrAuth
1711 * constant.
1712 *
1713 * @see llvm::ConstantPtrAuth::getAddrDiscriminator
1714 */
1716
1717/**
1718 * @}
1719 */
1720
1721/**
1722 * @defgroup LLVMCCoreTypeOther Other Types
1723 *
1724 * @{
1725 */
1726
1727/**
1728 * Create a void type in a context.
1729 */
1731
1732/**
1733 * Create a label type in a context.
1734 */
1736
1737/**
1738 * Create a X86 AMX type in a context.
1739 */
1741
1742/**
1743 * Create a token type in a context.
1744 */
1746
1747/**
1748 * Create a metadata type in a context.
1749 */
1751
1752/**
1753 * These are similar to the above functions except they operate on the
1754 * global context.
1755 */
1759
1760/**
1761 * Create a target extension type in LLVM context.
1762 */
1764 LLVMTypeRef *TypeParams,
1765 unsigned TypeParamCount,
1766 unsigned *IntParams,
1767 unsigned IntParamCount);
1768
1769/**
1770 * Obtain the name for this target extension type.
1771 *
1772 * @see llvm::TargetExtType::getName()
1773 */
1774const char *LLVMGetTargetExtTypeName(LLVMTypeRef TargetExtTy);
1775
1776/**
1777 * Obtain the number of type parameters for this target extension type.
1778 *
1779 * @see llvm::TargetExtType::getNumTypeParameters()
1780 */
1782
1783/**
1784 * Get the type parameter at the given index for the target extension type.
1785 *
1786 * @see llvm::TargetExtType::getTypeParameter()
1787 */
1789 unsigned Idx);
1790
1791/**
1792 * Obtain the number of int parameters for this target extension type.
1793 *
1794 * @see llvm::TargetExtType::getNumIntParameters()
1795 */
1796unsigned LLVMGetTargetExtTypeNumIntParams(LLVMTypeRef TargetExtTy);
1797
1798/**
1799 * Get the int parameter at the given index for the target extension type.
1800 *
1801 * @see llvm::TargetExtType::getIntParameter()
1802 */
1803unsigned LLVMGetTargetExtTypeIntParam(LLVMTypeRef TargetExtTy, unsigned Idx);
1804
1805/**
1806 * @}
1807 */
1808
1809/**
1810 * @}
1811 */
1812
1813/**
1814 * @defgroup LLVMCCoreValues Values
1815 *
1816 * The bulk of LLVM's object model consists of values, which comprise a very
1817 * rich type hierarchy.
1818 *
1819 * LLVMValueRef essentially represents llvm::Value. There is a rich
1820 * hierarchy of classes within this type. Depending on the instance
1821 * obtained, not all APIs are available.
1822 *
1823 * Callers can determine the type of an LLVMValueRef by calling the
1824 * LLVMIsA* family of functions (e.g. LLVMIsAArgument()). These
1825 * functions are defined by a macro, so it isn't obvious which are
1826 * available by looking at the Doxygen source code. Instead, look at the
1827 * source definition of LLVM_FOR_EACH_VALUE_SUBCLASS and note the list
1828 * of value names given. These value names also correspond to classes in
1829 * the llvm::Value hierarchy.
1830 *
1831 * @{
1832 */
1833
1834// Currently, clang-format tries to format the LLVM_FOR_EACH_VALUE_SUBCLASS
1835// macro in a progressively-indented fashion, which is not desired
1836// clang-format off
1837
1838#define LLVM_FOR_EACH_VALUE_SUBCLASS(macro) \
1839 macro(Argument) \
1840 macro(BasicBlock) \
1841 macro(InlineAsm) \
1842 macro(User) \
1843 macro(Constant) \
1844 macro(BlockAddress) \
1845 macro(ConstantAggregateZero) \
1846 macro(ConstantArray) \
1847 macro(ConstantDataSequential) \
1848 macro(ConstantDataArray) \
1849 macro(ConstantDataVector) \
1850 macro(ConstantExpr) \
1851 macro(ConstantFP) \
1852 macro(ConstantInt) \
1853 macro(ConstantPointerNull) \
1854 macro(ConstantStruct) \
1855 macro(ConstantTokenNone) \
1856 macro(ConstantVector) \
1857 macro(ConstantPtrAuth) \
1858 macro(GlobalValue) \
1859 macro(GlobalAlias) \
1860 macro(GlobalObject) \
1861 macro(Function) \
1862 macro(GlobalVariable) \
1863 macro(GlobalIFunc) \
1864 macro(UndefValue) \
1865 macro(PoisonValue) \
1866 macro(Instruction) \
1867 macro(UnaryOperator) \
1868 macro(BinaryOperator) \
1869 macro(CallInst) \
1870 macro(IntrinsicInst) \
1871 macro(DbgInfoIntrinsic) \
1872 macro(DbgVariableIntrinsic) \
1873 macro(DbgDeclareInst) \
1874 macro(DbgLabelInst) \
1875 macro(MemIntrinsic) \
1876 macro(MemCpyInst) \
1877 macro(MemMoveInst) \
1878 macro(MemSetInst) \
1879 macro(CmpInst) \
1880 macro(FCmpInst) \
1881 macro(ICmpInst) \
1882 macro(ExtractElementInst) \
1883 macro(GetElementPtrInst) \
1884 macro(InsertElementInst) \
1885 macro(InsertValueInst) \
1886 macro(LandingPadInst) \
1887 macro(PHINode) \
1888 macro(SelectInst) \
1889 macro(ShuffleVectorInst) \
1890 macro(StoreInst) \
1891 macro(BranchInst) \
1892 macro(IndirectBrInst) \
1893 macro(InvokeInst) \
1894 macro(ReturnInst) \
1895 macro(SwitchInst) \
1896 macro(UnreachableInst) \
1897 macro(ResumeInst) \
1898 macro(CleanupReturnInst) \
1899 macro(CatchReturnInst) \
1900 macro(CatchSwitchInst) \
1901 macro(CallBrInst) \
1902 macro(FuncletPadInst) \
1903 macro(CatchPadInst) \
1904 macro(CleanupPadInst) \
1905 macro(UnaryInstruction) \
1906 macro(AllocaInst) \
1907 macro(CastInst) \
1908 macro(AddrSpaceCastInst) \
1909 macro(BitCastInst) \
1910 macro(FPExtInst) \
1911 macro(FPToSIInst) \
1912 macro(FPToUIInst) \
1913 macro(FPTruncInst) \
1914 macro(IntToPtrInst) \
1915 macro(PtrToIntInst) \
1916 macro(SExtInst) \
1917 macro(SIToFPInst) \
1918 macro(TruncInst) \
1919 macro(UIToFPInst) \
1920 macro(ZExtInst) \
1921 macro(ExtractValueInst) \
1922 macro(LoadInst) \
1923 macro(VAArgInst) \
1924 macro(FreezeInst) \
1925 macro(AtomicCmpXchgInst) \
1926 macro(AtomicRMWInst) \
1927 macro(FenceInst)
1928
1929// clang-format on
1930
1931/**
1932 * @defgroup LLVMCCoreValueGeneral General APIs
1933 *
1934 * Functions in this section work on all LLVMValueRef instances,
1935 * regardless of their sub-type. They correspond to functions available
1936 * on llvm::Value.
1937 *
1938 * @{
1939 */
1940
1941/**
1942 * Obtain the type of a value.
1943 *
1944 * @see llvm::Value::getType()
1945 */
1947
1948/**
1949 * Obtain the enumerated type of a Value instance.
1950 *
1951 * @see llvm::Value::getValueID()
1952 */
1954
1955/**
1956 * Obtain the string name of a value.
1957 *
1958 * @see llvm::Value::getName()
1959 */
1960const char *LLVMGetValueName2(LLVMValueRef Val, size_t *Length);
1961
1962/**
1963 * Set the string name of a value.
1964 *
1965 * @see llvm::Value::setName()
1966 */
1967void LLVMSetValueName2(LLVMValueRef Val, const char *Name, size_t NameLen);
1968
1969/**
1970 * Dump a representation of a value to stderr.
1971 *
1972 * @see llvm::Value::dump()
1973 */
1974void LLVMDumpValue(LLVMValueRef Val);
1975
1976/**
1977 * Return a string representation of the value. Use
1978 * LLVMDisposeMessage to free the string.
1979 *
1980 * @see llvm::Value::print()
1981 */
1983
1984/**
1985 * Obtain the context to which this value is associated.
1986 *
1987 * @see llvm::Value::getContext()
1988 */
1990
1991/**
1992 * Return a string representation of the DbgRecord. Use
1993 * LLVMDisposeMessage to free the string.
1994 *
1995 * @see llvm::DbgRecord::print()
1996 */
1998
1999/**
2000 * Replace all uses of a value with another one.
2001 *
2002 * @see llvm::Value::replaceAllUsesWith()
2003 */
2005
2006/**
2007 * Determine whether the specified value instance is constant.
2008 */
2010
2011/**
2012 * Determine whether a value instance is undefined.
2013 */
2015
2016/**
2017 * Determine whether a value instance is poisonous.
2018 */
2020
2021/**
2022 * Convert value instances between types.
2023 *
2024 * Internally, an LLVMValueRef is "pinned" to a specific type. This
2025 * series of functions allows you to cast an instance to a specific
2026 * type.
2027 *
2028 * If the cast is not valid for the specified type, NULL is returned.
2029 *
2030 * @see llvm::dyn_cast_or_null<>
2031 */
2032#define LLVM_DECLARE_VALUE_CAST(name) \
2033 LLVMValueRef LLVMIsA##name(LLVMValueRef Val);
2035
2039
2040/** Deprecated: Use LLVMGetValueName2 instead. */
2041const char *LLVMGetValueName(LLVMValueRef Val);
2042/** Deprecated: Use LLVMSetValueName2 instead. */
2043void LLVMSetValueName(LLVMValueRef Val, const char *Name);
2044
2045/**
2046 * @}
2047 */
2048
2049/**
2050 * @defgroup LLVMCCoreValueUses Usage
2051 *
2052 * This module defines functions that allow you to inspect the uses of a
2053 * LLVMValueRef.
2054 *
2055 * It is possible to obtain an LLVMUseRef for any LLVMValueRef instance.
2056 * Each LLVMUseRef (which corresponds to a llvm::Use instance) holds a
2057 * llvm::User and llvm::Value.
2058 *
2059 * @{
2060 */
2061
2062/**
2063 * Obtain the first use of a value.
2064 *
2065 * Uses are obtained in an iterator fashion. First, call this function
2066 * to obtain a reference to the first use. Then, call LLVMGetNextUse()
2067 * on that instance and all subsequently obtained instances until
2068 * LLVMGetNextUse() returns NULL.
2069 *
2070 * @see llvm::Value::use_begin()
2071 */
2073
2074/**
2075 * Obtain the next use of a value.
2076 *
2077 * This effectively advances the iterator. It returns NULL if you are on
2078 * the final use and no more are available.
2079 */
2081
2082/**
2083 * Obtain the user value for a user.
2084 *
2085 * The returned value corresponds to a llvm::User type.
2086 *
2087 * @see llvm::Use::getUser()
2088 */
2090
2091/**
2092 * Obtain the value this use corresponds to.
2093 *
2094 * @see llvm::Use::get().
2095 */
2097
2098/**
2099 * @}
2100 */
2101
2102/**
2103 * @defgroup LLVMCCoreValueUser User value
2104 *
2105 * Function in this group pertain to LLVMValueRef instances that descent
2106 * from llvm::User. This includes constants, instructions, and
2107 * operators.
2108 *
2109 * @{
2110 */
2111
2112/**
2113 * Obtain an operand at a specific index in a llvm::User value.
2114 *
2115 * @see llvm::User::getOperand()
2116 */
2118
2119/**
2120 * Obtain the use of an operand at a specific index in a llvm::User value.
2121 *
2122 * @see llvm::User::getOperandUse()
2123 */
2125
2126/**
2127 * Set an operand at a specific index in a llvm::User value.
2128 *
2129 * @see llvm::User::setOperand()
2130 */
2131void LLVMSetOperand(LLVMValueRef User, unsigned Index, LLVMValueRef Val);
2132
2133/**
2134 * Obtain the number of operands in a llvm::User value.
2135 *
2136 * @see llvm::User::getNumOperands()
2137 */
2139
2140/**
2141 * @}
2142 */
2143
2144/**
2145 * @defgroup LLVMCCoreValueConstant Constants
2146 *
2147 * This section contains APIs for interacting with LLVMValueRef that
2148 * correspond to llvm::Constant instances.
2149 *
2150 * These functions will work for any LLVMValueRef in the llvm::Constant
2151 * class hierarchy.
2152 *
2153 * @{
2154 */
2155
2156/**
2157 * Obtain a constant value referring to the null instance of a type.
2158 *
2159 * @see llvm::Constant::getNullValue()
2160 */
2161LLVMValueRef LLVMConstNull(LLVMTypeRef Ty); /* all zeroes */
2162
2163/**
2164 * Obtain a constant value referring to the instance of a type
2165 * consisting of all ones.
2166 *
2167 * This is only valid for integer types.
2168 *
2169 * @see llvm::Constant::getAllOnesValue()
2170 */
2172
2173/**
2174 * Obtain a constant value referring to an undefined value of a type.
2175 *
2176 * @see llvm::UndefValue::get()
2177 */
2179
2180/**
2181 * Obtain a constant value referring to a poison value of a type.
2182 *
2183 * @see llvm::PoisonValue::get()
2184 */
2186
2187/**
2188 * Determine whether a value instance is null.
2189 *
2190 * @see llvm::Constant::isNullValue()
2191 */
2193
2194/**
2195 * Obtain a constant that is a constant pointer pointing to NULL for a
2196 * specified type.
2197 */
2199
2200/**
2201 * @defgroup LLVMCCoreValueConstantScalar Scalar constants
2202 *
2203 * Functions in this group model LLVMValueRef instances that correspond
2204 * to constants referring to scalar types.
2205 *
2206 * For integer types, the LLVMTypeRef parameter should correspond to a
2207 * llvm::IntegerType instance and the returned LLVMValueRef will
2208 * correspond to a llvm::ConstantInt.
2209 *
2210 * For floating point types, the LLVMTypeRef returned corresponds to a
2211 * llvm::ConstantFP.
2212 *
2213 * @{
2214 */
2215
2216/**
2217 * Obtain a constant value for an integer type.
2218 *
2219 * The returned value corresponds to a llvm::ConstantInt.
2220 *
2221 * @see llvm::ConstantInt::get()
2222 *
2223 * @param IntTy Integer type to obtain value of.
2224 * @param N The value the returned instance should refer to.
2225 * @param SignExtend Whether to sign extend the produced value.
2226 */
2227LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N,
2228 LLVMBool SignExtend);
2229
2230/**
2231 * Obtain a constant value for an integer of arbitrary precision.
2232 *
2233 * @see llvm::ConstantInt::get()
2234 */
2236 unsigned NumWords,
2237 const uint64_t Words[]);
2238
2239/**
2240 * Obtain a constant value for an integer parsed from a string.
2241 *
2242 * A similar API, LLVMConstIntOfStringAndSize is also available. If the
2243 * string's length is available, it is preferred to call that function
2244 * instead.
2245 *
2246 * @see llvm::ConstantInt::get()
2247 */
2249 uint8_t Radix);
2250
2251/**
2252 * Obtain a constant value for an integer parsed from a string with
2253 * specified length.
2254 *
2255 * @see llvm::ConstantInt::get()
2256 */
2258 unsigned SLen, uint8_t Radix);
2259
2260/**
2261 * Obtain a constant value referring to a double floating point value.
2262 */
2263LLVMValueRef LLVMConstReal(LLVMTypeRef RealTy, double N);
2264
2265/**
2266 * Obtain a constant for a floating point value parsed from a string.
2267 *
2268 * A similar API, LLVMConstRealOfStringAndSize is also available. It
2269 * should be used if the input string's length is known.
2270 */
2271LLVMValueRef LLVMConstRealOfString(LLVMTypeRef RealTy, const char *Text);
2272
2273/**
2274 * Obtain a constant for a floating point value parsed from a string.
2275 */
2277 unsigned SLen);
2278
2279/**
2280 * Obtain the zero extended value for an integer constant value.
2281 *
2282 * @see llvm::ConstantInt::getZExtValue()
2283 */
2284unsigned long long LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal);
2285
2286/**
2287 * Obtain the sign extended value for an integer constant value.
2288 *
2289 * @see llvm::ConstantInt::getSExtValue()
2290 */
2291long long LLVMConstIntGetSExtValue(LLVMValueRef ConstantVal);
2292
2293/**
2294 * Obtain the double value for an floating point constant value.
2295 * losesInfo indicates if some precision was lost in the conversion.
2296 *
2297 * @see llvm::ConstantFP::getDoubleValue
2298 */
2299double LLVMConstRealGetDouble(LLVMValueRef ConstantVal, LLVMBool *losesInfo);
2300
2301/**
2302 * @}
2303 */
2304
2305/**
2306 * @defgroup LLVMCCoreValueConstantComposite Composite Constants
2307 *
2308 * Functions in this group operate on composite constants.
2309 *
2310 * @{
2311 */
2312
2313/**
2314 * Create a ConstantDataSequential and initialize it with a string.
2315 *
2316 * @deprecated LLVMConstStringInContext is deprecated in favor of the API
2317 * accurate LLVMConstStringInContext2
2318 * @see llvm::ConstantDataArray::getString()
2319 */
2321 unsigned Length, LLVMBool DontNullTerminate);
2322
2323/**
2324 * Create a ConstantDataSequential and initialize it with a string.
2325 *
2326 * @see llvm::ConstantDataArray::getString()
2327 */
2329 size_t Length,
2330 LLVMBool DontNullTerminate);
2331
2332/**
2333 * Create a ConstantDataSequential with string content in the global context.
2334 *
2335 * This is the same as LLVMConstStringInContext except it operates on the
2336 * global context.
2337 *
2338 * @see LLVMConstStringInContext()
2339 * @see llvm::ConstantDataArray::getString()
2340 */
2341LLVMValueRef LLVMConstString(const char *Str, unsigned Length,
2342 LLVMBool DontNullTerminate);
2343
2344/**
2345 * Returns true if the specified constant is an array of i8.
2346 *
2347 * @see ConstantDataSequential::getAsString()
2348 */
2350
2351/**
2352 * Get the given constant data sequential as a string.
2353 *
2354 * @see ConstantDataSequential::getAsString()
2355 */
2356const char *LLVMGetAsString(LLVMValueRef c, size_t *Length);
2357
2358/**
2359 * Create an anonymous ConstantStruct with the specified values.
2360 *
2361 * @see llvm::ConstantStruct::getAnon()
2362 */
2364 LLVMValueRef *ConstantVals,
2365 unsigned Count, LLVMBool Packed);
2366
2367/**
2368 * Create a ConstantStruct in the global Context.
2369 *
2370 * This is the same as LLVMConstStructInContext except it operates on the
2371 * global Context.
2372 *
2373 * @see LLVMConstStructInContext()
2374 */
2375LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count,
2376 LLVMBool Packed);
2377
2378/**
2379 * Create a ConstantArray from values.
2380 *
2381 * @deprecated LLVMConstArray is deprecated in favor of the API accurate
2382 * LLVMConstArray2
2383 * @see llvm::ConstantArray::get()
2384 */
2386 LLVMValueRef *ConstantVals, unsigned Length);
2387
2388/**
2389 * Create a ConstantArray from values.
2390 *
2391 * @see llvm::ConstantArray::get()
2392 */
2393LLVMValueRef LLVMConstArray2(LLVMTypeRef ElementTy, LLVMValueRef *ConstantVals,
2394 uint64_t Length);
2395
2396/**
2397 * Create a non-anonymous ConstantStruct from values.
2398 *
2399 * @see llvm::ConstantStruct::get()
2400 */
2402 LLVMValueRef *ConstantVals,
2403 unsigned Count);
2404
2405/**
2406 * Get element of a constant aggregate (struct, array or vector) at the
2407 * specified index. Returns null if the index is out of range, or it's not
2408 * possible to determine the element (e.g., because the constant is a
2409 * constant expression.)
2410 *
2411 * @see llvm::Constant::getAggregateElement()
2412 */
2414
2415/**
2416 * Get an element at specified index as a constant.
2417 *
2418 * @see ConstantDataSequential::getElementAsConstant()
2419 */
2422 "Use LLVMGetAggregateElement instead");
2423
2424/**
2425 * Create a ConstantVector from values.
2426 *
2427 * @see llvm::ConstantVector::get()
2428 */
2429LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size);
2430
2431/**
2432 * Create a ConstantPtrAuth constant with the given values.
2433 *
2434 * @see llvm::ConstantPtrAuth::get()
2435 */
2437 LLVMValueRef Disc, LLVMValueRef AddrDisc);
2438
2439/**
2440 * @}
2441 */
2442
2443/**
2444 * @defgroup LLVMCCoreValueConstantExpressions Constant Expressions
2445 *
2446 * Functions in this group correspond to APIs on llvm::ConstantExpr.
2447 *
2448 * @see llvm::ConstantExpr.
2449 *
2450 * @{
2451 */
2459 "Use LLVMConstNull instead.");
2461LLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2462LLVMValueRef LLVMConstNSWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2463LLVMValueRef LLVMConstNUWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2464LLVMValueRef LLVMConstSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2465LLVMValueRef LLVMConstNSWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2466LLVMValueRef LLVMConstNUWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2467LLVMValueRef LLVMConstMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2468LLVMValueRef LLVMConstNSWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2469LLVMValueRef LLVMConstNUWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2470LLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2472 LLVMValueRef *ConstantIndices, unsigned NumIndices);
2474 LLVMValueRef *ConstantIndices,
2475 unsigned NumIndices);
2476/**
2477 * Creates a constant GetElementPtr expression. Similar to LLVMConstGEP2, but
2478 * allows specifying the no-wrap flags.
2479 *
2480 * @see llvm::ConstantExpr::getGetElementPtr()
2481 */
2483 LLVMValueRef ConstantVal,
2484 LLVMValueRef *ConstantIndices,
2485 unsigned NumIndices,
2486 LLVMGEPNoWrapFlags NoWrapFlags);
2493 LLVMTypeRef ToType);
2495 LLVMTypeRef ToType);
2497 LLVMValueRef IndexConstant);
2499 LLVMValueRef ElementValueConstant,
2500 LLVMValueRef IndexConstant);
2502 LLVMValueRef VectorBConstant,
2503 LLVMValueRef MaskConstant);
2505
2506/**
2507 * Gets the function associated with a given BlockAddress constant value.
2508 */
2510
2511/**
2512 * Gets the basic block associated with a given BlockAddress constant value.
2513 */
2515
2516/** Deprecated: Use LLVMGetInlineAsm instead. */
2518 const char *AsmString, const char *Constraints,
2519 LLVMBool HasSideEffects, LLVMBool IsAlignStack);
2520
2521/**
2522 * @}
2523 */
2524
2525/**
2526 * @defgroup LLVMCCoreValueConstantGlobals Global Values
2527 *
2528 * This group contains functions that operate on global values. Functions in
2529 * this group relate to functions in the llvm::GlobalValue class tree.
2530 *
2531 * @see llvm::GlobalValue
2532 *
2533 * @{
2534 */
2535
2540const char *LLVMGetSection(LLVMValueRef Global);
2541void LLVMSetSection(LLVMValueRef Global, const char *Section);
2547void LLVMSetUnnamedAddress(LLVMValueRef Global, LLVMUnnamedAddr UnnamedAddr);
2548
2549/**
2550 * Returns the "value type" of a global value. This differs from the formal
2551 * type of a global value which is always a pointer type.
2552 *
2553 * @see llvm::GlobalValue::getValueType()
2554 */
2556
2557/** Deprecated: Use LLVMGetUnnamedAddress instead. */
2559/** Deprecated: Use LLVMSetUnnamedAddress instead. */
2560void LLVMSetUnnamedAddr(LLVMValueRef Global, LLVMBool HasUnnamedAddr);
2561
2562/**
2563 * @defgroup LLVMCCoreValueWithAlignment Values with alignment
2564 *
2565 * Functions in this group only apply to values with alignment, i.e.
2566 * global variables, load and store instructions.
2567 */
2568
2569/**
2570 * Obtain the preferred alignment of the value.
2571 * @see llvm::AllocaInst::getAlignment()
2572 * @see llvm::LoadInst::getAlignment()
2573 * @see llvm::StoreInst::getAlignment()
2574 * @see llvm::AtomicRMWInst::setAlignment()
2575 * @see llvm::AtomicCmpXchgInst::setAlignment()
2576 * @see llvm::GlobalValue::getAlignment()
2577 */
2578unsigned LLVMGetAlignment(LLVMValueRef V);
2579
2580/**
2581 * Set the preferred alignment of the value.
2582 * @see llvm::AllocaInst::setAlignment()
2583 * @see llvm::LoadInst::setAlignment()
2584 * @see llvm::StoreInst::setAlignment()
2585 * @see llvm::AtomicRMWInst::setAlignment()
2586 * @see llvm::AtomicCmpXchgInst::setAlignment()
2587 * @see llvm::GlobalValue::setAlignment()
2588 */
2589void LLVMSetAlignment(LLVMValueRef V, unsigned Bytes);
2590
2591/**
2592 * Sets a metadata attachment, erasing the existing metadata attachment if
2593 * it already exists for the given kind.
2594 *
2595 * @see llvm::GlobalObject::setMetadata()
2596 */
2597void LLVMGlobalSetMetadata(LLVMValueRef Global, unsigned Kind,
2598 LLVMMetadataRef MD);
2599
2600/**
2601 * Erases a metadata attachment of the given kind if it exists.
2602 *
2603 * @see llvm::GlobalObject::eraseMetadata()
2604 */
2605void LLVMGlobalEraseMetadata(LLVMValueRef Global, unsigned Kind);
2606
2607/**
2608 * Removes all metadata attachments from this value.
2609 *
2610 * @see llvm::GlobalObject::clearMetadata()
2611 */
2613
2614/**
2615 * Retrieves an array of metadata entries representing the metadata attached to
2616 * this value. The caller is responsible for freeing this array by calling
2617 * \c LLVMDisposeValueMetadataEntries.
2618 *
2619 * @see llvm::GlobalObject::getAllMetadata()
2620 */
2622 size_t *NumEntries);
2623
2624/**
2625 * Destroys value metadata entries.
2626 */
2628
2629/**
2630 * Returns the kind of a value metadata entry at a specific index.
2631 */
2633 unsigned Index);
2634
2635/**
2636 * Returns the underlying metadata node of a value metadata entry at a
2637 * specific index.
2638 */
2641 unsigned Index);
2642
2643/**
2644 * @}
2645 */
2646
2647/**
2648 * @defgroup LLVMCoreValueConstantGlobalVariable Global Variables
2649 *
2650 * This group contains functions that operate on global variable values.
2651 *
2652 * @see llvm::GlobalVariable
2653 *
2654 * @{
2655 */
2658 const char *Name,
2659 unsigned AddressSpace);
2662 size_t Length);
2667void LLVMDeleteGlobal(LLVMValueRef GlobalVar);
2669void LLVMSetInitializer(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal);
2671void LLVMSetThreadLocal(LLVMValueRef GlobalVar, LLVMBool IsThreadLocal);
2673void LLVMSetGlobalConstant(LLVMValueRef GlobalVar, LLVMBool IsConstant);
2677void LLVMSetExternallyInitialized(LLVMValueRef GlobalVar, LLVMBool IsExtInit);
2678
2679/**
2680 * @}
2681 */
2682
2683/**
2684 * @defgroup LLVMCoreValueConstantGlobalAlias Global Aliases
2685 *
2686 * This group contains function that operate on global alias values.
2687 *
2688 * @see llvm::GlobalAlias
2689 *
2690 * @{
2691 */
2692
2693/**
2694 * Add a GlobalAlias with the given value type, address space and aliasee.
2695 *
2696 * @see llvm::GlobalAlias::create()
2697 */
2699 unsigned AddrSpace, LLVMValueRef Aliasee,
2700 const char *Name);
2701
2702/**
2703 * Obtain a GlobalAlias value from a Module by its name.
2704 *
2705 * The returned value corresponds to a llvm::GlobalAlias value.
2706 *
2707 * @see llvm::Module::getNamedAlias()
2708 */
2710 const char *Name, size_t NameLen);
2711
2712/**
2713 * Obtain an iterator to the first GlobalAlias in a Module.
2714 *
2715 * @see llvm::Module::alias_begin()
2716 */
2718
2719/**
2720 * Obtain an iterator to the last GlobalAlias in a Module.
2721 *
2722 * @see llvm::Module::alias_end()
2723 */
2725
2726/**
2727 * Advance a GlobalAlias iterator to the next GlobalAlias.
2728 *
2729 * Returns NULL if the iterator was already at the end and there are no more
2730 * global aliases.
2731 */
2733
2734/**
2735 * Decrement a GlobalAlias iterator to the previous GlobalAlias.
2736 *
2737 * Returns NULL if the iterator was already at the beginning and there are
2738 * no previous global aliases.
2739 */
2741
2742/**
2743 * Retrieve the target value of an alias.
2744 */
2746
2747/**
2748 * Set the target value of an alias.
2749 */
2750void LLVMAliasSetAliasee(LLVMValueRef Alias, LLVMValueRef Aliasee);
2751
2752/**
2753 * @}
2754 */
2755
2756/**
2757 * @defgroup LLVMCCoreValueFunction Function values
2758 *
2759 * Functions in this group operate on LLVMValueRef instances that
2760 * correspond to llvm::Function instances.
2761 *
2762 * @see llvm::Function
2763 *
2764 * @{
2765 */
2766
2767/**
2768 * Remove a function from its containing module and deletes it.
2769 *
2770 * @see llvm::Function::eraseFromParent()
2771 */
2773
2774/**
2775 * Check whether the given function has a personality function.
2776 *
2777 * @see llvm::Function::hasPersonalityFn()
2778 */
2780
2781/**
2782 * Obtain the personality function attached to the function.
2783 *
2784 * @see llvm::Function::getPersonalityFn()
2785 */
2787
2788/**
2789 * Set the personality function attached to the function.
2790 *
2791 * @see llvm::Function::setPersonalityFn()
2792 */
2793void LLVMSetPersonalityFn(LLVMValueRef Fn, LLVMValueRef PersonalityFn);
2794
2795/**
2796 * Obtain the intrinsic ID number which matches the given function name.
2797 *
2798 * @see llvm::Intrinsic::lookupIntrinsicID()
2799 */
2800unsigned LLVMLookupIntrinsicID(const char *Name, size_t NameLen);
2801
2802/**
2803 * Obtain the ID number from a function instance.
2804 *
2805 * @see llvm::Function::getIntrinsicID()
2806 */
2807unsigned LLVMGetIntrinsicID(LLVMValueRef Fn);
2808
2809/**
2810 * Get or insert the declaration of an intrinsic. For overloaded intrinsics,
2811 * parameter types must be provided to uniquely identify an overload.
2812 *
2813 * @see llvm::Intrinsic::getOrInsertDeclaration()
2814 */
2816 unsigned ID,
2817 LLVMTypeRef *ParamTypes,
2818 size_t ParamCount);
2819
2820/**
2821 * Retrieves the type of an intrinsic. For overloaded intrinsics, parameter
2822 * types must be provided to uniquely identify an overload.
2823 *
2824 * @see llvm::Intrinsic::getType()
2825 */
2827 LLVMTypeRef *ParamTypes, size_t ParamCount);
2828
2829/**
2830 * Retrieves the name of an intrinsic.
2831 *
2832 * @see llvm::Intrinsic::getName()
2833 */
2834const char *LLVMIntrinsicGetName(unsigned ID, size_t *NameLength);
2835
2836/** Deprecated: Use LLVMIntrinsicCopyOverloadedName2 instead. */
2837char *LLVMIntrinsicCopyOverloadedName(unsigned ID, LLVMTypeRef *ParamTypes,
2838 size_t ParamCount, size_t *NameLength);
2839
2840/**
2841 * Copies the name of an overloaded intrinsic identified by a given list of
2842 * parameter types.
2843 *
2844 * Unlike LLVMIntrinsicGetName, the caller is responsible for freeing the
2845 * returned string.
2846 *
2847 * This version also supports unnamed types.
2848 *
2849 * @see llvm::Intrinsic::getName()
2850 */
2852 LLVMTypeRef *ParamTypes,
2853 size_t ParamCount, size_t *NameLength);
2854
2855/**
2856 * Obtain if the intrinsic identified by the given ID is overloaded.
2857 *
2858 * @see llvm::Intrinsic::isOverloaded()
2859 */
2861
2862/**
2863 * Obtain the calling function of a function.
2864 *
2865 * The returned value corresponds to the LLVMCallConv enumeration.
2866 *
2867 * @see llvm::Function::getCallingConv()
2868 */
2870
2871/**
2872 * Set the calling convention of a function.
2873 *
2874 * @see llvm::Function::setCallingConv()
2875 *
2876 * @param Fn Function to operate on
2877 * @param CC LLVMCallConv to set calling convention to
2878 */
2879void LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC);
2880
2881/**
2882 * Obtain the name of the garbage collector to use during code
2883 * generation.
2884 *
2885 * @see llvm::Function::getGC()
2886 */
2887const char *LLVMGetGC(LLVMValueRef Fn);
2888
2889/**
2890 * Define the garbage collector to use during code generation.
2891 *
2892 * @see llvm::Function::setGC()
2893 */
2894void LLVMSetGC(LLVMValueRef Fn, const char *Name);
2895
2896/**
2897 * Gets the prefix data associated with a function. Only valid on functions, and
2898 * only if LLVMHasPrefixData returns true.
2899 * See https://llvm.org/docs/LangRef.html#prefix-data
2900 */
2902
2903/**
2904 * Check if a given function has prefix data. Only valid on functions.
2905 * See https://llvm.org/docs/LangRef.html#prefix-data
2906 */
2908
2909/**
2910 * Sets the prefix data for the function. Only valid on functions.
2911 * See https://llvm.org/docs/LangRef.html#prefix-data
2912 */
2913void LLVMSetPrefixData(LLVMValueRef Fn, LLVMValueRef prefixData);
2914
2915/**
2916 * Gets the prologue data associated with a function. Only valid on functions,
2917 * and only if LLVMHasPrologueData returns true.
2918 * See https://llvm.org/docs/LangRef.html#prologue-data
2919 */
2921
2922/**
2923 * Check if a given function has prologue data. Only valid on functions.
2924 * See https://llvm.org/docs/LangRef.html#prologue-data
2925 */
2927
2928/**
2929 * Sets the prologue data for the function. Only valid on functions.
2930 * See https://llvm.org/docs/LangRef.html#prologue-data
2931 */
2932void LLVMSetPrologueData(LLVMValueRef Fn, LLVMValueRef prologueData);
2933
2934/**
2935 * Add an attribute to a function.
2936 *
2937 * @see llvm::Function::addAttribute()
2938 */
2943 LLVMAttributeRef *Attrs);
2946 unsigned KindID);
2949 const char *K, unsigned KLen);
2951 unsigned KindID);
2953 const char *K, unsigned KLen);
2954
2955/**
2956 * Add a target-dependent attribute to a function
2957 * @see llvm::AttrBuilder::addAttribute()
2958 */
2960 const char *V);
2961
2962/**
2963 * @defgroup LLVMCCoreValueFunctionParameters Function Parameters
2964 *
2965 * Functions in this group relate to arguments/parameters on functions.
2966 *
2967 * Functions in this group expect LLVMValueRef instances that correspond
2968 * to llvm::Function instances.
2969 *
2970 * @{
2971 */
2972
2973/**
2974 * Obtain the number of parameters in a function.
2975 *
2976 * @see llvm::Function::arg_size()
2977 */
2978unsigned LLVMCountParams(LLVMValueRef Fn);
2979
2980/**
2981 * Obtain the parameters in a function.
2982 *
2983 * The takes a pointer to a pre-allocated array of LLVMValueRef that is
2984 * at least LLVMCountParams() long. This array will be filled with
2985 * LLVMValueRef instances which correspond to the parameters the
2986 * function receives. Each LLVMValueRef corresponds to a llvm::Argument
2987 * instance.
2988 *
2989 * @see llvm::Function::arg_begin()
2990 */
2991void LLVMGetParams(LLVMValueRef Fn, LLVMValueRef *Params);
2992
2993/**
2994 * Obtain the parameter at the specified index.
2995 *
2996 * Parameters are indexed from 0.
2997 *
2998 * @see llvm::Function::arg_begin()
2999 */
3001
3002/**
3003 * Obtain the function to which this argument belongs.
3004 *
3005 * Unlike other functions in this group, this one takes an LLVMValueRef
3006 * that corresponds to a llvm::Attribute.
3007 *
3008 * The returned LLVMValueRef is the llvm::Function to which this
3009 * argument belongs.
3010 */
3012
3013/**
3014 * Obtain the first parameter to a function.
3015 *
3016 * @see llvm::Function::arg_begin()
3017 */
3019
3020/**
3021 * Obtain the last parameter to a function.
3022 *
3023 * @see llvm::Function::arg_end()
3024 */
3026
3027/**
3028 * Obtain the next parameter to a function.
3029 *
3030 * This takes an LLVMValueRef obtained from LLVMGetFirstParam() (which is
3031 * actually a wrapped iterator) and obtains the next parameter from the
3032 * underlying iterator.
3033 */
3035
3036/**
3037 * Obtain the previous parameter to a function.
3038 *
3039 * This is the opposite of LLVMGetNextParam().
3040 */
3042
3043/**
3044 * Set the alignment for a function parameter.
3045 *
3046 * @see llvm::Argument::addAttr()
3047 * @see llvm::AttrBuilder::addAlignmentAttr()
3048 */
3049void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned Align);
3050
3051/**
3052 * @}
3053 */
3054
3055/**
3056 * @defgroup LLVMCCoreValueGlobalIFunc IFuncs
3057 *
3058 * Functions in this group relate to indirect functions.
3059 *
3060 * Functions in this group expect LLVMValueRef instances that correspond
3061 * to llvm::GlobalIFunc instances.
3062 *
3063 * @{
3064 */
3065
3066/**
3067 * Add a global indirect function to a module under a specified name.
3068 *
3069 * @see llvm::GlobalIFunc::create()
3070 */
3072 const char *Name, size_t NameLen,
3073 LLVMTypeRef Ty, unsigned AddrSpace,
3074 LLVMValueRef Resolver);
3075
3076/**
3077 * Obtain a GlobalIFunc value from a Module by its name.
3078 *
3079 * The returned value corresponds to a llvm::GlobalIFunc value.
3080 *
3081 * @see llvm::Module::getNamedIFunc()
3082 */
3084 const char *Name, size_t NameLen);
3085
3086/**
3087 * Obtain an iterator to the first GlobalIFunc in a Module.
3088 *
3089 * @see llvm::Module::ifunc_begin()
3090 */
3092
3093/**
3094 * Obtain an iterator to the last GlobalIFunc in a Module.
3095 *
3096 * @see llvm::Module::ifunc_end()
3097 */
3099
3100/**
3101 * Advance a GlobalIFunc iterator to the next GlobalIFunc.
3102 *
3103 * Returns NULL if the iterator was already at the end and there are no more
3104 * global aliases.
3105 */
3107
3108/**
3109 * Decrement a GlobalIFunc iterator to the previous GlobalIFunc.
3110 *
3111 * Returns NULL if the iterator was already at the beginning and there are
3112 * no previous global aliases.
3113 */
3115
3116/**
3117 * Retrieves the resolver function associated with this indirect function, or
3118 * NULL if it doesn't not exist.
3119 *
3120 * @see llvm::GlobalIFunc::getResolver()
3121 */
3123
3124/**
3125 * Sets the resolver function associated with this indirect function.
3126 *
3127 * @see llvm::GlobalIFunc::setResolver()
3128 */
3130
3131/**
3132 * Remove a global indirect function from its parent module and delete it.
3133 *
3134 * @see llvm::GlobalIFunc::eraseFromParent()
3135 */
3137
3138/**
3139 * Remove a global indirect function from its parent module.
3140 *
3141 * This unlinks the global indirect function from its containing module but
3142 * keeps it alive.
3143 *
3144 * @see llvm::GlobalIFunc::removeFromParent()
3145 */
3147
3148/**
3149 * @}
3150 */
3151
3152/**
3153 * @}
3154 */
3155
3156/**
3157 * @}
3158 */
3159
3160/**
3161 * @}
3162 */
3163
3164/**
3165 * @defgroup LLVMCCoreValueMetadata Metadata
3166 *
3167 * @{
3168 */
3169
3170/**
3171 * Create an MDString value from a given string value.
3172 *
3173 * The MDString value does not take ownership of the given string, it remains
3174 * the responsibility of the caller to free it.
3175 *
3176 * @see llvm::MDString::get()
3177 */
3179 size_t SLen);
3180
3181/**
3182 * Create an MDNode value with the given array of operands.
3183 *
3184 * @see llvm::MDNode::get()
3185 */
3187 size_t Count);
3188
3189/**
3190 * Obtain a Metadata as a Value.
3191 */
3193
3194/**
3195 * Obtain a Value as a Metadata.
3196 */
3198
3199/**
3200 * Obtain the underlying string from a MDString value.
3201 *
3202 * @param V Instance to obtain string from.
3203 * @param Length Memory address which will hold length of returned string.
3204 * @return String data in MDString.
3205 */
3206const char *LLVMGetMDString(LLVMValueRef V, unsigned *Length);
3207
3208/**
3209 * Obtain the number of operands from an MDNode value.
3210 *
3211 * @param V MDNode to get number of operands from.
3212 * @return Number of operands of the MDNode.
3213 */
3215
3216/**
3217 * Obtain the given MDNode's operands.
3218 *
3219 * The passed LLVMValueRef pointer should point to enough memory to hold all of
3220 * the operands of the given MDNode (see LLVMGetMDNodeNumOperands) as
3221 * LLVMValueRefs. This memory will be populated with the LLVMValueRefs of the
3222 * MDNode's operands.
3223 *
3224 * @param V MDNode to get the operands from.
3225 * @param Dest Destination array for operands.
3226 */
3228
3229/**
3230 * Replace an operand at a specific index in a llvm::MDNode value.
3231 *
3232 * @see llvm::MDNode::replaceOperandWith()
3233 */
3235 LLVMMetadataRef Replacement);
3236
3237/** Deprecated: Use LLVMMDStringInContext2 instead. */
3239 unsigned SLen);
3240/** Deprecated: Use LLVMMDStringInContext2 instead. */
3241LLVMValueRef LLVMMDString(const char *Str, unsigned SLen);
3242/** Deprecated: Use LLVMMDNodeInContext2 instead. */
3244 unsigned Count);
3245/** Deprecated: Use LLVMMDNodeInContext2 instead. */
3246LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count);
3247
3248/**
3249 * @}
3250 */
3251
3252/**
3253 * @defgroup LLVMCCoreOperandBundle Operand Bundles
3254 *
3255 * Functions in this group operate on LLVMOperandBundleRef instances that
3256 * correspond to llvm::OperandBundleDef instances.
3257 *
3258 * @see llvm::OperandBundleDef
3259 *
3260 * @{
3261 */
3262
3263/**
3264 * Create a new operand bundle.
3265 *
3266 * Every invocation should be paired with LLVMDisposeOperandBundle() or memory
3267 * will be leaked.
3268 *
3269 * @param Tag Tag name of the operand bundle
3270 * @param TagLen Length of Tag
3271 * @param Args Memory address of an array of bundle operands
3272 * @param NumArgs Length of Args
3273 */
3274LLVMOperandBundleRef LLVMCreateOperandBundle(const char *Tag, size_t TagLen,
3275 LLVMValueRef *Args,
3276 unsigned NumArgs);
3277
3278/**
3279 * Destroy an operand bundle.
3280 *
3281 * This must be called for every created operand bundle or memory will be
3282 * leaked.
3283 */
3285
3286/**
3287 * Obtain the tag of an operand bundle as a string.
3288 *
3289 * @param Bundle Operand bundle to obtain tag of.
3290 * @param Len Out parameter which holds the length of the returned string.
3291 * @return The tag name of Bundle.
3292 * @see OperandBundleDef::getTag()
3293 */
3294const char *LLVMGetOperandBundleTag(LLVMOperandBundleRef Bundle, size_t *Len);
3295
3296/**
3297 * Obtain the number of operands for an operand bundle.
3298 *
3299 * @param Bundle Operand bundle to obtain operand count of.
3300 * @return The number of operands.
3301 * @see OperandBundleDef::input_size()
3302 */
3304
3305/**
3306 * Obtain the operand for an operand bundle at the given index.
3307 *
3308 * @param Bundle Operand bundle to obtain operand of.
3309 * @param Index An operand index, must be less than
3310 * LLVMGetNumOperandBundleArgs().
3311 * @return The operand.
3312 */
3314 unsigned Index);
3315
3316/**
3317 * @}
3318 */
3319
3320/**
3321 * @defgroup LLVMCCoreValueBasicBlock Basic Block
3322 *
3323 * A basic block represents a single entry single exit section of code.
3324 * Basic blocks contain a list of instructions which form the body of
3325 * the block.
3326 *
3327 * Basic blocks belong to functions. They have the type of label.
3328 *
3329 * Basic blocks are themselves values. However, the C API models them as
3330 * LLVMBasicBlockRef.
3331 *
3332 * @see llvm::BasicBlock
3333 *
3334 * @{
3335 */
3336
3337/**
3338 * Convert a basic block instance to a value type.
3339 */
3341
3342/**
3343 * Determine whether an LLVMValueRef is itself a basic block.
3344 */
3346
3347/**
3348 * Convert an LLVMValueRef to an LLVMBasicBlockRef instance.
3349 */
3351
3352/**
3353 * Obtain the string name of a basic block.
3354 */
3356
3357/**
3358 * Obtain the function to which a basic block belongs.
3359 *
3360 * @see llvm::BasicBlock::getParent()
3361 */
3363
3364/**
3365 * Obtain the terminator instruction for a basic block.
3366 *
3367 * If the basic block does not have a terminator (it is not well-formed
3368 * if it doesn't), then NULL is returned.
3369 *
3370 * The returned LLVMValueRef corresponds to an llvm::Instruction.
3371 *
3372 * @see llvm::BasicBlock::getTerminator()
3373 */
3375
3376/**
3377 * Obtain the number of basic blocks in a function.
3378 *
3379 * @param Fn Function value to operate on.
3380 */
3382
3383/**
3384 * Obtain all of the basic blocks in a function.
3385 *
3386 * This operates on a function value. The BasicBlocks parameter is a
3387 * pointer to a pre-allocated array of LLVMBasicBlockRef of at least
3388 * LLVMCountBasicBlocks() in length. This array is populated with
3389 * LLVMBasicBlockRef instances.
3390 */
3392
3393/**
3394 * Obtain the first basic block in a function.
3395 *
3396 * The returned basic block can be used as an iterator. You will likely
3397 * eventually call into LLVMGetNextBasicBlock() with it.
3398 *
3399 * @see llvm::Function::begin()
3400 */
3402
3403/**
3404 * Obtain the last basic block in a function.
3405 *
3406 * @see llvm::Function::end()
3407 */
3409
3410/**
3411 * Advance a basic block iterator.
3412 */
3414
3415/**
3416 * Go backwards in a basic block iterator.
3417 */
3419
3420/**
3421 * Obtain the basic block that corresponds to the entry point of a
3422 * function.
3423 *
3424 * @see llvm::Function::getEntryBlock()
3425 */
3427
3428/**
3429 * Insert the given basic block after the insertion point of the given builder.
3430 *
3431 * The insertion point must be valid.
3432 *
3433 * @see llvm::Function::BasicBlockListType::insertAfter()
3434 */
3437
3438/**
3439 * Append the given basic block to the basic block list of the given function.
3440 *
3441 * @see llvm::Function::BasicBlockListType::push_back()
3442 */
3445
3446/**
3447 * Create a new basic block without inserting it into a function.
3448 *
3449 * @see llvm::BasicBlock::Create()
3450 */
3452 const char *Name);
3453
3454/**
3455 * Append a basic block to the end of a function.
3456 *
3457 * @see llvm::BasicBlock::Create()
3458 */
3460 LLVMValueRef Fn,
3461 const char *Name);
3462
3463/**
3464 * Append a basic block to the end of a function using the global
3465 * context.
3466 *
3467 * @see llvm::BasicBlock::Create()
3468 */
3470
3471/**
3472 * Insert a basic block in a function before another basic block.
3473 *
3474 * The function to add to is determined by the function of the
3475 * passed basic block.
3476 *
3477 * @see llvm::BasicBlock::Create()
3478 */
3481 const char *Name);
3482
3483/**
3484 * Insert a basic block in a function using the global context.
3485 *
3486 * @see llvm::BasicBlock::Create()
3487 */
3489 const char *Name);
3490
3491/**
3492 * Remove a basic block from a function and delete it.
3493 *
3494 * This deletes the basic block from its containing function and deletes
3495 * the basic block itself.
3496 *
3497 * @see llvm::BasicBlock::eraseFromParent()
3498 */
3500
3501/**
3502 * Remove a basic block from a function.
3503 *
3504 * This deletes the basic block from its containing function but keep
3505 * the basic block alive.
3506 *
3507 * @see llvm::BasicBlock::removeFromParent()
3508 */
3510
3511/**
3512 * Move a basic block to before another one.
3513 *
3514 * @see llvm::BasicBlock::moveBefore()
3515 */
3517
3518/**
3519 * Move a basic block to after another one.
3520 *
3521 * @see llvm::BasicBlock::moveAfter()
3522 */
3524
3525/**
3526 * Obtain the first instruction in a basic block.
3527 *
3528 * The returned LLVMValueRef corresponds to a llvm::Instruction
3529 * instance.
3530 */
3532
3533/**
3534 * Obtain the last instruction in a basic block.
3535 *
3536 * The returned LLVMValueRef corresponds to an LLVM:Instruction.
3537 */
3539
3540/**
3541 * @}
3542 */
3543
3544/**
3545 * @defgroup LLVMCCoreValueInstruction Instructions
3546 *
3547 * Functions in this group relate to the inspection and manipulation of
3548 * individual instructions.
3549 *
3550 * In the C++ API, an instruction is modeled by llvm::Instruction. This
3551 * class has a large number of descendents. llvm::Instruction is a
3552 * llvm::Value and in the C API, instructions are modeled by
3553 * LLVMValueRef.
3554 *
3555 * This group also contains sub-groups which operate on specific
3556 * llvm::Instruction types, e.g. llvm::CallInst.
3557 *
3558 * @{
3559 */
3560
3561/**
3562 * Determine whether an instruction has any metadata attached.
3563 */
3565
3566/**
3567 * Return metadata associated with an instruction value.
3568 */
3569LLVMValueRef LLVMGetMetadata(LLVMValueRef Val, unsigned KindID);
3570
3571/**
3572 * Set metadata associated with an instruction value.
3573 */
3574void LLVMSetMetadata(LLVMValueRef Val, unsigned KindID, LLVMValueRef Node);
3575
3576/**
3577 * Returns the metadata associated with an instruction value, but filters out
3578 * all the debug locations.
3579 *
3580 * @see llvm::Instruction::getAllMetadataOtherThanDebugLoc()
3581 */
3584 size_t *NumEntries);
3585
3586/**
3587 * Obtain the basic block to which an instruction belongs.
3588 *
3589 * @see llvm::Instruction::getParent()
3590 */
3592
3593/**
3594 * Obtain the instruction that occurs after the one specified.
3595 *
3596 * The next instruction will be from the same basic block.
3597 *
3598 * If this is the last instruction in a basic block, NULL will be
3599 * returned.
3600 */
3602
3603/**
3604 * Obtain the instruction that occurred before this one.
3605 *
3606 * If the instruction is the first instruction in a basic block, NULL
3607 * will be returned.
3608 */
3610
3611/**
3612 * Remove an instruction.
3613 *
3614 * The instruction specified is removed from its containing building
3615 * block but is kept alive.
3616 *
3617 * @see llvm::Instruction::removeFromParent()
3618 */
3620
3621/**
3622 * Remove and delete an instruction.
3623 *
3624 * The instruction specified is removed from its containing building
3625 * block and then deleted.
3626 *
3627 * @see llvm::Instruction::eraseFromParent()
3628 */
3630
3631/**
3632 * Delete an instruction.
3633 *
3634 * The instruction specified is deleted. It must have previously been
3635 * removed from its containing building block.
3636 *
3637 * @see llvm::Value::deleteValue()
3638 */
3640
3641/**
3642 * Obtain the code opcode for an individual instruction.
3643 *
3644 * @see llvm::Instruction::getOpCode()
3645 */
3647
3648/**
3649 * Obtain the predicate of an instruction.
3650 *
3651 * This is only valid for instructions that correspond to llvm::ICmpInst.
3652 *
3653 * @see llvm::ICmpInst::getPredicate()
3654 */
3656
3657/**
3658 * Obtain the float predicate of an instruction.
3659 *
3660 * This is only valid for instructions that correspond to llvm::FCmpInst.
3661 *
3662 * @see llvm::FCmpInst::getPredicate()
3663 */
3665
3666/**
3667 * Create a copy of 'this' instruction that is identical in all ways
3668 * except the following:
3669 * * The instruction has no parent
3670 * * The instruction has no name
3671 *
3672 * @see llvm::Instruction::clone()
3673 */
3675
3676/**
3677 * Determine whether an instruction is a terminator. This routine is named to
3678 * be compatible with historical functions that did this by querying the
3679 * underlying C++ type.
3680 *
3681 * @see llvm::Instruction::isTerminator()
3682 */
3684
3685/**
3686 * Obtain the first debug record attached to an instruction.
3687 *
3688 * Use LLVMGetNextDbgRecord() and LLVMGetPreviousDbgRecord() to traverse the
3689 * sequence of DbgRecords.
3690 *
3691 * Return the first DbgRecord attached to Inst or NULL if there are none.
3692 *
3693 * @see llvm::Instruction::getDbgRecordRange()
3694 */
3696
3697/**
3698 * Obtain the last debug record attached to an instruction.
3699 *
3700 * Return the last DbgRecord attached to Inst or NULL if there are none.
3701 *
3702 * @see llvm::Instruction::getDbgRecordRange()
3703 */
3705
3706/**
3707 * Obtain the next DbgRecord in the sequence or NULL if there are no more.
3708 *
3709 * @see llvm::Instruction::getDbgRecordRange()
3710 */
3712
3713/**
3714 * Obtain the previous DbgRecord in the sequence or NULL if there are no more.
3715 *
3716 * @see llvm::Instruction::getDbgRecordRange()
3717 */
3719
3720/**
3721 * @defgroup LLVMCCoreValueInstructionCall Call Sites and Invocations
3722 *
3723 * Functions in this group apply to instructions that refer to call
3724 * sites and invocations. These correspond to C++ types in the
3725 * llvm::CallInst class tree.
3726 *
3727 * @{
3728 */
3729
3730/**
3731 * Obtain the argument count for a call instruction.
3732 *
3733 * This expects an LLVMValueRef that corresponds to a llvm::CallInst,
3734 * llvm::InvokeInst, or llvm:FuncletPadInst.
3735 *
3736 * @see llvm::CallInst::getNumArgOperands()
3737 * @see llvm::InvokeInst::getNumArgOperands()
3738 * @see llvm::FuncletPadInst::getNumArgOperands()
3739 */
3740unsigned LLVMGetNumArgOperands(LLVMValueRef Instr);
3741
3742/**
3743 * Set the calling convention for a call instruction.
3744 *
3745 * This expects an LLVMValueRef that corresponds to a llvm::CallInst or
3746 * llvm::InvokeInst.
3747 *
3748 * @see llvm::CallInst::setCallingConv()
3749 * @see llvm::InvokeInst::setCallingConv()
3750 */
3751void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC);
3752
3753/**
3754 * Obtain the calling convention for a call instruction.
3755 *
3756 * This is the opposite of LLVMSetInstructionCallConv(). Reads its
3757 * usage.
3758 *
3759 * @see LLVMSetInstructionCallConv()
3760 */
3762
3764 unsigned Align);
3765
3770 LLVMAttributeRef *Attrs);
3773 unsigned KindID);
3776 const char *K, unsigned KLen);
3778 unsigned KindID);
3780 const char *K, unsigned KLen);
3781
3782/**
3783 * Obtain the function type called by this instruction.
3784 *
3785 * @see llvm::CallBase::getFunctionType()
3786 */
3788
3789/**
3790 * Obtain the pointer to the function invoked by this instruction.
3791 *
3792 * This expects an LLVMValueRef that corresponds to a llvm::CallInst or
3793 * llvm::InvokeInst.
3794 *
3795 * @see llvm::CallInst::getCalledOperand()
3796 * @see llvm::InvokeInst::getCalledOperand()
3797 */
3799
3800/**
3801 * Obtain the number of operand bundles attached to this instruction.
3802 *
3803 * This only works on llvm::CallInst and llvm::InvokeInst instructions.
3804 *
3805 * @see llvm::CallBase::getNumOperandBundles()
3806 */
3808
3809/**
3810 * Obtain the operand bundle attached to this instruction at the given index.
3811 * Use LLVMDisposeOperandBundle to free the operand bundle.
3812 *
3813 * This only works on llvm::CallInst and llvm::InvokeInst instructions.
3814 */
3816 unsigned Index);
3817
3818/**
3819 * Obtain whether a call instruction is a tail call.
3820 *
3821 * This only works on llvm::CallInst instructions.
3822 *
3823 * @see llvm::CallInst::isTailCall()
3824 */
3826
3827/**
3828 * Set whether a call instruction is a tail call.
3829 *
3830 * This only works on llvm::CallInst instructions.
3831 *
3832 * @see llvm::CallInst::setTailCall()
3833 */
3834void LLVMSetTailCall(LLVMValueRef CallInst, LLVMBool IsTailCall);
3835
3836/**
3837 * Obtain a tail call kind of the call instruction.
3838 *
3839 * @see llvm::CallInst::setTailCallKind()
3840 */
3842
3843/**
3844 * Set the call kind of the call instruction.
3845 *
3846 * @see llvm::CallInst::getTailCallKind()
3847 */
3849
3850/**
3851 * Return the normal destination basic block.
3852 *
3853 * This only works on llvm::InvokeInst instructions.
3854 *
3855 * @see llvm::InvokeInst::getNormalDest()
3856 */
3858
3859/**
3860 * Return the unwind destination basic block.
3861 *
3862 * Works on llvm::InvokeInst, llvm::CleanupReturnInst, and
3863 * llvm::CatchSwitchInst instructions.
3864 *
3865 * @see llvm::InvokeInst::getUnwindDest()
3866 * @see llvm::CleanupReturnInst::getUnwindDest()
3867 * @see llvm::CatchSwitchInst::getUnwindDest()
3868 */
3870
3871/**
3872 * Set the normal destination basic block.
3873 *
3874 * This only works on llvm::InvokeInst instructions.
3875 *
3876 * @see llvm::InvokeInst::setNormalDest()
3877 */
3879
3880/**
3881 * Set the unwind destination basic block.
3882 *
3883 * Works on llvm::InvokeInst, llvm::CleanupReturnInst, and
3884 * llvm::CatchSwitchInst instructions.
3885 *
3886 * @see llvm::InvokeInst::setUnwindDest()
3887 * @see llvm::CleanupReturnInst::setUnwindDest()
3888 * @see llvm::CatchSwitchInst::setUnwindDest()
3889 */
3891
3892/**
3893 * Get the default destination of a CallBr instruction.
3894 *
3895 * @see llvm::CallBrInst::getDefaultDest()
3896 */
3898
3899/**
3900 * Get the number of indirect destinations of a CallBr instruction.
3901 *
3902 * @see llvm::CallBrInst::getNumIndirectDests()
3903
3904 */
3906
3907/**
3908 * Get the indirect destination of a CallBr instruction at the given index.
3909 *
3910 * @see llvm::CallBrInst::getIndirectDest()
3911 */
3913
3914/**
3915 * @}
3916 */
3917
3918/**
3919 * @defgroup LLVMCCoreValueInstructionTerminator Terminators
3920 *
3921 * Functions in this group only apply to instructions for which
3922 * LLVMIsATerminatorInst returns true.
3923 *
3924 * @{
3925 */
3926
3927/**
3928 * Return the number of successors that this terminator has.
3929 *
3930 * @see llvm::Instruction::getNumSuccessors
3931 */
3932unsigned LLVMGetNumSuccessors(LLVMValueRef Term);
3933
3934/**
3935 * Return the specified successor.
3936 *
3937 * @see llvm::Instruction::getSuccessor
3938 */
3940
3941/**
3942 * Update the specified successor to point at the provided block.
3943 *
3944 * @see llvm::Instruction::setSuccessor
3945 */
3947
3948/**
3949 * Return if a branch is conditional.
3950 *
3951 * This only works on llvm::BranchInst instructions.
3952 *
3953 * @see llvm::BranchInst::isConditional
3954 */
3956
3957/**
3958 * Return the condition of a branch instruction.
3959 *
3960 * This only works on llvm::BranchInst instructions.
3961 *
3962 * @see llvm::BranchInst::getCondition
3963 */
3965
3966/**
3967 * Set the condition of a branch instruction.
3968 *
3969 * This only works on llvm::BranchInst instructions.
3970 *
3971 * @see llvm::BranchInst::setCondition
3972 */
3974
3975/**
3976 * Obtain the default destination basic block of a switch instruction.
3977 *
3978 * This only works on llvm::SwitchInst instructions.
3979 *
3980 * @see llvm::SwitchInst::getDefaultDest()
3981 */
3983
3984/**
3985 * @}
3986 */
3987
3988/**
3989 * @defgroup LLVMCCoreValueInstructionAlloca Allocas
3990 *
3991 * Functions in this group only apply to instructions that map to
3992 * llvm::AllocaInst instances.
3993 *
3994 * @{
3995 */
3996
3997/**
3998 * Obtain the type that is being allocated by the alloca instruction.
3999 */
4001
4002/**
4003 * @}
4004 */
4005
4006/**
4007 * @defgroup LLVMCCoreValueInstructionGetElementPointer GEPs
4008 *
4009 * Functions in this group only apply to instructions that map to
4010 * llvm::GetElementPtrInst instances.
4011 *
4012 * @{
4013 */
4014
4015/**
4016 * Check whether the given GEP operator is inbounds.
4017 */
4019
4020/**
4021 * Set the given GEP instruction to be inbounds or not.
4022 */
4024
4025/**
4026 * Get the source element type of the given GEP operator.
4027 */
4029
4030/**
4031 * Get the no-wrap related flags for the given GEP instruction.
4032 *
4033 * @see llvm::GetElementPtrInst::getNoWrapFlags
4034 */
4036
4037/**
4038 * Set the no-wrap related flags for the given GEP instruction.
4039 *
4040 * @see llvm::GetElementPtrInst::setNoWrapFlags
4041 */
4043
4044/**
4045 * @}
4046 */
4047
4048/**
4049 * @defgroup LLVMCCoreValueInstructionPHINode PHI Nodes
4050 *
4051 * Functions in this group only apply to instructions that map to
4052 * llvm::PHINode instances.
4053 *
4054 * @{
4055 */
4056
4057/**
4058 * Add an incoming value to the end of a PHI list.
4059 */
4060void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues,
4061 LLVMBasicBlockRef *IncomingBlocks, unsigned Count);
4062
4063/**
4064 * Obtain the number of incoming basic blocks to a PHI node.
4065 */
4066unsigned LLVMCountIncoming(LLVMValueRef PhiNode);
4067
4068/**
4069 * Obtain an incoming value to a PHI node as an LLVMValueRef.
4070 */
4072
4073/**
4074 * Obtain an incoming value to a PHI node as an LLVMBasicBlockRef.
4075 */
4077
4078/**
4079 * @}
4080 */
4081
4082/**
4083 * @defgroup LLVMCCoreValueInstructionExtractValue ExtractValue
4084 * @defgroup LLVMCCoreValueInstructionInsertValue InsertValue
4085 *
4086 * Functions in this group only apply to instructions that map to
4087 * llvm::ExtractValue and llvm::InsertValue instances.
4088 *
4089 * @{
4090 */
4091
4092/**
4093 * Obtain the number of indices.
4094 * NB: This also works on GEP operators.
4095 */
4096unsigned LLVMGetNumIndices(LLVMValueRef Inst);
4097
4098/**
4099 * Obtain the indices as an array.
4100 */
4101const unsigned *LLVMGetIndices(LLVMValueRef Inst);
4102
4103/**
4104 * @}
4105 */
4106
4107/**
4108 * @}
4109 */
4110
4111/**
4112 * @}
4113 */
4114
4115/**
4116 * @defgroup LLVMCCoreInstructionBuilder Instruction Builders
4117 *
4118 * An instruction builder represents a point within a basic block and is
4119 * the exclusive means of building instructions using the C interface.
4120 *
4121 * @{
4122 */
4123
4126/**
4127 * Set the builder position before Instr but after any attached debug records,
4128 * or if Instr is null set the position to the end of Block.
4129 */
4131 LLVMValueRef Instr);
4132/**
4133 * Set the builder position before Instr and any attached debug records,
4134 * or if Instr is null set the position to the end of Block.
4135 */
4137 LLVMBasicBlockRef Block,
4138 LLVMValueRef Inst);
4139/**
4140 * Set the builder position before Instr but after any attached debug records.
4141 */
4143/**
4144 * Set the builder position before Instr and any attached debug records.
4145 */
4147 LLVMValueRef Instr);
4153 const char *Name);
4155
4156/* Metadata */
4157
4158/**
4159 * Get location information used by debugging information.
4160 *
4161 * @see llvm::IRBuilder::getCurrentDebugLocation()
4162 */
4164
4165/**
4166 * Set location information used by debugging information.
4167 *
4168 * To clear the location metadata of the given instruction, pass NULL to \p Loc.
4169 *
4170 * @see llvm::IRBuilder::SetCurrentDebugLocation()
4171 */
4173
4174/**
4175 * Attempts to set the debug location for the given instruction using the
4176 * current debug location for the given builder. If the builder has no current
4177 * debug location, this function is a no-op.
4178 *
4179 * @deprecated LLVMSetInstDebugLocation is deprecated in favor of the more general
4180 * LLVMAddMetadataToInst.
4181 *
4182 * @see llvm::IRBuilder::SetInstDebugLocation()
4183 */
4185
4186/**
4187 * Adds the metadata registered with the given builder to the given instruction.
4188 *
4189 * @see llvm::IRBuilder::AddMetadataToInst()
4190 */
4192
4193/**
4194 * Get the dafult floating-point math metadata for a given builder.
4195 *
4196 * @see llvm::IRBuilder::getDefaultFPMathTag()
4197 */
4199
4200/**
4201 * Set the default floating-point math metadata for the given builder.
4202 *
4203 * To clear the metadata, pass NULL to \p FPMathTag.
4204 *
4205 * @see llvm::IRBuilder::setDefaultFPMathTag()
4206 */
4208 LLVMMetadataRef FPMathTag);
4209
4210/**
4211 * Obtain the context to which this builder is associated.
4212 *
4213 * @see llvm::IRBuilder::getContext()
4214 */
4216
4217/**
4218 * Deprecated: Passing the NULL location will crash.
4219 * Use LLVMGetCurrentDebugLocation2 instead.
4220 */
4222/**
4223 * Deprecated: Returning the NULL location will crash.
4224 * Use LLVMGetCurrentDebugLocation2 instead.
4225 */
4227
4228/* Terminators */
4232 unsigned N);
4237 LLVMBasicBlockRef Else, unsigned NumCases);
4239 unsigned NumDests);
4241 LLVMBasicBlockRef DefaultDest,
4242 LLVMBasicBlockRef *IndirectDests,
4243 unsigned NumIndirectDests, LLVMValueRef *Args,
4244 unsigned NumArgs, LLVMOperandBundleRef *Bundles,
4245 unsigned NumBundles, const char *Name);
4247 LLVMValueRef *Args, unsigned NumArgs,
4249 const char *Name);
4252 unsigned NumArgs, LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch,
4253 LLVMOperandBundleRef *Bundles, unsigned NumBundles, const char *Name);
4255
4256/* Exception Handling */
4259 LLVMValueRef PersFn, unsigned NumClauses,
4260 const char *Name);
4266 LLVMValueRef *Args, unsigned NumArgs,
4267 const char *Name);
4269 LLVMValueRef *Args, unsigned NumArgs,
4270 const char *Name);
4272 LLVMBasicBlockRef UnwindBB,
4273 unsigned NumHandlers, const char *Name);
4274
4275/* Add a case to the switch instruction */
4276void LLVMAddCase(LLVMValueRef Switch, LLVMValueRef OnVal,
4277 LLVMBasicBlockRef Dest);
4278
4279/* Add a destination to the indirectbr instruction */
4281
4282/* Get the number of clauses on the landingpad instruction */
4283unsigned LLVMGetNumClauses(LLVMValueRef LandingPad);
4284
4285/* Get the value of the clause at index Idx on the landingpad instruction */
4286LLVMValueRef LLVMGetClause(LLVMValueRef LandingPad, unsigned Idx);
4287
4288/* Add a catch or filter clause to the landingpad instruction */
4289void LLVMAddClause(LLVMValueRef LandingPad, LLVMValueRef ClauseVal);
4290
4291/* Get the 'cleanup' flag in the landingpad instruction */
4293
4294/* Set the 'cleanup' flag in the landingpad instruction */
4295void LLVMSetCleanup(LLVMValueRef LandingPad, LLVMBool Val);
4296
4297/* Add a destination to the catchswitch instruction */
4298void LLVMAddHandler(LLVMValueRef CatchSwitch, LLVMBasicBlockRef Dest);
4299
4300/* Get the number of handlers on the catchswitch instruction */
4301unsigned LLVMGetNumHandlers(LLVMValueRef CatchSwitch);
4302
4303/**
4304 * Obtain the basic blocks acting as handlers for a catchswitch instruction.
4305 *
4306 * The Handlers parameter should point to a pre-allocated array of
4307 * LLVMBasicBlockRefs at least LLVMGetNumHandlers() large. On return, the
4308 * first LLVMGetNumHandlers() entries in the array will be populated
4309 * with LLVMBasicBlockRef instances.
4310 *
4311 * @param CatchSwitch The catchswitch instruction to operate on.
4312 * @param Handlers Memory address of an array to be filled with basic blocks.
4313 */
4314void LLVMGetHandlers(LLVMValueRef CatchSwitch, LLVMBasicBlockRef *Handlers);
4315
4316/* Funclets */
4317
4318/* Get the number of funcletpad arguments. */
4319LLVMValueRef LLVMGetArgOperand(LLVMValueRef Funclet, unsigned i);
4320
4321/* Set a funcletpad argument at the given index. */
4322void LLVMSetArgOperand(LLVMValueRef Funclet, unsigned i, LLVMValueRef value);
4323
4324/**
4325 * Get the parent catchswitch instruction of a catchpad instruction.
4326 *
4327 * This only works on llvm::CatchPadInst instructions.
4328 *
4329 * @see llvm::CatchPadInst::getCatchSwitch()
4330 */
4332
4333/**
4334 * Set the parent catchswitch instruction of a catchpad instruction.
4335 *
4336 * This only works on llvm::CatchPadInst instructions.
4337 *
4338 * @see llvm::CatchPadInst::setCatchSwitch()
4339 */
4340void LLVMSetParentCatchSwitch(LLVMValueRef CatchPad, LLVMValueRef CatchSwitch);
4341
4342/* Arithmetic */
4344 const char *Name);
4346 const char *Name);
4348 const char *Name);
4350 const char *Name);
4352 const char *Name);
4354 const char *Name);
4356 const char *Name);
4358 const char *Name);
4360 const char *Name);
4362 const char *Name);
4364 const char *Name);
4366 const char *Name);
4368 const char *Name);
4370 const char *Name);
4372 const char *Name);
4374 const char *Name);
4376 const char *Name);
4378 const char *Name);
4380 const char *Name);
4382 const char *Name);
4384 const char *Name);
4386 const char *Name);
4388 const char *Name);
4390 const char *Name);
4392 const char *Name);
4394 const char *Name);
4397 const char *Name);
4400 const char *Name);
4402 LLVMValueRef V,
4403 const char *Name),
4404 "Use LLVMBuildNeg + LLVMSetNUW instead.");
4407
4409void LLVMSetNUW(LLVMValueRef ArithInst, LLVMBool HasNUW);
4411void LLVMSetNSW(LLVMValueRef ArithInst, LLVMBool HasNSW);
4412LLVMBool LLVMGetExact(LLVMValueRef DivOrShrInst);
4413void LLVMSetExact(LLVMValueRef DivOrShrInst, LLVMBool IsExact);
4414
4415/**
4416 * Gets if the instruction has the non-negative flag set.
4417 * Only valid for zext instructions.
4418 */
4420/**
4421 * Sets the non-negative flag for the instruction.
4422 * Only valid for zext instructions.
4423 */
4424void LLVMSetNNeg(LLVMValueRef NonNegInst, LLVMBool IsNonNeg);
4425
4426/**
4427 * Get the flags for which fast-math-style optimizations are allowed for this
4428 * value.
4429 *
4430 * Only valid on floating point instructions.
4431 * @see LLVMCanValueUseFastMathFlags
4432 */
4434
4435/**
4436 * Sets the flags for which fast-math-style optimizations are allowed for this
4437 * value.
4438 *
4439 * Only valid on floating point instructions.
4440 * @see LLVMCanValueUseFastMathFlags
4441 */
4443
4444/**
4445 * Check if a given value can potentially have fast math flags.
4446 *
4447 * Will return true for floating point arithmetic instructions, and for select,
4448 * phi, and call instructions whose type is a floating point type, or a vector
4449 * or array thereof. See https://llvm.org/docs/LangRef.html#fast-math-flags
4450 */
4452
4453/**
4454 * Gets whether the instruction has the disjoint flag set.
4455 * Only valid for or instructions.
4456 */
4458/**
4459 * Sets the disjoint flag for the instruction.
4460 * Only valid for or instructions.
4461 */
4462void LLVMSetIsDisjoint(LLVMValueRef Inst, LLVMBool IsDisjoint);
4463
4464/* Memory */
4467 LLVMValueRef Val, const char *Name);
4468
4469/**
4470 * Creates and inserts a memset to the specified pointer and the
4471 * specified value.
4472 *
4473 * @see llvm::IRRBuilder::CreateMemSet()
4474 */
4476 LLVMValueRef Val, LLVMValueRef Len,
4477 unsigned Align);
4478/**
4479 * Creates and inserts a memcpy between the specified pointers.
4480 *
4481 * @see llvm::IRRBuilder::CreateMemCpy()
4482 */
4484 LLVMValueRef Dst, unsigned DstAlign,
4485 LLVMValueRef Src, unsigned SrcAlign,
4487/**
4488 * Creates and inserts a memmove between the specified pointers.
4489 *
4490 * @see llvm::IRRBuilder::CreateMemMove()
4491 */
4493 LLVMValueRef Dst, unsigned DstAlign,
4494 LLVMValueRef Src, unsigned SrcAlign,
4496
4499 LLVMValueRef Val, const char *Name);
4502 LLVMValueRef PointerVal, const char *Name);
4505 LLVMValueRef Pointer, LLVMValueRef *Indices,
4506 unsigned NumIndices, const char *Name);
4508 LLVMValueRef Pointer, LLVMValueRef *Indices,
4509 unsigned NumIndices, const char *Name);
4510/**
4511 * Creates a GetElementPtr instruction. Similar to LLVMBuildGEP2, but allows
4512 * specifying the no-wrap flags.
4513 *
4514 * @see llvm::IRBuilder::CreateGEP()
4515 */
4517 LLVMValueRef Pointer,
4518 LLVMValueRef *Indices,
4519 unsigned NumIndices, const char *Name,
4520 LLVMGEPNoWrapFlags NoWrapFlags);
4522 LLVMValueRef Pointer, unsigned Idx,
4523 const char *Name);
4525 const char *Name);
4526/**
4527 * Deprecated: Use LLVMBuildGlobalString instead, which has identical behavior.
4528 */
4530 const char *Name);
4531LLVMBool LLVMGetVolatile(LLVMValueRef MemoryAccessInst);
4532void LLVMSetVolatile(LLVMValueRef MemoryAccessInst, LLVMBool IsVolatile);
4533LLVMBool LLVMGetWeak(LLVMValueRef CmpXchgInst);
4534void LLVMSetWeak(LLVMValueRef CmpXchgInst, LLVMBool IsWeak);
4536void LLVMSetOrdering(LLVMValueRef MemoryAccessInst, LLVMAtomicOrdering Ordering);
4538void LLVMSetAtomicRMWBinOp(LLVMValueRef AtomicRMWInst, LLVMAtomicRMWBinOp BinOp);
4539
4540/* Casts */
4542 LLVMTypeRef DestTy, const char *Name);
4544 LLVMTypeRef DestTy, const char *Name);
4546 LLVMTypeRef DestTy, const char *Name);
4548 LLVMTypeRef DestTy, const char *Name);
4550 LLVMTypeRef DestTy, const char *Name);
4552 LLVMTypeRef DestTy, const char *Name);
4554 LLVMTypeRef DestTy, const char *Name);
4556 LLVMTypeRef DestTy, const char *Name);
4558 LLVMTypeRef DestTy, const char *Name);
4560 LLVMTypeRef DestTy, const char *Name);
4562 LLVMTypeRef DestTy, const char *Name);
4564 LLVMTypeRef DestTy, const char *Name);
4566 LLVMTypeRef DestTy, const char *Name);
4568 LLVMTypeRef DestTy, const char *Name);
4570 LLVMTypeRef DestTy, const char *Name);
4572 LLVMTypeRef DestTy, const char *Name);
4574 LLVMTypeRef DestTy, const char *Name);
4576 LLVMTypeRef DestTy, const char *Name);
4578 LLVMTypeRef DestTy, LLVMBool IsSigned,
4579 const char *Name);
4581 LLVMTypeRef DestTy, const char *Name);
4582
4583/** Deprecated: This cast is always signed. Use LLVMBuildIntCast2 instead. */
4585 LLVMTypeRef DestTy, const char *Name);
4586
4588 LLVMTypeRef DestTy, LLVMBool DestIsSigned);
4589
4590/* Comparisons */
4593 const char *Name);
4596 const char *Name);
4597
4598/* Miscellaneous instructions */
4601 LLVMValueRef *Args, unsigned NumArgs,
4602 const char *Name);
4605 LLVMValueRef *Args, unsigned NumArgs,
4606 LLVMOperandBundleRef *Bundles,
4607 unsigned NumBundles, const char *Name);
4609 LLVMValueRef Then, LLVMValueRef Else,
4610 const char *Name);
4612 const char *Name);
4614 LLVMValueRef Index, const char *Name);
4617 const char *Name);
4619 LLVMValueRef V2, LLVMValueRef Mask,
4620 const char *Name);
4622 unsigned Index, const char *Name);
4624 LLVMValueRef EltVal, unsigned Index,
4625 const char *Name);
4627 const char *Name);
4628
4630 const char *Name);
4632 const char *Name);
4635 const char *Name);
4637 LLVMBool singleThread, const char *Name);
4639 LLVMAtomicOrdering ordering, unsigned SSID,
4640 const char *Name);
4642 LLVMValueRef PTR, LLVMValueRef Val,
4643 LLVMAtomicOrdering ordering,
4644 LLVMBool singleThread);
4647 LLVMValueRef PTR, LLVMValueRef Val,
4648 LLVMAtomicOrdering ordering,
4649 unsigned SSID);
4651 LLVMValueRef Cmp, LLVMValueRef New,
4652 LLVMAtomicOrdering SuccessOrdering,
4653 LLVMAtomicOrdering FailureOrdering,
4656 LLVMValueRef Cmp, LLVMValueRef New,
4657 LLVMAtomicOrdering SuccessOrdering,
4658 LLVMAtomicOrdering FailureOrdering,
4659 unsigned SSID);
4660
4661/**
4662 * Get the number of elements in the mask of a ShuffleVector instruction.
4663 */
4664unsigned LLVMGetNumMaskElements(LLVMValueRef ShuffleVectorInst);
4665
4666/**
4667 * \returns a constant that specifies that the result of a \c ShuffleVectorInst
4668 * is undefined.
4669 */
4670int LLVMGetUndefMaskElem(void);
4671
4672/**
4673 * Get the mask value at position Elt in the mask of a ShuffleVector
4674 * instruction.
4675 *
4676 * \Returns the result of \c LLVMGetUndefMaskElem() if the mask value is
4677 * poison at that position.
4678 */
4679int LLVMGetMaskValue(LLVMValueRef ShuffleVectorInst, unsigned Elt);
4680
4683
4684/**
4685 * Returns whether an instruction is an atomic instruction, e.g., atomicrmw,
4686 * cmpxchg, fence, or loads and stores with atomic ordering.
4687 */
4689
4690/**
4691 * Returns the synchronization scope ID of an atomic instruction.
4692 */
4693unsigned LLVMGetAtomicSyncScopeID(LLVMValueRef AtomicInst);
4694
4695/**
4696 * Sets the synchronization scope ID of an atomic instruction.
4697 */
4698void LLVMSetAtomicSyncScopeID(LLVMValueRef AtomicInst, unsigned SSID);
4699
4702 LLVMAtomicOrdering Ordering);
4705 LLVMAtomicOrdering Ordering);
4706
4707/**
4708 * @}
4709 */
4710
4711/**
4712 * @defgroup LLVMCCoreModuleProvider Module Providers
4713 *
4714 * @{
4715 */
4716
4717/**
4718 * Changes the type of M so it can be passed to FunctionPassManagers and the
4719 * JIT. They take ModuleProviders for historical reasons.
4720 */
4723
4724/**
4725 * Destroys the module M.
4726 */
4728
4729/**
4730 * @}
4731 */
4732
4733/**
4734 * @defgroup LLVMCCoreMemoryBuffers Memory Buffers
4735 *
4736 * @{
4737 */
4738
4740 LLVMMemoryBufferRef *OutMemBuf,
4741 char **OutMessage);
4743 char **OutMessage);
4745 size_t InputDataLength,
4746 const char *BufferName,
4747 LLVMBool RequiresNullTerminator);
4749 size_t InputDataLength,
4750