OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file | 3 // found in the LICENSE file |
4 | 4 |
5 #include "test/unittests/compiler/instruction-selector-unittest.h" | 5 #include "test/unittests/compiler/instruction-selector-unittest.h" |
6 | 6 |
7 namespace v8 { | 7 namespace v8 { |
8 namespace internal { | 8 namespace internal { |
9 namespace compiler { | 9 namespace compiler { |
10 | 10 |
(...skipping 23 matching lines...) Expand all Loading... |
34 uint32_t expected_size; | 34 uint32_t expected_size; |
35 }; | 35 }; |
36 | 36 |
37 struct FPCmp { | 37 struct FPCmp { |
38 MachInst2 mi; | 38 MachInst2 mi; |
39 FlagsCondition cond; | 39 FlagsCondition cond; |
40 }; | 40 }; |
41 | 41 |
42 const FPCmp kFPCmpInstructions[] = { | 42 const FPCmp kFPCmpInstructions[] = { |
43 {{&RawMachineAssembler::Float64Equal, "Float64Equal", kMips64CmpD, | 43 {{&RawMachineAssembler::Float64Equal, "Float64Equal", kMips64CmpD, |
44 kMachFloat64}, | 44 MachineType::Float64()}, |
45 kEqual}, | 45 kEqual}, |
46 {{&RawMachineAssembler::Float64LessThan, "Float64LessThan", kMips64CmpD, | 46 {{&RawMachineAssembler::Float64LessThan, "Float64LessThan", kMips64CmpD, |
47 kMachFloat64}, | 47 MachineType::Float64()}, |
48 kUnsignedLessThan}, | 48 kUnsignedLessThan}, |
49 {{&RawMachineAssembler::Float64LessThanOrEqual, "Float64LessThanOrEqual", | 49 {{&RawMachineAssembler::Float64LessThanOrEqual, "Float64LessThanOrEqual", |
50 kMips64CmpD, kMachFloat64}, | 50 kMips64CmpD, MachineType::Float64()}, |
51 kUnsignedLessThanOrEqual}, | 51 kUnsignedLessThanOrEqual}, |
52 {{&RawMachineAssembler::Float64GreaterThan, "Float64GreaterThan", | 52 {{&RawMachineAssembler::Float64GreaterThan, "Float64GreaterThan", |
53 kMips64CmpD, kMachFloat64}, | 53 kMips64CmpD, MachineType::Float64()}, |
54 kUnsignedLessThan}, | 54 kUnsignedLessThan}, |
55 {{&RawMachineAssembler::Float64GreaterThanOrEqual, | 55 {{&RawMachineAssembler::Float64GreaterThanOrEqual, |
56 "Float64GreaterThanOrEqual", kMips64CmpD, kMachFloat64}, | 56 "Float64GreaterThanOrEqual", kMips64CmpD, MachineType::Float64()}, |
57 kUnsignedLessThanOrEqual}}; | 57 kUnsignedLessThanOrEqual}}; |
58 | 58 |
59 struct Conversion { | 59 struct Conversion { |
60 // The machine_type field in MachInst1 represents the destination type. | 60 // The machine_type field in MachInst1 represents the destination type. |
61 MachInst1 mi; | 61 MachInst1 mi; |
62 MachineType src_machine_type; | 62 MachineType src_machine_type; |
63 }; | 63 }; |
64 | 64 |
65 | 65 |
66 // ---------------------------------------------------------------------------- | 66 // ---------------------------------------------------------------------------- |
67 // Logical instructions. | 67 // Logical instructions. |
68 // ---------------------------------------------------------------------------- | 68 // ---------------------------------------------------------------------------- |
69 | 69 |
70 | 70 |
71 const MachInst2 kLogicalInstructions[] = { | 71 const MachInst2 kLogicalInstructions[] = { |
72 {&RawMachineAssembler::Word32And, "Word32And", kMips64And, kMachInt32}, | 72 {&RawMachineAssembler::Word32And, "Word32And", kMips64And, |
73 {&RawMachineAssembler::Word64And, "Word64And", kMips64And, kMachInt64}, | 73 MachineType::Int32()}, |
74 {&RawMachineAssembler::Word32Or, "Word32Or", kMips64Or, kMachInt32}, | 74 {&RawMachineAssembler::Word64And, "Word64And", kMips64And, |
75 {&RawMachineAssembler::Word64Or, "Word64Or", kMips64Or, kMachInt64}, | 75 MachineType::Int64()}, |
76 {&RawMachineAssembler::Word32Xor, "Word32Xor", kMips64Xor, kMachInt32}, | 76 {&RawMachineAssembler::Word32Or, "Word32Or", kMips64Or, |
77 {&RawMachineAssembler::Word64Xor, "Word64Xor", kMips64Xor, kMachInt64}}; | 77 MachineType::Int32()}, |
| 78 {&RawMachineAssembler::Word64Or, "Word64Or", kMips64Or, |
| 79 MachineType::Int64()}, |
| 80 {&RawMachineAssembler::Word32Xor, "Word32Xor", kMips64Xor, |
| 81 MachineType::Int32()}, |
| 82 {&RawMachineAssembler::Word64Xor, "Word64Xor", kMips64Xor, |
| 83 MachineType::Int64()}}; |
78 | 84 |
79 | 85 |
80 // ---------------------------------------------------------------------------- | 86 // ---------------------------------------------------------------------------- |
81 // Shift instructions. | 87 // Shift instructions. |
82 // ---------------------------------------------------------------------------- | 88 // ---------------------------------------------------------------------------- |
83 | 89 |
84 | 90 |
85 const MachInst2 kShiftInstructions[] = { | 91 const MachInst2 kShiftInstructions[] = { |
86 {&RawMachineAssembler::Word32Shl, "Word32Shl", kMips64Shl, kMachInt32}, | 92 {&RawMachineAssembler::Word32Shl, "Word32Shl", kMips64Shl, |
87 {&RawMachineAssembler::Word64Shl, "Word64Shl", kMips64Dshl, kMachInt64}, | 93 MachineType::Int32()}, |
88 {&RawMachineAssembler::Word32Shr, "Word32Shr", kMips64Shr, kMachInt32}, | 94 {&RawMachineAssembler::Word64Shl, "Word64Shl", kMips64Dshl, |
89 {&RawMachineAssembler::Word64Shr, "Word64Shr", kMips64Dshr, kMachInt64}, | 95 MachineType::Int64()}, |
90 {&RawMachineAssembler::Word32Sar, "Word32Sar", kMips64Sar, kMachInt32}, | 96 {&RawMachineAssembler::Word32Shr, "Word32Shr", kMips64Shr, |
91 {&RawMachineAssembler::Word64Sar, "Word64Sar", kMips64Dsar, kMachInt64}, | 97 MachineType::Int32()}, |
92 {&RawMachineAssembler::Word32Ror, "Word32Ror", kMips64Ror, kMachInt32}, | 98 {&RawMachineAssembler::Word64Shr, "Word64Shr", kMips64Dshr, |
93 {&RawMachineAssembler::Word64Ror, "Word64Ror", kMips64Dror, kMachInt64}}; | 99 MachineType::Int64()}, |
| 100 {&RawMachineAssembler::Word32Sar, "Word32Sar", kMips64Sar, |
| 101 MachineType::Int32()}, |
| 102 {&RawMachineAssembler::Word64Sar, "Word64Sar", kMips64Dsar, |
| 103 MachineType::Int64()}, |
| 104 {&RawMachineAssembler::Word32Ror, "Word32Ror", kMips64Ror, |
| 105 MachineType::Int32()}, |
| 106 {&RawMachineAssembler::Word64Ror, "Word64Ror", kMips64Dror, |
| 107 MachineType::Int64()}}; |
94 | 108 |
95 | 109 |
96 // ---------------------------------------------------------------------------- | 110 // ---------------------------------------------------------------------------- |
97 // MUL/DIV instructions. | 111 // MUL/DIV instructions. |
98 // ---------------------------------------------------------------------------- | 112 // ---------------------------------------------------------------------------- |
99 | 113 |
100 | 114 |
101 const MachInst2 kMulDivInstructions[] = { | 115 const MachInst2 kMulDivInstructions[] = { |
102 {&RawMachineAssembler::Int32Mul, "Int32Mul", kMips64Mul, kMachInt32}, | 116 {&RawMachineAssembler::Int32Mul, "Int32Mul", kMips64Mul, |
103 {&RawMachineAssembler::Int32Div, "Int32Div", kMips64Div, kMachInt32}, | 117 MachineType::Int32()}, |
104 {&RawMachineAssembler::Uint32Div, "Uint32Div", kMips64DivU, kMachUint32}, | 118 {&RawMachineAssembler::Int32Div, "Int32Div", kMips64Div, |
105 {&RawMachineAssembler::Int64Mul, "Int64Mul", kMips64Dmul, kMachInt64}, | 119 MachineType::Int32()}, |
106 {&RawMachineAssembler::Int64Div, "Int64Div", kMips64Ddiv, kMachInt64}, | 120 {&RawMachineAssembler::Uint32Div, "Uint32Div", kMips64DivU, |
107 {&RawMachineAssembler::Uint64Div, "Uint64Div", kMips64DdivU, kMachUint64}, | 121 MachineType::Uint32()}, |
108 {&RawMachineAssembler::Float64Mul, "Float64Mul", kMips64MulD, kMachFloat64}, | 122 {&RawMachineAssembler::Int64Mul, "Int64Mul", kMips64Dmul, |
| 123 MachineType::Int64()}, |
| 124 {&RawMachineAssembler::Int64Div, "Int64Div", kMips64Ddiv, |
| 125 MachineType::Int64()}, |
| 126 {&RawMachineAssembler::Uint64Div, "Uint64Div", kMips64DdivU, |
| 127 MachineType::Uint64()}, |
| 128 {&RawMachineAssembler::Float64Mul, "Float64Mul", kMips64MulD, |
| 129 MachineType::Float64()}, |
109 {&RawMachineAssembler::Float64Div, "Float64Div", kMips64DivD, | 130 {&RawMachineAssembler::Float64Div, "Float64Div", kMips64DivD, |
110 kMachFloat64}}; | 131 MachineType::Float64()}}; |
111 | 132 |
112 | 133 |
113 // ---------------------------------------------------------------------------- | 134 // ---------------------------------------------------------------------------- |
114 // MOD instructions. | 135 // MOD instructions. |
115 // ---------------------------------------------------------------------------- | 136 // ---------------------------------------------------------------------------- |
116 | 137 |
117 | 138 |
118 const MachInst2 kModInstructions[] = { | 139 const MachInst2 kModInstructions[] = { |
119 {&RawMachineAssembler::Int32Mod, "Int32Mod", kMips64Mod, kMachInt32}, | 140 {&RawMachineAssembler::Int32Mod, "Int32Mod", kMips64Mod, |
120 {&RawMachineAssembler::Uint32Mod, "Uint32Mod", kMips64ModU, kMachInt32}, | 141 MachineType::Int32()}, |
| 142 {&RawMachineAssembler::Uint32Mod, "Uint32Mod", kMips64ModU, |
| 143 MachineType::Int32()}, |
121 {&RawMachineAssembler::Float64Mod, "Float64Mod", kMips64ModD, | 144 {&RawMachineAssembler::Float64Mod, "Float64Mod", kMips64ModD, |
122 kMachFloat64}}; | 145 MachineType::Float64()}}; |
123 | 146 |
124 | 147 |
125 // ---------------------------------------------------------------------------- | 148 // ---------------------------------------------------------------------------- |
126 // Arithmetic FPU instructions. | 149 // Arithmetic FPU instructions. |
127 // ---------------------------------------------------------------------------- | 150 // ---------------------------------------------------------------------------- |
128 | 151 |
129 | 152 |
130 const MachInst2 kFPArithInstructions[] = { | 153 const MachInst2 kFPArithInstructions[] = { |
131 {&RawMachineAssembler::Float64Add, "Float64Add", kMips64AddD, kMachFloat64}, | 154 {&RawMachineAssembler::Float64Add, "Float64Add", kMips64AddD, |
| 155 MachineType::Float64()}, |
132 {&RawMachineAssembler::Float64Sub, "Float64Sub", kMips64SubD, | 156 {&RawMachineAssembler::Float64Sub, "Float64Sub", kMips64SubD, |
133 kMachFloat64}}; | 157 MachineType::Float64()}}; |
134 | 158 |
135 | 159 |
136 // ---------------------------------------------------------------------------- | 160 // ---------------------------------------------------------------------------- |
137 // IntArithTest instructions, two nodes. | 161 // IntArithTest instructions, two nodes. |
138 // ---------------------------------------------------------------------------- | 162 // ---------------------------------------------------------------------------- |
139 | 163 |
140 | 164 |
141 const MachInst2 kAddSubInstructions[] = { | 165 const MachInst2 kAddSubInstructions[] = { |
142 {&RawMachineAssembler::Int32Add, "Int32Add", kMips64Add, kMachInt32}, | 166 {&RawMachineAssembler::Int32Add, "Int32Add", kMips64Add, |
143 {&RawMachineAssembler::Int64Add, "Int64Add", kMips64Dadd, kMachInt64}, | 167 MachineType::Int32()}, |
144 {&RawMachineAssembler::Int32Sub, "Int32Sub", kMips64Sub, kMachInt32}, | 168 {&RawMachineAssembler::Int64Add, "Int64Add", kMips64Dadd, |
145 {&RawMachineAssembler::Int64Sub, "Int64Sub", kMips64Dsub, kMachInt64}}; | 169 MachineType::Int64()}, |
| 170 {&RawMachineAssembler::Int32Sub, "Int32Sub", kMips64Sub, |
| 171 MachineType::Int32()}, |
| 172 {&RawMachineAssembler::Int64Sub, "Int64Sub", kMips64Dsub, |
| 173 MachineType::Int64()}}; |
146 | 174 |
147 | 175 |
148 // ---------------------------------------------------------------------------- | 176 // ---------------------------------------------------------------------------- |
149 // IntArithTest instructions, one node. | 177 // IntArithTest instructions, one node. |
150 // ---------------------------------------------------------------------------- | 178 // ---------------------------------------------------------------------------- |
151 | 179 |
152 | 180 |
153 const MachInst1 kAddSubOneInstructions[] = { | 181 const MachInst1 kAddSubOneInstructions[] = { |
154 {&RawMachineAssembler::Int32Neg, "Int32Neg", kMips64Sub, kMachInt32}, | 182 {&RawMachineAssembler::Int32Neg, "Int32Neg", kMips64Sub, |
155 {&RawMachineAssembler::Int64Neg, "Int64Neg", kMips64Dsub, kMachInt64}}; | 183 MachineType::Int32()}, |
| 184 {&RawMachineAssembler::Int64Neg, "Int64Neg", kMips64Dsub, |
| 185 MachineType::Int64()}}; |
156 | 186 |
157 | 187 |
158 // ---------------------------------------------------------------------------- | 188 // ---------------------------------------------------------------------------- |
159 // Arithmetic compare instructions. | 189 // Arithmetic compare instructions. |
160 // ---------------------------------------------------------------------------- | 190 // ---------------------------------------------------------------------------- |
161 | 191 |
162 | 192 |
163 const IntCmp kCmpInstructions[] = { | 193 const IntCmp kCmpInstructions[] = { |
164 {{&RawMachineAssembler::WordEqual, "WordEqual", kMips64Cmp, kMachInt64}, | 194 {{&RawMachineAssembler::WordEqual, "WordEqual", kMips64Cmp, |
| 195 MachineType::Int64()}, |
165 1U}, | 196 1U}, |
166 {{&RawMachineAssembler::WordNotEqual, "WordNotEqual", kMips64Cmp, | 197 {{&RawMachineAssembler::WordNotEqual, "WordNotEqual", kMips64Cmp, |
167 kMachInt64}, | 198 MachineType::Int64()}, |
168 1U}, | 199 1U}, |
169 {{&RawMachineAssembler::Word32Equal, "Word32Equal", kMips64Cmp, kMachInt32}, | 200 {{&RawMachineAssembler::Word32Equal, "Word32Equal", kMips64Cmp, |
| 201 MachineType::Int32()}, |
170 1U}, | 202 1U}, |
171 {{&RawMachineAssembler::Word32NotEqual, "Word32NotEqual", kMips64Cmp, | 203 {{&RawMachineAssembler::Word32NotEqual, "Word32NotEqual", kMips64Cmp, |
172 kMachInt32}, | 204 MachineType::Int32()}, |
173 1U}, | 205 1U}, |
174 {{&RawMachineAssembler::Int32LessThan, "Int32LessThan", kMips64Cmp, | 206 {{&RawMachineAssembler::Int32LessThan, "Int32LessThan", kMips64Cmp, |
175 kMachInt32}, | 207 MachineType::Int32()}, |
176 1U}, | 208 1U}, |
177 {{&RawMachineAssembler::Int32LessThanOrEqual, "Int32LessThanOrEqual", | 209 {{&RawMachineAssembler::Int32LessThanOrEqual, "Int32LessThanOrEqual", |
178 kMips64Cmp, kMachInt32}, | 210 kMips64Cmp, MachineType::Int32()}, |
179 1U}, | 211 1U}, |
180 {{&RawMachineAssembler::Int32GreaterThan, "Int32GreaterThan", kMips64Cmp, | 212 {{&RawMachineAssembler::Int32GreaterThan, "Int32GreaterThan", kMips64Cmp, |
181 kMachInt32}, | 213 MachineType::Int32()}, |
182 1U}, | 214 1U}, |
183 {{&RawMachineAssembler::Int32GreaterThanOrEqual, "Int32GreaterThanOrEqual", | 215 {{&RawMachineAssembler::Int32GreaterThanOrEqual, "Int32GreaterThanOrEqual", |
184 kMips64Cmp, kMachInt32}, | 216 kMips64Cmp, MachineType::Int32()}, |
185 1U}, | 217 1U}, |
186 {{&RawMachineAssembler::Uint32LessThan, "Uint32LessThan", kMips64Cmp, | 218 {{&RawMachineAssembler::Uint32LessThan, "Uint32LessThan", kMips64Cmp, |
187 kMachUint32}, | 219 MachineType::Uint32()}, |
188 1U}, | 220 1U}, |
189 {{&RawMachineAssembler::Uint32LessThanOrEqual, "Uint32LessThanOrEqual", | 221 {{&RawMachineAssembler::Uint32LessThanOrEqual, "Uint32LessThanOrEqual", |
190 kMips64Cmp, kMachUint32}, | 222 kMips64Cmp, MachineType::Uint32()}, |
191 1U}}; | 223 1U}}; |
192 | 224 |
193 | 225 |
194 // ---------------------------------------------------------------------------- | 226 // ---------------------------------------------------------------------------- |
195 // Conversion instructions. | 227 // Conversion instructions. |
196 // ---------------------------------------------------------------------------- | 228 // ---------------------------------------------------------------------------- |
197 | 229 |
198 const Conversion kConversionInstructions[] = { | 230 const Conversion kConversionInstructions[] = { |
199 // Conversion instructions are related to machine_operator.h: | 231 // Conversion instructions are related to machine_operator.h: |
200 // FPU conversions: | 232 // FPU conversions: |
201 // Convert representation of integers between float64 and int32/uint32. | 233 // Convert representation of integers between float64 and int32/uint32. |
202 // The precise rounding mode and handling of out of range inputs are *not* | 234 // The precise rounding mode and handling of out of range inputs are *not* |
203 // defined for these operators, since they are intended only for use with | 235 // defined for these operators, since they are intended only for use with |
204 // integers. | 236 // integers. |
205 // mips instructions: | 237 // mips instructions: |
206 // mtc1, cvt.d.w | 238 // mtc1, cvt.d.w |
207 {{&RawMachineAssembler::ChangeInt32ToFloat64, "ChangeInt32ToFloat64", | 239 {{&RawMachineAssembler::ChangeInt32ToFloat64, "ChangeInt32ToFloat64", |
208 kMips64CvtDW, kMachFloat64}, | 240 kMips64CvtDW, MachineType::Float64()}, |
209 kMachInt32}, | 241 MachineType::Int32()}, |
210 | 242 |
211 // mips instructions: | 243 // mips instructions: |
212 // cvt.d.uw | 244 // cvt.d.uw |
213 {{&RawMachineAssembler::ChangeUint32ToFloat64, "ChangeUint32ToFloat64", | 245 {{&RawMachineAssembler::ChangeUint32ToFloat64, "ChangeUint32ToFloat64", |
214 kMips64CvtDUw, kMachFloat64}, | 246 kMips64CvtDUw, MachineType::Float64()}, |
215 kMachInt32}, | 247 MachineType::Int32()}, |
216 | 248 |
217 // mips instructions: | 249 // mips instructions: |
218 // mfc1, trunc double to word, for more details look at mips macro | 250 // mfc1, trunc double to word, for more details look at mips macro |
219 // asm and mips asm file | 251 // asm and mips asm file |
220 {{&RawMachineAssembler::ChangeFloat64ToInt32, "ChangeFloat64ToInt32", | 252 {{&RawMachineAssembler::ChangeFloat64ToInt32, "ChangeFloat64ToInt32", |
221 kMips64TruncWD, kMachFloat64}, | 253 kMips64TruncWD, MachineType::Float64()}, |
222 kMachInt32}, | 254 MachineType::Int32()}, |
223 | 255 |
224 // mips instructions: | 256 // mips instructions: |
225 // trunc double to unsigned word, for more details look at mips macro | 257 // trunc double to unsigned word, for more details look at mips macro |
226 // asm and mips asm file | 258 // asm and mips asm file |
227 {{&RawMachineAssembler::ChangeFloat64ToUint32, "ChangeFloat64ToUint32", | 259 {{&RawMachineAssembler::ChangeFloat64ToUint32, "ChangeFloat64ToUint32", |
228 kMips64TruncUwD, kMachFloat64}, | 260 kMips64TruncUwD, MachineType::Float64()}, |
229 kMachInt32}}; | 261 MachineType::Int32()}}; |
230 | 262 |
231 const Conversion kFloat64RoundInstructions[] = { | 263 const Conversion kFloat64RoundInstructions[] = { |
232 {{&RawMachineAssembler::Float64RoundUp, "Float64RoundUp", kMips64CeilWD, | 264 {{&RawMachineAssembler::Float64RoundUp, "Float64RoundUp", kMips64CeilWD, |
233 kMachFloat64}, | 265 MachineType::Float64()}, |
234 kMachInt32}, | 266 MachineType::Int32()}, |
235 {{&RawMachineAssembler::Float64RoundDown, "Float64RoundDown", | 267 {{&RawMachineAssembler::Float64RoundDown, "Float64RoundDown", |
236 kMips64FloorWD, kMachFloat64}, | 268 kMips64FloorWD, MachineType::Float64()}, |
237 kMachInt32}, | 269 MachineType::Int32()}, |
238 {{&RawMachineAssembler::Float64RoundTiesEven, "Float64RoundTiesEven", | 270 {{&RawMachineAssembler::Float64RoundTiesEven, "Float64RoundTiesEven", |
239 kMips64RoundWD, kMachFloat64}, | 271 kMips64RoundWD, MachineType::Float64()}, |
240 kMachInt32}, | 272 MachineType::Int32()}, |
241 {{&RawMachineAssembler::Float64RoundTruncate, "Float64RoundTruncate", | 273 {{&RawMachineAssembler::Float64RoundTruncate, "Float64RoundTruncate", |
242 kMips64TruncWD, kMachFloat64}, | 274 kMips64TruncWD, MachineType::Float64()}, |
243 kMachInt32}}; | 275 MachineType::Int32()}}; |
244 | 276 |
245 } // namespace | 277 } // namespace |
246 | 278 |
247 | 279 |
248 typedef InstructionSelectorTestWithParam<FPCmp> InstructionSelectorFPCmpTest; | 280 typedef InstructionSelectorTestWithParam<FPCmp> InstructionSelectorFPCmpTest; |
249 | 281 |
250 TEST_P(InstructionSelectorFPCmpTest, Parameter) { | 282 TEST_P(InstructionSelectorFPCmpTest, Parameter) { |
251 const FPCmp cmp = GetParam(); | 283 const FPCmp cmp = GetParam(); |
252 StreamBuilder m(this, kMachInt32, cmp.mi.machine_type, cmp.mi.machine_type); | 284 StreamBuilder m(this, MachineType::Int32(), cmp.mi.machine_type, |
| 285 cmp.mi.machine_type); |
253 m.Return((m.*cmp.mi.constructor)(m.Parameter(0), m.Parameter(1))); | 286 m.Return((m.*cmp.mi.constructor)(m.Parameter(0), m.Parameter(1))); |
254 Stream s = m.Build(); | 287 Stream s = m.Build(); |
255 ASSERT_EQ(1U, s.size()); | 288 ASSERT_EQ(1U, s.size()); |
256 EXPECT_EQ(cmp.mi.arch_opcode, s[0]->arch_opcode()); | 289 EXPECT_EQ(cmp.mi.arch_opcode, s[0]->arch_opcode()); |
257 EXPECT_EQ(2U, s[0]->InputCount()); | 290 EXPECT_EQ(2U, s[0]->InputCount()); |
258 EXPECT_EQ(1U, s[0]->OutputCount()); | 291 EXPECT_EQ(1U, s[0]->OutputCount()); |
259 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 292 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
260 EXPECT_EQ(cmp.cond, s[0]->flags_condition()); | 293 EXPECT_EQ(cmp.cond, s[0]->flags_condition()); |
261 } | 294 } |
262 | 295 |
(...skipping 23 matching lines...) Expand all Loading... |
286 | 319 |
287 // ---------------------------------------------------------------------------- | 320 // ---------------------------------------------------------------------------- |
288 // Shift instructions. | 321 // Shift instructions. |
289 // ---------------------------------------------------------------------------- | 322 // ---------------------------------------------------------------------------- |
290 typedef InstructionSelectorTestWithParam<MachInst2> | 323 typedef InstructionSelectorTestWithParam<MachInst2> |
291 InstructionSelectorShiftTest; | 324 InstructionSelectorShiftTest; |
292 | 325 |
293 TEST_P(InstructionSelectorShiftTest, Immediate) { | 326 TEST_P(InstructionSelectorShiftTest, Immediate) { |
294 const MachInst2 dpi = GetParam(); | 327 const MachInst2 dpi = GetParam(); |
295 const MachineType type = dpi.machine_type; | 328 const MachineType type = dpi.machine_type; |
296 TRACED_FORRANGE(int32_t, imm, 0, (ElementSizeOf(type) * 8) - 1) { | 329 TRACED_FORRANGE(int32_t, imm, 0, |
| 330 ((1 << ElementSizeLog2Of(type.representation())) * 8) - 1) { |
297 StreamBuilder m(this, type, type); | 331 StreamBuilder m(this, type, type); |
298 m.Return((m.*dpi.constructor)(m.Parameter(0), m.Int32Constant(imm))); | 332 m.Return((m.*dpi.constructor)(m.Parameter(0), m.Int32Constant(imm))); |
299 Stream s = m.Build(); | 333 Stream s = m.Build(); |
300 ASSERT_EQ(1U, s.size()); | 334 ASSERT_EQ(1U, s.size()); |
301 EXPECT_EQ(dpi.arch_opcode, s[0]->arch_opcode()); | 335 EXPECT_EQ(dpi.arch_opcode, s[0]->arch_opcode()); |
302 EXPECT_EQ(2U, s[0]->InputCount()); | 336 EXPECT_EQ(2U, s[0]->InputCount()); |
303 EXPECT_TRUE(s[0]->InputAt(1)->IsImmediate()); | 337 EXPECT_TRUE(s[0]->InputAt(1)->IsImmediate()); |
304 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); | 338 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); |
305 EXPECT_EQ(1U, s[0]->OutputCount()); | 339 EXPECT_EQ(1U, s[0]->OutputCount()); |
306 } | 340 } |
307 } | 341 } |
308 | 342 |
309 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, InstructionSelectorShiftTest, | 343 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, InstructionSelectorShiftTest, |
310 ::testing::ValuesIn(kShiftInstructions)); | 344 ::testing::ValuesIn(kShiftInstructions)); |
311 | 345 |
312 TEST_F(InstructionSelectorTest, Word32ShrWithWord32AndWithImmediate) { | 346 TEST_F(InstructionSelectorTest, Word32ShrWithWord32AndWithImmediate) { |
313 // The available shift operand range is `0 <= imm < 32`, but we also test | 347 // The available shift operand range is `0 <= imm < 32`, but we also test |
314 // that immediates outside this range are handled properly (modulo-32). | 348 // that immediates outside this range are handled properly (modulo-32). |
315 TRACED_FORRANGE(int32_t, shift, -32, 63) { | 349 TRACED_FORRANGE(int32_t, shift, -32, 63) { |
316 int32_t lsb = shift & 0x1f; | 350 int32_t lsb = shift & 0x1f; |
317 TRACED_FORRANGE(int32_t, width, 1, 32 - lsb) { | 351 TRACED_FORRANGE(int32_t, width, 1, 32 - lsb) { |
318 uint32_t jnk = rng()->NextInt(); | 352 uint32_t jnk = rng()->NextInt(); |
319 jnk = (lsb > 0) ? (jnk >> (32 - lsb)) : 0; | 353 jnk = (lsb > 0) ? (jnk >> (32 - lsb)) : 0; |
320 uint32_t msk = ((0xffffffffu >> (32 - width)) << lsb) | jnk; | 354 uint32_t msk = ((0xffffffffu >> (32 - width)) << lsb) | jnk; |
321 StreamBuilder m(this, kMachInt32, kMachInt32); | 355 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
322 m.Return(m.Word32Shr(m.Word32And(m.Parameter(0), m.Int32Constant(msk)), | 356 m.Return(m.Word32Shr(m.Word32And(m.Parameter(0), m.Int32Constant(msk)), |
323 m.Int32Constant(shift))); | 357 m.Int32Constant(shift))); |
324 Stream s = m.Build(); | 358 Stream s = m.Build(); |
325 ASSERT_EQ(1U, s.size()); | 359 ASSERT_EQ(1U, s.size()); |
326 EXPECT_EQ(kMips64Ext, s[0]->arch_opcode()); | 360 EXPECT_EQ(kMips64Ext, s[0]->arch_opcode()); |
327 ASSERT_EQ(3U, s[0]->InputCount()); | 361 ASSERT_EQ(3U, s[0]->InputCount()); |
328 EXPECT_EQ(lsb, s.ToInt32(s[0]->InputAt(1))); | 362 EXPECT_EQ(lsb, s.ToInt32(s[0]->InputAt(1))); |
329 EXPECT_EQ(width, s.ToInt32(s[0]->InputAt(2))); | 363 EXPECT_EQ(width, s.ToInt32(s[0]->InputAt(2))); |
330 } | 364 } |
331 } | 365 } |
332 TRACED_FORRANGE(int32_t, shift, -32, 63) { | 366 TRACED_FORRANGE(int32_t, shift, -32, 63) { |
333 int32_t lsb = shift & 0x1f; | 367 int32_t lsb = shift & 0x1f; |
334 TRACED_FORRANGE(int32_t, width, 1, 32 - lsb) { | 368 TRACED_FORRANGE(int32_t, width, 1, 32 - lsb) { |
335 uint32_t jnk = rng()->NextInt(); | 369 uint32_t jnk = rng()->NextInt(); |
336 jnk = (lsb > 0) ? (jnk >> (32 - lsb)) : 0; | 370 jnk = (lsb > 0) ? (jnk >> (32 - lsb)) : 0; |
337 uint32_t msk = ((0xffffffffu >> (32 - width)) << lsb) | jnk; | 371 uint32_t msk = ((0xffffffffu >> (32 - width)) << lsb) | jnk; |
338 StreamBuilder m(this, kMachInt32, kMachInt32); | 372 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
339 m.Return(m.Word32Shr(m.Word32And(m.Int32Constant(msk), m.Parameter(0)), | 373 m.Return(m.Word32Shr(m.Word32And(m.Int32Constant(msk), m.Parameter(0)), |
340 m.Int32Constant(shift))); | 374 m.Int32Constant(shift))); |
341 Stream s = m.Build(); | 375 Stream s = m.Build(); |
342 ASSERT_EQ(1U, s.size()); | 376 ASSERT_EQ(1U, s.size()); |
343 EXPECT_EQ(kMips64Ext, s[0]->arch_opcode()); | 377 EXPECT_EQ(kMips64Ext, s[0]->arch_opcode()); |
344 ASSERT_EQ(3U, s[0]->InputCount()); | 378 ASSERT_EQ(3U, s[0]->InputCount()); |
345 EXPECT_EQ(lsb, s.ToInt32(s[0]->InputAt(1))); | 379 EXPECT_EQ(lsb, s.ToInt32(s[0]->InputAt(1))); |
346 EXPECT_EQ(width, s.ToInt32(s[0]->InputAt(2))); | 380 EXPECT_EQ(width, s.ToInt32(s[0]->InputAt(2))); |
347 } | 381 } |
348 } | 382 } |
349 } | 383 } |
350 | 384 |
351 | 385 |
352 TEST_F(InstructionSelectorTest, Word64ShrWithWord64AndWithImmediate) { | 386 TEST_F(InstructionSelectorTest, Word64ShrWithWord64AndWithImmediate) { |
353 // The available shift operand range is `0 <= imm < 64`, but we also test | 387 // The available shift operand range is `0 <= imm < 64`, but we also test |
354 // that immediates outside this range are handled properly (modulo-64). | 388 // that immediates outside this range are handled properly (modulo-64). |
355 TRACED_FORRANGE(int32_t, shift, -64, 127) { | 389 TRACED_FORRANGE(int32_t, shift, -64, 127) { |
356 int32_t lsb = shift & 0x3f; | 390 int32_t lsb = shift & 0x3f; |
357 TRACED_FORRANGE(int32_t, width, 1, 64 - lsb) { | 391 TRACED_FORRANGE(int32_t, width, 1, 64 - lsb) { |
358 uint64_t jnk = rng()->NextInt64(); | 392 uint64_t jnk = rng()->NextInt64(); |
359 jnk = (lsb > 0) ? (jnk >> (64 - lsb)) : 0; | 393 jnk = (lsb > 0) ? (jnk >> (64 - lsb)) : 0; |
360 uint64_t msk = | 394 uint64_t msk = |
361 ((V8_UINT64_C(0xffffffffffffffff) >> (64 - width)) << lsb) | jnk; | 395 ((V8_UINT64_C(0xffffffffffffffff) >> (64 - width)) << lsb) | jnk; |
362 StreamBuilder m(this, kMachInt64, kMachInt64); | 396 StreamBuilder m(this, MachineType::Int64(), MachineType::Int64()); |
363 m.Return(m.Word64Shr(m.Word64And(m.Parameter(0), m.Int64Constant(msk)), | 397 m.Return(m.Word64Shr(m.Word64And(m.Parameter(0), m.Int64Constant(msk)), |
364 m.Int64Constant(shift))); | 398 m.Int64Constant(shift))); |
365 Stream s = m.Build(); | 399 Stream s = m.Build(); |
366 ASSERT_EQ(1U, s.size()); | 400 ASSERT_EQ(1U, s.size()); |
367 EXPECT_EQ(kMips64Dext, s[0]->arch_opcode()); | 401 EXPECT_EQ(kMips64Dext, s[0]->arch_opcode()); |
368 ASSERT_EQ(3U, s[0]->InputCount()); | 402 ASSERT_EQ(3U, s[0]->InputCount()); |
369 EXPECT_EQ(lsb, s.ToInt64(s[0]->InputAt(1))); | 403 EXPECT_EQ(lsb, s.ToInt64(s[0]->InputAt(1))); |
370 EXPECT_EQ(width, s.ToInt64(s[0]->InputAt(2))); | 404 EXPECT_EQ(width, s.ToInt64(s[0]->InputAt(2))); |
371 } | 405 } |
372 } | 406 } |
373 TRACED_FORRANGE(int32_t, shift, -64, 127) { | 407 TRACED_FORRANGE(int32_t, shift, -64, 127) { |
374 int32_t lsb = shift & 0x3f; | 408 int32_t lsb = shift & 0x3f; |
375 TRACED_FORRANGE(int32_t, width, 1, 64 - lsb) { | 409 TRACED_FORRANGE(int32_t, width, 1, 64 - lsb) { |
376 uint64_t jnk = rng()->NextInt64(); | 410 uint64_t jnk = rng()->NextInt64(); |
377 jnk = (lsb > 0) ? (jnk >> (64 - lsb)) : 0; | 411 jnk = (lsb > 0) ? (jnk >> (64 - lsb)) : 0; |
378 uint64_t msk = | 412 uint64_t msk = |
379 ((V8_UINT64_C(0xffffffffffffffff) >> (64 - width)) << lsb) | jnk; | 413 ((V8_UINT64_C(0xffffffffffffffff) >> (64 - width)) << lsb) | jnk; |
380 StreamBuilder m(this, kMachInt64, kMachInt64); | 414 StreamBuilder m(this, MachineType::Int64(), MachineType::Int64()); |
381 m.Return(m.Word64Shr(m.Word64And(m.Int64Constant(msk), m.Parameter(0)), | 415 m.Return(m.Word64Shr(m.Word64And(m.Int64Constant(msk), m.Parameter(0)), |
382 m.Int64Constant(shift))); | 416 m.Int64Constant(shift))); |
383 Stream s = m.Build(); | 417 Stream s = m.Build(); |
384 ASSERT_EQ(1U, s.size()); | 418 ASSERT_EQ(1U, s.size()); |
385 EXPECT_EQ(kMips64Dext, s[0]->arch_opcode()); | 419 EXPECT_EQ(kMips64Dext, s[0]->arch_opcode()); |
386 ASSERT_EQ(3U, s[0]->InputCount()); | 420 ASSERT_EQ(3U, s[0]->InputCount()); |
387 EXPECT_EQ(lsb, s.ToInt64(s[0]->InputAt(1))); | 421 EXPECT_EQ(lsb, s.ToInt64(s[0]->InputAt(1))); |
388 EXPECT_EQ(width, s.ToInt64(s[0]->InputAt(2))); | 422 EXPECT_EQ(width, s.ToInt64(s[0]->InputAt(2))); |
389 } | 423 } |
390 } | 424 } |
391 } | 425 } |
392 | 426 |
393 | 427 |
394 TEST_F(InstructionSelectorTest, Word32AndToClearBits) { | 428 TEST_F(InstructionSelectorTest, Word32AndToClearBits) { |
395 TRACED_FORRANGE(int32_t, shift, 1, 31) { | 429 TRACED_FORRANGE(int32_t, shift, 1, 31) { |
396 int32_t mask = ~((1 << shift) - 1); | 430 int32_t mask = ~((1 << shift) - 1); |
397 StreamBuilder m(this, kMachInt32, kMachInt32); | 431 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
398 m.Return(m.Word32And(m.Parameter(0), m.Int32Constant(mask))); | 432 m.Return(m.Word32And(m.Parameter(0), m.Int32Constant(mask))); |
399 Stream s = m.Build(); | 433 Stream s = m.Build(); |
400 ASSERT_EQ(1U, s.size()); | 434 ASSERT_EQ(1U, s.size()); |
401 EXPECT_EQ(kMips64Ins, s[0]->arch_opcode()); | 435 EXPECT_EQ(kMips64Ins, s[0]->arch_opcode()); |
402 ASSERT_EQ(3U, s[0]->InputCount()); | 436 ASSERT_EQ(3U, s[0]->InputCount()); |
403 EXPECT_EQ(0, s.ToInt32(s[0]->InputAt(1))); | 437 EXPECT_EQ(0, s.ToInt32(s[0]->InputAt(1))); |
404 EXPECT_EQ(shift, s.ToInt32(s[0]->InputAt(2))); | 438 EXPECT_EQ(shift, s.ToInt32(s[0]->InputAt(2))); |
405 } | 439 } |
406 TRACED_FORRANGE(int32_t, shift, 1, 31) { | 440 TRACED_FORRANGE(int32_t, shift, 1, 31) { |
407 int32_t mask = ~((1 << shift) - 1); | 441 int32_t mask = ~((1 << shift) - 1); |
408 StreamBuilder m(this, kMachInt32, kMachInt32); | 442 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
409 m.Return(m.Word32And(m.Int32Constant(mask), m.Parameter(0))); | 443 m.Return(m.Word32And(m.Int32Constant(mask), m.Parameter(0))); |
410 Stream s = m.Build(); | 444 Stream s = m.Build(); |
411 ASSERT_EQ(1U, s.size()); | 445 ASSERT_EQ(1U, s.size()); |
412 EXPECT_EQ(kMips64Ins, s[0]->arch_opcode()); | 446 EXPECT_EQ(kMips64Ins, s[0]->arch_opcode()); |
413 ASSERT_EQ(3U, s[0]->InputCount()); | 447 ASSERT_EQ(3U, s[0]->InputCount()); |
414 EXPECT_EQ(0, s.ToInt32(s[0]->InputAt(1))); | 448 EXPECT_EQ(0, s.ToInt32(s[0]->InputAt(1))); |
415 EXPECT_EQ(shift, s.ToInt32(s[0]->InputAt(2))); | 449 EXPECT_EQ(shift, s.ToInt32(s[0]->InputAt(2))); |
416 } | 450 } |
417 } | 451 } |
418 | 452 |
419 | 453 |
420 TEST_F(InstructionSelectorTest, Word64AndToClearBits) { | 454 TEST_F(InstructionSelectorTest, Word64AndToClearBits) { |
421 TRACED_FORRANGE(int32_t, shift, 1, 31) { | 455 TRACED_FORRANGE(int32_t, shift, 1, 31) { |
422 int64_t mask = ~((1 << shift) - 1); | 456 int64_t mask = ~((1 << shift) - 1); |
423 StreamBuilder m(this, kMachInt64, kMachInt64); | 457 StreamBuilder m(this, MachineType::Int64(), MachineType::Int64()); |
424 m.Return(m.Word64And(m.Parameter(0), m.Int64Constant(mask))); | 458 m.Return(m.Word64And(m.Parameter(0), m.Int64Constant(mask))); |
425 Stream s = m.Build(); | 459 Stream s = m.Build(); |
426 ASSERT_EQ(1U, s.size()); | 460 ASSERT_EQ(1U, s.size()); |
427 EXPECT_EQ(kMips64Dins, s[0]->arch_opcode()); | 461 EXPECT_EQ(kMips64Dins, s[0]->arch_opcode()); |
428 ASSERT_EQ(3U, s[0]->InputCount()); | 462 ASSERT_EQ(3U, s[0]->InputCount()); |
429 EXPECT_EQ(0, s.ToInt32(s[0]->InputAt(1))); | 463 EXPECT_EQ(0, s.ToInt32(s[0]->InputAt(1))); |
430 EXPECT_EQ(shift, s.ToInt32(s[0]->InputAt(2))); | 464 EXPECT_EQ(shift, s.ToInt32(s[0]->InputAt(2))); |
431 } | 465 } |
432 TRACED_FORRANGE(int32_t, shift, 1, 31) { | 466 TRACED_FORRANGE(int32_t, shift, 1, 31) { |
433 int64_t mask = ~((1 << shift) - 1); | 467 int64_t mask = ~((1 << shift) - 1); |
434 StreamBuilder m(this, kMachInt64, kMachInt64); | 468 StreamBuilder m(this, MachineType::Int64(), MachineType::Int64()); |
435 m.Return(m.Word64And(m.Int64Constant(mask), m.Parameter(0))); | 469 m.Return(m.Word64And(m.Int64Constant(mask), m.Parameter(0))); |
436 Stream s = m.Build(); | 470 Stream s = m.Build(); |
437 ASSERT_EQ(1U, s.size()); | 471 ASSERT_EQ(1U, s.size()); |
438 EXPECT_EQ(kMips64Dins, s[0]->arch_opcode()); | 472 EXPECT_EQ(kMips64Dins, s[0]->arch_opcode()); |
439 ASSERT_EQ(3U, s[0]->InputCount()); | 473 ASSERT_EQ(3U, s[0]->InputCount()); |
440 EXPECT_EQ(0, s.ToInt32(s[0]->InputAt(1))); | 474 EXPECT_EQ(0, s.ToInt32(s[0]->InputAt(1))); |
441 EXPECT_EQ(shift, s.ToInt32(s[0]->InputAt(2))); | 475 EXPECT_EQ(shift, s.ToInt32(s[0]->InputAt(2))); |
442 } | 476 } |
443 } | 477 } |
444 | 478 |
(...skipping 16 matching lines...) Expand all Loading... |
461 EXPECT_EQ(2U, s[0]->InputCount()); | 495 EXPECT_EQ(2U, s[0]->InputCount()); |
462 EXPECT_EQ(1U, s[0]->OutputCount()); | 496 EXPECT_EQ(1U, s[0]->OutputCount()); |
463 } | 497 } |
464 | 498 |
465 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, InstructionSelectorLogicalTest, | 499 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, InstructionSelectorLogicalTest, |
466 ::testing::ValuesIn(kLogicalInstructions)); | 500 ::testing::ValuesIn(kLogicalInstructions)); |
467 | 501 |
468 | 502 |
469 TEST_F(InstructionSelectorTest, Word64XorMinusOneWithParameter) { | 503 TEST_F(InstructionSelectorTest, Word64XorMinusOneWithParameter) { |
470 { | 504 { |
471 StreamBuilder m(this, kMachInt64, kMachInt64); | 505 StreamBuilder m(this, MachineType::Int64(), MachineType::Int64()); |
472 m.Return(m.Word64Xor(m.Parameter(0), m.Int64Constant(-1))); | 506 m.Return(m.Word64Xor(m.Parameter(0), m.Int64Constant(-1))); |
473 Stream s = m.Build(); | 507 Stream s = m.Build(); |
474 ASSERT_EQ(1U, s.size()); | 508 ASSERT_EQ(1U, s.size()); |
475 EXPECT_EQ(kMips64Nor, s[0]->arch_opcode()); | 509 EXPECT_EQ(kMips64Nor, s[0]->arch_opcode()); |
476 EXPECT_EQ(2U, s[0]->InputCount()); | 510 EXPECT_EQ(2U, s[0]->InputCount()); |
477 EXPECT_EQ(1U, s[0]->OutputCount()); | 511 EXPECT_EQ(1U, s[0]->OutputCount()); |
478 } | 512 } |
479 { | 513 { |
480 StreamBuilder m(this, kMachInt64, kMachInt64); | 514 StreamBuilder m(this, MachineType::Int64(), MachineType::Int64()); |
481 m.Return(m.Word64Xor(m.Int64Constant(-1), m.Parameter(0))); | 515 m.Return(m.Word64Xor(m.Int64Constant(-1), m.Parameter(0))); |
482 Stream s = m.Build(); | 516 Stream s = m.Build(); |
483 ASSERT_EQ(1U, s.size()); | 517 ASSERT_EQ(1U, s.size()); |
484 EXPECT_EQ(kMips64Nor, s[0]->arch_opcode()); | 518 EXPECT_EQ(kMips64Nor, s[0]->arch_opcode()); |
485 EXPECT_EQ(2U, s[0]->InputCount()); | 519 EXPECT_EQ(2U, s[0]->InputCount()); |
486 EXPECT_EQ(1U, s[0]->OutputCount()); | 520 EXPECT_EQ(1U, s[0]->OutputCount()); |
487 } | 521 } |
488 } | 522 } |
489 | 523 |
490 | 524 |
491 TEST_F(InstructionSelectorTest, Word32XorMinusOneWithParameter) { | 525 TEST_F(InstructionSelectorTest, Word32XorMinusOneWithParameter) { |
492 { | 526 { |
493 StreamBuilder m(this, kMachInt32, kMachInt32); | 527 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
494 m.Return(m.Word32Xor(m.Parameter(0), m.Int32Constant(-1))); | 528 m.Return(m.Word32Xor(m.Parameter(0), m.Int32Constant(-1))); |
495 Stream s = m.Build(); | 529 Stream s = m.Build(); |
496 ASSERT_EQ(1U, s.size()); | 530 ASSERT_EQ(1U, s.size()); |
497 EXPECT_EQ(kMips64Nor, s[0]->arch_opcode()); | 531 EXPECT_EQ(kMips64Nor, s[0]->arch_opcode()); |
498 EXPECT_EQ(2U, s[0]->InputCount()); | 532 EXPECT_EQ(2U, s[0]->InputCount()); |
499 EXPECT_EQ(1U, s[0]->OutputCount()); | 533 EXPECT_EQ(1U, s[0]->OutputCount()); |
500 } | 534 } |
501 { | 535 { |
502 StreamBuilder m(this, kMachInt32, kMachInt32); | 536 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
503 m.Return(m.Word32Xor(m.Int32Constant(-1), m.Parameter(0))); | 537 m.Return(m.Word32Xor(m.Int32Constant(-1), m.Parameter(0))); |
504 Stream s = m.Build(); | 538 Stream s = m.Build(); |
505 ASSERT_EQ(1U, s.size()); | 539 ASSERT_EQ(1U, s.size()); |
506 EXPECT_EQ(kMips64Nor, s[0]->arch_opcode()); | 540 EXPECT_EQ(kMips64Nor, s[0]->arch_opcode()); |
507 EXPECT_EQ(2U, s[0]->InputCount()); | 541 EXPECT_EQ(2U, s[0]->InputCount()); |
508 EXPECT_EQ(1U, s[0]->OutputCount()); | 542 EXPECT_EQ(1U, s[0]->OutputCount()); |
509 } | 543 } |
510 } | 544 } |
511 | 545 |
512 | 546 |
513 TEST_F(InstructionSelectorTest, Word64XorMinusOneWithWord64Or) { | 547 TEST_F(InstructionSelectorTest, Word64XorMinusOneWithWord64Or) { |
514 { | 548 { |
515 StreamBuilder m(this, kMachInt64, kMachInt64); | 549 StreamBuilder m(this, MachineType::Int64(), MachineType::Int64()); |
516 m.Return(m.Word64Xor(m.Word64Or(m.Parameter(0), m.Parameter(0)), | 550 m.Return(m.Word64Xor(m.Word64Or(m.Parameter(0), m.Parameter(0)), |
517 m.Int64Constant(-1))); | 551 m.Int64Constant(-1))); |
518 Stream s = m.Build(); | 552 Stream s = m.Build(); |
519 ASSERT_EQ(1U, s.size()); | 553 ASSERT_EQ(1U, s.size()); |
520 EXPECT_EQ(kMips64Nor, s[0]->arch_opcode()); | 554 EXPECT_EQ(kMips64Nor, s[0]->arch_opcode()); |
521 EXPECT_EQ(2U, s[0]->InputCount()); | 555 EXPECT_EQ(2U, s[0]->InputCount()); |
522 EXPECT_EQ(1U, s[0]->OutputCount()); | 556 EXPECT_EQ(1U, s[0]->OutputCount()); |
523 } | 557 } |
524 { | 558 { |
525 StreamBuilder m(this, kMachInt64, kMachInt64); | 559 StreamBuilder m(this, MachineType::Int64(), MachineType::Int64()); |
526 m.Return(m.Word64Xor(m.Int64Constant(-1), | 560 m.Return(m.Word64Xor(m.Int64Constant(-1), |
527 m.Word64Or(m.Parameter(0), m.Parameter(0)))); | 561 m.Word64Or(m.Parameter(0), m.Parameter(0)))); |
528 Stream s = m.Build(); | 562 Stream s = m.Build(); |
529 ASSERT_EQ(1U, s.size()); | 563 ASSERT_EQ(1U, s.size()); |
530 EXPECT_EQ(kMips64Nor, s[0]->arch_opcode()); | 564 EXPECT_EQ(kMips64Nor, s[0]->arch_opcode()); |
531 EXPECT_EQ(2U, s[0]->InputCount()); | 565 EXPECT_EQ(2U, s[0]->InputCount()); |
532 EXPECT_EQ(1U, s[0]->OutputCount()); | 566 EXPECT_EQ(1U, s[0]->OutputCount()); |
533 } | 567 } |
534 } | 568 } |
535 | 569 |
536 | 570 |
537 TEST_F(InstructionSelectorTest, Word32XorMinusOneWithWord32Or) { | 571 TEST_F(InstructionSelectorTest, Word32XorMinusOneWithWord32Or) { |
538 { | 572 { |
539 StreamBuilder m(this, kMachInt32, kMachInt32); | 573 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
540 m.Return(m.Word32Xor(m.Word32Or(m.Parameter(0), m.Parameter(0)), | 574 m.Return(m.Word32Xor(m.Word32Or(m.Parameter(0), m.Parameter(0)), |
541 m.Int32Constant(-1))); | 575 m.Int32Constant(-1))); |
542 Stream s = m.Build(); | 576 Stream s = m.Build(); |
543 ASSERT_EQ(1U, s.size()); | 577 ASSERT_EQ(1U, s.size()); |
544 EXPECT_EQ(kMips64Nor, s[0]->arch_opcode()); | 578 EXPECT_EQ(kMips64Nor, s[0]->arch_opcode()); |
545 EXPECT_EQ(2U, s[0]->InputCount()); | 579 EXPECT_EQ(2U, s[0]->InputCount()); |
546 EXPECT_EQ(1U, s[0]->OutputCount()); | 580 EXPECT_EQ(1U, s[0]->OutputCount()); |
547 } | 581 } |
548 { | 582 { |
549 StreamBuilder m(this, kMachInt32, kMachInt32); | 583 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
550 m.Return(m.Word32Xor(m.Int32Constant(-1), | 584 m.Return(m.Word32Xor(m.Int32Constant(-1), |
551 m.Word32Or(m.Parameter(0), m.Parameter(0)))); | 585 m.Word32Or(m.Parameter(0), m.Parameter(0)))); |
552 Stream s = m.Build(); | 586 Stream s = m.Build(); |
553 ASSERT_EQ(1U, s.size()); | 587 ASSERT_EQ(1U, s.size()); |
554 EXPECT_EQ(kMips64Nor, s[0]->arch_opcode()); | 588 EXPECT_EQ(kMips64Nor, s[0]->arch_opcode()); |
555 EXPECT_EQ(2U, s[0]->InputCount()); | 589 EXPECT_EQ(2U, s[0]->InputCount()); |
556 EXPECT_EQ(1U, s[0]->OutputCount()); | 590 EXPECT_EQ(1U, s[0]->OutputCount()); |
557 } | 591 } |
558 } | 592 } |
559 | 593 |
560 | 594 |
561 TEST_F(InstructionSelectorTest, Word32AndWithImmediateWithWord32Shr) { | 595 TEST_F(InstructionSelectorTest, Word32AndWithImmediateWithWord32Shr) { |
562 // The available shift operand range is `0 <= imm < 32`, but we also test | 596 // The available shift operand range is `0 <= imm < 32`, but we also test |
563 // that immediates outside this range are handled properly (modulo-32). | 597 // that immediates outside this range are handled properly (modulo-32). |
564 TRACED_FORRANGE(int32_t, shift, -32, 63) { | 598 TRACED_FORRANGE(int32_t, shift, -32, 63) { |
565 int32_t lsb = shift & 0x1f; | 599 int32_t lsb = shift & 0x1f; |
566 TRACED_FORRANGE(int32_t, width, 1, 31) { | 600 TRACED_FORRANGE(int32_t, width, 1, 31) { |
567 uint32_t msk = (1 << width) - 1; | 601 uint32_t msk = (1 << width) - 1; |
568 StreamBuilder m(this, kMachInt32, kMachInt32); | 602 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
569 m.Return(m.Word32And(m.Word32Shr(m.Parameter(0), m.Int32Constant(shift)), | 603 m.Return(m.Word32And(m.Word32Shr(m.Parameter(0), m.Int32Constant(shift)), |
570 m.Int32Constant(msk))); | 604 m.Int32Constant(msk))); |
571 Stream s = m.Build(); | 605 Stream s = m.Build(); |
572 ASSERT_EQ(1U, s.size()); | 606 ASSERT_EQ(1U, s.size()); |
573 EXPECT_EQ(kMips64Ext, s[0]->arch_opcode()); | 607 EXPECT_EQ(kMips64Ext, s[0]->arch_opcode()); |
574 ASSERT_EQ(3U, s[0]->InputCount()); | 608 ASSERT_EQ(3U, s[0]->InputCount()); |
575 EXPECT_EQ(lsb, s.ToInt32(s[0]->InputAt(1))); | 609 EXPECT_EQ(lsb, s.ToInt32(s[0]->InputAt(1))); |
576 int32_t actual_width = (lsb + width > 32) ? (32 - lsb) : width; | 610 int32_t actual_width = (lsb + width > 32) ? (32 - lsb) : width; |
577 EXPECT_EQ(actual_width, s.ToInt32(s[0]->InputAt(2))); | 611 EXPECT_EQ(actual_width, s.ToInt32(s[0]->InputAt(2))); |
578 } | 612 } |
579 } | 613 } |
580 TRACED_FORRANGE(int32_t, shift, -32, 63) { | 614 TRACED_FORRANGE(int32_t, shift, -32, 63) { |
581 int32_t lsb = shift & 0x1f; | 615 int32_t lsb = shift & 0x1f; |
582 TRACED_FORRANGE(int32_t, width, 1, 31) { | 616 TRACED_FORRANGE(int32_t, width, 1, 31) { |
583 uint32_t msk = (1 << width) - 1; | 617 uint32_t msk = (1 << width) - 1; |
584 StreamBuilder m(this, kMachInt32, kMachInt32); | 618 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
585 m.Return( | 619 m.Return( |
586 m.Word32And(m.Int32Constant(msk), | 620 m.Word32And(m.Int32Constant(msk), |
587 m.Word32Shr(m.Parameter(0), m.Int32Constant(shift)))); | 621 m.Word32Shr(m.Parameter(0), m.Int32Constant(shift)))); |
588 Stream s = m.Build(); | 622 Stream s = m.Build(); |
589 ASSERT_EQ(1U, s.size()); | 623 ASSERT_EQ(1U, s.size()); |
590 EXPECT_EQ(kMips64Ext, s[0]->arch_opcode()); | 624 EXPECT_EQ(kMips64Ext, s[0]->arch_opcode()); |
591 ASSERT_EQ(3U, s[0]->InputCount()); | 625 ASSERT_EQ(3U, s[0]->InputCount()); |
592 EXPECT_EQ(lsb, s.ToInt32(s[0]->InputAt(1))); | 626 EXPECT_EQ(lsb, s.ToInt32(s[0]->InputAt(1))); |
593 int32_t actual_width = (lsb + width > 32) ? (32 - lsb) : width; | 627 int32_t actual_width = (lsb + width > 32) ? (32 - lsb) : width; |
594 EXPECT_EQ(actual_width, s.ToInt32(s[0]->InputAt(2))); | 628 EXPECT_EQ(actual_width, s.ToInt32(s[0]->InputAt(2))); |
595 } | 629 } |
596 } | 630 } |
597 } | 631 } |
598 | 632 |
599 | 633 |
600 TEST_F(InstructionSelectorTest, Word64AndWithImmediateWithWord64Shr) { | 634 TEST_F(InstructionSelectorTest, Word64AndWithImmediateWithWord64Shr) { |
601 // The available shift operand range is `0 <= imm < 64`, but we also test | 635 // The available shift operand range is `0 <= imm < 64`, but we also test |
602 // that immediates outside this range are handled properly (modulo-64). | 636 // that immediates outside this range are handled properly (modulo-64). |
603 TRACED_FORRANGE(int64_t, shift, -64, 127) { | 637 TRACED_FORRANGE(int64_t, shift, -64, 127) { |
604 int64_t lsb = shift & 0x3f; | 638 int64_t lsb = shift & 0x3f; |
605 TRACED_FORRANGE(int64_t, width, 1, 63) { | 639 TRACED_FORRANGE(int64_t, width, 1, 63) { |
606 uint64_t msk = (V8_UINT64_C(1) << width) - 1; | 640 uint64_t msk = (V8_UINT64_C(1) << width) - 1; |
607 StreamBuilder m(this, kMachInt64, kMachInt64); | 641 StreamBuilder m(this, MachineType::Int64(), MachineType::Int64()); |
608 m.Return(m.Word64And(m.Word64Shr(m.Parameter(0), m.Int64Constant(shift)), | 642 m.Return(m.Word64And(m.Word64Shr(m.Parameter(0), m.Int64Constant(shift)), |
609 m.Int64Constant(msk))); | 643 m.Int64Constant(msk))); |
610 Stream s = m.Build(); | 644 Stream s = m.Build(); |
611 ASSERT_EQ(1U, s.size()); | 645 ASSERT_EQ(1U, s.size()); |
612 EXPECT_EQ(kMips64Dext, s[0]->arch_opcode()); | 646 EXPECT_EQ(kMips64Dext, s[0]->arch_opcode()); |
613 ASSERT_EQ(3U, s[0]->InputCount()); | 647 ASSERT_EQ(3U, s[0]->InputCount()); |
614 EXPECT_EQ(lsb, s.ToInt64(s[0]->InputAt(1))); | 648 EXPECT_EQ(lsb, s.ToInt64(s[0]->InputAt(1))); |
615 int64_t actual_width = (lsb + width > 64) ? (64 - lsb) : width; | 649 int64_t actual_width = (lsb + width > 64) ? (64 - lsb) : width; |
616 EXPECT_EQ(actual_width, s.ToInt64(s[0]->InputAt(2))); | 650 EXPECT_EQ(actual_width, s.ToInt64(s[0]->InputAt(2))); |
617 } | 651 } |
618 } | 652 } |
619 TRACED_FORRANGE(int64_t, shift, -64, 127) { | 653 TRACED_FORRANGE(int64_t, shift, -64, 127) { |
620 int64_t lsb = shift & 0x3f; | 654 int64_t lsb = shift & 0x3f; |
621 TRACED_FORRANGE(int64_t, width, 1, 63) { | 655 TRACED_FORRANGE(int64_t, width, 1, 63) { |
622 uint64_t msk = (V8_UINT64_C(1) << width) - 1; | 656 uint64_t msk = (V8_UINT64_C(1) << width) - 1; |
623 StreamBuilder m(this, kMachInt64, kMachInt64); | 657 StreamBuilder m(this, MachineType::Int64(), MachineType::Int64()); |
624 m.Return( | 658 m.Return( |
625 m.Word64And(m.Int64Constant(msk), | 659 m.Word64And(m.Int64Constant(msk), |
626 m.Word64Shr(m.Parameter(0), m.Int64Constant(shift)))); | 660 m.Word64Shr(m.Parameter(0), m.Int64Constant(shift)))); |
627 Stream s = m.Build(); | 661 Stream s = m.Build(); |
628 ASSERT_EQ(1U, s.size()); | 662 ASSERT_EQ(1U, s.size()); |
629 EXPECT_EQ(kMips64Dext, s[0]->arch_opcode()); | 663 EXPECT_EQ(kMips64Dext, s[0]->arch_opcode()); |
630 ASSERT_EQ(3U, s[0]->InputCount()); | 664 ASSERT_EQ(3U, s[0]->InputCount()); |
631 EXPECT_EQ(lsb, s.ToInt64(s[0]->InputAt(1))); | 665 EXPECT_EQ(lsb, s.ToInt64(s[0]->InputAt(1))); |
632 int64_t actual_width = (lsb + width > 64) ? (64 - lsb) : width; | 666 int64_t actual_width = (lsb + width > 64) ? (64 - lsb) : width; |
633 EXPECT_EQ(actual_width, s.ToInt64(s[0]->InputAt(2))); | 667 EXPECT_EQ(actual_width, s.ToInt64(s[0]->InputAt(2))); |
634 } | 668 } |
635 } | 669 } |
636 } | 670 } |
637 | 671 |
638 | 672 |
639 TEST_F(InstructionSelectorTest, Word32ShlWithWord32And) { | 673 TEST_F(InstructionSelectorTest, Word32ShlWithWord32And) { |
640 TRACED_FORRANGE(int32_t, shift, 0, 30) { | 674 TRACED_FORRANGE(int32_t, shift, 0, 30) { |
641 StreamBuilder m(this, kMachInt32, kMachInt32); | 675 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
642 Node* const p0 = m.Parameter(0); | 676 Node* const p0 = m.Parameter(0); |
643 Node* const r = | 677 Node* const r = |
644 m.Word32Shl(m.Word32And(p0, m.Int32Constant((1 << (31 - shift)) - 1)), | 678 m.Word32Shl(m.Word32And(p0, m.Int32Constant((1 << (31 - shift)) - 1)), |
645 m.Int32Constant(shift + 1)); | 679 m.Int32Constant(shift + 1)); |
646 m.Return(r); | 680 m.Return(r); |
647 Stream s = m.Build(); | 681 Stream s = m.Build(); |
648 ASSERT_EQ(1U, s.size()); | 682 ASSERT_EQ(1U, s.size()); |
649 EXPECT_EQ(kMips64Shl, s[0]->arch_opcode()); | 683 EXPECT_EQ(kMips64Shl, s[0]->arch_opcode()); |
650 ASSERT_EQ(2U, s[0]->InputCount()); | 684 ASSERT_EQ(2U, s[0]->InputCount()); |
651 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); | 685 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
652 ASSERT_EQ(1U, s[0]->OutputCount()); | 686 ASSERT_EQ(1U, s[0]->OutputCount()); |
653 EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output())); | 687 EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output())); |
654 } | 688 } |
655 } | 689 } |
656 | 690 |
657 | 691 |
658 TEST_F(InstructionSelectorTest, Word64ShlWithWord64And) { | 692 TEST_F(InstructionSelectorTest, Word64ShlWithWord64And) { |
659 TRACED_FORRANGE(int32_t, shift, 0, 62) { | 693 TRACED_FORRANGE(int32_t, shift, 0, 62) { |
660 StreamBuilder m(this, kMachInt64, kMachInt64); | 694 StreamBuilder m(this, MachineType::Int64(), MachineType::Int64()); |
661 Node* const p0 = m.Parameter(0); | 695 Node* const p0 = m.Parameter(0); |
662 Node* const r = | 696 Node* const r = |
663 m.Word64Shl(m.Word64And(p0, m.Int64Constant((1L << (63 - shift)) - 1)), | 697 m.Word64Shl(m.Word64And(p0, m.Int64Constant((1L << (63 - shift)) - 1)), |
664 m.Int64Constant(shift + 1)); | 698 m.Int64Constant(shift + 1)); |
665 m.Return(r); | 699 m.Return(r); |
666 Stream s = m.Build(); | 700 Stream s = m.Build(); |
667 ASSERT_EQ(1U, s.size()); | 701 ASSERT_EQ(1U, s.size()); |
668 EXPECT_EQ(kMips64Dshl, s[0]->arch_opcode()); | 702 EXPECT_EQ(kMips64Dshl, s[0]->arch_opcode()); |
669 ASSERT_EQ(2U, s[0]->InputCount()); | 703 ASSERT_EQ(2U, s[0]->InputCount()); |
670 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); | 704 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
796 EXPECT_EQ(1U, s[0]->InputCount()); | 830 EXPECT_EQ(1U, s[0]->InputCount()); |
797 EXPECT_EQ(1U, s[0]->OutputCount()); | 831 EXPECT_EQ(1U, s[0]->OutputCount()); |
798 } | 832 } |
799 | 833 |
800 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, | 834 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, |
801 InstructionSelectorConversionTest, | 835 InstructionSelectorConversionTest, |
802 ::testing::ValuesIn(kConversionInstructions)); | 836 ::testing::ValuesIn(kConversionInstructions)); |
803 | 837 |
804 TEST_F(InstructionSelectorTest, ChangesFromToSmi) { | 838 TEST_F(InstructionSelectorTest, ChangesFromToSmi) { |
805 { | 839 { |
806 StreamBuilder m(this, kMachInt32, kMachInt32); | 840 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
807 m.Return(m.TruncateInt64ToInt32( | 841 m.Return(m.TruncateInt64ToInt32( |
808 m.Word64Sar(m.Parameter(0), m.Int32Constant(32)))); | 842 m.Word64Sar(m.Parameter(0), m.Int32Constant(32)))); |
809 Stream s = m.Build(); | 843 Stream s = m.Build(); |
810 ASSERT_EQ(1U, s.size()); | 844 ASSERT_EQ(1U, s.size()); |
811 EXPECT_EQ(kMips64Dsar, s[0]->arch_opcode()); | 845 EXPECT_EQ(kMips64Dsar, s[0]->arch_opcode()); |
812 EXPECT_EQ(kMode_None, s[0]->addressing_mode()); | 846 EXPECT_EQ(kMode_None, s[0]->addressing_mode()); |
813 ASSERT_EQ(2U, s[0]->InputCount()); | 847 ASSERT_EQ(2U, s[0]->InputCount()); |
814 EXPECT_EQ(1U, s[0]->OutputCount()); | 848 EXPECT_EQ(1U, s[0]->OutputCount()); |
815 } | 849 } |
816 { | 850 { |
817 StreamBuilder m(this, kMachInt32, kMachInt32); | 851 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
818 m.Return( | 852 m.Return( |
819 m.Word64Shl(m.ChangeInt32ToInt64(m.Parameter(0)), m.Int32Constant(32))); | 853 m.Word64Shl(m.ChangeInt32ToInt64(m.Parameter(0)), m.Int32Constant(32))); |
820 Stream s = m.Build(); | 854 Stream s = m.Build(); |
821 ASSERT_EQ(1U, s.size()); | 855 ASSERT_EQ(1U, s.size()); |
822 EXPECT_EQ(kMips64Dshl, s[0]->arch_opcode()); | 856 EXPECT_EQ(kMips64Dshl, s[0]->arch_opcode()); |
823 ASSERT_EQ(2U, s[0]->InputCount()); | 857 ASSERT_EQ(2U, s[0]->InputCount()); |
824 EXPECT_EQ(1U, s[0]->OutputCount()); | 858 EXPECT_EQ(1U, s[0]->OutputCount()); |
825 } | 859 } |
826 } | 860 } |
827 | 861 |
(...skipping 15 matching lines...) Expand all Loading... |
843 } | 877 } |
844 } | 878 } |
845 | 879 |
846 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, | 880 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, |
847 CombineChangeFloat64ToInt32WithRoundFloat64, | 881 CombineChangeFloat64ToInt32WithRoundFloat64, |
848 ::testing::ValuesIn(kFloat64RoundInstructions)); | 882 ::testing::ValuesIn(kFloat64RoundInstructions)); |
849 | 883 |
850 | 884 |
851 TEST_F(InstructionSelectorTest, CombineShiftsWithMul) { | 885 TEST_F(InstructionSelectorTest, CombineShiftsWithMul) { |
852 { | 886 { |
853 StreamBuilder m(this, kMachInt32, kMachInt32); | 887 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
854 m.Return(m.Int32Mul(m.Word64Sar(m.Parameter(0), m.Int32Constant(32)), | 888 m.Return(m.Int32Mul(m.Word64Sar(m.Parameter(0), m.Int32Constant(32)), |
855 m.Word64Sar(m.Parameter(0), m.Int32Constant(32)))); | 889 m.Word64Sar(m.Parameter(0), m.Int32Constant(32)))); |
856 Stream s = m.Build(); | 890 Stream s = m.Build(); |
857 ASSERT_EQ(1U, s.size()); | 891 ASSERT_EQ(1U, s.size()); |
858 EXPECT_EQ(kMips64DMulHigh, s[0]->arch_opcode()); | 892 EXPECT_EQ(kMips64DMulHigh, s[0]->arch_opcode()); |
859 EXPECT_EQ(kMode_None, s[0]->addressing_mode()); | 893 EXPECT_EQ(kMode_None, s[0]->addressing_mode()); |
860 ASSERT_EQ(2U, s[0]->InputCount()); | 894 ASSERT_EQ(2U, s[0]->InputCount()); |
861 EXPECT_EQ(1U, s[0]->OutputCount()); | 895 EXPECT_EQ(1U, s[0]->OutputCount()); |
862 } | 896 } |
863 } | 897 } |
864 | 898 |
865 | 899 |
866 TEST_F(InstructionSelectorTest, CombineShiftsWithDivMod) { | 900 TEST_F(InstructionSelectorTest, CombineShiftsWithDivMod) { |
867 { | 901 { |
868 StreamBuilder m(this, kMachInt32, kMachInt32); | 902 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
869 m.Return(m.Int32Div(m.Word64Sar(m.Parameter(0), m.Int32Constant(32)), | 903 m.Return(m.Int32Div(m.Word64Sar(m.Parameter(0), m.Int32Constant(32)), |
870 m.Word64Sar(m.Parameter(0), m.Int32Constant(32)))); | 904 m.Word64Sar(m.Parameter(0), m.Int32Constant(32)))); |
871 Stream s = m.Build(); | 905 Stream s = m.Build(); |
872 ASSERT_EQ(1U, s.size()); | 906 ASSERT_EQ(1U, s.size()); |
873 EXPECT_EQ(kMips64Ddiv, s[0]->arch_opcode()); | 907 EXPECT_EQ(kMips64Ddiv, s[0]->arch_opcode()); |
874 EXPECT_EQ(kMode_None, s[0]->addressing_mode()); | 908 EXPECT_EQ(kMode_None, s[0]->addressing_mode()); |
875 ASSERT_EQ(2U, s[0]->InputCount()); | 909 ASSERT_EQ(2U, s[0]->InputCount()); |
876 EXPECT_EQ(1U, s[0]->OutputCount()); | 910 EXPECT_EQ(1U, s[0]->OutputCount()); |
877 } | 911 } |
878 { | 912 { |
879 StreamBuilder m(this, kMachInt32, kMachInt32); | 913 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
880 m.Return(m.Int32Mod(m.Word64Sar(m.Parameter(0), m.Int32Constant(32)), | 914 m.Return(m.Int32Mod(m.Word64Sar(m.Parameter(0), m.Int32Constant(32)), |
881 m.Word64Sar(m.Parameter(0), m.Int32Constant(32)))); | 915 m.Word64Sar(m.Parameter(0), m.Int32Constant(32)))); |
882 Stream s = m.Build(); | 916 Stream s = m.Build(); |
883 ASSERT_EQ(1U, s.size()); | 917 ASSERT_EQ(1U, s.size()); |
884 EXPECT_EQ(kMips64Dmod, s[0]->arch_opcode()); | 918 EXPECT_EQ(kMips64Dmod, s[0]->arch_opcode()); |
885 EXPECT_EQ(kMode_None, s[0]->addressing_mode()); | 919 EXPECT_EQ(kMode_None, s[0]->addressing_mode()); |
886 ASSERT_EQ(2U, s[0]->InputCount()); | 920 ASSERT_EQ(2U, s[0]->InputCount()); |
887 EXPECT_EQ(1U, s[0]->OutputCount()); | 921 EXPECT_EQ(1U, s[0]->OutputCount()); |
888 } | 922 } |
889 } | 923 } |
890 | 924 |
891 | 925 |
892 // ---------------------------------------------------------------------------- | 926 // ---------------------------------------------------------------------------- |
893 // Loads and stores. | 927 // Loads and stores. |
894 // ---------------------------------------------------------------------------- | 928 // ---------------------------------------------------------------------------- |
895 | 929 |
896 | 930 |
897 namespace { | 931 namespace { |
898 | 932 |
899 struct MemoryAccess { | 933 struct MemoryAccess { |
900 MachineType type; | 934 MachineType type; |
901 ArchOpcode load_opcode; | 935 ArchOpcode load_opcode; |
902 ArchOpcode store_opcode; | 936 ArchOpcode store_opcode; |
903 }; | 937 }; |
904 | 938 |
905 static const MemoryAccess kMemoryAccesses[] = { | 939 static const MemoryAccess kMemoryAccesses[] = { |
906 {kMachInt8, kMips64Lb, kMips64Sb}, | 940 {MachineType::Int8(), kMips64Lb, kMips64Sb}, |
907 {kMachUint8, kMips64Lbu, kMips64Sb}, | 941 {MachineType::Uint8(), kMips64Lbu, kMips64Sb}, |
908 {kMachInt16, kMips64Lh, kMips64Sh}, | 942 {MachineType::Int16(), kMips64Lh, kMips64Sh}, |
909 {kMachUint16, kMips64Lhu, kMips64Sh}, | 943 {MachineType::Uint16(), kMips64Lhu, kMips64Sh}, |
910 {kMachInt32, kMips64Lw, kMips64Sw}, | 944 {MachineType::Int32(), kMips64Lw, kMips64Sw}, |
911 {kMachFloat32, kMips64Lwc1, kMips64Swc1}, | 945 {MachineType::Float32(), kMips64Lwc1, kMips64Swc1}, |
912 {kMachFloat64, kMips64Ldc1, kMips64Sdc1}, | 946 {MachineType::Float64(), kMips64Ldc1, kMips64Sdc1}, |
913 {kMachInt64, kMips64Ld, kMips64Sd}}; | 947 {MachineType::Int64(), kMips64Ld, kMips64Sd}}; |
914 | 948 |
915 | 949 |
916 struct MemoryAccessImm { | 950 struct MemoryAccessImm { |
917 MachineType type; | 951 MachineType type; |
918 ArchOpcode load_opcode; | 952 ArchOpcode load_opcode; |
919 ArchOpcode store_opcode; | 953 ArchOpcode store_opcode; |
920 bool (InstructionSelectorTest::Stream::*val_predicate)( | 954 bool (InstructionSelectorTest::Stream::*val_predicate)( |
921 const InstructionOperand*) const; | 955 const InstructionOperand*) const; |
922 const int32_t immediates[40]; | 956 const int32_t immediates[40]; |
923 }; | 957 }; |
(...skipping 18 matching lines...) Expand all Loading... |
942 return os << acc.type; | 976 return os << acc.type; |
943 } | 977 } |
944 | 978 |
945 | 979 |
946 // ---------------------------------------------------------------------------- | 980 // ---------------------------------------------------------------------------- |
947 // Loads and stores immediate values | 981 // Loads and stores immediate values |
948 // ---------------------------------------------------------------------------- | 982 // ---------------------------------------------------------------------------- |
949 | 983 |
950 | 984 |
951 const MemoryAccessImm kMemoryAccessesImm[] = { | 985 const MemoryAccessImm kMemoryAccessesImm[] = { |
952 {kMachInt8, | 986 {MachineType::Int8(), |
953 kMips64Lb, | 987 kMips64Lb, |
954 kMips64Sb, | 988 kMips64Sb, |
955 &InstructionSelectorTest::Stream::IsInteger, | 989 &InstructionSelectorTest::Stream::IsInteger, |
956 {-4095, -3340, -3231, -3224, -3088, -1758, -1203, -123, -117, -91, -89, | 990 {-4095, -3340, -3231, -3224, -3088, -1758, -1203, -123, -117, -91, -89, |
957 -87, -86, -82, -44, -23, -3, 0, 7, 10, 39, 52, 69, 71, 91, 92, 107, 109, | 991 -87, -86, -82, -44, -23, -3, 0, 7, 10, 39, 52, 69, 71, 91, 92, 107, 109, |
958 115, 124, 286, 655, 1362, 1569, 2587, 3067, 3096, 3462, 3510, 4095}}, | 992 115, 124, 286, 655, 1362, 1569, 2587, 3067, 3096, 3462, 3510, 4095}}, |
959 {kMachUint8, | 993 {MachineType::Uint8(), |
960 kMips64Lbu, | 994 kMips64Lbu, |
961 kMips64Sb, | 995 kMips64Sb, |
962 &InstructionSelectorTest::Stream::IsInteger, | 996 &InstructionSelectorTest::Stream::IsInteger, |
963 {-4095, -3340, -3231, -3224, -3088, -1758, -1203, -123, -117, -91, -89, | 997 {-4095, -3340, -3231, -3224, -3088, -1758, -1203, -123, -117, -91, -89, |
964 -87, -86, -82, -44, -23, -3, 0, 7, 10, 39, 52, 69, 71, 91, 92, 107, 109, | 998 -87, -86, -82, -44, -23, -3, 0, 7, 10, 39, 52, 69, 71, 91, 92, 107, 109, |
965 115, 124, 286, 655, 1362, 1569, 2587, 3067, 3096, 3462, 3510, 4095}}, | 999 115, 124, 286, 655, 1362, 1569, 2587, 3067, 3096, 3462, 3510, 4095}}, |
966 {kMachInt16, | 1000 {MachineType::Int16(), |
967 kMips64Lh, | 1001 kMips64Lh, |
968 kMips64Sh, | 1002 kMips64Sh, |
969 &InstructionSelectorTest::Stream::IsInteger, | 1003 &InstructionSelectorTest::Stream::IsInteger, |
970 {-4095, -3340, -3231, -3224, -3088, -1758, -1203, -123, -117, -91, -89, | 1004 {-4095, -3340, -3231, -3224, -3088, -1758, -1203, -123, -117, -91, -89, |
971 -87, -86, -82, -44, -23, -3, 0, 7, 10, 39, 52, 69, 71, 91, 92, 107, 109, | 1005 -87, -86, -82, -44, -23, -3, 0, 7, 10, 39, 52, 69, 71, 91, 92, 107, 109, |
972 115, 124, 286, 655, 1362, 1569, 2587, 3067, 3096, 3462, 3510, 4095}}, | 1006 115, 124, 286, 655, 1362, 1569, 2587, 3067, 3096, 3462, 3510, 4095}}, |
973 {kMachUint16, | 1007 {MachineType::Uint16(), |
974 kMips64Lhu, | 1008 kMips64Lhu, |
975 kMips64Sh, | 1009 kMips64Sh, |
976 &InstructionSelectorTest::Stream::IsInteger, | 1010 &InstructionSelectorTest::Stream::IsInteger, |
977 {-4095, -3340, -3231, -3224, -3088, -1758, -1203, -123, -117, -91, -89, | 1011 {-4095, -3340, -3231, -3224, -3088, -1758, -1203, -123, -117, -91, -89, |
978 -87, -86, -82, -44, -23, -3, 0, 7, 10, 39, 52, 69, 71, 91, 92, 107, 109, | 1012 -87, -86, -82, -44, -23, -3, 0, 7, 10, 39, 52, 69, 71, 91, 92, 107, 109, |
979 115, 124, 286, 655, 1362, 1569, 2587, 3067, 3096, 3462, 3510, 4095}}, | 1013 115, 124, 286, 655, 1362, 1569, 2587, 3067, 3096, 3462, 3510, 4095}}, |
980 {kMachInt32, | 1014 {MachineType::Int32(), |
981 kMips64Lw, | 1015 kMips64Lw, |
982 kMips64Sw, | 1016 kMips64Sw, |
983 &InstructionSelectorTest::Stream::IsInteger, | 1017 &InstructionSelectorTest::Stream::IsInteger, |
984 {-4095, -3340, -3231, -3224, -3088, -1758, -1203, -123, -117, -91, -89, | 1018 {-4095, -3340, -3231, -3224, -3088, -1758, -1203, -123, -117, -91, -89, |
985 -87, -86, -82, -44, -23, -3, 0, 7, 10, 39, 52, 69, 71, 91, 92, 107, 109, | 1019 -87, -86, -82, -44, -23, -3, 0, 7, 10, 39, 52, 69, 71, 91, 92, 107, 109, |
986 115, 124, 286, 655, 1362, 1569, 2587, 3067, 3096, 3462, 3510, 4095}}, | 1020 115, 124, 286, 655, 1362, 1569, 2587, 3067, 3096, 3462, 3510, 4095}}, |
987 {kMachFloat32, | 1021 {MachineType::Float32(), |
988 kMips64Lwc1, | 1022 kMips64Lwc1, |
989 kMips64Swc1, | 1023 kMips64Swc1, |
990 &InstructionSelectorTest::Stream::IsDouble, | 1024 &InstructionSelectorTest::Stream::IsDouble, |
991 {-4095, -3340, -3231, -3224, -3088, -1758, -1203, -123, -117, -91, -89, | 1025 {-4095, -3340, -3231, -3224, -3088, -1758, -1203, -123, -117, -91, -89, |
992 -87, -86, -82, -44, -23, -3, 0, 7, 10, 39, 52, 69, 71, 91, 92, 107, 109, | 1026 -87, -86, -82, -44, -23, -3, 0, 7, 10, 39, 52, 69, 71, 91, 92, 107, 109, |
993 115, 124, 286, 655, 1362, 1569, 2587, 3067, 3096, 3462, 3510, 4095}}, | 1027 115, 124, 286, 655, 1362, 1569, 2587, 3067, 3096, 3462, 3510, 4095}}, |
994 {kMachFloat64, | 1028 {MachineType::Float64(), |
995 kMips64Ldc1, | 1029 kMips64Ldc1, |
996 kMips64Sdc1, | 1030 kMips64Sdc1, |
997 &InstructionSelectorTest::Stream::IsDouble, | 1031 &InstructionSelectorTest::Stream::IsDouble, |
998 {-4095, -3340, -3231, -3224, -3088, -1758, -1203, -123, -117, -91, -89, | 1032 {-4095, -3340, -3231, -3224, -3088, -1758, -1203, -123, -117, -91, -89, |
999 -87, -86, -82, -44, -23, -3, 0, 7, 10, 39, 52, 69, 71, 91, 92, 107, 109, | 1033 -87, -86, -82, -44, -23, -3, 0, 7, 10, 39, 52, 69, 71, 91, 92, 107, 109, |
1000 115, 124, 286, 655, 1362, 1569, 2587, 3067, 3096, 3462, 3510, 4095}}, | 1034 115, 124, 286, 655, 1362, 1569, 2587, 3067, 3096, 3462, 3510, 4095}}, |
1001 {kMachInt64, | 1035 {MachineType::Int64(), |
1002 kMips64Ld, | 1036 kMips64Ld, |
1003 kMips64Sd, | 1037 kMips64Sd, |
1004 &InstructionSelectorTest::Stream::IsInteger, | 1038 &InstructionSelectorTest::Stream::IsInteger, |
1005 {-4095, -3340, -3231, -3224, -3088, -1758, -1203, -123, -117, -91, -89, | 1039 {-4095, -3340, -3231, -3224, -3088, -1758, -1203, -123, -117, -91, -89, |
1006 -87, -86, -82, -44, -23, -3, 0, 7, 10, 39, 52, 69, 71, 91, 92, 107, 109, | 1040 -87, -86, -82, -44, -23, -3, 0, 7, 10, 39, 52, 69, 71, 91, 92, 107, 109, |
1007 115, 124, 286, 655, 1362, 1569, 2587, 3067, 3096, 3462, 3510, 4095}}}; | 1041 115, 124, 286, 655, 1362, 1569, 2587, 3067, 3096, 3462, 3510, 4095}}}; |
1008 | 1042 |
1009 | 1043 |
1010 const MemoryAccessImm1 kMemoryAccessImmMoreThan16bit[] = { | 1044 const MemoryAccessImm1 kMemoryAccessImmMoreThan16bit[] = { |
1011 {kMachInt8, | 1045 {MachineType::Int8(), |
1012 kMips64Lb, | 1046 kMips64Lb, |
1013 kMips64Sb, | 1047 kMips64Sb, |
1014 &InstructionSelectorTest::Stream::IsInteger, | 1048 &InstructionSelectorTest::Stream::IsInteger, |
1015 {-65000, -55000, 32777, 55000, 65000}}, | 1049 {-65000, -55000, 32777, 55000, 65000}}, |
1016 {kMachInt8, | 1050 {MachineType::Int8(), |
1017 kMips64Lbu, | 1051 kMips64Lbu, |
1018 kMips64Sb, | 1052 kMips64Sb, |
1019 &InstructionSelectorTest::Stream::IsInteger, | 1053 &InstructionSelectorTest::Stream::IsInteger, |
1020 {-65000, -55000, 32777, 55000, 65000}}, | 1054 {-65000, -55000, 32777, 55000, 65000}}, |
1021 {kMachInt16, | 1055 {MachineType::Int16(), |
1022 kMips64Lh, | 1056 kMips64Lh, |
1023 kMips64Sh, | 1057 kMips64Sh, |
1024 &InstructionSelectorTest::Stream::IsInteger, | 1058 &InstructionSelectorTest::Stream::IsInteger, |
1025 {-65000, -55000, 32777, 55000, 65000}}, | 1059 {-65000, -55000, 32777, 55000, 65000}}, |
1026 {kMachInt16, | 1060 {MachineType::Int16(), |
1027 kMips64Lhu, | 1061 kMips64Lhu, |
1028 kMips64Sh, | 1062 kMips64Sh, |
1029 &InstructionSelectorTest::Stream::IsInteger, | 1063 &InstructionSelectorTest::Stream::IsInteger, |
1030 {-65000, -55000, 32777, 55000, 65000}}, | 1064 {-65000, -55000, 32777, 55000, 65000}}, |
1031 {kMachInt32, | 1065 {MachineType::Int32(), |
1032 kMips64Lw, | 1066 kMips64Lw, |
1033 kMips64Sw, | 1067 kMips64Sw, |
1034 &InstructionSelectorTest::Stream::IsInteger, | 1068 &InstructionSelectorTest::Stream::IsInteger, |
1035 {-65000, -55000, 32777, 55000, 65000}}, | 1069 {-65000, -55000, 32777, 55000, 65000}}, |
1036 {kMachFloat32, | 1070 {MachineType::Float32(), |
1037 kMips64Lwc1, | 1071 kMips64Lwc1, |
1038 kMips64Swc1, | 1072 kMips64Swc1, |
1039 &InstructionSelectorTest::Stream::IsDouble, | 1073 &InstructionSelectorTest::Stream::IsDouble, |
1040 {-65000, -55000, 32777, 55000, 65000}}, | 1074 {-65000, -55000, 32777, 55000, 65000}}, |
1041 {kMachFloat64, | 1075 {MachineType::Float64(), |
1042 kMips64Ldc1, | 1076 kMips64Ldc1, |
1043 kMips64Sdc1, | 1077 kMips64Sdc1, |
1044 &InstructionSelectorTest::Stream::IsDouble, | 1078 &InstructionSelectorTest::Stream::IsDouble, |
1045 {-65000, -55000, 32777, 55000, 65000}}, | 1079 {-65000, -55000, 32777, 55000, 65000}}, |
1046 {kMachInt64, | 1080 {MachineType::Int64(), |
1047 kMips64Ld, | 1081 kMips64Ld, |
1048 kMips64Sd, | 1082 kMips64Sd, |
1049 &InstructionSelectorTest::Stream::IsInteger, | 1083 &InstructionSelectorTest::Stream::IsInteger, |
1050 {-65000, -55000, 32777, 55000, 65000}}}; | 1084 {-65000, -55000, 32777, 55000, 65000}}}; |
1051 | 1085 |
1052 } // namespace | 1086 } // namespace |
1053 | 1087 |
1054 | 1088 |
1055 typedef InstructionSelectorTestWithParam<MemoryAccess> | 1089 typedef InstructionSelectorTestWithParam<MemoryAccess> |
1056 InstructionSelectorMemoryAccessTest; | 1090 InstructionSelectorMemoryAccessTest; |
1057 | 1091 |
1058 TEST_P(InstructionSelectorMemoryAccessTest, LoadWithParameters) { | 1092 TEST_P(InstructionSelectorMemoryAccessTest, LoadWithParameters) { |
1059 const MemoryAccess memacc = GetParam(); | 1093 const MemoryAccess memacc = GetParam(); |
1060 StreamBuilder m(this, memacc.type, kMachPtr, kMachInt32); | 1094 StreamBuilder m(this, memacc.type, MachineType::Pointer(), |
| 1095 MachineType::Int32()); |
1061 m.Return(m.Load(memacc.type, m.Parameter(0))); | 1096 m.Return(m.Load(memacc.type, m.Parameter(0))); |
1062 Stream s = m.Build(); | 1097 Stream s = m.Build(); |
1063 ASSERT_EQ(1U, s.size()); | 1098 ASSERT_EQ(1U, s.size()); |
1064 EXPECT_EQ(memacc.load_opcode, s[0]->arch_opcode()); | 1099 EXPECT_EQ(memacc.load_opcode, s[0]->arch_opcode()); |
1065 EXPECT_EQ(kMode_MRI, s[0]->addressing_mode()); | 1100 EXPECT_EQ(kMode_MRI, s[0]->addressing_mode()); |
1066 } | 1101 } |
1067 | 1102 |
1068 | 1103 |
1069 TEST_P(InstructionSelectorMemoryAccessTest, StoreWithParameters) { | 1104 TEST_P(InstructionSelectorMemoryAccessTest, StoreWithParameters) { |
1070 const MemoryAccess memacc = GetParam(); | 1105 const MemoryAccess memacc = GetParam(); |
1071 StreamBuilder m(this, kMachInt32, kMachPtr, kMachInt32, memacc.type); | 1106 StreamBuilder m(this, MachineType::Int32(), MachineType::Pointer(), |
| 1107 MachineType::Int32(), memacc.type); |
1072 m.Store(memacc.type, m.Parameter(0), m.Parameter(1), kNoWriteBarrier); | 1108 m.Store(memacc.type, m.Parameter(0), m.Parameter(1), kNoWriteBarrier); |
1073 m.Return(m.Int32Constant(0)); | 1109 m.Return(m.Int32Constant(0)); |
1074 Stream s = m.Build(); | 1110 Stream s = m.Build(); |
1075 ASSERT_EQ(1U, s.size()); | 1111 ASSERT_EQ(1U, s.size()); |
1076 EXPECT_EQ(memacc.store_opcode, s[0]->arch_opcode()); | 1112 EXPECT_EQ(memacc.store_opcode, s[0]->arch_opcode()); |
1077 EXPECT_EQ(kMode_MRI, s[0]->addressing_mode()); | 1113 EXPECT_EQ(kMode_MRI, s[0]->addressing_mode()); |
1078 } | 1114 } |
1079 | 1115 |
1080 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, | 1116 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, |
1081 InstructionSelectorMemoryAccessTest, | 1117 InstructionSelectorMemoryAccessTest, |
1082 ::testing::ValuesIn(kMemoryAccesses)); | 1118 ::testing::ValuesIn(kMemoryAccesses)); |
1083 | 1119 |
1084 | 1120 |
1085 // ---------------------------------------------------------------------------- | 1121 // ---------------------------------------------------------------------------- |
1086 // Load immediate. | 1122 // Load immediate. |
1087 // ---------------------------------------------------------------------------- | 1123 // ---------------------------------------------------------------------------- |
1088 | 1124 |
1089 | 1125 |
1090 typedef InstructionSelectorTestWithParam<MemoryAccessImm> | 1126 typedef InstructionSelectorTestWithParam<MemoryAccessImm> |
1091 InstructionSelectorMemoryAccessImmTest; | 1127 InstructionSelectorMemoryAccessImmTest; |
1092 | 1128 |
1093 TEST_P(InstructionSelectorMemoryAccessImmTest, LoadWithImmediateIndex) { | 1129 TEST_P(InstructionSelectorMemoryAccessImmTest, LoadWithImmediateIndex) { |
1094 const MemoryAccessImm memacc = GetParam(); | 1130 const MemoryAccessImm memacc = GetParam(); |
1095 TRACED_FOREACH(int32_t, index, memacc.immediates) { | 1131 TRACED_FOREACH(int32_t, index, memacc.immediates) { |
1096 StreamBuilder m(this, memacc.type, kMachPtr); | 1132 StreamBuilder m(this, memacc.type, MachineType::Pointer()); |
1097 m.Return(m.Load(memacc.type, m.Parameter(0), m.Int32Constant(index))); | 1133 m.Return(m.Load(memacc.type, m.Parameter(0), m.Int32Constant(index))); |
1098 Stream s = m.Build(); | 1134 Stream s = m.Build(); |
1099 ASSERT_EQ(1U, s.size()); | 1135 ASSERT_EQ(1U, s.size()); |
1100 EXPECT_EQ(memacc.load_opcode, s[0]->arch_opcode()); | 1136 EXPECT_EQ(memacc.load_opcode, s[0]->arch_opcode()); |
1101 EXPECT_EQ(kMode_MRI, s[0]->addressing_mode()); | 1137 EXPECT_EQ(kMode_MRI, s[0]->addressing_mode()); |
1102 ASSERT_EQ(2U, s[0]->InputCount()); | 1138 ASSERT_EQ(2U, s[0]->InputCount()); |
1103 ASSERT_EQ(InstructionOperand::IMMEDIATE, s[0]->InputAt(1)->kind()); | 1139 ASSERT_EQ(InstructionOperand::IMMEDIATE, s[0]->InputAt(1)->kind()); |
1104 EXPECT_EQ(index, s.ToInt32(s[0]->InputAt(1))); | 1140 EXPECT_EQ(index, s.ToInt32(s[0]->InputAt(1))); |
1105 ASSERT_EQ(1U, s[0]->OutputCount()); | 1141 ASSERT_EQ(1U, s[0]->OutputCount()); |
1106 EXPECT_TRUE((s.*memacc.val_predicate)(s[0]->Output())); | 1142 EXPECT_TRUE((s.*memacc.val_predicate)(s[0]->Output())); |
1107 } | 1143 } |
1108 } | 1144 } |
1109 | 1145 |
1110 | 1146 |
1111 // ---------------------------------------------------------------------------- | 1147 // ---------------------------------------------------------------------------- |
1112 // Store immediate. | 1148 // Store immediate. |
1113 // ---------------------------------------------------------------------------- | 1149 // ---------------------------------------------------------------------------- |
1114 | 1150 |
1115 | 1151 |
1116 TEST_P(InstructionSelectorMemoryAccessImmTest, StoreWithImmediateIndex) { | 1152 TEST_P(InstructionSelectorMemoryAccessImmTest, StoreWithImmediateIndex) { |
1117 const MemoryAccessImm memacc = GetParam(); | 1153 const MemoryAccessImm memacc = GetParam(); |
1118 TRACED_FOREACH(int32_t, index, memacc.immediates) { | 1154 TRACED_FOREACH(int32_t, index, memacc.immediates) { |
1119 StreamBuilder m(this, kMachInt32, kMachPtr, memacc.type); | 1155 StreamBuilder m(this, MachineType::Int32(), MachineType::Pointer(), |
| 1156 memacc.type); |
1120 m.Store(memacc.type, m.Parameter(0), m.Int32Constant(index), m.Parameter(1), | 1157 m.Store(memacc.type, m.Parameter(0), m.Int32Constant(index), m.Parameter(1), |
1121 kNoWriteBarrier); | 1158 kNoWriteBarrier); |
1122 m.Return(m.Int32Constant(0)); | 1159 m.Return(m.Int32Constant(0)); |
1123 Stream s = m.Build(); | 1160 Stream s = m.Build(); |
1124 ASSERT_EQ(1U, s.size()); | 1161 ASSERT_EQ(1U, s.size()); |
1125 EXPECT_EQ(memacc.store_opcode, s[0]->arch_opcode()); | 1162 EXPECT_EQ(memacc.store_opcode, s[0]->arch_opcode()); |
1126 EXPECT_EQ(kMode_MRI, s[0]->addressing_mode()); | 1163 EXPECT_EQ(kMode_MRI, s[0]->addressing_mode()); |
1127 ASSERT_EQ(3U, s[0]->InputCount()); | 1164 ASSERT_EQ(3U, s[0]->InputCount()); |
1128 ASSERT_EQ(InstructionOperand::IMMEDIATE, s[0]->InputAt(1)->kind()); | 1165 ASSERT_EQ(InstructionOperand::IMMEDIATE, s[0]->InputAt(1)->kind()); |
1129 EXPECT_EQ(index, s.ToInt32(s[0]->InputAt(1))); | 1166 EXPECT_EQ(index, s.ToInt32(s[0]->InputAt(1))); |
(...skipping 11 matching lines...) Expand all Loading... |
1141 // ---------------------------------------------------------------------------- | 1178 // ---------------------------------------------------------------------------- |
1142 | 1179 |
1143 | 1180 |
1144 typedef InstructionSelectorTestWithParam<MemoryAccessImm1> | 1181 typedef InstructionSelectorTestWithParam<MemoryAccessImm1> |
1145 InstructionSelectorMemoryAccessImmMoreThan16bitTest; | 1182 InstructionSelectorMemoryAccessImmMoreThan16bitTest; |
1146 | 1183 |
1147 TEST_P(InstructionSelectorMemoryAccessImmMoreThan16bitTest, | 1184 TEST_P(InstructionSelectorMemoryAccessImmMoreThan16bitTest, |
1148 LoadWithImmediateIndex) { | 1185 LoadWithImmediateIndex) { |
1149 const MemoryAccessImm1 memacc = GetParam(); | 1186 const MemoryAccessImm1 memacc = GetParam(); |
1150 TRACED_FOREACH(int32_t, index, memacc.immediates) { | 1187 TRACED_FOREACH(int32_t, index, memacc.immediates) { |
1151 StreamBuilder m(this, memacc.type, kMachPtr); | 1188 StreamBuilder m(this, memacc.type, MachineType::Pointer()); |
1152 m.Return(m.Load(memacc.type, m.Parameter(0), m.Int32Constant(index))); | 1189 m.Return(m.Load(memacc.type, m.Parameter(0), m.Int32Constant(index))); |
1153 Stream s = m.Build(); | 1190 Stream s = m.Build(); |
1154 ASSERT_EQ(2U, s.size()); | 1191 ASSERT_EQ(2U, s.size()); |
1155 // kMips64Dadd is expected opcode | 1192 // kMips64Dadd is expected opcode |
1156 // size more than 16 bits wide | 1193 // size more than 16 bits wide |
1157 EXPECT_EQ(kMips64Dadd, s[0]->arch_opcode()); | 1194 EXPECT_EQ(kMips64Dadd, s[0]->arch_opcode()); |
1158 EXPECT_EQ(kMode_None, s[0]->addressing_mode()); | 1195 EXPECT_EQ(kMode_None, s[0]->addressing_mode()); |
1159 EXPECT_EQ(2U, s[0]->InputCount()); | 1196 EXPECT_EQ(2U, s[0]->InputCount()); |
1160 EXPECT_EQ(1U, s[0]->OutputCount()); | 1197 EXPECT_EQ(1U, s[0]->OutputCount()); |
1161 } | 1198 } |
1162 } | 1199 } |
1163 | 1200 |
1164 TEST_P(InstructionSelectorMemoryAccessImmMoreThan16bitTest, | 1201 TEST_P(InstructionSelectorMemoryAccessImmMoreThan16bitTest, |
1165 StoreWithImmediateIndex) { | 1202 StoreWithImmediateIndex) { |
1166 const MemoryAccessImm1 memacc = GetParam(); | 1203 const MemoryAccessImm1 memacc = GetParam(); |
1167 TRACED_FOREACH(int32_t, index, memacc.immediates) { | 1204 TRACED_FOREACH(int32_t, index, memacc.immediates) { |
1168 StreamBuilder m(this, kMachInt32, kMachPtr, memacc.type); | 1205 StreamBuilder m(this, MachineType::Int32(), MachineType::Pointer(), |
| 1206 memacc.type); |
1169 m.Store(memacc.type, m.Parameter(0), m.Int32Constant(index), m.Parameter(1), | 1207 m.Store(memacc.type, m.Parameter(0), m.Int32Constant(index), m.Parameter(1), |
1170 kNoWriteBarrier); | 1208 kNoWriteBarrier); |
1171 m.Return(m.Int32Constant(0)); | 1209 m.Return(m.Int32Constant(0)); |
1172 Stream s = m.Build(); | 1210 Stream s = m.Build(); |
1173 ASSERT_EQ(2U, s.size()); | 1211 ASSERT_EQ(2U, s.size()); |
1174 // kMips64Add is expected opcode | 1212 // kMips64Add is expected opcode |
1175 // size more than 16 bits wide | 1213 // size more than 16 bits wide |
1176 EXPECT_EQ(kMips64Dadd, s[0]->arch_opcode()); | 1214 EXPECT_EQ(kMips64Dadd, s[0]->arch_opcode()); |
1177 EXPECT_EQ(kMode_None, s[0]->addressing_mode()); | 1215 EXPECT_EQ(kMode_None, s[0]->addressing_mode()); |
1178 EXPECT_EQ(2U, s[0]->InputCount()); | 1216 EXPECT_EQ(2U, s[0]->InputCount()); |
1179 EXPECT_EQ(1U, s[0]->OutputCount()); | 1217 EXPECT_EQ(1U, s[0]->OutputCount()); |
1180 } | 1218 } |
1181 } | 1219 } |
1182 | 1220 |
1183 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, | 1221 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, |
1184 InstructionSelectorMemoryAccessImmMoreThan16bitTest, | 1222 InstructionSelectorMemoryAccessImmMoreThan16bitTest, |
1185 ::testing::ValuesIn(kMemoryAccessImmMoreThan16bit)); | 1223 ::testing::ValuesIn(kMemoryAccessImmMoreThan16bit)); |
1186 | 1224 |
1187 | 1225 |
1188 // ---------------------------------------------------------------------------- | 1226 // ---------------------------------------------------------------------------- |
1189 // kMips64Cmp with zero testing. | 1227 // kMips64Cmp with zero testing. |
1190 // ---------------------------------------------------------------------------- | 1228 // ---------------------------------------------------------------------------- |
1191 | 1229 |
1192 | 1230 |
1193 TEST_F(InstructionSelectorTest, Word32EqualWithZero) { | 1231 TEST_F(InstructionSelectorTest, Word32EqualWithZero) { |
1194 { | 1232 { |
1195 StreamBuilder m(this, kMachInt32, kMachInt32); | 1233 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
1196 m.Return(m.Word32Equal(m.Parameter(0), m.Int32Constant(0))); | 1234 m.Return(m.Word32Equal(m.Parameter(0), m.Int32Constant(0))); |
1197 Stream s = m.Build(); | 1235 Stream s = m.Build(); |
1198 ASSERT_EQ(1U, s.size()); | 1236 ASSERT_EQ(1U, s.size()); |
1199 EXPECT_EQ(kMips64Cmp, s[0]->arch_opcode()); | 1237 EXPECT_EQ(kMips64Cmp, s[0]->arch_opcode()); |
1200 EXPECT_EQ(kMode_None, s[0]->addressing_mode()); | 1238 EXPECT_EQ(kMode_None, s[0]->addressing_mode()); |
1201 ASSERT_EQ(2U, s[0]->InputCount()); | 1239 ASSERT_EQ(2U, s[0]->InputCount()); |
1202 EXPECT_EQ(1U, s[0]->OutputCount()); | 1240 EXPECT_EQ(1U, s[0]->OutputCount()); |
1203 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 1241 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
1204 EXPECT_EQ(kEqual, s[0]->flags_condition()); | 1242 EXPECT_EQ(kEqual, s[0]->flags_condition()); |
1205 } | 1243 } |
1206 { | 1244 { |
1207 StreamBuilder m(this, kMachInt32, kMachInt32); | 1245 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
1208 m.Return(m.Word32Equal(m.Int32Constant(0), m.Parameter(0))); | 1246 m.Return(m.Word32Equal(m.Int32Constant(0), m.Parameter(0))); |
1209 Stream s = m.Build(); | 1247 Stream s = m.Build(); |
1210 ASSERT_EQ(1U, s.size()); | 1248 ASSERT_EQ(1U, s.size()); |
1211 EXPECT_EQ(kMips64Cmp, s[0]->arch_opcode()); | 1249 EXPECT_EQ(kMips64Cmp, s[0]->arch_opcode()); |
1212 EXPECT_EQ(kMode_None, s[0]->addressing_mode()); | 1250 EXPECT_EQ(kMode_None, s[0]->addressing_mode()); |
1213 ASSERT_EQ(2U, s[0]->InputCount()); | 1251 ASSERT_EQ(2U, s[0]->InputCount()); |
1214 EXPECT_EQ(1U, s[0]->OutputCount()); | 1252 EXPECT_EQ(1U, s[0]->OutputCount()); |
1215 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 1253 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
1216 EXPECT_EQ(kEqual, s[0]->flags_condition()); | 1254 EXPECT_EQ(kEqual, s[0]->flags_condition()); |
1217 } | 1255 } |
1218 } | 1256 } |
1219 | 1257 |
1220 | 1258 |
1221 TEST_F(InstructionSelectorTest, Word64EqualWithZero) { | 1259 TEST_F(InstructionSelectorTest, Word64EqualWithZero) { |
1222 { | 1260 { |
1223 StreamBuilder m(this, kMachInt64, kMachInt64); | 1261 StreamBuilder m(this, MachineType::Int64(), MachineType::Int64()); |
1224 m.Return(m.Word64Equal(m.Parameter(0), m.Int64Constant(0))); | 1262 m.Return(m.Word64Equal(m.Parameter(0), m.Int64Constant(0))); |
1225 Stream s = m.Build(); | 1263 Stream s = m.Build(); |
1226 ASSERT_EQ(1U, s.size()); | 1264 ASSERT_EQ(1U, s.size()); |
1227 EXPECT_EQ(kMips64Cmp, s[0]->arch_opcode()); | 1265 EXPECT_EQ(kMips64Cmp, s[0]->arch_opcode()); |
1228 EXPECT_EQ(kMode_None, s[0]->addressing_mode()); | 1266 EXPECT_EQ(kMode_None, s[0]->addressing_mode()); |
1229 ASSERT_EQ(2U, s[0]->InputCount()); | 1267 ASSERT_EQ(2U, s[0]->InputCount()); |
1230 EXPECT_EQ(1U, s[0]->OutputCount()); | 1268 EXPECT_EQ(1U, s[0]->OutputCount()); |
1231 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 1269 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
1232 EXPECT_EQ(kEqual, s[0]->flags_condition()); | 1270 EXPECT_EQ(kEqual, s[0]->flags_condition()); |
1233 } | 1271 } |
1234 { | 1272 { |
1235 StreamBuilder m(this, kMachInt64, kMachInt64); | 1273 StreamBuilder m(this, MachineType::Int64(), MachineType::Int64()); |
1236 m.Return(m.Word64Equal(m.Int32Constant(0), m.Parameter(0))); | 1274 m.Return(m.Word64Equal(m.Int32Constant(0), m.Parameter(0))); |
1237 Stream s = m.Build(); | 1275 Stream s = m.Build(); |
1238 ASSERT_EQ(1U, s.size()); | 1276 ASSERT_EQ(1U, s.size()); |
1239 EXPECT_EQ(kMips64Cmp, s[0]->arch_opcode()); | 1277 EXPECT_EQ(kMips64Cmp, s[0]->arch_opcode()); |
1240 EXPECT_EQ(kMode_None, s[0]->addressing_mode()); | 1278 EXPECT_EQ(kMode_None, s[0]->addressing_mode()); |
1241 ASSERT_EQ(2U, s[0]->InputCount()); | 1279 ASSERT_EQ(2U, s[0]->InputCount()); |
1242 EXPECT_EQ(1U, s[0]->OutputCount()); | 1280 EXPECT_EQ(1U, s[0]->OutputCount()); |
1243 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); | 1281 EXPECT_EQ(kFlags_set, s[0]->flags_mode()); |
1244 EXPECT_EQ(kEqual, s[0]->flags_condition()); | 1282 EXPECT_EQ(kEqual, s[0]->flags_condition()); |
1245 } | 1283 } |
1246 } | 1284 } |
1247 | 1285 |
1248 | 1286 |
1249 TEST_F(InstructionSelectorTest, Word32Clz) { | 1287 TEST_F(InstructionSelectorTest, Word32Clz) { |
1250 StreamBuilder m(this, kMachUint32, kMachUint32); | 1288 StreamBuilder m(this, MachineType::Uint32(), MachineType::Uint32()); |
1251 Node* const p0 = m.Parameter(0); | 1289 Node* const p0 = m.Parameter(0); |
1252 Node* const n = m.Word32Clz(p0); | 1290 Node* const n = m.Word32Clz(p0); |
1253 m.Return(n); | 1291 m.Return(n); |
1254 Stream s = m.Build(); | 1292 Stream s = m.Build(); |
1255 ASSERT_EQ(1U, s.size()); | 1293 ASSERT_EQ(1U, s.size()); |
1256 EXPECT_EQ(kMips64Clz, s[0]->arch_opcode()); | 1294 EXPECT_EQ(kMips64Clz, s[0]->arch_opcode()); |
1257 ASSERT_EQ(1U, s[0]->InputCount()); | 1295 ASSERT_EQ(1U, s[0]->InputCount()); |
1258 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); | 1296 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
1259 ASSERT_EQ(1U, s[0]->OutputCount()); | 1297 ASSERT_EQ(1U, s[0]->OutputCount()); |
1260 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | 1298 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
1261 } | 1299 } |
1262 | 1300 |
1263 | 1301 |
1264 TEST_F(InstructionSelectorTest, Word64Clz) { | 1302 TEST_F(InstructionSelectorTest, Word64Clz) { |
1265 StreamBuilder m(this, kMachUint64, kMachUint64); | 1303 StreamBuilder m(this, MachineType::Uint64(), MachineType::Uint64()); |
1266 Node* const p0 = m.Parameter(0); | 1304 Node* const p0 = m.Parameter(0); |
1267 Node* const n = m.Word64Clz(p0); | 1305 Node* const n = m.Word64Clz(p0); |
1268 m.Return(n); | 1306 m.Return(n); |
1269 Stream s = m.Build(); | 1307 Stream s = m.Build(); |
1270 ASSERT_EQ(1U, s.size()); | 1308 ASSERT_EQ(1U, s.size()); |
1271 EXPECT_EQ(kMips64Dclz, s[0]->arch_opcode()); | 1309 EXPECT_EQ(kMips64Dclz, s[0]->arch_opcode()); |
1272 ASSERT_EQ(1U, s[0]->InputCount()); | 1310 ASSERT_EQ(1U, s[0]->InputCount()); |
1273 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); | 1311 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
1274 ASSERT_EQ(1U, s[0]->OutputCount()); | 1312 ASSERT_EQ(1U, s[0]->OutputCount()); |
1275 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | 1313 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
1276 } | 1314 } |
1277 | 1315 |
1278 | 1316 |
1279 TEST_F(InstructionSelectorTest, Float32Abs) { | 1317 TEST_F(InstructionSelectorTest, Float32Abs) { |
1280 StreamBuilder m(this, kMachFloat32, kMachFloat32); | 1318 StreamBuilder m(this, MachineType::Float32(), MachineType::Float32()); |
1281 Node* const p0 = m.Parameter(0); | 1319 Node* const p0 = m.Parameter(0); |
1282 Node* const n = m.Float32Abs(p0); | 1320 Node* const n = m.Float32Abs(p0); |
1283 m.Return(n); | 1321 m.Return(n); |
1284 Stream s = m.Build(); | 1322 Stream s = m.Build(); |
1285 ASSERT_EQ(1U, s.size()); | 1323 ASSERT_EQ(1U, s.size()); |
1286 EXPECT_EQ(kMips64AbsS, s[0]->arch_opcode()); | 1324 EXPECT_EQ(kMips64AbsS, s[0]->arch_opcode()); |
1287 ASSERT_EQ(1U, s[0]->InputCount()); | 1325 ASSERT_EQ(1U, s[0]->InputCount()); |
1288 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); | 1326 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
1289 ASSERT_EQ(1U, s[0]->OutputCount()); | 1327 ASSERT_EQ(1U, s[0]->OutputCount()); |
1290 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | 1328 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
1291 } | 1329 } |
1292 | 1330 |
1293 | 1331 |
1294 TEST_F(InstructionSelectorTest, Float64Abs) { | 1332 TEST_F(InstructionSelectorTest, Float64Abs) { |
1295 StreamBuilder m(this, kMachFloat64, kMachFloat64); | 1333 StreamBuilder m(this, MachineType::Float64(), MachineType::Float64()); |
1296 Node* const p0 = m.Parameter(0); | 1334 Node* const p0 = m.Parameter(0); |
1297 Node* const n = m.Float64Abs(p0); | 1335 Node* const n = m.Float64Abs(p0); |
1298 m.Return(n); | 1336 m.Return(n); |
1299 Stream s = m.Build(); | 1337 Stream s = m.Build(); |
1300 ASSERT_EQ(1U, s.size()); | 1338 ASSERT_EQ(1U, s.size()); |
1301 EXPECT_EQ(kMips64AbsD, s[0]->arch_opcode()); | 1339 EXPECT_EQ(kMips64AbsD, s[0]->arch_opcode()); |
1302 ASSERT_EQ(1U, s[0]->InputCount()); | 1340 ASSERT_EQ(1U, s[0]->InputCount()); |
1303 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); | 1341 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
1304 ASSERT_EQ(1U, s[0]->OutputCount()); | 1342 ASSERT_EQ(1U, s[0]->OutputCount()); |
1305 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | 1343 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
1306 } | 1344 } |
1307 | 1345 |
1308 | 1346 |
1309 TEST_F(InstructionSelectorTest, Float32Max) { | 1347 TEST_F(InstructionSelectorTest, Float32Max) { |
1310 StreamBuilder m(this, kMachFloat32, kMachFloat32, kMachFloat32); | 1348 StreamBuilder m(this, MachineType::Float32(), MachineType::Float32(), |
| 1349 MachineType::Float32()); |
1311 Node* const p0 = m.Parameter(0); | 1350 Node* const p0 = m.Parameter(0); |
1312 Node* const p1 = m.Parameter(1); | 1351 Node* const p1 = m.Parameter(1); |
1313 Node* const n = m.Float32Max(p0, p1); | 1352 Node* const n = m.Float32Max(p0, p1); |
1314 m.Return(n); | 1353 m.Return(n); |
1315 Stream s = m.Build(); | 1354 Stream s = m.Build(); |
1316 // Float32Max is `(b < a) ? a : b`. | 1355 // Float32Max is `(b < a) ? a : b`. |
1317 ASSERT_EQ(1U, s.size()); | 1356 ASSERT_EQ(1U, s.size()); |
1318 EXPECT_EQ(kMips64Float32Max, s[0]->arch_opcode()); | 1357 EXPECT_EQ(kMips64Float32Max, s[0]->arch_opcode()); |
1319 ASSERT_EQ(2U, s[0]->InputCount()); | 1358 ASSERT_EQ(2U, s[0]->InputCount()); |
1320 ASSERT_EQ(1U, s[0]->OutputCount()); | 1359 ASSERT_EQ(1U, s[0]->OutputCount()); |
1321 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | 1360 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
1322 } | 1361 } |
1323 | 1362 |
1324 | 1363 |
1325 TEST_F(InstructionSelectorTest, Float32Min) { | 1364 TEST_F(InstructionSelectorTest, Float32Min) { |
1326 StreamBuilder m(this, kMachFloat32, kMachFloat32, kMachFloat32); | 1365 StreamBuilder m(this, MachineType::Float32(), MachineType::Float32(), |
| 1366 MachineType::Float32()); |
1327 Node* const p0 = m.Parameter(0); | 1367 Node* const p0 = m.Parameter(0); |
1328 Node* const p1 = m.Parameter(1); | 1368 Node* const p1 = m.Parameter(1); |
1329 Node* const n = m.Float32Min(p0, p1); | 1369 Node* const n = m.Float32Min(p0, p1); |
1330 m.Return(n); | 1370 m.Return(n); |
1331 Stream s = m.Build(); | 1371 Stream s = m.Build(); |
1332 // Float32Min is `(a < b) ? a : b`. | 1372 // Float32Min is `(a < b) ? a : b`. |
1333 ASSERT_EQ(1U, s.size()); | 1373 ASSERT_EQ(1U, s.size()); |
1334 EXPECT_EQ(kMips64Float32Min, s[0]->arch_opcode()); | 1374 EXPECT_EQ(kMips64Float32Min, s[0]->arch_opcode()); |
1335 ASSERT_EQ(2U, s[0]->InputCount()); | 1375 ASSERT_EQ(2U, s[0]->InputCount()); |
1336 ASSERT_EQ(1U, s[0]->OutputCount()); | 1376 ASSERT_EQ(1U, s[0]->OutputCount()); |
1337 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | 1377 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
1338 } | 1378 } |
1339 | 1379 |
1340 | 1380 |
1341 TEST_F(InstructionSelectorTest, Float64Max) { | 1381 TEST_F(InstructionSelectorTest, Float64Max) { |
1342 StreamBuilder m(this, kMachFloat64, kMachFloat64, kMachFloat64); | 1382 StreamBuilder m(this, MachineType::Float64(), MachineType::Float64(), |
| 1383 MachineType::Float64()); |
1343 Node* const p0 = m.Parameter(0); | 1384 Node* const p0 = m.Parameter(0); |
1344 Node* const p1 = m.Parameter(1); | 1385 Node* const p1 = m.Parameter(1); |
1345 Node* const n = m.Float64Max(p0, p1); | 1386 Node* const n = m.Float64Max(p0, p1); |
1346 m.Return(n); | 1387 m.Return(n); |
1347 Stream s = m.Build(); | 1388 Stream s = m.Build(); |
1348 // Float64Max is `(b < a) ? a : b`. | 1389 // Float64Max is `(b < a) ? a : b`. |
1349 ASSERT_EQ(1U, s.size()); | 1390 ASSERT_EQ(1U, s.size()); |
1350 EXPECT_EQ(kMips64Float64Max, s[0]->arch_opcode()); | 1391 EXPECT_EQ(kMips64Float64Max, s[0]->arch_opcode()); |
1351 ASSERT_EQ(2U, s[0]->InputCount()); | 1392 ASSERT_EQ(2U, s[0]->InputCount()); |
1352 ASSERT_EQ(1U, s[0]->OutputCount()); | 1393 ASSERT_EQ(1U, s[0]->OutputCount()); |
1353 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | 1394 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
1354 } | 1395 } |
1355 | 1396 |
1356 | 1397 |
1357 TEST_F(InstructionSelectorTest, Float64Min) { | 1398 TEST_F(InstructionSelectorTest, Float64Min) { |
1358 StreamBuilder m(this, kMachFloat64, kMachFloat64, kMachFloat64); | 1399 StreamBuilder m(this, MachineType::Float64(), MachineType::Float64(), |
| 1400 MachineType::Float64()); |
1359 Node* const p0 = m.Parameter(0); | 1401 Node* const p0 = m.Parameter(0); |
1360 Node* const p1 = m.Parameter(1); | 1402 Node* const p1 = m.Parameter(1); |
1361 Node* const n = m.Float64Min(p0, p1); | 1403 Node* const n = m.Float64Min(p0, p1); |
1362 m.Return(n); | 1404 m.Return(n); |
1363 Stream s = m.Build(); | 1405 Stream s = m.Build(); |
1364 // Float64Min is `(a < b) ? a : b`. | 1406 // Float64Min is `(a < b) ? a : b`. |
1365 ASSERT_EQ(1U, s.size()); | 1407 ASSERT_EQ(1U, s.size()); |
1366 EXPECT_EQ(kMips64Float64Min, s[0]->arch_opcode()); | 1408 EXPECT_EQ(kMips64Float64Min, s[0]->arch_opcode()); |
1367 ASSERT_EQ(2U, s[0]->InputCount()); | 1409 ASSERT_EQ(2U, s[0]->InputCount()); |
1368 ASSERT_EQ(1U, s[0]->OutputCount()); | 1410 ASSERT_EQ(1U, s[0]->OutputCount()); |
1369 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | 1411 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
1370 } | 1412 } |
1371 | 1413 |
1372 } // namespace compiler | 1414 } // namespace compiler |
1373 } // namespace internal | 1415 } // namespace internal |
1374 } // namespace v8 | 1416 } // namespace v8 |
OLD | NEW |