Commit 46f000bc authored by Camillo Bruni's avatar Camillo Bruni Committed by Commit Bot

[CSA] Replace Word32Not with Word32BitwiseNot

This should make the uses of binary vs. bitwise not very clear:
- Word32BinaryNot for logical negation
- Word32BitwiseNot for bitwise negation

Change-Id: I3345913111da0dbdae6fdf285f090b67eb3f3afc
Reviewed-on: https://chromium-review.googlesource.com/1169205
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55091}
parent ffc84ec3
......@@ -1126,7 +1126,8 @@ void TypedArrayBuiltinsAssembler::
TNode<JSTypedArray> dest,
TNode<IntPtrT> source_length,
TNode<IntPtrT> offset) {
CSA_ASSERT(this, Word32Not(IsBigInt64ElementsKind(LoadElementsKind(dest))));
CSA_ASSERT(this,
Word32BinaryNot(IsBigInt64ElementsKind(LoadElementsKind(dest))));
TNode<ExternalReference> f = ExternalConstant(
ExternalReference::copy_fast_number_jsarray_elements_to_typed_array());
CallCFunction5(MachineType::AnyTagged(), MachineType::AnyTagged(),
......
......@@ -1523,7 +1523,7 @@ TNode<BoolT> CodeStubAssembler::TaggedDoesntHaveInstanceType(
TNode<HeapObject> CodeStubAssembler::LoadFastProperties(
SloppyTNode<JSObject> object) {
CSA_SLOW_ASSERT(this, Word32Not(IsDictionaryMap(LoadMap(object))));
CSA_SLOW_ASSERT(this, Word32BinaryNot(IsDictionaryMap(LoadMap(object))));
TNode<Object> properties =
LoadObjectField(object, JSObject::kPropertiesOrHashOffset);
return Select<HeapObject>(TaggedIsSmi(properties),
......@@ -2492,7 +2492,7 @@ TNode<Word32T> CodeStubAssembler::PrototypeRequiresRuntimeLookup(
TNode<Map> map = LoadMap(function);
return Word32Or(
Word32Not(HasPrototypeProperty(function)),
Word32BinaryNot(HasPrototypeProperty(function)),
IsSetWord32<Map::HasNonInstancePrototypeBit>(LoadMapBitField(map)));
}
......
......@@ -538,12 +538,12 @@ TNode<Float64T> Float64Add(TNode<Float64T> a, TNode<Float64T> b);
V(Float64RoundTiesEven, Float64T, Float64T) \
V(Float64RoundTruncate, Float64T, Float64T) \
V(Word32Clz, Int32T, Word32T) \
V(Word32Not, Word32T, Word32T) \
V(Word32BitwiseNot, Word32T, Word32T) \
V(WordNot, WordT, WordT) \
V(Int32AbsWithOverflow, PAIR_TYPE(Int32T, BoolT), Int32T) \
V(Int64AbsWithOverflow, PAIR_TYPE(Int64T, BoolT), Int64T) \
V(IntPtrAbsWithOverflow, PAIR_TYPE(IntPtrT, BoolT), IntPtrT) \
V(Word32BinaryNot, Word32T, Word32T)
V(Word32BinaryNot, BoolT, Word32T)
// A "public" interface used by components outside of compiler directory to
// create code objects with TurboFan's backend. This class is mostly a thin
......
......@@ -229,7 +229,7 @@ class V8_EXPORT_PRIVATE RawMachineAssembler {
}
Node* WordNot(Node* a) {
if (machine()->Is32()) {
return Word32Not(a);
return Word32BitwiseNot(a);
} else {
return Word64Not(a);
}
......@@ -263,7 +263,7 @@ class V8_EXPORT_PRIVATE RawMachineAssembler {
Node* Word32NotEqual(Node* a, Node* b) {
return Word32BinaryNot(Word32Equal(a, b));
}
Node* Word32Not(Node* a) { return Word32Xor(a, Int32Constant(-1)); }
Node* Word32BitwiseNot(Node* a) { return Word32Xor(a, Int32Constant(-1)); }
Node* Word32BinaryNot(Node* a) { return Word32Equal(a, Int32Constant(0)); }
Node* Word64And(Node* a, Node* b) {
......
......@@ -1070,7 +1070,7 @@ IGNITION_HANDLER(BitwiseNot, InterpreterAssembler) {
// Number case.
BIND(&if_number);
TNode<Number> result =
ChangeInt32ToTagged(Signed(Word32Not(var_word32.value())));
ChangeInt32ToTagged(Signed(Word32BitwiseNot(var_word32.value())));
TNode<Smi> result_type = SelectSmiConstant(
TaggedIsSmi(result), BinaryOperationFeedback::kSignedSmall,
BinaryOperationFeedback::kNumber);
......
......@@ -2396,7 +2396,7 @@ TEST(RunWord32AndP) {
{
RawMachineAssemblerTester<int32_t> m;
Int32BinopTester bt(&m);
bt.AddReturn(m.Word32And(bt.param0, m.Word32Not(bt.param1)));
bt.AddReturn(m.Word32And(bt.param0, m.Word32BitwiseNot(bt.param1)));
FOR_UINT32_INPUTS(i) {
FOR_UINT32_INPUTS(j) {
int32_t expected = *i & ~(*j);
......@@ -2407,7 +2407,7 @@ TEST(RunWord32AndP) {
{
RawMachineAssemblerTester<int32_t> m;
Int32BinopTester bt(&m);
bt.AddReturn(m.Word32And(m.Word32Not(bt.param0), bt.param1));
bt.AddReturn(m.Word32And(m.Word32BitwiseNot(bt.param0), bt.param1));
FOR_UINT32_INPUTS(i) {
FOR_UINT32_INPUTS(j) {
int32_t expected = ~(*i) & *j;
......@@ -2516,7 +2516,8 @@ TEST(RunWord32AndImm) {
{
FOR_UINT32_INPUTS(i) {
RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32());
m.Return(m.Word32And(m.Int32Constant(*i), m.Word32Not(m.Parameter(0))));
m.Return(
m.Word32And(m.Int32Constant(*i), m.Word32BitwiseNot(m.Parameter(0))));
FOR_UINT32_INPUTS(j) {
uint32_t expected = *i & ~(*j);
CHECK_EQ(expected, m.Call(*j));
......@@ -2709,7 +2710,7 @@ TEST(RunWord32OrP) {
{
RawMachineAssemblerTester<int32_t> m;
Uint32BinopTester bt(&m);
bt.AddReturn(m.Word32Or(bt.param0, m.Word32Not(bt.param1)));
bt.AddReturn(m.Word32Or(bt.param0, m.Word32BitwiseNot(bt.param1)));
FOR_UINT32_INPUTS(i) {
FOR_UINT32_INPUTS(j) {
uint32_t expected = *i | ~(*j);
......@@ -2720,7 +2721,7 @@ TEST(RunWord32OrP) {
{
RawMachineAssemblerTester<int32_t> m;
Uint32BinopTester bt(&m);
bt.AddReturn(m.Word32Or(m.Word32Not(bt.param0), bt.param1));
bt.AddReturn(m.Word32Or(m.Word32BitwiseNot(bt.param0), bt.param1));
FOR_UINT32_INPUTS(i) {
FOR_UINT32_INPUTS(j) {
uint32_t expected = ~(*i) | *j;
......@@ -2745,7 +2746,8 @@ TEST(RunWord32OrImm) {
{
FOR_UINT32_INPUTS(i) {
RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32());
m.Return(m.Word32Or(m.Int32Constant(*i), m.Word32Not(m.Parameter(0))));
m.Return(
m.Word32Or(m.Int32Constant(*i), m.Word32BitwiseNot(m.Parameter(0))));
FOR_UINT32_INPUTS(j) {
uint32_t expected = *i | ~(*j);
CHECK_EQ(expected, m.Call(*j));
......@@ -2947,7 +2949,7 @@ TEST(RunWord32XorP) {
{
RawMachineAssemblerTester<int32_t> m;
Int32BinopTester bt(&m);
bt.AddReturn(m.Word32Xor(bt.param0, m.Word32Not(bt.param1)));
bt.AddReturn(m.Word32Xor(bt.param0, m.Word32BitwiseNot(bt.param1)));
FOR_INT32_INPUTS(i) {
FOR_INT32_INPUTS(j) {
int32_t expected = *i ^ ~(*j);
......@@ -2958,7 +2960,7 @@ TEST(RunWord32XorP) {
{
RawMachineAssemblerTester<int32_t> m;
Int32BinopTester bt(&m);
bt.AddReturn(m.Word32Xor(m.Word32Not(bt.param0), bt.param1));
bt.AddReturn(m.Word32Xor(m.Word32BitwiseNot(bt.param0), bt.param1));
FOR_INT32_INPUTS(i) {
FOR_INT32_INPUTS(j) {
int32_t expected = ~(*i) ^ *j;
......@@ -2969,7 +2971,8 @@ TEST(RunWord32XorP) {
{
FOR_UINT32_INPUTS(i) {
RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32());
m.Return(m.Word32Xor(m.Int32Constant(*i), m.Word32Not(m.Parameter(0))));
m.Return(
m.Word32Xor(m.Int32Constant(*i), m.Word32BitwiseNot(m.Parameter(0))));
FOR_UINT32_INPUTS(j) {
uint32_t expected = *i ^ ~(*j);
CHECK_EQ(expected, m.Call(*j));
......@@ -3454,10 +3457,9 @@ TEST(RunWord32RorInComparison) {
}
}
TEST(RunWord32NotP) {
TEST(RunWord32BitwiseNotP) {
RawMachineAssemblerTester<int32_t> m(MachineType::Int32());
m.Return(m.Word32Not(m.Parameter(0)));
m.Return(m.Word32BitwiseNot(m.Parameter(0)));
FOR_INT32_INPUTS(i) {
int expected = ~(*i);
CHECK_EQ(expected, m.Call(*i));
......
......@@ -1183,12 +1183,12 @@ TEST_P(InstructionSelectorShiftTest, Word32EqualToZeroWithImmediate) {
}
}
TEST_P(InstructionSelectorShiftTest, Word32NotWithParameters) {
TEST_P(InstructionSelectorShiftTest, Word32BitwiseNotWithParameters) {
const Shift shift = GetParam();
StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(),
MachineType::Int32());
m.Return(m.Word32Not((m.*shift.constructor)(m.Parameter(0), m.Parameter(1))));
m.Return(m.Word32BitwiseNot(
(m.*shift.constructor)(m.Parameter(0), m.Parameter(1))));
Stream s = m.Build();
ASSERT_EQ(1U, s.size());
EXPECT_EQ(kArmMvn, s[0]->arch_opcode());
......@@ -1197,12 +1197,11 @@ TEST_P(InstructionSelectorShiftTest, Word32NotWithParameters) {
EXPECT_EQ(1U, s[0]->OutputCount());
}
TEST_P(InstructionSelectorShiftTest, Word32NotWithImmediate) {
TEST_P(InstructionSelectorShiftTest, Word32BitwiseNotWithImmediate) {
const Shift shift = GetParam();
TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) {
StreamBuilder m(this, MachineType::Int32(), MachineType::Int32());
m.Return(m.Word32Not(
m.Return(m.Word32BitwiseNot(
(m.*shift.constructor)(m.Parameter(0), m.Int32Constant(imm))));
Stream s = m.Build();
ASSERT_EQ(1U, s.size());
......@@ -1214,13 +1213,14 @@ TEST_P(InstructionSelectorShiftTest, Word32NotWithImmediate) {
}
}
TEST_P(InstructionSelectorShiftTest, Word32AndWithWord32NotWithParameters) {
TEST_P(InstructionSelectorShiftTest,
Word32AndWithWord32BitwiseNotWithParameters) {
const Shift shift = GetParam();
StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(),
MachineType::Int32(), MachineType::Int32());
m.Return(m.Word32And(m.Parameter(0), m.Word32Not((m.*shift.constructor)(
m.Parameter(1), m.Parameter(2)))));
m.Return(
m.Word32And(m.Parameter(0), m.Word32BitwiseNot((m.*shift.constructor)(
m.Parameter(1), m.Parameter(2)))));
Stream s = m.Build();
ASSERT_EQ(1U, s.size());
EXPECT_EQ(kArmBic, s[0]->arch_opcode());
......@@ -1229,14 +1229,14 @@ TEST_P(InstructionSelectorShiftTest, Word32AndWithWord32NotWithParameters) {
EXPECT_EQ(1U, s[0]->OutputCount());
}
TEST_P(InstructionSelectorShiftTest, Word32AndWithWord32NotWithImmediate) {
TEST_P(InstructionSelectorShiftTest,
Word32AndWithWord32BitwiseNotWithImmediate) {
const Shift shift = GetParam();
TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) {
StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(),
MachineType::Int32());
m.Return(m.Word32And(m.Parameter(0),
m.Word32Not((m.*shift.constructor)(
m.Word32BitwiseNot((m.*shift.constructor)(
m.Parameter(1), m.Int32Constant(imm)))));
Stream s = m.Build();
ASSERT_EQ(1U, s.size());
......@@ -2971,12 +2971,11 @@ TEST_F(InstructionSelectorTest, Word32ShrWithWord32AndWithImmediateForARMv7) {
}
}
TEST_F(InstructionSelectorTest, Word32AndWithWord32Not) {
TEST_F(InstructionSelectorTest, Word32AndWithWord32BitwiseNot) {
{
StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(),
MachineType::Int32());
m.Return(m.Word32And(m.Parameter(0), m.Word32Not(m.Parameter(1))));
m.Return(m.Word32And(m.Parameter(0), m.Word32BitwiseNot(m.Parameter(1))));
Stream s = m.Build();
ASSERT_EQ(1U, s.size());
EXPECT_EQ(kArmBic, s[0]->arch_opcode());
......@@ -2987,7 +2986,7 @@ TEST_F(InstructionSelectorTest, Word32AndWithWord32Not) {
{
StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(),
MachineType::Int32());
m.Return(m.Word32And(m.Word32Not(m.Parameter(0)), m.Parameter(1)));
m.Return(m.Word32And(m.Word32BitwiseNot(m.Parameter(0)), m.Parameter(1)));
Stream s = m.Build();
ASSERT_EQ(1U, s.size());
EXPECT_EQ(kArmBic, s[0]->arch_opcode());
......@@ -3076,10 +3075,9 @@ TEST_F(InstructionSelectorTest, Word32EqualWithZero) {
}
}
TEST_F(InstructionSelectorTest, Word32NotWithParameter) {
TEST_F(InstructionSelectorTest, Word32BitwiseNotWithParameter) {
StreamBuilder m(this, MachineType::Int32(), MachineType::Int32());
m.Return(m.Word32Not(m.Parameter(0)));
m.Return(m.Word32BitwiseNot(m.Parameter(0)));
Stream s = m.Build();
ASSERT_EQ(1U, s.size());
EXPECT_EQ(kArmMvn, s[0]->arch_opcode());
......
......@@ -3746,8 +3746,8 @@ TEST_P(InstructionSelectorLogicalWithNotRHSTest, Parameter) {
{
StreamBuilder m(this, type, type, type);
if (type == MachineType::Int32()) {
m.Return(
(m.*inst.constructor)(m.Parameter(0), m.Word32Not(m.Parameter(1))));
m.Return((m.*inst.constructor)(m.Parameter(0),
m.Word32BitwiseNot(m.Parameter(1))));
} else {
ASSERT_EQ(MachineType::Int64(), type);
m.Return(
......@@ -3762,8 +3762,8 @@ TEST_P(InstructionSelectorLogicalWithNotRHSTest, Parameter) {
{
StreamBuilder m(this, type, type, type);
if (type == MachineType::Int32()) {
m.Return(
(m.*inst.constructor)(m.Word32Not(m.Parameter(0)), m.Parameter(1)));
m.Return((m.*inst.constructor)(m.Word32BitwiseNot(m.Parameter(0)),
m.Parameter(1)));
} else {
ASSERT_EQ(MachineType::Int64(), type);
m.Return(
......@@ -3782,10 +3782,9 @@ INSTANTIATE_TEST_CASE_P(InstructionSelectorTest,
InstructionSelectorLogicalWithNotRHSTest,
::testing::ValuesIn(kLogicalWithNotRHSs));
TEST_F(InstructionSelectorTest, Word32NotWithParameter) {
TEST_F(InstructionSelectorTest, Word32BitwiseNotWithParameter) {
StreamBuilder m(this, MachineType::Int32(), MachineType::Int32());
m.Return(m.Word32Not(m.Parameter(0)));
m.Return(m.Word32BitwiseNot(m.Parameter(0)));
Stream s = m.Build();
ASSERT_EQ(1U, s.size());
EXPECT_EQ(kArm64Not32, s[0]->arch_opcode());
......
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