Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Side by Side Diff: test/unittests/compiler/int64-lowering-unittest.cc

Issue 2122853002: Implement UnaligedLoad and UnaligedStore turbofan operators. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Nits. Fixes some errors Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/cctest/compiler/test-run-load-store.cc ('k') | test/unittests/compiler/node-test-utils.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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 "src/compiler/int64-lowering.h" 5 #include "src/compiler/int64-lowering.h"
6 #include "src/compiler/common-operator.h" 6 #include "src/compiler/common-operator.h"
7 #include "src/compiler/linkage.h" 7 #include "src/compiler/linkage.h"
8 #include "src/compiler/machine-operator.h" 8 #include "src/compiler/machine-operator.h"
9 #include "src/compiler/node.h" 9 #include "src/compiler/node.h"
10 10
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 int64_t value_[3]; 116 int64_t value_[3];
117 }; 117 };
118 118
119 TEST_F(Int64LoweringTest, Int64Constant) { 119 TEST_F(Int64LoweringTest, Int64Constant) {
120 LowerGraph(Int64Constant(value(0)), MachineRepresentation::kWord64); 120 LowerGraph(Int64Constant(value(0)), MachineRepresentation::kWord64);
121 EXPECT_THAT(graph()->end()->InputAt(1), 121 EXPECT_THAT(graph()->end()->InputAt(1),
122 IsReturn2(IsInt32Constant(low_word_value(0)), 122 IsReturn2(IsInt32Constant(low_word_value(0)),
123 IsInt32Constant(high_word_value(0)), start(), start())); 123 IsInt32Constant(high_word_value(0)), start(), start()));
124 } 124 }
125 125
126 TEST_F(Int64LoweringTest, Int64Load) {
127 int32_t base = 0x1234;
128 int32_t index = 0x5678;
129
130 LowerGraph(graph()->NewNode(machine()->Load(MachineType::Int64()),
131 Int32Constant(base), Int32Constant(index),
132 start(), start()),
133 MachineRepresentation::kWord64);
134
135 Capture<Node*> high_word_load;
136 #if defined(V8_TARGET_LITTLE_ENDIAN) 126 #if defined(V8_TARGET_LITTLE_ENDIAN)
137 Matcher<Node*> high_word_load_matcher = 127 #define LOAD_VERIFY(kLoad) \
138 IsLoad(MachineType::Int32(), IsInt32Constant(base), 128 Matcher<Node*> high_word_load_matcher = \
139 IsInt32Add(IsInt32Constant(index), IsInt32Constant(0x4)), start(), 129 Is##kLoad(MachineType::Int32(), IsInt32Constant(base), \
140 start()); 130 IsInt32Add(IsInt32Constant(index), IsInt32Constant(0x4)), \
141 131 start(), start()); \
142 EXPECT_THAT( 132 \
143 graph()->end()->InputAt(1), 133 EXPECT_THAT( \
144 IsReturn2(IsLoad(MachineType::Int32(), IsInt32Constant(base), 134 graph()->end()->InputAt(1), \
145 IsInt32Constant(index), AllOf(CaptureEq(&high_word_load), 135 IsReturn2( \
146 high_word_load_matcher), 136 Is##kLoad(MachineType::Int32(), IsInt32Constant(base), \
147 start()), 137 IsInt32Constant(index), \
148 AllOf(CaptureEq(&high_word_load), high_word_load_matcher), 138 AllOf(CaptureEq(&high_word_load), high_word_load_matcher), \
149 start(), start())); 139 start()), \
140 AllOf(CaptureEq(&high_word_load), high_word_load_matcher), start(), \
141 start()));
150 #elif defined(V8_TARGET_BIG_ENDIAN) 142 #elif defined(V8_TARGET_BIG_ENDIAN)
151 Matcher<Node*> high_word_load_matcher = 143 #define LOAD_VERIFY(kLoad) \
152 IsLoad(MachineType::Int32(), IsInt32Constant(base), 144 Matcher<Node*> high_word_load_matcher = \
153 IsInt32Constant(index), start(), start()); 145 Is##kLoad(MachineType::Int32(), IsInt32Constant(base), \
154 146 IsInt32Constant(index), start(), start()); \
155 EXPECT_THAT( 147 \
156 graph()->end()->InputAt(1), 148 EXPECT_THAT( \
157 IsReturn2( 149 graph()->end()->InputAt(1), \
158 IsLoad(MachineType::Int32(), IsInt32Constant(base), 150 IsReturn2( \
159 IsInt32Add(IsInt32Constant(index), IsInt32Constant(0x4)), 151 Is##kLoad(MachineType::Int32(), IsInt32Constant(base), \
160 AllOf(CaptureEq(&high_word_load), high_word_load_matcher), 152 IsInt32Add(IsInt32Constant(index), IsInt32Constant(0x4)), \
161 start()), 153 AllOf(CaptureEq(&high_word_load), high_word_load_matcher), \
162 AllOf(CaptureEq(&high_word_load), high_word_load_matcher), start(), 154 start()), \
155 AllOf(CaptureEq(&high_word_load), high_word_load_matcher), start(), \
163 start())); 156 start()));
164 #endif 157 #endif
158
159 #define INT64_LOAD_LOWERING(kLoad) \
160 int32_t base = 0x1234; \
161 int32_t index = 0x5678; \
162 \
163 LowerGraph(graph()->NewNode(machine()->kLoad(MachineType::Int64()), \
164 Int32Constant(base), Int32Constant(index), \
165 start(), start()), \
166 MachineRepresentation::kWord64); \
167 \
168 Capture<Node*> high_word_load; \
169 LOAD_VERIFY(kLoad)
170
171 TEST_F(Int64LoweringTest, Int64Load) { INT64_LOAD_LOWERING(Load); }
172
173 TEST_F(Int64LoweringTest, UnalignedInt64Load) {
174 INT64_LOAD_LOWERING(UnalignedLoad);
165 } 175 }
166 176
177 #if defined(V8_TARGET_LITTLE_ENDIAN)
178 #define STORE_VERIFY(kStore, kRep) \
179 EXPECT_THAT( \
180 graph()->end()->InputAt(1), \
181 IsReturn(IsInt32Constant(return_value), \
182 Is##kStore( \
183 kRep, IsInt32Constant(base), IsInt32Constant(index), \
184 IsInt32Constant(low_word_value(0)), \
185 Is##kStore( \
186 kRep, IsInt32Constant(base), \
187 IsInt32Add(IsInt32Constant(index), IsInt32Constant(4)), \
188 IsInt32Constant(high_word_value(0)), start(), start()), \
189 start()), \
190 start()));
191 #elif defined(V8_TARGET_BIG_ENDIAN)
192 #define STORE_VERIFY(kStore, kRep) \
193 EXPECT_THAT( \
194 graph()->end()->InputAt(1), \
195 IsReturn(IsInt32Constant(return_value), \
196 Is##kStore( \
197 kRep, IsInt32Constant(base), \
198 IsInt32Add(IsInt32Constant(index), IsInt32Constant(4)), \
199 IsInt32Constant(low_word_value(0)), \
200 Is##kStore( \
201 kRep, IsInt32Constant(base), IsInt32Constant(index), \
202 IsInt32Constant(high_word_value(0)), start(), start()), \
203 start()), \
204 start()));
205 #endif
206
207 #define INT64_STORE_LOWERING(kStore, kRep32, kRep64) \
208 int32_t base = 1111; \
209 int32_t index = 2222; \
210 int32_t return_value = 0x5555; \
211 \
212 Signature<MachineRepresentation>::Builder sig_builder(zone(), 1, 0); \
213 sig_builder.AddReturn(MachineRepresentation::kWord32); \
214 \
215 Node* store = graph()->NewNode(machine()->kStore(kRep64), \
216 Int32Constant(base), Int32Constant(index), \
217 Int64Constant(value(0)), start(), start()); \
218 \
219 Node* ret = graph()->NewNode(common()->Return(), \
220 Int32Constant(return_value), store, start()); \
221 \
222 NodeProperties::MergeControlToEnd(graph(), common(), ret); \
223 \
224 Int64Lowering lowering(graph(), machine(), common(), zone(), \
225 sig_builder.Build()); \
226 lowering.LowerGraph(); \
227 \
228 STORE_VERIFY(kStore, kRep32)
229
167 TEST_F(Int64LoweringTest, Int64Store) { 230 TEST_F(Int64LoweringTest, Int64Store) {
168 // We have to build the TF graph explicitly here because Store does not return 231 const StoreRepresentation rep64(MachineRepresentation::kWord64,
169 // a value. 232 WriteBarrierKind::kNoWriteBarrier);
233 const StoreRepresentation rep32(MachineRepresentation::kWord32,
234 WriteBarrierKind::kNoWriteBarrier);
235 INT64_STORE_LOWERING(Store, rep32, rep64);
236 }
170 237
171 int32_t base = 1111; 238 TEST_F(Int64LoweringTest, Int64UnalignedStore) {
172 int32_t index = 2222; 239 const UnalignedStoreRepresentation rep64(MachineRepresentation::kWord64);
173 int32_t return_value = 0x5555; 240 const UnalignedStoreRepresentation rep32(MachineRepresentation::kWord32);
174 241 INT64_STORE_LOWERING(UnalignedStore, rep32, rep64);
175 Signature<MachineRepresentation>::Builder sig_builder(zone(), 1, 0);
176 sig_builder.AddReturn(MachineRepresentation::kWord32);
177
178 Node* store = graph()->NewNode(
179 machine()->Store(StoreRepresentation(MachineRepresentation::kWord64,
180 WriteBarrierKind::kNoWriteBarrier)),
181 Int32Constant(base), Int32Constant(index), Int64Constant(value(0)),
182 start(), start());
183
184 Node* ret = graph()->NewNode(common()->Return(), Int32Constant(return_value),
185 store, start());
186
187 NodeProperties::MergeControlToEnd(graph(), common(), ret);
188
189 Int64Lowering lowering(graph(), machine(), common(), zone(),
190 sig_builder.Build());
191 lowering.LowerGraph();
192
193 const StoreRepresentation rep(MachineRepresentation::kWord32,
194 kNoWriteBarrier);
195
196 #if defined(V8_TARGET_LITTLE_ENDIAN)
197 EXPECT_THAT(
198 graph()->end()->InputAt(1),
199 IsReturn(
200 IsInt32Constant(return_value),
201 IsStore(
202 rep, IsInt32Constant(base), IsInt32Constant(index),
203 IsInt32Constant(low_word_value(0)),
204 IsStore(rep, IsInt32Constant(base),
205 IsInt32Add(IsInt32Constant(index), IsInt32Constant(4)),
206 IsInt32Constant(high_word_value(0)), start(), start()),
207 start()),
208 start()));
209 #elif defined(V8_TARGET_BIG_ENDIAN)
210 EXPECT_THAT(
211 graph()->end()->InputAt(1),
212 IsReturn(
213 IsInt32Constant(return_value),
214 IsStore(
215 rep, IsInt32Constant(base),
216 IsInt32Add(IsInt32Constant(index), IsInt32Constant(4)),
217 IsInt32Constant(low_word_value(0)),
218 IsStore(rep, IsInt32Constant(base), IsInt32Constant(index),
219 IsInt32Constant(high_word_value(0)), start(), start()),
220 start()),
221 start()));
222 #endif
223 } 242 }
224 243
225 TEST_F(Int64LoweringTest, Int64And) { 244 TEST_F(Int64LoweringTest, Int64And) {
226 LowerGraph(graph()->NewNode(machine()->Word64And(), Int64Constant(value(0)), 245 LowerGraph(graph()->NewNode(machine()->Word64And(), Int64Constant(value(0)),
227 Int64Constant(value(1))), 246 Int64Constant(value(1))),
228 MachineRepresentation::kWord64); 247 MachineRepresentation::kWord64);
229 EXPECT_THAT(graph()->end()->InputAt(1), 248 EXPECT_THAT(graph()->end()->InputAt(1),
230 IsReturn2(IsWord32And(IsInt32Constant(low_word_value(0)), 249 IsReturn2(IsWord32And(IsInt32Constant(low_word_value(0)),
231 IsInt32Constant(low_word_value(1))), 250 IsInt32Constant(low_word_value(1))),
232 IsWord32And(IsInt32Constant(high_word_value(0)), 251 IsWord32And(IsInt32Constant(high_word_value(0)),
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after
815 Float32Constant(2.5)); 834 Float32Constant(2.5));
816 } 835 }
817 836
818 TEST_F(Int64LoweringTest, I64PhiWord32) { 837 TEST_F(Int64LoweringTest, I64PhiWord32) {
819 TestPhi(this, MachineRepresentation::kWord32, Float32Constant(1), 838 TestPhi(this, MachineRepresentation::kWord32, Float32Constant(1),
820 Float32Constant(2)); 839 Float32Constant(2));
821 } 840 }
822 } // namespace compiler 841 } // namespace compiler
823 } // namespace internal 842 } // namespace internal
824 } // namespace v8 843 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/compiler/test-run-load-store.cc ('k') | test/unittests/compiler/node-test-utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698