bloqade.gemini.common.validation.call_site.InlineOrigins
classInlineOrigins¶source
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
| Name | Type | Default | Description |
|---|---|---|---|
callees | dict[tuple[str, int], tuple[CallSite, ir.Method]] | dict() | |
offsets | dict[int, int] | dict() |
Attributes
| Name | Type | Default | Description |
|---|---|---|---|
callees | dict[tuple[str, int], tuple[CallSite, ir.Method]] | field(default_factory=dict) | ``(file, line offset)`` -> the kernel defined there and the call reaching it. |
offsets | dict[int, int] | field(default_factory=dict) | ``id(stmt)`` -> the statement's own line offset, taken pre-``attach``. |
methodcollect¶source
bloqade.gemini.common.validation.call_site.InlineOrigins.collect
def collect(method: ir.Method) -> InlineOriginsRecord 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
| Name | Type | Description |
|---|---|---|
method | ir.Method |
Returns
InlineOrigins
methodsnapshot¶source
bloqade.gemini.common.validation.call_site.InlineOrigins.snapshot
def snapshot(method: ir.Method) -> NoneRecord every inlined statement’s line offset before attach runs.
Parameters
| Name | Type | Description |
|---|---|---|
method | ir.Method |
methodannotate¶source
bloqade.gemini.common.validation.call_site.InlineOrigins.annotate
Signature
def annotate(method: ir.Method, result: ValidationResult) -> ValidationResultExplain 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
| Name | Type | Description |
|---|---|---|
method | ir.Method | |
result | ValidationResult |
Returns
ValidationResult