• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "x64_isa.h"
17 #include "insn.h"
18 
19 namespace maplebe {
20 namespace x64 {
FlipConditionOp(MOperator flippedOp)21 MOperator FlipConditionOp(MOperator flippedOp)
22 {
23     switch (flippedOp) {
24         case X64MOP_t::MOP_je_l:
25             return X64MOP_t::MOP_jne_l;
26         case X64MOP_t::MOP_jne_l:
27             return X64MOP_t::MOP_je_l;
28         case X64MOP_t::MOP_ja_l:
29             return X64MOP_t::MOP_jbe_l;
30         case X64MOP_t::MOP_jbe_l:
31             return X64MOP_t::MOP_ja_l;
32         case X64MOP_t::MOP_jae_l:
33             return X64MOP_t::MOP_jb_l;
34         case X64MOP_t::MOP_jb_l:
35             return X64MOP_t::MOP_jae_l;
36         case X64MOP_t::MOP_jg_l:
37             return X64MOP_t::MOP_jle_l;
38         case X64MOP_t::MOP_jle_l:
39             return X64MOP_t::MOP_jg_l;
40         case X64MOP_t::MOP_jge_l:
41             return X64MOP_t::MOP_jl_l;
42         case X64MOP_t::MOP_jl_l:
43             return X64MOP_t::MOP_jge_l;
44         default:
45             break;
46     }
47     return X64MOP_t::MOP_begin;
48 }
49 
GetJumpTargetIdx(const Insn & insn)50 uint32 GetJumpTargetIdx(const Insn &insn)
51 {
52     CHECK_FATAL(insn.IsCondBranch() || insn.IsUnCondBranch(), "Not a jump insn");
53     return kInsnFirstOpnd;
54 }
55 } /* namespace x64 */
56 } /* namespace maplebe */
57