/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[] = { SystemZ_FeatureExecutionHint, |
24 | | SystemZ_FeatureLoadAndTrap, |
25 | | SystemZ_FeatureMiscellaneousExtensions, |
26 | | SystemZ_FeatureProcessorAssist, |
27 | | SystemZ_FeatureTransactionalExecution, |
28 | | SystemZ_FeatureDFPZonedConversion, |
29 | | SystemZ_FeatureEnhancedDAT2 }; |
30 | | |
31 | | static int systemz_arch11_features[] = { |
32 | | SystemZ_FeatureLoadAndZeroRightmostByte, |
33 | | SystemZ_FeatureLoadStoreOnCond2, SystemZ_FeatureMessageSecurityAssist5, |
34 | | SystemZ_FeatureDFPPackedConversion, SystemZ_FeatureVector |
35 | | }; |
36 | | |
37 | | static int systemz_arch12_features[] = { |
38 | | SystemZ_FeatureMiscellaneousExtensions2, |
39 | | SystemZ_FeatureGuardedStorage, |
40 | | SystemZ_FeatureMessageSecurityAssist7, |
41 | | SystemZ_FeatureMessageSecurityAssist8, |
42 | | SystemZ_FeatureVectorEnhancements1, |
43 | | SystemZ_FeatureVectorPackedDecimal, |
44 | | SystemZ_FeatureInsertReferenceBitsMultiple |
45 | | }; |
46 | | |
47 | | static int systemz_arch13_features[] = { |
48 | | SystemZ_FeatureMiscellaneousExtensions3, |
49 | | SystemZ_FeatureMessageSecurityAssist9, |
50 | | SystemZ_FeatureVectorEnhancements2, |
51 | | SystemZ_FeatureVectorPackedDecimalEnhancement, |
52 | | SystemZ_FeatureEnhancedSort, |
53 | | SystemZ_FeatureDeflateConversion |
54 | | }; |
55 | | |
56 | | static int systemz_arch14_features[] = { |
57 | | SystemZ_FeatureVectorPackedDecimalEnhancement2, |
58 | | SystemZ_FeatureNNPAssist, SystemZ_FeatureBEAREnhancement, |
59 | | SystemZ_FeatureResetDATProtection, |
60 | | SystemZ_FeatureProcessorActivityInstrumentation |
61 | | }; |
62 | | |
63 | | bool SystemZ_getFeatureBits(unsigned int mode, unsigned int feature) |
64 | 28.5k | { |
65 | 28.5k | switch (mode & ~CS_MODE_BIG_ENDIAN) { |
66 | 0 | case CS_MODE_SYSTEMZ_ARCH14: |
67 | 0 | case CS_MODE_SYSTEMZ_Z16: |
68 | 0 | if (arr_exist_int(systemz_arch14_features, |
69 | 0 | ARR_SIZE(systemz_arch14_features), feature)) { |
70 | 0 | return true; |
71 | 0 | } |
72 | | // fallthrough |
73 | 0 | case CS_MODE_SYSTEMZ_ARCH13: |
74 | 0 | case CS_MODE_SYSTEMZ_Z15: |
75 | 0 | if (arr_exist_int(systemz_arch13_features, |
76 | 0 | ARR_SIZE(systemz_arch13_features), feature)) { |
77 | 0 | return true; |
78 | 0 | } |
79 | | // fallthrough |
80 | 0 | case CS_MODE_SYSTEMZ_ARCH12: |
81 | 0 | case CS_MODE_SYSTEMZ_Z14: |
82 | 0 | if (arr_exist_int(systemz_arch12_features, |
83 | 0 | ARR_SIZE(systemz_arch12_features), feature)) { |
84 | 0 | return true; |
85 | 0 | } |
86 | | // fallthrough |
87 | 0 | case CS_MODE_SYSTEMZ_ARCH11: |
88 | 0 | case CS_MODE_SYSTEMZ_Z13: |
89 | 0 | if (arr_exist_int(systemz_arch11_features, |
90 | 0 | 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, |
97 | 0 | ARR_SIZE(systemz_arch10_features), feature)) { |
98 | 0 | return true; |
99 | 0 | } |
100 | | // fallthrough |
101 | 0 | case CS_MODE_SYSTEMZ_ARCH9: |
102 | 0 | case CS_MODE_SYSTEMZ_Z196: |
103 | 0 | if (arr_exist_int(systemz_arch9_features, |
104 | 0 | ARR_SIZE(systemz_arch9_features), feature)) { |
105 | 0 | return true; |
106 | 0 | } |
107 | | // fallthrough |
108 | 0 | case CS_MODE_SYSTEMZ_GENERIC: |
109 | 0 | case CS_MODE_SYSTEMZ_ARCH8: |
110 | 0 | case CS_MODE_SYSTEMZ_Z10: |
111 | | // There are no features defined for Arch8 |
112 | 0 | return false; |
113 | 28.5k | default: |
114 | | // Default case is the "allow all features", which is normal Capstone behavior |
115 | | // until https://github.com/capstone-engine/capstone/issues/1992 is implemented. |
116 | 28.5k | return true; |
117 | 28.5k | } |
118 | 28.5k | } |