| author | |
| committer | |
| log | 433558a92f005d3ad68528c62ffd6006c48b80bd |
| tree | 65c9132fecd73d2c77e44ed02625058e43d786b2 |
| parent | f279ccb8078db9df92f02e23f70486f1950b92ed |
5 files changed, 10 insertions(+), 19 deletions(-)
src/arch/x86_64/Emit.zig+2-2| ... | ... | @@ -177,12 +177,12 @@ fn encode(emit: *Emit, mnemonic: Instruction.Mnemonic, ops: struct { |
| 177 | 177 | op3: Instruction.Operand = .none, |
| 178 | 178 | op4: Instruction.Operand = .none, |
| 179 | 179 | }) InnerError!void { |
| 180 | const inst = Instruction.new(mnemonic, .{ | |
| 180 | const inst = try Instruction.new(mnemonic, .{ | |
| 181 | 181 | .op1 = ops.op1, |
| 182 | 182 | .op2 = ops.op2, |
| 183 | 183 | .op3 = ops.op3, |
| 184 | 184 | .op4 = ops.op4, |
| 185 | }) catch unreachable; | |
| 185 | }); | |
| 186 | 186 | return inst.encode(emit.code.writer()); |
| 187 | 187 | } |
| 188 | 188 |
src/arch/x86_64/Encoding.zig+1-1| ... | ... | @@ -121,7 +121,7 @@ pub fn findByMnemonic(mnemonic: Mnemonic, args: struct { |
| 121 | 121 | .encoding = encoding, |
| 122 | 122 | }; |
| 123 | 123 | var cwriter = std.io.countingWriter(std.io.null_writer); |
| 124 | inst.encode(cwriter.writer()) catch unreachable; | |
| 124 | inst.encode(cwriter.writer()) catch unreachable; // Not allowed to fail here unless OOM. | |
| 125 | 125 | return cwriter.bytes_written; |
| 126 | 126 | } |
| 127 | 127 | }; |
src/arch/x86_64/Mir.zig+4-7| ... | ... | @@ -24,9 +24,6 @@ instructions: std.MultiArrayList(Inst).Slice, |
| 24 | 24 | /// The meaning of this data is determined by `Inst.Tag` value. |
| 25 | 25 | extra: []const u32, |
| 26 | 26 | |
| 27 | pub const Mnemonic = encoder.Instruction.Mnemonic; | |
| 28 | pub const Operand = encoder.Instruction.Operand; | |
| 29 | ||
| 30 | 27 | pub const Inst = struct { |
| 31 | 28 | tag: Tag, |
| 32 | 29 | ops: Ops, |
| ... | ... | @@ -69,8 +66,6 @@ pub const Inst = struct { |
| 69 | 66 | imul, |
| 70 | 67 | /// |
| 71 | 68 | int3, |
| 72 | /// Conditional jump | |
| 73 | jcc, | |
| 74 | 69 | /// Jump |
| 75 | 70 | jmp, |
| 76 | 71 | /// Load effective address |
| ... | ... | @@ -99,8 +94,6 @@ pub const Inst = struct { |
| 99 | 94 | sar, |
| 100 | 95 | /// Integer subtraction with borrow |
| 101 | 96 | sbb, |
| 102 | /// Set byte on condition | |
| 103 | setcc, | |
| 104 | 97 | /// Logical shift left |
| 105 | 98 | shl, |
| 106 | 99 | /// Logical shift right |
| ... | ... | @@ -135,6 +128,10 @@ pub const Inst = struct { |
| 135 | 128 | |
| 136 | 129 | /// Conditional move |
| 137 | 130 | cmovcc, |
| 131 | /// Conditional jump | |
| 132 | jcc, | |
| 133 | /// Set byte on condition | |
| 134 | setcc, | |
| 138 | 135 | |
| 139 | 136 | /// Mov absolute to/from memory wrt segment register to/from rax |
| 140 | 137 | mov_moffs, |
src/arch/x86_64/bits.zig-7| ... | ... | @@ -242,13 +242,6 @@ pub const Register = enum(u7) { |
| 242 | 242 | }; |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | pub fn isRexInvalid(reg: Register) bool { | |
| 246 | return switch (@enumToInt(reg)) { | |
| 247 | @enumToInt(Register.ah)...@enumToInt(Register.bh) => true, | |
| 248 | else => false, | |
| 249 | }; | |
| 250 | } | |
| 251 | ||
| 252 | 245 | pub fn enc(reg: Register) u4 { |
| 253 | 246 | const base = switch (@enumToInt(reg)) { |
| 254 | 247 | // zig fmt: off |
src/arch/x86_64/encoder.zig+3-2| ... | ... | @@ -1,5 +1,6 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | 2 | const assert = std.debug.assert; |
| 3 | const log = std.log.scoped(.x86_64_encoder); | |
| 3 | 4 | const math = std.math; |
| 4 | 5 | |
| 5 | 6 | const bits = @import("bits.zig"); |
| ... | ... | @@ -106,7 +107,7 @@ pub const Instruction = struct { |
| 106 | 107 | .op3 = args.op3, |
| 107 | 108 | .op4 = args.op4, |
| 108 | 109 | })) orelse { |
| 109 | std.log.warn("{s} {s} {s} {s} {s}", .{ | |
| 110 | log.debug("no encoding found for: {s} {s} {s} {s} {s}", .{ | |
| 110 | 111 | @tagName(mnemonic), |
| 111 | 112 | @tagName(Encoding.Op.fromOperand(args.op1)), |
| 112 | 113 | @tagName(Encoding.Op.fromOperand(args.op2)), |
| ... | ... | @@ -115,7 +116,7 @@ pub const Instruction = struct { |
| 115 | 116 | }); |
| 116 | 117 | return error.InvalidInstruction; |
| 117 | 118 | }; |
| 118 | std.log.debug("{}", .{encoding}); | |
| 119 | log.debug("selected encoding: {}", .{encoding}); | |
| 119 | 120 | return .{ |
| 120 | 121 | .op1 = args.op1, |
| 121 | 122 | .op2 = args.op2, |