nodes_shared.h revision debeb98aaa8950caf1a19df490f2ac9bf563075b
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_SHARED_H_ 18#define ART_COMPILER_OPTIMIZING_NODES_SHARED_H_ 19 20namespace art { 21 22class HMultiplyAccumulate : public HExpression<3> { 23 public: 24 HMultiplyAccumulate(Primitive::Type type, 25 InstructionKind op, 26 HInstruction* accumulator, 27 HInstruction* mul_left, 28 HInstruction* mul_right, 29 uint32_t dex_pc = kNoDexPc) 30 : HExpression(type, SideEffects::None(), dex_pc), op_kind_(op) { 31 SetRawInputAt(kInputAccumulatorIndex, accumulator); 32 SetRawInputAt(kInputMulLeftIndex, mul_left); 33 SetRawInputAt(kInputMulRightIndex, mul_right); 34 } 35 36 static constexpr int kInputAccumulatorIndex = 0; 37 static constexpr int kInputMulLeftIndex = 1; 38 static constexpr int kInputMulRightIndex = 2; 39 40 bool CanBeMoved() const OVERRIDE { return true; } 41 bool InstructionDataEquals(HInstruction* other) const OVERRIDE { 42 return op_kind_ == other->AsMultiplyAccumulate()->op_kind_; 43 } 44 45 InstructionKind GetOpKind() const { return op_kind_; } 46 47 DECLARE_INSTRUCTION(MultiplyAccumulate); 48 49 private: 50 // Indicates if this is a MADD or MSUB. 51 const InstructionKind op_kind_; 52 53 DISALLOW_COPY_AND_ASSIGN(HMultiplyAccumulate); 54}; 55 56} // namespace art 57 58#endif // ART_COMPILER_OPTIMIZING_NODES_SHARED_H_ 59