Skip to content

bloqade.gemini.common.validation.call_site.InlineOrigins

← Module overview

classInlineOriginssource

bloqade.gemini.common.validation.call_site.InlineOrigins

Where each inlined statement came from, and which call brought it in.

Signature
class InlineOrigins(callees: dict[tuple[str, int], tuple[CallSite, ir.Method]] = dict(), offsets: dict[int, int] = dict())

Used across three points in run_pass, in order::

origins = InlineOrigins.collect(mt) # before the inliner runs origins.snapshot(mt) # before the validation suite runs origins.annotate(mt, suite.validate(mt)).raise_if_invalid()

The middle step exists because attach mutates node.source in place — ValidationError.source is the statement’s SourceInfo object, not a copy — so the statement’s true line offset has to be read before the suite touches it.

Parameters

NameTypeDefaultDescription
calleesdict[tuple[str, int], tuple[CallSite, ir.Method]]dict()
offsetsdict[int, int]dict()

Attributes

NameTypeDefaultDescription
calleesdict[tuple[str, int], tuple[CallSite, ir.Method]]field(default_factory=dict)``(file, line offset)`` -> the kernel defined there and the call reaching it.
offsetsdict[int, int]field(default_factory=dict)``id(stmt)`` -> the statement's own line offset, taken pre-``attach``.

methodcollectsource

bloqade.gemini.common.validation.call_site.InlineOrigins.collect

def collect(method: ir.Method) -> InlineOrigins

Record the call sites reachable from method.

Must run before inlining: the invokes it reads are gone afterwards.

The entry method itself is excluded. Code the user wrote in the kernel being compiled is not something a call introduced, and claiming otherwise would attach a misleading note to every ordinary error.

Parameters

NameTypeDescription
methodir.Method

Returns

InlineOrigins

source

methodsnapshotsource

bloqade.gemini.common.validation.call_site.InlineOrigins.snapshot

def snapshot(method: ir.Method) -> None

Record every inlined statement’s line offset before attach runs.

Parameters

NameTypeDescription
methodir.Method
source

methodannotatesource

bloqade.gemini.common.validation.call_site.InlineOrigins.annotate

Signature
def annotate(method: ir.Method, result: ValidationResult) -> ValidationResult

Explain every error that came from inlined code, and fix its excerpt.

Returns result so it can be chained onto validate.

offsets is what decides whether an error is about inlined code: snapshot only records statements that came from some other kernel, so a hit means the statement was spliced in and a miss means the user wrote it where the error says.

The note goes into the error’s message rather than its help, because ValidationResult._format_errors always prints the message but only prints help alongside a source caret — which is precisely what fails to render for an inlined statement.

Parameters

NameTypeDescription
methodir.Method
resultValidationResult

Returns

ValidationResult

source