Merge pull request #1156 from odin-lang/llvm-12.0.1-windows

Update Windows to LLVM 12.0.1
This commit is contained in:
gingerBill
2021-09-18 13:03:29 +01:00
committed by GitHub
41 changed files with 260 additions and 112 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -49,7 +49,8 @@ set compiler_warnings= ^
-wd4100 -wd4101 -wd4127 -wd4146 ^
-wd4456 -wd4457
set compiler_includes=
set compiler_includes= ^
/Isrc\
set libs= ^
kernel32.lib ^
bin\llvm\windows\LLVM-C.lib

View File

@@ -50,20 +50,20 @@ XXH_DISABLE_PREFETCH :: #config(XXH_DISABLE_PREFETCH, true)
/*
llvm.prefetch fails code generation on Linux.
*/
when XXH_DISABLE_PREFETCH {
import "core:sys/llvm"
when !XXH_DISABLE_PREFETCH {
prefetch_address :: #force_inline proc(address: rawptr) {
llvm.prefetch(address, .Read, .High, .Data)
intrinsics.prefetch_read_data(address, /*high*/3)
}
prefetch_offset :: #force_inline proc(address: rawptr, auto_cast offset: uintptr) {
prefetch_offset :: #force_inline proc(address: rawptr, #any_int offset: uintptr) {
ptr := rawptr(uintptr(address) + offset)
prefetch_address(ptr)
}
prefetch :: proc { prefetch_address, prefetch_offset, }
} else {
prefetch_address :: #force_inline proc(address: rawptr) {}
prefetch_offset :: #force_inline proc(address: rawptr, auto_cast offset: uintptr) {}
prefetch_address :: #force_inline proc(address: rawptr) {
}
prefetch_offset :: #force_inline proc(address: rawptr, #any_int offset: uintptr) {
}
}

View File

