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

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

Issue 1419903002: Subzero: Refactor x86 register definitions to use the alias mechanism. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Add some comments 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/AssemblerX8664/GPRArith.cpp -----------------------===// 1 //===- subzero/unittest/AssemblerX8664/GPRArith.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 23 matching lines...) Expand all
34 do { \ 34 do { \
35 static constexpr char TestString[] = \ 35 static constexpr char TestString[] = \
36 "(" #C ", " #Dest ", " #IsTrue ", " #Src0 ", " #Value0 ", " #Src1 \ 36 "(" #C ", " #Dest ", " #IsTrue ", " #Src0 ", " #Value0 ", " #Src1 \
37 ", " #Value1 ")"; \ 37 ", " #Value1 ")"; \
38 const uint32_t T0 = allocateDword(); \ 38 const uint32_t T0 = allocateDword(); \
39 constexpr uint32_t V0 = 0xF00F00; \ 39 constexpr uint32_t V0 = 0xF00F00; \
40 __ mov(IceType_i32, Encoded_GPR_##Src0(), Immediate(Value0)); \ 40 __ mov(IceType_i32, Encoded_GPR_##Src0(), Immediate(Value0)); \
41 __ mov(IceType_i32, Encoded_GPR_##Src1(), Immediate(Value1)); \ 41 __ mov(IceType_i32, Encoded_GPR_##Src1(), Immediate(Value1)); \
42 __ cmp(IceType_i32, Encoded_GPR_##Src0(), Encoded_GPR_##Src1()); \ 42 __ cmp(IceType_i32, Encoded_GPR_##Src0(), Encoded_GPR_##Src1()); \
43 __ mov(IceType_i32, Encoded_GPR_##Dest(), Immediate(0)); \ 43 __ mov(IceType_i32, Encoded_GPR_##Dest(), Immediate(0)); \
44 __ setcc(Cond::Br_##C, RegX8664::getEncodedByteReg(Encoded_GPR_##Dest())); \ 44 __ setcc(Cond::Br_##C, RegX8664::getEncodedGPR(Encoded_GPR_##Dest())); \
45 __ setcc(Cond::Br_##C, dwordAddress(T0)); \ 45 __ setcc(Cond::Br_##C, dwordAddress(T0)); \
46 \ 46 \
47 AssembledTest test = assemble(); \ 47 AssembledTest test = assemble(); \
48 test.setDwordTo(T0, V0); \ 48 test.setDwordTo(T0, V0); \
49 \ 49 \
50 test.run(); \ 50 test.run(); \
51 \ 51 \
52 ASSERT_EQ(IsTrue, test.Dest()) << TestString; \ 52 ASSERT_EQ(IsTrue, test.Dest()) << TestString; \
53 ASSERT_EQ((0xF00F00 | IsTrue), test.contentsOfDword(T0)) << TestString; \ 53 ASSERT_EQ((0xF00F00 | IsTrue), test.contentsOfDword(T0)) << TestString; \
54 reset(); \ 54 reset(); \
(...skipping 1693 matching lines...) Expand 10 before | Expand all | Expand 10 after
1748 TEST_F(AssemblerX8664Test, Bt) { 1748 TEST_F(AssemblerX8664Test, Bt) {
1749 #define TestImpl(Dst, Value0, Src, Value1) \ 1749 #define TestImpl(Dst, Value0, Src, Value1) \
1750 do { \ 1750 do { \
1751 static constexpr char TestString[] = \ 1751 static constexpr char TestString[] = \
1752 "(" #Dst ", " #Value0 ", " #Src ", " #Value1 ")"; \ 1752 "(" #Dst ", " #Value0 ", " #Src ", " #Value1 ")"; \
1753 static constexpr uint32_t Expected = ((Value0) & (1u << (Value1))) != 0; \ 1753 static constexpr uint32_t Expected = ((Value0) & (1u << (Value1))) != 0; \
1754 \ 1754 \
1755 __ mov(IceType_i32, Encoded_GPR_##Dst(), Immediate(Value0)); \ 1755 __ mov(IceType_i32, Encoded_GPR_##Dst(), Immediate(Value0)); \
1756 __ mov(IceType_i32, Encoded_GPR_##Src(), Immediate(Value1)); \ 1756 __ mov(IceType_i32, Encoded_GPR_##Src(), Immediate(Value1)); \
1757 __ bt(Encoded_GPR_##Dst(), Encoded_GPR_##Src()); \ 1757 __ bt(Encoded_GPR_##Dst(), Encoded_GPR_##Src()); \
1758 __ setcc(Cond::Br_b, ByteRegister::Encoded_Reg_al); \ 1758 __ setcc(Cond::Br_b, GPRRegister::Encoded_Reg_al); \
1759 __ And(IceType_i32, Encoded_GPR_eax(), Immediate(0xFFu)); \ 1759 __ And(IceType_i32, Encoded_GPR_eax(), Immediate(0xFFu)); \
1760 \ 1760 \
1761 AssembledTest test = assemble(); \ 1761 AssembledTest test = assemble(); \
1762 test.run(); \ 1762 test.run(); \
1763 \ 1763 \
1764 ASSERT_EQ(Expected, test.eax()) << TestString; \ 1764 ASSERT_EQ(Expected, test.eax()) << TestString; \
1765 reset(); \ 1765 reset(); \
1766 } while (0) 1766 } while (0)
1767 1767
1768 TestImpl(r1, 0x08000000, r2, 27u); 1768 TestImpl(r1, 0x08000000, r2, 27u);
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
1896 #undef TestImplValue 1896 #undef TestImplValue
1897 #undef TestImplSize 1897 #undef TestImplSize
1898 #undef TestImplRegAddr 1898 #undef TestImplRegAddr
1899 #undef TestImplRegReg 1899 #undef TestImplRegReg
1900 } 1900 }
1901 1901
1902 } // end of anonymous namespace 1902 } // end of anonymous namespace
1903 } // end of namespace Test 1903 } // end of namespace Test
1904 } // end of namespace X8664 1904 } // end of namespace X8664
1905 } // end of namespace Ice 1905 } // end of namespace Ice
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698