Skip to main content

Module gpu_include_parse

Module gpu_include_parse 

Source
Expand description

GPU #include row parser. Phase 17b.7: per TOK_PREPROC token of kind TOK_PP_INCLUDE / TOK_PP_INCLUDE_NEXT, extracts the path byte span and <…> vs "…" flag. Per-thread, fully parallel. GPU #include row parser.

Phase 17b.7: per TOK_PREPROC token classified as TOK_PP_INCLUDE or TOK_PP_INCLUDE_NEXT, extract the include path’s byte span and whether it was the <…> (system) form or "…" (local) form. Per-thread, fully parallel.

§Output columns (one row per token)

  • path_start, path_len - byte span between the delimiters (</> or "/").
  • is_system - 1 for <…>, 0 for "…".

Non-INCLUDE rows get all-zero output. path_len == 0 after this kernel means “not a parsed #include row” - equivalent to the CPU parse_include_literal returning None/error.

§Real-GPU lowering note

Two real-GPU lowering pitfalls (both shared with gpu_directive_metadata):

  1. DataType::U8 storage buffers are emitted by vyre-emit-naga as array<u32> (WGSL has no u8 storage). Expr::load("source", addr) therefore returns the u32 word at index addr, not the byte at byte-address addr. The kernel does the byte extraction inline so it produces the correct value on both backends.
  2. Whitespace skipping uses fixed-depth chained Selects because C directive separators are short in practice. Path extraction is bounded by the directive row length, so Linux-scale include paths are not truncated by a compile-time probe cap.

§Wire layout

Inputs:

  • tok_starts (U32), tok_lens (U32), directive_kinds (U32) - output of 17a.
  • source (U8).

Outputs (all U32, one element per token):

  • path_start_out, path_len_out, is_system_out.

Constants§

BINDING_DIRECTIVE_KINDS
Canonical binding for the input directive-kinds buffer.
BINDING_IS_SYSTEM_OUT
Canonical binding for the output is_system column.
BINDING_PATH_LEN_OUT
Canonical binding for the output path_len column.
BINDING_PATH_START_OUT
Canonical binding for the output path_start column.
BINDING_SOURCE
Canonical binding for the input source bytes.
BINDING_TOK_LENS
Canonical binding for the input per-token length buffer.
BINDING_TOK_STARTS
Canonical binding for the input per-token start-offset buffer.
OP_ID
Canonical op id.

Functions§

gpu_include_parse
Build the 17b.7 #include row parser Program.
gpu_include_parse_u8
Build the 17b.7 #include row parser over raw DataType::U8 source bytes.