@@ -46,6 +46,11 @@ fixed_point_div :: proc(lhs, rhs: $T, #const scale: uint) -> T where type_is
fixed_point_mul_sat :: proc(lhs, rhs: $T, #const scale: uint) -> T where type_is_integer(T) ---
fixed_point_div_sat :: proc(lhs, rhs: $T, #const scale: uint) -> T where type_is_integer(T) ---
prefetch_read_instruction :: proc(address: rawptr, #const locality: i32 /* 0..=3 */) ---
prefetch_read_data :: proc(address: rawptr, #const locality: i32 /* 0..=3 */) ---
prefetch_write_instruction :: proc(address: rawptr, #const locality: i32 /* 0..=3 */) ---
prefetch_write_data :: proc(address: rawptr, #const locality: i32 /* 0..=3 */) ---
// Compiler Hints
expect :: proc(val, expected_val: T) -> T ---

View File

@@ -2646,7 +2646,41 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32
operand->type = x.type;
}
break;
case BuiltinProc_prefetch_read_instruction:
case BuiltinProc_prefetch_read_data:
case BuiltinProc_prefetch_write_instruction:
case BuiltinProc_prefetch_write_data:
{
operand->mode = Addressing_NoValue;
operand->type = nullptr;
Operand x = {};
Operand y = {};
check_expr(c, &x, ce->args[0]);
check_expr(c, &y, ce->args[1]);
if (x.mode == Addressing_Invalid) {
return false;
}
if (y.mode == Addressing_Invalid) {
return false;
}
check_assignment(c, &x, t_rawptr, builtin_name);
if (x.mode == Addressing_Invalid) {
return false;
}
if (y.mode != Addressing_Constant && is_type_integer(y.type)) {
error(y.expr, "Second argument to '%.*s' representing the locality must be an integer in the range 0..=3", LIT(builtin_name));
return false;
}
i64 locality = exact_value_to_i64(y.value);
if (!(0 <= locality && locality <= 3)) {
error(y.expr, "Second argument to '%.*s' representing the locality must be an integer in the range 0..=3", LIT(builtin_name));
return false;
}
}
break;
case BuiltinProc_syscall:
{

View File

@@ -69,6 +69,11 @@ enum BuiltinProcId {
BuiltinProc_volatile_store,
BuiltinProc_volatile_load,
BuiltinProc_prefetch_read_instruction,
BuiltinProc_prefetch_read_data,
BuiltinProc_prefetch_write_instruction,
BuiltinProc_prefetch_write_data,
BuiltinProc_atomic_fence,
BuiltinProc_atomic_fence_acq,
@@ -305,6 +310,11 @@ gb_global BuiltinProc builtin_procs[BuiltinProc_COUNT] = {
{STR_LIT("volatile_store"), 2, false, Expr_Stmt, BuiltinProcPkg_intrinsics},
{STR_LIT("volatile_load"), 1, false, Expr_Expr, BuiltinProcPkg_intrinsics},
{STR_LIT("prefetch_read_instruction"), 2, false, Expr_Stmt, BuiltinProcPkg_intrinsics},
{STR_LIT("prefetch_read_data"), 2, false, Expr_Stmt, BuiltinProcPkg_intrinsics},
{STR_LIT("prefetch_write_instruction"), 2, false, Expr_Stmt, BuiltinProcPkg_intrinsics},
{STR_LIT("prefetch_write_data"), 2, false, Expr_Stmt, BuiltinProcPkg_intrinsics},
{STR_LIT("atomic_fence"), 0, false, Expr_Stmt, BuiltinProcPkg_intrinsics},
{STR_LIT("atomic_fence_acq"), 0, false, Expr_Stmt, BuiltinProcPkg_intrinsics},

View File

@@ -19,8 +19,8 @@
#ifndef LLVM_C_ANALYSIS_H
#define LLVM_C_ANALYSIS_H
#include "ExternC.h"
#include "Types.h"
#include "llvm-c/ExternC.h"
#include "llvm-c/Types.h"
LLVM_C_EXTERN_C_BEGIN

View File

@@ -19,8 +19,8 @@
#ifndef LLVM_C_BITREADER_H
#define LLVM_C_BITREADER_H
#include "ExternC.h"
#include "Types.h"
#include "llvm-c/ExternC.h"
#include "llvm-c/Types.h"
LLVM_C_EXTERN_C_BEGIN

View File

@@ -19,8 +19,8 @@
#ifndef LLVM_C_BITWRITER_H
#define LLVM_C_BITWRITER_H
#include "ExternC.h"
#include "Types.h"
#include "llvm-c/ExternC.h"
#include "llvm-c/Types.h"
LLVM_C_EXTERN_C_BEGIN

View File

@@ -14,8 +14,8 @@
#ifndef LLVM_C_COMDAT_H
#define LLVM_C_COMDAT_H
#include "ExternC.h"
#include "Types.h"
#include "llvm-c/ExternC.h"
#include "llvm-c/Types.h"
LLVM_C_EXTERN_C_BEGIN

View File

@@ -66,7 +66,7 @@
#define LLVM_USE_PERF 0
/* Major version of the LLVM API */
#define LLVM_VERSION_MAJOR 11
#define LLVM_VERSION_MAJOR 12
/* 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 "11.0.1"
#define LLVM_VERSION_STRING "12.0.1"
/* Whether LLVM records statistics for use with GetStatistics(),
* PrintStatistics() or PrintStatisticsJSON()

View File

@@ -15,9 +15,9 @@
#ifndef LLVM_C_CORE_H
#define LLVM_C_CORE_H
#include "ErrorHandling.h"
#include "ExternC.h"
#include "Types.h"
#include "llvm-c/ErrorHandling.h"
#include "llvm-c/ExternC.h"
#include "llvm-c/Types.h"
LLVM_C_EXTERN_C_BEGIN
@@ -162,7 +162,8 @@ typedef enum {
LLVMX86_MMXTypeKind, /**< X86 MMX */
LLVMTokenTypeKind, /**< Tokens */
LLVMScalableVectorTypeKind, /**< Scalable SIMD vector type */
LLVMBFloatTypeKind /**< 16 bit brain floating point type */
LLVMBFloatTypeKind, /**< 16 bit brain floating point type */
LLVMX86_AMXTypeKind /**< X86 AMX */
} LLVMTypeKind;
typedef enum {
@@ -281,6 +282,7 @@ typedef enum {
LLVMInlineAsmValueKind,
LLVMInstructionValueKind,
LLVMPoisonValueValueKind
} LLVMValueKind;
typedef enum {
@@ -602,6 +604,17 @@ unsigned LLVMGetEnumAttributeKind(LLVMAttributeRef A);
*/
uint64_t LLVMGetEnumAttributeValue(LLVMAttributeRef A);
/**
* Create a type attribute
*/
LLVMAttributeRef LLVMCreateTypeAttribute(LLVMContextRef C, unsigned KindID,
LLVMTypeRef type_ref);
/**
* Get the type attribute's value.
*/
LLVMTypeRef LLVMGetTypeAttributeValue(LLVMAttributeRef A);
/**
* Create a string attribute.
*/
@@ -624,6 +637,12 @@ const char *LLVMGetStringAttributeValue(LLVMAttributeRef A, unsigned *Length);
*/
LLVMBool LLVMIsEnumAttribute(LLVMAttributeRef A);
LLVMBool LLVMIsStringAttribute(LLVMAttributeRef A);
LLVMBool LLVMIsTypeAttribute(LLVMAttributeRef A);
/**
* Obtain a Type from a context by its registered name.
*/
LLVMTypeRef LLVMGetTypeByName2(LLVMContextRef C, const char *Name);
/**
* @}
@@ -866,9 +885,7 @@ LLVMValueRef LLVMGetInlineAsm(LLVMTypeRef Ty,
*/
LLVMContextRef LLVMGetModuleContext(LLVMModuleRef M);
/**
* Obtain a Type from a module by its registered name.
*/
/** Deprecated: Use LLVMGetTypeByName2 instead. */
LLVMTypeRef LLVMGetTypeByName(LLVMModuleRef M, const char *Name);
/**
@@ -1444,9 +1461,21 @@ unsigned LLVMGetPointerAddressSpace(LLVMTypeRef PointerTy);
LLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType, unsigned ElementCount);
/**
* Obtain the number of elements in a vector type.
* Create a vector type that contains a defined type and has a scalable
* number of elements.
*
* This only works on types that represent vectors.
* The created type will exist in the context thats its element type
* exists in.
*
* @see llvm::ScalableVectorType::get()
*/
LLVMTypeRef LLVMScalableVectorType(LLVMTypeRef ElementType,
unsigned ElementCount);
/**
* Obtain the (possibly scalable) number of elements in a vector type.
*
* This only works on types that represent vectors (fixed or scalable).
*
* @see llvm::VectorType::getNumElements()
*/
@@ -1477,6 +1506,11 @@ LLVMTypeRef LLVMLabelTypeInContext(LLVMContextRef C);
*/
LLVMTypeRef LLVMX86MMXTypeInContext(LLVMContextRef C);
/**
* Create a X86 AMX type in a context.
*/
LLVMTypeRef LLVMX86AMXTypeInContext(LLVMContextRef C);
/**
* Create a token type in a context.
*/
@@ -1494,6 +1528,7 @@ LLVMTypeRef LLVMMetadataTypeInContext(LLVMContextRef C);
LLVMTypeRef LLVMVoidType(void);
LLVMTypeRef LLVMLabelType(void);
LLVMTypeRef LLVMX86MMXType(void);
LLVMTypeRef LLVMX86AMXType(void);
/**
* @}
@@ -1550,6 +1585,7 @@ LLVMTypeRef LLVMX86MMXType(void);
macro(Function) \
macro(GlobalVariable) \
macro(UndefValue) \
macro(PoisonValue) \
macro(Instruction) \
macro(UnaryOperator) \
macro(BinaryOperator) \
@@ -1683,6 +1719,11 @@ LLVMBool LLVMIsConstant(LLVMValueRef Val);
*/
LLVMBool LLVMIsUndef(LLVMValueRef Val);
/**
* Determine whether a value instance is poisonous.
*/
LLVMBool LLVMIsPoison(LLVMValueRef Val);
/**
* Convert value instances between types.
*
@@ -1841,6 +1882,13 @@ LLVMValueRef LLVMConstAllOnes(LLVMTypeRef Ty);
*/
LLVMValueRef LLVMGetUndef(LLVMTypeRef Ty);
/**
* Obtain a constant value referring to a poison value of a type.
*
* @see llvm::PoisonValue::get()
*/
LLVMValueRef LLVMGetPoison(LLVMTypeRef Ty);
/**
* Determine whether a value instance is null.
*

View File

@@ -77,8 +77,4 @@ typedef signed int ssize_t;
# define UINT64_MAX 0xffffffffffffffffULL
#endif
#ifndef HUGE_VALF
#define HUGE_VALF (float)HUGE_VAL
#endif
#endif /* LLVM_C_DATATYPES_H */

View File

@@ -16,8 +16,8 @@
#ifndef LLVM_C_DEBUGINFO_H
#define LLVM_C_DEBUGINFO_H
#include "Core.h"
#include "ExternC.h"
#include "llvm-c/Core.h"
#include "llvm-c/ExternC.h"
LLVM_C_EXTERN_C_BEGIN
@@ -159,7 +159,9 @@ enum {
LLVMDIImportedEntityMetadataKind,
LLVMDIMacroMetadataKind,
LLVMDIMacroFileMetadataKind,
LLVMDICommonBlockMetadataKind
LLVMDICommonBlockMetadataKind,
LLVMDIStringTypeMetadataKind,
LLVMDIGenericSubrangeMetadataKind
};
typedef unsigned LLVMMetadataKind;

View File

@@ -15,8 +15,8 @@
#ifndef LLVM_C_DISASSEMBLER_H
#define LLVM_C_DISASSEMBLER_H
#include "DisassemblerTypes.h"
#include "ExternC.h"
#include "llvm-c/DisassemblerTypes.h"
#include "llvm-c/ExternC.h"
/**
* @defgroup LLVMCDisassembler Disassembler

View File

@@ -10,7 +10,7 @@
#ifndef LLVM_DISASSEMBLER_TYPES_H
#define LLVM_DISASSEMBLER_TYPES_H
#include "DataTypes.h"
#include "llvm-c/DataTypes.h"
#ifdef __cplusplus
#include <cstddef>
#else

View File

@@ -14,7 +14,7 @@
#ifndef LLVM_C_ERROR_H
#define LLVM_C_ERROR_H
#include "ExternC.h"
#include "llvm-c/ExternC.h"
LLVM_C_EXTERN_C_BEGIN
@@ -62,6 +62,11 @@ void LLVMDisposeErrorMessage(char *ErrMsg);
*/
LLVMErrorTypeId LLVMGetStringErrorTypeId(void);
/**
* Create a StringError.
*/
LLVMErrorRef LLVMCreateStringError(const char *ErrMsg);
LLVM_C_EXTERN_C_END
#endif

View File

@@ -14,7 +14,7 @@
#ifndef LLVM_C_ERROR_HANDLING_H
#define LLVM_C_ERROR_HANDLING_H
#include "ExternC.h"
#include "llvm-c/ExternC.h"
LLVM_C_EXTERN_C_BEGIN

View File

@@ -19,10 +19,10 @@
#ifndef LLVM_C_EXECUTIONENGINE_H
#define LLVM_C_EXECUTIONENGINE_H
#include "ExternC.h"
#include "Target.h"
#include "TargetMachine.h"
#include "Types.h"
#include "llvm-c/ExternC.h"
#include "llvm-c/Target.h"
#include "llvm-c/TargetMachine.h"
#include "llvm-c/Types.h"
LLVM_C_EXTERN_C_BEGIN

View File

@@ -14,8 +14,8 @@
#ifndef LLVM_C_IRREADER_H
#define LLVM_C_IRREADER_H
#include "ExternC.h"
#include "Types.h"
#include "llvm-c/ExternC.h"
#include "llvm-c/Types.h"
LLVM_C_EXTERN_C_BEGIN

View File

@@ -16,8 +16,8 @@
#ifndef LLVM_C_INITIALIZATION_H
#define LLVM_C_INITIALIZATION_H
#include "ExternC.h"
#include "Types.h"
#include "llvm-c/ExternC.h"
#include "llvm-c/Types.h"
LLVM_C_EXTERN_C_BEGIN

View File

@@ -14,8 +14,8 @@
#ifndef LLVM_C_LINKER_H
#define LLVM_C_LINKER_H
#include "ExternC.h"
#include "Types.h"
#include "llvm-c/ExternC.h"
#include "llvm-c/Types.h"
LLVM_C_EXTERN_C_BEGIN

View File

@@ -19,9 +19,9 @@
#ifndef LLVM_C_OBJECT_H
#define LLVM_C_OBJECT_H
#include "ExternC.h"
#include "Types.h"
#include "Config/llvm-config.h"
#include "llvm-c/ExternC.h"
#include "llvm-c/Types.h"
#include "llvm-c/Config/llvm-config.h"
LLVM_C_EXTERN_C_BEGIN

View File

@@ -15,8 +15,8 @@
#ifndef LLVM_C_REMARKS_H
#define LLVM_C_REMARKS_H
#include "ExternC.h"
#include "Types.h"
#include "llvm-c/ExternC.h"
#include "llvm-c/Types.h"
#ifdef __cplusplus
#include <cstddef>
#else

View File

@@ -14,9 +14,9 @@
#ifndef LLVM_C_SUPPORT_H
#define LLVM_C_SUPPORT_H
#include "DataTypes.h"
#include "ExternC.h"
#include "Types.h"
#include "llvm-c/DataTypes.h"
#include "llvm-c/ExternC.h"
#include "llvm-c/Types.h"
LLVM_C_EXTERN_C_BEGIN

View File

@@ -19,9 +19,9 @@
#ifndef LLVM_C_TARGET_H
#define LLVM_C_TARGET_H
#include "ExternC.h"
#include "Types.h"
#include "Config/llvm-config.h"
#include "llvm-c/ExternC.h"
#include "llvm-c/Types.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 "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 "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 "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 "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 "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 "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 "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 "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 "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 "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 "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 "Config/Disassemblers.def"
#include "llvm-c/Config/Disassemblers.def"
#undef LLVM_DISASSEMBLER /* Explicit undef to make SWIG happier */
}

View File

@@ -19,9 +19,9 @@
#ifndef LLVM_C_TARGETMACHINE_H
#define LLVM_C_TARGETMACHINE_H
#include "ExternC.h"
#include "Target.h"
#include "Types.h"
#include "llvm-c/ExternC.h"
#include "llvm-c/Target.h"
#include "llvm-c/Types.h"
LLVM_C_EXTERN_C_BEGIN

View File

@@ -15,8 +15,8 @@
#ifndef LLVM_C_TRANSFORMS_AGGRESSIVEINSTCOMBINE_H
#define LLVM_C_TRANSFORMS_AGGRESSIVEINSTCOMBINE_H
#include "../ExternC.h"
#include "../Types.h"
#include "llvm-c/ExternC.h"
#include "llvm-c/Types.h"
LLVM_C_EXTERN_C_BEGIN

View File

@@ -19,9 +19,9 @@
#ifndef LLVM_C_TRANSFORMS_COROUTINES_H
#define LLVM_C_TRANSFORMS_COROUTINES_H
#include "../ExternC.h"
#include "../Types.h"
#include "PassManagerBuilder.h"
#include "llvm-c/ExternC.h"
#include "llvm-c/Types.h"
#include "llvm-c/Transforms/PassManagerBuilder.h"
LLVM_C_EXTERN_C_BEGIN

View File

@@ -15,8 +15,8 @@
#ifndef LLVM_C_TRANSFORMS_IPO_H
#define LLVM_C_TRANSFORMS_IPO_H
#include "../ExternC.h"
#include "../Types.h"
#include "llvm-c/ExternC.h"
#include "llvm-c/Types.h"
LLVM_C_EXTERN_C_BEGIN
@@ -57,9 +57,6 @@ void LLVMAddGlobalDCEPass(LLVMPassManagerRef PM);
/** See llvm::createGlobalOptimizerPass function. */
void LLVMAddGlobalOptimizerPass(LLVMPassManagerRef PM);
/** See llvm::createIPConstantPropagationPass function. */
void LLVMAddIPConstantPropagationPass(LLVMPassManagerRef PM);
/** See llvm::createPruneEHPass function. */
void LLVMAddPruneEHPass(LLVMPassManagerRef PM);

View File

@@ -15,8 +15,8 @@
#ifndef LLVM_C_TRANSFORMS_INSTCOMBINE_H
#define LLVM_C_TRANSFORMS_INSTCOMBINE_H
#include "../ExternC.h"
#include "../Types.h"
#include "llvm-c/ExternC.h"
#include "llvm-c/Types.h"
LLVM_C_EXTERN_C_BEGIN

View File

@@ -14,8 +14,8 @@
#ifndef LLVM_C_TRANSFORMS_PASSMANAGERBUILDER_H
#define LLVM_C_TRANSFORMS_PASSMANAGERBUILDER_H
#include "../ExternC.h"
#include "../Types.h"
#include "llvm-c/ExternC.h"
#include "llvm-c/Types.h"
typedef struct LLVMOpaquePassManagerBuilder *LLVMPassManagerBuilderRef;

View File

@@ -19,8 +19,8 @@
#ifndef LLVM_C_TRANSFORMS_SCALAR_H
#define LLVM_C_TRANSFORMS_SCALAR_H
#include "../ExternC.h"
#include "../Types.h"
#include "llvm-c/ExternC.h"
#include "llvm-c/Types.h"
LLVM_C_EXTERN_C_BEGIN
@@ -67,6 +67,9 @@ 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);
@@ -125,9 +128,6 @@ void LLVMAddSimplifyLibCallsPass(LLVMPassManagerRef PM);
/** See llvm::createTailCallEliminationPass function. */
void LLVMAddTailCallEliminationPass(LLVMPassManagerRef PM);
/** See llvm::createConstantPropagationPass function. */
void LLVMAddConstantPropagationPass(LLVMPassManagerRef PM);
/** See llvm::demotePromoteMemoryToRegisterPass function. */
void LLVMAddDemoteMemoryToRegisterPass(LLVMPassManagerRef PM);

View File

@@ -19,8 +19,8 @@
#ifndef LLVM_C_TRANSFORMS_UTILS_H
#define LLVM_C_TRANSFORMS_UTILS_H
#include "../ExternC.h"
#include "../Types.h"
#include "llvm-c/ExternC.h"
#include "llvm-c/Types.h"
LLVM_C_EXTERN_C_BEGIN

View File

@@ -20,8 +20,8 @@
#ifndef LLVM_C_TRANSFORMS_VECTORIZE_H
#define LLVM_C_TRANSFORMS_VECTORIZE_H
#include "../ExternC.h"
#include "../Types.h"
#include "llvm-c/ExternC.h"
#include "llvm-c/Types.h"
LLVM_C_EXTERN_C_BEGIN

View File

@@ -14,8 +14,8 @@
#ifndef LLVM_C_TYPES_H
#define LLVM_C_TYPES_H
#include "DataTypes.h"
#include "ExternC.h"
#include "llvm-c/DataTypes.h"
#include "llvm-c/ExternC.h"
LLVM_C_EXTERN_C_BEGIN

View File

@@ -16,7 +16,7 @@
#ifndef LLVM_C_LTO_H
#define LLVM_C_LTO_H
#include "ExternC.h"
#include "llvm-c/ExternC.h"
#ifdef __cplusplus
#include <cstddef>

View File

@@ -23,6 +23,8 @@
#if LLVM_VERSION_MAJOR < 11
#error "LLVM Version 11 is the minimum required"
#elif LLVM_VERSION_MAJOR == 12 && !(LLVM_VERSION_MINOR > 0 || LLVM_VERSION_PATCH > 0)
#error "If LLVM Version 12.x.y is wanted, at least LLVM 12.0.1 is required"
#endif

View File

@@ -22,18 +22,18 @@ void lb_add_must_preserve_predicate_pass(lbModule *m, LLVMPassManagerRef fpm, i3
#if LLVM_VERSION_MAJOR < 12
#define LLVM_ADD_CONSTNAT_VALUE_PASS LLVMAddConstantPropagationPass
#define LLVM_ADD_CONSTANT_VALUE_PASS LLVMAddConstantPropagationPass
#else
#define LLVM_ADD_CONSTNAT_VALUE_PASS LLVMAddCorrelatedValuePropagationPass
#define LLVM_ADD_CONSTANT_VALUE_PASS LLVMAddCorrelatedValuePropagationPass
#endif
void lb_basic_populate_function_pass_manager(LLVMPassManagerRef fpm) {
LLVMAddPromoteMemoryToRegisterPass(fpm);
LLVMAddMergedLoadStoreMotionPass(fpm);
LLVM_ADD_CONSTNAT_VALUE_PASS(fpm);
LLVM_ADD_CONSTANT_VALUE_PASS(fpm);
LLVMAddEarlyCSEPass(fpm);
LLVM_ADD_CONSTNAT_VALUE_PASS(fpm);
LLVM_ADD_CONSTANT_VALUE_PASS(fpm);
LLVMAddMergedLoadStoreMotionPass(fpm);
LLVMAddPromoteMemoryToRegisterPass(fpm);
LLVMAddCFGSimplificationPass(fpm);
@@ -64,10 +64,10 @@ void lb_populate_function_pass_manager(lbModule *m, LLVMPassManagerRef fpm, bool
LLVMAddMemCpyOptPass(fpm);
LLVMAddPromoteMemoryToRegisterPass(fpm);
LLVMAddMergedLoadStoreMotionPass(fpm);
LLVM_ADD_CONSTNAT_VALUE_PASS(fpm);
LLVM_ADD_CONSTANT_VALUE_PASS(fpm);
LLVMAddEarlyCSEPass(fpm);
LLVM_ADD_CONSTNAT_VALUE_PASS(fpm);
LLVM_ADD_CONSTANT_VALUE_PASS(fpm);
LLVMAddMergedLoadStoreMotionPass(fpm);
LLVMAddPromoteMemoryToRegisterPass(fpm);
LLVMAddCFGSimplificationPass(fpm);
@@ -105,10 +105,10 @@ void lb_populate_function_pass_manager_specific(lbModule *m, LLVMPassManagerRef
LLVMAddMemCpyOptPass(fpm);
LLVMAddPromoteMemoryToRegisterPass(fpm);
LLVMAddMergedLoadStoreMotionPass(fpm);
LLVM_ADD_CONSTNAT_VALUE_PASS(fpm);
LLVM_ADD_CONSTANT_VALUE_PASS(fpm);
LLVMAddEarlyCSEPass(fpm);
LLVM_ADD_CONSTNAT_VALUE_PASS(fpm);
LLVM_ADD_CONSTANT_VALUE_PASS(fpm);
LLVMAddMergedLoadStoreMotionPass(fpm);
LLVMAddPromoteMemoryToRegisterPass(fpm);
LLVMAddCFGSimplificationPass(fpm);
@@ -165,7 +165,7 @@ void lb_add_function_simplifcation_passes(LLVMPassManagerRef mpm, i32 optimizati
LLVMAddInstructionCombiningPass(mpm);
LLVMAddJumpThreadingPass(mpm);
LLVM_ADD_CONSTNAT_VALUE_PASS(mpm);
LLVM_ADD_CONSTANT_VALUE_PASS(mpm);
LLVMAddDeadStoreEliminationPass(mpm);
LLVMAddLICMPass(mpm);
@@ -231,7 +231,7 @@ void lb_populate_module_pass_manager(LLVMTargetMachineRef target_machine, LLVMPa
LLVMAddInstructionCombiningPass(mpm);
if (optimization_level >= 2) {
LLVMAddEarlyCSEPass(mpm);
LLVM_ADD_CONSTNAT_VALUE_PASS(mpm);
LLVM_ADD_CONSTANT_VALUE_PASS(mpm);
LLVMAddLICMPass(mpm);
LLVMAddLoopUnswitchPass(mpm);
LLVMAddCFGSimplificationPass(mpm);

View File

@@ -1831,6 +1831,54 @@ lbValue lb_build_builtin_proc(lbProcedure *p, Ast *expr, TypeAndValue const &tv,
return lb_emit_conv(p, res, t);
}
case BuiltinProc_prefetch_read_instruction:
case BuiltinProc_prefetch_read_data:
case BuiltinProc_prefetch_write_instruction:
case BuiltinProc_prefetch_write_data:
{
lbValue ptr = lb_emit_conv(p, lb_build_expr(p, ce->args[0]), t_rawptr);
unsigned long long locality = cast(unsigned long long)exact_value_to_i64(ce->args[1]->tav.value);
unsigned long long rw = 0;
unsigned long long cache = 0;
switch (id) {
case BuiltinProc_prefetch_read_instruction:
rw = 0;
cache = 0;
break;
case BuiltinProc_prefetch_read_data:
rw = 0;
cache = 1;
break;
case BuiltinProc_prefetch_write_instruction:
rw = 1;
cache = 0;
break;
case BuiltinProc_prefetch_write_data:
rw = 1;
cache = 1;
break;
}
char const *name = "llvm.prefetch";
LLVMTypeRef types[1] = {lb_type(p->module, t_rawptr)};
unsigned id = LLVMLookupIntrinsicID(name, gb_strlen(name));
GB_ASSERT_MSG(id != 0, "Unable to find %s.%s", name, LLVMPrintTypeToString(types[0]));
LLVMValueRef ip = LLVMGetIntrinsicDeclaration(p->module->mod, id, types, gb_count_of(types));
LLVMTypeRef llvm_i32 = lb_type(p->module, t_i32);
LLVMValueRef args[4] = {};
args[0] = ptr.value;
args[1] = LLVMConstInt(llvm_i32, rw, false);
args[2] = LLVMConstInt(llvm_i32, locality, false);
args[3] = LLVMConstInt(llvm_i32, cache, false);
lbValue res = {};
res.value = LLVMBuildCall(p->builder, ip, args, gb_count_of(args), "");
res.type = nullptr;
return res;
}
case BuiltinProc_syscall:
{
unsigned arg_count = cast(unsigned)ce->args.count;