Coverage Report

Created: 2025-11-16 07:15

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/keystone/llvm/lib/Target/ARM/ARMFeatures.h
Line
Count
Source
1
//===-- ARMFeatures.h - Checks for ARM instruction features -----*- C++ -*-===//
2
//
3
//                     The LLVM Compiler Infrastructure
4
//
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
7
//
8
//===----------------------------------------------------------------------===//
9
//
10
// This file contains the code shared between ARM CodeGen and ARM MC
11
//
12
//===----------------------------------------------------------------------===//
13
14
#ifndef LLVM_LIB_TARGET_ARM_ARMFEATURES_H
15
#define LLVM_LIB_TARGET_ARM_ARMFEATURES_H
16
17
#include "MCTargetDesc/ARMMCTargetDesc.h"
18
19
namespace llvm_ks {
20
21
template<typename InstrType> // could be MachineInstr or MCInst
22
bool IsCPSRDead(InstrType *Instr);
23
24
template<typename InstrType> // could be MachineInstr or MCInst
25
213
inline bool isV8EligibleForIT(InstrType *Instr) {
26
213
  switch (Instr->getOpcode()) {
27
191
  default:
28
191
    return false;
29
9
  case ARM::tADC:
30
9
  case ARM::tADDi3:
31
9
  case ARM::tADDi8:
32
10
  case ARM::tADDrr:
33
10
  case ARM::tAND:
34
10
  case ARM::tASRri:
35
10
  case ARM::tASRrr:
36
10
  case ARM::tBIC:
37
10
  case ARM::tEOR:
38
10
  case ARM::tLSLri:
39
10
  case ARM::tLSLrr:
40
10
  case ARM::tLSRri:
41
10
  case ARM::tLSRrr:
42
10
  case ARM::tMOVi8:
43
10
  case ARM::tMUL:
44
10
  case ARM::tMVN:
45
10
  case ARM::tORR:
46
10
  case ARM::tROR:
47
10
  case ARM::tRSB:
48
12
  case ARM::tSBC:
49
12
  case ARM::tSUBi3:
50
12
  case ARM::tSUBi8:
51
12
  case ARM::tSUBrr:
52
    // Outside of an IT block, these set CPSR.
53
12
    return IsCPSRDead(Instr);
54
0
  case ARM::tADDrSPi:
55
0
  case ARM::tCMNz:
56
0
  case ARM::tCMPi8:
57
0
  case ARM::tCMPr:
58
0
  case ARM::tLDRBi:
59
0
  case ARM::tLDRBr:
60
0
  case ARM::tLDRHi:
61
0
  case ARM::tLDRHr:
62
0
  case ARM::tLDRSB:
63
0
  case ARM::tLDRSH:
64
3
  case ARM::tLDRi:
65
10
  case ARM::tLDRr:
66
10
  case ARM::tLDRspi:
67
10
  case ARM::tSTRBi:
68
10
  case ARM::tSTRBr:
69
10
  case ARM::tSTRHi:
70
10
  case ARM::tSTRHr:
71
10
  case ARM::tSTRi:
72
10
  case ARM::tSTRr:
73
10
  case ARM::tSTRspi:
74
10
  case ARM::tTST:
75
10
    return true;
76
// there are some "conditionally deprecated" opcodes
77
0
  case ARM::tADDspr:
78
0
  case ARM::tBLXr:
79
0
    return Instr->getOperand(2).getReg() != ARM::PC;
80
  // ADD PC, SP and BLX PC were always unpredictable,
81
  // now on top of it they're deprecated
82
0
  case ARM::tADDrSP:
83
0
  case ARM::tBX:
84
0
    return Instr->getOperand(0).getReg() != ARM::PC;
85
0
  case ARM::tADDhirr:
86
0
    return Instr->getOperand(0).getReg() != ARM::PC &&
87
0
           Instr->getOperand(2).getReg() != ARM::PC;
88
0
  case ARM::tCMPhir:
89
0
  case ARM::tMOVr:
90
0
    return Instr->getOperand(0).getReg() != ARM::PC &&
91
0
           Instr->getOperand(1).getReg() != ARM::PC;
92
213
  }
93
213
}
94
95
}
96
97
#endif