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

Side by Side Diff: unittest/AssemblerX8632/LowLevel.cpp

Issue 1428443002: Enhance address mode recovery (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Streamline absolute addressing support (rip-relative on x64) Created 5 years, 1 month 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
OLDNEW
1 //===- subzero/unittest/AssemblerX8632/LowLevel.cpp -----------------------===// 1 //===- subzero/unittest/AssemblerX8632/LowLevel.cpp -----------------------===//
2 // 2 //
3 // The Subzero Code Generator 3 // The Subzero Code Generator
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 #include "AssemblerX8632/TestUtil.h" 9 #include "AssemblerX8632/TestUtil.h"
10 10
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 << TestString; \ 133 << TestString; \
134 reset(); \ 134 reset(); \
135 } while (0) 135 } while (0)
136 136
137 #define TestRegAbsoluteAddr(Inst, Dst, Disp, OpType, ByteCountUntyped, ...) \ 137 #define TestRegAbsoluteAddr(Inst, Dst, Disp, OpType, ByteCountUntyped, ...) \
138 do { \ 138 do { \
139 static constexpr char TestString[] = \ 139 static constexpr char TestString[] = \
140 "(" #Inst ", " #Dst ", " #Disp ", " #OpType ", " #ByteCountUntyped \ 140 "(" #Inst ", " #Dst ", " #Disp ", " #OpType ", " #ByteCountUntyped \
141 ", " #__VA_ARGS__ ")"; \ 141 ", " #__VA_ARGS__ ")"; \
142 static constexpr uint8_t ByteCount = ByteCountUntyped; \ 142 static constexpr uint8_t ByteCount = ByteCountUntyped; \
143 static constexpr AssemblerFixup *Fixup = nullptr; \
143 __ Inst(IceType_##OpType, GPRRegister::Encoded_Reg_##Dst, \ 144 __ Inst(IceType_##OpType, GPRRegister::Encoded_Reg_##Dst, \
144 Address(Address::ABSOLUTE, Disp)); \ 145 Address(Disp, Fixup)); \
145 ASSERT_EQ(ByteCount, codeBytesSize()) << TestString; \ 146 ASSERT_EQ(ByteCount, codeBytesSize()) << TestString; \
146 ASSERT_TRUE(verifyBytes<ByteCount>(codeBytes(), __VA_ARGS__)) \ 147 ASSERT_TRUE(verifyBytes<ByteCount>(codeBytes(), __VA_ARGS__)) \
147 << TestString; \ 148 << TestString; \
148 reset(); \ 149 reset(); \
149 } while (0) 150 } while (0)
150 151
151 #define TestRegAddrBase(Inst, Dst, Base, Disp, OpType, ByteCountUntyped, ...) \ 152 #define TestRegAddrBase(Inst, Dst, Base, Disp, OpType, ByteCountUntyped, ...) \
152 do { \ 153 do { \
153 static constexpr char TestString[] = \ 154 static constexpr char TestString[] = \
154 "(" #Inst ", " #Dst ", " #Base ", " #Disp ", " #OpType \ 155 "(" #Inst ", " #Dst ", " #Base ", " #Disp ", " #OpType \
155 ", " #ByteCountUntyped ", " #__VA_ARGS__ ")"; \ 156 ", " #ByteCountUntyped ", " #__VA_ARGS__ ")"; \
156 static constexpr uint8_t ByteCount = ByteCountUntyped; \ 157 static constexpr uint8_t ByteCount = ByteCountUntyped; \
158 static constexpr AssemblerFixup *Fixup = nullptr; \
157 __ Inst(IceType_##OpType, GPRRegister::Encoded_Reg_##Dst, \ 159 __ Inst(IceType_##OpType, GPRRegister::Encoded_Reg_##Dst, \
158 Address(GPRRegister::Encoded_Reg_##Base, Disp)); \ 160 Address(GPRRegister::Encoded_Reg_##Base, Disp, Fixup)); \
159 ASSERT_EQ(ByteCount, codeBytesSize()) << TestString; \ 161 ASSERT_EQ(ByteCount, codeBytesSize()) << TestString; \
160 ASSERT_TRUE(verifyBytes<ByteCount>(codeBytes(), __VA_ARGS__)) \ 162 ASSERT_TRUE(verifyBytes<ByteCount>(codeBytes(), __VA_ARGS__)) \
161 << TestString; \ 163 << TestString; \
162 reset(); \ 164 reset(); \
163 } while (0) 165 } while (0)
164 166
165 #define TestRegAddrScaledIndex(Inst, Dst, Index, Scale, Disp, OpType, \ 167 #define TestRegAddrScaledIndex(Inst, Dst, Index, Scale, Disp, OpType, \
166 ByteCountUntyped, ...) \ 168 ByteCountUntyped, ...) \
167 do { \ 169 do { \
168 static constexpr char TestString[] = \ 170 static constexpr char TestString[] = \
169 "(" #Inst ", " #Dst ", " #Index ", " #Scale ", " #Disp ", " #OpType \ 171 "(" #Inst ", " #Dst ", " #Index ", " #Scale ", " #Disp ", " #OpType \
170 ", " #ByteCountUntyped ", " #__VA_ARGS__ ")"; \ 172 ", " #ByteCountUntyped ", " #__VA_ARGS__ ")"; \
171 static constexpr uint8_t ByteCount = ByteCountUntyped; \ 173 static constexpr uint8_t ByteCount = ByteCountUntyped; \
174 static constexpr AssemblerFixup *Fixup = nullptr; \
172 __ Inst(IceType_##OpType, GPRRegister::Encoded_Reg_##Dst, \ 175 __ Inst(IceType_##OpType, GPRRegister::Encoded_Reg_##Dst, \
173 Address(GPRRegister::Encoded_Reg_##Index, Traits::TIMES_##Scale, \ 176 Address(GPRRegister::Encoded_Reg_##Index, Traits::TIMES_##Scale, \
174 Disp)); \ 177 Disp, Fixup)); \
175 ASSERT_EQ(ByteCount, codeBytesSize()) << TestString; \ 178 ASSERT_EQ(ByteCount, codeBytesSize()) << TestString; \
176 ASSERT_TRUE(verifyBytes<ByteCount>(codeBytes(), __VA_ARGS__)) \ 179 ASSERT_TRUE(verifyBytes<ByteCount>(codeBytes(), __VA_ARGS__)) \
177 << TestString; \ 180 << TestString; \
178 reset(); \ 181 reset(); \
179 } while (0) 182 } while (0)
180 183
181 #define TestRegAddrBaseScaledIndex(Inst, Dst, Base, Index, Scale, Disp, \ 184 #define TestRegAddrBaseScaledIndex(Inst, Dst, Base, Index, Scale, Disp, \
182 OpType, ByteCountUntyped, ...) \ 185 OpType, ByteCountUntyped, ...) \
183 do { \ 186 do { \
184 static constexpr char TestString[] = \ 187 static constexpr char TestString[] = \
185 "(" #Inst ", " #Dst ", " #Base ", " #Index ", " #Scale ", " #Disp \ 188 "(" #Inst ", " #Dst ", " #Base ", " #Index ", " #Scale ", " #Disp \
186 ", " #OpType ", " #ByteCountUntyped ", " #__VA_ARGS__ ")"; \ 189 ", " #OpType ", " #ByteCountUntyped ", " #__VA_ARGS__ ")"; \
187 static constexpr uint8_t ByteCount = ByteCountUntyped; \ 190 static constexpr uint8_t ByteCount = ByteCountUntyped; \
191 static constexpr AssemblerFixup *Fixup = nullptr; \
188 __ Inst(IceType_##OpType, GPRRegister::Encoded_Reg_##Dst, \ 192 __ Inst(IceType_##OpType, GPRRegister::Encoded_Reg_##Dst, \
189 Address(GPRRegister::Encoded_Reg_##Base, \ 193 Address(GPRRegister::Encoded_Reg_##Base, \
190 GPRRegister::Encoded_Reg_##Index, Traits::TIMES_##Scale, \ 194 GPRRegister::Encoded_Reg_##Index, Traits::TIMES_##Scale, \
191 Disp)); \ 195 Disp, Fixup)); \
192 ASSERT_EQ(ByteCount, codeBytesSize()) << TestString; \ 196 ASSERT_EQ(ByteCount, codeBytesSize()) << TestString; \
193 ASSERT_TRUE(verifyBytes<ByteCount>(codeBytes(), __VA_ARGS__)) \ 197 ASSERT_TRUE(verifyBytes<ByteCount>(codeBytes(), __VA_ARGS__)) \
194 << TestString; \ 198 << TestString; \
195 reset(); \ 199 reset(); \
196 } while (0) 200 } while (0)
197 201
198 #define TestAddrBaseScaledIndexImm(Inst, Base, Index, Scale, Disp, Imm, \ 202 #define TestAddrBaseScaledIndexImm(Inst, Base, Index, Scale, Disp, Imm, \
199 OpType, ByteCountUntyped, ...) \ 203 OpType, ByteCountUntyped, ...) \
200 do { \ 204 do { \
201 static constexpr char TestString[] = \ 205 static constexpr char TestString[] = \
202 "(" #Inst ", " #Base ", " #Index ", " #Scale ", " #Disp ", " #Imm \ 206 "(" #Inst ", " #Base ", " #Index ", " #Scale ", " #Disp ", " #Imm \
203 ", " #OpType ", " #ByteCountUntyped ", " #__VA_ARGS__ ")"; \ 207 ", " #OpType ", " #ByteCountUntyped ", " #__VA_ARGS__ ")"; \
204 static constexpr uint8_t ByteCount = ByteCountUntyped; \ 208 static constexpr uint8_t ByteCount = ByteCountUntyped; \
209 static constexpr AssemblerFixup *Fixup = nullptr; \
205 __ Inst(IceType_##OpType, Address(GPRRegister::Encoded_Reg_##Base, \ 210 __ Inst(IceType_##OpType, Address(GPRRegister::Encoded_Reg_##Base, \
206 GPRRegister::Encoded_Reg_##Index, \ 211 GPRRegister::Encoded_Reg_##Index, \
207 Traits::TIMES_##Scale, Disp), \ 212 Traits::TIMES_##Scale, Disp, Fixup), \
208 Immediate(Imm)); \ 213 Immediate(Imm)); \
209 ASSERT_EQ(ByteCount, codeBytesSize()) << TestString; \ 214 ASSERT_EQ(ByteCount, codeBytesSize()) << TestString; \
210 ASSERT_TRUE(verifyBytes<ByteCount>(codeBytes(), __VA_ARGS__)) \ 215 ASSERT_TRUE(verifyBytes<ByteCount>(codeBytes(), __VA_ARGS__)) \
211 << TestString; \ 216 << TestString; \
212 reset(); \ 217 reset(); \
213 } while (0) 218 } while (0)
214 219
215 #define TestAddrBaseScaledIndexReg(Inst, Base, Index, Scale, Disp, Src, \ 220 #define TestAddrBaseScaledIndexReg(Inst, Base, Index, Scale, Disp, Src, \
216 OpType, ByteCountUntyped, ...) \ 221 OpType, ByteCountUntyped, ...) \
217 do { \ 222 do { \
218 static constexpr char TestString[] = \ 223 static constexpr char TestString[] = \
219 "(" #Inst ", " #Base ", " #Index ", " #Scale ", " #Disp ", " #Src \ 224 "(" #Inst ", " #Base ", " #Index ", " #Scale ", " #Disp ", " #Src \
220 ", " #OpType ", " #ByteCountUntyped ", " #__VA_ARGS__ ")"; \ 225 ", " #OpType ", " #ByteCountUntyped ", " #__VA_ARGS__ ")"; \
221 static constexpr uint8_t ByteCount = ByteCountUntyped; \ 226 static constexpr uint8_t ByteCount = ByteCountUntyped; \
227 static constexpr AssemblerFixup *Fixup = nullptr; \
222 __ Inst(IceType_##OpType, Address(GPRRegister::Encoded_Reg_##Base, \ 228 __ Inst(IceType_##OpType, Address(GPRRegister::Encoded_Reg_##Base, \
223 GPRRegister::Encoded_Reg_##Index, \ 229 GPRRegister::Encoded_Reg_##Index, \
224 Traits::TIMES_##Scale, Disp), \ 230 Traits::TIMES_##Scale, Disp, Fixup), \
225 GPRRegister::Encoded_Reg_##Src); \ 231 GPRRegister::Encoded_Reg_##Src); \
226 ASSERT_EQ(ByteCount, codeBytesSize()) << TestString; \ 232 ASSERT_EQ(ByteCount, codeBytesSize()) << TestString; \
227 ASSERT_TRUE(verifyBytes<ByteCount>(codeBytes(), __VA_ARGS__)) \ 233 ASSERT_TRUE(verifyBytes<ByteCount>(codeBytes(), __VA_ARGS__)) \
228 << TestString; \ 234 << TestString; \
229 reset(); \ 235 reset(); \
230 } while (0) 236 } while (0)
231 237
232 /* cmp GPR, GPR */ 238 /* cmp GPR, GPR */
233 TestRegReg(cmp, eax, ecx, i32, 2, 0x3B, 0xC1); 239 TestRegReg(cmp, eax, ecx, i32, 2, 0x3B, 0xC1);
234 TestRegReg(cmp, ecx, edx, i32, 2, 0x3B, 0xCA); 240 TestRegReg(cmp, ecx, edx, i32, 2, 0x3B, 0xCA);
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 EXPECT_FLOAT_EQ(1.0f, test.contentsOfDword<float>(S0)); 707 EXPECT_FLOAT_EQ(1.0f, test.contentsOfDword<float>(S0));
702 EXPECT_FLOAT_EQ(2.0f, test.contentsOfDword<float>(S1)); 708 EXPECT_FLOAT_EQ(2.0f, test.contentsOfDword<float>(S1));
703 EXPECT_FLOAT_EQ(3.0f, test.contentsOfDword<float>(S2)); 709 EXPECT_FLOAT_EQ(3.0f, test.contentsOfDword<float>(S2));
704 EXPECT_FLOAT_EQ(4.0f, test.contentsOfDword<float>(S3)); 710 EXPECT_FLOAT_EQ(4.0f, test.contentsOfDword<float>(S3));
705 } 711 }
706 712
707 } // end of anonymous namespace 713 } // end of anonymous namespace
708 } // end of namespace Test 714 } // end of namespace Test
709 } // end of namespace X8632 715 } // end of namespace X8632
710 } // end of namespace Ice 716 } // end of namespace Ice
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698