MCPcopy Create free account
hub / github.com/MJx0/KittyMemoryEx / decodeInsn

Function decodeInsn

KittyMemoryEx/KittyAsm.cpp:81–183  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79 /// name it is then a compiler warning rather than a silent "UNKNOWN" in reports.
80 std::string typeToString(EKittyInsnTypeArm32 t)
81 {
82#define CASE(x) \
83 case EKittyInsnTypeArm32::x: \
84 return #x;
85 switch (t)
86 {
87 CASE(UNKNOWN)
88 CASE(ADR)
89 CASE(ADR_REG)
90 CASE(ADD)
91 CASE(SUB)
92 CASE(SUB_SP_IMM)
93 CASE(MOV_IMM)
94 CASE(MOV_REG)
95 CASE(MOV_SHIFTED)
96 CASE(LDR)
97 CASE(STR)
98 CASE(LDRB)
99 CASE(STRB)
100 CASE(LDRH)
101 CASE(STRH)
102 CASE(LDRSH)
103 CASE(LDRSB)
104 CASE(LDR_LITERAL)
105 CASE(LDR_PC_REG)
106 CASE(B)
107 CASE(BL)
108 CASE(B_COND)
109 CASE(BX)
110 CASE(PUSH_SP)
111 CASE(POP_PC)
112 CASE(MOVW)
113 CASE(MOVT)
114 case EKittyInsnTypeArm32::COUNT: break; // sentinel, never a decoded type
115 }
116#undef CASE
117 return "UNKNOWN";
118 }
119
120 /// Width is a property of the *type*, not of the encoding, so it is answered
121 /// here rather than being recomputed at each call site - which is how byte-wide
122 /// accesses once came to be counted as pointer-width.
123 uint8_t loadStoreWidth(EKittyInsnTypeArm32 t)
124 {
125 switch (t)
126 {
127 case EKittyInsnTypeArm32::LDRB:
128 case EKittyInsnTypeArm32::STRB:
129 case EKittyInsnTypeArm32::LDRSB:
130 return 1;
131 case EKittyInsnTypeArm32::LDRH:
132 case EKittyInsnTypeArm32::STRH:
133 case EKittyInsnTypeArm32::LDRSH:
134 return 2;
135 case EKittyInsnTypeArm32::LDR:
136 case EKittyInsnTypeArm32::STR:
137 case EKittyInsnTypeArm32::LDR_LITERAL:
138 case EKittyInsnTypeArm32::LDR_PC_REG:

Callers

nothing calls this directly

Calls 10

decodeInsnTypeFunction · 0.85
typeToStringFunction · 0.85
bitFunction · 0.85
bitsFunction · 0.85
ror32Function · 0.85
regNameFunction · 0.85
signExtendFunction · 0.85
branchCondNameFunction · 0.85
xRegNameFunction · 0.85
wRegNameFunction · 0.85

Tested by

no test coverage detected