ART: Introduce individual HInstruction cloning.

Introduce API for HInstruction cloning, support it for a few
instructions. add a gtest.

Test: cloner_test.cc, test-art-target, test-art-host.

Change-Id: I8b6299be5d04a26390d9ef13a20ce82ee5ae4afe
diff --git a/compiler/optimizing/nodes_vector.h b/compiler/optimizing/nodes_vector.h
index 17540b9..59d5b9f 100644
--- a/compiler/optimizing/nodes_vector.h
+++ b/compiler/optimizing/nodes_vector.h
@@ -161,10 +161,10 @@
   static_assert(kNumberOfVectorOpPackedBits <= kMaxNumberOfPackedBits, "Too many packed fields.");
   using TypeField = BitField<DataType::Type, kFieldType, kFieldTypeSize>;
 
+  DEFAULT_COPY_CONSTRUCTOR(VecOperation);
+
  private:
   const size_t vector_length_;
-
-  DISALLOW_COPY_AND_ASSIGN(HVecOperation);
 };
 
 // Abstraction of a unary vector operation.
@@ -188,8 +188,8 @@
 
   DECLARE_ABSTRACT_INSTRUCTION(VecUnaryOperation);
 
- private:
-  DISALLOW_COPY_AND_ASSIGN(HVecUnaryOperation);
+ protected:
+  DEFAULT_COPY_CONSTRUCTOR(VecUnaryOperation);
 };
 
 // Abstraction of a binary vector operation.
@@ -216,8 +216,8 @@
 
   DECLARE_ABSTRACT_INSTRUCTION(VecBinaryOperation);
 
- private:
-  DISALLOW_COPY_AND_ASSIGN(HVecBinaryOperation);
+ protected:
+  DEFAULT_COPY_CONSTRUCTOR(VecBinaryOperation);
 };
 
 // Abstraction of a vector operation that references memory, with an alignment.
@@ -255,10 +255,11 @@
 
   DECLARE_ABSTRACT_INSTRUCTION(VecMemoryOperation);
 
+ protected:
+  DEFAULT_COPY_CONSTRUCTOR(VecMemoryOperation);
+
  private:
   Alignment alignment_;
-
-  DISALLOW_COPY_AND_ASSIGN(HVecMemoryOperation);
 };
 
 // Packed type consistency checker ("same vector length" integral types may mix freely).
@@ -296,8 +297,8 @@
 
   DECLARE_INSTRUCTION(VecReplicateScalar);
 
- private:
-  DISALLOW_COPY_AND_ASSIGN(HVecReplicateScalar);
+ protected:
+  DEFAULT_COPY_CONSTRUCTOR(VecReplicateScalar);
 };
 
 // Extracts a particular scalar from the given vector,
@@ -329,8 +330,8 @@
 
   DECLARE_INSTRUCTION(VecExtractScalar);
 
- private:
-  DISALLOW_COPY_AND_ASSIGN(HVecExtractScalar);
+ protected:
+  DEFAULT_COPY_CONSTRUCTOR(VecExtractScalar);
 };
 
 // Reduces the given vector into the first element as sum/min/max,
@@ -367,10 +368,11 @@
 
   DECLARE_INSTRUCTION(VecReduce);
 
+ protected:
+  DEFAULT_COPY_CONSTRUCTOR(VecReduce);
+
  private:
   const ReductionKind kind_;
-
-  DISALLOW_COPY_AND_ASSIGN(HVecReduce);
 };
 
 // Converts every component in the vector,
@@ -394,8 +396,8 @@
 
   DECLARE_INSTRUCTION(VecCnv);
 
- private:
-  DISALLOW_COPY_AND_ASSIGN(HVecCnv);
+ protected:
+  DEFAULT_COPY_CONSTRUCTOR(VecCnv);
 };
 
 // Negates every component in the vector,
@@ -415,8 +417,8 @@
 
   DECLARE_INSTRUCTION(VecNeg);
 
- private:
-  DISALLOW_COPY_AND_ASSIGN(HVecNeg);
+ protected:
+  DEFAULT_COPY_CONSTRUCTOR(VecNeg);
 };
 
 // Takes absolute value of every component in the vector,
@@ -437,8 +439,8 @@
 
   DECLARE_INSTRUCTION(VecAbs);
 
- private:
-  DISALLOW_COPY_AND_ASSIGN(HVecAbs);
+ protected:
+  DEFAULT_COPY_CONSTRUCTOR(VecAbs);
 };
 
 // Bitwise- or boolean-nots every component in the vector,
