Files
lifting-bits-remill/remill/Arch/X86/Semantics/CMOV.cpp
T
Peter Goodman 99df2e19d4 Running clang-format on files with some additional custom scripts for… (#444)
* Running clang-format on files with some additional custom scripts for my style

* Fix missing unique_ptr in remill/BC/Optimizer.h

* Fixes and selective disabling of clang-format
2020-08-05 15:42:25 -04:00

157 lines
4.7 KiB
C++

/*
* Copyright (c) 2017 Trail of Bits, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
namespace {
template <typename D, typename S1>
DEF_SEM(CMOVNLE, D dst, S1 src1) {
WriteZExt(dst, Select(BAnd(BNot(FLAG_ZF), BXnor(FLAG_SF, FLAG_OF)),
Read(src1), TruncTo<S1>(Read(dst))));
return memory;
}
template <typename D, typename S1>
DEF_SEM(CMOVNS, D dst, S1 src1) {
WriteZExt(dst, Select(BNot(FLAG_SF), Read(src1), TruncTo<S1>(Read(dst))));
return memory;
}
template <typename D, typename S1>
DEF_SEM(CMOVL, D dst, S1 src1) {
WriteZExt(dst,
Select(BXor(FLAG_SF, FLAG_OF), Read(src1), TruncTo<S1>(Read(dst))));
return memory;
}
template <typename D, typename S1>
DEF_SEM(CMOVNP, D dst, S1 src1) {
WriteZExt(dst, Select(BNot(FLAG_PF), Read(src1), TruncTo<S1>(Read(dst))));
return memory;
}
template <typename D, typename S1>
DEF_SEM(CMOVNZ, D dst, S1 src1) {
WriteZExt(dst, Select(BNot(FLAG_ZF), Read(src1), TruncTo<S1>(Read(dst))));
return memory;
}
template <typename D, typename S1>
DEF_SEM(CMOVNB, D dst, S1 src1) {
WriteZExt(dst, Select(BNot(FLAG_CF), Read(src1), TruncTo<S1>(Read(dst))));
return memory;
}
template <typename D, typename S1>
DEF_SEM(CMOVNO, D dst, S1 src1) {
WriteZExt(dst, Select(BNot(FLAG_OF), Read(src1), TruncTo<S1>(Read(dst))));
return memory;
}
template <typename D, typename S1>
DEF_SEM(CMOVNL, D dst, S1 src1) {
WriteZExt(
dst, Select(BXnor(FLAG_SF, FLAG_OF), Read(src1), TruncTo<S1>(Read(dst))));
return memory;
}
template <typename D, typename S1>
DEF_SEM(CMOVNBE, D dst, S1 src1) {
WriteZExt(dst, Select(BNot(BOr(FLAG_CF, FLAG_ZF)), Read(src1),
TruncTo<S1>(Read(dst))));
return memory;
}
template <typename D, typename S1>
DEF_SEM(CMOVBE, D dst, S1 src1) {
WriteZExt(dst,
Select(BOr(FLAG_CF, FLAG_ZF), Read(src1), TruncTo<S1>(Read(dst))));
return memory;
}
template <typename D, typename S1>
DEF_SEM(CMOVZ, D dst, S1 src1) {
WriteZExt(dst, Select(FLAG_ZF, Read(src1), TruncTo<S1>(Read(dst))));
return memory;
}
template <typename D, typename S1>
DEF_SEM(CMOVP, D dst, S1 src1) {
WriteZExt(dst, Select(FLAG_PF, Read(src1), TruncTo<S1>(Read(dst))));
return memory;
}
template <typename D, typename S1>
DEF_SEM(CMOVS, D dst, S1 src1) {
WriteZExt(dst, Select(FLAG_SF, Read(src1), TruncTo<S1>(Read(dst))));
return memory;
}
template <typename D, typename S1>
DEF_SEM(CMOVO, D dst, S1 src1) {
WriteZExt(dst, Select(FLAG_OF, Read(src1), TruncTo<S1>(Read(dst))));
return memory;
}
template <typename D, typename S1>
DEF_SEM(CMOVB, D dst, S1 src1) {
WriteZExt(dst, Select(FLAG_CF, Read(src1), TruncTo<S1>(Read(dst))));
return memory;
}
template <typename D, typename S1>
DEF_SEM(CMOVLE, D dst, S1 src1) {
WriteZExt(dst, Select(BOr(FLAG_ZF, BXor(FLAG_SF, FLAG_OF)), Read(src1),
TruncTo<S1>(Read(dst))));
return memory;
}
} // namespace
DEF_ISEL_RnW_Mn(CMOVBE_GPRv_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