| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "test/compiler-unittests/instruction-selector-unittest.h" | 5 #include "test/compiler-unittests/instruction-selector-unittest.h" |
| 6 | 6 |
| 7 namespace v8 { | 7 namespace v8 { |
| 8 namespace internal { | 8 namespace internal { |
| 9 namespace compiler { | 9 namespace compiler { |
| 10 | 10 |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 | 116 |
| 117 // ----------------------------------------------------------------------------- | 117 // ----------------------------------------------------------------------------- |
| 118 // Data processing instructions. | 118 // Data processing instructions. |
| 119 | 119 |
| 120 | 120 |
| 121 typedef InstructionSelectorTestWithParam<DPI> InstructionSelectorDPITest; | 121 typedef InstructionSelectorTestWithParam<DPI> InstructionSelectorDPITest; |
| 122 | 122 |
| 123 | 123 |
| 124 TEST_P(InstructionSelectorDPITest, Parameters) { | 124 TEST_P(InstructionSelectorDPITest, Parameters) { |
| 125 const DPI dpi = GetParam(); | 125 const DPI dpi = GetParam(); |
| 126 StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32); | 126 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); |
| 127 m.Return((m.*dpi.constructor)(m.Parameter(0), m.Parameter(1))); | 127 m.Return((m.*dpi.constructor)(m.Parameter(0), m.Parameter(1))); |
| 128 Stream s = m.Build(); | 128 Stream s = m.Build(); |
| 129 ASSERT_EQ(1U, s.size()); | 129 ASSERT_EQ(1U, s.size()); |
| 130 EXPECT_EQ(dpi.arch_opcode, s[0]->arch_opcode()); | 130 EXPECT_EQ(dpi.arch_opcode, s[0]->arch_opcode()); |
| 131 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); | 131 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); |
| 132 EXPECT_EQ(2U, s[0]->InputCount()); | 132 EXPECT_EQ(2U, s[0]->InputCount()); |
| 133 EXPECT_EQ(1U, s[0]->OutputCount()); | 133 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 134 } | 134 } |
| 135 | 135 |
| 136 | 136 |
| 137 TEST_P(InstructionSelectorDPITest, Immediate) { | 137 TEST_P(InstructionSelectorDPITest, Immediate) { |
| 138 const DPI dpi = GetParam(); | 138 const DPI dpi = GetParam(); |
| 139 TRACED_FOREACH(int32_t, imm, kImmediates) { | 139 TRACED_FOREACH(int32_t, imm, kImmediates) { |
| 140 StreamBuilder m(this, kMachineWord32, kMachineWord32); | 140 StreamBuilder m(this, kMachInt32, kMachInt32); |
| 141 m.Return((m.*dpi.constructor)(m.Parameter(0), m.Int32Constant(imm))); | 141 m.Return((m.*dpi.constructor)(m.Parameter(0), m.Int32Constant(imm))); |
| 142 Stream s = m.Build(); | 142 Stream s = m.Build(); |
| 143 ASSERT_EQ(1U, s.size()); | 143 ASSERT_EQ(1U, s.size()); |
| 144 EXPECT_EQ(dpi.arch_opcode, s[0]->arch_opcode()); | 144 EXPECT_EQ(dpi.arch_opcode, s[0]->arch_opcode()); |
| 145 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); | 145 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); |
| 146 ASSERT_EQ(2U, s[0]->InputCount()); | 146 ASSERT_EQ(2U, s[0]->InputCount()); |
| 147 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); | 147 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); |
| 148 EXPECT_EQ(1U, s[0]->OutputCount()); | 148 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 149 } | 149 } |
| 150 TRACED_FOREACH(int32_t, imm, kImmediates) { | 150 TRACED_FOREACH(int32_t, imm, kImmediates) { |
| 151 StreamBuilder m(this, kMachineWord32, kMachineWord32); | 151 StreamBuilder m(this, kMachInt32, kMachInt32); |
| 152 m.Return((m.*dpi.constructor)(m.Int32Constant(imm), m.Parameter(0))); | 152 m.Return((m.*dpi.constructor)(m.Int32Constant(imm), m.Parameter(0))); |
| 153 Stream s = m.Build(); | 153 Stream s = m.Build(); |
| 154 ASSERT_EQ(1U, s.size()); | 154 ASSERT_EQ(1U, s.size()); |
| 155 EXPECT_EQ(dpi.reverse_arch_opcode, s[0]->arch_opcode()); | 155 EXPECT_EQ(dpi.reverse_arch_opcode, s[0]->arch_opcode()); |
| 156 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); | 156 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); |
| 157 ASSERT_EQ(2U, s[0]->InputCount()); | 157 ASSERT_EQ(2U, s[0]->InputCount()); |
| 158 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); | 158 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); |
| 159 EXPECT_EQ(1U, s[0]->OutputCount()); | 159 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 160 } | 160 } |
| 161 } | 161 } |
| 162 | 162 |
| 163 | 163 |
| 164 TEST_P(InstructionSelectorDPITest, ShiftByParameter) { | 164 TEST_P(InstructionSelectorDPITest, ShiftByParameter) { |
| 165 const DPI dpi = GetParam(); | 165 const DPI dpi = GetParam(); |
| 166 TRACED_FOREACH(Shift, shift, kShifts) { | 166 TRACED_FOREACH(Shift, shift, kShifts) { |
| 167 StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32, | 167 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); |
| 168 kMachineWord32); | |
| 169 m.Return((m.*dpi.constructor)( | 168 m.Return((m.*dpi.constructor)( |
| 170 m.Parameter(0), | 169 m.Parameter(0), |
| 171 (m.*shift.constructor)(m.Parameter(1), m.Parameter(2)))); | 170 (m.*shift.constructor)(m.Parameter(1), m.Parameter(2)))); |
| 172 Stream s = m.Build(); | 171 Stream s = m.Build(); |
| 173 ASSERT_EQ(1U, s.size()); | 172 ASSERT_EQ(1U, s.size()); |
| 174 EXPECT_EQ(dpi.arch_opcode, s[0]->arch_opcode()); | 173 EXPECT_EQ(dpi.arch_opcode, s[0]->arch_opcode()); |
| 175 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); | 174 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); |
| 176 EXPECT_EQ(3U, s[0]->InputCount()); | 175 EXPECT_EQ(3U, s[0]->InputCount()); |
| 177 EXPECT_EQ(1U, s[0]->OutputCount()); | 176 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 178 } | 177 } |
| 179 TRACED_FOREACH(Shift, shift, kShifts) { | 178 TRACED_FOREACH(Shift, shift, kShifts) { |
| 180 StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32, | 179 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); |
| 181 kMachineWord32); | |
| 182 m.Return((m.*dpi.constructor)( | 180 m.Return((m.*dpi.constructor)( |
| 183 (m.*shift.constructor)(m.Parameter(0), m.Parameter(1)), | 181 (m.*shift.constructor)(m.Parameter(0), m.Parameter(1)), |
| 184 m.Parameter(2))); | 182 m.Parameter(2))); |
| 185 Stream s = m.Build(); | 183 Stream s = m.Build(); |
| 186 ASSERT_EQ(1U, s.size()); | 184 ASSERT_EQ(1U, s.size()); |
| 187 EXPECT_EQ(dpi.reverse_arch_opcode, s[0]->arch_opcode()); | 185 EXPECT_EQ(dpi.reverse_arch_opcode, s[0]->arch_opcode()); |
| 188 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); | 186 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); |
| 189 EXPECT_EQ(3U, s[0]->InputCount()); | 187 EXPECT_EQ(3U, s[0]->InputCount()); |
| 190 EXPECT_EQ(1U, s[0]->OutputCount()); | 188 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 191 } | 189 } |
| 192 } | 190 } |
| 193 | 191 |
| 194 | 192 |
| 195 TEST_P(InstructionSelectorDPITest, ShiftByImmediate) { | 193 TEST_P(InstructionSelectorDPITest, ShiftByImmediate) { |
| 196 const DPI dpi = GetParam(); | 194 const DPI dpi = GetParam(); |
| 197 TRACED_FOREACH(Shift, shift, kShifts) { | 195 TRACED_FOREACH(Shift, shift, kShifts) { |
| 198 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { | 196 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { |
| 199 StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32); | 197 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); |
| 200 m.Return((m.*dpi.constructor)( | 198 m.Return((m.*dpi.constructor)( |
| 201 m.Parameter(0), | 199 m.Parameter(0), |
| 202 (m.*shift.constructor)(m.Parameter(1), m.Int32Constant(imm)))); | 200 (m.*shift.constructor)(m.Parameter(1), m.Int32Constant(imm)))); |
| 203 Stream s = m.Build(); | 201 Stream s = m.Build(); |
| 204 ASSERT_EQ(1U, s.size()); | 202 ASSERT_EQ(1U, s.size()); |
| 205 EXPECT_EQ(dpi.arch_opcode, s[0]->arch_opcode()); | 203 EXPECT_EQ(dpi.arch_opcode, s[0]->arch_opcode()); |
| 206 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); | 204 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); |
| 207 ASSERT_EQ(3U, s[0]->InputCount()); | 205 ASSERT_EQ(3U, s[0]->InputCount()); |
| 208 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); | 206 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); |
| 209 EXPECT_EQ(1U, s[0]->OutputCount()); | 207 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 210 } | 208 } |
| 211 } | 209 } |
| 212 TRACED_FOREACH(Shift, shift, kShifts) { | 210 TRACED_FOREACH(Shift, shift, kShifts) { |
| 213 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { | 211 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { |
| 214 StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32); | 212 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); |
| 215 m.Return((m.*dpi.constructor)( | 213 m.Return((m.*dpi.constructor)( |
| 216 (m.*shift.constructor)(m.Parameter(0), m.Int32Constant(imm)), | 214 (m.*shift.constructor)(m.Parameter(0), m.Int32Constant(imm)), |
| 217 m.Parameter(1))); | 215 m.Parameter(1))); |
| 218 Stream s = m.Build(); | 216 Stream s = m.Build(); |
| 219 ASSERT_EQ(1U, s.size()); | 217 ASSERT_EQ(1U, s.size()); |
| 220 EXPECT_EQ(dpi.reverse_arch_opcode, s[0]->arch_opcode()); | 218 EXPECT_EQ(dpi.reverse_arch_opcode, s[0]->arch_opcode()); |
| 221 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); | 219 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); |
| 222 ASSERT_EQ(3U, s[0]->InputCount()); | 220 ASSERT_EQ(3U, s[0]->InputCount()); |
| 223 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); | 221 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); |
| 224 EXPECT_EQ(1U, s[0]->OutputCount()); | 222 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 225 } | 223 } |
| 226 } | 224 } |
| 227 } | 225 } |
| 228 | 226 |
| 229 | 227 |
| 230 TEST_P(InstructionSelectorDPITest, BranchWithParameters) { | 228 TEST_P(InstructionSelectorDPITest, BranchWithParameters) { |
| 231 const DPI dpi = GetParam(); | 229 const DPI dpi = GetParam(); |
| 232 StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32); | 230 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); |
| 233 MLabel a, b; | 231 MLabel a, b; |
| 234 m.Branch((m.*dpi.constructor)(m.Parameter(0), m.Parameter(1)), &a, &b); | 232 m.Branch((m.*dpi.constructor)(m.Parameter(0), m.Parameter(1)), &a, &b); |
| 235 m.Bind(&a); | 233 m.Bind(&a); |
| 236 m.Return(m.Int32Constant(1)); | 234 m.Return(m.Int32Constant(1)); |
| 237 m.Bind(&b); | 235 m.Bind(&b); |
| 238 m.Return(m.Int32Constant(0)); | 236 m.Return(m.Int32Constant(0)); |
| 239 Stream s = m.Build(); | 237 Stream s = m.Build(); |
| 240 ASSERT_EQ(1U, s.size()); | 238 ASSERT_EQ(1U, s.size()); |
| 241 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); | 239 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); |
| 242 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); | 240 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); |
| 243 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); | 241 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); |
| 244 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); | 242 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); |
| 245 } | 243 } |
| 246 | 244 |
| 247 | 245 |
| 248 TEST_P(InstructionSelectorDPITest, BranchWithImmediate) { | 246 TEST_P(InstructionSelectorDPITest, BranchWithImmediate) { |
| 249 const DPI dpi = GetParam(); | 247 const DPI dpi = GetParam(); |
| 250 TRACED_FOREACH(int32_t, imm, kImmediates) { | 248 TRACED_FOREACH(int32_t, imm, kImmediates) { |
| 251 StreamBuilder m(this, kMachineWord32, kMachineWord32); | 249 StreamBuilder m(this, kMachInt32, kMachInt32); |
| 252 MLabel a, b; | 250 MLabel a, b; |
| 253 m.Branch((m.*dpi.constructor)(m.Parameter(0), m.Int32Constant(imm)), &a, | 251 m.Branch((m.*dpi.constructor)(m.Parameter(0), m.Int32Constant(imm)), &a, |
| 254 &b); | 252 &b); |
| 255 m.Bind(&a); | 253 m.Bind(&a); |
| 256 m.Return(m.Int32Constant(1)); | 254 m.Return(m.Int32Constant(1)); |
| 257 m.Bind(&b); | 255 m.Bind(&b); |
| 258 m.Return(m.Int32Constant(0)); | 256 m.Return(m.Int32Constant(0)); |
| 259 Stream s = m.Build(); | 257 Stream s = m.Build(); |
| 260 ASSERT_EQ(1U, s.size()); | 258 ASSERT_EQ(1U, s.size()); |
| 261 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); | 259 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); |
| 262 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); | 260 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); |
| 263 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); | 261 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); |
| 264 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); | 262 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); |
| 265 } | 263 } |
| 266 TRACED_FOREACH(int32_t, imm, kImmediates) { | 264 TRACED_FOREACH(int32_t, imm, kImmediates) { |
| 267 StreamBuilder m(this, kMachineWord32, kMachineWord32); | 265 StreamBuilder m(this, kMachInt32, kMachInt32); |
| 268 MLabel a, b; | 266 MLabel a, b; |
| 269 m.Branch((m.*dpi.constructor)(m.Int32Constant(imm), m.Parameter(0)), &a, | 267 m.Branch((m.*dpi.constructor)(m.Int32Constant(imm), m.Parameter(0)), &a, |
| 270 &b); | 268 &b); |
| 271 m.Bind(&a); | 269 m.Bind(&a); |
| 272 m.Return(m.Int32Constant(1)); | 270 m.Return(m.Int32Constant(1)); |
| 273 m.Bind(&b); | 271 m.Bind(&b); |
| 274 m.Return(m.Int32Constant(0)); | 272 m.Return(m.Int32Constant(0)); |
| 275 Stream s = m.Build(); | 273 Stream s = m.Build(); |
| 276 ASSERT_EQ(1U, s.size()); | 274 ASSERT_EQ(1U, s.size()); |
| 277 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); | 275 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); |
| 278 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); | 276 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); |
| 279 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); | 277 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); |
| 280 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); | 278 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); |
| 281 } | 279 } |
| 282 } | 280 } |
| 283 | 281 |
| 284 | 282 |
| 285 TEST_P(InstructionSelectorDPITest, BranchWithShiftByParameter) { | 283 TEST_P(InstructionSelectorDPITest, BranchWithShiftByParameter) { |
| 286 const DPI dpi = GetParam(); | 284 const DPI dpi = GetParam(); |
| 287 TRACED_FOREACH(Shift, shift, kShifts) { | 285 TRACED_FOREACH(Shift, shift, kShifts) { |
| 288 StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32, | 286 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); |
| 289 kMachineWord32); | |
| 290 MLabel a, b; | 287 MLabel a, b; |
| 291 m.Branch((m.*dpi.constructor)( | 288 m.Branch((m.*dpi.constructor)( |
| 292 m.Parameter(0), | 289 m.Parameter(0), |
| 293 (m.*shift.constructor)(m.Parameter(1), m.Parameter(2))), | 290 (m.*shift.constructor)(m.Parameter(1), m.Parameter(2))), |
| 294 &a, &b); | 291 &a, &b); |
| 295 m.Bind(&a); | 292 m.Bind(&a); |
| 296 m.Return(m.Int32Constant(1)); | 293 m.Return(m.Int32Constant(1)); |
| 297 m.Bind(&b); | 294 m.Bind(&b); |
| 298 m.Return(m.Int32Constant(0)); | 295 m.Return(m.Int32Constant(0)); |
| 299 Stream s = m.Build(); | 296 Stream s = m.Build(); |
| 300 ASSERT_EQ(1U, s.size()); | 297 ASSERT_EQ(1U, s.size()); |
| 301 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); | 298 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); |
| 302 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); | 299 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); |
| 303 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); | 300 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); |
| 304 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); | 301 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); |
| 305 } | 302 } |
| 306 TRACED_FOREACH(Shift, shift, kShifts) { | 303 TRACED_FOREACH(Shift, shift, kShifts) { |
| 307 StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32, | 304 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); |
| 308 kMachineWord32); | |
| 309 MLabel a, b; | 305 MLabel a, b; |
| 310 m.Branch((m.*dpi.constructor)( | 306 m.Branch((m.*dpi.constructor)( |
| 311 (m.*shift.constructor)(m.Parameter(0), m.Parameter(1)), | 307 (m.*shift.constructor)(m.Parameter(0), m.Parameter(1)), |
| 312 m.Parameter(2)), | 308 m.Parameter(2)), |
| 313 &a, &b); | 309 &a, &b); |
| 314 m.Bind(&a); | 310 m.Bind(&a); |
| 315 m.Return(m.Int32Constant(1)); | 311 m.Return(m.Int32Constant(1)); |
| 316 m.Bind(&b); | 312 m.Bind(&b); |
| 317 m.Return(m.Int32Constant(0)); | 313 m.Return(m.Int32Constant(0)); |
| 318 Stream s = m.Build(); | 314 Stream s = m.Build(); |
| 319 ASSERT_EQ(1U, s.size()); | 315 ASSERT_EQ(1U, s.size()); |
| 320 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); | 316 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); |
| 321 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); | 317 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); |
| 322 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); | 318 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); |
| 323 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); | 319 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); |
| 324 } | 320 } |
| 325 } | 321 } |
| 326 | 322 |
| 327 | 323 |
| 328 TEST_P(InstructionSelectorDPITest, BranchWithShiftByImmediate) { | 324 TEST_P(InstructionSelectorDPITest, BranchWithShiftByImmediate) { |
| 329 const DPI dpi = GetParam(); | 325 const DPI dpi = GetParam(); |
| 330 TRACED_FOREACH(Shift, shift, kShifts) { | 326 TRACED_FOREACH(Shift, shift, kShifts) { |
| 331 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { | 327 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { |
| 332 StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32); | 328 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); |
| 333 MLabel a, b; | 329 MLabel a, b; |
| 334 m.Branch((m.*dpi.constructor)(m.Parameter(0), | 330 m.Branch((m.*dpi.constructor)(m.Parameter(0), |
| 335 (m.*shift.constructor)( | 331 (m.*shift.constructor)( |
| 336 m.Parameter(1), m.Int32Constant(imm))), | 332 m.Parameter(1), m.Int32Constant(imm))), |
| 337 &a, &b); | 333 &a, &b); |
| 338 m.Bind(&a); | 334 m.Bind(&a); |
| 339 m.Return(m.Int32Constant(1)); | 335 m.Return(m.Int32Constant(1)); |
| 340 m.Bind(&b); | 336 m.Bind(&b); |
| 341 m.Return(m.Int32Constant(0)); | 337 m.Return(m.Int32Constant(0)); |
| 342 Stream s = m.Build(); | 338 Stream s = m.Build(); |
| 343 ASSERT_EQ(1U, s.size()); | 339 ASSERT_EQ(1U, s.size()); |
| 344 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); | 340 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); |
| 345 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); | 341 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); |
| 346 ASSERT_EQ(5U, s[0]->InputCount()); | 342 ASSERT_EQ(5U, s[0]->InputCount()); |
| 347 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); | 343 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); |
| 348 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); | 344 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); |
| 349 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); | 345 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); |
| 350 } | 346 } |
| 351 } | 347 } |
| 352 TRACED_FOREACH(Shift, shift, kShifts) { | 348 TRACED_FOREACH(Shift, shift, kShifts) { |
| 353 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { | 349 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { |
| 354 StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32); | 350 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); |
| 355 MLabel a, b; | 351 MLabel a, b; |
| 356 m.Branch((m.*dpi.constructor)( | 352 m.Branch((m.*dpi.constructor)( |
| 357 (m.*shift.constructor)(m.Parameter(0), m.Int32Constant(imm)), | 353 (m.*shift.constructor)(m.Parameter(0), m.Int32Constant(imm)), |
| 358 m.Parameter(1)), | 354 m.Parameter(1)), |
| 359 &a, &b); | 355 &a, &b); |
| 360 m.Bind(&a); | 356 m.Bind(&a); |
| 361 m.Return(m.Int32Constant(1)); | 357 m.Return(m.Int32Constant(1)); |
| 362 m.Bind(&b); | 358 m.Bind(&b); |
| 363 m.Return(m.Int32Constant(0)); | 359 m.Return(m.Int32Constant(0)); |
| 364 Stream s = m.Build(); | 360 Stream s = m.Build(); |
| 365 ASSERT_EQ(1U, s.size()); | 361 ASSERT_EQ(1U, s.size()); |
| 366 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); | 362 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); |
| 367 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); | 363 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); |
| 368 ASSERT_EQ(5U, s[0]->InputCount()); | 364 ASSERT_EQ(5U, s[0]->InputCount()); |
| 369 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); | 365 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); |
| 370 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); | 366 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); |
| 371 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); | 367 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); |
| 372 } | 368 } |
| 373 } | 369 } |
| 374 } | 370 } |
| 375 | 371 |
| 376 | 372 |
| 377 TEST_P(InstructionSelectorDPITest, BranchIfZeroWithParameters) { | 373 TEST_P(InstructionSelectorDPITest, BranchIfZeroWithParameters) { |
| 378 const DPI dpi = GetParam(); | 374 const DPI dpi = GetParam(); |
| 379 StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32); | 375 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); |
| 380 MLabel a, b; | 376 MLabel a, b; |
| 381 m.Branch(m.Word32Equal((m.*dpi.constructor)(m.Parameter(0), m.Parameter(1)), | 377 m.Branch(m.Word32Equal((m.*dpi.constructor)(m.Parameter(0), m.Parameter(1)), |
| 382 m.Int32Constant(0)), | 378 m.Int32Constant(0)), |
| 383 &a, &b); | 379 &a, &b); |
| 384 m.Bind(&a); | 380 m.Bind(&a); |
| 385 m.Return(m.Int32Constant(1)); | 381 m.Return(m.Int32Constant(1)); |
| 386 m.Bind(&b); | 382 m.Bind(&b); |
| 387 m.Return(m.Int32Constant(0)); | 383 m.Return(m.Int32Constant(0)); |
| 388 Stream s = m.Build(); | 384 Stream s = m.Build(); |
| 389 ASSERT_EQ(1U, s.size()); | 385 ASSERT_EQ(1U, s.size()); |
| 390 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); | 386 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); |
| 391 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); | 387 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); |
| 392 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); | 388 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); |
| 393 EXPECT_EQ(kEqual, s[0]->flags_condition()); | 389 EXPECT_EQ(kEqual, s[0]->flags_condition()); |
| 394 } | 390 } |
| 395 | 391 |
| 396 | 392 |
| 397 TEST_P(InstructionSelectorDPITest, BranchIfNotZeroWithParameters) { | 393 TEST_P(InstructionSelectorDPITest, BranchIfNotZeroWithParameters) { |
| 398 const DPI dpi = GetParam(); | 394 const DPI dpi = GetParam(); |
| 399 StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32); | 395 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); |
| 400 MLabel a, b; | 396 MLabel a, b; |
| 401 m.Branch( | 397 m.Branch( |
| 402 m.Word32NotEqual((m.*dpi.constructor)(m.Parameter(0), m.Parameter(1)), | 398 m.Word32NotEqual((m.*dpi.constructor)(m.Parameter(0), m.Parameter(1)), |
| 403 m.Int32Constant(0)), | 399 m.Int32Constant(0)), |
| 404 &a, &b); | 400 &a, &b); |
| 405 m.Bind(&a); | 401 m.Bind(&a); |
| 406 m.Return(m.Int32Constant(1)); | 402 m.Return(m.Int32Constant(1)); |
| 407 m.Bind(&b); | 403 m.Bind(&b); |
| 408 m.Return(m.Int32Constant(0)); | 404 m.Return(m.Int32Constant(0)); |
| 409 Stream s = m.Build(); | 405 Stream s = m.Build(); |
| 410 ASSERT_EQ(1U, s.size()); | 406 ASSERT_EQ(1U, s.size()); |
| 411 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); | 407 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); |
| 412 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); | 408 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); |
| 413 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); | 409 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); |
| 414 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); | 410 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); |
| 415 } | 411 } |
| 416 | 412 |
| 417 | 413 |
| 418 TEST_P(InstructionSelectorDPITest, BranchIfZeroWithImmediate) { | 414 TEST_P(InstructionSelectorDPITest, BranchIfZeroWithImmediate) { |
| 419 const DPI dpi = GetParam(); | 415 const DPI dpi = GetParam(); |
| 420 TRACED_FOREACH(int32_t, imm, kImmediates) { | 416 TRACED_FOREACH(int32_t, imm, kImmediates) { |
| 421 StreamBuilder m(this, kMachineWord32, kMachineWord32); | 417 StreamBuilder m(this, kMachInt32, kMachInt32); |
| 422 MLabel a, b; | 418 MLabel a, b; |
| 423 m.Branch(m.Word32Equal( | 419 m.Branch(m.Word32Equal( |
| 424 (m.*dpi.constructor)(m.Parameter(0), m.Int32Constant(imm)), | 420 (m.*dpi.constructor)(m.Parameter(0), m.Int32Constant(imm)), |
| 425 m.Int32Constant(0)), | 421 m.Int32Constant(0)), |
| 426 &a, &b); | 422 &a, &b); |
| 427 m.Bind(&a); | 423 m.Bind(&a); |
| 428 m.Return(m.Int32Constant(1)); | 424 m.Return(m.Int32Constant(1)); |
| 429 m.Bind(&b); | 425 m.Bind(&b); |
| 430 m.Return(m.Int32Constant(0)); | 426 m.Return(m.Int32Constant(0)); |
| 431 Stream s = m.Build(); | 427 Stream s = m.Build(); |
| 432 ASSERT_EQ(1U, s.size()); | 428 ASSERT_EQ(1U, s.size()); |
| 433 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); | 429 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); |
| 434 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); | 430 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); |
| 435 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); | 431 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); |
| 436 EXPECT_EQ(kEqual, s[0]->flags_condition()); | 432 EXPECT_EQ(kEqual, s[0]->flags_condition()); |
| 437 } | 433 } |
| 438 TRACED_FOREACH(int32_t, imm, kImmediates) { | 434 TRACED_FOREACH(int32_t, imm, kImmediates) { |
| 439 StreamBuilder m(this, kMachineWord32, kMachineWord32); | 435 StreamBuilder m(this, kMachInt32, kMachInt32); |
| 440 MLabel a, b; | 436 MLabel a, b; |
| 441 m.Branch(m.Word32Equal( | 437 m.Branch(m.Word32Equal( |
| 442 (m.*dpi.constructor)(m.Int32Constant(imm), m.Parameter(0)), | 438 (m.*dpi.constructor)(m.Int32Constant(imm), m.Parameter(0)), |
| 443 m.Int32Constant(0)), | 439 m.Int32Constant(0)), |
| 444 &a, &b); | 440 &a, &b); |
| 445 m.Bind(&a); | 441 m.Bind(&a); |
| 446 m.Return(m.Int32Constant(1)); | 442 m.Return(m.Int32Constant(1)); |
| 447 m.Bind(&b); | 443 m.Bind(&b); |
| 448 m.Return(m.Int32Constant(0)); | 444 m.Return(m.Int32Constant(0)); |
| 449 Stream s = m.Build(); | 445 Stream s = m.Build(); |
| 450 ASSERT_EQ(1U, s.size()); | 446 ASSERT_EQ(1U, s.size()); |
| 451 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); | 447 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); |
| 452 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); | 448 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); |
| 453 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); | 449 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); |
| 454 EXPECT_EQ(kEqual, s[0]->flags_condition()); | 450 EXPECT_EQ(kEqual, s[0]->flags_condition()); |
| 455 } | 451 } |
| 456 } | 452 } |
| 457 | 453 |
| 458 | 454 |
| 459 TEST_P(InstructionSelectorDPITest, BranchIfNotZeroWithImmediate) { | 455 TEST_P(InstructionSelectorDPITest, BranchIfNotZeroWithImmediate) { |
| 460 const DPI dpi = GetParam(); | 456 const DPI dpi = GetParam(); |
| 461 TRACED_FOREACH(int32_t, imm, kImmediates) { | 457 TRACED_FOREACH(int32_t, imm, kImmediates) { |
| 462 StreamBuilder m(this, kMachineWord32, kMachineWord32); | 458 StreamBuilder m(this, kMachInt32, kMachInt32); |
| 463 MLabel a, b; | 459 MLabel a, b; |
| 464 m.Branch(m.Word32NotEqual( | 460 m.Branch(m.Word32NotEqual( |
| 465 (m.*dpi.constructor)(m.Parameter(0), m.Int32Constant(imm)), | 461 (m.*dpi.constructor)(m.Parameter(0), m.Int32Constant(imm)), |
| 466 m.Int32Constant(0)), | 462 m.Int32Constant(0)), |
| 467 &a, &b); | 463 &a, &b); |
| 468 m.Bind(&a); | 464 m.Bind(&a); |
| 469 m.Return(m.Int32Constant(1)); | 465 m.Return(m.Int32Constant(1)); |
| 470 m.Bind(&b); | 466 m.Bind(&b); |
| 471 m.Return(m.Int32Constant(0)); | 467 m.Return(m.Int32Constant(0)); |
| 472 Stream s = m.Build(); | 468 Stream s = m.Build(); |
| 473 ASSERT_EQ(1U, s.size()); | 469 ASSERT_EQ(1U, s.size()); |
| 474 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); | 470 EXPECT_EQ(dpi.test_arch_opcode, s[0]->arch_opcode()); |
| 475 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); | 471 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); |
| 476 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); | 472 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); |
| 477 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); | 473 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); |
| 478 } | 474 } |
| 479 TRACED_FOREACH(int32_t, imm, kImmediates) { | 475 TRACED_FOREACH(int32_t, imm, kImmediates) { |
| 480 StreamBuilder m(this, kMachineWord32, kMachineWord32); | 476 StreamBuilder m(this, kMachInt32, kMachInt32); |
| 481 MLabel a, b; | 477 MLabel a, b; |
| 482 m.Branch(m.Word32NotEqual( | 478 m.Branch(m.Word32NotEqual( |
| 483 (m.*dpi.constructor)(m.Int32Constant(imm), m.Parameter(0)), | 479 (m.*dpi.constructor)(m.Int32Constant(imm), m.Parameter(0)), |
| 484 m.Int32Constant(0)), | 480 m.Int32Constant(0)), |
| 485 &a, &b); | 481 &a, &b); |
| 486 m.Bind(&a); | 482 m.Bind(&a); |
| 487 m.Return(m.Int32Constant(1)); | 483 m.Return(m.Int32Constant(1)); |
| 488 m.Bind(&b); | 484 m.Bind(&b); |
| 489 m.Return(m.Int32Constant(0)); | 485 m.Return(m.Int32Constant(0)); |
| 490 Stream s = m.Build(); | 486 Stream s = m.Build(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 503 | 499 |
| 504 // ----------------------------------------------------------------------------- | 500 // ----------------------------------------------------------------------------- |
| 505 // Data processing instructions with overflow. | 501 // Data processing instructions with overflow. |
| 506 | 502 |
| 507 | 503 |
| 508 typedef InstructionSelectorTestWithParam<ODPI> InstructionSelectorODPITest; | 504 typedef InstructionSelectorTestWithParam<ODPI> InstructionSelectorODPITest; |
| 509 | 505 |
| 510 | 506 |
| 511 TEST_P(InstructionSelectorODPITest, OvfWithParameters) { | 507 TEST_P(InstructionSelectorODPITest, OvfWithParameters) { |
| 512 const ODPI odpi = GetParam(); | 508 const ODPI odpi = GetParam(); |
| 513 StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32); | 509 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); |
| 514 m.Return( | 510 m.Return( |
| 515 m.Projection(1, (m.*odpi.constructor)(m.Parameter(0), m.Parameter(1)))); | 511 m.Projection(1, (m.*odpi.constructor)(m.Parameter(0), m.Parameter(1)))); |
| 516 Stream s = m.Build(); | 512 Stream s = m.Build(); |
| 517 ASSERT_EQ(1U, s.size()); | 513 ASSERT_EQ(1U, s.size()); |
| 518 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); | 514 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); |
| 519 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); | 515 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); |
| 520 EXPECT_EQ(2U, s[0]->InputCount()); | 516 EXPECT_EQ(2U, s[0]->InputCount()); |
| 521 EXPECT_LE(1U, s[0]->OutputCount()); | 517 EXPECT_LE(1U, s[0]->OutputCount()); |
| 522 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 518 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 523 EXPECT_EQ(kOverflow, s[0]->flags_condition()); | 519 EXPECT_EQ(kOverflow, s[0]->flags_condition()); |
| 524 } | 520 } |
| 525 | 521 |
| 526 | 522 |
| 527 TEST_P(InstructionSelectorODPITest, OvfWithImmediate) { | 523 TEST_P(InstructionSelectorODPITest, OvfWithImmediate) { |
| 528 const ODPI odpi = GetParam(); | 524 const ODPI odpi = GetParam(); |
| 529 TRACED_FOREACH(int32_t, imm, kImmediates) { | 525 TRACED_FOREACH(int32_t, imm, kImmediates) { |
| 530 StreamBuilder m(this, kMachineWord32, kMachineWord32); | 526 StreamBuilder m(this, kMachInt32, kMachInt32); |
| 531 m.Return(m.Projection( | 527 m.Return(m.Projection( |
| 532 1, (m.*odpi.constructor)(m.Parameter(0), m.Int32Constant(imm)))); | 528 1, (m.*odpi.constructor)(m.Parameter(0), m.Int32Constant(imm)))); |
| 533 Stream s = m.Build(); | 529 Stream s = m.Build(); |
| 534 ASSERT_EQ(1U, s.size()); | 530 ASSERT_EQ(1U, s.size()); |
| 535 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); | 531 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); |
| 536 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); | 532 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); |
| 537 ASSERT_EQ(2U, s[0]->InputCount()); | 533 ASSERT_EQ(2U, s[0]->InputCount()); |
| 538 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); | 534 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); |
| 539 EXPECT_LE(1U, s[0]->OutputCount()); | 535 EXPECT_LE(1U, s[0]->OutputCount()); |
| 540 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 536 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 541 EXPECT_EQ(kOverflow, s[0]->flags_condition()); | 537 EXPECT_EQ(kOverflow, s[0]->flags_condition()); |
| 542 } | 538 } |
| 543 TRACED_FOREACH(int32_t, imm, kImmediates) { | 539 TRACED_FOREACH(int32_t, imm, kImmediates) { |
| 544 StreamBuilder m(this, kMachineWord32, kMachineWord32); | 540 StreamBuilder m(this, kMachInt32, kMachInt32); |
| 545 m.Return(m.Projection( | 541 m.Return(m.Projection( |
| 546 1, (m.*odpi.constructor)(m.Int32Constant(imm), m.Parameter(0)))); | 542 1, (m.*odpi.constructor)(m.Int32Constant(imm), m.Parameter(0)))); |
| 547 Stream s = m.Build(); | 543 Stream s = m.Build(); |
| 548 ASSERT_EQ(1U, s.size()); | 544 ASSERT_EQ(1U, s.size()); |
| 549 EXPECT_EQ(odpi.reverse_arch_opcode, s[0]->arch_opcode()); | 545 EXPECT_EQ(odpi.reverse_arch_opcode, s[0]->arch_opcode()); |
| 550 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); | 546 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); |
| 551 ASSERT_EQ(2U, s[0]->InputCount()); | 547 ASSERT_EQ(2U, s[0]->InputCount()); |
| 552 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); | 548 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); |
| 553 EXPECT_LE(1U, s[0]->OutputCount()); | 549 EXPECT_LE(1U, s[0]->OutputCount()); |
| 554 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 550 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 555 EXPECT_EQ(kOverflow, s[0]->flags_condition()); | 551 EXPECT_EQ(kOverflow, s[0]->flags_condition()); |
| 556 } | 552 } |
| 557 } | 553 } |
| 558 | 554 |
| 559 | 555 |
| 560 TEST_P(InstructionSelectorODPITest, OvfWithShiftByParameter) { | 556 TEST_P(InstructionSelectorODPITest, OvfWithShiftByParameter) { |
| 561 const ODPI odpi = GetParam(); | 557 const ODPI odpi = GetParam(); |
| 562 TRACED_FOREACH(Shift, shift, kShifts) { | 558 TRACED_FOREACH(Shift, shift, kShifts) { |
| 563 StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32, | 559 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); |
| 564 kMachineWord32); | |
| 565 m.Return(m.Projection( | 560 m.Return(m.Projection( |
| 566 1, (m.*odpi.constructor)( | 561 1, (m.*odpi.constructor)( |
| 567 m.Parameter(0), | 562 m.Parameter(0), |
| 568 (m.*shift.constructor)(m.Parameter(1), m.Parameter(2))))); | 563 (m.*shift.constructor)(m.Parameter(1), m.Parameter(2))))); |
| 569 Stream s = m.Build(); | 564 Stream s = m.Build(); |
| 570 ASSERT_EQ(1U, s.size()); | 565 ASSERT_EQ(1U, s.size()); |
| 571 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); | 566 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); |
| 572 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); | 567 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); |
| 573 EXPECT_EQ(3U, s[0]->InputCount()); | 568 EXPECT_EQ(3U, s[0]->InputCount()); |
| 574 EXPECT_LE(1U, s[0]->OutputCount()); | 569 EXPECT_LE(1U, s[0]->OutputCount()); |
| 575 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 570 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 576 EXPECT_EQ(kOverflow, s[0]->flags_condition()); | 571 EXPECT_EQ(kOverflow, s[0]->flags_condition()); |
| 577 } | 572 } |
| 578 TRACED_FOREACH(Shift, shift, kShifts) { | 573 TRACED_FOREACH(Shift, shift, kShifts) { |
| 579 StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32, | 574 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); |
| 580 kMachineWord32); | |
| 581 m.Return(m.Projection( | 575 m.Return(m.Projection( |
| 582 1, (m.*odpi.constructor)( | 576 1, (m.*odpi.constructor)( |
| 583 (m.*shift.constructor)(m.Parameter(0), m.Parameter(1)), | 577 (m.*shift.constructor)(m.Parameter(0), m.Parameter(1)), |
| 584 m.Parameter(0)))); | 578 m.Parameter(0)))); |
| 585 Stream s = m.Build(); | 579 Stream s = m.Build(); |
| 586 ASSERT_EQ(1U, s.size()); | 580 ASSERT_EQ(1U, s.size()); |
| 587 EXPECT_EQ(odpi.reverse_arch_opcode, s[0]->arch_opcode()); | 581 EXPECT_EQ(odpi.reverse_arch_opcode, s[0]->arch_opcode()); |
| 588 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); | 582 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); |
| 589 EXPECT_EQ(3U, s[0]->InputCount()); | 583 EXPECT_EQ(3U, s[0]->InputCount()); |
| 590 EXPECT_LE(1U, s[0]->OutputCount()); | 584 EXPECT_LE(1U, s[0]->OutputCount()); |
| 591 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 585 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 592 EXPECT_EQ(kOverflow, s[0]->flags_condition()); | 586 EXPECT_EQ(kOverflow, s[0]->flags_condition()); |
| 593 } | 587 } |
| 594 } | 588 } |
| 595 | 589 |
| 596 | 590 |
| 597 TEST_P(InstructionSelectorODPITest, OvfWithShiftByImmediate) { | 591 TEST_P(InstructionSelectorODPITest, OvfWithShiftByImmediate) { |
| 598 const ODPI odpi = GetParam(); | 592 const ODPI odpi = GetParam(); |
| 599 TRACED_FOREACH(Shift, shift, kShifts) { | 593 TRACED_FOREACH(Shift, shift, kShifts) { |
| 600 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { | 594 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { |
| 601 StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32); | 595 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); |
| 602 m.Return(m.Projection( | 596 m.Return(m.Projection( |
| 603 1, (m.*odpi.constructor)(m.Parameter(0), | 597 1, (m.*odpi.constructor)(m.Parameter(0), |
| 604 (m.*shift.constructor)( | 598 (m.*shift.constructor)( |
| 605 m.Parameter(1), m.Int32Constant(imm))))); | 599 m.Parameter(1), m.Int32Constant(imm))))); |
| 606 Stream s = m.Build(); | 600 Stream s = m.Build(); |
| 607 ASSERT_EQ(1U, s.size()); | 601 ASSERT_EQ(1U, s.size()); |
| 608 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); | 602 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); |
| 609 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); | 603 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); |
| 610 ASSERT_EQ(3U, s[0]->InputCount()); | 604 ASSERT_EQ(3U, s[0]->InputCount()); |
| 611 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); | 605 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); |
| 612 EXPECT_LE(1U, s[0]->OutputCount()); | 606 EXPECT_LE(1U, s[0]->OutputCount()); |
| 613 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 607 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 614 EXPECT_EQ(kOverflow, s[0]->flags_condition()); | 608 EXPECT_EQ(kOverflow, s[0]->flags_condition()); |
| 615 } | 609 } |
| 616 } | 610 } |
| 617 TRACED_FOREACH(Shift, shift, kShifts) { | 611 TRACED_FOREACH(Shift, shift, kShifts) { |
| 618 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { | 612 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { |
| 619 StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32); | 613 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); |
| 620 m.Return(m.Projection( | 614 m.Return(m.Projection( |
| 621 1, (m.*odpi.constructor)( | 615 1, (m.*odpi.constructor)( |
| 622 (m.*shift.constructor)(m.Parameter(1), m.Int32Constant(imm)), | 616 (m.*shift.constructor)(m.Parameter(1), m.Int32Constant(imm)), |
| 623 m.Parameter(0)))); | 617 m.Parameter(0)))); |
| 624 Stream s = m.Build(); | 618 Stream s = m.Build(); |
| 625 ASSERT_EQ(1U, s.size()); | 619 ASSERT_EQ(1U, s.size()); |
| 626 EXPECT_EQ(odpi.reverse_arch_opcode, s[0]->arch_opcode()); | 620 EXPECT_EQ(odpi.reverse_arch_opcode, s[0]->arch_opcode()); |
| 627 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); | 621 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); |
| 628 ASSERT_EQ(3U, s[0]->InputCount()); | 622 ASSERT_EQ(3U, s[0]->InputCount()); |
| 629 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); | 623 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); |
| 630 EXPECT_LE(1U, s[0]->OutputCount()); | 624 EXPECT_LE(1U, s[0]->OutputCount()); |
| 631 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 625 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 632 EXPECT_EQ(kOverflow, s[0]->flags_condition()); | 626 EXPECT_EQ(kOverflow, s[0]->flags_condition()); |
| 633 } | 627 } |
| 634 } | 628 } |
| 635 } | 629 } |
| 636 | 630 |
| 637 | 631 |
| 638 TEST_P(InstructionSelectorODPITest, ValWithParameters) { | 632 TEST_P(InstructionSelectorODPITest, ValWithParameters) { |
| 639 const ODPI odpi = GetParam(); | 633 const ODPI odpi = GetParam(); |
| 640 StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32); | 634 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); |
| 641 m.Return( | 635 m.Return( |
| 642 m.Projection(0, (m.*odpi.constructor)(m.Parameter(0), m.Parameter(1)))); | 636 m.Projection(0, (m.*odpi.constructor)(m.Parameter(0), m.Parameter(1)))); |
| 643 Stream s = m.Build(); | 637 Stream s = m.Build(); |
| 644 ASSERT_EQ(1U, s.size()); | 638 ASSERT_EQ(1U, s.size()); |
| 645 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); | 639 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); |
| 646 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); | 640 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); |
| 647 EXPECT_EQ(2U, s[0]->InputCount()); | 641 EXPECT_EQ(2U, s[0]->InputCount()); |
| 648 EXPECT_LE(1U, s[0]->OutputCount()); | 642 EXPECT_LE(1U, s[0]->OutputCount()); |
| 649 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); | 643 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); |
| 650 } | 644 } |
| 651 | 645 |
| 652 | 646 |
| 653 TEST_P(InstructionSelectorODPITest, ValWithImmediate) { | 647 TEST_P(InstructionSelectorODPITest, ValWithImmediate) { |
| 654 const ODPI odpi = GetParam(); | 648 const ODPI odpi = GetParam(); |
| 655 TRACED_FOREACH(int32_t, imm, kImmediates) { | 649 TRACED_FOREACH(int32_t, imm, kImmediates) { |
| 656 StreamBuilder m(this, kMachineWord32, kMachineWord32); | 650 StreamBuilder m(this, kMachInt32, kMachInt32); |
| 657 m.Return(m.Projection( | 651 m.Return(m.Projection( |
| 658 0, (m.*odpi.constructor)(m.Parameter(0), m.Int32Constant(imm)))); | 652 0, (m.*odpi.constructor)(m.Parameter(0), m.Int32Constant(imm)))); |
| 659 Stream s = m.Build(); | 653 Stream s = m.Build(); |
| 660 ASSERT_EQ(1U, s.size()); | 654 ASSERT_EQ(1U, s.size()); |
| 661 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); | 655 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); |
| 662 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); | 656 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); |
| 663 ASSERT_EQ(2U, s[0]->InputCount()); | 657 ASSERT_EQ(2U, s[0]->InputCount()); |
| 664 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); | 658 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); |
| 665 EXPECT_LE(1U, s[0]->OutputCount()); | 659 EXPECT_LE(1U, s[0]->OutputCount()); |
| 666 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); | 660 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); |
| 667 } | 661 } |
| 668 TRACED_FOREACH(int32_t, imm, kImmediates) { | 662 TRACED_FOREACH(int32_t, imm, kImmediates) { |
| 669 StreamBuilder m(this, kMachineWord32, kMachineWord32); | 663 StreamBuilder m(this, kMachInt32, kMachInt32); |
| 670 m.Return(m.Projection( | 664 m.Return(m.Projection( |
| 671 0, (m.*odpi.constructor)(m.Int32Constant(imm), m.Parameter(0)))); | 665 0, (m.*odpi.constructor)(m.Int32Constant(imm), m.Parameter(0)))); |
| 672 Stream s = m.Build(); | 666 Stream s = m.Build(); |
| 673 ASSERT_EQ(1U, s.size()); | 667 ASSERT_EQ(1U, s.size()); |
| 674 EXPECT_EQ(odpi.reverse_arch_opcode, s[0]->arch_opcode()); | 668 EXPECT_EQ(odpi.reverse_arch_opcode, s[0]->arch_opcode()); |
| 675 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); | 669 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); |
| 676 ASSERT_EQ(2U, s[0]->InputCount()); | 670 ASSERT_EQ(2U, s[0]->InputCount()); |
| 677 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); | 671 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); |
| 678 EXPECT_LE(1U, s[0]->OutputCount()); | 672 EXPECT_LE(1U, s[0]->OutputCount()); |
| 679 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); | 673 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); |
| 680 } | 674 } |
| 681 } | 675 } |
| 682 | 676 |
| 683 | 677 |
| 684 TEST_P(InstructionSelectorODPITest, ValWithShiftByParameter) { | 678 TEST_P(InstructionSelectorODPITest, ValWithShiftByParameter) { |
| 685 const ODPI odpi = GetParam(); | 679 const ODPI odpi = GetParam(); |
| 686 TRACED_FOREACH(Shift, shift, kShifts) { | 680 TRACED_FOREACH(Shift, shift, kShifts) { |
| 687 StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32, | 681 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); |
| 688 kMachineWord32); | |
| 689 m.Return(m.Projection( | 682 m.Return(m.Projection( |
| 690 0, (m.*odpi.constructor)( | 683 0, (m.*odpi.constructor)( |
| 691 m.Parameter(0), | 684 m.Parameter(0), |
| 692 (m.*shift.constructor)(m.Parameter(1), m.Parameter(2))))); | 685 (m.*shift.constructor)(m.Parameter(1), m.Parameter(2))))); |
| 693 Stream s = m.Build(); | 686 Stream s = m.Build(); |
| 694 ASSERT_EQ(1U, s.size()); | 687 ASSERT_EQ(1U, s.size()); |
| 695 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); | 688 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); |
| 696 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); | 689 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); |
| 697 EXPECT_EQ(3U, s[0]->InputCount()); | 690 EXPECT_EQ(3U, s[0]->InputCount()); |
| 698 EXPECT_LE(1U, s[0]->OutputCount()); | 691 EXPECT_LE(1U, s[0]->OutputCount()); |
| 699 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); | 692 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); |
| 700 } | 693 } |
| 701 TRACED_FOREACH(Shift, shift, kShifts) { | 694 TRACED_FOREACH(Shift, shift, kShifts) { |
| 702 StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32, | 695 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); |
| 703 kMachineWord32); | |
| 704 m.Return(m.Projection( | 696 m.Return(m.Projection( |
| 705 0, (m.*odpi.constructor)( | 697 0, (m.*odpi.constructor)( |
| 706 (m.*shift.constructor)(m.Parameter(0), m.Parameter(1)), | 698 (m.*shift.constructor)(m.Parameter(0), m.Parameter(1)), |
| 707 m.Parameter(0)))); | 699 m.Parameter(0)))); |
| 708 Stream s = m.Build(); | 700 Stream s = m.Build(); |
| 709 ASSERT_EQ(1U, s.size()); | 701 ASSERT_EQ(1U, s.size()); |
| 710 EXPECT_EQ(odpi.reverse_arch_opcode, s[0]->arch_opcode()); | 702 EXPECT_EQ(odpi.reverse_arch_opcode, s[0]->arch_opcode()); |
| 711 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); | 703 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); |
| 712 EXPECT_EQ(3U, s[0]->InputCount()); | 704 EXPECT_EQ(3U, s[0]->InputCount()); |
| 713 EXPECT_LE(1U, s[0]->OutputCount()); | 705 EXPECT_LE(1U, s[0]->OutputCount()); |
| 714 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); | 706 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); |
| 715 } | 707 } |
| 716 } | 708 } |
| 717 | 709 |
| 718 | 710 |
| 719 TEST_P(InstructionSelectorODPITest, ValWithShiftByImmediate) { | 711 TEST_P(InstructionSelectorODPITest, ValWithShiftByImmediate) { |
| 720 const ODPI odpi = GetParam(); | 712 const ODPI odpi = GetParam(); |
| 721 TRACED_FOREACH(Shift, shift, kShifts) { | 713 TRACED_FOREACH(Shift, shift, kShifts) { |
| 722 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { | 714 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { |
| 723 StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32); | 715 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); |
| 724 m.Return(m.Projection( | 716 m.Return(m.Projection( |
| 725 0, (m.*odpi.constructor)(m.Parameter(0), | 717 0, (m.*odpi.constructor)(m.Parameter(0), |
| 726 (m.*shift.constructor)( | 718 (m.*shift.constructor)( |
| 727 m.Parameter(1), m.Int32Constant(imm))))); | 719 m.Parameter(1), m.Int32Constant(imm))))); |
| 728 Stream s = m.Build(); | 720 Stream s = m.Build(); |
| 729 ASSERT_EQ(1U, s.size()); | 721 ASSERT_EQ(1U, s.size()); |
| 730 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); | 722 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); |
| 731 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); | 723 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); |
| 732 ASSERT_EQ(3U, s[0]->InputCount()); | 724 ASSERT_EQ(3U, s[0]->InputCount()); |
| 733 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); | 725 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); |
| 734 EXPECT_LE(1U, s[0]->OutputCount()); | 726 EXPECT_LE(1U, s[0]->OutputCount()); |
| 735 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); | 727 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); |
| 736 } | 728 } |
| 737 } | 729 } |
| 738 TRACED_FOREACH(Shift, shift, kShifts) { | 730 TRACED_FOREACH(Shift, shift, kShifts) { |
| 739 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { | 731 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { |
| 740 StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32); | 732 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); |
| 741 m.Return(m.Projection( | 733 m.Return(m.Projection( |
| 742 0, (m.*odpi.constructor)( | 734 0, (m.*odpi.constructor)( |
| 743 (m.*shift.constructor)(m.Parameter(1), m.Int32Constant(imm)), | 735 (m.*shift.constructor)(m.Parameter(1), m.Int32Constant(imm)), |
| 744 m.Parameter(0)))); | 736 m.Parameter(0)))); |
| 745 Stream s = m.Build(); | 737 Stream s = m.Build(); |
| 746 ASSERT_EQ(1U, s.size()); | 738 ASSERT_EQ(1U, s.size()); |
| 747 EXPECT_EQ(odpi.reverse_arch_opcode, s[0]->arch_opcode()); | 739 EXPECT_EQ(odpi.reverse_arch_opcode, s[0]->arch_opcode()); |
| 748 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); | 740 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); |
| 749 ASSERT_EQ(3U, s[0]->InputCount()); | 741 ASSERT_EQ(3U, s[0]->InputCount()); |
| 750 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); | 742 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); |
| 751 EXPECT_LE(1U, s[0]->OutputCount()); | 743 EXPECT_LE(1U, s[0]->OutputCount()); |
| 752 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); | 744 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); |
| 753 } | 745 } |
| 754 } | 746 } |
| 755 } | 747 } |
| 756 | 748 |
| 757 | 749 |
| 758 TEST_P(InstructionSelectorODPITest, BothWithParameters) { | 750 TEST_P(InstructionSelectorODPITest, BothWithParameters) { |
| 759 const ODPI odpi = GetParam(); | 751 const ODPI odpi = GetParam(); |
| 760 StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32); | 752 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); |
| 761 Node* n = (m.*odpi.constructor)(m.Parameter(0), m.Parameter(1)); | 753 Node* n = (m.*odpi.constructor)(m.Parameter(0), m.Parameter(1)); |
| 762 m.Return(m.Word32Equal(m.Projection(0, n), m.Projection(1, n))); | 754 m.Return(m.Word32Equal(m.Projection(0, n), m.Projection(1, n))); |
| 763 Stream s = m.Build(); | 755 Stream s = m.Build(); |
| 764 ASSERT_LE(1U, s.size()); | 756 ASSERT_LE(1U, s.size()); |
| 765 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); | 757 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); |
| 766 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); | 758 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); |
| 767 EXPECT_EQ(2U, s[0]->InputCount()); | 759 EXPECT_EQ(2U, s[0]->InputCount()); |
| 768 EXPECT_EQ(2U, s[0]->OutputCount()); | 760 EXPECT_EQ(2U, s[0]->OutputCount()); |
| 769 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 761 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 770 EXPECT_EQ(kOverflow, s[0]->flags_condition()); | 762 EXPECT_EQ(kOverflow, s[0]->flags_condition()); |
| 771 } | 763 } |
| 772 | 764 |
| 773 | 765 |
| 774 TEST_P(InstructionSelectorODPITest, BothWithImmediate) { | 766 TEST_P(InstructionSelectorODPITest, BothWithImmediate) { |
| 775 const ODPI odpi = GetParam(); | 767 const ODPI odpi = GetParam(); |
| 776 TRACED_FOREACH(int32_t, imm, kImmediates) { | 768 TRACED_FOREACH(int32_t, imm, kImmediates) { |
| 777 StreamBuilder m(this, kMachineWord32, kMachineWord32); | 769 StreamBuilder m(this, kMachInt32, kMachInt32); |
| 778 Node* n = (m.*odpi.constructor)(m.Parameter(0), m.Int32Constant(imm)); | 770 Node* n = (m.*odpi.constructor)(m.Parameter(0), m.Int32Constant(imm)); |
| 779 m.Return(m.Word32Equal(m.Projection(0, n), m.Projection(1, n))); | 771 m.Return(m.Word32Equal(m.Projection(0, n), m.Projection(1, n))); |
| 780 Stream s = m.Build(); | 772 Stream s = m.Build(); |
| 781 ASSERT_LE(1U, s.size()); | 773 ASSERT_LE(1U, s.size()); |
| 782 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); | 774 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); |
| 783 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); | 775 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); |
| 784 ASSERT_EQ(2U, s[0]->InputCount()); | 776 ASSERT_EQ(2U, s[0]->InputCount()); |
| 785 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); | 777 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); |
| 786 EXPECT_EQ(2U, s[0]->OutputCount()); | 778 EXPECT_EQ(2U, s[0]->OutputCount()); |
| 787 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 779 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 788 EXPECT_EQ(kOverflow, s[0]->flags_condition()); | 780 EXPECT_EQ(kOverflow, s[0]->flags_condition()); |
| 789 } | 781 } |
| 790 TRACED_FOREACH(int32_t, imm, kImmediates) { | 782 TRACED_FOREACH(int32_t, imm, kImmediates) { |
| 791 StreamBuilder m(this, kMachineWord32, kMachineWord32); | 783 StreamBuilder m(this, kMachInt32, kMachInt32); |
| 792 Node* n = (m.*odpi.constructor)(m.Int32Constant(imm), m.Parameter(0)); | 784 Node* n = (m.*odpi.constructor)(m.Int32Constant(imm), m.Parameter(0)); |
| 793 m.Return(m.Word32Equal(m.Projection(0, n), m.Projection(1, n))); | 785 m.Return(m.Word32Equal(m.Projection(0, n), m.Projection(1, n))); |
| 794 Stream s = m.Build(); | 786 Stream s = m.Build(); |
| 795 ASSERT_LE(1U, s.size()); | 787 ASSERT_LE(1U, s.size()); |
| 796 EXPECT_EQ(odpi.reverse_arch_opcode, s[0]->arch_opcode()); | 788 EXPECT_EQ(odpi.reverse_arch_opcode, s[0]->arch_opcode()); |
| 797 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); | 789 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); |
| 798 ASSERT_EQ(2U, s[0]->InputCount()); | 790 ASSERT_EQ(2U, s[0]->InputCount()); |
| 799 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); | 791 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); |
| 800 EXPECT_EQ(2U, s[0]->OutputCount()); | 792 EXPECT_EQ(2U, s[0]->OutputCount()); |
| 801 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 793 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 802 EXPECT_EQ(kOverflow, s[0]->flags_condition()); | 794 EXPECT_EQ(kOverflow, s[0]->flags_condition()); |
| 803 } | 795 } |
| 804 } | 796 } |
| 805 | 797 |
| 806 | 798 |
| 807 TEST_P(InstructionSelectorODPITest, BothWithShiftByParameter) { | 799 TEST_P(InstructionSelectorODPITest, BothWithShiftByParameter) { |
| 808 const ODPI odpi = GetParam(); | 800 const ODPI odpi = GetParam(); |
| 809 TRACED_FOREACH(Shift, shift, kShifts) { | 801 TRACED_FOREACH(Shift, shift, kShifts) { |
| 810 StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32, | 802 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); |
| 811 kMachineWord32); | |
| 812 Node* n = (m.*odpi.constructor)( | 803 Node* n = (m.*odpi.constructor)( |
| 813 m.Parameter(0), (m.*shift.constructor)(m.Parameter(1), m.Parameter(2))); | 804 m.Parameter(0), (m.*shift.constructor)(m.Parameter(1), m.Parameter(2))); |
| 814 m.Return(m.Word32Equal(m.Projection(0, n), m.Projection(1, n))); | 805 m.Return(m.Word32Equal(m.Projection(0, n), m.Projection(1, n))); |
| 815 Stream s = m.Build(); | 806 Stream s = m.Build(); |
| 816 ASSERT_LE(1U, s.size()); | 807 ASSERT_LE(1U, s.size()); |
| 817 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); | 808 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); |
| 818 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); | 809 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); |
| 819 EXPECT_EQ(3U, s[0]->InputCount()); | 810 EXPECT_EQ(3U, s[0]->InputCount()); |
| 820 EXPECT_EQ(2U, s[0]->OutputCount()); | 811 EXPECT_EQ(2U, s[0]->OutputCount()); |
| 821 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 812 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 822 EXPECT_EQ(kOverflow, s[0]->flags_condition()); | 813 EXPECT_EQ(kOverflow, s[0]->flags_condition()); |
| 823 } | 814 } |
| 824 TRACED_FOREACH(Shift, shift, kShifts) { | 815 TRACED_FOREACH(Shift, shift, kShifts) { |
| 825 StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32, | 816 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); |
| 826 kMachineWord32); | |
| 827 Node* n = (m.*odpi.constructor)( | 817 Node* n = (m.*odpi.constructor)( |
| 828 (m.*shift.constructor)(m.Parameter(0), m.Parameter(1)), m.Parameter(2)); | 818 (m.*shift.constructor)(m.Parameter(0), m.Parameter(1)), m.Parameter(2)); |
| 829 m.Return(m.Word32Equal(m.Projection(0, n), m.Projection(1, n))); | 819 m.Return(m.Word32Equal(m.Projection(0, n), m.Projection(1, n))); |
| 830 Stream s = m.Build(); | 820 Stream s = m.Build(); |
| 831 ASSERT_LE(1U, s.size()); | 821 ASSERT_LE(1U, s.size()); |
| 832 EXPECT_EQ(odpi.reverse_arch_opcode, s[0]->arch_opcode()); | 822 EXPECT_EQ(odpi.reverse_arch_opcode, s[0]->arch_opcode()); |
| 833 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); | 823 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); |
| 834 EXPECT_EQ(3U, s[0]->InputCount()); | 824 EXPECT_EQ(3U, s[0]->InputCount()); |
| 835 EXPECT_EQ(2U, s[0]->OutputCount()); | 825 EXPECT_EQ(2U, s[0]->OutputCount()); |
| 836 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 826 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 837 EXPECT_EQ(kOverflow, s[0]->flags_condition()); | 827 EXPECT_EQ(kOverflow, s[0]->flags_condition()); |
| 838 } | 828 } |
| 839 } | 829 } |
| 840 | 830 |
| 841 | 831 |
| 842 TEST_P(InstructionSelectorODPITest, BothWithShiftByImmediate) { | 832 TEST_P(InstructionSelectorODPITest, BothWithShiftByImmediate) { |
| 843 const ODPI odpi = GetParam(); | 833 const ODPI odpi = GetParam(); |
| 844 TRACED_FOREACH(Shift, shift, kShifts) { | 834 TRACED_FOREACH(Shift, shift, kShifts) { |
| 845 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { | 835 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { |
| 846 StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32); | 836 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); |
| 847 Node* n = (m.*odpi.constructor)( | 837 Node* n = (m.*odpi.constructor)( |
| 848 m.Parameter(0), | 838 m.Parameter(0), |
| 849 (m.*shift.constructor)(m.Parameter(1), m.Int32Constant(imm))); | 839 (m.*shift.constructor)(m.Parameter(1), m.Int32Constant(imm))); |
| 850 m.Return(m.Word32Equal(m.Projection(0, n), m.Projection(1, n))); | 840 m.Return(m.Word32Equal(m.Projection(0, n), m.Projection(1, n))); |
| 851 Stream s = m.Build(); | 841 Stream s = m.Build(); |
| 852 ASSERT_LE(1U, s.size()); | 842 ASSERT_LE(1U, s.size()); |
| 853 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); | 843 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); |
| 854 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); | 844 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); |
| 855 ASSERT_EQ(3U, s[0]->InputCount()); | 845 ASSERT_EQ(3U, s[0]->InputCount()); |
| 856 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); | 846 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); |
| 857 EXPECT_EQ(2U, s[0]->OutputCount()); | 847 EXPECT_EQ(2U, s[0]->OutputCount()); |
| 858 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 848 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 859 EXPECT_EQ(kOverflow, s[0]->flags_condition()); | 849 EXPECT_EQ(kOverflow, s[0]->flags_condition()); |
| 860 } | 850 } |
| 861 } | 851 } |
| 862 TRACED_FOREACH(Shift, shift, kShifts) { | 852 TRACED_FOREACH(Shift, shift, kShifts) { |
| 863 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { | 853 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { |
| 864 StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32); | 854 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); |
| 865 Node* n = (m.*odpi.constructor)( | 855 Node* n = (m.*odpi.constructor)( |
| 866 (m.*shift.constructor)(m.Parameter(0), m.Int32Constant(imm)), | 856 (m.*shift.constructor)(m.Parameter(0), m.Int32Constant(imm)), |
| 867 m.Parameter(1)); | 857 m.Parameter(1)); |
| 868 m.Return(m.Word32Equal(m.Projection(0, n), m.Projection(1, n))); | 858 m.Return(m.Word32Equal(m.Projection(0, n), m.Projection(1, n))); |
| 869 Stream s = m.Build(); | 859 Stream s = m.Build(); |
| 870 ASSERT_LE(1U, s.size()); | 860 ASSERT_LE(1U, s.size()); |
| 871 EXPECT_EQ(odpi.reverse_arch_opcode, s[0]->arch_opcode()); | 861 EXPECT_EQ(odpi.reverse_arch_opcode, s[0]->arch_opcode()); |
| 872 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); | 862 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); |
| 873 ASSERT_EQ(3U, s[0]->InputCount()); | 863 ASSERT_EQ(3U, s[0]->InputCount()); |
| 874 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); | 864 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); |
| 875 EXPECT_EQ(2U, s[0]->OutputCount()); | 865 EXPECT_EQ(2U, s[0]->OutputCount()); |
| 876 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 866 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 877 EXPECT_EQ(kOverflow, s[0]->flags_condition()); | 867 EXPECT_EQ(kOverflow, s[0]->flags_condition()); |
| 878 } | 868 } |
| 879 } | 869 } |
| 880 } | 870 } |
| 881 | 871 |
| 882 | 872 |
| 883 TEST_P(InstructionSelectorODPITest, BranchWithParameters) { | 873 TEST_P(InstructionSelectorODPITest, BranchWithParameters) { |
| 884 const ODPI odpi = GetParam(); | 874 const ODPI odpi = GetParam(); |
| 885 StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32); | 875 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); |
| 886 MLabel a, b; | 876 MLabel a, b; |
| 887 Node* n = (m.*odpi.constructor)(m.Parameter(0), m.Parameter(1)); | 877 Node* n = (m.*odpi.constructor)(m.Parameter(0), m.Parameter(1)); |
| 888 m.Branch(m.Projection(1, n), &a, &b); | 878 m.Branch(m.Projection(1, n), &a, &b); |
| 889 m.Bind(&a); | 879 m.Bind(&a); |
| 890 m.Return(m.Int32Constant(0)); | 880 m.Return(m.Int32Constant(0)); |
| 891 m.Bind(&b); | 881 m.Bind(&b); |
| 892 m.Return(m.Projection(0, n)); | 882 m.Return(m.Projection(0, n)); |
| 893 Stream s = m.Build(); | 883 Stream s = m.Build(); |
| 894 ASSERT_EQ(1U, s.size()); | 884 ASSERT_EQ(1U, s.size()); |
| 895 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); | 885 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); |
| 896 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); | 886 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); |
| 897 EXPECT_EQ(4U, s[0]->InputCount()); | 887 EXPECT_EQ(4U, s[0]->InputCount()); |
| 898 EXPECT_EQ(1U, s[0]->OutputCount()); | 888 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 899 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); | 889 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); |
| 900 EXPECT_EQ(kOverflow, s[0]->flags_condition()); | 890 EXPECT_EQ(kOverflow, s[0]->flags_condition()); |
| 901 } | 891 } |
| 902 | 892 |
| 903 | 893 |
| 904 TEST_P(InstructionSelectorODPITest, BranchWithImmediate) { | 894 TEST_P(InstructionSelectorODPITest, BranchWithImmediate) { |
| 905 const ODPI odpi = GetParam(); | 895 const ODPI odpi = GetParam(); |
| 906 TRACED_FOREACH(int32_t, imm, kImmediates) { | 896 TRACED_FOREACH(int32_t, imm, kImmediates) { |
| 907 StreamBuilder m(this, kMachineWord32, kMachineWord32); | 897 StreamBuilder m(this, kMachInt32, kMachInt32); |
| 908 MLabel a, b; | 898 MLabel a, b; |
| 909 Node* n = (m.*odpi.constructor)(m.Parameter(0), m.Int32Constant(imm)); | 899 Node* n = (m.*odpi.constructor)(m.Parameter(0), m.Int32Constant(imm)); |
| 910 m.Branch(m.Projection(1, n), &a, &b); | 900 m.Branch(m.Projection(1, n), &a, &b); |
| 911 m.Bind(&a); | 901 m.Bind(&a); |
| 912 m.Return(m.Int32Constant(0)); | 902 m.Return(m.Int32Constant(0)); |
| 913 m.Bind(&b); | 903 m.Bind(&b); |
| 914 m.Return(m.Projection(0, n)); | 904 m.Return(m.Projection(0, n)); |
| 915 Stream s = m.Build(); | 905 Stream s = m.Build(); |
| 916 ASSERT_EQ(1U, s.size()); | 906 ASSERT_EQ(1U, s.size()); |
| 917 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); | 907 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); |
| 918 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); | 908 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); |
| 919 ASSERT_EQ(4U, s[0]->InputCount()); | 909 ASSERT_EQ(4U, s[0]->InputCount()); |
| 920 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); | 910 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); |
| 921 EXPECT_EQ(1U, s[0]->OutputCount()); | 911 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 922 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); | 912 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); |
| 923 EXPECT_EQ(kOverflow, s[0]->flags_condition()); | 913 EXPECT_EQ(kOverflow, s[0]->flags_condition()); |
| 924 } | 914 } |
| 925 TRACED_FOREACH(int32_t, imm, kImmediates) { | 915 TRACED_FOREACH(int32_t, imm, kImmediates) { |
| 926 StreamBuilder m(this, kMachineWord32, kMachineWord32); | 916 StreamBuilder m(this, kMachInt32, kMachInt32); |
| 927 MLabel a, b; | 917 MLabel a, b; |
| 928 Node* n = (m.*odpi.constructor)(m.Int32Constant(imm), m.Parameter(0)); | 918 Node* n = (m.*odpi.constructor)(m.Int32Constant(imm), m.Parameter(0)); |
| 929 m.Branch(m.Projection(1, n), &a, &b); | 919 m.Branch(m.Projection(1, n), &a, &b); |
| 930 m.Bind(&a); | 920 m.Bind(&a); |
| 931 m.Return(m.Int32Constant(0)); | 921 m.Return(m.Int32Constant(0)); |
| 932 m.Bind(&b); | 922 m.Bind(&b); |
| 933 m.Return(m.Projection(0, n)); | 923 m.Return(m.Projection(0, n)); |
| 934 Stream s = m.Build(); | 924 Stream s = m.Build(); |
| 935 ASSERT_EQ(1U, s.size()); | 925 ASSERT_EQ(1U, s.size()); |
| 936 EXPECT_EQ(odpi.reverse_arch_opcode, s[0]->arch_opcode()); | 926 EXPECT_EQ(odpi.reverse_arch_opcode, s[0]->arch_opcode()); |
| 937 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); | 927 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); |
| 938 ASSERT_EQ(4U, s[0]->InputCount()); | 928 ASSERT_EQ(4U, s[0]->InputCount()); |
| 939 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); | 929 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); |
| 940 EXPECT_EQ(1U, s[0]->OutputCount()); | 930 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 941 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); | 931 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); |
| 942 EXPECT_EQ(kOverflow, s[0]->flags_condition()); | 932 EXPECT_EQ(kOverflow, s[0]->flags_condition()); |
| 943 } | 933 } |
| 944 } | 934 } |
| 945 | 935 |
| 946 | 936 |
| 947 TEST_P(InstructionSelectorODPITest, BranchIfZeroWithParameters) { | 937 TEST_P(InstructionSelectorODPITest, BranchIfZeroWithParameters) { |
| 948 const ODPI odpi = GetParam(); | 938 const ODPI odpi = GetParam(); |
| 949 StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32); | 939 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); |
| 950 MLabel a, b; | 940 MLabel a, b; |
| 951 Node* n = (m.*odpi.constructor)(m.Parameter(0), m.Parameter(1)); | 941 Node* n = (m.*odpi.constructor)(m.Parameter(0), m.Parameter(1)); |
| 952 m.Branch(m.Word32Equal(m.Projection(1, n), m.Int32Constant(0)), &a, &b); | 942 m.Branch(m.Word32Equal(m.Projection(1, n), m.Int32Constant(0)), &a, &b); |
| 953 m.Bind(&a); | 943 m.Bind(&a); |
| 954 m.Return(m.Projection(0, n)); | 944 m.Return(m.Projection(0, n)); |
| 955 m.Bind(&b); | 945 m.Bind(&b); |
| 956 m.Return(m.Int32Constant(0)); | 946 m.Return(m.Int32Constant(0)); |
| 957 Stream s = m.Build(); | 947 Stream s = m.Build(); |
| 958 ASSERT_EQ(1U, s.size()); | 948 ASSERT_EQ(1U, s.size()); |
| 959 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); | 949 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); |
| 960 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); | 950 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); |
| 961 EXPECT_EQ(4U, s[0]->InputCount()); | 951 EXPECT_EQ(4U, s[0]->InputCount()); |
| 962 EXPECT_EQ(1U, s[0]->OutputCount()); | 952 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 963 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); | 953 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); |
| 964 EXPECT_EQ(kNotOverflow, s[0]->flags_condition()); | 954 EXPECT_EQ(kNotOverflow, s[0]->flags_condition()); |
| 965 } | 955 } |
| 966 | 956 |
| 967 | 957 |
| 968 TEST_P(InstructionSelectorODPITest, BranchIfNotZeroWithParameters) { | 958 TEST_P(InstructionSelectorODPITest, BranchIfNotZeroWithParameters) { |
| 969 const ODPI odpi = GetParam(); | 959 const ODPI odpi = GetParam(); |
| 970 StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32); | 960 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); |
| 971 MLabel a, b; | 961 MLabel a, b; |
| 972 Node* n = (m.*odpi.constructor)(m.Parameter(0), m.Parameter(1)); | 962 Node* n = (m.*odpi.constructor)(m.Parameter(0), m.Parameter(1)); |
| 973 m.Branch(m.Word32NotEqual(m.Projection(1, n), m.Int32Constant(0)), &a, &b); | 963 m.Branch(m.Word32NotEqual(m.Projection(1, n), m.Int32Constant(0)), &a, &b); |
| 974 m.Bind(&a); | 964 m.Bind(&a); |
| 975 m.Return(m.Projection(0, n)); | 965 m.Return(m.Projection(0, n)); |
| 976 m.Bind(&b); | 966 m.Bind(&b); |
| 977 m.Return(m.Int32Constant(0)); | 967 m.Return(m.Int32Constant(0)); |
| 978 Stream s = m.Build(); | 968 Stream s = m.Build(); |
| 979 ASSERT_EQ(1U, s.size()); | 969 ASSERT_EQ(1U, s.size()); |
| 980 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); | 970 EXPECT_EQ(odpi.arch_opcode, s[0]->arch_opcode()); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 992 | 982 |
| 993 // ----------------------------------------------------------------------------- | 983 // ----------------------------------------------------------------------------- |
| 994 // Shifts. | 984 // Shifts. |
| 995 | 985 |
| 996 | 986 |
| 997 typedef InstructionSelectorTestWithParam<Shift> InstructionSelectorShiftTest; | 987 typedef InstructionSelectorTestWithParam<Shift> InstructionSelectorShiftTest; |
| 998 | 988 |
| 999 | 989 |
| 1000 TEST_P(InstructionSelectorShiftTest, Parameters) { | 990 TEST_P(InstructionSelectorShiftTest, Parameters) { |
| 1001 const Shift shift = GetParam(); | 991 const Shift shift = GetParam(); |
| 1002 StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32); | 992 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); |
| 1003 m.Return((m.*shift.constructor)(m.Parameter(0), m.Parameter(1))); | 993 m.Return((m.*shift.constructor)(m.Parameter(0), m.Parameter(1))); |
| 1004 Stream s = m.Build(); | 994 Stream s = m.Build(); |
| 1005 ASSERT_EQ(1U, s.size()); | 995 ASSERT_EQ(1U, s.size()); |
| 1006 EXPECT_EQ(kArmMov, s[0]->arch_opcode()); | 996 EXPECT_EQ(kArmMov, s[0]->arch_opcode()); |
| 1007 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); | 997 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); |
| 1008 EXPECT_EQ(2U, s[0]->InputCount()); | 998 EXPECT_EQ(2U, s[0]->InputCount()); |
| 1009 EXPECT_EQ(1U, s[0]->OutputCount()); | 999 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 1010 } | 1000 } |
| 1011 | 1001 |
| 1012 | 1002 |
| 1013 TEST_P(InstructionSelectorShiftTest, Immediate) { | 1003 TEST_P(InstructionSelectorShiftTest, Immediate) { |
| 1014 const Shift shift = GetParam(); | 1004 const Shift shift = GetParam(); |
| 1015 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { | 1005 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { |
| 1016 StreamBuilder m(this, kMachineWord32, kMachineWord32); | 1006 StreamBuilder m(this, kMachInt32, kMachInt32); |
| 1017 m.Return((m.*shift.constructor)(m.Parameter(0), m.Int32Constant(imm))); | 1007 m.Return((m.*shift.constructor)(m.Parameter(0), m.Int32Constant(imm))); |
| 1018 Stream s = m.Build(); | 1008 Stream s = m.Build(); |
| 1019 ASSERT_EQ(1U, s.size()); | 1009 ASSERT_EQ(1U, s.size()); |
| 1020 EXPECT_EQ(kArmMov, s[0]->arch_opcode()); | 1010 EXPECT_EQ(kArmMov, s[0]->arch_opcode()); |
| 1021 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); | 1011 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); |
| 1022 ASSERT_EQ(2U, s[0]->InputCount()); | 1012 ASSERT_EQ(2U, s[0]->InputCount()); |
| 1023 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); | 1013 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); |
| 1024 EXPECT_EQ(1U, s[0]->OutputCount()); | 1014 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 1025 } | 1015 } |
| 1026 } | 1016 } |
| 1027 | 1017 |
| 1028 | 1018 |
| 1029 TEST_P(InstructionSelectorShiftTest, Word32EqualWithParameter) { | 1019 TEST_P(InstructionSelectorShiftTest, Word32EqualWithParameter) { |
| 1030 const Shift shift = GetParam(); | 1020 const Shift shift = GetParam(); |
| 1031 { | 1021 { |
| 1032 StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32, | 1022 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); |
| 1033 kMachineWord32); | |
| 1034 m.Return( | 1023 m.Return( |
| 1035 m.Word32Equal(m.Parameter(0), | 1024 m.Word32Equal(m.Parameter(0), |
| 1036 (m.*shift.constructor)(m.Parameter(1), m.Parameter(2)))); | 1025 (m.*shift.constructor)(m.Parameter(1), m.Parameter(2)))); |
| 1037 Stream s = m.Build(); | 1026 Stream s = m.Build(); |
| 1038 ASSERT_EQ(1U, s.size()); | 1027 ASSERT_EQ(1U, s.size()); |
| 1039 EXPECT_EQ(kArmCmp, s[0]->arch_opcode()); | 1028 EXPECT_EQ(kArmCmp, s[0]->arch_opcode()); |
| 1040 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); | 1029 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); |
| 1041 EXPECT_EQ(3U, s[0]->InputCount()); | 1030 EXPECT_EQ(3U, s[0]->InputCount()); |
| 1042 EXPECT_EQ(1U, s[0]->OutputCount()); | 1031 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 1043 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 1032 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 1044 EXPECT_EQ(kEqual, s[0]->flags_condition()); | 1033 EXPECT_EQ(kEqual, s[0]->flags_condition()); |
| 1045 } | 1034 } |
| 1046 { | 1035 { |
| 1047 StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32, | 1036 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); |
| 1048 kMachineWord32); | |
| 1049 m.Return( | 1037 m.Return( |
| 1050 m.Word32Equal((m.*shift.constructor)(m.Parameter(1), m.Parameter(2)), | 1038 m.Word32Equal((m.*shift.constructor)(m.Parameter(1), m.Parameter(2)), |
| 1051 m.Parameter(0))); | 1039 m.Parameter(0))); |
| 1052 Stream s = m.Build(); | 1040 Stream s = m.Build(); |
| 1053 ASSERT_EQ(1U, s.size()); | 1041 ASSERT_EQ(1U, s.size()); |
| 1054 EXPECT_EQ(kArmCmp, s[0]->arch_opcode()); | 1042 EXPECT_EQ(kArmCmp, s[0]->arch_opcode()); |
| 1055 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); | 1043 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); |
| 1056 EXPECT_EQ(3U, s[0]->InputCount()); | 1044 EXPECT_EQ(3U, s[0]->InputCount()); |
| 1057 EXPECT_EQ(1U, s[0]->OutputCount()); | 1045 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 1058 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 1046 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 1059 EXPECT_EQ(kEqual, s[0]->flags_condition()); | 1047 EXPECT_EQ(kEqual, s[0]->flags_condition()); |
| 1060 } | 1048 } |
| 1061 } | 1049 } |
| 1062 | 1050 |
| 1063 | 1051 |
| 1064 TEST_P(InstructionSelectorShiftTest, Word32EqualWithParameterAndImmediate) { | 1052 TEST_P(InstructionSelectorShiftTest, Word32EqualWithParameterAndImmediate) { |
| 1065 const Shift shift = GetParam(); | 1053 const Shift shift = GetParam(); |
| 1066 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { | 1054 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { |
| 1067 StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32); | 1055 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); |
| 1068 m.Return(m.Word32Equal( | 1056 m.Return(m.Word32Equal( |
| 1069 (m.*shift.constructor)(m.Parameter(1), m.Int32Constant(imm)), | 1057 (m.*shift.constructor)(m.Parameter(1), m.Int32Constant(imm)), |
| 1070 m.Parameter(0))); | 1058 m.Parameter(0))); |
| 1071 Stream s = m.Build(); | 1059 Stream s = m.Build(); |
| 1072 ASSERT_EQ(1U, s.size()); | 1060 ASSERT_EQ(1U, s.size()); |
| 1073 EXPECT_EQ(kArmCmp, s[0]->arch_opcode()); | 1061 EXPECT_EQ(kArmCmp, s[0]->arch_opcode()); |
| 1074 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); | 1062 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); |
| 1075 ASSERT_EQ(3U, s[0]->InputCount()); | 1063 ASSERT_EQ(3U, s[0]->InputCount()); |
| 1076 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); | 1064 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); |
| 1077 EXPECT_EQ(1U, s[0]->OutputCount()); | 1065 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 1078 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 1066 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 1079 EXPECT_EQ(kEqual, s[0]->flags_condition()); | 1067 EXPECT_EQ(kEqual, s[0]->flags_condition()); |
| 1080 } | 1068 } |
| 1081 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { | 1069 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { |
| 1082 StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32); | 1070 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); |
| 1083 m.Return(m.Word32Equal( | 1071 m.Return(m.Word32Equal( |
| 1084 m.Parameter(0), | 1072 m.Parameter(0), |
| 1085 (m.*shift.constructor)(m.Parameter(1), m.Int32Constant(imm)))); | 1073 (m.*shift.constructor)(m.Parameter(1), m.Int32Constant(imm)))); |
| 1086 Stream s = m.Build(); | 1074 Stream s = m.Build(); |
| 1087 ASSERT_EQ(1U, s.size()); | 1075 ASSERT_EQ(1U, s.size()); |
| 1088 EXPECT_EQ(kArmCmp, s[0]->arch_opcode()); | 1076 EXPECT_EQ(kArmCmp, s[0]->arch_opcode()); |
| 1089 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); | 1077 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); |
| 1090 ASSERT_EQ(3U, s[0]->InputCount()); | 1078 ASSERT_EQ(3U, s[0]->InputCount()); |
| 1091 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); | 1079 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); |
| 1092 EXPECT_EQ(1U, s[0]->OutputCount()); | 1080 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 1093 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 1081 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 1094 EXPECT_EQ(kEqual, s[0]->flags_condition()); | 1082 EXPECT_EQ(kEqual, s[0]->flags_condition()); |
| 1095 } | 1083 } |
| 1096 } | 1084 } |
| 1097 | 1085 |
| 1098 | 1086 |
| 1099 TEST_P(InstructionSelectorShiftTest, Word32NotWithParameters) { | 1087 TEST_P(InstructionSelectorShiftTest, Word32NotWithParameters) { |
| 1100 const Shift shift = GetParam(); | 1088 const Shift shift = GetParam(); |
| 1101 StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32); | 1089 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); |
| 1102 m.Return(m.Word32Not((m.*shift.constructor)(m.Parameter(0), m.Parameter(1)))); | 1090 m.Return(m.Word32Not((m.*shift.constructor)(m.Parameter(0), m.Parameter(1)))); |
| 1103 Stream s = m.Build(); | 1091 Stream s = m.Build(); |
| 1104 ASSERT_EQ(1U, s.size()); | 1092 ASSERT_EQ(1U, s.size()); |
| 1105 EXPECT_EQ(kArmMvn, s[0]->arch_opcode()); | 1093 EXPECT_EQ(kArmMvn, s[0]->arch_opcode()); |
| 1106 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); | 1094 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); |
| 1107 EXPECT_EQ(2U, s[0]->InputCount()); | 1095 EXPECT_EQ(2U, s[0]->InputCount()); |
| 1108 EXPECT_EQ(1U, s[0]->OutputCount()); | 1096 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 1109 } | 1097 } |
| 1110 | 1098 |
| 1111 | 1099 |
| 1112 TEST_P(InstructionSelectorShiftTest, Word32NotWithImmediate) { | 1100 TEST_P(InstructionSelectorShiftTest, Word32NotWithImmediate) { |
| 1113 const Shift shift = GetParam(); | 1101 const Shift shift = GetParam(); |
| 1114 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { | 1102 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { |
| 1115 StreamBuilder m(this, kMachineWord32, kMachineWord32); | 1103 StreamBuilder m(this, kMachInt32, kMachInt32); |
| 1116 m.Return(m.Word32Not( | 1104 m.Return(m.Word32Not( |
| 1117 (m.*shift.constructor)(m.Parameter(0), m.Int32Constant(imm)))); | 1105 (m.*shift.constructor)(m.Parameter(0), m.Int32Constant(imm)))); |
| 1118 Stream s = m.Build(); | 1106 Stream s = m.Build(); |
| 1119 ASSERT_EQ(1U, s.size()); | 1107 ASSERT_EQ(1U, s.size()); |
| 1120 EXPECT_EQ(kArmMvn, s[0]->arch_opcode()); | 1108 EXPECT_EQ(kArmMvn, s[0]->arch_opcode()); |
| 1121 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); | 1109 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); |
| 1122 ASSERT_EQ(2U, s[0]->InputCount()); | 1110 ASSERT_EQ(2U, s[0]->InputCount()); |
| 1123 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); | 1111 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); |
| 1124 EXPECT_EQ(1U, s[0]->OutputCount()); | 1112 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 1125 } | 1113 } |
| 1126 } | 1114 } |
| 1127 | 1115 |
| 1128 | 1116 |
| 1129 TEST_P(InstructionSelectorShiftTest, Word32AndWithWord32NotWithParameters) { | 1117 TEST_P(InstructionSelectorShiftTest, Word32AndWithWord32NotWithParameters) { |
| 1130 const Shift shift = GetParam(); | 1118 const Shift shift = GetParam(); |
| 1131 StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32, | 1119 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); |
| 1132 kMachineWord32); | |
| 1133 m.Return(m.Word32And(m.Parameter(0), m.Word32Not((m.*shift.constructor)( | 1120 m.Return(m.Word32And(m.Parameter(0), m.Word32Not((m.*shift.constructor)( |
| 1134 m.Parameter(1), m.Parameter(2))))); | 1121 m.Parameter(1), m.Parameter(2))))); |
| 1135 Stream s = m.Build(); | 1122 Stream s = m.Build(); |
| 1136 ASSERT_EQ(1U, s.size()); | 1123 ASSERT_EQ(1U, s.size()); |
| 1137 EXPECT_EQ(kArmBic, s[0]->arch_opcode()); | 1124 EXPECT_EQ(kArmBic, s[0]->arch_opcode()); |
| 1138 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); | 1125 EXPECT_EQ(shift.r_mode, s[0]->addressing_mode()); |
| 1139 EXPECT_EQ(3U, s[0]->InputCount()); | 1126 EXPECT_EQ(3U, s[0]->InputCount()); |
| 1140 EXPECT_EQ(1U, s[0]->OutputCount()); | 1127 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 1141 } | 1128 } |
| 1142 | 1129 |
| 1143 | 1130 |
| 1144 TEST_P(InstructionSelectorShiftTest, Word32AndWithWord32NotWithImmediate) { | 1131 TEST_P(InstructionSelectorShiftTest, Word32AndWithWord32NotWithImmediate) { |
| 1145 const Shift shift = GetParam(); | 1132 const Shift shift = GetParam(); |
| 1146 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { | 1133 TRACED_FORRANGE(int32_t, imm, shift.i_low, shift.i_high) { |
| 1147 StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32); | 1134 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); |
| 1148 m.Return(m.Word32And(m.Parameter(0), | 1135 m.Return(m.Word32And(m.Parameter(0), |
| 1149 m.Word32Not((m.*shift.constructor)( | 1136 m.Word32Not((m.*shift.constructor)( |
| 1150 m.Parameter(1), m.Int32Constant(imm))))); | 1137 m.Parameter(1), m.Int32Constant(imm))))); |
| 1151 Stream s = m.Build(); | 1138 Stream s = m.Build(); |
| 1152 ASSERT_EQ(1U, s.size()); | 1139 ASSERT_EQ(1U, s.size()); |
| 1153 EXPECT_EQ(kArmBic, s[0]->arch_opcode()); | 1140 EXPECT_EQ(kArmBic, s[0]->arch_opcode()); |
| 1154 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); | 1141 EXPECT_EQ(shift.i_mode, s[0]->addressing_mode()); |
| 1155 ASSERT_EQ(3U, s[0]->InputCount()); | 1142 ASSERT_EQ(3U, s[0]->InputCount()); |
| 1156 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); | 1143 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(2))); |
| 1157 EXPECT_EQ(1U, s[0]->OutputCount()); | 1144 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 1158 } | 1145 } |
| 1159 } | 1146 } |
| 1160 | 1147 |
| 1161 | 1148 |
| 1162 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, InstructionSelectorShiftTest, | 1149 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, InstructionSelectorShiftTest, |
| 1163 ::testing::ValuesIn(kShifts)); | 1150 ::testing::ValuesIn(kShifts)); |
| 1164 | 1151 |
| 1165 | 1152 |
| 1166 // ----------------------------------------------------------------------------- | 1153 // ----------------------------------------------------------------------------- |
| 1167 // Miscellaneous. | 1154 // Miscellaneous. |
| 1168 | 1155 |
| 1169 | 1156 |
| 1170 TEST_F(InstructionSelectorTest, Int32AddWithInt32Mul) { | 1157 TEST_F(InstructionSelectorTest, Int32AddWithInt32Mul) { |
| 1171 { | 1158 { |
| 1172 StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32, | 1159 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); |
| 1173 kMachineWord32); | |
| 1174 m.Return( | 1160 m.Return( |
| 1175 m.Int32Add(m.Parameter(0), m.Int32Mul(m.Parameter(1), m.Parameter(2)))); | 1161 m.Int32Add(m.Parameter(0), m.Int32Mul(m.Parameter(1), m.Parameter(2)))); |
| 1176 Stream s = m.Build(); | 1162 Stream s = m.Build(); |
| 1177 ASSERT_EQ(1U, s.size()); | 1163 ASSERT_EQ(1U, s.size()); |
| 1178 EXPECT_EQ(kArmMla, s[0]->arch_opcode()); | 1164 EXPECT_EQ(kArmMla, s[0]->arch_opcode()); |
| 1179 EXPECT_EQ(3U, s[0]->InputCount()); | 1165 EXPECT_EQ(3U, s[0]->InputCount()); |
| 1180 EXPECT_EQ(1U, s[0]->OutputCount()); | 1166 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 1181 } | 1167 } |
| 1182 { | 1168 { |
| 1183 StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32, | 1169 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); |
| 1184 kMachineWord32); | |
| 1185 m.Return( | 1170 m.Return( |
| 1186 m.Int32Add(m.Int32Mul(m.Parameter(1), m.Parameter(2)), m.Parameter(0))); | 1171 m.Int32Add(m.Int32Mul(m.Parameter(1), m.Parameter(2)), m.Parameter(0))); |
| 1187 Stream s = m.Build(); | 1172 Stream s = m.Build(); |
| 1188 ASSERT_EQ(1U, s.size()); | 1173 ASSERT_EQ(1U, s.size()); |
| 1189 EXPECT_EQ(kArmMla, s[0]->arch_opcode()); | 1174 EXPECT_EQ(kArmMla, s[0]->arch_opcode()); |
| 1190 EXPECT_EQ(3U, s[0]->InputCount()); | 1175 EXPECT_EQ(3U, s[0]->InputCount()); |
| 1191 EXPECT_EQ(1U, s[0]->OutputCount()); | 1176 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 1192 } | 1177 } |
| 1193 } | 1178 } |
| 1194 | 1179 |
| 1195 | 1180 |
| 1196 TEST_F(InstructionSelectorTest, Int32DivWithParameters) { | 1181 TEST_F(InstructionSelectorTest, Int32DivWithParameters) { |
| 1197 StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32); | 1182 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); |
| 1198 m.Return(m.Int32Div(m.Parameter(0), m.Parameter(1))); | 1183 m.Return(m.Int32Div(m.Parameter(0), m.Parameter(1))); |
| 1199 Stream s = m.Build(); | 1184 Stream s = m.Build(); |
| 1200 ASSERT_EQ(4U, s.size()); | 1185 ASSERT_EQ(4U, s.size()); |
| 1201 EXPECT_EQ(kArmVcvtF64S32, s[0]->arch_opcode()); | 1186 EXPECT_EQ(kArmVcvtF64S32, s[0]->arch_opcode()); |
| 1202 ASSERT_EQ(1U, s[0]->OutputCount()); | 1187 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 1203 EXPECT_EQ(kArmVcvtF64S32, s[1]->arch_opcode()); | 1188 EXPECT_EQ(kArmVcvtF64S32, s[1]->arch_opcode()); |
| 1204 ASSERT_EQ(1U, s[1]->OutputCount()); | 1189 ASSERT_EQ(1U, s[1]->OutputCount()); |
| 1205 EXPECT_EQ(kArmVdivF64, s[2]->arch_opcode()); | 1190 EXPECT_EQ(kArmVdivF64, s[2]->arch_opcode()); |
| 1206 ASSERT_EQ(2U, s[2]->InputCount()); | 1191 ASSERT_EQ(2U, s[2]->InputCount()); |
| 1207 ASSERT_EQ(1U, s[2]->OutputCount()); | 1192 ASSERT_EQ(1U, s[2]->OutputCount()); |
| 1208 EXPECT_EQ(s.ToVreg(s[0]->Output()), s.ToVreg(s[2]->InputAt(0))); | 1193 EXPECT_EQ(s.ToVreg(s[0]->Output()), s.ToVreg(s[2]->InputAt(0))); |
| 1209 EXPECT_EQ(s.ToVreg(s[1]->Output()), s.ToVreg(s[2]->InputAt(1))); | 1194 EXPECT_EQ(s.ToVreg(s[1]->Output()), s.ToVreg(s[2]->InputAt(1))); |
| 1210 EXPECT_EQ(kArmVcvtS32F64, s[3]->arch_opcode()); | 1195 EXPECT_EQ(kArmVcvtS32F64, s[3]->arch_opcode()); |
| 1211 ASSERT_EQ(1U, s[3]->InputCount()); | 1196 ASSERT_EQ(1U, s[3]->InputCount()); |
| 1212 EXPECT_EQ(s.ToVreg(s[2]->Output()), s.ToVreg(s[3]->InputAt(0))); | 1197 EXPECT_EQ(s.ToVreg(s[2]->Output()), s.ToVreg(s[3]->InputAt(0))); |
| 1213 } | 1198 } |
| 1214 | 1199 |
| 1215 | 1200 |
| 1216 TEST_F(InstructionSelectorTest, Int32DivWithParametersForSUDIV) { | 1201 TEST_F(InstructionSelectorTest, Int32DivWithParametersForSUDIV) { |
| 1217 StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32); | 1202 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); |
| 1218 m.Return(m.Int32Div(m.Parameter(0), m.Parameter(1))); | 1203 m.Return(m.Int32Div(m.Parameter(0), m.Parameter(1))); |
| 1219 Stream s = m.Build(SUDIV); | 1204 Stream s = m.Build(SUDIV); |
| 1220 ASSERT_EQ(1U, s.size()); | 1205 ASSERT_EQ(1U, s.size()); |
| 1221 EXPECT_EQ(kArmSdiv, s[0]->arch_opcode()); | 1206 EXPECT_EQ(kArmSdiv, s[0]->arch_opcode()); |
| 1222 } | 1207 } |
| 1223 | 1208 |
| 1224 | 1209 |
| 1225 TEST_F(InstructionSelectorTest, Int32ModWithParameters) { | 1210 TEST_F(InstructionSelectorTest, Int32ModWithParameters) { |
| 1226 StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32); | 1211 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); |
| 1227 m.Return(m.Int32Mod(m.Parameter(0), m.Parameter(1))); | 1212 m.Return(m.Int32Mod(m.Parameter(0), m.Parameter(1))); |
| 1228 Stream s = m.Build(); | 1213 Stream s = m.Build(); |
| 1229 ASSERT_EQ(6U, s.size()); | 1214 ASSERT_EQ(6U, s.size()); |
| 1230 EXPECT_EQ(kArmVcvtF64S32, s[0]->arch_opcode()); | 1215 EXPECT_EQ(kArmVcvtF64S32, s[0]->arch_opcode()); |
| 1231 ASSERT_EQ(1U, s[0]->OutputCount()); | 1216 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 1232 EXPECT_EQ(kArmVcvtF64S32, s[1]->arch_opcode()); | 1217 EXPECT_EQ(kArmVcvtF64S32, s[1]->arch_opcode()); |
| 1233 ASSERT_EQ(1U, s[1]->OutputCount()); | 1218 ASSERT_EQ(1U, s[1]->OutputCount()); |
| 1234 EXPECT_EQ(kArmVdivF64, s[2]->arch_opcode()); | 1219 EXPECT_EQ(kArmVdivF64, s[2]->arch_opcode()); |
| 1235 ASSERT_EQ(2U, s[2]->InputCount()); | 1220 ASSERT_EQ(2U, s[2]->InputCount()); |
| 1236 ASSERT_EQ(1U, s[2]->OutputCount()); | 1221 ASSERT_EQ(1U, s[2]->OutputCount()); |
| 1237 EXPECT_EQ(s.ToVreg(s[0]->Output()), s.ToVreg(s[2]->InputAt(0))); | 1222 EXPECT_EQ(s.ToVreg(s[0]->Output()), s.ToVreg(s[2]->InputAt(0))); |
| 1238 EXPECT_EQ(s.ToVreg(s[1]->Output()), s.ToVreg(s[2]->InputAt(1))); | 1223 EXPECT_EQ(s.ToVreg(s[1]->Output()), s.ToVreg(s[2]->InputAt(1))); |
| 1239 EXPECT_EQ(kArmVcvtS32F64, s[3]->arch_opcode()); | 1224 EXPECT_EQ(kArmVcvtS32F64, s[3]->arch_opcode()); |
| 1240 ASSERT_EQ(1U, s[3]->InputCount()); | 1225 ASSERT_EQ(1U, s[3]->InputCount()); |
| 1241 EXPECT_EQ(s.ToVreg(s[2]->Output()), s.ToVreg(s[3]->InputAt(0))); | 1226 EXPECT_EQ(s.ToVreg(s[2]->Output()), s.ToVreg(s[3]->InputAt(0))); |
| 1242 EXPECT_EQ(kArmMul, s[4]->arch_opcode()); | 1227 EXPECT_EQ(kArmMul, s[4]->arch_opcode()); |
| 1243 ASSERT_EQ(1U, s[4]->OutputCount()); | 1228 ASSERT_EQ(1U, s[4]->OutputCount()); |
| 1244 ASSERT_EQ(2U, s[4]->InputCount()); | 1229 ASSERT_EQ(2U, s[4]->InputCount()); |
| 1245 EXPECT_EQ(s.ToVreg(s[3]->Output()), s.ToVreg(s[4]->InputAt(0))); | 1230 EXPECT_EQ(s.ToVreg(s[3]->Output()), s.ToVreg(s[4]->InputAt(0))); |
| 1246 EXPECT_EQ(s.ToVreg(s[1]->InputAt(0)), s.ToVreg(s[4]->InputAt(1))); | 1231 EXPECT_EQ(s.ToVreg(s[1]->InputAt(0)), s.ToVreg(s[4]->InputAt(1))); |
| 1247 EXPECT_EQ(kArmSub, s[5]->arch_opcode()); | 1232 EXPECT_EQ(kArmSub, s[5]->arch_opcode()); |
| 1248 ASSERT_EQ(1U, s[5]->OutputCount()); | 1233 ASSERT_EQ(1U, s[5]->OutputCount()); |
| 1249 ASSERT_EQ(2U, s[5]->InputCount()); | 1234 ASSERT_EQ(2U, s[5]->InputCount()); |
| 1250 EXPECT_EQ(s.ToVreg(s[0]->InputAt(0)), s.ToVreg(s[5]->InputAt(0))); | 1235 EXPECT_EQ(s.ToVreg(s[0]->InputAt(0)), s.ToVreg(s[5]->InputAt(0))); |
| 1251 EXPECT_EQ(s.ToVreg(s[4]->Output()), s.ToVreg(s[5]->InputAt(1))); | 1236 EXPECT_EQ(s.ToVreg(s[4]->Output()), s.ToVreg(s[5]->InputAt(1))); |
| 1252 } | 1237 } |
| 1253 | 1238 |
| 1254 | 1239 |
| 1255 TEST_F(InstructionSelectorTest, Int32ModWithParametersForSUDIV) { | 1240 TEST_F(InstructionSelectorTest, Int32ModWithParametersForSUDIV) { |
| 1256 StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32); | 1241 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); |
| 1257 m.Return(m.Int32Mod(m.Parameter(0), m.Parameter(1))); | 1242 m.Return(m.Int32Mod(m.Parameter(0), m.Parameter(1))); |
| 1258 Stream s = m.Build(SUDIV); | 1243 Stream s = m.Build(SUDIV); |
| 1259 ASSERT_EQ(3U, s.size()); | 1244 ASSERT_EQ(3U, s.size()); |
| 1260 EXPECT_EQ(kArmSdiv, s[0]->arch_opcode()); | 1245 EXPECT_EQ(kArmSdiv, s[0]->arch_opcode()); |
| 1261 ASSERT_EQ(1U, s[0]->OutputCount()); | 1246 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 1262 ASSERT_EQ(2U, s[0]->InputCount()); | 1247 ASSERT_EQ(2U, s[0]->InputCount()); |
| 1263 EXPECT_EQ(kArmMul, s[1]->arch_opcode()); | 1248 EXPECT_EQ(kArmMul, s[1]->arch_opcode()); |
| 1264 ASSERT_EQ(1U, s[1]->OutputCount()); | 1249 ASSERT_EQ(1U, s[1]->OutputCount()); |
| 1265 ASSERT_EQ(2U, s[1]->InputCount()); | 1250 ASSERT_EQ(2U, s[1]->InputCount()); |
| 1266 EXPECT_EQ(s.ToVreg(s[0]->Output()), s.ToVreg(s[1]->InputAt(0))); | 1251 EXPECT_EQ(s.ToVreg(s[0]->Output()), s.ToVreg(s[1]->InputAt(0))); |
| 1267 EXPECT_EQ(s.ToVreg(s[0]->InputAt(1)), s.ToVreg(s[1]->InputAt(1))); | 1252 EXPECT_EQ(s.ToVreg(s[0]->InputAt(1)), s.ToVreg(s[1]->InputAt(1))); |
| 1268 EXPECT_EQ(kArmSub, s[2]->arch_opcode()); | 1253 EXPECT_EQ(kArmSub, s[2]->arch_opcode()); |
| 1269 ASSERT_EQ(1U, s[2]->OutputCount()); | 1254 ASSERT_EQ(1U, s[2]->OutputCount()); |
| 1270 ASSERT_EQ(2U, s[2]->InputCount()); | 1255 ASSERT_EQ(2U, s[2]->InputCount()); |
| 1271 EXPECT_EQ(s.ToVreg(s[0]->InputAt(0)), s.ToVreg(s[2]->InputAt(0))); | 1256 EXPECT_EQ(s.ToVreg(s[0]->InputAt(0)), s.ToVreg(s[2]->InputAt(0))); |
| 1272 EXPECT_EQ(s.ToVreg(s[1]->Output()), s.ToVreg(s[2]->InputAt(1))); | 1257 EXPECT_EQ(s.ToVreg(s[1]->Output()), s.ToVreg(s[2]->InputAt(1))); |
| 1273 } | 1258 } |
| 1274 | 1259 |
| 1275 | 1260 |
| 1276 TEST_F(InstructionSelectorTest, Int32ModWithParametersForSUDIVAndMLS) { | 1261 TEST_F(InstructionSelectorTest, Int32ModWithParametersForSUDIVAndMLS) { |
| 1277 StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32); | 1262 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); |
| 1278 m.Return(m.Int32Mod(m.Parameter(0), m.Parameter(1))); | 1263 m.Return(m.Int32Mod(m.Parameter(0), m.Parameter(1))); |
| 1279 Stream s = m.Build(MLS, SUDIV); | 1264 Stream s = m.Build(MLS, SUDIV); |
| 1280 ASSERT_EQ(2U, s.size()); | 1265 ASSERT_EQ(2U, s.size()); |
| 1281 EXPECT_EQ(kArmSdiv, s[0]->arch_opcode()); | 1266 EXPECT_EQ(kArmSdiv, s[0]->arch_opcode()); |
| 1282 ASSERT_EQ(1U, s[0]->OutputCount()); | 1267 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 1283 ASSERT_EQ(2U, s[0]->InputCount()); | 1268 ASSERT_EQ(2U, s[0]->InputCount()); |
| 1284 EXPECT_EQ(kArmMls, s[1]->arch_opcode()); | 1269 EXPECT_EQ(kArmMls, s[1]->arch_opcode()); |
| 1285 ASSERT_EQ(1U, s[1]->OutputCount()); | 1270 ASSERT_EQ(1U, s[1]->OutputCount()); |
| 1286 ASSERT_EQ(3U, s[1]->InputCount()); | 1271 ASSERT_EQ(3U, s[1]->InputCount()); |
| 1287 EXPECT_EQ(s.ToVreg(s[0]->Output()), s.ToVreg(s[1]->InputAt(0))); | 1272 EXPECT_EQ(s.ToVreg(s[0]->Output()), s.ToVreg(s[1]->InputAt(0))); |
| 1288 EXPECT_EQ(s.ToVreg(s[0]->InputAt(1)), s.ToVreg(s[1]->InputAt(1))); | 1273 EXPECT_EQ(s.ToVreg(s[0]->InputAt(1)), s.ToVreg(s[1]->InputAt(1))); |
| 1289 EXPECT_EQ(s.ToVreg(s[0]->InputAt(0)), s.ToVreg(s[1]->InputAt(2))); | 1274 EXPECT_EQ(s.ToVreg(s[0]->InputAt(0)), s.ToVreg(s[1]->InputAt(2))); |
| 1290 } | 1275 } |
| 1291 | 1276 |
| 1292 | 1277 |
| 1293 TEST_F(InstructionSelectorTest, Int32MulWithParameters) { | 1278 TEST_F(InstructionSelectorTest, Int32MulWithParameters) { |
| 1294 StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32); | 1279 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); |
| 1295 m.Return(m.Int32Mul(m.Parameter(0), m.Parameter(1))); | 1280 m.Return(m.Int32Mul(m.Parameter(0), m.Parameter(1))); |
| 1296 Stream s = m.Build(); | 1281 Stream s = m.Build(); |
| 1297 ASSERT_EQ(1U, s.size()); | 1282 ASSERT_EQ(1U, s.size()); |
| 1298 EXPECT_EQ(kArmMul, s[0]->arch_opcode()); | 1283 EXPECT_EQ(kArmMul, s[0]->arch_opcode()); |
| 1299 EXPECT_EQ(2U, s[0]->InputCount()); | 1284 EXPECT_EQ(2U, s[0]->InputCount()); |
| 1300 EXPECT_EQ(1U, s[0]->OutputCount()); | 1285 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 1301 } | 1286 } |
| 1302 | 1287 |
| 1303 | 1288 |
| 1304 TEST_F(InstructionSelectorTest, Int32MulWithImmediate) { | 1289 TEST_F(InstructionSelectorTest, Int32MulWithImmediate) { |
| 1305 // x * (2^k + 1) -> x + (x >> k) | 1290 // x * (2^k + 1) -> x + (x >> k) |
| 1306 TRACED_FORRANGE(int32_t, k, 1, 30) { | 1291 TRACED_FORRANGE(int32_t, k, 1, 30) { |
| 1307 StreamBuilder m(this, kMachineWord32, kMachineWord32); | 1292 StreamBuilder m(this, kMachInt32, kMachInt32); |
| 1308 m.Return(m.Int32Mul(m.Parameter(0), m.Int32Constant((1 << k) + 1))); | 1293 m.Return(m.Int32Mul(m.Parameter(0), m.Int32Constant((1 << k) + 1))); |
| 1309 Stream s = m.Build(); | 1294 Stream s = m.Build(); |
| 1310 ASSERT_EQ(1U, s.size()); | 1295 ASSERT_EQ(1U, s.size()); |
| 1311 EXPECT_EQ(kArmAdd, s[0]->arch_opcode()); | 1296 EXPECT_EQ(kArmAdd, s[0]->arch_opcode()); |
| 1312 EXPECT_EQ(kMode_Operand2_R_LSL_I, s[0]->addressing_mode()); | 1297 EXPECT_EQ(kMode_Operand2_R_LSL_I, s[0]->addressing_mode()); |
| 1313 ASSERT_EQ(3U, s[0]->InputCount()); | 1298 ASSERT_EQ(3U, s[0]->InputCount()); |
| 1314 EXPECT_EQ(s.ToVreg(s[0]->InputAt(0)), s.ToVreg(s[0]->InputAt(1))); | 1299 EXPECT_EQ(s.ToVreg(s[0]->InputAt(0)), s.ToVreg(s[0]->InputAt(1))); |
| 1315 EXPECT_EQ(k, s.ToInt32(s[0]->InputAt(2))); | 1300 EXPECT_EQ(k, s.ToInt32(s[0]->InputAt(2))); |
| 1316 EXPECT_EQ(1U, s[0]->OutputCount()); | 1301 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 1317 } | 1302 } |
| 1318 // x * (2^k - 1) -> -x + (x >> k) | 1303 // x * (2^k - 1) -> -x + (x >> k) |
| 1319 TRACED_FORRANGE(int32_t, k, 3, 30) { | 1304 TRACED_FORRANGE(int32_t, k, 3, 30) { |
| 1320 StreamBuilder m(this, kMachineWord32, kMachineWord32); | 1305 StreamBuilder m(this, kMachInt32, kMachInt32); |
| 1321 m.Return(m.Int32Mul(m.Parameter(0), m.Int32Constant((1 << k) - 1))); | 1306 m.Return(m.Int32Mul(m.Parameter(0), m.Int32Constant((1 << k) - 1))); |
| 1322 Stream s = m.Build(); | 1307 Stream s = m.Build(); |
| 1323 ASSERT_EQ(1U, s.size()); | 1308 ASSERT_EQ(1U, s.size()); |
| 1324 EXPECT_EQ(kArmRsb, s[0]->arch_opcode()); | 1309 EXPECT_EQ(kArmRsb, s[0]->arch_opcode()); |
| 1325 EXPECT_EQ(kMode_Operand2_R_LSL_I, s[0]->addressing_mode()); | 1310 EXPECT_EQ(kMode_Operand2_R_LSL_I, s[0]->addressing_mode()); |
| 1326 ASSERT_EQ(3U, s[0]->InputCount()); | 1311 ASSERT_EQ(3U, s[0]->InputCount()); |
| 1327 EXPECT_EQ(s.ToVreg(s[0]->InputAt(0)), s.ToVreg(s[0]->InputAt(1))); | 1312 EXPECT_EQ(s.ToVreg(s[0]->InputAt(0)), s.ToVreg(s[0]->InputAt(1))); |
| 1328 EXPECT_EQ(k, s.ToInt32(s[0]->InputAt(2))); | 1313 EXPECT_EQ(k, s.ToInt32(s[0]->InputAt(2))); |
| 1329 EXPECT_EQ(1U, s[0]->OutputCount()); | 1314 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 1330 } | 1315 } |
| 1331 // (2^k + 1) * x -> x + (x >> k) | 1316 // (2^k + 1) * x -> x + (x >> k) |
| 1332 TRACED_FORRANGE(int32_t, k, 1, 30) { | 1317 TRACED_FORRANGE(int32_t, k, 1, 30) { |
| 1333 StreamBuilder m(this, kMachineWord32, kMachineWord32); | 1318 StreamBuilder m(this, kMachInt32, kMachInt32); |
| 1334 m.Return(m.Int32Mul(m.Int32Constant((1 << k) + 1), m.Parameter(0))); | 1319 m.Return(m.Int32Mul(m.Int32Constant((1 << k) + 1), m.Parameter(0))); |
| 1335 Stream s = m.Build(); | 1320 Stream s = m.Build(); |
| 1336 ASSERT_EQ(1U, s.size()); | 1321 ASSERT_EQ(1U, s.size()); |
| 1337 EXPECT_EQ(kArmAdd, s[0]->arch_opcode()); | 1322 EXPECT_EQ(kArmAdd, s[0]->arch_opcode()); |
| 1338 EXPECT_EQ(kMode_Operand2_R_LSL_I, s[0]->addressing_mode()); | 1323 EXPECT_EQ(kMode_Operand2_R_LSL_I, s[0]->addressing_mode()); |
| 1339 ASSERT_EQ(3U, s[0]->InputCount()); | 1324 ASSERT_EQ(3U, s[0]->InputCount()); |
| 1340 EXPECT_EQ(s.ToVreg(s[0]->InputAt(0)), s.ToVreg(s[0]->InputAt(1))); | 1325 EXPECT_EQ(s.ToVreg(s[0]->InputAt(0)), s.ToVreg(s[0]->InputAt(1))); |
| 1341 EXPECT_EQ(k, s.ToInt32(s[0]->InputAt(2))); | 1326 EXPECT_EQ(k, s.ToInt32(s[0]->InputAt(2))); |
| 1342 EXPECT_EQ(1U, s[0]->OutputCount()); | 1327 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 1343 } | 1328 } |
| 1344 // x * (2^k - 1) -> -x + (x >> k) | 1329 // x * (2^k - 1) -> -x + (x >> k) |
| 1345 TRACED_FORRANGE(int32_t, k, 3, 30) { | 1330 TRACED_FORRANGE(int32_t, k, 3, 30) { |
| 1346 StreamBuilder m(this, kMachineWord32, kMachineWord32); | 1331 StreamBuilder m(this, kMachInt32, kMachInt32); |
| 1347 m.Return(m.Int32Mul(m.Int32Constant((1 << k) - 1), m.Parameter(0))); | 1332 m.Return(m.Int32Mul(m.Int32Constant((1 << k) - 1), m.Parameter(0))); |
| 1348 Stream s = m.Build(); | 1333 Stream s = m.Build(); |
| 1349 ASSERT_EQ(1U, s.size()); | 1334 ASSERT_EQ(1U, s.size()); |
| 1350 EXPECT_EQ(kArmRsb, s[0]->arch_opcode()); | 1335 EXPECT_EQ(kArmRsb, s[0]->arch_opcode()); |
| 1351 EXPECT_EQ(kMode_Operand2_R_LSL_I, s[0]->addressing_mode()); | 1336 EXPECT_EQ(kMode_Operand2_R_LSL_I, s[0]->addressing_mode()); |
| 1352 ASSERT_EQ(3U, s[0]->InputCount()); | 1337 ASSERT_EQ(3U, s[0]->InputCount()); |
| 1353 EXPECT_EQ(s.ToVreg(s[0]->InputAt(0)), s.ToVreg(s[0]->InputAt(1))); | 1338 EXPECT_EQ(s.ToVreg(s[0]->InputAt(0)), s.ToVreg(s[0]->InputAt(1))); |
| 1354 EXPECT_EQ(k, s.ToInt32(s[0]->InputAt(2))); | 1339 EXPECT_EQ(k, s.ToInt32(s[0]->InputAt(2))); |
| 1355 EXPECT_EQ(1U, s[0]->OutputCount()); | 1340 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 1356 } | 1341 } |
| 1357 } | 1342 } |
| 1358 | 1343 |
| 1359 | 1344 |
| 1360 TEST_F(InstructionSelectorTest, Int32SubWithInt32Mul) { | 1345 TEST_F(InstructionSelectorTest, Int32SubWithInt32Mul) { |
| 1361 StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32, | 1346 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); |
| 1362 kMachineWord32); | |
| 1363 m.Return( | 1347 m.Return( |
| 1364 m.Int32Sub(m.Parameter(0), m.Int32Mul(m.Parameter(1), m.Parameter(2)))); | 1348 m.Int32Sub(m.Parameter(0), m.Int32Mul(m.Parameter(1), m.Parameter(2)))); |
| 1365 Stream s = m.Build(); | 1349 Stream s = m.Build(); |
| 1366 ASSERT_EQ(2U, s.size()); | 1350 ASSERT_EQ(2U, s.size()); |
| 1367 EXPECT_EQ(kArmMul, s[0]->arch_opcode()); | 1351 EXPECT_EQ(kArmMul, s[0]->arch_opcode()); |
| 1368 ASSERT_EQ(1U, s[0]->OutputCount()); | 1352 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 1369 EXPECT_EQ(kArmSub, s[1]->arch_opcode()); | 1353 EXPECT_EQ(kArmSub, s[1]->arch_opcode()); |
| 1370 ASSERT_EQ(2U, s[1]->InputCount()); | 1354 ASSERT_EQ(2U, s[1]->InputCount()); |
| 1371 EXPECT_EQ(s.ToVreg(s[0]->Output()), s.ToVreg(s[1]->InputAt(1))); | 1355 EXPECT_EQ(s.ToVreg(s[0]->Output()), s.ToVreg(s[1]->InputAt(1))); |
| 1372 } | 1356 } |
| 1373 | 1357 |
| 1374 | 1358 |
| 1375 TEST_F(InstructionSelectorTest, Int32SubWithInt32MulForMLS) { | 1359 TEST_F(InstructionSelectorTest, Int32SubWithInt32MulForMLS) { |
| 1376 StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32, | 1360 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); |
| 1377 kMachineWord32); | |
| 1378 m.Return( | 1361 m.Return( |
| 1379 m.Int32Sub(m.Parameter(0), m.Int32Mul(m.Parameter(1), m.Parameter(2)))); | 1362 m.Int32Sub(m.Parameter(0), m.Int32Mul(m.Parameter(1), m.Parameter(2)))); |
| 1380 Stream s = m.Build(MLS); | 1363 Stream s = m.Build(MLS); |
| 1381 ASSERT_EQ(1U, s.size()); | 1364 ASSERT_EQ(1U, s.size()); |
| 1382 EXPECT_EQ(kArmMls, s[0]->arch_opcode()); | 1365 EXPECT_EQ(kArmMls, s[0]->arch_opcode()); |
| 1383 EXPECT_EQ(1U, s[0]->OutputCount()); | 1366 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 1384 EXPECT_EQ(3U, s[0]->InputCount()); | 1367 EXPECT_EQ(3U, s[0]->InputCount()); |
| 1385 } | 1368 } |
| 1386 | 1369 |
| 1387 | 1370 |
| 1388 TEST_F(InstructionSelectorTest, Int32UDivWithParameters) { | 1371 TEST_F(InstructionSelectorTest, Int32UDivWithParameters) { |
| 1389 StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32); | 1372 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); |
| 1390 m.Return(m.Int32UDiv(m.Parameter(0), m.Parameter(1))); | 1373 m.Return(m.Int32UDiv(m.Parameter(0), m.Parameter(1))); |
| 1391 Stream s = m.Build(); | 1374 Stream s = m.Build(); |
| 1392 ASSERT_EQ(4U, s.size()); | 1375 ASSERT_EQ(4U, s.size()); |
| 1393 EXPECT_EQ(kArmVcvtF64U32, s[0]->arch_opcode()); | 1376 EXPECT_EQ(kArmVcvtF64U32, s[0]->arch_opcode()); |
| 1394 ASSERT_EQ(1U, s[0]->OutputCount()); | 1377 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 1395 EXPECT_EQ(kArmVcvtF64U32, s[1]->arch_opcode()); | 1378 EXPECT_EQ(kArmVcvtF64U32, s[1]->arch_opcode()); |
| 1396 ASSERT_EQ(1U, s[1]->OutputCount()); | 1379 ASSERT_EQ(1U, s[1]->OutputCount()); |
| 1397 EXPECT_EQ(kArmVdivF64, s[2]->arch_opcode()); | 1380 EXPECT_EQ(kArmVdivF64, s[2]->arch_opcode()); |
| 1398 ASSERT_EQ(2U, s[2]->InputCount()); | 1381 ASSERT_EQ(2U, s[2]->InputCount()); |
| 1399 ASSERT_EQ(1U, s[2]->OutputCount()); | 1382 ASSERT_EQ(1U, s[2]->OutputCount()); |
| 1400 EXPECT_EQ(s.ToVreg(s[0]->Output()), s.ToVreg(s[2]->InputAt(0))); | 1383 EXPECT_EQ(s.ToVreg(s[0]->Output()), s.ToVreg(s[2]->InputAt(0))); |
| 1401 EXPECT_EQ(s.ToVreg(s[1]->Output()), s.ToVreg(s[2]->InputAt(1))); | 1384 EXPECT_EQ(s.ToVreg(s[1]->Output()), s.ToVreg(s[2]->InputAt(1))); |
| 1402 EXPECT_EQ(kArmVcvtU32F64, s[3]->arch_opcode()); | 1385 EXPECT_EQ(kArmVcvtU32F64, s[3]->arch_opcode()); |
| 1403 ASSERT_EQ(1U, s[3]->InputCount()); | 1386 ASSERT_EQ(1U, s[3]->InputCount()); |
| 1404 EXPECT_EQ(s.ToVreg(s[2]->Output()), s.ToVreg(s[3]->InputAt(0))); | 1387 EXPECT_EQ(s.ToVreg(s[2]->Output()), s.ToVreg(s[3]->InputAt(0))); |
| 1405 } | 1388 } |
| 1406 | 1389 |
| 1407 | 1390 |
| 1408 TEST_F(InstructionSelectorTest, Int32UDivWithParametersForSUDIV) { | 1391 TEST_F(InstructionSelectorTest, Int32UDivWithParametersForSUDIV) { |
| 1409 StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32); | 1392 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); |
| 1410 m.Return(m.Int32UDiv(m.Parameter(0), m.Parameter(1))); | 1393 m.Return(m.Int32UDiv(m.Parameter(0), m.Parameter(1))); |
| 1411 Stream s = m.Build(SUDIV); | 1394 Stream s = m.Build(SUDIV); |
| 1412 ASSERT_EQ(1U, s.size()); | 1395 ASSERT_EQ(1U, s.size()); |
| 1413 EXPECT_EQ(kArmUdiv, s[0]->arch_opcode()); | 1396 EXPECT_EQ(kArmUdiv, s[0]->arch_opcode()); |
| 1414 } | 1397 } |
| 1415 | 1398 |
| 1416 | 1399 |
| 1417 TEST_F(InstructionSelectorTest, Int32UModWithParameters) { | 1400 TEST_F(InstructionSelectorTest, Int32UModWithParameters) { |
| 1418 StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32); | 1401 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); |
| 1419 m.Return(m.Int32UMod(m.Parameter(0), m.Parameter(1))); | 1402 m.Return(m.Int32UMod(m.Parameter(0), m.Parameter(1))); |
| 1420 Stream s = m.Build(); | 1403 Stream s = m.Build(); |
| 1421 ASSERT_EQ(6U, s.size()); | 1404 ASSERT_EQ(6U, s.size()); |
| 1422 EXPECT_EQ(kArmVcvtF64U32, s[0]->arch_opcode()); | 1405 EXPECT_EQ(kArmVcvtF64U32, s[0]->arch_opcode()); |
| 1423 ASSERT_EQ(1U, s[0]->OutputCount()); | 1406 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 1424 EXPECT_EQ(kArmVcvtF64U32, s[1]->arch_opcode()); | 1407 EXPECT_EQ(kArmVcvtF64U32, s[1]->arch_opcode()); |
| 1425 ASSERT_EQ(1U, s[1]->OutputCount()); | 1408 ASSERT_EQ(1U, s[1]->OutputCount()); |
| 1426 EXPECT_EQ(kArmVdivF64, s[2]->arch_opcode()); | 1409 EXPECT_EQ(kArmVdivF64, s[2]->arch_opcode()); |
| 1427 ASSERT_EQ(2U, s[2]->InputCount()); | 1410 ASSERT_EQ(2U, s[2]->InputCount()); |
| 1428 ASSERT_EQ(1U, s[2]->OutputCount()); | 1411 ASSERT_EQ(1U, s[2]->OutputCount()); |
| 1429 EXPECT_EQ(s.ToVreg(s[0]->Output()), s.ToVreg(s[2]->InputAt(0))); | 1412 EXPECT_EQ(s.ToVreg(s[0]->Output()), s.ToVreg(s[2]->InputAt(0))); |
| 1430 EXPECT_EQ(s.ToVreg(s[1]->Output()), s.ToVreg(s[2]->InputAt(1))); | 1413 EXPECT_EQ(s.ToVreg(s[1]->Output()), s.ToVreg(s[2]->InputAt(1))); |
| 1431 EXPECT_EQ(kArmVcvtU32F64, s[3]->arch_opcode()); | 1414 EXPECT_EQ(kArmVcvtU32F64, s[3]->arch_opcode()); |
| 1432 ASSERT_EQ(1U, s[3]->InputCount()); | 1415 ASSERT_EQ(1U, s[3]->InputCount()); |
| 1433 EXPECT_EQ(s.ToVreg(s[2]->Output()), s.ToVreg(s[3]->InputAt(0))); | 1416 EXPECT_EQ(s.ToVreg(s[2]->Output()), s.ToVreg(s[3]->InputAt(0))); |
| 1434 EXPECT_EQ(kArmMul, s[4]->arch_opcode()); | 1417 EXPECT_EQ(kArmMul, s[4]->arch_opcode()); |
| 1435 ASSERT_EQ(1U, s[4]->OutputCount()); | 1418 ASSERT_EQ(1U, s[4]->OutputCount()); |
| 1436 ASSERT_EQ(2U, s[4]->InputCount()); | 1419 ASSERT_EQ(2U, s[4]->InputCount()); |
| 1437 EXPECT_EQ(s.ToVreg(s[3]->Output()), s.ToVreg(s[4]->InputAt(0))); | 1420 EXPECT_EQ(s.ToVreg(s[3]->Output()), s.ToVreg(s[4]->InputAt(0))); |
| 1438 EXPECT_EQ(s.ToVreg(s[1]->InputAt(0)), s.ToVreg(s[4]->InputAt(1))); | 1421 EXPECT_EQ(s.ToVreg(s[1]->InputAt(0)), s.ToVreg(s[4]->InputAt(1))); |
| 1439 EXPECT_EQ(kArmSub, s[5]->arch_opcode()); | 1422 EXPECT_EQ(kArmSub, s[5]->arch_opcode()); |
| 1440 ASSERT_EQ(1U, s[5]->OutputCount()); | 1423 ASSERT_EQ(1U, s[5]->OutputCount()); |
| 1441 ASSERT_EQ(2U, s[5]->InputCount()); | 1424 ASSERT_EQ(2U, s[5]->InputCount()); |
| 1442 EXPECT_EQ(s.ToVreg(s[0]->InputAt(0)), s.ToVreg(s[5]->InputAt(0))); | 1425 EXPECT_EQ(s.ToVreg(s[0]->InputAt(0)), s.ToVreg(s[5]->InputAt(0))); |
| 1443 EXPECT_EQ(s.ToVreg(s[4]->Output()), s.ToVreg(s[5]->InputAt(1))); | 1426 EXPECT_EQ(s.ToVreg(s[4]->Output()), s.ToVreg(s[5]->InputAt(1))); |
| 1444 } | 1427 } |
| 1445 | 1428 |
| 1446 | 1429 |
| 1447 TEST_F(InstructionSelectorTest, Int32UModWithParametersForSUDIV) { | 1430 TEST_F(InstructionSelectorTest, Int32UModWithParametersForSUDIV) { |
| 1448 StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32); | 1431 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); |
| 1449 m.Return(m.Int32UMod(m.Parameter(0), m.Parameter(1))); | 1432 m.Return(m.Int32UMod(m.Parameter(0), m.Parameter(1))); |
| 1450 Stream s = m.Build(SUDIV); | 1433 Stream s = m.Build(SUDIV); |
| 1451 ASSERT_EQ(3U, s.size()); | 1434 ASSERT_EQ(3U, s.size()); |
| 1452 EXPECT_EQ(kArmUdiv, s[0]->arch_opcode()); | 1435 EXPECT_EQ(kArmUdiv, s[0]->arch_opcode()); |
| 1453 ASSERT_EQ(1U, s[0]->OutputCount()); | 1436 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 1454 ASSERT_EQ(2U, s[0]->InputCount()); | 1437 ASSERT_EQ(2U, s[0]->InputCount()); |
| 1455 EXPECT_EQ(kArmMul, s[1]->arch_opcode()); | 1438 EXPECT_EQ(kArmMul, s[1]->arch_opcode()); |
| 1456 ASSERT_EQ(1U, s[1]->OutputCount()); | 1439 ASSERT_EQ(1U, s[1]->OutputCount()); |
| 1457 ASSERT_EQ(2U, s[1]->InputCount()); | 1440 ASSERT_EQ(2U, s[1]->InputCount()); |
| 1458 EXPECT_EQ(s.ToVreg(s[0]->Output()), s.ToVreg(s[1]->InputAt(0))); | 1441 EXPECT_EQ(s.ToVreg(s[0]->Output()), s.ToVreg(s[1]->InputAt(0))); |
| 1459 EXPECT_EQ(s.ToVreg(s[0]->InputAt(1)), s.ToVreg(s[1]->InputAt(1))); | 1442 EXPECT_EQ(s.ToVreg(s[0]->InputAt(1)), s.ToVreg(s[1]->InputAt(1))); |
| 1460 EXPECT_EQ(kArmSub, s[2]->arch_opcode()); | 1443 EXPECT_EQ(kArmSub, s[2]->arch_opcode()); |
| 1461 ASSERT_EQ(1U, s[2]->OutputCount()); | 1444 ASSERT_EQ(1U, s[2]->OutputCount()); |
| 1462 ASSERT_EQ(2U, s[2]->InputCount()); | 1445 ASSERT_EQ(2U, s[2]->InputCount()); |
| 1463 EXPECT_EQ(s.ToVreg(s[0]->InputAt(0)), s.ToVreg(s[2]->InputAt(0))); | 1446 EXPECT_EQ(s.ToVreg(s[0]->InputAt(0)), s.ToVreg(s[2]->InputAt(0))); |
| 1464 EXPECT_EQ(s.ToVreg(s[1]->Output()), s.ToVreg(s[2]->InputAt(1))); | 1447 EXPECT_EQ(s.ToVreg(s[1]->Output()), s.ToVreg(s[2]->InputAt(1))); |
| 1465 } | 1448 } |
| 1466 | 1449 |
| 1467 | 1450 |
| 1468 TEST_F(InstructionSelectorTest, Int32UModWithParametersForSUDIVAndMLS) { | 1451 TEST_F(InstructionSelectorTest, Int32UModWithParametersForSUDIVAndMLS) { |
| 1469 StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32); | 1452 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); |
| 1470 m.Return(m.Int32UMod(m.Parameter(0), m.Parameter(1))); | 1453 m.Return(m.Int32UMod(m.Parameter(0), m.Parameter(1))); |
| 1471 Stream s = m.Build(MLS, SUDIV); | 1454 Stream s = m.Build(MLS, SUDIV); |
| 1472 ASSERT_EQ(2U, s.size()); | 1455 ASSERT_EQ(2U, s.size()); |
| 1473 EXPECT_EQ(kArmUdiv, s[0]->arch_opcode()); | 1456 EXPECT_EQ(kArmUdiv, s[0]->arch_opcode()); |
| 1474 ASSERT_EQ(1U, s[0]->OutputCount()); | 1457 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 1475 ASSERT_EQ(2U, s[0]->InputCount()); | 1458 ASSERT_EQ(2U, s[0]->InputCount()); |
| 1476 EXPECT_EQ(kArmMls, s[1]->arch_opcode()); | 1459 EXPECT_EQ(kArmMls, s[1]->arch_opcode()); |
| 1477 ASSERT_EQ(1U, s[1]->OutputCount()); | 1460 ASSERT_EQ(1U, s[1]->OutputCount()); |
| 1478 ASSERT_EQ(3U, s[1]->InputCount()); | 1461 ASSERT_EQ(3U, s[1]->InputCount()); |
| 1479 EXPECT_EQ(s.ToVreg(s[0]->Output()), s.ToVreg(s[1]->InputAt(0))); | 1462 EXPECT_EQ(s.ToVreg(s[0]->Output()), s.ToVreg(s[1]->InputAt(0))); |
| 1480 EXPECT_EQ(s.ToVreg(s[0]->InputAt(1)), s.ToVreg(s[1]->InputAt(1))); | 1463 EXPECT_EQ(s.ToVreg(s[0]->InputAt(1)), s.ToVreg(s[1]->InputAt(1))); |
| 1481 EXPECT_EQ(s.ToVreg(s[0]->InputAt(0)), s.ToVreg(s[1]->InputAt(2))); | 1464 EXPECT_EQ(s.ToVreg(s[0]->InputAt(0)), s.ToVreg(s[1]->InputAt(2))); |
| 1482 } | 1465 } |
| 1483 | 1466 |
| 1484 | 1467 |
| 1485 TEST_F(InstructionSelectorTest, Word32AndWithUbfxImmediateForARMv7) { | 1468 TEST_F(InstructionSelectorTest, Word32AndWithUbfxImmediateForARMv7) { |
| 1486 TRACED_FORRANGE(int32_t, width, 1, 32) { | 1469 TRACED_FORRANGE(int32_t, width, 1, 32) { |
| 1487 StreamBuilder m(this, kMachineWord32, kMachineWord32); | 1470 StreamBuilder m(this, kMachInt32, kMachInt32); |
| 1488 m.Return(m.Word32And(m.Parameter(0), | 1471 m.Return(m.Word32And(m.Parameter(0), |
| 1489 m.Int32Constant(0xffffffffu >> (32 - width)))); | 1472 m.Int32Constant(0xffffffffu >> (32 - width)))); |
| 1490 Stream s = m.Build(ARMv7); | 1473 Stream s = m.Build(ARMv7); |
| 1491 ASSERT_EQ(1U, s.size()); | 1474 ASSERT_EQ(1U, s.size()); |
| 1492 EXPECT_EQ(kArmUbfx, s[0]->arch_opcode()); | 1475 EXPECT_EQ(kArmUbfx, s[0]->arch_opcode()); |
| 1493 ASSERT_EQ(3U, s[0]->InputCount()); | 1476 ASSERT_EQ(3U, s[0]->InputCount()); |
| 1494 EXPECT_EQ(0, s.ToInt32(s[0]->InputAt(1))); | 1477 EXPECT_EQ(0, s.ToInt32(s[0]->InputAt(1))); |
| 1495 EXPECT_EQ(width, s.ToInt32(s[0]->InputAt(2))); | 1478 EXPECT_EQ(width, s.ToInt32(s[0]->InputAt(2))); |
| 1496 } | 1479 } |
| 1497 TRACED_FORRANGE(int32_t, width, 1, 32) { | 1480 TRACED_FORRANGE(int32_t, width, 1, 32) { |
| 1498 StreamBuilder m(this, kMachineWord32, kMachineWord32); | 1481 StreamBuilder m(this, kMachInt32, kMachInt32); |
| 1499 m.Return(m.Word32And(m.Int32Constant(0xffffffffu >> (32 - width)), | 1482 m.Return(m.Word32And(m.Int32Constant(0xffffffffu >> (32 - width)), |
| 1500 m.Parameter(0))); | 1483 m.Parameter(0))); |
| 1501 Stream s = m.Build(ARMv7); | 1484 Stream s = m.Build(ARMv7); |
| 1502 ASSERT_EQ(1U, s.size()); | 1485 ASSERT_EQ(1U, s.size()); |
| 1503 EXPECT_EQ(kArmUbfx, s[0]->arch_opcode()); | 1486 EXPECT_EQ(kArmUbfx, s[0]->arch_opcode()); |
| 1504 ASSERT_EQ(3U, s[0]->InputCount()); | 1487 ASSERT_EQ(3U, s[0]->InputCount()); |
| 1505 EXPECT_EQ(0, s.ToInt32(s[0]->InputAt(1))); | 1488 EXPECT_EQ(0, s.ToInt32(s[0]->InputAt(1))); |
| 1506 EXPECT_EQ(width, s.ToInt32(s[0]->InputAt(2))); | 1489 EXPECT_EQ(width, s.ToInt32(s[0]->InputAt(2))); |
| 1507 } | 1490 } |
| 1508 } | 1491 } |
| 1509 | 1492 |
| 1510 | 1493 |
| 1511 TEST_F(InstructionSelectorTest, Word32AndWithBfcImmediateForARMv7) { | 1494 TEST_F(InstructionSelectorTest, Word32AndWithBfcImmediateForARMv7) { |
| 1512 TRACED_FORRANGE(int32_t, lsb, 0, 31) { | 1495 TRACED_FORRANGE(int32_t, lsb, 0, 31) { |
| 1513 TRACED_FORRANGE(int32_t, width, 1, (32 - lsb) - 1) { | 1496 TRACED_FORRANGE(int32_t, width, 1, (32 - lsb) - 1) { |
| 1514 StreamBuilder m(this, kMachineWord32, kMachineWord32); | 1497 StreamBuilder m(this, kMachInt32, kMachInt32); |
| 1515 m.Return(m.Word32And( | 1498 m.Return(m.Word32And( |
| 1516 m.Parameter(0), | 1499 m.Parameter(0), |
| 1517 m.Int32Constant(~((0xffffffffu >> (32 - width)) << lsb)))); | 1500 m.Int32Constant(~((0xffffffffu >> (32 - width)) << lsb)))); |
| 1518 Stream s = m.Build(ARMv7); | 1501 Stream s = m.Build(ARMv7); |
| 1519 ASSERT_EQ(1U, s.size()); | 1502 ASSERT_EQ(1U, s.size()); |
| 1520 EXPECT_EQ(kArmBfc, s[0]->arch_opcode()); | 1503 EXPECT_EQ(kArmBfc, s[0]->arch_opcode()); |
| 1521 ASSERT_EQ(1U, s[0]->OutputCount()); | 1504 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 1522 EXPECT_TRUE( | 1505 EXPECT_TRUE( |
| 1523 UnallocatedOperand::cast(s[0]->Output())->HasSameAsInputPolicy()); | 1506 UnallocatedOperand::cast(s[0]->Output())->HasSameAsInputPolicy()); |
| 1524 ASSERT_EQ(3U, s[0]->InputCount()); | 1507 ASSERT_EQ(3U, s[0]->InputCount()); |
| 1525 EXPECT_EQ(lsb, s.ToInt32(s[0]->InputAt(1))); | 1508 EXPECT_EQ(lsb, s.ToInt32(s[0]->InputAt(1))); |
| 1526 EXPECT_EQ(width, s.ToInt32(s[0]->InputAt(2))); | 1509 EXPECT_EQ(width, s.ToInt32(s[0]->InputAt(2))); |
| 1527 } | 1510 } |
| 1528 } | 1511 } |
| 1529 TRACED_FORRANGE(int32_t, lsb, 0, 31) { | 1512 TRACED_FORRANGE(int32_t, lsb, 0, 31) { |
| 1530 TRACED_FORRANGE(int32_t, width, 1, (32 - lsb) - 1) { | 1513 TRACED_FORRANGE(int32_t, width, 1, (32 - lsb) - 1) { |
| 1531 StreamBuilder m(this, kMachineWord32, kMachineWord32); | 1514 StreamBuilder m(this, kMachInt32, kMachInt32); |
| 1532 m.Return( | 1515 m.Return( |
| 1533 m.Word32And(m.Int32Constant(~((0xffffffffu >> (32 - width)) << lsb)), | 1516 m.Word32And(m.Int32Constant(~((0xffffffffu >> (32 - width)) << lsb)), |
| 1534 m.Parameter(0))); | 1517 m.Parameter(0))); |
| 1535 Stream s = m.Build(ARMv7); | 1518 Stream s = m.Build(ARMv7); |
| 1536 ASSERT_EQ(1U, s.size()); | 1519 ASSERT_EQ(1U, s.size()); |
| 1537 EXPECT_EQ(kArmBfc, s[0]->arch_opcode()); | 1520 EXPECT_EQ(kArmBfc, s[0]->arch_opcode()); |
| 1538 ASSERT_EQ(1U, s[0]->OutputCount()); | 1521 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 1539 EXPECT_TRUE( | 1522 EXPECT_TRUE( |
| 1540 UnallocatedOperand::cast(s[0]->Output())->HasSameAsInputPolicy()); | 1523 UnallocatedOperand::cast(s[0]->Output())->HasSameAsInputPolicy()); |
| 1541 ASSERT_EQ(3U, s[0]->InputCount()); | 1524 ASSERT_EQ(3U, s[0]->InputCount()); |
| 1542 EXPECT_EQ(lsb, s.ToInt32(s[0]->InputAt(1))); | 1525 EXPECT_EQ(lsb, s.ToInt32(s[0]->InputAt(1))); |
| 1543 EXPECT_EQ(width, s.ToInt32(s[0]->InputAt(2))); | 1526 EXPECT_EQ(width, s.ToInt32(s[0]->InputAt(2))); |
| 1544 } | 1527 } |
| 1545 } | 1528 } |
| 1546 } | 1529 } |
| 1547 | 1530 |
| 1548 | 1531 |
| 1549 TEST_F(InstructionSelectorTest, Word32ShrWithWord32AndWithImmediateForARMv7) { | 1532 TEST_F(InstructionSelectorTest, Word32ShrWithWord32AndWithImmediateForARMv7) { |
| 1550 TRACED_FORRANGE(int32_t, lsb, 0, 31) { | 1533 TRACED_FORRANGE(int32_t, lsb, 0, 31) { |
| 1551 TRACED_FORRANGE(int32_t, width, 1, 32 - lsb) { | 1534 TRACED_FORRANGE(int32_t, width, 1, 32 - lsb) { |
| 1552 uint32_t max = 1 << lsb; | 1535 uint32_t max = 1 << lsb; |
| 1553 if (max > static_cast<uint32_t>(kMaxInt)) max -= 1; | 1536 if (max > static_cast<uint32_t>(kMaxInt)) max -= 1; |
| 1554 uint32_t jnk = rng()->NextInt(max); | 1537 uint32_t jnk = rng()->NextInt(max); |
| 1555 uint32_t msk = ((0xffffffffu >> (32 - width)) << lsb) | jnk; | 1538 uint32_t msk = ((0xffffffffu >> (32 - width)) << lsb) | jnk; |
| 1556 StreamBuilder m(this, kMachineWord32, kMachineWord32); | 1539 StreamBuilder m(this, kMachInt32, kMachInt32); |
| 1557 m.Return(m.Word32Shr(m.Word32And(m.Parameter(0), m.Int32Constant(msk)), | 1540 m.Return(m.Word32Shr(m.Word32And(m.Parameter(0), m.Int32Constant(msk)), |
| 1558 m.Int32Constant(lsb))); | 1541 m.Int32Constant(lsb))); |
| 1559 Stream s = m.Build(ARMv7); | 1542 Stream s = m.Build(ARMv7); |
| 1560 ASSERT_EQ(1U, s.size()); | 1543 ASSERT_EQ(1U, s.size()); |
| 1561 EXPECT_EQ(kArmUbfx, s[0]->arch_opcode()); | 1544 EXPECT_EQ(kArmUbfx, s[0]->arch_opcode()); |
| 1562 ASSERT_EQ(3U, s[0]->InputCount()); | 1545 ASSERT_EQ(3U, s[0]->InputCount()); |
| 1563 EXPECT_EQ(lsb, s.ToInt32(s[0]->InputAt(1))); | 1546 EXPECT_EQ(lsb, s.ToInt32(s[0]->InputAt(1))); |
| 1564 EXPECT_EQ(width, s.ToInt32(s[0]->InputAt(2))); | 1547 EXPECT_EQ(width, s.ToInt32(s[0]->InputAt(2))); |
| 1565 } | 1548 } |
| 1566 } | 1549 } |
| 1567 TRACED_FORRANGE(int32_t, lsb, 0, 31) { | 1550 TRACED_FORRANGE(int32_t, lsb, 0, 31) { |
| 1568 TRACED_FORRANGE(int32_t, width, 1, 32 - lsb) { | 1551 TRACED_FORRANGE(int32_t, width, 1, 32 - lsb) { |
| 1569 uint32_t max = 1 << lsb; | 1552 uint32_t max = 1 << lsb; |
| 1570 if (max > static_cast<uint32_t>(kMaxInt)) max -= 1; | 1553 if (max > static_cast<uint32_t>(kMaxInt)) max -= 1; |
| 1571 uint32_t jnk = rng()->NextInt(max); | 1554 uint32_t jnk = rng()->NextInt(max); |
| 1572 uint32_t msk = ((0xffffffffu >> (32 - width)) << lsb) | jnk; | 1555 uint32_t msk = ((0xffffffffu >> (32 - width)) << lsb) | jnk; |
| 1573 StreamBuilder m(this, kMachineWord32, kMachineWord32); | 1556 StreamBuilder m(this, kMachInt32, kMachInt32); |
| 1574 m.Return(m.Word32Shr(m.Word32And(m.Int32Constant(msk), m.Parameter(0)), | 1557 m.Return(m.Word32Shr(m.Word32And(m.Int32Constant(msk), m.Parameter(0)), |
| 1575 m.Int32Constant(lsb))); | 1558 m.Int32Constant(lsb))); |
| 1576 Stream s = m.Build(ARMv7); | 1559 Stream s = m.Build(ARMv7); |
| 1577 ASSERT_EQ(1U, s.size()); | 1560 ASSERT_EQ(1U, s.size()); |
| 1578 EXPECT_EQ(kArmUbfx, s[0]->arch_opcode()); | 1561 EXPECT_EQ(kArmUbfx, s[0]->arch_opcode()); |
| 1579 ASSERT_EQ(3U, s[0]->InputCount()); | 1562 ASSERT_EQ(3U, s[0]->InputCount()); |
| 1580 EXPECT_EQ(lsb, s.ToInt32(s[0]->InputAt(1))); | 1563 EXPECT_EQ(lsb, s.ToInt32(s[0]->InputAt(1))); |
| 1581 EXPECT_EQ(width, s.ToInt32(s[0]->InputAt(2))); | 1564 EXPECT_EQ(width, s.ToInt32(s[0]->InputAt(2))); |
| 1582 } | 1565 } |
| 1583 } | 1566 } |
| 1584 } | 1567 } |
| 1585 | 1568 |
| 1586 | 1569 |
| 1587 TEST_F(InstructionSelectorTest, Word32AndWithWord32Not) { | 1570 TEST_F(InstructionSelectorTest, Word32AndWithWord32Not) { |
| 1588 { | 1571 { |
| 1589 StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32); | 1572 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); |
| 1590 m.Return(m.Word32And(m.Parameter(0), m.Word32Not(m.Parameter(1)))); | 1573 m.Return(m.Word32And(m.Parameter(0), m.Word32Not(m.Parameter(1)))); |
| 1591 Stream s = m.Build(); | 1574 Stream s = m.Build(); |
| 1592 ASSERT_EQ(1U, s.size()); | 1575 ASSERT_EQ(1U, s.size()); |
| 1593 EXPECT_EQ(kArmBic, s[0]->arch_opcode()); | 1576 EXPECT_EQ(kArmBic, s[0]->arch_opcode()); |
| 1594 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); | 1577 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); |
| 1595 EXPECT_EQ(2U, s[0]->InputCount()); | 1578 EXPECT_EQ(2U, s[0]->InputCount()); |
| 1596 EXPECT_EQ(1U, s[0]->OutputCount()); | 1579 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 1597 } | 1580 } |
| 1598 { | 1581 { |
| 1599 StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32); | 1582 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); |
| 1600 m.Return(m.Word32And(m.Word32Not(m.Parameter(0)), m.Parameter(1))); | 1583 m.Return(m.Word32And(m.Word32Not(m.Parameter(0)), m.Parameter(1))); |
| 1601 Stream s = m.Build(); | 1584 Stream s = m.Build(); |
| 1602 ASSERT_EQ(1U, s.size()); | 1585 ASSERT_EQ(1U, s.size()); |
| 1603 EXPECT_EQ(kArmBic, s[0]->arch_opcode()); | 1586 EXPECT_EQ(kArmBic, s[0]->arch_opcode()); |
| 1604 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); | 1587 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); |
| 1605 EXPECT_EQ(2U, s[0]->InputCount()); | 1588 EXPECT_EQ(2U, s[0]->InputCount()); |
| 1606 EXPECT_EQ(1U, s[0]->OutputCount()); | 1589 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 1607 } | 1590 } |
| 1608 } | 1591 } |
| 1609 | 1592 |
| 1610 | 1593 |
| 1611 TEST_F(InstructionSelectorTest, Word32EqualWithParameters) { | 1594 TEST_F(InstructionSelectorTest, Word32EqualWithParameters) { |
| 1612 StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32); | 1595 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); |
| 1613 m.Return(m.Word32Equal(m.Parameter(0), m.Parameter(1))); | 1596 m.Return(m.Word32Equal(m.Parameter(0), m.Parameter(1))); |
| 1614 Stream s = m.Build(); | 1597 Stream s = m.Build(); |
| 1615 ASSERT_EQ(1U, s.size()); | 1598 ASSERT_EQ(1U, s.size()); |
| 1616 EXPECT_EQ(kArmCmp, s[0]->arch_opcode()); | 1599 EXPECT_EQ(kArmCmp, s[0]->arch_opcode()); |
| 1617 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); | 1600 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); |
| 1618 EXPECT_EQ(2U, s[0]->InputCount()); | 1601 EXPECT_EQ(2U, s[0]->InputCount()); |
| 1619 EXPECT_EQ(1U, s[0]->OutputCount()); | 1602 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 1620 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 1603 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 1621 EXPECT_EQ(kEqual, s[0]->flags_condition()); | 1604 EXPECT_EQ(kEqual, s[0]->flags_condition()); |
| 1622 } | 1605 } |
| 1623 | 1606 |
| 1624 | 1607 |
| 1625 TEST_F(InstructionSelectorTest, Word32EqualWithImmediate) { | 1608 TEST_F(InstructionSelectorTest, Word32EqualWithImmediate) { |
| 1626 TRACED_FOREACH(int32_t, imm, kImmediates) { | 1609 TRACED_FOREACH(int32_t, imm, kImmediates) { |
| 1627 if (imm == 0) continue; | 1610 if (imm == 0) continue; |
| 1628 StreamBuilder m(this, kMachineWord32, kMachineWord32); | 1611 StreamBuilder m(this, kMachInt32, kMachInt32); |
| 1629 m.Return(m.Word32Equal(m.Parameter(0), m.Int32Constant(imm))); | 1612 m.Return(m.Word32Equal(m.Parameter(0), m.Int32Constant(imm))); |
| 1630 Stream s = m.Build(); | 1613 Stream s = m.Build(); |
| 1631 ASSERT_EQ(1U, s.size()); | 1614 ASSERT_EQ(1U, s.size()); |
| 1632 EXPECT_EQ(kArmCmp, s[0]->arch_opcode()); | 1615 EXPECT_EQ(kArmCmp, s[0]->arch_opcode()); |
| 1633 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); | 1616 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); |
| 1634 ASSERT_EQ(2U, s[0]->InputCount()); | 1617 ASSERT_EQ(2U, s[0]->InputCount()); |
| 1635 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); | 1618 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); |
| 1636 EXPECT_EQ(1U, s[0]->OutputCount()); | 1619 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 1637 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 1620 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 1638 EXPECT_EQ(kEqual, s[0]->flags_condition()); | 1621 EXPECT_EQ(kEqual, s[0]->flags_condition()); |
| 1639 } | 1622 } |
| 1640 TRACED_FOREACH(int32_t, imm, kImmediates) { | 1623 TRACED_FOREACH(int32_t, imm, kImmediates) { |
| 1641 if (imm == 0) continue; | 1624 if (imm == 0) continue; |
| 1642 StreamBuilder m(this, kMachineWord32, kMachineWord32); | 1625 StreamBuilder m(this, kMachInt32, kMachInt32); |
| 1643 m.Return(m.Word32Equal(m.Int32Constant(imm), m.Parameter(0))); | 1626 m.Return(m.Word32Equal(m.Int32Constant(imm), m.Parameter(0))); |
| 1644 Stream s = m.Build(); | 1627 Stream s = m.Build(); |
| 1645 ASSERT_EQ(1U, s.size()); | 1628 ASSERT_EQ(1U, s.size()); |
| 1646 EXPECT_EQ(kArmCmp, s[0]->arch_opcode()); | 1629 EXPECT_EQ(kArmCmp, s[0]->arch_opcode()); |
| 1647 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); | 1630 EXPECT_EQ(kMode_Operand2_I, s[0]->addressing_mode()); |
| 1648 ASSERT_EQ(2U, s[0]->InputCount()); | 1631 ASSERT_EQ(2U, s[0]->InputCount()); |
| 1649 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); | 1632 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); |
| 1650 EXPECT_EQ(1U, s[0]->OutputCount()); | 1633 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 1651 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 1634 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 1652 EXPECT_EQ(kEqual, s[0]->flags_condition()); | 1635 EXPECT_EQ(kEqual, s[0]->flags_condition()); |
| 1653 } | 1636 } |
| 1654 } | 1637 } |
| 1655 | 1638 |
| 1656 | 1639 |
| 1657 TEST_F(InstructionSelectorTest, Word32EqualWithZero) { | 1640 TEST_F(InstructionSelectorTest, Word32EqualWithZero) { |
| 1658 { | 1641 { |
| 1659 StreamBuilder m(this, kMachineWord32, kMachineWord32); | 1642 StreamBuilder m(this, kMachInt32, kMachInt32); |
| 1660 m.Return(m.Word32Equal(m.Parameter(0), m.Int32Constant(0))); | 1643 m.Return(m.Word32Equal(m.Parameter(0), m.Int32Constant(0))); |
| 1661 Stream s = m.Build(); | 1644 Stream s = m.Build(); |
| 1662 ASSERT_EQ(1U, s.size()); | 1645 ASSERT_EQ(1U, s.size()); |
| 1663 EXPECT_EQ(kArmTst, s[0]->arch_opcode()); | 1646 EXPECT_EQ(kArmTst, s[0]->arch_opcode()); |
| 1664 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); | 1647 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); |
| 1665 ASSERT_EQ(2U, s[0]->InputCount()); | 1648 ASSERT_EQ(2U, s[0]->InputCount()); |
| 1666 EXPECT_EQ(s.ToVreg(s[0]->InputAt(0)), s.ToVreg(s[0]->InputAt(1))); | 1649 EXPECT_EQ(s.ToVreg(s[0]->InputAt(0)), s.ToVreg(s[0]->InputAt(1))); |
| 1667 EXPECT_EQ(1U, s[0]->OutputCount()); | 1650 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 1668 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 1651 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 1669 EXPECT_EQ(kEqual, s[0]->flags_condition()); | 1652 EXPECT_EQ(kEqual, s[0]->flags_condition()); |
| 1670 } | 1653 } |
| 1671 { | 1654 { |
| 1672 StreamBuilder m(this, kMachineWord32, kMachineWord32); | 1655 StreamBuilder m(this, kMachInt32, kMachInt32); |
| 1673 m.Return(m.Word32Equal(m.Int32Constant(0), m.Parameter(0))); | 1656 m.Return(m.Word32Equal(m.Int32Constant(0), m.Parameter(0))); |
| 1674 Stream s = m.Build(); | 1657 Stream s = m.Build(); |
| 1675 ASSERT_EQ(1U, s.size()); | 1658 ASSERT_EQ(1U, s.size()); |
| 1676 EXPECT_EQ(kArmTst, s[0]->arch_opcode()); | 1659 EXPECT_EQ(kArmTst, s[0]->arch_opcode()); |
| 1677 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); | 1660 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); |
| 1678 ASSERT_EQ(2U, s[0]->InputCount()); | 1661 ASSERT_EQ(2U, s[0]->InputCount()); |
| 1679 EXPECT_EQ(s.ToVreg(s[0]->InputAt(0)), s.ToVreg(s[0]->InputAt(1))); | 1662 EXPECT_EQ(s.ToVreg(s[0]->InputAt(0)), s.ToVreg(s[0]->InputAt(1))); |
| 1680 EXPECT_EQ(1U, s[0]->OutputCount()); | 1663 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 1681 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 1664 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
| 1682 EXPECT_EQ(kEqual, s[0]->flags_condition()); | 1665 EXPECT_EQ(kEqual, s[0]->flags_condition()); |
| 1683 } | 1666 } |
| 1684 } | 1667 } |
| 1685 | 1668 |
| 1686 | 1669 |
| 1687 TEST_F(InstructionSelectorTest, Word32NotWithParameter) { | 1670 TEST_F(InstructionSelectorTest, Word32NotWithParameter) { |
| 1688 StreamBuilder m(this, kMachineWord32, kMachineWord32); | 1671 StreamBuilder m(this, kMachInt32, kMachInt32); |
| 1689 m.Return(m.Word32Not(m.Parameter(0))); | 1672 m.Return(m.Word32Not(m.Parameter(0))); |
| 1690 Stream s = m.Build(); | 1673 Stream s = m.Build(); |
| 1691 ASSERT_EQ(1U, s.size()); | 1674 ASSERT_EQ(1U, s.size()); |
| 1692 EXPECT_EQ(kArmMvn, s[0]->arch_opcode()); | 1675 EXPECT_EQ(kArmMvn, s[0]->arch_opcode()); |
| 1693 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); | 1676 EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); |
| 1694 EXPECT_EQ(1U, s[0]->InputCount()); | 1677 EXPECT_EQ(1U, s[0]->InputCount()); |
| 1695 EXPECT_EQ(1U, s[0]->OutputCount()); | 1678 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 1696 } | 1679 } |
| 1697 | 1680 |
| 1698 | 1681 |
| 1699 TEST_F(InstructionSelectorTest, Word32AndWithWord32ShrWithImmediateForARMv7) { | 1682 TEST_F(InstructionSelectorTest, Word32AndWithWord32ShrWithImmediateForARMv7) { |
| 1700 TRACED_FORRANGE(int32_t, lsb, 0, 31) { | 1683 TRACED_FORRANGE(int32_t, lsb, 0, 31) { |
| 1701 TRACED_FORRANGE(int32_t, width, 1, 32 - lsb) { | 1684 TRACED_FORRANGE(int32_t, width, 1, 32 - lsb) { |
| 1702 StreamBuilder m(this, kMachineWord32, kMachineWord32); | 1685 StreamBuilder m(this, kMachInt32, kMachInt32); |
| 1703 m.Return(m.Word32And(m.Word32Shr(m.Parameter(0), m.Int32Constant(lsb)), | 1686 m.Return(m.Word32And(m.Word32Shr(m.Parameter(0), m.Int32Constant(lsb)), |
| 1704 m.Int32Constant(0xffffffffu >> (32 - width)))); | 1687 m.Int32Constant(0xffffffffu >> (32 - width)))); |
| 1705 Stream s = m.Build(ARMv7); | 1688 Stream s = m.Build(ARMv7); |
| 1706 ASSERT_EQ(1U, s.size()); | 1689 ASSERT_EQ(1U, s.size()); |
| 1707 EXPECT_EQ(kArmUbfx, s[0]->arch_opcode()); | 1690 EXPECT_EQ(kArmUbfx, s[0]->arch_opcode()); |
| 1708 ASSERT_EQ(3U, s[0]->InputCount()); | 1691 ASSERT_EQ(3U, s[0]->InputCount()); |
| 1709 EXPECT_EQ(lsb, s.ToInt32(s[0]->InputAt(1))); | 1692 EXPECT_EQ(lsb, s.ToInt32(s[0]->InputAt(1))); |
| 1710 EXPECT_EQ(width, s.ToInt32(s[0]->InputAt(2))); | 1693 EXPECT_EQ(width, s.ToInt32(s[0]->InputAt(2))); |
| 1711 } | 1694 } |
| 1712 } | 1695 } |
| 1713 TRACED_FORRANGE(int32_t, lsb, 0, 31) { | 1696 TRACED_FORRANGE(int32_t, lsb, 0, 31) { |
| 1714 TRACED_FORRANGE(int32_t, width, 1, 32 - lsb) { | 1697 TRACED_FORRANGE(int32_t, width, 1, 32 - lsb) { |
| 1715 StreamBuilder m(this, kMachineWord32, kMachineWord32); | 1698 StreamBuilder m(this, kMachInt32, kMachInt32); |
| 1716 m.Return(m.Word32And(m.Int32Constant(0xffffffffu >> (32 - width)), | 1699 m.Return(m.Word32And(m.Int32Constant(0xffffffffu >> (32 - width)), |
| 1717 m.Word32Shr(m.Parameter(0), m.Int32Constant(lsb)))); | 1700 m.Word32Shr(m.Parameter(0), m.Int32Constant(lsb)))); |
| 1718 Stream s = m.Build(ARMv7); | 1701 Stream s = m.Build(ARMv7); |
| 1719 ASSERT_EQ(1U, s.size()); | 1702 ASSERT_EQ(1U, s.size()); |
| 1720 EXPECT_EQ(kArmUbfx, s[0]->arch_opcode()); | 1703 EXPECT_EQ(kArmUbfx, s[0]->arch_opcode()); |
| 1721 ASSERT_EQ(3U, s[0]->InputCount()); | 1704 ASSERT_EQ(3U, s[0]->InputCount()); |
| 1722 EXPECT_EQ(lsb, s.ToInt32(s[0]->InputAt(1))); | 1705 EXPECT_EQ(lsb, s.ToInt32(s[0]->InputAt(1))); |
| 1723 EXPECT_EQ(width, s.ToInt32(s[0]->InputAt(2))); | 1706 EXPECT_EQ(width, s.ToInt32(s[0]->InputAt(2))); |
| 1724 } | 1707 } |
| 1725 } | 1708 } |
| 1726 } | 1709 } |
| 1727 | 1710 |
| 1728 } // namespace compiler | 1711 } // namespace compiler |
| 1729 } // namespace internal | 1712 } // namespace internal |
| 1730 } // namespace v8 | 1713 } // namespace v8 |
| OLD | NEW |