mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-09 15:19:07 +00:00
spirv: fpext and fptrunc instructions
This commit is contained in:
parent
d2692af8e2
commit
d8b591766a
3 changed files with 19 additions and 2 deletions
|
|
@ -1957,6 +1957,7 @@ const DeclGen = struct {
|
||||||
.int_from_ptr => try self.airIntFromPtr(inst),
|
.int_from_ptr => try self.airIntFromPtr(inst),
|
||||||
.float_from_int => try self.airFloatFromInt(inst),
|
.float_from_int => try self.airFloatFromInt(inst),
|
||||||
.int_from_float => try self.airIntFromFloat(inst),
|
.int_from_float => try self.airIntFromFloat(inst),
|
||||||
|
.fpext, .fptrunc => try self.airFloatCast(inst),
|
||||||
.not => try self.airNot(inst),
|
.not => try self.airNot(inst),
|
||||||
|
|
||||||
.array_to_slice => try self.airArrayToSlice(inst),
|
.array_to_slice => try self.airArrayToSlice(inst),
|
||||||
|
|
@ -2685,6 +2686,23 @@ const DeclGen = struct {
|
||||||
return result_id;
|
return result_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn airFloatCast(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 dest_ty = self.typeOfIndex(inst);
|
||||||
|
const dest_ty_id = try self.resolveTypeId(dest_ty);
|
||||||
|
|
||||||
|
const result_id = self.spv.allocId();
|
||||||
|
try self.func.body.emit(self.spv.gpa, .OpFConvert, .{
|
||||||
|
.id_result_type = dest_ty_id,
|
||||||
|
.id_result = result_id,
|
||||||
|
.float_value = operand_id,
|
||||||
|
});
|
||||||
|
return result_id;
|
||||||
|
}
|
||||||
|
|
||||||
fn airNot(self: *DeclGen, inst: Air.Inst.Index) !?IdRef {
|
fn airNot(self: *DeclGen, inst: Air.Inst.Index) !?IdRef {
|
||||||
if (self.liveness.isUnused(inst)) return null;
|
if (self.liveness.isUnused(inst)) return null;
|
||||||
const ty_op = self.air.instructions.items(.data)[inst].ty_op;
|
const ty_op = self.air.instructions.items(.data)[inst].ty_op;
|
||||||
|
|
|
||||||
|
|
@ -230,7 +230,7 @@ fn writeMemoryModel(spv: *SpvModule, target: std.Target) !void {
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: Put this in a proper section.
|
// TODO: Put this in a proper section.
|
||||||
try spv.sections.capabilities.emit(spv.gpa, .OpMemoryModel, .{
|
try spv.sections.extensions.emit(spv.gpa, .OpMemoryModel, .{
|
||||||
.addressing_model = addressing_model,
|
.addressing_model = addressing_model,
|
||||||
.memory_model = memory_model,
|
.memory_model = memory_model,
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -648,7 +648,6 @@ test "@floatCast cast down" {
|
||||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
|
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
|
||||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
|
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
|
||||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
var double: f64 = 0.001534;
|
var double: f64 = 0.001534;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue