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