tiny.choir.ir.dialects.shape
Defined in ir.dialects.
API (10)
Actions
Public operations.
Source
Source: lib/choir/src/core/dialects/spec.zig:694
zig
pub const shape = struct { pub fn of(comptime spec: anytype) interfaces.OperationShape { comptime validateSpec(@TypeOf(spec)); return .{ .operands = field(spec, "operands"), .results = field(spec, "results"), .regions = field(spec, "regions"), .successors = field(spec, "successors"), }; } pub fn fixed( comptime operands: anytype, comptime results: anytype, comptime regions: anytype, comptime successors: anytype, ) interfaces.OperationShape { return of(.{ .operands = operands, .results = results, .regions = regions, .successors = successors, }); } pub fn leaf(comptime operands: anytype, comptime results: anytype) interfaces.OperationShape { return of(.{ .operands = operands, .results = results, .regions = 0, .successors = 0, }); } pub fn noNested(comptime spec: anytype) interfaces.OperationShape { comptime validateNoNestedSpec(@TypeOf(spec)); const base = of(spec); return .{ .operands = base.operands, .results = base.results, .regions = interfaces.CountRange.exactly(0), .successors = interfaces.CountRange.exactly(0), }; } pub fn exactly(comptime count: usize) interfaces.CountRange { return interfaces.CountRange.exactly(count); } pub fn atLeast(comptime count: usize) interfaces.CountRange { return interfaces.CountRange.atLeast(count); } pub fn atMost(comptime count: usize) interfaces.CountRange { return interfaces.CountRange.atMost(count); } pub fn between(comptime min: usize, comptime max: usize) interfaces.CountRange { return interfaces.CountRange.between(min, max); } pub fn any() interfaces.CountRange { return .{}; } pub fn range(comptime value: anytype) interfaces.CountRange { return rangeFrom(value); } fn field(comptime spec: anytype, comptime name: []const u8) interfaces.CountRange { if (comptime @hasField(@TypeOf(spec), name)) { return rangeFrom(@field(spec, name)); } return .{}; } fn rangeFrom(comptime value: anytype) interfaces.CountRange { const Value = @TypeOf(value); if (Value == interfaces.CountRange) return value; return switch (@typeInfo(Value)) { .comptime_int => blk: { if (value < 0) @compileError("operation shape count cannot be negative"); break :blk interfaces.CountRange.exactly(@as(usize, value)); }, .int => |int_info| blk: { if (int_info.signedness == .signed and value < 0) { @compileError("operation shape count cannot be negative"); } break :blk interfaces.CountRange.exactly(@intCast(value)); }, .pointer => |pointer_info| switch (pointer_info.size) { .one => switch (@typeInfo(pointer_info.child)) { .array => |array_info| blk: { if (array_info.child == u8) { @compileError("operation shape fields must use a list of component names, not one component name"); } tryComponentNames(value.*, "shape"); break :blk interfaces.CountRange.exactly(array_info.len); }, .@"struct" => |struct_info| blk: { tryComponentNames(value.*, "shape"); break :blk interfaces.CountRange.exactly(struct_info.field_names.len); }, else => @compileError("operation shape fields must be integer counts, CountRange values, or component name lists"), }, .slice => blk: { tryComponentNames(value, "shape"); break :blk interfaces.CountRange.exactly(value.len); }, else => @compileError("operation shape fields must be integer counts, CountRange values, or component name lists"), }, .array => |array_info| blk: { if (array_info.child == u8) { @compileError("operation shape fields must use a list of component names, not one component name"); } tryComponentNames(value, "shape"); break :blk interfaces.CountRange.exactly(array_info.len); }, .@"struct" => |struct_info| blk: { tryComponentNames(value, "shape"); break :blk interfaces.CountRange.exactly(struct_info.field_names.len); }, else => @compileError("operation shape fields must be integer counts or CountRange values"), }; } fn validateSpec(comptime Spec: type) void { switch (@typeInfo(Spec)) { .@"struct" => |struct_info| { inline for (struct_info.field_names) |field_name| { if (!std.mem.eql(u8, field_name, "operands") and !std.mem.eql(u8, field_name, "results") and !std.mem.eql(u8, field_name, "regions") and !std.mem.eql(u8, field_name, "successors")) { @compileError("unknown operation shape field: " ++ field_name); } } }, else => @compileError("operation shape spec must be a struct literal"), } } fn validateNoNestedSpec(comptime Spec: type) void { validateSpec(Spec); if (@hasField(Spec, "regions")) @compileError("noNested operation shape cannot specify regions"); if (@hasField(Spec, "successors")) @compileError("noNested operation shape cannot specify successors"); }};Source: lib/choir/src/core/dialects/root.zig:46
zig
pub const shape = spec.shape;Also reachable as
backends.wasm.emission.module_encoding.common.ir.dialects.shape.
Complete caller list for ir.dialects.shape.atMost
7 direct callers.
lib.choir.src.core.dialects.spec.test_opSpec_names_components_independently_from_shape_ranges[function] — test source atlib/choir/src/core/dialects/spec.zig:3760in nearest public ownerlib.choir.src.core.dialects.speclib.choir.src.core.dialects.spec.test_operationTemplate_explicit_leaf_mixin_derives_optional_and_segment_accessors[function] — test source atlib/choir/src/core/dialects/spec.zig:3666in nearest public ownerlib.choir.src.core.dialects.speclib.choir.src.core.dialects.spec.test_operation_descriptor_DSL_builds_dialect_operation_sets[function] — test source atlib/choir/src/core/dialects/spec.zig:3414in nearest public ownerlib.choir.src.core.dialects.speclib.choir.src.core.dialects.spec.test_operation_descriptor_DSL_exports_compact_operation_metadata[function] — test source atlib/choir/src/core/dialects/spec.zig:3097in nearest public ownerlib.choir.src.core.dialects.speclib.choir.src.core.dialects.spec.test_operation_segment_helpers_set_attributes_and_read_named_segments[function] — test source atlib/choir/src/core/dialects/spec.zig:3201in nearest public ownerlib.choir.src.core.dialects.speclib.choir.src.core.dialects.spec.test_shape_DSL_leaf_constrains_nested_IR_to_zero[function] — test source atlib/choir/src/core/dialects/spec.zig:3061in nearest public ownerlib.choir.src.core.dialects.speclib.choir.src.core.dialects.spec.test_shape_DSL_maps_integers_and_count_ranges_into_operation_shapes[function] — test source atlib/choir/src/core/dialects/spec.zig:3040in nearest public ownerlib.choir.src.core.dialects.spec
Complete caller list for ir.dialects.shape.leaf
10 direct callers.
lib.choir.src.core.dialects.spec.operationTemplate.binaryFixedResultImpl[function] — private source atlib/choir/src/core/dialects/spec.zig:1975in nearest public ownerlib.choir.src.core.dialects.speclib.choir.src.core.dialects.spec.operationTemplate.binarySameTypeImpl[function] — private source atlib/choir/src/core/dialects/spec.zig:1908in nearest public ownerlib.choir.src.core.dialects.speclib.choir.src.core.dialects.spec.operationTemplate.selectSameTypeImpl[function] — private source atlib/choir/src/core/dialects/spec.zig:2302in nearest public ownerlib.choir.src.core.dialects.speclib.choir.src.core.dialects.spec.operationTemplate.ternarySameTypeImpl[function] — private source atlib/choir/src/core/dialects/spec.zig:2227in nearest public ownerlib.choir.src.core.dialects.speclib.choir.src.core.dialects.spec.operationTemplate.unaryExplicitTypeImpl[function] — private source atlib/choir/src/core/dialects/spec.zig:2142in nearest public ownerlib.choir.src.core.dialects.speclib.choir.src.core.dialects.spec.operationTemplate.unaryFixedResultImpl[function] — private source atlib/choir/src/core/dialects/spec.zig:2070in nearest public ownerlib.choir.src.core.dialects.speclib.choir.src.core.dialects.spec.operationTemplate.unaryNoResultImpl[function] — private source atlib/choir/src/core/dialects/spec.zig:2201in nearest public ownerlib.choir.src.core.dialects.speclib.choir.src.core.dialects.spec.operationTemplate.unarySameTypeImpl[function] — private source atlib/choir/src/core/dialects/spec.zig:2011in nearest public ownerlib.choir.src.core.dialects.speclib.choir.src.core.dialects.spec.operationTemplate.unarySameTypeStringAttrImpl[function] — private source atlib/choir/src/core/dialects/spec.zig:2102in nearest public ownerlib.choir.src.core.dialects.speclib.choir.src.core.dialects.spec.test_shape_DSL_leaf_constrains_nested_IR_to_zero[function] — test source atlib/choir/src/core/dialects/spec.zig:3061in nearest public ownerlib.choir.src.core.dialects.spec
Audit
| Definitions | 11 |
|---|---|
| Public names | 22 |
| Members | 0 |
| Version | 26.7.0 |
| Revision | daab053ee433 |