DECLARE_ABSTRACT_INSTRUCTION(VecOperation);
- private:
+ protected:
// Additional packed bits.
static constexpr size_t kFieldType = HInstruction::kNumberOfGenericPackedBits;
static constexpr size_t kFieldTypeSize =
static_assert(kNumberOfVectorOpPackedBits <= kMaxNumberOfPackedBits, "Too many packed fields.");
using TypeField = BitField<Primitive::Type, kFieldType, kFieldTypeSize>;
+ private:
const size_t vector_length_;
DISALLOW_COPY_AND_ASSIGN(HVecOperation);
DISALLOW_COPY_AND_ASSIGN(HVecMemoryOperation);
};
+// Packed type consistency checker (same vector length integral types may mix freely).
+inline static bool HasConsistentPackedTypes(HInstruction* input, Primitive::Type type) {
+ DCHECK(input->IsVecOperation());
+ Primitive::Type input_type = input->AsVecOperation()->GetPackedType();
+ switch (input_type) {
+ case Primitive::kPrimBoolean:
+ case Primitive::kPrimByte:
+ return type == Primitive::kPrimBoolean ||
+ type == Primitive::kPrimByte;
+ case Primitive::kPrimChar:
+ case Primitive::kPrimShort:
+ return type == Primitive::kPrimChar ||
+ type == Primitive::kPrimShort;
+ default:
+ return type == input_type;
+ }
+}
+
//
// Definitions of concrete unary vector operations in HIR.
//
size_t vector_length,
uint32_t dex_pc = kNoDexPc)
: HVecUnaryOperation(arena, input, packed_type, vector_length, dex_pc) {
- DCHECK(input->IsVecOperation());
- DCHECK_EQ(input->AsVecOperation()->GetPackedType(), packed_type);
+ DCHECK(HasConsistentPackedTypes(input, packed_type));
}
// TODO: probably integral promotion
uint32_t dex_pc = kNoDexPc)
: HVecUnaryOperation(arena, input, packed_type, vector_length, dex_pc) {
DCHECK(input->IsVecOperation());
- DCHECK_NE(input->AsVecOperation()->GetPackedType(), packed_type); // actual convert
+ DCHECK_NE(GetInputType(), GetResultType()); // actual convert
}
Primitive::Type GetInputType() const { return InputAt(0)->AsVecOperation()->GetPackedType(); }
size_t vector_length,
uint32_t dex_pc = kNoDexPc)
: HVecUnaryOperation(arena, input, packed_type, vector_length, dex_pc) {
- DCHECK(input->IsVecOperation());
- DCHECK_EQ(input->AsVecOperation()->GetPackedType(), packed_type);
+ DCHECK(HasConsistentPackedTypes(input, packed_type));
}
DECLARE_INSTRUCTION(VecNeg);
private:
size_t vector_length,
uint32_t dex_pc = kNoDexPc)
: HVecUnaryOperation(arena, input, packed_type, vector_length, dex_pc) {
- DCHECK(input->IsVecOperation());
- DCHECK_EQ(input->AsVecOperation()->GetPackedType(), packed_type);
+ DCHECK(HasConsistentPackedTypes(input, packed_type));
}
DECLARE_INSTRUCTION(VecAbs);
private:
size_t vector_length,
uint32_t dex_pc = kNoDexPc)
: HVecBinaryOperation(arena, left, right, packed_type, vector_length, dex_pc) {
- DCHECK(left->IsVecOperation() && right->IsVecOperation());
- DCHECK_EQ(left->AsVecOperation()->GetPackedType(), packed_type);
- DCHECK_EQ(right->AsVecOperation()->GetPackedType(), packed_type);
+ DCHECK(HasConsistentPackedTypes(left, packed_type));
+ DCHECK(HasConsistentPackedTypes(right, packed_type));
}
DECLARE_INSTRUCTION(VecAdd);
private:
bool is_unsigned,
bool is_rounded,
uint32_t dex_pc = kNoDexPc)
- : HVecBinaryOperation(arena, left, right, packed_type, vector_length, dex_pc),
- is_unsigned_(is_unsigned),
- is_rounded_(is_rounded) {
- DCHECK(left->IsVecOperation() && right->IsVecOperation());
- DCHECK_EQ(left->AsVecOperation()->GetPackedType(), packed_type);
- DCHECK_EQ(right->AsVecOperation()->GetPackedType(), packed_type);
+ : HVecBinaryOperation(arena, left, right, packed_type, vector_length, dex_pc) {
+ DCHECK(HasConsistentPackedTypes(left, packed_type));
+ DCHECK(HasConsistentPackedTypes(right, packed_type));
+ SetPackedFlag<kFieldHAddIsUnsigned>(is_unsigned);
+ SetPackedFlag<kFieldHAddIsRounded>(is_rounded);
}
- bool IsUnsigned() const { return is_unsigned_; }
- bool IsRounded() const { return is_rounded_; }
+ bool IsUnsigned() const { return GetPackedFlag<kFieldHAddIsUnsigned>(); }
+ bool IsRounded() const { return GetPackedFlag<kFieldHAddIsRounded>(); }
DECLARE_INSTRUCTION(VecHalvingAdd);
private:
- bool is_unsigned_;
- bool is_rounded_;
+ // 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);
};
size_t vector_length,
uint32_t dex_pc = kNoDexPc)
: HVecBinaryOperation(arena, left, right, packed_type, vector_length, dex_pc) {
- DCHECK(left->IsVecOperation() && right->IsVecOperation());
- DCHECK_EQ(left->AsVecOperation()->GetPackedType(), packed_type);
- DCHECK_EQ(right->AsVecOperation()->GetPackedType(), packed_type);
+ DCHECK(HasConsistentPackedTypes(left, packed_type));
+ DCHECK(HasConsistentPackedTypes(right, packed_type));
}
DECLARE_INSTRUCTION(VecSub);
private:
size_t vector_length,
uint32_t dex_pc = kNoDexPc)
: HVecBinaryOperation(arena, left, right, packed_type, vector_length, dex_pc) {
- DCHECK(left->IsVecOperation() && right->IsVecOperation());
- DCHECK_EQ(left->AsVecOperation()->GetPackedType(), packed_type);
- DCHECK_EQ(right->AsVecOperation()->GetPackedType(), packed_type);
+ DCHECK(HasConsistentPackedTypes(left, packed_type));
+ DCHECK(HasConsistentPackedTypes(right, packed_type));
}
DECLARE_INSTRUCTION(VecMul);
private:
size_t vector_length,
uint32_t dex_pc = kNoDexPc)
: HVecBinaryOperation(arena, left, right, packed_type, vector_length, dex_pc) {
- DCHECK(left->IsVecOperation() && right->IsVecOperation());
- DCHECK_EQ(left->AsVecOperation()->GetPackedType(), packed_type);
- DCHECK_EQ(right->AsVecOperation()->GetPackedType(), packed_type);
+ DCHECK(HasConsistentPackedTypes(left, packed_type));
+ DCHECK(HasConsistentPackedTypes(right, packed_type));
}
DECLARE_INSTRUCTION(VecDiv);
private:
size_t vector_length,
uint32_t dex_pc = kNoDexPc)
: HVecBinaryOperation(arena, left, right, packed_type, vector_length, dex_pc) {
- DCHECK(left->IsVecOperation() && right->IsVecOperation());
- DCHECK_EQ(left->AsVecOperation()->GetPackedType(), packed_type);
- DCHECK_EQ(right->AsVecOperation()->GetPackedType(), packed_type);
+ DCHECK(HasConsistentPackedTypes(left, packed_type));
+ DCHECK(HasConsistentPackedTypes(right, packed_type));
}
DECLARE_INSTRUCTION(VecMin);
private:
size_t vector_length,
uint32_t dex_pc = kNoDexPc)
: HVecBinaryOperation(arena, left, right, packed_type, vector_length, dex_pc) {
- DCHECK(left->IsVecOperation() && right->IsVecOperation());
- DCHECK_EQ(left->AsVecOperation()->GetPackedType(), packed_type);
- DCHECK_EQ(right->AsVecOperation()->GetPackedType(), packed_type);
+ DCHECK(HasConsistentPackedTypes(left, packed_type));
+ DCHECK(HasConsistentPackedTypes(right, packed_type));
}
DECLARE_INSTRUCTION(VecMax);
private:
size_t vector_length,
uint32_t dex_pc = kNoDexPc)
: HVecBinaryOperation(arena, left, right, packed_type, vector_length, dex_pc) {
- DCHECK(left->IsVecOperation());
- DCHECK_EQ(left->AsVecOperation()->GetPackedType(), packed_type);
+ DCHECK(HasConsistentPackedTypes(left, packed_type));
}
DECLARE_INSTRUCTION(VecShl);
private:
size_t vector_length,
uint32_t dex_pc = kNoDexPc)
: HVecBinaryOperation(arena, left, right, packed_type, vector_length, dex_pc) {
- DCHECK(left->IsVecOperation());
- DCHECK_EQ(left->AsVecOperation()->GetPackedType(), packed_type);
+ DCHECK(HasConsistentPackedTypes(left, packed_type));
}
DECLARE_INSTRUCTION(VecShr);
private:
size_t vector_length,
uint32_t dex_pc = kNoDexPc)
: HVecBinaryOperation(arena, left, right, packed_type, vector_length, dex_pc) {
- DCHECK(left->IsVecOperation());
- DCHECK_EQ(left->AsVecOperation()->GetPackedType(), packed_type);
+ DCHECK(HasConsistentPackedTypes(left, packed_type));
}
DECLARE_INSTRUCTION(VecUShr);
private:
dex_pc),
op_kind_(op) {
DCHECK(op == InstructionKind::kAdd || op == InstructionKind::kSub);
- DCHECK(accumulator->IsVecOperation());
- DCHECK(mul_left->IsVecOperation() && mul_right->IsVecOperation());
- DCHECK_EQ(accumulator->AsVecOperation()->GetPackedType(), packed_type);
- DCHECK_EQ(mul_left->AsVecOperation()->GetPackedType(), packed_type);
- DCHECK_EQ(mul_right->AsVecOperation()->GetPackedType(), packed_type);
-
+ DCHECK(HasConsistentPackedTypes(accumulator, packed_type));
+ DCHECK(HasConsistentPackedTypes(mul_left, packed_type));
+ DCHECK(HasConsistentPackedTypes(mul_right, packed_type));
SetRawInputAt(kInputAccumulatorIndex, accumulator);
SetRawInputAt(kInputMulLeftIndex, mul_left);
SetRawInputAt(kInputMulRightIndex, mul_right);
HInstruction* index,
Primitive::Type packed_type,
size_t vector_length,
+ bool is_string_char_at,
uint32_t dex_pc = kNoDexPc)
: HVecMemoryOperation(arena,
packed_type,
dex_pc) {
SetRawInputAt(0, base);
SetRawInputAt(1, index);
+ SetPackedFlag<kFieldIsStringCharAt>(is_string_char_at);
}
DECLARE_INSTRUCTION(VecLoad);
+
+ bool IsStringCharAt() const { return GetPackedFlag<kFieldIsStringCharAt>(); }
+
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);
};
/* number_of_inputs */ 3,
vector_length,
dex_pc) {
- DCHECK(value->IsVecOperation());
- DCHECK_EQ(value->AsVecOperation()->GetPackedType(), packed_type);
+ DCHECK(HasConsistentPackedTypes(value, packed_type));
SetRawInputAt(0, base);
SetRawInputAt(1, index);
SetRawInputAt(2, value);