Coverage Report

Created: 2025-07-01 07:03

/src/capstonenext/arch/SystemZ/SystemZDisassemblerExtension.c
Line
Count
Source (jump to first uncovered line)
1
/* Capstone Disassembly Engine */
2
/* By Rot127 <unisono@quyllur.org>, 2022-2023 */
3
4
#include <capstone/systemz.h>
5
#include "SystemZDisassemblerExtension.h"
6
#include "../../utils.h"
7
8
#include "SystemZMCTargetDesc.h"
9
10
static int systemz_arch9_features[] = {
11
  SystemZ_FeatureDistinctOps,
12
  SystemZ_FeatureFastSerialization,
13
  SystemZ_FeatureFPExtension,
14
  SystemZ_FeatureHighWord,
15
  SystemZ_FeatureInterlockedAccess1,
16
  SystemZ_FeatureLoadStoreOnCond,
17
  SystemZ_FeaturePopulationCount,
18
  SystemZ_FeatureMessageSecurityAssist3,
19
  SystemZ_FeatureMessageSecurityAssist4,
20
  SystemZ_FeatureResetReferenceBitsMultiple
21
};
22
23
static int systemz_arch10_features[] = {
24
  SystemZ_FeatureExecutionHint,
25
  SystemZ_FeatureLoadAndTrap,
26
  SystemZ_FeatureMiscellaneousExtensions,
27
  SystemZ_FeatureProcessorAssist,
28
  SystemZ_FeatureTransactionalExecution,
29
  SystemZ_FeatureDFPZonedConversion,
30
  SystemZ_FeatureEnhancedDAT2
31
};
32
33
static int systemz_arch11_features[] = {
34
  SystemZ_FeatureLoadAndZeroRightmostByte,
35
  SystemZ_FeatureLoadStoreOnCond2,
36
  SystemZ_FeatureMessageSecurityAssist5,
37
  SystemZ_FeatureDFPPackedConversion,
38
  SystemZ_FeatureVector
39
};
40
41
static int systemz_arch12_features[] = {
42
  SystemZ_FeatureMiscellaneousExtensions2,
43
  SystemZ_FeatureGuardedStorage,
44
  SystemZ_FeatureMessageSecurityAssist7,
45
  SystemZ_FeatureMessageSecurityAssist8,
46
  SystemZ_FeatureVectorEnhancements1,
47
  SystemZ_FeatureVectorPackedDecimal,
48
  SystemZ_FeatureInsertReferenceBitsMultiple
49
};
50
51
static int systemz_arch13_features[] = {
52
  SystemZ_FeatureMiscellaneousExtensions3,
53
  SystemZ_FeatureMessageSecurityAssist9,
54
  SystemZ_FeatureVectorEnhancements2,
55
  SystemZ_FeatureVectorPackedDecimalEnhancement,
56
  SystemZ_FeatureEnhancedSort,
57
  SystemZ_FeatureDeflateConversion
58
};
59
60
static int systemz_arch14_features[] = {
61
  SystemZ_FeatureVectorPackedDecimalEnhancement2,
62
  SystemZ_FeatureNNPAssist,
63
  SystemZ_FeatureBEAREnhancement,
64
  SystemZ_FeatureResetDATProtection,
65
  SystemZ_FeatureProcessorActivityInstrumentation
66
};
67
68
16.3k
bool SystemZ_getFeatureBits(unsigned int mode, unsigned int feature) {
69
16.3k
  switch (mode & ~CS_MODE_BIG_ENDIAN) {
70
0
  case CS_MODE_SYSTEMZ_ARCH14:
71
0
  case CS_MODE_SYSTEMZ_Z16:
72
0
    if (arr_exist_int(systemz_arch14_features, ARR_SIZE(systemz_arch14_features), feature)) {
73
0
      return true;
74
0
    }
75
    // fallthrough
76
0
  case CS_MODE_SYSTEMZ_ARCH13:
77
0
  case CS_MODE_SYSTEMZ_Z15:
78
0
    if (arr_exist_int(systemz_arch13_features, ARR_SIZE(systemz_arch13_features), feature)) {
79
0
      return true;
80
0
    }
81
    // fallthrough
82
0
  case CS_MODE_SYSTEMZ_ARCH12:
83
0
  case CS_MODE_SYSTEMZ_Z14:
84
0
    if (arr_exist_int(systemz_arch12_features, ARR_SIZE(systemz_arch12_features), feature)) {
85
0
      return true;
86
0
    }
87
    // fallthrough
88
0
  case CS_MODE_SYSTEMZ_ARCH11:
89
0
  case CS_MODE_SYSTEMZ_Z13:
90
0
    if (arr_exist_int(systemz_arch11_features, ARR_SIZE(systemz_arch11_features), feature)) {
91
0
      return true;
92
0
    }
93
    // fallthrough
94
0
  case CS_MODE_SYSTEMZ_ARCH10:
95
0
  case CS_MODE_SYSTEMZ_ZEC12:
96
0
    if (arr_exist_int(systemz_arch10_features, ARR_SIZE(systemz_arch10_features), feature)) {
97
0
      return true;
98
0
    }
99
    // fallthrough
100
0
  case CS_MODE_SYSTEMZ_ARCH9:
101
0
  case CS_MODE_SYSTEMZ_Z196:
102
0
    if (arr_exist_int(systemz_arch9_features, ARR_SIZE(systemz_arch9_features), feature)) {
103
0
      return true;
104
0
    }
105
    // fallthrough
106
0
  case CS_MODE_SYSTEMZ_GENERIC:
107
0
  case CS_MODE_SYSTEMZ_ARCH8:
108
0
  case CS_MODE_SYSTEMZ_Z10:
109
    // There are no features defined for Arch8
110
0
    return false;
111
16.3k
  default:
112
    // Default case is the "allow all features", which is normal Capstone behavior
113
    // until https://github.com/capstone-engine/capstone/issues/1992 is implemented.
114
16.3k
    return true;
115
16.3k
  }
116
16.3k
}