Ejemplo n.º 1
0
    def testOpsProd(self):
        ops1 = set([
            proof_tools.Operands(disasms=('a', )),
            proof_tools.Operands(disasms=('b', ))
        ])

        ops2 = set([
            proof_tools.Operands(disasms=('1', )),
            proof_tools.Operands(disasms=('2', ))
        ])

        ops3 = set([
            proof_tools.Operands(disasms=('i', )),
            proof_tools.Operands(disasms=('ii', ))
        ])

        self.assertEquals(
            set([
                proof_tools.Operands(disasms=('a', '1', 'i')),
                proof_tools.Operands(disasms=('a', '1', 'ii')),
                proof_tools.Operands(disasms=('a', '2', 'i')),
                proof_tools.Operands(disasms=('a', '2', 'ii')),
                proof_tools.Operands(disasms=('b', '1', 'i')),
                proof_tools.Operands(disasms=('b', '1', 'ii')),
                proof_tools.Operands(disasms=('b', '2', 'i')),
                proof_tools.Operands(disasms=('b', '2', 'ii'))
            ]), proof_tools.OpsProd(ops1, ops2, ops3))
Ejemplo n.º 2
0
def Validate(trie_diffs, bitness):
    """Validate that trie_diffs adds 16 bit shld/shrd in 32bit mode."""

    # No instructions should be removed for 32/64 bit DFAs.
    # No instructions should be added for 64 bit DFA because it already
    # contains 16 bit shld/shrd instructions.
    # in 32-bit mode, 16 bit shld/shrd should be added.
    # This is of the forms:
    # shld|shrd, imm|%cl, reg16, reg16|mem
    if bitness == 32:
        mnemonics = proof_tools.MnemonicOp('shld') | proof_tools.MnemonicOp(
            'shrd')
        reg16 = proof_tools.GprOperands(bitness=bitness, operand_size=16)
        mem = proof_tools.AllMemoryOperands(bitness=bitness)
        imm = proof_tools.ImmOp()
        cl = set([proof_tools.Operands(disasms=('%cl', ))])

        expected_adds = proof_tools.OpsProd(mnemonics, imm | cl, reg16,
                                            reg16 | mem)

    else:
        expected_adds = set()

    proof_tools.AssertDiffSetEquals(trie_diffs,
                                    expected_adds=expected_adds,
                                    expected_removes=set())
Ejemplo n.º 3
0
def Validate(trie_diffs, bitness):
    """Validates that all allowed patterns of vbroadcast* are added"""
    xmm = proof_tools.AllXMMOperands(bitness)
    ymm = proof_tools.AllYMMOperands(bitness)
    mem = proof_tools.AllMemoryOperands(bitness)

    # vbroadcastf128 and vbroadcastsd work with ymm registers.
    # vbroadcastsd can work with xmm or ymm registers.
    vbroadcastf128 = proof_tools.OpsProd(
        proof_tools.MnemonicOp('vbroadcastf128'), mem, ymm)
    vbroadcastsd = proof_tools.OpsProd(proof_tools.MnemonicOp('vbroadcastsd'),
                                       mem, ymm)
    vbroadcastss = proof_tools.OpsProd(proof_tools.MnemonicOp('vbroadcastss'),
                                       mem, xmm | ymm)

    proof_tools.AssertDiffSetEquals(
        trie_diffs,
        expected_adds=(vbroadcastf128 | vbroadcastsd | vbroadcastss),
        expected_removes=set())
Ejemplo n.º 4
0
def Validate(trie_diffs, bitness):
    """Validate the trie_diffs adds 16 bit movbe is added in 32bit mode."""

    # No instructions should be removed for 32/64 bit DFAs.
    # No instructions should be added for 64 bit DFA because it already
    # contains 16 bit movbe instructions.
    # in 32-bit mode, 16 bit movbe should be added.
    # This is of two forms:
    #   movbe mem, reg16
    #      or
    #   movbe reg16, mem
    if bitness == 32:
        mnemonic = proof_tools.MnemonicOp('movbe')
        reg16 = proof_tools.GprOperands(bitness=bitness, operand_size=16)
        mem = proof_tools.AllMemoryOperands(bitness=bitness)

        expected_adds = (proof_tools.OpsProd(mnemonic, mem, reg16)
                         | proof_tools.OpsProd(mnemonic, reg16, mem))
    else:
        expected_adds = set()

    proof_tools.AssertDiffSetEquals(trie_diffs,
                                    expected_adds=expected_adds,
                                    expected_removes=set())
Ejemplo n.º 5
0
def Validate(trie_diffs, bitness):
    """Validate the trie_diffs adds 16 bit bsr/bsf is added in 32bit mode."""

    # No instructions should be removed for 32/64 bit DFAs.
    # No instructions should be added for 64 bit DFA because it already
    # contains 16 bit bsr/bsf instructions.
    # in 32-bit mode, 16 bit bsr/bsf should be added.
    # This is of the forms:
    #   {bsr,bsf} mem16/reg16, reg16
    if bitness == 32:
        mnemonics = proof_tools.MnemonicOp('bsr') | proof_tools.MnemonicOp(
            'bsf')
        reg16 = proof_tools.GprOperands(bitness=bitness, operand_size=16)
        mem = proof_tools.AllMemoryOperands(bitness=bitness)
        expected_adds = proof_tools.OpsProd(mnemonics, reg16 | mem, reg16)
    else:
        expected_adds = set()

    proof_tools.AssertDiffSetEquals(trie_diffs,
                                    expected_adds=expected_adds,
                                    expected_removes=set())