fix(gpu): accept numeric percent-prefixed PTX identifiers

Preserve format and Evidence semantics at their owning boundaries, with focused regression coverage and documentation where applicable.

Fixes #6771
This commit is contained in:
morluto committed 2026-10-23 23:36:21 +08:00
1 parent 7f613149be
commit 5af154fc4b
3 files changed
+53 -1

No files matched your search

+14
View File
@@ -183,6 +183,20 @@ it("sums bare names and every register range while preserving unsupported totals
]);
expect(row!.kernel.limitations.join(" ")).toContain("count unknown");
});
it("counts numeric percent-prefixed PTX register names", () => {
const [row] = [
...readPtxKernels(
".entry kernel() { .reg .b32 %0; mov.u32 %0, 0; ret; }",
"object",
),
];
expect(row!.kernel.registers.virtual).toEqual([{ type: ".b32", count: 1 }]);
});
it.each(["0", "%"])("rejects malformed PTX register identifier %s", (name) => {
expect(() => [
...readPtxKernels(`.entry kernel() { .reg .b32 ${name}; ret; }`, "object"),
]).toThrow();
});
it("does not round overflowing register totals or accept truncated ranges", () => {
for (const declaration of [
"%r<9007199254740991>, %s",
+1 -1
View File
@@ -85,7 +85,7 @@ const sizeOf = (type: string | undefined): number | null => {
const match = /^\.(?:b|u|s|f)(8|16|32|64|128)$/u.exec(type ?? "");
return match === null ? null : Number(match[1]) / 8;
};
const identifier = /^%?[A-Za-z_$][\w$@.]*$/u;
const identifier = /^(?:%?[A-Za-z_$][\w$@.]*|%[0-9][A-Za-z0-9_$]*)$/u;
/** Stream register names/ranges without retaining the declaration token list. */
const registerDeclaration = (
next: () => Token,