| 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 <limits> | 5 #include <limits> |
| 6 | 6 |
| 7 #include "test/unittests/compiler/instruction-selector-unittest.h" | 7 #include "test/unittests/compiler/instruction-selector-unittest.h" |
| 8 | 8 |
| 9 namespace v8 { | 9 namespace v8 { |
| 10 namespace internal { | 10 namespace internal { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 MachineType machine_type; | 45 MachineType machine_type; |
| 46 ArchOpcode arch_opcode; | 46 ArchOpcode arch_opcode; |
| 47 }; | 47 }; |
| 48 | 48 |
| 49 | 49 |
| 50 std::ostream& operator<<(std::ostream& os, const FAI& fai) { | 50 std::ostream& operator<<(std::ostream& os, const FAI& fai) { |
| 51 return os << fai.constructor_name; | 51 return os << fai.constructor_name; |
| 52 } | 52 } |
| 53 | 53 |
| 54 | 54 |
| 55 const FAI kFAIs[] = { | 55 const FAI kFAIs[] = {{&RawMachineAssembler::Float32Add, "Float32Add", |
| 56 {&RawMachineAssembler::Float32Add, "Float32Add", kMachFloat32, kArmVaddF32}, | 56 MachineType::Float32(), kArmVaddF32}, |
| 57 {&RawMachineAssembler::Float64Add, "Float64Add", kMachFloat64, kArmVaddF64}, | 57 {&RawMachineAssembler::Float64Add, "Float64Add", |
| 58 {&RawMachineAssembler::Float32Sub, "Float32Sub", kMachFloat32, kArmVsubF32}, | 58 MachineType::Float64(), kArmVaddF64}, |
| 59 {&RawMachineAssembler::Float64Sub, "Float64Sub", kMachFloat64, kArmVsubF64}, | 59 {&RawMachineAssembler::Float32Sub, "Float32Sub", |
| 60 {&RawMachineAssembler::Float32Mul, "Float32Mul", kMachFloat32, kArmVmulF32}, | 60 MachineType::Float32(), kArmVsubF32}, |
| 61 {&RawMachineAssembler::Float64Mul, "Float64Mul", kMachFloat64, kArmVmulF64}, | 61 {&RawMachineAssembler::Float64Sub, "Float64Sub", |
| 62 {&RawMachineAssembler::Float32Div, "Float32Div", kMachFloat32, kArmVdivF32}, | 62 MachineType::Float64(), kArmVsubF64}, |
| 63 {&RawMachineAssembler::Float64Div, "Float64Div", kMachFloat64, | 63 {&RawMachineAssembler::Float32Mul, "Float32Mul", |
| 64 kArmVdivF64}}; | 64 MachineType::Float32(), kArmVmulF32}, |
| 65 {&RawMachineAssembler::Float64Mul, "Float64Mul", |
| 66 MachineType::Float64(), kArmVmulF64}, |
| 67 {&RawMachineAssembler::Float32Div, "Float32Div", |
| 68 MachineType::Float32(), kArmVdivF32}, |
| 69 {&RawMachineAssembler::Float64Div, "Float64Div", |
| 70 MachineType::Float64(), kArmVdivF64}}; |
| 65 | 71 |
| 66 | 72 |
| 67 // Data processing instructions with overflow. | 73 // Data processing instructions with overflow. |
| 68 struct ODPI { | 74 struct ODPI { |
| 69 Constructor constructor; | 75 Constructor constructor; |
| 70 const char* constructor_name; | 76 const char* constructor_name; |
| 71 ArchOpcode arch_opcode; | 77 ArchOpcode arch_opcode; |
| 72 ArchOpcode reverse_arch_opcode; | 78 ArchOpcode reverse_arch_opcode; |
| 73 }; | 79 }; |
| 74 | 80 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 | 140 |
| 135 // ----------------------------------------------------------------------------- | 141 // ----------------------------------------------------------------------------- |
| 136 // Data processing instructions. | 142 // Data processing instructions. |
| 137 | 143 |
| 138 | 144 |
| 139 typedef InstructionSelectorTestWithParam<DPI> InstructionSelectorDPITest; | 145 typedef InstructionSelectorTestWithParam<DPI> InstructionSelectorDPITest; |
| 140 | 146 |
| 141 | 147 |
| 142 TEST_P(InstructionSelectorDPITest, Parameters) { | 148 TEST_P(InstructionSelectorDPITest, Parameters) { |
| 143 const DPI dpi = GetParam(); | 149 const DPI dpi = GetParam(); |
| 144 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); | 150 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 151 MachineType::Int32()); |
| 145 m.Return((m.*dpi.constructor)(m.Parameter(0), m.Parameter(1))); | 152 m.Return((m.*dpi.constructor)(m.Parameter(0), m.Parameter(1))); |
| 146 Stream s = m.Build(); | 153 Stream s = m.Build(); |
| 147 ASSERT_EQ(1U, s.size()); | 154 ASSERT_EQ(1U, s.size()); |
| 148 EXPECT_EQ(dpi.arch_opcode, s[0]->arch_opcode()); | 155 EXPECT_EQ(dpi.arch_opcode, s[0]->arch_opcode()); |
| 149 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); | 156 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); |
| 150 EXPECT_EQ(2U, s[0]->InputCount()); | 157 EXPECT_EQ(2U, s[0]->InputCount()); |
| 151 EXPECT_EQ(1U, s[0]->OutputCount()); | 158 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 152 } | 159 } |
| 153 | 160 |
| 154 | 161 |
| 155 TEST_P(InstructionSelectorDPITest, Immediate) { | 162 TEST_P(InstructionSelectorDPITest, Immediate) { |
| 156 const DPI dpi = GetParam(); | 163 const DPI dpi = GetParam(); |
| 157 TRACED_FOREACH(int32_t, imm, kImmediates) { | 164 TRACED_FOREACH(int32_t, imm, kImmediates) { |
| 158 StreamBuilder m(this, kMachInt32, kMachInt32); | 165 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
| 159 m.Return((m.*dpi.constructor)(m.Parameter(0), m.Int32Constant(imm))); | 166 m.Return((m.*dpi.constructor)(m.Parameter(0), m.Int32Constant(imm))); |
| 160 Stream s = m.Build(); | 167 Stream s = m.Build(); |
| 161 ASSERT_EQ(1U, s.size()); | 168 ASSERT_EQ(1U, s.size()); |
| 162 EXPECT_EQ(dpi.arch_opcode, s[0]->arch_opcode()); | 169 EXPECT_EQ(dpi.arch_opcode, s[0]->arch_opcode()); |
| 163 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); | 170 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); |
| 164 ASSERT_EQ(2U, s[0]->InputCount()); | 171 ASSERT_EQ(2U, s[0]->InputCount()); |
| 165 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); | 172 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); |
| 166 EXPECT_EQ(1U, s[0]->OutputCount()); | 173 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 167 } | 174 } |
| 168 TRACED_FOREACH(int32_t, imm, kImmediates) { | 175 TRACED_FOREACH(int32_t, imm, kImmediates) { |
| 169 StreamBuilder m(this, kMachInt32, kMachInt32); | 176 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
| 170 m.Return((m.*dpi.constructor)(m.Int32Constant(imm), m.Parameter(0))); | 177 m.Return((m.*dpi.constructor)(m.Int32Constant(imm), m.Parameter(0))); |
| 171 Stream s = m.Build(); | 178 Stream s = m.Build(); |
| 172 ASSERT_EQ(1U, s.size()); | 179 ASSERT_EQ(1U, s.size()); |
| 173 EXPECT_EQ(dpi.reverse_arch_opcode, s[0]->arch_opcode()); | 180 EXPECT_EQ(dpi.reverse_arch_opcode, s[0]->arch_opcode()); |
| 174 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); | 181 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); |
| 175 ASSERT_EQ(2U, s[0]->InputCount()); | 182 ASSERT_EQ(2U, s[0]->InputCount()); |
| 176 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); | 183 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); |
| 177 EXPECT_EQ(1U, s[0]->OutputCount()); | 184 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 178 } | 185 } |
| 179 } | 186 } |
| 180 | 187 |
| 181 | 188 |
| 182 TEST_P(InstructionSelectorDPITest, ShiftByParameter) { | 189 TEST_P(InstructionSelectorDPITest, ShiftByParameter) { |
| 183 const DPI dpi = GetParam(); | 190 const DPI dpi = GetParam(); |
| 184 TRACED_FOREACH(Shift, shift, kShifts) { | 191 TRACED_FOREACH(Shift, shift, kShifts) { |
| 185 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); | 192 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 193 MachineType::Int32(), MachineType::Int32()); |
| 186 m.Return((m.*dpi.constructor)( | 194 m.Return((m.*dpi.constructor)( |
| 187 m.Parameter(0), | 195 m.Parameter(0), |
| 188 (m.*shift.constructor)(m.Parameter(1), m.Parameter(2)))); | 196 (m.*shift.constructor)(m.Parameter(1), m.Parameter(2)))); |
| 189 Stream s = m.Build(); | 197 Stream s = m.Build(); |
| 190 ASSERT_EQ(1U, s.size()); | 198 ASSERT_EQ(1U, s.size()); |
| 191 EXPECT_EQ(dpi.arch_opcode, s[0]->arch_opcode()); | 199 EXPECT_EQ(dpi.arch_opcode, s[0]->arch_opcode()); |
| 192 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); | 200 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); |
| 193 EXPECT_EQ(3U, s[0]->InputCount()); | 201 EXPECT_EQ(3U, s[0]->InputCount()); |
| 194 EXPECT_EQ(1U, s[0]->OutputCount()); | 202 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 195 } | 203 } |
| 196 TRACED_FOREACH(Shift, shift, kShifts) { | 204 TRACED_FOREACH(Shift, shift, kShifts) { |
| 197 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); | 205 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 206 MachineType::Int32(), MachineType::Int32()); |
| 198 m.Return((m.*dpi.constructor)( | 207 m.Return((m.*dpi.constructor)( |
| 199 (m.*shift.constructor)(m.Parameter(0), m.Parameter(1)), | 208 (m.*shift.constructor)(m.Parameter(0), m.Parameter(1)), |
| 200 m.Parameter(2))); | 209 m.Parameter(2))); |
| 201 Stream s = m.Build(); | 210 Stream s = m.Build(); |
| 202 ASSERT_EQ(1U, s.size()); | 211 ASSERT_EQ(1U, s.size()); |
| 203 EXPECT_EQ(dpi.reverse_arch_opcode, s[0]->arch_opcode()); | 212 EXPECT_EQ(dpi.reverse_arch_opcode, s[0]->arch_opcode()); |
| 204 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); | 213 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); |
| 205 EXPECT_EQ(3U, s[0]->InputCount()); | 214 EXPECT_EQ(3U, s[0]->InputCount()); |
| 206 EXPECT_EQ(1U, s[0]->OutputCount()); | 215 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 207 } | 216 } |
| 208 } | 217 } |
| 209 | 218 |
| 210 | 219 |
| 211 TEST_P(InstructionSelectorDPITest, ShiftByImmediate) { | 220 TEST_P(InstructionSelectorDPITest, ShiftByImmediate) { |
| 212 const DPI dpi = GetParam(); | 221 const DPI dpi = GetParam(); |
| 213 TRACED_FOREACH(Shift, shift, kShifts) { | 222 TRACED_FOREACH(Shift, shift, kShifts) { |
| 214 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { | 223 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { |
| 215 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); | 224 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 225 MachineType::Int32()); |
| 216 m.Return((m.*dpi.constructor)( | 226 m.Return((m.*dpi.constructor)( |
| 217 m.Parameter(0), | 227 m.Parameter(0), |
| 218 (m.*shift.constructor)(m.Parameter(1), m.Int32Constant(imm)))); | 228 (m.*shift.constructor)(m.Parameter(1), m.Int32Constant(imm)))); |
| 219 Stream s = m.Build(); | 229 Stream s = m.Build(); |
| 220 ASSERT_EQ(1U, s.size()); | 230 ASSERT_EQ(1U, s.size()); |
| 221 EXPECT_EQ(dpi.arch_opcode, s[0]->arch_opcode()); | 231 EXPECT_EQ(dpi.arch_opcode, s[0]->arch_opcode()); |
| 222 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); | 232 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); |
| 223 ASSERT_EQ(3U, s[0]->InputCount()); | 233 ASSERT_EQ(3U, s[0]->InputCount()); |
| 224 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); | 234 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); |
| 225 EXPECT_EQ(1U, s[0]->OutputCount()); | 235 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 226 } | 236 } |
| 227 } | 237 } |
| 228 TRACED_FOREACH(Shift, shift, kShifts) { | 238 TRACED_FOREACH(Shift, shift, kShifts) { |
| 229 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { | 239 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { |
| 230 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); | 240 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 241 MachineType::Int32()); |
| 231 m.Return((m.*dpi.constructor)( | 242 m.Return((m.*dpi.constructor)( |
| 232 (m.*shift.constructor)(m.Parameter(0), m.Int32Constant(imm)), | 243 (m.*shift.constructor)(m.Parameter(0), m.Int32Constant(imm)), |
| 233 m.Parameter(1))); | 244 m.Parameter(1))); |
| 234 Stream s = m.Build(); | 245 Stream s = m.Build(); |
| 235 ASSERT_EQ(1U, s.size()); | 246 ASSERT_EQ(1U, s.size()); |
| 236 EXPECT_EQ(dpi.reverse_arch_opcode, s[0]->arch_opcode()); | 247 EXPECT_EQ(dpi.reverse_arch_opcode, s[0]->arch_opcode()); |
| 237 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); | 248 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); |
| 238 ASSERT_EQ(3U, s[0]->InputCount()); | 249 ASSERT_EQ(3U, s[0]->InputCount()); |
| 239 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); | 250 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); |
| 240 EXPECT_EQ(1U, s[0]->OutputCount()); | 251 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 241 } | 252 } |
| 242 } | 253 } |
| 243 } | 254 } |
| 244 | 255 |
| 245 | 256 |
| 246 TEST_P(InstructionSelectorDPITest, BranchWithParameters) { | 257 TEST_P(InstructionSelectorDPITest, BranchWithParameters) { |
| 247 const DPI dpi = GetParam(); | 258 const DPI dpi = GetParam(); |
| 248 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); | 259 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 260 MachineType::Int32()); |
| 249 RawMachineLabel a, b; | 261 RawMachineLabel a, b; |
| 250 m.Branch((m.*dpi.constructor)(m.Parameter(0), m.Parameter(1)), &a, &b); | 262 m.Branch((m.*dpi.constructor)(m.Parameter(0), m.Parameter(1)), &a, &b); |
| 251 m.Bind(&a); | 263 m.Bind(&a); |
| 252 m.Return(m.Int32Constant(1)); | 264 m.Return(m.Int32Constant(1)); |
| 253 m.Bind(&b); | 265 m.Bind(&b); |
| 254 m.Return(m.Int32Constant(0)); | 266 m.Return(m.Int32Constant(0)); |
| 255 Stream s = m.Build(); | 267 Stream s = m.Build(); |
| 256 ASSERT_EQ(1U, s.size()); | 268 ASSERT_EQ(1U, s.size()); |
| 257 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); | 269 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); |
| 258 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); | 270 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); |
| 259 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); | 271 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); |
| 260 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); | 272 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); |
| 261 } | 273 } |
| 262 | 274 |
| 263 | 275 |
| 264 TEST_P(InstructionSelectorDPITest, BranchWithImmediate) { | 276 TEST_P(InstructionSelectorDPITest, BranchWithImmediate) { |
| 265 const DPI dpi = GetParam(); | 277 const DPI dpi = GetParam(); |
| 266 TRACED_FOREACH(int32_t, imm, kImmediates) { | 278 TRACED_FOREACH(int32_t, imm, kImmediates) { |
| 267 StreamBuilder m(this, kMachInt32, kMachInt32); | 279 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
| 268 RawMachineLabel a, b; | 280 RawMachineLabel a, b; |
| 269 m.Branch((m.*dpi.constructor)(m.Parameter(0), m.Int32Constant(imm)), &a, | 281 m.Branch((m.*dpi.constructor)(m.Parameter(0), m.Int32Constant(imm)), &a, |
| 270 &b); | 282 &b); |
| 271 m.Bind(&a); | 283 m.Bind(&a); |
| 272 m.Return(m.Int32Constant(1)); | 284 m.Return(m.Int32Constant(1)); |
| 273 m.Bind(&b); | 285 m.Bind(&b); |
| 274 m.Return(m.Int32Constant(0)); | 286 m.Return(m.Int32Constant(0)); |
| 275 Stream s = m.Build(); | 287 Stream s = m.Build(); |
| 276 ASSERT_EQ(1U, s.size()); | 288 ASSERT_EQ(1U, s.size()); |
| 277 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); | 289 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); |
| 278 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); | 290 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); |
| 279 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); | 291 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); |
| 280 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); | 292 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); |
| 281 } | 293 } |
| 282 TRACED_FOREACH(int32_t, imm, kImmediates) { | 294 TRACED_FOREACH(int32_t, imm, kImmediates) { |
| 283 StreamBuilder m(this, kMachInt32, kMachInt32); | 295 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
| 284 RawMachineLabel a, b; | 296 RawMachineLabel a, b; |
| 285 m.Branch((m.*dpi.constructor)(m.Int32Constant(imm), m.Parameter(0)), &a, | 297 m.Branch((m.*dpi.constructor)(m.Int32Constant(imm), m.Parameter(0)), &a, |
| 286 &b); | 298 &b); |
| 287 m.Bind(&a); | 299 m.Bind(&a); |
| 288 m.Return(m.Int32Constant(1)); | 300 m.Return(m.Int32Constant(1)); |
| 289 m.Bind(&b); | 301 m.Bind(&b); |
| 290 m.Return(m.Int32Constant(0)); | 302 m.Return(m.Int32Constant(0)); |
| 291 Stream s = m.Build(); | 303 Stream s = m.Build(); |
| 292 ASSERT_EQ(1U, s.size()); | 304 ASSERT_EQ(1U, s.size()); |
| 293 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); | 305 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); |
| 294 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); | 306 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); |
| 295 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); | 307 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); |
| 296 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); | 308 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); |
| 297 } | 309 } |
| 298 } | 310 } |
| 299 | 311 |
| 300 | 312 |
| 301 TEST_P(InstructionSelectorDPITest, BranchWithShiftByParameter) { | 313 TEST_P(InstructionSelectorDPITest, BranchWithShiftByParameter) { |
| 302 const DPI dpi = GetParam(); | 314 const DPI dpi = GetParam(); |
| 303 TRACED_FOREACH(Shift, shift, kShifts) { | 315 TRACED_FOREACH(Shift, shift, kShifts) { |
| 304 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); | 316 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 317 MachineType::Int32(), MachineType::Int32()); |
| 305 RawMachineLabel a, b; | 318 RawMachineLabel a, b; |
| 306 m.Branch((m.*dpi.constructor)( | 319 m.Branch((m.*dpi.constructor)( |
| 307 m.Parameter(0), | 320 m.Parameter(0), |
| 308 (m.*shift.constructor)(m.Parameter(1), m.Parameter(2))), | 321 (m.*shift.constructor)(m.Parameter(1), m.Parameter(2))), |
| 309 &a, &b); | 322 &a, &b); |
| 310 m.Bind(&a); | 323 m.Bind(&a); |
| 311 m.Return(m.Int32Constant(1)); | 324 m.Return(m.Int32Constant(1)); |
| 312 m.Bind(&b); | 325 m.Bind(&b); |
| 313 m.Return(m.Int32Constant(0)); | 326 m.Return(m.Int32Constant(0)); |
| 314 Stream s = m.Build(); | 327 Stream s = m.Build(); |
| 315 ASSERT_EQ(1U, s.size()); | 328 ASSERT_EQ(1U, s.size()); |
| 316 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); | 329 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); |
| 317 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); | 330 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); |
| 318 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); | 331 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); |
| 319 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); | 332 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); |
| 320 } | 333 } |
| 321 TRACED_FOREACH(Shift, shift, kShifts) { | 334 TRACED_FOREACH(Shift, shift, kShifts) { |
| 322 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); | 335 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 336 MachineType::Int32(), MachineType::Int32()); |
| 323 RawMachineLabel a, b; | 337 RawMachineLabel a, b; |
| 324 m.Branch((m.*dpi.constructor)( | 338 m.Branch((m.*dpi.constructor)( |
| 325 (m.*shift.constructor)(m.Parameter(0), m.Parameter(1)), | 339 (m.*shift.constructor)(m.Parameter(0), m.Parameter(1)), |
| 326 m.Parameter(2)), | 340 m.Parameter(2)), |
| 327 &a, &b); | 341 &a, &b); |
| 328 m.Bind(&a); | 342 m.Bind(&a); |
| 329 m.Return(m.Int32Constant(1)); | 343 m.Return(m.Int32Constant(1)); |
| 330 m.Bind(&b); | 344 m.Bind(&b); |
| 331 m.Return(m.Int32Constant(0)); | 345 m.Return(m.Int32Constant(0)); |
| 332 Stream s = m.Build(); | 346 Stream s = m.Build(); |
| 333 ASSERT_EQ(1U, s.size()); | 347 ASSERT_EQ(1U, s.size()); |
| 334 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); | 348 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); |
| 335 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); | 349 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); |
| 336 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); | 350 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); |
| 337 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); | 351 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); |
| 338 } | 352 } |
| 339 } | 353 } |
| 340 | 354 |
| 341 | 355 |
| 342 TEST_P(InstructionSelectorDPITest, BranchWithShiftByImmediate) { | 356 TEST_P(InstructionSelectorDPITest, BranchWithShiftByImmediate) { |
| 343 const DPI dpi = GetParam(); | 357 const DPI dpi = GetParam(); |
| 344 TRACED_FOREACH(Shift, shift, kShifts) { | 358 TRACED_FOREACH(Shift, shift, kShifts) { |
| 345 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { | 359 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { |
| 346 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); | 360 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 361 MachineType::Int32()); |
| 347 RawMachineLabel a, b; | 362 RawMachineLabel a, b; |
| 348 m.Branch((m.*dpi.constructor)(m.Parameter(0), | 363 m.Branch((m.*dpi.constructor)(m.Parameter(0), |
| 349 (m.*shift.constructor)( | 364 (m.*shift.constructor)( |
| 350 m.Parameter(1), m.Int32Constant(imm))), | 365 m.Parameter(1), m.Int32Constant(imm))), |
| 351 &a, &b); | 366 &a, &b); |
| 352 m.Bind(&a); | 367 m.Bind(&a); |
| 353 m.Return(m.Int32Constant(1)); | 368 m.Return(m.Int32Constant(1)); |
| 354 m.Bind(&b); | 369 m.Bind(&b); |
| 355 m.Return(m.Int32Constant(0)); | 370 m.Return(m.Int32Constant(0)); |
| 356 Stream s = m.Build(); | 371 Stream s = m.Build(); |
| 357 ASSERT_EQ(1U, s.size()); | 372 ASSERT_EQ(1U, s.size()); |
| 358 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); | 373 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); |
| 359 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); | 374 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); |
| 360 ASSERT_EQ(5U, s[0]->InputCount()); | 375 ASSERT_EQ(5U, s[0]->InputCount()); |
| 361 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); | 376 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); |
| 362 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); | 377 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); |
| 363 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); | 378 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); |
| 364 } | 379 } |
| 365 } | 380 } |
| 366 TRACED_FOREACH(Shift, shift, kShifts) { | 381 TRACED_FOREACH(Shift, shift, kShifts) { |
| 367 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { | 382 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { |
| 368 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); | 383 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 384 MachineType::Int32()); |
| 369 RawMachineLabel a, b; | 385 RawMachineLabel a, b; |
| 370 m.Branch((m.*dpi.constructor)( | 386 m.Branch((m.*dpi.constructor)( |
| 371 (m.*shift.constructor)(m.Parameter(0), m.Int32Constant(imm)), | 387 (m.*shift.constructor)(m.Parameter(0), m.Int32Constant(imm)), |
| 372 m.Parameter(1)), | 388 m.Parameter(1)), |
| 373 &a, &b); | 389 &a, &b); |
| 374 m.Bind(&a); | 390 m.Bind(&a); |
| 375 m.Return(m.Int32Constant(1)); | 391 m.Return(m.Int32Constant(1)); |
| 376 m.Bind(&b); | 392 m.Bind(&b); |
| 377 m.Return(m.Int32Constant(0)); | 393 m.Return(m.Int32Constant(0)); |
| 378 Stream s = m.Build(); | 394 Stream s = m.Build(); |
| 379 ASSERT_EQ(1U, s.size()); | 395 ASSERT_EQ(1U, s.size()); |
| 380 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); | 396 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); |
| 381 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); | 397 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); |
| 382 ASSERT_EQ(5U, s[0]->InputCount()); | 398 ASSERT_EQ(5U, s[0]->InputCount()); |
| 383 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); | 399 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); |
| 384 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); | 400 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); |
| 385 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); | 401 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); |
| 386 } | 402 } |
| 387 } | 403 } |
| 388 } | 404 } |
| 389 | 405 |
| 390 | 406 |
| 391 TEST_P(InstructionSelectorDPITest, BranchIfZeroWithParameters) { | 407 TEST_P(InstructionSelectorDPITest, BranchIfZeroWithParameters) { |
| 392 const DPI dpi = GetParam(); | 408 const DPI dpi = GetParam(); |
| 393 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); | 409 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 410 MachineType::Int32()); |
| 394 RawMachineLabel a, b; | 411 RawMachineLabel a, b; |
| 395 m.Branch(m.Word32Equal((m.*dpi.constructor)(m.Parameter(0), m.Parameter(1)), | 412 m.Branch(m.Word32Equal((m.*dpi.constructor)(m.Parameter(0), m.Parameter(1)), |
| 396 m.Int32Constant(0)), | 413 m.Int32Constant(0)), |
| 397 &a, &b); | 414 &a, &b); |
| 398 m.Bind(&a); | 415 m.Bind(&a); |
| 399 m.Return(m.Int32Constant(1)); | 416 m.Return(m.Int32Constant(1)); |
| 400 m.Bind(&b); | 417 m.Bind(&b); |
| 401 m.Return(m.Int32Constant(0)); | 418 m.Return(m.Int32Constant(0)); |
| 402 Stream s = m.Build(); | 419 Stream s = m.Build(); |
| 403 ASSERT_EQ(1U, s.size()); | 420 ASSERT_EQ(1U, s.size()); |
| 404 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); | 421 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); |
| 405 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); | 422 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); |
| 406 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); | 423 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); |
| 407 EXPECT_EQ(kEqual, s[0]->flags_condition()); | 424 EXPECT_EQ(kEqual, s[0]->flags_condition()); |
| 408 } | 425 } |
| 409 | 426 |
| 410 | 427 |
| 411 TEST_P(InstructionSelectorDPITest, BranchIfNotZeroWithParameters) { | 428 TEST_P(InstructionSelectorDPITest, BranchIfNotZeroWithParameters) { |
| 412 const DPI dpi = GetParam(); | 429 const DPI dpi = GetParam(); |
| 413 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); | 430 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 431 MachineType::Int32()); |
| 414 RawMachineLabel a, b; | 432 RawMachineLabel a, b; |
| 415 m.Branch( | 433 m.Branch( |
| 416 m.Word32NotEqual((m.*dpi.constructor)(m.Parameter(0), m.Parameter(1)), | 434 m.Word32NotEqual((m.*dpi.constructor)(m.Parameter(0), m.Parameter(1)), |
| 417 m.Int32Constant(0)), | 435 m.Int32Constant(0)), |
| 418 &a, &b); | 436 &a, &b); |
| 419 m.Bind(&a); | 437 m.Bind(&a); |
| 420 m.Return(m.Int32Constant(1)); | 438 m.Return(m.Int32Constant(1)); |
| 421 m.Bind(&b); | 439 m.Bind(&b); |
| 422 m.Return(m.Int32Constant(0)); | 440 m.Return(m.Int32Constant(0)); |
| 423 Stream s = m.Build(); | 441 Stream s = m.Build(); |
| 424 ASSERT_EQ(1U, s.size()); | 442 ASSERT_EQ(1U, s.size()); |
| 425 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); | 443 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); |
| 426 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); | 444 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); |
| 427 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); | 445 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); |
| 428 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); | 446 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); |
| 429 } | 447 } |
| 430 | 448 |
| 431 | 449 |
| 432 TEST_P(InstructionSelectorDPITest, BranchIfZeroWithImmediate) { | 450 TEST_P(InstructionSelectorDPITest, BranchIfZeroWithImmediate) { |
| 433 const DPI dpi = GetParam(); | 451 const DPI dpi = GetParam(); |
| 434 TRACED_FOREACH(int32_t, imm, kImmediates) { | 452 TRACED_FOREACH(int32_t, imm, kImmediates) { |
| 435 StreamBuilder m(this, kMachInt32, kMachInt32); | 453 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
| 436 RawMachineLabel a, b; | 454 RawMachineLabel a, b; |
| 437 m.Branch(m.Word32Equal( | 455 m.Branch(m.Word32Equal( |
| 438 (m.*dpi.constructor)(m.Parameter(0), m.Int32Constant(imm)), | 456 (m.*dpi.constructor)(m.Parameter(0), m.Int32Constant(imm)), |
| 439 m.Int32Constant(0)), | 457 m.Int32Constant(0)), |
| 440 &a, &b); | 458 &a, &b); |
| 441 m.Bind(&a); | 459 m.Bind(&a); |
| 442 m.Return(m.Int32Constant(1)); | 460 m.Return(m.Int32Constant(1)); |
| 443 m.Bind(&b); | 461 m.Bind(&b); |
| 444 m.Return(m.Int32Constant(0)); | 462 m.Return(m.Int32Constant(0)); |
| 445 Stream s = m.Build(); | 463 Stream s = m.Build(); |
| 446 ASSERT_EQ(1U, s.size()); | 464 ASSERT_EQ(1U, s.size()); |
| 447 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); | 465 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); |
| 448 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); | 466 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); |
| 449 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); | 467 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); |
| 450 EXPECT_EQ(kEqual, s[0]->flags_condition()); | 468 EXPECT_EQ(kEqual, s[0]->flags_condition()); |
| 451 } | 469 } |
| 452 TRACED_FOREACH(int32_t, imm, kImmediates) { | 470 TRACED_FOREACH(int32_t, imm, kImmediates) { |
| 453 StreamBuilder m(this, kMachInt32, kMachInt32); | 471 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
| 454 RawMachineLabel a, b; | 472 RawMachineLabel a, b; |
| 455 m.Branch(m.Word32Equal( | 473 m.Branch(m.Word32Equal( |
| 456 (m.*dpi.constructor)(m.Int32Constant(imm), m.Parameter(0)), | 474 (m.*dpi.constructor)(m.Int32Constant(imm), m.Parameter(0)), |
| 457 m.Int32Constant(0)), | 475 m.Int32Constant(0)), |
| 458 &a, &b); | 476 &a, &b); |
| 459 m.Bind(&a); | 477 m.Bind(&a); |
| 460 m.Return(m.Int32Constant(1)); | 478 m.Return(m.Int32Constant(1)); |
| 461 m.Bind(&b); | 479 m.Bind(&b); |
| 462 m.Return(m.Int32Constant(0)); | 480 m.Return(m.Int32Constant(0)); |
| 463 Stream s = m.Build(); | 481 Stream s = m.Build(); |
| 464 ASSERT_EQ(1U, s.size()); | 482 ASSERT_EQ(1U, s.size()); |
| 465 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); | 483 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); |
| 466 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); | 484 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); |
| 467 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); | 485 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); |
| 468 EXPECT_EQ(kEqual, s[0]->flags_condition()); | 486 EXPECT_EQ(kEqual, s[0]->flags_condition()); |
| 469 } | 487 } |
| 470 } | 488 } |
| 471 | 489 |
| 472 | 490 |
| 473 TEST_P(InstructionSelectorDPITest, BranchIfNotZeroWithImmediate) { | 491 TEST_P(InstructionSelectorDPITest, BranchIfNotZeroWithImmediate) { |
| 474 const DPI dpi = GetParam(); | 492 const DPI dpi = GetParam(); |
| 475 TRACED_FOREACH(int32_t, imm, kImmediates) { | 493 TRACED_FOREACH(int32_t, imm, kImmediates) { |
| 476 StreamBuilder m(this, kMachInt32, kMachInt32); | 494 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
| 477 RawMachineLabel a, b; | 495 RawMachineLabel a, b; |
| 478 m.Branch(m.Word32NotEqual( | 496 m.Branch(m.Word32NotEqual( |
| 479 (m.*dpi.constructor)(m.Parameter(0), m.Int32Constant(imm)), | 497 (m.*dpi.constructor)(m.Parameter(0), m.Int32Constant(imm)), |
| 480 m.Int32Constant(0)), | 498 m.Int32Constant(0)), |
| 481 &a, &b); | 499 &a, &b); |
| 482 m.Bind(&a); | 500 m.Bind(&a); |
| 483 m.Return(m.Int32Constant(1)); | 501 m.Return(m.Int32Constant(1)); |
| 484 m.Bind(&b); | 502 m.Bind(&b); |
| 485 m.Return(m.Int32Constant(0)); | 503 m.Return(m.Int32Constant(0)); |
| 486 Stream s = m.Build(); | 504 Stream s = m.Build(); |
| 487 ASSERT_EQ(1U, s.size()); | 505 ASSERT_EQ(1U, s.size()); |
| 488 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); | 506 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); |
| 489 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); | 507 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); |
| 490 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); | 508 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); |
| 491 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); | 509 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); |
| 492 } | 510 } |
| 493 TRACED_FOREACH(int32_t, imm, kImmediates) { | 511 TRACED_FOREACH(int32_t, imm, kImmediates) { |
| 494 StreamBuilder m(this, kMachInt32, kMachInt32); | 512 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
| 495 RawMachineLabel a, b; | 513 RawMachineLabel a, b; |
| 496 m.Branch(m.Word32NotEqual( | 514 m.Branch(m.Word32NotEqual( |
| 497 (m.*dpi.constructor)(m.Int32Constant(imm), m.Parameter(0)), | 515 (m.*dpi.constructor)(m.Int32Constant(imm), m.Parameter(0)), |
| 498 m.Int32Constant(0)), | 516 m.Int32Constant(0)), |
| 499 &a, &b); | 517 &a, &b); |
| 500 m.Bind(&a); | 518 m.Bind(&a); |
| 501 m.Return(m.Int32Constant(1)); | 519 m.Return(m.Int32Constant(1)); |
| 502 m.Bind(&b); | 520 m.Bind(&b); |
| 503 m.Return(m.Int32Constant(0)); | 521 m.Return(m.Int32Constant(0)); |
| 504 Stream s = m.Build(); | 522 Stream s = m.Build(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 517 | 535 |
| 518 // ----------------------------------------------------------------------------- | 536 // ----------------------------------------------------------------------------- |
| 519 // Data processing instructions with overflow. | 537 // Data processing instructions with overflow. |
| 520 | 538 |
| 521 | 539 |
| 522 typedef InstructionSelectorTestWithParam<ODPI> InstructionSelectorODPITest; | 540 typedef InstructionSelectorTestWithParam<ODPI> InstructionSelectorODPITest; |
| 523 | 541 |
| 524 | 542 |
| 525 TEST_P(InstructionSelectorODPITest, OvfWithParameters) { | 543 TEST_P(InstructionSelectorODPITest, OvfWithParameters) { |
| 526 const ODPI odpi = GetParam(); | 544 const ODPI odpi = GetParam(); |
| 527 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); | 545 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 546 MachineType::Int32()); |
| 528 m.Return( | 547 m.Return( |
| 529 m.Projection(1, (m.*odpi.constructor)(m.Parameter(0), m.Parameter(1)))); | 548 m.Projection(1, (m.*odpi.constructor)(m.Parameter(0), m.Parameter(1)))); |
| 530 Stream s = m.Build(); | 549 Stream s = m.Build(); |
| 531 ASSERT_EQ(1U, s.size()); | 550 ASSERT_EQ(1U, s.size()); |
| 532 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); | 551 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); |
| 533 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); | 552 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); |
| 534 EXPECT_EQ(2U, s[0]->InputCount()); | 553 EXPECT_EQ(2U, s[0]->InputCount()); |
| 535 EXPECT_LE(1U, s[0]->OutputCount()); | 554 EXPECT_LE(1U, s[0]->OutputCount()); |
| 536 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 555 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 537 EXPECT_EQ(kOverflow, s[0]->flags_condition()); | 556 EXPECT_EQ(kOverflow, s[0]->flags_condition()); |
| 538 } | 557 } |
| 539 | 558 |
| 540 | 559 |
| 541 TEST_P(InstructionSelectorODPITest, OvfWithImmediate) { | 560 TEST_P(InstructionSelectorODPITest, OvfWithImmediate) { |
| 542 const ODPI odpi = GetParam(); | 561 const ODPI odpi = GetParam(); |
| 543 TRACED_FOREACH(int32_t, imm, kImmediates) { | 562 TRACED_FOREACH(int32_t, imm, kImmediates) { |
| 544 StreamBuilder m(this, kMachInt32, kMachInt32); | 563 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
| 545 m.Return(m.Projection( | 564 m.Return(m.Projection( |
| 546 1, (m.*odpi.constructor)(m.Parameter(0), m.Int32Constant(imm)))); | 565 1, (m.*odpi.constructor)(m.Parameter(0), m.Int32Constant(imm)))); |
| 547 Stream s = m.Build(); | 566 Stream s = m.Build(); |
| 548 ASSERT_EQ(1U, s.size()); | 567 ASSERT_EQ(1U, s.size()); |
| 549 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); | 568 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); |
| 550 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); | 569 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); |
| 551 ASSERT_EQ(2U, s[0]->InputCount()); | 570 ASSERT_EQ(2U, s[0]->InputCount()); |
| 552 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); | 571 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); |
| 553 EXPECT_LE(1U, s[0]->OutputCount()); | 572 EXPECT_LE(1U, s[0]->OutputCount()); |
| 554 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 573 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 555 EXPECT_EQ(kOverflow, s[0]->flags_condition()); | 574 EXPECT_EQ(kOverflow, s[0]->flags_condition()); |
| 556 } | 575 } |
| 557 TRACED_FOREACH(int32_t, imm, kImmediates) { | 576 TRACED_FOREACH(int32_t, imm, kImmediates) { |
| 558 StreamBuilder m(this, kMachInt32, kMachInt32); | 577 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
| 559 m.Return(m.Projection( | 578 m.Return(m.Projection( |
| 560 1, (m.*odpi.constructor)(m.Int32Constant(imm), m.Parameter(0)))); | 579 1, (m.*odpi.constructor)(m.Int32Constant(imm), m.Parameter(0)))); |
| 561 Stream s = m.Build(); | 580 Stream s = m.Build(); |
| 562 ASSERT_EQ(1U, s.size()); | 581 ASSERT_EQ(1U, s.size()); |
| 563 EXPECT_EQ(odpi.reverse_arch_opcode, s[0]->arch_opcode()); | 582 EXPECT_EQ(odpi.reverse_arch_opcode, s[0]->arch_opcode()); |
| 564 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); | 583 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); |
| 565 ASSERT_EQ(2U, s[0]->InputCount()); | 584 ASSERT_EQ(2U, s[0]->InputCount()); |
| 566 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); | 585 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); |
| 567 EXPECT_LE(1U, s[0]->OutputCount()); | 586 EXPECT_LE(1U, s[0]->OutputCount()); |
| 568 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 587 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 569 EXPECT_EQ(kOverflow, s[0]->flags_condition()); | 588 EXPECT_EQ(kOverflow, s[0]->flags_condition()); |
| 570 } | 589 } |
| 571 } | 590 } |
| 572 | 591 |
| 573 | 592 |
| 574 TEST_P(InstructionSelectorODPITest, OvfWithShiftByParameter) { | 593 TEST_P(InstructionSelectorODPITest, OvfWithShiftByParameter) { |
| 575 const ODPI odpi = GetParam(); | 594 const ODPI odpi = GetParam(); |
| 576 TRACED_FOREACH(Shift, shift, kShifts) { | 595 TRACED_FOREACH(Shift, shift, kShifts) { |
| 577 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); | 596 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 597 MachineType::Int32(), MachineType::Int32()); |
| 578 m.Return(m.Projection( | 598 m.Return(m.Projection( |
| 579 1, (m.*odpi.constructor)( | 599 1, (m.*odpi.constructor)( |
| 580 m.Parameter(0), | 600 m.Parameter(0), |
| 581 (m.*shift.constructor)(m.Parameter(1), m.Parameter(2))))); | 601 (m.*shift.constructor)(m.Parameter(1), m.Parameter(2))))); |
| 582 Stream s = m.Build(); | 602 Stream s = m.Build(); |
| 583 ASSERT_EQ(1U, s.size()); | 603 ASSERT_EQ(1U, s.size()); |
| 584 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); | 604 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); |
| 585 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); | 605 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); |
| 586 EXPECT_EQ(3U, s[0]->InputCount()); | 606 EXPECT_EQ(3U, s[0]->InputCount()); |
| 587 EXPECT_LE(1U, s[0]->OutputCount()); | 607 EXPECT_LE(1U, s[0]->OutputCount()); |
| 588 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 608 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 589 EXPECT_EQ(kOverflow, s[0]->flags_condition()); | 609 EXPECT_EQ(kOverflow, s[0]->flags_condition()); |
| 590 } | 610 } |
| 591 TRACED_FOREACH(Shift, shift, kShifts) { | 611 TRACED_FOREACH(Shift, shift, kShifts) { |
| 592 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); | 612 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 613 MachineType::Int32(), MachineType::Int32()); |
| 593 m.Return(m.Projection( | 614 m.Return(m.Projection( |
| 594 1, (m.*odpi.constructor)( | 615 1, (m.*odpi.constructor)( |
| 595 (m.*shift.constructor)(m.Parameter(0), m.Parameter(1)), | 616 (m.*shift.constructor)(m.Parameter(0), m.Parameter(1)), |
| 596 m.Parameter(0)))); | 617 m.Parameter(0)))); |
| 597 Stream s = m.Build(); | 618 Stream s = m.Build(); |
| 598 ASSERT_EQ(1U, s.size()); | 619 ASSERT_EQ(1U, s.size()); |
| 599 EXPECT_EQ(odpi.reverse_arch_opcode, s[0]->arch_opcode()); | 620 EXPECT_EQ(odpi.reverse_arch_opcode, s[0]->arch_opcode()); |
| 600 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); | 621 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); |
| 601 EXPECT_EQ(3U, s[0]->InputCount()); | 622 EXPECT_EQ(3U, s[0]->InputCount()); |
| 602 EXPECT_LE(1U, s[0]->OutputCount()); | 623 EXPECT_LE(1U, s[0]->OutputCount()); |
| 603 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 624 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 604 EXPECT_EQ(kOverflow, s[0]->flags_condition()); | 625 EXPECT_EQ(kOverflow, s[0]->flags_condition()); |
| 605 } | 626 } |
| 606 } | 627 } |
| 607 | 628 |
| 608 | 629 |
| 609 TEST_P(InstructionSelectorODPITest, OvfWithShiftByImmediate) { | 630 TEST_P(InstructionSelectorODPITest, OvfWithShiftByImmediate) { |
| 610 const ODPI odpi = GetParam(); | 631 const ODPI odpi = GetParam(); |
| 611 TRACED_FOREACH(Shift, shift, kShifts) { | 632 TRACED_FOREACH(Shift, shift, kShifts) { |
| 612 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { | 633 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { |
| 613 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); | 634 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 635 MachineType::Int32()); |
| 614 m.Return(m.Projection( | 636 m.Return(m.Projection( |
| 615 1, (m.*odpi.constructor)(m.Parameter(0), | 637 1, (m.*odpi.constructor)(m.Parameter(0), |
| 616 (m.*shift.constructor)( | 638 (m.*shift.constructor)( |
| 617 m.Parameter(1), m.Int32Constant(imm))))); | 639 m.Parameter(1), m.Int32Constant(imm))))); |
| 618 Stream s = m.Build(); | 640 Stream s = m.Build(); |
| 619 ASSERT_EQ(1U, s.size()); | 641 ASSERT_EQ(1U, s.size()); |
| 620 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); | 642 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); |
| 621 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); | 643 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); |
| 622 ASSERT_EQ(3U, s[0]->InputCount()); | 644 ASSERT_EQ(3U, s[0]->InputCount()); |
| 623 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); | 645 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); |
| 624 EXPECT_LE(1U, s[0]->OutputCount()); | 646 EXPECT_LE(1U, s[0]->OutputCount()); |
| 625 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 647 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 626 EXPECT_EQ(kOverflow, s[0]->flags_condition()); | 648 EXPECT_EQ(kOverflow, s[0]->flags_condition()); |
| 627 } | 649 } |
| 628 } | 650 } |
| 629 TRACED_FOREACH(Shift, shift, kShifts) { | 651 TRACED_FOREACH(Shift, shift, kShifts) { |
| 630 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { | 652 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { |
| 631 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); | 653 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 654 MachineType::Int32()); |
| 632 m.Return(m.Projection( | 655 m.Return(m.Projection( |
| 633 1, (m.*odpi.constructor)( | 656 1, (m.*odpi.constructor)( |
| 634 (m.*shift.constructor)(m.Parameter(1), m.Int32Constant(imm)), | 657 (m.*shift.constructor)(m.Parameter(1), m.Int32Constant(imm)), |
| 635 m.Parameter(0)))); | 658 m.Parameter(0)))); |
| 636 Stream s = m.Build(); | 659 Stream s = m.Build(); |
| 637 ASSERT_EQ(1U, s.size()); | 660 ASSERT_EQ(1U, s.size()); |
| 638 EXPECT_EQ(odpi.reverse_arch_opcode, s[0]->arch_opcode()); | 661 EXPECT_EQ(odpi.reverse_arch_opcode, s[0]->arch_opcode()); |
| 639 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); | 662 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); |
| 640 ASSERT_EQ(3U, s[0]->InputCount()); | 663 ASSERT_EQ(3U, s[0]->InputCount()); |
| 641 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); | 664 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); |
| 642 EXPECT_LE(1U, s[0]->OutputCount()); | 665 EXPECT_LE(1U, s[0]->OutputCount()); |
| 643 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 666 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 644 EXPECT_EQ(kOverflow, s[0]->flags_condition()); | 667 EXPECT_EQ(kOverflow, s[0]->flags_condition()); |
| 645 } | 668 } |
| 646 } | 669 } |
| 647 } | 670 } |
| 648 | 671 |
| 649 | 672 |
| 650 TEST_P(InstructionSelectorODPITest, ValWithParameters) { | 673 TEST_P(InstructionSelectorODPITest, ValWithParameters) { |
| 651 const ODPI odpi = GetParam(); | 674 const ODPI odpi = GetParam(); |
| 652 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); | 675 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 676 MachineType::Int32()); |
| 653 m.Return( | 677 m.Return( |
| 654 m.Projection(0, (m.*odpi.constructor)(m.Parameter(0), m.Parameter(1)))); | 678 m.Projection(0, (m.*odpi.constructor)(m.Parameter(0), m.Parameter(1)))); |
| 655 Stream s = m.Build(); | 679 Stream s = m.Build(); |
| 656 ASSERT_EQ(1U, s.size()); | 680 ASSERT_EQ(1U, s.size()); |
| 657 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); | 681 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); |
| 658 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); | 682 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); |
| 659 EXPECT_EQ(2U, s[0]->InputCount()); | 683 EXPECT_EQ(2U, s[0]->InputCount()); |
| 660 EXPECT_LE(1U, s[0]->OutputCount()); | 684 EXPECT_LE(1U, s[0]->OutputCount()); |
| 661 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); | 685 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); |
| 662 } | 686 } |
| 663 | 687 |
| 664 | 688 |
| 665 TEST_P(InstructionSelectorODPITest, ValWithImmediate) { | 689 TEST_P(InstructionSelectorODPITest, ValWithImmediate) { |
| 666 const ODPI odpi = GetParam(); | 690 const ODPI odpi = GetParam(); |
| 667 TRACED_FOREACH(int32_t, imm, kImmediates) { | 691 TRACED_FOREACH(int32_t, imm, kImmediates) { |
| 668 StreamBuilder m(this, kMachInt32, kMachInt32); | 692 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
| 669 m.Return(m.Projection( | 693 m.Return(m.Projection( |
| 670 0, (m.*odpi.constructor)(m.Parameter(0), m.Int32Constant(imm)))); | 694 0, (m.*odpi.constructor)(m.Parameter(0), m.Int32Constant(imm)))); |
| 671 Stream s = m.Build(); | 695 Stream s = m.Build(); |
| 672 ASSERT_EQ(1U, s.size()); | 696 ASSERT_EQ(1U, s.size()); |
| 673 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); | 697 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); |
| 674 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); | 698 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); |
| 675 ASSERT_EQ(2U, s[0]->InputCount()); | 699 ASSERT_EQ(2U, s[0]->InputCount()); |
| 676 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); | 700 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); |
| 677 EXPECT_LE(1U, s[0]->OutputCount()); | 701 EXPECT_LE(1U, s[0]->OutputCount()); |
| 678 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); | 702 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); |
| 679 } | 703 } |
| 680 TRACED_FOREACH(int32_t, imm, kImmediates) { | 704 TRACED_FOREACH(int32_t, imm, kImmediates) { |
| 681 StreamBuilder m(this, kMachInt32, kMachInt32); | 705 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
| 682 m.Return(m.Projection( | 706 m.Return(m.Projection( |
| 683 0, (m.*odpi.constructor)(m.Int32Constant(imm), m.Parameter(0)))); | 707 0, (m.*odpi.constructor)(m.Int32Constant(imm), m.Parameter(0)))); |
| 684 Stream s = m.Build(); | 708 Stream s = m.Build(); |
| 685 ASSERT_EQ(1U, s.size()); | 709 ASSERT_EQ(1U, s.size()); |
| 686 EXPECT_EQ(odpi.reverse_arch_opcode, s[0]->arch_opcode()); | 710 EXPECT_EQ(odpi.reverse_arch_opcode, s[0]->arch_opcode()); |
| 687 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); | 711 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); |
| 688 ASSERT_EQ(2U, s[0]->InputCount()); | 712 ASSERT_EQ(2U, s[0]->InputCount()); |
| 689 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); | 713 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); |
| 690 EXPECT_LE(1U, s[0]->OutputCount()); | 714 EXPECT_LE(1U, s[0]->OutputCount()); |
| 691 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); | 715 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); |
| 692 } | 716 } |
| 693 } | 717 } |
| 694 | 718 |
| 695 | 719 |
| 696 TEST_P(InstructionSelectorODPITest, ValWithShiftByParameter) { | 720 TEST_P(InstructionSelectorODPITest, ValWithShiftByParameter) { |
| 697 const ODPI odpi = GetParam(); | 721 const ODPI odpi = GetParam(); |
| 698 TRACED_FOREACH(Shift, shift, kShifts) { | 722 TRACED_FOREACH(Shift, shift, kShifts) { |
| 699 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); | 723 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 724 MachineType::Int32(), MachineType::Int32()); |
| 700 m.Return(m.Projection( | 725 m.Return(m.Projection( |
| 701 0, (m.*odpi.constructor)( | 726 0, (m.*odpi.constructor)( |
| 702 m.Parameter(0), | 727 m.Parameter(0), |
| 703 (m.*shift.constructor)(m.Parameter(1), m.Parameter(2))))); | 728 (m.*shift.constructor)(m.Parameter(1), m.Parameter(2))))); |
| 704 Stream s = m.Build(); | 729 Stream s = m.Build(); |
| 705 ASSERT_EQ(1U, s.size()); | 730 ASSERT_EQ(1U, s.size()); |
| 706 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); | 731 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); |
| 707 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); | 732 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); |
| 708 EXPECT_EQ(3U, s[0]->InputCount()); | 733 EXPECT_EQ(3U, s[0]->InputCount()); |
| 709 EXPECT_LE(1U, s[0]->OutputCount()); | 734 EXPECT_LE(1U, s[0]->OutputCount()); |
| 710 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); | 735 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); |
| 711 } | 736 } |
| 712 TRACED_FOREACH(Shift, shift, kShifts) { | 737 TRACED_FOREACH(Shift, shift, kShifts) { |
| 713 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); | 738 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 739 MachineType::Int32(), MachineType::Int32()); |
| 714 m.Return(m.Projection( | 740 m.Return(m.Projection( |
| 715 0, (m.*odpi.constructor)( | 741 0, (m.*odpi.constructor)( |
| 716 (m.*shift.constructor)(m.Parameter(0), m.Parameter(1)), | 742 (m.*shift.constructor)(m.Parameter(0), m.Parameter(1)), |
| 717 m.Parameter(0)))); | 743 m.Parameter(0)))); |
| 718 Stream s = m.Build(); | 744 Stream s = m.Build(); |
| 719 ASSERT_EQ(1U, s.size()); | 745 ASSERT_EQ(1U, s.size()); |
| 720 EXPECT_EQ(odpi.reverse_arch_opcode, s[0]->arch_opcode()); | 746 EXPECT_EQ(odpi.reverse_arch_opcode, s[0]->arch_opcode()); |
| 721 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); | 747 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); |
| 722 EXPECT_EQ(3U, s[0]->InputCount()); | 748 EXPECT_EQ(3U, s[0]->InputCount()); |
| 723 EXPECT_LE(1U, s[0]->OutputCount()); | 749 EXPECT_LE(1U, s[0]->OutputCount()); |
| 724 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); | 750 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); |
| 725 } | 751 } |
| 726 } | 752 } |
| 727 | 753 |
| 728 | 754 |
| 729 TEST_P(InstructionSelectorODPITest, ValWithShiftByImmediate) { | 755 TEST_P(InstructionSelectorODPITest, ValWithShiftByImmediate) { |
| 730 const ODPI odpi = GetParam(); | 756 const ODPI odpi = GetParam(); |
| 731 TRACED_FOREACH(Shift, shift, kShifts) { | 757 TRACED_FOREACH(Shift, shift, kShifts) { |
| 732 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { | 758 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { |
| 733 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); | 759 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 760 MachineType::Int32()); |
| 734 m.Return(m.Projection( | 761 m.Return(m.Projection( |
| 735 0, (m.*odpi.constructor)(m.Parameter(0), | 762 0, (m.*odpi.constructor)(m.Parameter(0), |
| 736 (m.*shift.constructor)( | 763 (m.*shift.constructor)( |
| 737 m.Parameter(1), m.Int32Constant(imm))))); | 764 m.Parameter(1), m.Int32Constant(imm))))); |
| 738 Stream s = m.Build(); | 765 Stream s = m.Build(); |
| 739 ASSERT_EQ(1U, s.size()); | 766 ASSERT_EQ(1U, s.size()); |
| 740 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); | 767 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); |
| 741 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); | 768 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); |
| 742 ASSERT_EQ(3U, s[0]->InputCount()); | 769 ASSERT_EQ(3U, s[0]->InputCount()); |
| 743 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); | 770 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); |
| 744 EXPECT_LE(1U, s[0]->OutputCount()); | 771 EXPECT_LE(1U, s[0]->OutputCount()); |
| 745 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); | 772 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); |
| 746 } | 773 } |
| 747 } | 774 } |
| 748 TRACED_FOREACH(Shift, shift, kShifts) { | 775 TRACED_FOREACH(Shift, shift, kShifts) { |
| 749 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { | 776 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { |
| 750 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); | 777 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 778 MachineType::Int32()); |
| 751 m.Return(m.Projection( | 779 m.Return(m.Projection( |
| 752 0, (m.*odpi.constructor)( | 780 0, (m.*odpi.constructor)( |
| 753 (m.*shift.constructor)(m.Parameter(1), m.Int32Constant(imm)), | 781 (m.*shift.constructor)(m.Parameter(1), m.Int32Constant(imm)), |
| 754 m.Parameter(0)))); | 782 m.Parameter(0)))); |
| 755 Stream s = m.Build(); | 783 Stream s = m.Build(); |
| 756 ASSERT_EQ(1U, s.size()); | 784 ASSERT_EQ(1U, s.size()); |
| 757 EXPECT_EQ(odpi.reverse_arch_opcode, s[0]->arch_opcode()); | 785 EXPECT_EQ(odpi.reverse_arch_opcode, s[0]->arch_opcode()); |
| 758 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); | 786 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); |
| 759 ASSERT_EQ(3U, s[0]->InputCount()); | 787 ASSERT_EQ(3U, s[0]->InputCount()); |
| 760 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); | 788 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); |
| 761 EXPECT_LE(1U, s[0]->OutputCount()); | 789 EXPECT_LE(1U, s[0]->OutputCount()); |
| 762 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); | 790 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); |
| 763 } | 791 } |
| 764 } | 792 } |
| 765 } | 793 } |
| 766 | 794 |
| 767 | 795 |
| 768 TEST_P(InstructionSelectorODPITest, BothWithParameters) { | 796 TEST_P(InstructionSelectorODPITest, BothWithParameters) { |
| 769 const ODPI odpi = GetParam(); | 797 const ODPI odpi = GetParam(); |
| 770 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); | 798 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 799 MachineType::Int32()); |
| 771 Node* n = (m.*odpi.constructor)(m.Parameter(0), m.Parameter(1)); | 800 Node* n = (m.*odpi.constructor)(m.Parameter(0), m.Parameter(1)); |
| 772 m.Return(m.Word32Equal(m.Projection(0, n), m.Projection(1, n))); | 801 m.Return(m.Word32Equal(m.Projection(0, n), m.Projection(1, n))); |
| 773 Stream s = m.Build(); | 802 Stream s = m.Build(); |
| 774 ASSERT_LE(1U, s.size()); | 803 ASSERT_LE(1U, s.size()); |
| 775 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); | 804 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); |
| 776 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); | 805 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); |
| 777 EXPECT_EQ(2U, s[0]->InputCount()); | 806 EXPECT_EQ(2U, s[0]->InputCount()); |
| 778 EXPECT_EQ(2U, s[0]->OutputCount()); | 807 EXPECT_EQ(2U, s[0]->OutputCount()); |
| 779 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 808 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 780 EXPECT_EQ(kOverflow, s[0]->flags_condition()); | 809 EXPECT_EQ(kOverflow, s[0]->flags_condition()); |
| 781 } | 810 } |
| 782 | 811 |
| 783 | 812 |
| 784 TEST_P(InstructionSelectorODPITest, BothWithImmediate) { | 813 TEST_P(InstructionSelectorODPITest, BothWithImmediate) { |
| 785 const ODPI odpi = GetParam(); | 814 const ODPI odpi = GetParam(); |
| 786 TRACED_FOREACH(int32_t, imm, kImmediates) { | 815 TRACED_FOREACH(int32_t, imm, kImmediates) { |
| 787 StreamBuilder m(this, kMachInt32, kMachInt32); | 816 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
| 788 Node* n = (m.*odpi.constructor)(m.Parameter(0), m.Int32Constant(imm)); | 817 Node* n = (m.*odpi.constructor)(m.Parameter(0), m.Int32Constant(imm)); |
| 789 m.Return(m.Word32Equal(m.Projection(0, n), m.Projection(1, n))); | 818 m.Return(m.Word32Equal(m.Projection(0, n), m.Projection(1, n))); |
| 790 Stream s = m.Build(); | 819 Stream s = m.Build(); |
| 791 ASSERT_LE(1U, s.size()); | 820 ASSERT_LE(1U, s.size()); |
| 792 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); | 821 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); |
| 793 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); | 822 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); |
| 794 ASSERT_EQ(2U, s[0]->InputCount()); | 823 ASSERT_EQ(2U, s[0]->InputCount()); |
| 795 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); | 824 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); |
| 796 EXPECT_EQ(2U, s[0]->OutputCount()); | 825 EXPECT_EQ(2U, s[0]->OutputCount()); |
| 797 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 826 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 798 EXPECT_EQ(kOverflow, s[0]->flags_condition()); | 827 EXPECT_EQ(kOverflow, s[0]->flags_condition()); |
| 799 } | 828 } |
| 800 TRACED_FOREACH(int32_t, imm, kImmediates) { | 829 TRACED_FOREACH(int32_t, imm, kImmediates) { |
| 801 StreamBuilder m(this, kMachInt32, kMachInt32); | 830 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
| 802 Node* n = (m.*odpi.constructor)(m.Int32Constant(imm), m.Parameter(0)); | 831 Node* n = (m.*odpi.constructor)(m.Int32Constant(imm), m.Parameter(0)); |
| 803 m.Return(m.Word32Equal(m.Projection(0, n), m.Projection(1, n))); | 832 m.Return(m.Word32Equal(m.Projection(0, n), m.Projection(1, n))); |
| 804 Stream s = m.Build(); | 833 Stream s = m.Build(); |
| 805 ASSERT_LE(1U, s.size()); | 834 ASSERT_LE(1U, s.size()); |
| 806 EXPECT_EQ(odpi.reverse_arch_opcode, s[0]->arch_opcode()); | 835 EXPECT_EQ(odpi.reverse_arch_opcode, s[0]->arch_opcode()); |
| 807 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); | 836 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); |
| 808 ASSERT_EQ(2U, s[0]->InputCount()); | 837 ASSERT_EQ(2U, s[0]->InputCount()); |
| 809 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); | 838 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); |
| 810 EXPECT_EQ(2U, s[0]->OutputCount()); | 839 EXPECT_EQ(2U, s[0]->OutputCount()); |
| 811 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 840 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 812 EXPECT_EQ(kOverflow, s[0]->flags_condition()); | 841 EXPECT_EQ(kOverflow, s[0]->flags_condition()); |
| 813 } | 842 } |
| 814 } | 843 } |
| 815 | 844 |
| 816 | 845 |
| 817 TEST_P(InstructionSelectorODPITest, BothWithShiftByParameter) { | 846 TEST_P(InstructionSelectorODPITest, BothWithShiftByParameter) { |
| 818 const ODPI odpi = GetParam(); | 847 const ODPI odpi = GetParam(); |
| 819 TRACED_FOREACH(Shift, shift, kShifts) { | 848 TRACED_FOREACH(Shift, shift, kShifts) { |
| 820 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); | 849 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 850 MachineType::Int32(), MachineType::Int32()); |
| 821 Node* n = (m.*odpi.constructor)( | 851 Node* n = (m.*odpi.constructor)( |
| 822 m.Parameter(0), (m.*shift.constructor)(m.Parameter(1), m.Parameter(2))); | 852 m.Parameter(0), (m.*shift.constructor)(m.Parameter(1), m.Parameter(2))); |
| 823 m.Return(m.Word32Equal(m.Projection(0, n), m.Projection(1, n))); | 853 m.Return(m.Word32Equal(m.Projection(0, n), m.Projection(1, n))); |
| 824 Stream s = m.Build(); | 854 Stream s = m.Build(); |
| 825 ASSERT_LE(1U, s.size()); | 855 ASSERT_LE(1U, s.size()); |
| 826 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); | 856 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); |
| 827 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); | 857 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); |
| 828 EXPECT_EQ(3U, s[0]->InputCount()); | 858 EXPECT_EQ(3U, s[0]->InputCount()); |
| 829 EXPECT_EQ(2U, s[0]->OutputCount()); | 859 EXPECT_EQ(2U, s[0]->OutputCount()); |
| 830 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 860 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 831 EXPECT_EQ(kOverflow, s[0]->flags_condition()); | 861 EXPECT_EQ(kOverflow, s[0]->flags_condition()); |
| 832 } | 862 } |
| 833 TRACED_FOREACH(Shift, shift, kShifts) { | 863 TRACED_FOREACH(Shift, shift, kShifts) { |
| 834 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); | 864 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 865 MachineType::Int32(), MachineType::Int32()); |
| 835 Node* n = (m.*odpi.constructor)( | 866 Node* n = (m.*odpi.constructor)( |
| 836 (m.*shift.constructor)(m.Parameter(0), m.Parameter(1)), m.Parameter(2)); | 867 (m.*shift.constructor)(m.Parameter(0), m.Parameter(1)), m.Parameter(2)); |
| 837 m.Return(m.Word32Equal(m.Projection(0, n), m.Projection(1, n))); | 868 m.Return(m.Word32Equal(m.Projection(0, n), m.Projection(1, n))); |
| 838 Stream s = m.Build(); | 869 Stream s = m.Build(); |
| 839 ASSERT_LE(1U, s.size()); | 870 ASSERT_LE(1U, s.size()); |
| 840 EXPECT_EQ(odpi.reverse_arch_opcode, s[0]->arch_opcode()); | 871 EXPECT_EQ(odpi.reverse_arch_opcode, s[0]->arch_opcode()); |
| 841 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); | 872 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); |
| 842 EXPECT_EQ(3U, s[0]->InputCount()); | 873 EXPECT_EQ(3U, s[0]->InputCount()); |
| 843 EXPECT_EQ(2U, s[0]->OutputCount()); | 874 EXPECT_EQ(2U, s[0]->OutputCount()); |
| 844 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 875 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 845 EXPECT_EQ(kOverflow, s[0]->flags_condition()); | 876 EXPECT_EQ(kOverflow, s[0]->flags_condition()); |
| 846 } | 877 } |
| 847 } | 878 } |
| 848 | 879 |
| 849 | 880 |
| 850 TEST_P(InstructionSelectorODPITest, BothWithShiftByImmediate) { | 881 TEST_P(InstructionSelectorODPITest, BothWithShiftByImmediate) { |
| 851 const ODPI odpi = GetParam(); | 882 const ODPI odpi = GetParam(); |
| 852 TRACED_FOREACH(Shift, shift, kShifts) { | 883 TRACED_FOREACH(Shift, shift, kShifts) { |
| 853 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { | 884 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { |
| 854 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); | 885 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 886 MachineType::Int32()); |
| 855 Node* n = (m.*odpi.constructor)( | 887 Node* n = (m.*odpi.constructor)( |
| 856 m.Parameter(0), | 888 m.Parameter(0), |
| 857 (m.*shift.constructor)(m.Parameter(1), m.Int32Constant(imm))); | 889 (m.*shift.constructor)(m.Parameter(1), m.Int32Constant(imm))); |
| 858 m.Return(m.Word32Equal(m.Projection(0, n), m.Projection(1, n))); | 890 m.Return(m.Word32Equal(m.Projection(0, n), m.Projection(1, n))); |
| 859 Stream s = m.Build(); | 891 Stream s = m.Build(); |
| 860 ASSERT_LE(1U, s.size()); | 892 ASSERT_LE(1U, s.size()); |
| 861 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); | 893 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); |
| 862 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); | 894 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); |
| 863 ASSERT_EQ(3U, s[0]->InputCount()); | 895 ASSERT_EQ(3U, s[0]->InputCount()); |
| 864 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); | 896 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); |
| 865 EXPECT_EQ(2U, s[0]->OutputCount()); | 897 EXPECT_EQ(2U, s[0]->OutputCount()); |
| 866 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 898 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 867 EXPECT_EQ(kOverflow, s[0]->flags_condition()); | 899 EXPECT_EQ(kOverflow, s[0]->flags_condition()); |
| 868 } | 900 } |
| 869 } | 901 } |
| 870 TRACED_FOREACH(Shift, shift, kShifts) { | 902 TRACED_FOREACH(Shift, shift, kShifts) { |
| 871 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { | 903 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { |
| 872 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); | 904 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 905 MachineType::Int32()); |
| 873 Node* n = (m.*odpi.constructor)( | 906 Node* n = (m.*odpi.constructor)( |
| 874 (m.*shift.constructor)(m.Parameter(0), m.Int32Constant(imm)), | 907 (m.*shift.constructor)(m.Parameter(0), m.Int32Constant(imm)), |
| 875 m.Parameter(1)); | 908 m.Parameter(1)); |
| 876 m.Return(m.Word32Equal(m.Projection(0, n), m.Projection(1, n))); | 909 m.Return(m.Word32Equal(m.Projection(0, n), m.Projection(1, n))); |
| 877 Stream s = m.Build(); | 910 Stream s = m.Build(); |
| 878 ASSERT_LE(1U, s.size()); | 911 ASSERT_LE(1U, s.size()); |
| 879 EXPECT_EQ(odpi.reverse_arch_opcode, s[0]->arch_opcode()); | 912 EXPECT_EQ(odpi.reverse_arch_opcode, s[0]->arch_opcode()); |
| 880 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); | 913 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); |
| 881 ASSERT_EQ(3U, s[0]->InputCount()); | 914 ASSERT_EQ(3U, s[0]->InputCount()); |
| 882 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); | 915 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); |
| 883 EXPECT_EQ(2U, s[0]->OutputCount()); | 916 EXPECT_EQ(2U, s[0]->OutputCount()); |
| 884 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 917 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 885 EXPECT_EQ(kOverflow, s[0]->flags_condition()); | 918 EXPECT_EQ(kOverflow, s[0]->flags_condition()); |
| 886 } | 919 } |
| 887 } | 920 } |
| 888 } | 921 } |
| 889 | 922 |
| 890 | 923 |
| 891 TEST_P(InstructionSelectorODPITest, BranchWithParameters) { | 924 TEST_P(InstructionSelectorODPITest, BranchWithParameters) { |
| 892 const ODPI odpi = GetParam(); | 925 const ODPI odpi = GetParam(); |
| 893 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); | 926 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 927 MachineType::Int32()); |
| 894 RawMachineLabel a, b; | 928 RawMachineLabel a, b; |
| 895 Node* n = (m.*odpi.constructor)(m.Parameter(0), m.Parameter(1)); | 929 Node* n = (m.*odpi.constructor)(m.Parameter(0), m.Parameter(1)); |
| 896 m.Branch(m.Projection(1, n), &a, &b); | 930 m.Branch(m.Projection(1, n), &a, &b); |
| 897 m.Bind(&a); | 931 m.Bind(&a); |
| 898 m.Return(m.Int32Constant(0)); | 932 m.Return(m.Int32Constant(0)); |
| 899 m.Bind(&b); | 933 m.Bind(&b); |
| 900 m.Return(m.Projection(0, n)); | 934 m.Return(m.Projection(0, n)); |
| 901 Stream s = m.Build(); | 935 Stream s = m.Build(); |
| 902 ASSERT_EQ(1U, s.size()); | 936 ASSERT_EQ(1U, s.size()); |
| 903 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); | 937 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); |
| 904 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); | 938 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); |
| 905 EXPECT_EQ(4U, s[0]->InputCount()); | 939 EXPECT_EQ(4U, s[0]->InputCount()); |
| 906 EXPECT_EQ(1U, s[0]->OutputCount()); | 940 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 907 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); | 941 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); |
| 908 EXPECT_EQ(kOverflow, s[0]->flags_condition()); | 942 EXPECT_EQ(kOverflow, s[0]->flags_condition()); |
| 909 } | 943 } |
| 910 | 944 |
| 911 | 945 |
| 912 TEST_P(InstructionSelectorODPITest, BranchWithImmediate) { | 946 TEST_P(InstructionSelectorODPITest, BranchWithImmediate) { |
| 913 const ODPI odpi = GetParam(); | 947 const ODPI odpi = GetParam(); |
| 914 TRACED_FOREACH(int32_t, imm, kImmediates) { | 948 TRACED_FOREACH(int32_t, imm, kImmediates) { |
| 915 StreamBuilder m(this, kMachInt32, kMachInt32); | 949 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
| 916 RawMachineLabel a, b; | 950 RawMachineLabel a, b; |
| 917 Node* n = (m.*odpi.constructor)(m.Parameter(0), m.Int32Constant(imm)); | 951 Node* n = (m.*odpi.constructor)(m.Parameter(0), m.Int32Constant(imm)); |
| 918 m.Branch(m.Projection(1, n), &a, &b); | 952 m.Branch(m.Projection(1, n), &a, &b); |
| 919 m.Bind(&a); | 953 m.Bind(&a); |
| 920 m.Return(m.Int32Constant(0)); | 954 m.Return(m.Int32Constant(0)); |
| 921 m.Bind(&b); | 955 m.Bind(&b); |
| 922 m.Return(m.Projection(0, n)); | 956 m.Return(m.Projection(0, n)); |
| 923 Stream s = m.Build(); | 957 Stream s = m.Build(); |
| 924 ASSERT_EQ(1U, s.size()); | 958 ASSERT_EQ(1U, s.size()); |
| 925 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); | 959 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); |
| 926 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); | 960 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); |
| 927 ASSERT_EQ(4U, s[0]->InputCount()); | 961 ASSERT_EQ(4U, s[0]->InputCount()); |
| 928 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); | 962 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); |
| 929 EXPECT_EQ(1U, s[0]->OutputCount()); | 963 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 930 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); | 964 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); |
| 931 EXPECT_EQ(kOverflow, s[0]->flags_condition()); | 965 EXPECT_EQ(kOverflow, s[0]->flags_condition()); |
| 932 } | 966 } |
| 933 TRACED_FOREACH(int32_t, imm, kImmediates) { | 967 TRACED_FOREACH(int32_t, imm, kImmediates) { |
| 934 StreamBuilder m(this, kMachInt32, kMachInt32); | 968 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
| 935 RawMachineLabel a, b; | 969 RawMachineLabel a, b; |
| 936 Node* n = (m.*odpi.constructor)(m.Int32Constant(imm), m.Parameter(0)); | 970 Node* n = (m.*odpi.constructor)(m.Int32Constant(imm), m.Parameter(0)); |
| 937 m.Branch(m.Projection(1, n), &a, &b); | 971 m.Branch(m.Projection(1, n), &a, &b); |
| 938 m.Bind(&a); | 972 m.Bind(&a); |
| 939 m.Return(m.Int32Constant(0)); | 973 m.Return(m.Int32Constant(0)); |
| 940 m.Bind(&b); | 974 m.Bind(&b); |
| 941 m.Return(m.Projection(0, n)); | 975 m.Return(m.Projection(0, n)); |
| 942 Stream s = m.Build(); | 976 Stream s = m.Build(); |
| 943 ASSERT_EQ(1U, s.size()); | 977 ASSERT_EQ(1U, s.size()); |
| 944 EXPECT_EQ(odpi.reverse_arch_opcode, s[0]->arch_opcode()); | 978 EXPECT_EQ(odpi.reverse_arch_opcode, s[0]->arch_opcode()); |
| 945 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); | 979 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); |
| 946 ASSERT_EQ(4U, s[0]->InputCount()); | 980 ASSERT_EQ(4U, s[0]->InputCount()); |
| 947 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); | 981 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); |
| 948 EXPECT_EQ(1U, s[0]->OutputCount()); | 982 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 949 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); | 983 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); |
| 950 EXPECT_EQ(kOverflow, s[0]->flags_condition()); | 984 EXPECT_EQ(kOverflow, s[0]->flags_condition()); |
| 951 } | 985 } |
| 952 } | 986 } |
| 953 | 987 |
| 954 | 988 |
| 955 TEST_P(InstructionSelectorODPITest, BranchIfZeroWithParameters) { | 989 TEST_P(InstructionSelectorODPITest, BranchIfZeroWithParameters) { |
| 956 const ODPI odpi = GetParam(); | 990 const ODPI odpi = GetParam(); |
| 957 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); | 991 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 992 MachineType::Int32()); |
| 958 RawMachineLabel a, b; | 993 RawMachineLabel a, b; |
| 959 Node* n = (m.*odpi.constructor)(m.Parameter(0), m.Parameter(1)); | 994 Node* n = (m.*odpi.constructor)(m.Parameter(0), m.Parameter(1)); |
| 960 m.Branch(m.Word32Equal(m.Projection(1, n), m.Int32Constant(0)), &a, &b); | 995 m.Branch(m.Word32Equal(m.Projection(1, n), m.Int32Constant(0)), &a, &b); |
| 961 m.Bind(&a); | 996 m.Bind(&a); |
| 962 m.Return(m.Projection(0, n)); | 997 m.Return(m.Projection(0, n)); |
| 963 m.Bind(&b); | 998 m.Bind(&b); |
| 964 m.Return(m.Int32Constant(0)); | 999 m.Return(m.Int32Constant(0)); |
| 965 Stream s = m.Build(); | 1000 Stream s = m.Build(); |
| 966 ASSERT_EQ(1U, s.size()); | 1001 ASSERT_EQ(1U, s.size()); |
| 967 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); | 1002 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); |
| 968 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); | 1003 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); |
| 969 EXPECT_EQ(4U, s[0]->InputCount()); | 1004 EXPECT_EQ(4U, s[0]->InputCount()); |
| 970 EXPECT_EQ(1U, s[0]->OutputCount()); | 1005 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 971 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); | 1006 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); |
| 972 EXPECT_EQ(kNotOverflow, s[0]->flags_condition()); | 1007 EXPECT_EQ(kNotOverflow, s[0]->flags_condition()); |
| 973 } | 1008 } |
| 974 | 1009 |
| 975 | 1010 |
| 976 TEST_P(InstructionSelectorODPITest, BranchIfNotZeroWithParameters) { | 1011 TEST_P(InstructionSelectorODPITest, BranchIfNotZeroWithParameters) { |
| 977 const ODPI odpi = GetParam(); | 1012 const ODPI odpi = GetParam(); |
| 978 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); | 1013 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 1014 MachineType::Int32()); |
| 979 RawMachineLabel a, b; | 1015 RawMachineLabel a, b; |
| 980 Node* n = (m.*odpi.constructor)(m.Parameter(0), m.Parameter(1)); | 1016 Node* n = (m.*odpi.constructor)(m.Parameter(0), m.Parameter(1)); |
| 981 m.Branch(m.Word32NotEqual(m.Projection(1, n), m.Int32Constant(0)), &a, &b); | 1017 m.Branch(m.Word32NotEqual(m.Projection(1, n), m.Int32Constant(0)), &a, &b); |
| 982 m.Bind(&a); | 1018 m.Bind(&a); |
| 983 m.Return(m.Projection(0, n)); | 1019 m.Return(m.Projection(0, n)); |
| 984 m.Bind(&b); | 1020 m.Bind(&b); |
| 985 m.Return(m.Int32Constant(0)); | 1021 m.Return(m.Int32Constant(0)); |
| 986 Stream s = m.Build(); | 1022 Stream s = m.Build(); |
| 987 ASSERT_EQ(1U, s.size()); | 1023 ASSERT_EQ(1U, s.size()); |
| 988 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); | 1024 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1000 | 1036 |
| 1001 // ----------------------------------------------------------------------------- | 1037 // ----------------------------------------------------------------------------- |
| 1002 // Shifts. | 1038 // Shifts. |
| 1003 | 1039 |
| 1004 | 1040 |
| 1005 typedef InstructionSelectorTestWithParam<Shift> InstructionSelectorShiftTest; | 1041 typedef InstructionSelectorTestWithParam<Shift> InstructionSelectorShiftTest; |
| 1006 | 1042 |
| 1007 | 1043 |
| 1008 TEST_P(InstructionSelectorShiftTest, Parameters) { | 1044 TEST_P(InstructionSelectorShiftTest, Parameters) { |
| 1009 const Shift shift = GetParam(); | 1045 const Shift shift = GetParam(); |
| 1010 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); | 1046 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 1047 MachineType::Int32()); |
| 1011 m.Return((m.*shift.constructor)(m.Parameter(0), m.Parameter(1))); | 1048 m.Return((m.*shift.constructor)(m.Parameter(0), m.Parameter(1))); |
| 1012 Stream s = m.Build(); | 1049 Stream s = m.Build(); |
| 1013 ASSERT_EQ(1U, s.size()); | 1050 ASSERT_EQ(1U, s.size()); |
| 1014 EXPECT_EQ(kArmMov, s[0]->arch_opcode()); | 1051 EXPECT_EQ(kArmMov, s[0]->arch_opcode()); |
| 1015 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); | 1052 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); |
| 1016 EXPECT_EQ(2U, s[0]->InputCount()); | 1053 EXPECT_EQ(2U, s[0]->InputCount()); |
| 1017 EXPECT_EQ(1U, s[0]->OutputCount()); | 1054 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 1018 } | 1055 } |
| 1019 | 1056 |
| 1020 | 1057 |
| 1021 TEST_P(InstructionSelectorShiftTest, Immediate) { | 1058 TEST_P(InstructionSelectorShiftTest, Immediate) { |
| 1022 const Shift shift = GetParam(); | 1059 const Shift shift = GetParam(); |
| 1023 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { | 1060 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { |
| 1024 StreamBuilder m(this, kMachInt32, kMachInt32); | 1061 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
| 1025 m.Return((m.*shift.constructor)(m.Parameter(0), m.Int32Constant(imm))); | 1062 m.Return((m.*shift.constructor)(m.Parameter(0), m.Int32Constant(imm))); |
| 1026 Stream s = m.Build(); | 1063 Stream s = m.Build(); |
| 1027 ASSERT_EQ(1U, s.size()); | 1064 ASSERT_EQ(1U, s.size()); |
| 1028 EXPECT_EQ(kArmMov, s[0]->arch_opcode()); | 1065 EXPECT_EQ(kArmMov, s[0]->arch_opcode()); |
| 1029 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); | 1066 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); |
| 1030 ASSERT_EQ(2U, s[0]->InputCount()); | 1067 ASSERT_EQ(2U, s[0]->InputCount()); |
| 1031 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); | 1068 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); |
| 1032 EXPECT_EQ(1U, s[0]->OutputCount()); | 1069 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 1033 } | 1070 } |
| 1034 } | 1071 } |
| 1035 | 1072 |
| 1036 | 1073 |
| 1037 TEST_P(InstructionSelectorShiftTest, Word32EqualWithParameter) { | 1074 TEST_P(InstructionSelectorShiftTest, Word32EqualWithParameter) { |
| 1038 const Shift shift = GetParam(); | 1075 const Shift shift = GetParam(); |
| 1039 { | 1076 { |
| 1040 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); | 1077 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 1078 MachineType::Int32(), MachineType::Int32()); |
| 1041 m.Return( | 1079 m.Return( |
| 1042 m.Word32Equal(m.Parameter(0), | 1080 m.Word32Equal(m.Parameter(0), |
| 1043 (m.*shift.constructor)(m.Parameter(1), m.Parameter(2)))); | 1081 (m.*shift.constructor)(m.Parameter(1), m.Parameter(2)))); |
| 1044 Stream s = m.Build(); | 1082 Stream s = m.Build(); |
| 1045 ASSERT_EQ(1U, s.size()); | 1083 ASSERT_EQ(1U, s.size()); |
| 1046 EXPECT_EQ(kArmCmp, s[0]->arch_opcode()); | 1084 EXPECT_EQ(kArmCmp, s[0]->arch_opcode()); |
| 1047 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); | 1085 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); |
| 1048 EXPECT_EQ(3U, s[0]->InputCount()); | 1086 EXPECT_EQ(3U, s[0]->InputCount()); |
| 1049 EXPECT_EQ(1U, s[0]->OutputCount()); | 1087 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 1050 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 1088 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 1051 EXPECT_EQ(kEqual, s[0]->flags_condition()); | 1089 EXPECT_EQ(kEqual, s[0]->flags_condition()); |
| 1052 } | 1090 } |
| 1053 { | 1091 { |
| 1054 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); | 1092 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 1093 MachineType::Int32(), MachineType::Int32()); |
| 1055 m.Return( | 1094 m.Return( |
| 1056 m.Word32Equal((m.*shift.constructor)(m.Parameter(1), m.Parameter(2)), | 1095 m.Word32Equal((m.*shift.constructor)(m.Parameter(1), m.Parameter(2)), |
| 1057 m.Parameter(0))); | 1096 m.Parameter(0))); |
| 1058 Stream s = m.Build(); | 1097 Stream s = m.Build(); |
| 1059 ASSERT_EQ(1U, s.size()); | 1098 ASSERT_EQ(1U, s.size()); |
| 1060 EXPECT_EQ(kArmCmp, s[0]->arch_opcode()); | 1099 EXPECT_EQ(kArmCmp, s[0]->arch_opcode()); |
| 1061 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); | 1100 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); |
| 1062 EXPECT_EQ(3U, s[0]->InputCount()); | 1101 EXPECT_EQ(3U, s[0]->InputCount()); |
| 1063 EXPECT_EQ(1U, s[0]->OutputCount()); | 1102 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 1064 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 1103 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 1065 EXPECT_EQ(kEqual, s[0]->flags_condition()); | 1104 EXPECT_EQ(kEqual, s[0]->flags_condition()); |
| 1066 } | 1105 } |
| 1067 } | 1106 } |
| 1068 | 1107 |
| 1069 | 1108 |
| 1070 TEST_P(InstructionSelectorShiftTest, Word32EqualWithParameterAndImmediate) { | 1109 TEST_P(InstructionSelectorShiftTest, Word32EqualWithParameterAndImmediate) { |
| 1071 const Shift shift = GetParam(); | 1110 const Shift shift = GetParam(); |
| 1072 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { | 1111 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { |
| 1073 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); | 1112 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 1113 MachineType::Int32()); |
| 1074 m.Return(m.Word32Equal( | 1114 m.Return(m.Word32Equal( |
| 1075 (m.*shift.constructor)(m.Parameter(1), m.Int32Constant(imm)), | 1115 (m.*shift.constructor)(m.Parameter(1), m.Int32Constant(imm)), |
| 1076 m.Parameter(0))); | 1116 m.Parameter(0))); |
| 1077 Stream s = m.Build(); | 1117 Stream s = m.Build(); |
| 1078 ASSERT_EQ(1U, s.size()); | 1118 ASSERT_EQ(1U, s.size()); |
| 1079 EXPECT_EQ(kArmCmp, s[0]->arch_opcode()); | 1119 EXPECT_EQ(kArmCmp, s[0]->arch_opcode()); |
| 1080 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); | 1120 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); |
| 1081 ASSERT_EQ(3U, s[0]->InputCount()); | 1121 ASSERT_EQ(3U, s[0]->InputCount()); |
| 1082 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); | 1122 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); |
| 1083 EXPECT_EQ(1U, s[0]->OutputCount()); | 1123 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 1084 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 1124 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 1085 EXPECT_EQ(kEqual, s[0]->flags_condition()); | 1125 EXPECT_EQ(kEqual, s[0]->flags_condition()); |
| 1086 } | 1126 } |
| 1087 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { | 1127 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { |
| 1088 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); | 1128 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 1129 MachineType::Int32()); |
| 1089 m.Return(m.Word32Equal( | 1130 m.Return(m.Word32Equal( |
| 1090 m.Parameter(0), | 1131 m.Parameter(0), |
| 1091 (m.*shift.constructor)(m.Parameter(1), m.Int32Constant(imm)))); | 1132 (m.*shift.constructor)(m.Parameter(1), m.Int32Constant(imm)))); |
| 1092 Stream s = m.Build(); | 1133 Stream s = m.Build(); |
| 1093 ASSERT_EQ(1U, s.size()); | 1134 ASSERT_EQ(1U, s.size()); |
| 1094 EXPECT_EQ(kArmCmp, s[0]->arch_opcode()); | 1135 EXPECT_EQ(kArmCmp, s[0]->arch_opcode()); |
| 1095 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); | 1136 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); |
| 1096 ASSERT_EQ(3U, s[0]->InputCount()); | 1137 ASSERT_EQ(3U, s[0]->InputCount()); |
| 1097 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); | 1138 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); |
| 1098 EXPECT_EQ(1U, s[0]->OutputCount()); | 1139 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 1099 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 1140 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 1100 EXPECT_EQ(kEqual, s[0]->flags_condition()); | 1141 EXPECT_EQ(kEqual, s[0]->flags_condition()); |
| 1101 } | 1142 } |
| 1102 } | 1143 } |
| 1103 | 1144 |
| 1104 | 1145 |
| 1105 TEST_P(InstructionSelectorShiftTest, Word32EqualToZeroWithParameters) { | 1146 TEST_P(InstructionSelectorShiftTest, Word32EqualToZeroWithParameters) { |
| 1106 const Shift shift = GetParam(); | 1147 const Shift shift = GetParam(); |
| 1107 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); | 1148 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 1149 MachineType::Int32()); |
| 1108 m.Return( | 1150 m.Return( |
| 1109 m.Word32Equal(m.Int32Constant(0), | 1151 m.Word32Equal(m.Int32Constant(0), |
| 1110 (m.*shift.constructor)(m.Parameter(0), m.Parameter(1)))); | 1152 (m.*shift.constructor)(m.Parameter(0), m.Parameter(1)))); |
| 1111 Stream s = m.Build(); | 1153 Stream s = m.Build(); |
| 1112 ASSERT_EQ(1U, s.size()); | 1154 ASSERT_EQ(1U, s.size()); |
| 1113 EXPECT_EQ(kArmMov, s[0]->arch_opcode()); | 1155 EXPECT_EQ(kArmMov, s[0]->arch_opcode()); |
| 1114 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); | 1156 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); |
| 1115 EXPECT_EQ(2U, s[0]->InputCount()); | 1157 EXPECT_EQ(2U, s[0]->InputCount()); |
| 1116 EXPECT_EQ(2U, s[0]->OutputCount()); | 1158 EXPECT_EQ(2U, s[0]->OutputCount()); |
| 1117 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 1159 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 1118 EXPECT_EQ(kEqual, s[0]->flags_condition()); | 1160 EXPECT_EQ(kEqual, s[0]->flags_condition()); |
| 1119 } | 1161 } |
| 1120 | 1162 |
| 1121 | 1163 |
| 1122 TEST_P(InstructionSelectorShiftTest, Word32EqualToZeroWithImmediate) { | 1164 TEST_P(InstructionSelectorShiftTest, Word32EqualToZeroWithImmediate) { |
| 1123 const Shift shift = GetParam(); | 1165 const Shift shift = GetParam(); |
| 1124 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { | 1166 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { |
| 1125 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); | 1167 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 1168 MachineType::Int32()); |
| 1126 m.Return(m.Word32Equal( | 1169 m.Return(m.Word32Equal( |
| 1127 m.Int32Constant(0), | 1170 m.Int32Constant(0), |
| 1128 (m.*shift.constructor)(m.Parameter(0), m.Int32Constant(imm)))); | 1171 (m.*shift.constructor)(m.Parameter(0), m.Int32Constant(imm)))); |
| 1129 Stream s = m.Build(); | 1172 Stream s = m.Build(); |
| 1130 ASSERT_EQ(1U, s.size()); | 1173 ASSERT_EQ(1U, s.size()); |
| 1131 EXPECT_EQ(kArmMov, s[0]->arch_opcode()); | 1174 EXPECT_EQ(kArmMov, s[0]->arch_opcode()); |
| 1132 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); | 1175 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); |
| 1133 ASSERT_EQ(2U, s[0]->InputCount()); | 1176 ASSERT_EQ(2U, s[0]->InputCount()); |
| 1134 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); | 1177 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); |
| 1135 EXPECT_EQ(2U, s[0]->OutputCount()); | 1178 EXPECT_EQ(2U, s[0]->OutputCount()); |
| 1136 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 1179 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 1137 EXPECT_EQ(kEqual, s[0]->flags_condition()); | 1180 EXPECT_EQ(kEqual, s[0]->flags_condition()); |
| 1138 } | 1181 } |
| 1139 } | 1182 } |
| 1140 | 1183 |
| 1141 | 1184 |
| 1142 TEST_P(InstructionSelectorShiftTest, Word32NotWithParameters) { | 1185 TEST_P(InstructionSelectorShiftTest, Word32NotWithParameters) { |
| 1143 const Shift shift = GetParam(); | 1186 const Shift shift = GetParam(); |
| 1144 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); | 1187 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 1188 MachineType::Int32()); |
| 1145 m.Return(m.Word32Not((m.*shift.constructor)(m.Parameter(0), m.Parameter(1)))); | 1189 m.Return(m.Word32Not((m.*shift.constructor)(m.Parameter(0), m.Parameter(1)))); |
| 1146 Stream s = m.Build(); | 1190 Stream s = m.Build(); |
| 1147 ASSERT_EQ(1U, s.size()); | 1191 ASSERT_EQ(1U, s.size()); |
| 1148 EXPECT_EQ(kArmMvn, s[0]->arch_opcode()); | 1192 EXPECT_EQ(kArmMvn, s[0]->arch_opcode()); |
| 1149 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); | 1193 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); |
| 1150 EXPECT_EQ(2U, s[0]->InputCount()); | 1194 EXPECT_EQ(2U, s[0]->InputCount()); |
| 1151 EXPECT_EQ(1U, s[0]->OutputCount()); | 1195 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 1152 } | 1196 } |
| 1153 | 1197 |
| 1154 | 1198 |
| 1155 TEST_P(InstructionSelectorShiftTest, Word32NotWithImmediate) { | 1199 TEST_P(InstructionSelectorShiftTest, Word32NotWithImmediate) { |
| 1156 const Shift shift = GetParam(); | 1200 const Shift shift = GetParam(); |
| 1157 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { | 1201 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { |
| 1158 StreamBuilder m(this, kMachInt32, kMachInt32); | 1202 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
| 1159 m.Return(m.Word32Not( | 1203 m.Return(m.Word32Not( |
| 1160 (m.*shift.constructor)(m.Parameter(0), m.Int32Constant(imm)))); | 1204 (m.*shift.constructor)(m.Parameter(0), m.Int32Constant(imm)))); |
| 1161 Stream s = m.Build(); | 1205 Stream s = m.Build(); |
| 1162 ASSERT_EQ(1U, s.size()); | 1206 ASSERT_EQ(1U, s.size()); |
| 1163 EXPECT_EQ(kArmMvn, s[0]->arch_opcode()); | 1207 EXPECT_EQ(kArmMvn, s[0]->arch_opcode()); |
| 1164 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); | 1208 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); |
| 1165 ASSERT_EQ(2U, s[0]->InputCount()); | 1209 ASSERT_EQ(2U, s[0]->InputCount()); |
| 1166 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); | 1210 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); |
| 1167 EXPECT_EQ(1U, s[0]->OutputCount()); | 1211 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 1168 } | 1212 } |
| 1169 } | 1213 } |
| 1170 | 1214 |
| 1171 | 1215 |
| 1172 TEST_P(InstructionSelectorShiftTest, Word32AndWithWord32NotWithParameters) { | 1216 TEST_P(InstructionSelectorShiftTest, Word32AndWithWord32NotWithParameters) { |
| 1173 const Shift shift = GetParam(); | 1217 const Shift shift = GetParam(); |
| 1174 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); | 1218 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 1219 MachineType::Int32(), MachineType::Int32()); |
| 1175 m.Return(m.Word32And(m.Parameter(0), m.Word32Not((m.*shift.constructor)( | 1220 m.Return(m.Word32And(m.Parameter(0), m.Word32Not((m.*shift.constructor)( |
| 1176 m.Parameter(1), m.Parameter(2))))); | 1221 m.Parameter(1), m.Parameter(2))))); |
| 1177 Stream s = m.Build(); | 1222 Stream s = m.Build(); |
| 1178 ASSERT_EQ(1U, s.size()); | 1223 ASSERT_EQ(1U, s.size()); |
| 1179 EXPECT_EQ(kArmBic, s[0]->arch_opcode()); | 1224 EXPECT_EQ(kArmBic, s[0]->arch_opcode()); |
| 1180 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); | 1225 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); |
| 1181 EXPECT_EQ(3U, s[0]->InputCount()); | 1226 EXPECT_EQ(3U, s[0]->InputCount()); |
| 1182 EXPECT_EQ(1U, s[0]->OutputCount()); | 1227 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 1183 } | 1228 } |
| 1184 | 1229 |
| 1185 | 1230 |
| 1186 TEST_P(InstructionSelectorShiftTest, Word32AndWithWord32NotWithImmediate) { | 1231 TEST_P(InstructionSelectorShiftTest, Word32AndWithWord32NotWithImmediate) { |
| 1187 const Shift shift = GetParam(); | 1232 const Shift shift = GetParam(); |
| 1188 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { | 1233 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { |
| 1189 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); | 1234 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 1235 MachineType::Int32()); |
| 1190 m.Return(m.Word32And(m.Parameter(0), | 1236 m.Return(m.Word32And(m.Parameter(0), |
| 1191 m.Word32Not((m.*shift.constructor)( | 1237 m.Word32Not((m.*shift.constructor)( |
| 1192 m.Parameter(1), m.Int32Constant(imm))))); | 1238 m.Parameter(1), m.Int32Constant(imm))))); |
| 1193 Stream s = m.Build(); | 1239 Stream s = m.Build(); |
| 1194 ASSERT_EQ(1U, s.size()); | 1240 ASSERT_EQ(1U, s.size()); |
| 1195 EXPECT_EQ(kArmBic, s[0]->arch_opcode()); | 1241 EXPECT_EQ(kArmBic, s[0]->arch_opcode()); |
| 1196 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); | 1242 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); |
| 1197 ASSERT_EQ(3U, s[0]->InputCount()); | 1243 ASSERT_EQ(3U, s[0]->InputCount()); |
| 1198 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); | 1244 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); |
| 1199 EXPECT_EQ(1U, s[0]->OutputCount()); | 1245 EXPECT_EQ(1U, s[0]->OutputCount()); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1220 const int32_t immediates[40]; | 1266 const int32_t immediates[40]; |
| 1221 }; | 1267 }; |
| 1222 | 1268 |
| 1223 | 1269 |
| 1224 std::ostream& operator<<(std::ostream& os, const MemoryAccess& memacc) { | 1270 std::ostream& operator<<(std::ostream& os, const MemoryAccess& memacc) { |
| 1225 return os << memacc.type; | 1271 return os << memacc.type; |
| 1226 } | 1272 } |
| 1227 | 1273 |
| 1228 | 1274 |
| 1229 const MemoryAccess kMemoryAccesses[] = { | 1275 const MemoryAccess kMemoryAccesses[] = { |
| 1230 {kMachInt8, | 1276 {MachineType::Int8(), |
| 1231 kArmLdrsb, | 1277 kArmLdrsb, |
| 1232 kArmStrb, | 1278 kArmStrb, |
| 1233 &InstructionSelectorTest::Stream::IsInteger, | 1279 &InstructionSelectorTest::Stream::IsInteger, |
| 1234 {-4095, -3340, -3231, -3224, -3088, -1758, -1203, -123, -117, -91, -89, | 1280 {-4095, -3340, -3231, -3224, -3088, -1758, -1203, -123, -117, -91, -89, |
| 1235 -87, -86, -82, -44, -23, -3, 0, 7, 10, 39, 52, 69, 71, 91, 92, 107, 109, | 1281 -87, -86, -82, -44, -23, -3, 0, 7, 10, 39, 52, 69, 71, 91, 92, 107, 109, |
| 1236 115, 124, 286, 655, 1362, 1569, 2587, 3067, 3096, 3462, 3510, 4095}}, | 1282 115, 124, 286, 655, 1362, 1569, 2587, 3067, 3096, 3462, 3510, 4095}}, |
| 1237 {kMachUint8, | 1283 {MachineType::Uint8(), |
| 1238 kArmLdrb, | 1284 kArmLdrb, |
| 1239 kArmStrb, | 1285 kArmStrb, |
| 1240 &InstructionSelectorTest::Stream::IsInteger, | 1286 &InstructionSelectorTest::Stream::IsInteger, |
| 1241 {-4095, -3914, -3536, -3234, -3185, -3169, -1073, -990, -859, -720, -434, | 1287 {-4095, -3914, -3536, -3234, -3185, -3169, -1073, -990, -859, -720, -434, |
| 1242 -127, -124, -122, -105, -91, -86, -64, -55, -53, -30, -10, -3, 0, 20, 28, | 1288 -127, -124, -122, -105, -91, -86, -64, -55, -53, -30, -10, -3, 0, 20, 28, |
| 1243 39, 58, 64, 73, 75, 100, 108, 121, 686, 963, 1363, 2759, 3449, 4095}}, | 1289 39, 58, 64, 73, 75, 100, 108, 121, 686, 963, 1363, 2759, 3449, 4095}}, |
| 1244 {kMachInt16, | 1290 {MachineType::Int16(), |
| 1245 kArmLdrsh, | 1291 kArmLdrsh, |
| 1246 kArmStrh, | 1292 kArmStrh, |
| 1247 &InstructionSelectorTest::Stream::IsInteger, | 1293 &InstructionSelectorTest::Stream::IsInteger, |
| 1248 {-255, -251, -232, -220, -144, -138, -130, -126, -116, -115, -102, -101, | 1294 {-255, -251, -232, -220, -144, -138, -130, -126, -116, -115, -102, -101, |
| 1249 -98, -69, -59, -56, -39, -35, -23, -19, -7, 0, 22, 26, 37, 68, 83, 87, 98, | 1295 -98, -69, -59, -56, -39, -35, -23, -19, -7, 0, 22, 26, 37, 68, 83, 87, 98, |
| 1250 102, 108, 111, 117, 171, 195, 203, 204, 245, 246, 255}}, | 1296 102, 108, 111, 117, 171, 195, 203, 204, 245, 246, 255}}, |
| 1251 {kMachUint16, | 1297 {MachineType::Uint16(), |
| 1252 kArmLdrh, | 1298 kArmLdrh, |
| 1253 kArmStrh, | 1299 kArmStrh, |
| 1254 &InstructionSelectorTest::Stream::IsInteger, | 1300 &InstructionSelectorTest::Stream::IsInteger, |
| 1255 {-255, -230, -201, -172, -125, -119, -118, -105, -98, -79, -54, -42, -41, | 1301 {-255, -230, -201, -172, -125, -119, -118, -105, -98, -79, -54, -42, -41, |
| 1256 -32, -12, -11, -5, -4, 0, 5, 9, 25, 28, 51, 58, 60, 89, 104, 108, 109, | 1302 -32, -12, -11, -5, -4, 0, 5, 9, 25, 28, 51, 58, 60, 89, 104, 108, 109, |
| 1257 114, 116, 120, 138, 150, 161, 166, 172, 228, 255}}, | 1303 114, 116, 120, 138, 150, 161, 166, 172, 228, 255}}, |
| 1258 {kMachInt32, | 1304 {MachineType::Int32(), |
| 1259 kArmLdr, | 1305 kArmLdr, |
| 1260 kArmStr, | 1306 kArmStr, |
| 1261 &InstructionSelectorTest::Stream::IsInteger, | 1307 &InstructionSelectorTest::Stream::IsInteger, |
| 1262 {-4095, -1898, -1685, -1562, -1408, -1313, -344, -128, -116, -100, -92, | 1308 {-4095, -1898, -1685, -1562, -1408, -1313, -344, -128, -116, -100, -92, |
| 1263 -80, -72, -71, -56, -25, -21, -11, -9, 0, 3, 5, 27, 28, 42, 52, 63, 88, | 1309 -80, -72, -71, -56, -25, -21, -11, -9, 0, 3, 5, 27, 28, 42, 52, 63, 88, |
| 1264 93, 97, 125, 846, 1037, 2102, 2403, 2597, 2632, 2997, 3935, 4095}}, | 1310 93, 97, 125, 846, 1037, 2102, 2403, 2597, 2632, 2997, 3935, 4095}}, |
| 1265 {kMachFloat32, | 1311 {MachineType::Float32(), |
| 1266 kArmVldrF32, | 1312 kArmVldrF32, |
| 1267 kArmVstrF32, | 1313 kArmVstrF32, |
| 1268 &InstructionSelectorTest::Stream::IsDouble, | 1314 &InstructionSelectorTest::Stream::IsDouble, |
| 1269 {-1020, -928, -896, -772, -728, -680, -660, -488, -372, -112, -100, -92, | 1315 {-1020, -928, -896, -772, -728, -680, -660, -488, -372, -112, -100, -92, |
| 1270 -84, -80, -72, -64, -60, -56, -52, -48, -36, -32, -20, -8, -4, 0, 8, 20, | 1316 -84, -80, -72, -64, -60, -56, -52, -48, -36, -32, -20, -8, -4, 0, 8, 20, |
| 1271 24, 40, 64, 112, 204, 388, 516, 852, 856, 976, 988, 1020}}, | 1317 24, 40, 64, 112, 204, 388, 516, 852, 856, 976, 988, 1020}}, |
| 1272 {kMachFloat64, | 1318 {MachineType::Float64(), |
| 1273 kArmVldrF64, | 1319 kArmVldrF64, |
| 1274 kArmVstrF64, | 1320 kArmVstrF64, |
| 1275 &InstructionSelectorTest::Stream::IsDouble, | 1321 &InstructionSelectorTest::Stream::IsDouble, |
| 1276 {-1020, -948, -796, -696, -612, -364, -320, -308, -128, -112, -108, -104, | 1322 {-1020, -948, -796, -696, -612, -364, -320, -308, -128, -112, -108, -104, |
| 1277 -96, -84, -80, -56, -48, -40, -20, 0, 24, 28, 36, 48, 64, 84, 96, 100, | 1323 -96, -84, -80, -56, -48, -40, -20, 0, 24, 28, 36, 48, 64, 84, 96, 100, |
| 1278 108, 116, 120, 140, 156, 408, 432, 444, 772, 832, 940, 1020}}}; | 1324 108, 116, 120, 140, 156, 408, 432, 444, 772, 832, 940, 1020}}}; |
| 1279 | 1325 |
| 1280 } // namespace | 1326 } // namespace |
| 1281 | 1327 |
| 1282 | 1328 |
| 1283 typedef InstructionSelectorTestWithParam<MemoryAccess> | 1329 typedef InstructionSelectorTestWithParam<MemoryAccess> |
| 1284 InstructionSelectorMemoryAccessTest; | 1330 InstructionSelectorMemoryAccessTest; |
| 1285 | 1331 |
| 1286 | 1332 |
| 1287 TEST_P(InstructionSelectorMemoryAccessTest, LoadWithParameters) { | 1333 TEST_P(InstructionSelectorMemoryAccessTest, LoadWithParameters) { |
| 1288 const MemoryAccess memacc = GetParam(); | 1334 const MemoryAccess memacc = GetParam(); |
| 1289 StreamBuilder m(this, memacc.type, kMachPtr, kMachInt32); | 1335 StreamBuilder m(this, memacc.type, MachineType::Pointer(), |
| 1336 MachineType::Int32()); |
| 1290 m.Return(m.Load(memacc.type, m.Parameter(0), m.Parameter(1))); | 1337 m.Return(m.Load(memacc.type, m.Parameter(0), m.Parameter(1))); |
| 1291 Stream s = m.Build(); | 1338 Stream s = m.Build(); |
| 1292 ASSERT_EQ(1U, s.size()); | 1339 ASSERT_EQ(1U, s.size()); |
| 1293 EXPECT_EQ(memacc.ldr_opcode, s[0]->arch_opcode()); | 1340 EXPECT_EQ(memacc.ldr_opcode, s[0]->arch_opcode()); |
| 1294 EXPECT_EQ(kMode_Offset_RR, s[0]->addressing_mode()); | 1341 EXPECT_EQ(kMode_Offset_RR, s[0]->addressing_mode()); |
| 1295 EXPECT_EQ(2U, s[0]->InputCount()); | 1342 EXPECT_EQ(2U, s[0]->InputCount()); |
| 1296 ASSERT_EQ(1U, s[0]->OutputCount()); | 1343 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 1297 EXPECT_TRUE((s.*memacc.val_predicate)(s[0]->Output())); | 1344 EXPECT_TRUE((s.*memacc.val_predicate)(s[0]->Output())); |
| 1298 } | 1345 } |
| 1299 | 1346 |
| 1300 | 1347 |
| 1301 TEST_P(InstructionSelectorMemoryAccessTest, LoadWithImmediateIndex) { | 1348 TEST_P(InstructionSelectorMemoryAccessTest, LoadWithImmediateIndex) { |
| 1302 const MemoryAccess memacc = GetParam(); | 1349 const MemoryAccess memacc = GetParam(); |
| 1303 TRACED_FOREACH(int32_t, index, memacc.immediates) { | 1350 TRACED_FOREACH(int32_t, index, memacc.immediates) { |
| 1304 StreamBuilder m(this, memacc.type, kMachPtr); | 1351 StreamBuilder m(this, memacc.type, MachineType::Pointer()); |
| 1305 m.Return(m.Load(memacc.type, m.Parameter(0), m.Int32Constant(index))); | 1352 m.Return(m.Load(memacc.type, m.Parameter(0), m.Int32Constant(index))); |
| 1306 Stream s = m.Build(); | 1353 Stream s = m.Build(); |
| 1307 ASSERT_EQ(1U, s.size()); | 1354 ASSERT_EQ(1U, s.size()); |
| 1308 EXPECT_EQ(memacc.ldr_opcode, s[0]->arch_opcode()); | 1355 EXPECT_EQ(memacc.ldr_opcode, s[0]->arch_opcode()); |
| 1309 EXPECT_EQ(kMode_Offset_RI, s[0]->addressing_mode()); | 1356 EXPECT_EQ(kMode_Offset_RI, s[0]->addressing_mode()); |
| 1310 ASSERT_EQ(2U, s[0]->InputCount()); | 1357 ASSERT_EQ(2U, s[0]->InputCount()); |
| 1311 ASSERT_EQ(InstructionOperand::IMMEDIATE, s[0]->InputAt(1)->kind()); | 1358 ASSERT_EQ(InstructionOperand::IMMEDIATE, s[0]->InputAt(1)->kind()); |
| 1312 EXPECT_EQ(index, s.ToInt32(s[0]->InputAt(1))); | 1359 EXPECT_EQ(index, s.ToInt32(s[0]->InputAt(1))); |
| 1313 ASSERT_EQ(1U, s[0]->OutputCount()); | 1360 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 1314 EXPECT_TRUE((s.*memacc.val_predicate)(s[0]->Output())); | 1361 EXPECT_TRUE((s.*memacc.val_predicate)(s[0]->Output())); |
| 1315 } | 1362 } |
| 1316 } | 1363 } |
| 1317 | 1364 |
| 1318 | 1365 |
| 1319 TEST_P(InstructionSelectorMemoryAccessTest, StoreWithParameters) { | 1366 TEST_P(InstructionSelectorMemoryAccessTest, StoreWithParameters) { |
| 1320 const MemoryAccess memacc = GetParam(); | 1367 const MemoryAccess memacc = GetParam(); |
| 1321 StreamBuilder m(this, kMachInt32, kMachPtr, kMachInt32, memacc.type); | 1368 StreamBuilder m(this, MachineType::Int32(), MachineType::Pointer(), |
| 1369 MachineType::Int32(), memacc.type); |
| 1322 m.Store(memacc.type, m.Parameter(0), m.Parameter(1), m.Parameter(2), | 1370 m.Store(memacc.type, m.Parameter(0), m.Parameter(1), m.Parameter(2), |
| 1323 kNoWriteBarrier); | 1371 kNoWriteBarrier); |
| 1324 m.Return(m.Int32Constant(0)); | 1372 m.Return(m.Int32Constant(0)); |
| 1325 Stream s = m.Build(); | 1373 Stream s = m.Build(); |
| 1326 ASSERT_EQ(1U, s.size()); | 1374 ASSERT_EQ(1U, s.size()); |
| 1327 EXPECT_EQ(memacc.str_opcode, s[0]->arch_opcode()); | 1375 EXPECT_EQ(memacc.str_opcode, s[0]->arch_opcode()); |
| 1328 EXPECT_EQ(kMode_Offset_RR, s[0]->addressing_mode()); | 1376 EXPECT_EQ(kMode_Offset_RR, s[0]->addressing_mode()); |
| 1329 EXPECT_EQ(3U, s[0]->InputCount()); | 1377 EXPECT_EQ(3U, s[0]->InputCount()); |
| 1330 EXPECT_EQ(0U, s[0]->OutputCount()); | 1378 EXPECT_EQ(0U, s[0]->OutputCount()); |
| 1331 } | 1379 } |
| 1332 | 1380 |
| 1333 | 1381 |
| 1334 TEST_P(InstructionSelectorMemoryAccessTest, StoreWithImmediateIndex) { | 1382 TEST_P(InstructionSelectorMemoryAccessTest, StoreWithImmediateIndex) { |
| 1335 const MemoryAccess memacc = GetParam(); | 1383 const MemoryAccess memacc = GetParam(); |
| 1336 TRACED_FOREACH(int32_t, index, memacc.immediates) { | 1384 TRACED_FOREACH(int32_t, index, memacc.immediates) { |
| 1337 StreamBuilder m(this, kMachInt32, kMachPtr, memacc.type); | 1385 StreamBuilder m(this, MachineType::Int32(), MachineType::Pointer(), |
| 1386 memacc.type); |
| 1338 m.Store(memacc.type, m.Parameter(0), m.Int32Constant(index), m.Parameter(1), | 1387 m.Store(memacc.type, m.Parameter(0), m.Int32Constant(index), m.Parameter(1), |
| 1339 kNoWriteBarrier); | 1388 kNoWriteBarrier); |
| 1340 m.Return(m.Int32Constant(0)); | 1389 m.Return(m.Int32Constant(0)); |
| 1341 Stream s = m.Build(); | 1390 Stream s = m.Build(); |
| 1342 ASSERT_EQ(1U, s.size()); | 1391 ASSERT_EQ(1U, s.size()); |
| 1343 EXPECT_EQ(memacc.str_opcode, s[0]->arch_opcode()); | 1392 EXPECT_EQ(memacc.str_opcode, s[0]->arch_opcode()); |
| 1344 EXPECT_EQ(kMode_Offset_RI, s[0]->addressing_mode()); | 1393 EXPECT_EQ(kMode_Offset_RI, s[0]->addressing_mode()); |
| 1345 ASSERT_EQ(3U, s[0]->InputCount()); | 1394 ASSERT_EQ(3U, s[0]->InputCount()); |
| 1346 ASSERT_EQ(InstructionOperand::IMMEDIATE, s[0]->InputAt(1)->kind()); | 1395 ASSERT_EQ(InstructionOperand::IMMEDIATE, s[0]->InputAt(1)->kind()); |
| 1347 EXPECT_EQ(index, s.ToInt32(s[0]->InputAt(1))); | 1396 EXPECT_EQ(index, s.ToInt32(s[0]->InputAt(1))); |
| 1348 EXPECT_EQ(0U, s[0]->OutputCount()); | 1397 EXPECT_EQ(0U, s[0]->OutputCount()); |
| 1349 } | 1398 } |
| 1350 } | 1399 } |
| 1351 | 1400 |
| 1352 | 1401 |
| 1353 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, | 1402 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, |
| 1354 InstructionSelectorMemoryAccessTest, | 1403 InstructionSelectorMemoryAccessTest, |
| 1355 ::testing::ValuesIn(kMemoryAccesses)); | 1404 ::testing::ValuesIn(kMemoryAccesses)); |
| 1356 | 1405 |
| 1357 | 1406 |
| 1358 // ----------------------------------------------------------------------------- | 1407 // ----------------------------------------------------------------------------- |
| 1359 // Conversions. | 1408 // Conversions. |
| 1360 | 1409 |
| 1361 | 1410 |
| 1362 TEST_F(InstructionSelectorTest, ChangeFloat32ToFloat64WithParameter) { | 1411 TEST_F(InstructionSelectorTest, ChangeFloat32ToFloat64WithParameter) { |
| 1363 StreamBuilder m(this, kMachFloat64, kMachFloat32); | 1412 StreamBuilder m(this, MachineType::Float64(), MachineType::Float32()); |
| 1364 m.Return(m.ChangeFloat32ToFloat64(m.Parameter(0))); | 1413 m.Return(m.ChangeFloat32ToFloat64(m.Parameter(0))); |
| 1365 Stream s = m.Build(); | 1414 Stream s = m.Build(); |
| 1366 ASSERT_EQ(1U, s.size()); | 1415 ASSERT_EQ(1U, s.size()); |
| 1367 EXPECT_EQ(kArmVcvtF64F32, s[0]->arch_opcode()); | 1416 EXPECT_EQ(kArmVcvtF64F32, s[0]->arch_opcode()); |
| 1368 EXPECT_EQ(1U, s[0]->InputCount()); | 1417 EXPECT_EQ(1U, s[0]->InputCount()); |
| 1369 EXPECT_EQ(1U, s[0]->OutputCount()); | 1418 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 1370 } | 1419 } |
| 1371 | 1420 |
| 1372 | 1421 |
| 1373 TEST_F(InstructionSelectorTest, TruncateFloat64ToFloat32WithParameter) { | 1422 TEST_F(InstructionSelectorTest, TruncateFloat64ToFloat32WithParameter) { |
| 1374 StreamBuilder m(this, kMachFloat32, kMachFloat64); | 1423 StreamBuilder m(this, MachineType::Float32(), MachineType::Float64()); |
| 1375 m.Return(m.TruncateFloat64ToFloat32(m.Parameter(0))); | 1424 m.Return(m.TruncateFloat64ToFloat32(m.Parameter(0))); |
| 1376 Stream s = m.Build(); | 1425 Stream s = m.Build(); |
| 1377 ASSERT_EQ(1U, s.size()); | 1426 ASSERT_EQ(1U, s.size()); |
| 1378 EXPECT_EQ(kArmVcvtF32F64, s[0]->arch_opcode()); | 1427 EXPECT_EQ(kArmVcvtF32F64, s[0]->arch_opcode()); |
| 1379 EXPECT_EQ(1U, s[0]->InputCount()); | 1428 EXPECT_EQ(1U, s[0]->InputCount()); |
| 1380 EXPECT_EQ(1U, s[0]->OutputCount()); | 1429 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 1381 } | 1430 } |
| 1382 | 1431 |
| 1383 | 1432 |
| 1384 // ----------------------------------------------------------------------------- | 1433 // ----------------------------------------------------------------------------- |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1416 | 1465 |
| 1417 } // namespace | 1466 } // namespace |
| 1418 | 1467 |
| 1419 | 1468 |
| 1420 typedef InstructionSelectorTestWithParam<Comparison> | 1469 typedef InstructionSelectorTestWithParam<Comparison> |
| 1421 InstructionSelectorComparisonTest; | 1470 InstructionSelectorComparisonTest; |
| 1422 | 1471 |
| 1423 | 1472 |
| 1424 TEST_P(InstructionSelectorComparisonTest, Parameters) { | 1473 TEST_P(InstructionSelectorComparisonTest, Parameters) { |
| 1425 const Comparison& cmp = GetParam(); | 1474 const Comparison& cmp = GetParam(); |
| 1426 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); | 1475 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 1476 MachineType::Int32()); |
| 1427 Node* const p0 = m.Parameter(0); | 1477 Node* const p0 = m.Parameter(0); |
| 1428 Node* const p1 = m.Parameter(1); | 1478 Node* const p1 = m.Parameter(1); |
| 1429 Node* const r = (m.*cmp.constructor)(p0, p1); | 1479 Node* const r = (m.*cmp.constructor)(p0, p1); |
| 1430 m.Return(r); | 1480 m.Return(r); |
| 1431 Stream const s = m.Build(); | 1481 Stream const s = m.Build(); |
| 1432 ASSERT_EQ(1U, s.size()); | 1482 ASSERT_EQ(1U, s.size()); |
| 1433 EXPECT_EQ(kArmCmp, s[0]->arch_opcode()); | 1483 EXPECT_EQ(kArmCmp, s[0]->arch_opcode()); |
| 1434 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); | 1484 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); |
| 1435 ASSERT_EQ(2U, s[0]->InputCount()); | 1485 ASSERT_EQ(2U, s[0]->InputCount()); |
| 1436 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); | 1486 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
| 1437 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1))); | 1487 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1))); |
| 1438 ASSERT_EQ(1U, s[0]->OutputCount()); | 1488 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 1439 EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->OutputAt(0))); | 1489 EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->OutputAt(0))); |
| 1440 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 1490 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 1441 EXPECT_EQ(cmp.flags_condition, s[0]->flags_condition()); | 1491 EXPECT_EQ(cmp.flags_condition, s[0]->flags_condition()); |
| 1442 } | 1492 } |
| 1443 | 1493 |
| 1444 | 1494 |
| 1445 TEST_P(InstructionSelectorComparisonTest, Word32EqualWithZero) { | 1495 TEST_P(InstructionSelectorComparisonTest, Word32EqualWithZero) { |
| 1446 { | 1496 { |
| 1447 const Comparison& cmp = GetParam(); | 1497 const Comparison& cmp = GetParam(); |
| 1448 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); | 1498 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 1499 MachineType::Int32()); |
| 1449 Node* const p0 = m.Parameter(0); | 1500 Node* const p0 = m.Parameter(0); |
| 1450 Node* const p1 = m.Parameter(1); | 1501 Node* const p1 = m.Parameter(1); |
| 1451 Node* const r = | 1502 Node* const r = |
| 1452 m.Word32Equal((m.*cmp.constructor)(p0, p1), m.Int32Constant(0)); | 1503 m.Word32Equal((m.*cmp.constructor)(p0, p1), m.Int32Constant(0)); |
| 1453 m.Return(r); | 1504 m.Return(r); |
| 1454 Stream const s = m.Build(); | 1505 Stream const s = m.Build(); |
| 1455 ASSERT_EQ(1U, s.size()); | 1506 ASSERT_EQ(1U, s.size()); |
| 1456 EXPECT_EQ(kArmCmp, s[0]->arch_opcode()); | 1507 EXPECT_EQ(kArmCmp, s[0]->arch_opcode()); |
| 1457 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); | 1508 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); |
| 1458 ASSERT_EQ(2U, s[0]->InputCount()); | 1509 ASSERT_EQ(2U, s[0]->InputCount()); |
| 1459 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); | 1510 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
| 1460 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1))); | 1511 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1))); |
| 1461 ASSERT_EQ(1U, s[0]->OutputCount()); | 1512 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 1462 EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->OutputAt(0))); | 1513 EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->OutputAt(0))); |
| 1463 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 1514 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 1464 EXPECT_EQ(cmp.negated_flags_condition, s[0]->flags_condition()); | 1515 EXPECT_EQ(cmp.negated_flags_condition, s[0]->flags_condition()); |
| 1465 } | 1516 } |
| 1466 { | 1517 { |
| 1467 const Comparison& cmp = GetParam(); | 1518 const Comparison& cmp = GetParam(); |
| 1468 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); | 1519 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 1520 MachineType::Int32()); |
| 1469 Node* const p0 = m.Parameter(0); | 1521 Node* const p0 = m.Parameter(0); |
| 1470 Node* const p1 = m.Parameter(1); | 1522 Node* const p1 = m.Parameter(1); |
| 1471 Node* const r = | 1523 Node* const r = |
| 1472 m.Word32Equal(m.Int32Constant(0), (m.*cmp.constructor)(p0, p1)); | 1524 m.Word32Equal(m.Int32Constant(0), (m.*cmp.constructor)(p0, p1)); |
| 1473 m.Return(r); | 1525 m.Return(r); |
| 1474 Stream const s = m.Build(); | 1526 Stream const s = m.Build(); |
| 1475 ASSERT_EQ(1U, s.size()); | 1527 ASSERT_EQ(1U, s.size()); |
| 1476 EXPECT_EQ(kArmCmp, s[0]->arch_opcode()); | 1528 EXPECT_EQ(kArmCmp, s[0]->arch_opcode()); |
| 1477 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); | 1529 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); |
| 1478 ASSERT_EQ(2U, s[0]->InputCount()); | 1530 ASSERT_EQ(2U, s[0]->InputCount()); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1507 kFloatGreaterThanOrEqual}}; | 1559 kFloatGreaterThanOrEqual}}; |
| 1508 | 1560 |
| 1509 } // namespace | 1561 } // namespace |
| 1510 | 1562 |
| 1511 typedef InstructionSelectorTestWithParam<Comparison> | 1563 typedef InstructionSelectorTestWithParam<Comparison> |
| 1512 InstructionSelectorF32ComparisonTest; | 1564 InstructionSelectorF32ComparisonTest; |
| 1513 | 1565 |
| 1514 | 1566 |
| 1515 TEST_P(InstructionSelectorF32ComparisonTest, WithParameters) { | 1567 TEST_P(InstructionSelectorF32ComparisonTest, WithParameters) { |
| 1516 const Comparison& cmp = GetParam(); | 1568 const Comparison& cmp = GetParam(); |
| 1517 StreamBuilder m(this, kMachInt32, kMachFloat32, kMachFloat32); | 1569 StreamBuilder m(this, MachineType::Int32(), MachineType::Float32(), |
| 1570 MachineType::Float32()); |
| 1518 m.Return((m.*cmp.constructor)(m.Parameter(0), m.Parameter(1))); | 1571 m.Return((m.*cmp.constructor)(m.Parameter(0), m.Parameter(1))); |
| 1519 Stream const s = m.Build(); | 1572 Stream const s = m.Build(); |
| 1520 ASSERT_EQ(1U, s.size()); | 1573 ASSERT_EQ(1U, s.size()); |
| 1521 EXPECT_EQ(kArmVcmpF32, s[0]->arch_opcode()); | 1574 EXPECT_EQ(kArmVcmpF32, s[0]->arch_opcode()); |
| 1522 ASSERT_EQ(2U, s[0]->InputCount()); | 1575 ASSERT_EQ(2U, s[0]->InputCount()); |
| 1523 ASSERT_EQ(1U, s[0]->OutputCount()); | 1576 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 1524 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 1577 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 1525 EXPECT_EQ(cmp.flags_condition, s[0]->flags_condition()); | 1578 EXPECT_EQ(cmp.flags_condition, s[0]->flags_condition()); |
| 1526 } | 1579 } |
| 1527 | 1580 |
| 1528 | 1581 |
| 1529 TEST_P(InstructionSelectorF32ComparisonTest, NegatedWithParameters) { | 1582 TEST_P(InstructionSelectorF32ComparisonTest, NegatedWithParameters) { |
| 1530 const Comparison& cmp = GetParam(); | 1583 const Comparison& cmp = GetParam(); |
| 1531 StreamBuilder m(this, kMachInt32, kMachFloat32, kMachFloat32); | 1584 StreamBuilder m(this, MachineType::Int32(), MachineType::Float32(), |
| 1585 MachineType::Float32()); |
| 1532 m.Return( | 1586 m.Return( |
| 1533 m.WordBinaryNot((m.*cmp.constructor)(m.Parameter(0), m.Parameter(1)))); | 1587 m.WordBinaryNot((m.*cmp.constructor)(m.Parameter(0), m.Parameter(1)))); |
| 1534 Stream const s = m.Build(); | 1588 Stream const s = m.Build(); |
| 1535 ASSERT_EQ(1U, s.size()); | 1589 ASSERT_EQ(1U, s.size()); |
| 1536 EXPECT_EQ(kArmVcmpF32, s[0]->arch_opcode()); | 1590 EXPECT_EQ(kArmVcmpF32, s[0]->arch_opcode()); |
| 1537 ASSERT_EQ(2U, s[0]->InputCount()); | 1591 ASSERT_EQ(2U, s[0]->InputCount()); |
| 1538 ASSERT_EQ(1U, s[0]->OutputCount()); | 1592 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 1539 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 1593 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 1540 EXPECT_EQ(cmp.negated_flags_condition, s[0]->flags_condition()); | 1594 EXPECT_EQ(cmp.negated_flags_condition, s[0]->flags_condition()); |
| 1541 } | 1595 } |
| 1542 | 1596 |
| 1543 | 1597 |
| 1544 TEST_P(InstructionSelectorF32ComparisonTest, WithImmediateZeroOnRight) { | 1598 TEST_P(InstructionSelectorF32ComparisonTest, WithImmediateZeroOnRight) { |
| 1545 const Comparison& cmp = GetParam(); | 1599 const Comparison& cmp = GetParam(); |
| 1546 StreamBuilder m(this, kMachInt32, kMachFloat32); | 1600 StreamBuilder m(this, MachineType::Int32(), MachineType::Float32()); |
| 1547 m.Return((m.*cmp.constructor)(m.Parameter(0), m.Float32Constant(0.0))); | 1601 m.Return((m.*cmp.constructor)(m.Parameter(0), m.Float32Constant(0.0))); |
| 1548 Stream const s = m.Build(); | 1602 Stream const s = m.Build(); |
| 1549 ASSERT_EQ(1U, s.size()); | 1603 ASSERT_EQ(1U, s.size()); |
| 1550 EXPECT_EQ(kArmVcmpF32, s[0]->arch_opcode()); | 1604 EXPECT_EQ(kArmVcmpF32, s[0]->arch_opcode()); |
| 1551 ASSERT_EQ(2U, s[0]->InputCount()); | 1605 ASSERT_EQ(2U, s[0]->InputCount()); |
| 1552 EXPECT_TRUE(s[0]->InputAt(1)->IsImmediate()); | 1606 EXPECT_TRUE(s[0]->InputAt(1)->IsImmediate()); |
| 1553 ASSERT_EQ(1U, s[0]->OutputCount()); | 1607 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 1554 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 1608 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 1555 EXPECT_EQ(cmp.flags_condition, s[0]->flags_condition()); | 1609 EXPECT_EQ(cmp.flags_condition, s[0]->flags_condition()); |
| 1556 } | 1610 } |
| 1557 | 1611 |
| 1558 | 1612 |
| 1559 TEST_P(InstructionSelectorF32ComparisonTest, WithImmediateZeroOnLeft) { | 1613 TEST_P(InstructionSelectorF32ComparisonTest, WithImmediateZeroOnLeft) { |
| 1560 const Comparison& cmp = GetParam(); | 1614 const Comparison& cmp = GetParam(); |
| 1561 StreamBuilder m(this, kMachInt32, kMachFloat32); | 1615 StreamBuilder m(this, MachineType::Int32(), MachineType::Float32()); |
| 1562 m.Return((m.*cmp.constructor)(m.Float32Constant(0.0f), m.Parameter(0))); | 1616 m.Return((m.*cmp.constructor)(m.Float32Constant(0.0f), m.Parameter(0))); |
| 1563 Stream const s = m.Build(); | 1617 Stream const s = m.Build(); |
| 1564 ASSERT_EQ(1U, s.size()); | 1618 ASSERT_EQ(1U, s.size()); |
| 1565 EXPECT_EQ(kArmVcmpF32, s[0]->arch_opcode()); | 1619 EXPECT_EQ(kArmVcmpF32, s[0]->arch_opcode()); |
| 1566 ASSERT_EQ(2U, s[0]->InputCount()); | 1620 ASSERT_EQ(2U, s[0]->InputCount()); |
| 1567 EXPECT_TRUE(s[0]->InputAt(1)->IsImmediate()); | 1621 EXPECT_TRUE(s[0]->InputAt(1)->IsImmediate()); |
| 1568 ASSERT_EQ(1U, s[0]->OutputCount()); | 1622 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 1569 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 1623 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 1570 EXPECT_EQ(cmp.commuted_flags_condition, s[0]->flags_condition()); | 1624 EXPECT_EQ(cmp.commuted_flags_condition, s[0]->flags_condition()); |
| 1571 } | 1625 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1588 kFloatGreaterThanOrEqual}}; | 1642 kFloatGreaterThanOrEqual}}; |
| 1589 | 1643 |
| 1590 } // namespace | 1644 } // namespace |
| 1591 | 1645 |
| 1592 typedef InstructionSelectorTestWithParam<Comparison> | 1646 typedef InstructionSelectorTestWithParam<Comparison> |
| 1593 InstructionSelectorF64ComparisonTest; | 1647 InstructionSelectorF64ComparisonTest; |
| 1594 | 1648 |
| 1595 | 1649 |
| 1596 TEST_P(InstructionSelectorF64ComparisonTest, WithParameters) { | 1650 TEST_P(InstructionSelectorF64ComparisonTest, WithParameters) { |
| 1597 const Comparison& cmp = GetParam(); | 1651 const Comparison& cmp = GetParam(); |
| 1598 StreamBuilder m(this, kMachInt32, kMachFloat64, kMachFloat64); | 1652 StreamBuilder m(this, MachineType::Int32(), MachineType::Float64(), |
| 1653 MachineType::Float64()); |
| 1599 m.Return((m.*cmp.constructor)(m.Parameter(0), m.Parameter(1))); | 1654 m.Return((m.*cmp.constructor)(m.Parameter(0), m.Parameter(1))); |
| 1600 Stream const s = m.Build(); | 1655 Stream const s = m.Build(); |
| 1601 ASSERT_EQ(1U, s.size()); | 1656 ASSERT_EQ(1U, s.size()); |
| 1602 EXPECT_EQ(kArmVcmpF64, s[0]->arch_opcode()); | 1657 EXPECT_EQ(kArmVcmpF64, s[0]->arch_opcode()); |
| 1603 ASSERT_EQ(2U, s[0]->InputCount()); | 1658 ASSERT_EQ(2U, s[0]->InputCount()); |
| 1604 ASSERT_EQ(1U, s[0]->OutputCount()); | 1659 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 1605 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 1660 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 1606 EXPECT_EQ(cmp.flags_condition, s[0]->flags_condition()); | 1661 EXPECT_EQ(cmp.flags_condition, s[0]->flags_condition()); |
| 1607 } | 1662 } |
| 1608 | 1663 |
| 1609 | 1664 |
| 1610 TEST_P(InstructionSelectorF64ComparisonTest, NegatedWithParameters) { | 1665 TEST_P(InstructionSelectorF64ComparisonTest, NegatedWithParameters) { |
| 1611 const Comparison& cmp = GetParam(); | 1666 const Comparison& cmp = GetParam(); |
| 1612 StreamBuilder m(this, kMachInt32, kMachFloat64, kMachFloat64); | 1667 StreamBuilder m(this, MachineType::Int32(), MachineType::Float64(), |
| 1668 MachineType::Float64()); |
| 1613 m.Return( | 1669 m.Return( |
| 1614 m.WordBinaryNot((m.*cmp.constructor)(m.Parameter(0), m.Parameter(1)))); | 1670 m.WordBinaryNot((m.*cmp.constructor)(m.Parameter(0), m.Parameter(1)))); |
| 1615 Stream const s = m.Build(); | 1671 Stream const s = m.Build(); |
| 1616 ASSERT_EQ(1U, s.size()); | 1672 ASSERT_EQ(1U, s.size()); |
| 1617 EXPECT_EQ(kArmVcmpF64, s[0]->arch_opcode()); | 1673 EXPECT_EQ(kArmVcmpF64, s[0]->arch_opcode()); |
| 1618 ASSERT_EQ(2U, s[0]->InputCount()); | 1674 ASSERT_EQ(2U, s[0]->InputCount()); |
| 1619 ASSERT_EQ(1U, s[0]->OutputCount()); | 1675 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 1620 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 1676 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 1621 EXPECT_EQ(cmp.negated_flags_condition, s[0]->flags_condition()); | 1677 EXPECT_EQ(cmp.negated_flags_condition, s[0]->flags_condition()); |
| 1622 } | 1678 } |
| 1623 | 1679 |
| 1624 | 1680 |
| 1625 TEST_P(InstructionSelectorF64ComparisonTest, WithImmediateZeroOnRight) { | 1681 TEST_P(InstructionSelectorF64ComparisonTest, WithImmediateZeroOnRight) { |
| 1626 const Comparison& cmp = GetParam(); | 1682 const Comparison& cmp = GetParam(); |
| 1627 StreamBuilder m(this, kMachInt32, kMachFloat64); | 1683 StreamBuilder m(this, MachineType::Int32(), MachineType::Float64()); |
| 1628 m.Return((m.*cmp.constructor)(m.Parameter(0), m.Float64Constant(0.0))); | 1684 m.Return((m.*cmp.constructor)(m.Parameter(0), m.Float64Constant(0.0))); |
| 1629 Stream const s = m.Build(); | 1685 Stream const s = m.Build(); |
| 1630 ASSERT_EQ(1U, s.size()); | 1686 ASSERT_EQ(1U, s.size()); |
| 1631 EXPECT_EQ(kArmVcmpF64, s[0]->arch_opcode()); | 1687 EXPECT_EQ(kArmVcmpF64, s[0]->arch_opcode()); |
| 1632 ASSERT_EQ(2U, s[0]->InputCount()); | 1688 ASSERT_EQ(2U, s[0]->InputCount()); |
| 1633 EXPECT_TRUE(s[0]->InputAt(1)->IsImmediate()); | 1689 EXPECT_TRUE(s[0]->InputAt(1)->IsImmediate()); |
| 1634 ASSERT_EQ(1U, s[0]->OutputCount()); | 1690 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 1635 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 1691 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 1636 EXPECT_EQ(cmp.flags_condition, s[0]->flags_condition()); | 1692 EXPECT_EQ(cmp.flags_condition, s[0]->flags_condition()); |
| 1637 } | 1693 } |
| 1638 | 1694 |
| 1639 | 1695 |
| 1640 TEST_P(InstructionSelectorF64ComparisonTest, WithImmediateZeroOnLeft) { | 1696 TEST_P(InstructionSelectorF64ComparisonTest, WithImmediateZeroOnLeft) { |
| 1641 const Comparison& cmp = GetParam(); | 1697 const Comparison& cmp = GetParam(); |
| 1642 StreamBuilder m(this, kMachInt32, kMachFloat64); | 1698 StreamBuilder m(this, MachineType::Int32(), MachineType::Float64()); |
| 1643 m.Return((m.*cmp.constructor)(m.Float64Constant(0.0), m.Parameter(0))); | 1699 m.Return((m.*cmp.constructor)(m.Float64Constant(0.0), m.Parameter(0))); |
| 1644 Stream const s = m.Build(); | 1700 Stream const s = m.Build(); |
| 1645 ASSERT_EQ(1U, s.size()); | 1701 ASSERT_EQ(1U, s.size()); |
| 1646 EXPECT_EQ(kArmVcmpF64, s[0]->arch_opcode()); | 1702 EXPECT_EQ(kArmVcmpF64, s[0]->arch_opcode()); |
| 1647 ASSERT_EQ(2U, s[0]->InputCount()); | 1703 ASSERT_EQ(2U, s[0]->InputCount()); |
| 1648 EXPECT_TRUE(s[0]->InputAt(1)->IsImmediate()); | 1704 EXPECT_TRUE(s[0]->InputAt(1)->IsImmediate()); |
| 1649 ASSERT_EQ(1U, s[0]->OutputCount()); | 1705 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 1650 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 1706 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 1651 EXPECT_EQ(cmp.commuted_flags_condition, s[0]->flags_condition()); | 1707 EXPECT_EQ(cmp.commuted_flags_condition, s[0]->flags_condition()); |
| 1652 } | 1708 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1682 EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->OutputAt(0))); | 1738 EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->OutputAt(0))); |
| 1683 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); | 1739 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); |
| 1684 } | 1740 } |
| 1685 | 1741 |
| 1686 | 1742 |
| 1687 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, InstructionSelectorFAITest, | 1743 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, InstructionSelectorFAITest, |
| 1688 ::testing::ValuesIn(kFAIs)); | 1744 ::testing::ValuesIn(kFAIs)); |
| 1689 | 1745 |
| 1690 | 1746 |
| 1691 TEST_F(InstructionSelectorTest, Float32Abs) { | 1747 TEST_F(InstructionSelectorTest, Float32Abs) { |
| 1692 StreamBuilder m(this, kMachFloat32, kMachFloat32); | 1748 StreamBuilder m(this, MachineType::Float32(), MachineType::Float32()); |
| 1693 Node* const p0 = m.Parameter(0); | 1749 Node* const p0 = m.Parameter(0); |
| 1694 Node* const n = m.Float32Abs(p0); | 1750 Node* const n = m.Float32Abs(p0); |
| 1695 m.Return(n); | 1751 m.Return(n); |
| 1696 Stream s = m.Build(); | 1752 Stream s = m.Build(); |
| 1697 ASSERT_EQ(1U, s.size()); | 1753 ASSERT_EQ(1U, s.size()); |
| 1698 EXPECT_EQ(kArmVabsF32, s[0]->arch_opcode()); | 1754 EXPECT_EQ(kArmVabsF32, s[0]->arch_opcode()); |
| 1699 ASSERT_EQ(1U, s[0]->InputCount()); | 1755 ASSERT_EQ(1U, s[0]->InputCount()); |
| 1700 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); | 1756 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
| 1701 ASSERT_EQ(1U, s[0]->OutputCount()); | 1757 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 1702 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | 1758 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
| 1703 } | 1759 } |
| 1704 | 1760 |
| 1705 | 1761 |
| 1706 TEST_F(InstructionSelectorTest, Float64Abs) { | 1762 TEST_F(InstructionSelectorTest, Float64Abs) { |
| 1707 StreamBuilder m(this, kMachFloat64, kMachFloat64); | 1763 StreamBuilder m(this, MachineType::Float64(), MachineType::Float64()); |
| 1708 Node* const p0 = m.Parameter(0); | 1764 Node* const p0 = m.Parameter(0); |
| 1709 Node* const n = m.Float64Abs(p0); | 1765 Node* const n = m.Float64Abs(p0); |
| 1710 m.Return(n); | 1766 m.Return(n); |
| 1711 Stream s = m.Build(); | 1767 Stream s = m.Build(); |
| 1712 ASSERT_EQ(1U, s.size()); | 1768 ASSERT_EQ(1U, s.size()); |
| 1713 EXPECT_EQ(kArmVabsF64, s[0]->arch_opcode()); | 1769 EXPECT_EQ(kArmVabsF64, s[0]->arch_opcode()); |
| 1714 ASSERT_EQ(1U, s[0]->InputCount()); | 1770 ASSERT_EQ(1U, s[0]->InputCount()); |
| 1715 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); | 1771 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
| 1716 ASSERT_EQ(1U, s[0]->OutputCount()); | 1772 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 1717 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | 1773 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
| 1718 } | 1774 } |
| 1719 | 1775 |
| 1720 | 1776 |
| 1721 TEST_F(InstructionSelectorTest, Float32AddWithFloat32Mul) { | 1777 TEST_F(InstructionSelectorTest, Float32AddWithFloat32Mul) { |
| 1722 { | 1778 { |
| 1723 StreamBuilder m(this, kMachFloat32, kMachFloat32, kMachFloat32, | 1779 StreamBuilder m(this, MachineType::Float32(), MachineType::Float32(), |
| 1724 kMachFloat32); | 1780 MachineType::Float32(), MachineType::Float32()); |
| 1725 Node* const p0 = m.Parameter(0); | 1781 Node* const p0 = m.Parameter(0); |
| 1726 Node* const p1 = m.Parameter(1); | 1782 Node* const p1 = m.Parameter(1); |
| 1727 Node* const p2 = m.Parameter(2); | 1783 Node* const p2 = m.Parameter(2); |
| 1728 Node* const n = m.Float32Add(m.Float32Mul(p0, p1), p2); | 1784 Node* const n = m.Float32Add(m.Float32Mul(p0, p1), p2); |
| 1729 m.Return(n); | 1785 m.Return(n); |
| 1730 Stream s = m.Build(); | 1786 Stream s = m.Build(); |
| 1731 ASSERT_EQ(1U, s.size()); | 1787 ASSERT_EQ(1U, s.size()); |
| 1732 EXPECT_EQ(kArmVmlaF32, s[0]->arch_opcode()); | 1788 EXPECT_EQ(kArmVmlaF32, s[0]->arch_opcode()); |
| 1733 ASSERT_EQ(3U, s[0]->InputCount()); | 1789 ASSERT_EQ(3U, s[0]->InputCount()); |
| 1734 EXPECT_EQ(s.ToVreg(p2), s.ToVreg(s[0]->InputAt(0))); | 1790 EXPECT_EQ(s.ToVreg(p2), s.ToVreg(s[0]->InputAt(0))); |
| 1735 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(1))); | 1791 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(1))); |
| 1736 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(2))); | 1792 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(2))); |
| 1737 ASSERT_EQ(1U, s[0]->OutputCount()); | 1793 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 1738 EXPECT_TRUE( | 1794 EXPECT_TRUE( |
| 1739 UnallocatedOperand::cast(s[0]->Output())->HasSameAsInputPolicy()); | 1795 UnallocatedOperand::cast(s[0]->Output())->HasSameAsInputPolicy()); |
| 1740 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | 1796 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
| 1741 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); | 1797 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); |
| 1742 } | 1798 } |
| 1743 { | 1799 { |
| 1744 StreamBuilder m(this, kMachFloat32, kMachFloat32, kMachFloat32, | 1800 StreamBuilder m(this, MachineType::Float32(), MachineType::Float32(), |
| 1745 kMachFloat32); | 1801 MachineType::Float32(), MachineType::Float32()); |
| 1746 Node* const p0 = m.Parameter(0); | 1802 Node* const p0 = m.Parameter(0); |
| 1747 Node* const p1 = m.Parameter(1); | 1803 Node* const p1 = m.Parameter(1); |
| 1748 Node* const p2 = m.Parameter(2); | 1804 Node* const p2 = m.Parameter(2); |
| 1749 Node* const n = m.Float32Add(p0, m.Float32Mul(p1, p2)); | 1805 Node* const n = m.Float32Add(p0, m.Float32Mul(p1, p2)); |
| 1750 m.Return(n); | 1806 m.Return(n); |
| 1751 Stream s = m.Build(); | 1807 Stream s = m.Build(); |
| 1752 ASSERT_EQ(1U, s.size()); | 1808 ASSERT_EQ(1U, s.size()); |
| 1753 EXPECT_EQ(kArmVmlaF32, s[0]->arch_opcode()); | 1809 EXPECT_EQ(kArmVmlaF32, s[0]->arch_opcode()); |
| 1754 ASSERT_EQ(3U, s[0]->InputCount()); | 1810 ASSERT_EQ(3U, s[0]->InputCount()); |
| 1755 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); | 1811 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
| 1756 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1))); | 1812 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1))); |
| 1757 EXPECT_EQ(s.ToVreg(p2), s.ToVreg(s[0]->InputAt(2))); | 1813 EXPECT_EQ(s.ToVreg(p2), s.ToVreg(s[0]->InputAt(2))); |
| 1758 ASSERT_EQ(1U, s[0]->OutputCount()); | 1814 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 1759 EXPECT_TRUE( | 1815 EXPECT_TRUE( |
| 1760 UnallocatedOperand::cast(s[0]->Output())->HasSameAsInputPolicy()); | 1816 UnallocatedOperand::cast(s[0]->Output())->HasSameAsInputPolicy()); |
| 1761 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | 1817 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
| 1762 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); | 1818 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); |
| 1763 } | 1819 } |
| 1764 } | 1820 } |
| 1765 | 1821 |
| 1766 | 1822 |
| 1767 TEST_F(InstructionSelectorTest, Float64AddWithFloat64Mul) { | 1823 TEST_F(InstructionSelectorTest, Float64AddWithFloat64Mul) { |
| 1768 { | 1824 { |
| 1769 StreamBuilder m(this, kMachFloat64, kMachFloat64, kMachFloat64, | 1825 StreamBuilder m(this, MachineType::Float64(), MachineType::Float64(), |
| 1770 kMachFloat64); | 1826 MachineType::Float64(), MachineType::Float64()); |
| 1771 Node* const p0 = m.Parameter(0); | 1827 Node* const p0 = m.Parameter(0); |
| 1772 Node* const p1 = m.Parameter(1); | 1828 Node* const p1 = m.Parameter(1); |
| 1773 Node* const p2 = m.Parameter(2); | 1829 Node* const p2 = m.Parameter(2); |
| 1774 Node* const n = m.Float64Add(m.Float64Mul(p0, p1), p2); | 1830 Node* const n = m.Float64Add(m.Float64Mul(p0, p1), p2); |
| 1775 m.Return(n); | 1831 m.Return(n); |
| 1776 Stream s = m.Build(); | 1832 Stream s = m.Build(); |
| 1777 ASSERT_EQ(1U, s.size()); | 1833 ASSERT_EQ(1U, s.size()); |
| 1778 EXPECT_EQ(kArmVmlaF64, s[0]->arch_opcode()); | 1834 EXPECT_EQ(kArmVmlaF64, s[0]->arch_opcode()); |
| 1779 ASSERT_EQ(3U, s[0]->InputCount()); | 1835 ASSERT_EQ(3U, s[0]->InputCount()); |
| 1780 EXPECT_EQ(s.ToVreg(p2), s.ToVreg(s[0]->InputAt(0))); | 1836 EXPECT_EQ(s.ToVreg(p2), s.ToVreg(s[0]->InputAt(0))); |
| 1781 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(1))); | 1837 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(1))); |
| 1782 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(2))); | 1838 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(2))); |
| 1783 ASSERT_EQ(1U, s[0]->OutputCount()); | 1839 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 1784 EXPECT_TRUE( | 1840 EXPECT_TRUE( |
| 1785 UnallocatedOperand::cast(s[0]->Output())->HasSameAsInputPolicy()); | 1841 UnallocatedOperand::cast(s[0]->Output())->HasSameAsInputPolicy()); |
| 1786 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | 1842 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
| 1787 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); | 1843 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); |
| 1788 } | 1844 } |
| 1789 { | 1845 { |
| 1790 StreamBuilder m(this, kMachFloat64, kMachFloat64, kMachFloat64, | 1846 StreamBuilder m(this, MachineType::Float64(), MachineType::Float64(), |
| 1791 kMachFloat64); | 1847 MachineType::Float64(), MachineType::Float64()); |
| 1792 Node* const p0 = m.Parameter(0); | 1848 Node* const p0 = m.Parameter(0); |
| 1793 Node* const p1 = m.Parameter(1); | 1849 Node* const p1 = m.Parameter(1); |
| 1794 Node* const p2 = m.Parameter(2); | 1850 Node* const p2 = m.Parameter(2); |
| 1795 Node* const n = m.Float64Add(p0, m.Float64Mul(p1, p2)); | 1851 Node* const n = m.Float64Add(p0, m.Float64Mul(p1, p2)); |
| 1796 m.Return(n); | 1852 m.Return(n); |
| 1797 Stream s = m.Build(); | 1853 Stream s = m.Build(); |
| 1798 ASSERT_EQ(1U, s.size()); | 1854 ASSERT_EQ(1U, s.size()); |
| 1799 EXPECT_EQ(kArmVmlaF64, s[0]->arch_opcode()); | 1855 EXPECT_EQ(kArmVmlaF64, s[0]->arch_opcode()); |
| 1800 ASSERT_EQ(3U, s[0]->InputCount()); | 1856 ASSERT_EQ(3U, s[0]->InputCount()); |
| 1801 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); | 1857 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
| 1802 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1))); | 1858 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1))); |
| 1803 EXPECT_EQ(s.ToVreg(p2), s.ToVreg(s[0]->InputAt(2))); | 1859 EXPECT_EQ(s.ToVreg(p2), s.ToVreg(s[0]->InputAt(2))); |
| 1804 ASSERT_EQ(1U, s[0]->OutputCount()); | 1860 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 1805 EXPECT_TRUE( | 1861 EXPECT_TRUE( |
| 1806 UnallocatedOperand::cast(s[0]->Output())->HasSameAsInputPolicy()); | 1862 UnallocatedOperand::cast(s[0]->Output())->HasSameAsInputPolicy()); |
| 1807 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | 1863 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
| 1808 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); | 1864 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); |
| 1809 } | 1865 } |
| 1810 } | 1866 } |
| 1811 | 1867 |
| 1812 | 1868 |
| 1813 TEST_F(InstructionSelectorTest, Float32SubWithMinusZero) { | 1869 TEST_F(InstructionSelectorTest, Float32SubWithMinusZero) { |
| 1814 StreamBuilder m(this, kMachFloat32, kMachFloat32); | 1870 StreamBuilder m(this, MachineType::Float32(), MachineType::Float32()); |
| 1815 Node* const p0 = m.Parameter(0); | 1871 Node* const p0 = m.Parameter(0); |
| 1816 Node* const n = m.Float32Sub(m.Float32Constant(-0.0f), p0); | 1872 Node* const n = m.Float32Sub(m.Float32Constant(-0.0f), p0); |
| 1817 m.Return(n); | 1873 m.Return(n); |
| 1818 Stream s = m.Build(); | 1874 Stream s = m.Build(); |
| 1819 ASSERT_EQ(1U, s.size()); | 1875 ASSERT_EQ(1U, s.size()); |
| 1820 EXPECT_EQ(kArmVnegF32, s[0]->arch_opcode()); | 1876 EXPECT_EQ(kArmVnegF32, s[0]->arch_opcode()); |
| 1821 ASSERT_EQ(1U, s[0]->InputCount()); | 1877 ASSERT_EQ(1U, s[0]->InputCount()); |
| 1822 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); | 1878 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
| 1823 ASSERT_EQ(1U, s[0]->OutputCount()); | 1879 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 1824 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | 1880 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
| 1825 } | 1881 } |
| 1826 | 1882 |
| 1827 | 1883 |
| 1828 TEST_F(InstructionSelectorTest, Float64SubWithMinusZero) { | 1884 TEST_F(InstructionSelectorTest, Float64SubWithMinusZero) { |
| 1829 StreamBuilder m(this, kMachFloat64, kMachFloat64); | 1885 StreamBuilder m(this, MachineType::Float64(), MachineType::Float64()); |
| 1830 Node* const p0 = m.Parameter(0); | 1886 Node* const p0 = m.Parameter(0); |
| 1831 Node* const n = m.Float64Sub(m.Float64Constant(-0.0), p0); | 1887 Node* const n = m.Float64Sub(m.Float64Constant(-0.0), p0); |
| 1832 m.Return(n); | 1888 m.Return(n); |
| 1833 Stream s = m.Build(); | 1889 Stream s = m.Build(); |
| 1834 ASSERT_EQ(1U, s.size()); | 1890 ASSERT_EQ(1U, s.size()); |
| 1835 EXPECT_EQ(kArmVnegF64, s[0]->arch_opcode()); | 1891 EXPECT_EQ(kArmVnegF64, s[0]->arch_opcode()); |
| 1836 ASSERT_EQ(1U, s[0]->InputCount()); | 1892 ASSERT_EQ(1U, s[0]->InputCount()); |
| 1837 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); | 1893 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
| 1838 ASSERT_EQ(1U, s[0]->OutputCount()); | 1894 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 1839 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | 1895 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
| 1840 } | 1896 } |
| 1841 | 1897 |
| 1842 | 1898 |
| 1843 TEST_F(InstructionSelectorTest, Float32SubWithFloat32Mul) { | 1899 TEST_F(InstructionSelectorTest, Float32SubWithFloat32Mul) { |
| 1844 StreamBuilder m(this, kMachFloat32, kMachFloat32, kMachFloat32, kMachFloat32); | 1900 StreamBuilder m(this, MachineType::Float32(), MachineType::Float32(), |
| 1901 MachineType::Float32(), MachineType::Float32()); |
| 1845 Node* const p0 = m.Parameter(0); | 1902 Node* const p0 = m.Parameter(0); |
| 1846 Node* const p1 = m.Parameter(1); | 1903 Node* const p1 = m.Parameter(1); |
| 1847 Node* const p2 = m.Parameter(2); | 1904 Node* const p2 = m.Parameter(2); |
| 1848 Node* const n = m.Float32Sub(p0, m.Float32Mul(p1, p2)); | 1905 Node* const n = m.Float32Sub(p0, m.Float32Mul(p1, p2)); |
| 1849 m.Return(n); | 1906 m.Return(n); |
| 1850 Stream s = m.Build(); | 1907 Stream s = m.Build(); |
| 1851 ASSERT_EQ(1U, s.size()); | 1908 ASSERT_EQ(1U, s.size()); |
| 1852 EXPECT_EQ(kArmVmlsF32, s[0]->arch_opcode()); | 1909 EXPECT_EQ(kArmVmlsF32, s[0]->arch_opcode()); |
| 1853 ASSERT_EQ(3U, s[0]->InputCount()); | 1910 ASSERT_EQ(3U, s[0]->InputCount()); |
| 1854 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); | 1911 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
| 1855 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1))); | 1912 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1))); |
| 1856 EXPECT_EQ(s.ToVreg(p2), s.ToVreg(s[0]->InputAt(2))); | 1913 EXPECT_EQ(s.ToVreg(p2), s.ToVreg(s[0]->InputAt(2))); |
| 1857 ASSERT_EQ(1U, s[0]->OutputCount()); | 1914 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 1858 EXPECT_TRUE(UnallocatedOperand::cast(s[0]->Output())->HasSameAsInputPolicy()); | 1915 EXPECT_TRUE(UnallocatedOperand::cast(s[0]->Output())->HasSameAsInputPolicy()); |
| 1859 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | 1916 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
| 1860 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); | 1917 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); |
| 1861 } | 1918 } |
| 1862 | 1919 |
| 1863 | 1920 |
| 1864 TEST_F(InstructionSelectorTest, Float64SubWithFloat64Mul) { | 1921 TEST_F(InstructionSelectorTest, Float64SubWithFloat64Mul) { |
| 1865 StreamBuilder m(this, kMachFloat64, kMachFloat64, kMachFloat64, kMachFloat64); | 1922 StreamBuilder m(this, MachineType::Float64(), MachineType::Float64(), |
| 1923 MachineType::Float64(), MachineType::Float64()); |
| 1866 Node* const p0 = m.Parameter(0); | 1924 Node* const p0 = m.Parameter(0); |
| 1867 Node* const p1 = m.Parameter(1); | 1925 Node* const p1 = m.Parameter(1); |
| 1868 Node* const p2 = m.Parameter(2); | 1926 Node* const p2 = m.Parameter(2); |
| 1869 Node* const n = m.Float64Sub(p0, m.Float64Mul(p1, p2)); | 1927 Node* const n = m.Float64Sub(p0, m.Float64Mul(p1, p2)); |
| 1870 m.Return(n); | 1928 m.Return(n); |
| 1871 Stream s = m.Build(); | 1929 Stream s = m.Build(); |
| 1872 ASSERT_EQ(1U, s.size()); | 1930 ASSERT_EQ(1U, s.size()); |
| 1873 EXPECT_EQ(kArmVmlsF64, s[0]->arch_opcode()); | 1931 EXPECT_EQ(kArmVmlsF64, s[0]->arch_opcode()); |
| 1874 ASSERT_EQ(3U, s[0]->InputCount()); | 1932 ASSERT_EQ(3U, s[0]->InputCount()); |
| 1875 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); | 1933 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
| 1876 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1))); | 1934 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1))); |
| 1877 EXPECT_EQ(s.ToVreg(p2), s.ToVreg(s[0]->InputAt(2))); | 1935 EXPECT_EQ(s.ToVreg(p2), s.ToVreg(s[0]->InputAt(2))); |
| 1878 ASSERT_EQ(1U, s[0]->OutputCount()); | 1936 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 1879 EXPECT_TRUE(UnallocatedOperand::cast(s[0]->Output())->HasSameAsInputPolicy()); | 1937 EXPECT_TRUE(UnallocatedOperand::cast(s[0]->Output())->HasSameAsInputPolicy()); |
| 1880 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | 1938 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
| 1881 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); | 1939 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); |
| 1882 } | 1940 } |
| 1883 | 1941 |
| 1884 | 1942 |
| 1885 TEST_F(InstructionSelectorTest, Float32Sqrt) { | 1943 TEST_F(InstructionSelectorTest, Float32Sqrt) { |
| 1886 StreamBuilder m(this, kMachFloat32, kMachFloat32); | 1944 StreamBuilder m(this, MachineType::Float32(), MachineType::Float32()); |
| 1887 Node* const p0 = m.Parameter(0); | 1945 Node* const p0 = m.Parameter(0); |
| 1888 Node* const n = m.Float32Sqrt(p0); | 1946 Node* const n = m.Float32Sqrt(p0); |
| 1889 m.Return(n); | 1947 m.Return(n); |
| 1890 Stream s = m.Build(); | 1948 Stream s = m.Build(); |
| 1891 ASSERT_EQ(1U, s.size()); | 1949 ASSERT_EQ(1U, s.size()); |
| 1892 EXPECT_EQ(kArmVsqrtF32, s[0]->arch_opcode()); | 1950 EXPECT_EQ(kArmVsqrtF32, s[0]->arch_opcode()); |
| 1893 ASSERT_EQ(1U, s[0]->InputCount()); | 1951 ASSERT_EQ(1U, s[0]->InputCount()); |
| 1894 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); | 1952 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
| 1895 ASSERT_EQ(1U, s[0]->OutputCount()); | 1953 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 1896 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | 1954 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
| 1897 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); | 1955 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); |
| 1898 } | 1956 } |
| 1899 | 1957 |
| 1900 | 1958 |
| 1901 TEST_F(InstructionSelectorTest, Float64Sqrt) { | 1959 TEST_F(InstructionSelectorTest, Float64Sqrt) { |
| 1902 StreamBuilder m(this, kMachFloat64, kMachFloat64); | 1960 StreamBuilder m(this, MachineType::Float64(), MachineType::Float64()); |
| 1903 Node* const p0 = m.Parameter(0); | 1961 Node* const p0 = m.Parameter(0); |
| 1904 Node* const n = m.Float64Sqrt(p0); | 1962 Node* const n = m.Float64Sqrt(p0); |
| 1905 m.Return(n); | 1963 m.Return(n); |
| 1906 Stream s = m.Build(); | 1964 Stream s = m.Build(); |
| 1907 ASSERT_EQ(1U, s.size()); | 1965 ASSERT_EQ(1U, s.size()); |
| 1908 EXPECT_EQ(kArmVsqrtF64, s[0]->arch_opcode()); | 1966 EXPECT_EQ(kArmVsqrtF64, s[0]->arch_opcode()); |
| 1909 ASSERT_EQ(1U, s[0]->InputCount()); | 1967 ASSERT_EQ(1U, s[0]->InputCount()); |
| 1910 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); | 1968 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
| 1911 ASSERT_EQ(1U, s[0]->OutputCount()); | 1969 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 1912 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | 1970 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
| 1913 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); | 1971 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); |
| 1914 } | 1972 } |
| 1915 | 1973 |
| 1916 | 1974 |
| 1917 // ----------------------------------------------------------------------------- | 1975 // ----------------------------------------------------------------------------- |
| 1918 // Miscellaneous. | 1976 // Miscellaneous. |
| 1919 | 1977 |
| 1920 | 1978 |
| 1921 TEST_F(InstructionSelectorTest, Int32AddWithInt32Mul) { | 1979 TEST_F(InstructionSelectorTest, Int32AddWithInt32Mul) { |
| 1922 { | 1980 { |
| 1923 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); | 1981 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 1982 MachineType::Int32(), MachineType::Int32()); |
| 1924 Node* const p0 = m.Parameter(0); | 1983 Node* const p0 = m.Parameter(0); |
| 1925 Node* const p1 = m.Parameter(1); | 1984 Node* const p1 = m.Parameter(1); |
| 1926 Node* const p2 = m.Parameter(2); | 1985 Node* const p2 = m.Parameter(2); |
| 1927 Node* const n = m.Int32Add(p0, m.Int32Mul(p1, p2)); | 1986 Node* const n = m.Int32Add(p0, m.Int32Mul(p1, p2)); |
| 1928 m.Return(n); | 1987 m.Return(n); |
| 1929 Stream s = m.Build(); | 1988 Stream s = m.Build(); |
| 1930 ASSERT_EQ(1U, s.size()); | 1989 ASSERT_EQ(1U, s.size()); |
| 1931 EXPECT_EQ(kArmMla, s[0]->arch_opcode()); | 1990 EXPECT_EQ(kArmMla, s[0]->arch_opcode()); |
| 1932 ASSERT_EQ(3U, s[0]->InputCount()); | 1991 ASSERT_EQ(3U, s[0]->InputCount()); |
| 1933 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(0))); | 1992 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(0))); |
| 1934 EXPECT_EQ(s.ToVreg(p2), s.ToVreg(s[0]->InputAt(1))); | 1993 EXPECT_EQ(s.ToVreg(p2), s.ToVreg(s[0]->InputAt(1))); |
| 1935 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(2))); | 1994 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(2))); |
| 1936 ASSERT_EQ(1U, s[0]->OutputCount()); | 1995 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 1937 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | 1996 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
| 1938 } | 1997 } |
| 1939 { | 1998 { |
| 1940 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); | 1999 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 2000 MachineType::Int32(), MachineType::Int32()); |
| 1941 Node* const p0 = m.Parameter(0); | 2001 Node* const p0 = m.Parameter(0); |
| 1942 Node* const p1 = m.Parameter(1); | 2002 Node* const p1 = m.Parameter(1); |
| 1943 Node* const p2 = m.Parameter(2); | 2003 Node* const p2 = m.Parameter(2); |
| 1944 Node* const n = m.Int32Add(m.Int32Mul(p1, p2), p0); | 2004 Node* const n = m.Int32Add(m.Int32Mul(p1, p2), p0); |
| 1945 m.Return(n); | 2005 m.Return(n); |
| 1946 Stream s = m.Build(); | 2006 Stream s = m.Build(); |
| 1947 ASSERT_EQ(1U, s.size()); | 2007 ASSERT_EQ(1U, s.size()); |
| 1948 EXPECT_EQ(kArmMla, s[0]->arch_opcode()); | 2008 EXPECT_EQ(kArmMla, s[0]->arch_opcode()); |
| 1949 ASSERT_EQ(3U, s[0]->InputCount()); | 2009 ASSERT_EQ(3U, s[0]->InputCount()); |
| 1950 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(0))); | 2010 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(0))); |
| 1951 EXPECT_EQ(s.ToVreg(p2), s.ToVreg(s[0]->InputAt(1))); | 2011 EXPECT_EQ(s.ToVreg(p2), s.ToVreg(s[0]->InputAt(1))); |
| 1952 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(2))); | 2012 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(2))); |
| 1953 ASSERT_EQ(1U, s[0]->OutputCount()); | 2013 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 1954 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | 2014 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
| 1955 } | 2015 } |
| 1956 } | 2016 } |
| 1957 | 2017 |
| 1958 | 2018 |
| 1959 TEST_F(InstructionSelectorTest, Int32AddWithInt32MulHigh) { | 2019 TEST_F(InstructionSelectorTest, Int32AddWithInt32MulHigh) { |
| 1960 { | 2020 { |
| 1961 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); | 2021 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 2022 MachineType::Int32(), MachineType::Int32()); |
| 1962 Node* const p0 = m.Parameter(0); | 2023 Node* const p0 = m.Parameter(0); |
| 1963 Node* const p1 = m.Parameter(1); | 2024 Node* const p1 = m.Parameter(1); |
| 1964 Node* const p2 = m.Parameter(2); | 2025 Node* const p2 = m.Parameter(2); |
| 1965 Node* const n = m.Int32Add(p0, m.Int32MulHigh(p1, p2)); | 2026 Node* const n = m.Int32Add(p0, m.Int32MulHigh(p1, p2)); |
| 1966 m.Return(n); | 2027 m.Return(n); |
| 1967 Stream s = m.Build(); | 2028 Stream s = m.Build(); |
| 1968 ASSERT_EQ(1U, s.size()); | 2029 ASSERT_EQ(1U, s.size()); |
| 1969 EXPECT_EQ(kArmSmmla, s[0]->arch_opcode()); | 2030 EXPECT_EQ(kArmSmmla, s[0]->arch_opcode()); |
| 1970 ASSERT_EQ(3U, s[0]->InputCount()); | 2031 ASSERT_EQ(3U, s[0]->InputCount()); |
| 1971 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(0))); | 2032 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(0))); |
| 1972 EXPECT_EQ(s.ToVreg(p2), s.ToVreg(s[0]->InputAt(1))); | 2033 EXPECT_EQ(s.ToVreg(p2), s.ToVreg(s[0]->InputAt(1))); |
| 1973 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(2))); | 2034 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(2))); |
| 1974 ASSERT_EQ(1U, s[0]->OutputCount()); | 2035 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 1975 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | 2036 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
| 1976 } | 2037 } |
| 1977 { | 2038 { |
| 1978 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); | 2039 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 2040 MachineType::Int32(), MachineType::Int32()); |
| 1979 Node* const p0 = m.Parameter(0); | 2041 Node* const p0 = m.Parameter(0); |
| 1980 Node* const p1 = m.Parameter(1); | 2042 Node* const p1 = m.Parameter(1); |
| 1981 Node* const p2 = m.Parameter(2); | 2043 Node* const p2 = m.Parameter(2); |
| 1982 Node* const n = m.Int32Add(m.Int32MulHigh(p1, p2), p0); | 2044 Node* const n = m.Int32Add(m.Int32MulHigh(p1, p2), p0); |
| 1983 m.Return(n); | 2045 m.Return(n); |
| 1984 Stream s = m.Build(); | 2046 Stream s = m.Build(); |
| 1985 ASSERT_EQ(1U, s.size()); | 2047 ASSERT_EQ(1U, s.size()); |
| 1986 EXPECT_EQ(kArmSmmla, s[0]->arch_opcode()); | 2048 EXPECT_EQ(kArmSmmla, s[0]->arch_opcode()); |
| 1987 ASSERT_EQ(3U, s[0]->InputCount()); | 2049 ASSERT_EQ(3U, s[0]->InputCount()); |
| 1988 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(0))); | 2050 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(0))); |
| 1989 EXPECT_EQ(s.ToVreg(p2), s.ToVreg(s[0]->InputAt(1))); | 2051 EXPECT_EQ(s.ToVreg(p2), s.ToVreg(s[0]->InputAt(1))); |
| 1990 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(2))); | 2052 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(2))); |
| 1991 ASSERT_EQ(1U, s[0]->OutputCount()); | 2053 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 1992 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | 2054 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
| 1993 } | 2055 } |
| 1994 } | 2056 } |
| 1995 | 2057 |
| 1996 | 2058 |
| 1997 TEST_F(InstructionSelectorTest, Int32AddWithWord32And) { | 2059 TEST_F(InstructionSelectorTest, Int32AddWithWord32And) { |
| 1998 { | 2060 { |
| 1999 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); | 2061 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 2062 MachineType::Int32()); |
| 2000 Node* const p0 = m.Parameter(0); | 2063 Node* const p0 = m.Parameter(0); |
| 2001 Node* const p1 = m.Parameter(1); | 2064 Node* const p1 = m.Parameter(1); |
| 2002 Node* const r = m.Int32Add(m.Word32And(p0, m.Int32Constant(0xff)), p1); | 2065 Node* const r = m.Int32Add(m.Word32And(p0, m.Int32Constant(0xff)), p1); |
| 2003 m.Return(r); | 2066 m.Return(r); |
| 2004 Stream s = m.Build(); | 2067 Stream s = m.Build(); |
| 2005 ASSERT_EQ(1U, s.size()); | 2068 ASSERT_EQ(1U, s.size()); |
| 2006 EXPECT_EQ(kArmUxtab, s[0]->arch_opcode()); | 2069 EXPECT_EQ(kArmUxtab, s[0]->arch_opcode()); |
| 2007 ASSERT_EQ(3U, s[0]->InputCount()); | 2070 ASSERT_EQ(3U, s[0]->InputCount()); |
| 2008 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(0))); | 2071 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(0))); |
| 2009 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(1))); | 2072 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(1))); |
| 2010 EXPECT_EQ(0, s.ToInt32(s[0]->InputAt(2))); | 2073 EXPECT_EQ(0, s.ToInt32(s[0]->InputAt(2))); |
| 2011 ASSERT_EQ(1U, s[0]->OutputCount()); | 2074 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 2012 EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output())); | 2075 EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output())); |
| 2013 } | 2076 } |
| 2014 { | 2077 { |
| 2015 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); | 2078 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 2079 MachineType::Int32()); |
| 2016 Node* const p0 = m.Parameter(0); | 2080 Node* const p0 = m.Parameter(0); |
| 2017 Node* const p1 = m.Parameter(1); | 2081 Node* const p1 = m.Parameter(1); |
| 2018 Node* const r = m.Int32Add(p1, m.Word32And(p0, m.Int32Constant(0xff))); | 2082 Node* const r = m.Int32Add(p1, m.Word32And(p0, m.Int32Constant(0xff))); |
| 2019 m.Return(r); | 2083 m.Return(r); |
| 2020 Stream s = m.Build(); | 2084 Stream s = m.Build(); |
| 2021 ASSERT_EQ(1U, s.size()); | 2085 ASSERT_EQ(1U, s.size()); |
| 2022 EXPECT_EQ(kArmUxtab, s[0]->arch_opcode()); | 2086 EXPECT_EQ(kArmUxtab, s[0]->arch_opcode()); |
| 2023 ASSERT_EQ(3U, s[0]->InputCount()); | 2087 ASSERT_EQ(3U, s[0]->InputCount()); |
| 2024 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(0))); | 2088 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(0))); |
| 2025 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(1))); | 2089 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(1))); |
| 2026 EXPECT_EQ(0, s.ToInt32(s[0]->InputAt(2))); | 2090 EXPECT_EQ(0, s.ToInt32(s[0]->InputAt(2))); |
| 2027 ASSERT_EQ(1U, s[0]->OutputCount()); | 2091 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 2028 EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output())); | 2092 EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output())); |
| 2029 } | 2093 } |
| 2030 { | 2094 { |
| 2031 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); | 2095 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 2096 MachineType::Int32()); |
| 2032 Node* const p0 = m.Parameter(0); | 2097 Node* const p0 = m.Parameter(0); |
| 2033 Node* const p1 = m.Parameter(1); | 2098 Node* const p1 = m.Parameter(1); |
| 2034 Node* const r = m.Int32Add(m.Word32And(p0, m.Int32Constant(0xffff)), p1); | 2099 Node* const r = m.Int32Add(m.Word32And(p0, m.Int32Constant(0xffff)), p1); |
| 2035 m.Return(r); | 2100 m.Return(r); |
| 2036 Stream s = m.Build(); | 2101 Stream s = m.Build(); |
| 2037 ASSERT_EQ(1U, s.size()); | 2102 ASSERT_EQ(1U, s.size()); |
| 2038 EXPECT_EQ(kArmUxtah, s[0]->arch_opcode()); | 2103 EXPECT_EQ(kArmUxtah, s[0]->arch_opcode()); |
| 2039 ASSERT_EQ(3U, s[0]->InputCount()); | 2104 ASSERT_EQ(3U, s[0]->InputCount()); |
| 2040 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(0))); | 2105 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(0))); |
| 2041 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(1))); | 2106 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(1))); |
| 2042 EXPECT_EQ(0, s.ToInt32(s[0]->InputAt(2))); | 2107 EXPECT_EQ(0, s.ToInt32(s[0]->InputAt(2))); |
| 2043 ASSERT_EQ(1U, s[0]->OutputCount()); | 2108 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 2044 EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output())); | 2109 EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output())); |
| 2045 } | 2110 } |
| 2046 { | 2111 { |
| 2047 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); | 2112 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 2113 MachineType::Int32()); |
| 2048 Node* const p0 = m.Parameter(0); | 2114 Node* const p0 = m.Parameter(0); |
| 2049 Node* const p1 = m.Parameter(1); | 2115 Node* const p1 = m.Parameter(1); |
| 2050 Node* const r = m.Int32Add(p1, m.Word32And(p0, m.Int32Constant(0xffff))); | 2116 Node* const r = m.Int32Add(p1, m.Word32And(p0, m.Int32Constant(0xffff))); |
| 2051 m.Return(r); | 2117 m.Return(r); |
| 2052 Stream s = m.Build(); | 2118 Stream s = m.Build(); |
| 2053 ASSERT_EQ(1U, s.size()); | 2119 ASSERT_EQ(1U, s.size()); |
| 2054 EXPECT_EQ(kArmUxtah, s[0]->arch_opcode()); | 2120 EXPECT_EQ(kArmUxtah, s[0]->arch_opcode()); |
| 2055 ASSERT_EQ(3U, s[0]->InputCount()); | 2121 ASSERT_EQ(3U, s[0]->InputCount()); |
| 2056 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(0))); | 2122 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(0))); |
| 2057 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(1))); | 2123 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(1))); |
| 2058 EXPECT_EQ(0, s.ToInt32(s[0]->InputAt(2))); | 2124 EXPECT_EQ(0, s.ToInt32(s[0]->InputAt(2))); |
| 2059 ASSERT_EQ(1U, s[0]->OutputCount()); | 2125 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 2060 EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output())); | 2126 EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output())); |
| 2061 } | 2127 } |
| 2062 } | 2128 } |
| 2063 | 2129 |
| 2064 | 2130 |
| 2065 TEST_F(InstructionSelectorTest, Int32AddWithWord32SarWithWord32Shl) { | 2131 TEST_F(InstructionSelectorTest, Int32AddWithWord32SarWithWord32Shl) { |
| 2066 { | 2132 { |
| 2067 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); | 2133 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 2134 MachineType::Int32()); |
| 2068 Node* const p0 = m.Parameter(0); | 2135 Node* const p0 = m.Parameter(0); |
| 2069 Node* const p1 = m.Parameter(1); | 2136 Node* const p1 = m.Parameter(1); |
| 2070 Node* const r = m.Int32Add( | 2137 Node* const r = m.Int32Add( |
| 2071 m.Word32Sar(m.Word32Shl(p0, m.Int32Constant(24)), m.Int32Constant(24)), | 2138 m.Word32Sar(m.Word32Shl(p0, m.Int32Constant(24)), m.Int32Constant(24)), |
| 2072 p1); | 2139 p1); |
| 2073 m.Return(r); | 2140 m.Return(r); |
| 2074 Stream s = m.Build(); | 2141 Stream s = m.Build(); |
| 2075 ASSERT_EQ(1U, s.size()); | 2142 ASSERT_EQ(1U, s.size()); |
| 2076 EXPECT_EQ(kArmSxtab, s[0]->arch_opcode()); | 2143 EXPECT_EQ(kArmSxtab, s[0]->arch_opcode()); |
| 2077 ASSERT_EQ(3U, s[0]->InputCount()); | 2144 ASSERT_EQ(3U, s[0]->InputCount()); |
| 2078 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(0))); | 2145 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(0))); |
| 2079 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(1))); | 2146 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(1))); |
| 2080 EXPECT_EQ(0, s.ToInt32(s[0]->InputAt(2))); | 2147 EXPECT_EQ(0, s.ToInt32(s[0]->InputAt(2))); |
| 2081 ASSERT_EQ(1U, s[0]->OutputCount()); | 2148 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 2082 EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output())); | 2149 EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output())); |
| 2083 } | 2150 } |
| 2084 { | 2151 { |
| 2085 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); | 2152 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 2153 MachineType::Int32()); |
| 2086 Node* const p0 = m.Parameter(0); | 2154 Node* const p0 = m.Parameter(0); |
| 2087 Node* const p1 = m.Parameter(1); | 2155 Node* const p1 = m.Parameter(1); |
| 2088 Node* const r = m.Int32Add( | 2156 Node* const r = m.Int32Add( |
| 2089 p1, | 2157 p1, |
| 2090 m.Word32Sar(m.Word32Shl(p0, m.Int32Constant(24)), m.Int32Constant(24))); | 2158 m.Word32Sar(m.Word32Shl(p0, m.Int32Constant(24)), m.Int32Constant(24))); |
| 2091 m.Return(r); | 2159 m.Return(r); |
| 2092 Stream s = m.Build(); | 2160 Stream s = m.Build(); |
| 2093 ASSERT_EQ(1U, s.size()); | 2161 ASSERT_EQ(1U, s.size()); |
| 2094 EXPECT_EQ(kArmSxtab, s[0]->arch_opcode()); | 2162 EXPECT_EQ(kArmSxtab, s[0]->arch_opcode()); |
| 2095 ASSERT_EQ(3U, s[0]->InputCount()); | 2163 ASSERT_EQ(3U, s[0]->InputCount()); |
| 2096 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(0))); | 2164 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(0))); |
| 2097 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(1))); | 2165 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(1))); |
| 2098 EXPECT_EQ(0, s.ToInt32(s[0]->InputAt(2))); | 2166 EXPECT_EQ(0, s.ToInt32(s[0]->InputAt(2))); |
| 2099 ASSERT_EQ(1U, s[0]->OutputCount()); | 2167 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 2100 EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output())); | 2168 EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output())); |
| 2101 } | 2169 } |
| 2102 { | 2170 { |
| 2103 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); | 2171 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 2172 MachineType::Int32()); |
| 2104 Node* const p0 = m.Parameter(0); | 2173 Node* const p0 = m.Parameter(0); |
| 2105 Node* const p1 = m.Parameter(1); | 2174 Node* const p1 = m.Parameter(1); |
| 2106 Node* const r = m.Int32Add( | 2175 Node* const r = m.Int32Add( |
| 2107 m.Word32Sar(m.Word32Shl(p0, m.Int32Constant(16)), m.Int32Constant(16)), | 2176 m.Word32Sar(m.Word32Shl(p0, m.Int32Constant(16)), m.Int32Constant(16)), |
| 2108 p1); | 2177 p1); |
| 2109 m.Return(r); | 2178 m.Return(r); |
| 2110 Stream s = m.Build(); | 2179 Stream s = m.Build(); |
| 2111 ASSERT_EQ(1U, s.size()); | 2180 ASSERT_EQ(1U, s.size()); |
| 2112 EXPECT_EQ(kArmSxtah, s[0]->arch_opcode()); | 2181 EXPECT_EQ(kArmSxtah, s[0]->arch_opcode()); |
| 2113 ASSERT_EQ(3U, s[0]->InputCount()); | 2182 ASSERT_EQ(3U, s[0]->InputCount()); |
| 2114 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(0))); | 2183 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(0))); |
| 2115 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(1))); | 2184 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(1))); |
| 2116 EXPECT_EQ(0, s.ToInt32(s[0]->InputAt(2))); | 2185 EXPECT_EQ(0, s.ToInt32(s[0]->InputAt(2))); |
| 2117 ASSERT_EQ(1U, s[0]->OutputCount()); | 2186 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 2118 EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output())); | 2187 EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output())); |
| 2119 } | 2188 } |
| 2120 { | 2189 { |
| 2121 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); | 2190 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 2191 MachineType::Int32()); |
| 2122 Node* const p0 = m.Parameter(0); | 2192 Node* const p0 = m.Parameter(0); |
| 2123 Node* const p1 = m.Parameter(1); | 2193 Node* const p1 = m.Parameter(1); |
| 2124 Node* const r = m.Int32Add( | 2194 Node* const r = m.Int32Add( |
| 2125 p1, | 2195 p1, |
| 2126 m.Word32Sar(m.Word32Shl(p0, m.Int32Constant(16)), m.Int32Constant(16))); | 2196 m.Word32Sar(m.Word32Shl(p0, m.Int32Constant(16)), m.Int32Constant(16))); |
| 2127 m.Return(r); | 2197 m.Return(r); |
| 2128 Stream s = m.Build(); | 2198 Stream s = m.Build(); |
| 2129 ASSERT_EQ(1U, s.size()); | 2199 ASSERT_EQ(1U, s.size()); |
| 2130 EXPECT_EQ(kArmSxtah, s[0]->arch_opcode()); | 2200 EXPECT_EQ(kArmSxtah, s[0]->arch_opcode()); |
| 2131 ASSERT_EQ(3U, s[0]->InputCount()); | 2201 ASSERT_EQ(3U, s[0]->InputCount()); |
| 2132 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(0))); | 2202 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(0))); |
| 2133 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(1))); | 2203 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(1))); |
| 2134 EXPECT_EQ(0, s.ToInt32(s[0]->InputAt(2))); | 2204 EXPECT_EQ(0, s.ToInt32(s[0]->InputAt(2))); |
| 2135 ASSERT_EQ(1U, s[0]->OutputCount()); | 2205 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 2136 EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output())); | 2206 EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output())); |
| 2137 } | 2207 } |
| 2138 } | 2208 } |
| 2139 | 2209 |
| 2140 | 2210 |
| 2141 TEST_F(InstructionSelectorTest, Int32SubWithInt32Mul) { | 2211 TEST_F(InstructionSelectorTest, Int32SubWithInt32Mul) { |
| 2142 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); | 2212 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 2213 MachineType::Int32(), MachineType::Int32()); |
| 2143 m.Return( | 2214 m.Return( |
| 2144 m.Int32Sub(m.Parameter(0), m.Int32Mul(m.Parameter(1), m.Parameter(2)))); | 2215 m.Int32Sub(m.Parameter(0), m.Int32Mul(m.Parameter(1), m.Parameter(2)))); |
| 2145 Stream s = m.Build(); | 2216 Stream s = m.Build(); |
| 2146 ASSERT_EQ(2U, s.size()); | 2217 ASSERT_EQ(2U, s.size()); |
| 2147 EXPECT_EQ(kArmMul, s[0]->arch_opcode()); | 2218 EXPECT_EQ(kArmMul, s[0]->arch_opcode()); |
| 2148 ASSERT_EQ(1U, s[0]->OutputCount()); | 2219 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 2149 EXPECT_EQ(kArmSub, s[1]->arch_opcode()); | 2220 EXPECT_EQ(kArmSub, s[1]->arch_opcode()); |
| 2150 ASSERT_EQ(2U, s[1]->InputCount()); | 2221 ASSERT_EQ(2U, s[1]->InputCount()); |
| 2151 EXPECT_EQ(s.ToVreg(s[0]->Output()), s.ToVreg(s[1]->InputAt(1))); | 2222 EXPECT_EQ(s.ToVreg(s[0]->Output()), s.ToVreg(s[1]->InputAt(1))); |
| 2152 } | 2223 } |
| 2153 | 2224 |
| 2154 | 2225 |
| 2155 TEST_F(InstructionSelectorTest, Int32SubWithInt32MulForMLS) { | 2226 TEST_F(InstructionSelectorTest, Int32SubWithInt32MulForMLS) { |
| 2156 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); | 2227 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 2228 MachineType::Int32(), MachineType::Int32()); |
| 2157 m.Return( | 2229 m.Return( |
| 2158 m.Int32Sub(m.Parameter(0), m.Int32Mul(m.Parameter(1), m.Parameter(2)))); | 2230 m.Int32Sub(m.Parameter(0), m.Int32Mul(m.Parameter(1), m.Parameter(2)))); |
| 2159 Stream s = m.Build(MLS); | 2231 Stream s = m.Build(MLS); |
| 2160 ASSERT_EQ(1U, s.size()); | 2232 ASSERT_EQ(1U, s.size()); |
| 2161 EXPECT_EQ(kArmMls, s[0]->arch_opcode()); | 2233 EXPECT_EQ(kArmMls, s[0]->arch_opcode()); |
| 2162 EXPECT_EQ(1U, s[0]->OutputCount()); | 2234 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 2163 EXPECT_EQ(3U, s[0]->InputCount()); | 2235 EXPECT_EQ(3U, s[0]->InputCount()); |
| 2164 } | 2236 } |
| 2165 | 2237 |
| 2166 | 2238 |
| 2167 TEST_F(InstructionSelectorTest, Int32DivWithParameters) { | 2239 TEST_F(InstructionSelectorTest, Int32DivWithParameters) { |
| 2168 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); | 2240 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 2241 MachineType::Int32()); |
| 2169 m.Return(m.Int32Div(m.Parameter(0), m.Parameter(1))); | 2242 m.Return(m.Int32Div(m.Parameter(0), m.Parameter(1))); |
| 2170 Stream s = m.Build(); | 2243 Stream s = m.Build(); |
| 2171 ASSERT_EQ(4U, s.size()); | 2244 ASSERT_EQ(4U, s.size()); |
| 2172 EXPECT_EQ(kArmVcvtF64S32, s[0]->arch_opcode()); | 2245 EXPECT_EQ(kArmVcvtF64S32, s[0]->arch_opcode()); |
| 2173 ASSERT_EQ(1U, s[0]->OutputCount()); | 2246 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 2174 EXPECT_EQ(kArmVcvtF64S32, s[1]->arch_opcode()); | 2247 EXPECT_EQ(kArmVcvtF64S32, s[1]->arch_opcode()); |
| 2175 ASSERT_EQ(1U, s[1]->OutputCount()); | 2248 ASSERT_EQ(1U, s[1]->OutputCount()); |
| 2176 EXPECT_EQ(kArmVdivF64, s[2]->arch_opcode()); | 2249 EXPECT_EQ(kArmVdivF64, s[2]->arch_opcode()); |
| 2177 ASSERT_EQ(2U, s[2]->InputCount()); | 2250 ASSERT_EQ(2U, s[2]->InputCount()); |
| 2178 ASSERT_EQ(1U, s[2]->OutputCount()); | 2251 ASSERT_EQ(1U, s[2]->OutputCount()); |
| 2179 EXPECT_EQ(s.ToVreg(s[0]->Output()), s.ToVreg(s[2]->InputAt(0))); | 2252 EXPECT_EQ(s.ToVreg(s[0]->Output()), s.ToVreg(s[2]->InputAt(0))); |
| 2180 EXPECT_EQ(s.ToVreg(s[1]->Output()), s.ToVreg(s[2]->InputAt(1))); | 2253 EXPECT_EQ(s.ToVreg(s[1]->Output()), s.ToVreg(s[2]->InputAt(1))); |
| 2181 EXPECT_EQ(kArmVcvtS32F64, s[3]->arch_opcode()); | 2254 EXPECT_EQ(kArmVcvtS32F64, s[3]->arch_opcode()); |
| 2182 ASSERT_EQ(1U, s[3]->InputCount()); | 2255 ASSERT_EQ(1U, s[3]->InputCount()); |
| 2183 EXPECT_EQ(s.ToVreg(s[2]->Output()), s.ToVreg(s[3]->InputAt(0))); | 2256 EXPECT_EQ(s.ToVreg(s[2]->Output()), s.ToVreg(s[3]->InputAt(0))); |
| 2184 } | 2257 } |
| 2185 | 2258 |
| 2186 | 2259 |
| 2187 TEST_F(InstructionSelectorTest, Int32DivWithParametersForSUDIV) { | 2260 TEST_F(InstructionSelectorTest, Int32DivWithParametersForSUDIV) { |
| 2188 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); | 2261 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 2262 MachineType::Int32()); |
| 2189 m.Return(m.Int32Div(m.Parameter(0), m.Parameter(1))); | 2263 m.Return(m.Int32Div(m.Parameter(0), m.Parameter(1))); |
| 2190 Stream s = m.Build(SUDIV); | 2264 Stream s = m.Build(SUDIV); |
| 2191 ASSERT_EQ(1U, s.size()); | 2265 ASSERT_EQ(1U, s.size()); |
| 2192 EXPECT_EQ(kArmSdiv, s[0]->arch_opcode()); | 2266 EXPECT_EQ(kArmSdiv, s[0]->arch_opcode()); |
| 2193 } | 2267 } |
| 2194 | 2268 |
| 2195 | 2269 |
| 2196 TEST_F(InstructionSelectorTest, Int32ModWithParameters) { | 2270 TEST_F(InstructionSelectorTest, Int32ModWithParameters) { |
| 2197 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); | 2271 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 2272 MachineType::Int32()); |
| 2198 m.Return(m.Int32Mod(m.Parameter(0), m.Parameter(1))); | 2273 m.Return(m.Int32Mod(m.Parameter(0), m.Parameter(1))); |
| 2199 Stream s = m.Build(); | 2274 Stream s = m.Build(); |
| 2200 ASSERT_EQ(6U, s.size()); | 2275 ASSERT_EQ(6U, s.size()); |
| 2201 EXPECT_EQ(kArmVcvtF64S32, s[0]->arch_opcode()); | 2276 EXPECT_EQ(kArmVcvtF64S32, s[0]->arch_opcode()); |
| 2202 ASSERT_EQ(1U, s[0]->OutputCount()); | 2277 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 2203 EXPECT_EQ(kArmVcvtF64S32, s[1]->arch_opcode()); | 2278 EXPECT_EQ(kArmVcvtF64S32, s[1]->arch_opcode()); |
| 2204 ASSERT_EQ(1U, s[1]->OutputCount()); | 2279 ASSERT_EQ(1U, s[1]->OutputCount()); |
| 2205 EXPECT_EQ(kArmVdivF64, s[2]->arch_opcode()); | 2280 EXPECT_EQ(kArmVdivF64, s[2]->arch_opcode()); |
| 2206 ASSERT_EQ(2U, s[2]->InputCount()); | 2281 ASSERT_EQ(2U, s[2]->InputCount()); |
| 2207 ASSERT_EQ(1U, s[2]->OutputCount()); | 2282 ASSERT_EQ(1U, s[2]->OutputCount()); |
| 2208 EXPECT_EQ(s.ToVreg(s[0]->Output()), s.ToVreg(s[2]->InputAt(0))); | 2283 EXPECT_EQ(s.ToVreg(s[0]->Output()), s.ToVreg(s[2]->InputAt(0))); |
| 2209 EXPECT_EQ(s.ToVreg(s[1]->Output()), s.ToVreg(s[2]->InputAt(1))); | 2284 EXPECT_EQ(s.ToVreg(s[1]->Output()), s.ToVreg(s[2]->InputAt(1))); |
| 2210 EXPECT_EQ(kArmVcvtS32F64, s[3]->arch_opcode()); | 2285 EXPECT_EQ(kArmVcvtS32F64, s[3]->arch_opcode()); |
| 2211 ASSERT_EQ(1U, s[3]->InputCount()); | 2286 ASSERT_EQ(1U, s[3]->InputCount()); |
| 2212 EXPECT_EQ(s.ToVreg(s[2]->Output()), s.ToVreg(s[3]->InputAt(0))); | 2287 EXPECT_EQ(s.ToVreg(s[2]->Output()), s.ToVreg(s[3]->InputAt(0))); |
| 2213 EXPECT_EQ(kArmMul, s[4]->arch_opcode()); | 2288 EXPECT_EQ(kArmMul, s[4]->arch_opcode()); |
| 2214 ASSERT_EQ(1U, s[4]->OutputCount()); | 2289 ASSERT_EQ(1U, s[4]->OutputCount()); |
| 2215 ASSERT_EQ(2U, s[4]->InputCount()); | 2290 ASSERT_EQ(2U, s[4]->InputCount()); |
| 2216 EXPECT_EQ(s.ToVreg(s[3]->Output()), s.ToVreg(s[4]->InputAt(0))); | 2291 EXPECT_EQ(s.ToVreg(s[3]->Output()), s.ToVreg(s[4]->InputAt(0))); |
| 2217 EXPECT_EQ(s.ToVreg(s[1]->InputAt(0)), s.ToVreg(s[4]->InputAt(1))); | 2292 EXPECT_EQ(s.ToVreg(s[1]->InputAt(0)), s.ToVreg(s[4]->InputAt(1))); |
| 2218 EXPECT_EQ(kArmSub, s[5]->arch_opcode()); | 2293 EXPECT_EQ(kArmSub, s[5]->arch_opcode()); |
| 2219 ASSERT_EQ(1U, s[5]->OutputCount()); | 2294 ASSERT_EQ(1U, s[5]->OutputCount()); |
| 2220 ASSERT_EQ(2U, s[5]->InputCount()); | 2295 ASSERT_EQ(2U, s[5]->InputCount()); |
| 2221 EXPECT_EQ(s.ToVreg(s[0]->InputAt(0)), s.ToVreg(s[5]->InputAt(0))); | 2296 EXPECT_EQ(s.ToVreg(s[0]->InputAt(0)), s.ToVreg(s[5]->InputAt(0))); |
| 2222 EXPECT_EQ(s.ToVreg(s[4]->Output()), s.ToVreg(s[5]->InputAt(1))); | 2297 EXPECT_EQ(s.ToVreg(s[4]->Output()), s.ToVreg(s[5]->InputAt(1))); |
| 2223 } | 2298 } |
| 2224 | 2299 |
| 2225 | 2300 |
| 2226 TEST_F(InstructionSelectorTest, Int32ModWithParametersForSUDIV) { | 2301 TEST_F(InstructionSelectorTest, Int32ModWithParametersForSUDIV) { |
| 2227 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); | 2302 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 2303 MachineType::Int32()); |
| 2228 m.Return(m.Int32Mod(m.Parameter(0), m.Parameter(1))); | 2304 m.Return(m.Int32Mod(m.Parameter(0), m.Parameter(1))); |
| 2229 Stream s = m.Build(SUDIV); | 2305 Stream s = m.Build(SUDIV); |
| 2230 ASSERT_EQ(3U, s.size()); | 2306 ASSERT_EQ(3U, s.size()); |
| 2231 EXPECT_EQ(kArmSdiv, s[0]->arch_opcode()); | 2307 EXPECT_EQ(kArmSdiv, s[0]->arch_opcode()); |
| 2232 ASSERT_EQ(1U, s[0]->OutputCount()); | 2308 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 2233 ASSERT_EQ(2U, s[0]->InputCount()); | 2309 ASSERT_EQ(2U, s[0]->InputCount()); |
| 2234 EXPECT_EQ(kArmMul, s[1]->arch_opcode()); | 2310 EXPECT_EQ(kArmMul, s[1]->arch_opcode()); |
| 2235 ASSERT_EQ(1U, s[1]->OutputCount()); | 2311 ASSERT_EQ(1U, s[1]->OutputCount()); |
| 2236 ASSERT_EQ(2U, s[1]->InputCount()); | 2312 ASSERT_EQ(2U, s[1]->InputCount()); |
| 2237 EXPECT_EQ(s.ToVreg(s[0]->Output()), s.ToVreg(s[1]->InputAt(0))); | 2313 EXPECT_EQ(s.ToVreg(s[0]->Output()), s.ToVreg(s[1]->InputAt(0))); |
| 2238 EXPECT_EQ(s.ToVreg(s[0]->InputAt(1)), s.ToVreg(s[1]->InputAt(1))); | 2314 EXPECT_EQ(s.ToVreg(s[0]->InputAt(1)), s.ToVreg(s[1]->InputAt(1))); |
| 2239 EXPECT_EQ(kArmSub, s[2]->arch_opcode()); | 2315 EXPECT_EQ(kArmSub, s[2]->arch_opcode()); |
| 2240 ASSERT_EQ(1U, s[2]->OutputCount()); | 2316 ASSERT_EQ(1U, s[2]->OutputCount()); |
| 2241 ASSERT_EQ(2U, s[2]->InputCount()); | 2317 ASSERT_EQ(2U, s[2]->InputCount()); |
| 2242 EXPECT_EQ(s.ToVreg(s[0]->InputAt(0)), s.ToVreg(s[2]->InputAt(0))); | 2318 EXPECT_EQ(s.ToVreg(s[0]->InputAt(0)), s.ToVreg(s[2]->InputAt(0))); |
| 2243 EXPECT_EQ(s.ToVreg(s[1]->Output()), s.ToVreg(s[2]->InputAt(1))); | 2319 EXPECT_EQ(s.ToVreg(s[1]->Output()), s.ToVreg(s[2]->InputAt(1))); |
| 2244 } | 2320 } |
| 2245 | 2321 |
| 2246 | 2322 |
| 2247 TEST_F(InstructionSelectorTest, Int32ModWithParametersForSUDIVAndMLS) { | 2323 TEST_F(InstructionSelectorTest, Int32ModWithParametersForSUDIVAndMLS) { |
| 2248 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); | 2324 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 2325 MachineType::Int32()); |
| 2249 m.Return(m.Int32Mod(m.Parameter(0), m.Parameter(1))); | 2326 m.Return(m.Int32Mod(m.Parameter(0), m.Parameter(1))); |
| 2250 Stream s = m.Build(MLS, SUDIV); | 2327 Stream s = m.Build(MLS, SUDIV); |
| 2251 ASSERT_EQ(2U, s.size()); | 2328 ASSERT_EQ(2U, s.size()); |
| 2252 EXPECT_EQ(kArmSdiv, s[0]->arch_opcode()); | 2329 EXPECT_EQ(kArmSdiv, s[0]->arch_opcode()); |
| 2253 ASSERT_EQ(1U, s[0]->OutputCount()); | 2330 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 2254 ASSERT_EQ(2U, s[0]->InputCount()); | 2331 ASSERT_EQ(2U, s[0]->InputCount()); |
| 2255 EXPECT_EQ(kArmMls, s[1]->arch_opcode()); | 2332 EXPECT_EQ(kArmMls, s[1]->arch_opcode()); |
| 2256 ASSERT_EQ(1U, s[1]->OutputCount()); | 2333 ASSERT_EQ(1U, s[1]->OutputCount()); |
| 2257 ASSERT_EQ(3U, s[1]->InputCount()); | 2334 ASSERT_EQ(3U, s[1]->InputCount()); |
| 2258 EXPECT_EQ(s.ToVreg(s[0]->Output()), s.ToVreg(s[1]->InputAt(0))); | 2335 EXPECT_EQ(s.ToVreg(s[0]->Output()), s.ToVreg(s[1]->InputAt(0))); |
| 2259 EXPECT_EQ(s.ToVreg(s[0]->InputAt(1)), s.ToVreg(s[1]->InputAt(1))); | 2336 EXPECT_EQ(s.ToVreg(s[0]->InputAt(1)), s.ToVreg(s[1]->InputAt(1))); |
| 2260 EXPECT_EQ(s.ToVreg(s[0]->InputAt(0)), s.ToVreg(s[1]->InputAt(2))); | 2337 EXPECT_EQ(s.ToVreg(s[0]->InputAt(0)), s.ToVreg(s[1]->InputAt(2))); |
| 2261 } | 2338 } |
| 2262 | 2339 |
| 2263 | 2340 |
| 2264 TEST_F(InstructionSelectorTest, Int32MulWithParameters) { | 2341 TEST_F(InstructionSelectorTest, Int32MulWithParameters) { |
| 2265 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); | 2342 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 2343 MachineType::Int32()); |
| 2266 m.Return(m.Int32Mul(m.Parameter(0), m.Parameter(1))); | 2344 m.Return(m.Int32Mul(m.Parameter(0), m.Parameter(1))); |
| 2267 Stream s = m.Build(); | 2345 Stream s = m.Build(); |
| 2268 ASSERT_EQ(1U, s.size()); | 2346 ASSERT_EQ(1U, s.size()); |
| 2269 EXPECT_EQ(kArmMul, s[0]->arch_opcode()); | 2347 EXPECT_EQ(kArmMul, s[0]->arch_opcode()); |
| 2270 EXPECT_EQ(2U, s[0]->InputCount()); | 2348 EXPECT_EQ(2U, s[0]->InputCount()); |
| 2271 EXPECT_EQ(1U, s[0]->OutputCount()); | 2349 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 2272 } | 2350 } |
| 2273 | 2351 |
| 2274 | 2352 |
| 2275 TEST_F(InstructionSelectorTest, Int32MulWithImmediate) { | 2353 TEST_F(InstructionSelectorTest, Int32MulWithImmediate) { |
| 2276 // x * (2^k + 1) -> x + (x >> k) | 2354 // x * (2^k + 1) -> x + (x >> k) |
| 2277 TRACED_FORRANGE(int32_t, k, 1, 30) { | 2355 TRACED_FORRANGE(int32_t, k, 1, 30) { |
| 2278 StreamBuilder m(this, kMachInt32, kMachInt32); | 2356 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
| 2279 m.Return(m.Int32Mul(m.Parameter(0), m.Int32Constant((1 << k) + 1))); | 2357 m.Return(m.Int32Mul(m.Parameter(0), m.Int32Constant((1 << k) + 1))); |
| 2280 Stream s = m.Build(); | 2358 Stream s = m.Build(); |
| 2281 ASSERT_EQ(1U, s.size()); | 2359 ASSERT_EQ(1U, s.size()); |
| 2282 EXPECT_EQ(kArmAdd, s[0]->arch_opcode()); | 2360 EXPECT_EQ(kArmAdd, s[0]->arch_opcode()); |
| 2283 EXPECT_EQ(kMode_Operand2_R_LSL_I, s[0]->addressing_mode()); | 2361 EXPECT_EQ(kMode_Operand2_R_LSL_I, s[0]->addressing_mode()); |
| 2284 ASSERT_EQ(3U, s[0]->InputCount()); | 2362 ASSERT_EQ(3U, s[0]->InputCount()); |
| 2285 EXPECT_EQ(s.ToVreg(s[0]->InputAt(0)), s.ToVreg(s[0]->InputAt(1))); | 2363 EXPECT_EQ(s.ToVreg(s[0]->InputAt(0)), s.ToVreg(s[0]->InputAt(1))); |
| 2286 EXPECT_EQ(k, s.ToInt32(s[0]->InputAt(2))); | 2364 EXPECT_EQ(k, s.ToInt32(s[0]->InputAt(2))); |
| 2287 EXPECT_EQ(1U, s[0]->OutputCount()); | 2365 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 2288 } | 2366 } |
| 2289 // x * (2^k - 1) -> -x + (x >> k) | 2367 // x * (2^k - 1) -> -x + (x >> k) |
| 2290 TRACED_FORRANGE(int32_t, k, 3, 30) { | 2368 TRACED_FORRANGE(int32_t, k, 3, 30) { |
| 2291 StreamBuilder m(this, kMachInt32, kMachInt32); | 2369 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
| 2292 m.Return(m.Int32Mul(m.Parameter(0), m.Int32Constant((1 << k) - 1))); | 2370 m.Return(m.Int32Mul(m.Parameter(0), m.Int32Constant((1 << k) - 1))); |
| 2293 Stream s = m.Build(); | 2371 Stream s = m.Build(); |
| 2294 ASSERT_EQ(1U, s.size()); | 2372 ASSERT_EQ(1U, s.size()); |
| 2295 EXPECT_EQ(kArmRsb, s[0]->arch_opcode()); | 2373 EXPECT_EQ(kArmRsb, s[0]->arch_opcode()); |
| 2296 EXPECT_EQ(kMode_Operand2_R_LSL_I, s[0]->addressing_mode()); | 2374 EXPECT_EQ(kMode_Operand2_R_LSL_I, s[0]->addressing_mode()); |
| 2297 ASSERT_EQ(3U, s[0]->InputCount()); | 2375 ASSERT_EQ(3U, s[0]->InputCount()); |
| 2298 EXPECT_EQ(s.ToVreg(s[0]->InputAt(0)), s.ToVreg(s[0]->InputAt(1))); | 2376 EXPECT_EQ(s.ToVreg(s[0]->InputAt(0)), s.ToVreg(s[0]->InputAt(1))); |
| 2299 EXPECT_EQ(k, s.ToInt32(s[0]->InputAt(2))); | 2377 EXPECT_EQ(k, s.ToInt32(s[0]->InputAt(2))); |
| 2300 EXPECT_EQ(1U, s[0]->OutputCount()); | 2378 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 2301 } | 2379 } |
| 2302 // (2^k + 1) * x -> x + (x >> k) | 2380 // (2^k + 1) * x -> x + (x >> k) |
| 2303 TRACED_FORRANGE(int32_t, k, 1, 30) { | 2381 TRACED_FORRANGE(int32_t, k, 1, 30) { |
| 2304 StreamBuilder m(this, kMachInt32, kMachInt32); | 2382 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
| 2305 m.Return(m.Int32Mul(m.Int32Constant((1 << k) + 1), m.Parameter(0))); | 2383 m.Return(m.Int32Mul(m.Int32Constant((1 << k) + 1), m.Parameter(0))); |
| 2306 Stream s = m.Build(); | 2384 Stream s = m.Build(); |
| 2307 ASSERT_EQ(1U, s.size()); | 2385 ASSERT_EQ(1U, s.size()); |
| 2308 EXPECT_EQ(kArmAdd, s[0]->arch_opcode()); | 2386 EXPECT_EQ(kArmAdd, s[0]->arch_opcode()); |
| 2309 EXPECT_EQ(kMode_Operand2_R_LSL_I, s[0]->addressing_mode()); | 2387 EXPECT_EQ(kMode_Operand2_R_LSL_I, s[0]->addressing_mode()); |
| 2310 ASSERT_EQ(3U, s[0]->InputCount()); | 2388 ASSERT_EQ(3U, s[0]->InputCount()); |
| 2311 EXPECT_EQ(s.ToVreg(s[0]->InputAt(0)), s.ToVreg(s[0]->InputAt(1))); | 2389 EXPECT_EQ(s.ToVreg(s[0]->InputAt(0)), s.ToVreg(s[0]->InputAt(1))); |
| 2312 EXPECT_EQ(k, s.ToInt32(s[0]->InputAt(2))); | 2390 EXPECT_EQ(k, s.ToInt32(s[0]->InputAt(2))); |
| 2313 EXPECT_EQ(1U, s[0]->OutputCount()); | 2391 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 2314 } | 2392 } |
| 2315 // x * (2^k - 1) -> -x + (x >> k) | 2393 // x * (2^k - 1) -> -x + (x >> k) |
| 2316 TRACED_FORRANGE(int32_t, k, 3, 30) { | 2394 TRACED_FORRANGE(int32_t, k, 3, 30) { |
| 2317 StreamBuilder m(this, kMachInt32, kMachInt32); | 2395 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
| 2318 m.Return(m.Int32Mul(m.Int32Constant((1 << k) - 1), m.Parameter(0))); | 2396 m.Return(m.Int32Mul(m.Int32Constant((1 << k) - 1), m.Parameter(0))); |
| 2319 Stream s = m.Build(); | 2397 Stream s = m.Build(); |
| 2320 ASSERT_EQ(1U, s.size()); | 2398 ASSERT_EQ(1U, s.size()); |
| 2321 EXPECT_EQ(kArmRsb, s[0]->arch_opcode()); | 2399 EXPECT_EQ(kArmRsb, s[0]->arch_opcode()); |
| 2322 EXPECT_EQ(kMode_Operand2_R_LSL_I, s[0]->addressing_mode()); | 2400 EXPECT_EQ(kMode_Operand2_R_LSL_I, s[0]->addressing_mode()); |
| 2323 ASSERT_EQ(3U, s[0]->InputCount()); | 2401 ASSERT_EQ(3U, s[0]->InputCount()); |
| 2324 EXPECT_EQ(s.ToVreg(s[0]->InputAt(0)), s.ToVreg(s[0]->InputAt(1))); | 2402 EXPECT_EQ(s.ToVreg(s[0]->InputAt(0)), s.ToVreg(s[0]->InputAt(1))); |
| 2325 EXPECT_EQ(k, s.ToInt32(s[0]->InputAt(2))); | 2403 EXPECT_EQ(k, s.ToInt32(s[0]->InputAt(2))); |
| 2326 EXPECT_EQ(1U, s[0]->OutputCount()); | 2404 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 2327 } | 2405 } |
| 2328 } | 2406 } |
| 2329 | 2407 |
| 2330 | 2408 |
| 2331 TEST_F(InstructionSelectorTest, Int32MulHighWithParameters) { | 2409 TEST_F(InstructionSelectorTest, Int32MulHighWithParameters) { |
| 2332 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); | 2410 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 2411 MachineType::Int32()); |
| 2333 Node* const p0 = m.Parameter(0); | 2412 Node* const p0 = m.Parameter(0); |
| 2334 Node* const p1 = m.Parameter(1); | 2413 Node* const p1 = m.Parameter(1); |
| 2335 Node* const n = m.Int32MulHigh(p0, p1); | 2414 Node* const n = m.Int32MulHigh(p0, p1); |
| 2336 m.Return(n); | 2415 m.Return(n); |
| 2337 Stream s = m.Build(); | 2416 Stream s = m.Build(); |
| 2338 ASSERT_EQ(1U, s.size()); | 2417 ASSERT_EQ(1U, s.size()); |
| 2339 EXPECT_EQ(kArmSmmul, s[0]->arch_opcode()); | 2418 EXPECT_EQ(kArmSmmul, s[0]->arch_opcode()); |
| 2340 ASSERT_EQ(2U, s[0]->InputCount()); | 2419 ASSERT_EQ(2U, s[0]->InputCount()); |
| 2341 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); | 2420 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
| 2342 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1))); | 2421 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1))); |
| 2343 ASSERT_EQ(1U, s[0]->OutputCount()); | 2422 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 2344 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | 2423 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
| 2345 } | 2424 } |
| 2346 | 2425 |
| 2347 | 2426 |
| 2348 TEST_F(InstructionSelectorTest, Uint32MulHighWithParameters) { | 2427 TEST_F(InstructionSelectorTest, Uint32MulHighWithParameters) { |
| 2349 StreamBuilder m(this, kMachUint32, kMachUint32, kMachUint32); | 2428 StreamBuilder m(this, MachineType::Uint32(), MachineType::Uint32(), |
| 2429 MachineType::Uint32()); |
| 2350 Node* const p0 = m.Parameter(0); | 2430 Node* const p0 = m.Parameter(0); |
| 2351 Node* const p1 = m.Parameter(1); | 2431 Node* const p1 = m.Parameter(1); |
| 2352 Node* const n = m.Uint32MulHigh(p0, p1); | 2432 Node* const n = m.Uint32MulHigh(p0, p1); |
| 2353 m.Return(n); | 2433 m.Return(n); |
| 2354 Stream s = m.Build(); | 2434 Stream s = m.Build(); |
| 2355 ASSERT_EQ(1U, s.size()); | 2435 ASSERT_EQ(1U, s.size()); |
| 2356 EXPECT_EQ(kArmUmull, s[0]->arch_opcode()); | 2436 EXPECT_EQ(kArmUmull, s[0]->arch_opcode()); |
| 2357 ASSERT_EQ(2U, s[0]->InputCount()); | 2437 ASSERT_EQ(2U, s[0]->InputCount()); |
| 2358 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); | 2438 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
| 2359 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1))); | 2439 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1))); |
| 2360 ASSERT_EQ(2U, s[0]->OutputCount()); | 2440 ASSERT_EQ(2U, s[0]->OutputCount()); |
| 2361 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->OutputAt(1))); | 2441 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->OutputAt(1))); |
| 2362 } | 2442 } |
| 2363 | 2443 |
| 2364 | 2444 |
| 2365 TEST_F(InstructionSelectorTest, Uint32DivWithParameters) { | 2445 TEST_F(InstructionSelectorTest, Uint32DivWithParameters) { |
| 2366 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); | 2446 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 2447 MachineType::Int32()); |
| 2367 m.Return(m.Uint32Div(m.Parameter(0), m.Parameter(1))); | 2448 m.Return(m.Uint32Div(m.Parameter(0), m.Parameter(1))); |
| 2368 Stream s = m.Build(); | 2449 Stream s = m.Build(); |
| 2369 ASSERT_EQ(4U, s.size()); | 2450 ASSERT_EQ(4U, s.size()); |
| 2370 EXPECT_EQ(kArmVcvtF64U32, s[0]->arch_opcode()); | 2451 EXPECT_EQ(kArmVcvtF64U32, s[0]->arch_opcode()); |
| 2371 ASSERT_EQ(1U, s[0]->OutputCount()); | 2452 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 2372 EXPECT_EQ(kArmVcvtF64U32, s[1]->arch_opcode()); | 2453 EXPECT_EQ(kArmVcvtF64U32, s[1]->arch_opcode()); |
| 2373 ASSERT_EQ(1U, s[1]->OutputCount()); | 2454 ASSERT_EQ(1U, s[1]->OutputCount()); |
| 2374 EXPECT_EQ(kArmVdivF64, s[2]->arch_opcode()); | 2455 EXPECT_EQ(kArmVdivF64, s[2]->arch_opcode()); |
| 2375 ASSERT_EQ(2U, s[2]->InputCount()); | 2456 ASSERT_EQ(2U, s[2]->InputCount()); |
| 2376 ASSERT_EQ(1U, s[2]->OutputCount()); | 2457 ASSERT_EQ(1U, s[2]->OutputCount()); |
| 2377 EXPECT_EQ(s.ToVreg(s[0]->Output()), s.ToVreg(s[2]->InputAt(0))); | 2458 EXPECT_EQ(s.ToVreg(s[0]->Output()), s.ToVreg(s[2]->InputAt(0))); |
| 2378 EXPECT_EQ(s.ToVreg(s[1]->Output()), s.ToVreg(s[2]->InputAt(1))); | 2459 EXPECT_EQ(s.ToVreg(s[1]->Output()), s.ToVreg(s[2]->InputAt(1))); |
| 2379 EXPECT_EQ(kArmVcvtU32F64, s[3]->arch_opcode()); | 2460 EXPECT_EQ(kArmVcvtU32F64, s[3]->arch_opcode()); |
| 2380 ASSERT_EQ(1U, s[3]->InputCount()); | 2461 ASSERT_EQ(1U, s[3]->InputCount()); |
| 2381 EXPECT_EQ(s.ToVreg(s[2]->Output()), s.ToVreg(s[3]->InputAt(0))); | 2462 EXPECT_EQ(s.ToVreg(s[2]->Output()), s.ToVreg(s[3]->InputAt(0))); |
| 2382 } | 2463 } |
| 2383 | 2464 |
| 2384 | 2465 |
| 2385 TEST_F(InstructionSelectorTest, Uint32DivWithParametersForSUDIV) { | 2466 TEST_F(InstructionSelectorTest, Uint32DivWithParametersForSUDIV) { |
| 2386 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); | 2467 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 2468 MachineType::Int32()); |
| 2387 m.Return(m.Uint32Div(m.Parameter(0), m.Parameter(1))); | 2469 m.Return(m.Uint32Div(m.Parameter(0), m.Parameter(1))); |
| 2388 Stream s = m.Build(SUDIV); | 2470 Stream s = m.Build(SUDIV); |
| 2389 ASSERT_EQ(1U, s.size()); | 2471 ASSERT_EQ(1U, s.size()); |
| 2390 EXPECT_EQ(kArmUdiv, s[0]->arch_opcode()); | 2472 EXPECT_EQ(kArmUdiv, s[0]->arch_opcode()); |
| 2391 } | 2473 } |
| 2392 | 2474 |
| 2393 | 2475 |
| 2394 TEST_F(InstructionSelectorTest, Uint32ModWithParameters) { | 2476 TEST_F(InstructionSelectorTest, Uint32ModWithParameters) { |
| 2395 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); | 2477 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 2478 MachineType::Int32()); |
| 2396 m.Return(m.Uint32Mod(m.Parameter(0), m.Parameter(1))); | 2479 m.Return(m.Uint32Mod(m.Parameter(0), m.Parameter(1))); |
| 2397 Stream s = m.Build(); | 2480 Stream s = m.Build(); |
| 2398 ASSERT_EQ(6U, s.size()); | 2481 ASSERT_EQ(6U, s.size()); |
| 2399 EXPECT_EQ(kArmVcvtF64U32, s[0]->arch_opcode()); | 2482 EXPECT_EQ(kArmVcvtF64U32, s[0]->arch_opcode()); |
| 2400 ASSERT_EQ(1U, s[0]->OutputCount()); | 2483 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 2401 EXPECT_EQ(kArmVcvtF64U32, s[1]->arch_opcode()); | 2484 EXPECT_EQ(kArmVcvtF64U32, s[1]->arch_opcode()); |
| 2402 ASSERT_EQ(1U, s[1]->OutputCount()); | 2485 ASSERT_EQ(1U, s[1]->OutputCount()); |
| 2403 EXPECT_EQ(kArmVdivF64, s[2]->arch_opcode()); | 2486 EXPECT_EQ(kArmVdivF64, s[2]->arch_opcode()); |
| 2404 ASSERT_EQ(2U, s[2]->InputCount()); | 2487 ASSERT_EQ(2U, s[2]->InputCount()); |
| 2405 ASSERT_EQ(1U, s[2]->OutputCount()); | 2488 ASSERT_EQ(1U, s[2]->OutputCount()); |
| 2406 EXPECT_EQ(s.ToVreg(s[0]->Output()), s.ToVreg(s[2]->InputAt(0))); | 2489 EXPECT_EQ(s.ToVreg(s[0]->Output()), s.ToVreg(s[2]->InputAt(0))); |
| 2407 EXPECT_EQ(s.ToVreg(s[1]->Output()), s.ToVreg(s[2]->InputAt(1))); | 2490 EXPECT_EQ(s.ToVreg(s[1]->Output()), s.ToVreg(s[2]->InputAt(1))); |
| 2408 EXPECT_EQ(kArmVcvtU32F64, s[3]->arch_opcode()); | 2491 EXPECT_EQ(kArmVcvtU32F64, s[3]->arch_opcode()); |
| 2409 ASSERT_EQ(1U, s[3]->InputCount()); | 2492 ASSERT_EQ(1U, s[3]->InputCount()); |
| 2410 EXPECT_EQ(s.ToVreg(s[2]->Output()), s.ToVreg(s[3]->InputAt(0))); | 2493 EXPECT_EQ(s.ToVreg(s[2]->Output()), s.ToVreg(s[3]->InputAt(0))); |
| 2411 EXPECT_EQ(kArmMul, s[4]->arch_opcode()); | 2494 EXPECT_EQ(kArmMul, s[4]->arch_opcode()); |
| 2412 ASSERT_EQ(1U, s[4]->OutputCount()); | 2495 ASSERT_EQ(1U, s[4]->OutputCount()); |
| 2413 ASSERT_EQ(2U, s[4]->InputCount()); | 2496 ASSERT_EQ(2U, s[4]->InputCount()); |
| 2414 EXPECT_EQ(s.ToVreg(s[3]->Output()), s.ToVreg(s[4]->InputAt(0))); | 2497 EXPECT_EQ(s.ToVreg(s[3]->Output()), s.ToVreg(s[4]->InputAt(0))); |
| 2415 EXPECT_EQ(s.ToVreg(s[1]->InputAt(0)), s.ToVreg(s[4]->InputAt(1))); | 2498 EXPECT_EQ(s.ToVreg(s[1]->InputAt(0)), s.ToVreg(s[4]->InputAt(1))); |
| 2416 EXPECT_EQ(kArmSub, s[5]->arch_opcode()); | 2499 EXPECT_EQ(kArmSub, s[5]->arch_opcode()); |
| 2417 ASSERT_EQ(1U, s[5]->OutputCount()); | 2500 ASSERT_EQ(1U, s[5]->OutputCount()); |
| 2418 ASSERT_EQ(2U, s[5]->InputCount()); | 2501 ASSERT_EQ(2U, s[5]->InputCount()); |
| 2419 EXPECT_EQ(s.ToVreg(s[0]->InputAt(0)), s.ToVreg(s[5]->InputAt(0))); | 2502 EXPECT_EQ(s.ToVreg(s[0]->InputAt(0)), s.ToVreg(s[5]->InputAt(0))); |
| 2420 EXPECT_EQ(s.ToVreg(s[4]->Output()), s.ToVreg(s[5]->InputAt(1))); | 2503 EXPECT_EQ(s.ToVreg(s[4]->Output()), s.ToVreg(s[5]->InputAt(1))); |
| 2421 } | 2504 } |
| 2422 | 2505 |
| 2423 | 2506 |
| 2424 TEST_F(InstructionSelectorTest, Uint32ModWithParametersForSUDIV) { | 2507 TEST_F(InstructionSelectorTest, Uint32ModWithParametersForSUDIV) { |
| 2425 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); | 2508 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 2509 MachineType::Int32()); |
| 2426 m.Return(m.Uint32Mod(m.Parameter(0), m.Parameter(1))); | 2510 m.Return(m.Uint32Mod(m.Parameter(0), m.Parameter(1))); |
| 2427 Stream s = m.Build(SUDIV); | 2511 Stream s = m.Build(SUDIV); |
| 2428 ASSERT_EQ(3U, s.size()); | 2512 ASSERT_EQ(3U, s.size()); |
| 2429 EXPECT_EQ(kArmUdiv, s[0]->arch_opcode()); | 2513 EXPECT_EQ(kArmUdiv, s[0]->arch_opcode()); |
| 2430 ASSERT_EQ(1U, s[0]->OutputCount()); | 2514 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 2431 ASSERT_EQ(2U, s[0]->InputCount()); | 2515 ASSERT_EQ(2U, s[0]->InputCount()); |
| 2432 EXPECT_EQ(kArmMul, s[1]->arch_opcode()); | 2516 EXPECT_EQ(kArmMul, s[1]->arch_opcode()); |
| 2433 ASSERT_EQ(1U, s[1]->OutputCount()); | 2517 ASSERT_EQ(1U, s[1]->OutputCount()); |
| 2434 ASSERT_EQ(2U, s[1]->InputCount()); | 2518 ASSERT_EQ(2U, s[1]->InputCount()); |
| 2435 EXPECT_EQ(s.ToVreg(s[0]->Output()), s.ToVreg(s[1]->InputAt(0))); | 2519 EXPECT_EQ(s.ToVreg(s[0]->Output()), s.ToVreg(s[1]->InputAt(0))); |
| 2436 EXPECT_EQ(s.ToVreg(s[0]->InputAt(1)), s.ToVreg(s[1]->InputAt(1))); | 2520 EXPECT_EQ(s.ToVreg(s[0]->InputAt(1)), s.ToVreg(s[1]->InputAt(1))); |
| 2437 EXPECT_EQ(kArmSub, s[2]->arch_opcode()); | 2521 EXPECT_EQ(kArmSub, s[2]->arch_opcode()); |
| 2438 ASSERT_EQ(1U, s[2]->OutputCount()); | 2522 ASSERT_EQ(1U, s[2]->OutputCount()); |
| 2439 ASSERT_EQ(2U, s[2]->InputCount()); | 2523 ASSERT_EQ(2U, s[2]->InputCount()); |
| 2440 EXPECT_EQ(s.ToVreg(s[0]->InputAt(0)), s.ToVreg(s[2]->InputAt(0))); | 2524 EXPECT_EQ(s.ToVreg(s[0]->InputAt(0)), s.ToVreg(s[2]->InputAt(0))); |
| 2441 EXPECT_EQ(s.ToVreg(s[1]->Output()), s.ToVreg(s[2]->InputAt(1))); | 2525 EXPECT_EQ(s.ToVreg(s[1]->Output()), s.ToVreg(s[2]->InputAt(1))); |
| 2442 } | 2526 } |
| 2443 | 2527 |
| 2444 | 2528 |
| 2445 TEST_F(InstructionSelectorTest, Uint32ModWithParametersForSUDIVAndMLS) { | 2529 TEST_F(InstructionSelectorTest, Uint32ModWithParametersForSUDIVAndMLS) { |
| 2446 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); | 2530 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 2531 MachineType::Int32()); |
| 2447 m.Return(m.Uint32Mod(m.Parameter(0), m.Parameter(1))); | 2532 m.Return(m.Uint32Mod(m.Parameter(0), m.Parameter(1))); |
| 2448 Stream s = m.Build(MLS, SUDIV); | 2533 Stream s = m.Build(MLS, SUDIV); |
| 2449 ASSERT_EQ(2U, s.size()); | 2534 ASSERT_EQ(2U, s.size()); |
| 2450 EXPECT_EQ(kArmUdiv, s[0]->arch_opcode()); | 2535 EXPECT_EQ(kArmUdiv, s[0]->arch_opcode()); |
| 2451 ASSERT_EQ(1U, s[0]->OutputCount()); | 2536 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 2452 ASSERT_EQ(2U, s[0]->InputCount()); | 2537 ASSERT_EQ(2U, s[0]->InputCount()); |
| 2453 EXPECT_EQ(kArmMls, s[1]->arch_opcode()); | 2538 EXPECT_EQ(kArmMls, s[1]->arch_opcode()); |
| 2454 ASSERT_EQ(1U, s[1]->OutputCount()); | 2539 ASSERT_EQ(1U, s[1]->OutputCount()); |
| 2455 ASSERT_EQ(3U, s[1]->InputCount()); | 2540 ASSERT_EQ(3U, s[1]->InputCount()); |
| 2456 EXPECT_EQ(s.ToVreg(s[0]->Output()), s.ToVreg(s[1]->InputAt(0))); | 2541 EXPECT_EQ(s.ToVreg(s[0]->Output()), s.ToVreg(s[1]->InputAt(0))); |
| 2457 EXPECT_EQ(s.ToVreg(s[0]->InputAt(1)), s.ToVreg(s[1]->InputAt(1))); | 2542 EXPECT_EQ(s.ToVreg(s[0]->InputAt(1)), s.ToVreg(s[1]->InputAt(1))); |
| 2458 EXPECT_EQ(s.ToVreg(s[0]->InputAt(0)), s.ToVreg(s[1]->InputAt(2))); | 2543 EXPECT_EQ(s.ToVreg(s[0]->InputAt(0)), s.ToVreg(s[1]->InputAt(2))); |
| 2459 } | 2544 } |
| 2460 | 2545 |
| 2461 | 2546 |
| 2462 TEST_F(InstructionSelectorTest, Word32AndWithUbfxImmediateForARMv7) { | 2547 TEST_F(InstructionSelectorTest, Word32AndWithUbfxImmediateForARMv7) { |
| 2463 TRACED_FORRANGE(int32_t, width, 1, 32) { | 2548 TRACED_FORRANGE(int32_t, width, 1, 32) { |
| 2464 StreamBuilder m(this, kMachInt32, kMachInt32); | 2549 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
| 2465 m.Return(m.Word32And(m.Parameter(0), | 2550 m.Return(m.Word32And(m.Parameter(0), |
| 2466 m.Int32Constant(0xffffffffu >> (32 - width)))); | 2551 m.Int32Constant(0xffffffffu >> (32 - width)))); |
| 2467 Stream s = m.Build(ARMv7); | 2552 Stream s = m.Build(ARMv7); |
| 2468 ASSERT_EQ(1U, s.size()); | 2553 ASSERT_EQ(1U, s.size()); |
| 2469 EXPECT_EQ(kArmUbfx, s[0]->arch_opcode()); | 2554 EXPECT_EQ(kArmUbfx, s[0]->arch_opcode()); |
| 2470 ASSERT_EQ(3U, s[0]->InputCount()); | 2555 ASSERT_EQ(3U, s[0]->InputCount()); |
| 2471 EXPECT_EQ(0, s.ToInt32(s[0]->InputAt(1))); | 2556 EXPECT_EQ(0, s.ToInt32(s[0]->InputAt(1))); |
| 2472 EXPECT_EQ(width, s.ToInt32(s[0]->InputAt(2))); | 2557 EXPECT_EQ(width, s.ToInt32(s[0]->InputAt(2))); |
| 2473 } | 2558 } |
| 2474 TRACED_FORRANGE(int32_t, width, 1, 32) { | 2559 TRACED_FORRANGE(int32_t, width, 1, 32) { |
| 2475 StreamBuilder m(this, kMachInt32, kMachInt32); | 2560 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
| 2476 m.Return(m.Word32And(m.Int32Constant(0xffffffffu >> (32 - width)), | 2561 m.Return(m.Word32And(m.Int32Constant(0xffffffffu >> (32 - width)), |
| 2477 m.Parameter(0))); | 2562 m.Parameter(0))); |
| 2478 Stream s = m.Build(ARMv7); | 2563 Stream s = m.Build(ARMv7); |
| 2479 ASSERT_EQ(1U, s.size()); | 2564 ASSERT_EQ(1U, s.size()); |
| 2480 EXPECT_EQ(kArmUbfx, s[0]->arch_opcode()); | 2565 EXPECT_EQ(kArmUbfx, s[0]->arch_opcode()); |
| 2481 ASSERT_EQ(3U, s[0]->InputCount()); | 2566 ASSERT_EQ(3U, s[0]->InputCount()); |
| 2482 EXPECT_EQ(0, s.ToInt32(s[0]->InputAt(1))); | 2567 EXPECT_EQ(0, s.ToInt32(s[0]->InputAt(1))); |
| 2483 EXPECT_EQ(width, s.ToInt32(s[0]->InputAt(2))); | 2568 EXPECT_EQ(width, s.ToInt32(s[0]->InputAt(2))); |
| 2484 } | 2569 } |
| 2485 } | 2570 } |
| 2486 | 2571 |
| 2487 | 2572 |
| 2488 TEST_F(InstructionSelectorTest, Word32AndWithBfcImmediateForARMv7) { | 2573 TEST_F(InstructionSelectorTest, Word32AndWithBfcImmediateForARMv7) { |
| 2489 TRACED_FORRANGE(int32_t, lsb, 0, 31) { | 2574 TRACED_FORRANGE(int32_t, lsb, 0, 31) { |
| 2490 TRACED_FORRANGE(int32_t, width, 9, (32 - lsb) - 1) { | 2575 TRACED_FORRANGE(int32_t, width, 9, (32 - lsb) - 1) { |
| 2491 StreamBuilder m(this, kMachInt32, kMachInt32); | 2576 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
| 2492 m.Return(m.Word32And( | 2577 m.Return(m.Word32And( |
| 2493 m.Parameter(0), | 2578 m.Parameter(0), |
| 2494 m.Int32Constant(~((0xffffffffu >> (32 - width)) << lsb)))); | 2579 m.Int32Constant(~((0xffffffffu >> (32 - width)) << lsb)))); |
| 2495 Stream s = m.Build(ARMv7); | 2580 Stream s = m.Build(ARMv7); |
| 2496 ASSERT_EQ(1U, s.size()); | 2581 ASSERT_EQ(1U, s.size()); |
| 2497 EXPECT_EQ(kArmBfc, s[0]->arch_opcode()); | 2582 EXPECT_EQ(kArmBfc, s[0]->arch_opcode()); |
| 2498 ASSERT_EQ(1U, s[0]->OutputCount()); | 2583 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 2499 EXPECT_TRUE( | 2584 EXPECT_TRUE( |
| 2500 UnallocatedOperand::cast(s[0]->Output())->HasSameAsInputPolicy()); | 2585 UnallocatedOperand::cast(s[0]->Output())->HasSameAsInputPolicy()); |
| 2501 ASSERT_EQ(3U, s[0]->InputCount()); | 2586 ASSERT_EQ(3U, s[0]->InputCount()); |
| 2502 EXPECT_EQ(lsb, s.ToInt32(s[0]->InputAt(1))); | 2587 EXPECT_EQ(lsb, s.ToInt32(s[0]->InputAt(1))); |
| 2503 EXPECT_EQ(width, s.ToInt32(s[0]->InputAt(2))); | 2588 EXPECT_EQ(width, s.ToInt32(s[0]->InputAt(2))); |
| 2504 } | 2589 } |
| 2505 } | 2590 } |
| 2506 TRACED_FORRANGE(int32_t, lsb, 0, 31) { | 2591 TRACED_FORRANGE(int32_t, lsb, 0, 31) { |
| 2507 TRACED_FORRANGE(int32_t, width, 9, (32 - lsb) - 1) { | 2592 TRACED_FORRANGE(int32_t, width, 9, (32 - lsb) - 1) { |
| 2508 StreamBuilder m(this, kMachInt32, kMachInt32); | 2593 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
| 2509 m.Return( | 2594 m.Return( |
| 2510 m.Word32And(m.Int32Constant(~((0xffffffffu >> (32 - width)) << lsb)), | 2595 m.Word32And(m.Int32Constant(~((0xffffffffu >> (32 - width)) << lsb)), |
| 2511 m.Parameter(0))); | 2596 m.Parameter(0))); |
| 2512 Stream s = m.Build(ARMv7); | 2597 Stream s = m.Build(ARMv7); |
| 2513 ASSERT_EQ(1U, s.size()); | 2598 ASSERT_EQ(1U, s.size()); |
| 2514 EXPECT_EQ(kArmBfc, s[0]->arch_opcode()); | 2599 EXPECT_EQ(kArmBfc, s[0]->arch_opcode()); |
| 2515 ASSERT_EQ(1U, s[0]->OutputCount()); | 2600 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 2516 EXPECT_TRUE( | 2601 EXPECT_TRUE( |
| 2517 UnallocatedOperand::cast(s[0]->Output())->HasSameAsInputPolicy()); | 2602 UnallocatedOperand::cast(s[0]->Output())->HasSameAsInputPolicy()); |
| 2518 ASSERT_EQ(3U, s[0]->InputCount()); | 2603 ASSERT_EQ(3U, s[0]->InputCount()); |
| 2519 EXPECT_EQ(lsb, s.ToInt32(s[0]->InputAt(1))); | 2604 EXPECT_EQ(lsb, s.ToInt32(s[0]->InputAt(1))); |
| 2520 EXPECT_EQ(width, s.ToInt32(s[0]->InputAt(2))); | 2605 EXPECT_EQ(width, s.ToInt32(s[0]->InputAt(2))); |
| 2521 } | 2606 } |
| 2522 } | 2607 } |
| 2523 } | 2608 } |
| 2524 | 2609 |
| 2525 | 2610 |
| 2526 TEST_F(InstructionSelectorTest, Word32AndWith0xffff) { | 2611 TEST_F(InstructionSelectorTest, Word32AndWith0xffff) { |
| 2527 { | 2612 { |
| 2528 StreamBuilder m(this, kMachInt32, kMachInt32); | 2613 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
| 2529 Node* const p0 = m.Parameter(0); | 2614 Node* const p0 = m.Parameter(0); |
| 2530 Node* const r = m.Word32And(p0, m.Int32Constant(0xffff)); | 2615 Node* const r = m.Word32And(p0, m.Int32Constant(0xffff)); |
| 2531 m.Return(r); | 2616 m.Return(r); |
| 2532 Stream s = m.Build(); | 2617 Stream s = m.Build(); |
| 2533 ASSERT_EQ(1U, s.size()); | 2618 ASSERT_EQ(1U, s.size()); |
| 2534 EXPECT_EQ(kArmUxth, s[0]->arch_opcode()); | 2619 EXPECT_EQ(kArmUxth, s[0]->arch_opcode()); |
| 2535 ASSERT_EQ(2U, s[0]->InputCount()); | 2620 ASSERT_EQ(2U, s[0]->InputCount()); |
| 2536 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); | 2621 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
| 2537 EXPECT_EQ(0, s.ToInt32(s[0]->InputAt(1))); | 2622 EXPECT_EQ(0, s.ToInt32(s[0]->InputAt(1))); |
| 2538 ASSERT_EQ(1U, s[0]->OutputCount()); | 2623 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 2539 EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output())); | 2624 EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output())); |
| 2540 } | 2625 } |
| 2541 { | 2626 { |
| 2542 StreamBuilder m(this, kMachInt32, kMachInt32); | 2627 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
| 2543 Node* const p0 = m.Parameter(0); | 2628 Node* const p0 = m.Parameter(0); |
| 2544 Node* const r = m.Word32And(m.Int32Constant(0xffff), p0); | 2629 Node* const r = m.Word32And(m.Int32Constant(0xffff), p0); |
| 2545 m.Return(r); | 2630 m.Return(r); |
| 2546 Stream s = m.Build(); | 2631 Stream s = m.Build(); |
| 2547 ASSERT_EQ(1U, s.size()); | 2632 ASSERT_EQ(1U, s.size()); |
| 2548 EXPECT_EQ(kArmUxth, s[0]->arch_opcode()); | 2633 EXPECT_EQ(kArmUxth, s[0]->arch_opcode()); |
| 2549 ASSERT_EQ(2U, s[0]->InputCount()); | 2634 ASSERT_EQ(2U, s[0]->InputCount()); |
| 2550 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); | 2635 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
| 2551 EXPECT_EQ(0, s.ToInt32(s[0]->InputAt(1))); | 2636 EXPECT_EQ(0, s.ToInt32(s[0]->InputAt(1))); |
| 2552 ASSERT_EQ(1U, s[0]->OutputCount()); | 2637 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 2553 EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output())); | 2638 EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output())); |
| 2554 } | 2639 } |
| 2555 } | 2640 } |
| 2556 | 2641 |
| 2557 | 2642 |
| 2558 TEST_F(InstructionSelectorTest, Word32SarWithWord32Shl) { | 2643 TEST_F(InstructionSelectorTest, Word32SarWithWord32Shl) { |
| 2559 { | 2644 { |
| 2560 StreamBuilder m(this, kMachInt32, kMachInt32); | 2645 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
| 2561 Node* const p0 = m.Parameter(0); | 2646 Node* const p0 = m.Parameter(0); |
| 2562 Node* const r = | 2647 Node* const r = |
| 2563 m.Word32Sar(m.Word32Shl(p0, m.Int32Constant(24)), m.Int32Constant(24)); | 2648 m.Word32Sar(m.Word32Shl(p0, m.Int32Constant(24)), m.Int32Constant(24)); |
| 2564 m.Return(r); | 2649 m.Return(r); |
| 2565 Stream s = m.Build(); | 2650 Stream s = m.Build(); |
| 2566 ASSERT_EQ(1U, s.size()); | 2651 ASSERT_EQ(1U, s.size()); |
| 2567 EXPECT_EQ(kArmSxtb, s[0]->arch_opcode()); | 2652 EXPECT_EQ(kArmSxtb, s[0]->arch_opcode()); |
| 2568 ASSERT_EQ(2U, s[0]->InputCount()); | 2653 ASSERT_EQ(2U, s[0]->InputCount()); |
| 2569 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); | 2654 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
| 2570 EXPECT_EQ(0, s.ToInt32(s[0]->InputAt(1))); | 2655 EXPECT_EQ(0, s.ToInt32(s[0]->InputAt(1))); |
| 2571 ASSERT_EQ(1U, s[0]->OutputCount()); | 2656 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 2572 EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output())); | 2657 EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output())); |
| 2573 } | 2658 } |
| 2574 { | 2659 { |
| 2575 StreamBuilder m(this, kMachInt32, kMachInt32); | 2660 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
| 2576 Node* const p0 = m.Parameter(0); | 2661 Node* const p0 = m.Parameter(0); |
| 2577 Node* const r = | 2662 Node* const r = |
| 2578 m.Word32Sar(m.Word32Shl(p0, m.Int32Constant(16)), m.Int32Constant(16)); | 2663 m.Word32Sar(m.Word32Shl(p0, m.Int32Constant(16)), m.Int32Constant(16)); |
| 2579 m.Return(r); | 2664 m.Return(r); |
| 2580 Stream s = m.Build(); | 2665 Stream s = m.Build(); |
| 2581 ASSERT_EQ(1U, s.size()); | 2666 ASSERT_EQ(1U, s.size()); |
| 2582 EXPECT_EQ(kArmSxth, s[0]->arch_opcode()); | 2667 EXPECT_EQ(kArmSxth, s[0]->arch_opcode()); |
| 2583 ASSERT_EQ(2U, s[0]->InputCount()); | 2668 ASSERT_EQ(2U, s[0]->InputCount()); |
| 2584 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); | 2669 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
| 2585 EXPECT_EQ(0, s.ToInt32(s[0]->InputAt(1))); | 2670 EXPECT_EQ(0, s.ToInt32(s[0]->InputAt(1))); |
| 2586 ASSERT_EQ(1U, s[0]->OutputCount()); | 2671 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 2587 EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output())); | 2672 EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output())); |
| 2588 } | 2673 } |
| 2589 } | 2674 } |
| 2590 | 2675 |
| 2591 | 2676 |
| 2592 TEST_F(InstructionSelectorTest, Word32ShrWithWord32AndWithImmediateForARMv7) { | 2677 TEST_F(InstructionSelectorTest, Word32ShrWithWord32AndWithImmediateForARMv7) { |
| 2593 TRACED_FORRANGE(int32_t, lsb, 0, 31) { | 2678 TRACED_FORRANGE(int32_t, lsb, 0, 31) { |
| 2594 TRACED_FORRANGE(int32_t, width, 1, 32 - lsb) { | 2679 TRACED_FORRANGE(int32_t, width, 1, 32 - lsb) { |
| 2595 uint32_t max = 1 << lsb; | 2680 uint32_t max = 1 << lsb; |
| 2596 if (max > static_cast<uint32_t>(kMaxInt)) max -= 1; | 2681 if (max > static_cast<uint32_t>(kMaxInt)) max -= 1; |
| 2597 uint32_t jnk = rng()->NextInt(max); | 2682 uint32_t jnk = rng()->NextInt(max); |
| 2598 uint32_t msk = ((0xffffffffu >> (32 - width)) << lsb) | jnk; | 2683 uint32_t msk = ((0xffffffffu >> (32 - width)) << lsb) | jnk; |
| 2599 StreamBuilder m(this, kMachInt32, kMachInt32); | 2684 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
| 2600 m.Return(m.Word32Shr(m.Word32And(m.Parameter(0), m.Int32Constant(msk)), | 2685 m.Return(m.Word32Shr(m.Word32And(m.Parameter(0), m.Int32Constant(msk)), |
| 2601 m.Int32Constant(lsb))); | 2686 m.Int32Constant(lsb))); |
| 2602 Stream s = m.Build(ARMv7); | 2687 Stream s = m.Build(ARMv7); |
| 2603 ASSERT_EQ(1U, s.size()); | 2688 ASSERT_EQ(1U, s.size()); |
| 2604 EXPECT_EQ(kArmUbfx, s[0]->arch_opcode()); | 2689 EXPECT_EQ(kArmUbfx, s[0]->arch_opcode()); |
| 2605 ASSERT_EQ(3U, s[0]->InputCount()); | 2690 ASSERT_EQ(3U, s[0]->InputCount()); |
| 2606 EXPECT_EQ(lsb, s.ToInt32(s[0]->InputAt(1))); | 2691 EXPECT_EQ(lsb, s.ToInt32(s[0]->InputAt(1))); |
| 2607 EXPECT_EQ(width, s.ToInt32(s[0]->InputAt(2))); | 2692 EXPECT_EQ(width, s.ToInt32(s[0]->InputAt(2))); |
| 2608 } | 2693 } |
| 2609 } | 2694 } |
| 2610 TRACED_FORRANGE(int32_t, lsb, 0, 31) { | 2695 TRACED_FORRANGE(int32_t, lsb, 0, 31) { |
| 2611 TRACED_FORRANGE(int32_t, width, 1, 32 - lsb) { | 2696 TRACED_FORRANGE(int32_t, width, 1, 32 - lsb) { |
| 2612 uint32_t max = 1 << lsb; | 2697 uint32_t max = 1 << lsb; |
| 2613 if (max > static_cast<uint32_t>(kMaxInt)) max -= 1; | 2698 if (max > static_cast<uint32_t>(kMaxInt)) max -= 1; |
| 2614 uint32_t jnk = rng()->NextInt(max); | 2699 uint32_t jnk = rng()->NextInt(max); |
| 2615 uint32_t msk = ((0xffffffffu >> (32 - width)) << lsb) | jnk; | 2700 uint32_t msk = ((0xffffffffu >> (32 - width)) << lsb) | jnk; |
| 2616 StreamBuilder m(this, kMachInt32, kMachInt32); | 2701 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
| 2617 m.Return(m.Word32Shr(m.Word32And(m.Int32Constant(msk), m.Parameter(0)), | 2702 m.Return(m.Word32Shr(m.Word32And(m.Int32Constant(msk), m.Parameter(0)), |
| 2618 m.Int32Constant(lsb))); | 2703 m.Int32Constant(lsb))); |
| 2619 Stream s = m.Build(ARMv7); | 2704 Stream s = m.Build(ARMv7); |
| 2620 ASSERT_EQ(1U, s.size()); | 2705 ASSERT_EQ(1U, s.size()); |
| 2621 EXPECT_EQ(kArmUbfx, s[0]->arch_opcode()); | 2706 EXPECT_EQ(kArmUbfx, s[0]->arch_opcode()); |
| 2622 ASSERT_EQ(3U, s[0]->InputCount()); | 2707 ASSERT_EQ(3U, s[0]->InputCount()); |
| 2623 EXPECT_EQ(lsb, s.ToInt32(s[0]->InputAt(1))); | 2708 EXPECT_EQ(lsb, s.ToInt32(s[0]->InputAt(1))); |
| 2624 EXPECT_EQ(width, s.ToInt32(s[0]->InputAt(2))); | 2709 EXPECT_EQ(width, s.ToInt32(s[0]->InputAt(2))); |
| 2625 } | 2710 } |
| 2626 } | 2711 } |
| 2627 } | 2712 } |
| 2628 | 2713 |
| 2629 | 2714 |
| 2630 TEST_F(InstructionSelectorTest, Word32AndWithWord32Not) { | 2715 TEST_F(InstructionSelectorTest, Word32AndWithWord32Not) { |
| 2631 { | 2716 { |
| 2632 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); | 2717 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 2718 MachineType::Int32()); |
| 2633 m.Return(m.Word32And(m.Parameter(0), m.Word32Not(m.Parameter(1)))); | 2719 m.Return(m.Word32And(m.Parameter(0), m.Word32Not(m.Parameter(1)))); |
| 2634 Stream s = m.Build(); | 2720 Stream s = m.Build(); |
| 2635 ASSERT_EQ(1U, s.size()); | 2721 ASSERT_EQ(1U, s.size()); |
| 2636 EXPECT_EQ(kArmBic, s[0]->arch_opcode()); | 2722 EXPECT_EQ(kArmBic, s[0]->arch_opcode()); |
| 2637 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); | 2723 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); |
| 2638 EXPECT_EQ(2U, s[0]->InputCount()); | 2724 EXPECT_EQ(2U, s[0]->InputCount()); |
| 2639 EXPECT_EQ(1U, s[0]->OutputCount()); | 2725 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 2640 } | 2726 } |
| 2641 { | 2727 { |
| 2642 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); | 2728 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 2729 MachineType::Int32()); |
| 2643 m.Return(m.Word32And(m.Word32Not(m.Parameter(0)), m.Parameter(1))); | 2730 m.Return(m.Word32And(m.Word32Not(m.Parameter(0)), m.Parameter(1))); |
| 2644 Stream s = m.Build(); | 2731 Stream s = m.Build(); |
| 2645 ASSERT_EQ(1U, s.size()); | 2732 ASSERT_EQ(1U, s.size()); |
| 2646 EXPECT_EQ(kArmBic, s[0]->arch_opcode()); | 2733 EXPECT_EQ(kArmBic, s[0]->arch_opcode()); |
| 2647 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); | 2734 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); |
| 2648 EXPECT_EQ(2U, s[0]->InputCount()); | 2735 EXPECT_EQ(2U, s[0]->InputCount()); |
| 2649 EXPECT_EQ(1U, s[0]->OutputCount()); | 2736 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 2650 } | 2737 } |
| 2651 } | 2738 } |
| 2652 | 2739 |
| 2653 | 2740 |
| 2654 TEST_F(InstructionSelectorTest, Word32EqualWithParameters) { | 2741 TEST_F(InstructionSelectorTest, Word32EqualWithParameters) { |
| 2655 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); | 2742 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| 2743 MachineType::Int32()); |
| 2656 m.Return(m.Word32Equal(m.Parameter(0), m.Parameter(1))); | 2744 m.Return(m.Word32Equal(m.Parameter(0), m.Parameter(1))); |
| 2657 Stream s = m.Build(); | 2745 Stream s = m.Build(); |
| 2658 ASSERT_EQ(1U, s.size()); | 2746 ASSERT_EQ(1U, s.size()); |
| 2659 EXPECT_EQ(kArmCmp, s[0]->arch_opcode()); | 2747 EXPECT_EQ(kArmCmp, s[0]->arch_opcode()); |
| 2660 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); | 2748 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); |
| 2661 EXPECT_EQ(2U, s[0]->InputCount()); | 2749 EXPECT_EQ(2U, s[0]->InputCount()); |
| 2662 EXPECT_EQ(1U, s[0]->OutputCount()); | 2750 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 2663 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 2751 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 2664 EXPECT_EQ(kEqual, s[0]->flags_condition()); | 2752 EXPECT_EQ(kEqual, s[0]->flags_condition()); |
| 2665 } | 2753 } |
| 2666 | 2754 |
| 2667 | 2755 |
| 2668 TEST_F(InstructionSelectorTest, Word32EqualWithImmediate) { | 2756 TEST_F(InstructionSelectorTest, Word32EqualWithImmediate) { |
| 2669 TRACED_FOREACH(int32_t, imm, kImmediates) { | 2757 TRACED_FOREACH(int32_t, imm, kImmediates) { |
| 2670 if (imm == 0) continue; | 2758 if (imm == 0) continue; |
| 2671 StreamBuilder m(this, kMachInt32, kMachInt32); | 2759 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
| 2672 m.Return(m.Word32Equal(m.Parameter(0), m.Int32Constant(imm))); | 2760 m.Return(m.Word32Equal(m.Parameter(0), m.Int32Constant(imm))); |
| 2673 Stream s = m.Build(); | 2761 Stream s = m.Build(); |
| 2674 ASSERT_EQ(1U, s.size()); | 2762 ASSERT_EQ(1U, s.size()); |
| 2675 EXPECT_EQ(kArmCmp, s[0]->arch_opcode()); | 2763 EXPECT_EQ(kArmCmp, s[0]->arch_opcode()); |
| 2676 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); | 2764 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); |
| 2677 ASSERT_EQ(2U, s[0]->InputCount()); | 2765 ASSERT_EQ(2U, s[0]->InputCount()); |
| 2678 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); | 2766 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); |
| 2679 EXPECT_EQ(1U, s[0]->OutputCount()); | 2767 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 2680 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 2768 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 2681 EXPECT_EQ(kEqual, s[0]->flags_condition()); | 2769 EXPECT_EQ(kEqual, s[0]->flags_condition()); |
| 2682 } | 2770 } |
| 2683 TRACED_FOREACH(int32_t, imm, kImmediates) { | 2771 TRACED_FOREACH(int32_t, imm, kImmediates) { |
| 2684 if (imm == 0) continue; | 2772 if (imm == 0) continue; |
| 2685 StreamBuilder m(this, kMachInt32, kMachInt32); | 2773 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
| 2686 m.Return(m.Word32Equal(m.Int32Constant(imm), m.Parameter(0))); | 2774 m.Return(m.Word32Equal(m.Int32Constant(imm), m.Parameter(0))); |
| 2687 Stream s = m.Build(); | 2775 Stream s = m.Build(); |
| 2688 ASSERT_EQ(1U, s.size()); | 2776 ASSERT_EQ(1U, s.size()); |
| 2689 EXPECT_EQ(kArmCmp, s[0]->arch_opcode()); | 2777 EXPECT_EQ(kArmCmp, s[0]->arch_opcode()); |
| 2690 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); | 2778 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); |
| 2691 ASSERT_EQ(2U, s[0]->InputCount()); | 2779 ASSERT_EQ(2U, s[0]->InputCount()); |
| 2692 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); | 2780 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); |
| 2693 EXPECT_EQ(1U, s[0]->OutputCount()); | 2781 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 2694 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 2782 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 2695 EXPECT_EQ(kEqual, s[0]->flags_condition()); | 2783 EXPECT_EQ(kEqual, s[0]->flags_condition()); |
| 2696 } | 2784 } |
| 2697 } | 2785 } |
| 2698 | 2786 |
| 2699 | 2787 |
| 2700 TEST_F(InstructionSelectorTest, Word32EqualWithZero) { | 2788 TEST_F(InstructionSelectorTest, Word32EqualWithZero) { |
| 2701 { | 2789 { |
| 2702 StreamBuilder m(this, kMachInt32, kMachInt32); | 2790 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
| 2703 m.Return(m.Word32Equal(m.Parameter(0), m.Int32Constant(0))); | 2791 m.Return(m.Word32Equal(m.Parameter(0), m.Int32Constant(0))); |
| 2704 Stream s = m.Build(); | 2792 Stream s = m.Build(); |
| 2705 ASSERT_EQ(1U, s.size()); | 2793 ASSERT_EQ(1U, s.size()); |
| 2706 EXPECT_EQ(kArmTst, s[0]->arch_opcode()); | 2794 EXPECT_EQ(kArmTst, s[0]->arch_opcode()); |
| 2707 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); | 2795 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); |
| 2708 ASSERT_EQ(2U, s[0]->InputCount()); | 2796 ASSERT_EQ(2U, s[0]->InputCount()); |
| 2709 EXPECT_EQ(s.ToVreg(s[0]->InputAt(0)), s.ToVreg(s[0]->InputAt(1))); | 2797 EXPECT_EQ(s.ToVreg(s[0]->InputAt(0)), s.ToVreg(s[0]->InputAt(1))); |
| 2710 EXPECT_EQ(1U, s[0]->OutputCount()); | 2798 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 2711 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 2799 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 2712 EXPECT_EQ(kEqual, s[0]->flags_condition()); | 2800 EXPECT_EQ(kEqual, s[0]->flags_condition()); |
| 2713 } | 2801 } |
| 2714 { | 2802 { |
| 2715 StreamBuilder m(this, kMachInt32, kMachInt32); | 2803 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
| 2716 m.Return(m.Word32Equal(m.Int32Constant(0), m.Parameter(0))); | 2804 m.Return(m.Word32Equal(m.Int32Constant(0), m.Parameter(0))); |
| 2717 Stream s = m.Build(); | 2805 Stream s = m.Build(); |
| 2718 ASSERT_EQ(1U, s.size()); | 2806 ASSERT_EQ(1U, s.size()); |
| 2719 EXPECT_EQ(kArmTst, s[0]->arch_opcode()); | 2807 EXPECT_EQ(kArmTst, s[0]->arch_opcode()); |
| 2720 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); | 2808 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); |
| 2721 ASSERT_EQ(2U, s[0]->InputCount()); | 2809 ASSERT_EQ(2U, s[0]->InputCount()); |
| 2722 EXPECT_EQ(s.ToVreg(s[0]->InputAt(0)), s.ToVreg(s[0]->InputAt(1))); | 2810 EXPECT_EQ(s.ToVreg(s[0]->InputAt(0)), s.ToVreg(s[0]->InputAt(1))); |
| 2723 EXPECT_EQ(1U, s[0]->OutputCount()); | 2811 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 2724 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 2812 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 2725 EXPECT_EQ(kEqual, s[0]->flags_condition()); | 2813 EXPECT_EQ(kEqual, s[0]->flags_condition()); |
| 2726 } | 2814 } |
| 2727 } | 2815 } |
| 2728 | 2816 |
| 2729 | 2817 |
| 2730 TEST_F(InstructionSelectorTest, Word32NotWithParameter) { | 2818 TEST_F(InstructionSelectorTest, Word32NotWithParameter) { |
| 2731 StreamBuilder m(this, kMachInt32, kMachInt32); | 2819 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
| 2732 m.Return(m.Word32Not(m.Parameter(0))); | 2820 m.Return(m.Word32Not(m.Parameter(0))); |
| 2733 Stream s = m.Build(); | 2821 Stream s = m.Build(); |
| 2734 ASSERT_EQ(1U, s.size()); | 2822 ASSERT_EQ(1U, s.size()); |
| 2735 EXPECT_EQ(kArmMvn, s[0]->arch_opcode()); | 2823 EXPECT_EQ(kArmMvn, s[0]->arch_opcode()); |
| 2736 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); | 2824 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); |
| 2737 EXPECT_EQ(1U, s[0]->InputCount()); | 2825 EXPECT_EQ(1U, s[0]->InputCount()); |
| 2738 EXPECT_EQ(1U, s[0]->OutputCount()); | 2826 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 2739 } | 2827 } |
| 2740 | 2828 |
| 2741 | 2829 |
| 2742 TEST_F(InstructionSelectorTest, Word32AndWithWord32ShrWithImmediateForARMv7) { | 2830 TEST_F(InstructionSelectorTest, Word32AndWithWord32ShrWithImmediateForARMv7) { |
| 2743 TRACED_FORRANGE(int32_t, lsb, 0, 31) { | 2831 TRACED_FORRANGE(int32_t, lsb, 0, 31) { |
| 2744 TRACED_FORRANGE(int32_t, width, 1, 32 - lsb) { | 2832 TRACED_FORRANGE(int32_t, width, 1, 32 - lsb) { |
| 2745 StreamBuilder m(this, kMachInt32, kMachInt32); | 2833 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
| 2746 m.Return(m.Word32And(m.Word32Shr(m.Parameter(0), m.Int32Constant(lsb)), | 2834 m.Return(m.Word32And(m.Word32Shr(m.Parameter(0), m.Int32Constant(lsb)), |
| 2747 m.Int32Constant(0xffffffffu >> (32 - width)))); | 2835 m.Int32Constant(0xffffffffu >> (32 - width)))); |
| 2748 Stream s = m.Build(ARMv7); | 2836 Stream s = m.Build(ARMv7); |
| 2749 ASSERT_EQ(1U, s.size()); | 2837 ASSERT_EQ(1U, s.size()); |
| 2750 EXPECT_EQ(kArmUbfx, s[0]->arch_opcode()); | 2838 EXPECT_EQ(kArmUbfx, s[0]->arch_opcode()); |
| 2751 ASSERT_EQ(3U, s[0]->InputCount()); | 2839 ASSERT_EQ(3U, s[0]->InputCount()); |
| 2752 EXPECT_EQ(lsb, s.ToInt32(s[0]->InputAt(1))); | 2840 EXPECT_EQ(lsb, s.ToInt32(s[0]->InputAt(1))); |
| 2753 EXPECT_EQ(width, s.ToInt32(s[0]->InputAt(2))); | 2841 EXPECT_EQ(width, s.ToInt32(s[0]->InputAt(2))); |
| 2754 } | 2842 } |
| 2755 } | 2843 } |
| 2756 TRACED_FORRANGE(int32_t, lsb, 0, 31) { | 2844 TRACED_FORRANGE(int32_t, lsb, 0, 31) { |
| 2757 TRACED_FORRANGE(int32_t, width, 1, 32 - lsb) { | 2845 TRACED_FORRANGE(int32_t, width, 1, 32 - lsb) { |
| 2758 StreamBuilder m(this, kMachInt32, kMachInt32); | 2846 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
| 2759 m.Return(m.Word32And(m.Int32Constant(0xffffffffu >> (32 - width)), | 2847 m.Return(m.Word32And(m.Int32Constant(0xffffffffu >> (32 - width)), |
| 2760 m.Word32Shr(m.Parameter(0), m.Int32Constant(lsb)))); | 2848 m.Word32Shr(m.Parameter(0), m.Int32Constant(lsb)))); |
| 2761 Stream s = m.Build(ARMv7); | 2849 Stream s = m.Build(ARMv7); |
| 2762 ASSERT_EQ(1U, s.size()); | 2850 ASSERT_EQ(1U, s.size()); |
| 2763 EXPECT_EQ(kArmUbfx, s[0]->arch_opcode()); | 2851 EXPECT_EQ(kArmUbfx, s[0]->arch_opcode()); |
| 2764 ASSERT_EQ(3U, s[0]->InputCount()); | 2852 ASSERT_EQ(3U, s[0]->InputCount()); |
| 2765 EXPECT_EQ(lsb, s.ToInt32(s[0]->InputAt(1))); | 2853 EXPECT_EQ(lsb, s.ToInt32(s[0]->InputAt(1))); |
| 2766 EXPECT_EQ(width, s.ToInt32(s[0]->InputAt(2))); | 2854 EXPECT_EQ(width, s.ToInt32(s[0]->InputAt(2))); |
| 2767 } | 2855 } |
| 2768 } | 2856 } |
| 2769 } | 2857 } |
| 2770 | 2858 |
| 2771 | 2859 |
| 2772 TEST_F(InstructionSelectorTest, Word32Clz) { | 2860 TEST_F(InstructionSelectorTest, Word32Clz) { |
| 2773 StreamBuilder m(this, kMachUint32, kMachUint32); | 2861 StreamBuilder m(this, MachineType::Uint32(), MachineType::Uint32()); |
| 2774 Node* const p0 = m.Parameter(0); | 2862 Node* const p0 = m.Parameter(0); |
| 2775 Node* const n = m.Word32Clz(p0); | 2863 Node* const n = m.Word32Clz(p0); |
| 2776 m.Return(n); | 2864 m.Return(n); |
| 2777 Stream s = m.Build(); | 2865 Stream s = m.Build(); |
| 2778 ASSERT_EQ(1U, s.size()); | 2866 ASSERT_EQ(1U, s.size()); |
| 2779 EXPECT_EQ(kArmClz, s[0]->arch_opcode()); | 2867 EXPECT_EQ(kArmClz, s[0]->arch_opcode()); |
| 2780 ASSERT_EQ(1U, s[0]->InputCount()); | 2868 ASSERT_EQ(1U, s[0]->InputCount()); |
| 2781 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); | 2869 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
| 2782 ASSERT_EQ(1U, s[0]->OutputCount()); | 2870 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 2783 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | 2871 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
| 2784 } | 2872 } |
| 2785 | 2873 |
| 2786 } // namespace compiler | 2874 } // namespace compiler |
| 2787 } // namespace internal | 2875 } // namespace internal |
| 2788 } // namespace v8 | 2876 } // namespace v8 |
| OLD | NEW |