Files
ziran/bootstrap/compiler_runtime_emit/compiler_runtime_emit.h
T
waozi c0efdfd534 Keep only the runtime helpers a closed program calls
The small runtime headers (zir_bounds.h, zir_slice.h, zir_string.h,
zir_vec.h) are split into helper segments by /*@Name*/ marks, the
convention ziran_simd_ops.h already uses; a helper's mark also lists the
helpers that call it. EmitRuntimeHeaders takes the names a closed
program's generated files spell and writes only the segments they name.
Other programs keep every helper, and the marks never reach generated
output.

Kryon's window headers go from 8524 to 6628 bytes: zir_bounds.h drops
EmptyArrayIndex and zir_slice.h drops the range helpers.
2026-11-15 18:59:55 -03:00

167 lines
4.3 KiB
C

/* Generated by zi2c from compiler_runtime_emit.zi. */
#ifndef ZIRAN_COMPILER_RUNTIME_EMIT_H
#define ZIRAN_COMPILER_RUNTIME_EMIT_H
#include <stdbool.h>
#include "zir_string_types.h"
#include "zir_slice.h"
#include "file.h"
#include "vec.h"
#ifdef __cplusplus
extern "C" {
#endif
#define IncludePrefix "#include \""
#ifdef ZIRAN_COMPILER_RUNTIME_EMIT_H_PRIVATE
#define SimdOpsName "ziran_simd_ops.h"
#endif
typedef struct RuntimeHeader RuntimeHeader;
typedef struct SimdNames SimdNames;
typedef struct ZirSimdUses ZirSimdUses;
#ifndef ZIRAN_CONCRETE_FORWARD___type_c53c2d7c4913dc02
#define ZIRAN_CONCRETE_FORWARD___type_c53c2d7c4913dc02
typedef struct __type_c53c2d7c4913dc02 __type_c53c2d7c4913dc02;
#endif
typedef struct GeneratedPathStore GeneratedPathStore;
#ifdef ZIRAN_COMPILER_RUNTIME_EMIT_H_PRIVATE
typedef struct TextDescriptor TextDescriptor;
#endif
#ifdef ZIRAN_COMPILER_RUNTIME_EMIT_H_PRIVATE
typedef struct ByteDescriptor ByteDescriptor;
#endif
#ifdef ZIRAN_COMPILER_RUNTIME_EMIT_H_PRIVATE
typedef struct Segment Segment;
#endif
typedef struct zir_8e7ef9a1e6f28a8e_Results__string__bool zir_8e7ef9a1e6f28a8e_Results__string__bool;
#ifndef ZIRAN_CONCRETE_FORWARD___type_838711075b90279a
#define ZIRAN_CONCRETE_FORWARD___type_838711075b90279a
typedef struct __type_838711075b90279a __type_838711075b90279a;
#endif
#ifndef ZIRAN_CONCRETE_FORWARD___type_9626e91dad9499a3
#define ZIRAN_CONCRETE_FORWARD___type_9626e91dad9499a3
typedef struct __type_9626e91dad9499a3 __type_9626e91dad9499a3;
#endif
#ifdef ZIRAN_COMPILER_RUNTIME_EMIT_H_PRIVATE
#ifndef ZIRAN_CONCRETE_FORWARD___type_2f893a38d978b828
#define ZIRAN_CONCRETE_FORWARD___type_2f893a38d978b828
typedef struct __type_2f893a38d978b828 __type_2f893a38d978b828;
#endif
#endif
#ifndef ZIRAN_CONCRETE_FORWARD___type_1f00ef809eed7c2e
#define ZIRAN_CONCRETE_FORWARD___type_1f00ef809eed7c2e
typedef struct __type_1f00ef809eed7c2e __type_1f00ef809eed7c2e;
#endif
struct RuntimeHeader {
const char * name;
const char * text;
uint32_t includes;
};
struct SimdNames {
const char ** text;
size_t* length;
size_t count;
size_t capacity;
size_t* slots;
size_t slot_count;
};
struct ZirSimdUses {
SimdNames names;
int32_t header;
};
#ifndef ZIRAN_CONCRETE___type_c53c2d7c4913dc02
#define ZIRAN_CONCRETE___type_c53c2d7c4913dc02
struct __type_c53c2d7c4913dc02 {
String* data;
int64_t count;
int64_t capacity;
};
#endif
struct GeneratedPathStore {
__type_c53c2d7c4913dc02 paths;
};
#ifdef ZIRAN_COMPILER_RUNTIME_EMIT_H_PRIVATE
struct TextDescriptor {
uint8_t* data;
size_t length;
};
#endif
#ifdef ZIRAN_COMPILER_RUNTIME_EMIT_H_PRIVATE
struct ByteDescriptor {
uint8_t* data;
int64_t length;
};
#endif
#ifdef ZIRAN_COMPILER_RUNTIME_EMIT_H_PRIVATE
struct Segment {
int64_t helper;
int64_t start;
int64_t length;
int64_t next;
};
#endif
struct zir_8e7ef9a1e6f28a8e_Results__string__bool {
String value_0;
bool value_1;
};
#ifndef ZIRAN_CONCRETE___type_838711075b90279a
#define ZIRAN_CONCRETE___type_838711075b90279a
struct __type_838711075b90279a {
uint8_t* data;
int64_t count;
int64_t capacity;
};
#endif
#ifndef ZIRAN_CONCRETE___type_9626e91dad9499a3
#define ZIRAN_CONCRETE___type_9626e91dad9499a3
struct __type_9626e91dad9499a3 {
bool* data;
int64_t count;
int64_t capacity;
};
#endif
#ifdef ZIRAN_COMPILER_RUNTIME_EMIT_H_PRIVATE
#ifndef ZIRAN_CONCRETE___type_2f893a38d978b828
#define ZIRAN_CONCRETE___type_2f893a38d978b828
struct __type_2f893a38d978b828 {
Segment* data;
int64_t count;
int64_t capacity;
};
#endif
#endif
#ifndef ZIRAN_CONCRETE___type_1f00ef809eed7c2e
#define ZIRAN_CONCRETE___type_1f00ef809eed7c2e
struct __type_1f00ef809eed7c2e {
int64_t* data;
int64_t count;
int64_t capacity;
};
#endif
extern GeneratedPathStore GeneratedPaths;
bool compiler_runtime_emit_RecordPath(String path);
bool compiler_runtime_emit_RecordPathC(uint8_t* path);
int64_t compiler_runtime_emit_GeneratedPathCount(void);
uint8_t* compiler_runtime_emit_GeneratedPath(int64_t index);
bool compiler_runtime_emit_IsRuntimeHeader(String name);
bool compiler_runtime_emit_EmitRuntimeHeaders(String out_dir, String generated_path, ZirSimdUses* simd, SimdNames* used);
bool compiler_runtime_emit_EmitSimdOps(String out_dir, ZirSimdUses* uses);
#ifdef __cplusplus
}
#endif
#endif /* ZIRAN_COMPILER_RUNTIME_EMIT_H */