[Flint] normalize surface addresses and pack Gen9 message payloads
Mirror Gitea refs to GitHub / mirror (push) Successful in 21s
Test / build_and_test (push) Successful in 2m54s
Build / build (push) Successful in 4m37s

This commit is contained in:
2026-08-28 19:35:16 +02:00
parent 441d5fbb96
commit 0788470ee5
14 changed files with 503 additions and 28 deletions
+26
View File
@@ -33,6 +33,7 @@ pub const Error = error{
UnloweredSystemValue,
UnloweredResource,
UnloweredMessage,
InvalidMessage,
InvalidPayloadLayout,
EntryBlockHasParameters,
DuplicateBlockParameter,
@@ -168,6 +169,22 @@ fn validateInstruction(program: *const program_ir.Program, inst: instruction.Ins
if (!op.data.type.isInitialTargetType())
return Error.InvalidBufferAccess;
},
.surface_message => |op| {
try validateRegisterSpan(program, op.payload);
if (!op.data_type.isInitialTargetType())
return Error.InvalidMessage;
switch (op.kind) {
.read => {
if (op.payload.register_count != 1 or op.response == null)
return Error.InvalidMessage;
try validateRegisterSpan(program, op.response.?);
if (op.response.?.register_count != 1)
return Error.InvalidMessage;
},
.write => if (op.payload.register_count != 2 or op.response != null)
return Error.InvalidMessage,
}
},
.move => |op| {
try validateDestination(program, op.destination);
try validateSource(program, op.source);
@@ -303,6 +320,15 @@ fn validateDestination(program: *const program_ir.Program, destination: operand.
}
}
fn validateRegisterSpan(program: *const program_ir.Program, span: operand.RegisterSpan) Error!void {
if (span.register_count == 0)
return Error.InvalidMessage;
switch (span.base) {
.virtual, .physical_grf => try validateRegisterRef(program, span.base),
else => return Error.InvalidMessage,
}
}
fn validateRegisterRef(program: *const program_ir.Program, register: operand.RegisterRef) Error!void {
switch (register) {
.virtual => |id| if (!program.virtual_registers.isLive(id))