Extend set of <enum> from a 64-member cap to 256, Java-EnumSet style. Sets
of 64 members or fewer keep the existing single-register bitmask (QBE w/l);
sets of 65..256 members ('jumbo') become an inline byte-array bitmap of
ceil(N/8) bytes, treated as a value aggregate (passed by reference, returned
via sret, memset/memcpy), with operations performed by new RTL helpers.
Representation (uSymbolTable): TSetTypeDesc.IsJumbo (BitCount > 64) and
RawByteSize; RawSize/ByteSize/AllocAlign sized accordingly. TSymbol gains
ConstSetBytes/ConstSetQbe for jumbo constants (can't fit an Int64 mask).
RTL: new runtime/src/main/pascal/blaise_set.pas — _SetIn/_SetInclude/
_SetExclude/_SetUnion/_SetInter/_SetDiff/_SetEqual/_SetCopy over byte-array
bitmaps (overlap-safe). Wired into runtime/Makefile.
Semantic: the four >64 caps become >256. AnalyseSetConstDecl folds a jumbo
const to a byte array. The anonymous set for 'X in [a,b,c]' is sized to the
largest listed ordinal (when constant), not the full enum — keeping the
common low-ordinal membership test (incl. the compiler's own TokenKind
tests) on the fast register path. This also fixes a latent miscompile: the
old fixed-l representation silently dropped any listed ordinal >= 64.
Codegen (both backends): jumbo branches for literal, in, +/-/*, =/<>,
Include/Exclude, for-in, assignment, params (pmJumboSetValue ABI), and sret
returns. The register 'in' gained a range guard for literal-sized sets.
Native reserves two 32-byte scratch slots per frame (and .bss in main) for
set-op/literal result buffers. QBE adds IsAggregateAddrType so jumbo sets
ride the record/static-array address paths and are never promoted.
OPDF: no format change — recSet SizeInBytes (1 byte) already covers <=32.
Verified: FIXPOINT_OK and NATIVE_FIXPOINT_OK; full suite (3172 tests) green
built by the stage-2 binary, the QBE fixpoint binary, and the native
fixpoint binary; bif-coverage OK. Tests: cp.test.jumboset (12 IR) and
cp.test.e2e.jumboset (6 e2e, both backends via AssertRunsOnAll); the
>256-member rejection test in cp.test.sets updated. Docs: grammar.ebnf and
language-rationale set-type sections updated for the 256 cap and literal
sizing.
Closes the design discussion behind #81.
104 lines
3.3 KiB
Makefile
104 lines
3.3 KiB
Makefile
#
|
|
# Blaise — An Object Pascal Compiler
|
|
# Copyright (c) 2026 Graeme Geldenhuys
|
|
# SPDX-License-Identifier: Apache-2.0 WITH Swift-exception
|
|
# Licensed under the Apache License v2.0 with Runtime Library Exception.
|
|
# See LICENSE file in the project root for full license terms.
|
|
#
|
|
# Each Pascal unit is compiled directly via Blaise's unit-as-top-level
|
|
# mode (project_unit_as_toplevel, 2026-05-24): a single
|
|
# `blaise --source X.pas --output X.o` invocation runs qbe + cc -c
|
|
# + objcopy-embed in one step. No build-driver shims, no IR-strip
|
|
# sed pipelines, no intermediate .ssa/.s files needed.
|
|
SHELL = /bin/bash
|
|
|
|
CC = gcc
|
|
CFLAGS = -O2 -Wall -Wextra -std=c11
|
|
|
|
SRC_DIR = src/main/c
|
|
PAS_SRC_DIR = src/main/pascal
|
|
ASM_DIR = src/main/asm
|
|
OBJ_DIR = target
|
|
LIB = $(OBJ_DIR)/blaise_rtl.a
|
|
|
|
# Where the compiler binary lives — install copies the RTL there so the
|
|
# driver finds it automatically next to itself.
|
|
COMPILER_BIN = ../compiler/target
|
|
BLAISE = $(COMPILER_BIN)/blaise
|
|
|
|
# Assembly sources — platform-specific, no C compiler needed.
|
|
ASM_OBJS = $(OBJ_DIR)/blaise_setjmp_x86_64.o \
|
|
$(OBJ_DIR)/blaise_atomic_x86_64.o \
|
|
$(OBJ_DIR)/blaise_utf8_x86_64.o
|
|
|
|
# Pascal RTL units compiled via the Blaise compiler.
|
|
PAS_OBJS = $(OBJ_DIR)/blaise_mem.o \
|
|
$(OBJ_DIR)/blaise_str.o \
|
|
$(OBJ_DIR)/blaise_set.o \
|
|
$(OBJ_DIR)/blaise_arc.o \
|
|
$(OBJ_DIR)/blaise_weak.o \
|
|
$(OBJ_DIR)/blaise_float.o \
|
|
$(OBJ_DIR)/blaise_thread.o \
|
|
$(OBJ_DIR)/blaise_exc.o \
|
|
$(OBJ_DIR)/rtl_platform_posix.o
|
|
|
|
OBJS = $(ASM_OBJS) $(PAS_OBJS)
|
|
|
|
.PHONY: all install clean
|
|
|
|
all: $(LIB)
|
|
|
|
$(LIB): $(OBJS)
|
|
ar rcs $@ $^
|
|
|
|
# --- Assembly rules ---
|
|
$(OBJ_DIR)/%.o: $(ASM_DIR)/%.s
|
|
@mkdir -p $(OBJ_DIR)
|
|
$(CC) -c -o $@ $<
|
|
|
|
# --- Pascal unit rules (unit-as-top-level) ---
|
|
$(OBJ_DIR)/blaise_mem.o: $(PAS_SRC_DIR)/blaise_mem.pas
|
|
@mkdir -p $(OBJ_DIR)
|
|
$(BLAISE) --source $< --unit-path $(PAS_SRC_DIR) --output $@
|
|
|
|
$(OBJ_DIR)/blaise_str.o: $(PAS_SRC_DIR)/blaise_str.pas
|
|
@mkdir -p $(OBJ_DIR)
|
|
$(BLAISE) --source $< --unit-path $(PAS_SRC_DIR) --output $@
|
|
|
|
$(OBJ_DIR)/blaise_set.o: $(PAS_SRC_DIR)/blaise_set.pas
|
|
@mkdir -p $(OBJ_DIR)
|
|
$(BLAISE) --source $< --unit-path $(PAS_SRC_DIR) --output $@
|
|
|
|
$(OBJ_DIR)/blaise_arc.o: $(PAS_SRC_DIR)/blaise_arc.pas
|
|
@mkdir -p $(OBJ_DIR)
|
|
$(BLAISE) --source $< --unit-path $(PAS_SRC_DIR) --output $@
|
|
|
|
$(OBJ_DIR)/blaise_weak.o: $(PAS_SRC_DIR)/blaise_weak.pas
|
|
@mkdir -p $(OBJ_DIR)
|
|
$(BLAISE) --source $< --unit-path $(PAS_SRC_DIR) --output $@
|
|
|
|
$(OBJ_DIR)/blaise_float.o: $(PAS_SRC_DIR)/blaise_float.pas
|
|
@mkdir -p $(OBJ_DIR)
|
|
$(BLAISE) --source $< --unit-path $(PAS_SRC_DIR) --output $@
|
|
|
|
$(OBJ_DIR)/blaise_thread.o: $(PAS_SRC_DIR)/blaise_thread.pas
|
|
@mkdir -p $(OBJ_DIR)
|
|
$(BLAISE) --source $< --unit-path $(PAS_SRC_DIR) --output $@
|
|
|
|
$(OBJ_DIR)/blaise_exc.o: $(PAS_SRC_DIR)/blaise_exc.pas
|
|
@mkdir -p $(OBJ_DIR)
|
|
$(BLAISE) --source $< --unit-path $(PAS_SRC_DIR) --output $@
|
|
|
|
$(OBJ_DIR)/rtl_platform_posix.o: $(PAS_SRC_DIR)/rtl.platform.posix.pas \
|
|
$(PAS_SRC_DIR)/rtl.platform.pas
|
|
@mkdir -p $(OBJ_DIR)
|
|
$(BLAISE) --source $< --unit-path $(PAS_SRC_DIR) --output $@
|
|
|
|
install: $(LIB)
|
|
@mkdir -p $(COMPILER_BIN)
|
|
cp $(LIB) $(COMPILER_BIN)/blaise_rtl.a
|
|
@echo "Installed blaise_rtl.a → $(COMPILER_BIN)/blaise_rtl.a"
|
|
|
|
clean:
|
|
rm -f $(OBJ_DIR)/*.o $(OBJ_DIR)/*.s $(OBJ_DIR)/*.ssa $(LIB)
|