Merge pull request #2805 from odin-lang/llvm-17

Support LLVM 17.0.1
This commit is contained in:
gingerBill
2023-09-28 16:01:26 +01:00
committed by GitHub
60 changed files with 3718 additions and 1270 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -114,4 +114,4 @@ if %release_mode% EQU 0 odin run examples/demo
del *.obj > NUL 2> NUL
:end_of_build
:end_of_build

View File

@@ -254,6 +254,7 @@ Typeid_Kind :: enum u8 {
Relative_Pointer,
Relative_Multi_Pointer,
Matrix,
Soa_Pointer,
}
#assert(len(Typeid_Kind) < 32)
@@ -510,6 +511,19 @@ Odin_Endian_Type :: type_of(ODIN_ENDIAN)
*/
Odin_Platform_Subtarget_Type :: type_of(ODIN_PLATFORM_SUBTARGET)
/*
// Defined internally by the compiler
Odin_Sanitizer_Flag :: enum u32 {
Address = 0,
Memory = 1,
Thread = 2,
}
Odin_Sanitizer_Flags :: distinct bitset[Odin_Sanitizer_Flag; u32]
ODIN_SANITIZER_FLAGS // is a constant
*/
Odin_Sanitizer_Flags :: type_of(ODIN_SANITIZER_FLAGS)
/////////////////////////////
// Init Startup Procedures //

View File

