mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 04:48:20 +00:00
spirv: air unwrap_errunion_payload
This commit is contained in:
parent
48ab11639a
commit
4f215a6d28
@ -1732,6 +1732,7 @@ pub const DeclGen = struct {
|
||||
.unreach, .trap => return self.airUnreach(),
|
||||
|
||||
.unwrap_errunion_err => try self.airErrUnionErr(inst),
|
||||
.unwrap_errunion_payload => try self.airErrUnionPayload(inst),
|
||||
.wrap_errunion_err => try self.airWrapErrUnionErr(inst),
|
||||
|
||||
.is_null => try self.airIsNull(inst, .is_null),
|
||||
@ -3185,6 +3186,21 @@ pub const DeclGen = struct {
|
||||
return try self.extractField(Type.anyerror, operand_id, eu_layout.errorFieldIndex());
|
||||
}
|
||||
|
||||
fn airErrUnionPayload(self: *DeclGen, inst: Air.Inst.Index) !?IdRef {
|
||||
if (self.liveness.isUnused(inst)) return null;
|
||||
|
||||
const ty_op = self.air.instructions.items(.data)[inst].ty_op;
|
||||
const operand_id = try self.resolve(ty_op.operand);
|
||||
const payload_ty = self.typeOfIndex(inst);
|
||||
const eu_layout = self.errorUnionLayout(payload_ty);
|
||||
|
||||
if (!eu_layout.payload_has_bits) {
|
||||
return null; // No error possible.
|
||||
}
|
||||
|
||||
return try self.extractField(payload_ty, operand_id, eu_layout.payloadFieldIndex());
|
||||
}
|
||||
|
||||
fn airWrapErrUnionErr(self: *DeclGen, inst: Air.Inst.Index) !?IdRef {
|
||||
if (self.liveness.isUnused(inst)) return null;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user