Skip to documentation
SLOP

tiny.choir.ir.dialects.operationTemplate

Reference tiny.choir ir dialects operationTemplate

Defined in ir.dialects.

API (20)

Actions

Public operations.

Types and contracts

Public types and contracts.

No direct callersNo direct callsir.dialectsoperationTemplate
Static calls · unresolved targets: unknown · external targets: unknown.

Source

Source: lib/choir/src/core/dialects/spec.zig:1421

zig
pub const operationTemplate = struct {    pub const FoldFn = *const fn (        op: *const anyopaque,        results: *interfaces.FoldResults,    ) anyerror!void;    pub const FixedResultTypeFn = *const fn (ctx: *Context) anyerror!Type;    pub fn dialect(comptime DialectType: type) type {        return struct {            pub fn binarySameType(                comptime mnemonic: []const u8,                comptime options: opSpec.Options,            ) type {                return operationTemplate.binarySameType(DialectType, mnemonic, options);            }            pub fn binarySameTypeFold(                comptime mnemonic: []const u8,                comptime options: opSpec.Options,                comptime fold_fn: FoldFn,            ) type {                return operationTemplate.binarySameTypeFold(DialectType, mnemonic, options, fold_fn);            }            pub fn binaryFixedResult(                comptime mnemonic: []const u8,                comptime options: opSpec.Options,                comptime result_type_fn: FixedResultTypeFn,            ) type {                return operationTemplate.binaryFixedResult(DialectType, mnemonic, options, result_type_fn);            }            pub fn unarySameType(                comptime mnemonic: []const u8,                comptime options: opSpec.Options,            ) type {                return operationTemplate.unarySameType(DialectType, mnemonic, options);            }            pub fn unarySameTypeFold(                comptime mnemonic: []const u8,                comptime options: opSpec.Options,                comptime fold_fn: FoldFn,            ) type {                return operationTemplate.unarySameTypeFold(DialectType, mnemonic, options, fold_fn);            }            pub fn unaryFixedResult(                comptime mnemonic: []const u8,                comptime options: opSpec.Options,                comptime result_type_fn: FixedResultTypeFn,            ) type {                return operationTemplate.unaryFixedResult(DialectType, mnemonic, options, result_type_fn);            }            pub fn unarySameTypeStringAttr(                comptime mnemonic: []const u8,                comptime attr_name: []const u8,                comptime attr_value: []const u8,                comptime options: opSpec.Options,            ) type {                return operationTemplate.unarySameTypeStringAttr(DialectType, mnemonic, attr_name, attr_value, options);            }            pub fn unaryExplicitTypeFold(                comptime mnemonic: []const u8,                comptime options: opSpec.Options,                comptime fold_fn: FoldFn,            ) type {                return operationTemplate.unaryExplicitTypeFold(DialectType, mnemonic, options, fold_fn);            }            pub fn unaryExplicitType(                comptime mnemonic: []const u8,                comptime options: opSpec.Options,            ) type {                return operationTemplate.unaryExplicitType(DialectType, mnemonic, options);            }            pub fn unaryNoResult(                comptime mnemonic: []const u8,                comptime options: opSpec.Options,            ) type {                return operationTemplate.unaryNoResult(DialectType, mnemonic, options);            }            pub fn ternarySameType(                comptime mnemonic: []const u8,                comptime options: opSpec.Options,            ) type {                return operationTemplate.ternarySameType(DialectType, mnemonic, options);            }            pub fn ternarySameTypeFold(                comptime mnemonic: []const u8,                comptime options: opSpec.Options,                comptime fold_fn: FoldFn,            ) type {                return operationTemplate.ternarySameTypeFold(DialectType, mnemonic, options, fold_fn);            }            pub fn selectSameType(                comptime mnemonic: []const u8,                comptime options: opSpec.Options,            ) type {                return operationTemplate.selectSameType(DialectType, mnemonic, options);            }            pub fn selectSameTypeFold(                comptime mnemonic: []const u8,                comptime options: opSpec.Options,                comptime fold_fn: FoldFn,            ) type {                return operationTemplate.selectSameTypeFold(DialectType, mnemonic, options, fold_fn);            }            pub fn explicitLeaf(                comptime OpType: type,                comptime spec: anytype,            ) type {                return operationTemplate.explicitLeaf(DialectType, OpType, spec);            }            pub fn explicit(                comptime OpType: type,                comptime spec: anytype,            ) type {                return operationTemplate.explicit(DialectType, OpType, spec);            }            pub fn explicitTerminator(                comptime OpType: type,                comptime spec: anytype,            ) type {                return operationTemplate.explicitTerminator(DialectType, OpType, spec);            }        };    }    pub fn binarySameType(        comptime DialectType: type,        comptime mnemonic: []const u8,        comptime options: opSpec.Options,    ) type {        return binarySameTypeImpl(DialectType, mnemonic, options, null);    }    pub fn binarySameTypeFold(        comptime DialectType: type,        comptime mnemonic: []const u8,        comptime options: opSpec.Options,        comptime fold_fn: FoldFn,    ) type {        return binarySameTypeImpl(DialectType, mnemonic, options, fold_fn);    }    pub fn binaryFixedResult(        comptime DialectType: type,        comptime mnemonic: []const u8,        comptime options: opSpec.Options,        comptime result_type_fn: FixedResultTypeFn,    ) type {        return binaryFixedResultImpl(DialectType, mnemonic, options, result_type_fn);    }    pub fn unarySameType(        comptime DialectType: type,        comptime mnemonic: []const u8,        comptime options: opSpec.Options,    ) type {        return unarySameTypeImpl(DialectType, mnemonic, options, null);    }    pub fn unarySameTypeFold(        comptime DialectType: type,        comptime mnemonic: []const u8,        comptime options: opSpec.Options,        comptime fold_fn: FoldFn,    ) type {        return unarySameTypeImpl(DialectType, mnemonic, options, fold_fn);    }    pub fn unaryFixedResult(        comptime DialectType: type,        comptime mnemonic: []const u8,        comptime options: opSpec.Options,        comptime result_type_fn: FixedResultTypeFn,    ) type {        return unaryFixedResultImpl(DialectType, mnemonic, options, result_type_fn);    }    pub fn unarySameTypeStringAttr(        comptime DialectType: type,        comptime mnemonic: []const u8,        comptime attr_name: []const u8,        comptime attr_value: []const u8,        comptime options: opSpec.Options,    ) type {        return unarySameTypeStringAttrImpl(DialectType, mnemonic, attr_name, attr_value, options);    }    pub fn unaryExplicitTypeFold(        comptime DialectType: type,        comptime mnemonic: []const u8,        comptime options: opSpec.Options,        comptime fold_fn: FoldFn,    ) type {        return unaryExplicitTypeImpl(DialectType, mnemonic, options, fold_fn);    }    pub fn unaryExplicitType(        comptime DialectType: type,        comptime mnemonic: []const u8,        comptime options: opSpec.Options,    ) type {        return unaryExplicitTypeImpl(DialectType, mnemonic, options, null);    }    pub fn unaryNoResult(        comptime DialectType: type,        comptime mnemonic: []const u8,        comptime options: opSpec.Options,    ) type {        return unaryNoResultImpl(DialectType, mnemonic, options);    }    pub fn ternarySameType(        comptime DialectType: type,        comptime mnemonic: []const u8,        comptime options: opSpec.Options,    ) type {        return ternarySameTypeImpl(DialectType, mnemonic, options, null);    }    pub fn ternarySameTypeFold(        comptime DialectType: type,        comptime mnemonic: []const u8,        comptime options: opSpec.Options,        comptime fold_fn: FoldFn,    ) type {        return ternarySameTypeImpl(DialectType, mnemonic, options, fold_fn);    }    pub fn selectSameType(        comptime DialectType: type,        comptime mnemonic: []const u8,        comptime options: opSpec.Options,    ) type {        return selectSameTypeImpl(DialectType, mnemonic, options, null);    }    pub fn selectSameTypeFold(        comptime DialectType: type,        comptime mnemonic: []const u8,        comptime options: opSpec.Options,        comptime fold_fn: FoldFn,    ) type {        return selectSameTypeImpl(DialectType, mnemonic, options, fold_fn);    }    pub fn explicitLeaf(        comptime DialectType: type,        comptime OpType: type,        comptime spec: anytype,    ) type {        const op_specs = opSpec.dialect(DialectType);        const generated_spec = op_specs.leaf(spec);        const accessors = operationAttributeAccessors(OpType, generated_spec);        return struct {            pub const operation_spec = generated_spec;            pub const operation_name = generated_spec.name;            pub const setI64Attr = accessors.setI64Attr;            pub const getI64Attr = accessors.getI64Attr;            pub const setBoolAttr = accessors.setBoolAttr;            pub const getBoolAttr = accessors.getBoolAttr;            pub const setStringAttr = accessors.setStringAttr;            pub const getStringAttr = accessors.getStringAttr;            pub const setDialectAttrPayload = accessors.setDialectAttrPayload;            pub const getDialectAttrPayload = accessors.getDialectAttrPayload;            pub const dialectAttrName = accessors.dialectAttrName;            pub fn createLeaf(                ctx: *Context,                loc: Location,                operands: []const *IrValue,                result_types: []const Type,            ) !OpType {                var builder = OperationBuilder.init(ctx);                var state = Operation.State.init(operation_name, loc);                state.addOperands(operands);                state.addTypes(result_types);                const op = try builder.create(state);                return .{ .op = op };            }            pub fn getOperand(self: OpType, comptime component_name: []const u8) *IrValue {                return operand(operation_spec, self.op, component_name);            }            pub fn getOptionalOperand(self: OpType, comptime component_name: []const u8) ?*IrValue {                return optionalOperand(operation_spec, self.op, component_name);            }            pub fn getOperandSegment(self: OpType, comptime component_name: []const u8) ?[]const *IrValue {                return operandSegmentValues(operation_spec, self.op, component_name);            }            pub fn getOperandSegmentValue(self: OpType, comptime component_name: []const u8) ?*IrValue {                return operandSegmentValue(operation_spec, self.op, component_name);            }            pub fn getNamedResult(self: OpType, comptime component_name: []const u8) *IrValue {                return result(operation_spec, self.op, component_name);            }            pub fn getOptionalResult(self: OpType, comptime component_name: []const u8) ?*IrValue {                return optionalResult(operation_spec, self.op, component_name);            }            pub fn getResultSegment(self: OpType, comptime component_name: []const u8) ?[]IrValue {                return resultSegmentValues(operation_spec, self.op, component_name);            }            pub fn getResultSegmentValue(self: OpType, comptime component_name: []const u8) ?*IrValue {                return resultSegmentValue(operation_spec, self.op, component_name);            }            pub fn getResult(self: OpType) *IrValue {                if (operation_spec.result_names.len != 1) {                    @compileError("operationTemplate.explicitLeaf getResult requires exactly one named result");                }                return result(operation_spec, self.op, operation_spec.result_names[0]);            }        };    }    pub fn explicit(        comptime DialectType: type,        comptime OpType: type,        comptime spec: anytype,    ) type {        const op_specs = opSpec.dialect(DialectType);        const generated_spec = op_specs.define(spec);        const accessors = operationAttributeAccessors(OpType, generated_spec);        return struct {            pub const operation_spec = generated_spec;            pub const operation_name = generated_spec.name;            pub const setI64Attr = accessors.setI64Attr;            pub const getI64Attr = accessors.getI64Attr;            pub const setBoolAttr = accessors.setBoolAttr;            pub const getBoolAttr = accessors.getBoolAttr;            pub const setStringAttr = accessors.setStringAttr;            pub const getStringAttr = accessors.getStringAttr;            pub const setDialectAttrPayload = accessors.setDialectAttrPayload;            pub const getDialectAttrPayload = accessors.getDialectAttrPayload;            pub const dialectAttrName = accessors.dialectAttrName;            pub fn createOperation(                ctx: *Context,                loc: Location,                operands: []const *IrValue,                result_types: []const Type,                region_bodies: []const *Region,                successors: []const *Block,            ) !OpType {                var builder = OperationBuilder.init(ctx);                var state = Operation.State.init(operation_name, loc);                state.addOperands(operands);                state.addTypes(result_types);                state.addRegionBodies(region_bodies);                state.addSuccessors(successors);                const op = try builder.create(state);                return .{ .op = op };            }            pub fn getOperand(self: OpType, comptime component_name: []const u8) *IrValue {                return operand(operation_spec, self.op, component_name);            }            pub fn getOptionalOperand(self: OpType, comptime component_name: []const u8) ?*IrValue {                return optionalOperand(operation_spec, self.op, component_name);            }            pub fn getOperandSegment(self: OpType, comptime component_name: []const u8) ?[]const *IrValue {                return operandSegmentValues(operation_spec, self.op, component_name);            }            pub fn getOperandSegmentValue(self: OpType, comptime component_name: []const u8) ?*IrValue {                return operandSegmentValue(operation_spec, self.op, component_name);            }            pub fn getNamedResult(self: OpType, comptime component_name: []const u8) *IrValue {                return result(operation_spec, self.op, component_name);            }            pub fn getOptionalResult(self: OpType, comptime component_name: []const u8) ?*IrValue {                return optionalResult(operation_spec, self.op, component_name);            }            pub fn getResultSegment(self: OpType, comptime component_name: []const u8) ?[]IrValue {                return resultSegmentValues(operation_spec, self.op, component_name);            }            pub fn getResultSegmentValue(self: OpType, comptime component_name: []const u8) ?*IrValue {                return resultSegmentValue(operation_spec, self.op, component_name);            }            pub fn getRegion(self: OpType, comptime component_name: []const u8) *Region {                return region(operation_spec, self.op, component_name);            }            pub fn getOptionalRegion(self: OpType, comptime component_name: []const u8) ?*Region {                return optionalRegion(operation_spec, self.op, component_name);            }            pub fn getSuccessor(self: OpType, comptime component_name: []const u8) *Block {                return successor(operation_spec, self.op, component_name);            }            pub fn getOptionalSuccessor(self: OpType, comptime component_name: []const u8) ?*Block {                return optionalSuccessor(operation_spec, self.op, component_name);            }        };    }    pub fn explicitTerminator(        comptime DialectType: type,        comptime OpType: type,        comptime spec: anytype,    ) type {        const op_specs = opSpec.dialect(DialectType);        const generated_spec = op_specs.terminator(spec);        const accessors = operationAttributeAccessors(OpType, generated_spec);        return struct {            pub const operation_spec = generated_spec;            pub const operation_name = generated_spec.name;            pub const setI64Attr = accessors.setI64Attr;            pub const getI64Attr = accessors.getI64Attr;            pub const setBoolAttr = accessors.setBoolAttr;            pub const getBoolAttr = accessors.getBoolAttr;            pub const setStringAttr = accessors.setStringAttr;            pub const getStringAttr = accessors.getStringAttr;            pub const setDialectAttrPayload = accessors.setDialectAttrPayload;            pub const getDialectAttrPayload = accessors.getDialectAttrPayload;            pub const dialectAttrName = accessors.dialectAttrName;            pub fn createTerminator(                ctx: *Context,                loc: Location,                operands: []const *IrValue,                successors: []const *Block,            ) !OpType {                var builder = OperationBuilder.init(ctx);                var state = Operation.State.init(operation_name, loc);                state.addOperands(operands);                state.addSuccessors(successors);                const op = try builder.create(state);                return .{ .op = op };            }            pub fn getOperand(self: OpType, comptime component_name: []const u8) *IrValue {                return operand(operation_spec, self.op, component_name);            }            pub fn getOptionalOperand(self: OpType, comptime component_name: []const u8) ?*IrValue {                return optionalOperand(operation_spec, self.op, component_name);            }            pub fn getOperandSegment(self: OpType, comptime component_name: []const u8) ?[]const *IrValue {                return operandSegmentValues(operation_spec, self.op, component_name);            }            pub fn getOperandSegmentValue(self: OpType, comptime component_name: []const u8) ?*IrValue {                return operandSegmentValue(operation_spec, self.op, component_name);            }            pub fn getSuccessor(self: OpType, comptime component_name: []const u8) *Block {                return successor(operation_spec, self.op, component_name);            }            pub fn getOptionalSuccessor(self: OpType, comptime component_name: []const u8) ?*Block {                return optionalSuccessor(operation_spec, self.op, component_name);            }        };    }    fn binarySameTypeImpl(        comptime DialectType: type,        comptime mnemonic: []const u8,        comptime options: opSpec.Options,        comptime fold_fn: ?FoldFn,    ) type {        const generated_spec = opSpec.shaped(operationName(DialectType.name, mnemonic), shape.leaf(2, 1), options);        if (fold_fn) |fold_impl| {            return struct {                op: *Operation,                pub const operation_spec = generated_spec;                pub const operation_name = operation_spec.name;                pub const fold = fold_impl;                pub fn create(ctx: *Context, loc: Location, lhs: *IrValue, rhs: *IrValue) !@This() {                    var builder = OperationBuilder.init(ctx);                    var state = Operation.State.init(operation_name, loc);                    state.addOperands(&.{ lhs, rhs });                    state.addTypes(&.{lhs.type});                    const op = try builder.create(state);                    return .{ .op = op };                }                pub fn getResult(self: *const @This()) *IrValue {                    return self.op.getResult(0).?;                }                pub fn getLhs(self: @This()) *IrValue {                    return self.op.getOperand(0).?;                }                pub fn getRhs(self: @This()) *IrValue {                    return self.op.getOperand(1).?;                }            };        }        return struct {            op: *Operation,            pub const operation_spec = generated_spec;            pub const operation_name = operation_spec.name;            pub fn create(ctx: *Context, loc: Location, lhs: *IrValue, rhs: *IrValue) !@This() {                var builder = OperationBuilder.init(ctx);                var state = Operation.State.init(operation_name, loc);                state.addOperands(&.{ lhs, rhs });                state.addTypes(&.{lhs.type});                const op = try builder.create(state);                return .{ .op = op };            }            pub fn getResult(self: *const @This()) *IrValue {                return self.op.getResult(0).?;            }            pub fn getLhs(self: @This()) *IrValue {                return self.op.getOperand(0).?;            }            pub fn getRhs(self: @This()) *IrValue {                return self.op.getOperand(1).?;            }        };    }    fn binaryFixedResultImpl(        comptime DialectType: type,        comptime mnemonic: []const u8,        comptime options: opSpec.Options,        comptime result_type_fn: FixedResultTypeFn,    ) type {        const generated_spec = opSpec.shaped(operationName(DialectType.name, mnemonic), shape.leaf(2, 1), options);        return struct {            op: *Operation,            pub const operation_spec = generated_spec;            pub const operation_name = operation_spec.name;            pub fn create(ctx: *Context, loc: Location, lhs: *IrValue, rhs: *IrValue) !@This() {                var builder = OperationBuilder.init(ctx);                var state = Operation.State.init(operation_name, loc);                state.addOperands(&.{ lhs, rhs });                state.addTypes(&.{try result_type_fn(ctx)});                const op = try builder.create(state);                return .{ .op = op };            }            pub fn getResult(self: *const @This()) *IrValue {                return self.op.getResult(0).?;            }            pub fn getLhs(self: @This()) *IrValue {                return self.op.getOperand(0).?;            }            pub fn getRhs(self: @This()) *IrValue {                return self.op.getOperand(1).?;            }        };    }    fn unarySameTypeImpl(        comptime DialectType: type,        comptime mnemonic: []const u8,        comptime options: opSpec.Options,        comptime fold_fn: ?FoldFn,    ) type {        const generated_spec = opSpec.shaped(operationName(DialectType.name, mnemonic), shape.leaf(1, 1), options);        if (fold_fn) |fold_impl| {            return struct {                op: *Operation,                pub const operation_spec = generated_spec;                pub const operation_name = operation_spec.name;                pub const fold = fold_impl;                pub fn create(ctx: *Context, loc: Location, input: *IrValue) !@This() {                    var builder = OperationBuilder.init(ctx);                    var state = Operation.State.init(operation_name, loc);                    state.addOperands(&.{input});                    state.addTypes(&.{input.type});                    const op = try builder.create(state);                    return .{ .op = op };                }                pub fn getResult(self: *const @This()) *IrValue {                    return self.op.getResult(0).?;                }                pub fn getInput(self: @This()) *IrValue {                    return self.op.getOperand(0).?;                }            };        }        return struct {            op: *Operation,            pub const operation_spec = generated_spec;            pub const operation_name = operation_spec.name;            pub fn create(ctx: *Context, loc: Location, input: *IrValue) !@This() {                var builder = OperationBuilder.init(ctx);                var state = Operation.State.init(operation_name, loc);                state.addOperands(&.{input});                state.addTypes(&.{input.type});                const op = try builder.create(state);                return .{ .op = op };            }            pub fn getResult(self: *const @This()) *IrValue {                return self.op.getResult(0).?;            }            pub fn getInput(self: @This()) *IrValue {                return self.op.getOperand(0).?;            }        };    }    fn unaryFixedResultImpl(        comptime DialectType: type,        comptime mnemonic: []const u8,        comptime options: opSpec.Options,        comptime result_type_fn: FixedResultTypeFn,    ) type {        const generated_spec = opSpec.shaped(operationName(DialectType.name, mnemonic), shape.leaf(1, 1), options);        return struct {            op: *Operation,            pub const operation_spec = generated_spec;            pub const operation_name = operation_spec.name;            pub fn create(ctx: *Context, loc: Location, input: *IrValue) !@This() {                var builder = OperationBuilder.init(ctx);                var state = Operation.State.init(operation_name, loc);                state.addOperands(&.{input});                state.addTypes(&.{try result_type_fn(ctx)});                const op = try builder.create(state);                return .{ .op = op };            }            pub fn getResult(self: *const @This()) *IrValue {                return self.op.getResult(0).?;            }            pub fn getInput(self: @This()) *IrValue {                return self.op.getOperand(0).?;            }        };    }    fn unarySameTypeStringAttrImpl(        comptime DialectType: type,        comptime mnemonic: []const u8,        comptime attr_name: []const u8,        comptime attr_value: []const u8,        comptime options: opSpec.Options,    ) type {        const generated_options = optionsWithAttr(options, attr_name);        const generated_spec = opSpec.shaped(operationName(DialectType.name, mnemonic), shape.leaf(1, 1), generated_options);        return struct {            op: *Operation,            pub const operation_spec = generated_spec;            pub const operation_name = operation_spec.name;            pub fn create(ctx: *Context, loc: Location, input: *IrValue) !@This() {                var builder = OperationBuilder.init(ctx);                var state = Operation.State.init(operation_name, loc);                state.addOperands(&.{input});                state.addTypes(&.{input.type});                const op = try builder.create(state);                try op.setAttr(attr_name, try ctx.getStringAttr(attr_value));                return .{ .op = op };            }            pub fn getResult(self: *const @This()) *IrValue {                return self.op.getResult(0).?;            }            pub fn getInput(self: @This()) *IrValue {                return self.op.getOperand(0).?;            }            pub fn getStringAttr(self: @This()) ?[]const u8 {                const attr = self.op.getAttrAs(Attribute.StringAttr, attr_name) orelse return null;                return attr.getValue();            }        };    }    fn unaryExplicitTypeImpl(        comptime DialectType: type,        comptime mnemonic: []const u8,        comptime options: opSpec.Options,        comptime fold_fn: ?FoldFn,    ) type {        const generated_spec = opSpec.shaped(operationName(DialectType.name, mnemonic), shape.leaf(1, 1), options);        if (fold_fn) |fold_impl| {            return struct {                op: *Operation,                pub const operation_spec = generated_spec;                pub const operation_name = operation_spec.name;                pub const fold = fold_impl;                pub fn create(ctx: *Context, loc: Location, input: *IrValue, result_type: Type) !@This() {                    var builder = OperationBuilder.init(ctx);                    var state = Operation.State.init(operation_name, loc);                    state.addOperands(&.{input});                    state.addTypes(&.{result_type});                    const op = try builder.create(state);                    return .{ .op = op };                }                pub fn getResult(self: *const @This()) *IrValue {                    return self.op.getResult(0).?;                }                pub fn getInput(self: @This()) *IrValue {                    return self.op.getOperand(0).?;                }            };        }        return struct {            op: *Operation,            pub const operation_spec = generated_spec;            pub const operation_name = operation_spec.name;            pub fn create(ctx: *Context, loc: Location, input: *IrValue, result_type: Type) !@This() {                var builder = OperationBuilder.init(ctx);                var state = Operation.State.init(operation_name, loc);                state.addOperands(&.{input});                state.addTypes(&.{result_type});                const op = try builder.create(state);                return .{ .op = op };            }            pub fn getResult(self: *const @This()) *IrValue {                return self.op.getResult(0).?;            }            pub fn getInput(self: @This()) *IrValue {                return self.op.getOperand(0).?;            }        };    }    fn unaryNoResultImpl(        comptime DialectType: type,        comptime mnemonic: []const u8,        comptime options: opSpec.Options,    ) type {        const generated_spec = opSpec.shaped(operationName(DialectType.name, mnemonic), shape.leaf(1, 0), options);        return struct {            op: *Operation,            pub const operation_spec = generated_spec;            pub const operation_name = operation_spec.name;            pub fn create(ctx: *Context, loc: Location, input: *IrValue) !@This() {                var builder = OperationBuilder.init(ctx);                var state = Operation.State.init(operation_name, loc);                state.addOperands(&.{input});                const op = try builder.create(state);                return .{ .op = op };            }            pub fn getInput(self: @This()) *IrValue {                return self.op.getOperand(0).?;            }        };    }    fn ternarySameTypeImpl(        comptime DialectType: type,        comptime mnemonic: []const u8,        comptime options: opSpec.Options,        comptime fold_fn: ?FoldFn,    ) type {        const generated_spec = opSpec.shaped(operationName(DialectType.name, mnemonic), shape.leaf(3, 1), options);        if (fold_fn) |fold_impl| {            return struct {                op: *Operation,                pub const operation_spec = generated_spec;                pub const operation_name = operation_spec.name;                pub const fold = fold_impl;                pub fn create(ctx: *Context, loc: Location, a: *IrValue, b: *IrValue, c: *IrValue) !@This() {                    var builder = OperationBuilder.init(ctx);                    var state = Operation.State.init(operation_name, loc);                    state.addOperands(&.{ a, b, c });                    state.addTypes(&.{a.type});                    const op = try builder.create(state);                    return .{ .op = op };                }                pub fn getResult(self: *const @This()) *IrValue {                    return self.op.getResult(0).?;                }                pub fn getA(self: @This()) *IrValue {                    return self.op.getOperand(0).?;                }                pub fn getB(self: @This()) *IrValue {                    return self.op.getOperand(1).?;                }                pub fn getC(self: @This()) *IrValue {                    return self.op.getOperand(2).?;                }            };        }        return struct {            op: *Operation,            pub const operation_spec = generated_spec;            pub const operation_name = operation_spec.name;            pub fn create(ctx: *Context, loc: Location, a: *IrValue, b: *IrValue, c: *IrValue) !@This() {                var builder = OperationBuilder.init(ctx);                var state = Operation.State.init(operation_name, loc);                state.addOperands(&.{ a, b, c });                state.addTypes(&.{a.type});                const op = try builder.create(state);                return .{ .op = op };            }            pub fn getResult(self: *const @This()) *IrValue {                return self.op.getResult(0).?;            }            pub fn getA(self: @This()) *IrValue {                return self.op.getOperand(0).?;            }            pub fn getB(self: @This()) *IrValue {                return self.op.getOperand(1).?;            }            pub fn getC(self: @This()) *IrValue {                return self.op.getOperand(2).?;            }        };    }    fn selectSameTypeImpl(        comptime DialectType: type,        comptime mnemonic: []const u8,        comptime options: opSpec.Options,        comptime fold_fn: ?FoldFn,    ) type {        const generated_spec = opSpec.shaped(operationName(DialectType.name, mnemonic), shape.leaf(3, 1), options);        if (fold_fn) |fold_impl| {            return struct {                op: *Operation,                pub const operation_spec = generated_spec;                pub const operation_name = operation_spec.name;                pub const fold = fold_impl;                pub fn create(ctx: *Context, loc: Location, condition: *IrValue, true_value: *IrValue, false_value: *IrValue) !@This() {                    var builder = OperationBuilder.init(ctx);                    var state = Operation.State.init(operation_name, loc);                    state.addOperands(&.{ condition, true_value, false_value });                    state.addTypes(&.{true_value.type});                    const op = try builder.create(state);                    return .{ .op = op };                }                pub fn getResult(self: *const @This()) *IrValue {                    return self.op.getResult(0).?;                }                pub fn getCondition(self: @This()) *IrValue {                    return self.op.getOperand(0).?;                }                pub fn getTrueValue(self: @This()) *IrValue {                    return self.op.getOperand(1).?;                }                pub fn getFalseValue(self: @This()) *IrValue {                    return self.op.getOperand(2).?;                }            };        }        return struct {            op: *Operation,            pub const operation_spec = generated_spec;            pub const operation_name = operation_spec.name;            pub fn create(ctx: *Context, loc: Location, condition: *IrValue, true_value: *IrValue, false_value: *IrValue) !@This() {                var builder = OperationBuilder.init(ctx);                var state = Operation.State.init(operation_name, loc);                state.addOperands(&.{ condition, true_value, false_value });                state.addTypes(&.{true_value.type});                const op = try builder.create(state);                return .{ .op = op };            }            pub fn getResult(self: *const @This()) *IrValue {                return self.op.getResult(0).?;            }            pub fn getCondition(self: @This()) *IrValue {                return self.op.getOperand(0).?;            }            pub fn getTrueValue(self: @This()) *IrValue {                return self.op.getOperand(1).?;            }            pub fn getFalseValue(self: @This()) *IrValue {                return self.op.getOperand(2).?;            }        };    }    fn optionsWithAttr(comptime options: opSpec.Options, comptime attr_name: []const u8) opSpec.Options {        return .{            .traits = options.traits,            .attrs = attrsWithName(options.attrs, attr_name),            .required_attrs = attrsWithName(options.required_attrs, attr_name),            .attribute_specs = attributeSpecsWithNames(options.attribute_specs, attrsWithName(options.attrs, attr_name)),            .operand_segments = options.operand_segments,            .result_segments = options.result_segments,            .operand_types = options.operand_types,            .result_types = options.result_types,            .properties = options.properties,            .interfaces = options.interfaces,            .dynamic_traits = options.dynamic_traits,        };    }    fn attrsWithName(comptime attrs: []const []const u8, comptime attr_name: []const u8) []const []const u8 {        if (attr_name.len == 0) @compileError("operation attribute name cannot be empty");        for (attrs) |existing| {            if (std.mem.eql(u8, existing, attr_name)) @compileError("operation attribute name is duplicated");        }        const values = comptime blk: {            var out: [attrs.len + 1][]const u8 = undefined;            for (attrs, 0..) |attr, index| {                out[index] = attr;            }            out[attrs.len] = attr_name;            break :blk out;        };        return &values;    }};

