1 # Copyright (c) 2014 The Native Client Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 """Templates for grouping together similar proofs."""
10 def LockedRegWithRegOrMem16bit(mnemonic_name, bitness):
11 """Computes all 16 bit optionally locked reg, reg/mem ops.
17 instr reg16 mem/reg16.
19 Note: when locking is issued, the second operand must be memory and not a reg.
22 mnemonic_name: the mnemonic we are producing the pattern for.
23 bitness: the bitness of the architecture (32 or 64)
25 All possible disassembly sequences that follow the pattern.
27 assert bitness in (32, 64)
28 instr = proof_tools.MnemonicOp(mnemonic_name)
29 reg16 = proof_tools.GprOperands(bitness=bitness, operand_size=16)
30 mem = proof_tools.AllMemoryOperands(bitness=bitness)
31 lock = proof_tools.LockPrefix()
32 return (proof_tools.OpsProd(lock, instr, reg16, mem) |
33 proof_tools.OpsProd(instr, reg16, reg16 | mem))
36 def XmmYmmOrMemory3operand(mnemonic_name, bitness):
37 """Set of 3 operand xmm/ymm/memory ops (memory is a possible source operand).
41 instr xmm1/mem, xmm2, xmm3
43 instr ymm1/mem, ymm2, ymm3
46 mnemonic_name: the mnemonic we are producing the pattern for.
47 bitness: the bitness of the architecture (32 or 64)
49 All possible disassembly sequences that follow the pattern.
51 xmm = proof_tools.AllXMMOperands(bitness)
52 ymm = proof_tools.AllYMMOperands(bitness)
53 mem = proof_tools.AllMemoryOperands(bitness)
54 mnemonic = proof_tools.MnemonicOp(mnemonic_name)
56 return (proof_tools.OpsProd(mnemonic, (xmm | mem), xmm, xmm) |
57 proof_tools.OpsProd(mnemonic, (ymm | mem), ymm, ymm))