diff options
| author | Jacob Young <jacobly0@users.noreply.github.com> | 2025-01-30 11:58:32 -0500 |
|---|---|---|
| committer | Jacob Young <jacobly0@users.noreply.github.com> | 2025-01-31 23:00:34 -0500 |
| commit | afa74c6b213efb1ff85b86ce4a9edd5cc03e5a9b (patch) | |
| tree | 6a4d326e31eda55c359ec1e2aef05681bbef0298 /src/codegen/spirv.zig | |
| parent | 8195b64f575acaed9dbc59e745a98acebb71dc60 (diff) | |
| download | zig-afa74c6b213efb1ff85b86ce4a9edd5cc03e5a9b.tar.gz zig-afa74c6b213efb1ff85b86ce4a9edd5cc03e5a9b.zip | |
Sema: introduce all_vector_instructions backend feature
Sema is arbitrarily scalarizing some operations, which means that when I
try to implement vectorized versions of those operations in a backend,
they are impossible to test due to Sema not producing them. Now, I can
implement them and then temporarily enable the new feature for that
backend in order to test them. Once the backend supports all of them,
the feature can be permanently enabled.
This also deletes the Air instructions `int_from_bool` and
`int_from_ptr`, which are just bitcasts with a fixed result type, since
changing `un_op` to `ty_op` takes up the same amount of memory.
Diffstat (limited to 'src/codegen/spirv.zig')
| -rw-r--r-- | src/codegen/spirv.zig | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/src/codegen/spirv.zig b/src/codegen/spirv.zig index e9322a9d70..e1baf20156 100644 --- a/src/codegen/spirv.zig +++ b/src/codegen/spirv.zig @@ -3449,10 +3449,8 @@ const NavGen = struct { .bitcast => try self.airBitCast(inst), .intcast, .trunc => try self.airIntCast(inst), - .int_from_ptr => try self.airIntFromPtr(inst), .float_from_int => try self.airFloatFromInt(inst), .int_from_float => try self.airIntFromFloat(inst), - .int_from_bool => try self.airIntFromBool(inst), .fpext, .fptrunc => try self.airFloatCast(inst), .not => try self.airNot(inst), @@ -4706,9 +4704,14 @@ const NavGen = struct { fn airBitCast(self: *NavGen, inst: Air.Inst.Index) !?IdRef { const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op; - const operand_id = try self.resolve(ty_op.operand); const operand_ty = self.typeOf(ty_op.operand); const result_ty = self.typeOfIndex(inst); + if (operand_ty.toIntern() == .bool_type) { + const operand = try self.temporary(ty_op.operand); + const result = try self.intFromBool(operand); + return try result.materialize(self); + } + const operand_id = try self.resolve(ty_op.operand); return try self.bitCast(result_ty, operand_ty, operand_id); } @@ -4749,12 +4752,6 @@ const NavGen = struct { return result_id; } - fn airIntFromPtr(self: *NavGen, inst: Air.Inst.Index) !?IdRef { - const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op; - const operand_id = try self.resolve(un_op); - return try self.intFromPtr(operand_id); - } - fn airFloatFromInt(self: *NavGen, inst: Air.Inst.Index) !?IdRef { const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op; const operand_ty = self.typeOf(ty_op.operand); @@ -4808,13 +4805,6 @@ const NavGen = struct { return result_id; } - fn airIntFromBool(self: *NavGen, inst: Air.Inst.Index) !?IdRef { - const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op; - const operand = try self.temporary(un_op); - const result = try self.intFromBool(operand); - return try result.materialize(self); - } - fn airFloatCast(self: *NavGen, inst: Air.Inst.Index) !?IdRef { const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op; const operand_id = try self.resolve(ty_op.operand); |