Source: lib/choir/src/core/dialects/root.zig:52

zig
pub const operationTemplate = spec.operationTemplate;
Called byCallsir.dialects.operationTemplatedialectprivate sourcelib.choir.src.core.dialects.spec.operationTem...binaryFixedResultImplir.dialects.operationTemplatebinaryFixedResult
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsir.dialects.operationTemplatedialectprivate sourcelib.choir.src.core.dialects.spec.operationTem...binarySameTypeImplir.dialects.operationTemplatebinarySameType
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsir.dialects.operationTemplatedialectprivate sourcelib.choir.src.core.dialects.spec.operationTem...binarySameTypeImplir.dialects.operationTemplatebinarySameTypeFold
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallstest sourcelib.choir.src.core.dialects.spectest: operationTemplate carries verif...test sourcelib.choir.src.core.dialects.spectest: operationTemplate explicit leaf...test sourcelib.choir.src.core.dialects.spectest: operationTemplate explicit leaf...test sourcelib.choir.src.core.dialects.spectest: operationTemplate explicit leaf...test sourcelib.choir.src.core.dialects.spectest: operationTemplate explicit mixi...+8 moreir.dialects.operationTemplatebinaryFixedResultir.dialects.operationTemplatebinarySameTypeir.dialects.operationTemplatebinarySameTypeFoldir.dialects.operationTemplateexplicitir.dialects.operationTemplateexplicitLeaf+12 moreir.dialects.operationTemplatedialect
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsir.dialects.operationTemplatedialectOperationBuildercreateOperationBuilderinitir.dialects.opSpecdialectir.dialectsoperandir.dialectsoperandSegmentValue+11 moreir.dialects.operationTemplateexplicit
Static calls · unresolved targets: 0 · external targets: 6.
Called byCallsir.dialects.operationTemplatedialectOperationBuildercreateOperationBuilderinitir.dialects.opSpecdialectir.dialectsoperandir.dialectsoperandSegmentValue+7 moreir.dialects.operationTemplateexplicitLeaf
Static calls · unresolved targets: 0 · external targets: 4.
Called byCallsir.dialects.operationTemplatedialectOperationBuildercreateOperationBuilderinitir.dialects.opSpecdialectir.dialectsoperandir.dialectsoperandSegmentValue+5 moreir.dialects.operationTemplateexplicitTerminator
Static calls · unresolved targets: 0 · external targets: 4.
Called byCallsir.dialects.operationTemplatedialectprivate sourcelib.choir.src.core.dialects.spec.operationTem...selectSameTypeImplir.dialects.operationTemplateselectSameType
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsir.dialects.operationTemplatedialectprivate sourcelib.choir.src.core.dialects.spec.operationTem...selectSameTypeImplir.dialects.operationTemplateselectSameTypeFold
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsir.dialects.operationTemplatedialectprivate sourcelib.choir.src.core.dialects.spec.operationTem...ternarySameTypeImplir.dialects.operationTemplateternarySameType
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsir.dialects.operationTemplatedialectprivate sourcelib.choir.src.core.dialects.spec.operationTem...ternarySameTypeImplir.dialects.operationTemplateternarySameTypeFold
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsir.dialects.operationTemplatedialectprivate sourcelib.choir.src.core.dialects.spec.operationTem...unaryExplicitTypeImplir.dialects.operationTemplateunaryExplicitType
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsir.dialects.operationTemplatedialectprivate sourcelib.choir.src.core.dialects.spec.operationTem...unaryExplicitTypeImplir.dialects.operationTemplateunaryExplicitTypeFold
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsir.dialects.operationTemplatedialectprivate sourcelib.choir.src.core.dialects.spec.operationTem...unaryFixedResultImplir.dialects.operationTemplateunaryFixedResult
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsir.dialects.operationTemplatedialectprivate sourcelib.choir.src.core.dialects.spec.operationTem...unaryNoResultImplir.dialects.operationTemplateunaryNoResult
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsir.dialects.operationTemplatedialectprivate sourcelib.choir.src.core.dialects.spec.operationTem...unarySameTypeImplir.dialects.operationTemplateunarySameType
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsir.dialects.operationTemplatedialectprivate sourcelib.choir.src.core.dialects.spec.operationTem...unarySameTypeImplir.dialects.operationTemplateunarySameTypeFold
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsir.dialects.operationTemplatedialectprivate sourcelib.choir.src.core.dialects.spec.operationTem...unarySameTypeStringAttrImplir.dialects.operationTemplateunarySameTypeStringAttr
Static calls · unresolved targets: 0 · external targets: 0.

Also reachable as

backends.wasm.emission.module_encoding.common.ir.dialects.operationTemplate.

Complete caller list for ir.dialects.operationTemplate.dialect

13 direct callers.

Complete call list for ir.dialects.operationTemplate.dialect

17 direct calls.

Complete call list for ir.dialects.operationTemplate.explicit

16 direct calls.

Complete call list for ir.dialects.operationTemplate.explicitLeaf

12 direct calls.

Complete call list for ir.dialects.operationTemplate.explicitTerminator

10 direct calls.

Audit

Definitions21
Public names42
Members0
Version26.7.0
Revisiondaab053ee433