feature. See also
. The project being documented here (as the example) is the Zig library itself.
Builder.convTag
fn convTag(
self: *Builder,
signedness: Constant.Cast.Signedness,
val_ty: Type,
ty: Type,
) Function.Instruction.Tag
File
Code
fn convTag(
self: *Builder,
signedness: Constant.Cast.Signedness,
val_ty: Type,
ty: Type,
) Function.Instruction.Tag {
assert(val_ty != ty);
return switch (val_ty.scalarTag(self)) {
.simple => switch (ty.scalarTag(self)) {
.simple => switch (std.math.order(val_ty.scalarBits(self), ty.scalarBits(self))) {
.lt => .fpext,
.eq => unreachable,
.gt => .fptrunc,
},
.integer => switch (signedness) {
.unsigned => .fptoui,
.signed => .fptosi,
.unneeded => unreachable,
},
else => unreachable,
},
.integer => switch (ty.scalarTag(self)) {
.simple => switch (signedness) {
.unsigned => .uitofp,
.signed => .sitofp,
.unneeded => unreachable,
},
.integer => switch (std.math.order(val_ty.scalarBits(self), ty.scalarBits(self))) {
.lt => switch (signedness) {
.unsigned => .zext,
.signed => .sext,
.unneeded => unreachable,
},
.eq => unreachable,
.gt => switch (signedness) {
.unsigned => .@"trunc nuw",
.signed => .@"trunc nsw",
.unneeded => .trunc,
},
},
.pointer => .inttoptr,
else => unreachable,
},
.pointer => switch (ty.scalarTag(self)) {
.integer => .ptrtoint,
.pointer => .addrspacecast,
else => unreachable,
},
else => unreachable,
};
}