@@ -459,8 +461,8 @@
 
   DECLARE_INSTRUCTION(VecNot);
 
- private:
-  DISALLOW_COPY_AND_ASSIGN(HVecNot);
+ protected:
+  DEFAULT_COPY_CONSTRUCTOR(VecNot);
 };
 
 //
@@ -486,8 +488,8 @@
 
   DECLARE_INSTRUCTION(VecAdd);
 
- private:
-  DISALLOW_COPY_AND_ASSIGN(HVecAdd);
+ protected:
+  DEFAULT_COPY_CONSTRUCTOR(VecAdd);
 };
 
 // Performs halving add on every component in the two vectors, viz.
@@ -531,14 +533,15 @@
 
   DECLARE_INSTRUCTION(VecHalvingAdd);
 
+ protected:
+  DEFAULT_COPY_CONSTRUCTOR(VecHalvingAdd);
+
  private:
   // Additional packed bits.
   static constexpr size_t kFieldHAddIsUnsigned = HVecOperation::kNumberOfVectorOpPackedBits;
   static constexpr size_t kFieldHAddIsRounded = kFieldHAddIsUnsigned + 1;
   static constexpr size_t kNumberOfHAddPackedBits = kFieldHAddIsRounded + 1;
   static_assert(kNumberOfHAddPackedBits <= kMaxNumberOfPackedBits, "Too many packed fields.");
-
-  DISALLOW_COPY_AND_ASSIGN(HVecHalvingAdd);
 };
 
 // Subtracts every component in the two vectors,
@@ -560,8 +563,8 @@
 
   DECLARE_INSTRUCTION(VecSub);
 
- private:
-  DISALLOW_COPY_AND_ASSIGN(HVecSub);
+ protected:
+  DEFAULT_COPY_CONSTRUCTOR(VecSub);
 };
 
 // Multiplies every component in the two vectors,
@@ -583,8 +586,8 @@
 
   DECLARE_INSTRUCTION(VecMul);
 
- private:
-  DISALLOW_COPY_AND_ASSIGN(HVecMul);
+ protected:
+  DEFAULT_COPY_CONSTRUCTOR(VecMul);
 };
 
 // Divides every component in the two vectors,
@@ -606,8 +609,8 @@
 
   DECLARE_INSTRUCTION(VecDiv);
 
- private:
-  DISALLOW_COPY_AND_ASSIGN(HVecDiv);
+ protected:
+  DEFAULT_COPY_CONSTRUCTOR(VecDiv);
 };
 
 // Takes minimum of every component in the two vectors,
@@ -645,13 +648,14 @@
 
   DECLARE_INSTRUCTION(VecMin);
 
+ protected:
+  DEFAULT_COPY_CONSTRUCTOR(VecMin);
+
  private:
   // Additional packed bits.
   static constexpr size_t kFieldMinOpIsUnsigned = HVecOperation::kNumberOfVectorOpPackedBits;
   static constexpr size_t kNumberOfMinOpPackedBits = kFieldMinOpIsUnsigned + 1;
   static_assert(kNumberOfMinOpPackedBits <= kMaxNumberOfPackedBits, "Too many packed fields.");
-
-  DISALLOW_COPY_AND_ASSIGN(HVecMin);
 };
 
 // Takes maximum of every component in the two vectors,
@@ -689,13 +693,14 @@
 
   DECLARE_INSTRUCTION(VecMax);
 
+ protected:
+  DEFAULT_COPY_CONSTRUCTOR(VecMax);
+
  private:
   // Additional packed bits.
   static constexpr size_t kFieldMaxOpIsUnsigned = HVecOperation::kNumberOfVectorOpPackedBits;
   static constexpr size_t kNumberOfMaxOpPackedBits = kFieldMaxOpIsUnsigned + 1;
   static_assert(kNumberOfMaxOpPackedBits <= kMaxNumberOfPackedBits, "Too many packed fields.");
-
-  DISALLOW_COPY_AND_ASSIGN(HVecMax);
 };
 
 // Bitwise-ands every component in the two vectors,
@@ -716,8 +721,8 @@
 
   DECLARE_INSTRUCTION(VecAnd);
 
- private:
-  DISALLOW_COPY_AND_ASSIGN(HVecAnd);
+ protected:
+  DEFAULT_COPY_CONSTRUCTOR(VecAnd);
 };
 
 // Bitwise-and-nots every component in the two vectors,
