enum Alignment [src]
Fields
default = std.math.maxInt(u6)
_
Members
- fmt (Function)
- fromByteUnits (Function)
- Prefixed (struct)
- toByteUnits (Function)
- toLlvm (Function)
Source
pub const Alignment = enum(u6) {
default = std.math.maxInt(u6),
_,
pub fn fromByteUnits(bytes: u64) Alignment {
if (bytes == 0) return .default;
assert(std.math.isPowerOfTwo(bytes));
assert(bytes <= 1 << 32);
return @enumFromInt(@ctz(bytes));
}
pub fn toByteUnits(self: Alignment) ?u64 {
return if (self == .default) null else @as(u64, 1) << @intFromEnum(self);
}
pub fn toLlvm(self: Alignment) u6 {
return if (self == .default) 0 else (@intFromEnum(self) + 1);
}
pub const Prefixed = struct {
alignment: Alignment,
prefix: []const u8,
pub fn format(p: Prefixed, w: *Writer) Writer.Error!void {
const byte_units = p.alignment.toByteUnits() orelse return;
return w.print("{s}align {d}", .{ p.prefix, byte_units });
}
};
pub fn fmt(alignment: Alignment, prefix: []const u8) Prefixed {
return .{ .alignment = alignment, .prefix = prefix };
}
}