diff options
Diffstat (limited to 'contrib/llvm/include/llvm-c')
-rw-r--r-- | contrib/llvm/include/llvm-c/Core.h | 380 | ||||
-rw-r--r-- | contrib/llvm/include/llvm-c/Disassembler.h | 6 | ||||
-rw-r--r-- | contrib/llvm/include/llvm-c/ErrorHandling.h | 2 | ||||
-rw-r--r-- | contrib/llvm/include/llvm-c/Linker.h | 14 | ||||
-rw-r--r-- | contrib/llvm/include/llvm-c/OrcBindings.h | 35 | ||||
-rw-r--r-- | contrib/llvm/include/llvm-c/Target.h | 25 | ||||
-rw-r--r-- | contrib/llvm/include/llvm-c/TargetMachine.h | 4 | ||||
-rw-r--r-- | contrib/llvm/include/llvm-c/Transforms/Scalar.h | 6 | ||||
-rw-r--r-- | contrib/llvm/include/llvm-c/Types.h | 7 | ||||
-rw-r--r-- | contrib/llvm/include/llvm-c/lto.h | 274 |
10 files changed, 674 insertions, 79 deletions
diff --git a/contrib/llvm/include/llvm-c/Core.h b/contrib/llvm/include/llvm-c/Core.h index c8fda15..76f8b31 100644 --- a/contrib/llvm/include/llvm-c/Core.h +++ b/contrib/llvm/include/llvm-c/Core.h @@ -94,6 +94,8 @@ typedef enum { LLVMJumpTableAttribute = 1ULL << 45, LLVMConvergentAttribute = 1ULL << 46, LLVMSafeStackAttribute = 1ULL << 47, + LLVMSwiftSelfAttribute = 1ULL << 48, + LLVMSwiftErrorAttribute = 1ULL << 49, */ } LLVMAttribute; @@ -246,6 +248,38 @@ typedef enum { } LLVMCallConv; typedef enum { + LLVMArgumentValueKind, + LLVMBasicBlockValueKind, + LLVMMemoryUseValueKind, + LLVMMemoryDefValueKind, + LLVMMemoryPhiValueKind, + + LLVMFunctionValueKind, + LLVMGlobalAliasValueKind, + LLVMGlobalIFuncValueKind, + LLVMGlobalVariableValueKind, + LLVMBlockAddressValueKind, + LLVMConstantExprValueKind, + LLVMConstantArrayValueKind, + LLVMConstantStructValueKind, + LLVMConstantVectorValueKind, + + LLVMUndefValueValueKind, + LLVMConstantAggregateZeroValueKind, + LLVMConstantDataArrayValueKind, + LLVMConstantDataVectorValueKind, + LLVMConstantIntValueKind, + LLVMConstantFPValueKind, + LLVMConstantPointerNullValueKind, + LLVMConstantTokenNoneValueKind, + + LLVMMetadataAsValueValueKind, + LLVMInlineAsmValueKind, + + LLVMInstructionValueKind, +} LLVMValueKind; + +typedef enum { LLVMIntEQ = 32, /**< equal */ LLVMIntNE, /**< not equal */ LLVMIntUGT, /**< unsigned greater than */ @@ -347,6 +381,20 @@ typedef enum { } LLVMDiagnosticSeverity; /** + * Attribute index are either LLVMAttributeReturnIndex, + * LLVMAttributeFunctionIndex or a parameter number from 1 to N. + */ +enum { + LLVMAttributeReturnIndex = 0U, + // ISO C restricts enumerator values to range of 'int' + // (4294967295 is too large) + // LLVMAttributeFunctionIndex = ~0U, + LLVMAttributeFunctionIndex = -1, +}; + +typedef unsigned LLVMAttributeIndex; + +/** * @} */ @@ -398,6 +446,16 @@ void LLVMContextSetDiagnosticHandler(LLVMContextRef C, void *DiagnosticContext); /** + * Get the diagnostic handler of this context. + */ +LLVMDiagnosticHandler LLVMContextGetDiagnosticHandler(LLVMContextRef C); + +/** + * Get the diagnostic context of this context. + */ +void *LLVMContextGetDiagnosticContext(LLVMContextRef C); + +/** * Set the yield callback function for this context. * * @see LLVMContext::setYieldCallback() @@ -428,9 +486,63 @@ char *LLVMGetDiagInfoDescription(LLVMDiagnosticInfoRef DI); */ LLVMDiagnosticSeverity LLVMGetDiagInfoSeverity(LLVMDiagnosticInfoRef DI); -unsigned LLVMGetMDKindIDInContext(LLVMContextRef C, const char* Name, +unsigned LLVMGetMDKindIDInContext(LLVMContextRef C, const char *Name, unsigned SLen); -unsigned LLVMGetMDKindID(const char* Name, unsigned SLen); +unsigned LLVMGetMDKindID(const char *Name, unsigned SLen); + +/** + * Return an unique id given the name of a enum attribute, + * or 0 if no attribute by that name exists. + * + * See http://llvm.org/docs/LangRef.html#parameter-attributes + * and http://llvm.org/docs/LangRef.html#function-attributes + * for the list of available attributes. + * + * NB: Attribute names and/or id are subject to change without + * going through the C API deprecation cycle. + */ +unsigned LLVMGetEnumAttributeKindForName(const char *Name, size_t SLen); +unsigned LLVMGetLastEnumAttributeKind(void); + +/** + * Create an enum attribute. + */ +LLVMAttributeRef LLVMCreateEnumAttribute(LLVMContextRef C, unsigned KindID, + uint64_t Val); + +/** + * Get the unique id corresponding to the enum attribute + * passed as argument. + */ +unsigned LLVMGetEnumAttributeKind(LLVMAttributeRef A); + +/** + * Get the enum attribute's value. 0 is returned if none exists. + */ +uint64_t LLVMGetEnumAttributeValue(LLVMAttributeRef A); + +/** + * Create a string attribute. + */ +LLVMAttributeRef LLVMCreateStringAttribute(LLVMContextRef C, + const char *K, unsigned KLength, + const char *V, unsigned VLength); + +/** + * Get the string attribute's kind. + */ +const char *LLVMGetStringAttributeKind(LLVMAttributeRef A, unsigned *Length); + +/** + * Get the string attribute's value. + */ +const char *LLVMGetStringAttributeValue(LLVMAttributeRef A, unsigned *Length); + +/** + * Check for the different types of attributes. + */ +LLVMBool LLVMIsEnumAttribute(LLVMAttributeRef A); +LLVMBool LLVMIsStringAttribute(LLVMAttributeRef A); /** * @} @@ -479,10 +591,35 @@ LLVMModuleRef LLVMCloneModule(LLVMModuleRef M); void LLVMDisposeModule(LLVMModuleRef M); /** + * Obtain the identifier of a module. + * + * @param M Module to obtain identifier of + * @param Len Out parameter which holds the length of the returned string. + * @return The identifier of M. + * @see Module::getModuleIdentifier() + */ +const char *LLVMGetModuleIdentifier(LLVMModuleRef M, size_t *Len); + +/** + * Set the identifier of a module to a string Ident with length Len. + * + * @param M The module to set identifier + * @param Ident The string to set M's identifier to + * @param Len Length of Ident + * @see Module::setModuleIdentifier() + */ +void LLVMSetModuleIdentifier(LLVMModuleRef M, const char *Ident, size_t Len); + +/** * Obtain the data layout for a module. * - * @see Module::getDataLayout() + * @see Module::getDataLayoutStr() + * + * LLVMGetDataLayout is DEPRECATED, as the name is not only incorrect, + * but match the name of another method on the module. Prefer the use + * of LLVMGetDataLayoutStr, which is not ambiguous. */ +const char *LLVMGetDataLayoutStr(LLVMModuleRef M); const char *LLVMGetDataLayout(LLVMModuleRef M); /** @@ -490,7 +627,7 @@ const char *LLVMGetDataLayout(LLVMModuleRef M); * * @see Module::setDataLayout() */ -void LLVMSetDataLayout(LLVMModuleRef M, const char *Triple); +void LLVMSetDataLayout(LLVMModuleRef M, const char *DataLayoutStr); /** * Obtain the target triple for a module. @@ -554,7 +691,7 @@ LLVMTypeRef LLVMGetTypeByName(LLVMModuleRef M, const char *Name); * * @see llvm::Module::getNamedMetadata() */ -unsigned LLVMGetNamedMetadataNumOperands(LLVMModuleRef M, const char* name); +unsigned LLVMGetNamedMetadataNumOperands(LLVMModuleRef M, const char *Name); /** * Obtain the named metadata operands for a module. @@ -567,7 +704,8 @@ unsigned LLVMGetNamedMetadataNumOperands(LLVMModuleRef M, const char* name); * @see llvm::Module::getNamedMetadata() * @see llvm::MDNode::getOperand() */ -void LLVMGetNamedMetadataOperands(LLVMModuleRef M, const char* name, LLVMValueRef *Dest); +void LLVMGetNamedMetadataOperands(LLVMModuleRef M, const char *Name, + LLVMValueRef *Dest); /** * Add an operand to named metadata. @@ -575,7 +713,7 @@ void LLVMGetNamedMetadataOperands(LLVMModuleRef M, const char* name, LLVMValueRe * @see llvm::Module::getNamedMetadata() * @see llvm::MDNode::addOperand() */ -void LLVMAddNamedMetadataOperand(LLVMModuleRef M, const char* name, +void LLVMAddNamedMetadataOperand(LLVMModuleRef M, const char *Name, LLVMValueRef Val); /** @@ -1164,6 +1302,13 @@ LLVMTypeRef LLVMX86MMXType(void); LLVMTypeRef LLVMTypeOf(LLVMValueRef Val); /** + * Obtain the enumerated type of a Value instance. + * + * @see llvm::Value::getValueID() + */ +LLVMValueKind LLVMGetValueKind(LLVMValueRef Val); + +/** * Obtain the string name of a value. * * @see llvm::Value::getName() @@ -1200,7 +1345,7 @@ char *LLVMPrintValueToString(LLVMValueRef Val); void LLVMReplaceAllUsesWith(LLVMValueRef OldVal, LLVMValueRef NewVal); /** - * Determine whether the specified constant instance is constant. + * Determine whether the specified value instance is constant. */ LLVMBool LLVMIsConstant(LLVMValueRef Val); @@ -1520,7 +1665,7 @@ LLVMBool LLVMIsConstantString(LLVMValueRef c); * * @see ConstantDataSequential::getAsString() */ -const char *LLVMGetAsString(LLVMValueRef c, size_t* out); +const char *LLVMGetAsString(LLVMValueRef c, size_t *Length); /** * Create an anonymous ConstantStruct with the specified values. @@ -1564,7 +1709,7 @@ LLVMValueRef LLVMConstNamedStruct(LLVMTypeRef StructTy, * * @see ConstantDataSequential::getElementAsConstant() */ -LLVMValueRef LLVMGetElementAsConstant(LLVMValueRef c, unsigned idx); +LLVMValueRef LLVMGetElementAsConstant(LLVMValueRef C, unsigned idx); /** * Create a ConstantVector from values. @@ -1727,8 +1872,8 @@ unsigned LLVMGetAlignment(LLVMValueRef V); void LLVMSetAlignment(LLVMValueRef V, unsigned Bytes); /** - * @} - */ + * @} + */ /** * @defgroup LLVMCoreValueConstantGlobalVariable Global Variables @@ -1799,6 +1944,13 @@ LLVMValueRef LLVMAddAlias(LLVMModuleRef M, LLVMTypeRef Ty, LLVMValueRef Aliasee, void LLVMDeleteFunction(LLVMValueRef Fn); /** + * Check whether the given function has a personality function. + * + * @see llvm::Function::hasPersonalityFn() + */ +LLVMBool LLVMHasPersonalityFn(LLVMValueRef Fn); + +/** * Obtain the personality function attached to the function. * * @see llvm::Function::getPersonalityFn() @@ -1860,6 +2012,22 @@ void LLVMSetGC(LLVMValueRef Fn, const char *Name); */ void LLVMAddFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA); +void LLVMAddAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx, + LLVMAttributeRef A); +unsigned LLVMGetAttributeCountAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx); +void LLVMGetAttributesAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx, + LLVMAttributeRef *Attrs); +LLVMAttributeRef LLVMGetEnumAttributeAtIndex(LLVMValueRef F, + LLVMAttributeIndex Idx, + unsigned KindID); +LLVMAttributeRef LLVMGetStringAttributeAtIndex(LLVMValueRef F, + LLVMAttributeIndex Idx, + const char *K, unsigned KLen); +void LLVMRemoveEnumAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx, + unsigned KindID); +void LLVMRemoveStringAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx, + const char *K, unsigned KLen); + /** * Add a target-dependent attribute to a function * @see llvm::AttrBuilder::addAttribute() @@ -1985,7 +2153,7 @@ LLVMAttribute LLVMGetAttribute(LLVMValueRef Arg); * @see llvm::Argument::addAttr() * @see llvm::AttrBuilder::addAlignmentAttr() */ -void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align); +void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned Align); /** * @} @@ -2043,10 +2211,10 @@ LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count); * Obtain the underlying string from a MDString value. * * @param V Instance to obtain string from. - * @param Len Memory address which will hold length of returned string. + * @param Length Memory address which will hold length of returned string. * @return String data in MDString. */ -const char *LLVMGetMDString(LLVMValueRef V, unsigned* Len); +const char *LLVMGetMDString(LLVMValueRef V, unsigned *Length); /** * Obtain the number of operands from an MDNode value. @@ -2106,6 +2274,11 @@ LLVMBool LLVMValueIsBasicBlock(LLVMValueRef Val); LLVMBasicBlockRef LLVMValueAsBasicBlock(LLVMValueRef Val); /** + * Obtain the string name of a basic block. + */ +const char *LLVMGetBasicBlockName(LLVMBasicBlockRef BB); + +/** * Obtain the function to which a basic block belongs. * * @see llvm::BasicBlock::getParent() @@ -2327,6 +2500,16 @@ LLVMValueRef LLVMGetPreviousInstruction(LLVMValueRef Inst); * Remove and delete an instruction. * * The instruction specified is removed from its containing building + * block but is kept alive. + * + * @see llvm::Instruction::removeFromParent() + */ +void LLVMInstructionRemoveFromParent(LLVMValueRef Inst); + +/** + * Remove and delete an instruction. + * + * The instruction specified is removed from its containing building * block and then deleted. * * @see llvm::Instruction::eraseFromParent() @@ -2381,6 +2564,17 @@ LLVMValueRef LLVMInstructionClone(LLVMValueRef Inst); */ /** + * Obtain the argument count for a call instruction. + * + * This expects an LLVMValueRef that corresponds to a llvm::CallInst or + * llvm::InvokeInst. + * + * @see llvm::CallInst::getNumArgOperands() + * @see llvm::InvokeInst::getNumArgOperands() + */ +unsigned LLVMGetNumArgOperands(LLVMValueRef Instr); + +/** * Set the calling convention for a call instruction. * * This expects an LLVMValueRef that corresponds to a llvm::CallInst or @@ -2401,12 +2595,38 @@ void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC); */ unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr); - void LLVMAddInstrAttribute(LLVMValueRef Instr, unsigned index, LLVMAttribute); void LLVMRemoveInstrAttribute(LLVMValueRef Instr, unsigned index, LLVMAttribute); void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index, - unsigned align); + unsigned Align); + +void LLVMAddCallSiteAttribute(LLVMValueRef C, LLVMAttributeIndex Idx, + LLVMAttributeRef A); +unsigned LLVMGetCallSiteAttributeCount(LLVMValueRef C, LLVMAttributeIndex Idx); +void LLVMGetCallSiteAttributes(LLVMValueRef C, LLVMAttributeIndex Idx, + LLVMAttributeRef *Attrs); +LLVMAttributeRef LLVMGetCallSiteEnumAttribute(LLVMValueRef C, + LLVMAttributeIndex Idx, + unsigned KindID); +LLVMAttributeRef LLVMGetCallSiteStringAttribute(LLVMValueRef C, + LLVMAttributeIndex Idx, + const char *K, unsigned KLen); +void LLVMRemoveCallSiteEnumAttribute(LLVMValueRef C, LLVMAttributeIndex Idx, + unsigned KindID); +void LLVMRemoveCallSiteStringAttribute(LLVMValueRef C, LLVMAttributeIndex Idx, + const char *K, unsigned KLen); + +/** + * Obtain the pointer to the function invoked by this instruction. + * + * This expects an LLVMValueRef that corresponds to a llvm::CallInst or + * llvm::InvokeInst. + * + * @see llvm::CallInst::getCalledValue() + * @see llvm::InvokeInst::getCalledValue() + */ +LLVMValueRef LLVMGetCalledValue(LLVMValueRef Instr); /** * Obtain whether a call instruction is a tail call. @@ -2427,6 +2647,42 @@ LLVMBool LLVMIsTailCall(LLVMValueRef CallInst); void LLVMSetTailCall(LLVMValueRef CallInst, LLVMBool IsTailCall); /** + * Return the normal destination basic block. + * + * This only works on llvm::InvokeInst instructions. + * + * @see llvm::InvokeInst::getNormalDest() + */ +LLVMBasicBlockRef LLVMGetNormalDest(LLVMValueRef InvokeInst); + +/** + * Return the unwind destination basic block. + * + * This only works on llvm::InvokeInst instructions. + * + * @see llvm::InvokeInst::getUnwindDest() + */ +LLVMBasicBlockRef LLVMGetUnwindDest(LLVMValueRef InvokeInst); + +/** + * Set the normal destination basic block. + * + * This only works on llvm::InvokeInst instructions. + * + * @see llvm::InvokeInst::setNormalDest() + */ +void LLVMSetNormalDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B); + +/** + * Set the unwind destination basic block. + * + * This only works on llvm::InvokeInst instructions. + * + * @see llvm::InvokeInst::setUnwindDest() + */ +void LLVMSetUnwindDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B); + +/** * @} */ @@ -2501,6 +2757,47 @@ LLVMBasicBlockRef LLVMGetSwitchDefaultDest(LLVMValueRef SwitchInstr); */ /** + * @defgroup LLVMCCoreValueInstructionAlloca Allocas + * + * Functions in this group only apply to instructions that map to + * llvm::AllocaInst instances. + * + * @{ + */ + +/** + * Obtain the type that is being allocated by the alloca instruction. + */ +LLVMTypeRef LLVMGetAllocatedType(LLVMValueRef Alloca); + +/** + * @} + */ + +/** + * @defgroup LLVMCCoreValueInstructionGetElementPointer GEPs + * + * Functions in this group only apply to instructions that map to + * llvm::GetElementPtrInst instances. + * + * @{ + */ + +/** + * Check whether the given GEP instruction is inbounds. + */ +LLVMBool LLVMIsInBounds(LLVMValueRef GEP); + +/** + * Set the given GEP instruction to be inbounds or not. + */ +void LLVMSetIsInBounds(LLVMValueRef GEP, LLVMBool InBounds); + +/** + * @} + */ + +/** * @defgroup LLVMCCoreValueInstructionPHINode PHI Nodes * * Functions in this group only apply to instructions that map to @@ -2535,6 +2832,31 @@ LLVMBasicBlockRef LLVMGetIncomingBlock(LLVMValueRef PhiNode, unsigned Index); */ /** + * @defgroup LLVMCCoreValueInstructionExtractValue ExtractValue + * @defgroup LLVMCCoreValueInstructionInsertValue InsertValue + * + * Functions in this group only apply to instructions that map to + * llvm::ExtractValue and llvm::InsertValue instances. + * + * @{ + */ + +/** + * Obtain the number of indices. + * NB: This also works on GEP. + */ +unsigned LLVMGetNumIndices(LLVMValueRef Inst); + +/** + * Obtain the indices as an array. + */ +const unsigned *LLVMGetIndices(LLVMValueRef Inst); + +/** + * @} + */ + +/** * @} */ @@ -2598,9 +2920,18 @@ void LLVMAddCase(LLVMValueRef Switch, LLVMValueRef OnVal, /* Add a destination to the indirectbr instruction */ void LLVMAddDestination(LLVMValueRef IndirectBr, LLVMBasicBlockRef Dest); +/* Get the number of clauses on the landingpad instruction */ +unsigned LLVMGetNumClauses(LLVMValueRef LandingPad); + +/* Get the value of the clause at idnex Idx on the landingpad instruction */ +LLVMValueRef LLVMGetClause(LLVMValueRef LandingPad, unsigned Idx); + /* Add a catch or filter clause to the landingpad instruction */ void LLVMAddClause(LLVMValueRef LandingPad, LLVMValueRef ClauseVal); +/* Get the 'cleanup' flag in the landingpad instruction */ +LLVMBool LLVMIsCleanup(LLVMValueRef LandingPad); + /* Set the 'cleanup' flag in the landingpad instruction */ void LLVMSetCleanup(LLVMValueRef LandingPad, LLVMBool Val); @@ -2780,6 +3111,21 @@ LLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B, LLVMAtomicRMWBinOp op, LLVMValueRef PTR, LLVMValueRef Val, LLVMAtomicOrdering ordering, LLVMBool singleThread); +LLVMValueRef LLVMBuildAtomicCmpXchg(LLVMBuilderRef B, LLVMValueRef Ptr, + LLVMValueRef Cmp, LLVMValueRef New, + LLVMAtomicOrdering SuccessOrdering, + LLVMAtomicOrdering FailureOrdering, + LLVMBool SingleThread); + +LLVMBool LLVMIsAtomicSingleThread(LLVMValueRef AtomicInst); +void LLVMSetAtomicSingleThread(LLVMValueRef AtomicInst, LLVMBool SingleThread); + +LLVMAtomicOrdering LLVMGetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst); +void LLVMSetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst, + LLVMAtomicOrdering Ordering); +LLVMAtomicOrdering LLVMGetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst); +void LLVMSetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst, + LLVMAtomicOrdering Ordering); /** * @} diff --git a/contrib/llvm/include/llvm-c/Disassembler.h b/contrib/llvm/include/llvm-c/Disassembler.h index d6cbe31c..d6f92e5 100644 --- a/contrib/llvm/include/llvm-c/Disassembler.h +++ b/contrib/llvm/include/llvm-c/Disassembler.h @@ -16,7 +16,11 @@ #define LLVM_C_DISASSEMBLER_H #include "llvm/Support/DataTypes.h" +#ifdef __cplusplus +#include <cstddef> +#else #include <stddef.h> +#endif /** * @defgroup LLVMCDisassembler Disassembler @@ -251,4 +255,4 @@ size_t LLVMDisasmInstruction(LLVMDisasmContextRef DC, uint8_t *Bytes, } #endif /* !defined(__cplusplus) */ -#endif /* !defined(LLVM_C_DISASSEMBLER_H) */ +#endif /* LLVM_C_DISASSEMBLER_H */ diff --git a/contrib/llvm/include/llvm-c/ErrorHandling.h b/contrib/llvm/include/llvm-c/ErrorHandling.h index 5a80bc5..2059b3a 100644 --- a/contrib/llvm/include/llvm-c/ErrorHandling.h +++ b/contrib/llvm/include/llvm-c/ErrorHandling.h @@ -14,8 +14,6 @@ #ifndef LLVM_C_ERROR_HANDLING_H #define LLVM_C_ERROR_HANDLING_H -#include "llvm-c/Types.h" - #ifdef __cplusplus extern "C" { #endif diff --git a/contrib/llvm/include/llvm-c/Linker.h b/contrib/llvm/include/llvm-c/Linker.h index 4d9bd46..d02c37f 100644 --- a/contrib/llvm/include/llvm-c/Linker.h +++ b/contrib/llvm/include/llvm-c/Linker.h @@ -28,20 +28,6 @@ typedef enum { } LLVMLinkerMode; /* Links the source module into the destination module. The source module is - * damaged. The only thing that can be done is destroy it. Optionally returns a - * human-readable description of any errors that occurred in linking. OutMessage - * must be disposed with LLVMDisposeMessage. The return value is true if an - * error occurred, false otherwise. - * - * Note that the linker mode parameter \p Unused is no longer used, and has - * no effect. - * - * This function is deprecated. Use LLVMLinkModules2 instead. - */ -LLVMBool LLVMLinkModules(LLVMModuleRef Dest, LLVMModuleRef Src, - LLVMLinkerMode Unused, char **OutMessage); - -/* Links the source module into the destination module. The source module is * destroyed. * The return value is true if an error occurred, false otherwise. * Use the diagnostic handler to get any diagnostic message. diff --git a/contrib/llvm/include/llvm-c/OrcBindings.h b/contrib/llvm/include/llvm-c/OrcBindings.h index f6aff91..de2969a 100644 --- a/contrib/llvm/include/llvm-c/OrcBindings.h +++ b/contrib/llvm/include/llvm-c/OrcBindings.h @@ -23,7 +23,6 @@ #define LLVM_C_ORCBINDINGS_H #include "llvm-c/Object.h" -#include "llvm-c/Support.h" #include "llvm-c/TargetMachine.h" #ifdef __cplusplus @@ -33,11 +32,12 @@ extern "C" { typedef struct LLVMOrcOpaqueJITStack *LLVMOrcJITStackRef; typedef uint32_t LLVMOrcModuleHandle; typedef uint64_t LLVMOrcTargetAddress; -typedef uint64_t (*LLVMOrcSymbolResolverFn)(const char *Name, - void *LookupCtx); +typedef uint64_t (*LLVMOrcSymbolResolverFn)(const char *Name, void *LookupCtx); typedef uint64_t (*LLVMOrcLazyCompileCallbackFn)(LLVMOrcJITStackRef JITStack, void *CallbackCtx); +typedef enum { LLVMOrcErrSuccess = 0, LLVMOrcErrGeneric } LLVMOrcErrorCode; + /** * Create an ORC JIT stack. * @@ -50,6 +50,14 @@ typedef uint64_t (*LLVMOrcLazyCompileCallbackFn)(LLVMOrcJITStackRef JITStack, LLVMOrcJITStackRef LLVMOrcCreateInstance(LLVMTargetMachineRef TM); /** + * Get the error message for the most recent error (if any). + * + * This message is owned by the ORC JIT Stack and will be freed when the stack + * is disposed of by LLVMOrcDisposeInstance. + */ +const char *LLVMOrcGetErrorMsg(LLVMOrcJITStackRef JITStack); + +/** * Mangle the given symbol. * Memory will be allocated for MangledSymbol to hold the result. The client */ @@ -59,7 +67,6 @@ void LLVMOrcGetMangledSymbol(LLVMOrcJITStackRef JITStack, char **MangledSymbol, /** * Dispose of a mangled symbol. */ - void LLVMOrcDisposeMangledSymbol(char *MangledSymbol); /** @@ -73,16 +80,16 @@ LLVMOrcCreateLazyCompileCallback(LLVMOrcJITStackRef JITStack, /** * Create a named indirect call stub. */ -void LLVMOrcCreateIndirectStub(LLVMOrcJITStackRef JITStack, - const char *StubName, - LLVMOrcTargetAddress InitAddr); +LLVMOrcErrorCode LLVMOrcCreateIndirectStub(LLVMOrcJITStackRef JITStack, + const char *StubName, + LLVMOrcTargetAddress InitAddr); /** * Set the pointer for the given indirect stub. */ -void LLVMOrcSetIndirectStubPointer(LLVMOrcJITStackRef JITStack, - const char *StubName, - LLVMOrcTargetAddress NewAddr); +LLVMOrcErrorCode LLVMOrcSetIndirectStubPointer(LLVMOrcJITStackRef JITStack, + const char *StubName, + LLVMOrcTargetAddress NewAddr); /** * Add module to be eagerly compiled. @@ -103,10 +110,10 @@ LLVMOrcAddLazilyCompiledIR(LLVMOrcJITStackRef JITStack, LLVMModuleRef Mod, /** * Add an object file. */ -LLVMOrcModuleHandle -LLVMOrcAddObjectFile(LLVMOrcJITStackRef JITStack, LLVMObjectFileRef Obj, - LLVMOrcSymbolResolverFn SymbolResolver, - void *SymbolResolverCtx); +LLVMOrcModuleHandle LLVMOrcAddObjectFile(LLVMOrcJITStackRef JITStack, + LLVMObjectFileRef Obj, + LLVMOrcSymbolResolverFn SymbolResolver, + void *SymbolResolverCtx); /** * Remove a module set from the JIT. diff --git a/contrib/llvm/include/llvm-c/Target.h b/contrib/llvm/include/llvm-c/Target.h index 24d2cb4..03004ba 100644 --- a/contrib/llvm/include/llvm-c/Target.h +++ b/contrib/llvm/include/llvm-c/Target.h @@ -183,14 +183,27 @@ static inline LLVMBool LLVMInitializeNativeDisassembler(void) { /*===-- Target Data -------------------------------------------------------===*/ +/** + * Obtain the data layout for a module. + * + * @see Module::getDataLayout() + */ +LLVMTargetDataRef LLVMGetModuleDataLayout(LLVMModuleRef M); + +/** + * Set the data layout for a module. + * + * @see Module::setDataLayout() + */ +void LLVMSetModuleDataLayout(LLVMModuleRef M, LLVMTargetDataRef DL); + /** Creates target data from a target layout string. See the constructor llvm::DataLayout::DataLayout. */ LLVMTargetDataRef LLVMCreateTargetData(const char *StringRep); -/** Adds target data information to a pass manager. This does not take ownership - of the target data. - See the method llvm::PassManagerBase::add. */ -void LLVMAddTargetData(LLVMTargetDataRef TD, LLVMPassManagerRef PM); +/** Deallocates a TargetData. + See the destructor llvm::DataLayout::~DataLayout. */ +void LLVMDisposeTargetData(LLVMTargetDataRef TD); /** Adds target library information to a pass manager. This does not take ownership of the target library info. @@ -275,10 +288,6 @@ unsigned LLVMElementAtOffset(LLVMTargetDataRef TD, LLVMTypeRef StructTy, unsigned long long LLVMOffsetOfElement(LLVMTargetDataRef TD, LLVMTypeRef StructTy, unsigned Element); -/** Deallocates a TargetData. - See the destructor llvm::DataLayout::~DataLayout. */ -void LLVMDisposeTargetData(LLVMTargetDataRef TD); - /** * @} */ diff --git a/contrib/llvm/include/llvm-c/TargetMachine.h b/contrib/llvm/include/llvm-c/TargetMachine.h index 3037080..1d1f61f 100644 --- a/contrib/llvm/include/llvm-c/TargetMachine.h +++ b/contrib/llvm/include/llvm-c/TargetMachine.h @@ -115,8 +115,8 @@ char *LLVMGetTargetMachineCPU(LLVMTargetMachineRef T); LLVMDisposeMessage. */ char *LLVMGetTargetMachineFeatureString(LLVMTargetMachineRef T); -/** Returns the llvm::DataLayout used for this llvm:TargetMachine. */ -LLVMTargetDataRef LLVMGetTargetMachineData(LLVMTargetMachineRef T); +/** Create a DataLayout based on the targetMachine. */ +LLVMTargetDataRef LLVMCreateTargetDataLayout(LLVMTargetMachineRef T); /** Set the target machine's ASM verbosity. */ void LLVMSetTargetMachineAsmVerbosity(LLVMTargetMachineRef T, diff --git a/contrib/llvm/include/llvm-c/Transforms/Scalar.h b/contrib/llvm/include/llvm-c/Transforms/Scalar.h index c989ee8..b8a0998 100644 --- a/contrib/llvm/include/llvm-c/Transforms/Scalar.h +++ b/contrib/llvm/include/llvm-c/Transforms/Scalar.h @@ -104,13 +104,13 @@ void LLVMAddReassociatePass(LLVMPassManagerRef PM); /** See llvm::createSCCPPass function. */ void LLVMAddSCCPPass(LLVMPassManagerRef PM); -/** See llvm::createScalarReplAggregatesPass function. */ +/** See llvm::createSROAPass function. */ void LLVMAddScalarReplAggregatesPass(LLVMPassManagerRef PM); -/** See llvm::createScalarReplAggregatesPass function. */ +/** See llvm::createSROAPass function. */ void LLVMAddScalarReplAggregatesPassSSA(LLVMPassManagerRef PM); -/** See llvm::createScalarReplAggregatesPass function. */ +/** See llvm::createSROAPass function. */ void LLVMAddScalarReplAggregatesPassWithThreshold(LLVMPassManagerRef PM, int Threshold); diff --git a/contrib/llvm/include/llvm-c/Types.h b/contrib/llvm/include/llvm-c/Types.h index 1902958..3d472a6 100644 --- a/contrib/llvm/include/llvm-c/Types.h +++ b/contrib/llvm/include/llvm-c/Types.h @@ -109,6 +109,13 @@ typedef struct LLVMOpaquePassRegistry *LLVMPassRegistryRef; typedef struct LLVMOpaqueUse *LLVMUseRef; /** + * Used to represent an attributes. + * + * @see llvm::Attribute + */ +typedef struct LLVMOpaqueAttributeRef *LLVMAttributeRef; + +/** * @see llvm::DiagnosticInfo */ typedef struct LLVMOpaqueDiagnosticInfo *LLVMDiagnosticInfoRef; diff --git a/contrib/llvm/include/llvm-c/lto.h b/contrib/llvm/include/llvm-c/lto.h index 691a0cd..b1f5a45 100644 --- a/contrib/llvm/include/llvm-c/lto.h +++ b/contrib/llvm/include/llvm-c/lto.h @@ -16,7 +16,11 @@ #ifndef LLVM_C_LTO_H #define LLVM_C_LTO_H +#ifdef __cplusplus +#include <cstddef> +#else #include <stddef.h> +#endif #include <sys/types.h> #ifndef __cplusplus @@ -40,7 +44,7 @@ typedef bool lto_bool_t; * @{ */ -#define LTO_API_VERSION 17 +#define LTO_API_VERSION 20 /** * \since prior to LTO_API_VERSION=3 @@ -91,6 +95,9 @@ typedef struct LLVMOpaqueLTOModule *lto_module_t; /** opaque reference to a code generator */ typedef struct LLVMOpaqueLTOCodeGenerator *lto_code_gen_t; +/** opaque reference to a thin code generator */ +typedef struct LLVMOpaqueThinLTOCodeGenerator *thinlto_code_gen_t; + #ifdef __cplusplus extern "C" { #endif @@ -103,7 +110,6 @@ extern "C" { extern const char* lto_get_version(void); - /** * Returns the last error string or NULL if last operation was successful. * @@ -120,7 +126,6 @@ lto_get_error_message(void); extern lto_bool_t lto_module_is_object_file(const char* path); - /** * Checks if a file is a loadable object compiled for requested target. * @@ -130,15 +135,22 @@ extern lto_bool_t lto_module_is_object_file_for_target(const char* path, const char* target_triple_prefix); - /** - * Checks if a buffer is a loadable object file. + * Return true if \p Buffer contains a bitcode file with ObjC code (category + * or class) in it. * - * \since prior to LTO_API_VERSION=3 + * \since LTO_API_VERSION=20 */ extern lto_bool_t -lto_module_is_object_file_in_memory(const void* mem, size_t length); +lto_module_has_objc_category(const void *mem, size_t length); +/** +* Checks if a buffer is a loadable object file. +* +* \since prior to LTO_API_VERSION=3 +*/ +extern lto_bool_t lto_module_is_object_file_in_memory(const void *mem, + size_t length); /** * Checks if a buffer is a loadable object compiled for requested target. @@ -149,7 +161,6 @@ extern lto_bool_t lto_module_is_object_file_in_memory_for_target(const void* mem, size_t length, const char* target_triple_prefix); - /** * Loads an object file from disk. * Returns NULL on error (check lto_get_error_message() for details). @@ -159,7 +170,6 @@ lto_module_is_object_file_in_memory_for_target(const void* mem, size_t length, extern lto_module_t lto_module_create(const char* path); - /** * Loads an object file from memory. * Returns NULL on error (check lto_get_error_message() for details). @@ -252,7 +262,6 @@ lto_module_get_target_triple(lto_module_t mod); extern void lto_module_set_target_triple(lto_module_t mod, const char *triple); - /** * Returns the number of symbols in the object module. * @@ -261,7 +270,6 @@ lto_module_set_target_triple(lto_module_t mod, const char *triple); extern unsigned int lto_module_get_num_symbols(lto_module_t mod); - /** * Returns the name of the ith symbol in the object module. * @@ -270,7 +278,6 @@ lto_module_get_num_symbols(lto_module_t mod); extern const char* lto_module_get_symbol_name(lto_module_t mod, unsigned int index); - /** * Returns the attributes of the ith symbol in the object module. * @@ -279,7 +286,6 @@ lto_module_get_symbol_name(lto_module_t mod, unsigned int index); extern lto_symbol_attributes lto_module_get_symbol_attribute(lto_module_t mod, unsigned int index); - /** * Returns the module's linker options. * @@ -291,7 +297,6 @@ lto_module_get_symbol_attribute(lto_module_t mod, unsigned int index); extern const char* lto_module_get_linkeropts(lto_module_t mod); - /** * Diagnostic severity. * @@ -393,7 +398,6 @@ lto_codegen_set_module(lto_code_gen_t cg, lto_module_t mod); extern lto_bool_t lto_codegen_set_debug_model(lto_code_gen_t cg, lto_debug_model); - /** * Sets which PIC code model to generated. * Returns true on error (check lto_get_error_message() for details). @@ -403,7 +407,6 @@ lto_codegen_set_debug_model(lto_code_gen_t cg, lto_debug_model); extern lto_bool_t lto_codegen_set_pic_model(lto_code_gen_t cg, lto_codegen_model); - /** * Sets the cpu to generate code for. * @@ -412,7 +415,6 @@ lto_codegen_set_pic_model(lto_code_gen_t cg, lto_codegen_model); extern void lto_codegen_set_cpu(lto_code_gen_t cg, const char *cpu); - /** * Sets the location of the assembler tool to run. If not set, libLTO * will use gcc to invoke the assembler. @@ -548,6 +550,242 @@ extern void lto_codegen_set_should_embed_uselists(lto_code_gen_t cg, lto_bool_t ShouldEmbedUselists); +/** + * @} + * @defgroup LLVMCTLTO ThinLTO + * @ingroup LLVMC + * + * @{ + */ + +/** + * Type to wrap a single object returned by ThinLTO. + * + * \since LTO_API_VERSION=18 + */ +typedef struct { + const char *Buffer; + size_t Size; +} LTOObjectBuffer; + +/** + * Instantiates a ThinLTO code generator. + * Returns NULL on error (check lto_get_error_message() for details). + * + * + * The ThinLTOCodeGenerator is not intended to be reuse for multiple + * compilation: the model is that the client adds modules to the generator and + * ask to perform the ThinLTO optimizations / codegen, and finally destroys the + * codegenerator. + * + * \since LTO_API_VERSION=18 + */ +extern thinlto_code_gen_t thinlto_create_codegen(void); + +/** + * Frees the generator and all memory it internally allocated. + * Upon return the thinlto_code_gen_t is no longer valid. + * + * \since LTO_API_VERSION=18 + */ +extern void thinlto_codegen_dispose(thinlto_code_gen_t cg); + +/** + * Add a module to a ThinLTO code generator. Identifier has to be unique among + * all the modules in a code generator. The data buffer stays owned by the + * client, and is expected to be available for the entire lifetime of the + * thinlto_code_gen_t it is added to. + * + * On failure, returns NULL (check lto_get_error_message() for details). + * + * + * \since LTO_API_VERSION=18 + */ +extern void thinlto_codegen_add_module(thinlto_code_gen_t cg, + const char *identifier, const char *data, + int length); + +/** + * Optimize and codegen all the modules added to the codegenerator using + * ThinLTO. Resulting objects are accessible using thinlto_module_get_object(). + * + * \since LTO_API_VERSION=18 + */ +extern void thinlto_codegen_process(thinlto_code_gen_t cg); + +/** + * Returns the number of object files produced by the ThinLTO CodeGenerator. + * + * It usually matches the number of input files, but this is not a guarantee of + * the API and may change in future implementation, so the client should not + * assume it. + * + * \since LTO_API_VERSION=18 + */ +extern unsigned int thinlto_module_get_num_objects(thinlto_code_gen_t cg); + +/** + * Returns a reference to the ith object file produced by the ThinLTO + * CodeGenerator. + * + * Client should use \p thinlto_module_get_num_objects() to get the number of + * available objects. + * + * \since LTO_API_VERSION=18 + */ +extern LTOObjectBuffer thinlto_module_get_object(thinlto_code_gen_t cg, + unsigned int index); + +/** + * Sets which PIC code model to generate. + * Returns true on error (check lto_get_error_message() for details). + * + * \since LTO_API_VERSION=18 + */ +extern lto_bool_t thinlto_codegen_set_pic_model(thinlto_code_gen_t cg, + lto_codegen_model); + +/** + * @} + * @defgroup LLVMCTLTO_CACHING ThinLTO Cache Control + * @ingroup LLVMCTLTO + * + * These entry points control the ThinLTO cache. The cache is intended to + * support incremental build, and thus needs to be persistent accross build. + * The client enabled the cache by supplying a path to an existing directory. + * The code generator will use this to store objects files that may be reused + * during a subsequent build. + * To avoid filling the disk space, a few knobs are provided: + * - The pruning interval limit the frequency at which the garbage collector + * will try to scan the cache directory to prune it from expired entries. + * Setting to -1 disable the pruning (default). + * - The pruning expiration time indicates to the garbage collector how old an + * entry needs to be to be removed. + * - Finally, the garbage collector can be instructed to prune the cache till + * the occupied space goes below a threshold. + * @{ + */ + +/** + * Sets the path to a directory to use as a cache storage for incremental build. + * Setting this activates caching. + * + * \since LTO_API_VERSION=18 + */ +extern void thinlto_codegen_set_cache_dir(thinlto_code_gen_t cg, + const char *cache_dir); + +/** + * Sets the cache pruning interval (in seconds). A negative value disable the + * pruning. An unspecified default value will be applied, and a value of 0 will + * be ignored. + * + * \since LTO_API_VERSION=18 + */ +extern void thinlto_codegen_set_cache_pruning_interval(thinlto_code_gen_t cg, + int interval); + +/** + * Sets the maximum cache size that can be persistent across build, in terms of + * percentage of the available space on the the disk. Set to 100 to indicate + * no limit, 50 to indicate that the cache size will not be left over half the + * available space. A value over 100 will be reduced to 100, a value of 0 will + * be ignored. An unspecified default value will be applied. + * + * The formula looks like: + * AvailableSpace = FreeSpace + ExistingCacheSize + * NewCacheSize = AvailableSpace * P/100 + * + * \since LTO_API_VERSION=18 + */ +extern void thinlto_codegen_set_final_cache_size_relative_to_available_space( + thinlto_code_gen_t cg, unsigned percentage); + +/** + * Sets the expiration (in seconds) for an entry in the cache. An unspecified + * default value will be applied. A value of 0 will be ignored. + * + * \since LTO_API_VERSION=18 + */ +extern void thinlto_codegen_set_cache_entry_expiration(thinlto_code_gen_t cg, + unsigned expiration); + +/** + * @} + */ + +/** + * Sets the path to a directory to use as a storage for temporary bitcode files. + * The intention is to make the bitcode files available for debugging at various + * stage of the pipeline. + * + * \since LTO_API_VERSION=18 + */ +extern void thinlto_codegen_set_savetemps_dir(thinlto_code_gen_t cg, + const char *save_temps_dir); + +/** + * Sets the cpu to generate code for. + * + * \since LTO_API_VERSION=18 + */ +extern void thinlto_codegen_set_cpu(thinlto_code_gen_t cg, const char *cpu); + +/** + * Disable CodeGen, only run the stages till codegen and stop. The output will + * be bitcode. + * + * \since LTO_API_VERSION=19 + */ +extern void thinlto_codegen_disable_codegen(thinlto_code_gen_t cg, + lto_bool_t disable); + +/** + * Perform CodeGen only: disable all other stages. + * + * \since LTO_API_VERSION=19 + */ +extern void thinlto_codegen_set_codegen_only(thinlto_code_gen_t cg, + lto_bool_t codegen_only); + +/** + * Parse -mllvm style debug options. + * + * \since LTO_API_VERSION=18 + */ +extern void thinlto_debug_options(const char *const *options, int number); + +/** + * Test if a module has support for ThinLTO linking. + * + * \since LTO_API_VERSION=18 + */ +extern lto_bool_t lto_module_is_thinlto(lto_module_t mod); + +/** + * Adds a symbol to the list of global symbols that must exist in the final + * generated code. If a function is not listed there, it might be inlined into + * every usage and optimized away. For every single module, the functions + * referenced from code outside of the ThinLTO modules need to be added here. + * + * \since LTO_API_VERSION=18 + */ +extern void thinlto_codegen_add_must_preserve_symbol(thinlto_code_gen_t cg, + const char *name, + int length); + +/** + * Adds a symbol to the list of global symbols that are cross-referenced between + * ThinLTO files. If the ThinLTO CodeGenerator can ensure that every + * references from a ThinLTO module to this symbol is optimized away, then + * the symbol can be discarded. + * + * \since LTO_API_VERSION=18 + */ +extern void thinlto_codegen_add_cross_referenced_symbol(thinlto_code_gen_t cg, + const char *name, + int length); + #ifdef __cplusplus } #endif @@ -556,4 +794,4 @@ lto_codegen_set_should_embed_uselists(lto_code_gen_t cg, * @} */ -#endif +#endif /* LLVM_C_LTO_H */ |