Commit e10a30d4 authored by jiepan's avatar jiepan Committed by Commit Bot

Fix PrintParameter of S8x16Shuffle

The lane indices of S8x16Shuffle will be printed as null-terminated
character array in Operator1's PrintParameter implementation.This patch
add S8x16ShuffleParameter class, override operater<<, print indices as
integer array.

before fix:
Shuffle[\b\t\n^K\f\r^N^O]

after fix:
Shuffle[8,9,10,11,12,13,14,15,0,0,0,0,0,0,0,0]

Change-Id: I421e639f5229d3a5e348868be33f2d8bbfcfd2d6
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1922735
Commit-Queue: Jie Pan <jie.pan@intel.com>
Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Reviewed-by: 's avatarBill Budge <bbudge@chromium.org>
Auto-Submit: Jie Pan <jie.pan@intel.com>
Cr-Commit-Position: refs/heads/master@{#65253}
parent 80fd0b3d
......@@ -3142,7 +3142,7 @@ void InstructionSelector::CanonicalizeShuffle(bool inputs_equal,
void InstructionSelector::CanonicalizeShuffle(Node* node, uint8_t* shuffle,
bool* is_swizzle) {
// Get raw shuffle indices.
memcpy(shuffle, S8x16ShuffleOf(node->op()), kSimd128Size);
memcpy(shuffle, S8x16ShuffleParameterOf(node->op()).data(), kSimd128Size);
bool needs_swap;
bool inputs_equal = GetVirtualRegister(node->InputAt(0)) ==
GetVirtualRegister(node->InputAt(1));
......
......@@ -1492,18 +1492,38 @@ const Operator* MachineOperatorBuilder::I64x2ReplaceLaneI32Pair(
"Replace lane", 3, 0, 0, 1, 0, 0, lane_index);
}
const Operator* MachineOperatorBuilder::S8x16Shuffle(
const uint8_t shuffle[16]) {
uint8_t* array = zone_->NewArray<uint8_t>(16);
memcpy(array, shuffle, 16);
return new (zone_)
Operator1<uint8_t*>(IrOpcode::kS8x16Shuffle, Operator::kPure, "Shuffle",
2, 0, 0, 1, 0, 0, array);
bool operator==(S8x16ShuffleParameter const& lhs,
S8x16ShuffleParameter const& rhs) {
return (lhs.shuffle() == rhs.shuffle());
}
bool operator!=(S8x16ShuffleParameter const& lhs,
S8x16ShuffleParameter const& rhs) {
return !(lhs == rhs);
}
size_t hash_value(S8x16ShuffleParameter const& p) {
return base::hash_range(p.shuffle().begin(), p.shuffle().end());
}
const uint8_t* S8x16ShuffleOf(Operator const* op) {
std::ostream& operator<<(std::ostream& os, S8x16ShuffleParameter const& p) {
for (int i = 0; i < 16; i++) {
const char* separator = (i < 15) ? "," : "";
os << static_cast<uint32_t>(p[i]) << separator;
}
return os;
}
S8x16ShuffleParameter const& S8x16ShuffleParameterOf(Operator const* op) {
DCHECK_EQ(IrOpcode::kS8x16Shuffle, op->opcode());
return OpParameter<uint8_t*>(op);
return OpParameter<S8x16ShuffleParameter>(op);
}
const Operator* MachineOperatorBuilder::S8x16Shuffle(
const uint8_t shuffle[16]) {
return new (zone_) Operator1<S8x16ShuffleParameter>(
IrOpcode::kS8x16Shuffle, Operator::kPure, "Shuffle", 2, 0, 0, 1, 0, 0,
S8x16ShuffleParameter(shuffle));
}
StackCheckKind StackCheckKindOf(Operator const* op) {
......
......@@ -153,8 +153,31 @@ MachineRepresentation AtomicStoreRepresentationOf(Operator const* op)
MachineType AtomicOpType(Operator const* op) V8_WARN_UNUSED_RESULT;
V8_EXPORT_PRIVATE const uint8_t* S8x16ShuffleOf(Operator const* op)
V8_WARN_UNUSED_RESULT;
class S8x16ShuffleParameter {
public:
explicit S8x16ShuffleParameter(const uint8_t shuffle[16]) {
std::copy(shuffle, shuffle + 16, shuffle_.begin());
}
const std::array<uint8_t, 16>& shuffle() const { return shuffle_; }
const uint8_t* data() const { return shuffle_.data(); }
uint8_t operator[](int x) const { return shuffle_[x]; }
private:
std::array<uint8_t, 16> shuffle_;
};
V8_EXPORT_PRIVATE bool operator==(S8x16ShuffleParameter const& lhs,
S8x16ShuffleParameter const& rhs);
bool operator!=(S8x16ShuffleParameter const& lhs,
S8x16ShuffleParameter const& rhs);
size_t hash_value(S8x16ShuffleParameter const& p);
V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&,
S8x16ShuffleParameter const&);
V8_EXPORT_PRIVATE S8x16ShuffleParameter const& S8x16ShuffleParameterOf(
Operator const* op) V8_WARN_UNUSED_RESULT;
StackCheckKind StackCheckKindOf(Operator const* op) V8_WARN_UNUSED_RESULT;
......
......@@ -1428,7 +1428,7 @@ void SimdScalarLowering::LowerNode(Node* node) {
}
case IrOpcode::kS8x16Shuffle: {
DCHECK_EQ(2, node->InputCount());
const uint8_t* shuffle = S8x16ShuffleOf(node->op());
S8x16ShuffleParameter shuffle = S8x16ShuffleParameterOf(node->op());
Node** rep_left = GetReplacementsWithType(node->InputAt(0), rep_type);
Node** rep_right = GetReplacementsWithType(node->InputAt(1), rep_type);
Node** rep_node = zone()->NewArray<Node*>(16);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment