Skip to content

Commit 0ff8147

Browse files
committed
relaxes x86 operands deconstructor to address llvm changes
Occasionally, llvm refines their instruction definitions and change the number of operands, for example this [commit][1] added an extra destination register operand. For the old lifters we used a pretty strict rules for operands deconstructing and for the bts, btc, and btr instructions we were expecting two operands (now there are three of them). I decided to relax the deconstructor instead of changing the definition of instructions, first to preserve backward compatibility with the older versions of llvm and second because many other instructions could be affected by the same changes from the llvm side, and I don't see any harm if we will accept instructions with one more argument, knowing that destinations are always prepended. [1]: llvm/llvm-project@fe96ff7
1 parent 5042075 commit 0ff8147

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

plugins/x86/x86_operands.ml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,16 @@ let m ~f mem insn =
2828

2929
let rr ~f mem insn =
3030
match Insn.ops insn with
31-
| [| Op.Reg reg1; Op.Reg reg2 |] -> f mem reg1 reg2
31+
| [| _; Op.Reg reg1; Op.Reg reg2 |]
32+
| [| Op.Reg reg1; Op.Reg reg2 |] ->
33+
f mem reg1 reg2
3234
| _ -> invalid_operands ~here:[%here] insn
3335

3436
let ri ~f mem insn =
3537
match Insn.ops insn with
36-
| [| Op.Reg reg; Op.Imm imm |] -> f mem reg imm
38+
| [| _; Op.Reg reg; Op.Imm imm |]
39+
| [| Op.Reg reg; Op.Imm imm |] ->
40+
f mem reg imm
3741
| _ -> invalid_operands ~here:[%here] insn
3842

3943
let ir ~f mem insn =

0 commit comments

Comments
 (0)