OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "test/unittests/compiler/instruction-selector-unittest.h" | 5 #include "test/unittests/compiler/instruction-selector-unittest.h" |
6 | 6 |
7 namespace v8 { | 7 namespace v8 { |
8 namespace internal { | 8 namespace internal { |
9 namespace compiler { | 9 namespace compiler { |
10 | 10 |
(...skipping 3096 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3107 m.Return(n); | 3107 m.Return(n); |
3108 Stream s = m.Build(); | 3108 Stream s = m.Build(); |
3109 ASSERT_EQ(1U, s.size()); | 3109 ASSERT_EQ(1U, s.size()); |
3110 EXPECT_EQ(kArm64Float64Neg, s[0]->arch_opcode()); | 3110 EXPECT_EQ(kArm64Float64Neg, s[0]->arch_opcode()); |
3111 ASSERT_EQ(1U, s[0]->InputCount()); | 3111 ASSERT_EQ(1U, s[0]->InputCount()); |
3112 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); | 3112 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
3113 ASSERT_EQ(1U, s[0]->OutputCount()); | 3113 ASSERT_EQ(1U, s[0]->OutputCount()); |
3114 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | 3114 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
3115 } | 3115 } |
3116 | 3116 |
| 3117 |
| 3118 TEST_F(InstructionSelectorTest, Float32Max) { |
| 3119 StreamBuilder m(this, kMachFloat32, kMachFloat32, kMachFloat32); |
| 3120 Node* const p0 = m.Parameter(0); |
| 3121 Node* const p1 = m.Parameter(1); |
| 3122 Node* const n = m.Float32Max(p0, p1); |
| 3123 m.Return(n); |
| 3124 Stream s = m.Build(); |
| 3125 // Float32Max is `(b < a) ? a : b`. |
| 3126 ASSERT_EQ(1U, s.size()); |
| 3127 EXPECT_EQ(kArm64Float32Max, s[0]->arch_opcode()); |
| 3128 ASSERT_EQ(2U, s[0]->InputCount()); |
| 3129 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
| 3130 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1))); |
| 3131 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 3132 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
| 3133 } |
| 3134 |
| 3135 |
| 3136 TEST_F(InstructionSelectorTest, Float32Min) { |
| 3137 StreamBuilder m(this, kMachFloat32, kMachFloat32, kMachFloat32); |
| 3138 Node* const p0 = m.Parameter(0); |
| 3139 Node* const p1 = m.Parameter(1); |
| 3140 Node* const n = m.Float32Min(p0, p1); |
| 3141 m.Return(n); |
| 3142 Stream s = m.Build(); |
| 3143 // Float32Min is `(a < b) ? a : b`. |
| 3144 ASSERT_EQ(1U, s.size()); |
| 3145 EXPECT_EQ(kArm64Float32Min, s[0]->arch_opcode()); |
| 3146 ASSERT_EQ(2U, s[0]->InputCount()); |
| 3147 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
| 3148 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1))); |
| 3149 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 3150 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
| 3151 } |
| 3152 |
| 3153 |
| 3154 TEST_F(InstructionSelectorTest, Float64Max) { |
| 3155 StreamBuilder m(this, kMachFloat64, kMachFloat64, kMachFloat64); |
| 3156 Node* const p0 = m.Parameter(0); |
| 3157 Node* const p1 = m.Parameter(1); |
| 3158 Node* const n = m.Float64Max(p0, p1); |
| 3159 m.Return(n); |
| 3160 Stream s = m.Build(); |
| 3161 // Float64Max is `(b < a) ? a : b`. |
| 3162 ASSERT_EQ(1U, s.size()); |
| 3163 EXPECT_EQ(kArm64Float64Max, s[0]->arch_opcode()); |
| 3164 ASSERT_EQ(2U, s[0]->InputCount()); |
| 3165 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
| 3166 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1))); |
| 3167 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 3168 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
| 3169 } |
| 3170 |
| 3171 |
| 3172 TEST_F(InstructionSelectorTest, Float64Min) { |
| 3173 StreamBuilder m(this, kMachFloat64, kMachFloat64, kMachFloat64); |
| 3174 Node* const p0 = m.Parameter(0); |
| 3175 Node* const p1 = m.Parameter(1); |
| 3176 Node* const n = m.Float64Min(p0, p1); |
| 3177 m.Return(n); |
| 3178 Stream s = m.Build(); |
| 3179 // Float64Min is `(a < b) ? a : b`. |
| 3180 ASSERT_EQ(1U, s.size()); |
| 3181 EXPECT_EQ(kArm64Float64Min, s[0]->arch_opcode()); |
| 3182 ASSERT_EQ(2U, s[0]->InputCount()); |
| 3183 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
| 3184 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1))); |
| 3185 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 3186 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
| 3187 } |
| 3188 |
3117 } // namespace compiler | 3189 } // namespace compiler |
3118 } // namespace internal | 3190 } // namespace internal |
3119 } // namespace v8 | 3191 } // namespace v8 |
OLD | NEW |