mirror of
https://github.com/ziglang/zig.git
synced 2026-01-20 22:35:24 +00:00
spirv: opaque types
This commit is contained in:
parent
a241cf90d6
commit
4e22f811e7
@ -1215,6 +1215,13 @@ pub const DeclGen = struct {
|
||||
try self.type_map.put(self.gpa, ty.toIntern(), .{ .ty_ref = ty_ref });
|
||||
return ty_ref;
|
||||
},
|
||||
.Opaque => {
|
||||
return try self.spv.resolve(.{
|
||||
.opaque_type = .{
|
||||
.name = .none, // TODO
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
.Null,
|
||||
.Undefined,
|
||||
|
||||
@ -81,6 +81,9 @@ const Tag = enum {
|
||||
/// have member names trailing.
|
||||
/// data is payload to SimpleStructType
|
||||
type_struct_simple_with_member_names,
|
||||
/// Opaque type.
|
||||
/// data is name string.
|
||||
type_opaque,
|
||||
|
||||
// -- Values
|
||||
/// Value of type u8
|
||||
@ -235,6 +238,7 @@ pub const Key = union(enum) {
|
||||
function_type: FunctionType,
|
||||
ptr_type: PointerType,
|
||||
struct_type: StructType,
|
||||
opaque_type: OpaqueType,
|
||||
|
||||
// -- values
|
||||
int: Int,
|
||||
@ -289,6 +293,10 @@ pub const Key = union(enum) {
|
||||
}
|
||||
};
|
||||
|
||||
pub const OpaqueType = struct {
|
||||
name: String = .none,
|
||||
};
|
||||
|
||||
pub const Int = struct {
|
||||
/// The type: any bitness integer.
|
||||
ty: Ref,
|
||||
@ -539,6 +547,13 @@ fn emit(
|
||||
}
|
||||
// TODO: Decorations?
|
||||
},
|
||||
.opaque_type => |opaque_type| {
|
||||
const name = if (self.getString(opaque_type.name)) |name| name else "";
|
||||
try section.emit(spv.gpa, .OpTypeOpaque, .{
|
||||
.id_result = result_id,
|
||||
.literal_string = name,
|
||||
});
|
||||
},
|
||||
.int => |int| {
|
||||
const int_type = self.lookup(int.ty).int_type;
|
||||
const ty_id = self.resultId(int.ty);
|
||||
@ -697,6 +712,11 @@ pub fn resolve(self: *Self, spv: *Module, key: Key) !Ref {
|
||||
};
|
||||
}
|
||||
},
|
||||
.opaque_type => |opaque_type| Item{
|
||||
.tag = .type_opaque,
|
||||
.result_id = result_id,
|
||||
.data = @intFromEnum(opaque_type.name),
|
||||
},
|
||||
.int => |int| blk: {
|
||||
const int_type = self.lookup(int.ty).int_type;
|
||||
if (int_type.signedness == .unsigned and int_type.bits == 8) {
|
||||
@ -874,6 +894,11 @@ pub fn lookup(self: *const Self, ref: Ref) Key {
|
||||
},
|
||||
};
|
||||
},
|
||||
.type_opaque => .{
|
||||
.opaque_type = .{
|
||||
.name = @as(String, @enumFromInt(data)),
|
||||
},
|
||||
},
|
||||
.float16 => .{ .float = .{
|
||||
.ty = self.get(.{ .float_type = .{ .bits = 16 } }),
|
||||
.value = .{ .float16 = @as(f16, @bitCast(@as(u16, @intCast(data)))) },
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user