Default native, Wasm, C and Go output follows manual safety like C: a native data pointer is its address, so loads, stores, byte compares and platform services use it directly, globals are RIP-relative addresses, allocate takes plain frame-arena bytes and resize passes the raw block. Element and member accesses use the unchecked operand forms, the machine verifier's checked-memory obligation and the proven facts apply only to --checks programs, and the native loader builds its slot table and host token resolver only for a checked bundle. Wasm skips index, subview and resize checks; generated C uses raw indexes, SliceRangeAt and the new StringRangeAt; Go drops Ziran's explicit range checks. ARMv7 keeps checked pointers until its encoder has the unchecked forms. --checks builds today's checked program. Trap, hostile-twin and bounds tests build with it, and new assertions show the default C build has no index check. The bootstrap, including the macOS copy, is regenerated.
182 lines
4.7 KiB
C
182 lines
4.7 KiB
C
/* Generated by zi2c from compiler_proof_kernel.zi. */
|
|
#ifndef ZIRAN_COMPILER_PROOF_KERNEL_H
|
|
#define ZIRAN_COMPILER_PROOF_KERNEL_H
|
|
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
#define ProofBudget 100000
|
|
#define ProofDepth 64
|
|
#define ProofTerms 4096
|
|
#define ProofFacts 128
|
|
#define ProofTypes 32
|
|
#ifdef ZIRAN_COMPILER_PROOF_KERNEL_H_PRIVATE
|
|
#define OrderTerms 64
|
|
#endif
|
|
typedef int32_t ProofOp;
|
|
typedef struct ProofType ProofType;
|
|
typedef struct ProofTerm ProofTerm;
|
|
typedef struct ProofFact ProofFact;
|
|
typedef struct ProofKernel ProofKernel;
|
|
#ifdef ZIRAN_COMPILER_PROOF_KERNEL_H_PRIVATE
|
|
typedef struct Monomial Monomial;
|
|
#endif
|
|
#ifdef ZIRAN_COMPILER_PROOF_KERNEL_H_PRIVATE
|
|
#ifndef ZIRAN_CONCRETE_FORWARD___type_1d5d50278dc3155f
|
|
#define ZIRAN_CONCRETE_FORWARD___type_1d5d50278dc3155f
|
|
typedef struct __type_1d5d50278dc3155f __type_1d5d50278dc3155f;
|
|
#endif
|
|
#endif
|
|
#ifdef ZIRAN_COMPILER_PROOF_KERNEL_H_PRIVATE
|
|
typedef struct Polynomial Polynomial;
|
|
#endif
|
|
#ifdef ZIRAN_COMPILER_PROOF_KERNEL_H_PRIVATE
|
|
typedef struct Order Order;
|
|
#endif
|
|
#ifdef ZIRAN_COMPILER_PROOF_KERNEL_H_PRIVATE
|
|
typedef struct OrderResult OrderResult;
|
|
#endif
|
|
|
|
enum {
|
|
ProofOp_Const = 0,
|
|
ProofOp_Var = 1,
|
|
ProofOp_Add = 2,
|
|
ProofOp_Sub = 3,
|
|
ProofOp_Mul = 4,
|
|
ProofOp_Eq = 5,
|
|
ProofOp_Lt = 6,
|
|
ProofOp_Le = 7,
|
|
ProofOp_And = 8,
|
|
ProofOp_Or = 9,
|
|
ProofOp_Not = 10,
|
|
ProofOp_Ite = 11,
|
|
};
|
|
|
|
struct ProofType {
|
|
uint32_t width;
|
|
bool is_unsigned;
|
|
uint64_t identity;
|
|
};
|
|
|
|
struct ProofTerm {
|
|
ProofOp op;
|
|
int32_t type;
|
|
int32_t a;
|
|
int32_t b;
|
|
int32_t c;
|
|
uint64_t value;
|
|
};
|
|
|
|
struct ProofFact {
|
|
int32_t term;
|
|
bool truth;
|
|
};
|
|
|
|
struct ProofKernel {
|
|
ProofType types[32];
|
|
int32_t type_count;
|
|
ProofTerm terms[4096];
|
|
int32_t count;
|
|
int32_t budget;
|
|
bool exhausted;
|
|
ProofFact facts[128];
|
|
int32_t fact_count;
|
|
};
|
|
#ifdef ZIRAN_COMPILER_PROOF_KERNEL_H_PRIVATE
|
|
|
|
struct Monomial {
|
|
uint64_t coefficient;
|
|
int32_t degree;
|
|
int32_t factors[64];
|
|
};
|
|
#endif
|
|
#ifdef ZIRAN_COMPILER_PROOF_KERNEL_H_PRIVATE
|
|
#ifndef ZIRAN_CONCRETE___type_1d5d50278dc3155f
|
|
#define ZIRAN_CONCRETE___type_1d5d50278dc3155f
|
|
|
|
struct __type_1d5d50278dc3155f {
|
|
Monomial* data;
|
|
int64_t count;
|
|
int64_t capacity;
|
|
};
|
|
#endif
|
|
#endif
|
|
#ifdef ZIRAN_COMPILER_PROOF_KERNEL_H_PRIVATE
|
|
|
|
struct Polynomial {
|
|
__type_1d5d50278dc3155f terms;
|
|
int64_t count;
|
|
};
|
|
#endif
|
|
#ifdef ZIRAN_COMPILER_PROOF_KERNEL_H_PRIVATE
|
|
|
|
struct Order {
|
|
int32_t ids[64];
|
|
int32_t count;
|
|
uint8_t edges[64][64];
|
|
int32_t diseq[128][2];
|
|
int32_t diseq_count;
|
|
};
|
|
#endif
|
|
#ifdef ZIRAN_COMPILER_PROOF_KERNEL_H_PRIVATE
|
|
|
|
struct OrderResult {
|
|
int32_t truth;
|
|
bool impossible;
|
|
};
|
|
#endif
|
|
void compiler_proof_kernel_Init(ProofKernel* k);
|
|
int32_t compiler_proof_kernel_TypeAdd(ProofKernel* k, ProofType type);
|
|
int32_t compiler_proof_kernel_Node(ProofKernel* k, ProofOp op, int32_t type, int32_t a, int32_t b, int32_t c, uint64_t value);
|
|
bool compiler_proof_kernel_Equal(ProofKernel* k, int32_t a, int32_t b, bool ring);
|
|
bool compiler_proof_kernel_Close(ProofKernel* k, int32_t goal, bool ring, bool order, bool cases);
|
|
int32_t compiler_proof_kernel_Rewrite(ProofKernel* k, int32_t goal, int32_t from, int32_t to, int32_t depth);
|
|
|
|
/* Small procedures other modules inline; compiler_proof_kernel.c defines them. */
|
|
#if !defined(__cplusplus) && !defined(ZIRAN_COMPILER_PROOF_KERNEL_H_SOURCE) && !defined(ZIRAN_NO_HEADER_INLINE)
|
|
#include "zir_vec.h"
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
static inline int32_t compiler_proof_kernel_TypeAdd_ziran_inline(ProofKernel* k, ProofType type);
|
|
#define compiler_proof_kernel_TypeAdd(...) compiler_proof_kernel_TypeAdd_ziran_inline(__VA_ARGS__)
|
|
|
|
static inline int32_t
|
|
compiler_proof_kernel_TypeAdd_ziran_inline(ProofKernel* k, ProofType type)
|
|
{
|
|
{
|
|
int32_t range_first_0 = 0;
|
|
int32_t range_last_0 = (int32_t)((uint32_t)(k->type_count) - 1u);
|
|
int32_t i = range_first_0;
|
|
if (i <= range_last_0) for (;;) {
|
|
ProofType known = (k->types)[i];
|
|
if (known.width == type.width && known.is_unsigned == type.is_unsigned && known.identity == type.identity) {
|
|
return i;
|
|
}
|
|
if (i == range_last_0) {
|
|
break;
|
|
}
|
|
i = (int32_t)((uint32_t)i + 1u);
|
|
}
|
|
}
|
|
if (k->type_count == 32) {
|
|
bool* value_0 = &(k->exhausted);
|
|
(*value_0) = true;
|
|
return -1;
|
|
}
|
|
ProofType* value_1 = &(k->types[k->type_count]);
|
|
(*value_1) = type;
|
|
int32_t* value_2 = &(k->type_count);
|
|
(*value_2) = (int32_t)((uint32_t)((*value_2)) + 1u);
|
|
return (int32_t)((uint32_t)(k->type_count) - 1u);
|
|
}
|
|
#endif
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* ZIRAN_COMPILER_PROOF_KERNEL_H */
|