aboutsummaryrefslogtreecommitdiff
path: root/src/value.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-07-13 19:15:19 -0400
committerGitHub <noreply@github.com>2022-07-13 19:15:19 -0400
commit1653a9b2597c66cbcc88ea75d8a4b88c163584a5 (patch)
tree9cbe5d66e5088006ac4b5d5b4861a3b8b25a7a54 /src/value.zig
parentfad95741db7529bbad873fb330c25d64ac765340 (diff)
parent92bc3cbe27792be0300fb5f104c011a11f3cf40f (diff)
downloadzig-1653a9b2597c66cbcc88ea75d8a4b88c163584a5.tar.gz
zig-1653a9b2597c66cbcc88ea75d8a4b88c163584a5.zip
Merge pull request #12098 from ziglang/llvm-riscv64
LLVM: implement signext/zeroext attributes
Diffstat (limited to 'src/value.zig')
-rw-r--r--src/value.zig17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/value.zig b/src/value.zig
index 04999c778a..b52e67e31c 100644
--- a/src/value.zig
+++ b/src/value.zig
@@ -1468,8 +1468,7 @@ pub const Value = extern union {
const repr = std.math.break_f80(f);
std.mem.writeInt(u64, buffer[0..8], repr.fraction, endian);
std.mem.writeInt(u16, buffer[8..10], repr.exp, endian);
- // TODO set the rest of the bytes to undefined. should we use 0xaa
- // or is there a different way?
+ std.mem.set(u8, buffer[10..], 0);
return;
}
const Int = @Type(.{ .Int = .{
@@ -1481,20 +1480,18 @@ pub const Value = extern union {
}
fn floatReadFromMemory(comptime F: type, target: Target, buffer: []const u8) F {
+ const endian = target.cpu.arch.endian();
if (F == f80) {
- switch (target.cpu.arch) {
- .i386, .x86_64 => return std.math.make_f80(.{
- .fraction = std.mem.readIntLittle(u64, buffer[0..8]),
- .exp = std.mem.readIntLittle(u16, buffer[8..10]),
- }),
- else => {},
- }
+ return std.math.make_f80(.{
+ .fraction = readInt(u64, buffer[0..8], endian),
+ .exp = readInt(u16, buffer[8..10], endian),
+ });
}
const Int = @Type(.{ .Int = .{
.signedness = .unsigned,
.bits = @typeInfo(F).Float.bits,
} });
- const int = readInt(Int, buffer[0..@sizeOf(Int)], target.cpu.arch.endian());
+ const int = readInt(Int, buffer[0..@sizeOf(Int)], endian);
return @bitCast(F, int);
}