mirror of
https://github.com/odin-lang/Odin.git
synced 2026-08-16 18:48:14 +00:00
Merge branch 'master' into bill/subtype-type-info
This commit is contained in:
16
.github/workflows/ci.yml
vendored
16
.github/workflows/ci.yml
vendored
@@ -52,7 +52,7 @@ jobs:
|
||||
usesh: true
|
||||
copyback: false
|
||||
prepare: |
|
||||
pkg install -y gmake git bash python3 libxml2 llvm17
|
||||
pkg install -y gmake git bash python3 libxml2 llvm18
|
||||
run: |
|
||||
# `set -e` is needed for test failures to register. https://github.com/vmactions/freebsd-vm/issues/72
|
||||
set -e -x
|
||||
@@ -87,20 +87,20 @@ jobs:
|
||||
run: |
|
||||
wget https://apt.llvm.org/llvm.sh
|
||||
chmod +x llvm.sh
|
||||
sudo ./llvm.sh 17
|
||||
echo "/usr/lib/llvm-17/bin" >> $GITHUB_PATH
|
||||
sudo ./llvm.sh 20
|
||||
echo "/usr/lib/llvm-20/bin" >> $GITHUB_PATH
|
||||
|
||||
- name: Download LLVM (MacOS Intel)
|
||||
if: matrix.os == 'macos-13'
|
||||
run: |
|
||||
brew install llvm@17 lua@5.4
|
||||
echo "/usr/local/opt/llvm@17/bin" >> $GITHUB_PATH
|
||||
brew install llvm@18 lua@5.4
|
||||
echo "/usr/local/opt/llvm@18/bin" >> $GITHUB_PATH
|
||||
|
||||
- name: Download LLVM (MacOS ARM)
|
||||
if: matrix.os == 'macos-14'
|
||||
run: |
|
||||
brew install llvm@17 wasmtime lua@5.4
|
||||
echo "/opt/homebrew/opt/llvm@17/bin" >> $GITHUB_PATH
|
||||
brew install llvm@18 wasmtime lua@5.4
|
||||
echo "/opt/homebrew/opt/llvm@18/bin" >> $GITHUB_PATH
|
||||
|
||||
- name: Build Odin
|
||||
run: ./build_odin.sh release
|
||||
@@ -167,7 +167,7 @@ jobs:
|
||||
|
||||
- name: Run demo on WASI WASM32
|
||||
run: |
|
||||
./odin build examples/demo -target:wasi_wasm32 -vet -strict-style -disallow-do -out:demo.wasm
|
||||
./odin build examples/demo -target:wasi_wasm32 -vet -strict-style -disallow-do -out:demo
|
||||
wasmtime ./demo.wasm
|
||||
if: matrix.os == 'macos-14'
|
||||
|
||||
|
||||
4
.github/workflows/nightly.yml
vendored
4
.github/workflows/nightly.yml
vendored
@@ -53,8 +53,8 @@ jobs:
|
||||
- name: (Linux) Download LLVM
|
||||
run: |
|
||||
apk add --no-cache \
|
||||
musl-dev llvm18-dev clang18 git mold lz4 \
|
||||
libxml2-static llvm18-static zlib-static zstd-static \
|
||||
musl-dev llvm20-dev clang20 git mold lz4 \
|
||||
libxml2-static llvm20-static zlib-static zstd-static \
|
||||
make
|
||||
shell: alpine.sh --root {0}
|
||||
- name: build odin
|
||||
|
||||
BIN
LLVM-C.dll
BIN
LLVM-C.dll
Binary file not shown.
BIN
bin/lld-link.exe
BIN
bin/lld-link.exe
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
bin/wasm-ld.exe
BIN
bin/wasm-ld.exe
Binary file not shown.
@@ -116,11 +116,12 @@ register_user_formatter :: proc(id: typeid, formatter: User_Formatter) -> Regist
|
||||
}
|
||||
// Creates a formatted string
|
||||
//
|
||||
// *Allocates Using Context's Allocator*
|
||||
// *Allocates Using Provided Allocator*
|
||||
//
|
||||
// Inputs:
|
||||
// - args: A variadic list of arguments to be formatted.
|
||||
// - sep: An optional separator string (default is a single space).
|
||||
// - allocator: (default: context.allocator)
|
||||
//
|
||||
// Returns: A formatted string.
|
||||
//
|
||||
@@ -132,11 +133,12 @@ aprint :: proc(args: ..any, sep := " ", allocator := context.allocator) -> strin
|
||||
}
|
||||
// Creates a formatted string with a newline character at the end
|
||||
//
|
||||
// *Allocates Using Context's Allocator*
|
||||
// *Allocates Using Provided Allocator*
|
||||
//
|
||||
// Inputs:
|
||||
// - args: A variadic list of arguments to be formatted.
|
||||
// - sep: An optional separator string (default is a single space).
|
||||
// - allocator: (default: context.allocator)
|
||||
//
|
||||
// Returns: A formatted string with a newline character at the end.
|
||||
//
|
||||
@@ -148,11 +150,12 @@ aprintln :: proc(args: ..any, sep := " ", allocator := context.allocator) -> str
|
||||
}
|
||||
// Creates a formatted string using a format string and arguments
|
||||
//
|
||||
// *Allocates Using Context's Allocator*
|
||||
// *Allocates Using Provided Allocator*
|
||||
//
|
||||
// Inputs:
|
||||
// - fmt: A format string with placeholders for the provided arguments.
|
||||
// - args: A variadic list of arguments to be formatted.
|
||||
// - allocator: (default: context.allocator)
|
||||
// - newline: Whether the string should end with a newline. (See `aprintfln`.)
|
||||
//
|
||||
// Returns: A formatted string. The returned string must be freed accordingly.
|
||||
@@ -165,11 +168,12 @@ aprintf :: proc(fmt: string, args: ..any, allocator := context.allocator, newlin
|
||||
}
|
||||
// Creates a formatted string using a format string and arguments, followed by a newline.
|
||||
//
|
||||
// *Allocates Using Context's Allocator*
|
||||
// *Allocates Using Provided Allocator*
|
||||
//
|
||||
// Inputs:
|
||||
// - fmt: A format string with placeholders for the provided arguments.
|
||||
// - args: A variadic list of arguments to be formatted.
|
||||
// - allocator: (default: context.allocator)
|
||||
//
|
||||
// Returns: A formatted string. The returned string must be freed accordingly.
|
||||
//
|
||||
@@ -359,11 +363,12 @@ panicf :: proc(fmt: string, args: ..any, loc := #caller_location) -> ! {
|
||||
|
||||
// Creates a formatted C string
|
||||
//
|
||||
// *Allocates Using Context's Allocator*
|
||||
// *Allocates Using Provided Allocator*
|
||||
//
|
||||
// Inputs:
|
||||
// - args: A variadic list of arguments to be formatted.
|
||||
// - sep: An optional separator string (default is a single space).
|
||||
// - allocator: (default: context.allocator)
|
||||
//
|
||||
// Returns: A formatted C string.
|
||||
//
|
||||
@@ -379,11 +384,12 @@ caprint :: proc(args: ..any, sep := " ", allocator := context.allocator) -> cstr
|
||||
|
||||
// Creates a formatted C string
|
||||
//
|
||||
// *Allocates Using Context's Allocator*
|
||||
// *Allocates Using Provided Allocator*
|
||||
//
|
||||
// Inputs:
|
||||
// - format: A format string with placeholders for the provided arguments
|
||||
// - args: A variadic list of arguments to be formatted
|
||||
// - allocator: (default: context.allocator)
|
||||
// - newline: Whether the string should end with a newline. (See `caprintfln`.)
|
||||
//
|
||||
// Returns: A formatted C string
|
||||
@@ -399,11 +405,12 @@ caprintf :: proc(format: string, args: ..any, allocator := context.allocator, ne
|
||||
}
|
||||
// Creates a formatted C string, followed by a newline.
|
||||
//
|
||||
// *Allocates Using Context's Allocator*
|
||||
// *Allocates Using Provided Allocator*
|
||||
//
|
||||
// Inputs:
|
||||
// - format: A format string with placeholders for the provided arguments
|
||||
// - args: A variadic list of arguments to be formatted
|
||||
// - allocator: (default: context.allocator)
|
||||
//
|
||||
// Returns: A formatted C string
|
||||
//
|
||||
|
||||
@@ -212,7 +212,7 @@ rt_sigreturn :: proc "c" () -> ! {
|
||||
/*
|
||||
Alter an action taken by a process.
|
||||
*/
|
||||
rt_sigaction :: proc "contextless" (sig: Signal, sigaction: ^Sig_Action($T), old_sigaction: ^Sig_Action) -> Errno {
|
||||
rt_sigaction :: proc "contextless" (sig: Signal, sigaction: ^Sig_Action($T), old_sigaction: ^Sig_Action($U)) -> Errno {
|
||||
// NOTE(jason): It appears that the restorer is required for i386 and amd64
|
||||
when ODIN_ARCH == .i386 || ODIN_ARCH == .amd64 {
|
||||
sigaction.flags += {.RESTORER}
|
||||
|
||||
@@ -317,5 +317,18 @@ SYS_futex_waitv :: uintptr(449)
|
||||
SYS_set_mempolicy_home_node :: uintptr(450)
|
||||
SYS_cachestat :: uintptr(451)
|
||||
SYS_fchmodat2 :: uintptr(452)
|
||||
|
||||
SYS_map_shadow_stack :: uintptr(453)
|
||||
SYS_futex_wake :: uintptr(454)
|
||||
SYS_futex_wait :: uintptr(455)
|
||||
SYS_futex_requeue :: uintptr(456)
|
||||
SYS_statmount :: uintptr(457)
|
||||
SYS_listmount :: uintptr(458)
|
||||
SYS_lsm_get_self_attr :: uintptr(459)
|
||||
SYS_lsm_set_self_attr :: uintptr(460)
|
||||
SYS_lsm_list_modules :: uintptr(461)
|
||||
SYS_mseal :: uintptr(462)
|
||||
SYS_setxattrat :: uintptr(463)
|
||||
SYS_getxattrat :: uintptr(464)
|
||||
SYS_listxattrat :: uintptr(465)
|
||||
SYS_removexattrat :: uintptr(466)
|
||||
|
||||
|
||||
@@ -189,7 +189,7 @@ Key_Location :: enum u8 {
|
||||
KEYBOARD_MAX_KEY_SIZE :: 32
|
||||
KEYBOARD_MAX_CODE_SIZE :: 32
|
||||
|
||||
GAMEPAD_MAX_ID_SIZE :: 64
|
||||
GAMEPAD_MAX_ID_SIZE :: 96
|
||||
GAMEPAD_MAX_MAPPING_SIZE :: 64
|
||||
|
||||
GAMEPAD_MAX_BUTTONS :: 64
|
||||
@@ -239,6 +239,12 @@ Gamepad_State :: struct {
|
||||
_mapping_buf: [GAMEPAD_MAX_MAPPING_SIZE]byte `fmt:"-"`,
|
||||
}
|
||||
|
||||
Pointer_Type :: enum u8 {
|
||||
Mouse,
|
||||
Pen,
|
||||
Touch,
|
||||
}
|
||||
|
||||
Event :: struct {
|
||||
kind: Event_Kind,
|
||||
target_kind: Event_Target_Kind,
|
||||
@@ -275,6 +281,8 @@ Event :: struct {
|
||||
|
||||
repeat: bool,
|
||||
|
||||
char: rune,
|
||||
|
||||
_key_len: int `fmt:"-"`,
|
||||
_code_len: int `fmt:"-"`,
|
||||
_key_buf: [KEYBOARD_MAX_KEY_SIZE]byte `fmt:"-"`,
|
||||
@@ -295,6 +303,21 @@ Event :: struct {
|
||||
|
||||
button: i16,
|
||||
buttons: bit_set[0..<16; u16],
|
||||
|
||||
pointer: struct {
|
||||
altitude_angle: f64,
|
||||
azimuth_angle: f64,
|
||||
persistent_device_id: int,
|
||||
pointer_id: int,
|
||||
width: int,
|
||||
height: int,
|
||||
pressure: f64,
|
||||
tangential_pressure: f64,
|
||||
tilt: [2]f64,
|
||||
twist: f64,
|
||||
pointer_type: Pointer_Type,
|
||||
is_primary: bool,
|
||||
},
|
||||
},
|
||||
|
||||
gamepad: Gamepad_State,
|
||||
@@ -384,7 +407,14 @@ get_gamepad_state :: proc "contextless" (index: int, s: ^Gamepad_State) -> bool
|
||||
if s == nil {
|
||||
return false
|
||||
}
|
||||
return _get_gamepad_state(index, s)
|
||||
|
||||
if !_get_gamepad_state(index, s) {
|
||||
return false
|
||||
}
|
||||
|
||||
s.id = string(s._id_buf[:s._id_len])
|
||||
s.mapping = string(s._mapping_buf[:s._mapping_len])
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
@@ -415,4 +445,4 @@ do_event_callback :: proc(user_data: rawptr, callback: proc(e: Event)) {
|
||||
|
||||
callback(event)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,4 +9,5 @@ foreign odin_env {
|
||||
abort :: proc() -> ! ---
|
||||
alert :: proc(msg: string) ---
|
||||
evaluate :: proc(str: string) ---
|
||||
}
|
||||
open :: proc(url: string, name := "", specs := "") ---
|
||||
}
|
||||
|
||||
@@ -402,6 +402,9 @@ class WebGLInterface {
|
||||
BlendEquation: (mode) => {
|
||||
this.ctx.blendEquation(mode);
|
||||
},
|
||||
BlendEquationSeparate: (modeRGB, modeAlpha) => {
|
||||
this.ctx.blendEquationSeparate(modeRGB, modeAlpha);
|
||||
},
|
||||
BlendFunc: (sfactor, dfactor) => {
|
||||
this.ctx.blendFunc(sfactor, dfactor);
|
||||
},
|
||||
@@ -633,6 +636,13 @@ class WebGLInterface {
|
||||
GetParameter: (pname) => {
|
||||
return this.ctx.getParameter(pname);
|
||||
},
|
||||
GetParameter4i: (pname, v0, v1, v2, v3) => {
|
||||
const i4 = this.ctx.getParameter(pname);
|
||||
this.mem.storeI32(v0, i4[0]);
|
||||
this.mem.storeI32(v1, i4[1]);
|
||||
this.mem.storeI32(v2, i4[2]);
|
||||
this.mem.storeI32(v3, i4[3]);
|
||||
},
|
||||
GetProgramParameter: (program, pname) => {
|
||||
return this.ctx.getProgramParameter(this.programs[program], pname)
|
||||
},
|
||||
@@ -1421,6 +1431,13 @@ function odinSetupDefaultImports(wasmMemoryInterface, consoleElement, memory) {
|
||||
abort: () => { Module.abort() },
|
||||
evaluate: (str_ptr, str_len) => { eval.call(null, wasmMemoryInterface.loadString(str_ptr, str_len)); },
|
||||
|
||||
open: (url_ptr, url_len, name_ptr, name_len, specs_ptr, specs_len) => {
|
||||
const url = wasmMemoryInterface.loadString(url_ptr, url_len);
|
||||
const name = wasmMemoryInterface.loadString(name_ptr, name_len);
|
||||
const specs = wasmMemoryInterface.loadString(specs_ptr, specs_len);
|
||||
window.open(url, name, specs);
|
||||
},
|
||||
|
||||
// return a bigint to be converted to i64
|
||||
time_now: () => BigInt(Date.now()),
|
||||
tick_now: () => performance.now(),
|
||||
@@ -1533,6 +1550,29 @@ function odinSetupDefaultImports(wasmMemoryInterface, consoleElement, memory) {
|
||||
|
||||
wmi.storeI16(off(2), e.button);
|
||||
wmi.storeU16(off(2), e.buttons);
|
||||
|
||||
if (e instanceof PointerEvent) {
|
||||
wmi.storeF64(off(8), e.altitudeAngle);
|
||||
wmi.storeF64(off(8), e.azimuthAngle);
|
||||
wmi.storeInt(off(W), e.persistentDeviceId);
|
||||
wmi.storeInt(off(W), e.pointerId);
|
||||
wmi.storeInt(off(W), e.width);
|
||||
wmi.storeInt(off(W), e.height);
|
||||
wmi.storeF64(off(8), e.pressure);
|
||||
wmi.storeF64(off(8), e.tangentialPressure);
|
||||
wmi.storeF64(off(8), e.tiltX);
|
||||
wmi.storeF64(off(8), e.tiltY);
|
||||
wmi.storeF64(off(8), e.twist);
|
||||
if (e.pointerType == "pen") {
|
||||
wmi.storeU8(off(1), 1);
|
||||
} else if (e.pointerType == "touch") {
|
||||
wmi.storeU8(off(1), 2);
|
||||
} else {
|
||||
wmi.storeU8(off(1), 0);
|
||||
}
|
||||
wmi.storeU8(off(1), !!e.isPrimary);
|
||||
}
|
||||
|
||||
} else if (e instanceof KeyboardEvent) {
|
||||
// Note: those strings are constructed
|
||||
// on the native side from buffers that
|
||||
@@ -1549,6 +1589,8 @@ function odinSetupDefaultImports(wasmMemoryInterface, consoleElement, memory) {
|
||||
|
||||
wmi.storeU8(off(1), !!e.repeat);
|
||||
|
||||
wmi.storeI32(off(4), e.charCode);
|
||||
|
||||
wmi.storeInt(off(W, W), e.key.length)
|
||||
wmi.storeInt(off(W, W), e.code.length)
|
||||
wmi.storeString(off(32, 1), e.key);
|
||||
@@ -1588,10 +1630,24 @@ function odinSetupDefaultImports(wasmMemoryInterface, consoleElement, memory) {
|
||||
}
|
||||
}
|
||||
|
||||
wmi.storeInt(off(W, W), e.gamepad.id.length)
|
||||
wmi.storeInt(off(W, W), e.gamepad.mapping.length)
|
||||
wmi.storeString(off(64, 1), e.gamepad.id);
|
||||
wmi.storeString(off(64, 1), e.gamepad.mapping);
|
||||
let idLength = e.gamepad.id.length;
|
||||
let id = e.gamepad.id;
|
||||
if (idLength > 96) {
|
||||
idLength = 96;
|
||||
id = id.slice(0, 93) + '...';
|
||||
}
|
||||
|
||||
let mappingLength = e.gamepad.mapping.length;
|
||||
let mapping = e.gamepad.mapping;
|
||||
if (mappingLength > 64) {
|
||||
mappingLength = 61;
|
||||
mapping = mapping.slice(0, 61) + '...';
|
||||
}
|
||||
|
||||
wmi.storeInt(off(W, W), idLength);
|
||||
wmi.storeInt(off(W, W), mappingLength);
|
||||
wmi.storeString(off(96, 1), id);
|
||||
wmi.storeString(off(64, 1), mapping);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1756,10 +1812,24 @@ function odinSetupDefaultImports(wasmMemoryInterface, consoleElement, memory) {
|
||||
}
|
||||
}
|
||||
|
||||
wmi.storeInt(off(W, W), gamepad.id.length)
|
||||
wmi.storeInt(off(W, W), gamepad.mapping.length)
|
||||
wmi.storeString(off(64, 1), gamepad.id);
|
||||
wmi.storeString(off(64, 1), gamepad.mapping);
|
||||
let idLength = gamepad.id.length;
|
||||
let id = gamepad.id;
|
||||
if (idLength > 96) {
|
||||
idLength = 96;
|
||||
id = id.slice(0, 93) + '...';
|
||||
}
|
||||
|
||||
let mappingLength = gamepad.mapping.length;
|
||||
let mapping = gamepad.mapping;
|
||||
if (mappingLength > 64) {
|
||||
mappingLength = 61;
|
||||
mapping = mapping.slice(0, 61) + '...';
|
||||
}
|
||||
|
||||
wmi.storeInt(off(W, W), idLength);
|
||||
wmi.storeInt(off(W, W), mappingLength);
|
||||
wmi.storeString(off(96, 1), id);
|
||||
wmi.storeString(off(64, 1), mapping);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -3670,6 +3670,11 @@ gb_internal bool check_transmute(CheckerContext *c, Ast *node, Operand *o, Type
|
||||
}
|
||||
|
||||
gb_internal bool check_binary_array_expr(CheckerContext *c, Token op, Operand *x, Operand *y) {
|
||||
if (is_type_array_like(x->type) || is_type_array_like(y->type)) {
|
||||
if (op.kind == Token_CmpAnd || op.kind == Token_CmpOr) {
|
||||
error(op, "Array programming is not allowed with the operator '%.*s'", LIT(op.string));
|
||||
}
|
||||
}
|
||||
if (is_type_array(x->type) && !is_type_array(y->type)) {
|
||||
if (check_is_assignable_to(c, y, x->type)) {
|
||||
if (check_binary_op(c, x, op)) {
|
||||
@@ -4508,8 +4513,7 @@ gb_internal void convert_to_typed(CheckerContext *c, Operand *operand, Type *tar
|
||||
} else {
|
||||
switch (operand->type->Basic.kind) {
|
||||
case Basic_UntypedBool:
|
||||
if (!is_type_boolean(target_type) &&
|
||||
!is_type_integer(target_type)) {
|
||||
if (!is_type_boolean(target_type)) {
|
||||
operand->mode = Addressing_Invalid;
|
||||
convert_untyped_error(c, operand, target_type);
|
||||
return;
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -142,16 +142,16 @@
|
||||
#define LLVM_USE_PERF 0
|
||||
|
||||
/* Major version of the LLVM API */
|
||||
#define LLVM_VERSION_MAJOR 18
|
||||
#define LLVM_VERSION_MAJOR 20
|
||||
|
||||
/* Minor version of the LLVM API */
|
||||
#define LLVM_VERSION_MINOR 1
|
||||
|
||||
/* Patch version of the LLVM API */
|
||||
#define LLVM_VERSION_PATCH 8
|
||||
#define LLVM_VERSION_PATCH 0
|
||||
|
||||
/* LLVM version string */
|
||||
#define LLVM_VERSION_STRING "18.1.8"
|
||||
#define LLVM_VERSION_STRING "20.1.0"
|
||||
|
||||
/* Whether LLVM records statistics for use with GetStatistics(),
|
||||
* PrintStatistics() or PrintStatisticsJSON()
|
||||
|
||||
@@ -15,11 +15,11 @@
|
||||
#ifndef LLVM_C_CORE_H
|
||||
#define LLVM_C_CORE_H
|
||||
|
||||
#include "Deprecated.h"
|
||||
#include "ErrorHandling.h"
|
||||
#include "ExternC.h"
|
||||
#include "llvm-c/Deprecated.h"
|
||||
#include "llvm-c/ErrorHandling.h"
|
||||
#include "llvm-c/ExternC.h"
|
||||
|
||||
#include "Types.h"
|
||||
#include "llvm-c/Types.h"
|
||||
|
||||
LLVM_C_EXTERN_C_BEGIN
|
||||
|
||||
@@ -146,27 +146,27 @@ typedef enum {
|
||||
} LLVMOpcode;
|
||||
|
||||
typedef enum {
|
||||
LLVMVoidTypeKind, /**< type with no size */
|
||||
LLVMHalfTypeKind, /**< 16 bit floating point type */
|
||||
LLVMFloatTypeKind, /**< 32 bit floating point type */
|
||||
LLVMDoubleTypeKind, /**< 64 bit floating point type */
|
||||
LLVMX86_FP80TypeKind, /**< 80 bit floating point type (X87) */
|
||||
LLVMFP128TypeKind, /**< 128 bit floating point type (112-bit mantissa)*/
|
||||
LLVMPPC_FP128TypeKind, /**< 128 bit floating point type (two 64-bits) */
|
||||
LLVMLabelTypeKind, /**< Labels */
|
||||
LLVMIntegerTypeKind, /**< Arbitrary bit width integers */
|
||||
LLVMFunctionTypeKind, /**< Functions */
|
||||
LLVMStructTypeKind, /**< Structures */
|
||||
LLVMArrayTypeKind, /**< Arrays */
|
||||
LLVMPointerTypeKind, /**< Pointers */
|
||||
LLVMVectorTypeKind, /**< Fixed width SIMD vector type */
|
||||
LLVMMetadataTypeKind, /**< Metadata */
|
||||
LLVMX86_MMXTypeKind, /**< X86 MMX */
|
||||
LLVMTokenTypeKind, /**< Tokens */
|
||||
LLVMScalableVectorTypeKind, /**< Scalable SIMD vector type */
|
||||
LLVMBFloatTypeKind, /**< 16 bit brain floating point type */
|
||||
LLVMX86_AMXTypeKind, /**< X86 AMX */
|
||||
LLVMTargetExtTypeKind, /**< Target extension type */
|
||||
LLVMVoidTypeKind = 0, /**< type with no size */
|
||||
LLVMHalfTypeKind = 1, /**< 16 bit floating point type */
|
||||
LLVMFloatTypeKind = 2, /**< 32 bit floating point type */
|
||||
LLVMDoubleTypeKind = 3, /**< 64 bit floating point type */
|
||||
LLVMX86_FP80TypeKind = 4, /**< 80 bit floating point type (X87) */
|
||||
LLVMFP128TypeKind = 5, /**< 128 bit floating point type (112-bit mantissa)*/
|
||||
LLVMPPC_FP128TypeKind = 6, /**< 128 bit floating point type (two 64-bits) */
|
||||
LLVMLabelTypeKind = 7, /**< Labels */
|
||||
LLVMIntegerTypeKind = 8, /**< Arbitrary bit width integers */
|
||||
LLVMFunctionTypeKind = 9, /**< Functions */
|
||||
LLVMStructTypeKind = 10, /**< Structures */
|
||||
LLVMArrayTypeKind = 11, /**< Arrays */
|
||||
LLVMPointerTypeKind = 12, /**< Pointers */
|
||||
LLVMVectorTypeKind = 13, /**< Fixed width SIMD vector type */
|
||||
LLVMMetadataTypeKind = 14, /**< Metadata */
|
||||
/* 15 previously used by LLVMX86_MMXTypeKind */
|
||||
LLVMTokenTypeKind = 16, /**< Tokens */
|
||||
LLVMScalableVectorTypeKind = 17, /**< Scalable SIMD vector type */
|
||||
LLVMBFloatTypeKind = 18, /**< 16 bit brain floating point type */
|
||||
LLVMX86_AMXTypeKind = 19, /**< X86 AMX */
|
||||
LLVMTargetExtTypeKind = 20, /**< Target extension type */
|
||||
} LLVMTypeKind;
|
||||
|
||||
typedef enum {
|
||||
@@ -286,6 +286,7 @@ typedef enum {
|
||||
LLVMInstructionValueKind,
|
||||
LLVMPoisonValueValueKind,
|
||||
LLVMConstantTargetNoneValueKind,
|
||||
LLVMConstantPtrAuthValueKind,
|
||||
} LLVMValueKind;
|
||||
|
||||
typedef enum {
|
||||
@@ -361,35 +362,42 @@ typedef enum {
|
||||
} LLVMAtomicOrdering;
|
||||
|
||||
typedef enum {
|
||||
LLVMAtomicRMWBinOpXchg, /**< Set the new value and return the one old */
|
||||
LLVMAtomicRMWBinOpAdd, /**< Add a value and return the old one */
|
||||
LLVMAtomicRMWBinOpSub, /**< Subtract a value and return the old one */
|
||||
LLVMAtomicRMWBinOpAnd, /**< And a value and return the old one */
|
||||
LLVMAtomicRMWBinOpNand, /**< Not-And a value and return the old one */
|
||||
LLVMAtomicRMWBinOpOr, /**< OR a value and return the old one */
|
||||
LLVMAtomicRMWBinOpXor, /**< Xor a value and return the old one */
|
||||
LLVMAtomicRMWBinOpMax, /**< Sets the value if it's greater than the
|
||||
original using a signed comparison and return
|
||||
the old one */
|
||||
LLVMAtomicRMWBinOpMin, /**< Sets the value if it's Smaller than the
|
||||
original using a signed comparison and return
|
||||
the old one */
|
||||
LLVMAtomicRMWBinOpUMax, /**< Sets the value if it's greater than the
|
||||
original using an unsigned comparison and return
|
||||
the old one */
|
||||
LLVMAtomicRMWBinOpUMin, /**< Sets the value if it's greater than the
|
||||
original using an unsigned comparison and return
|
||||
the old one */
|
||||
LLVMAtomicRMWBinOpFAdd, /**< Add a floating point value and return the
|
||||
old one */
|
||||
LLVMAtomicRMWBinOpFSub, /**< Subtract a floating point value and return the
|
||||
LLVMAtomicRMWBinOpXchg, /**< Set the new value and return the one old */
|
||||
LLVMAtomicRMWBinOpAdd, /**< Add a value and return the old one */
|
||||
LLVMAtomicRMWBinOpSub, /**< Subtract a value and return the old one */
|
||||
LLVMAtomicRMWBinOpAnd, /**< And a value and return the old one */
|
||||
LLVMAtomicRMWBinOpNand, /**< Not-And a value and return the old one */
|
||||
LLVMAtomicRMWBinOpOr, /**< OR a value and return the old one */
|
||||
LLVMAtomicRMWBinOpXor, /**< Xor a value and return the old one */
|
||||
LLVMAtomicRMWBinOpMax, /**< Sets the value if it's greater than the
|
||||
original using a signed comparison and return
|
||||
the old one */
|
||||
LLVMAtomicRMWBinOpMin, /**< Sets the value if it's Smaller than the
|
||||
original using a signed comparison and return
|
||||
the old one */
|
||||
LLVMAtomicRMWBinOpUMax, /**< Sets the value if it's greater than the
|
||||
original using an unsigned comparison and return
|
||||
the old one */
|
||||
LLVMAtomicRMWBinOpUMin, /**< Sets the value if it's greater than the
|
||||
original using an unsigned comparison and return
|
||||
the old one */
|
||||
LLVMAtomicRMWBinOpFAdd, /**< Add 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 */
|
||||
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 */
|
||||
LLVMAtomicRMWBinOpUIncWrap, /**< Increments the value, wrapping back to zero
|
||||
when incremented above input value */
|
||||
LLVMAtomicRMWBinOpUDecWrap, /**< Decrements the value, wrapping back to
|
||||
the input value when decremented below zero */
|
||||
LLVMAtomicRMWBinOpUSubCond, /**<Subtracts the value only if no unsigned
|
||||
overflow */
|
||||
LLVMAtomicRMWBinOpUSubSat, /**<Subtracts the value, clamping to zero */
|
||||
} LLVMAtomicRMWBinOp;
|
||||
|
||||
typedef enum {
|
||||
@@ -467,6 +475,8 @@ enum {
|
||||
LLVMAttributeFunctionIndex = -1,
|
||||
};
|
||||
|
||||
typedef unsigned LLVMAttributeIndex;
|
||||
|
||||
/**
|
||||
* Tail call kind for LLVMSetTailCallKind and LLVMGetTailCallKind.
|
||||
*
|
||||
@@ -481,8 +491,6 @@ typedef enum {
|
||||
LLVMTailCallKindNoTail = 3,
|
||||
} LLVMTailCallKind;
|
||||
|
||||
typedef unsigned LLVMAttributeIndex;
|
||||
|
||||
enum {
|
||||
LLVMFastMathAllowReassoc = (1 << 0),
|
||||
LLVMFastMathNoNaNs = (1 << 1),
|
||||
@@ -506,6 +514,20 @@ enum {
|
||||
*/
|
||||
typedef unsigned LLVMFastMathFlags;
|
||||
|
||||
enum {
|
||||
LLVMGEPFlagInBounds = (1 << 0),
|
||||
LLVMGEPFlagNUSW = (1 << 1),
|
||||
LLVMGEPFlagNUW = (1 << 2),
|
||||
};
|
||||
|
||||
/**
|
||||
* Flags that constrain the allowed wrap semantics of a getelementptr
|
||||
* instruction.
|
||||
*
|
||||
* See https://llvm.org/docs/LangRef.html#getelementptr-instruction
|
||||
*/
|
||||
typedef unsigned LLVMGEPNoWrapFlags;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
@@ -627,6 +649,11 @@ unsigned LLVMGetMDKindIDInContext(LLVMContextRef C, const char *Name,
|
||||
unsigned SLen);
|
||||
unsigned LLVMGetMDKindID(const char *Name, unsigned SLen);
|
||||
|
||||
/**
|
||||
* Maps a synchronization scope name to a ID unique within this context.
|
||||
*/
|
||||
unsigned LLVMGetSyncScopeID(LLVMContextRef C, const char *Name, size_t SLen);
|
||||
|
||||
/**
|
||||
* Return an unique id given the name of a enum attribute,
|
||||
* or 0 if no attribute by that name exists.
|
||||
@@ -669,6 +696,18 @@ LLVMAttributeRef LLVMCreateTypeAttribute(LLVMContextRef C, unsigned KindID,
|
||||
*/
|
||||
LLVMTypeRef LLVMGetTypeAttributeValue(LLVMAttributeRef A);
|
||||
|
||||
/**
|
||||
* Create a ConstantRange attribute.
|
||||
*
|
||||
* LowerWords and UpperWords need to be NumBits divided by 64 rounded up
|
||||
* elements long.
|
||||
*/
|
||||
LLVMAttributeRef LLVMCreateConstantRangeAttribute(LLVMContextRef C,
|
||||
unsigned KindID,
|
||||
unsigned NumBits,
|
||||
const uint64_t LowerWords[],
|
||||
const uint64_t UpperWords[]);
|
||||
|
||||
/**
|
||||
* Create a string attribute.
|
||||
*/
|
||||
@@ -744,6 +783,24 @@ LLVMModuleRef LLVMCloneModule(LLVMModuleRef M);
|
||||
*/
|
||||
void LLVMDisposeModule(LLVMModuleRef M);
|
||||
|
||||
/**
|
||||
* Soon to be deprecated.
|
||||
* See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
|
||||
*
|
||||
* Returns true if the module is in the new debug info mode which uses
|
||||
* non-instruction debug records instead of debug intrinsics for variable
|
||||
* location tracking.
|
||||
*/
|
||||
LLVMBool LLVMIsNewDbgInfoFormat(LLVMModuleRef M);
|
||||
|
||||
/**
|
||||
* Soon to be deprecated.
|
||||
* See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
|
||||
*
|
||||
* Convert module into desired debug info format.
|
||||
*/
|
||||
void LLVMSetIsNewDbgInfoFormat(LLVMModuleRef M, LLVMBool UseNewFormat);
|
||||
|
||||
/**
|
||||
* Obtain the identifier of a module.
|
||||
*
|
||||
@@ -1130,6 +1187,16 @@ LLVMValueRef LLVMAddFunction(LLVMModuleRef M, const char *Name,
|
||||
*/
|
||||
LLVMValueRef LLVMGetNamedFunction(LLVMModuleRef M, const char *Name);
|
||||
|
||||
/**
|
||||
* Obtain a Function value from a Module by its name.
|
||||
*
|
||||
* The returned value corresponds to a llvm::Function value.
|
||||
*
|
||||
* @see llvm::Module::getFunction()
|
||||
*/
|
||||
LLVMValueRef LLVMGetNamedFunctionWithLength(LLVMModuleRef M, const char *Name,
|
||||
size_t Length);
|
||||
|
||||
/**
|
||||
* Obtain an iterator to the first Function in a Module.
|
||||
*
|
||||
@@ -1618,6 +1685,35 @@ LLVMTypeRef LLVMScalableVectorType(LLVMTypeRef ElementType,
|
||||
*/
|
||||
unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy);
|
||||
|
||||
/**
|
||||
* Get the pointer value for the associated ConstantPtrAuth constant.
|
||||
*
|
||||
* @see llvm::ConstantPtrAuth::getPointer
|
||||
*/
|
||||
LLVMValueRef LLVMGetConstantPtrAuthPointer(LLVMValueRef PtrAuth);
|
||||
|
||||
/**
|
||||
* Get the key value for the associated ConstantPtrAuth constant.
|
||||
*
|
||||
* @see llvm::ConstantPtrAuth::getKey
|
||||
*/
|
||||
LLVMValueRef LLVMGetConstantPtrAuthKey(LLVMValueRef PtrAuth);
|
||||
|
||||
/**
|
||||
* Get the discriminator value for the associated ConstantPtrAuth constant.
|
||||
*
|
||||
* @see llvm::ConstantPtrAuth::getDiscriminator
|
||||
*/
|
||||
LLVMValueRef LLVMGetConstantPtrAuthDiscriminator(LLVMValueRef PtrAuth);
|
||||
|
||||
/**
|
||||
* Get the address discriminator value for the associated ConstantPtrAuth
|
||||
* constant.
|
||||
*
|
||||
* @see llvm::ConstantPtrAuth::getAddrDiscriminator
|
||||
*/
|
||||
LLVMValueRef LLVMGetConstantPtrAuthAddrDiscriminator(LLVMValueRef PtrAuth);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
@@ -1638,11 +1734,6 @@ LLVMTypeRef LLVMVoidTypeInContext(LLVMContextRef C);
|
||||
*/
|
||||
LLVMTypeRef LLVMLabelTypeInContext(LLVMContextRef C);
|
||||
|
||||
/**
|
||||
* Create a X86 MMX type in a context.
|
||||
*/
|
||||
LLVMTypeRef LLVMX86MMXTypeInContext(LLVMContextRef C);
|
||||
|
||||
/**
|
||||
* Create a X86 AMX type in a context.
|
||||
*/
|
||||
@@ -1664,7 +1755,6 @@ LLVMTypeRef LLVMMetadataTypeInContext(LLVMContextRef C);
|
||||
*/
|
||||
LLVMTypeRef LLVMVoidType(void);
|
||||
LLVMTypeRef LLVMLabelType(void);
|
||||
LLVMTypeRef LLVMX86MMXType(void);
|
||||
LLVMTypeRef LLVMX86AMXType(void);
|
||||
|
||||
/**
|
||||
@@ -1676,6 +1766,42 @@ LLVMTypeRef LLVMTargetExtTypeInContext(LLVMContextRef C, const char *Name,
|
||||
unsigned *IntParams,
|
||||
unsigned IntParamCount);
|
||||
|
||||
/**
|
||||
* Obtain the name for this target extension type.
|
||||
*
|
||||
* @see llvm::TargetExtType::getName()
|
||||
*/
|
||||
const char *LLVMGetTargetExtTypeName(LLVMTypeRef TargetExtTy);
|
||||
|
||||
/**
|
||||
* Obtain the number of type parameters for this target extension type.
|
||||
*
|
||||
* @see llvm::TargetExtType::getNumTypeParameters()
|
||||
*/
|
||||
unsigned LLVMGetTargetExtTypeNumTypeParams(LLVMTypeRef TargetExtTy);
|
||||
|
||||
/**
|
||||
* Get the type parameter at the given index for the target extension type.
|
||||
*
|
||||
* @see llvm::TargetExtType::getTypeParameter()
|
||||
*/
|
||||
LLVMTypeRef LLVMGetTargetExtTypeTypeParam(LLVMTypeRef TargetExtTy,
|
||||
unsigned Idx);
|
||||
|
||||
/**
|
||||
* Obtain the number of int parameters for this target extension type.
|
||||
*
|
||||
* @see llvm::TargetExtType::getNumIntParameters()
|
||||
*/
|
||||
unsigned LLVMGetTargetExtTypeNumIntParams(LLVMTypeRef TargetExtTy);
|
||||
|
||||
/**
|
||||
* Get the int parameter at the given index for the target extension type.
|
||||
*
|
||||
* @see llvm::TargetExtType::getIntParameter()
|
||||
*/
|
||||
unsigned LLVMGetTargetExtTypeIntParam(LLVMTypeRef TargetExtTy, unsigned Idx);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
@@ -1705,6 +1831,10 @@ LLVMTypeRef LLVMTargetExtTypeInContext(LLVMContextRef C, const char *Name,
|
||||
* @{
|
||||
*/
|
||||
|
||||
// Currently, clang-format tries to format the LLVM_FOR_EACH_VALUE_SUBCLASS
|
||||
// macro in a progressively-indented fashion, which is not desired
|
||||
// clang-format off
|
||||
|
||||
#define LLVM_FOR_EACH_VALUE_SUBCLASS(macro) \
|
||||
macro(Argument) \
|
||||
macro(BasicBlock) \
|
||||
@@ -1724,6 +1854,7 @@ LLVMTypeRef LLVMTargetExtTypeInContext(LLVMContextRef C, const char *Name,
|
||||
macro(ConstantStruct) \
|
||||
macro(ConstantTokenNone) \
|
||||
macro(ConstantVector) \
|
||||
macro(ConstantPtrAuth) \
|
||||
macro(GlobalValue) \
|
||||
macro(GlobalAlias) \
|
||||
macro(GlobalObject) \
|
||||
@@ -1795,6 +1926,8 @@ LLVMTypeRef LLVMTargetExtTypeInContext(LLVMContextRef C, const char *Name,
|
||||
macro(AtomicRMWInst) \
|
||||
macro(FenceInst)
|
||||
|
||||
// clang-format on
|
||||
|
||||
/**
|
||||
* @defgroup LLVMCCoreValueGeneral General APIs
|
||||
*
|
||||
@@ -1848,6 +1981,21 @@ void LLVMDumpValue(LLVMValueRef Val);
|
||||
*/
|
||||
char *LLVMPrintValueToString(LLVMValueRef Val);
|
||||
|
||||
/**
|
||||
* Obtain the context to which this value is associated.
|
||||
*
|
||||
* @see llvm::Value::getContext()
|
||||
*/
|
||||
LLVMContextRef LLVMGetValueContext(LLVMValueRef Val);
|
||||
|
||||
/**
|
||||
* Return a string representation of the DbgRecord. Use
|
||||
* LLVMDisposeMessage to free the string.
|
||||
*
|
||||
* @see llvm::DbgRecord::print()
|
||||
*/
|
||||
char *LLVMPrintDbgRecordToString(LLVMDbgRecordRef Record);
|
||||
|
||||
/**
|
||||
* Replace all uses of a value with another one.
|
||||
*
|
||||
@@ -2165,11 +2313,22 @@ double LLVMConstRealGetDouble(LLVMValueRef ConstantVal, LLVMBool *losesInfo);
|
||||
/**
|
||||
* Create a ConstantDataSequential and initialize it with a string.
|
||||
*
|
||||
* @deprecated LLVMConstStringInContext is deprecated in favor of the API
|
||||
* accurate LLVMConstStringInContext2
|
||||
* @see llvm::ConstantDataArray::getString()
|
||||
*/
|
||||
LLVMValueRef LLVMConstStringInContext(LLVMContextRef C, const char *Str,
|
||||
unsigned Length, LLVMBool DontNullTerminate);
|
||||
|
||||
/**
|
||||
* Create a ConstantDataSequential and initialize it with a string.
|
||||
*
|
||||
* @see llvm::ConstantDataArray::getString()
|
||||
*/
|
||||
LLVMValueRef LLVMConstStringInContext2(LLVMContextRef C, const char *Str,
|
||||
size_t Length,
|
||||
LLVMBool DontNullTerminate);
|
||||
|
||||
/**
|
||||
* Create a ConstantDataSequential with string content in the global context.
|
||||
*
|
||||
@@ -2269,6 +2428,14 @@ LLVM_ATTRIBUTE_C_DEPRECATED(
|
||||
*/
|
||||
LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size);
|
||||
|
||||
/**
|
||||
* Create a ConstantPtrAuth constant with the given values.
|
||||
*
|
||||
* @see llvm::ConstantPtrAuth::get()
|
||||
*/
|
||||
LLVMValueRef LLVMConstantPtrAuth(LLVMValueRef Ptr, LLVMValueRef Key,
|
||||
LLVMValueRef Disc, LLVMValueRef AddrDisc);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
@@ -2287,7 +2454,9 @@ LLVMValueRef LLVMAlignOf(LLVMTypeRef Ty);
|
||||
LLVMValueRef LLVMSizeOf(LLVMTypeRef Ty);
|
||||
LLVMValueRef LLVMConstNeg(LLVMValueRef ConstantVal);
|
||||
LLVMValueRef LLVMConstNSWNeg(LLVMValueRef ConstantVal);
|
||||
LLVMValueRef LLVMConstNUWNeg(LLVMValueRef ConstantVal);
|
||||
LLVM_ATTRIBUTE_C_DEPRECATED(
|
||||
LLVMValueRef LLVMConstNUWNeg(LLVMValueRef ConstantVal),
|
||||
"Use LLVMConstNull instead.");
|
||||
LLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal);
|
||||
LLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
|
||||
LLVMValueRef LLVMConstNSWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
|
||||
@@ -2299,16 +2468,22 @@ LLVMValueRef LLVMConstMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
|
||||
LLVMValueRef LLVMConstNSWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
|
||||
LLVMValueRef LLVMConstNUWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
|
||||
LLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
|
||||
LLVMValueRef LLVMConstICmp(LLVMIntPredicate Predicate,
|
||||
LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
|
||||
LLVMValueRef LLVMConstFCmp(LLVMRealPredicate Predicate,
|
||||
LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
|
||||
LLVMValueRef LLVMConstShl(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
|
||||
LLVMValueRef LLVMConstGEP2(LLVMTypeRef Ty, LLVMValueRef ConstantVal,
|
||||
LLVMValueRef *ConstantIndices, unsigned NumIndices);
|
||||
LLVMValueRef LLVMConstInBoundsGEP2(LLVMTypeRef Ty, LLVMValueRef ConstantVal,
|
||||
LLVMValueRef *ConstantIndices,
|
||||
unsigned NumIndices);
|
||||
/**
|
||||
* Creates a constant GetElementPtr expression. Similar to LLVMConstGEP2, but
|
||||
* allows specifying the no-wrap flags.
|
||||
*
|
||||
* @see llvm::ConstantExpr::getGetElementPtr()
|
||||
*/
|
||||
LLVMValueRef LLVMConstGEPWithNoWrapFlags(LLVMTypeRef Ty,
|
||||
LLVMValueRef ConstantVal,
|
||||
LLVMValueRef *ConstantIndices,
|
||||
unsigned NumIndices,
|
||||
LLVMGEPNoWrapFlags NoWrapFlags);
|
||||
LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
|
||||
LLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
|
||||
LLVMValueRef LLVMConstIntToPtr(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
|
||||
@@ -2328,6 +2503,16 @@ LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant,
|
||||
LLVMValueRef MaskConstant);
|
||||
LLVMValueRef LLVMBlockAddress(LLVMValueRef F, LLVMBasicBlockRef BB);
|
||||
|
||||
/**
|
||||
* Gets the function associated with a given BlockAddress constant value.
|
||||
*/
|
||||
LLVMValueRef LLVMGetBlockAddressFunction(LLVMValueRef BlockAddr);
|
||||
|
||||
/**
|
||||
* Gets the basic block associated with a given BlockAddress constant value.
|
||||
*/
|
||||
LLVMBasicBlockRef LLVMGetBlockAddressBasicBlock(LLVMValueRef BlockAddr);
|
||||
|
||||
/** Deprecated: Use LLVMGetInlineAsm instead. */
|
||||
LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty,
|
||||
const char *AsmString, const char *Constraints,
|
||||
@@ -2473,6 +2658,8 @@ LLVMValueRef LLVMAddGlobalInAddressSpace(LLVMModuleRef M, LLVMTypeRef Ty,
|
||||
const char *Name,
|
||||
unsigned AddressSpace);
|
||||
LLVMValueRef LLVMGetNamedGlobal(LLVMModuleRef M, const char *Name);
|
||||
LLVMValueRef LLVMGetNamedGlobalWithLength(LLVMModuleRef M, const char *Name,
|
||||
size_t Length);
|
||||
LLVMValueRef LLVMGetFirstGlobal(LLVMModuleRef M);
|
||||
LLVMValueRef LLVMGetLastGlobal(LLVMModuleRef M);
|
||||
LLVMValueRef LLVMGetNextGlobal(LLVMValueRef GlobalVar);
|
||||
@@ -2608,7 +2795,7 @@ void LLVMSetPersonalityFn(LLVMValueRef Fn, LLVMValueRef PersonalityFn);
|
||||
/**
|
||||
* Obtain the intrinsic ID number which matches the given function name.
|
||||
*
|
||||
* @see llvm::Function::lookupIntrinsicID()
|
||||
* @see llvm::Intrinsic::lookupIntrinsicID()
|
||||
*/
|
||||
unsigned LLVMLookupIntrinsicID(const char *Name, size_t NameLen);
|
||||
|
||||
@@ -2620,10 +2807,10 @@ unsigned LLVMLookupIntrinsicID(const char *Name, size_t NameLen);
|
||||
unsigned LLVMGetIntrinsicID(LLVMValueRef Fn);
|
||||
|
||||
/**
|
||||
* Create or insert the declaration of an intrinsic. For overloaded intrinsics,
|
||||
* Get or insert the declaration of an intrinsic. For overloaded intrinsics,
|
||||
* parameter types must be provided to uniquely identify an overload.
|
||||
*
|
||||
* @see llvm::Intrinsic::getDeclaration()
|
||||
* @see llvm::Intrinsic::getOrInsertDeclaration()
|
||||
*/
|
||||
LLVMValueRef LLVMGetIntrinsicDeclaration(LLVMModuleRef Mod,
|
||||
unsigned ID,
|
||||
@@ -2647,10 +2834,8 @@ 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);
|
||||
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
|
||||
@@ -2663,10 +2848,9 @@ const char *LLVMIntrinsicCopyOverloadedName(unsigned ID,
|
||||
*
|
||||
* @see llvm::Intrinsic::getName()
|
||||
*/
|
||||
const char *LLVMIntrinsicCopyOverloadedName2(LLVMModuleRef Mod, unsigned ID,
|
||||
LLVMTypeRef *ParamTypes,
|
||||
size_t ParamCount,
|
||||
size_t *NameLength);
|
||||
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.
|
||||
@@ -2709,6 +2893,44 @@ const char *LLVMGetGC(LLVMValueRef Fn);
|
||||
*/
|
||||
void LLVMSetGC(LLVMValueRef Fn, const char *Name);
|
||||
|
||||
/**
|
||||
* Gets the prefix data associated with a function. Only valid on functions, and
|
||||
* only if LLVMHasPrefixData returns true.
|
||||
* See https://llvm.org/docs/LangRef.html#prefix-data
|
||||
*/
|
||||
LLVMValueRef LLVMGetPrefixData(LLVMValueRef Fn);
|
||||
|
||||
/**
|
||||
* Check if a given function has prefix data. Only valid on functions.
|
||||
* See https://llvm.org/docs/LangRef.html#prefix-data
|
||||
*/
|
||||
LLVMBool LLVMHasPrefixData(LLVMValueRef Fn);
|
||||
|
||||
/**
|
||||
* Sets the prefix data for the function. Only valid on functions.
|
||||
* See https://llvm.org/docs/LangRef.html#prefix-data
|
||||
*/
|
||||
void LLVMSetPrefixData(LLVMValueRef Fn, LLVMValueRef prefixData);
|
||||
|
||||
/**
|
||||
* Gets the prologue data associated with a function. Only valid on functions,
|
||||
* and only if LLVMHasPrologueData returns true.
|
||||
* See https://llvm.org/docs/LangRef.html#prologue-data
|
||||
*/
|
||||
LLVMValueRef LLVMGetPrologueData(LLVMValueRef Fn);
|
||||
|
||||
/**
|
||||
* Check if a given function has prologue data. Only valid on functions.
|
||||
* See https://llvm.org/docs/LangRef.html#prologue-data
|
||||
*/
|
||||
LLVMBool LLVMHasPrologueData(LLVMValueRef Fn);
|
||||
|
||||
/**
|
||||
* Sets the prologue data for the function. Only valid on functions.
|
||||
* See https://llvm.org/docs/LangRef.html#prologue-data
|
||||
*/
|
||||
void LLVMSetPrologueData(LLVMValueRef Fn, LLVMValueRef prologueData);
|
||||
|
||||
/**
|
||||
* Add an attribute to a function.
|
||||
*
|
||||
@@ -3426,8 +3648,7 @@ LLVMOpcode LLVMGetInstructionOpcode(LLVMValueRef Inst);
|
||||
/**
|
||||
* Obtain the predicate of an instruction.
|
||||
*
|
||||
* This is only valid for instructions that correspond to llvm::ICmpInst
|
||||
* or llvm::ConstantExpr whose opcode is llvm::Instruction::ICmp.
|
||||
* This is only valid for instructions that correspond to llvm::ICmpInst.
|
||||
*
|
||||
* @see llvm::ICmpInst::getPredicate()
|
||||
*/
|
||||
@@ -3436,8 +3657,7 @@ LLVMIntPredicate LLVMGetICmpPredicate(LLVMValueRef Inst);
|
||||
/**
|
||||
* Obtain the float predicate of an instruction.
|
||||
*
|
||||
* This is only valid for instructions that correspond to llvm::FCmpInst
|
||||
* or llvm::ConstantExpr whose opcode is llvm::Instruction::FCmp.
|
||||
* This is only valid for instructions that correspond to llvm::FCmpInst.
|
||||
*
|
||||
* @see llvm::FCmpInst::getPredicate()
|
||||
*/
|
||||
@@ -3462,6 +3682,41 @@ LLVMValueRef LLVMInstructionClone(LLVMValueRef Inst);
|
||||
*/
|
||||
LLVMValueRef LLVMIsATerminatorInst(LLVMValueRef Inst);
|
||||
|
||||
/**
|
||||
* Obtain the first debug record attached to an instruction.
|
||||
*
|
||||
* Use LLVMGetNextDbgRecord() and LLVMGetPreviousDbgRecord() to traverse the
|
||||
* sequence of DbgRecords.
|
||||
*
|
||||
* Return the first DbgRecord attached to Inst or NULL if there are none.
|
||||
*
|
||||
* @see llvm::Instruction::getDbgRecordRange()
|
||||
*/
|
||||
LLVMDbgRecordRef LLVMGetFirstDbgRecord(LLVMValueRef Inst);
|
||||
|
||||
/**
|
||||
* Obtain the last debug record attached to an instruction.
|
||||
*
|
||||
* Return the last DbgRecord attached to Inst or NULL if there are none.
|
||||
*
|
||||
* @see llvm::Instruction::getDbgRecordRange()
|
||||
*/
|
||||
LLVMDbgRecordRef LLVMGetLastDbgRecord(LLVMValueRef Inst);
|
||||
|
||||
/**
|
||||
* Obtain the next DbgRecord in the sequence or NULL if there are no more.
|
||||
*
|
||||
* @see llvm::Instruction::getDbgRecordRange()
|
||||
*/
|
||||
LLVMDbgRecordRef LLVMGetNextDbgRecord(LLVMDbgRecordRef DbgRecord);
|
||||
|
||||
/**
|
||||
* Obtain the previous DbgRecord in the sequence or NULL if there are no more.
|
||||
*
|
||||
* @see llvm::Instruction::getDbgRecordRange()
|
||||
*/
|
||||
LLVMDbgRecordRef LLVMGetPreviousDbgRecord(LLVMDbgRecordRef DbgRecord);
|
||||
|
||||
/**
|
||||
* @defgroup LLVMCCoreValueInstructionCall Call Sites and Invocations
|
||||
*
|
||||
@@ -3634,6 +3889,28 @@ void LLVMSetNormalDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B);
|
||||
*/
|
||||
void LLVMSetUnwindDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B);
|
||||
|
||||
/**
|
||||
* Get the default destination of a CallBr instruction.
|
||||
*
|
||||
* @see llvm::CallBrInst::getDefaultDest()
|
||||
*/
|
||||
LLVMBasicBlockRef LLVMGetCallBrDefaultDest(LLVMValueRef CallBr);
|
||||
|
||||
/**
|
||||
* Get the number of indirect destinations of a CallBr instruction.
|
||||
*
|
||||
* @see llvm::CallBrInst::getNumIndirectDests()
|
||||
|
||||
*/
|
||||
unsigned LLVMGetCallBrNumIndirectDests(LLVMValueRef CallBr);
|
||||
|
||||
/**
|
||||
* Get the indirect destination of a CallBr instruction at the given index.
|
||||
*
|
||||
* @see llvm::CallBrInst::getIndirectDest()
|
||||
*/
|
||||
LLVMBasicBlockRef LLVMGetCallBrIndirectDest(LLVMValueRef CallBr, unsigned Idx);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
@@ -3750,6 +4027,20 @@ void LLVMSetIsInBounds(LLVMValueRef GEP, LLVMBool InBounds);
|
||||
*/
|
||||
LLVMTypeRef LLVMGetGEPSourceElementType(LLVMValueRef GEP);
|
||||
|
||||
/**
|
||||
* Get the no-wrap related flags for the given GEP instruction.
|
||||
*
|
||||
* @see llvm::GetElementPtrInst::getNoWrapFlags
|
||||
*/
|
||||
LLVMGEPNoWrapFlags LLVMGEPGetNoWrapFlags(LLVMValueRef GEP);
|
||||
|
||||
/**
|
||||
* Set the no-wrap related flags for the given GEP instruction.
|
||||
*
|
||||
* @see llvm::GetElementPtrInst::setNoWrapFlags
|
||||
*/
|
||||
void LLVMGEPSetNoWrapFlags(LLVMValueRef GEP, LLVMGEPNoWrapFlags NoWrapFlags);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
@@ -3832,9 +4123,28 @@ const unsigned *LLVMGetIndices(LLVMValueRef Inst);
|
||||
|
||||
LLVMBuilderRef LLVMCreateBuilderInContext(LLVMContextRef C);
|
||||
LLVMBuilderRef LLVMCreateBuilder(void);
|
||||
/**
|
||||
* Set the builder position before Instr but after any attached debug records,
|
||||
* or if Instr is null set the position to the end of Block.
|
||||
*/
|
||||
void LLVMPositionBuilder(LLVMBuilderRef Builder, LLVMBasicBlockRef Block,
|
||||
LLVMValueRef Instr);
|
||||
/**
|
||||
* Set the builder position before Instr and any attached debug records,
|
||||
* or if Instr is null set the position to the end of Block.
|
||||
*/
|
||||
void LLVMPositionBuilderBeforeDbgRecords(LLVMBuilderRef Builder,
|
||||
LLVMBasicBlockRef Block,
|
||||
LLVMValueRef Inst);
|
||||
/**
|
||||
* Set the builder position before Instr but after any attached debug records.
|
||||
*/
|
||||
void LLVMPositionBuilderBefore(LLVMBuilderRef Builder, LLVMValueRef Instr);
|
||||
/**
|
||||
* Set the builder position before Instr and any attached debug records.
|
||||
*/
|
||||
void LLVMPositionBuilderBeforeInstrAndDbgRecords(LLVMBuilderRef Builder,
|
||||
LLVMValueRef Instr);
|
||||
void LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder, LLVMBasicBlockRef Block);
|
||||
LLVMBasicBlockRef LLVMGetInsertBlock(LLVMBuilderRef Builder);
|
||||
void LLVMClearInsertionPosition(LLVMBuilderRef Builder);
|
||||
@@ -3897,6 +4207,13 @@ LLVMMetadataRef LLVMBuilderGetDefaultFPMathTag(LLVMBuilderRef Builder);
|
||||
void LLVMBuilderSetDefaultFPMathTag(LLVMBuilderRef Builder,
|
||||
LLVMMetadataRef FPMathTag);
|
||||
|
||||
/**
|
||||
* Obtain the context to which this builder is associated.
|
||||
*
|
||||
* @see llvm::IRBuilder::getContext()
|
||||
*/
|
||||
LLVMContextRef LLVMGetBuilderContext(LLVMBuilderRef Builder);
|
||||
|
||||
/**
|
||||
* Deprecated: Passing the NULL location will crash.
|
||||
* Use LLVMGetCurrentDebugLocation2 instead.
|
||||
@@ -3920,6 +4237,12 @@ LLVMValueRef LLVMBuildSwitch(LLVMBuilderRef, LLVMValueRef V,
|
||||
LLVMBasicBlockRef Else, unsigned NumCases);
|
||||
LLVMValueRef LLVMBuildIndirectBr(LLVMBuilderRef B, LLVMValueRef Addr,
|
||||
unsigned NumDests);
|
||||
LLVMValueRef LLVMBuildCallBr(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Fn,
|
||||
LLVMBasicBlockRef DefaultDest,
|
||||
LLVMBasicBlockRef *IndirectDests,
|
||||
unsigned NumIndirectDests, LLVMValueRef *Args,
|
||||
unsigned NumArgs, LLVMOperandBundleRef *Bundles,
|
||||
unsigned NumBundles, const char *Name);
|
||||
LLVMValueRef LLVMBuildInvoke2(LLVMBuilderRef, LLVMTypeRef Ty, LLVMValueRef Fn,
|
||||
LLVMValueRef *Args, unsigned NumArgs,
|
||||
LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch,
|
||||
@@ -4075,8 +4398,10 @@ LLVMValueRef LLVMBuildBinOp(LLVMBuilderRef B, LLVMOpcode Op,
|
||||
LLVMValueRef LLVMBuildNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
|
||||
LLVMValueRef LLVMBuildNSWNeg(LLVMBuilderRef B, LLVMValueRef V,
|
||||
const char *Name);
|
||||
LLVMValueRef LLVMBuildNUWNeg(LLVMBuilderRef B, LLVMValueRef V,
|
||||
const char *Name);
|
||||
LLVM_ATTRIBUTE_C_DEPRECATED(LLVMValueRef LLVMBuildNUWNeg(LLVMBuilderRef B,
|
||||
LLVMValueRef V,
|
||||
const char *Name),
|
||||
"Use LLVMBuildNeg + LLVMSetNUW instead.");
|
||||
LLVMValueRef LLVMBuildFNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
|
||||
LLVMValueRef LLVMBuildNot(LLVMBuilderRef, LLVMValueRef V, const char *Name);
|
||||
|
||||
@@ -4182,11 +4507,25 @@ LLVMValueRef LLVMBuildGEP2(LLVMBuilderRef B, LLVMTypeRef Ty,
|
||||
LLVMValueRef LLVMBuildInBoundsGEP2(LLVMBuilderRef B, LLVMTypeRef Ty,
|
||||
LLVMValueRef Pointer, LLVMValueRef *Indices,
|
||||
unsigned NumIndices, const char *Name);
|
||||
/**
|
||||
* Creates a GetElementPtr instruction. Similar to LLVMBuildGEP2, but allows
|
||||
* specifying the no-wrap flags.
|
||||
*
|
||||
* @see llvm::IRBuilder::CreateGEP()
|
||||
*/
|
||||
LLVMValueRef LLVMBuildGEPWithNoWrapFlags(LLVMBuilderRef B, LLVMTypeRef Ty,
|
||||
LLVMValueRef Pointer,
|
||||
LLVMValueRef *Indices,
|
||||
unsigned NumIndices, const char *Name,
|
||||
LLVMGEPNoWrapFlags NoWrapFlags);
|
||||
LLVMValueRef LLVMBuildStructGEP2(LLVMBuilderRef B, LLVMTypeRef Ty,
|
||||
LLVMValueRef Pointer, unsigned Idx,
|
||||
const char *Name);
|
||||
LLVMValueRef LLVMBuildGlobalString(LLVMBuilderRef B, const char *Str,
|
||||
const char *Name);
|
||||
/**
|
||||
* Deprecated: Use LLVMBuildGlobalString instead, which has identical behavior.
|
||||
*/
|
||||
LLVMValueRef LLVMBuildGlobalStringPtr(LLVMBuilderRef B, const char *Str,
|
||||
const char *Name);
|
||||
LLVMBool LLVMGetVolatile(LLVMValueRef MemoryAccessInst);
|
||||
@@ -4296,15 +4635,28 @@ LLVMValueRef LLVMBuildPtrDiff2(LLVMBuilderRef, LLVMTypeRef ElemTy,
|
||||
const char *Name);
|
||||
LLVMValueRef LLVMBuildFence(LLVMBuilderRef B, LLVMAtomicOrdering ordering,
|
||||
LLVMBool singleThread, const char *Name);
|
||||
LLVMValueRef LLVMBuildFenceSyncScope(LLVMBuilderRef B,
|
||||
LLVMAtomicOrdering ordering, unsigned SSID,
|
||||
const char *Name);
|
||||
LLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B, LLVMAtomicRMWBinOp op,
|
||||
LLVMValueRef PTR, LLVMValueRef Val,
|
||||
LLVMAtomicOrdering ordering,
|
||||
LLVMBool singleThread);
|
||||
LLVMValueRef LLVMBuildAtomicRMWSyncScope(LLVMBuilderRef B,
|
||||
LLVMAtomicRMWBinOp op,
|
||||
LLVMValueRef PTR, LLVMValueRef Val,
|
||||
LLVMAtomicOrdering ordering,
|
||||
unsigned SSID);
|
||||
LLVMValueRef LLVMBuildAtomicCmpXchg(LLVMBuilderRef B, LLVMValueRef Ptr,
|
||||
LLVMValueRef Cmp, LLVMValueRef New,
|
||||
LLVMAtomicOrdering SuccessOrdering,
|
||||
LLVMAtomicOrdering FailureOrdering,
|
||||
LLVMBool SingleThread);
|
||||
LLVMValueRef LLVMBuildAtomicCmpXchgSyncScope(LLVMBuilderRef B, LLVMValueRef Ptr,
|
||||
LLVMValueRef Cmp, LLVMValueRef New,
|
||||
LLVMAtomicOrdering SuccessOrdering,
|
||||
LLVMAtomicOrdering FailureOrdering,
|
||||
unsigned SSID);
|
||||
|
||||
/**
|
||||
* Get the number of elements in the mask of a ShuffleVector instruction.
|
||||
@@ -4329,6 +4681,22 @@ int LLVMGetMaskValue(LLVMValueRef ShuffleVectorInst, unsigned Elt);
|
||||
LLVMBool LLVMIsAtomicSingleThread(LLVMValueRef AtomicInst);
|
||||
void LLVMSetAtomicSingleThread(LLVMValueRef AtomicInst, LLVMBool SingleThread);
|
||||
|
||||
/**
|
||||
* Returns whether an instruction is an atomic instruction, e.g., atomicrmw,
|
||||
* cmpxchg, fence, or loads and stores with atomic ordering.
|
||||
*/
|
||||
LLVMBool LLVMIsAtomic(LLVMValueRef Inst);
|
||||
|
||||
/**
|
||||
* Returns the synchronization scope ID of an atomic instruction.
|
||||
*/
|
||||
unsigned LLVMGetAtomicSyncScopeID(LLVMValueRef AtomicInst);
|
||||
|
||||
/**
|
||||
* Sets the synchronization scope ID of an atomic instruction.
|
||||
*/
|
||||
void LLVMSetAtomicSyncScopeID(LLVMValueRef AtomicInst, unsigned SSID);
|
||||
|
||||
LLVMAtomicOrdering LLVMGetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst);
|
||||
void LLVMSetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst,
|
||||
LLVMAtomicOrdering Ordering);
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
#ifndef LLVM_C_DEBUGINFO_H
|
||||
#define LLVM_C_DEBUGINFO_H
|
||||
|
||||
#include "ExternC.h"
|
||||
#include "Types.h"
|
||||
#include "llvm-c/ExternC.h"
|
||||
#include "llvm-c/Types.h"
|
||||
|
||||
LLVM_C_EXTERN_C_BEGIN
|
||||
|
||||
@@ -125,7 +125,21 @@ typedef enum {
|
||||
LLVMDWARFSourceLanguageFortran18,
|
||||
LLVMDWARFSourceLanguageAda2005,
|
||||
LLVMDWARFSourceLanguageAda2012,
|
||||
LLVMDWARFSourceLanguageHIP,
|
||||
LLVMDWARFSourceLanguageAssembly,
|
||||
LLVMDWARFSourceLanguageC_sharp,
|
||||
LLVMDWARFSourceLanguageMojo,
|
||||
LLVMDWARFSourceLanguageGLSL,
|
||||
LLVMDWARFSourceLanguageGLSL_ES,
|
||||
LLVMDWARFSourceLanguageHLSL,
|
||||
LLVMDWARFSourceLanguageOpenCL_CPP,
|
||||
LLVMDWARFSourceLanguageCPP_for_OpenCL,
|
||||
LLVMDWARFSourceLanguageSYCL,
|
||||
LLVMDWARFSourceLanguageRuby,
|
||||
LLVMDWARFSourceLanguageMove,
|
||||
LLVMDWARFSourceLanguageHylo,
|
||||
LLVMDWARFSourceLanguageMetal,
|
||||
|
||||
// Vendor extensions:
|
||||
LLVMDWARFSourceLanguageMips_Assembler,
|
||||
LLVMDWARFSourceLanguageGOOGLE_RenderScript,
|
||||
@@ -856,13 +870,16 @@ LLVMDIBuilderCreateObjCProperty(LLVMDIBuilderRef Builder,
|
||||
LLVMMetadataRef Ty);
|
||||
|
||||
/**
|
||||
* Create a uniqued DIType* clone with FlagObjectPointer and FlagArtificial set.
|
||||
* Create a uniqued DIType* clone with FlagObjectPointer. If \c Implicit
|
||||
* is true, then also set FlagArtificial.
|
||||
* \param Builder The DIBuilder.
|
||||
* \param Type The underlying type to which this pointer points.
|
||||
* \param Implicit Indicates whether this pointer was implicitly generated
|
||||
* (i.e., not spelled out in source).
|
||||
*/
|
||||
LLVMMetadataRef
|
||||
LLVMDIBuilderCreateObjectPointerType(LLVMDIBuilderRef Builder,
|
||||
LLVMMetadataRef Type);
|
||||
LLVMMetadataRef LLVMDIBuilderCreateObjectPointerType(LLVMDIBuilderRef Builder,
|
||||
LLVMMetadataRef Type,
|
||||
LLVMBool Implicit);
|
||||
|
||||
/**
|
||||
* Create debugging information entry for a qualified
|
||||
@@ -1249,66 +1266,84 @@ LLVMMetadataRef LLVMDIBuilderCreateTempGlobalVariableFwdDecl(
|
||||
LLVMMetadataRef Decl, uint32_t AlignInBits);
|
||||
|
||||
/**
|
||||
* Insert a new llvm.dbg.declare intrinsic call before the given instruction.
|
||||
* Only use in "new debug format" (LLVMIsNewDbgInfoFormat() is true).
|
||||
* See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
|
||||
*
|
||||
* The debug format can be switched later after inserting the records using
|
||||
* LLVMSetIsNewDbgInfoFormat, if needed for legacy or transitionary reasons.
|
||||
*
|
||||
* Insert a Declare DbgRecord before the given instruction.
|
||||
* \param Builder The DIBuilder.
|
||||
* \param Storage The storage of the variable to declare.
|
||||
* \param VarInfo The variable's debug info descriptor.
|
||||
* \param Expr A complex location expression for the variable.
|
||||
* \param DebugLoc Debug info location.
|
||||
* \param Instr Instruction acting as a location for the new intrinsic.
|
||||
* \param Instr Instruction acting as a location for the new record.
|
||||
*/
|
||||
LLVMValueRef LLVMDIBuilderInsertDeclareBefore(
|
||||
LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo,
|
||||
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr);
|
||||
LLVMDbgRecordRef LLVMDIBuilderInsertDeclareRecordBefore(
|
||||
LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo,
|
||||
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr);
|
||||
|
||||
/**
|
||||
* Insert a new llvm.dbg.declare intrinsic call at the end of the given basic
|
||||
* block. If the basic block has a terminator instruction, the intrinsic is
|
||||
* inserted before that terminator instruction.
|
||||
* Only use in "new debug format" (LLVMIsNewDbgInfoFormat() is true).
|
||||
* See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
|
||||
*
|
||||
* The debug format can be switched later after inserting the records using
|
||||
* LLVMSetIsNewDbgInfoFormat, if needed for legacy or transitionary reasons.
|
||||
*
|
||||
* Insert a Declare DbgRecord at the end of the given basic block. If the basic
|
||||
* block has a terminator instruction, the record is inserted before that
|
||||
* terminator instruction.
|
||||
* \param Builder The DIBuilder.
|
||||
* \param Storage The storage of the variable to declare.
|
||||
* \param VarInfo The variable's debug info descriptor.
|
||||
* \param Expr A complex location expression for the variable.
|
||||
* \param DebugLoc Debug info location.
|
||||
* \param Block Basic block acting as a location for the new intrinsic.
|
||||
* \param Block Basic block acting as a location for the new record.
|
||||
*/
|
||||
LLVMValueRef LLVMDIBuilderInsertDeclareAtEnd(
|
||||
LLVMDbgRecordRef LLVMDIBuilderInsertDeclareRecordAtEnd(
|
||||
LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo,
|
||||
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block);
|
||||
|
||||
/**
|
||||
* Insert a new llvm.dbg.value intrinsic call before the given instruction.
|
||||
* Only use in "new debug format" (LLVMIsNewDbgInfoFormat() is true).
|
||||
* See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
|
||||
*
|
||||
* The debug format can be switched later after inserting the records using
|
||||
* LLVMSetIsNewDbgInfoFormat, if needed for legacy or transitionary reasons.
|
||||
*
|
||||
* Insert a new debug record before the given instruction.
|
||||
* \param Builder The DIBuilder.
|
||||
* \param Val The value of the variable.
|
||||
* \param VarInfo The variable's debug info descriptor.
|
||||
* \param Expr A complex location expression for the variable.
|
||||
* \param DebugLoc Debug info location.
|
||||
* \param Instr Instruction acting as a location for the new intrinsic.
|
||||
* \param Instr Instruction acting as a location for the new record.
|
||||
*/
|
||||
LLVMValueRef LLVMDIBuilderInsertDbgValueBefore(LLVMDIBuilderRef Builder,
|
||||
LLVMValueRef Val,
|
||||
LLVMMetadataRef VarInfo,
|
||||
LLVMMetadataRef Expr,
|
||||
LLVMMetadataRef DebugLoc,
|
||||
LLVMValueRef Instr);
|
||||
LLVMDbgRecordRef LLVMDIBuilderInsertDbgValueRecordBefore(
|
||||
LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo,
|
||||
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr);
|
||||
|
||||
/**
|
||||
* Insert a new llvm.dbg.value intrinsic call at the end of the given basic
|
||||
* block. If the basic block has a terminator instruction, the intrinsic is
|
||||
* inserted before that terminator instruction.
|
||||
* Only use in "new debug format" (LLVMIsNewDbgInfoFormat() is true).
|
||||
* See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
|
||||
*
|
||||
* The debug format can be switched later after inserting the records using
|
||||
* LLVMSetIsNewDbgInfoFormat, if needed for legacy or transitionary reasons.
|
||||
*
|
||||
* Insert a new debug record at the end of the given basic block. If the
|
||||
* basic block has a terminator instruction, the record is inserted before
|
||||
* that terminator instruction.
|
||||
* \param Builder The DIBuilder.
|
||||
* \param Val The value of the variable.
|
||||
* \param VarInfo The variable's debug info descriptor.
|
||||
* \param Expr A complex location expression for the variable.
|
||||
* \param DebugLoc Debug info location.
|
||||
* \param Block Basic block acting as a location for the new intrinsic.
|
||||
* \param Block Basic block acting as a location for the new record.
|
||||
*/
|
||||
LLVMValueRef LLVMDIBuilderInsertDbgValueAtEnd(LLVMDIBuilderRef Builder,
|
||||
LLVMValueRef Val,
|
||||
LLVMMetadataRef VarInfo,
|
||||
LLVMMetadataRef Expr,
|
||||
LLVMMetadataRef DebugLoc,
|
||||
LLVMBasicBlockRef Block);
|
||||
LLVMDbgRecordRef LLVMDIBuilderInsertDbgValueRecordAtEnd(
|
||||
LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo,
|
||||
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block);
|
||||
|
||||
/**
|
||||
* Create a new descriptor for a local auto variable.
|
||||
@@ -1384,6 +1419,52 @@ LLVMMetadataRef LLVMInstructionGetDebugLoc(LLVMValueRef Inst);
|
||||
*/
|
||||
void LLVMInstructionSetDebugLoc(LLVMValueRef Inst, LLVMMetadataRef Loc);
|
||||
|
||||
/**
|
||||
* Create a new descriptor for a label
|
||||
*
|
||||
* \param Builder The DIBuilder.
|
||||
* \param Scope The scope to create the label in.
|
||||
* \param Name Variable name.
|
||||
* \param NameLen Length of variable name.
|
||||
* \param File The file to create the label in.
|
||||
* \param LineNo Line Number.
|
||||
* \param AlwaysPreserve Preserve the label regardless of optimization.
|
||||
*
|
||||
* @see llvm::DIBuilder::createLabel()
|
||||
*/
|
||||
LLVMMetadataRef LLVMDIBuilderCreateLabel(
|
||||
LLVMDIBuilderRef Builder,
|
||||
LLVMMetadataRef Context, const char *Name, size_t NameLen,
|
||||
LLVMMetadataRef File, unsigned LineNo, LLVMBool AlwaysPreserve);
|
||||
|
||||
/**
|
||||
* Insert a new llvm.dbg.label intrinsic call
|
||||
*
|
||||
* \param Builder The DIBuilder.
|
||||
* \param LabelInfo The Label's debug info descriptor
|
||||
* \param Location The debug info location
|
||||
* \param InsertBefore Location for the new intrinsic.
|
||||
*
|
||||
* @see llvm::DIBuilder::insertLabel()
|
||||
*/
|
||||
LLVMDbgRecordRef LLVMDIBuilderInsertLabelBefore(
|
||||
LLVMDIBuilderRef Builder, LLVMMetadataRef LabelInfo,
|
||||
LLVMMetadataRef Location, LLVMValueRef InsertBefore);
|
||||
|
||||
/**
|
||||
* Insert a new llvm.dbg.label intrinsic call
|
||||
*
|
||||
* \param Builder The DIBuilder.
|
||||
* \param LabelInfo The Label's debug info descriptor
|
||||
* \param Location The debug info location
|
||||
* \param InsertAtEnd Location for the new intrinsic.
|
||||
*
|
||||
* @see llvm::DIBuilder::insertLabel()
|
||||
*/
|
||||
LLVMDbgRecordRef LLVMDIBuilderInsertLabelAtEnd(
|
||||
LLVMDIBuilderRef Builder, LLVMMetadataRef LabelInfo,
|
||||
LLVMMetadataRef Location, LLVMBasicBlockRef InsertAtEnd);
|
||||
|
||||
/**
|
||||
* Obtain the enumerated type of a Metadata instance.
|
||||
*
|
||||
|
||||
@@ -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
|
||||
@@ -79,8 +79,10 @@ int LLVMSetDisasmOptions(LLVMDisasmContextRef DC, uint64_t Options);
|
||||
#define LLVMDisassembler_Option_AsmPrinterVariant 4
|
||||
/* The option to set comment on instructions */
|
||||
#define LLVMDisassembler_Option_SetInstrComments 8
|
||||
/* The option to print latency information alongside instructions */
|
||||
/* The option to print latency information alongside instructions */
|
||||
#define LLVMDisassembler_Option_PrintLatency 16
|
||||
/* The option to print in color */
|
||||
#define LLVMDisassembler_Option_Color 32
|
||||
|
||||
/**
|
||||
* Dispose of a disassembler context.
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#ifndef LLVM_C_DISASSEMBLERTYPES_H
|
||||
#define LLVM_C_DISASSEMBLERTYPES_H
|
||||
|
||||
#include "DataTypes.h"
|
||||
#include "llvm-c/DataTypes.h"
|
||||
#ifdef __cplusplus
|
||||
#include <cstddef>
|
||||
#else
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -51,6 +51,14 @@ LLVMErrorTypeId LLVMGetErrorTypeId(LLVMErrorRef Err);
|
||||
*/
|
||||
void LLVMConsumeError(LLVMErrorRef Err);
|
||||
|
||||
/**
|
||||
* Report a fatal error if Err is a failure value.
|
||||
*
|
||||
* This function can be used to wrap calls to fallible functions ONLY when it is
|
||||
* known that the Error will always be a success value.
|
||||
*/
|
||||
void LLVMCantFail(LLVMErrorRef Err);
|
||||
|
||||
/**
|
||||
* Returns the given string's error message. This operation consumes the error,
|
||||
* and the given LLVMErrorRef value is not usable once this call returns.
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#ifndef LLVM_C_ERRORHANDLING_H
|
||||
#define LLVM_C_ERRORHANDLING_H
|
||||
|
||||
#include "ExternC.h"
|
||||
#include "llvm-c/ExternC.h"
|
||||
|
||||
LLVM_C_EXTERN_C_BEGIN
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -24,10 +24,10 @@
|
||||
#ifndef LLVM_C_LLJIT_H
|
||||
#define LLVM_C_LLJIT_H
|
||||
|
||||
#include "Error.h"
|
||||
#include "Orc.h"
|
||||
#include "TargetMachine.h"
|
||||
#include "Types.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
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#ifndef LLVM_C_LLJITUTILS_H
|
||||
#define LLVM_C_LLJITUTILS_H
|
||||
|
||||
#include "LLJIT.h"
|
||||
#include "llvm-c/LLJIT.h"
|
||||
|
||||
LLVM_C_EXTERN_C_BEGIN
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -27,9 +27,9 @@
|
||||
#ifndef LLVM_C_ORC_H
|
||||
#define LLVM_C_ORC_H
|
||||
|
||||
#include "Error.h"
|
||||
#include "TargetMachine.h"
|
||||
#include "Types.h"
|
||||
#include "llvm-c/Error.h"
|
||||
#include "llvm-c/TargetMachine.h"
|
||||
#include "llvm-c/Types.h"
|
||||
|
||||
LLVM_C_EXTERN_C_BEGIN
|
||||
|
||||
@@ -181,6 +181,15 @@ typedef struct {
|
||||
*/
|
||||
typedef LLVMOrcCDependenceMapPair *LLVMOrcCDependenceMapPairs;
|
||||
|
||||
/**
|
||||
* A set of symbols that share dependencies.
|
||||
*/
|
||||
typedef struct {
|
||||
LLVMOrcCSymbolsList Symbols;
|
||||
LLVMOrcCDependenceMapPairs Dependencies;
|
||||
size_t NumDependencies;
|
||||
} LLVMOrcCSymbolDependenceGroup;
|
||||
|
||||
/**
|
||||
* Lookup kind. This can be used by definition generators when deciding whether
|
||||
* to produce a definition for a requested symbol.
|
||||
@@ -808,6 +817,19 @@ LLVMErrorRef LLVMOrcMaterializationResponsibilityNotifyResolved(
|
||||
* that all symbols covered by this MaterializationResponsibility instance
|
||||
* have been emitted.
|
||||
*
|
||||
* This function takes ownership of the symbols in the Dependencies struct.
|
||||
* This allows the following pattern...
|
||||
*
|
||||
* LLVMOrcSymbolStringPoolEntryRef Names[] = {...};
|
||||
* LLVMOrcCDependenceMapPair Dependence = {JD, {Names, sizeof(Names)}}
|
||||
* LLVMOrcMaterializationResponsibilityAddDependencies(JD, Name, &Dependence,
|
||||
* 1);
|
||||
*
|
||||
* ... without requiring cleanup of the elements of the Names array afterwards.
|
||||
*
|
||||
* The client is still responsible for deleting the Dependencies.Names arrays,
|
||||
* and the Dependencies array itself.
|
||||
*
|
||||
* This method will return an error if any symbols being resolved have been
|
||||
* moved to the error state due to the failure of a dependency. If this
|
||||
* method returns an error then clients should log it and call
|
||||
@@ -817,7 +839,8 @@ LLVMErrorRef LLVMOrcMaterializationResponsibilityNotifyResolved(
|
||||
* LLVMErrorSuccess.
|
||||
*/
|
||||
LLVMErrorRef LLVMOrcMaterializationResponsibilityNotifyEmitted(
|
||||
LLVMOrcMaterializationResponsibilityRef MR);
|
||||
LLVMOrcMaterializationResponsibilityRef MR,
|
||||
LLVMOrcCSymbolDependenceGroup *SymbolDepGroups, size_t NumSymbolDepGroups);
|
||||
|
||||
/**
|
||||
* Attempt to claim responsibility for new definitions. This method can be
|
||||
@@ -870,38 +893,6 @@ LLVMErrorRef LLVMOrcMaterializationResponsibilityDelegate(
|
||||
LLVMOrcSymbolStringPoolEntryRef *Symbols, size_t NumSymbols,
|
||||
LLVMOrcMaterializationResponsibilityRef *Result);
|
||||
|
||||
/**
|
||||
* Adds dependencies to a symbol that the MaterializationResponsibility is
|
||||
* responsible for.
|
||||
*
|
||||
* This function takes ownership of Dependencies struct. The Names
|
||||
* array have been retained for this function. This allows the following
|
||||
* pattern...
|
||||
*
|
||||
* LLVMOrcSymbolStringPoolEntryRef Names[] = {...};
|
||||
* LLVMOrcCDependenceMapPair Dependence = {JD, {Names, sizeof(Names)}}
|
||||
* LLVMOrcMaterializationResponsibilityAddDependencies(JD, Name, &Dependence,
|
||||
* 1);
|
||||
*
|
||||
* ... without requiring cleanup of the elements of the Names array afterwards.
|
||||
*
|
||||
* The client is still responsible for deleting the Dependencies.Names array
|
||||
* itself.
|
||||
*/
|
||||
void LLVMOrcMaterializationResponsibilityAddDependencies(
|
||||
LLVMOrcMaterializationResponsibilityRef MR,
|
||||
LLVMOrcSymbolStringPoolEntryRef Name,
|
||||
LLVMOrcCDependenceMapPairs Dependencies, size_t NumPairs);
|
||||
|
||||
/**
|
||||
* Adds dependencies to all symbols that the MaterializationResponsibility is
|
||||
* responsible for. See LLVMOrcMaterializationResponsibilityAddDependencies for
|
||||
* notes about memory responsibility.
|
||||
*/
|
||||
void LLVMOrcMaterializationResponsibilityAddDependenciesForAll(
|
||||
LLVMOrcMaterializationResponsibilityRef MR,
|
||||
LLVMOrcCDependenceMapPairs Dependencies, size_t NumPairs);
|
||||
|
||||
/**
|
||||
* Create a "bare" JITDylib.
|
||||
*
|
||||
|
||||
@@ -24,11 +24,11 @@
|
||||
#ifndef LLVM_C_ORCEE_H
|
||||
#define LLVM_C_ORCEE_H
|
||||
|
||||
#include "Error.h"
|
||||
#include "ExecutionEngine.h"
|
||||
#include "Orc.h"
|
||||
#include "TargetMachine.h"
|
||||
#include "Types.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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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 */
|
||||
}
|
||||
|
||||
@@ -244,7 +244,7 @@ LLVMTypeRef LLVMIntPtrTypeInContext(LLVMContextRef C, LLVMTargetDataRef TD);
|
||||
LLVMTypeRef LLVMIntPtrTypeForASInContext(LLVMContextRef C, LLVMTargetDataRef TD,
|
||||
unsigned AS);
|
||||
|
||||
/** Computes the size of a type in bytes for a target.
|
||||
/** Computes the size of a type in bits for a target.
|
||||
See the method llvm::DataLayout::getTypeSizeInBits. */
|
||||
unsigned long long LLVMSizeOfTypeInBits(LLVMTargetDataRef TD, LLVMTypeRef Ty);
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
#ifndef LLVM_C_TRANSFORMS_PASSBUILDER_H
|
||||
#define LLVM_C_TRANSFORMS_PASSBUILDER_H
|
||||
|
||||
#include "../Error.h"
|
||||
#include "../TargetMachine.h"
|
||||
#include "../Types.h"
|
||||
#include "llvm-c/Error.h"
|
||||
#include "llvm-c/TargetMachine.h"
|
||||
#include "llvm-c/Types.h"
|
||||
|
||||
/**
|
||||
* @defgroup LLVMCCoreNewPM New Pass Manager
|
||||
@@ -50,6 +50,16 @@ LLVMErrorRef LLVMRunPasses(LLVMModuleRef M, const char *Passes,
|
||||
LLVMTargetMachineRef TM,
|
||||
LLVMPassBuilderOptionsRef Options);
|
||||
|
||||
/**
|
||||
* Construct and run a set of passes over a function.
|
||||
*
|
||||
* This function behaves the same as LLVMRunPasses, but operates on a single
|
||||
* function instead of an entire module.
|
||||
*/
|
||||
LLVMErrorRef LLVMRunPassesOnFunction(LLVMValueRef F, const char *Passes,
|
||||
LLVMTargetMachineRef TM,
|
||||
LLVMPassBuilderOptionsRef Options);
|
||||
|
||||
/**
|
||||
* Create a new set of options for a PassBuilder
|
||||
*
|
||||
@@ -72,6 +82,14 @@ void LLVMPassBuilderOptionsSetVerifyEach(LLVMPassBuilderOptionsRef Options,
|
||||
void LLVMPassBuilderOptionsSetDebugLogging(LLVMPassBuilderOptionsRef Options,
|
||||
LLVMBool DebugLogging);
|
||||
|
||||
/**
|
||||
* Specify a custom alias analysis pipeline for the PassBuilder to be used
|
||||
* instead of the default one. The string argument is not copied; the caller
|
||||
* is responsible for ensuring it outlives the PassBuilderOptions instance.
|
||||
*/
|
||||
void LLVMPassBuilderOptionsSetAAPipeline(LLVMPassBuilderOptionsRef Options,
|
||||
const char *AAPipeline);
|
||||
|
||||
void LLVMPassBuilderOptionsSetLoopInterleaving(
|
||||
LLVMPassBuilderOptionsRef Options, LLVMBool LoopInterleaving);
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -169,6 +169,11 @@ typedef struct LLVMOpaqueJITEventListener *LLVMJITEventListenerRef;
|
||||
*/
|
||||
typedef struct LLVMOpaqueBinary *LLVMBinaryRef;
|
||||
|
||||
/**
|
||||
* @see llvm::DbgRecord
|
||||
*/
|
||||
typedef struct LLVMOpaqueDbgRecord *LLVMDbgRecordRef;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -256,8 +256,10 @@ gb_internal i64 lb_sizeof(LLVMTypeRef type) {
|
||||
}
|
||||
break;
|
||||
|
||||
#if LLVM_VERSION_MAJOR < 20
|
||||
case LLVMX86_MMXTypeKind:
|
||||
return 8;
|
||||
#endif
|
||||
case LLVMVectorTypeKind:
|
||||
{
|
||||
LLVMTypeRef elem = OdinLLVMGetVectorElementType(type);
|
||||
@@ -310,8 +312,10 @@ gb_internal i64 lb_alignof(LLVMTypeRef type) {
|
||||
case LLVMArrayTypeKind:
|
||||
return lb_alignof(OdinLLVMGetArrayElementType(type));
|
||||
|
||||
#if LLVM_VERSION_MAJOR < 20
|
||||
case LLVMX86_MMXTypeKind:
|
||||
return 8;
|
||||
#endif
|
||||
case LLVMVectorTypeKind:
|
||||
{
|
||||
// TODO(bill): This appears to be correct but LLVM isn't necessarily "great" with regards to documentation
|
||||
|
||||
@@ -1591,797 +1591,7 @@ gb_internal WORKER_TASK_PROC(lb_llvm_module_pass_worker_proc) {
|
||||
LLVMPassBuilderOptionsRef pb_options = LLVMCreatePassBuilderOptions();
|
||||
defer (LLVMDisposePassBuilderOptions(pb_options));
|
||||
|
||||
switch (build_context.optimization_level) {
|
||||
case -1:
|
||||
array_add(&passes, "function(annotation-remarks)");
|
||||
break;
|
||||
case 0:
|
||||
array_add(&passes, "always-inline");
|
||||
array_add(&passes, "function(annotation-remarks)");
|
||||
break;
|
||||
case 1:
|
||||
// default<Os>
|
||||
// Passes removed: coro, openmp, sroa
|
||||
#if LLVM_VERSION_MAJOR == 17
|
||||
array_add(&passes, u8R"(
|
||||
annotation2metadata,
|
||||
forceattrs,
|
||||
inferattrs,
|
||||
function<eager-inv>(
|
||||
lower-expect,
|
||||
simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;no-switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
|
||||
early-cse<>
|
||||
),
|
||||
ipsccp,
|
||||
called-value-propagation,
|
||||
globalopt,
|
||||
function<eager-inv>(
|
||||
mem2reg,
|
||||
instcombine<max-iterations=1000;no-use-loop-info>,
|
||||
simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>
|
||||
),
|
||||
require<globals-aa>,
|
||||
function(
|
||||
invalidate<aa>
|
||||
),
|
||||
require<profile-summary>,
|
||||
cgscc(
|
||||
devirt<4>(
|
||||
inline<only-mandatory>,
|
||||
inline,
|
||||
function-attrs<skip-non-recursive>,
|
||||
function<eager-inv;no-rerun>(
|
||||
early-cse<memssa>,
|
||||
speculative-execution,
|
||||
jump-threading,
|
||||
correlated-propagation,
|
||||
simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
|
||||
instcombine<max-iterations=1000;no-use-loop-info>,
|
||||
aggressive-instcombine,
|
||||
constraint-elimination,
|
||||
tailcallelim,
|
||||
simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
|
||||
reassociate,
|
||||
loop-mssa(
|
||||
loop-instsimplify,
|
||||
loop-simplifycfg,
|
||||
licm<no-allowspeculation>,
|
||||
loop-rotate<header-duplication;no-prepare-for-lto>,
|
||||
licm<allowspeculation>,
|
||||
simple-loop-unswitch<no-nontrivial;trivial>
|
||||
),
|
||||
simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
|
||||
instcombine<max-iterations=1000;no-use-loop-info>,
|
||||
loop(
|
||||
loop-idiom,
|
||||
indvars,
|
||||
loop-deletion,
|
||||
loop-unroll-full
|
||||
),
|
||||
vector-combine,
|
||||
mldst-motion<no-split-footer-bb>,
|
||||
gvn<>,
|
||||
sccp,
|
||||
bdce,
|
||||
instcombine<max-iterations=1000;no-use-loop-info>,
|
||||
jump-threading,
|
||||
correlated-propagation,
|
||||
adce,
|
||||
memcpyopt,
|
||||
dse,
|
||||
move-auto-init,
|
||||
loop-mssa(
|
||||
licm<allowspeculation>
|
||||
),
|
||||
simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch>,
|
||||
instcombine<max-iterations=1000;no-use-loop-info>
|
||||
),
|
||||
function-attrs,
|
||||
function(
|
||||
require<should-not-run-function-passes>
|
||||
)
|
||||
)
|
||||
),
|
||||
deadargelim,
|
||||
globalopt,
|
||||
globaldce,
|
||||
elim-avail-extern,
|
||||
rpo-function-attrs,
|
||||
recompute-globalsaa,
|
||||
function<eager-inv>(
|
||||
float2int,
|
||||
lower-constant-intrinsics,
|
||||
loop(
|
||||
loop-rotate<header-duplication;no-prepare-for-lto>,
|
||||
loop-deletion
|
||||
),
|
||||
loop-distribute,
|
||||
inject-tli-mappings,
|
||||
loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,
|
||||
loop-load-elim,
|
||||
instcombine<max-iterations=1000;no-use-loop-info>,
|
||||
simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch>,
|
||||
slp-vectorizer,
|
||||
vector-combine,
|
||||
instcombine<max-iterations=1000;no-use-loop-info>,
|
||||
loop-unroll<O2>,
|
||||
transform-warning,
|
||||
instcombine<max-iterations=1000;no-use-loop-info>,
|
||||
loop-mssa(
|
||||
licm<allowspeculation>
|
||||
),
|
||||
alignment-from-assumptions,
|
||||
loop-sink,
|
||||
instsimplify,
|
||||
div-rem-pairs,
|
||||
tailcallelim,
|
||||
simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>
|
||||
),
|
||||
globaldce,
|
||||
constmerge,
|
||||
cg-profile,
|
||||
rel-lookup-table-converter,
|
||||
function(
|
||||
annotation-remarks
|
||||
),
|
||||
verify
|
||||
)");
|
||||
#else
|
||||
array_add(&passes, u8R"(
|
||||
annotation2metadata,
|
||||
forceattrs,
|
||||
inferattrs,
|
||||
function<eager-inv>(
|
||||
lower-expect,
|
||||
simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;no-switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
|
||||
sroa<modify-cfg>,
|
||||
early-cse<>
|
||||
),
|
||||
ipsccp,
|
||||
called-value-propagation,
|
||||
globalopt,
|
||||
function<eager-inv>(
|
||||
mem2reg,
|
||||
instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
|
||||
simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>
|
||||
),
|
||||
always-inline,
|
||||
require<globals-aa>,
|
||||
function(
|
||||
invalidate<aa>
|
||||
),
|
||||
require<profile-summary>,
|
||||
cgscc(
|
||||
devirt<4>(
|
||||
inline,
|
||||
function-attrs<skip-non-recursive-function-attrs>,
|
||||
function<eager-inv;no-rerun>(
|
||||
sroa<modify-cfg>,
|
||||
early-cse<memssa>,
|
||||
speculative-execution<only-if-divergent-target>,
|
||||
jump-threading,
|
||||
correlated-propagation,
|
||||
simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
|
||||
instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
|
||||
aggressive-instcombine,
|
||||
tailcallelim,
|
||||
simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
|
||||
reassociate,
|
||||
constraint-elimination,
|
||||
loop-mssa(
|
||||
loop-instsimplify,
|
||||
loop-simplifycfg,
|
||||
licm<no-allowspeculation>,
|
||||
loop-rotate<header-duplication;no-prepare-for-lto>,
|
||||
licm<allowspeculation>,
|
||||
simple-loop-unswitch<no-nontrivial;trivial>
|
||||
),
|
||||
simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
|
||||
instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
|
||||
loop(
|
||||
loop-idiom,
|
||||
indvars,
|
||||
loop-deletion,
|
||||
loop-unroll-full
|
||||
),
|
||||
sroa<modify-cfg>,
|
||||
vector-combine,
|
||||
mldst-motion<no-split-footer-bb>,
|
||||
gvn<>,
|
||||
sccp,
|
||||
bdce,
|
||||
instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
|
||||
jump-threading,
|
||||
correlated-propagation,
|
||||
adce,
|
||||
memcpyopt,
|
||||
dse,
|
||||
move-auto-init,
|
||||
loop-mssa(
|
||||
licm<allowspeculation>
|
||||
),
|
||||
simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch>,
|
||||
instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>
|
||||
),
|
||||
function-attrs,
|
||||
function(
|
||||
require<should-not-run-function-passes>
|
||||
)
|
||||
)
|
||||
),
|
||||
deadargelim,
|
||||
globalopt,
|
||||
globaldce,
|
||||
elim-avail-extern,
|
||||
rpo-function-attrs,
|
||||
recompute-globalsaa,
|
||||
function<eager-inv>(
|
||||
float2int,
|
||||
lower-constant-intrinsics,
|
||||
loop(
|
||||
loop-rotate<header-duplication;no-prepare-for-lto>,
|
||||
loop-deletion
|
||||
),
|
||||
loop-distribute,
|
||||
inject-tli-mappings,
|
||||
loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,
|
||||
infer-alignment,
|
||||
loop-load-elim,
|
||||
instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
|
||||
simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch>,
|
||||
slp-vectorizer,
|
||||
vector-combine,
|
||||
instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
|
||||
loop-unroll<O2>,
|
||||
transform-warning,
|
||||
sroa<preserve-cfg>,
|
||||
infer-alignment,
|
||||
instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
|
||||
loop-mssa(
|
||||
licm<allowspeculation>
|
||||
),
|
||||
alignment-from-assumptions,
|
||||
loop-sink,
|
||||
instsimplify,
|
||||
div-rem-pairs,
|
||||
tailcallelim,
|
||||
simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>
|
||||
),
|
||||
globaldce,
|
||||
constmerge,
|
||||
cg-profile,
|
||||
rel-lookup-table-converter,
|
||||
function(
|
||||
annotation-remarks
|
||||
),
|
||||
verify
|
||||
)");
|
||||
#endif
|
||||
break;
|
||||
// default<O2>
|
||||
// Passes removed: coro, openmp, sroa
|
||||
case 2:
|
||||
#if LLVM_VERSION_MAJOR == 17
|
||||
array_add(&passes, u8R"(
|
||||
annotation2metadata,
|
||||
forceattrs,
|
||||
inferattrs,
|
||||
function<eager-inv>(
|
||||
lower-expect,
|
||||
simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;no-switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
|
||||
early-cse<>
|
||||
),
|
||||
ipsccp,
|
||||
called-value-propagation,
|
||||
globalopt,
|
||||
function<eager-inv>(
|
||||
mem2reg,
|
||||
instcombine<max-iterations=1000;no-use-loop-info>,
|
||||
simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>
|
||||
),
|
||||
require<globals-aa>,
|
||||
function(
|
||||
invalidate<aa>
|
||||
),
|
||||
require<profile-summary>,
|
||||
cgscc(
|
||||
devirt<4>(
|
||||
inline<only-mandatory>,
|
||||
inline,
|
||||
function-attrs<skip-non-recursive>,
|
||||
function<eager-inv;no-rerun>(
|
||||
early-cse<memssa>,
|
||||
speculative-execution,
|
||||
jump-threading,
|
||||
correlated-propagation,
|
||||
simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
|
||||
instcombine<max-iterations=1000;no-use-loop-info>,
|
||||
aggressive-instcombine,
|
||||
constraint-elimination,
|
||||
libcalls-shrinkwrap,
|
||||
tailcallelim,
|
||||
simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
|
||||
reassociate,
|
||||
loop-mssa(
|
||||
loop-instsimplify,
|
||||
loop-simplifycfg,
|
||||
licm<no-allowspeculation>,
|
||||
loop-rotate<header-duplication;no-prepare-for-lto>,
|
||||
licm<allowspeculation>,
|
||||
simple-loop-unswitch<no-nontrivial;trivial>
|
||||
),
|
||||
simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
|
||||
instcombine<max-iterations=1000;no-use-loop-info>,
|
||||
loop(
|
||||
loop-idiom,
|
||||
indvars,
|
||||
loop-deletion,
|
||||
loop-unroll-full
|
||||
),
|
||||
vector-combine,
|
||||
mldst-motion<no-split-footer-bb>,
|
||||
gvn<>,
|
||||
sccp,
|
||||
bdce,
|
||||
instcombine<max-iterations=1000;no-use-loop-info>,
|
||||
jump-threading,
|
||||
correlated-propagation,
|
||||
adce,
|
||||
memcpyopt,
|
||||
dse,
|
||||
move-auto-init,
|
||||
loop-mssa(
|
||||
licm<allowspeculation>
|
||||
),
|
||||
simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch>,
|
||||
instcombine<max-iterations=1000;no-use-loop-info>
|
||||
),
|
||||
function-attrs,
|
||||
function(
|
||||
require<should-not-run-function-passes>
|
||||
)
|
||||
)
|
||||
),
|
||||
deadargelim,
|
||||
globalopt,
|
||||
globaldce,
|
||||
elim-avail-extern,
|
||||
rpo-function-attrs,
|
||||
recompute-globalsaa,
|
||||
function<eager-inv>(
|
||||
float2int,
|
||||
lower-constant-intrinsics,
|
||||
loop(
|
||||
loop-rotate<header-duplication;no-prepare-for-lto>,
|
||||
loop-deletion
|
||||
),
|
||||
loop-distribute,
|
||||
inject-tli-mappings,
|
||||
loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,
|
||||
loop-load-elim,
|
||||
instcombine<max-iterations=1000;no-use-loop-info>,
|
||||
simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch>,
|
||||
slp-vectorizer,
|
||||
vector-combine,
|
||||
instcombine<max-iterations=1000;no-use-loop-info>,
|
||||
loop-unroll<O2>,
|
||||
transform-warning,
|
||||
instcombine<max-iterations=1000;no-use-loop-info>,
|
||||
loop-mssa(
|
||||
licm<allowspeculation>
|
||||
),
|
||||
alignment-from-assumptions,
|
||||
loop-sink,
|
||||
instsimplify,
|
||||
div-rem-pairs,
|
||||
tailcallelim,
|
||||
simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>
|
||||
),
|
||||
globaldce,
|
||||
constmerge,
|
||||
cg-profile,
|
||||
rel-lookup-table-converter,
|
||||
function(
|
||||
annotation-remarks
|
||||
),
|
||||
verify
|
||||
)");
|
||||
#else
|
||||
array_add(&passes, u8R"(
|
||||
annotation2metadata,
|
||||
forceattrs,
|
||||
inferattrs,
|
||||
function<eager-inv>(
|
||||
lower-expect,
|
||||
simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;no-switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
|
||||
sroa<modify-cfg>,
|
||||
early-cse<>
|
||||
),
|
||||
ipsccp,
|
||||
called-value-propagation,
|
||||
globalopt,
|
||||
function<eager-inv>(
|
||||
mem2reg,
|
||||
instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
|
||||
simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>
|
||||
),
|
||||
always-inline,
|
||||
require<globals-aa>,
|
||||
function(
|
||||
invalidate<aa>
|
||||
),
|
||||
require<profile-summary>,
|
||||
cgscc(
|
||||
devirt<4>(
|
||||
inline,
|
||||
function-attrs<skip-non-recursive-function-attrs>,
|
||||
function<eager-inv;no-rerun>(
|
||||
sroa<modify-cfg>,
|
||||
early-cse<memssa>,
|
||||
speculative-execution<only-if-divergent-target>,
|
||||
jump-threading,
|
||||
correlated-propagation,
|
||||
simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
|
||||
instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
|
||||
aggressive-instcombine,
|
||||
libcalls-shrinkwrap,
|
||||
tailcallelim,
|
||||
simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
|
||||
reassociate,
|
||||
constraint-elimination,
|
||||
loop-mssa(
|
||||
loop-instsimplify,
|
||||
loop-simplifycfg,
|
||||
licm<no-allowspeculation>,
|
||||
loop-rotate<header-duplication;no-prepare-for-lto>,
|
||||
licm<allowspeculation>,
|
||||
simple-loop-unswitch<no-nontrivial;trivial>
|
||||
),
|
||||
simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
|
||||
instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
|
||||
loop(
|
||||
loop-idiom,
|
||||
indvars,
|
||||
loop-deletion,
|
||||
loop-unroll-full
|
||||
),
|
||||
sroa<modify-cfg>,
|
||||
vector-combine,
|
||||
mldst-motion<no-split-footer-bb>,
|
||||
gvn<>,
|
||||
sccp,
|
||||
bdce,
|
||||
instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
|
||||
jump-threading,
|
||||
correlated-propagation,
|
||||
adce,
|
||||
memcpyopt,
|
||||
dse,
|
||||
move-auto-init,
|
||||
loop-mssa(
|
||||
licm<allowspeculation>
|
||||
),
|
||||
simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch>,
|
||||
instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>
|
||||
),
|
||||
function-attrs,
|
||||
function(
|
||||
require<should-not-run-function-passes>
|
||||
)
|
||||
)
|
||||
),
|
||||
deadargelim,
|
||||
globalopt,
|
||||
globaldce,
|
||||
elim-avail-extern,
|
||||
rpo-function-attrs,
|
||||
recompute-globalsaa,
|
||||
function<eager-inv>(
|
||||
float2int,
|
||||
lower-constant-intrinsics,
|
||||
loop(
|
||||
loop-rotate<header-duplication;no-prepare-for-lto>,
|
||||
loop-deletion
|
||||
),
|
||||
loop-distribute,
|
||||
inject-tli-mappings,
|
||||
loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,
|
||||
infer-alignment,
|
||||
loop-load-elim,
|
||||
instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
|
||||
simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch>,
|
||||
slp-vectorizer,
|
||||
vector-combine,
|
||||
instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
|
||||
loop-unroll<O2>,
|
||||
transform-warning,
|
||||
sroa<modify-cfg>,
|
||||
infer-alignment,
|
||||
instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
|
||||
loop-mssa(
|
||||
licm<allowspeculation>
|
||||
),
|
||||
alignment-from-assumptions,
|
||||
loop-sink,
|
||||
instsimplify,
|
||||
div-rem-pairs,
|
||||
tailcallelim,
|
||||
simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>
|
||||
),
|
||||
globaldce,
|
||||
constmerge,
|
||||
cg-profile,
|
||||
rel-lookup-table-converter,
|
||||
function(
|
||||
annotation-remarks
|
||||
),
|
||||
verify
|
||||
)");
|
||||
#endif
|
||||
break;
|
||||
|
||||
case 3:
|
||||
// default<O3>
|
||||
// Passes removed: coro, openmp, sroa
|
||||
#if LLVM_VERSION_MAJOR == 17
|
||||
array_add(&passes, u8R"(
|
||||
annotation2metadata,
|
||||
forceattrs,
|
||||
inferattrs,
|
||||
function<eager-inv>(
|
||||
lower-expect,
|
||||
simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;no-switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
|
||||
early-cse<>,
|
||||
callsite-splitting
|
||||
),
|
||||
ipsccp,
|
||||
called-value-propagation,
|
||||
globalopt,
|
||||
function<eager-inv>(
|
||||
mem2reg,
|
||||
instcombine<max-iterations=1000;no-use-loop-info>,
|
||||
simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>
|
||||
),
|
||||
require<globals-aa>,
|
||||
function(
|
||||
invalidate<aa>
|
||||
),
|
||||
require<profile-summary>,
|
||||
cgscc(
|
||||
devirt<4>(
|
||||
inline<only-mandatory>,
|
||||
inline,
|
||||
function-attrs<skip-non-recursive>,
|
||||
argpromotion,
|
||||
function<eager-inv;no-rerun>(
|
||||
early-cse<memssa>,
|
||||
speculative-execution,
|
||||
jump-threading,
|
||||
correlated-propagation,
|
||||
simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
|
||||
instcombine<max-iterations=1000;no-use-loop-info>,
|
||||
aggressive-instcombine,
|
||||
constraint-elimination,
|
||||
libcalls-shrinkwrap,
|
||||
tailcallelim,
|
||||
simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
|
||||
reassociate,
|
||||
loop-mssa(
|
||||
loop-instsimplify,
|
||||
loop-simplifycfg,
|
||||
licm<no-allowspeculation>,
|
||||
loop-rotate<header-duplication;no-prepare-for-lto>,
|
||||
licm<allowspeculation>,
|
||||
simple-loop-unswitch<nontrivial;trivial>
|
||||
),
|
||||
simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
|
||||
instcombine<max-iterations=1000;no-use-loop-info>,
|
||||
loop(
|
||||
loop-idiom,
|
||||
indvars,
|
||||
loop-deletion,
|
||||
loop-unroll-full
|
||||
),
|
||||
vector-combine,
|
||||
mldst-motion<no-split-footer-bb>,
|
||||
gvn<>,
|
||||
sccp,
|
||||
bdce,
|
||||
instcombine<max-iterations=1000;no-use-loop-info>,
|
||||
jump-threading,
|
||||
correlated-propagation,
|
||||
adce,
|
||||
memcpyopt,
|
||||
dse,
|
||||
move-auto-init,
|
||||
loop-mssa(
|
||||
licm<allowspeculation>
|
||||
),
|
||||
simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch>,
|
||||
instcombine<max-iterations=1000;no-use-loop-info>
|
||||
),
|
||||
function-attrs,
|
||||
function(
|
||||
require<should-not-run-function-passes>
|
||||
)
|
||||
)
|
||||
),
|
||||
deadargelim,
|
||||
globalopt,
|
||||
globaldce,
|
||||
elim-avail-extern,
|
||||
rpo-function-attrs,
|
||||
recompute-globalsaa,
|
||||
function<eager-inv>(
|
||||
float2int,
|
||||
lower-constant-intrinsics,
|
||||
chr,
|
||||
loop(
|
||||
loop-rotate<header-duplication;no-prepare-for-lto>,
|
||||
loop-deletion
|
||||
),
|
||||
loop-distribute,
|
||||
inject-tli-mappings,
|
||||
loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,
|
||||
loop-load-elim,
|
||||
instcombine<max-iterations=1000;no-use-loop-info>,
|
||||
simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch>,
|
||||
slp-vectorizer,
|
||||
vector-combine,
|
||||
instcombine<max-iterations=1000;no-use-loop-info>,
|
||||
loop-unroll<O3>,
|
||||
transform-warning,
|
||||
instcombine<max-iterations=1000;no-use-loop-info>,
|
||||
loop-mssa(
|
||||
licm<allowspeculation>
|
||||
),
|
||||
alignment-from-assumptions,
|
||||
loop-sink,
|
||||
instsimplify,
|
||||
div-rem-pairs,
|
||||
tailcallelim,
|
||||
simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>
|
||||
),
|
||||
globaldce,
|
||||
constmerge,
|
||||
cg-profile,
|
||||
rel-lookup-table-converter,
|
||||
function(
|
||||
annotation-remarks
|
||||
),
|
||||
verify
|
||||
)");
|
||||
#else
|
||||
array_add(&passes, u8R"(
|
||||
annotation2metadata,
|
||||
forceattrs,
|
||||
inferattrs,
|
||||
function<eager-inv>(
|
||||
lower-expect,
|
||||
simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;no-switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
|
||||
sroa<modify-cfg>,
|
||||
early-cse<>,
|
||||
callsite-splitting
|
||||
),
|
||||
ipsccp,
|
||||
called-value-propagation,
|
||||
globalopt,
|
||||
function<eager-inv>(
|
||||
mem2reg,
|
||||
instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
|
||||
simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>
|
||||
),
|
||||
always-inline,
|
||||
require<globals-aa>,
|
||||
function(invalidate<aa>),
|
||||
require<profile-summary>,
|
||||
cgscc(
|
||||
devirt<4>(
|
||||
inline,
|
||||
function-attrs<skip-non-recursive-function-attrs>,
|
||||
argpromotion,
|
||||
function<eager-inv;no-rerun>(
|
||||
sroa<modify-cfg>,
|
||||
early-cse<memssa>,
|
||||
speculative-execution<only-if-divergent-target>,
|
||||
jump-threading,
|
||||
correlated-propagation,
|
||||
simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
|
||||
instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
|
||||
aggressive-instcombine,
|
||||
libcalls-shrinkwrap,
|
||||
tailcallelim,
|
||||
simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
|
||||
reassociate,
|
||||
constraint-elimination,
|
||||
loop-mssa(
|
||||
loop-instsimplify,
|
||||
loop-simplifycfg,
|
||||
licm<no-allowspeculation>,
|
||||
loop-rotate<header-duplication;no-prepare-for-lto>,
|
||||
licm<allowspeculation>,
|
||||
simple-loop-unswitch<nontrivial;trivial>
|
||||
),
|
||||
simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>,
|
||||
instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
|
||||
loop(
|
||||
loop-idiom,
|
||||
indvars,
|
||||
loop-deletion,
|
||||
loop-unroll-full
|
||||
),
|
||||
sroa<modify-cfg>,
|
||||
vector-combine,
|
||||
mldst-motion<no-split-footer-bb>,
|
||||
gvn<>,
|
||||
sccp,
|
||||
bdce,
|
||||
instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
|
||||
jump-threading,
|
||||
correlated-propagation,
|
||||
adce,
|
||||
memcpyopt,
|
||||
dse,
|
||||
move-auto-init,
|
||||
loop-mssa(licm<allowspeculation>),
|
||||
simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch>,
|
||||
instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>
|
||||
),
|
||||
function-attrs,
|
||||
function(
|
||||
require<should-not-run-function-passes>
|
||||
)
|
||||
)
|
||||
),
|
||||
deadargelim,
|
||||
globalopt,
|
||||
globaldce,
|
||||
elim-avail-extern,
|
||||
rpo-function-attrs,
|
||||
recompute-globalsaa,
|
||||
function<eager-inv>(
|
||||
float2int,
|
||||
lower-constant-intrinsics,
|
||||
chr,
|
||||
loop(
|
||||
loop-rotate<header-duplication;no-prepare-for-lto>,
|
||||
loop-deletion
|
||||
),
|
||||
loop-distribute,
|
||||
inject-tli-mappings,
|
||||
loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,
|
||||
infer-alignment,
|
||||
loop-load-elim,
|
||||
instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
|
||||
simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch>,
|
||||
slp-vectorizer,
|
||||
vector-combine,
|
||||
instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
|
||||
loop-unroll<O3>,
|
||||
transform-warning,
|
||||
sroa<preserve-cfg>,
|
||||
infer-alignment,
|
||||
instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,
|
||||
loop-mssa(licm<allowspeculation>),
|
||||
alignment-from-assumptions,
|
||||
loop-sink,
|
||||
instsimplify,
|
||||
div-rem-pairs,
|
||||
tailcallelim,
|
||||
simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch>
|
||||
),
|
||||
globaldce,
|
||||
constmerge,
|
||||
cg-profile,
|
||||
rel-lookup-table-converter,
|
||||
function(
|
||||
annotation-remarks
|
||||
),
|
||||
verify
|
||||
)");
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
#include "llvm_backend_passes.cpp"
|
||||
|
||||
// asan - Linux, Darwin, Windows
|
||||
// msan - linux
|
||||
@@ -2591,7 +1801,7 @@ gb_internal String lb_filepath_obj_for_module(lbModule *m) {
|
||||
path = gb_string_appendc(path, "/");
|
||||
path = gb_string_append_length(path, name.text, name.len);
|
||||
|
||||
{
|
||||
if (USE_SEPARATE_MODULES) {
|
||||
GB_ASSERT(m->module_name != nullptr);
|
||||
String s = make_string_c(m->module_name);
|
||||
String prefix = str_lit("odin_package");
|
||||
@@ -2958,13 +2168,16 @@ gb_internal bool lb_generate_code(lbGenerator *gen) {
|
||||
LLVMInitializeWebAssemblyAsmParser();
|
||||
LLVMInitializeWebAssemblyDisassembler();
|
||||
break;
|
||||
case TargetArch_riscv64:
|
||||
LLVMInitializeRISCVTargetInfo();
|
||||
LLVMInitializeRISCVTarget();
|
||||
LLVMInitializeRISCVTargetMC();
|
||||
LLVMInitializeRISCVAsmPrinter();
|
||||
LLVMInitializeRISCVAsmParser();
|
||||
LLVMInitializeRISCVDisassembler();
|
||||
break;
|
||||
default:
|
||||
LLVMInitializeAllTargetInfos();
|
||||
LLVMInitializeAllTargets();
|
||||
LLVMInitializeAllTargetMCs();
|
||||
LLVMInitializeAllAsmPrinters();
|
||||
LLVMInitializeAllAsmParsers();
|
||||
LLVMInitializeAllDisassemblers();
|
||||
GB_PANIC("Unimplemented LLVM target initialization");
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -1085,7 +1085,12 @@ gb_internal void lb_add_debug_local_variable(lbProcedure *p, LLVMValueRef ptr, T
|
||||
LLVMMetadataRef llvm_debug_loc = lb_debug_location_from_token_pos(p, token.pos);
|
||||
LLVMMetadataRef llvm_expr = LLVMDIBuilderCreateExpression(m->debug_builder, nullptr, 0);
|
||||
lb_set_llvm_metadata(m, ptr, llvm_expr);
|
||||
|
||||
#if LLVM_VERSION_MAJOR <= 18
|
||||
LLVMDIBuilderInsertDeclareAtEnd(m->debug_builder, storage, var_info, llvm_expr, llvm_debug_loc, block);
|
||||
#else
|
||||
LLVMDIBuilderInsertDbgValueRecordAtEnd(m->debug_builder, storage, var_info, llvm_expr, llvm_debug_loc, block);
|
||||
#endif
|
||||
}
|
||||
|
||||
gb_internal void lb_add_debug_param_variable(lbProcedure *p, LLVMValueRef ptr, Type *type, Token const &token, unsigned arg_number, lbBlock *block) {
|
||||
|
||||
@@ -2145,6 +2145,12 @@ gb_internal lbValue lb_emit_conv(lbProcedure *p, lbValue value, Type *t) {
|
||||
}
|
||||
}
|
||||
for (Type *vt : dst->Union.variants) {
|
||||
if (src_type == t_llvm_bool && is_type_boolean(vt)) {
|
||||
value = lb_emit_conv(p, value, vt);
|
||||
lbAddr parent = lb_add_local_generated(p, t, true);
|
||||
lb_emit_store_union_variant(p, parent.addr, value, vt);
|
||||
return lb_addr_load(p, parent);
|
||||
}
|
||||
if (are_types_identical(src_type, vt)) {
|
||||
lbAddr parent = lb_add_local_generated(p, t, true);
|
||||
lb_emit_store_union_variant(p, parent.addr, value, vt);
|
||||
|
||||
1195
src/llvm_backend_passes.cpp
Normal file
1195
src/llvm_backend_passes.cpp
Normal file
File diff suppressed because it is too large
Load Diff
@@ -3621,6 +3621,7 @@ gb_internal lbValue lb_build_call_expr_internal(lbProcedure *p, Ast *expr) {
|
||||
GB_ASSERT(ce->args.count == 1);
|
||||
lbValue x = lb_build_expr(p, ce->args[0]);
|
||||
lbValue y = lb_emit_conv(p, x, tv.type);
|
||||
y.type = tv.type;
|
||||
return y;
|
||||
}
|
||||
|
||||
|
||||
@@ -1938,7 +1938,11 @@ gb_internal void lb_build_type_switch_stmt(lbProcedure *p, AstTypeSwitchStmt *ss
|
||||
lb_add_entity(p->module, case_entity, ptr);
|
||||
lb_add_debug_local_variable(p, ptr.value, case_entity->type, case_entity->token);
|
||||
} else {
|
||||
lb_store_type_case_implicit(p, clause, parent_value, false);
|
||||
if (by_reference) {
|
||||
lb_store_type_case_implicit(p, clause, parent_ptr, false);
|
||||
} else {
|
||||
lb_store_type_case_implicit(p, clause, parent_value, false);
|
||||
}
|
||||
}
|
||||
|
||||
lb_type_case_body(p, ss->label, clause, body, done);
|
||||
|
||||
@@ -2112,11 +2112,10 @@ gb_internal lbAddr lb_handle_objc_find_or_register_selector(lbProcedure *p, Stri
|
||||
}
|
||||
|
||||
if (!entity) {
|
||||
gbString global_name = gb_string_make(temporary_allocator(), "__$objc_SEL$");
|
||||
gbString global_name = gb_string_make(temporary_allocator(), "__$objc_SEL::");
|
||||
global_name = gb_string_append_length(global_name, name.text, name.len);
|
||||
|
||||
lbAddr default_addr = lb_add_global_generated_with_name(
|
||||
default_module, t_objc_SEL, {},
|
||||
lbAddr default_addr = lb_add_global_generated_with_name(default_module, t_objc_SEL, {},
|
||||
make_string(cast(u8 const *)global_name, gb_string_length(global_name)),
|
||||
&entity);
|
||||
string_map_set(&default_module->objc_selectors, name, lbObjcRef{entity, default_addr});
|
||||
@@ -2175,7 +2174,7 @@ gb_internal lbAddr lb_handle_objc_find_or_register_class(lbProcedure *p, String
|
||||
}
|
||||
|
||||
if (!entity) {
|
||||
gbString global_name = gb_string_make(temporary_allocator(), "__$objc_Class$");
|
||||
gbString global_name = gb_string_make(temporary_allocator(), "__$objc_Class::");
|
||||
global_name = gb_string_append_length(global_name, name.text, name.len);
|
||||
|
||||
lbAddr default_addr = lb_add_global_generated_with_name(default_module, t_objc_Class, {},
|
||||
|
||||
@@ -756,7 +756,7 @@ gb_internal void futex_signal(Futex *f) {
|
||||
|
||||
perror("Futex wake");
|
||||
GB_PANIC("futex wake fail");
|
||||
} else if (ret == 1) {
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -773,7 +773,7 @@ gb_internal void futex_broadcast(Futex *f) {
|
||||
|
||||
perror("Futex wake");
|
||||
GB_PANIC("futex wake fail");
|
||||
} else if (ret == 1) {
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -783,7 +783,7 @@ gb_internal void futex_wait(Futex *f, Footex val) {
|
||||
for (;;) {
|
||||
int ret = futex((volatile uint32_t *)f, FUTEX_WAIT | FUTEX_PRIVATE_FLAG, val, NULL, NULL);
|
||||
if (ret == -1) {
|
||||
if (*f != val) {
|
||||
if (errno == EAGAIN) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
33
vendor/libc/ctype.odin
vendored
Normal file
33
vendor/libc/ctype.odin
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
package odin_libc
|
||||
|
||||
@(require, linkage="strong", link_name="isdigit")
|
||||
isdigit :: proc "c" (c: i32) -> b32 {
|
||||
switch c {
|
||||
case '0'..='9': return true
|
||||
case: return false
|
||||
}
|
||||
}
|
||||
|
||||
@(require, linkage="strong", link_name="isblank")
|
||||
isblank :: proc "c" (c: i32) -> b32 {
|
||||
switch c {
|
||||
case '\t', ' ': return true
|
||||
case: return false
|
||||
}
|
||||
}
|
||||
|
||||
@(require, linkage="strong", link_name="isspace")
|
||||
isspace :: proc "c" (c: i32) -> b32 {
|
||||
switch c {
|
||||
case '\t', ' ', '\n', '\v', '\f', '\r': return true
|
||||
case: return false
|
||||
}
|
||||
}
|
||||
|
||||
@(require, linkage="strong", link_name="toupper")
|
||||
toupper :: proc "c" (c: i32) -> i32 {
|
||||
if c >= 'a' && c <= 'z' {
|
||||
return c - ('a' - 'A')
|
||||
}
|
||||
return c
|
||||
}
|
||||
21
vendor/libc/include/alloca.h
vendored
Normal file
21
vendor/libc/include/alloca.h
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
void *alloca(size_t); /* built-in for gcc */
|
||||
|
||||
#if defined(__GNUC__) && __GNUC__ >= 3
|
||||
/* built-in for gcc 3 */
|
||||
#undef alloca
|
||||
#undef __alloca
|
||||
#define alloca(size) __alloca(size)
|
||||
#define __alloca(size) __builtin_alloca(size)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
12
vendor/libc/include/assert.h
vendored
12
vendor/libc/include/assert.h
vendored
@@ -1,3 +1,9 @@
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef NDEBUG
|
||||
#define assert(e) ((void)0)
|
||||
#else
|
||||
@@ -14,3 +20,9 @@ void __odin_libc_assert_fail(const char *, const char *, int, const char *);
|
||||
(__builtin_expect(!(e), 0) ? __odin_libc_assert_fail(__func__, __ASSERT_FILE_NAME, __LINE__, #e) : (void)0)
|
||||
|
||||
#endif /* NDEBUG */
|
||||
|
||||
#define static_assert _Static_assert
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
15
vendor/libc/include/ctype.h
vendored
Normal file
15
vendor/libc/include/ctype.h
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#pragma once
|
||||
|
||||
int isdigit(int c);
|
||||
int isblank(int c);
|
||||
int isspace(int c);
|
||||
|
||||
int toupper(int c);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
0
vendor/libc/include/inttypes.h
vendored
Normal file
0
vendor/libc/include/inttypes.h
vendored
Normal file
49
vendor/libc/include/math.h
vendored
49
vendor/libc/include/math.h
vendored
@@ -1,21 +1,66 @@
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#define INFINITY (1.0 / 0.0)
|
||||
#define NAN (0.0 / 0.0)
|
||||
|
||||
float sqrtf(float);
|
||||
float cosf(float);
|
||||
float sinf(float);
|
||||
float atan2f(float, float);
|
||||
bool isnan(float);
|
||||
bool isinf(float);
|
||||
|
||||
float floorf(float x);
|
||||
double floor(double x);
|
||||
float ceilf(float x);
|
||||
double ceil(double x);
|
||||
double sqrt(double x);
|
||||
float powf(float x, float y);
|
||||
double pow(double x, double y);
|
||||
float fmodf(float x, float y);
|
||||
double fmod(double x, double y);
|
||||
double cos(double x);
|
||||
float acosf(float x);
|
||||
double acos(double x);
|
||||
float fabsf(float x);
|
||||
double fabs(double x);
|
||||
int abs(int);
|
||||
double ldexp(double, int);
|
||||
double exp(double);
|
||||
float logf(float);
|
||||
double log(double);
|
||||
double sin(double);
|
||||
double trunc(double);
|
||||
double log2(double);
|
||||
double log10(double);
|
||||
double asin(double);
|
||||
double atan(double);
|
||||
double tan(double);
|
||||
double atan2(double, double);
|
||||
double modf(double, double*);
|
||||
|
||||
bool __isnanf(float);
|
||||
bool __isnand(double);
|
||||
#define isnan(x) \
|
||||
( sizeof(x) == sizeof(float) ? __isnanf((float)(x)) \
|
||||
: : __isnand((double)(x)))
|
||||
|
||||
bool __isinff(float);
|
||||
bool __isinfd(double);
|
||||
#define isinf(x) \
|
||||
( sizeof(x) == sizeof(float) ? __isinff((float)(x)) \
|
||||
: : __isinfd((double)(x)))
|
||||
|
||||
bool __isfinitef(float);
|
||||
bool __isfinited(double);
|
||||
#define isfinite(x) \
|
||||
( sizeof(x) == sizeof(float) ? __isfinitef((float)(x)) \
|
||||
: : __isfinited((double)(x)))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
58
vendor/libc/include/stdio.h
vendored
58
vendor/libc/include/stdio.h
vendored
@@ -1,8 +1,14 @@
|
||||
#include <stddef.h>
|
||||
#include <stdarg.h>
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <alloca.h>
|
||||
#include <assert.h>
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
|
||||
typedef struct {} FILE;
|
||||
|
||||
#define SEEK_SET 0
|
||||
@@ -12,6 +18,8 @@ typedef struct {} FILE;
|
||||
#define stdout ((FILE *)2)
|
||||
#define stderr ((FILE *)3)
|
||||
|
||||
#define EOF -1
|
||||
|
||||
FILE *fopen(const char *, char *);
|
||||
int fclose(FILE *);
|
||||
int fseek(FILE *, long, int);
|
||||
@@ -21,6 +29,10 @@ size_t fwrite(const void *, size_t, size_t, FILE *);
|
||||
|
||||
int vfprintf(FILE *, const char *, va_list);
|
||||
int vsnprintf(char *, size_t, const char *, va_list);
|
||||
int vsprintf(char *, const char *, va_list);
|
||||
|
||||
int putchar(int ch);
|
||||
int getchar();
|
||||
|
||||
static inline int snprintf(char *buf, size_t size, const char *fmt, ...) {
|
||||
va_list args;
|
||||
@@ -30,6 +42,14 @@ static inline int snprintf(char *buf, size_t size, const char *fmt, ...) {
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline int sprintf(char *buf, const char *fmt, ...) {
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
int result = vsprintf(buf, fmt, args);
|
||||
va_end(args);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline int fprintf(FILE *f, const char *fmt, ...) {
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
@@ -45,3 +65,37 @@ static inline int printf(const char *fmt, ...) {
|
||||
va_end(args);
|
||||
return result;
|
||||
}
|
||||
|
||||
int __sscanf(const char *str, const char *format, void *ptrs);
|
||||
|
||||
static inline int vsscanf(const char *str, const char *format, va_list ap) {
|
||||
int count = 0;
|
||||
for (int i = 0; format[i]; i++) {
|
||||
if (format[i] == '%') {
|
||||
if (format[i+1] == '%') {
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
void **ptrs = (void **)(alloca(count*sizeof(void *)));
|
||||
for (int i = 0; i < count; i++) {
|
||||
ptrs[i] = va_arg(ap, void *);
|
||||
}
|
||||
|
||||
return __sscanf(str, format, ptrs);
|
||||
}
|
||||
|
||||
static inline int sscanf(const char *str, const char *format, ...) {
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
int res = vsscanf(str, format, args);
|
||||
va_end(args);
|
||||
return res;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
25
vendor/libc/include/stdlib.h
vendored
25
vendor/libc/include/stdlib.h
vendored
@@ -1,3 +1,9 @@
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
void *malloc(size_t size);
|
||||
@@ -17,3 +23,22 @@ long long atoll(const char *);
|
||||
double atof(const char *);
|
||||
|
||||
long strtol(const char *, char **, int);
|
||||
double strtod(const char *, char **);
|
||||
|
||||
void abort();
|
||||
void exit(int exit_code);
|
||||
|
||||
#define ATEXIT_MAX 32
|
||||
|
||||
int atexit(typeof(void (void)) *);
|
||||
|
||||
typedef struct {
|
||||
long int quot;
|
||||
long int rem;
|
||||
} ldiv_t;
|
||||
|
||||
ldiv_t ldiv(long int number, long int denom);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
11
vendor/libc/include/string.h
vendored
11
vendor/libc/include/string.h
vendored
@@ -1,9 +1,16 @@
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
void *memcpy(void *, const void *, size_t);
|
||||
void *memset(void *, int, size_t);
|
||||
void *memmove(void *, void *, size_t);
|
||||
int memcmp(const void *, const void *, size_t);
|
||||
void *memchr(const void *, int, size_t);
|
||||
|
||||
unsigned long strlen(const char *str);
|
||||
|
||||
@@ -19,3 +26,7 @@ int strcmp(const char *, const char *);
|
||||
int strncmp(const char *, const char *, size_t);
|
||||
|
||||
char *strstr(const char *, const char *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
16
vendor/libc/include/time.h
vendored
Normal file
16
vendor/libc/include/time.h
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef int64_t clock_t;
|
||||
typedef clock_t time_t;
|
||||
|
||||
clock_t clock();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
124
vendor/libc/math.odin
vendored
124
vendor/libc/math.odin
vendored
@@ -14,23 +14,28 @@ cosf :: proc "c" (v: f32) -> f32 {
|
||||
return math.cos(v)
|
||||
}
|
||||
|
||||
@(require, linkage="strong", link_name="sinf")
|
||||
sinf :: proc "c" (v: f32) -> f32 {
|
||||
return math.sin(v)
|
||||
}
|
||||
|
||||
@(require, linkage="strong", link_name="atan2f")
|
||||
atan2f :: proc "c" (v: f32, v2: f32) -> f32 {
|
||||
return math.atan2(v, v2)
|
||||
}
|
||||
|
||||
@(require, linkage="strong", link_name="isnan")
|
||||
isnan :: proc "c" (v: f32) -> bool {
|
||||
@(require, linkage="strong", link_name="__isnanf")
|
||||
isnanf :: proc "c" (v: f32) -> bool {
|
||||
return math.is_nan(v)
|
||||
}
|
||||
|
||||
@(require, linkage="strong", link_name="isinf")
|
||||
isinf :: proc "c" (v: f32) -> bool {
|
||||
@(require, linkage="strong", link_name="__isnand")
|
||||
isnand :: proc "c" (v: f64) -> bool {
|
||||
return math.is_nan(v)
|
||||
}
|
||||
|
||||
@(require, linkage="strong", link_name="__isinff")
|
||||
isinff :: proc "c" (v: f32) -> bool {
|
||||
return math.is_inf(v)
|
||||
}
|
||||
|
||||
@(require, linkage="strong", link_name="__isinfd")
|
||||
isinfd :: proc "c" (v: f64) -> bool {
|
||||
return math.is_inf(v)
|
||||
}
|
||||
|
||||
@@ -39,21 +44,41 @@ sqrt :: proc "c" (x: f64) -> f64 {
|
||||
return math.sqrt(x)
|
||||
}
|
||||
|
||||
@(require, linkage="strong", link_name="floorf")
|
||||
floorf :: proc "c" (x: f32) -> f32 {
|
||||
return math.floor(x)
|
||||
}
|
||||
|
||||
@(require, linkage="strong", link_name="floor")
|
||||
floor :: proc "c" (x: f64) -> f64 {
|
||||
return math.floor(x)
|
||||
}
|
||||
|
||||
@(require, linkage="strong", link_name="ceilf")
|
||||
ceilf :: proc "c" (x: f32) -> f32 {
|
||||
return math.ceil(x)
|
||||
}
|
||||
|
||||
@(require, linkage="strong", link_name="ceil")
|
||||
ceil :: proc "c" (x: f64) -> f64 {
|
||||
return math.ceil(x)
|
||||
}
|
||||
|
||||
@(require, linkage="strong", link_name="powf")
|
||||
powf :: proc "c" (x, y: f32) -> f32 {
|
||||
return math.pow(x, y)
|
||||
}
|
||||
|
||||
@(require, linkage="strong", link_name="pow")
|
||||
pow :: proc "c" (x, y: f64) -> f64 {
|
||||
return math.pow(x, y)
|
||||
}
|
||||
|
||||
@(require, linkage="strong", link_name="fmodf")
|
||||
fmodf :: proc "c" (x, y: f32) -> f32 {
|
||||
return math.mod(x, y)
|
||||
}
|
||||
|
||||
@(require, linkage="strong", link_name="fmod")
|
||||
fmod :: proc "c" (x, y: f64) -> f64 {
|
||||
return math.mod(x, y)
|
||||
@@ -64,11 +89,21 @@ cos :: proc "c" (x: f64) -> f64 {
|
||||
return math.cos(x)
|
||||
}
|
||||
|
||||
@(require, linkage="strong", link_name="acosf")
|
||||
acosf :: proc "c" (x: f32) -> f32 {
|
||||
return math.acos(x)
|
||||
}
|
||||
|
||||
@(require, linkage="strong", link_name="acos")
|
||||
acos :: proc "c" (x: f64) -> f64 {
|
||||
return math.acos(x)
|
||||
}
|
||||
|
||||
@(require, linkage="strong", link_name="fabsf")
|
||||
fabsf :: proc "c" (x: f32) -> f32 {
|
||||
return math.abs(x)
|
||||
}
|
||||
|
||||
@(require, linkage="strong", link_name="fabs")
|
||||
fabs :: proc "c" (x: f64) -> f64 {
|
||||
return math.abs(x)
|
||||
@@ -89,6 +124,11 @@ exp :: proc "c" (x: f64) -> f64 {
|
||||
return math.exp(x)
|
||||
}
|
||||
|
||||
@(require, linkage="strong", link_name="logf")
|
||||
logf :: proc "c" (x: f32) -> f32 {
|
||||
return math.ln(x)
|
||||
}
|
||||
|
||||
@(require, linkage="strong", link_name="log")
|
||||
log :: proc "c" (x: f64) -> f64 {
|
||||
return math.ln(x)
|
||||
@@ -98,3 +138,69 @@ log :: proc "c" (x: f64) -> f64 {
|
||||
sin :: proc "c" (x: f64) -> f64 {
|
||||
return math.sin(x)
|
||||
}
|
||||
|
||||
@(require, linkage="strong", link_name="sinf")
|
||||
sinf :: proc "c" (v: f32) -> f32 {
|
||||
return math.sin(v)
|
||||
}
|
||||
|
||||
|
||||
@(require, linkage="strong", link_name="trunc")
|
||||
trunc :: proc "c" (x: f64) -> f64 {
|
||||
return math.trunc(x)
|
||||
}
|
||||
|
||||
@(require, linkage="strong", link_name="__isfinitef")
|
||||
isfinitef :: proc "c" (x: f32) -> bool {
|
||||
switch math.classify(x) {
|
||||
case .Normal, .Subnormal, .Zero, .Neg_Zero: return true
|
||||
case .Inf, .Neg_Inf, .NaN: return false
|
||||
case: unreachable()
|
||||
}
|
||||
}
|
||||
|
||||
@(require, linkage="strong", link_name="__isfinited")
|
||||
isfinited :: proc "c" (x: f64) -> bool {
|
||||
switch math.classify(x) {
|
||||
case .Normal, .Subnormal, .Zero, .Neg_Zero: return true
|
||||
case .Inf, .Neg_Inf, .NaN: return false
|
||||
case: unreachable()
|
||||
}
|
||||
}
|
||||
|
||||
@(require, linkage="strong", link_name="log2")
|
||||
log2 :: proc "c" (x: f64) -> f64 {
|
||||
return math.log2(x)
|
||||
}
|
||||
|
||||
@(require, linkage="strong", link_name="log10")
|
||||
log10 :: proc "c" (x: f64) -> f64 {
|
||||
return math.log10(x)
|
||||
}
|
||||
|
||||
@(require, linkage="strong", link_name="asin")
|
||||
asin :: proc "c" (x: f64) -> f64 {
|
||||
return math.asin(x)
|
||||
}
|
||||
|
||||
@(require, linkage="strong", link_name="atan")
|
||||
atan :: proc "c" (x: f64) -> f64 {
|
||||
return math.atan(x)
|
||||
}
|
||||
|
||||
@(require, linkage="strong", link_name="tan")
|
||||
tan :: proc "c" (x: f64) -> f64 {
|
||||
return math.tan(x)
|
||||
}
|
||||
|
||||
@(require, linkage="strong", link_name="atan2")
|
||||
atan2 :: proc "c" (y: f64, x: f64) -> f64 {
|
||||
return math.atan2(y, x)
|
||||
}
|
||||
|
||||
@(require, linkage="strong", link_name="modf")
|
||||
modf :: proc "c" (num: f64, iptr: ^f64) -> f64 {
|
||||
integral, fractional := math.modf(num)
|
||||
iptr^ = integral
|
||||
return fractional
|
||||
}
|
||||
|
||||
413
vendor/libc/stdio.odin
vendored
413
vendor/libc/stdio.odin
vendored
@@ -1,18 +1,23 @@
|
||||
#+build !freestanding
|
||||
package odin_libc
|
||||
|
||||
import "base:runtime"
|
||||
|
||||
import "core:c"
|
||||
import "core:io"
|
||||
import "core:os"
|
||||
import "core:strconv"
|
||||
|
||||
import stb "vendor:stb/sprintf"
|
||||
|
||||
FILE :: uintptr
|
||||
|
||||
EOF :: -1
|
||||
|
||||
@(require, linkage="strong", link_name="fopen")
|
||||
fopen :: proc "c" (path: cstring, mode: cstring) -> FILE {
|
||||
context = g_ctx
|
||||
unimplemented("odin_libc.fopen")
|
||||
unimplemented("vendor/libc: fopen")
|
||||
}
|
||||
|
||||
@(require, linkage="strong", link_name="fseek")
|
||||
@@ -63,6 +68,31 @@ fwrite :: proc "c" (buffer: [^]byte, size: uint, count: uint, file: FILE) -> uin
|
||||
return uint(max(0, n))
|
||||
}
|
||||
|
||||
@(require, linkage="strong", link_name="putchar")
|
||||
putchar :: proc "c" (char: c.int) -> c.int {
|
||||
context = g_ctx
|
||||
|
||||
n, err := os.write_byte(os.stdout, byte(char))
|
||||
if n == 0 || err != nil {
|
||||
return EOF
|
||||
}
|
||||
return char
|
||||
}
|
||||
|
||||
@(require, linkage="strong", link_name="getchar")
|
||||
getchar :: proc "c" () -> c.int {
|
||||
when #defined(os.stdin) {
|
||||
ret: [1]byte
|
||||
n, err := os.read(os.stdin, ret[:])
|
||||
if n == 0 || err != nil {
|
||||
return EOF
|
||||
}
|
||||
return c.int(ret[0])
|
||||
} else {
|
||||
return EOF
|
||||
}
|
||||
}
|
||||
|
||||
@(require, linkage="strong", link_name="vsnprintf")
|
||||
vsnprintf :: proc "c" (buf: [^]byte, count: uint, fmt: cstring, args: ^c.va_list) -> i32 {
|
||||
i32_count := i32(count)
|
||||
@@ -70,6 +100,11 @@ vsnprintf :: proc "c" (buf: [^]byte, count: uint, fmt: cstring, args: ^c.va_list
|
||||
return stb.vsnprintf(buf, i32_count, fmt, args)
|
||||
}
|
||||
|
||||
@(require, linkage="strong", link_name="vsprintf")
|
||||
vsprintf :: proc "c" (buf: [^]byte, fmt: cstring, args: ^c.va_list) -> i32 {
|
||||
return stb.vsprintf(buf, fmt, args)
|
||||
}
|
||||
|
||||
@(require, linkage="strong", link_name="vfprintf")
|
||||
vfprintf :: proc "c" (file: FILE, fmt: cstring, args: ^c.va_list) -> i32 {
|
||||
context = g_ctx
|
||||
@@ -105,3 +140,379 @@ vfprintf :: proc "c" (file: FILE, fmt: cstring, args: ^c.va_list) -> i32 {
|
||||
|
||||
return i32(len(buf))
|
||||
}
|
||||
|
||||
/*
|
||||
Derived from musl libc - MIT licensed - Copyright © 2005-2020 Rich Felker, et al.
|
||||
*/
|
||||
@(require, linkage="strong", link_name="__sscanf")
|
||||
_sscanf :: proc "c" (str, fmt: [^]byte, orig_ptrs: [^]rawptr) -> i32 {
|
||||
Size :: enum u8 {
|
||||
None,
|
||||
hh,
|
||||
h,
|
||||
l,
|
||||
L,
|
||||
ll,
|
||||
}
|
||||
|
||||
store_int :: proc(dest: rawptr, size: Size, i: u64) {
|
||||
if dest == nil { return }
|
||||
#partial switch size {
|
||||
case .hh:
|
||||
(^c.char)(dest)^ = c.char(i)
|
||||
case .h:
|
||||
(^c.short)(dest)^ = c.short(i)
|
||||
case .None:
|
||||
(^c.int)(dest)^ = c.int(i)
|
||||
case .l:
|
||||
(^c.long)(dest)^ = c.long(i)
|
||||
case .ll:
|
||||
(^c.longlong)(dest)^ = c.longlong(i)
|
||||
}
|
||||
}
|
||||
|
||||
context = g_ctx
|
||||
|
||||
str := str
|
||||
ptrs := orig_ptrs
|
||||
|
||||
// TODO: implement wide char variants
|
||||
|
||||
pos: u64
|
||||
dest: rawptr
|
||||
ch, t: byte
|
||||
// wcs: [^]c.wchar_t
|
||||
s: [^]byte
|
||||
k, i, width: int
|
||||
alloc: bool
|
||||
scanset: [257]byte
|
||||
invert: u8
|
||||
matches: i32
|
||||
size: Size
|
||||
input_fail, match_fail, fmt_fail, alloc_fail: bool
|
||||
|
||||
main_loop: for p := fmt; p[0] != 0; p = p[1:] {
|
||||
alloc = false
|
||||
|
||||
if isspace(i32(p[0])) {
|
||||
for isspace(i32(p[0])) {
|
||||
p = p[1:]
|
||||
}
|
||||
for isspace(i32(str[0])) {
|
||||
str = str[1:]
|
||||
pos += 1
|
||||
}
|
||||
}
|
||||
|
||||
if p[0] != '%' || p[1] == '%' {
|
||||
if p[0] == '%' {
|
||||
p = p[1:]
|
||||
}
|
||||
ch = str[0]
|
||||
if ch != p[0] {
|
||||
if ch == 0 {
|
||||
input_fail = true
|
||||
break
|
||||
}
|
||||
match_fail = true
|
||||
break
|
||||
}
|
||||
pos += 1
|
||||
continue
|
||||
}
|
||||
|
||||
p = p[1:]
|
||||
if p[0] == '*' {
|
||||
dest = nil
|
||||
p = p[1:]
|
||||
} else if isdigit(i32(p[0])) && p[1] == '$' {
|
||||
dest = orig_ptrs[p[0] - '0']
|
||||
p = p[2:]
|
||||
} else {
|
||||
dest = ptrs[0]
|
||||
ptrs = ptrs[1:]
|
||||
}
|
||||
|
||||
for width = 0; isdigit(i32(p[0])); p = p[1:] {
|
||||
width = 10 * width + int(p[0] - '0')
|
||||
}
|
||||
|
||||
if p[0] == 'm' {
|
||||
// wcs = nil
|
||||
s = nil
|
||||
alloc = dest != nil
|
||||
p = p[1:]
|
||||
} else {
|
||||
alloc = false
|
||||
}
|
||||
|
||||
size = .None
|
||||
p = p[1:]
|
||||
switch p[-1] {
|
||||
case 'h':
|
||||
size = .h
|
||||
if p[0] == 'h' {
|
||||
p = p[1:]
|
||||
size = .hh
|
||||
}
|
||||
case 'l':
|
||||
size = .l
|
||||
if p[0] == 'l' {
|
||||
p = p[1:]
|
||||
size = .ll
|
||||
}
|
||||
case 'j':
|
||||
size = .ll
|
||||
case 'z', 't':
|
||||
size = .l
|
||||
case 'L':
|
||||
size = .L
|
||||
case 'd', 'i', 'o', 'u', 'x',
|
||||
'a', 'e', 'f', 'g',
|
||||
'A', 'E', 'F', 'G', 'X',
|
||||
's', 'c', '[',
|
||||
'S', 'C', 'p', 'n':
|
||||
p = p[-1:]
|
||||
case:
|
||||
fmt_fail = true
|
||||
break main_loop
|
||||
}
|
||||
|
||||
t = p[0]
|
||||
|
||||
switch t {
|
||||
case 'C':
|
||||
t = 'c'
|
||||
size = .l
|
||||
case 'S':
|
||||
t = 's'
|
||||
size = .l
|
||||
}
|
||||
|
||||
switch t {
|
||||
case 'c':
|
||||
if width < 1 {
|
||||
width = 1
|
||||
}
|
||||
case '[':
|
||||
case 'n':
|
||||
store_int(dest, size, pos)
|
||||
continue
|
||||
case:
|
||||
for isspace(i32(str[0])) {
|
||||
str = str[1:]
|
||||
pos += 1
|
||||
}
|
||||
}
|
||||
|
||||
if str[0] == 0 {
|
||||
input_fail = true
|
||||
break
|
||||
}
|
||||
|
||||
if width == 0 {
|
||||
width = max(int)
|
||||
}
|
||||
|
||||
switch t {
|
||||
case 's', 'c', '[':
|
||||
if t == 'c' || t == 's' {
|
||||
runtime.memset(&scanset, -1, size_of(scanset))
|
||||
scanset[0] = 0
|
||||
if t == 's' {
|
||||
scanset['\t'] = 0
|
||||
scanset['\n'] = 0
|
||||
scanset['\v'] = 0
|
||||
scanset['\f'] = 0
|
||||
scanset['\r'] = 0
|
||||
scanset[' '] = 0
|
||||
}
|
||||
} else {
|
||||
p = p[1:]
|
||||
invert = 0
|
||||
if p[0] == '^' {
|
||||
p = p[1:]
|
||||
invert = 1
|
||||
}
|
||||
|
||||
runtime.memset(&scanset, i32(invert), size_of(scanset))
|
||||
scanset[0] = 0
|
||||
if p[0] == '-' {
|
||||
p = p[1:]
|
||||
scanset['-'] = 1 - invert
|
||||
} else if p[0] == ']' {
|
||||
p = p[1:]
|
||||
scanset[']'] = 1 - invert
|
||||
}
|
||||
|
||||
for ; p[0] != ']'; p = p[1:] {
|
||||
if p[0] == 0 {
|
||||
fmt_fail = true
|
||||
break main_loop
|
||||
}
|
||||
if p[0] == '-' && p[1] != ']' {
|
||||
c := p
|
||||
p = p[1:]
|
||||
for ch = c[0]; c[0] < p[0]; c, ch = c[1:], c[0] {
|
||||
scanset[ch] = 1 - invert
|
||||
}
|
||||
scanset[p[0]] = 1 - invert
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// wcs = nil
|
||||
s = nil
|
||||
i = 0
|
||||
k = t == 'c' ? width + 1 : 31
|
||||
if size == .l {
|
||||
unimplemented("vendor/libc: sscanf wide character support")
|
||||
} else if alloc {
|
||||
s = make([^]byte, k)
|
||||
if s == nil {
|
||||
alloc_fail = true
|
||||
break main_loop
|
||||
}
|
||||
|
||||
for ch = str[0]; scanset[ch] != 0 && i < width; {
|
||||
s[i] = ch
|
||||
i += 1
|
||||
if i == k {
|
||||
old_size := k
|
||||
k += k + 1
|
||||
tmp, _ := runtime.non_zero_mem_resize(s, old_size, k)
|
||||
if tmp == nil {
|
||||
alloc_fail = true
|
||||
break main_loop
|
||||
}
|
||||
s = raw_data(tmp)
|
||||
}
|
||||
|
||||
str = str[1:]
|
||||
ch = str[0]
|
||||
}
|
||||
} else {
|
||||
s = cast([^]byte)dest
|
||||
if s != nil {
|
||||
for ch = str[0]; scanset[ch] != 0 && i < width; {
|
||||
s[i] = ch
|
||||
i += 1
|
||||
|
||||
str = str[1:]
|
||||
ch = str[0]
|
||||
}
|
||||
} else {
|
||||
for ; scanset[str[0]] != 0 && i < width; str = str[1:] {}
|
||||
}
|
||||
}
|
||||
|
||||
if i == 0 {
|
||||
match_fail = true
|
||||
break main_loop
|
||||
}
|
||||
|
||||
str = str[-1:]
|
||||
|
||||
if t == 'c' && i != width {
|
||||
match_fail = true
|
||||
break main_loop
|
||||
}
|
||||
|
||||
if alloc {
|
||||
(^rawptr)(dest)^ = s
|
||||
}
|
||||
|
||||
if t != 'c' {
|
||||
if s != nil {s[i] = 0}
|
||||
}
|
||||
case:
|
||||
base := -1
|
||||
switch t {
|
||||
case 'p', 'X', 'x':
|
||||
base = 16
|
||||
if i + 2 < width && str[0] == '0' && str[1] == 'x' {
|
||||
str = str[2:]
|
||||
}
|
||||
case 'o':
|
||||
base = 8
|
||||
if i + 1 < width && str[0] == '0' {
|
||||
str = str[1:]
|
||||
}
|
||||
case 'd', 'u':
|
||||
base = 10
|
||||
case 'i':
|
||||
base = 0
|
||||
}
|
||||
|
||||
odin_str := string(cstring(str))
|
||||
odin_str = odin_str[:min(len(odin_str), width-i)]
|
||||
cnt: int
|
||||
if base >= 0 {
|
||||
x: i64
|
||||
if base == 0 {
|
||||
x, _ = strconv.parse_i64_maybe_prefixed(odin_str, &cnt)
|
||||
} else {
|
||||
x, _ = strconv.parse_i64_of_base(odin_str, base, &cnt)
|
||||
}
|
||||
|
||||
if cnt == 0 {
|
||||
match_fail = true
|
||||
break main_loop
|
||||
}
|
||||
|
||||
if t == 'p' && dest != nil {
|
||||
(^rawptr)(dest)^ = rawptr(uintptr(x))
|
||||
} else {
|
||||
store_int(dest, size, u64(x))
|
||||
}
|
||||
} else {
|
||||
// should be a guarantee bcs of validation above.
|
||||
// switch t {
|
||||
// case 'a', 'A',
|
||||
// 'e', 'E',
|
||||
// 'f', 'F',
|
||||
// 'g', 'G':
|
||||
// }
|
||||
x, _ := strconv.parse_f64(odin_str, &cnt)
|
||||
|
||||
if cnt == 0 {
|
||||
match_fail = true
|
||||
break main_loop
|
||||
}
|
||||
|
||||
if dest != nil {
|
||||
#partial switch size {
|
||||
case .None:
|
||||
(^c.float)(dest)^ = c.float(x)
|
||||
case .l:
|
||||
(^c.double)(dest)^ = c.double(x)
|
||||
case .L:
|
||||
(^c.double)(dest)^ = c.double(x) // longdouble
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pos += u64(cnt)
|
||||
str = str[cnt:]
|
||||
}
|
||||
|
||||
if dest != nil {
|
||||
matches += 1
|
||||
}
|
||||
}
|
||||
|
||||
if fmt_fail || alloc_fail || input_fail {
|
||||
if matches == 0 {
|
||||
matches = -1
|
||||
}
|
||||
}
|
||||
|
||||
if match_fail {
|
||||
if alloc {
|
||||
free(s)
|
||||
// free(wcs)
|
||||
}
|
||||
}
|
||||
|
||||
return matches
|
||||
}
|
||||
|
||||
73
vendor/libc/stdlib.odin
vendored
73
vendor/libc/stdlib.odin
vendored
@@ -1,8 +1,10 @@
|
||||
package odin_libc
|
||||
|
||||
import "base:intrinsics"
|
||||
import "base:runtime"
|
||||
|
||||
import "core:c"
|
||||
import "core:os"
|
||||
import "core:slice"
|
||||
import "core:sort"
|
||||
import "core:strconv"
|
||||
@@ -108,12 +110,81 @@ atof :: proc "c" (str: cstring) -> f64 {
|
||||
@(require, linkage="strong", link_name="strtol")
|
||||
strtol :: proc "c" (str: cstring, str_end: ^cstring, base: i32) -> c.long {
|
||||
context = g_ctx
|
||||
|
||||
sstr := string(str)
|
||||
sstr = strings.trim_left_space(sstr)
|
||||
|
||||
n: int
|
||||
i, _ := strconv.parse_i64_of_base(sstr, int(base), &n)
|
||||
str_end ^= cstring(raw_data(sstr)[n:])
|
||||
if str_end != nil {
|
||||
str_end ^= cstring(raw_data(sstr)[n:])
|
||||
}
|
||||
return c.long(clamp(i, i64(min(c.long)), i64(max(c.long))))
|
||||
}
|
||||
|
||||
@(require, linkage="strong", link_name="strtod")
|
||||
strtod :: proc "c" (str: cstring, str_end: ^cstring) -> c.double {
|
||||
context = g_ctx
|
||||
|
||||
sstr := string(str)
|
||||
sstr = strings.trim_left_space(sstr)
|
||||
|
||||
n: int
|
||||
val, _ := strconv.parse_f64(sstr, &n)
|
||||
if str_end != nil {
|
||||
str_end ^= cstring(raw_data(sstr)[n:])
|
||||
}
|
||||
|
||||
return c.double(val)
|
||||
}
|
||||
|
||||
@(require, linkage="strong", link_name="abort")
|
||||
abort :: proc "c" () -> ! {
|
||||
intrinsics.trap()
|
||||
}
|
||||
|
||||
ATEXIT_MAX :: 32
|
||||
|
||||
@(private)
|
||||
atexit_functions: [ATEXIT_MAX]proc "c" ()
|
||||
@(private)
|
||||
atexit_functions_count: int
|
||||
|
||||
@(require, linkage="strong", link_name="atexit")
|
||||
atexit :: proc "c" (function: proc "c" ()) -> i32 {
|
||||
entry := intrinsics.atomic_add(&atexit_functions_count, 1)
|
||||
if entry >= ATEXIT_MAX {
|
||||
return -1
|
||||
}
|
||||
|
||||
atexit_functions[entry] = function
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
@(require, linkage="strong", link_name="exit")
|
||||
exit :: proc "c" (exit_code: c.int) -> ! {
|
||||
finish_atexit()
|
||||
os.exit(int(exit_code))
|
||||
}
|
||||
|
||||
@(private, fini)
|
||||
finish_atexit :: proc "c" () {
|
||||
n := intrinsics.atomic_exchange(&atexit_functions_count, 0)
|
||||
for function in atexit_functions[:n] {
|
||||
function()
|
||||
}
|
||||
}
|
||||
|
||||
ldiv_t :: struct {
|
||||
quot: c.long,
|
||||
rem: c.long,
|
||||
}
|
||||
|
||||
@(require, linkage="strong", link_name="ldiv")
|
||||
ldiv :: proc "c" (number: c.long, denom: c.long) -> ldiv_t {
|
||||
return {
|
||||
quot = number / denom,
|
||||
rem = number %% denom,
|
||||
}
|
||||
}
|
||||
|
||||
10
vendor/libc/string.odin
vendored
10
vendor/libc/string.odin
vendored
@@ -5,6 +5,7 @@ import "base:intrinsics"
|
||||
import "core:c"
|
||||
import "core:strings"
|
||||
import "core:mem"
|
||||
import "core:bytes"
|
||||
|
||||
// NOTE: already defined by Odin.
|
||||
// void *memcpy(void *, const void *, size_t);
|
||||
@@ -109,3 +110,12 @@ strstr :: proc "c" (str: cstring, substr: cstring) -> cstring {
|
||||
return cstring(([^]byte)(str)[idx:])
|
||||
}
|
||||
|
||||
@(require, linkage="strong", link_name="memchr")
|
||||
memchr :: proc "c" (str: [^]byte, c: i32, n: uint) -> [^]byte {
|
||||
idx := bytes.index_byte(str[:n], u8(c))
|
||||
if idx < 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
return str[idx:]
|
||||
}
|
||||
|
||||
10
vendor/libc/time.odin
vendored
Normal file
10
vendor/libc/time.odin
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
package odin_libc
|
||||
|
||||
import "core:time"
|
||||
|
||||
clock_t :: i64
|
||||
|
||||
@(require, linkage="strong", link_name="clock")
|
||||
clock :: proc "c" () -> clock_t {
|
||||
return time.tick_now()._nsec
|
||||
}
|
||||
4
vendor/sdl3/sdl3_pixels.odin
vendored
4
vendor/sdl3/sdl3_pixels.odin
vendored
@@ -550,7 +550,7 @@ PixelFormatDetails :: struct {
|
||||
|
||||
@(default_calling_convention="c", link_prefix="SDL_")
|
||||
foreign lib {
|
||||
GetPixelFormatName :: proc(format: PixelFormat) -> rawptr ---
|
||||
GetPixelFormatName :: proc(format: PixelFormat) -> cstring ---
|
||||
GetMasksForPixelFormat :: proc(format: PixelFormat, bpp: ^c.int, Rmask, Gmask, Bmask, Amask: ^Uint32) -> bool ---
|
||||
GetPixelFormatForMasks :: proc(bpp: c.int, Rmask, Gmask, Bmask, Amask: Uint32) -> PixelFormat ---
|
||||
GetPixelFormatDetails :: proc(format: PixelFormat) -> ^PixelFormatDetails ---
|
||||
@@ -561,4 +561,4 @@ foreign lib {
|
||||
MapRGBA :: proc(format: ^PixelFormatDetails, palette: ^Palette, r, g, b, a: Uint8) -> Uint32 ---
|
||||
GetRGB :: proc(pixel: Uint32, format: ^PixelFormatDetails, palette: ^Palette, r, g, b: ^Uint8) ---
|
||||
GetRGBA :: proc(pixel: Uint32, format: ^PixelFormatDetails, palette: ^Palette, r, g, b, a: ^Uint8) ---
|
||||
}
|
||||
}
|
||||
|
||||
22
vendor/wasm/WebGL/webgl.odin
vendored
22
vendor/wasm/WebGL/webgl.odin
vendored
@@ -46,16 +46,17 @@ foreign webgl {
|
||||
|
||||
IsExtensionSupported :: proc(name: string) -> bool ---
|
||||
|
||||
ActiveTexture :: proc(x: Enum) ---
|
||||
AttachShader :: proc(program: Program, shader: Shader) ---
|
||||
BindAttribLocation :: proc(program: Program, index: i32, name: string) ---
|
||||
BindBuffer :: proc(target: Enum, buffer: Buffer) ---
|
||||
BindFramebuffer :: proc(target: Enum, framebuffer: Framebuffer) ---
|
||||
BindTexture :: proc(target: Enum, texture: Texture) ---
|
||||
BlendColor :: proc(red, green, blue, alpha: f32) ---
|
||||
BlendEquation :: proc(mode: Enum) ---
|
||||
BlendFunc :: proc(sfactor, dfactor: Enum) ---
|
||||
BlendFuncSeparate :: proc(srcRGB, dstRGB, srcAlpha, dstAlpha: Enum) ---
|
||||
ActiveTexture :: proc(x: Enum) ---
|
||||
AttachShader :: proc(program: Program, shader: Shader) ---
|
||||
BindAttribLocation :: proc(program: Program, index: i32, name: string) ---
|
||||
BindBuffer :: proc(target: Enum, buffer: Buffer) ---
|
||||
BindFramebuffer :: proc(target: Enum, framebuffer: Framebuffer) ---
|
||||
BindTexture :: proc(target: Enum, texture: Texture) ---
|
||||
BlendColor :: proc(red, green, blue, alpha: f32) ---
|
||||
BlendEquation :: proc(mode: Enum) ---
|
||||
BlendEquationSeparate :: proc(modeRGB: Enum, modeAlpha: Enum) ---
|
||||
BlendFunc :: proc(sfactor, dfactor: Enum) ---
|
||||
BlendFuncSeparate :: proc(srcRGB, dstRGB, srcAlpha, dstAlpha: Enum) ---
|
||||
|
||||
BufferData :: proc(target: Enum, size: int, data: rawptr, usage: Enum) ---
|
||||
BufferSubData :: proc(target: Enum, offset: uintptr, size: int, data: rawptr) ---
|
||||
@@ -113,6 +114,7 @@ foreign webgl {
|
||||
GetVertexAttribOffset :: proc(index: i32, pname: Enum) -> uintptr ---
|
||||
GetProgramParameter :: proc(program: Program, pname: Enum) -> i32 ---
|
||||
GetParameter :: proc(pname: Enum) -> i32 ---
|
||||
GetParameter4i :: proc(pname: Enum, v0, v1, v2, v4: ^i32) ---
|
||||
|
||||
Hint :: proc(target: Enum, mode: Enum) ---
|
||||
|
||||
|
||||
2
vendor/wasm/WebGL/webgl_helpers.odin
vendored
2
vendor/wasm/WebGL/webgl_helpers.odin
vendored
@@ -29,7 +29,7 @@ CreateProgramFromStrings :: proc(vs_sources, fs_sources: []string) -> (program:
|
||||
}
|
||||
|
||||
program = CreateProgram()
|
||||
defer if !ok do DeleteProgram(program)
|
||||
defer if !ok { DeleteProgram(program) }
|
||||
|
||||
AttachShader(program, vs)
|
||||
AttachShader(program, fs)
|
||||
|
||||
Reference in New Issue
Block a user