/src/keystone/llvm/lib/Target/ARM/MCTargetDesc/ARMAddressingModes.h
Line | Count | Source |
1 | | //===-- ARMAddressingModes.h - ARM Addressing Modes -------------*- 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 ARM addressing mode implementation stuff. |
11 | | // |
12 | | //===----------------------------------------------------------------------===// |
13 | | |
14 | | #ifndef LLVM_LIB_TARGET_ARM_MCTARGETDESC_ARMADDRESSINGMODES_H |
15 | | #define LLVM_LIB_TARGET_ARM_MCTARGETDESC_ARMADDRESSINGMODES_H |
16 | | |
17 | | #include "llvm/ADT/APFloat.h" |
18 | | #include "llvm/ADT/APInt.h" |
19 | | #include "llvm/Support/ErrorHandling.h" |
20 | | #include "llvm/Support/MathExtras.h" |
21 | | #include <cassert> |
22 | | |
23 | | namespace llvm_ks { |
24 | | |
25 | | /// ARM_AM - ARM Addressing Mode Stuff |
26 | | namespace ARM_AM { |
27 | | enum ShiftOpc { |
28 | | no_shift = 0, |
29 | | asr, |
30 | | lsl, |
31 | | lsr, |
32 | | ror, |
33 | | rrx |
34 | | }; |
35 | | |
36 | | enum AddrOpc { |
37 | | sub = 0, |
38 | | add |
39 | | }; |
40 | | |
41 | 0 | static inline const char *getAddrOpcStr(AddrOpc Op) { |
42 | 0 | return Op == sub ? "-" : ""; |
43 | 0 | } Unexecuted instantiation: ARMAsmParser.cpp:llvm_ks::ARM_AM::getAddrOpcStr(llvm_ks::ARM_AM::AddrOpc) Unexecuted instantiation: ARMAsmBackend.cpp:llvm_ks::ARM_AM::getAddrOpcStr(llvm_ks::ARM_AM::AddrOpc) Unexecuted instantiation: ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::getAddrOpcStr(llvm_ks::ARM_AM::AddrOpc) |
44 | | |
45 | 0 | static inline const char *getShiftOpcStr(ShiftOpc Op) { |
46 | 0 | switch (Op) { |
47 | 0 | default: llvm_unreachable("Unknown shift opc!"); |
48 | 0 | case ARM_AM::asr: return "asr"; |
49 | 0 | case ARM_AM::lsl: return "lsl"; |
50 | 0 | case ARM_AM::lsr: return "lsr"; |
51 | 0 | case ARM_AM::ror: return "ror"; |
52 | 0 | case ARM_AM::rrx: return "rrx"; |
53 | 0 | } |
54 | 0 | } Unexecuted instantiation: ARMAsmParser.cpp:llvm_ks::ARM_AM::getShiftOpcStr(llvm_ks::ARM_AM::ShiftOpc) Unexecuted instantiation: ARMAsmBackend.cpp:llvm_ks::ARM_AM::getShiftOpcStr(llvm_ks::ARM_AM::ShiftOpc) Unexecuted instantiation: ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::getShiftOpcStr(llvm_ks::ARM_AM::ShiftOpc) |
55 | | |
56 | 0 | static inline unsigned getShiftOpcEncoding(ShiftOpc Op) { |
57 | 0 | switch (Op) { |
58 | 0 | default: llvm_unreachable("Unknown shift opc!"); |
59 | 0 | case ARM_AM::asr: return 2; |
60 | 0 | case ARM_AM::lsl: return 0; |
61 | 0 | case ARM_AM::lsr: return 1; |
62 | 0 | case ARM_AM::ror: return 3; |
63 | 0 | } |
64 | 0 | } Unexecuted instantiation: ARMAsmParser.cpp:llvm_ks::ARM_AM::getShiftOpcEncoding(llvm_ks::ARM_AM::ShiftOpc) Unexecuted instantiation: ARMAsmBackend.cpp:llvm_ks::ARM_AM::getShiftOpcEncoding(llvm_ks::ARM_AM::ShiftOpc) Unexecuted instantiation: ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::getShiftOpcEncoding(llvm_ks::ARM_AM::ShiftOpc) |
65 | | |
66 | | enum AMSubMode { |
67 | | bad_am_submode = 0, |
68 | | ia, |
69 | | ib, |
70 | | da, |
71 | | db |
72 | | }; |
73 | | |
74 | 0 | static inline const char *getAMSubModeStr(AMSubMode Mode) { |
75 | 0 | switch (Mode) { |
76 | 0 | default: llvm_unreachable("Unknown addressing sub-mode!"); |
77 | 0 | case ARM_AM::ia: return "ia"; |
78 | 0 | case ARM_AM::ib: return "ib"; |
79 | 0 | case ARM_AM::da: return "da"; |
80 | 0 | case ARM_AM::db: return "db"; |
81 | 0 | } |
82 | 0 | } Unexecuted instantiation: ARMAsmParser.cpp:llvm_ks::ARM_AM::getAMSubModeStr(llvm_ks::ARM_AM::AMSubMode) Unexecuted instantiation: ARMAsmBackend.cpp:llvm_ks::ARM_AM::getAMSubModeStr(llvm_ks::ARM_AM::AMSubMode) Unexecuted instantiation: ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::getAMSubModeStr(llvm_ks::ARM_AM::AMSubMode) |
83 | | |
84 | | /// rotr32 - Rotate a 32-bit unsigned value right by a specified # bits. |
85 | | /// |
86 | 29.9k | static inline unsigned rotr32(unsigned Val, unsigned Amt) { |
87 | 29.9k | assert(Amt < 32 && "Invalid rotate amount"); |
88 | 29.9k | return (Val >> Amt) | (Val << ((32-Amt)&31)); |
89 | 29.9k | } ARMAsmParser.cpp:llvm_ks::ARM_AM::rotr32(unsigned int, unsigned int) Line | Count | Source | 86 | 23.5k | static inline unsigned rotr32(unsigned Val, unsigned Amt) { | 87 | 23.5k | assert(Amt < 32 && "Invalid rotate amount"); | 88 | 23.5k | return (Val >> Amt) | (Val << ((32-Amt)&31)); | 89 | 23.5k | } |
ARMAsmBackend.cpp:llvm_ks::ARM_AM::rotr32(unsigned int, unsigned int) Line | Count | Source | 86 | 4.39k | static inline unsigned rotr32(unsigned Val, unsigned Amt) { | 87 | 4.39k | assert(Amt < 32 && "Invalid rotate amount"); | 88 | 4.39k | return (Val >> Amt) | (Val << ((32-Amt)&31)); | 89 | 4.39k | } |
ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::rotr32(unsigned int, unsigned int) Line | Count | Source | 86 | 2.04k | static inline unsigned rotr32(unsigned Val, unsigned Amt) { | 87 | 2.04k | assert(Amt < 32 && "Invalid rotate amount"); | 88 | 2.04k | return (Val >> Amt) | (Val << ((32-Amt)&31)); | 89 | 2.04k | } |
|
90 | | |
91 | | /// rotl32 - Rotate a 32-bit unsigned value left by a specified # bits. |
92 | | /// |
93 | 1.88k | static inline unsigned rotl32(unsigned Val, unsigned Amt) { |
94 | 1.88k | assert(Amt < 32 && "Invalid rotate amount"); |
95 | 1.88k | return (Val << Amt) | (Val >> ((32-Amt)&31)); |
96 | 1.88k | } ARMAsmParser.cpp:llvm_ks::ARM_AM::rotl32(unsigned int, unsigned int) Line | Count | Source | 93 | 976 | static inline unsigned rotl32(unsigned Val, unsigned Amt) { | 94 | 976 | assert(Amt < 32 && "Invalid rotate amount"); | 95 | 976 | return (Val << Amt) | (Val >> ((32-Amt)&31)); | 96 | 976 | } |
ARMAsmBackend.cpp:llvm_ks::ARM_AM::rotl32(unsigned int, unsigned int) Line | Count | Source | 93 | 612 | static inline unsigned rotl32(unsigned Val, unsigned Amt) { | 94 | 612 | assert(Amt < 32 && "Invalid rotate amount"); | 95 | 612 | return (Val << Amt) | (Val >> ((32-Amt)&31)); | 96 | 612 | } |
ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::rotl32(unsigned int, unsigned int) Line | Count | Source | 93 | 292 | static inline unsigned rotl32(unsigned Val, unsigned Amt) { | 94 | 292 | assert(Amt < 32 && "Invalid rotate amount"); | 95 | 292 | return (Val << Amt) | (Val >> ((32-Amt)&31)); | 96 | 292 | } |
|
97 | | |
98 | | //===--------------------------------------------------------------------===// |
99 | | // Addressing Mode #1: shift_operand with registers |
100 | | //===--------------------------------------------------------------------===// |
101 | | // |
102 | | // This 'addressing mode' is used for arithmetic instructions. It can |
103 | | // represent things like: |
104 | | // reg |
105 | | // reg [asr|lsl|lsr|ror|rrx] reg |
106 | | // reg [asr|lsl|lsr|ror|rrx] imm |
107 | | // |
108 | | // This is stored three operands [rega, regb, opc]. The first is the base |
109 | | // reg, the second is the shift amount (or reg0 if not present or imm). The |
110 | | // third operand encodes the shift opcode and the imm if a reg isn't present. |
111 | | // |
112 | 3.85k | static inline unsigned getSORegOpc(ShiftOpc ShOp, unsigned Imm) { |
113 | 3.85k | return ShOp | (Imm << 3); |
114 | 3.85k | } ARMAsmParser.cpp:llvm_ks::ARM_AM::getSORegOpc(llvm_ks::ARM_AM::ShiftOpc, unsigned int) Line | Count | Source | 112 | 3.85k | static inline unsigned getSORegOpc(ShiftOpc ShOp, unsigned Imm) { | 113 | 3.85k | return ShOp | (Imm << 3); | 114 | 3.85k | } |
Unexecuted instantiation: ARMAsmBackend.cpp:llvm_ks::ARM_AM::getSORegOpc(llvm_ks::ARM_AM::ShiftOpc, unsigned int) Unexecuted instantiation: ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::getSORegOpc(llvm_ks::ARM_AM::ShiftOpc, unsigned int) |
115 | 3.28k | static inline unsigned getSORegOffset(unsigned Op) { |
116 | 3.28k | return Op >> 3; |
117 | 3.28k | } ARMAsmParser.cpp:llvm_ks::ARM_AM::getSORegOffset(unsigned int) Line | Count | Source | 115 | 993 | static inline unsigned getSORegOffset(unsigned Op) { | 116 | 993 | return Op >> 3; | 117 | 993 | } |
Unexecuted instantiation: ARMAsmBackend.cpp:llvm_ks::ARM_AM::getSORegOffset(unsigned int) ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::getSORegOffset(unsigned int) Line | Count | Source | 115 | 2.28k | static inline unsigned getSORegOffset(unsigned Op) { | 116 | 2.28k | return Op >> 3; | 117 | 2.28k | } |
|
118 | 4.23k | static inline ShiftOpc getSORegShOp(unsigned Op) { |
119 | 4.23k | return (ShiftOpc)(Op & 7); |
120 | 4.23k | } ARMAsmParser.cpp:llvm_ks::ARM_AM::getSORegShOp(unsigned int) Line | Count | Source | 118 | 1.49k | static inline ShiftOpc getSORegShOp(unsigned Op) { | 119 | 1.49k | return (ShiftOpc)(Op & 7); | 120 | 1.49k | } |
Unexecuted instantiation: ARMAsmBackend.cpp:llvm_ks::ARM_AM::getSORegShOp(unsigned int) ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::getSORegShOp(unsigned int) Line | Count | Source | 118 | 2.73k | static inline ShiftOpc getSORegShOp(unsigned Op) { | 119 | 2.73k | return (ShiftOpc)(Op & 7); | 120 | 2.73k | } |
|
121 | | |
122 | | /// getSOImmValImm - Given an encoded imm field for the reg/imm form, return |
123 | | /// the 8-bit imm value. |
124 | 0 | static inline unsigned getSOImmValImm(unsigned Imm) { |
125 | 0 | return Imm & 0xFF; |
126 | 0 | } Unexecuted instantiation: ARMAsmParser.cpp:llvm_ks::ARM_AM::getSOImmValImm(unsigned int) Unexecuted instantiation: ARMAsmBackend.cpp:llvm_ks::ARM_AM::getSOImmValImm(unsigned int) Unexecuted instantiation: ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::getSOImmValImm(unsigned int) |
127 | | /// getSOImmValRot - Given an encoded imm field for the reg/imm form, return |
128 | | /// the rotate amount. |
129 | 0 | static inline unsigned getSOImmValRot(unsigned Imm) { |
130 | 0 | return (Imm >> 8) * 2; |
131 | 0 | } Unexecuted instantiation: ARMAsmParser.cpp:llvm_ks::ARM_AM::getSOImmValRot(unsigned int) Unexecuted instantiation: ARMAsmBackend.cpp:llvm_ks::ARM_AM::getSOImmValRot(unsigned int) Unexecuted instantiation: ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::getSOImmValRot(unsigned int) |
132 | | |
133 | | /// getSOImmValRotate - Try to handle Imm with an immediate shifter operand, |
134 | | /// computing the rotate amount to use. If this immediate value cannot be |
135 | | /// handled with a single shifter-op, determine a good rotate amount that will |
136 | | /// take a maximal chunk of bits out of the immediate. |
137 | 7.38k | static inline unsigned getSOImmValRotate(unsigned Imm) { |
138 | | // 8-bit (or less) immediates are trivially shifter_operands with a rotate |
139 | | // of zero. |
140 | 7.38k | if ((Imm & ~255U) == 0) return 0; |
141 | | |
142 | | // Use CTZ to compute the rotate amount. |
143 | 7.38k | unsigned TZ = countTrailingZeros(Imm); |
144 | | |
145 | | // Rotate amount must be even. Something like 0x200 must be rotated 8 bits, |
146 | | // not 9. |
147 | 7.38k | unsigned RotAmt = TZ & ~1; |
148 | | |
149 | | // If we can handle this spread, return it. |
150 | 7.38k | if ((rotr32(Imm, RotAmt) & ~255U) == 0) |
151 | 1.53k | return (32-RotAmt)&31; // HW rotates right, not left. |
152 | | |
153 | | // For values like 0xF000000F, we should ignore the low 6 bits, then |
154 | | // retry the hunt. |
155 | 5.84k | if (Imm & 63U) { |
156 | 5.13k | unsigned TZ2 = countTrailingZeros(Imm & ~63U); |
157 | 5.13k | unsigned RotAmt2 = TZ2 & ~1; |
158 | 5.13k | if ((rotr32(Imm, RotAmt2) & ~255U) == 0) |
159 | 341 | return (32-RotAmt2)&31; // HW rotates right, not left. |
160 | 5.13k | } |
161 | | |
162 | | // Otherwise, we have no way to cover this span of bits with a single |
163 | | // shifter_op immediate. Return a chunk of bits that will be useful to |
164 | | // handle. |
165 | 5.50k | return (32-RotAmt)&31; // HW rotates right, not left. |
166 | 5.84k | } ARMAsmParser.cpp:llvm_ks::ARM_AM::getSOImmValRotate(unsigned int) Line | Count | Source | 137 | 5.33k | static inline unsigned getSOImmValRotate(unsigned Imm) { | 138 | | // 8-bit (or less) immediates are trivially shifter_operands with a rotate | 139 | | // of zero. | 140 | 5.33k | if ((Imm & ~255U) == 0) return 0; | 141 | | | 142 | | // Use CTZ to compute the rotate amount. | 143 | 5.33k | unsigned TZ = countTrailingZeros(Imm); | 144 | | | 145 | | // Rotate amount must be even. Something like 0x200 must be rotated 8 bits, | 146 | | // not 9. | 147 | 5.33k | unsigned RotAmt = TZ & ~1; | 148 | | | 149 | | // If we can handle this spread, return it. | 150 | 5.33k | if ((rotr32(Imm, RotAmt) & ~255U) == 0) | 151 | 784 | return (32-RotAmt)&31; // HW rotates right, not left. | 152 | | | 153 | | // For values like 0xF000000F, we should ignore the low 6 bits, then | 154 | | // retry the hunt. | 155 | 4.55k | if (Imm & 63U) { | 156 | 3.88k | unsigned TZ2 = countTrailingZeros(Imm & ~63U); | 157 | 3.88k | unsigned RotAmt2 = TZ2 & ~1; | 158 | 3.88k | if ((rotr32(Imm, RotAmt2) & ~255U) == 0) | 159 | 192 | return (32-RotAmt2)&31; // HW rotates right, not left. | 160 | 3.88k | } | 161 | | | 162 | | // Otherwise, we have no way to cover this span of bits with a single | 163 | | // shifter_op immediate. Return a chunk of bits that will be useful to | 164 | | // handle. | 165 | 4.36k | return (32-RotAmt)&31; // HW rotates right, not left. | 166 | 4.55k | } |
ARMAsmBackend.cpp:llvm_ks::ARM_AM::getSOImmValRotate(unsigned int) Line | Count | Source | 137 | 1.68k | static inline unsigned getSOImmValRotate(unsigned Imm) { | 138 | | // 8-bit (or less) immediates are trivially shifter_operands with a rotate | 139 | | // of zero. | 140 | 1.68k | if ((Imm & ~255U) == 0) return 0; | 141 | | | 142 | | // Use CTZ to compute the rotate amount. | 143 | 1.68k | unsigned TZ = countTrailingZeros(Imm); | 144 | | | 145 | | // Rotate amount must be even. Something like 0x200 must be rotated 8 bits, | 146 | | // not 9. | 147 | 1.68k | unsigned RotAmt = TZ & ~1; | 148 | | | 149 | | // If we can handle this spread, return it. | 150 | 1.68k | if ((rotr32(Imm, RotAmt) & ~255U) == 0) | 151 | 609 | return (32-RotAmt)&31; // HW rotates right, not left. | 152 | | | 153 | | // For values like 0xF000000F, we should ignore the low 6 bits, then | 154 | | // retry the hunt. | 155 | 1.07k | if (Imm & 63U) { | 156 | 1.03k | unsigned TZ2 = countTrailingZeros(Imm & ~63U); | 157 | 1.03k | unsigned RotAmt2 = TZ2 & ~1; | 158 | 1.03k | if ((rotr32(Imm, RotAmt2) & ~255U) == 0) | 159 | 3 | return (32-RotAmt2)&31; // HW rotates right, not left. | 160 | 1.03k | } | 161 | | | 162 | | // Otherwise, we have no way to cover this span of bits with a single | 163 | | // shifter_op immediate. Return a chunk of bits that will be useful to | 164 | | // handle. | 165 | 1.06k | return (32-RotAmt)&31; // HW rotates right, not left. | 166 | 1.07k | } |
ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::getSOImmValRotate(unsigned int) Line | Count | Source | 137 | 367 | static inline unsigned getSOImmValRotate(unsigned Imm) { | 138 | | // 8-bit (or less) immediates are trivially shifter_operands with a rotate | 139 | | // of zero. | 140 | 367 | if ((Imm & ~255U) == 0) return 0; | 141 | | | 142 | | // Use CTZ to compute the rotate amount. | 143 | 367 | unsigned TZ = countTrailingZeros(Imm); | 144 | | | 145 | | // Rotate amount must be even. Something like 0x200 must be rotated 8 bits, | 146 | | // not 9. | 147 | 367 | unsigned RotAmt = TZ & ~1; | 148 | | | 149 | | // If we can handle this spread, return it. | 150 | 367 | if ((rotr32(Imm, RotAmt) & ~255U) == 0) | 151 | 146 | return (32-RotAmt)&31; // HW rotates right, not left. | 152 | | | 153 | | // For values like 0xF000000F, we should ignore the low 6 bits, then | 154 | | // retry the hunt. | 155 | 221 | if (Imm & 63U) { | 156 | 221 | unsigned TZ2 = countTrailingZeros(Imm & ~63U); | 157 | 221 | unsigned RotAmt2 = TZ2 & ~1; | 158 | 221 | if ((rotr32(Imm, RotAmt2) & ~255U) == 0) | 159 | 146 | return (32-RotAmt2)&31; // HW rotates right, not left. | 160 | 221 | } | 161 | | | 162 | | // Otherwise, we have no way to cover this span of bits with a single | 163 | | // shifter_op immediate. Return a chunk of bits that will be useful to | 164 | | // handle. | 165 | 75 | return (32-RotAmt)&31; // HW rotates right, not left. | 166 | 221 | } |
|
167 | | |
168 | | /// getSOImmVal - Given a 32-bit immediate, if it is something that can fit |
169 | | /// into an shifter_operand immediate operand, return the 12-bit encoding for |
170 | | /// it. If not, return -1. |
171 | 15.4k | static inline int getSOImmVal(unsigned Arg) { |
172 | | // 8-bit (or less) immediates are trivially shifter_operands with a rotate |
173 | | // of zero. |
174 | 15.4k | if ((Arg & ~255U) == 0) return Arg; |
175 | | |
176 | 7.38k | unsigned RotAmt = getSOImmValRotate(Arg); |
177 | | |
178 | | // If this cannot be handled with a single shifter_op, bail out. |
179 | 7.38k | if (rotr32(~255U, RotAmt) & Arg) |
180 | 5.50k | return -1; |
181 | | |
182 | | // Encode this correctly. |
183 | 1.88k | return rotl32(Arg, RotAmt) | ((RotAmt>>1) << 8); |
184 | 7.38k | } ARMAsmParser.cpp:llvm_ks::ARM_AM::getSOImmVal(unsigned int) Line | Count | Source | 171 | 11.4k | static inline int getSOImmVal(unsigned Arg) { | 172 | | // 8-bit (or less) immediates are trivially shifter_operands with a rotate | 173 | | // of zero. | 174 | 11.4k | if ((Arg & ~255U) == 0) return Arg; | 175 | | | 176 | 5.33k | unsigned RotAmt = getSOImmValRotate(Arg); | 177 | | | 178 | | // If this cannot be handled with a single shifter_op, bail out. | 179 | 5.33k | if (rotr32(~255U, RotAmt) & Arg) | 180 | 4.36k | return -1; | 181 | | | 182 | | // Encode this correctly. | 183 | 976 | return rotl32(Arg, RotAmt) | ((RotAmt>>1) << 8); | 184 | 5.33k | } |
ARMAsmBackend.cpp:llvm_ks::ARM_AM::getSOImmVal(unsigned int) Line | Count | Source | 171 | 2.91k | static inline int getSOImmVal(unsigned Arg) { | 172 | | // 8-bit (or less) immediates are trivially shifter_operands with a rotate | 173 | | // of zero. | 174 | 2.91k | if ((Arg & ~255U) == 0) return Arg; | 175 | | | 176 | 1.68k | unsigned RotAmt = getSOImmValRotate(Arg); | 177 | | | 178 | | // If this cannot be handled with a single shifter_op, bail out. | 179 | 1.68k | if (rotr32(~255U, RotAmt) & Arg) | 180 | 1.06k | return -1; | 181 | | | 182 | | // Encode this correctly. | 183 | 612 | return rotl32(Arg, RotAmt) | ((RotAmt>>1) << 8); | 184 | 1.68k | } |
ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::getSOImmVal(unsigned int) Line | Count | Source | 171 | 1.04k | static inline int getSOImmVal(unsigned Arg) { | 172 | | // 8-bit (or less) immediates are trivially shifter_operands with a rotate | 173 | | // of zero. | 174 | 1.04k | if ((Arg & ~255U) == 0) return Arg; | 175 | | | 176 | 367 | unsigned RotAmt = getSOImmValRotate(Arg); | 177 | | | 178 | | // If this cannot be handled with a single shifter_op, bail out. | 179 | 367 | if (rotr32(~255U, RotAmt) & Arg) | 180 | 75 | return -1; | 181 | | | 182 | | // Encode this correctly. | 183 | 292 | return rotl32(Arg, RotAmt) | ((RotAmt>>1) << 8); | 184 | 367 | } |
|
185 | | |
186 | | /// isSOImmTwoPartVal - Return true if the specified value can be obtained by |
187 | | /// or'ing together two SOImmVal's. |
188 | 0 | static inline bool isSOImmTwoPartVal(unsigned V) { |
189 | 0 | // If this can be handled with a single shifter_op, bail out. |
190 | 0 | V = rotr32(~255U, getSOImmValRotate(V)) & V; |
191 | 0 | if (V == 0) |
192 | 0 | return false; |
193 | 0 |
|
194 | 0 | // If this can be handled with two shifter_op's, accept. |
195 | 0 | V = rotr32(~255U, getSOImmValRotate(V)) & V; |
196 | 0 | return V == 0; |
197 | 0 | } Unexecuted instantiation: ARMAsmParser.cpp:llvm_ks::ARM_AM::isSOImmTwoPartVal(unsigned int) Unexecuted instantiation: ARMAsmBackend.cpp:llvm_ks::ARM_AM::isSOImmTwoPartVal(unsigned int) Unexecuted instantiation: ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::isSOImmTwoPartVal(unsigned int) |
198 | | |
199 | | /// getSOImmTwoPartFirst - If V is a value that satisfies isSOImmTwoPartVal, |
200 | | /// return the first chunk of it. |
201 | 0 | static inline unsigned getSOImmTwoPartFirst(unsigned V) { |
202 | 0 | return rotr32(255U, getSOImmValRotate(V)) & V; |
203 | 0 | } Unexecuted instantiation: ARMAsmParser.cpp:llvm_ks::ARM_AM::getSOImmTwoPartFirst(unsigned int) Unexecuted instantiation: ARMAsmBackend.cpp:llvm_ks::ARM_AM::getSOImmTwoPartFirst(unsigned int) Unexecuted instantiation: ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::getSOImmTwoPartFirst(unsigned int) |
204 | | |
205 | | /// getSOImmTwoPartSecond - If V is a value that satisfies isSOImmTwoPartVal, |
206 | | /// return the second chunk of it. |
207 | 0 | static inline unsigned getSOImmTwoPartSecond(unsigned V) { |
208 | 0 | // Mask out the first hunk. |
209 | 0 | V = rotr32(~255U, getSOImmValRotate(V)) & V; |
210 | 0 |
|
211 | 0 | // Take what's left. |
212 | 0 | assert(V == (rotr32(255U, getSOImmValRotate(V)) & V)); |
213 | 0 | return V; |
214 | 0 | } Unexecuted instantiation: ARMAsmParser.cpp:llvm_ks::ARM_AM::getSOImmTwoPartSecond(unsigned int) Unexecuted instantiation: ARMAsmBackend.cpp:llvm_ks::ARM_AM::getSOImmTwoPartSecond(unsigned int) Unexecuted instantiation: ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::getSOImmTwoPartSecond(unsigned int) |
215 | | |
216 | | /// getThumbImmValShift - Try to handle Imm with a 8-bit immediate followed |
217 | | /// by a left shift. Returns the shift amount to use. |
218 | 0 | static inline unsigned getThumbImmValShift(unsigned Imm) { |
219 | 0 | // 8-bit (or less) immediates are trivially immediate operand with a shift |
220 | 0 | // of zero. |
221 | 0 | if ((Imm & ~255U) == 0) return 0; |
222 | 0 |
|
223 | 0 | // Use CTZ to compute the shift amount. |
224 | 0 | return countTrailingZeros(Imm); |
225 | 0 | } Unexecuted instantiation: ARMAsmParser.cpp:llvm_ks::ARM_AM::getThumbImmValShift(unsigned int) Unexecuted instantiation: ARMAsmBackend.cpp:llvm_ks::ARM_AM::getThumbImmValShift(unsigned int) Unexecuted instantiation: ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::getThumbImmValShift(unsigned int) |
226 | | |
227 | | /// isThumbImmShiftedVal - Return true if the specified value can be obtained |
228 | | /// by left shifting a 8-bit immediate. |
229 | 0 | static inline bool isThumbImmShiftedVal(unsigned V) { |
230 | 0 | // If this can be handled with |
231 | 0 | V = (~255U << getThumbImmValShift(V)) & V; |
232 | 0 | return V == 0; |
233 | 0 | } Unexecuted instantiation: ARMAsmParser.cpp:llvm_ks::ARM_AM::isThumbImmShiftedVal(unsigned int) Unexecuted instantiation: ARMAsmBackend.cpp:llvm_ks::ARM_AM::isThumbImmShiftedVal(unsigned int) Unexecuted instantiation: ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::isThumbImmShiftedVal(unsigned int) |
234 | | |
235 | | /// getThumbImm16ValShift - Try to handle Imm with a 16-bit immediate followed |
236 | | /// by a left shift. Returns the shift amount to use. |
237 | 0 | static inline unsigned getThumbImm16ValShift(unsigned Imm) { |
238 | 0 | // 16-bit (or less) immediates are trivially immediate operand with a shift |
239 | 0 | // of zero. |
240 | 0 | if ((Imm & ~65535U) == 0) return 0; |
241 | 0 |
|
242 | 0 | // Use CTZ to compute the shift amount. |
243 | 0 | return countTrailingZeros(Imm); |
244 | 0 | } Unexecuted instantiation: ARMAsmParser.cpp:llvm_ks::ARM_AM::getThumbImm16ValShift(unsigned int) Unexecuted instantiation: ARMAsmBackend.cpp:llvm_ks::ARM_AM::getThumbImm16ValShift(unsigned int) Unexecuted instantiation: ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::getThumbImm16ValShift(unsigned int) |
245 | | |
246 | | /// isThumbImm16ShiftedVal - Return true if the specified value can be |
247 | | /// obtained by left shifting a 16-bit immediate. |
248 | 0 | static inline bool isThumbImm16ShiftedVal(unsigned V) { |
249 | 0 | // If this can be handled with |
250 | 0 | V = (~65535U << getThumbImm16ValShift(V)) & V; |
251 | 0 | return V == 0; |
252 | 0 | } Unexecuted instantiation: ARMAsmParser.cpp:llvm_ks::ARM_AM::isThumbImm16ShiftedVal(unsigned int) Unexecuted instantiation: ARMAsmBackend.cpp:llvm_ks::ARM_AM::isThumbImm16ShiftedVal(unsigned int) Unexecuted instantiation: ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::isThumbImm16ShiftedVal(unsigned int) |
253 | | |
254 | | /// getThumbImmNonShiftedVal - If V is a value that satisfies |
255 | | /// isThumbImmShiftedVal, return the non-shiftd value. |
256 | 0 | static inline unsigned getThumbImmNonShiftedVal(unsigned V) { |
257 | 0 | return V >> getThumbImmValShift(V); |
258 | 0 | } Unexecuted instantiation: ARMAsmParser.cpp:llvm_ks::ARM_AM::getThumbImmNonShiftedVal(unsigned int) Unexecuted instantiation: ARMAsmBackend.cpp:llvm_ks::ARM_AM::getThumbImmNonShiftedVal(unsigned int) Unexecuted instantiation: ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::getThumbImmNonShiftedVal(unsigned int) |
259 | | |
260 | | |
261 | | /// getT2SOImmValSplat - Return the 12-bit encoded representation |
262 | | /// if the specified value can be obtained by splatting the low 8 bits |
263 | | /// into every other byte or every byte of a 32-bit value. i.e., |
264 | | /// 00000000 00000000 00000000 abcdefgh control = 0 |
265 | | /// 00000000 abcdefgh 00000000 abcdefgh control = 1 |
266 | | /// abcdefgh 00000000 abcdefgh 00000000 control = 2 |
267 | | /// abcdefgh abcdefgh abcdefgh abcdefgh control = 3 |
268 | | /// Return -1 if none of the above apply. |
269 | | /// See ARM Reference Manual A6.3.2. |
270 | 17.5k | static inline int getT2SOImmValSplatVal(unsigned V) { |
271 | 17.5k | unsigned u, Vs, Imm; |
272 | | // control = 0 |
273 | 17.5k | if ((V & 0xffffff00) == 0) |
274 | 8.13k | return V; |
275 | | |
276 | | // If the value is zeroes in the first byte, just shift those off |
277 | 9.40k | Vs = ((V & 0xff) == 0) ? V >> 8 : V; |
278 | | // Any passing value only has 8 bits of payload, splatted across the word |
279 | 9.40k | Imm = Vs & 0xff; |
280 | | // Likewise, any passing values have the payload splatted into the 3rd byte |
281 | 9.40k | u = Imm | (Imm << 16); |
282 | | |
283 | | // control = 1 or 2 |
284 | 9.40k | if (Vs == u) |
285 | 49 | return (((Vs == V) ? 1 : 2) << 8) | Imm; |
286 | | |
287 | | // control = 3 |
288 | 9.35k | if (Vs == (u | (u << 8))) |
289 | 1.32k | return (3 << 8) | Imm; |
290 | | |
291 | 8.02k | return -1; |
292 | 9.35k | } ARMAsmParser.cpp:llvm_ks::ARM_AM::getT2SOImmValSplatVal(unsigned int) Line | Count | Source | 270 | 13.5k | static inline int getT2SOImmValSplatVal(unsigned V) { | 271 | 13.5k | unsigned u, Vs, Imm; | 272 | | // control = 0 | 273 | 13.5k | if ((V & 0xffffff00) == 0) | 274 | 4.80k | return V; | 275 | | | 276 | | // If the value is zeroes in the first byte, just shift those off | 277 | 8.71k | Vs = ((V & 0xff) == 0) ? V >> 8 : V; | 278 | | // Any passing value only has 8 bits of payload, splatted across the word | 279 | 8.71k | Imm = Vs & 0xff; | 280 | | // Likewise, any passing values have the payload splatted into the 3rd byte | 281 | 8.71k | u = Imm | (Imm << 16); | 282 | | | 283 | | // control = 1 or 2 | 284 | 8.71k | if (Vs == u) | 285 | 32 | return (((Vs == V) ? 1 : 2) << 8) | Imm; | 286 | | | 287 | | // control = 3 | 288 | 8.68k | if (Vs == (u | (u << 8))) | 289 | 1.20k | return (3 << 8) | Imm; | 290 | | | 291 | 7.48k | return -1; | 292 | 8.68k | } |
Unexecuted instantiation: ARMAsmBackend.cpp:llvm_ks::ARM_AM::getT2SOImmValSplatVal(unsigned int) ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::getT2SOImmValSplatVal(unsigned int) Line | Count | Source | 270 | 4.01k | static inline int getT2SOImmValSplatVal(unsigned V) { | 271 | 4.01k | unsigned u, Vs, Imm; | 272 | | // control = 0 | 273 | 4.01k | if ((V & 0xffffff00) == 0) | 274 | 3.33k | return V; | 275 | | | 276 | | // If the value is zeroes in the first byte, just shift those off | 277 | 683 | Vs = ((V & 0xff) == 0) ? V >> 8 : V; | 278 | | // Any passing value only has 8 bits of payload, splatted across the word | 279 | 683 | Imm = Vs & 0xff; | 280 | | // Likewise, any passing values have the payload splatted into the 3rd byte | 281 | 683 | u = Imm | (Imm << 16); | 282 | | | 283 | | // control = 1 or 2 | 284 | 683 | if (Vs == u) | 285 | 17 | return (((Vs == V) ? 1 : 2) << 8) | Imm; | 286 | | | 287 | | // control = 3 | 288 | 666 | if (Vs == (u | (u << 8))) | 289 | 120 | return (3 << 8) | Imm; | 290 | | | 291 | 546 | return -1; | 292 | 666 | } |
|
293 | | |
294 | | /// getT2SOImmValRotateVal - Return the 12-bit encoded representation if the |
295 | | /// specified value is a rotated 8-bit value. Return -1 if no rotation |
296 | | /// encoding is possible. |
297 | | /// See ARM Reference Manual A6.3.2. |
298 | 8.02k | static inline int getT2SOImmValRotateVal(unsigned V) { |
299 | 8.02k | unsigned RotAmt = countLeadingZeros(V); |
300 | 8.02k | if (RotAmt >= 24) |
301 | 0 | return -1; |
302 | | |
303 | | // If 'Arg' can be handled with a single shifter_op return the value. |
304 | 8.02k | if ((rotr32(0xff000000U, RotAmt) & V) == V) |
305 | 1.74k | return (rotr32(V, 24 - RotAmt) & 0x7f) | ((RotAmt + 8) << 7); |
306 | | |
307 | 6.28k | return -1; |
308 | 8.02k | } ARMAsmParser.cpp:llvm_ks::ARM_AM::getT2SOImmValRotateVal(unsigned int) Line | Count | Source | 298 | 7.48k | static inline int getT2SOImmValRotateVal(unsigned V) { | 299 | 7.48k | unsigned RotAmt = countLeadingZeros(V); | 300 | 7.48k | if (RotAmt >= 24) | 301 | 0 | return -1; | 302 | | | 303 | | // If 'Arg' can be handled with a single shifter_op return the value. | 304 | 7.48k | if ((rotr32(0xff000000U, RotAmt) & V) == V) | 305 | 1.20k | return (rotr32(V, 24 - RotAmt) & 0x7f) | ((RotAmt + 8) << 7); | 306 | | | 307 | 6.28k | return -1; | 308 | 7.48k | } |
Unexecuted instantiation: ARMAsmBackend.cpp:llvm_ks::ARM_AM::getT2SOImmValRotateVal(unsigned int) ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::getT2SOImmValRotateVal(unsigned int) Line | Count | Source | 298 | 546 | static inline int getT2SOImmValRotateVal(unsigned V) { | 299 | 546 | unsigned RotAmt = countLeadingZeros(V); | 300 | 546 | if (RotAmt >= 24) | 301 | 0 | return -1; | 302 | | | 303 | | // If 'Arg' can be handled with a single shifter_op return the value. | 304 | 546 | if ((rotr32(0xff000000U, RotAmt) & V) == V) | 305 | 546 | return (rotr32(V, 24 - RotAmt) & 0x7f) | ((RotAmt + 8) << 7); | 306 | | | 307 | 0 | return -1; | 308 | 546 | } |
|
309 | | |
310 | | /// getT2SOImmVal - Given a 32-bit immediate, if it is something that can fit |
311 | | /// into a Thumb-2 shifter_operand immediate operand, return the 12-bit |
312 | | /// encoding for it. If not, return -1. |
313 | | /// See ARM Reference Manual A6.3.2. |
314 | 17.5k | static inline int getT2SOImmVal(unsigned Arg) { |
315 | | // If 'Arg' is an 8-bit splat, then get the encoded value. |
316 | 17.5k | int Splat = getT2SOImmValSplatVal(Arg); |
317 | 17.5k | if (Splat != -1) |
318 | 9.51k | return Splat; |
319 | | |
320 | | // If 'Arg' can be handled with a single shifter_op return the value. |
321 | 8.02k | int Rot = getT2SOImmValRotateVal(Arg); |
322 | 8.02k | if (Rot != -1) |
323 | 1.74k | return Rot; |
324 | | |
325 | 6.28k | return -1; |
326 | 8.02k | } ARMAsmParser.cpp:llvm_ks::ARM_AM::getT2SOImmVal(unsigned int) Line | Count | Source | 314 | 13.5k | static inline int getT2SOImmVal(unsigned Arg) { | 315 | | // If 'Arg' is an 8-bit splat, then get the encoded value. | 316 | 13.5k | int Splat = getT2SOImmValSplatVal(Arg); | 317 | 13.5k | if (Splat != -1) | 318 | 6.04k | return Splat; | 319 | | | 320 | | // If 'Arg' can be handled with a single shifter_op return the value. | 321 | 7.48k | int Rot = getT2SOImmValRotateVal(Arg); | 322 | 7.48k | if (Rot != -1) | 323 | 1.20k | return Rot; | 324 | | | 325 | 6.28k | return -1; | 326 | 7.48k | } |
Unexecuted instantiation: ARMAsmBackend.cpp:llvm_ks::ARM_AM::getT2SOImmVal(unsigned int) ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::getT2SOImmVal(unsigned int) Line | Count | Source | 314 | 4.01k | static inline int getT2SOImmVal(unsigned Arg) { | 315 | | // If 'Arg' is an 8-bit splat, then get the encoded value. | 316 | 4.01k | int Splat = getT2SOImmValSplatVal(Arg); | 317 | 4.01k | if (Splat != -1) | 318 | 3.47k | return Splat; | 319 | | | 320 | | // If 'Arg' can be handled with a single shifter_op return the value. | 321 | 546 | int Rot = getT2SOImmValRotateVal(Arg); | 322 | 546 | if (Rot != -1) | 323 | 546 | return Rot; | 324 | | | 325 | 0 | return -1; | 326 | 546 | } |
|
327 | | |
328 | 0 | static inline unsigned getT2SOImmValRotate(unsigned V) { |
329 | 0 | if ((V & ~255U) == 0) return 0; |
330 | 0 | // Use CTZ to compute the rotate amount. |
331 | 0 | unsigned RotAmt = countTrailingZeros(V); |
332 | 0 | return (32 - RotAmt) & 31; |
333 | 0 | } Unexecuted instantiation: ARMAsmParser.cpp:llvm_ks::ARM_AM::getT2SOImmValRotate(unsigned int) Unexecuted instantiation: ARMAsmBackend.cpp:llvm_ks::ARM_AM::getT2SOImmValRotate(unsigned int) Unexecuted instantiation: ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::getT2SOImmValRotate(unsigned int) |
334 | | |
335 | 0 | static inline bool isT2SOImmTwoPartVal (unsigned Imm) { |
336 | 0 | unsigned V = Imm; |
337 | 0 | // Passing values can be any combination of splat values and shifter |
338 | 0 | // values. If this can be handled with a single shifter or splat, bail |
339 | 0 | // out. Those should be handled directly, not with a two-part val. |
340 | 0 | if (getT2SOImmValSplatVal(V) != -1) |
341 | 0 | return false; |
342 | 0 | V = rotr32 (~255U, getT2SOImmValRotate(V)) & V; |
343 | 0 | if (V == 0) |
344 | 0 | return false; |
345 | 0 |
|
346 | 0 | // If this can be handled as an immediate, accept. |
347 | 0 | if (getT2SOImmVal(V) != -1) return true; |
348 | 0 |
|
349 | 0 | // Likewise, try masking out a splat value first. |
350 | 0 | V = Imm; |
351 | 0 | if (getT2SOImmValSplatVal(V & 0xff00ff00U) != -1) |
352 | 0 | V &= ~0xff00ff00U; |
353 | 0 | else if (getT2SOImmValSplatVal(V & 0x00ff00ffU) != -1) |
354 | 0 | V &= ~0x00ff00ffU; |
355 | 0 | // If what's left can be handled as an immediate, accept. |
356 | 0 | if (getT2SOImmVal(V) != -1) return true; |
357 | 0 |
|
358 | 0 | // Otherwise, do not accept. |
359 | 0 | return false; |
360 | 0 | } Unexecuted instantiation: ARMAsmParser.cpp:llvm_ks::ARM_AM::isT2SOImmTwoPartVal(unsigned int) Unexecuted instantiation: ARMAsmBackend.cpp:llvm_ks::ARM_AM::isT2SOImmTwoPartVal(unsigned int) Unexecuted instantiation: ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::isT2SOImmTwoPartVal(unsigned int) |
361 | | |
362 | 0 | static inline unsigned getT2SOImmTwoPartFirst(unsigned Imm) { |
363 | 0 | assert (isT2SOImmTwoPartVal(Imm) && |
364 | 0 | "Immedate cannot be encoded as two part immediate!"); |
365 | 0 | // Try a shifter operand as one part |
366 | 0 | unsigned V = rotr32 (~255, getT2SOImmValRotate(Imm)) & Imm; |
367 | 0 | // If the rest is encodable as an immediate, then return it. |
368 | 0 | if (getT2SOImmVal(V) != -1) return V; |
369 | 0 |
|
370 | 0 | // Try masking out a splat value first. |
371 | 0 | if (getT2SOImmValSplatVal(Imm & 0xff00ff00U) != -1) |
372 | 0 | return Imm & 0xff00ff00U; |
373 | 0 |
|
374 | 0 | // The other splat is all that's left as an option. |
375 | 0 | assert (getT2SOImmValSplatVal(Imm & 0x00ff00ffU) != -1); |
376 | 0 | return Imm & 0x00ff00ffU; |
377 | 0 | } Unexecuted instantiation: ARMAsmParser.cpp:llvm_ks::ARM_AM::getT2SOImmTwoPartFirst(unsigned int) Unexecuted instantiation: ARMAsmBackend.cpp:llvm_ks::ARM_AM::getT2SOImmTwoPartFirst(unsigned int) Unexecuted instantiation: ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::getT2SOImmTwoPartFirst(unsigned int) |
378 | | |
379 | 0 | static inline unsigned getT2SOImmTwoPartSecond(unsigned Imm) { |
380 | 0 | // Mask out the first hunk |
381 | 0 | Imm ^= getT2SOImmTwoPartFirst(Imm); |
382 | 0 | // Return what's left |
383 | 0 | assert (getT2SOImmVal(Imm) != -1 && |
384 | 0 | "Unable to encode second part of T2 two part SO immediate"); |
385 | 0 | return Imm; |
386 | 0 | } Unexecuted instantiation: ARMAsmParser.cpp:llvm_ks::ARM_AM::getT2SOImmTwoPartSecond(unsigned int) Unexecuted instantiation: ARMAsmBackend.cpp:llvm_ks::ARM_AM::getT2SOImmTwoPartSecond(unsigned int) Unexecuted instantiation: ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::getT2SOImmTwoPartSecond(unsigned int) |
387 | | |
388 | | |
389 | | //===--------------------------------------------------------------------===// |
390 | | // Addressing Mode #2 |
391 | | //===--------------------------------------------------------------------===// |
392 | | // |
393 | | // This is used for most simple load/store instructions. |
394 | | // |
395 | | // addrmode2 := reg +/- reg shop imm |
396 | | // addrmode2 := reg +/- imm12 |
397 | | // |
398 | | // The first operand is always a Reg. The second operand is a reg if in |
399 | | // reg/reg form, otherwise it's reg#0. The third field encodes the operation |
400 | | // in bit 12, the immediate in bits 0-11, and the shift op in 13-15. The |
401 | | // fourth operand 16-17 encodes the index mode. |
402 | | // |
403 | | // If this addressing mode is a frame index (before prolog/epilog insertion |
404 | | // and code rewriting), this operand will have the form: FI#, reg0, <offs> |
405 | | // with no shift amount for the frame offset. |
406 | | // |
407 | | static inline unsigned getAM2Opc(AddrOpc Opc, unsigned Imm12, ShiftOpc SO, |
408 | 373 | unsigned IdxMode = 0) { |
409 | 373 | assert(Imm12 < (1 << 12) && "Imm too large!"); |
410 | 373 | bool isSub = Opc == sub; |
411 | 373 | return Imm12 | ((int)isSub << 12) | (SO << 13) | (IdxMode << 16) ; |
412 | 373 | } ARMAsmParser.cpp:llvm_ks::ARM_AM::getAM2Opc(llvm_ks::ARM_AM::AddrOpc, unsigned int, llvm_ks::ARM_AM::ShiftOpc, unsigned int) Line | Count | Source | 408 | 373 | unsigned IdxMode = 0) { | 409 | 373 | assert(Imm12 < (1 << 12) && "Imm too large!"); | 410 | 373 | bool isSub = Opc == sub; | 411 | 373 | return Imm12 | ((int)isSub << 12) | (SO << 13) | (IdxMode << 16) ; | 412 | 373 | } |
Unexecuted instantiation: ARMAsmBackend.cpp:llvm_ks::ARM_AM::getAM2Opc(llvm_ks::ARM_AM::AddrOpc, unsigned int, llvm_ks::ARM_AM::ShiftOpc, unsigned int) Unexecuted instantiation: ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::getAM2Opc(llvm_ks::ARM_AM::AddrOpc, unsigned int, llvm_ks::ARM_AM::ShiftOpc, unsigned int) |
413 | 402 | static inline unsigned getAM2Offset(unsigned AM2Opc) { |
414 | 402 | return AM2Opc & ((1 << 12)-1); |
415 | 402 | } Unexecuted instantiation: ARMAsmParser.cpp:llvm_ks::ARM_AM::getAM2Offset(unsigned int) Unexecuted instantiation: ARMAsmBackend.cpp:llvm_ks::ARM_AM::getAM2Offset(unsigned int) ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::getAM2Offset(unsigned int) Line | Count | Source | 413 | 402 | static inline unsigned getAM2Offset(unsigned AM2Opc) { | 414 | 402 | return AM2Opc & ((1 << 12)-1); | 415 | 402 | } |
|
416 | 402 | static inline AddrOpc getAM2Op(unsigned AM2Opc) { |
417 | 402 | return ((AM2Opc >> 12) & 1) ? sub : add; |
418 | 402 | } Unexecuted instantiation: ARMAsmParser.cpp:llvm_ks::ARM_AM::getAM2Op(unsigned int) Unexecuted instantiation: ARMAsmBackend.cpp:llvm_ks::ARM_AM::getAM2Op(unsigned int) ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::getAM2Op(unsigned int) Line | Count | Source | 416 | 402 | static inline AddrOpc getAM2Op(unsigned AM2Opc) { | 417 | 402 | return ((AM2Opc >> 12) & 1) ? sub : add; | 418 | 402 | } |
|
419 | 135 | static inline ShiftOpc getAM2ShiftOpc(unsigned AM2Opc) { |
420 | 135 | return (ShiftOpc)((AM2Opc >> 13) & 7); |
421 | 135 | } Unexecuted instantiation: ARMAsmParser.cpp:llvm_ks::ARM_AM::getAM2ShiftOpc(unsigned int) Unexecuted instantiation: ARMAsmBackend.cpp:llvm_ks::ARM_AM::getAM2ShiftOpc(unsigned int) ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::getAM2ShiftOpc(unsigned int) Line | Count | Source | 419 | 135 | static inline ShiftOpc getAM2ShiftOpc(unsigned AM2Opc) { | 420 | 135 | return (ShiftOpc)((AM2Opc >> 13) & 7); | 421 | 135 | } |
|
422 | 0 | static inline unsigned getAM2IdxMode(unsigned AM2Opc) { |
423 | 0 | return (AM2Opc >> 16); |
424 | 0 | } Unexecuted instantiation: ARMAsmParser.cpp:llvm_ks::ARM_AM::getAM2IdxMode(unsigned int) Unexecuted instantiation: ARMAsmBackend.cpp:llvm_ks::ARM_AM::getAM2IdxMode(unsigned int) Unexecuted instantiation: ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::getAM2IdxMode(unsigned int) |
425 | | |
426 | | |
427 | | //===--------------------------------------------------------------------===// |
428 | | // Addressing Mode #3 |
429 | | //===--------------------------------------------------------------------===// |
430 | | // |
431 | | // This is used for sign-extending loads, and load/store-pair instructions. |
432 | | // |
433 | | // addrmode3 := reg +/- reg |
434 | | // addrmode3 := reg +/- imm8 |
435 | | // |
436 | | // The first operand is always a Reg. The second operand is a reg if in |
437 | | // reg/reg form, otherwise it's reg#0. The third field encodes the operation |
438 | | // in bit 8, the immediate in bits 0-7. The fourth operand 9-10 encodes the |
439 | | // index mode. |
440 | | |
441 | | /// getAM3Opc - This function encodes the addrmode3 opc field. |
442 | | static inline unsigned getAM3Opc(AddrOpc Opc, unsigned char Offset, |
443 | 269 | unsigned IdxMode = 0) { |
444 | 269 | bool isSub = Opc == sub; |
445 | 269 | return ((int)isSub << 8) | Offset | (IdxMode << 9); |
446 | 269 | } ARMAsmParser.cpp:llvm_ks::ARM_AM::getAM3Opc(llvm_ks::ARM_AM::AddrOpc, unsigned char, unsigned int) Line | Count | Source | 443 | 269 | unsigned IdxMode = 0) { | 444 | 269 | bool isSub = Opc == sub; | 445 | 269 | return ((int)isSub << 8) | Offset | (IdxMode << 9); | 446 | 269 | } |
Unexecuted instantiation: ARMAsmBackend.cpp:llvm_ks::ARM_AM::getAM3Opc(llvm_ks::ARM_AM::AddrOpc, unsigned char, unsigned int) Unexecuted instantiation: ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::getAM3Opc(llvm_ks::ARM_AM::AddrOpc, unsigned char, unsigned int) |
447 | 268 | static inline unsigned char getAM3Offset(unsigned AM3Opc) { |
448 | 268 | return AM3Opc & 0xFF; |
449 | 268 | } Unexecuted instantiation: ARMAsmParser.cpp:llvm_ks::ARM_AM::getAM3Offset(unsigned int) Unexecuted instantiation: ARMAsmBackend.cpp:llvm_ks::ARM_AM::getAM3Offset(unsigned int) ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::getAM3Offset(unsigned int) Line | Count | Source | 447 | 268 | static inline unsigned char getAM3Offset(unsigned AM3Opc) { | 448 | 268 | return AM3Opc & 0xFF; | 449 | 268 | } |
|
450 | 268 | static inline AddrOpc getAM3Op(unsigned AM3Opc) { |
451 | 268 | return ((AM3Opc >> 8) & 1) ? sub : add; |
452 | 268 | } Unexecuted instantiation: ARMAsmParser.cpp:llvm_ks::ARM_AM::getAM3Op(unsigned int) Unexecuted instantiation: ARMAsmBackend.cpp:llvm_ks::ARM_AM::getAM3Op(unsigned int) ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::getAM3Op(unsigned int) Line | Count | Source | 450 | 268 | static inline AddrOpc getAM3Op(unsigned AM3Opc) { | 451 | 268 | return ((AM3Opc >> 8) & 1) ? sub : add; | 452 | 268 | } |
|
453 | 0 | static inline unsigned getAM3IdxMode(unsigned AM3Opc) { |
454 | 0 | return (AM3Opc >> 9); |
455 | 0 | } Unexecuted instantiation: ARMAsmParser.cpp:llvm_ks::ARM_AM::getAM3IdxMode(unsigned int) Unexecuted instantiation: ARMAsmBackend.cpp:llvm_ks::ARM_AM::getAM3IdxMode(unsigned int) Unexecuted instantiation: ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::getAM3IdxMode(unsigned int) |
456 | | |
457 | | //===--------------------------------------------------------------------===// |
458 | | // Addressing Mode #4 |
459 | | //===--------------------------------------------------------------------===// |
460 | | // |
461 | | // This is used for load / store multiple instructions. |
462 | | // |
463 | | // addrmode4 := reg, <mode> |
464 | | // |
465 | | // The four modes are: |
466 | | // IA - Increment after |
467 | | // IB - Increment before |
468 | | // DA - Decrement after |
469 | | // DB - Decrement before |
470 | | // For VFP instructions, only the IA and DB modes are valid. |
471 | | |
472 | 0 | static inline AMSubMode getAM4SubMode(unsigned Mode) { |
473 | 0 | return (AMSubMode)(Mode & 0x7); |
474 | 0 | } Unexecuted instantiation: ARMAsmParser.cpp:llvm_ks::ARM_AM::getAM4SubMode(unsigned int) Unexecuted instantiation: ARMAsmBackend.cpp:llvm_ks::ARM_AM::getAM4SubMode(unsigned int) Unexecuted instantiation: ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::getAM4SubMode(unsigned int) |
475 | | |
476 | 0 | static inline unsigned getAM4ModeImm(AMSubMode SubMode) { |
477 | 0 | return (int)SubMode; |
478 | 0 | } Unexecuted instantiation: ARMAsmParser.cpp:llvm_ks::ARM_AM::getAM4ModeImm(llvm_ks::ARM_AM::AMSubMode) Unexecuted instantiation: ARMAsmBackend.cpp:llvm_ks::ARM_AM::getAM4ModeImm(llvm_ks::ARM_AM::AMSubMode) Unexecuted instantiation: ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::getAM4ModeImm(llvm_ks::ARM_AM::AMSubMode) |
479 | | |
480 | | //===--------------------------------------------------------------------===// |
481 | | // Addressing Mode #5 |
482 | | //===--------------------------------------------------------------------===// |
483 | | // |
484 | | // This is used for coprocessor instructions, such as FP load/stores. |
485 | | // |
486 | | // addrmode5 := reg +/- imm8*4 |
487 | | // |
488 | | // The first operand is always a Reg. The second operand encodes the |
489 | | // operation (add or subtract) in bit 8 and the immediate in bits 0-7. |
490 | | |
491 | | /// getAM5Opc - This function encodes the addrmode5 opc field. |
492 | 4 | static inline unsigned getAM5Opc(AddrOpc Opc, unsigned char Offset) { |
493 | 4 | bool isSub = Opc == sub; |
494 | 4 | return ((int)isSub << 8) | Offset; |
495 | 4 | } ARMAsmParser.cpp:llvm_ks::ARM_AM::getAM5Opc(llvm_ks::ARM_AM::AddrOpc, unsigned char) Line | Count | Source | 492 | 4 | static inline unsigned getAM5Opc(AddrOpc Opc, unsigned char Offset) { | 493 | 4 | bool isSub = Opc == sub; | 494 | 4 | return ((int)isSub << 8) | Offset; | 495 | 4 | } |
Unexecuted instantiation: ARMAsmBackend.cpp:llvm_ks::ARM_AM::getAM5Opc(llvm_ks::ARM_AM::AddrOpc, unsigned char) Unexecuted instantiation: ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::getAM5Opc(llvm_ks::ARM_AM::AddrOpc, unsigned char) |
496 | 1.77k | static inline unsigned char getAM5Offset(unsigned AM5Opc) { |
497 | 1.77k | return AM5Opc & 0xFF; |
498 | 1.77k | } Unexecuted instantiation: ARMAsmParser.cpp:llvm_ks::ARM_AM::getAM5Offset(unsigned int) Unexecuted instantiation: ARMAsmBackend.cpp:llvm_ks::ARM_AM::getAM5Offset(unsigned int) ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::getAM5Offset(unsigned int) Line | Count | Source | 496 | 1.77k | static inline unsigned char getAM5Offset(unsigned AM5Opc) { | 497 | 1.77k | return AM5Opc & 0xFF; | 498 | 1.77k | } |
|
499 | 4 | static inline AddrOpc getAM5Op(unsigned AM5Opc) { |
500 | 4 | return ((AM5Opc >> 8) & 1) ? sub : add; |
501 | 4 | } Unexecuted instantiation: ARMAsmParser.cpp:llvm_ks::ARM_AM::getAM5Op(unsigned int) Unexecuted instantiation: ARMAsmBackend.cpp:llvm_ks::ARM_AM::getAM5Op(unsigned int) ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::getAM5Op(unsigned int) Line | Count | Source | 499 | 4 | static inline AddrOpc getAM5Op(unsigned AM5Opc) { | 500 | 4 | return ((AM5Opc >> 8) & 1) ? sub : add; | 501 | 4 | } |
|
502 | | |
503 | | //===--------------------------------------------------------------------===// |
504 | | // Addressing Mode #5 FP16 |
505 | | //===--------------------------------------------------------------------===// |
506 | | // |
507 | | // This is used for coprocessor instructions, such as 16-bit FP load/stores. |
508 | | // |
509 | | // addrmode5fp16 := reg +/- imm8*2 |
510 | | // |
511 | | // The first operand is always a Reg. The second operand encodes the |
512 | | // operation (add or subtract) in bit 8 and the immediate in bits 0-7. |
513 | | |
514 | | /// getAM5FP16Opc - This function encodes the addrmode5fp16 opc field. |
515 | 0 | static inline unsigned getAM5FP16Opc(AddrOpc Opc, unsigned char Offset) { |
516 | 0 | bool isSub = Opc == sub; |
517 | 0 | return ((int)isSub << 8) | Offset; |
518 | 0 | } Unexecuted instantiation: ARMAsmParser.cpp:llvm_ks::ARM_AM::getAM5FP16Opc(llvm_ks::ARM_AM::AddrOpc, unsigned char) Unexecuted instantiation: ARMAsmBackend.cpp:llvm_ks::ARM_AM::getAM5FP16Opc(llvm_ks::ARM_AM::AddrOpc, unsigned char) Unexecuted instantiation: ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::getAM5FP16Opc(llvm_ks::ARM_AM::AddrOpc, unsigned char) |
519 | 0 | static inline unsigned char getAM5FP16Offset(unsigned AM5Opc) { |
520 | 0 | return AM5Opc & 0xFF; |
521 | 0 | } Unexecuted instantiation: ARMAsmParser.cpp:llvm_ks::ARM_AM::getAM5FP16Offset(unsigned int) Unexecuted instantiation: ARMAsmBackend.cpp:llvm_ks::ARM_AM::getAM5FP16Offset(unsigned int) Unexecuted instantiation: ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::getAM5FP16Offset(unsigned int) |
522 | 0 | static inline AddrOpc getAM5FP16Op(unsigned AM5Opc) { |
523 | 0 | return ((AM5Opc >> 8) & 1) ? sub : add; |
524 | 0 | } Unexecuted instantiation: ARMAsmParser.cpp:llvm_ks::ARM_AM::getAM5FP16Op(unsigned int) Unexecuted instantiation: ARMAsmBackend.cpp:llvm_ks::ARM_AM::getAM5FP16Op(unsigned int) Unexecuted instantiation: ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::getAM5FP16Op(unsigned int) |
525 | | |
526 | | //===--------------------------------------------------------------------===// |
527 | | // Addressing Mode #6 |
528 | | //===--------------------------------------------------------------------===// |
529 | | // |
530 | | // This is used for NEON load / store instructions. |
531 | | // |
532 | | // addrmode6 := reg with optional alignment |
533 | | // |
534 | | // This is stored in two operands [regaddr, align]. The first is the |
535 | | // address register. The second operand is the value of the alignment |
536 | | // specifier in bytes or zero if no explicit alignment. |
537 | | // Valid alignments depend on the specific instruction. |
538 | | |
539 | | //===--------------------------------------------------------------------===// |
540 | | // NEON Modified Immediates |
541 | | //===--------------------------------------------------------------------===// |
542 | | // |
543 | | // Several NEON instructions (e.g., VMOV) take a "modified immediate" |
544 | | // vector operand, where a small immediate encoded in the instruction |
545 | | // specifies a full NEON vector value. These modified immediates are |
546 | | // represented here as encoded integers. The low 8 bits hold the immediate |
547 | | // value; bit 12 holds the "Op" field of the instruction, and bits 11-8 hold |
548 | | // the "Cmode" field of the instruction. The interfaces below treat the |
549 | | // Op and Cmode values as a single 5-bit value. |
550 | | |
551 | 0 | static inline unsigned createNEONModImm(unsigned OpCmode, unsigned Val) { |
552 | 0 | return (OpCmode << 8) | Val; |
553 | 0 | } Unexecuted instantiation: ARMAsmParser.cpp:llvm_ks::ARM_AM::createNEONModImm(unsigned int, unsigned int) Unexecuted instantiation: ARMAsmBackend.cpp:llvm_ks::ARM_AM::createNEONModImm(unsigned int, unsigned int) Unexecuted instantiation: ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::createNEONModImm(unsigned int, unsigned int) |
554 | 0 | static inline unsigned getNEONModImmOpCmode(unsigned ModImm) { |
555 | 0 | return (ModImm >> 8) & 0x1f; |
556 | 0 | } Unexecuted instantiation: ARMAsmParser.cpp:llvm_ks::ARM_AM::getNEONModImmOpCmode(unsigned int) Unexecuted instantiation: ARMAsmBackend.cpp:llvm_ks::ARM_AM::getNEONModImmOpCmode(unsigned int) Unexecuted instantiation: ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::getNEONModImmOpCmode(unsigned int) |
557 | 0 | static inline unsigned getNEONModImmVal(unsigned ModImm) { |
558 | 0 | return ModImm & 0xff; |
559 | 0 | } Unexecuted instantiation: ARMAsmParser.cpp:llvm_ks::ARM_AM::getNEONModImmVal(unsigned int) Unexecuted instantiation: ARMAsmBackend.cpp:llvm_ks::ARM_AM::getNEONModImmVal(unsigned int) Unexecuted instantiation: ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::getNEONModImmVal(unsigned int) |
560 | | |
561 | | /// decodeNEONModImm - Decode a NEON modified immediate value into the |
562 | | /// element value and the element size in bits. (If the element size is |
563 | | /// smaller than the vector, it is splatted into all the elements.) |
564 | 0 | static inline uint64_t decodeNEONModImm(unsigned ModImm, unsigned &EltBits) { |
565 | 0 | unsigned OpCmode = getNEONModImmOpCmode(ModImm); |
566 | 0 | unsigned Imm8 = getNEONModImmVal(ModImm); |
567 | 0 | uint64_t Val = 0; |
568 | 0 |
|
569 | 0 | if (OpCmode == 0xe) { |
570 | 0 | // 8-bit vector elements |
571 | 0 | Val = Imm8; |
572 | 0 | EltBits = 8; |
573 | 0 | } else if ((OpCmode & 0xc) == 0x8) { |
574 | 0 | // 16-bit vector elements |
575 | 0 | unsigned ByteNum = (OpCmode & 0x6) >> 1; |
576 | 0 | Val = Imm8 << (8 * ByteNum); |
577 | 0 | EltBits = 16; |
578 | 0 | } else if ((OpCmode & 0x8) == 0) { |
579 | 0 | // 32-bit vector elements, zero with one byte set |
580 | 0 | unsigned ByteNum = (OpCmode & 0x6) >> 1; |
581 | 0 | Val = Imm8 << (8 * ByteNum); |
582 | 0 | EltBits = 32; |
583 | 0 | } else if ((OpCmode & 0xe) == 0xc) { |
584 | 0 | // 32-bit vector elements, one byte with low bits set |
585 | 0 | unsigned ByteNum = 1 + (OpCmode & 0x1); |
586 | 0 | Val = (Imm8 << (8 * ByteNum)) | (0xffff >> (8 * (2 - ByteNum))); |
587 | 0 | EltBits = 32; |
588 | 0 | } else if (OpCmode == 0x1e) { |
589 | 0 | // 64-bit vector elements |
590 | 0 | for (unsigned ByteNum = 0; ByteNum < 8; ++ByteNum) { |
591 | 0 | if ((ModImm >> ByteNum) & 1) |
592 | 0 | Val |= (uint64_t)0xff << (8 * ByteNum); |
593 | 0 | } |
594 | 0 | EltBits = 64; |
595 | 0 | } else { |
596 | 0 | llvm_unreachable("Unsupported NEON immediate"); |
597 | 0 | } |
598 | 0 | return Val; |
599 | 0 | } Unexecuted instantiation: ARMAsmParser.cpp:llvm_ks::ARM_AM::decodeNEONModImm(unsigned int, unsigned int&) Unexecuted instantiation: ARMAsmBackend.cpp:llvm_ks::ARM_AM::decodeNEONModImm(unsigned int, unsigned int&) Unexecuted instantiation: ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::decodeNEONModImm(unsigned int, unsigned int&) |
600 | | |
601 | | // Generic validation for single-byte immediate (0X00, 00X0, etc). |
602 | 135 | static inline bool isNEONBytesplat(unsigned Value, unsigned Size) { |
603 | 135 | assert(Size >= 1 && Size <= 4 && "Invalid size"); |
604 | 135 | unsigned count = 0; |
605 | 499 | for (unsigned i = 0; i < Size; ++i) { |
606 | 364 | if (Value & 0xff) count++; |
607 | 364 | Value >>= 8; |
608 | 364 | } |
609 | 135 | return count == 1; |
610 | 135 | } ARMAsmParser.cpp:llvm_ks::ARM_AM::isNEONBytesplat(unsigned int, unsigned int) Line | Count | Source | 602 | 135 | static inline bool isNEONBytesplat(unsigned Value, unsigned Size) { | 603 | 135 | assert(Size >= 1 && Size <= 4 && "Invalid size"); | 604 | 135 | unsigned count = 0; | 605 | 499 | for (unsigned i = 0; i < Size; ++i) { | 606 | 364 | if (Value & 0xff) count++; | 607 | 364 | Value >>= 8; | 608 | 364 | } | 609 | 135 | return count == 1; | 610 | 135 | } |
Unexecuted instantiation: ARMAsmBackend.cpp:llvm_ks::ARM_AM::isNEONBytesplat(unsigned int, unsigned int) Unexecuted instantiation: ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::isNEONBytesplat(unsigned int, unsigned int) |
611 | | |
612 | | /// Checks if Value is a correct immediate for instructions like VBIC/VORR. |
613 | 255 | static inline bool isNEONi16splat(unsigned Value) { |
614 | 255 | if (Value > 0xffff) |
615 | 141 | return false; |
616 | | // i16 value with set bits only in one byte X0 or 0X. |
617 | 114 | return Value == 0 || isNEONBytesplat(Value, 2); |
618 | 255 | } ARMAsmParser.cpp:llvm_ks::ARM_AM::isNEONi16splat(unsigned int) Line | Count | Source | 613 | 255 | static inline bool isNEONi16splat(unsigned Value) { | 614 | 255 | if (Value > 0xffff) | 615 | 141 | return false; | 616 | | // i16 value with set bits only in one byte X0 or 0X. | 617 | 114 | return Value == 0 || isNEONBytesplat(Value, 2); | 618 | 255 | } |
Unexecuted instantiation: ARMAsmBackend.cpp:llvm_ks::ARM_AM::isNEONi16splat(unsigned int) Unexecuted instantiation: ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::isNEONi16splat(unsigned int) |
619 | | |
620 | | // Encode NEON 16 bits Splat immediate for instructions like VBIC/VORR |
621 | 46 | static inline unsigned encodeNEONi16splat(unsigned Value) { |
622 | 46 | assert(isNEONi16splat(Value) && "Invalid NEON splat value"); |
623 | 46 | if (Value >= 0x100) |
624 | 4 | Value = (Value >> 8) | 0xa00; |
625 | 42 | else |
626 | 42 | Value |= 0x800; |
627 | 46 | return Value; |
628 | 46 | } ARMAsmParser.cpp:llvm_ks::ARM_AM::encodeNEONi16splat(unsigned int) Line | Count | Source | 621 | 46 | static inline unsigned encodeNEONi16splat(unsigned Value) { | 622 | 46 | assert(isNEONi16splat(Value) && "Invalid NEON splat value"); | 623 | 46 | if (Value >= 0x100) | 624 | 4 | Value = (Value >> 8) | 0xa00; | 625 | 42 | else | 626 | 42 | Value |= 0x800; | 627 | 46 | return Value; | 628 | 46 | } |
Unexecuted instantiation: ARMAsmBackend.cpp:llvm_ks::ARM_AM::encodeNEONi16splat(unsigned int) Unexecuted instantiation: ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::encodeNEONi16splat(unsigned int) |
629 | | |
630 | | /// Checks if Value is a correct immediate for instructions like VBIC/VORR. |
631 | 58 | static inline bool isNEONi32splat(unsigned Value) { |
632 | | // i32 value with set bits only in one byte X000, 0X00, 00X0, or 000X. |
633 | 58 | return Value == 0 || isNEONBytesplat(Value, 4); |
634 | 58 | } ARMAsmParser.cpp:llvm_ks::ARM_AM::isNEONi32splat(unsigned int) Line | Count | Source | 631 | 58 | static inline bool isNEONi32splat(unsigned Value) { | 632 | | // i32 value with set bits only in one byte X000, 0X00, 00X0, or 000X. | 633 | 58 | return Value == 0 || isNEONBytesplat(Value, 4); | 634 | 58 | } |
Unexecuted instantiation: ARMAsmBackend.cpp:llvm_ks::ARM_AM::isNEONi32splat(unsigned int) Unexecuted instantiation: ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::isNEONi32splat(unsigned int) |
635 | | |
636 | | /// Encode NEON 32 bits Splat immediate for instructions like VBIC/VORR. |
637 | 17 | static inline unsigned encodeNEONi32splat(unsigned Value) { |
638 | 17 | assert(isNEONi32splat(Value) && "Invalid NEON splat value"); |
639 | 17 | if (Value >= 0x100 && Value <= 0xff00) |
640 | 1 | Value = (Value >> 8) | 0x200; |
641 | 16 | else if (Value > 0xffff && Value <= 0xff0000) |
642 | 1 | Value = (Value >> 16) | 0x400; |
643 | 15 | else if (Value > 0xffffff) |
644 | 1 | Value = (Value >> 24) | 0x600; |
645 | 17 | return Value; |
646 | 17 | } ARMAsmParser.cpp:llvm_ks::ARM_AM::encodeNEONi32splat(unsigned int) Line | Count | Source | 637 | 17 | static inline unsigned encodeNEONi32splat(unsigned Value) { | 638 | 17 | assert(isNEONi32splat(Value) && "Invalid NEON splat value"); | 639 | 17 | if (Value >= 0x100 && Value <= 0xff00) | 640 | 1 | Value = (Value >> 8) | 0x200; | 641 | 16 | else if (Value > 0xffff && Value <= 0xff0000) | 642 | 1 | Value = (Value >> 16) | 0x400; | 643 | 15 | else if (Value > 0xffffff) | 644 | 1 | Value = (Value >> 24) | 0x600; | 645 | 17 | return Value; | 646 | 17 | } |
Unexecuted instantiation: ARMAsmBackend.cpp:llvm_ks::ARM_AM::encodeNEONi32splat(unsigned int) Unexecuted instantiation: ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::encodeNEONi32splat(unsigned int) |
647 | | |
648 | | //===--------------------------------------------------------------------===// |
649 | | // Floating-point Immediates |
650 | | // |
651 | 380 | static inline float getFPImmFloat(unsigned Imm) { |
652 | | // We expect an 8-bit binary encoding of a floating-point number here. |
653 | 380 | union { |
654 | 380 | uint32_t I; |
655 | 380 | float F; |
656 | 380 | } FPUnion; |
657 | | |
658 | 380 | uint8_t Sign = (Imm >> 7) & 0x1; |
659 | 380 | uint8_t Exp = (Imm >> 4) & 0x7; |
660 | 380 | uint8_t Mantissa = Imm & 0xf; |
661 | | |
662 | | // 8-bit FP iEEEE Float Encoding |
663 | | // abcd efgh aBbbbbbc defgh000 00000000 00000000 |
664 | | // |
665 | | // where B = NOT(b); |
666 | | |
667 | 380 | FPUnion.I = 0; |
668 | 380 | FPUnion.I |= Sign << 31; |
669 | 380 | FPUnion.I |= ((Exp & 0x4) != 0 ? 0 : 1) << 30; |
670 | 380 | FPUnion.I |= ((Exp & 0x4) != 0 ? 0x1f : 0) << 25; |
671 | 380 | FPUnion.I |= (Exp & 0x3) << 23; |
672 | 380 | FPUnion.I |= Mantissa << 19; |
673 | 380 | return FPUnion.F; |
674 | 380 | } ARMAsmParser.cpp:llvm_ks::ARM_AM::getFPImmFloat(unsigned int) Line | Count | Source | 651 | 380 | static inline float getFPImmFloat(unsigned Imm) { | 652 | | // We expect an 8-bit binary encoding of a floating-point number here. | 653 | 380 | union { | 654 | 380 | uint32_t I; | 655 | 380 | float F; | 656 | 380 | } FPUnion; | 657 | | | 658 | 380 | uint8_t Sign = (Imm >> 7) & 0x1; | 659 | 380 | uint8_t Exp = (Imm >> 4) & 0x7; | 660 | 380 | uint8_t Mantissa = Imm & 0xf; | 661 | | | 662 | | // 8-bit FP iEEEE Float Encoding | 663 | | // abcd efgh aBbbbbbc defgh000 00000000 00000000 | 664 | | // | 665 | | // where B = NOT(b); | 666 | | | 667 | 380 | FPUnion.I = 0; | 668 | 380 | FPUnion.I |= Sign << 31; | 669 | 380 | FPUnion.I |= ((Exp & 0x4) != 0 ? 0 : 1) << 30; | 670 | 380 | FPUnion.I |= ((Exp & 0x4) != 0 ? 0x1f : 0) << 25; | 671 | 380 | FPUnion.I |= (Exp & 0x3) << 23; | 672 | 380 | FPUnion.I |= Mantissa << 19; | 673 | 380 | return FPUnion.F; | 674 | 380 | } |
Unexecuted instantiation: ARMAsmBackend.cpp:llvm_ks::ARM_AM::getFPImmFloat(unsigned int) Unexecuted instantiation: ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::getFPImmFloat(unsigned int) |
675 | | |
676 | | /// getFP16Imm - Return an 8-bit floating-point version of the 16-bit |
677 | | /// floating-point value. If the value cannot be represented as an 8-bit |
678 | | /// floating-point value, then return -1. |
679 | 0 | static inline int getFP16Imm(const APInt &Imm) { |
680 | 0 | uint32_t Sign = Imm.lshr(15).getZExtValue() & 1; |
681 | 0 | int32_t Exp = (Imm.lshr(10).getSExtValue() & 0x1f) - 15; // -14 to 15 |
682 | 0 | int64_t Mantissa = Imm.getZExtValue() & 0x3ff; // 10 bits |
683 | 0 |
|
684 | 0 | // We can handle 4 bits of mantissa. |
685 | 0 | // mantissa = (16+UInt(e:f:g:h))/16. |
686 | 0 | if (Mantissa & 0x3f) |
687 | 0 | return -1; |
688 | 0 | Mantissa >>= 6; |
689 | 0 |
|
690 | 0 | // We can handle 3 bits of exponent: exp == UInt(NOT(b):c:d)-3 |
691 | 0 | if (Exp < -3 || Exp > 4) |
692 | 0 | return -1; |
693 | 0 | Exp = ((Exp+3) & 0x7) ^ 4; |
694 | 0 |
|
695 | 0 | return ((int)Sign << 7) | (Exp << 4) | Mantissa; |
696 | 0 | } Unexecuted instantiation: ARMAsmParser.cpp:llvm_ks::ARM_AM::getFP16Imm(llvm_ks::APInt const&) Unexecuted instantiation: ARMAsmBackend.cpp:llvm_ks::ARM_AM::getFP16Imm(llvm_ks::APInt const&) Unexecuted instantiation: ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::getFP16Imm(llvm_ks::APInt const&) |
697 | | |
698 | 0 | static inline int getFP16Imm(const APFloat &FPImm) { |
699 | 0 | return getFP16Imm(FPImm.bitcastToAPInt()); |
700 | 0 | } Unexecuted instantiation: ARMAsmParser.cpp:llvm_ks::ARM_AM::getFP16Imm(llvm_ks::APFloat const&) Unexecuted instantiation: ARMAsmBackend.cpp:llvm_ks::ARM_AM::getFP16Imm(llvm_ks::APFloat const&) Unexecuted instantiation: ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::getFP16Imm(llvm_ks::APFloat const&) |
701 | | |
702 | | /// getFP32Imm - Return an 8-bit floating-point version of the 32-bit |
703 | | /// floating-point value. If the value cannot be represented as an 8-bit |
704 | | /// floating-point value, then return -1. |
705 | 1.19k | static inline int getFP32Imm(const APInt &Imm) { |
706 | 1.19k | uint32_t Sign = Imm.lshr(31).getZExtValue() & 1; |
707 | 1.19k | int32_t Exp = (Imm.lshr(23).getSExtValue() & 0xff) - 127; // -126 to 127 |
708 | 1.19k | int64_t Mantissa = Imm.getZExtValue() & 0x7fffff; // 23 bits |
709 | | |
710 | | // We can handle 4 bits of mantissa. |
711 | | // mantissa = (16+UInt(e:f:g:h))/16. |
712 | 1.19k | if (Mantissa & 0x7ffff) |
713 | 268 | return -1; |
714 | 925 | Mantissa >>= 19; |
715 | 925 | if ((Mantissa & 0xf) != Mantissa) |
716 | 0 | return -1; |
717 | | |
718 | | // We can handle 3 bits of exponent: exp == UInt(NOT(b):c:d)-3 |
719 | 925 | if (Exp < -3 || Exp > 4) |
720 | 27 | return -1; |
721 | 898 | Exp = ((Exp+3) & 0x7) ^ 4; |
722 | | |
723 | 898 | return ((int)Sign << 7) | (Exp << 4) | Mantissa; |
724 | 925 | } ARMAsmParser.cpp:llvm_ks::ARM_AM::getFP32Imm(llvm_ks::APInt const&) Line | Count | Source | 705 | 1.19k | static inline int getFP32Imm(const APInt &Imm) { | 706 | 1.19k | uint32_t Sign = Imm.lshr(31).getZExtValue() & 1; | 707 | 1.19k | int32_t Exp = (Imm.lshr(23).getSExtValue() & 0xff) - 127; // -126 to 127 | 708 | 1.19k | int64_t Mantissa = Imm.getZExtValue() & 0x7fffff; // 23 bits | 709 | | | 710 | | // We can handle 4 bits of mantissa. | 711 | | // mantissa = (16+UInt(e:f:g:h))/16. | 712 | 1.19k | if (Mantissa & 0x7ffff) | 713 | 268 | return -1; | 714 | 925 | Mantissa >>= 19; | 715 | 925 | if ((Mantissa & 0xf) != Mantissa) | 716 | 0 | return -1; | 717 | | | 718 | | // We can handle 3 bits of exponent: exp == UInt(NOT(b):c:d)-3 | 719 | 925 | if (Exp < -3 || Exp > 4) | 720 | 27 | return -1; | 721 | 898 | Exp = ((Exp+3) & 0x7) ^ 4; | 722 | | | 723 | 898 | return ((int)Sign << 7) | (Exp << 4) | Mantissa; | 724 | 925 | } |
Unexecuted instantiation: ARMAsmBackend.cpp:llvm_ks::ARM_AM::getFP32Imm(llvm_ks::APInt const&) Unexecuted instantiation: ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::getFP32Imm(llvm_ks::APInt const&) |
725 | | |
726 | 0 | static inline int getFP32Imm(const APFloat &FPImm) { |
727 | 0 | return getFP32Imm(FPImm.bitcastToAPInt()); |
728 | 0 | } Unexecuted instantiation: ARMAsmParser.cpp:llvm_ks::ARM_AM::getFP32Imm(llvm_ks::APFloat const&) Unexecuted instantiation: ARMAsmBackend.cpp:llvm_ks::ARM_AM::getFP32Imm(llvm_ks::APFloat const&) Unexecuted instantiation: ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::getFP32Imm(llvm_ks::APFloat const&) |
729 | | |
730 | | /// getFP64Imm - Return an 8-bit floating-point version of the 64-bit |
731 | | /// floating-point value. If the value cannot be represented as an 8-bit |
732 | | /// floating-point value, then return -1. |
733 | 0 | static inline int getFP64Imm(const APInt &Imm) { |
734 | 0 | uint64_t Sign = Imm.lshr(63).getZExtValue() & 1; |
735 | 0 | int64_t Exp = (Imm.lshr(52).getSExtValue() & 0x7ff) - 1023; // -1022 to 1023 |
736 | 0 | uint64_t Mantissa = Imm.getZExtValue() & 0xfffffffffffffULL; |
737 | 0 |
|
738 | 0 | // We can handle 4 bits of mantissa. |
739 | 0 | // mantissa = (16+UInt(e:f:g:h))/16. |
740 | 0 | if (Mantissa & 0xffffffffffffULL) |
741 | 0 | return -1; |
742 | 0 | Mantissa >>= 48; |
743 | 0 | if ((Mantissa & 0xf) != Mantissa) |
744 | 0 | return -1; |
745 | 0 |
|
746 | 0 | // We can handle 3 bits of exponent: exp == UInt(NOT(b):c:d)-3 |
747 | 0 | if (Exp < -3 || Exp > 4) |
748 | 0 | return -1; |
749 | 0 | Exp = ((Exp+3) & 0x7) ^ 4; |
750 | 0 |
|
751 | 0 | return ((int)Sign << 7) | (Exp << 4) | Mantissa; |
752 | 0 | } Unexecuted instantiation: ARMAsmParser.cpp:llvm_ks::ARM_AM::getFP64Imm(llvm_ks::APInt const&) Unexecuted instantiation: ARMAsmBackend.cpp:llvm_ks::ARM_AM::getFP64Imm(llvm_ks::APInt const&) Unexecuted instantiation: ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::getFP64Imm(llvm_ks::APInt const&) |
753 | | |
754 | 0 | static inline int getFP64Imm(const APFloat &FPImm) { |
755 | 0 | return getFP64Imm(FPImm.bitcastToAPInt()); |
756 | 0 | } Unexecuted instantiation: ARMAsmParser.cpp:llvm_ks::ARM_AM::getFP64Imm(llvm_ks::APFloat const&) Unexecuted instantiation: ARMAsmBackend.cpp:llvm_ks::ARM_AM::getFP64Imm(llvm_ks::APFloat const&) Unexecuted instantiation: ARMMCCodeEmitter.cpp:llvm_ks::ARM_AM::getFP64Imm(llvm_ks::APFloat const&) |
757 | | |
758 | | } // end namespace ARM_AM |
759 | | } // end namespace llvm_ks |
760 | | |
761 | | #endif |
762 | | |