Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef ART_COMPILER_OPTIMIZING_NODES_VECTOR_H_ |
| 18 | #define ART_COMPILER_OPTIMIZING_NODES_VECTOR_H_ |
| 19 | |
| 20 | // This #include should never be used by compilation, because this header file (nodes_vector.h) |
| 21 | // is included in the header file nodes.h itself. However it gives editing tools better context. |
| 22 | #include "nodes.h" |
| 23 | |
| 24 | namespace art { |
| 25 | |
| 26 | // Memory alignment, represented as an offset relative to a base, where 0 <= offset < base, |
| 27 | // and base is a power of two. For example, the value Alignment(16, 0) means memory is |
| 28 | // perfectly aligned at a 16-byte boundary, whereas the value Alignment(16, 4) means |
| 29 | // memory is always exactly 4 bytes above such a boundary. |
| 30 | class Alignment { |
| 31 | public: |
| 32 | Alignment(size_t base, size_t offset) : base_(base), offset_(offset) { |
| 33 | DCHECK_LT(offset, base); |
| 34 | DCHECK(IsPowerOfTwo(base)); |
| 35 | } |
| 36 | |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 37 | // Returns true if memory is at least aligned at the given boundary. |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 38 | // Assumes requested base is power of two. |
| 39 | bool IsAlignedAt(size_t base) const { |
| 40 | DCHECK_NE(0u, base); |
| 41 | DCHECK(IsPowerOfTwo(base)); |
| 42 | return ((offset_ | base_) & (base - 1u)) == 0; |
| 43 | } |
| 44 | |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 45 | size_t Base() const { return base_; } |
| 46 | |
| 47 | size_t Offset() const { return offset_; } |
| 48 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 49 | std::string ToString() const { |
| 50 | return "ALIGN(" + std::to_string(base_) + "," + std::to_string(offset_) + ")"; |
| 51 | } |
| 52 | |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 53 | bool operator==(const Alignment& other) const { |
| 54 | return base_ == other.base_ && offset_ == other.offset_; |
| 55 | } |
| 56 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 57 | private: |
| 58 | size_t base_; |
| 59 | size_t offset_; |
| 60 | }; |
| 61 | |
| 62 | // |
| 63 | // Definitions of abstract vector operations in HIR. |
| 64 | // |
| 65 | |
| 66 | // Abstraction of a vector operation, i.e., an operation that performs |
| 67 | // GetVectorLength() x GetPackedType() operations simultaneously. |
| 68 | class HVecOperation : public HVariableInputSizeInstruction { |
| 69 | public: |
Aart Bik | 0148de4 | 2017-09-05 09:25:01 -0700 | [diff] [blame] | 70 | // A SIMD operation looks like a FPU location. |
| 71 | // TODO: we could introduce SIMD types in HIR. |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 72 | static constexpr DataType::Type kSIMDType = DataType::Type::kFloat64; |
Aart Bik | 0148de4 | 2017-09-05 09:25:01 -0700 | [diff] [blame] | 73 | |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 74 | HVecOperation(ArenaAllocator* allocator, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 75 | DataType::Type packed_type, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 76 | SideEffects side_effects, |
| 77 | size_t number_of_inputs, |
| 78 | size_t vector_length, |
| 79 | uint32_t dex_pc) |
| 80 | : HVariableInputSizeInstruction(side_effects, |
| 81 | dex_pc, |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 82 | allocator, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 83 | number_of_inputs, |
| 84 | kArenaAllocVectorNode), |
| 85 | vector_length_(vector_length) { |
| 86 | SetPackedField<TypeField>(packed_type); |
| 87 | DCHECK_LT(1u, vector_length); |
| 88 | } |
| 89 | |
| 90 | // Returns the number of elements packed in a vector. |
| 91 | size_t GetVectorLength() const { |
| 92 | return vector_length_; |
| 93 | } |
| 94 | |
| 95 | // Returns the number of bytes in a full vector. |
| 96 | size_t GetVectorNumberOfBytes() const { |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 97 | return vector_length_ * DataType::Size(GetPackedType()); |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 98 | } |
| 99 | |
Aart Bik | 0148de4 | 2017-09-05 09:25:01 -0700 | [diff] [blame] | 100 | // Returns the type of the vector operation. |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 101 | DataType::Type GetType() const OVERRIDE { |
Aart Bik | 0148de4 | 2017-09-05 09:25:01 -0700 | [diff] [blame] | 102 | return kSIMDType; |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 103 | } |
| 104 | |
| 105 | // Returns the true component type packed in a vector. |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 106 | DataType::Type GetPackedType() const { |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 107 | return GetPackedField<TypeField>(); |
| 108 | } |
| 109 | |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 110 | // Assumes vector nodes cannot be moved by default. Each concrete implementation |
| 111 | // that can be moved should override this method and return true. |
| 112 | bool CanBeMoved() const OVERRIDE { return false; } |
| 113 | |
| 114 | // Tests if all data of a vector node (vector length and packed type) is equal. |
| 115 | // Each concrete implementation that adds more fields should test equality of |
| 116 | // those fields in its own method *and* call all super methods. |
| 117 | bool InstructionDataEquals(const HInstruction* other) const OVERRIDE { |
| 118 | DCHECK(other->IsVecOperation()); |
| 119 | const HVecOperation* o = other->AsVecOperation(); |
| 120 | return GetVectorLength() == o->GetVectorLength() && GetPackedType() == o->GetPackedType(); |
| 121 | } |
| 122 | |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 123 | // Maps an integral type to the same-size signed type and leaves other types alone. |
| 124 | // Can be used to test relaxed type consistency in which packed same-size integral |
| 125 | // types can co-exist, but other type mixes are an error. |
| 126 | static DataType::Type ToSignedType(DataType::Type type) { |
| 127 | switch (type) { |
| 128 | case DataType::Type::kBool: // 1-byte storage unit |
| 129 | case DataType::Type::kUint8: |
| 130 | return DataType::Type::kInt8; |
| 131 | case DataType::Type::kUint16: |
| 132 | return DataType::Type::kInt16; |
| 133 | default: |
| 134 | DCHECK(type != DataType::Type::kVoid && type != DataType::Type::kReference) << type; |
| 135 | return type; |
| 136 | } |
| 137 | } |
| 138 | |
Aart Bik | 4d1a9d4 | 2017-10-19 14:40:55 -0700 | [diff] [blame] | 139 | // Maps an integral type to the same-size unsigned type and leaves other types alone. |
| 140 | static DataType::Type ToUnsignedType(DataType::Type type) { |
| 141 | switch (type) { |
| 142 | case DataType::Type::kBool: // 1-byte storage unit |
| 143 | case DataType::Type::kInt8: |
| 144 | return DataType::Type::kUint8; |
| 145 | case DataType::Type::kInt16: |
| 146 | return DataType::Type::kUint16; |
| 147 | default: |
| 148 | DCHECK(type != DataType::Type::kVoid && type != DataType::Type::kReference) << type; |
| 149 | return type; |
| 150 | } |
| 151 | } |
| 152 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 153 | DECLARE_ABSTRACT_INSTRUCTION(VecOperation); |
| 154 | |
Aart Bik | db14fcf | 2017-04-25 15:53:58 -0700 | [diff] [blame] | 155 | protected: |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 156 | // Additional packed bits. |
| 157 | static constexpr size_t kFieldType = HInstruction::kNumberOfGenericPackedBits; |
| 158 | static constexpr size_t kFieldTypeSize = |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 159 | MinimumBitsToStore(static_cast<size_t>(DataType::Type::kLast)); |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 160 | static constexpr size_t kNumberOfVectorOpPackedBits = kFieldType + kFieldTypeSize; |
| 161 | static_assert(kNumberOfVectorOpPackedBits <= kMaxNumberOfPackedBits, "Too many packed fields."); |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 162 | using TypeField = BitField<DataType::Type, kFieldType, kFieldTypeSize>; |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 163 | |
Artem Serov | cced8ba | 2017-07-19 18:18:09 +0100 | [diff] [blame^] | 164 | DEFAULT_COPY_CONSTRUCTOR(VecOperation); |
| 165 | |
Aart Bik | db14fcf | 2017-04-25 15:53:58 -0700 | [diff] [blame] | 166 | private: |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 167 | const size_t vector_length_; |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 168 | }; |
| 169 | |
| 170 | // Abstraction of a unary vector operation. |
| 171 | class HVecUnaryOperation : public HVecOperation { |
| 172 | public: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 173 | HVecUnaryOperation(ArenaAllocator* allocator, |
Aart Bik | 8de5916 | 2017-04-21 09:42:01 -0700 | [diff] [blame] | 174 | HInstruction* input, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 175 | DataType::Type packed_type, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 176 | size_t vector_length, |
| 177 | uint32_t dex_pc) |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 178 | : HVecOperation(allocator, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 179 | packed_type, |
| 180 | SideEffects::None(), |
Aart Bik | 8de5916 | 2017-04-21 09:42:01 -0700 | [diff] [blame] | 181 | /* number_of_inputs */ 1, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 182 | vector_length, |
Aart Bik | 8de5916 | 2017-04-21 09:42:01 -0700 | [diff] [blame] | 183 | dex_pc) { |
| 184 | SetRawInputAt(0, input); |
| 185 | } |
| 186 | |
| 187 | HInstruction* GetInput() const { return InputAt(0); } |
| 188 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 189 | DECLARE_ABSTRACT_INSTRUCTION(VecUnaryOperation); |
Aart Bik | 8de5916 | 2017-04-21 09:42:01 -0700 | [diff] [blame] | 190 | |
Artem Serov | cced8ba | 2017-07-19 18:18:09 +0100 | [diff] [blame^] | 191 | protected: |
| 192 | DEFAULT_COPY_CONSTRUCTOR(VecUnaryOperation); |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 193 | }; |
| 194 | |
| 195 | // Abstraction of a binary vector operation. |
| 196 | class HVecBinaryOperation : public HVecOperation { |
| 197 | public: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 198 | HVecBinaryOperation(ArenaAllocator* allocator, |
Aart Bik | 8de5916 | 2017-04-21 09:42:01 -0700 | [diff] [blame] | 199 | HInstruction* left, |
| 200 | HInstruction* right, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 201 | DataType::Type packed_type, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 202 | size_t vector_length, |
| 203 | uint32_t dex_pc) |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 204 | : HVecOperation(allocator, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 205 | packed_type, |
| 206 | SideEffects::None(), |
Aart Bik | 8de5916 | 2017-04-21 09:42:01 -0700 | [diff] [blame] | 207 | /* number_of_inputs */ 2, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 208 | vector_length, |
Aart Bik | 8de5916 | 2017-04-21 09:42:01 -0700 | [diff] [blame] | 209 | dex_pc) { |
| 210 | SetRawInputAt(0, left); |
| 211 | SetRawInputAt(1, right); |
| 212 | } |
Artem Serov | f34dd20 | 2017-04-10 17:41:46 +0100 | [diff] [blame] | 213 | |
| 214 | HInstruction* GetLeft() const { return InputAt(0); } |
| 215 | HInstruction* GetRight() const { return InputAt(1); } |
| 216 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 217 | DECLARE_ABSTRACT_INSTRUCTION(VecBinaryOperation); |
Aart Bik | 8de5916 | 2017-04-21 09:42:01 -0700 | [diff] [blame] | 218 | |
Artem Serov | cced8ba | 2017-07-19 18:18:09 +0100 | [diff] [blame^] | 219 | protected: |
| 220 | DEFAULT_COPY_CONSTRUCTOR(VecBinaryOperation); |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 221 | }; |
| 222 | |
| 223 | // Abstraction of a vector operation that references memory, with an alignment. |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 224 | // The Android runtime guarantees elements have at least natural alignment. |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 225 | class HVecMemoryOperation : public HVecOperation { |
| 226 | public: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 227 | HVecMemoryOperation(ArenaAllocator* allocator, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 228 | DataType::Type packed_type, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 229 | SideEffects side_effects, |
| 230 | size_t number_of_inputs, |
| 231 | size_t vector_length, |
| 232 | uint32_t dex_pc) |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 233 | : HVecOperation(allocator, |
| 234 | packed_type, |
| 235 | side_effects, |
| 236 | number_of_inputs, |
| 237 | vector_length, |
| 238 | dex_pc), |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 239 | alignment_(DataType::Size(packed_type), 0) { |
Artem Serov | e1811ed | 2017-04-27 16:50:47 +0100 | [diff] [blame] | 240 | DCHECK_GE(number_of_inputs, 2u); |
| 241 | } |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 242 | |
| 243 | void SetAlignment(Alignment alignment) { alignment_ = alignment; } |
| 244 | |
| 245 | Alignment GetAlignment() const { return alignment_; } |
| 246 | |
Artem Serov | e1811ed | 2017-04-27 16:50:47 +0100 | [diff] [blame] | 247 | HInstruction* GetArray() const { return InputAt(0); } |
| 248 | HInstruction* GetIndex() const { return InputAt(1); } |
| 249 | |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 250 | bool InstructionDataEquals(const HInstruction* other) const OVERRIDE { |
| 251 | DCHECK(other->IsVecMemoryOperation()); |
| 252 | const HVecMemoryOperation* o = other->AsVecMemoryOperation(); |
| 253 | return HVecOperation::InstructionDataEquals(o) && GetAlignment() == o->GetAlignment(); |
| 254 | } |
| 255 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 256 | DECLARE_ABSTRACT_INSTRUCTION(VecMemoryOperation); |
| 257 | |
Artem Serov | cced8ba | 2017-07-19 18:18:09 +0100 | [diff] [blame^] | 258 | protected: |
| 259 | DEFAULT_COPY_CONSTRUCTOR(VecMemoryOperation); |
| 260 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 261 | private: |
| 262 | Alignment alignment_; |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 263 | }; |
| 264 | |
Aart Bik | 0148de4 | 2017-09-05 09:25:01 -0700 | [diff] [blame] | 265 | // Packed type consistency checker ("same vector length" integral types may mix freely). |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 266 | inline static bool HasConsistentPackedTypes(HInstruction* input, DataType::Type type) { |
Aart Bik | 0148de4 | 2017-09-05 09:25:01 -0700 | [diff] [blame] | 267 | if (input->IsPhi()) { |
| 268 | return input->GetType() == HVecOperation::kSIMDType; // carries SIMD |
| 269 | } |
Aart Bik | d58bc32 | 2017-05-01 14:49:18 -0700 | [diff] [blame] | 270 | DCHECK(input->IsVecOperation()); |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 271 | DataType::Type input_type = input->AsVecOperation()->GetPackedType(); |
Aart Bik | 4d1a9d4 | 2017-10-19 14:40:55 -0700 | [diff] [blame] | 272 | DCHECK_EQ(HVecOperation::ToUnsignedType(input_type) == HVecOperation::ToUnsignedType(type), |
| 273 | HVecOperation::ToSignedType(input_type) == HVecOperation::ToSignedType(type)); |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 274 | return HVecOperation::ToSignedType(input_type) == HVecOperation::ToSignedType(type); |
Aart Bik | d58bc32 | 2017-05-01 14:49:18 -0700 | [diff] [blame] | 275 | } |
| 276 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 277 | // |
Aart Bik | 8de5916 | 2017-04-21 09:42:01 -0700 | [diff] [blame] | 278 | // Definitions of concrete unary vector operations in HIR. |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 279 | // |
| 280 | |
| 281 | // Replicates the given scalar into a vector, |
| 282 | // viz. replicate(x) = [ x, .. , x ]. |
| 283 | class HVecReplicateScalar FINAL : public HVecUnaryOperation { |
| 284 | public: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 285 | HVecReplicateScalar(ArenaAllocator* allocator, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 286 | HInstruction* scalar, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 287 | DataType::Type packed_type, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 288 | size_t vector_length, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 289 | uint32_t dex_pc) |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 290 | : HVecUnaryOperation(allocator, scalar, packed_type, vector_length, dex_pc) { |
Aart Bik | 8de5916 | 2017-04-21 09:42:01 -0700 | [diff] [blame] | 291 | DCHECK(!scalar->IsVecOperation()); |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 292 | } |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 293 | |
| 294 | // A replicate needs to stay in place, since SIMD registers are not |
| 295 | // kept alive across vector loop boundaries (yet). |
| 296 | bool CanBeMoved() const OVERRIDE { return false; } |
| 297 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 298 | DECLARE_INSTRUCTION(VecReplicateScalar); |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 299 | |
Artem Serov | cced8ba | 2017-07-19 18:18:09 +0100 | [diff] [blame^] | 300 | protected: |
| 301 | DEFAULT_COPY_CONSTRUCTOR(VecReplicateScalar); |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 302 | }; |
| 303 | |
Aart Bik | 0148de4 | 2017-09-05 09:25:01 -0700 | [diff] [blame] | 304 | // Extracts a particular scalar from the given vector, |
| 305 | // viz. extract[ x1, .. , xn ] = x_i. |
| 306 | // |
| 307 | // TODO: for now only i == 1 case supported. |
| 308 | class HVecExtractScalar FINAL : public HVecUnaryOperation { |
| 309 | public: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 310 | HVecExtractScalar(ArenaAllocator* allocator, |
Aart Bik | 0148de4 | 2017-09-05 09:25:01 -0700 | [diff] [blame] | 311 | HInstruction* input, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 312 | DataType::Type packed_type, |
Aart Bik | 0148de4 | 2017-09-05 09:25:01 -0700 | [diff] [blame] | 313 | size_t vector_length, |
| 314 | size_t index, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 315 | uint32_t dex_pc) |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 316 | : HVecUnaryOperation(allocator, input, packed_type, vector_length, dex_pc) { |
Aart Bik | d58bc32 | 2017-05-01 14:49:18 -0700 | [diff] [blame] | 317 | DCHECK(HasConsistentPackedTypes(input, packed_type)); |
Aart Bik | 0148de4 | 2017-09-05 09:25:01 -0700 | [diff] [blame] | 318 | DCHECK_LT(index, vector_length); |
| 319 | DCHECK_EQ(index, 0u); |
| 320 | } |
| 321 | |
| 322 | // Yields a single component in the vector. |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 323 | DataType::Type GetType() const OVERRIDE { |
Aart Bik | 0148de4 | 2017-09-05 09:25:01 -0700 | [diff] [blame] | 324 | return GetPackedType(); |
| 325 | } |
| 326 | |
| 327 | // An extract needs to stay in place, since SIMD registers are not |
| 328 | // kept alive across vector loop boundaries (yet). |
| 329 | bool CanBeMoved() const OVERRIDE { return false; } |
| 330 | |
| 331 | DECLARE_INSTRUCTION(VecExtractScalar); |
| 332 | |
Artem Serov | cced8ba | 2017-07-19 18:18:09 +0100 | [diff] [blame^] | 333 | protected: |
| 334 | DEFAULT_COPY_CONSTRUCTOR(VecExtractScalar); |
Aart Bik | 0148de4 | 2017-09-05 09:25:01 -0700 | [diff] [blame] | 335 | }; |
| 336 | |
| 337 | // Reduces the given vector into the first element as sum/min/max, |
| 338 | // viz. sum-reduce[ x1, .. , xn ] = [ y, ---- ], where y = sum xi |
| 339 | // and the "-" denotes "don't care" (implementation dependent). |
| 340 | class HVecReduce FINAL : public HVecUnaryOperation { |
| 341 | public: |
| 342 | enum ReductionKind { |
| 343 | kSum = 1, |
| 344 | kMin = 2, |
| 345 | kMax = 3 |
| 346 | }; |
| 347 | |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 348 | HVecReduce(ArenaAllocator* allocator, |
Aart Bik | 0148de4 | 2017-09-05 09:25:01 -0700 | [diff] [blame] | 349 | HInstruction* input, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 350 | DataType::Type packed_type, |
Aart Bik | 0148de4 | 2017-09-05 09:25:01 -0700 | [diff] [blame] | 351 | size_t vector_length, |
| 352 | ReductionKind kind, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 353 | uint32_t dex_pc) |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 354 | : HVecUnaryOperation(allocator, input, packed_type, vector_length, dex_pc), |
Aart Bik | 0148de4 | 2017-09-05 09:25:01 -0700 | [diff] [blame] | 355 | kind_(kind) { |
| 356 | DCHECK(HasConsistentPackedTypes(input, packed_type)); |
Aart Bik | cfa59b4 | 2017-08-31 09:08:13 -0700 | [diff] [blame] | 357 | } |
| 358 | |
Aart Bik | 0148de4 | 2017-09-05 09:25:01 -0700 | [diff] [blame] | 359 | ReductionKind GetKind() const { return kind_; } |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 360 | |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 361 | bool CanBeMoved() const OVERRIDE { return true; } |
| 362 | |
Aart Bik | 0148de4 | 2017-09-05 09:25:01 -0700 | [diff] [blame] | 363 | bool InstructionDataEquals(const HInstruction* other) const OVERRIDE { |
| 364 | DCHECK(other->IsVecReduce()); |
| 365 | const HVecReduce* o = other->AsVecReduce(); |
| 366 | return HVecOperation::InstructionDataEquals(o) && GetKind() == o->GetKind(); |
| 367 | } |
| 368 | |
| 369 | DECLARE_INSTRUCTION(VecReduce); |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 370 | |
Artem Serov | cced8ba | 2017-07-19 18:18:09 +0100 | [diff] [blame^] | 371 | protected: |
| 372 | DEFAULT_COPY_CONSTRUCTOR(VecReduce); |
| 373 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 374 | private: |
Aart Bik | 0148de4 | 2017-09-05 09:25:01 -0700 | [diff] [blame] | 375 | const ReductionKind kind_; |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 376 | }; |
| 377 | |
| 378 | // Converts every component in the vector, |
| 379 | // viz. cnv[ x1, .. , xn ] = [ cnv(x1), .. , cnv(xn) ]. |
| 380 | class HVecCnv FINAL : public HVecUnaryOperation { |
| 381 | public: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 382 | HVecCnv(ArenaAllocator* allocator, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 383 | HInstruction* input, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 384 | DataType::Type packed_type, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 385 | size_t vector_length, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 386 | uint32_t dex_pc) |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 387 | : HVecUnaryOperation(allocator, input, packed_type, vector_length, dex_pc) { |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 388 | DCHECK(input->IsVecOperation()); |
Aart Bik | d58bc32 | 2017-05-01 14:49:18 -0700 | [diff] [blame] | 389 | DCHECK_NE(GetInputType(), GetResultType()); // actual convert |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 390 | } |
| 391 | |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 392 | DataType::Type GetInputType() const { return InputAt(0)->AsVecOperation()->GetPackedType(); } |
| 393 | DataType::Type GetResultType() const { return GetPackedType(); } |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 394 | |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 395 | bool CanBeMoved() const OVERRIDE { return true; } |
| 396 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 397 | DECLARE_INSTRUCTION(VecCnv); |
| 398 | |
Artem Serov | cced8ba | 2017-07-19 18:18:09 +0100 | [diff] [blame^] | 399 | protected: |
| 400 | DEFAULT_COPY_CONSTRUCTOR(VecCnv); |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 401 | }; |
| 402 | |
| 403 | // Negates every component in the vector, |
| 404 | // viz. neg[ x1, .. , xn ] = [ -x1, .. , -xn ]. |
| 405 | class HVecNeg FINAL : public HVecUnaryOperation { |
| 406 | public: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 407 | HVecNeg(ArenaAllocator* allocator, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 408 | HInstruction* input, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 409 | DataType::Type packed_type, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 410 | size_t vector_length, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 411 | uint32_t dex_pc) |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 412 | : HVecUnaryOperation(allocator, input, packed_type, vector_length, dex_pc) { |
Aart Bik | d58bc32 | 2017-05-01 14:49:18 -0700 | [diff] [blame] | 413 | DCHECK(HasConsistentPackedTypes(input, packed_type)); |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 414 | } |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 415 | |
| 416 | bool CanBeMoved() const OVERRIDE { return true; } |
| 417 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 418 | DECLARE_INSTRUCTION(VecNeg); |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 419 | |
Artem Serov | cced8ba | 2017-07-19 18:18:09 +0100 | [diff] [blame^] | 420 | protected: |
| 421 | DEFAULT_COPY_CONSTRUCTOR(VecNeg); |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 422 | }; |
| 423 | |
Aart Bik | 6daebeb | 2017-04-03 14:35:41 -0700 | [diff] [blame] | 424 | // Takes absolute value of every component in the vector, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 425 | // viz. abs[ x1, .. , xn ] = [ |x1|, .. , |xn| ] |
| 426 | // for signed operand x. |
Aart Bik | 6daebeb | 2017-04-03 14:35:41 -0700 | [diff] [blame] | 427 | class HVecAbs FINAL : public HVecUnaryOperation { |
| 428 | public: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 429 | HVecAbs(ArenaAllocator* allocator, |
Aart Bik | 6daebeb | 2017-04-03 14:35:41 -0700 | [diff] [blame] | 430 | HInstruction* input, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 431 | DataType::Type packed_type, |
Aart Bik | 6daebeb | 2017-04-03 14:35:41 -0700 | [diff] [blame] | 432 | size_t vector_length, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 433 | uint32_t dex_pc) |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 434 | : HVecUnaryOperation(allocator, input, packed_type, vector_length, dex_pc) { |
Aart Bik | d58bc32 | 2017-05-01 14:49:18 -0700 | [diff] [blame] | 435 | DCHECK(HasConsistentPackedTypes(input, packed_type)); |
Aart Bik | 6daebeb | 2017-04-03 14:35:41 -0700 | [diff] [blame] | 436 | } |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 437 | |
| 438 | bool CanBeMoved() const OVERRIDE { return true; } |
| 439 | |
Aart Bik | 6daebeb | 2017-04-03 14:35:41 -0700 | [diff] [blame] | 440 | DECLARE_INSTRUCTION(VecAbs); |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 441 | |
Artem Serov | cced8ba | 2017-07-19 18:18:09 +0100 | [diff] [blame^] | 442 | protected: |
| 443 | DEFAULT_COPY_CONSTRUCTOR(VecAbs); |
Aart Bik | 6daebeb | 2017-04-03 14:35:41 -0700 | [diff] [blame] | 444 | }; |
| 445 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 446 | // Bitwise- or boolean-nots every component in the vector, |
| 447 | // viz. not[ x1, .. , xn ] = [ ~x1, .. , ~xn ], or |
| 448 | // not[ x1, .. , xn ] = [ !x1, .. , !xn ] for boolean. |
| 449 | class HVecNot FINAL : public HVecUnaryOperation { |
| 450 | public: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 451 | HVecNot(ArenaAllocator* allocator, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 452 | HInstruction* input, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 453 | DataType::Type packed_type, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 454 | size_t vector_length, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 455 | uint32_t dex_pc) |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 456 | : HVecUnaryOperation(allocator, input, packed_type, vector_length, dex_pc) { |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 457 | DCHECK(input->IsVecOperation()); |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 458 | } |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 459 | |
| 460 | bool CanBeMoved() const OVERRIDE { return true; } |
| 461 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 462 | DECLARE_INSTRUCTION(VecNot); |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 463 | |
Artem Serov | cced8ba | 2017-07-19 18:18:09 +0100 | [diff] [blame^] | 464 | protected: |
| 465 | DEFAULT_COPY_CONSTRUCTOR(VecNot); |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 466 | }; |
| 467 | |
Aart Bik | 8de5916 | 2017-04-21 09:42:01 -0700 | [diff] [blame] | 468 | // |
| 469 | // Definitions of concrete binary vector operations in HIR. |
| 470 | // |
| 471 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 472 | // Adds every component in the two vectors, |
| 473 | // viz. [ x1, .. , xn ] + [ y1, .. , yn ] = [ x1 + y1, .. , xn + yn ]. |
| 474 | class HVecAdd FINAL : public HVecBinaryOperation { |
| 475 | public: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 476 | HVecAdd(ArenaAllocator* allocator, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 477 | HInstruction* left, |
| 478 | HInstruction* right, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 479 | DataType::Type packed_type, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 480 | size_t vector_length, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 481 | uint32_t dex_pc) |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 482 | : HVecBinaryOperation(allocator, left, right, packed_type, vector_length, dex_pc) { |
Aart Bik | d58bc32 | 2017-05-01 14:49:18 -0700 | [diff] [blame] | 483 | DCHECK(HasConsistentPackedTypes(left, packed_type)); |
| 484 | DCHECK(HasConsistentPackedTypes(right, packed_type)); |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 485 | } |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 486 | |
| 487 | bool CanBeMoved() const OVERRIDE { return true; } |
| 488 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 489 | DECLARE_INSTRUCTION(VecAdd); |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 490 | |
Artem Serov | cced8ba | 2017-07-19 18:18:09 +0100 | [diff] [blame^] | 491 | protected: |
| 492 | DEFAULT_COPY_CONSTRUCTOR(VecAdd); |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 493 | }; |
| 494 | |
Aart Bik | f3e61ee | 2017-04-12 17:09:20 -0700 | [diff] [blame] | 495 | // Performs halving add on every component in the two vectors, viz. |
Aart Bik | dbbac8f | 2017-09-01 13:06:08 -0700 | [diff] [blame] | 496 | // rounded [ x1, .. , xn ] hradd [ y1, .. , yn ] = [ (x1 + y1 + 1) >> 1, .. , (xn + yn + 1) >> 1 ] |
| 497 | // truncated [ x1, .. , xn ] hadd [ y1, .. , yn ] = [ (x1 + y1) >> 1, .. , (xn + yn ) >> 1 ] |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 498 | // for either both signed or both unsigned operands x, y. |
Aart Bik | f3e61ee | 2017-04-12 17:09:20 -0700 | [diff] [blame] | 499 | class HVecHalvingAdd FINAL : public HVecBinaryOperation { |
| 500 | public: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 501 | HVecHalvingAdd(ArenaAllocator* allocator, |
Aart Bik | f3e61ee | 2017-04-12 17:09:20 -0700 | [diff] [blame] | 502 | HInstruction* left, |
| 503 | HInstruction* right, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 504 | DataType::Type packed_type, |
Aart Bik | f3e61ee | 2017-04-12 17:09:20 -0700 | [diff] [blame] | 505 | size_t vector_length, |
Aart Bik | f3e61ee | 2017-04-12 17:09:20 -0700 | [diff] [blame] | 506 | bool is_rounded, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 507 | bool is_unsigned, |
| 508 | uint32_t dex_pc) |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 509 | : HVecBinaryOperation(allocator, left, right, packed_type, vector_length, dex_pc) { |
Vladimir Marko | d5d2f2c | 2017-09-26 12:37:26 +0100 | [diff] [blame] | 510 | // The `is_unsigned` flag should be used exclusively with the Int32 or Int64. |
| 511 | // This flag is a temporary measure while we do not have the Uint32 and Uint64 data types. |
| 512 | DCHECK(!is_unsigned || |
| 513 | packed_type == DataType::Type::kInt32 || |
| 514 | packed_type == DataType::Type::kInt64) << packed_type; |
Aart Bik | d58bc32 | 2017-05-01 14:49:18 -0700 | [diff] [blame] | 515 | DCHECK(HasConsistentPackedTypes(left, packed_type)); |
| 516 | DCHECK(HasConsistentPackedTypes(right, packed_type)); |
Aart Bik | db14fcf | 2017-04-25 15:53:58 -0700 | [diff] [blame] | 517 | SetPackedFlag<kFieldHAddIsUnsigned>(is_unsigned); |
| 518 | SetPackedFlag<kFieldHAddIsRounded>(is_rounded); |
Aart Bik | f3e61ee | 2017-04-12 17:09:20 -0700 | [diff] [blame] | 519 | } |
| 520 | |
Aart Bik | db14fcf | 2017-04-25 15:53:58 -0700 | [diff] [blame] | 521 | bool IsUnsigned() const { return GetPackedFlag<kFieldHAddIsUnsigned>(); } |
| 522 | bool IsRounded() const { return GetPackedFlag<kFieldHAddIsRounded>(); } |
Aart Bik | f3e61ee | 2017-04-12 17:09:20 -0700 | [diff] [blame] | 523 | |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 524 | bool CanBeMoved() const OVERRIDE { return true; } |
| 525 | |
| 526 | bool InstructionDataEquals(const HInstruction* other) const OVERRIDE { |
| 527 | DCHECK(other->IsVecHalvingAdd()); |
| 528 | const HVecHalvingAdd* o = other->AsVecHalvingAdd(); |
| 529 | return HVecOperation::InstructionDataEquals(o) && |
| 530 | IsUnsigned() == o->IsUnsigned() && |
| 531 | IsRounded() == o->IsRounded(); |
| 532 | } |
| 533 | |
Aart Bik | f3e61ee | 2017-04-12 17:09:20 -0700 | [diff] [blame] | 534 | DECLARE_INSTRUCTION(VecHalvingAdd); |
| 535 | |
Artem Serov | cced8ba | 2017-07-19 18:18:09 +0100 | [diff] [blame^] | 536 | protected: |
| 537 | DEFAULT_COPY_CONSTRUCTOR(VecHalvingAdd); |
| 538 | |
Aart Bik | f3e61ee | 2017-04-12 17:09:20 -0700 | [diff] [blame] | 539 | private: |
Aart Bik | db14fcf | 2017-04-25 15:53:58 -0700 | [diff] [blame] | 540 | // Additional packed bits. |
| 541 | static constexpr size_t kFieldHAddIsUnsigned = HVecOperation::kNumberOfVectorOpPackedBits; |
| 542 | static constexpr size_t kFieldHAddIsRounded = kFieldHAddIsUnsigned + 1; |
| 543 | static constexpr size_t kNumberOfHAddPackedBits = kFieldHAddIsRounded + 1; |
| 544 | static_assert(kNumberOfHAddPackedBits <= kMaxNumberOfPackedBits, "Too many packed fields."); |
Aart Bik | f3e61ee | 2017-04-12 17:09:20 -0700 | [diff] [blame] | 545 | }; |
| 546 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 547 | // Subtracts every component in the two vectors, |
| 548 | // viz. [ x1, .. , xn ] - [ y1, .. , yn ] = [ x1 - y1, .. , xn - yn ]. |
| 549 | class HVecSub FINAL : public HVecBinaryOperation { |
| 550 | public: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 551 | HVecSub(ArenaAllocator* allocator, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 552 | HInstruction* left, |
| 553 | HInstruction* right, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 554 | DataType::Type packed_type, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 555 | size_t vector_length, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 556 | uint32_t dex_pc) |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 557 | : HVecBinaryOperation(allocator, left, right, packed_type, vector_length, dex_pc) { |
Aart Bik | d58bc32 | 2017-05-01 14:49:18 -0700 | [diff] [blame] | 558 | DCHECK(HasConsistentPackedTypes(left, packed_type)); |
| 559 | DCHECK(HasConsistentPackedTypes(right, packed_type)); |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 560 | } |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 561 | |
| 562 | bool CanBeMoved() const OVERRIDE { return true; } |
| 563 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 564 | DECLARE_INSTRUCTION(VecSub); |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 565 | |
Artem Serov | cced8ba | 2017-07-19 18:18:09 +0100 | [diff] [blame^] | 566 | protected: |
| 567 | DEFAULT_COPY_CONSTRUCTOR(VecSub); |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 568 | }; |
| 569 | |
| 570 | // Multiplies every component in the two vectors, |
| 571 | // viz. [ x1, .. , xn ] * [ y1, .. , yn ] = [ x1 * y1, .. , xn * yn ]. |
| 572 | class HVecMul FINAL : public HVecBinaryOperation { |
| 573 | public: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 574 | HVecMul(ArenaAllocator* allocator, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 575 | HInstruction* left, |
| 576 | HInstruction* right, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 577 | DataType::Type packed_type, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 578 | size_t vector_length, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 579 | uint32_t dex_pc) |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 580 | : HVecBinaryOperation(allocator, left, right, packed_type, vector_length, dex_pc) { |
Aart Bik | d58bc32 | 2017-05-01 14:49:18 -0700 | [diff] [blame] | 581 | DCHECK(HasConsistentPackedTypes(left, packed_type)); |
| 582 | DCHECK(HasConsistentPackedTypes(right, packed_type)); |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 583 | } |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 584 | |
| 585 | bool CanBeMoved() const OVERRIDE { return true; } |
| 586 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 587 | DECLARE_INSTRUCTION(VecMul); |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 588 | |
Artem Serov | cced8ba | 2017-07-19 18:18:09 +0100 | [diff] [blame^] | 589 | protected: |
| 590 | DEFAULT_COPY_CONSTRUCTOR(VecMul); |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 591 | }; |
| 592 | |
| 593 | // Divides every component in the two vectors, |
| 594 | // viz. [ x1, .. , xn ] / [ y1, .. , yn ] = [ x1 / y1, .. , xn / yn ]. |
| 595 | class HVecDiv FINAL : public HVecBinaryOperation { |
| 596 | public: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 597 | HVecDiv(ArenaAllocator* allocator, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 598 | HInstruction* left, |
| 599 | HInstruction* right, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 600 | DataType::Type packed_type, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 601 | size_t vector_length, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 602 | uint32_t dex_pc) |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 603 | : HVecBinaryOperation(allocator, left, right, packed_type, vector_length, dex_pc) { |
Aart Bik | d58bc32 | 2017-05-01 14:49:18 -0700 | [diff] [blame] | 604 | DCHECK(HasConsistentPackedTypes(left, packed_type)); |
| 605 | DCHECK(HasConsistentPackedTypes(right, packed_type)); |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 606 | } |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 607 | |
| 608 | bool CanBeMoved() const OVERRIDE { return true; } |
| 609 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 610 | DECLARE_INSTRUCTION(VecDiv); |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 611 | |
Artem Serov | cced8ba | 2017-07-19 18:18:09 +0100 | [diff] [blame^] | 612 | protected: |
| 613 | DEFAULT_COPY_CONSTRUCTOR(VecDiv); |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 614 | }; |
| 615 | |
Aart Bik | f3e61ee | 2017-04-12 17:09:20 -0700 | [diff] [blame] | 616 | // Takes minimum of every component in the two vectors, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 617 | // viz. MIN( [ x1, .. , xn ] , [ y1, .. , yn ]) = [ min(x1, y1), .. , min(xn, yn) ] |
| 618 | // for either both signed or both unsigned operands x, y. |
Aart Bik | f3e61ee | 2017-04-12 17:09:20 -0700 | [diff] [blame] | 619 | class HVecMin FINAL : public HVecBinaryOperation { |
| 620 | public: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 621 | HVecMin(ArenaAllocator* allocator, |
Aart Bik | f3e61ee | 2017-04-12 17:09:20 -0700 | [diff] [blame] | 622 | HInstruction* left, |
| 623 | HInstruction* right, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 624 | DataType::Type packed_type, |
Aart Bik | f3e61ee | 2017-04-12 17:09:20 -0700 | [diff] [blame] | 625 | size_t vector_length, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 626 | bool is_unsigned, |
| 627 | uint32_t dex_pc) |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 628 | : HVecBinaryOperation(allocator, left, right, packed_type, vector_length, dex_pc) { |
Vladimir Marko | d5d2f2c | 2017-09-26 12:37:26 +0100 | [diff] [blame] | 629 | // The `is_unsigned` flag should be used exclusively with the Int32 or Int64. |
| 630 | // This flag is a temporary measure while we do not have the Uint32 and Uint64 data types. |
| 631 | DCHECK(!is_unsigned || |
| 632 | packed_type == DataType::Type::kInt32 || |
| 633 | packed_type == DataType::Type::kInt64) << packed_type; |
Aart Bik | d58bc32 | 2017-05-01 14:49:18 -0700 | [diff] [blame] | 634 | DCHECK(HasConsistentPackedTypes(left, packed_type)); |
| 635 | DCHECK(HasConsistentPackedTypes(right, packed_type)); |
Aart Bik | c8e93c7 | 2017-05-10 10:49:22 -0700 | [diff] [blame] | 636 | SetPackedFlag<kFieldMinOpIsUnsigned>(is_unsigned); |
Aart Bik | f3e61ee | 2017-04-12 17:09:20 -0700 | [diff] [blame] | 637 | } |
Aart Bik | c8e93c7 | 2017-05-10 10:49:22 -0700 | [diff] [blame] | 638 | |
| 639 | bool IsUnsigned() const { return GetPackedFlag<kFieldMinOpIsUnsigned>(); } |
| 640 | |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 641 | bool CanBeMoved() const OVERRIDE { return true; } |
| 642 | |
| 643 | bool InstructionDataEquals(const HInstruction* other) const OVERRIDE { |
| 644 | DCHECK(other->IsVecMin()); |
| 645 | const HVecMin* o = other->AsVecMin(); |
| 646 | return HVecOperation::InstructionDataEquals(o) && IsUnsigned() == o->IsUnsigned(); |
| 647 | } |
| 648 | |
Aart Bik | f3e61ee | 2017-04-12 17:09:20 -0700 | [diff] [blame] | 649 | DECLARE_INSTRUCTION(VecMin); |
Aart Bik | c8e93c7 | 2017-05-10 10:49:22 -0700 | [diff] [blame] | 650 | |
Artem Serov | cced8ba | 2017-07-19 18:18:09 +0100 | [diff] [blame^] | 651 | protected: |
| 652 | DEFAULT_COPY_CONSTRUCTOR(VecMin); |
| 653 | |
Aart Bik | f3e61ee | 2017-04-12 17:09:20 -0700 | [diff] [blame] | 654 | private: |
Aart Bik | c8e93c7 | 2017-05-10 10:49:22 -0700 | [diff] [blame] | 655 | // Additional packed bits. |
| 656 | static constexpr size_t kFieldMinOpIsUnsigned = HVecOperation::kNumberOfVectorOpPackedBits; |
| 657 | static constexpr size_t kNumberOfMinOpPackedBits = kFieldMinOpIsUnsigned + 1; |
| 658 | static_assert(kNumberOfMinOpPackedBits <= kMaxNumberOfPackedBits, "Too many packed fields."); |
Aart Bik | f3e61ee | 2017-04-12 17:09:20 -0700 | [diff] [blame] | 659 | }; |
| 660 | |
| 661 | // Takes maximum of every component in the two vectors, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 662 | // viz. MAX( [ x1, .. , xn ] , [ y1, .. , yn ]) = [ max(x1, y1), .. , max(xn, yn) ] |
| 663 | // for either both signed or both unsigned operands x, y. |
Aart Bik | f3e61ee | 2017-04-12 17:09:20 -0700 | [diff] [blame] | 664 | class HVecMax FINAL : public HVecBinaryOperation { |
| 665 | public: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 666 | HVecMax(ArenaAllocator* allocator, |
Aart Bik | f3e61ee | 2017-04-12 17:09:20 -0700 | [diff] [blame] | 667 | HInstruction* left, |
| 668 | HInstruction* right, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 669 | DataType::Type packed_type, |
Aart Bik | f3e61ee | 2017-04-12 17:09:20 -0700 | [diff] [blame] | 670 | size_t vector_length, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 671 | bool is_unsigned, |
| 672 | uint32_t dex_pc) |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 673 | : HVecBinaryOperation(allocator, left, right, packed_type, vector_length, dex_pc) { |
Vladimir Marko | d5d2f2c | 2017-09-26 12:37:26 +0100 | [diff] [blame] | 674 | // The `is_unsigned` flag should be used exclusively with the Int32 or Int64. |
| 675 | // This flag is a temporary measure while we do not have the Uint32 and Uint64 data types. |
| 676 | DCHECK(!is_unsigned || |
| 677 | packed_type == DataType::Type::kInt32 || |
| 678 | packed_type == DataType::Type::kInt64) << packed_type; |
Aart Bik | d58bc32 | 2017-05-01 14:49:18 -0700 | [diff] [blame] | 679 | DCHECK(HasConsistentPackedTypes(left, packed_type)); |
| 680 | DCHECK(HasConsistentPackedTypes(right, packed_type)); |
Aart Bik | c8e93c7 | 2017-05-10 10:49:22 -0700 | [diff] [blame] | 681 | SetPackedFlag<kFieldMaxOpIsUnsigned>(is_unsigned); |
Aart Bik | f3e61ee | 2017-04-12 17:09:20 -0700 | [diff] [blame] | 682 | } |
Aart Bik | c8e93c7 | 2017-05-10 10:49:22 -0700 | [diff] [blame] | 683 | |
| 684 | bool IsUnsigned() const { return GetPackedFlag<kFieldMaxOpIsUnsigned>(); } |
| 685 | |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 686 | bool CanBeMoved() const OVERRIDE { return true; } |
| 687 | |
| 688 | bool InstructionDataEquals(const HInstruction* other) const OVERRIDE { |
| 689 | DCHECK(other->IsVecMax()); |
| 690 | const HVecMax* o = other->AsVecMax(); |
| 691 | return HVecOperation::InstructionDataEquals(o) && IsUnsigned() == o->IsUnsigned(); |
| 692 | } |
| 693 | |
Aart Bik | f3e61ee | 2017-04-12 17:09:20 -0700 | [diff] [blame] | 694 | DECLARE_INSTRUCTION(VecMax); |
Aart Bik | c8e93c7 | 2017-05-10 10:49:22 -0700 | [diff] [blame] | 695 | |
Artem Serov | cced8ba | 2017-07-19 18:18:09 +0100 | [diff] [blame^] | 696 | protected: |
| 697 | DEFAULT_COPY_CONSTRUCTOR(VecMax); |
| 698 | |
Aart Bik | f3e61ee | 2017-04-12 17:09:20 -0700 | [diff] [blame] | 699 | private: |
Aart Bik | c8e93c7 | 2017-05-10 10:49:22 -0700 | [diff] [blame] | 700 | // Additional packed bits. |
| 701 | static constexpr size_t kFieldMaxOpIsUnsigned = HVecOperation::kNumberOfVectorOpPackedBits; |
| 702 | static constexpr size_t kNumberOfMaxOpPackedBits = kFieldMaxOpIsUnsigned + 1; |
| 703 | static_assert(kNumberOfMaxOpPackedBits <= kMaxNumberOfPackedBits, "Too many packed fields."); |
Aart Bik | f3e61ee | 2017-04-12 17:09:20 -0700 | [diff] [blame] | 704 | }; |
| 705 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 706 | // Bitwise-ands every component in the two vectors, |
| 707 | // viz. [ x1, .. , xn ] & [ y1, .. , yn ] = [ x1 & y1, .. , xn & yn ]. |
| 708 | class HVecAnd FINAL : public HVecBinaryOperation { |
| 709 | public: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 710 | HVecAnd(ArenaAllocator* allocator, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 711 | HInstruction* left, |
| 712 | HInstruction* right, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 713 | DataType::Type packed_type, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 714 | size_t vector_length, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 715 | uint32_t dex_pc) |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 716 | : HVecBinaryOperation(allocator, left, right, packed_type, vector_length, dex_pc) { |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 717 | DCHECK(left->IsVecOperation() && right->IsVecOperation()); |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 718 | } |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 719 | |
| 720 | bool CanBeMoved() const OVERRIDE { return true; } |
| 721 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 722 | DECLARE_INSTRUCTION(VecAnd); |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 723 | |
Artem Serov | cced8ba | 2017-07-19 18:18:09 +0100 | [diff] [blame^] | 724 | protected: |
| 725 | DEFAULT_COPY_CONSTRUCTOR(VecAnd); |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 726 | }; |
| 727 | |
| 728 | // Bitwise-and-nots every component in the two vectors, |
| 729 | // viz. [ x1, .. , xn ] and-not [ y1, .. , yn ] = [ ~x1 & y1, .. , ~xn & yn ]. |
| 730 | class HVecAndNot FINAL : public HVecBinaryOperation { |
| 731 | public: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 732 | HVecAndNot(ArenaAllocator* allocator, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 733 | HInstruction* left, |
| 734 | HInstruction* right, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 735 | DataType::Type packed_type, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 736 | size_t vector_length, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 737 | uint32_t dex_pc) |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 738 | : HVecBinaryOperation(allocator, left, right, packed_type, vector_length, dex_pc) { |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 739 | DCHECK(left->IsVecOperation() && right->IsVecOperation()); |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 740 | } |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 741 | |
| 742 | bool CanBeMoved() const OVERRIDE { return true; } |
| 743 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 744 | DECLARE_INSTRUCTION(VecAndNot); |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 745 | |
Artem Serov | cced8ba | 2017-07-19 18:18:09 +0100 | [diff] [blame^] | 746 | protected: |
| 747 | DEFAULT_COPY_CONSTRUCTOR(VecAndNot); |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 748 | }; |
| 749 | |
| 750 | // Bitwise-ors every component in the two vectors, |
| 751 | // viz. [ x1, .. , xn ] | [ y1, .. , yn ] = [ x1 | y1, .. , xn | yn ]. |
| 752 | class HVecOr FINAL : public HVecBinaryOperation { |
| 753 | public: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 754 | HVecOr(ArenaAllocator* allocator, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 755 | HInstruction* left, |
| 756 | HInstruction* right, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 757 | DataType::Type packed_type, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 758 | size_t vector_length, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 759 | uint32_t dex_pc) |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 760 | : HVecBinaryOperation(allocator, left, right, packed_type, vector_length, dex_pc) { |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 761 | DCHECK(left->IsVecOperation() && right->IsVecOperation()); |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 762 | } |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 763 | |
| 764 | bool CanBeMoved() const OVERRIDE { return true; } |
| 765 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 766 | DECLARE_INSTRUCTION(VecOr); |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 767 | |
Artem Serov | cced8ba | 2017-07-19 18:18:09 +0100 | [diff] [blame^] | 768 | protected: |
| 769 | DEFAULT_COPY_CONSTRUCTOR(VecOr); |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 770 | }; |
| 771 | |
| 772 | // Bitwise-xors every component in the two vectors, |
| 773 | // viz. [ x1, .. , xn ] ^ [ y1, .. , yn ] = [ x1 ^ y1, .. , xn ^ yn ]. |
| 774 | class HVecXor FINAL : public HVecBinaryOperation { |
| 775 | public: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 776 | HVecXor(ArenaAllocator* allocator, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 777 | HInstruction* left, |
| 778 | HInstruction* right, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 779 | DataType::Type packed_type, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 780 | size_t vector_length, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 781 | uint32_t dex_pc) |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 782 | : HVecBinaryOperation(allocator, left, right, packed_type, vector_length, dex_pc) { |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 783 | DCHECK(left->IsVecOperation() && right->IsVecOperation()); |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 784 | } |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 785 | |
| 786 | bool CanBeMoved() const OVERRIDE { return true; } |
| 787 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 788 | DECLARE_INSTRUCTION(VecXor); |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 789 | |
Artem Serov | cced8ba | 2017-07-19 18:18:09 +0100 | [diff] [blame^] | 790 | protected: |
| 791 | DEFAULT_COPY_CONSTRUCTOR(VecXor); |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 792 | }; |
| 793 | |
| 794 | // Logically shifts every component in the vector left by the given distance, |
| 795 | // viz. [ x1, .. , xn ] << d = [ x1 << d, .. , xn << d ]. |
| 796 | class HVecShl FINAL : public HVecBinaryOperation { |
| 797 | public: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 798 | HVecShl(ArenaAllocator* allocator, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 799 | HInstruction* left, |
| 800 | HInstruction* right, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 801 | DataType::Type packed_type, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 802 | size_t vector_length, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 803 | uint32_t dex_pc) |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 804 | : HVecBinaryOperation(allocator, left, right, packed_type, vector_length, dex_pc) { |
Aart Bik | d58bc32 | 2017-05-01 14:49:18 -0700 | [diff] [blame] | 805 | DCHECK(HasConsistentPackedTypes(left, packed_type)); |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 806 | } |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 807 | |
| 808 | bool CanBeMoved() const OVERRIDE { return true; } |
| 809 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 810 | DECLARE_INSTRUCTION(VecShl); |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 811 | |
Artem Serov | cced8ba | 2017-07-19 18:18:09 +0100 | [diff] [blame^] | 812 | protected: |
| 813 | DEFAULT_COPY_CONSTRUCTOR(VecShl); |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 814 | }; |
| 815 | |
| 816 | // Arithmetically shifts every component in the vector right by the given distance, |
| 817 | // viz. [ x1, .. , xn ] >> d = [ x1 >> d, .. , xn >> d ]. |
| 818 | class HVecShr FINAL : public HVecBinaryOperation { |
| 819 | public: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 820 | HVecShr(ArenaAllocator* allocator, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 821 | HInstruction* left, |
| 822 | HInstruction* right, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 823 | DataType::Type packed_type, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 824 | size_t vector_length, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 825 | uint32_t dex_pc) |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 826 | : HVecBinaryOperation(allocator, left, right, packed_type, vector_length, dex_pc) { |
Aart Bik | d58bc32 | 2017-05-01 14:49:18 -0700 | [diff] [blame] | 827 | DCHECK(HasConsistentPackedTypes(left, packed_type)); |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 828 | } |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 829 | |
| 830 | bool CanBeMoved() const OVERRIDE { return true; } |
| 831 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 832 | DECLARE_INSTRUCTION(VecShr); |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 833 | |
Artem Serov | cced8ba | 2017-07-19 18:18:09 +0100 | [diff] [blame^] | 834 | protected: |
| 835 | DEFAULT_COPY_CONSTRUCTOR(VecShr); |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 836 | }; |
| 837 | |
| 838 | // Logically shifts every component in the vector right by the given distance, |
| 839 | // viz. [ x1, .. , xn ] >>> d = [ x1 >>> d, .. , xn >>> d ]. |
| 840 | class HVecUShr FINAL : public HVecBinaryOperation { |
| 841 | public: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 842 | HVecUShr(ArenaAllocator* allocator, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 843 | HInstruction* left, |
| 844 | HInstruction* right, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 845 | DataType::Type packed_type, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 846 | size_t vector_length, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 847 | uint32_t dex_pc) |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 848 | : HVecBinaryOperation(allocator, left, right, packed_type, vector_length, dex_pc) { |
Aart Bik | d58bc32 | 2017-05-01 14:49:18 -0700 | [diff] [blame] | 849 | DCHECK(HasConsistentPackedTypes(left, packed_type)); |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 850 | } |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 851 | |
| 852 | bool CanBeMoved() const OVERRIDE { return true; } |
| 853 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 854 | DECLARE_INSTRUCTION(VecUShr); |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 855 | |
Artem Serov | cced8ba | 2017-07-19 18:18:09 +0100 | [diff] [blame^] | 856 | protected: |
| 857 | DEFAULT_COPY_CONSTRUCTOR(VecUShr); |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 858 | }; |
| 859 | |
Aart Bik | 8de5916 | 2017-04-21 09:42:01 -0700 | [diff] [blame] | 860 | // |
| 861 | // Definitions of concrete miscellaneous vector operations in HIR. |
| 862 | // |
| 863 | |
| 864 | // Assigns the given scalar elements to a vector, |
Aart Bik | dbbac8f | 2017-09-01 13:06:08 -0700 | [diff] [blame] | 865 | // viz. set( array(x1, .. , xn) ) = [ x1, .. , xn ] if n == m, |
| 866 | // set( array(x1, .. , xm) ) = [ x1, .. , xm, 0, .. , 0 ] if m < n. |
Aart Bik | 8de5916 | 2017-04-21 09:42:01 -0700 | [diff] [blame] | 867 | class HVecSetScalars FINAL : public HVecOperation { |
Aart Bik | 0148de4 | 2017-09-05 09:25:01 -0700 | [diff] [blame] | 868 | public: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 869 | HVecSetScalars(ArenaAllocator* allocator, |
Aart Bik | 5e3afa9 | 2017-09-20 14:11:11 -0700 | [diff] [blame] | 870 | HInstruction* scalars[], |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 871 | DataType::Type packed_type, |
Aart Bik | 8de5916 | 2017-04-21 09:42:01 -0700 | [diff] [blame] | 872 | size_t vector_length, |
Aart Bik | 0148de4 | 2017-09-05 09:25:01 -0700 | [diff] [blame] | 873 | size_t number_of_scalars, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 874 | uint32_t dex_pc) |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 875 | : HVecOperation(allocator, |
Aart Bik | 8de5916 | 2017-04-21 09:42:01 -0700 | [diff] [blame] | 876 | packed_type, |
| 877 | SideEffects::None(), |
Aart Bik | 0148de4 | 2017-09-05 09:25:01 -0700 | [diff] [blame] | 878 | number_of_scalars, |
Aart Bik | 8de5916 | 2017-04-21 09:42:01 -0700 | [diff] [blame] | 879 | vector_length, |
| 880 | dex_pc) { |
Aart Bik | 0148de4 | 2017-09-05 09:25:01 -0700 | [diff] [blame] | 881 | for (size_t i = 0; i < number_of_scalars; i++) { |
Aart Bik | 5e3afa9 | 2017-09-20 14:11:11 -0700 | [diff] [blame] | 882 | DCHECK(!scalars[i]->IsVecOperation() || scalars[i]->IsVecExtractScalar()); |
Aart Bik | 8de5916 | 2017-04-21 09:42:01 -0700 | [diff] [blame] | 883 | SetRawInputAt(0, scalars[i]); |
| 884 | } |
| 885 | } |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 886 | |
| 887 | // Setting scalars needs to stay in place, since SIMD registers are not |
| 888 | // kept alive across vector loop boundaries (yet). |
| 889 | bool CanBeMoved() const OVERRIDE { return false; } |
| 890 | |
Aart Bik | 8de5916 | 2017-04-21 09:42:01 -0700 | [diff] [blame] | 891 | DECLARE_INSTRUCTION(VecSetScalars); |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 892 | |
Artem Serov | cced8ba | 2017-07-19 18:18:09 +0100 | [diff] [blame^] | 893 | protected: |
| 894 | DEFAULT_COPY_CONSTRUCTOR(VecSetScalars); |
Aart Bik | 8de5916 | 2017-04-21 09:42:01 -0700 | [diff] [blame] | 895 | }; |
| 896 | |
Aart Bik | dbbac8f | 2017-09-01 13:06:08 -0700 | [diff] [blame] | 897 | // Multiplies every component in the two vectors, adds the result vector to the accumulator vector, |
| 898 | // viz. [ a1, .. , an ] + [ x1, .. , xn ] * [ y1, .. , yn ] = [ a1 + x1 * y1, .. , an + xn * yn ]. |
Artem Serov | f34dd20 | 2017-04-10 17:41:46 +0100 | [diff] [blame] | 899 | class HVecMultiplyAccumulate FINAL : public HVecOperation { |
| 900 | public: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 901 | HVecMultiplyAccumulate(ArenaAllocator* allocator, |
Artem Serov | f34dd20 | 2017-04-10 17:41:46 +0100 | [diff] [blame] | 902 | InstructionKind op, |
| 903 | HInstruction* accumulator, |
| 904 | HInstruction* mul_left, |
| 905 | HInstruction* mul_right, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 906 | DataType::Type packed_type, |
Artem Serov | f34dd20 | 2017-04-10 17:41:46 +0100 | [diff] [blame] | 907 | size_t vector_length, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 908 | uint32_t dex_pc) |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 909 | : HVecOperation(allocator, |
Artem Serov | f34dd20 | 2017-04-10 17:41:46 +0100 | [diff] [blame] | 910 | packed_type, |
| 911 | SideEffects::None(), |
Aart Bik | 8de5916 | 2017-04-21 09:42:01 -0700 | [diff] [blame] | 912 | /* number_of_inputs */ 3, |
Artem Serov | f34dd20 | 2017-04-10 17:41:46 +0100 | [diff] [blame] | 913 | vector_length, |
| 914 | dex_pc), |
| 915 | op_kind_(op) { |
| 916 | DCHECK(op == InstructionKind::kAdd || op == InstructionKind::kSub); |
Aart Bik | d58bc32 | 2017-05-01 14:49:18 -0700 | [diff] [blame] | 917 | DCHECK(HasConsistentPackedTypes(accumulator, packed_type)); |
| 918 | DCHECK(HasConsistentPackedTypes(mul_left, packed_type)); |
| 919 | DCHECK(HasConsistentPackedTypes(mul_right, packed_type)); |
Aart Bik | dbbac8f | 2017-09-01 13:06:08 -0700 | [diff] [blame] | 920 | SetRawInputAt(0, accumulator); |
| 921 | SetRawInputAt(1, mul_left); |
| 922 | SetRawInputAt(2, mul_right); |
Artem Serov | f34dd20 | 2017-04-10 17:41:46 +0100 | [diff] [blame] | 923 | } |
| 924 | |
Nicolas Geoffray | 9858bf7 | 2017-07-08 12:34:55 +0000 | [diff] [blame] | 925 | bool CanBeMoved() const OVERRIDE { return true; } |
| 926 | |
Artem Serov | f34dd20 | 2017-04-10 17:41:46 +0100 | [diff] [blame] | 927 | bool InstructionDataEquals(const HInstruction* other) const OVERRIDE { |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 928 | DCHECK(other->IsVecMultiplyAccumulate()); |
| 929 | const HVecMultiplyAccumulate* o = other->AsVecMultiplyAccumulate(); |
| 930 | return HVecOperation::InstructionDataEquals(o) && GetOpKind() == o->GetOpKind(); |
Artem Serov | f34dd20 | 2017-04-10 17:41:46 +0100 | [diff] [blame] | 931 | } |
| 932 | |
| 933 | InstructionKind GetOpKind() const { return op_kind_; } |
| 934 | |
| 935 | DECLARE_INSTRUCTION(VecMultiplyAccumulate); |
| 936 | |
Artem Serov | cced8ba | 2017-07-19 18:18:09 +0100 | [diff] [blame^] | 937 | protected: |
| 938 | DEFAULT_COPY_CONSTRUCTOR(VecMultiplyAccumulate); |
| 939 | |
Artem Serov | f34dd20 | 2017-04-10 17:41:46 +0100 | [diff] [blame] | 940 | private: |
| 941 | // Indicates if this is a MADD or MSUB. |
| 942 | const InstructionKind op_kind_; |
Artem Serov | f34dd20 | 2017-04-10 17:41:46 +0100 | [diff] [blame] | 943 | }; |
| 944 | |
Aart Bik | dbbac8f | 2017-09-01 13:06:08 -0700 | [diff] [blame] | 945 | // Takes the absolute difference of two vectors, and adds the results to |
| 946 | // same-precision or wider-precision components in the accumulator, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 947 | // viz. SAD([ a1, .. , am ], [ x1, .. , xn ], [ y1, .. , yn ]) = |
Aart Bik | dbbac8f | 2017-09-01 13:06:08 -0700 | [diff] [blame] | 948 | // [ a1 + sum abs(xi-yi), .. , am + sum abs(xj-yj) ], |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 949 | // for m <= n, non-overlapping sums, and signed operands x, y. |
Aart Bik | dbbac8f | 2017-09-01 13:06:08 -0700 | [diff] [blame] | 950 | class HVecSADAccumulate FINAL : public HVecOperation { |
| 951 | public: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 952 | HVecSADAccumulate(ArenaAllocator* allocator, |
Aart Bik | dbbac8f | 2017-09-01 13:06:08 -0700 | [diff] [blame] | 953 | HInstruction* accumulator, |
| 954 | HInstruction* sad_left, |
| 955 | HInstruction* sad_right, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 956 | DataType::Type packed_type, |
Aart Bik | dbbac8f | 2017-09-01 13:06:08 -0700 | [diff] [blame] | 957 | size_t vector_length, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 958 | uint32_t dex_pc) |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 959 | : HVecOperation(allocator, |
Aart Bik | dbbac8f | 2017-09-01 13:06:08 -0700 | [diff] [blame] | 960 | packed_type, |
| 961 | SideEffects::None(), |
| 962 | /* number_of_inputs */ 3, |
| 963 | vector_length, |
| 964 | dex_pc) { |
| 965 | DCHECK(HasConsistentPackedTypes(accumulator, packed_type)); |
| 966 | DCHECK(sad_left->IsVecOperation()); |
| 967 | DCHECK(sad_right->IsVecOperation()); |
Vladimir Marko | 61b9228 | 2017-10-11 13:23:17 +0100 | [diff] [blame] | 968 | DCHECK_EQ(ToSignedType(sad_left->AsVecOperation()->GetPackedType()), |
| 969 | ToSignedType(sad_right->AsVecOperation()->GetPackedType())); |
Aart Bik | dbbac8f | 2017-09-01 13:06:08 -0700 | [diff] [blame] | 970 | SetRawInputAt(0, accumulator); |
| 971 | SetRawInputAt(1, sad_left); |
| 972 | SetRawInputAt(2, sad_right); |
| 973 | } |
| 974 | |
| 975 | DECLARE_INSTRUCTION(VecSADAccumulate); |
| 976 | |
Artem Serov | cced8ba | 2017-07-19 18:18:09 +0100 | [diff] [blame^] | 977 | protected: |
| 978 | DEFAULT_COPY_CONSTRUCTOR(VecSADAccumulate); |
Aart Bik | dbbac8f | 2017-09-01 13:06:08 -0700 | [diff] [blame] | 979 | }; |
| 980 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 981 | // Loads a vector from memory, viz. load(mem, 1) |
| 982 | // yield the vector [ mem(1), .. , mem(n) ]. |
| 983 | class HVecLoad FINAL : public HVecMemoryOperation { |
| 984 | public: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 985 | HVecLoad(ArenaAllocator* allocator, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 986 | HInstruction* base, |
| 987 | HInstruction* index, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 988 | DataType::Type packed_type, |
Vladimir Marko | d5d2f2c | 2017-09-26 12:37:26 +0100 | [diff] [blame] | 989 | SideEffects side_effects, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 990 | size_t vector_length, |
Aart Bik | db14fcf | 2017-04-25 15:53:58 -0700 | [diff] [blame] | 991 | bool is_string_char_at, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 992 | uint32_t dex_pc) |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 993 | : HVecMemoryOperation(allocator, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 994 | packed_type, |
Vladimir Marko | d5d2f2c | 2017-09-26 12:37:26 +0100 | [diff] [blame] | 995 | side_effects, |
Aart Bik | 8de5916 | 2017-04-21 09:42:01 -0700 | [diff] [blame] | 996 | /* number_of_inputs */ 2, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 997 | vector_length, |
| 998 | dex_pc) { |
| 999 | SetRawInputAt(0, base); |
| 1000 | SetRawInputAt(1, index); |
Aart Bik | db14fcf | 2017-04-25 15:53:58 -0700 | [diff] [blame] | 1001 | SetPackedFlag<kFieldIsStringCharAt>(is_string_char_at); |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 1002 | } |
Aart Bik | db14fcf | 2017-04-25 15:53:58 -0700 | [diff] [blame] | 1003 | |
| 1004 | bool IsStringCharAt() const { return GetPackedFlag<kFieldIsStringCharAt>(); } |
| 1005 | |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 1006 | bool CanBeMoved() const OVERRIDE { return true; } |
| 1007 | |
| 1008 | bool InstructionDataEquals(const HInstruction* other) const OVERRIDE { |
| 1009 | DCHECK(other->IsVecLoad()); |
| 1010 | const HVecLoad* o = other->AsVecLoad(); |
| 1011 | return HVecMemoryOperation::InstructionDataEquals(o) && IsStringCharAt() == o->IsStringCharAt(); |
| 1012 | } |
| 1013 | |
| 1014 | DECLARE_INSTRUCTION(VecLoad); |
| 1015 | |
Artem Serov | cced8ba | 2017-07-19 18:18:09 +0100 | [diff] [blame^] | 1016 | protected: |
| 1017 | DEFAULT_COPY_CONSTRUCTOR(VecLoad); |
| 1018 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 1019 | private: |
Aart Bik | db14fcf | 2017-04-25 15:53:58 -0700 | [diff] [blame] | 1020 | // Additional packed bits. |
| 1021 | static constexpr size_t kFieldIsStringCharAt = HVecOperation::kNumberOfVectorOpPackedBits; |
| 1022 | static constexpr size_t kNumberOfVecLoadPackedBits = kFieldIsStringCharAt + 1; |
| 1023 | static_assert(kNumberOfVecLoadPackedBits <= kMaxNumberOfPackedBits, "Too many packed fields."); |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 1024 | }; |
| 1025 | |
| 1026 | // Stores a vector to memory, viz. store(m, 1, [x1, .. , xn] ) |
| 1027 | // sets mem(1) = x1, .. , mem(n) = xn. |
| 1028 | class HVecStore FINAL : public HVecMemoryOperation { |
| 1029 | public: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 1030 | HVecStore(ArenaAllocator* allocator, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 1031 | HInstruction* base, |
| 1032 | HInstruction* index, |
| 1033 | HInstruction* value, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 1034 | DataType::Type packed_type, |
Vladimir Marko | d5d2f2c | 2017-09-26 12:37:26 +0100 | [diff] [blame] | 1035 | SideEffects side_effects, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 1036 | size_t vector_length, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 1037 | uint32_t dex_pc) |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 1038 | : HVecMemoryOperation(allocator, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 1039 | packed_type, |
Vladimir Marko | d5d2f2c | 2017-09-26 12:37:26 +0100 | [diff] [blame] | 1040 | side_effects, |
Aart Bik | 8de5916 | 2017-04-21 09:42:01 -0700 | [diff] [blame] | 1041 | /* number_of_inputs */ 3, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 1042 | vector_length, |
| 1043 | dex_pc) { |
Aart Bik | d58bc32 | 2017-05-01 14:49:18 -0700 | [diff] [blame] | 1044 | DCHECK(HasConsistentPackedTypes(value, packed_type)); |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 1045 | SetRawInputAt(0, base); |
| 1046 | SetRawInputAt(1, index); |
| 1047 | SetRawInputAt(2, value); |
| 1048 | } |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 1049 | |
| 1050 | // A store needs to stay in place. |
| 1051 | bool CanBeMoved() const OVERRIDE { return false; } |
| 1052 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 1053 | DECLARE_INSTRUCTION(VecStore); |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 1054 | |
Artem Serov | cced8ba | 2017-07-19 18:18:09 +0100 | [diff] [blame^] | 1055 | protected: |
| 1056 | DEFAULT_COPY_CONSTRUCTOR(VecStore) |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 1057 | }; |
| 1058 | |
| 1059 | } // namespace art |
| 1060 | |
| 1061 | #endif // ART_COMPILER_OPTIMIZING_NODES_VECTOR_H_ |