1 // Copyright 2006 The Android Open Source Project
8 // Note: this list of opcodes must match the list used to initialize
9 // the opflags[] array in opcode.cpp.
67 // Define thumb opcodes
107 OP_END // must be last
110 extern uint32_t opcode_flags[];
111 extern const char *opcode_names[];
113 // Define bit flags for the opcode categories
114 static const uint32_t kCatByte = 0x0001;
115 static const uint32_t kCatHalf = 0x0002;
116 static const uint32_t kCatWord = 0x0004;
117 static const uint32_t kCatLong = 0x0008;
118 static const uint32_t kCatNumBytes = (kCatByte | kCatHalf | kCatWord | kCatLong);
119 static const uint32_t kCatMultiple = 0x0010;
120 static const uint32_t kCatSigned = 0x0020;
121 static const uint32_t kCatLoad = 0x0040;
122 static const uint32_t kCatStore = 0x0080;
123 static const uint32_t kCatMemoryRef = (kCatLoad | kCatStore);
124 static const uint32_t kCatAlu = 0x0100;
125 static const uint32_t kCatBranch = 0x0200;
126 static const uint32_t kCatBranchLink = 0x0400;
127 static const uint32_t kCatBranchExch = 0x0800;
128 static const uint32_t kCatCoproc = 0x1000;
129 static const uint32_t kCatLoadMultiple = (kCatLoad | kCatMultiple);
130 static const uint32_t kCatStoreMultiple = (kCatStore | kCatMultiple);
132 inline bool isALU(Opcode op) { return (opcode_flags[op] & kCatAlu) != 0; }
133 inline bool isBranch(Opcode op) { return (opcode_flags[op] & kCatBranch) != 0; }
134 inline bool isBranchLink(Opcode op) {
135 return (opcode_flags[op] & kCatBranchLink) != 0;
137 inline bool isBranchExch(Opcode op) {
138 return (opcode_flags[op] & kCatBranchExch) != 0;
140 inline bool isLoad(Opcode op) { return (opcode_flags[op] & kCatLoad) != 0; }
141 inline bool isLoadMultiple(Opcode op) {
142 return (opcode_flags[op] & kCatLoadMultiple) == kCatLoadMultiple;
144 inline bool isStoreMultiple(Opcode op) {
145 return (opcode_flags[op] & kCatStoreMultiple) == kCatStoreMultiple;
147 inline bool isStore(Opcode op) { return (opcode_flags[op] & kCatStore) != 0; }
148 inline bool isSigned(Opcode op) { return (opcode_flags[op] & kCatSigned) != 0; }
149 inline bool isMemoryRef(Opcode op) {
150 return (opcode_flags[op] & kCatMemoryRef) != 0;
152 inline int getAccessSize(Opcode op) { return opcode_flags[op] & kCatNumBytes; }
153 inline bool isCoproc(Opcode op) { return (opcode_flags[op] & kCatCoproc) != 0; }
154 inline int getNumAccesses(Opcode op, uint32_t binary) {
155 extern int num_one_bits[];
156 int num_accesses = 0;
157 if (opcode_flags[op] & kCatNumBytes)
159 else if (opcode_flags[op] & kCatMultiple) {
160 num_accesses = num_one_bits[(binary >> 8) & 0xff]
161 + num_one_bits[binary & 0xff];