Alexandre Rames | e6dbf48 | 2015-10-19 10:10:41 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015 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_ARM64_H_ |
| 18 | #define ART_COMPILER_OPTIMIZING_NODES_ARM64_H_ |
| 19 | |
Scott Wakeling | 40a04bf | 2015-12-11 09:50:36 +0000 | [diff] [blame] | 20 | #include "nodes.h" |
| 21 | |
Alexandre Rames | e6dbf48 | 2015-10-19 10:10:41 +0100 | [diff] [blame] | 22 | namespace art { |
| 23 | |
Vladimir Marko | fcb503c | 2016-05-18 12:48:17 +0100 | [diff] [blame] | 24 | class HArm64DataProcWithShifterOp FINAL : public HExpression<2> { |
Alexandre Rames | 8626b74 | 2015-11-25 16:28:08 +0000 | [diff] [blame] | 25 | public: |
| 26 | enum OpKind { |
| 27 | kLSL, // Logical shift left. |
| 28 | kLSR, // Logical shift right. |
| 29 | kASR, // Arithmetic shift right. |
| 30 | kUXTB, // Unsigned extend byte. |
| 31 | kUXTH, // Unsigned extend half-word. |
| 32 | kUXTW, // Unsigned extend word. |
| 33 | kSXTB, // Signed extend byte. |
| 34 | kSXTH, // Signed extend half-word. |
| 35 | kSXTW, // Signed extend word. |
| 36 | |
| 37 | // Aliases. |
| 38 | kFirstShiftOp = kLSL, |
| 39 | kLastShiftOp = kASR, |
| 40 | kFirstExtensionOp = kUXTB, |
| 41 | kLastExtensionOp = kSXTW |
| 42 | }; |
| 43 | HArm64DataProcWithShifterOp(HInstruction* instr, |
| 44 | HInstruction* left, |
| 45 | HInstruction* right, |
| 46 | OpKind op, |
| 47 | // The shift argument is unused if the operation |
| 48 | // is an extension. |
| 49 | int shift = 0, |
| 50 | uint32_t dex_pc = kNoDexPc) |
| 51 | : HExpression(instr->GetType(), SideEffects::None(), dex_pc), |
| 52 | instr_kind_(instr->GetKind()), op_kind_(op), shift_amount_(shift) { |
| 53 | DCHECK(!instr->HasSideEffects()); |
| 54 | SetRawInputAt(0, left); |
| 55 | SetRawInputAt(1, right); |
| 56 | } |
| 57 | |
| 58 | bool CanBeMoved() const OVERRIDE { return true; } |
Vladimir Marko | 372f10e | 2016-05-17 16:30:10 +0100 | [diff] [blame] | 59 | bool InstructionDataEquals(const HInstruction* other_instr) const OVERRIDE { |
| 60 | const HArm64DataProcWithShifterOp* other = other_instr->AsArm64DataProcWithShifterOp(); |
Alexandre Rames | 8626b74 | 2015-11-25 16:28:08 +0000 | [diff] [blame] | 61 | return instr_kind_ == other->instr_kind_ && |
| 62 | op_kind_ == other->op_kind_ && |
| 63 | shift_amount_ == other->shift_amount_; |
| 64 | } |
| 65 | |
| 66 | static bool IsShiftOp(OpKind op_kind) { |
| 67 | return kFirstShiftOp <= op_kind && op_kind <= kLastShiftOp; |
| 68 | } |
| 69 | |
| 70 | static bool IsExtensionOp(OpKind op_kind) { |
| 71 | return kFirstExtensionOp <= op_kind && op_kind <= kLastExtensionOp; |
| 72 | } |
| 73 | |
| 74 | // Find the operation kind and shift amount from a bitfield move instruction. |
| 75 | static void GetOpInfoFromInstruction(HInstruction* bitfield_op, |
| 76 | /*out*/OpKind* op_kind, |
| 77 | /*out*/int* shift_amount); |
| 78 | |
| 79 | InstructionKind GetInstrKind() const { return instr_kind_; } |
| 80 | OpKind GetOpKind() const { return op_kind_; } |
| 81 | int GetShiftAmount() const { return shift_amount_; } |
| 82 | |
| 83 | DECLARE_INSTRUCTION(Arm64DataProcWithShifterOp); |
| 84 | |
| 85 | private: |
| 86 | InstructionKind instr_kind_; |
| 87 | OpKind op_kind_; |
| 88 | int shift_amount_; |
| 89 | |
| 90 | friend std::ostream& operator<<(std::ostream& os, OpKind op); |
| 91 | |
| 92 | DISALLOW_COPY_AND_ASSIGN(HArm64DataProcWithShifterOp); |
| 93 | }; |
| 94 | |
| 95 | std::ostream& operator<<(std::ostream& os, const HArm64DataProcWithShifterOp::OpKind op); |
| 96 | |
Alexandre Rames | e6dbf48 | 2015-10-19 10:10:41 +0100 | [diff] [blame] | 97 | } // namespace art |
| 98 | |
| 99 | #endif // ART_COMPILER_OPTIMIZING_NODES_ARM64_H_ |