@@ -13,6 +13,9 @@ RUNTIME_LINKAGE :: "strong" when (
!IS_WASM) else "internal"
RUNTIME_REQUIRE :: !ODIN_TILDE
@(private)
__float16 :: f16 when __ODIN_LLVM_F16_SUPPORTED else u16
@(private)
byte_slice :: #force_inline proc "contextless" (data: rawptr, len: int) -> []byte #no_bounds_check {
@@ -797,7 +800,7 @@ quo_quaternion256 :: proc "contextless" (q, r: quaternion256) -> quaternion256 {
}
@(link_name="__truncsfhf2", linkage=RUNTIME_LINKAGE, require=RUNTIME_REQUIRE)
truncsfhf2 :: proc "c" (value: f32) -> u16 {
truncsfhf2 :: proc "c" (value: f32) -> __float16 {
v: struct #raw_union { i: u32, f: f32 }
i, s, e, m: i32
@@ -811,7 +814,7 @@ truncsfhf2 :: proc "c" (value: f32) -> u16 {
if e <= 0 {
if e < -10 {
return u16(s)
return transmute(__float16)u16(s)
}
m = (m | 0x00800000) >> u32(1 - e)
@@ -819,14 +822,14 @@ truncsfhf2 :: proc "c" (value: f32) -> u16 {
m += 0x00002000
}
return u16(s | (m >> 13))
return transmute(__float16)u16(s | (m >> 13))
} else if e == 0xff - (127 - 15) {
if m == 0 {
return u16(s | 0x7c00) /* NOTE(bill): infinity */
return transmute(__float16)u16(s | 0x7c00) /* NOTE(bill): infinity */
} else {
/* NOTE(bill): NAN */
m >>= 13
return u16(s | 0x7c00 | m | i32(m == 0))
return transmute(__float16)u16(s | 0x7c00 | m | i32(m == 0))
}
} else {
if m & 0x00001000 != 0 {
@@ -846,23 +849,24 @@ truncsfhf2 :: proc "c" (value: f32) -> u16 {
intrinsics.volatile_store(&f, g)
}
return u16(s | 0x7c00)
return transmute(__float16)u16(s | 0x7c00)
}
return u16(s | (e << 10) | (m >> 13))
return transmute(__float16)u16(s | (e << 10) | (m >> 13))
}
}
@(link_name="__truncdfhf2", linkage=RUNTIME_LINKAGE, require=RUNTIME_REQUIRE)
truncdfhf2 :: proc "c" (value: f64) -> u16 {
truncdfhf2 :: proc "c" (value: f64) -> __float16 {
return truncsfhf2(f32(value))
}
@(link_name="__gnu_h2f_ieee", linkage=RUNTIME_LINKAGE, require=RUNTIME_REQUIRE)
gnu_h2f_ieee :: proc "c" (value: u16) -> f32 {
gnu_h2f_ieee :: proc "c" (value_: __float16) -> f32 {
fp32 :: struct #raw_union { u: u32, f: f32 }
value := transmute(u16)value_
v: fp32
magic, inf_or_nan: fp32
magic.u = u32((254 - 15) << 23)
@@ -879,12 +883,12 @@ gnu_h2f_ieee :: proc "c" (value: u16) -> f32 {
@(link_name="__gnu_f2h_ieee", linkage=RUNTIME_LINKAGE, require=RUNTIME_REQUIRE)
gnu_f2h_ieee :: proc "c" (value: f32) -> u16 {
gnu_f2h_ieee :: proc "c" (value: f32) -> __float16 {
return truncsfhf2(value)
}
@(link_name="__extendhfsf2", linkage=RUNTIME_LINKAGE, require=RUNTIME_REQUIRE)
extendhfsf2 :: proc "c" (value: u16) -> f32 {
extendhfsf2 :: proc "c" (value: __float16) -> f32 {
return gnu_h2f_ieee(value)
}

View File

@@ -314,6 +314,14 @@ gb_internal void array_add(Array<T> *array, T const &t) {
array->count++;
}
gb_internal void array_add(Array<char const *> *array, char const *t) {
if (array->capacity < array->count+1) {
array__grow(array, 0);
}
array->data[array->count] = t;
array->count++;
}
template <typename T>
gb_internal T *array_add_and_get(Array<T> *array) {
if (array->count < array->capacity) {

View File

@@ -264,6 +264,14 @@ u64 get_vet_flag_from_name(String const &name) {
}
enum SanitizerFlags : u32 {
SanitizerFlag_NONE = 0,
SanitizerFlag_Address = 1u<<0,
SanitizerFlag_Memory = 1u<<1,
SanitizerFlag_Thread = 1u<<2,
};
// This stores the information for the specify architecture of this build
struct BuildContext {
@@ -305,6 +313,7 @@ struct BuildContext {
String pdb_filepath;
u64 vet_flags;
u32 sanitizer_flags;
bool has_resource;
String link_flags;
@@ -1381,7 +1390,7 @@ gb_internal void init_build_context(TargetMetrics *cross_target, Subtarget subta
bc->optimization_level = -1; // -o:none
}
bc->optimization_level = gb_clamp(bc->optimization_level, -1, 2);
bc->optimization_level = gb_clamp(bc->optimization_level, -1, 3);
// ENFORCE DYNAMIC MAP CALLS
bc->dynamic_map_calls = true;
@@ -1738,6 +1747,42 @@ gb_internal bool init_build_paths(String init_filename) {
return false;
}
if (build_context.sanitizer_flags & SanitizerFlag_Address) {
switch (build_context.metrics.os) {
case TargetOs_windows:
case TargetOs_linux:
case TargetOs_darwin:
break;
default:
gb_printf_err("-sanitize:address is only supported on windows, linux, and darwin\n");
return false;
}
}
if (build_context.sanitizer_flags & SanitizerFlag_Memory) {
switch (build_context.metrics.os) {
case TargetOs_linux:
break;
default:
gb_printf_err("-sanitize:memory is only supported on linux\n");
return false;
}
if (build_context.metrics.os != TargetOs_linux) {
return false;
}
}
if (build_context.sanitizer_flags & SanitizerFlag_Thread) {
switch (build_context.metrics.os) {
case TargetOs_linux:
case TargetOs_darwin:
break;
default:
gb_printf_err("-sanitize:thread is only supported on linux and darwin\n");
return false;
}
}
if (bc->target_features_string.len != 0) {
enable_target_feature({}, bc->target_features_string);

View File

@@ -1336,10 +1336,6 @@ gb_internal void check_proc_group_decl(CheckerContext *ctx, Entity *pg_entity, D
is_invalid = true;
break;
case ProcOverload_Polymorphic:
#if 0
error(p->token, "Overloaded procedure '%.*s' has a polymorphic counterpart in the procedure group '%.*s' which is not allowed", LIT(name), LIT(proc_group_name));
is_invalid = true;
#endif
break;
case ProcOverload_ParamCount:
case ProcOverload_ParamTypes:

View File

@@ -3683,18 +3683,7 @@ gb_internal void check_binary_expr(CheckerContext *c, Operand *x, Ast *node, Typ
ExactValue b = y->value;
if (!is_type_constant_type(x->type)) {
#if 0
gbString xt = type_to_string(x->type);
gbString err_str = expr_to_string(node);
error(op, "Invalid type, '%s', for constant binary expression '%s'", xt, err_str);
gb_string_free(err_str);
gb_string_free(xt);
x->mode = Addressing_Invalid;
#else
// NOTE(bill, 2021-04-21): The above is literally a useless error message.
// Why did I add it in the first place?!
x->mode = Addressing_Value;
#endif
return;
}

View File

@@ -1059,24 +1059,6 @@ gb_internal void check_bit_set_type(CheckerContext *c, Type *type, Type *named_t
} else {
Type *elem = check_type_expr(c, bs->elem, nullptr);
#if 0
if (named_type != nullptr && named_type->kind == Type_Named &&
elem->kind == Type_Enum) {
// NOTE(bill): Anonymous enumeration
String prefix = named_type->Named.name;
String enum_name = concatenate_strings(heap_allocator(), prefix, str_lit(".enum"));
Token token = make_token_ident(enum_name);
Entity *e = alloc_entity_type_name(nullptr, token, nullptr, EntityState_Resolved);
Type *named = alloc_type_named(enum_name, elem, e);
e->type = named;
e->TypeName.is_type_alias = true;
elem = named;
}
#endif
type->BitSet.elem = elem;
if (!is_type_valid_bit_set_elem(elem)) {
error(bs->elem, "Expected an enum type for a bit_set");

View File

@@ -858,7 +858,7 @@ gb_internal AstPackage *create_builtin_package(char const *name) {
gbAllocator a = permanent_allocator();
AstPackage *pkg = gb_alloc_item(a, AstPackage);
pkg->name = make_string_c(name);
pkg->kind = Package_Normal;
pkg->kind = Package_Builtin;
pkg->scope = create_scope(nullptr, nullptr);
pkg->scope->flags |= ScopeFlag_Pkg | ScopeFlag_Global | ScopeFlag_Builtin;
@@ -935,6 +935,7 @@ gb_internal i64 odin_compile_timestamp(void) {
return ns_after_1970;
}
gb_internal bool lb_use_new_pass_system(void);
gb_internal void init_universal(void) {
BuildContext *bc = &build_context;
@@ -1083,6 +1084,35 @@ gb_internal void init_universal(void) {
add_global_constant("ODIN_COMPILE_TIMESTAMP", t_untyped_integer, exact_value_i64(odin_compile_timestamp()));
add_global_bool_constant("__ODIN_LLVM_F16_SUPPORTED", lb_use_new_pass_system());
{
GlobalEnumValue values[3] = {
{"Address", 0},
{"Memory", 1},
{"Thread", 2},
};
Type *enum_type = nullptr;
auto flags = add_global_enum_type(str_lit("Odin_Sanitizer_Flag"), values, gb_count_of(values), &enum_type);
Type *bit_set_type = alloc_type_bit_set();
bit_set_type->BitSet.elem = enum_type;
bit_set_type->BitSet.underlying = t_u32;
bit_set_type->BitSet.lower = 0;
bit_set_type->BitSet.upper = 2;
type_size_of(bit_set_type);
String type_name = str_lit("Odin_Sanitizer_Flags");
Scope *scope = create_scope(nullptr, builtin_pkg->scope);
Entity *entity = alloc_entity_type_name(scope, make_token_ident(type_name), nullptr, EntityState_Resolved);
Type *named_type = alloc_type_named(type_name, bit_set_type, entity);
set_base_type(named_type, bit_set_type);
add_global_constant("ODIN_SANITIZER_FLAGS", named_type, exact_value_u64(bc->sanitizer_flags));
}
// Builtin Procedures
for (isize i = 0; i < gb_count_of(builtin_procs); i++) {

View File

@@ -1101,11 +1101,9 @@ gb_internal void odin_doc_write_docs(OdinDocWriter *w) {
case Package_Init:
pkg_flags |= OdinDocPkgFlag_Init;
break;
}
if (pkg->name == "builtin") {
pkg_flags |= OdinDocPkgFlag_Builtin;
} else if (pkg->name == "intrinsics") {
case Package_Builtin:
pkg_flags |= OdinDocPkgFlag_Builtin;
break;
}
OdinDocPkg doc_pkg = {};

View File

@@ -61,8 +61,13 @@ LLVMBool LLVMGetBitcodeModuleInContext(LLVMContextRef ContextRef,
LLVMMemoryBufferRef MemBuf,
LLVMModuleRef *OutM, char **OutMessage);
/** Reads a module from the specified path, returning via the OutMP parameter a
* module provider which performs lazy deserialization. Returns 0 on success. */
/** Reads a module from the given memory buffer, returning via the OutMP
* parameter a module provider which performs lazy deserialization.
*
* Returns 0 on success.
*
* Takes ownership of \p MemBuf if (and only if) the module was read
* successfully. */
LLVMBool LLVMGetBitcodeModuleInContext2(LLVMContextRef ContextRef,
LLVMMemoryBufferRef MemBuf,
LLVMModuleRef *OutM);

View File

@@ -19,14 +19,20 @@
LLVM_C_EXTERN_C_BEGIN
/**
* @defgroup LLVMCCoreComdat Comdats
* @ingroup LLVMCCore
*
* @{
*/
typedef enum {
LLVMAnyComdatSelectionKind, ///< The linker may choose any COMDAT.
LLVMExactMatchComdatSelectionKind, ///< The data referenced by the COMDAT must
///< be the same.
LLVMLargestComdatSelectionKind, ///< The linker will choose the largest
///< COMDAT.
LLVMNoDuplicatesComdatSelectionKind, ///< No other Module may specify this
///< COMDAT.
LLVMNoDeduplicateComdatSelectionKind, ///< No deduplication is performed.
LLVMSameSizeComdatSelectionKind ///< The data referenced by the COMDAT must be
///< the same size.
} LLVMComdatSelectionKind;
@@ -67,6 +73,10 @@ LLVMComdatSelectionKind LLVMGetComdatSelectionKind(LLVMComdatRef C);
*/
void LLVMSetComdatSelectionKind(LLVMComdatRef C, LLVMComdatSelectionKind Kind);
/**
* @}
*/
LLVM_C_EXTERN_C_END
#endif

View File

@@ -1,4 +1,4 @@
/*===------- llvm/Config/abi-breaking.h - llvm configuration -------*- C -*-===*/
/*===------- llvm-c/Config//abi-breaking.h - llvm configuration -------*- C -*-===*/
/* */
/* Part of the LLVM Project, under the Apache License v2.0 with LLVM */
/* Exceptions. */

View File

@@ -1,4 +1,4 @@
/*===------- llvm/Config/llvm-config.h - llvm configuration -------*- C -*-===*/
/*===------- llvm-c/Config//llvm-config.h - llvm configuration -------*- C -*-===*/
/* */
/* Part of the LLVM Project, under the Apache License v2.0 with LLVM */
/* Exceptions. */
@@ -66,7 +66,7 @@
#define LLVM_USE_PERF 0
/* Major version of the LLVM API */
#define LLVM_VERSION_MAJOR 12
#define LLVM_VERSION_MAJOR 17
/* Minor version of the LLVM API */
#define LLVM_VERSION_MINOR 0
@@ -75,7 +75,7 @@
#define LLVM_VERSION_PATCH 1
/* LLVM version string */
#define LLVM_VERSION_STRING "12.0.1"
#define LLVM_VERSION_STRING "17.0.1"
/* Whether LLVM records statistics for use with GetStatistics(),
* PrintStatistics() or PrintStatisticsJSON()

View File

@@ -15,8 +15,10 @@
#ifndef LLVM_C_CORE_H
#define LLVM_C_CORE_H
#include "llvm-c/Deprecated.h"
#include "llvm-c/ErrorHandling.h"
#include "llvm-c/ExternC.h"
#include "llvm-c/Types.h"
LLVM_C_EXTERN_C_BEGIN
@@ -163,7 +165,8 @@ typedef enum {
LLVMTokenTypeKind, /**< Tokens */
LLVMScalableVectorTypeKind, /**< Scalable SIMD vector type */
LLVMBFloatTypeKind, /**< 16 bit brain floating point type */
LLVMX86_AMXTypeKind /**< X86 AMX */
LLVMX86_AMXTypeKind, /**< X86 AMX */
LLVMTargetExtTypeKind, /**< Target extension type */
} LLVMTypeKind;
typedef enum {
@@ -282,7 +285,8 @@ typedef enum {
LLVMInlineAsmValueKind,
LLVMInstructionValueKind,
LLVMPoisonValueValueKind
LLVMPoisonValueValueKind,
LLVMConstantTargetNoneValueKind,
} LLVMValueKind;
typedef enum {
@@ -379,8 +383,14 @@ typedef enum {
the old one */
LLVMAtomicRMWBinOpFAdd, /**< Add a floating point value and return the
old one */
LLVMAtomicRMWBinOpFSub /**< Subtract a floating point value and return the
old one */
LLVMAtomicRMWBinOpFSub, /**< Subtract a floating point value and return the
old one */
LLVMAtomicRMWBinOpFMax, /**< Sets the value if it's greater than the
original using an floating point comparison and
return the old one */
LLVMAtomicRMWBinOpFMin, /**< Sets the value if it's smaller than the
original using an floating point comparison and
return the old one */
} LLVMAtomicRMWBinOp;
typedef enum {
@@ -464,13 +474,21 @@ typedef unsigned LLVMAttributeIndex;
* @}
*/
void LLVMInitializeCore(LLVMPassRegistryRef R);
/** Deallocate and destroy all ManagedStatic variables.
@see llvm::llvm_shutdown
@see ManagedStatic */
void LLVMShutdown(void);
/*===-- Version query -----------------------------------------------------===*/
/**
* Return the major, minor, and patch version of LLVM
*
* The version components are returned via the function's three output
* parameters or skipped if a NULL pointer was supplied.
*/
void LLVMGetVersion(unsigned *Major, unsigned *Minor, unsigned *Patch);
/*===-- Error handling ----------------------------------------------------===*/
char *LLVMCreateMessage(const char *Message);
@@ -872,11 +890,11 @@ void LLVMAppendModuleInlineAsm(LLVMModuleRef M, const char *Asm, size_t Len);
*
* @see InlineAsm::get()
*/
LLVMValueRef LLVMGetInlineAsm(LLVMTypeRef Ty,
char *AsmString, size_t AsmStringSize,
char *Constraints, size_t ConstraintsSize,
LLVMBool HasSideEffects, LLVMBool IsAlignStack,
LLVMInlineAsmDialect Dialect);
LLVMValueRef LLVMGetInlineAsm(LLVMTypeRef Ty, char *AsmString,
size_t AsmStringSize, char *Constraints,
size_t ConstraintsSize, LLVMBool HasSideEffects,
LLVMBool IsAlignStack,
LLVMInlineAsmDialect Dialect, LLVMBool CanThrow);
/**
* Obtain the context to which this module is associated.
@@ -1389,9 +1407,7 @@ LLVMBool LLVMIsLiteralStruct(LLVMTypeRef StructTy);
*/
/**
* Obtain the type of elements within a sequential type.
*
* This works on array, vector, and pointer types.
* Obtain the element type of an array or vector type.
*
* @see llvm::SequentialType::getElementType()
*/
@@ -1417,10 +1433,33 @@ unsigned LLVMGetNumContainedTypes(LLVMTypeRef Tp);
* The created type will exist in the context that its element type
* exists in.
*
* @deprecated LLVMArrayType is deprecated in favor of the API accurate
* LLVMArrayType2
* @see llvm::ArrayType::get()
*/
LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount);
/**
* Create a fixed size array type that refers to a specific type.
*
* The created type will exist in the context that its element type
* exists in.
*
* @see llvm::ArrayType::get()
*/
LLVMTypeRef LLVMArrayType2(LLVMTypeRef ElementType, uint64_t ElementCount);
/**
* Obtain the length of an array type.
*
* This only works on types that represent arrays.
*
* @deprecated LLVMGetArrayLength is deprecated in favor of the API accurate
* LLVMGetArrayLength2
* @see llvm::ArrayType::getNumElements()
*/
unsigned LLVMGetArrayLength(LLVMTypeRef ArrayTy);
/**
* Obtain the length of an array type.
*
@@ -1428,7 +1467,7 @@ LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount);
*
* @see llvm::ArrayType::getNumElements()
*/
unsigned LLVMGetArrayLength(LLVMTypeRef ArrayTy);
uint64_t LLVMGetArrayLength2(LLVMTypeRef ArrayTy);
/**
* Create a pointer type that points to a defined type.
@@ -1440,6 +1479,22 @@ unsigned LLVMGetArrayLength(LLVMTypeRef ArrayTy);
*/
LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, unsigned AddressSpace);
/**
* Determine whether a pointer is opaque.
*
* True if this is an instance of an opaque PointerType.
*
* @see llvm::Type::isOpaquePointerTy()
*/
LLVMBool LLVMPointerTypeIsOpaque(LLVMTypeRef Ty);
/**
* Create an opaque pointer type in a context.
*
* @see llvm::PointerType::get()
*/
LLVMTypeRef LLVMPointerTypeInContext(LLVMContextRef C, unsigned AddressSpace);
/**
* Obtain the address space of a pointer type.
*
@@ -1530,6 +1585,15 @@ LLVMTypeRef LLVMLabelType(void);
LLVMTypeRef LLVMX86MMXType(void);
LLVMTypeRef LLVMX86AMXType(void);
/**
* Create a target extension type in LLVM context.
*/
LLVMTypeRef LLVMTargetExtTypeInContext(LLVMContextRef C, const char *Name,
LLVMTypeRef *TypeParams,
unsigned TypeParamCount,
unsigned *IntParams,
unsigned IntParamCount);
/**
* @}
*/
@@ -1580,10 +1644,10 @@ LLVMTypeRef LLVMX86AMXType(void);
macro(ConstantVector) \
macro(GlobalValue) \
macro(GlobalAlias) \
macro(GlobalIFunc) \
macro(GlobalObject) \
macro(Function) \
macro(GlobalVariable) \
macro(GlobalIFunc) \
macro(UndefValue) \
macro(PoisonValue) \
macro(Instruction) \
@@ -1740,6 +1804,7 @@ LLVMBool LLVMIsPoison(LLVMValueRef Val);
LLVM_FOR_EACH_VALUE_SUBCLASS(LLVM_DECLARE_VALUE_CAST)
LLVMValueRef LLVMIsAMDNode(LLVMValueRef Val);
LLVMValueRef LLVMIsAValueAsMetadata(LLVMValueRef Val);
LLVMValueRef LLVMIsAMDString(LLVMValueRef Val);
/** Deprecated: Use LLVMGetValueName2 instead. */
@@ -2072,11 +2137,21 @@ LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count,
/**
* Create a ConstantArray from values.
*
* @deprecated LLVMConstArray is deprecated in favor of the API accurate
* LLVMConstArray2
* @see llvm::ConstantArray::get()
*/
LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy,
LLVMValueRef *ConstantVals, unsigned Length);
/**
* Create a ConstantArray from values.
*
* @see llvm::ConstantArray::get()
*/
LLVMValueRef LLVMConstArray2(LLVMTypeRef ElementTy, LLVMValueRef *ConstantVals,
uint64_t Length);
/**
* Create a non-anonymous ConstantStruct from values.
*
@@ -2086,12 +2161,24 @@ LLVMValueRef LLVMConstNamedStruct(LLVMTypeRef StructTy,
LLVMValueRef *ConstantVals,
unsigned Count);
/**
* Get element of a constant aggregate (struct, array or vector) at the
* specified index. Returns null if the index is out of range, or it's not
* possible to determine the element (e.g., because the constant is a
* constant expression.)
*
* @see llvm::Constant::getAggregateElement()
*/
LLVMValueRef LLVMGetAggregateElement(LLVMValueRef C, unsigned Idx);
/**
* Get an element at specified index as a constant.
*
* @see ConstantDataSequential::getElementAsConstant()
*/
LLVMValueRef LLVMGetElementAsConstant(LLVMValueRef C, unsigned idx);
LLVM_ATTRIBUTE_C_DEPRECATED(
LLVMValueRef LLVMGetElementAsConstant(LLVMValueRef C, unsigned idx),
"Use LLVMGetAggregateElement instead");
/**
* Create a ConstantVector from values.
@@ -2119,28 +2206,16 @@ LLVMValueRef LLVMSizeOf(LLVMTypeRef Ty);
LLVMValueRef LLVMConstNeg(LLVMValueRef ConstantVal);
LLVMValueRef LLVMConstNSWNeg(LLVMValueRef ConstantVal);
LLVMValueRef LLVMConstNUWNeg(LLVMValueRef ConstantVal);
LLVMValueRef LLVMConstFNeg(LLVMValueRef ConstantVal);
LLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal);
LLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstNSWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstNUWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstFAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstNSWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstNUWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstFSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstNSWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstNUWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstFMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstUDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstExactUDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstExactSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstFDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstURem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstSRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstFRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstAnd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstOr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
@@ -2151,13 +2226,8 @@ LLVMValueRef LLVMConstFCmp(LLVMRealPredicate Predicate,
LLVMValueRef LLVMConstShl(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstLShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstAShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstGEP(LLVMValueRef ConstantVal,
LLVMValueRef *ConstantIndices, unsigned NumIndices);
LLVMValueRef LLVMConstGEP2(LLVMTypeRef Ty, LLVMValueRef ConstantVal,
LLVMValueRef *ConstantIndices, unsigned NumIndices);
LLVMValueRef LLVMConstInBoundsGEP(LLVMValueRef ConstantVal,
LLVMValueRef *ConstantIndices,
unsigned NumIndices);
LLVMValueRef LLVMConstInBoundsGEP2(LLVMTypeRef Ty, LLVMValueRef ConstantVal,
LLVMValueRef *ConstantIndices,
unsigned NumIndices);
@@ -2185,9 +2255,6 @@ LLVMValueRef LLVMConstPointerCast(LLVMValueRef ConstantVal,
LLVMValueRef LLVMConstIntCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType,
LLVMBool isSigned);
LLVMValueRef LLVMConstFPCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
LLVMValueRef LLVMConstSelect(LLVMValueRef ConstantCondition,
LLVMValueRef ConstantIfTrue,
LLVMValueRef ConstantIfFalse);
LLVMValueRef LLVMConstExtractElement(LLVMValueRef VectorConstant,
LLVMValueRef IndexConstant);
LLVMValueRef LLVMConstInsertElement(LLVMValueRef VectorConstant,
@@ -2196,11 +2263,6 @@ LLVMValueRef LLVMConstInsertElement(LLVMValueRef VectorConstant,
LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant,
LLVMValueRef VectorBConstant,
LLVMValueRef MaskConstant);
LLVMValueRef LLVMConstExtractValue(LLVMValueRef AggConstant, unsigned *IdxList,
unsigned NumIdx);
LLVMValueRef LLVMConstInsertValue(LLVMValueRef AggConstant,
LLVMValueRef ElementValueConstant,
unsigned *IdxList, unsigned NumIdx);
LLVMValueRef LLVMBlockAddress(LLVMValueRef F, LLVMBasicBlockRef BB);
/** Deprecated: Use LLVMGetInlineAsm instead. */
@@ -2261,6 +2323,8 @@ void LLVMSetUnnamedAddr(LLVMValueRef Global, LLVMBool HasUnnamedAddr);
* @see llvm::AllocaInst::getAlignment()
* @see llvm::LoadInst::getAlignment()
* @see llvm::StoreInst::getAlignment()
* @see llvm::AtomicRMWInst::setAlignment()
* @see llvm::AtomicCmpXchgInst::setAlignment()
* @see llvm::GlobalValue::getAlignment()
*/
unsigned LLVMGetAlignment(LLVMValueRef V);
@@ -2270,6 +2334,8 @@ unsigned LLVMGetAlignment(LLVMValueRef V);
* @see llvm::AllocaInst::setAlignment()
* @see llvm::LoadInst::setAlignment()
* @see llvm::StoreInst::setAlignment()
* @see llvm::AtomicRMWInst::setAlignment()
* @see llvm::AtomicCmpXchgInst::setAlignment()
* @see llvm::GlobalValue::setAlignment()
*/
void LLVMSetAlignment(LLVMValueRef V, unsigned Bytes);
@@ -2373,8 +2439,15 @@ void LLVMSetExternallyInitialized(LLVMValueRef GlobalVar, LLVMBool IsExtInit);
*
* @{
*/
LLVMValueRef LLVMAddAlias(LLVMModuleRef M, LLVMTypeRef Ty, LLVMValueRef Aliasee,
const char *Name);
/**
* Add a GlobalAlias with the given value type, address space and aliasee.
*
* @see llvm::GlobalAlias::create()
*/
LLVMValueRef LLVMAddAlias2(LLVMModuleRef M, LLVMTypeRef ValueTy,
unsigned AddrSpace, LLVMValueRef Aliasee,
const char *Name);
/**
* Obtain a GlobalAlias value from a Module by its name.
@@ -2510,6 +2583,12 @@ LLVMTypeRef LLVMIntrinsicGetType(LLVMContextRef Ctx, unsigned ID,
*/
const char *LLVMIntrinsicGetName(unsigned ID, size_t *NameLength);
/** Deprecated: Use LLVMIntrinsicCopyOverloadedName2 instead. */
const char *LLVMIntrinsicCopyOverloadedName(unsigned ID,
LLVMTypeRef *ParamTypes,
size_t ParamCount,
size_t *NameLength);
/**
* Copies the name of an overloaded intrinsic identified by a given list of
* parameter types.
@@ -2517,12 +2596,14 @@ const char *LLVMIntrinsicGetName(unsigned ID, size_t *NameLength);
* Unlike LLVMIntrinsicGetName, the caller is responsible for freeing the
* returned string.
*
* This version also supports unnamed types.
*
* @see llvm::Intrinsic::getName()
*/
const char *LLVMIntrinsicCopyOverloadedName(unsigned ID,
LLVMTypeRef *ParamTypes,
size_t ParamCount,
size_t *NameLength);
const char *LLVMIntrinsicCopyOverloadedName2(LLVMModuleRef Mod, unsigned ID,
LLVMTypeRef *ParamTypes,
size_t ParamCount,
size_t *NameLength);
/**
* Obtain if the intrinsic identified by the given ID is overloaded.
@@ -2860,6 +2941,14 @@ unsigned LLVMGetMDNodeNumOperands(LLVMValueRef V);
*/
void LLVMGetMDNodeOperands(LLVMValueRef V, LLVMValueRef *Dest);
/**
* Replace an operand at a specific index in a llvm::MDNode value.
*
* @see llvm::MDNode::replaceOperandWith()
*/
void LLVMReplaceMDNodeOperandWith(LLVMValueRef V, unsigned Index,
LLVMMetadataRef Replacement);
/** Deprecated: Use LLVMMDStringInContext2 instead. */
LLVMValueRef LLVMMDStringInContext(LLVMContextRef C, const char *Str,
unsigned SLen);
@@ -3167,7 +3256,7 @@ LLVMValueRef LLVMGetNextInstruction(LLVMValueRef Inst);
LLVMValueRef LLVMGetPreviousInstruction(LLVMValueRef Inst);
/**
* Remove and delete an instruction.
* Remove an instruction.
*
* The instruction specified is removed from its containing building
* block but is kept alive.
@@ -3186,6 +3275,16 @@ void LLVMInstructionRemoveFromParent(LLVMValueRef Inst);
*/
void LLVMInstructionEraseFromParent(LLVMValueRef Inst);
/**
* Delete an instruction.
*
* The instruction specified is deleted. It must have previously been
* removed from its containing building block.
*
* @see llvm::Value::deleteValue()
*/
void LLVMDeleteInstruction(LLVMValueRef Inst);
/**
* Obtain the code opcode for an individual instruction.
*
@@ -3275,7 +3374,7 @@ void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC);
*/
unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr);
void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index,
void LLVMSetInstrParamAlignment(LLVMValueRef Instr, LLVMAttributeIndex Idx,
unsigned Align);
void LLVMAddCallSiteAttribute(LLVMValueRef C, LLVMAttributeIndex Idx,
@@ -3474,7 +3573,7 @@ LLVMTypeRef LLVMGetAllocatedType(LLVMValueRef Alloca);
*/
/**
* Check whether the given GEP instruction is inbounds.
* Check whether the given GEP operator is inbounds.
*/
LLVMBool LLVMIsInBounds(LLVMValueRef GEP);
@@ -3483,6 +3582,11 @@ LLVMBool LLVMIsInBounds(LLVMValueRef GEP);
*/
void LLVMSetIsInBounds(LLVMValueRef GEP, LLVMBool InBounds);
/**
* Get the source element type of the given GEP operator.
*/
LLVMTypeRef LLVMGetGEPSourceElementType(LLVMValueRef GEP);
/**
* @}
*/
@@ -3533,7 +3637,7 @@ LLVMBasicBlockRef LLVMGetIncomingBlock(LLVMValueRef PhiNode, unsigned Index);
/**
* Obtain the number of indices.
* NB: This also works on GEP.
* NB: This also works on GEP operators.
*/
unsigned LLVMGetNumIndices(LLVMValueRef Inst);
@@ -3599,10 +3703,20 @@ void LLVMSetCurrentDebugLocation2(LLVMBuilderRef Builder, LLVMMetadataRef Loc);
* current debug location for the given builder. If the builder has no current
* debug location, this function is a no-op.
*
* @deprecated LLVMSetInstDebugLocation is deprecated in favor of the more general
* LLVMAddMetadataToInst.
*
* @see llvm::IRBuilder::SetInstDebugLocation()
*/
void LLVMSetInstDebugLocation(LLVMBuilderRef Builder, LLVMValueRef Inst);
/**
* Adds the metadata registered with the given builder to the given instruction.
*
* @see llvm::IRBuilder::AddMetadataToInst()
*/
void LLVMAddMetadataToInst(LLVMBuilderRef Builder, LLVMValueRef Inst);
/**
* Get the dafult floating-point math metadata for a given builder.
*
@@ -3643,12 +3757,6 @@ LLVMValueRef LLVMBuildSwitch(LLVMBuilderRef, LLVMValueRef V,
LLVMBasicBlockRef Else, unsigned NumCases);
LLVMValueRef LLVMBuildIndirectBr(LLVMBuilderRef B, LLVMValueRef Addr,
unsigned NumDests);
// LLVMBuildInvoke is deprecated in favor of LLVMBuildInvoke2, in preparation
// for opaque pointer types.
LLVMValueRef LLVMBuildInvoke(LLVMBuilderRef, LLVMValueRef Fn,
LLVMValueRef *Args, unsigned NumArgs,
LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch,
const char *Name);
LLVMValueRef LLVMBuildInvoke2(LLVMBuilderRef, LLVMTypeRef Ty, LLVMValueRef Fn,
LLVMValueRef *Args, unsigned NumArgs,
LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch,
@@ -3805,6 +3913,13 @@ LLVMValueRef LLVMBuildNUWNeg(LLVMBuilderRef B, LLVMValueRef V,
LLVMValueRef LLVMBuildFNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
LLVMValueRef LLVMBuildNot(LLVMBuilderRef, LLVMValueRef V, const char *Name);
LLVMBool LLVMGetNUW(LLVMValueRef ArithInst);
void LLVMSetNUW(LLVMValueRef ArithInst, LLVMBool HasNUW);
LLVMBool LLVMGetNSW(LLVMValueRef ArithInst);
void LLVMSetNSW(LLVMValueRef ArithInst, LLVMBool HasNSW);
LLVMBool LLVMGetExact(LLVMValueRef DivOrShrInst);
void LLVMSetExact(LLVMValueRef DivOrShrInst, LLVMBool IsExact);
/* Memory */
LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
LLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef, LLVMTypeRef Ty,
@@ -3842,23 +3957,9 @@ LLVMValueRef LLVMBuildAlloca(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
LLVMValueRef LLVMBuildArrayAlloca(LLVMBuilderRef, LLVMTypeRef Ty,
LLVMValueRef Val, const char *Name);
LLVMValueRef LLVMBuildFree(LLVMBuilderRef, LLVMValueRef PointerVal);
// LLVMBuildLoad is deprecated in favor of LLVMBuildLoad2, in preparation for
// opaque pointer types.
LLVMValueRef LLVMBuildLoad(LLVMBuilderRef, LLVMValueRef PointerVal,
const char *Name);
LLVMValueRef LLVMBuildLoad2(LLVMBuilderRef, LLVMTypeRef Ty,
LLVMValueRef PointerVal, const char *Name);
LLVMValueRef LLVMBuildStore(LLVMBuilderRef, LLVMValueRef Val, LLVMValueRef Ptr);
// LLVMBuildGEP, LLVMBuildInBoundsGEP, and LLVMBuildStructGEP are deprecated in
// favor of LLVMBuild*GEP2, in preparation for opaque pointer types.
LLVMValueRef LLVMBuildGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
LLVMValueRef *Indices, unsigned NumIndices,
const char *Name);
LLVMValueRef LLVMBuildInBoundsGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
LLVMValueRef *Indices, unsigned NumIndices,
const char *Name);
LLVMValueRef LLVMBuildStructGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
unsigned Idx, const char *Name);
LLVMValueRef LLVMBuildGEP2(LLVMBuilderRef B, LLVMTypeRef Ty,
LLVMValueRef Pointer, LLVMValueRef *Indices,
unsigned NumIndices, const char *Name);
@@ -3928,6 +4029,9 @@ LLVMValueRef LLVMBuildFPCast(LLVMBuilderRef, LLVMValueRef Val,
LLVMValueRef LLVMBuildIntCast(LLVMBuilderRef, LLVMValueRef Val, /*Signed cast!*/
LLVMTypeRef DestTy, const char *Name);
LLVMOpcode LLVMGetCastOpcode(LLVMValueRef Src, LLVMBool SrcIsSigned,
LLVMTypeRef DestTy, LLVMBool DestIsSigned);
/* Comparisons */
LLVMValueRef LLVMBuildICmp(LLVMBuilderRef, LLVMIntPredicate Op,
LLVMValueRef LHS, LLVMValueRef RHS,
@@ -3938,11 +4042,6 @@ LLVMValueRef LLVMBuildFCmp(LLVMBuilderRef, LLVMRealPredicate Op,
/* Miscellaneous instructions */
LLVMValueRef LLVMBuildPhi(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
// LLVMBuildCall is deprecated in favor of LLVMBuildCall2, in preparation for
// opaque pointer types.
LLVMValueRef LLVMBuildCall(LLVMBuilderRef, LLVMValueRef Fn,
LLVMValueRef *Args, unsigned NumArgs,
const char *Name);
LLVMValueRef LLVMBuildCall2(LLVMBuilderRef, LLVMTypeRef, LLVMValueRef Fn,
LLVMValueRef *Args, unsigned NumArgs,
const char *Name);
@@ -3971,8 +4070,9 @@ LLVMValueRef LLVMBuildIsNull(LLVMBuilderRef, LLVMValueRef Val,
const char *Name);
LLVMValueRef LLVMBuildIsNotNull(LLVMBuilderRef, LLVMValueRef Val,
const char *Name);
LLVMValueRef LLVMBuildPtrDiff(LLVMBuilderRef, LLVMValueRef LHS,
LLVMValueRef RHS, const char *Name);
LLVMValueRef LLVMBuildPtrDiff2(LLVMBuilderRef, LLVMTypeRef ElemTy,
LLVMValueRef LHS, LLVMValueRef RHS,
const char *Name);
LLVMValueRef LLVMBuildFence(LLVMBuilderRef B, LLVMAtomicOrdering ordering,
LLVMBool singleThread, const char *Name);
LLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B, LLVMAtomicRMWBinOp op,
@@ -4000,8 +4100,8 @@ int LLVMGetUndefMaskElem(void);
* Get the mask value at position Elt in the mask of a ShuffleVector
* instruction.
*
* \Returns the result of \c LLVMGetUndefMaskElem() if the mask value is undef
* at that position.
* \Returns the result of \c LLVMGetUndefMaskElem() if the mask value is
* poison at that position.
*/
int LLVMGetMaskValue(LLVMValueRef ShuffleVectorInst, unsigned Elt);
@@ -4063,26 +4163,13 @@ const char *LLVMGetBufferStart(LLVMMemoryBufferRef MemBuf);
size_t LLVMGetBufferSize(LLVMMemoryBufferRef MemBuf);
void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf);
/**
* @}
*/
/**
* @defgroup LLVMCCorePassRegistry Pass Registry
*
* @{
*/
/** Return the global pass registry, for use with initialization functions.
@see llvm::PassRegistry::getPassRegistry */
LLVMPassRegistryRef LLVMGetGlobalPassRegistry(void);
/**
* @}
*/
/**
* @defgroup LLVMCCorePassManagers Pass Managers
* @ingroup LLVMCCore
*
* @{
*/

View File

@@ -16,11 +16,18 @@
#ifndef LLVM_C_DEBUGINFO_H
#define LLVM_C_DEBUGINFO_H
#include "llvm-c/Core.h"
#include "llvm-c/ExternC.h"
#include "llvm-c/Types.h"
LLVM_C_EXTERN_C_BEGIN
/**
* @defgroup LLVMCCoreDebugInfo Debug Information
* @ingroup LLVMCCore
*
* @{
*/
/**
* Debug info flags.
*/
@@ -109,6 +116,16 @@ typedef enum {
LLVMDWARFSourceLanguageFortran08,
LLVMDWARFSourceLanguageRenderScript,
LLVMDWARFSourceLanguageBLISS,
LLVMDWARFSourceLanguageKotlin,
LLVMDWARFSourceLanguageZig,
LLVMDWARFSourceLanguageCrystal,
LLVMDWARFSourceLanguageC_plus_plus_17,
LLVMDWARFSourceLanguageC_plus_plus_20,
LLVMDWARFSourceLanguageC17,
LLVMDWARFSourceLanguageFortran18,
LLVMDWARFSourceLanguageAda2005,
LLVMDWARFSourceLanguageAda2012,
LLVMDWARFSourceLanguageMojo,
// Vendor extensions:
LLVMDWARFSourceLanguageMips_Assembler,
LLVMDWARFSourceLanguageGOOGLE_RenderScript,
@@ -161,7 +178,9 @@ enum {
LLVMDIMacroFileMetadataKind,
LLVMDICommonBlockMetadataKind,
LLVMDIStringTypeMetadataKind,
LLVMDIGenericSubrangeMetadataKind
LLVMDIGenericSubrangeMetadataKind,
LLVMDIArgListMetadataKind,
LLVMDIAssignIDMetadataKind,
};
typedef unsigned LLVMMetadataKind;
@@ -225,6 +244,13 @@ void LLVMDisposeDIBuilder(LLVMDIBuilderRef Builder);
*/
void LLVMDIBuilderFinalize(LLVMDIBuilderRef Builder);
/**
* Finalize a specific subprogram.
* No new variables may be added to this subprogram afterwards.
*/
void LLVMDIBuilderFinalizeSubprogram(LLVMDIBuilderRef Builder,
LLVMMetadataRef Subprogram);
/**
* A CompileUnit provides an anchor for all debugging
* information generated during this instance of compilation.
@@ -388,48 +414,48 @@ LLVMDIBuilderCreateImportedModuleFromNamespace(LLVMDIBuilderRef Builder,
* \param ImportedEntity Previous imported entity to alias.
* \param File File where the declaration is located.
* \param Line Line number of the declaration.
* \param Elements Renamed elements.
* \param NumElements Number of renamed elements.
*/
LLVMMetadataRef
LLVMDIBuilderCreateImportedModuleFromAlias(LLVMDIBuilderRef Builder,
LLVMMetadataRef Scope,
LLVMMetadataRef ImportedEntity,
LLVMMetadataRef File,
unsigned Line);
LLVMMetadataRef LLVMDIBuilderCreateImportedModuleFromAlias(
LLVMDIBuilderRef Builder, LLVMMetadataRef Scope,
LLVMMetadataRef ImportedEntity, LLVMMetadataRef File, unsigned Line,
LLVMMetadataRef *Elements, unsigned NumElements);
/**
* Create a descriptor for an imported module.
* \param Builder The \c DIBuilder.
* \param Scope The scope this module is imported into
* \param M The module being imported here
* \param File File where the declaration is located.
* \param Line Line number of the declaration.
* \param Builder The \c DIBuilder.
* \param Scope The scope this module is imported into
* \param M The module being imported here
* \param File File where the declaration is located.
* \param Line Line number of the declaration.
* \param Elements Renamed elements.
* \param NumElements Number of renamed elements.
*/
LLVMMetadataRef
LLVMDIBuilderCreateImportedModuleFromModule(LLVMDIBuilderRef Builder,
LLVMMetadataRef Scope,
LLVMMetadataRef M,
LLVMMetadataRef File,
unsigned Line);
LLVMMetadataRef LLVMDIBuilderCreateImportedModuleFromModule(
LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, LLVMMetadataRef M,
LLVMMetadataRef File, unsigned Line, LLVMMetadataRef *Elements,
unsigned NumElements);
/**
* Create a descriptor for an imported function, type, or variable. Suitable
* for e.g. FORTRAN-style USE declarations.
* \param Builder The DIBuilder.
* \param Scope The scope this module is imported into.
* \param Decl The declaration (or definition) of a function, type,
or variable.
* \param File File where the declaration is located.
* \param Line Line number of the declaration.
* \param Name A name that uniquely identifies this imported declaration.
* \param NameLen The length of the C string passed to \c Name.
* \param Builder The DIBuilder.
* \param Scope The scope this module is imported into.
* \param Decl The declaration (or definition) of a function, type,
or variable.
* \param File File where the declaration is located.
* \param Line Line number of the declaration.
* \param Name A name that uniquely identifies this imported
declaration.
* \param NameLen The length of the C string passed to \c Name.
* \param Elements Renamed elements.
* \param NumElements Number of renamed elements.
*/
LLVMMetadataRef
LLVMDIBuilderCreateImportedDeclaration(LLVMDIBuilderRef Builder,
LLVMMetadataRef Scope,
LLVMMetadataRef Decl,
LLVMMetadataRef File,
unsigned Line,
const char *Name, size_t NameLen);
LLVMMetadataRef LLVMDIBuilderCreateImportedDeclaration(
LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, LLVMMetadataRef Decl,
LLVMMetadataRef File, unsigned Line, const char *Name, size_t NameLen,
LLVMMetadataRef *Elements, unsigned NumElements);
/**
* Creates a new DebugLocation that describes a source location.
@@ -1087,7 +1113,7 @@ LLVMMetadataRef LLVMDIBuilderGetOrCreateArray(LLVMDIBuilderRef Builder,
* \param Length Length of the address operation array.
*/
LLVMMetadataRef LLVMDIBuilderCreateExpression(LLVMDIBuilderRef Builder,
int64_t *Addr, size_t Length);
uint64_t *Addr, size_t Length);
/**
* Create a new descriptor for the specified variable that does not have an
@@ -1097,7 +1123,7 @@ LLVMMetadataRef LLVMDIBuilderCreateExpression(LLVMDIBuilderRef Builder,
*/
LLVMMetadataRef
LLVMDIBuilderCreateConstantValueExpression(LLVMDIBuilderRef Builder,
int64_t Value);
uint64_t Value);
/**
* Create a new descriptor for the specified variable.
@@ -1124,6 +1150,12 @@ LLVMMetadataRef LLVMDIBuilderCreateGlobalVariableExpression(
unsigned LineNo, LLVMMetadataRef Ty, LLVMBool LocalToUnit,
LLVMMetadataRef Expr, LLVMMetadataRef Decl, uint32_t AlignInBits);
/**
* Get the dwarf::Tag of a DINode
*/
uint16_t LLVMGetDINodeTag(LLVMMetadataRef MD);
/**
* Retrieves the \c DIVariable associated with this global variable expression.
* \param GVE The global variable expression.
@@ -1359,6 +1391,10 @@ void LLVMInstructionSetDebugLoc(LLVMValueRef Inst, LLVMMetadataRef Loc);
*/
LLVMMetadataKind LLVMGetMetadataKind(LLVMMetadataRef Metadata);
/**
* @}
*/
LLVM_C_EXTERN_C_END
#endif

38
src/llvm-c/Deprecated.h Normal file
View File

@@ -0,0 +1,38 @@
/*===-- llvm-c/Deprecated.h - Deprecation macro -------------------*- C -*-===*\
|* *|
|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
|* Exceptions. *|
|* See https://llvm.org/LICENSE.txt for license information. *|
|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
|* *|
|*===----------------------------------------------------------------------===*|
|* *|
|* This header declares LLVM_ATTRIBUTE_C_DEPRECATED() macro, which can be *|
|* used to deprecate functions in the C interface. *|
|* *|
\*===----------------------------------------------------------------------===*/
#ifndef LLVM_C_DEPRECATED_H
#define LLVM_C_DEPRECATED_H
#ifndef __has_feature
# define __has_feature(x) 0
#endif
// This is a variant of LLVM_ATTRIBUTE_DEPRECATED() that is compatible with
// C compilers.
#if __has_feature(attribute_deprecated_with_message)
# define LLVM_ATTRIBUTE_C_DEPRECATED(decl, message) \
decl __attribute__((deprecated(message)))
#elif defined(__GNUC__)
# define LLVM_ATTRIBUTE_C_DEPRECATED(decl, message) \
decl __attribute__((deprecated))
#elif defined(_MSC_VER)
# define LLVM_ATTRIBUTE_C_DEPRECATED(decl, message) \
__declspec(deprecated(message)) decl
#else
# define LLVM_ATTRIBUTE_C_DEPRECATED(decl, message) \
decl
#endif
#endif /* LLVM_C_DEPRECATED_H */

View File

@@ -7,8 +7,8 @@
|* *|
|*===----------------------------------------------------------------------===*/
#ifndef LLVM_DISASSEMBLER_TYPES_H
#define LLVM_DISASSEMBLER_TYPES_H
#ifndef LLVM_C_DISASSEMBLERTYPES_H
#define LLVM_C_DISASSEMBLERTYPES_H
#include "llvm-c/DataTypes.h"
#ifdef __cplusplus
@@ -17,6 +17,12 @@
#include <stddef.h>
#endif
/**
* @addtogroup LLVMCDisassembler
*
* @{
*/
/**
* An opaque reference to a disassembler context.
*/
@@ -32,15 +38,15 @@ typedef void *LLVMDisasmContextRef;
* one operand with symbolic information. To determine the symbolic operand
* information for each operand, the bytes for the specific operand in the
* instruction are specified by the Offset parameter and its byte widith is the
* size parameter. For instructions sets with fixed widths and one symbolic
* operand per instruction, the Offset parameter will be zero and Size parameter
* will be the instruction width. The information is returned in TagBuf and is
* Triple specific with its specific information defined by the value of
* TagType for that Triple. If symbolic information is returned the function
* returns 1, otherwise it returns 0.
* OpSize parameter. For instructions sets with fixed widths and one symbolic
* operand per instruction, the Offset parameter will be zero and InstSize
* parameter will be the instruction width. The information is returned in
* TagBuf and is Triple specific with its specific information defined by the
* value of TagType for that Triple. If symbolic information is returned the
* function * returns 1, otherwise it returns 0.
*/
typedef int (*LLVMOpInfoCallback)(void *DisInfo, uint64_t PC,
uint64_t Offset, uint64_t Size,
typedef int (*LLVMOpInfoCallback)(void *DisInfo, uint64_t PC, uint64_t Offset,
uint64_t OpSize, uint64_t InstSize,
int TagType, void *TagBuf);
/**
@@ -157,4 +163,8 @@ typedef const char *(*LLVMSymbolLookupCallback)(void *DisInfo,
/* The output reference is to a C++ symbol name. */
#define LLVMDisassembler_ReferenceType_DeMangled_Name 9
/**
* @}
*/
#endif

View File

@@ -18,6 +18,13 @@
LLVM_C_EXTERN_C_BEGIN
/**
* @defgroup LLVMCError Error Handling
* @ingroup LLVMC
*
* @{
*/
#define LLVMErrorSuccess 0
/**
@@ -67,6 +74,10 @@ LLVMErrorTypeId LLVMGetStringErrorTypeId(void);
*/
LLVMErrorRef LLVMCreateStringError(const char *ErrMsg);
/**
* @}
*/
LLVM_C_EXTERN_C_END
#endif

View File

@@ -11,13 +11,19 @@
|* *|
\*===----------------------------------------------------------------------===*/
#ifndef LLVM_C_ERROR_HANDLING_H
#define LLVM_C_ERROR_HANDLING_H
#ifndef LLVM_C_ERRORHANDLING_H
#define LLVM_C_ERRORHANDLING_H
#include "llvm-c/ExternC.h"
LLVM_C_EXTERN_C_BEGIN
/**
* @addtogroup LLVMCError
*
* @{
*/
typedef void (*LLVMFatalErrorHandler)(const char *Reason);
/**
@@ -42,6 +48,10 @@ void LLVMResetFatalErrorHandler(void);
*/
void LLVMEnablePrettyStackTrace(void);
/**
* @}
*/
LLVM_C_EXTERN_C_END
#endif

View File

@@ -11,8 +11,8 @@
|* *|
\*===----------------------------------------------------------------------===*/
#ifndef LLVM_C_EXTERN_C_H
#define LLVM_C_EXTERN_C_H
#ifndef LLVM_C_EXTERNC_H
#define LLVM_C_EXTERNC_H
#ifdef __clang__
#define LLVM_C_STRICT_PROTOTYPES_BEGIN \

View File

@@ -19,6 +19,13 @@
LLVM_C_EXTERN_C_BEGIN
/**
* @defgroup LLVMCCoreIRReader IR Reader
* @ingroup LLVMCCore
*
* @{
*/
/**
* Read LLVM IR from a memory buffer and convert it into an in-memory Module
* object. Returns 0 on success.
@@ -32,6 +39,10 @@ LLVMBool LLVMParseIRInContext(LLVMContextRef ContextRef,
LLVMMemoryBufferRef MemBuf, LLVMModuleRef *OutM,
char **OutMessage);
/**
* @}
*/
LLVM_C_EXTERN_C_END
#endif

View File

@@ -1,53 +0,0 @@
/*===-- llvm-c/Initialization.h - Initialization C Interface ------*- C -*-===*\
|* *|
|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
|* Exceptions. *|
|* See https://llvm.org/LICENSE.txt for license information. *|
|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
|* *|
|*===----------------------------------------------------------------------===*|
|* *|
|* This header declares the C interface to LLVM initialization routines, *|
|* which must be called before you can use the functionality provided by *|
|* the corresponding LLVM library. *|
|* *|
\*===----------------------------------------------------------------------===*/
#ifndef LLVM_C_INITIALIZATION_H
#define LLVM_C_INITIALIZATION_H
#include "llvm-c/ExternC.h"
#include "llvm-c/Types.h"
LLVM_C_EXTERN_C_BEGIN
/**
* @defgroup LLVMCInitialization Initialization Routines
* @ingroup LLVMC
*
* This module contains routines used to initialize the LLVM system.
*
* @{
*/
void LLVMInitializeCore(LLVMPassRegistryRef R);
void LLVMInitializeTransformUtils(LLVMPassRegistryRef R);
void LLVMInitializeScalarOpts(LLVMPassRegistryRef R);
void LLVMInitializeObjCARCOpts(LLVMPassRegistryRef R);
void LLVMInitializeVectorization(LLVMPassRegistryRef R);
void LLVMInitializeInstCombine(LLVMPassRegistryRef R);
void LLVMInitializeAggressiveInstCombiner(LLVMPassRegistryRef R);
void LLVMInitializeIPO(LLVMPassRegistryRef R);
void LLVMInitializeInstrumentation(LLVMPassRegistryRef R);
void LLVMInitializeAnalysis(LLVMPassRegistryRef R);
void LLVMInitializeIPA(LLVMPassRegistryRef R);
void LLVMInitializeCodeGen(LLVMPassRegistryRef R);
void LLVMInitializeTarget(LLVMPassRegistryRef R);
/**
* @}
*/
LLVM_C_EXTERN_C_END
#endif

251
src/llvm-c/LLJIT.h Normal file
View File

@@ -0,0 +1,251 @@
/*===----------- llvm-c/LLJIT.h - OrcV2 LLJIT C bindings --------*- C++ -*-===*\
|* *|
|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
|* Exceptions. *|
|* See https://llvm.org/LICENSE.txt for license information. *|
|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
|* *|
|*===----------------------------------------------------------------------===*|
|* *|
|* This header declares the C interface to the LLJIT class in *|
|* libLLVMOrcJIT.a, which provides a simple MCJIT-like ORC JIT. *|
|* *|
|* Many exotic languages can interoperate with C code but have a harder time *|
|* with C++ due to name mangling. So in addition to C, this interface enables *|
|* tools written in such languages. *|
|* *|
|* Note: This interface is experimental. It is *NOT* stable, and may be *|
|* changed without warning. Only C API usage documentation is *|
|* provided. See the C++ documentation for all higher level ORC API *|
|* details. *|
|* *|
\*===----------------------------------------------------------------------===*/
#ifndef LLVM_C_LLJIT_H
#define LLVM_C_LLJIT_H
#include "llvm-c/Error.h"
#include "llvm-c/Orc.h"
#include "llvm-c/TargetMachine.h"
#include "llvm-c/Types.h"
LLVM_C_EXTERN_C_BEGIN
/**
* @defgroup LLVMCExecutionEngineLLJIT LLJIT
* @ingroup LLVMCExecutionEngine
*
* @{
*/
/**
* A function for constructing an ObjectLinkingLayer instance to be used
* by an LLJIT instance.
*
* Clients can call LLVMOrcLLJITBuilderSetObjectLinkingLayerCreator to
* set the creator function to use when constructing an LLJIT instance.
* This can be used to override the default linking layer implementation
* that would otherwise be chosen by LLJITBuilder.
*
* Object linking layers returned by this function will become owned by the
* LLJIT instance. The client is not responsible for managing their lifetimes
* after the function returns.
*/
typedef LLVMOrcObjectLayerRef (
*LLVMOrcLLJITBuilderObjectLinkingLayerCreatorFunction)(
void *Ctx, LLVMOrcExecutionSessionRef ES, const char *Triple);
/**
* A reference to an orc::LLJITBuilder instance.
*/
typedef struct LLVMOrcOpaqueLLJITBuilder *LLVMOrcLLJITBuilderRef;
/**
* A reference to an orc::LLJIT instance.
*/
typedef struct LLVMOrcOpaqueLLJIT *LLVMOrcLLJITRef;
/**
* Create an LLVMOrcLLJITBuilder.
*
* The client owns the resulting LLJITBuilder and should dispose of it using
* LLVMOrcDisposeLLJITBuilder once they are done with it.
*/
LLVMOrcLLJITBuilderRef LLVMOrcCreateLLJITBuilder(void);
/**
* Dispose of an LLVMOrcLLJITBuilderRef. This should only be called if ownership
* has not been passed to LLVMOrcCreateLLJIT (e.g. because some error prevented
* that function from being called).
*/
void LLVMOrcDisposeLLJITBuilder(LLVMOrcLLJITBuilderRef Builder);
/**
* Set the JITTargetMachineBuilder to be used when constructing the LLJIT
* instance. Calling this function is optional: if it is not called then the
* LLJITBuilder will use JITTargeTMachineBuilder::detectHost to construct a
* JITTargetMachineBuilder.
*
* This function takes ownership of the JTMB argument: clients should not
* dispose of the JITTargetMachineBuilder after calling this function.
*/
void LLVMOrcLLJITBuilderSetJITTargetMachineBuilder(
LLVMOrcLLJITBuilderRef Builder, LLVMOrcJITTargetMachineBuilderRef JTMB);
/**
* Set an ObjectLinkingLayer creator function for this LLJIT instance.
*/
void LLVMOrcLLJITBuilderSetObjectLinkingLayerCreator(
LLVMOrcLLJITBuilderRef Builder,
LLVMOrcLLJITBuilderObjectLinkingLayerCreatorFunction F, void *Ctx);
/**
* Create an LLJIT instance from an LLJITBuilder.
*
* This operation takes ownership of the Builder argument: clients should not
* dispose of the builder after calling this function (even if the function
* returns an error). If a null Builder argument is provided then a
* default-constructed LLJITBuilder will be used.
*
* On success the resulting LLJIT instance is uniquely owned by the client and
* automatically manages the memory of all JIT'd code and all modules that are
* transferred to it (e.g. via LLVMOrcLLJITAddLLVMIRModule). Disposing of the
* LLJIT instance will free all memory managed by the JIT, including JIT'd code
* and not-yet compiled modules.
*/
LLVMErrorRef LLVMOrcCreateLLJIT(LLVMOrcLLJITRef *Result,
LLVMOrcLLJITBuilderRef Builder);
/**
* Dispose of an LLJIT instance.
*/
LLVMErrorRef LLVMOrcDisposeLLJIT(LLVMOrcLLJITRef J);
/**
* Get a reference to the ExecutionSession for this LLJIT instance.
*
* The ExecutionSession is owned by the LLJIT instance. The client is not
* responsible for managing its memory.
*/
LLVMOrcExecutionSessionRef LLVMOrcLLJITGetExecutionSession(LLVMOrcLLJITRef J);
/**
* Return a reference to the Main JITDylib.
*
* The JITDylib is owned by the LLJIT instance. The client is not responsible
* for managing its memory.
*/
LLVMOrcJITDylibRef LLVMOrcLLJITGetMainJITDylib(LLVMOrcLLJITRef J);
/**
* Return the target triple for this LLJIT instance. This string is owned by
* the LLJIT instance and should not be freed by the client.
*/
const char *LLVMOrcLLJITGetTripleString(LLVMOrcLLJITRef J);
/**
* Returns the global prefix character according to the LLJIT's DataLayout.
*/
char LLVMOrcLLJITGetGlobalPrefix(LLVMOrcLLJITRef J);
/**
* Mangles the given string according to the LLJIT instance's DataLayout, then
* interns the result in the SymbolStringPool and returns a reference to the
* pool entry. Clients should call LLVMOrcReleaseSymbolStringPoolEntry to
* decrement the ref-count on the pool entry once they are finished with this
* value.
*/
LLVMOrcSymbolStringPoolEntryRef
LLVMOrcLLJITMangleAndIntern(LLVMOrcLLJITRef J, const char *UnmangledName);
/**
* Add a buffer representing an object file to the given JITDylib in the given
* LLJIT instance. This operation transfers ownership of the buffer to the
* LLJIT instance. The buffer should not be disposed of or referenced once this
* function returns.
*
* Resources associated with the given object will be tracked by the given
* JITDylib's default resource tracker.
*/
LLVMErrorRef LLVMOrcLLJITAddObjectFile(LLVMOrcLLJITRef J, LLVMOrcJITDylibRef JD,
LLVMMemoryBufferRef ObjBuffer);
/**
* Add a buffer representing an object file to the given ResourceTracker's
* JITDylib in the given LLJIT instance. This operation transfers ownership of
* the buffer to the LLJIT instance. The buffer should not be disposed of or
* referenced once this function returns.
*
* Resources associated with the given object will be tracked by ResourceTracker
* RT.
*/
LLVMErrorRef LLVMOrcLLJITAddObjectFileWithRT(LLVMOrcLLJITRef J,
LLVMOrcResourceTrackerRef RT,
LLVMMemoryBufferRef ObjBuffer);
/**
* Add an IR module to the given JITDylib in the given LLJIT instance. This
* operation transfers ownership of the TSM argument to the LLJIT instance.
* The TSM argument should not be disposed of or referenced once this
* function returns.
*
* Resources associated with the given Module will be tracked by the given
* JITDylib's default resource tracker.
*/
LLVMErrorRef LLVMOrcLLJITAddLLVMIRModule(LLVMOrcLLJITRef J,
LLVMOrcJITDylibRef JD,
LLVMOrcThreadSafeModuleRef TSM);
/**
* Add an IR module to the given ResourceTracker's JITDylib in the given LLJIT
* instance. This operation transfers ownership of the TSM argument to the LLJIT
* instance. The TSM argument should not be disposed of or referenced once this
* function returns.
*
* Resources associated with the given Module will be tracked by ResourceTracker
* RT.
*/
LLVMErrorRef LLVMOrcLLJITAddLLVMIRModuleWithRT(LLVMOrcLLJITRef J,
LLVMOrcResourceTrackerRef JD,
LLVMOrcThreadSafeModuleRef TSM);
/**
* Look up the given symbol in the main JITDylib of the given LLJIT instance.
*
* This operation does not take ownership of the Name argument.
*/
LLVMErrorRef LLVMOrcLLJITLookup(LLVMOrcLLJITRef J,
LLVMOrcExecutorAddress *Result,
const char *Name);
/**
* Returns a non-owning reference to the LLJIT instance's object linking layer.
*/
LLVMOrcObjectLayerRef LLVMOrcLLJITGetObjLinkingLayer(LLVMOrcLLJITRef J);
/**
* Returns a non-owning reference to the LLJIT instance's object linking layer.
*/
LLVMOrcObjectTransformLayerRef
LLVMOrcLLJITGetObjTransformLayer(LLVMOrcLLJITRef J);
/**
* Returns a non-owning reference to the LLJIT instance's IR transform layer.
*/
LLVMOrcIRTransformLayerRef LLVMOrcLLJITGetIRTransformLayer(LLVMOrcLLJITRef J);
/**
* Get the LLJIT instance's default data layout string.
*
* This string is owned by the LLJIT instance and does not need to be freed
* by the caller.
*/
const char *LLVMOrcLLJITGetDataLayoutStr(LLVMOrcLLJITRef J);
/**
* @}
*/
LLVM_C_EXTERN_C_END
#endif /* LLVM_C_LLJIT_H */

View File

@@ -1,66 +0,0 @@
//===-- llvm/LinkTimeOptimizer.h - LTO Public C Interface -------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This header provides a C API to use the LLVM link time optimization
// library. This is intended to be used by linkers which are C-only in
// their implementation for performing LTO.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_C_LINKTIMEOPTIMIZER_H
#define LLVM_C_LINKTIMEOPTIMIZER_H
#include "ExternC.h"
LLVM_C_EXTERN_C_BEGIN
/**
* @defgroup LLVMCLinkTimeOptimizer Link Time Optimization
* @ingroup LLVMC
*
* @{
*/
/// This provides a dummy type for pointers to the LTO object.
typedef void* llvm_lto_t;
/// This provides a C-visible enumerator to manage status codes.
/// This should map exactly onto the C++ enumerator LTOStatus.
typedef enum llvm_lto_status {
LLVM_LTO_UNKNOWN,
LLVM_LTO_OPT_SUCCESS,
LLVM_LTO_READ_SUCCESS,
LLVM_LTO_READ_FAILURE,
LLVM_LTO_WRITE_FAILURE,
LLVM_LTO_NO_TARGET,
LLVM_LTO_NO_WORK,
LLVM_LTO_MODULE_MERGE_FAILURE,
LLVM_LTO_ASM_FAILURE,
// Added C-specific error codes
LLVM_LTO_NULL_OBJECT
} llvm_lto_status_t;
/// This provides C interface to initialize link time optimizer. This allows
/// linker to use dlopen() interface to dynamically load LinkTimeOptimizer.
/// extern "C" helps, because dlopen() interface uses name to find the symbol.
extern llvm_lto_t llvm_create_optimizer(void);
extern void llvm_destroy_optimizer(llvm_lto_t lto);
extern llvm_lto_status_t llvm_read_object_file
(llvm_lto_t lto, const char* input_filename);
extern llvm_lto_status_t llvm_optimize_modules
(llvm_lto_t lto, const char* output_filename);
/**
* @}
*/
LLVM_C_EXTERN_C_END
#endif

View File

@@ -19,6 +19,13 @@
LLVM_C_EXTERN_C_BEGIN
/**
* @defgroup LLVMCCoreLinker Linker
* @ingroup LLVMCCore
*
* @{
*/
/* This enum is provided for backwards-compatibility only. It has no effect. */
typedef enum {
LLVMLinkerDestroySource = 0, /* This is the default behavior. */
@@ -35,4 +42,8 @@ LLVMBool LLVMLinkModules2(LLVMModuleRef Dest, LLVMModuleRef Src);
LLVM_C_EXTERN_C_END
/**
* @}
*/
#endif

View File

@@ -21,7 +21,7 @@
#include "llvm-c/ExternC.h"
#include "llvm-c/Types.h"
#include "llvm-c/Config/llvm-config.h"
#include "llvm-c/Config//llvm-config.h"
LLVM_C_EXTERN_C_BEGIN
@@ -38,21 +38,23 @@ typedef struct LLVMOpaqueSymbolIterator *LLVMSymbolIteratorRef;
typedef struct LLVMOpaqueRelocationIterator *LLVMRelocationIteratorRef;
typedef enum {
LLVMBinaryTypeArchive, /**< Archive file. */
LLVMBinaryTypeMachOUniversalBinary, /**< Mach-O Universal Binary file. */
LLVMBinaryTypeCOFFImportFile, /**< COFF Import file. */
LLVMBinaryTypeIR, /**< LLVM IR. */
LLVMBinaryTypeWinRes, /**< Windows resource (.res) file. */
LLVMBinaryTypeCOFF, /**< COFF Object file. */
LLVMBinaryTypeELF32L, /**< ELF 32-bit, little endian. */
LLVMBinaryTypeELF32B, /**< ELF 32-bit, big endian. */
LLVMBinaryTypeELF64L, /**< ELF 64-bit, little endian. */
LLVMBinaryTypeELF64B, /**< ELF 64-bit, big endian. */
LLVMBinaryTypeMachO32L, /**< MachO 32-bit, little endian. */
LLVMBinaryTypeMachO32B, /**< MachO 32-bit, big endian. */
LLVMBinaryTypeMachO64L, /**< MachO 64-bit, little endian. */
LLVMBinaryTypeMachO64B, /**< MachO 64-bit, big endian. */
LLVMBinaryTypeWasm, /**< Web Assembly. */
LLVMBinaryTypeArchive, /**< Archive file. */
LLVMBinaryTypeMachOUniversalBinary, /**< Mach-O Universal Binary file. */
LLVMBinaryTypeCOFFImportFile, /**< COFF Import file. */
LLVMBinaryTypeIR, /**< LLVM IR. */
LLVMBinaryTypeWinRes, /**< Windows resource (.res) file. */
LLVMBinaryTypeCOFF, /**< COFF Object file. */
LLVMBinaryTypeELF32L, /**< ELF 32-bit, little endian. */
LLVMBinaryTypeELF32B, /**< ELF 32-bit, big endian. */
LLVMBinaryTypeELF64L, /**< ELF 64-bit, little endian. */
LLVMBinaryTypeELF64B, /**< ELF 64-bit, big endian. */
LLVMBinaryTypeMachO32L, /**< MachO 32-bit, little endian. */
LLVMBinaryTypeMachO32B, /**< MachO 32-bit, big endian. */
LLVMBinaryTypeMachO64L, /**< MachO 64-bit, little endian. */
LLVMBinaryTypeMachO64B, /**< MachO 64-bit, big endian. */
LLVMBinaryTypeWasm, /**< Web Assembly. */
LLVMBinaryTypeOffload, /**< Offloading fatbinary. */
} LLVMBinaryType;
/**

1292
src/llvm-c/Orc.h Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,169 +0,0 @@
/*===----------- llvm-c/OrcBindings.h - Orc Lib C Iface ---------*- C++ -*-===*\
|* *|
|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
|* Exceptions. *|
|* See https://llvm.org/LICENSE.txt for license information. *|
|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
|* *|
|*===----------------------------------------------------------------------===*|
|* *|
|* This header declares the C interface to libLLVMOrcJIT.a, which implements *|
|* JIT compilation of LLVM IR. *|
|* *|
|* Many exotic languages can interoperate with C code but have a harder time *|
|* with C++ due to name mangling. So in addition to C, this interface enables *|
|* tools written in such languages. *|
|* *|
|* Note: This interface is experimental. It is *NOT* stable, and may be *|
|* changed without warning. *|
|* *|
\*===----------------------------------------------------------------------===*/
#ifndef LLVM_C_ORCBINDINGS_H
#define LLVM_C_ORCBINDINGS_H
#include "Error.h"
#include "ExternC.h"
#include "Object.h"
#include "TargetMachine.h"
LLVM_C_EXTERN_C_BEGIN
typedef struct LLVMOrcOpaqueJITStack *LLVMOrcJITStackRef;
typedef uint64_t LLVMOrcModuleHandle;
typedef uint64_t LLVMOrcTargetAddress;
typedef uint64_t (*LLVMOrcSymbolResolverFn)(const char *Name, void *LookupCtx);
typedef uint64_t (*LLVMOrcLazyCompileCallbackFn)(LLVMOrcJITStackRef JITStack,
void *CallbackCtx);
/**
* Create an ORC JIT stack.
*
* The client owns the resulting stack, and must call OrcDisposeInstance(...)
* to destroy it and free its memory. The JIT stack will take ownership of the
* TargetMachine, which will be destroyed when the stack is destroyed. The
* client should not attempt to dispose of the Target Machine, or it will result
* in a double-free.
*/
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
*/
void LLVMOrcGetMangledSymbol(LLVMOrcJITStackRef JITStack, char **MangledSymbol,
const char *Symbol);
/**
* Dispose of a mangled symbol.
*/
void LLVMOrcDisposeMangledSymbol(char *MangledSymbol);
/**
* Create a lazy compile callback.
*/
LLVMErrorRef LLVMOrcCreateLazyCompileCallback(
LLVMOrcJITStackRef JITStack, LLVMOrcTargetAddress *RetAddr,
LLVMOrcLazyCompileCallbackFn Callback, void *CallbackCtx);
/**
* Create a named indirect call stub.
*/
LLVMErrorRef LLVMOrcCreateIndirectStub(LLVMOrcJITStackRef JITStack,
const char *StubName,
LLVMOrcTargetAddress InitAddr);
/**
* Set the pointer for the given indirect stub.
*/
LLVMErrorRef LLVMOrcSetIndirectStubPointer(LLVMOrcJITStackRef JITStack,
const char *StubName,
LLVMOrcTargetAddress NewAddr);
/**
* Add module to be eagerly compiled.
*/
LLVMErrorRef LLVMOrcAddEagerlyCompiledIR(LLVMOrcJITStackRef JITStack,
LLVMOrcModuleHandle *RetHandle,
LLVMModuleRef Mod,
LLVMOrcSymbolResolverFn SymbolResolver,
void *SymbolResolverCtx);
/**
* Add module to be lazily compiled one function at a time.
*/
LLVMErrorRef LLVMOrcAddLazilyCompiledIR(LLVMOrcJITStackRef JITStack,
LLVMOrcModuleHandle *RetHandle,
LLVMModuleRef Mod,
LLVMOrcSymbolResolverFn SymbolResolver,
void *SymbolResolverCtx);
/**
* Add an object file.
*
* This method takes ownership of the given memory buffer and attempts to add
* it to the JIT as an object file.
* Clients should *not* dispose of the 'Obj' argument: the JIT will manage it
* from this call onwards.
*/
LLVMErrorRef LLVMOrcAddObjectFile(LLVMOrcJITStackRef JITStack,
LLVMOrcModuleHandle *RetHandle,
LLVMMemoryBufferRef Obj,
LLVMOrcSymbolResolverFn SymbolResolver,
void *SymbolResolverCtx);
/**
* Remove a module set from the JIT.
*
* This works for all modules that can be added via OrcAdd*, including object
* files.
*/
LLVMErrorRef LLVMOrcRemoveModule(LLVMOrcJITStackRef JITStack,
LLVMOrcModuleHandle H);
/**
* Get symbol address from JIT instance.
*/
LLVMErrorRef LLVMOrcGetSymbolAddress(LLVMOrcJITStackRef JITStack,
LLVMOrcTargetAddress *RetAddr,
const char *SymbolName);
/**
* Get symbol address from JIT instance, searching only the specified
* handle.
*/
LLVMErrorRef LLVMOrcGetSymbolAddressIn(LLVMOrcJITStackRef JITStack,
LLVMOrcTargetAddress *RetAddr,
LLVMOrcModuleHandle H,
const char *SymbolName);
/**
* Dispose of an ORC JIT stack.
*/
LLVMErrorRef LLVMOrcDisposeInstance(LLVMOrcJITStackRef JITStack);
/**
* Register a JIT Event Listener.
*
* A NULL listener is ignored.
*/
void LLVMOrcRegisterJITEventListener(LLVMOrcJITStackRef JITStack, LLVMJITEventListenerRef L);
/**
* Unegister a JIT Event Listener.
*
* A NULL listener is ignored.
*/
void LLVMOrcUnregisterJITEventListener(LLVMOrcJITStackRef JITStack, LLVMJITEventListenerRef L);
LLVM_C_EXTERN_C_END
#endif /* LLVM_C_ORCBINDINGS_H */

103
src/llvm-c/OrcEE.h Normal file
View File

@@ -0,0 +1,103 @@
/*===-- llvm-c/OrcEE.h - OrcV2 C bindings ExecutionEngine utils -*- C++ -*-===*\
|* *|
|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
|* Exceptions. *|
|* See https://llvm.org/LICENSE.txt for license information. *|
|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
|* *|
|*===----------------------------------------------------------------------===*|
|* *|
|* This header declares the C interface to ExecutionEngine based utils, e.g. *|
|* RTDyldObjectLinkingLayer (based on RuntimeDyld) in Orc. *|
|* *|
|* Many exotic languages can interoperate with C code but have a harder time *|
|* with C++ due to name mangling. So in addition to C, this interface enables *|
|* tools written in such languages. *|
|* *|
|* Note: This interface is experimental. It is *NOT* stable, and may be *|
|* changed without warning. Only C API usage documentation is *|
|* provided. See the C++ documentation for all higher level ORC API *|
|* details. *|
|* *|
\*===----------------------------------------------------------------------===*/
#ifndef LLVM_C_ORCEE_H
#define LLVM_C_ORCEE_H
#include "llvm-c/Error.h"
#include "llvm-c/ExecutionEngine.h"
#include "llvm-c/Orc.h"
#include "llvm-c/TargetMachine.h"
#include "llvm-c/Types.h"
LLVM_C_EXTERN_C_BEGIN
typedef void *(*LLVMMemoryManagerCreateContextCallback)(void *CtxCtx);
typedef void (*LLVMMemoryManagerNotifyTerminatingCallback)(void *CtxCtx);
/**
* @defgroup LLVMCExecutionEngineORCEE ExecutionEngine-based ORC Utils
* @ingroup LLVMCExecutionEngine
*
* @{
*/
/**
* Create a RTDyldObjectLinkingLayer instance using the standard
* SectionMemoryManager for memory management.
*/
LLVMOrcObjectLayerRef
LLVMOrcCreateRTDyldObjectLinkingLayerWithSectionMemoryManager(
LLVMOrcExecutionSessionRef ES);
/**
* Create a RTDyldObjectLinkingLayer instance using MCJIT-memory-manager-like
* callbacks.
*
* This is intended to simplify transitions for existing MCJIT clients. The
* callbacks used are similar (but not identical) to the callbacks for
* LLVMCreateSimpleMCJITMemoryManager: Unlike MCJIT, RTDyldObjectLinkingLayer
* will create a new memory manager for each object linked by calling the given
* CreateContext callback. This allows for code removal by destroying each
* allocator individually. Every allocator will be destroyed (if it has not been
* already) at RTDyldObjectLinkingLayer destruction time, and the
* NotifyTerminating callback will be called to indicate that no further
* allocation contexts will be created.
*
* To implement MCJIT-like behavior clients can implement CreateContext,
* NotifyTerminating, and Destroy as:
*
* void *CreateContext(void *CtxCtx) { return CtxCtx; }
* void NotifyTerminating(void *CtxCtx) { MyOriginalDestroy(CtxCtx); }
* void Destroy(void *Ctx) { }
*
* This scheme simply reuses the CreateContextCtx pointer as the one-and-only
* allocation context.
*/
LLVMOrcObjectLayerRef
LLVMOrcCreateRTDyldObjectLinkingLayerWithMCJITMemoryManagerLikeCallbacks(
LLVMOrcExecutionSessionRef ES, void *CreateContextCtx,
LLVMMemoryManagerCreateContextCallback CreateContext,
LLVMMemoryManagerNotifyTerminatingCallback NotifyTerminating,
LLVMMemoryManagerAllocateCodeSectionCallback AllocateCodeSection,
LLVMMemoryManagerAllocateDataSectionCallback AllocateDataSection,
LLVMMemoryManagerFinalizeMemoryCallback FinalizeMemory,
LLVMMemoryManagerDestroyCallback Destroy);
/**
* Add the given listener to the given RTDyldObjectLinkingLayer.
*
* Note: Layer must be an RTDyldObjectLinkingLayer instance or
* behavior is undefined.
*/
void LLVMOrcRTDyldObjectLinkingLayerRegisterJITEventListener(
LLVMOrcObjectLayerRef RTDyldObjLinkingLayer,
LLVMJITEventListenerRef Listener);
/**
* @}
*/
LLVM_C_EXTERN_C_END
#endif /* LLVM_C_ORCEE_H */

View File

@@ -20,6 +20,12 @@
LLVM_C_EXTERN_C_BEGIN
/**
* @addtogroup LLVMCCore
*
* @{
*/
/**
* This function permanently loads the dynamic library at the given path.
* It is safe to call this function multiple times for the same library.
@@ -57,6 +63,10 @@ void *LLVMSearchForAddressOfSymbol(const char *symbolName);
*/
void LLVMAddSymbol(const char *symbolName, void *symbolValue);
/**
* @}
*/
LLVM_C_EXTERN_C_END
#endif

View File

@@ -21,7 +21,7 @@
#include "llvm-c/ExternC.h"
#include "llvm-c/Types.h"
#include "llvm-c/Config/llvm-config.h"
#include "llvm-c/Config//llvm-config.h"
LLVM_C_EXTERN_C_BEGIN
@@ -40,34 +40,34 @@ typedef struct LLVMOpaqueTargetLibraryInfotData *LLVMTargetLibraryInfoRef;
/* Declare all of the target-initialization functions that are available. */
#define LLVM_TARGET(TargetName) \
void LLVMInitialize##TargetName##TargetInfo(void);
#include "llvm-c/Config/Targets.def"
#include "llvm-c/Config//Targets.def"
#undef LLVM_TARGET /* Explicit undef to make SWIG happier */
#define LLVM_TARGET(TargetName) void LLVMInitialize##TargetName##Target(void);
#include "llvm-c/Config/Targets.def"
#include "llvm-c/Config//Targets.def"
#undef LLVM_TARGET /* Explicit undef to make SWIG happier */
#define LLVM_TARGET(TargetName) \
void LLVMInitialize##TargetName##TargetMC(void);
#include "llvm-c/Config/Targets.def"
#include "llvm-c/Config//Targets.def"
#undef LLVM_TARGET /* Explicit undef to make SWIG happier */
/* Declare all of the available assembly printer initialization functions. */
#define LLVM_ASM_PRINTER(TargetName) \
void LLVMInitialize##TargetName##AsmPrinter(void);
#include "llvm-c/Config/AsmPrinters.def"
#include "llvm-c/Config//AsmPrinters.def"
#undef LLVM_ASM_PRINTER /* Explicit undef to make SWIG happier */
/* Declare all of the available assembly parser initialization functions. */
#define LLVM_ASM_PARSER(TargetName) \
void LLVMInitialize##TargetName##AsmParser(void);
#include "llvm-c/Config/AsmParsers.def"
#include "llvm-c/Config//AsmParsers.def"
#undef LLVM_ASM_PARSER /* Explicit undef to make SWIG happier */
/* Declare all of the available disassembler initialization functions. */
#define LLVM_DISASSEMBLER(TargetName) \
void LLVMInitialize##TargetName##Disassembler(void);
#include "llvm-c/Config/Disassemblers.def"
#include "llvm-c/Config//Disassemblers.def"
#undef LLVM_DISASSEMBLER /* Explicit undef to make SWIG happier */
/** LLVMInitializeAllTargetInfos - The main program should call this function if
@@ -75,7 +75,7 @@ typedef struct LLVMOpaqueTargetLibraryInfotData *LLVMTargetLibraryInfoRef;
support. */
static inline void LLVMInitializeAllTargetInfos(void) {
#define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##TargetInfo();
#include "llvm-c/Config/Targets.def"
#include "llvm-c/Config//Targets.def"
#undef LLVM_TARGET /* Explicit undef to make SWIG happier */
}
@@ -84,7 +84,7 @@ static inline void LLVMInitializeAllTargetInfos(void) {
support. */
static inline void LLVMInitializeAllTargets(void) {
#define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##Target();
#include "llvm-c/Config/Targets.def"
#include "llvm-c/Config//Targets.def"
#undef LLVM_TARGET /* Explicit undef to make SWIG happier */
}
@@ -93,7 +93,7 @@ static inline void LLVMInitializeAllTargets(void) {
support. */
static inline void LLVMInitializeAllTargetMCs(void) {
#define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##TargetMC();
#include "llvm-c/Config/Targets.def"
#include "llvm-c/Config//Targets.def"
#undef LLVM_TARGET /* Explicit undef to make SWIG happier */
}
@@ -102,7 +102,7 @@ static inline void LLVMInitializeAllTargetMCs(void) {
available via the TargetRegistry. */
static inline void LLVMInitializeAllAsmPrinters(void) {
#define LLVM_ASM_PRINTER(TargetName) LLVMInitialize##TargetName##AsmPrinter();
#include "llvm-c/Config/AsmPrinters.def"
#include "llvm-c/Config//AsmPrinters.def"
#undef LLVM_ASM_PRINTER /* Explicit undef to make SWIG happier */
}
@@ -111,7 +111,7 @@ static inline void LLVMInitializeAllAsmPrinters(void) {
available via the TargetRegistry. */
static inline void LLVMInitializeAllAsmParsers(void) {
#define LLVM_ASM_PARSER(TargetName) LLVMInitialize##TargetName##AsmParser();
#include "llvm-c/Config/AsmParsers.def"
#include "llvm-c/Config//AsmParsers.def"
#undef LLVM_ASM_PARSER /* Explicit undef to make SWIG happier */
}
@@ -121,7 +121,7 @@ static inline void LLVMInitializeAllAsmParsers(void) {
static inline void LLVMInitializeAllDisassemblers(void) {
#define LLVM_DISASSEMBLER(TargetName) \
LLVMInitialize##TargetName##Disassembler();
#include "llvm-c/Config/Disassemblers.def"
#include "llvm-c/Config//Disassemblers.def"
#undef LLVM_DISASSEMBLER /* Explicit undef to make SWIG happier */
}

View File

@@ -25,6 +25,12 @@
LLVM_C_EXTERN_C_BEGIN
/**
* @addtogroup LLVMCTarget
*
* @{
*/
typedef struct LLVMOpaqueTargetMachine *LLVMTargetMachineRef;
typedef struct LLVMTarget *LLVMTargetRef;
@@ -130,7 +136,9 @@ void LLVMSetTargetMachineAsmVerbosity(LLVMTargetMachineRef T,
wraps several c++ only classes (among them a file stream). Returns any
error in ErrorMessage. Use LLVMDisposeMessage to dispose the message. */
LLVMBool LLVMTargetMachineEmitToFile(LLVMTargetMachineRef T, LLVMModuleRef M,
char *Filename, LLVMCodeGenFileType codegen, char **ErrorMessage);
const char *Filename,
LLVMCodeGenFileType codegen,
char **ErrorMessage);
/** Compile the LLVM IR stored in \p M and store the result in \p OutMemBuf. */
LLVMBool LLVMTargetMachineEmitToMemoryBuffer(LLVMTargetMachineRef T, LLVMModuleRef M,
@@ -156,6 +164,10 @@ char* LLVMGetHostCPUFeatures(void);
/** Adds the target-specific analysis passes to the pass manager. */
void LLVMAddAnalysisPasses(LLVMTargetMachineRef T, LLVMPassManagerRef PM);
/**
* @}
*/
LLVM_C_EXTERN_C_END
#endif

View File

@@ -1,40 +0,0 @@
/*===-- AggressiveInstCombine.h ---------------------------------*- C++ -*-===*\
|* *|
|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
|* Exceptions. *|
|* See https://llvm.org/LICENSE.txt for license information. *|
|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
|* *|
|*===----------------------------------------------------------------------===*|
|* *|
|* This header declares the C interface to libLLVMAggressiveInstCombine.a, *|
|* which combines instructions to form fewer, simple IR instructions. *|
|* *|
\*===----------------------------------------------------------------------===*/
#ifndef LLVM_C_TRANSFORMS_AGGRESSIVEINSTCOMBINE_H
#define LLVM_C_TRANSFORMS_AGGRESSIVEINSTCOMBINE_H
#include "llvm-c/ExternC.h"
#include "llvm-c/Types.h"
LLVM_C_EXTERN_C_BEGIN
/**
* @defgroup LLVMCTransformsAggressiveInstCombine Aggressive Instruction Combining transformations
* @ingroup LLVMCTransforms
*
* @{
*/
/** See llvm::createAggressiveInstCombinerPass function. */
void LLVMAddAggressiveInstCombinerPass(LLVMPassManagerRef PM);
/**
* @}
*/
LLVM_C_EXTERN_C_END
#endif

View File

@@ -1,56 +0,0 @@
/*===-- Coroutines.h - Coroutines Library C Interface -----------*- C++ -*-===*\
|* *|
|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
|* Exceptions. *|
|* See https://llvm.org/LICENSE.txt for license information. *|
|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
|* *|
|*===----------------------------------------------------------------------===*|
|* *|
|* This header declares the C interface to libLLVMCoroutines.a, which *|
|* implements various scalar transformations of the LLVM IR. *|
|* *|
|* Many exotic languages can interoperate with C code but have a harder time *|
|* with C++ due to name mangling. So in addition to C, this interface enables *|
|* tools written in such languages. *|
|* *|
\*===----------------------------------------------------------------------===*/
#ifndef LLVM_C_TRANSFORMS_COROUTINES_H
#define LLVM_C_TRANSFORMS_COROUTINES_H
#include "llvm-c/ExternC.h"
#include "llvm-c/Types.h"
#include "llvm-c/Transforms/PassManagerBuilder.h"
LLVM_C_EXTERN_C_BEGIN
/**
* @defgroup LLVMCTransformsCoroutines Coroutine transformations
* @ingroup LLVMCTransforms
*
* @{
*/
/** See llvm::createCoroEarlyLegacyPass function. */
void LLVMAddCoroEarlyPass(LLVMPassManagerRef PM);
/** See llvm::createCoroSplitLegacyPass function. */
void LLVMAddCoroSplitPass(LLVMPassManagerRef PM);
/** See llvm::createCoroElideLegacyPass function. */
void LLVMAddCoroElidePass(LLVMPassManagerRef PM);
/** See llvm::createCoroCleanupLegacyPass function. */
void LLVMAddCoroCleanupPass(LLVMPassManagerRef PM);
/** See llvm::addCoroutinePassesToExtensionPoints. */
void LLVMPassManagerBuilderAddCoroutinePassesToExtensionPoints(LLVMPassManagerBuilderRef PMB);
/**
* @}
*/
LLVM_C_EXTERN_C_END
#endif

View File

@@ -1,96 +0,0 @@
/*===-- IPO.h - Interprocedural Transformations C Interface -----*- C++ -*-===*\
|* *|
|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
|* Exceptions. *|
|* See https://llvm.org/LICENSE.txt for license information. *|
|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
|* *|
|*===----------------------------------------------------------------------===*|
|* *|
|* This header declares the C interface to libLLVMIPO.a, which implements *|
|* various interprocedural transformations of the LLVM IR. *|
|* *|
\*===----------------------------------------------------------------------===*/
#ifndef LLVM_C_TRANSFORMS_IPO_H
#define LLVM_C_TRANSFORMS_IPO_H
#include "llvm-c/ExternC.h"
#include "llvm-c/Types.h"
LLVM_C_EXTERN_C_BEGIN
/**
* @defgroup LLVMCTransformsIPO Interprocedural transformations
* @ingroup LLVMCTransforms
*
* @{
*/
/** See llvm::createArgumentPromotionPass function. */
void LLVMAddArgumentPromotionPass(LLVMPassManagerRef PM);
/** See llvm::createConstantMergePass function. */
void LLVMAddConstantMergePass(LLVMPassManagerRef PM);
/** See llvm::createMergeFunctionsPass function. */
void LLVMAddMergeFunctionsPass(LLVMPassManagerRef PM);
/** See llvm::createCalledValuePropagationPass function. */
void LLVMAddCalledValuePropagationPass(LLVMPassManagerRef PM);
/** See llvm::createDeadArgEliminationPass function. */
void LLVMAddDeadArgEliminationPass(LLVMPassManagerRef PM);
/** See llvm::createFunctionAttrsPass function. */
void LLVMAddFunctionAttrsPass(LLVMPassManagerRef PM);
/** See llvm::createFunctionInliningPass function. */
void LLVMAddFunctionInliningPass(LLVMPassManagerRef PM);
/** See llvm::createAlwaysInlinerPass function. */
void LLVMAddAlwaysInlinerPass(LLVMPassManagerRef PM);
/** See llvm::createGlobalDCEPass function. */
void LLVMAddGlobalDCEPass(LLVMPassManagerRef PM);
/** See llvm::createGlobalOptimizerPass function. */
void LLVMAddGlobalOptimizerPass(LLVMPassManagerRef PM);
/** See llvm::createPruneEHPass function. */
void LLVMAddPruneEHPass(LLVMPassManagerRef PM);
/** See llvm::createIPSCCPPass function. */
void LLVMAddIPSCCPPass(LLVMPassManagerRef PM);
/** See llvm::createInternalizePass function. */
void LLVMAddInternalizePass(LLVMPassManagerRef, unsigned AllButMain);
/**
* Create and add the internalize pass to the given pass manager with the
* provided preservation callback.
*
* The context parameter is forwarded to the callback on each invocation.
* As such, it is the responsibility of the caller to extend its lifetime
* until execution of this pass has finished.
*
* @see llvm::createInternalizePass function.
*/
void LLVMAddInternalizePassWithMustPreservePredicate(
LLVMPassManagerRef PM,
void *Context,
LLVMBool (*MustPreserve)(LLVMValueRef, void *));
/** See llvm::createStripDeadPrototypesPass function. */
void LLVMAddStripDeadPrototypesPass(LLVMPassManagerRef PM);
/** See llvm::createStripSymbolsPass function. */
void LLVMAddStripSymbolsPass(LLVMPassManagerRef PM);
/**
* @}
*/
LLVM_C_EXTERN_C_END
#endif

View File

@@ -1,40 +0,0 @@
/*===-- Scalar.h - Scalar Transformation Library C Interface ----*- C++ -*-===*\
|* *|
|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
|* Exceptions. *|
|* See https://llvm.org/LICENSE.txt for license information. *|
|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
|* *|
|*===----------------------------------------------------------------------===*|
|* *|
|* This header declares the C interface to libLLVMInstCombine.a, which *|
|* combines instructions to form fewer, simple IR instructions. *|
|* *|
\*===----------------------------------------------------------------------===*/
#ifndef LLVM_C_TRANSFORMS_INSTCOMBINE_H
#define LLVM_C_TRANSFORMS_INSTCOMBINE_H
#include "llvm-c/ExternC.h"
#include "llvm-c/Types.h"
LLVM_C_EXTERN_C_BEGIN
/**
* @defgroup LLVMCTransformsInstCombine Instruction Combining transformations
* @ingroup LLVMCTransforms
*
* @{
*/
/** See llvm::createInstructionCombiningPass function. */
void LLVMAddInstructionCombiningPass(LLVMPassManagerRef PM);
/**
* @}
*/
LLVM_C_EXTERN_C_END
#endif

View File

@@ -0,0 +1,116 @@
/*===-- llvm-c/Transform/PassBuilder.h - PassBuilder for LLVM C ---*- C -*-===*\
|* *|
|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
|* Exceptions. *|
|* See https://llvm.org/LICENSE.txt for license information. *|
|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
|* *|
|*===----------------------------------------------------------------------===*|
|* *|
|* This header contains the LLVM-C interface into the new pass manager *|
|* *|
\*===----------------------------------------------------------------------===*/
#ifndef LLVM_C_TRANSFORMS_PASSBUILDER_H
#define LLVM_C_TRANSFORMS_PASSBUILDER_H
#include "llvm-c/Error.h"
#include "llvm-c/TargetMachine.h"
#include "llvm-c/Types.h"
/**
* @defgroup LLVMCCoreNewPM New Pass Manager
* @ingroup LLVMCCore
*
* @{
*/
LLVM_C_EXTERN_C_BEGIN
/**
* A set of options passed which are attached to the Pass Manager upon run.
*
* This corresponds to an llvm::LLVMPassBuilderOptions instance
*
* The details for how the different properties of this structure are used can
* be found in the source for LLVMRunPasses
*/
typedef struct LLVMOpaquePassBuilderOptions *LLVMPassBuilderOptionsRef;
/**
* Construct and run a set of passes over a module
*
* This function takes a string with the passes that should be used. The format
* of this string is the same as opt's -passes argument for the new pass
* manager. Individual passes may be specified, separated by commas. Full
* pipelines may also be invoked using `default<O3>` and friends. See opt for
* full reference of the Passes format.
*/
LLVMErrorRef LLVMRunPasses(LLVMModuleRef M, const char *Passes,
LLVMTargetMachineRef TM,
LLVMPassBuilderOptionsRef Options);
/**
* Create a new set of options for a PassBuilder
*
* Ownership of the returned instance is given to the client, and they are
* responsible for it. The client should call LLVMDisposePassBuilderOptions
* to free the pass builder options.
*/
LLVMPassBuilderOptionsRef LLVMCreatePassBuilderOptions(void);
/**
* Toggle adding the VerifierPass for the PassBuilder, ensuring all functions
* inside the module is valid.
*/
void LLVMPassBuilderOptionsSetVerifyEach(LLVMPassBuilderOptionsRef Options,
LLVMBool VerifyEach);
/**
* Toggle debug logging when running the PassBuilder
*/
void LLVMPassBuilderOptionsSetDebugLogging(LLVMPassBuilderOptionsRef Options,
LLVMBool DebugLogging);
void LLVMPassBuilderOptionsSetLoopInterleaving(
LLVMPassBuilderOptionsRef Options, LLVMBool LoopInterleaving);
void LLVMPassBuilderOptionsSetLoopVectorization(
LLVMPassBuilderOptionsRef Options, LLVMBool LoopVectorization);
void LLVMPassBuilderOptionsSetSLPVectorization(
LLVMPassBuilderOptionsRef Options, LLVMBool SLPVectorization);
void LLVMPassBuilderOptionsSetLoopUnrolling(LLVMPassBuilderOptionsRef Options,
LLVMBool LoopUnrolling);
void LLVMPassBuilderOptionsSetForgetAllSCEVInLoopUnroll(
LLVMPassBuilderOptionsRef Options, LLVMBool ForgetAllSCEVInLoopUnroll);
void LLVMPassBuilderOptionsSetLicmMssaOptCap(LLVMPassBuilderOptionsRef Options,
unsigned LicmMssaOptCap);
void LLVMPassBuilderOptionsSetLicmMssaNoAccForPromotionCap(
LLVMPassBuilderOptionsRef Options, unsigned LicmMssaNoAccForPromotionCap);
void LLVMPassBuilderOptionsSetCallGraphProfile(
LLVMPassBuilderOptionsRef Options, LLVMBool CallGraphProfile);
void LLVMPassBuilderOptionsSetMergeFunctions(LLVMPassBuilderOptionsRef Options,
LLVMBool MergeFunctions);
void LLVMPassBuilderOptionsSetInlinerThreshold(
LLVMPassBuilderOptionsRef Options, int Threshold);
/**
* Dispose of a heap-allocated PassBuilderOptions instance
*/
void LLVMDisposePassBuilderOptions(LLVMPassBuilderOptionsRef Options);
/**
* @}
*/
LLVM_C_EXTERN_C_END
#endif // LLVM_C_TRANSFORMS_PASSBUILDER_H

View File

@@ -1,87 +0,0 @@
/*===-- llvm-c/Transform/PassManagerBuilder.h - PMB C Interface ---*- C -*-===*\
|* *|
|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
|* Exceptions. *|
|* See https://llvm.org/LICENSE.txt for license information. *|
|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
|* *|
|*===----------------------------------------------------------------------===*|
|* *|
|* This header declares the C interface to the PassManagerBuilder class. *|
|* *|
\*===----------------------------------------------------------------------===*/
#ifndef LLVM_C_TRANSFORMS_PASSMANAGERBUILDER_H
#define LLVM_C_TRANSFORMS_PASSMANAGERBUILDER_H
#include "llvm-c/ExternC.h"
#include "llvm-c/Types.h"
typedef struct LLVMOpaquePassManagerBuilder *LLVMPassManagerBuilderRef;
LLVM_C_EXTERN_C_BEGIN
/**
* @defgroup LLVMCTransformsPassManagerBuilder Pass manager builder
* @ingroup LLVMCTransforms
*
* @{
*/
/** See llvm::PassManagerBuilder. */
LLVMPassManagerBuilderRef LLVMPassManagerBuilderCreate(void);
void LLVMPassManagerBuilderDispose(LLVMPassManagerBuilderRef PMB);
/** See llvm::PassManagerBuilder::OptLevel. */
void
LLVMPassManagerBuilderSetOptLevel(LLVMPassManagerBuilderRef PMB,
unsigned OptLevel);
/** See llvm::PassManagerBuilder::SizeLevel. */
void
LLVMPassManagerBuilderSetSizeLevel(LLVMPassManagerBuilderRef PMB,
unsigned SizeLevel);
/** See llvm::PassManagerBuilder::DisableUnitAtATime. */
void
LLVMPassManagerBuilderSetDisableUnitAtATime(LLVMPassManagerBuilderRef PMB,
LLVMBool Value);
/** See llvm::PassManagerBuilder::DisableUnrollLoops. */
void
LLVMPassManagerBuilderSetDisableUnrollLoops(LLVMPassManagerBuilderRef PMB,
LLVMBool Value);
/** See llvm::PassManagerBuilder::DisableSimplifyLibCalls */
void
LLVMPassManagerBuilderSetDisableSimplifyLibCalls(LLVMPassManagerBuilderRef PMB,
LLVMBool Value);
/** See llvm::PassManagerBuilder::Inliner. */
void
LLVMPassManagerBuilderUseInlinerWithThreshold(LLVMPassManagerBuilderRef PMB,
unsigned Threshold);
/** See llvm::PassManagerBuilder::populateFunctionPassManager. */
void
LLVMPassManagerBuilderPopulateFunctionPassManager(LLVMPassManagerBuilderRef PMB,
LLVMPassManagerRef PM);
/** See llvm::PassManagerBuilder::populateModulePassManager. */
void
LLVMPassManagerBuilderPopulateModulePassManager(LLVMPassManagerBuilderRef PMB,
LLVMPassManagerRef PM);
/** See llvm::PassManagerBuilder::populateLTOPassManager. */
void LLVMPassManagerBuilderPopulateLTOPassManager(LLVMPassManagerBuilderRef PMB,
LLVMPassManagerRef PM,
LLVMBool Internalize,
LLVMBool RunInliner);
/**
* @}
*/
LLVM_C_EXTERN_C_END
#endif

View File

@@ -1,170 +0,0 @@
/*===-- Scalar.h - Scalar Transformation Library C Interface ----*- C++ -*-===*\
|* *|
|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
|* Exceptions. *|
|* See https://llvm.org/LICENSE.txt for license information. *|
|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
|* *|
|*===----------------------------------------------------------------------===*|
|* *|
|* This header declares the C interface to libLLVMScalarOpts.a, which *|
|* implements various scalar transformations of the LLVM IR. *|
|* *|
|* Many exotic languages can interoperate with C code but have a harder time *|
|* with C++ due to name mangling. So in addition to C, this interface enables *|
|* tools written in such languages. *|
|* *|
\*===----------------------------------------------------------------------===*/
#ifndef LLVM_C_TRANSFORMS_SCALAR_H
#define LLVM_C_TRANSFORMS_SCALAR_H
#include "llvm-c/ExternC.h"
#include "llvm-c/Types.h"
LLVM_C_EXTERN_C_BEGIN
/**
* @defgroup LLVMCTransformsScalar Scalar transformations
* @ingroup LLVMCTransforms
*
* @{
*/
/** See llvm::createAggressiveDCEPass function. */
void LLVMAddAggressiveDCEPass(LLVMPassManagerRef PM);
/** See llvm::createDeadCodeEliminationPass function. */
void LLVMAddDCEPass(LLVMPassManagerRef PM);
/** See llvm::createBitTrackingDCEPass function. */
void LLVMAddBitTrackingDCEPass(LLVMPassManagerRef PM);
/** See llvm::createAlignmentFromAssumptionsPass function. */
void LLVMAddAlignmentFromAssumptionsPass(LLVMPassManagerRef PM);
/** See llvm::createCFGSimplificationPass function. */
void LLVMAddCFGSimplificationPass(LLVMPassManagerRef PM);
/** See llvm::createDeadStoreEliminationPass function. */
void LLVMAddDeadStoreEliminationPass(LLVMPassManagerRef PM);
/** See llvm::createScalarizerPass function. */
void LLVMAddScalarizerPass(LLVMPassManagerRef PM);
/** See llvm::createMergedLoadStoreMotionPass function. */
void LLVMAddMergedLoadStoreMotionPass(LLVMPassManagerRef PM);
/** See llvm::createGVNPass function. */
void LLVMAddGVNPass(LLVMPassManagerRef PM);
/** See llvm::createGVNPass function. */
void LLVMAddNewGVNPass(LLVMPassManagerRef PM);
/** See llvm::createIndVarSimplifyPass function. */
void LLVMAddIndVarSimplifyPass(LLVMPassManagerRef PM);
/** See llvm::createInstructionCombiningPass function. */
void LLVMAddInstructionCombiningPass(LLVMPassManagerRef PM);
/** See llvm::createInstSimplifyLegacyPass function. */
void LLVMAddInstructionSimplifyPass(LLVMPassManagerRef PM);
/** See llvm::createJumpThreadingPass function. */
void LLVMAddJumpThreadingPass(LLVMPassManagerRef PM);
/** See llvm::createLICMPass function. */
void LLVMAddLICMPass(LLVMPassManagerRef PM);
/** See llvm::createLoopDeletionPass function. */
void LLVMAddLoopDeletionPass(LLVMPassManagerRef PM);
/** See llvm::createLoopIdiomPass function */
void LLVMAddLoopIdiomPass(LLVMPassManagerRef PM);
/** See llvm::createLoopRotatePass function. */
void LLVMAddLoopRotatePass(LLVMPassManagerRef PM);
/** See llvm::createLoopRerollPass function. */
void LLVMAddLoopRerollPass(LLVMPassManagerRef PM);
/** See llvm::createLoopUnrollPass function. */
void LLVMAddLoopUnrollPass(LLVMPassManagerRef PM);
/** See llvm::createLoopUnrollAndJamPass function. */
void LLVMAddLoopUnrollAndJamPass(LLVMPassManagerRef PM);
/** See llvm::createLoopUnswitchPass function. */
void LLVMAddLoopUnswitchPass(LLVMPassManagerRef PM);
/** See llvm::createLowerAtomicPass function. */
void LLVMAddLowerAtomicPass(LLVMPassManagerRef PM);
/** See llvm::createMemCpyOptPass function. */
void LLVMAddMemCpyOptPass(LLVMPassManagerRef PM);
/** See llvm::createPartiallyInlineLibCallsPass function. */
void LLVMAddPartiallyInlineLibCallsPass(LLVMPassManagerRef PM);
/** See llvm::createReassociatePass function. */
void LLVMAddReassociatePass(LLVMPassManagerRef PM);
/** See llvm::createSCCPPass function. */
void LLVMAddSCCPPass(LLVMPassManagerRef PM);
/** See llvm::createSROAPass function. */
void LLVMAddScalarReplAggregatesPass(LLVMPassManagerRef PM);
/** See llvm::createSROAPass function. */
void LLVMAddScalarReplAggregatesPassSSA(LLVMPassManagerRef PM);
/** See llvm::createSROAPass function. */
void LLVMAddScalarReplAggregatesPassWithThreshold(LLVMPassManagerRef PM,
int Threshold);
/** See llvm::createSimplifyLibCallsPass function. */
void LLVMAddSimplifyLibCallsPass(LLVMPassManagerRef PM);
/** See llvm::createTailCallEliminationPass function. */
void LLVMAddTailCallEliminationPass(LLVMPassManagerRef PM);
/** See llvm::demotePromoteMemoryToRegisterPass function. */
void LLVMAddDemoteMemoryToRegisterPass(LLVMPassManagerRef PM);
/** See llvm::createVerifierPass function. */
void LLVMAddVerifierPass(LLVMPassManagerRef PM);
/** See llvm::createCorrelatedValuePropagationPass function */
void LLVMAddCorrelatedValuePropagationPass(LLVMPassManagerRef PM);
/** See llvm::createEarlyCSEPass function */
void LLVMAddEarlyCSEPass(LLVMPassManagerRef PM);
/** See llvm::createEarlyCSEPass function */
void LLVMAddEarlyCSEMemSSAPass(LLVMPassManagerRef PM);
/** See llvm::createLowerExpectIntrinsicPass function */
void LLVMAddLowerExpectIntrinsicPass(LLVMPassManagerRef PM);
/** See llvm::createLowerConstantIntrinsicsPass function */
void LLVMAddLowerConstantIntrinsicsPass(LLVMPassManagerRef PM);
/** See llvm::createTypeBasedAliasAnalysisPass function */
void LLVMAddTypeBasedAliasAnalysisPass(LLVMPassManagerRef PM);
/** See llvm::createScopedNoAliasAAPass function */
void LLVMAddScopedNoAliasAAPass(LLVMPassManagerRef PM);
/** See llvm::createBasicAliasAnalysisPass function */
void LLVMAddBasicAliasAnalysisPass(LLVMPassManagerRef PM);
/** See llvm::createUnifyFunctionExitNodesPass function */
void LLVMAddUnifyFunctionExitNodesPass(LLVMPassManagerRef PM);
/**
* @}
*/
LLVM_C_EXTERN_C_END
#endif

View File

@@ -1,50 +0,0 @@
/*===-- Utils.h - Transformation Utils Library C Interface ------*- C++ -*-===*\
|* *|
|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
|* Exceptions. *|
|* See https://llvm.org/LICENSE.txt for license information. *|
|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
|* *|
|*===----------------------------------------------------------------------===*|
|* *|
|* This header declares the C interface to libLLVMTransformUtils.a, which *|
|* implements various transformation utilities of the LLVM IR. *|
|* *|
|* Many exotic languages can interoperate with C code but have a harder time *|
|* with C++ due to name mangling. So in addition to C, this interface enables *|
|* tools written in such languages. *|
|* *|
\*===----------------------------------------------------------------------===*/
#ifndef LLVM_C_TRANSFORMS_UTILS_H
#define LLVM_C_TRANSFORMS_UTILS_H
#include "llvm-c/ExternC.h"
#include "llvm-c/Types.h"
LLVM_C_EXTERN_C_BEGIN
/**
* @defgroup LLVMCTransformsUtils Transformation Utilities
* @ingroup LLVMCTransforms
*
* @{
*/
/** See llvm::createLowerSwitchPass function. */
void LLVMAddLowerSwitchPass(LLVMPassManagerRef PM);
/** See llvm::createPromoteMemoryToRegisterPass function. */
void LLVMAddPromoteMemoryToRegisterPass(LLVMPassManagerRef PM);
/** See llvm::createAddDiscriminatorsPass function. */
void LLVMAddAddDiscriminatorsPass(LLVMPassManagerRef PM);
/**
* @}
*/
LLVM_C_EXTERN_C_END
#endif

View File

@@ -1,47 +0,0 @@
/*===---------------------------Vectorize.h --------------------- -*- C -*-===*\
|*===----------- Vectorization Transformation Library C Interface ---------===*|
|* *|
|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
|* Exceptions. *|
|* See https://llvm.org/LICENSE.txt for license information. *|
|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
|* *|
|*===----------------------------------------------------------------------===*|
|* *|
|* This header declares the C interface to libLLVMVectorize.a, which *|
|* implements various vectorization transformations of the LLVM IR. *|
|* *|
|* Many exotic languages can interoperate with C code but have a harder time *|
|* with C++ due to name mangling. So in addition to C, this interface enables *|
|* tools written in such languages. *|
|* *|
\*===----------------------------------------------------------------------===*/
#ifndef LLVM_C_TRANSFORMS_VECTORIZE_H
#define LLVM_C_TRANSFORMS_VECTORIZE_H
#include "llvm-c/ExternC.h"
#include "llvm-c/Types.h"
LLVM_C_EXTERN_C_BEGIN
/**
* @defgroup LLVMCTransformsVectorize Vectorization transformations
* @ingroup LLVMCTransforms
*
* @{
*/
/** See llvm::createLoopVectorizePass function. */
void LLVMAddLoopVectorizePass(LLVMPassManagerRef PM);
/** See llvm::createSLPVectorizerPass function. */
void LLVMAddSLPVectorizePass(LLVMPassManagerRef PM);
/**
* @}
*/
LLVM_C_EXTERN_C_END
#endif

View File

@@ -126,9 +126,6 @@ typedef struct LLVMOpaqueModuleProvider *LLVMModuleProviderRef;
/** @see llvm::PassManagerBase */
typedef struct LLVMOpaquePassManager *LLVMPassManagerRef;
/** @see llvm::PassRegistry */
typedef struct LLVMOpaquePassRegistry *LLVMPassRegistryRef;
/**
* Used to get the users and usees of a Value.
*

79
src/llvm-c/blake3.h Normal file
View File

@@ -0,0 +1,79 @@
/*===-- llvm-c/blake3.h - BLAKE3 C Interface ----------------------*- C -*-===*\
|* *|
|* Released into the public domain with CC0 1.0 *|
|* See 'llvm/lib/Support/BLAKE3/LICENSE' for info. *|
|* SPDX-License-Identifier: CC0-1.0 *|
|* *|
|*===----------------------------------------------------------------------===*|
|* *|
|* This header declares the C interface to LLVM's BLAKE3 implementation. *|
|* Original BLAKE3 C API: https://github.com/BLAKE3-team/BLAKE3/tree/1.3.1/c *|
|* *|
|* Symbols are prefixed with 'llvm' to avoid a potential conflict with *|
|* another BLAKE3 version within the same program. *|
|* *|
\*===----------------------------------------------------------------------===*/
#ifndef LLVM_C_BLAKE3_H
#define LLVM_C_BLAKE3_H
#include <stddef.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
#define LLVM_BLAKE3_VERSION_STRING "1.3.1"
#define LLVM_BLAKE3_KEY_LEN 32
#define LLVM_BLAKE3_OUT_LEN 32
#define LLVM_BLAKE3_BLOCK_LEN 64
#define LLVM_BLAKE3_CHUNK_LEN 1024
#define LLVM_BLAKE3_MAX_DEPTH 54
// This struct is a private implementation detail. It has to be here because
// it's part of llvm_blake3_hasher below.
typedef struct {
uint32_t cv[8];
uint64_t chunk_counter;
uint8_t buf[LLVM_BLAKE3_BLOCK_LEN];
uint8_t buf_len;
uint8_t blocks_compressed;
uint8_t flags;
} llvm_blake3_chunk_state;
typedef struct {
uint32_t key[8];
llvm_blake3_chunk_state chunk;
uint8_t cv_stack_len;
// The stack size is MAX_DEPTH + 1 because we do lazy merging. For example,
// with 7 chunks, we have 3 entries in the stack. Adding an 8th chunk
// requires a 4th entry, rather than merging everything down to 1, because we
// don't know whether more input is coming. This is different from how the
// reference implementation does things.
uint8_t cv_stack[(LLVM_BLAKE3_MAX_DEPTH + 1) * LLVM_BLAKE3_OUT_LEN];
} llvm_blake3_hasher;
const char *llvm_blake3_version(void);
void llvm_blake3_hasher_init(llvm_blake3_hasher *self);
void llvm_blake3_hasher_init_keyed(llvm_blake3_hasher *self,
const uint8_t key[LLVM_BLAKE3_KEY_LEN]);
void llvm_blake3_hasher_init_derive_key(llvm_blake3_hasher *self,
const char *context);
void llvm_blake3_hasher_init_derive_key_raw(llvm_blake3_hasher *self,
const void *context,
size_t context_len);
void llvm_blake3_hasher_update(llvm_blake3_hasher *self, const void *input,
size_t input_len);
void llvm_blake3_hasher_finalize(const llvm_blake3_hasher *self, uint8_t *out,
size_t out_len);
void llvm_blake3_hasher_finalize_seek(const llvm_blake3_hasher *self,
uint64_t seek, uint8_t *out,
size_t out_len);
void llvm_blake3_hasher_reset(llvm_blake3_hasher *self);
#ifdef __cplusplus
}
#endif
#endif /* LLVM_C_BLAKE3_H */

View File

@@ -46,7 +46,7 @@ typedef bool lto_bool_t;
* @{
*/
#define LTO_API_VERSION 27
#define LTO_API_VERSION 29
/**
* \since prior to LTO_API_VERSION=3
@@ -312,6 +312,16 @@ extern lto_bool_t lto_module_get_macho_cputype(lto_module_t mod,
unsigned int *out_cputype,
unsigned int *out_cpusubtype);
/**
* This function can be used by the linker to check if a given module has
* any constructor or destructor functions.
*
* Returns true if the module has either the @llvm.global_ctors or the
* @llvm.global_dtors symbol. Otherwise returns false.
*
* \since LTO_API_VERSION=29
*/
extern lto_bool_t lto_module_has_ctor_dtor(lto_module_t mod);
/**
* Diagnostic severity.
*
@@ -527,7 +537,23 @@ extern unsigned int
lto_api_version(void);
/**
* Sets options to help debug codegen bugs.
* Parses options immediately, making them available as early as possible. For
* example during executing codegen::InitTargetOptionsFromCodeGenFlags. Since
* parsing shud only happen once, only one of lto_codegen_debug_options or
* lto_set_debug_options should be called.
*
* This function takes one or more options separated by spaces.
* Warning: passing file paths through this function may confuse the argument
* parser if the paths contain spaces.
*
* \since LTO_API_VERSION=28
*/
extern void lto_set_debug_options(const char *const *options, int number);
/**
* Sets options to help debug codegen bugs. Since parsing shud only happen once,
* only one of lto_codegen_debug_options or lto_set_debug_options
* should be called.
*
* This function takes one or more options separated by spaces.
* Warning: passing file paths through this function may confuse the argument

View File

@@ -1130,14 +1130,14 @@ namespace lbAbiArm64 {
return non_struct(c, return_type);
} else if (is_homogenous_aggregate(c, return_type, &homo_base_type, &homo_member_count)) {
if (is_homogenous_aggregate_small_enough(homo_base_type, homo_member_count)) {
return lb_arg_type_direct(return_type, LLVMArrayType(homo_base_type, homo_member_count), nullptr, nullptr);
return lb_arg_type_direct(return_type, llvm_array_type(homo_base_type, homo_member_count), nullptr, nullptr);
} else {
//TODO(Platin): do i need to create stuff that can handle the diffrent return type?
// else this needs a fix in llvm_backend_proc as we would need to cast it to the correct array type
LB_ABI_MODIFY_RETURN_IF_TUPLE_MACRO();
//LLVMTypeRef array_type = LLVMArrayType(homo_base_type, homo_member_count);
//LLVMTypeRef array_type = llvm_array_type(homo_base_type, homo_member_count);
LLVMAttributeRef attr = lb_create_enum_attribute_with_type(c, "sret", return_type);
return lb_arg_type_indirect(return_type, attr);
}
@@ -1155,7 +1155,7 @@ namespace lbAbiArm64 {
cast_type = LLVMInt64TypeInContext(c);
} else {
unsigned count = cast(unsigned)((size+7)/8);
cast_type = LLVMArrayType(LLVMInt64TypeInContext(c), count);
cast_type = llvm_array_type(LLVMInt64TypeInContext(c), count);
}
return lb_arg_type_direct(return_type, cast_type, nullptr, nullptr);
} else {
@@ -1180,7 +1180,7 @@ namespace lbAbiArm64 {
args[i] = non_struct(c, type);
} else if (is_homogenous_aggregate(c, type, &homo_base_type, &homo_member_count)) {
if (is_homogenous_aggregate_small_enough(homo_base_type, homo_member_count)) {
args[i] = lb_arg_type_direct(type, LLVMArrayType(homo_base_type, homo_member_count), nullptr, nullptr);
args[i] = lb_arg_type_direct(type, llvm_array_type(homo_base_type, homo_member_count), nullptr, nullptr);
} else {
args[i] = lb_arg_type_indirect(type, nullptr);;
}
@@ -1198,7 +1198,7 @@ namespace lbAbiArm64 {
cast_type = LLVMIntTypeInContext(c, 64);
} else {
unsigned count = cast(unsigned)((size+7)/8);
cast_type = LLVMArrayType(LLVMIntTypeInContext(c, 64), count);
cast_type = llvm_array_type(LLVMIntTypeInContext(c, 64), count);
}
args[i] = lb_arg_type_direct(type, cast_type, nullptr, nullptr);
} else {
@@ -1439,10 +1439,10 @@ namespace lbAbiArm32 {
args[i] = lb_arg_type_indirect(t, nullptr);
} else if (a <= 4) {
unsigned n = cast(unsigned)((sz + 3) / 4);
args[i] = lb_arg_type_direct(LLVMArrayType(LLVMIntTypeInContext(c, 32), n));
args[i] = lb_arg_type_direct(llvm_array_type(LLVMIntTypeInContext(c, 32), n));
} else {
unsigned n = cast(unsigned)((sz + 7) / 8);
args[i] = lb_arg_type_direct(LLVMArrayType(LLVMIntTypeInContext(c, 64), n));
args[i] = lb_arg_type_direct(llvm_array_type(LLVMIntTypeInContext(c, 64), n));
}
}
}

View File

@@ -168,7 +168,7 @@ gb_internal lbValue lb_equal_proc_for_type(lbModule *m, Type *type) {
map_set(&m->equal_procs, type, p);
lb_begin_procedure_body(p);
lb_add_attribute_to_proc(m, p->value, "readonly");
// lb_add_attribute_to_proc(m, p->value, "readonly");
lb_add_attribute_to_proc(m, p->value, "nounwind");
LLVMValueRef x = LLVMGetParam(p->value, 0);
@@ -337,7 +337,7 @@ gb_internal lbValue lb_hasher_proc_for_type(lbModule *m, Type *type) {
lb_begin_procedure_body(p);
defer (lb_end_procedure_body(p));
lb_add_attribute_to_proc(m, p->value, "readonly");
// lb_add_attribute_to_proc(m, p->value, "readonly");
lb_add_attribute_to_proc(m, p->value, "nounwind");
LLVMValueRef x = LLVMGetParam(p->value, 0);
@@ -346,7 +346,7 @@ gb_internal lbValue lb_hasher_proc_for_type(lbModule *m, Type *type) {
lbValue seed = {y, t_uintptr};
lb_add_proc_attribute_at_index(p, 1+0, "nonnull");
lb_add_proc_attribute_at_index(p, 1+0, "readonly");
// lb_add_proc_attribute_at_index(p, 1+0, "readonly");
if (is_type_simple_compare(type)) {
lbValue res = lb_simple_compare_hash(p, type, data, seed);
@@ -1025,6 +1025,10 @@ gb_internal lbProcedure *lb_create_startup_type_info(lbModule *m) {
LLVMSetLinkage(p->value, LLVMInternalLinkage);
lb_add_attribute_to_proc(m, p->value, "nounwind");
if (!LB_USE_GIANT_PACKED_STRUCT) {
lb_add_attribute_to_proc(m, p->value, "optnone");
lb_add_attribute_to_proc(m, p->value, "noinline");
}
lb_begin_procedure_body(p);
@@ -1086,6 +1090,8 @@ gb_internal lbProcedure *lb_create_startup_runtime(lbModule *main_module, lbProc
lbProcedure *p = lb_create_dummy_procedure(main_module, str_lit(LB_STARTUP_RUNTIME_PROC_NAME), proc_type);
p->is_startup = true;
lb_add_attribute_to_proc(p->module, p->value, "optnone");
lb_add_attribute_to_proc(p->module, p->value, "noinline");
lb_begin_procedure_body(p);
@@ -1189,6 +1195,8 @@ gb_internal lbProcedure *lb_create_cleanup_runtime(lbModule *main_module) { // C
lbProcedure *p = lb_create_dummy_procedure(main_module, str_lit(LB_CLEANUP_RUNTIME_PROC_NAME), proc_type);
p->is_startup = true;
lb_add_attribute_to_proc(p->module, p->value, "optnone");
lb_add_attribute_to_proc(p->module, p->value, "noinline");
lb_begin_procedure_body(p);
@@ -1352,33 +1360,25 @@ gb_internal WORKER_TASK_PROC(lb_llvm_function_pass_per_module) {
{
GB_ASSERT(m->function_pass_managers[lbFunctionPassManager_default] == nullptr);
m->function_pass_managers[lbFunctionPassManager_default] = LLVMCreateFunctionPassManagerForModule(m->mod);
m->function_pass_managers[lbFunctionPassManager_default_without_memcpy] = LLVMCreateFunctionPassManagerForModule(m->mod);
m->function_pass_managers[lbFunctionPassManager_none] = LLVMCreateFunctionPassManagerForModule(m->mod);
m->function_pass_managers[lbFunctionPassManager_minimal] = LLVMCreateFunctionPassManagerForModule(m->mod);
m->function_pass_managers[lbFunctionPassManager_size] = LLVMCreateFunctionPassManagerForModule(m->mod);
m->function_pass_managers[lbFunctionPassManager_speed] = LLVMCreateFunctionPassManagerForModule(m->mod);
for (i32 i = 0; i < lbFunctionPassManager_COUNT; i++) {
m->function_pass_managers[i] = LLVMCreateFunctionPassManagerForModule(m->mod);
}
LLVMInitializeFunctionPassManager(m->function_pass_managers[lbFunctionPassManager_default]);
LLVMInitializeFunctionPassManager(m->function_pass_managers[lbFunctionPassManager_default_without_memcpy]);
LLVMInitializeFunctionPassManager(m->function_pass_managers[lbFunctionPassManager_none]);
LLVMInitializeFunctionPassManager(m->function_pass_managers[lbFunctionPassManager_minimal]);
LLVMInitializeFunctionPassManager(m->function_pass_managers[lbFunctionPassManager_size]);
LLVMInitializeFunctionPassManager(m->function_pass_managers[lbFunctionPassManager_speed]);
for (i32 i = 0; i < lbFunctionPassManager_COUNT; i++) {
LLVMInitializeFunctionPassManager(m->function_pass_managers[i]);
}
lb_populate_function_pass_manager(m, m->function_pass_managers[lbFunctionPassManager_default], false, build_context.optimization_level);
lb_populate_function_pass_manager(m, m->function_pass_managers[lbFunctionPassManager_default_without_memcpy], true, build_context.optimization_level);
lb_populate_function_pass_manager_specific(m, m->function_pass_managers[lbFunctionPassManager_none], -1);
lb_populate_function_pass_manager_specific(m, m->function_pass_managers[lbFunctionPassManager_minimal], 0);
lb_populate_function_pass_manager_specific(m, m->function_pass_managers[lbFunctionPassManager_size], 1);
lb_populate_function_pass_manager_specific(m, m->function_pass_managers[lbFunctionPassManager_speed], 2);
lb_populate_function_pass_manager_specific(m, m->function_pass_managers[lbFunctionPassManager_none], -1);
lb_populate_function_pass_manager_specific(m, m->function_pass_managers[lbFunctionPassManager_minimal], 0);
lb_populate_function_pass_manager_specific(m, m->function_pass_managers[lbFunctionPassManager_size], 1);
lb_populate_function_pass_manager_specific(m, m->function_pass_managers[lbFunctionPassManager_speed], 2);
lb_populate_function_pass_manager_specific(m, m->function_pass_managers[lbFunctionPassManager_aggressive], 3);
LLVMFinalizeFunctionPassManager(m->function_pass_managers[lbFunctionPassManager_default]);
LLVMFinalizeFunctionPassManager(m->function_pass_managers[lbFunctionPassManager_default_without_memcpy]);
LLVMFinalizeFunctionPassManager(m->function_pass_managers[lbFunctionPassManager_none]);
LLVMFinalizeFunctionPassManager(m->function_pass_managers[lbFunctionPassManager_minimal]);
LLVMFinalizeFunctionPassManager(m->function_pass_managers[lbFunctionPassManager_size]);
LLVMFinalizeFunctionPassManager(m->function_pass_managers[lbFunctionPassManager_speed]);
for (i32 i = 0; i < lbFunctionPassManager_COUNT; i++) {
LLVMFinalizeFunctionPassManager(m->function_pass_managers[i]);
}
}
if (m == &m->gen->default_module) {
@@ -1393,6 +1393,8 @@ gb_internal WORKER_TASK_PROC(lb_llvm_function_pass_per_module) {
lbFunctionPassManagerKind pass_manager_kind = lbFunctionPassManager_default;
if (p->flags & lbProcedureFlag_WithoutMemcpyPass) {
pass_manager_kind = lbFunctionPassManager_default_without_memcpy;
lb_add_attribute_to_proc(p->module, p->value, "optnone");
lb_add_attribute_to_proc(p->module, p->value, "noinline");
} else {
if (p->entity && p->entity->kind == Entity_Procedure) {
switch (p->entity->Procedure.optimization_mode) {
@@ -1402,6 +1404,7 @@ gb_internal WORKER_TASK_PROC(lb_llvm_function_pass_per_module) {
break;
case ProcedureOptimizationMode_Size:
pass_manager_kind = lbFunctionPassManager_size;
lb_add_attribute_to_proc(p->module, p->value, "optsize");
break;
case ProcedureOptimizationMode_Speed:
pass_manager_kind = lbFunctionPassManager_speed;
@@ -1449,6 +1452,83 @@ gb_internal WORKER_TASK_PROC(lb_llvm_module_pass_worker_proc) {
LLVMPassManagerRef module_pass_manager = LLVMCreatePassManager();
lb_populate_module_pass_manager(wd->target_machine, module_pass_manager, build_context.optimization_level);
LLVMRunPassManager(module_pass_manager, wd->m->mod);
#if LB_USE_NEW_PASS_SYSTEM
auto passes = array_make<char const *>(heap_allocator(), 0, 64);
defer (array_free(&passes));
LLVMPassBuilderOptionsRef pb_options = LLVMCreatePassBuilderOptions();
defer (LLVMDisposePassBuilderOptions(pb_options));
switch (build_context.optimization_level) {
case -1:
break;
case 0:
array_add(&passes, "always-inline");
array_add(&passes, "function(annotation-remarks)");
break;
case 1:
array_add(&passes, "default<Os>");
break;
case 2:
array_add(&passes, "default<O2>");
break;
case 3:
array_add(&passes, "default<O3>");
break;
}
// asan - Linux, Darwin, Windows
// msan - linux
// tsan - Linux, Darwin
// ubsan - Linux, Darwin, Windows (NOT SUPPORTED WITH LLVM C-API)
if (build_context.sanitizer_flags & SanitizerFlag_Address) {
array_add(&passes, "asan");
}
if (build_context.sanitizer_flags & SanitizerFlag_Memory) {
array_add(&passes, "msan");
}
if (build_context.sanitizer_flags & SanitizerFlag_Thread) {
array_add(&passes, "tsan");
}
if (passes.count == 0) {
array_add(&passes, "verify");
}
gbString passes_str = gb_string_make_reserve(heap_allocator(), 1024);
defer (gb_string_free(passes_str));
for_array(i, passes) {
if (i != 0) {
passes_str = gb_string_appendc(passes_str, ",");
}
passes_str = gb_string_appendc(passes_str, passes[i]);
}
LLVMErrorRef llvm_err = LLVMRunPasses(wd->m->mod, passes_str, wd->target_machine, pb_options);
defer (LLVMConsumeError(llvm_err));
if (llvm_err != nullptr) {
char *llvm_error = LLVMGetErrorMessage(llvm_err);
gb_printf_err("LLVM Error:\n%s\n", llvm_error);
LLVMDisposeErrorMessage(llvm_error);
llvm_error = nullptr;
if (build_context.keep_temp_files) {
TIME_SECTION("LLVM Print Module to File");
String filepath_ll = lb_filepath_ll_for_module(wd->m);
if (LLVMPrintModuleToFile(wd->m->mod, cast(char const *)filepath_ll.text, &llvm_error)) {
gb_printf_err("LLVM Error: %s\n", llvm_error);
}
}
gb_exit(1);
return 1;
}
#endif
return 0;
}
@@ -2035,12 +2115,15 @@ gb_internal bool lb_generate_code(lbGenerator *gen) {
// GB_ASSERT_MSG(LLVMTargetHasAsmBackend(target));
LLVMCodeGenOptLevel code_gen_level = LLVMCodeGenLevelNone;
if (!LB_USE_NEW_PASS_SYSTEM) {
build_context.optimization_level = gb_clamp(build_context.optimization_level, -1, 2);
}
switch (build_context.optimization_level) {
case 0: code_gen_level = LLVMCodeGenLevelNone; break;
case 1: code_gen_level = LLVMCodeGenLevelLess; break;
case 2: code_gen_level = LLVMCodeGenLevelDefault; break;
case 3: code_gen_level = LLVMCodeGenLevelDefault; break; // NOTE(bill): force -opt:3 to be the same as -opt:2
// case 3: code_gen_level = LLVMCodeGenLevelAggressive; break;
default:/*fallthrough*/
case 0: code_gen_level = LLVMCodeGenLevelNone; break;
case 1: code_gen_level = LLVMCodeGenLevelLess; break;
case 2: code_gen_level = LLVMCodeGenLevelDefault; break;
case 3: code_gen_level = LLVMCodeGenLevelAggressive; break;
}
// NOTE(bill): Target Machine Creation
@@ -2144,10 +2227,16 @@ gb_internal bool lb_generate_code(lbGenerator *gen) {
{ // Add type info data
isize max_type_info_count = info->minimum_dependency_type_info_set.count+1;
// gb_printf_err("max_type_info_count: %td\n", max_type_info_count);
Type *t = alloc_type_array(t_type_info, max_type_info_count);
LLVMValueRef g = LLVMAddGlobal(m->mod, lb_type(m, t), LB_TYPE_INFO_DATA_NAME);
LLVMSetInitializer(g, LLVMConstNull(lb_type(m, t)));
// IMPORTANT NOTE(bill): As LLVM does not have a union type, an array of unions cannot be initialized
// at compile time without cheating in some way. This means to emulate an array of unions is to use
// a giant packed struct of "corrected" data types.
LLVMTypeRef internal_llvm_type = lb_setup_type_info_data_internal_type(m, max_type_info_count);
LLVMValueRef g = LLVMAddGlobal(m->mod, internal_llvm_type, LB_TYPE_INFO_DATA_NAME);
LLVMSetInitializer(g, LLVMConstNull(internal_llvm_type));
LLVMSetLinkage(g, USE_SEPARATE_MODULES ? LLVMExternalLinkage : LLVMInternalLinkage);
lbValue value = {};
@@ -2156,6 +2245,10 @@ gb_internal bool lb_generate_code(lbGenerator *gen) {
lb_global_type_info_data_entity = alloc_entity_variable(nullptr, make_token_ident(LB_TYPE_INFO_DATA_NAME), t, EntityState_Resolved);
lb_add_entity(m, lb_global_type_info_data_entity, value);
if (LB_USE_GIANT_PACKED_STRUCT) {
lb_make_global_private_const(g);
}
}
{ // Type info member buffer
// NOTE(bill): Removes need for heap allocation by making it global memory
@@ -2180,50 +2273,63 @@ gb_internal bool lb_generate_code(lbGenerator *gen) {
}
}
if (count > 0) {
{
char const *name = LB_TYPE_INFO_TYPES_NAME;
Type *t = alloc_type_array(t_type_info_ptr, count);
LLVMValueRef g = LLVMAddGlobal(m->mod, lb_type(m, t), name);
LLVMSetInitializer(g, LLVMConstNull(lb_type(m, t)));
LLVMSetLinkage(g, LLVMInternalLinkage);
lb_global_type_info_member_types = lb_addr({g, alloc_type_pointer(t)});
{
char const *name = LB_TYPE_INFO_TYPES_NAME;
Type *t = alloc_type_array(t_type_info_ptr, count);
LLVMValueRef g = LLVMAddGlobal(m->mod, lb_type(m, t), name);
LLVMSetInitializer(g, LLVMConstNull(lb_type(m, t)));
LLVMSetLinkage(g, LLVMInternalLinkage);
if (LB_USE_GIANT_PACKED_STRUCT) {
lb_make_global_private_const(g);
}
lb_global_type_info_member_types = lb_addr({g, alloc_type_pointer(t)});
}
{
char const *name = LB_TYPE_INFO_NAMES_NAME;
Type *t = alloc_type_array(t_string, count);
LLVMValueRef g = LLVMAddGlobal(m->mod, lb_type(m, t), name);
LLVMSetInitializer(g, LLVMConstNull(lb_type(m, t)));
LLVMSetLinkage(g, LLVMInternalLinkage);
if (LB_USE_GIANT_PACKED_STRUCT) {
lb_make_global_private_const(g);
}
{
char const *name = LB_TYPE_INFO_NAMES_NAME;
Type *t = alloc_type_array(t_string, count);
LLVMValueRef g = LLVMAddGlobal(m->mod, lb_type(m, t), name);
LLVMSetInitializer(g, LLVMConstNull(lb_type(m, t)));
LLVMSetLinkage(g, LLVMInternalLinkage);
lb_global_type_info_member_names = lb_addr({g, alloc_type_pointer(t)});
}
{
char const *name = LB_TYPE_INFO_OFFSETS_NAME;
Type *t = alloc_type_array(t_uintptr, count);
LLVMValueRef g = LLVMAddGlobal(m->mod, lb_type(m, t), name);
LLVMSetInitializer(g, LLVMConstNull(lb_type(m, t)));
LLVMSetLinkage(g, LLVMInternalLinkage);
lb_global_type_info_member_offsets = lb_addr({g, alloc_type_pointer(t)});
lb_global_type_info_member_names = lb_addr({g, alloc_type_pointer(t)});
}
{
char const *name = LB_TYPE_INFO_OFFSETS_NAME;
Type *t = alloc_type_array(t_uintptr, count);
LLVMValueRef g = LLVMAddGlobal(m->mod, lb_type(m, t), name);
LLVMSetInitializer(g, LLVMConstNull(lb_type(m, t)));
LLVMSetLinkage(g, LLVMInternalLinkage);
if (LB_USE_GIANT_PACKED_STRUCT) {
lb_make_global_private_const(g);
}
lb_global_type_info_member_offsets = lb_addr({g, alloc_type_pointer(t)});
}
{
char const *name = LB_TYPE_INFO_USINGS_NAME;
Type *t = alloc_type_array(t_bool, count);
LLVMValueRef g = LLVMAddGlobal(m->mod, lb_type(m, t), name);
LLVMSetInitializer(g, LLVMConstNull(lb_type(m, t)));
LLVMSetLinkage(g, LLVMInternalLinkage);
lb_global_type_info_member_usings = lb_addr({g, alloc_type_pointer(t)});
{
char const *name = LB_TYPE_INFO_USINGS_NAME;
Type *t = alloc_type_array(t_bool, count);
LLVMValueRef g = LLVMAddGlobal(m->mod, lb_type(m, t), name);
LLVMSetInitializer(g, LLVMConstNull(lb_type(m, t)));
LLVMSetLinkage(g, LLVMInternalLinkage);
if (LB_USE_GIANT_PACKED_STRUCT) {
lb_make_global_private_const(g);
}
lb_global_type_info_member_usings = lb_addr({g, alloc_type_pointer(t)});
}
{
char const *name = LB_TYPE_INFO_TAGS_NAME;
Type *t = alloc_type_array(t_string, count);
LLVMValueRef g = LLVMAddGlobal(m->mod, lb_type(m, t), name);
LLVMSetInitializer(g, LLVMConstNull(lb_type(m, t)));
LLVMSetLinkage(g, LLVMInternalLinkage);
lb_global_type_info_member_tags = lb_addr({g, alloc_type_pointer(t)});
{
char const *name = LB_TYPE_INFO_TAGS_NAME;
Type *t = alloc_type_array(t_string, count);
LLVMValueRef g = LLVMAddGlobal(m->mod, lb_type(m, t), name);
LLVMSetInitializer(g, LLVMConstNull(lb_type(m, t)));
LLVMSetLinkage(g, LLVMInternalLinkage);
if (LB_USE_GIANT_PACKED_STRUCT) {
lb_make_global_private_const(g);
}
lb_global_type_info_member_tags = lb_addr({g, alloc_type_pointer(t)});
}
}
}
@@ -2444,17 +2550,13 @@ gb_internal bool lb_generate_code(lbGenerator *gen) {
}
}
TIME_SECTION("LLVM Function Pass");
lb_llvm_function_passes(gen, do_threading && !build_context.ODIN_DEBUG);
TIME_SECTION("LLVM Module Pass");
lb_llvm_module_passes(gen, do_threading);
TIME_SECTION("LLVM Module Verification");
if (!lb_llvm_module_verification(gen, do_threading)) {
return false;
}
@@ -2498,6 +2600,21 @@ gb_internal bool lb_generate_code(lbGenerator *gen) {
return false;
}
if (build_context.sanitizer_flags & SanitizerFlag_Address) {
auto paths = array_make<String>(heap_allocator(), 0, 1);
if (build_context.metrics.os == TargetOs_windows) {
String path = concatenate_strings(permanent_allocator(), build_context.ODIN_ROOT, str_lit("\\bin\\llvm\\windows\\clang_rt.asan-x86_64.lib"));
array_add(&paths, path);
}
Entity *lib = alloc_entity_library_name(nullptr, make_token_ident("asan_lib"), nullptr, slice_from_array(paths), str_lit("asan_lib"));
array_add(&gen->foreign_libraries, lib);
}
if (build_context.sanitizer_flags & SanitizerFlag_Memory) {
}
if (build_context.sanitizer_flags & SanitizerFlag_Thread) {
}
gb_sort_array(gen->foreign_libraries.data, gen->foreign_libraries.count, foreign_library_cmp);
return true;

View File

@@ -6,13 +6,7 @@
#include "llvm-c/Object.h"
#include "llvm-c/BitWriter.h"
#include "llvm-c/DebugInfo.h"
#include "llvm-c/Transforms/AggressiveInstCombine.h"
#include "llvm-c/Transforms/InstCombine.h"
#include "llvm-c/Transforms/IPO.h"
#include "llvm-c/Transforms/PassManagerBuilder.h"
#include "llvm-c/Transforms/Scalar.h"
#include "llvm-c/Transforms/Utils.h"
#include "llvm-c/Transforms/Vectorize.h"
#include "llvm-c/Transforms/PassBuilder.h"
#else
#include <llvm-c/Core.h>
#include <llvm-c/ExecutionEngine.h>
@@ -54,6 +48,20 @@
#define ODIN_LLVM_MINIMUM_VERSION_14 0
#endif
#if LLVM_VERSION_MAJOR == 15 || LLVM_VERSION_MAJOR == 16
#error "LLVM versions 15 and 16 are not supported"
#endif
#if LLVM_VERSION_MAJOR >= 17
#define LB_USE_NEW_PASS_SYSTEM 1
#else
#define LB_USE_NEW_PASS_SYSTEM 0
#endif
gb_internal bool lb_use_new_pass_system(void) {
return LB_USE_NEW_PASS_SYSTEM;
}
struct lbProcedure;
struct lbValue {
@@ -123,6 +131,7 @@ enum lbFunctionPassManagerKind {
lbFunctionPassManager_minimal,
lbFunctionPassManager_size,
lbFunctionPassManager_speed,
lbFunctionPassManager_aggressive,
lbFunctionPassManager_COUNT
};
@@ -170,6 +179,8 @@ struct lbModule {
lbProcedure *curr_procedure;
LLVMBuilderRef const_dummy_builder;
LLVMDIBuilderRef debug_builder;
LLVMMetadataRef debug_compile_unit;
@@ -440,6 +451,7 @@ gb_internal lbValue lb_emit_runtime_call(lbProcedure *p, char const *c_name, Arr
gb_internal lbValue lb_emit_ptr_offset(lbProcedure *p, lbValue ptr, lbValue index);
gb_internal lbValue lb_const_ptr_offset(lbModule *m, lbValue ptr, lbValue index);
gb_internal lbValue lb_string_elem(lbProcedure *p, lbValue string);
gb_internal lbValue lb_string_len(lbProcedure *p, lbValue string);
gb_internal lbValue lb_cstring_len(lbProcedure *p, lbValue value);
@@ -486,6 +498,7 @@ gb_internal lbValue lb_find_value_from_entity(lbModule *m, Entity *e);
gb_internal void lb_store_type_case_implicit(lbProcedure *p, Ast *clause, lbValue value);
gb_internal lbAddr lb_store_range_stmt_val(lbProcedure *p, Ast *stmt_val, lbValue value);
gb_internal lbValue lb_emit_source_code_location_const(lbProcedure *p, String const &procedure, TokenPos const &pos);
gb_internal lbValue lb_const_source_code_location_const(lbModule *m, String const &procedure, TokenPos const &pos);
gb_internal lbValue lb_handle_param_value(lbProcedure *p, Type *parameter_type, ParameterValue const &param_value, TokenPos const &pos);
@@ -542,6 +555,15 @@ gb_internal LLVMTypeRef OdinLLVMGetVectorElementType(LLVMTypeRef type);
gb_internal String lb_filepath_ll_for_module(lbModule *m);
gb_internal LLVMTypeRef llvm_array_type(LLVMTypeRef ElementType, uint64_t ElementCount) {
#if LB_USE_NEW_PASS_SYSTEM
return LLVMArrayType2(ElementType, ElementCount);
#else
return LLVMArrayType(ElementType, cast(unsigned)ElementCount);
#endif
}
#define LB_STARTUP_RUNTIME_PROC_NAME "__$startup_runtime"
#define LB_CLEANUP_RUNTIME_PROC_NAME "__$cleanup_runtime"
#define LB_STARTUP_TYPE_INFO_PROC_NAME "__$startup_type_info"

View File

@@ -14,17 +14,6 @@ gb_internal bool lb_is_const_or_global(lbValue value) {
if (lb_is_const(value)) {
return true;
}
// TODO remove use of LLVMGetElementType
#if 0
if (LLVMGetValueKind(value.value) == LLVMGlobalVariableValueKind) {
LLVMTypeRef t = LLVMGetElementType(LLVMTypeOf(value.value));
if (!lb_is_type_kind(t, LLVMPointerTypeKind)) {
return false;
}
LLVMTypeRef elem = LLVMGetElementType(t);
return lb_is_type_kind(elem, LLVMFunctionTypeKind);
}
#endif
return false;
}
@@ -75,8 +64,8 @@ gb_internal String lb_get_const_string(lbModule *m, lbValue value) {
unsigned ptr_indices[1] = {0};
unsigned len_indices[1] = {1};
LLVMValueRef underlying_ptr = LLVMConstExtractValue(value.value, ptr_indices, gb_count_of(ptr_indices));
LLVMValueRef underlying_len = LLVMConstExtractValue(value.value, len_indices, gb_count_of(len_indices));
LLVMValueRef underlying_ptr = llvm_const_extract_value(m, value.value, ptr_indices, gb_count_of(ptr_indices));
LLVMValueRef underlying_len = llvm_const_extract_value(m, value.value, len_indices, gb_count_of(len_indices));
GB_ASSERT(LLVMGetConstOpcode(underlying_ptr) == LLVMGetElementPtr);
underlying_ptr = LLVMGetOperand(underlying_ptr, 0);
@@ -295,14 +284,12 @@ gb_internal lbValue lb_expr_untyped_const_to_typed(lbModule *m, Ast *expr, Type
return lb_const_value(m, t, tv.value);
}
gb_internal lbValue lb_emit_source_code_location_const(lbProcedure *p, String const &procedure, TokenPos const &pos) {
lbModule *m = p->module;
gb_internal lbValue lb_const_source_code_location_const(lbModule *m, String const &procedure, TokenPos const &pos) {
LLVMValueRef fields[4] = {};
fields[0]/*file*/ = lb_find_or_add_entity_string(p->module, get_file_path_string(pos.file_id)).value;
fields[0]/*file*/ = lb_find_or_add_entity_string(m, get_file_path_string(pos.file_id)).value;
fields[1]/*line*/ = lb_const_int(m, t_i32, pos.line).value;
fields[2]/*column*/ = lb_const_int(m, t_i32, pos.column).value;
fields[3]/*procedure*/ = lb_find_or_add_entity_string(p->module, procedure).value;
fields[3]/*procedure*/ = lb_find_or_add_entity_string(m, procedure).value;
lbValue res = {};
res.value = llvm_const_named_struct(m, t_source_code_location, fields, gb_count_of(fields));
@@ -310,6 +297,12 @@ gb_internal lbValue lb_emit_source_code_location_const(lbProcedure *p, String co
return res;
}
gb_internal lbValue lb_emit_source_code_location_const(lbProcedure *p, String const &procedure, TokenPos const &pos) {
lbModule *m = p->module;
return lb_const_source_code_location_const(m, procedure, pos);
}
gb_internal lbValue lb_emit_source_code_location_const(lbProcedure *p, Ast *node) {
String proc_name = {};
if (p->entity) {
@@ -1096,7 +1089,7 @@ gb_internal lbValue lb_const_value(lbModule *m, Type *type, ExactValue value, bo
if (is_constant) {
LLVMValueRef elem_value = lb_const_value(m, tav.type, tav.value, allow_local).value;
if (LLVMIsConstant(elem_value)) {
values[index] = LLVMConstInsertValue(values[index], elem_value, idx_list, idx_list_len);
values[index] = llvm_const_insert_value(m, values[index], elem_value, idx_list, idx_list_len);
} else {
is_constant = false;
}

View File

@@ -4292,7 +4292,7 @@ gb_internal lbAddr lb_build_addr_compound_lit(lbProcedure *p, Ast *expr) {
unsigned len_index = lb_convert_struct_index(p->module, type, 1);
if (lb_is_const(slice)) {
unsigned indices[1] = {len_index};
count.value = LLVMConstExtractValue(slice.value, indices, gb_count_of(indices));
count.value = llvm_const_extract_value(p->module, slice.value, indices, gb_count_of(indices));
} else {
count.value = LLVMBuildExtractValue(p->builder, slice.value, len_index, "");
}

View File

@@ -90,6 +90,8 @@ gb_internal void lb_init_module(lbModule *m, Checker *c) {
map_init(&m->map_cell_info_map, 0);
map_init(&m->exact_value_compound_literal_addr_map, 1024);
m->const_dummy_builder = LLVMCreateBuilderInContext(m->ctx);
}
gb_internal bool lb_init_generator(lbGenerator *gen, Checker *c) {
@@ -276,11 +278,60 @@ gb_internal lbValue lb_zero(lbModule *m, Type *t) {
v.type = t;
return v;
}
gb_internal LLVMValueRef llvm_const_extract_value(lbModule *m, LLVMValueRef agg, unsigned index) {
LLVMValueRef res = agg;
GB_ASSERT(LLVMIsConstant(res));
res = LLVMBuildExtractValue(m->const_dummy_builder, res, index, "");
GB_ASSERT(LLVMIsConstant(res));
return res;
}
gb_internal LLVMValueRef llvm_const_extract_value(lbModule *m, LLVMValueRef agg, unsigned *indices, isize count) {
// return LLVMConstExtractValue(value, indices, count);
LLVMValueRef res = agg;
GB_ASSERT(LLVMIsConstant(res));
for (isize i = 0; i < count; i++) {
res = LLVMBuildExtractValue(m->const_dummy_builder, res, indices[i], "");
GB_ASSERT(LLVMIsConstant(res));
}
return res;
}
gb_internal LLVMValueRef llvm_const_insert_value(lbModule *m, LLVMValueRef agg, LLVMValueRef val, unsigned index) {
GB_ASSERT(LLVMIsConstant(agg));
GB_ASSERT(LLVMIsConstant(val));
LLVMValueRef extracted_value = val;
LLVMValueRef nested = llvm_const_extract_value(m, agg, index);
GB_ASSERT(LLVMIsConstant(nested));
extracted_value = LLVMBuildInsertValue(m->const_dummy_builder, nested, extracted_value, index, "");
GB_ASSERT(LLVMIsConstant(extracted_value));
return extracted_value;
}
gb_internal LLVMValueRef llvm_const_insert_value(lbModule *m, LLVMValueRef agg, LLVMValueRef val, unsigned *indices, isize count) {
GB_ASSERT(LLVMIsConstant(agg));
GB_ASSERT(LLVMIsConstant(val));
GB_ASSERT(count > 0);
LLVMValueRef extracted_value = val;
for (isize i = count-1; i >= 0; i--) {
LLVMValueRef nested = llvm_const_extract_value(m, agg, indices, i);
GB_ASSERT(LLVMIsConstant(nested));
extracted_value = LLVMBuildInsertValue(m->const_dummy_builder, nested, extracted_value, indices[i], "");
}
GB_ASSERT(LLVMIsConstant(extracted_value));
return extracted_value;
}
gb_internal LLVMValueRef llvm_cstring(lbModule *m, String const &str) {
lbValue v = lb_find_or_add_entity_string(m, str);
unsigned indices[1] = {0};
return LLVMConstExtractValue(v.value, indices, gb_count_of(indices));
return llvm_const_extract_value(m, v.value, indices, gb_count_of(indices));
}
gb_internal bool lb_is_instr_terminating(LLVMValueRef instr) {
@@ -1888,14 +1939,14 @@ gb_internal LLVMTypeRef lb_type_internal(lbModule *m, Type *type) {
case Type_Array: {
m->internal_type_level += 1;
LLVMTypeRef t = LLVMArrayType(lb_type(m, type->Array.elem), cast(unsigned)type->Array.count);
LLVMTypeRef t = llvm_array_type(lb_type(m, type->Array.elem), type->Array.count);
m->internal_type_level -= 1;
return t;
}
case Type_EnumeratedArray: {
m->internal_type_level += 1;
LLVMTypeRef t = LLVMArrayType(lb_type(m, type->EnumeratedArray.elem), cast(unsigned)type->EnumeratedArray.count);
LLVMTypeRef t = llvm_array_type(lb_type(m, type->EnumeratedArray.elem), type->EnumeratedArray.count);
m->internal_type_level -= 1;
return t;
}
@@ -2129,7 +2180,7 @@ gb_internal LLVMTypeRef lb_type_internal(lbModule *m, Type *type) {
m->internal_type_level -= 1;
LLVMTypeRef elem = lb_type(m, type->Matrix.elem);
LLVMTypeRef t = LLVMArrayType(elem, cast(unsigned)elem_count);
LLVMTypeRef t = llvm_array_type(elem, elem_count);
m->internal_type_level += 1;
return t;

View File

@@ -56,8 +56,7 @@ gb_internal void lb_populate_function_pass_manager_specific(lbModule *m, LLVMPas
#endif
gb_internal bool lb_opt_ignore(i32 optimization_level) {
optimization_level = gb_clamp(optimization_level, -1, 2);
return optimization_level == -1;
return optimization_level < 0;
}
gb_internal void lb_basic_populate_function_pass_manager(LLVMPassManagerRef fpm, i32 optimization_level) {
@@ -65,6 +64,7 @@ gb_internal void lb_basic_populate_function_pass_manager(LLVMPassManagerRef fpm,
return;
}
#if !LB_USE_NEW_PASS_SYSTEM
if (false && optimization_level <= 0 && build_context.ODIN_DEBUG) {
LLVMAddMergedLoadStoreMotionPass(fpm);
} else {
@@ -75,6 +75,7 @@ gb_internal void lb_basic_populate_function_pass_manager(LLVMPassManagerRef fpm,
LLVMAddEarlyCSEPass(fpm);
}
}
#endif
}
gb_internal void lb_populate_function_pass_manager(lbModule *m, LLVMPassManagerRef fpm, bool ignore_memcpy_pass, i32 optimization_level) {
@@ -82,6 +83,7 @@ gb_internal void lb_populate_function_pass_manager(lbModule *m, LLVMPassManagerR
return;
}
#if !LB_USE_NEW_PASS_SYSTEM
if (ignore_memcpy_pass) {
lb_basic_populate_function_pass_manager(fpm, optimization_level);
return;
@@ -109,6 +111,7 @@ gb_internal void lb_populate_function_pass_manager(lbModule *m, LLVMPassManagerR
LLVMAddEarlyCSEPass(fpm);
LLVMAddLowerExpectIntrinsicPass(fpm);
#endif
#endif
}
gb_internal void lb_populate_function_pass_manager_specific(lbModule *m, LLVMPassManagerRef fpm, i32 optimization_level) {
@@ -116,6 +119,7 @@ gb_internal void lb_populate_function_pass_manager_specific(lbModule *m, LLVMPas
return;
}
#if !LB_USE_NEW_PASS_SYSTEM
if (optimization_level <= 0) {
LLVMAddMemCpyOptPass(fpm);
lb_basic_populate_function_pass_manager(fpm, optimization_level);
@@ -148,9 +152,11 @@ gb_internal void lb_populate_function_pass_manager_specific(lbModule *m, LLVMPas
LLVMAddEarlyCSEPass(fpm);
LLVMAddLowerExpectIntrinsicPass(fpm);
#endif
#endif
}
gb_internal void lb_add_function_simplifcation_passes(LLVMPassManagerRef mpm, i32 optimization_level) {
#if !LB_USE_NEW_PASS_SYSTEM
LLVMAddCFGSimplificationPass(mpm);
LLVMAddJumpThreadingPass(mpm);
@@ -183,6 +189,7 @@ gb_internal void lb_add_function_simplifcation_passes(LLVMPassManagerRef mpm, i3
LLVMAddLoopRerollPass(mpm);
LLVMAddAggressiveDCEPass(mpm);
LLVMAddCFGSimplificationPass(mpm);
#endif
}
@@ -193,7 +200,7 @@ gb_internal void lb_populate_module_pass_manager(LLVMTargetMachineRef target_mac
if (optimization_level <= 0 && build_context.ODIN_DEBUG) {
return;
}
#if !LB_USE_NEW_PASS_SYSTEM
LLVMAddAlwaysInlinerPass(mpm);
LLVMAddStripDeadPrototypesPass(mpm);
LLVMAddAnalysisPasses(target_machine, mpm);
@@ -263,6 +270,7 @@ gb_internal void lb_populate_module_pass_manager(LLVMTargetMachineRef target_mac
}
LLVMAddCFGSimplificationPass(mpm);
#endif
}
@@ -435,7 +443,7 @@ gb_internal void lb_append_to_compiler_used(lbModule *m, LLVMValueRef func) {
}
LLVMTypeRef Int8PtrTy = LLVMPointerType(LLVMInt8TypeInContext(m->ctx), 0);
LLVMTypeRef ATy = LLVMArrayType(Int8PtrTy, operands);
LLVMTypeRef ATy = llvm_array_type(Int8PtrTy, operands);
constants[operands - 1] = LLVMConstBitCast(func, Int8PtrTy);
LLVMValueRef initializer = LLVMConstArray(Int8PtrTy, constants, operands);

View File

@@ -139,7 +139,7 @@ gb_internal lbProcedure *lb_create_procedure(lbModule *m, Entity *entity, bool i
lb_ensure_abi_function_type(m, p);
lb_add_function_type_attributes(p->value, p->abi_function_type, p->abi_function_type->calling_convention);
if (pt->Proc.diverging) {
lb_add_attribute_to_proc(m, p->value, "noreturn");
}
@@ -152,7 +152,6 @@ gb_internal lbProcedure *lb_create_procedure(lbModule *m, Entity *entity, bool i
lb_add_attribute_to_proc(m, p->value, "noredzone");
}
switch (p->inlining) {
case ProcInlining_inline:
lb_add_attribute_to_proc(m, p->value, "alwaysinline");
@@ -318,6 +317,18 @@ gb_internal lbProcedure *lb_create_procedure(lbModule *m, Entity *entity, bool i
}
}
if (p->body && entity->pkg && ((entity->pkg->kind == Package_Normal) || (entity->pkg->kind == Package_Init))) {
if (build_context.sanitizer_flags & SanitizerFlag_Address) {
lb_add_attribute_to_proc(m, p->value, "sanitize_address");
}
if (build_context.sanitizer_flags & SanitizerFlag_Memory) {
lb_add_attribute_to_proc(m, p->value, "sanitize_memory");
}
if (build_context.sanitizer_flags & SanitizerFlag_Thread) {
lb_add_attribute_to_proc(m, p->value, "sanitize_thread");
}
}
lbValue proc_value = {p->value, p->type};
lb_add_entity(m, entity, proc_value);
lb_add_member(m, p->name, proc_value);
@@ -853,8 +864,21 @@ gb_internal lbValue lb_emit_call_internal(lbProcedure *p, lbValue value, lbValue
for (unsigned i = 0; i < param_count; i++) {
LLVMTypeRef param_type = param_types[i];
LLVMTypeRef arg_type = LLVMTypeOf(args[i]);
// LLVMTypeKind param_kind = LLVMGetTypeKind(param_type);
// LLVMTypeKind arg_kind = LLVMGetTypeKind(arg_type);
if (LB_USE_NEW_PASS_SYSTEM &&
arg_type != param_type) {
LLVMTypeKind arg_kind = LLVMGetTypeKind(arg_type);
LLVMTypeKind param_kind = LLVMGetTypeKind(param_type);
if (arg_kind == param_kind &&
arg_kind == LLVMPointerTypeKind) {
// NOTE(bill): LLVM's newer `ptr` only type system seems to fail at times
// I don't know why...
args[i] = LLVMBuildPointerCast(p->builder, args[i], param_type, "");
gb_printf_err("%s\n", LLVMPrintValueToString(args[i]));
arg_type = param_type;
continue;
}
}
GB_ASSERT_MSG(
arg_type == param_type,
"Parameter types do not match: %s != %s, argument: %s\n\t%s",

File diff suppressed because it is too large Load Diff

View File

@@ -980,12 +980,12 @@ gb_internal LLVMTypeRef lb_type_padding_filler(lbModule *m, i64 padding, i64 pad
GB_ASSERT_MSG(elem != nullptr, "Invalid lb_type_padding_filler padding and padding_align: %lld", padding_align);
if (len != 1) {
return LLVMArrayType(elem, cast(unsigned)len);
return llvm_array_type(elem, len);
} else {
return elem;
}
} else {
return LLVMArrayType(lb_type(m, t_u8), cast(unsigned)padding);
return llvm_array_type(lb_type(m, t_u8), padding);
}
}
@@ -1437,6 +1437,17 @@ gb_internal lbValue lb_emit_ptr_offset(lbProcedure *p, lbValue ptr, lbValue inde
return res;
}
gb_internal lbValue lb_const_ptr_offset(lbModule *m, lbValue ptr, lbValue index) {
LLVMValueRef indices[1] = {index.value};
lbValue res = {};
res.type = ptr.type;
LLVMTypeRef type = lb_type(m, type_deref(res.type, true));
GB_ASSERT(lb_is_const(ptr) && lb_is_const(index));
res.value = LLVMConstGEP2(type, ptr.value, indices, 1);
return res;
}
gb_internal lbValue lb_emit_matrix_epi(lbProcedure *p, lbValue s, isize row, isize column) {
Type *t = s.type;
GB_ASSERT(is_type_pointer(t));

View File

@@ -300,6 +300,8 @@ enum BuildFlagKind {
BuildFlag_Tilde,
BuildFlag_Sanitize,
#if defined(GB_SYSTEM_WINDOWS)
BuildFlag_IgnoreVsSearch,
BuildFlag_ResourceFile,
@@ -410,7 +412,6 @@ gb_internal bool parse_build_flags(Array<String> args) {
add_flag(&build_flags, BuildFlag_SingleFile, str_lit("file"), BuildFlagParam_None, Command__does_build | Command__does_check);
add_flag(&build_flags, BuildFlag_OutFile, str_lit("out"), BuildFlagParam_String, Command__does_build | Command_test);
add_flag(&build_flags, BuildFlag_OptimizationMode, str_lit("o"), BuildFlagParam_String, Command__does_build);
add_flag(&build_flags, BuildFlag_OptimizationMode, str_lit("O"), BuildFlagParam_String, Command__does_build);
add_flag(&build_flags, BuildFlag_ShowTimings, str_lit("show-timings"), BuildFlagParam_None, Command__does_check);
add_flag(&build_flags, BuildFlag_ShowMoreTimings, str_lit("show-more-timings"), BuildFlagParam_None, Command__does_check);
add_flag(&build_flags, BuildFlag_ExportTimings, str_lit("export-timings"), BuildFlagParam_String, Command__does_check);
@@ -486,6 +487,8 @@ gb_internal bool parse_build_flags(Array<String> args) {
add_flag(&build_flags, BuildFlag_Tilde, str_lit("tilde"), BuildFlagParam_None, Command__does_build);
#endif
add_flag(&build_flags, BuildFlag_Sanitize, str_lit("sanitize"), BuildFlagParam_String, Command__does_build, true);
#if defined(GB_SYSTEM_WINDOWS)
add_flag(&build_flags, BuildFlag_IgnoreVsSearch, str_lit("ignore-vs-search"), BuildFlagParam_None, Command__does_build);
add_flag(&build_flags, BuildFlag_ResourceFile, str_lit("resource"), BuildFlagParam_String, Command__does_build);
@@ -660,12 +663,18 @@ gb_internal bool parse_build_flags(Array<String> args) {
} else if (value.value_string == "speed") {
build_context.custom_optimization_level = true;
build_context.optimization_level = 2;
} else if (value.value_string == "aggressive" && LB_USE_NEW_PASS_SYSTEM) {
build_context.custom_optimization_level = true;
build_context.optimization_level = 3;
} else {
gb_printf_err("Invalid optimization mode for -o:<string>, got %.*s\n", LIT(value.value_string));
gb_printf_err("Valid optimization modes:\n");
gb_printf_err("\tminimal\n");
gb_printf_err("\tsize\n");
gb_printf_err("\tspeed\n");
if (LB_USE_NEW_PASS_SYSTEM) {
gb_printf_err("\taggressive\n");
}
gb_printf_err("\tnone (useful for -debug builds)\n");
bad_flags = true;
}
@@ -1194,6 +1203,21 @@ gb_internal bool parse_build_flags(Array<String> args) {
build_context.tilde_backend = true;
break;
case BuildFlag_Sanitize:
GB_ASSERT(value.kind == ExactValue_String);
if (str_eq_ignore_case(value.value_string, str_lit("address"))) {
build_context.sanitizer_flags |= SanitizerFlag_Address;
} else if (str_eq_ignore_case(value.value_string, str_lit("memory"))) {
build_context.sanitizer_flags |= SanitizerFlag_Memory;
} else if (str_eq_ignore_case(value.value_string, str_lit("thread"))) {
build_context.sanitizer_flags |= SanitizerFlag_Thread;
} else {
gb_printf_err("-sanitize:<string> options are 'address', 'memory', and 'thread'\n");
bad_flags = true;
}
break;
#if defined(GB_SYSTEM_WINDOWS)
case BuildFlag_IgnoreVsSearch: {
GB_ASSERT(value.kind == ExactValue_Invalid);
@@ -1649,8 +1673,13 @@ gb_internal void print_show_help(String const arg0, String const &command) {
print_usage_line(1, "-o:<string>");
print_usage_line(2, "Set the optimization mode for compilation");
print_usage_line(2, "Accepted values: minimal, size, speed, none");
if (LB_USE_NEW_PASS_SYSTEM) {
print_usage_line(2, "Accepted values: none, minimal, size, speed, aggressive");
} else {
print_usage_line(2, "Accepted values: none, minimal, size, speed");
}
print_usage_line(2, "Example: -o:speed");
print_usage_line(2, "The default is -o:minimal");
print_usage_line(0, "");
}
@@ -1929,6 +1958,15 @@ gb_internal void print_show_help(String const arg0, String const &command) {
}
if (run_or_build) {
print_usage_line(1, "-sanitize:<string>");
print_usage_line(1, "Enables sanitization analysis");
print_usage_line(1, "Options are 'address', 'memory', and 'thread'");
print_usage_line(1, "NOTE: This flag can be used multiple times");
print_usage_line(0, "");
}
if (run_or_build) {
#if defined(GB_SYSTEM_WINDOWS)
print_usage_line(1, "-ignore-vs-search");

View File

@@ -60,6 +60,7 @@ enum PackageKind {
Package_Normal,
Package_Runtime,
Package_Init,
Package_Builtin,
};
struct ImportedFile {