mirror of
https://github.com/ziglang/zig.git
synced 2026-01-18 21:35:25 +00:00
stage2 sparcv9: Add Format 1 encoder
This commit is contained in:
parent
92c262aa93
commit
048035ea55
@ -1,5 +1,6 @@
|
||||
const std = @import("std");
|
||||
const DW = std.dwarf;
|
||||
const assert = std.debug.assert;
|
||||
const testing = std.testing;
|
||||
|
||||
/// General purpose registers in the SPARCv9 instruction set
|
||||
@ -448,4 +449,15 @@ pub const Instruction = union(enum) {
|
||||
pub fn toU32(self: Instruction) u32 {
|
||||
return @bitCast(u32, self);
|
||||
}
|
||||
|
||||
fn format1(disp: i32) Instruction {
|
||||
// In SPARC, branch target needs to be aligned to 4 bytes.
|
||||
assert(disp % 4 == 0);
|
||||
|
||||
// Discard the last two bits since those are implicitly zero.
|
||||
const udisp = @truncate(u30, @bitCast(u32, disp) >> 2);
|
||||
return Instruction{ .format_1 = .{
|
||||
.disp30 = udisp,
|
||||
} };
|
||||
}
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user