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

Side by Side Diff: unittest/AssemblerX8664/TestUtil.h

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: Fix assembler unit tests. Fix register names. Code review changes. Rebase 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
« no previous file with comments | « unittest/AssemblerX8664/LowLevel.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 1
2 //===- subzero/unittest/unittest/AssemblerX8664/TestUtil.h ------*- C++ -*-===// 2 //===- subzero/unittest/unittest/AssemblerX8664/TestUtil.h ------*- C++ -*-===//
3 // 3 //
4 // The Subzero Code Generator 4 // The Subzero Code Generator
5 // 5 //
6 // This file is distributed under the University of Illinois Open Source 6 // This file is distributed under the University of Illinois Open Source
7 // License. See LICENSE.TXT for details. 7 // License. See LICENSE.TXT for details.
8 // 8 //
9 //===----------------------------------------------------------------------===// 9 //===----------------------------------------------------------------------===//
10 // 10 //
(...skipping 11 matching lines...) Expand all
22 #include <cassert> 22 #include <cassert>
23 #include <sys/mman.h> 23 #include <sys/mman.h>
24 24
25 namespace Ice { 25 namespace Ice {
26 namespace X8664 { 26 namespace X8664 {
27 namespace Test { 27 namespace Test {
28 28
29 class AssemblerX8664TestBase : public ::testing::Test { 29 class AssemblerX8664TestBase : public ::testing::Test {
30 protected: 30 protected:
31 using Address = AssemblerX8664::Traits::Address; 31 using Address = AssemblerX8664::Traits::Address;
32 using ByteRegister = AssemblerX8664::Traits::ByteRegister;
33 using Cond = AssemblerX8664::Traits::Cond; 32 using Cond = AssemblerX8664::Traits::Cond;
34 using GPRRegister = AssemblerX8664::Traits::GPRRegister; 33 using GPRRegister = AssemblerX8664::Traits::GPRRegister;
34 using ByteRegister = AssemblerX8664::Traits::ByteRegister;
35 using Traits = AssemblerX8664::Traits; 35 using Traits = AssemblerX8664::Traits;
36 using XmmRegister = AssemblerX8664::Traits::XmmRegister; 36 using XmmRegister = AssemblerX8664::Traits::XmmRegister;
37 37
38 // The following are "nicknames" for all possible GPRs in x86-64. With those, we 38 // The following are "nicknames" for all possible GPRs in x86-64. With those, we
39 // can use, e.g., 39 // can use, e.g.,
40 // 40 //
41 // Encoded_GPR_al() 41 // Encoded_GPR_al()
42 // 42 //
43 // instead of GPRRegister::Encoded_Reg_eax for 8 bit operands. They also 43 // instead of GPRRegister::Encoded_Reg_eax for 8 bit operands. They also
44 // introduce "regular" nicknames for legacy x86-32 register (e.g., eax becomes 44 // introduce "regular" nicknames for legacy x86-32 register (e.g., eax becomes
45 // r1; esp, r0). 45 // r1; esp, r0).
46 #define LegacyRegAliases(NewName, Name64, Name32, Name16, Name8) \ 46 #define LegacyRegAliases(NewName, Name64, Name32, Name16, Name8) \
47 static constexpr GPRRegister Encoded_GPR_##NewName() { \ 47 static constexpr GPRRegister Encoded_GPR_##NewName() { \
48 return GPRRegister::Encoded_Reg_##Name32; \ 48 return GPRRegister::Encoded_Reg_##Name32; \
49 } \ 49 } \
50 static constexpr GPRRegister Encoded_GPR_##NewName##q() { \ 50 static constexpr GPRRegister Encoded_GPR_##NewName##q() { \
51 return GPRRegister::Encoded_Reg_##Name32; \ 51 return GPRRegister::Encoded_Reg_##Name32; \
52 } \ 52 } \
53 static constexpr GPRRegister Encoded_GPR_##NewName##d() { \ 53 static constexpr GPRRegister Encoded_GPR_##NewName##d() { \
54 return GPRRegister::Encoded_Reg_##Name32; \ 54 return GPRRegister::Encoded_Reg_##Name32; \
55 } \ 55 } \
56 static constexpr GPRRegister Encoded_GPR_##NewName##w() { \ 56 static constexpr GPRRegister Encoded_GPR_##NewName##w() { \
57 return GPRRegister::Encoded_Reg_##Name32; \ 57 return GPRRegister::Encoded_Reg_##Name32; \
58 } \ 58 } \
59 static constexpr GPRRegister Encoded_GPR_##NewName##l() { \ 59 static constexpr GPRRegister Encoded_GPR_##NewName##l() { \
60 return GPRRegister::Encoded_Reg_##Name32; \ 60 return GPRRegister::Encoded_Reg_##Name32; \
61 } \ 61 } \
62 static constexpr ByteRegister Encoded_Bytereg_##NewName() { \
63 return ByteRegister::Encoded_8_Reg_##Name8; \
64 } \
62 static constexpr GPRRegister Encoded_GPR_##Name64() { \ 65 static constexpr GPRRegister Encoded_GPR_##Name64() { \
63 return GPRRegister::Encoded_Reg_##Name32; \ 66 return GPRRegister::Encoded_Reg_##Name32; \
64 } \ 67 } \
65 static constexpr GPRRegister Encoded_GPR_##Name32() { \ 68 static constexpr GPRRegister Encoded_GPR_##Name32() { \
66 return GPRRegister::Encoded_Reg_##Name32; \ 69 return GPRRegister::Encoded_Reg_##Name32; \
67 } \ 70 } \
68 static constexpr GPRRegister Encoded_GPR_##Name16() { \ 71 static constexpr GPRRegister Encoded_GPR_##Name16() { \
69 return GPRRegister::Encoded_Reg_##Name32; \ 72 return GPRRegister::Encoded_Reg_##Name32; \
70 } \ 73 } \
71 static constexpr GPRRegister Encoded_GPR_##Name8() { \ 74 static constexpr GPRRegister Encoded_GPR_##Name8() { \
72 return GPRRegister::Encoded_Reg_##Name32; \ 75 return GPRRegister::Encoded_Reg_##Name32; \
73 } 76 }
74 #define NewRegAliases(Name) \ 77 #define NewRegAliases(Name) \
75 static constexpr GPRRegister Encoded_GPR_##Name() { \ 78 static constexpr GPRRegister Encoded_GPR_##Name() { \
76 return GPRRegister::Encoded_Reg_##Name##d; \ 79 return GPRRegister::Encoded_Reg_##Name##d; \
77 } \ 80 } \
78 static constexpr GPRRegister Encoded_GPR_##Name##q() { \ 81 static constexpr GPRRegister Encoded_GPR_##Name##q() { \
79 return GPRRegister::Encoded_Reg_##Name##d; \ 82 return GPRRegister::Encoded_Reg_##Name##d; \
80 } \ 83 } \
81 static constexpr GPRRegister Encoded_GPR_##Name##d() { \ 84 static constexpr GPRRegister Encoded_GPR_##Name##d() { \
82 return GPRRegister::Encoded_Reg_##Name##d; \ 85 return GPRRegister::Encoded_Reg_##Name##d; \
83 } \ 86 } \
84 static constexpr GPRRegister Encoded_GPR_##Name##w() { \ 87 static constexpr GPRRegister Encoded_GPR_##Name##w() { \
85 return GPRRegister::Encoded_Reg_##Name##d; \ 88 return GPRRegister::Encoded_Reg_##Name##d; \
86 } \ 89 } \
87 static constexpr GPRRegister Encoded_GPR_##Name##l() { \ 90 static constexpr GPRRegister Encoded_GPR_##Name##l() { \
88 return GPRRegister::Encoded_Reg_##Name##d; \ 91 return GPRRegister::Encoded_Reg_##Name##d; \
92 } \
93 static constexpr ByteRegister Encoded_Bytereg_##Name() { \
94 return ByteRegister::Encoded_8_Reg_##Name##l; \
89 } 95 }
90 #define XmmRegAliases(Name) \ 96 #define XmmRegAliases(Name) \
91 static constexpr XmmRegister Encoded_Xmm_##Name() { \ 97 static constexpr XmmRegister Encoded_Xmm_##Name() { \
92 return XmmRegister::Encoded_Reg_##Name; \ 98 return XmmRegister::Encoded_Reg_##Name; \
93 } 99 }
94 LegacyRegAliases(r0, rsp, esp, sp, spl); 100 LegacyRegAliases(r0, rsp, esp, sp, spl);
95 LegacyRegAliases(r1, rax, eax, ax, al); 101 LegacyRegAliases(r1, rax, eax, ax, al);
96 LegacyRegAliases(r2, rbx, ebx, bx, bl); 102 LegacyRegAliases(r2, rbx, ebx, bx, bl);
97 LegacyRegAliases(r3, rcx, ecx, cx, cl); 103 LegacyRegAliases(r3, rcx, ecx, cx, cl);
98 LegacyRegAliases(r4, rdx, edx, dx, dl); 104 LegacyRegAliases(r4, rdx, edx, dx, dl);
(...skipping 989 matching lines...) Expand 10 before | Expand all | Expand 10 after
1088 1094
1089 bool NeedsEpilogue; 1095 bool NeedsEpilogue;
1090 uint32_t NumAllocatedDwords; 1096 uint32_t NumAllocatedDwords;
1091 }; 1097 };
1092 1098
1093 } // end of namespace Test 1099 } // end of namespace Test
1094 } // end of namespace X8664 1100 } // end of namespace X8664
1095 } // end of namespace Ice 1101 } // end of namespace Ice
1096 1102
1097 #endif // ASSEMBLERX8664_TESTUTIL_H_ 1103 #endif // ASSEMBLERX8664_TESTUTIL_H_
OLDNEW
« no previous file with comments | « unittest/AssemblerX8664/LowLevel.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698