@@ -738,8 +743,8 @@
 
   DECLARE_INSTRUCTION(VecAndNot);
 
- private:
-  DISALLOW_COPY_AND_ASSIGN(HVecAndNot);
+ protected:
+  DEFAULT_COPY_CONSTRUCTOR(VecAndNot);
 };
 
 // Bitwise-ors every component in the two vectors,
@@ -760,8 +765,8 @@
 
   DECLARE_INSTRUCTION(VecOr);
 
- private:
-  DISALLOW_COPY_AND_ASSIGN(HVecOr);
+ protected:
+  DEFAULT_COPY_CONSTRUCTOR(VecOr);
 };
 
 // Bitwise-xors every component in the two vectors,
@@ -782,8 +787,8 @@
 
   DECLARE_INSTRUCTION(VecXor);
 
- private:
-  DISALLOW_COPY_AND_ASSIGN(HVecXor);
+ protected:
+  DEFAULT_COPY_CONSTRUCTOR(VecXor);
 };
 
 // Logically shifts every component in the vector left by the given distance,
@@ -804,8 +809,8 @@
 
   DECLARE_INSTRUCTION(VecShl);
 
- private:
-  DISALLOW_COPY_AND_ASSIGN(HVecShl);
+ protected:
+  DEFAULT_COPY_CONSTRUCTOR(VecShl);
 };
 
 // Arithmetically shifts every component in the vector right by the given distance,
@@ -826,8 +831,8 @@
 
   DECLARE_INSTRUCTION(VecShr);
 
- private:
-  DISALLOW_COPY_AND_ASSIGN(HVecShr);
+ protected:
+  DEFAULT_COPY_CONSTRUCTOR(VecShr);
 };
 
 // Logically shifts every component in the vector right by the given distance,
@@ -848,8 +853,8 @@
 
   DECLARE_INSTRUCTION(VecUShr);
 
- private:
-  DISALLOW_COPY_AND_ASSIGN(HVecUShr);
+ protected:
+  DEFAULT_COPY_CONSTRUCTOR(VecUShr);
 };
 
 //
@@ -885,8 +890,8 @@
 
   DECLARE_INSTRUCTION(VecSetScalars);
 
- private:
-  DISALLOW_COPY_AND_ASSIGN(HVecSetScalars);
+ protected:
+  DEFAULT_COPY_CONSTRUCTOR(VecSetScalars);
 };
 
 // Multiplies every component in the two vectors, adds the result vector to the accumulator vector,
@@ -929,11 +934,12 @@
 
   DECLARE_INSTRUCTION(VecMultiplyAccumulate);
 
+ protected:
+  DEFAULT_COPY_CONSTRUCTOR(VecMultiplyAccumulate);
+
  private:
   // Indicates if this is a MADD or MSUB.
   const InstructionKind op_kind_;
-
-  DISALLOW_COPY_AND_ASSIGN(HVecMultiplyAccumulate);
 };
 
 // Takes the absolute difference of two vectors, and adds the results to
@@ -968,8 +974,8 @@
 
   DECLARE_INSTRUCTION(VecSADAccumulate);
 
- private:
-  DISALLOW_COPY_AND_ASSIGN(HVecSADAccumulate);
+ protected:
+  DEFAULT_COPY_CONSTRUCTOR(VecSADAccumulate);
 };
 
 // Loads a vector from memory, viz. load(mem, 1)
@@ -1007,13 +1013,14 @@
 
   DECLARE_INSTRUCTION(VecLoad);
 
+ protected:
+  DEFAULT_COPY_CONSTRUCTOR(VecLoad);
+
  private:
   // Additional packed bits.
   static constexpr size_t kFieldIsStringCharAt = HVecOperation::kNumberOfVectorOpPackedBits;
   static constexpr size_t kNumberOfVecLoadPackedBits = kFieldIsStringCharAt + 1;
   static_assert(kNumberOfVecLoadPackedBits <= kMaxNumberOfPackedBits, "Too many packed fields.");
-
-  DISALLOW_COPY_AND_ASSIGN(HVecLoad);
 };
 
 // Stores a vector to memory, viz. store(m, 1, [x1, .. , xn] )
@@ -1045,8 +1052,8 @@
 
   DECLARE_INSTRUCTION(VecStore);
 
- private:
-  DISALLOW_COPY_AND_ASSIGN(HVecStore);
+ protected:
+  DEFAULT_COPY_CONSTRUCTOR(VecStore)
 };
 
 }  // namespace art