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

Side by Side Diff: test/compiler-unittests/ia32/instruction-selector-ia32-unittest.cc

Issue 505713002: [turbofan] Add backend support for signed loads. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix x64. Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "test/compiler-unittests/instruction-selector-unittest.h" 5 #include "test/compiler-unittests/instruction-selector-unittest.h"
6 6
7 namespace v8 { 7 namespace v8 {
8 namespace internal { 8 namespace internal {
9 namespace compiler { 9 namespace compiler {
10 10
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 StreamBuilder m(this, kMachInt32, kMachInt32); 66 StreamBuilder m(this, kMachInt32, kMachInt32);
67 m.Return(m.Int32Sub(m.Parameter(0), m.Int32Constant(imm))); 67 m.Return(m.Int32Sub(m.Parameter(0), m.Int32Constant(imm)));
68 Stream s = m.Build(); 68 Stream s = m.Build();
69 ASSERT_EQ(1U, s.size()); 69 ASSERT_EQ(1U, s.size());
70 EXPECT_EQ(kIA32Sub, s[0]->arch_opcode()); 70 EXPECT_EQ(kIA32Sub, s[0]->arch_opcode());
71 ASSERT_EQ(2U, s[0]->InputCount()); 71 ASSERT_EQ(2U, s[0]->InputCount());
72 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); 72 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1)));
73 } 73 }
74 } 74 }
75 75
76
77 // -----------------------------------------------------------------------------
78 // Loads and stores
79
80 namespace {
81
82 struct MemoryAccess {
83 MachineType type;
84 ArchOpcode load_opcode;
85 ArchOpcode store_opcode;
86 };
87
88
89 std::ostream& operator<<(std::ostream& os, const MemoryAccess& memacc) {
90 OStringStream ost;
91 ost << memacc.type;
92 return os << ost.c_str();
93 }
94
95
96 static const MemoryAccess kMemoryAccesses[] = {
97 {kMachInt8, kIA32Movsxbl, kIA32Movb},
98 {kMachUint8, kIA32Movzxbl, kIA32Movb},
99 {kMachInt16, kIA32Movsxwl, kIA32Movw},
100 {kMachUint16, kIA32Movzxwl, kIA32Movw},
101 {kMachInt32, kIA32Movl, kIA32Movl},
102 {kMachUint32, kIA32Movl, kIA32Movl},
103 {kMachFloat64, kIA32Movsd, kIA32Movsd}};
104
105 } // namespace
106
107
108 typedef InstructionSelectorTestWithParam<MemoryAccess>
109 InstructionSelectorMemoryAccessTest;
110
111
112 TEST_P(InstructionSelectorMemoryAccessTest, LoadWithParameters) {
113 const MemoryAccess memacc = GetParam();
114 StreamBuilder m(this, memacc.type, kMachPtr, kMachInt32);
115 m.Return(m.Load(memacc.type, m.Parameter(0), m.Parameter(1)));
116 Stream s = m.Build();
117 ASSERT_EQ(1U, s.size());
118 EXPECT_EQ(memacc.load_opcode, s[0]->arch_opcode());
119 EXPECT_EQ(2U, s[0]->InputCount());
120 EXPECT_EQ(1U, s[0]->OutputCount());
121 }
122
123
124 TEST_P(InstructionSelectorMemoryAccessTest, LoadWithImmediateBase) {
125 const MemoryAccess memacc = GetParam();
126 TRACED_FOREACH(int32_t, base, kImmediates) {
127 StreamBuilder m(this, memacc.type, kMachPtr);
128 m.Return(m.Load(memacc.type, m.Int32Constant(base), m.Parameter(0)));
129 Stream s = m.Build();
130 ASSERT_EQ(1U, s.size());
131 EXPECT_EQ(memacc.load_opcode, s[0]->arch_opcode());
132 ASSERT_EQ(2U, s[0]->InputCount());
133 ASSERT_EQ(InstructionOperand::IMMEDIATE, s[0]->InputAt(1)->kind());
134 EXPECT_EQ(base, s.ToInt32(s[0]->InputAt(1)));
135 EXPECT_EQ(1U, s[0]->OutputCount());
136 }
137 }
138
139
140 TEST_P(InstructionSelectorMemoryAccessTest, LoadWithImmediateIndex) {
141 const MemoryAccess memacc = GetParam();
142 TRACED_FOREACH(int32_t, index, kImmediates) {
143 StreamBuilder m(this, memacc.type, kMachPtr);
144 m.Return(m.Load(memacc.type, m.Parameter(0), m.Int32Constant(index)));
145 Stream s = m.Build();
146 ASSERT_EQ(1U, s.size());
147 EXPECT_EQ(memacc.load_opcode, s[0]->arch_opcode());
148 ASSERT_EQ(2U, s[0]->InputCount());
149 ASSERT_EQ(InstructionOperand::IMMEDIATE, s[0]->InputAt(1)->kind());
150 EXPECT_EQ(index, s.ToInt32(s[0]->InputAt(1)));
151 EXPECT_EQ(1U, s[0]->OutputCount());
152 }
153 }
154
155
156 TEST_P(InstructionSelectorMemoryAccessTest, StoreWithParameters) {
157 const MemoryAccess memacc = GetParam();
158 StreamBuilder m(this, kMachInt32, kMachPtr, kMachInt32, memacc.type);
159 m.Store(memacc.type, m.Parameter(0), m.Parameter(1), m.Parameter(2));
160 m.Return(m.Int32Constant(0));
161 Stream s = m.Build();
162 ASSERT_EQ(1U, s.size());
163 EXPECT_EQ(memacc.store_opcode, s[0]->arch_opcode());
164 EXPECT_EQ(3U, s[0]->InputCount());
165 EXPECT_EQ(0U, s[0]->OutputCount());
166 }
167
168
169 TEST_P(InstructionSelectorMemoryAccessTest, StoreWithImmediateBase) {
170 const MemoryAccess memacc = GetParam();
171 TRACED_FOREACH(int32_t, base, kImmediates) {
172 StreamBuilder m(this, kMachInt32, kMachInt32, memacc.type);
173 m.Store(memacc.type, m.Int32Constant(base), m.Parameter(0), m.Parameter(1));
174 m.Return(m.Int32Constant(0));
175 Stream s = m.Build();
176 ASSERT_EQ(1U, s.size());
177 EXPECT_EQ(memacc.store_opcode, s[0]->arch_opcode());
178 ASSERT_EQ(3U, s[0]->InputCount());
179 ASSERT_EQ(InstructionOperand::IMMEDIATE, s[0]->InputAt(1)->kind());
180 EXPECT_EQ(base, s.ToInt32(s[0]->InputAt(1)));
181 EXPECT_EQ(0U, s[0]->OutputCount());
182 }
183 }
184
185
186 TEST_P(InstructionSelectorMemoryAccessTest, StoreWithImmediateIndex) {
187 const MemoryAccess memacc = GetParam();
188 TRACED_FOREACH(int32_t, index, kImmediates) {
189 StreamBuilder m(this, kMachInt32, kMachPtr, memacc.type);
190 m.Store(memacc.type, m.Parameter(0), m.Int32Constant(index),
191 m.Parameter(1));
192 m.Return(m.Int32Constant(0));
193 Stream s = m.Build();
194 ASSERT_EQ(1U, s.size());
195 EXPECT_EQ(memacc.store_opcode, s[0]->arch_opcode());
196 ASSERT_EQ(3U, s[0]->InputCount());
197 ASSERT_EQ(InstructionOperand::IMMEDIATE, s[0]->InputAt(1)->kind());
198 EXPECT_EQ(index, s.ToInt32(s[0]->InputAt(1)));
199 EXPECT_EQ(0U, s[0]->OutputCount());
200 }
201 }
202
203
204 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest,
205 InstructionSelectorMemoryAccessTest,
206 ::testing::ValuesIn(kMemoryAccesses));
207
76 } // namespace compiler 208 } // namespace compiler
77 } // namespace internal 209 } // namespace internal
78 } // namespace v8 210 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698