authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-03-12 08:47:23+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-03-12 08:47:23+01:00
log955e394792af69fc8c795802c0165e5c86f5ea73
tree501cf12f3af5a7d4c25f8273a65a4b21ba9e98cf
parent707a74655be9fd702cb1be84baa719b29435fcf7

x86_64: fix 32bit build issues in the encoder


1 files changed, 4 insertions(+), 3 deletions(-)

src/arch/x86_64/Encoding.zig+4-3
...@@ -105,6 +105,7 @@ pub fn findByMnemonic(mnemonic: Mnemonic, args: struct {...@@ -105,6 +105,7 @@ pub fn findByMnemonic(mnemonic: Mnemonic, args: struct {
105 }105 }
106106
107 if (count == 0) return null;107 if (count == 0) return null;
108 if (count == 1) return candidates[0];
108109
109 const EncodingLength = struct {110 const EncodingLength = struct {
110 fn estimate(encoding: Encoding, params: struct {111 fn estimate(encoding: Encoding, params: struct {
...@@ -112,7 +113,7 @@ pub fn findByMnemonic(mnemonic: Mnemonic, args: struct {...@@ -112,7 +113,7 @@ pub fn findByMnemonic(mnemonic: Mnemonic, args: struct {
112 op2: Instruction.Operand,113 op2: Instruction.Operand,
113 op3: Instruction.Operand,114 op3: Instruction.Operand,
114 op4: Instruction.Operand,115 op4: Instruction.Operand,
115 }) !usize {116 }) usize {
116 var inst = Instruction{117 var inst = Instruction{
117 .op1 = params.op1,118 .op1 = params.op1,
118 .op2 = params.op2,119 .op2 = params.op2,
...@@ -122,7 +123,7 @@ pub fn findByMnemonic(mnemonic: Mnemonic, args: struct {...@@ -122,7 +123,7 @@ pub fn findByMnemonic(mnemonic: Mnemonic, args: struct {
122 };123 };
123 var cwriter = std.io.countingWriter(std.io.null_writer);124 var cwriter = std.io.countingWriter(std.io.null_writer);
124 inst.encode(cwriter.writer()) catch unreachable; // Not allowed to fail here unless OOM.125 inst.encode(cwriter.writer()) catch unreachable; // Not allowed to fail here unless OOM.
125 return cwriter.bytes_written;126 return @intCast(usize, cwriter.bytes_written);
126 }127 }
127 };128 };
128129
...@@ -138,7 +139,7 @@ pub fn findByMnemonic(mnemonic: Mnemonic, args: struct {...@@ -138,7 +139,7 @@ pub fn findByMnemonic(mnemonic: Mnemonic, args: struct {
138 else => {},139 else => {},
139 }140 }
140141
141 const len = try EncodingLength.estimate(candidate, .{142 const len = EncodingLength.estimate(candidate, .{
142 .op1 = args.op1,143 .op1 = args.op1,
143 .op2 = args.op2,144 .op2 = args.op2,
144 .op3 = args.op3,145 .op3 = args.op3,