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

Side by Side Diff: unittest/AssemblerX8664/Locked.cpp

Issue 1278173009: Inline memove for small constant sizes and refactor memcpy and memset. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Created 5 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
« no previous file with comments | « unittest/AssemblerX8632/Locked.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/unittest/AssemblerX8664/Locked.cpp -------------------------===// 1 //===- subzero/unittest/AssemblerX8664/Locked.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 "AssemblerX8664/TestUtil.h" 9 #include "AssemblerX8664/TestUtil.h"
10 10
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 TestImpl(r10); 78 TestImpl(r10);
79 TestImpl(r11); 79 TestImpl(r11);
80 TestImpl(r12); 80 TestImpl(r12);
81 TestImpl(r13); 81 TestImpl(r13);
82 TestImpl(r14); 82 TestImpl(r14);
83 TestImpl(r15); 83 TestImpl(r15);
84 84
85 #undef TestImpl 85 #undef TestImpl
86 #undef TestImplSize 86 #undef TestImplSize
87 #undef TestImplAddrReg 87 #undef TestImplAddrReg
88
89 #define TestImplRegReg(Reg0, Value0, Reg1, Value1, Size) \
90 do { \
91 static constexpr char TestString[] = \
92 "(" #Reg0 "," #Value0 ", " #Reg1 ", " #Value1 ", " #Size ")"; \
93 const uint32_t V0 = (Value0)&Mask##Size; \
94 const uint32_t V1 = (Value1)&Mask##Size; \
95 \
96 __ mov(IceType_i##Size, Encoded_GPR_##Reg0(), Immediate(Value0)); \
97 __ mov(IceType_i##Size, Encoded_GPR_##Reg1(), Immediate(Value1)); \
98 __ xchg(IceType_i##Size, Encoded_GPR_##Reg0(), Encoded_GPR_##Reg1()); \
99 __ And(IceType_i32, Encoded_GPR_##Reg0(), Immediate(Mask##Size)); \
100 __ And(IceType_i32, Encoded_GPR_##Reg1(), Immediate(Mask##Size)); \
101 \
102 AssembledTest test = assemble(); \
103 test.run(); \
104 \
105 ASSERT_EQ(V0, test.Reg1()) << TestString; \
106 ASSERT_EQ(V1, test.Reg0()) << TestString; \
107 reset(); \
108 } while (0)
109
110 #define TestImplSize(Reg0, Reg1, Size) \
111 do { \
112 TestImplRegReg(Reg0, 0xa2b34567, Reg1, 0x0507ddee, Size); \
113 } while (0)
114
115 #define TestImpl(Reg0, Reg1) \
116 do { \
117 TestImplSize(Reg0, Reg1, 8); \
118 TestImplSize(Reg0, Reg1, 16); \
119 TestImplSize(Reg0, Reg1, 32); \
120 } while (0)
121
122 // r1 == rax so has a short encoding
123 TestImpl(r6, r1);
124 TestImpl(r1, r8);
125
126 TestImpl(r2, r10);
127 TestImpl(r3, r11);
128 TestImpl(r4, r12);
129 TestImpl(r5, r13);
130 TestImpl(r6, r14);
131 TestImpl(r7, r15);
132
133 #undef TestImpl
134 #undef TestImplSize
135 #undef TestImplRegReg
88 } 136 }
89 137
90 TEST_F(AssemblerX8664Test, Xadd) { 138 TEST_F(AssemblerX8664Test, Xadd) {
91 static constexpr bool NotLocked = false; 139 static constexpr bool NotLocked = false;
92 static constexpr bool Locked = true; 140 static constexpr bool Locked = true;
93 141
94 static constexpr uint32_t Mask8 = 0x000000FF; 142 static constexpr uint32_t Mask8 = 0x000000FF;
95 static constexpr uint32_t Mask16 = 0x0000FFFF; 143 static constexpr uint32_t Mask16 = 0x0000FFFF;
96 static constexpr uint32_t Mask32 = 0xFFFFFFFF; 144 static constexpr uint32_t Mask32 = 0xFFFFFFFF;
97 145
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 ASSERT_TRUE(verifyBytes<ByteCountLocked32>( 488 ASSERT_TRUE(verifyBytes<ByteCountLocked32>(
441 codeBytes(), 0xF0, 0x44, 0x0F, 0xB1, 0x35, 0x00, 0xFF, 0x01, 0x00)); 489 codeBytes(), 0xF0, 0x44, 0x0F, 0xB1, 0x35, 0x00, 0xFF, 0x01, 0x00));
442 reset(); 490 reset();
443 } 491 }
444 } 492 }
445 493
446 } // end of anonymous namespace 494 } // end of anonymous namespace
447 } // end of namespace Test 495 } // end of namespace Test
448 } // end of namespace X8664 496 } // end of namespace X8664
449 } // end of namespace Ice 497 } // end of namespace Ice
OLDNEW
« no previous file with comments | « unittest/AssemblerX8632/Locked.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698