sema: strip flag, lime1 model, cascade fixes, lint cleanup

- Add `strip` field to Sema struct; suppress debug instructions
  (dbg_stmt, dbg_var_val, dbg_inline_block, dbg_arg_inline) when
  strip=true, matching Zig's behavior for ReleaseSmall
- Add lime1 CPU model ptr_nav in triggerArchModuleCascade (default
  model for wasm32 target)
- Add comptime tracker tags for target_ptr and struct_field_ptr
- Add intern helpers: internPtrMutable, internUndef,
  internPtrComptimeAlloc, internPtrUav, internPtrField
- Add findStructFieldIndexFromZir for field lookup in struct_decl ZIR
- Add analyzeNavValC for general const declaration evaluation
- Add zirFieldValComptime namespace lookup on resolved types
- Expand triggerArchModuleCascade: CpuFeature, FeatureSetFns, Feature,
  featureSet, Set, addFeature
- Fix lint: const pointers, duplicate condition, remove unused intern
  functions (internUnionValue, internOptPayload, internOptNull,
  internRepeated, internPtrUavAligned, internPtrSlice)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-27 13:42:19 +00:00
parent e2e4948337
commit 6a1f0158b3
4 changed files with 903 additions and 36 deletions

View File

@@ -1,5 +1,6 @@
#include "intern_pool.h"
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

File diff suppressed because it is too large Load Diff

View File

@@ -284,6 +284,10 @@ typedef struct Sema {
// When true, test declarations are analyzed (test blocks become
// analyzeable functions). Set by the caller before semaAnalyze.
bool is_test;
// When true, debug statements (dbg_stmt, dbg_var_val, etc.) and
// debug inline blocks are suppressed. Matches Zig's
// block.ownerModule().strip. Set by the caller before semaAnalyze.
bool strip;
// File index into s_loaded_modules[] for this sema's module.
// Set by analyzeNavValC / semaAnalyze. UINT32_MAX = unknown.
uint32_t file_idx;

View File

@@ -75,6 +75,8 @@ fn stagesCheck(gpa: Allocator, comptime path: []const u8, source: [:0]const u8)
defer sc.semaDeinit(&c_sema);
c_sema.source_dir = source_dir_path.ptr;
c_sema.module_root = module_root_path.ptr;
// Pre-generated AIR uses ReleaseSmall (strip=true), so match it.
c_sema.strip = true;
// Set root_fqn and module_prefix so C sema FQNs match Zig's.
// lib/std/ files: "std.{prefix}.func" (std.zig compiled as root)
// other files: "{stem}.func" (standalone compilation)