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

Side by Side Diff: src/IceRegistersX8664.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 | « src/IceRegistersX8632.h ('k') | src/IceTargetLowering.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/src/IceRegistersX8664.h - Register information ---*- C++ -*-===// 1 //===- subzero/src/IceRegistersX8664.h - Register information ---*- C++ -*-===//
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 /// 9 ///
10 /// \file 10 /// \file
11 /// This file declares the registers and their encodings for x86-64. 11 /// This file declares the registers and their encodings for x86-64.
12 /// 12 ///
13 //===----------------------------------------------------------------------===// 13 //===----------------------------------------------------------------------===//
14 14
15 #ifndef SUBZERO_SRC_ICEREGISTERSX8664_H 15 #ifndef SUBZERO_SRC_ICEREGISTERSX8664_H
16 #define SUBZERO_SRC_ICEREGISTERSX8664_H 16 #define SUBZERO_SRC_ICEREGISTERSX8664_H
17 17
18 #include "IceDefs.h" 18 #include "IceDefs.h"
19 #include "IceInstX8664.def" 19 #include "IceInstX8664.def"
20 #include "IceTypes.h" 20 #include "IceTypes.h"
21 21
22 namespace Ice { 22 namespace Ice {
23 23
24 class RegX8664 { 24 class RegX8664 {
25 public: 25 public:
26 /// An enum of every register. The enum value may not match the encoding used 26 /// An enum of every register. The enum value may not match the encoding used
27 /// to binary encode register operands in instructions. 27 /// to binary encode register operands in instructions.
28 enum AllRegisters { 28 enum AllRegisters {
29 #define X(val, encode, name64, name, name16, name8, scratch, preserved, \ 29 #define X(val, encode, name, base, scratch, preserved, stackptr, frameptr, \
30 stackptr, frameptr, isInt, isFP) \ 30 isGPR, is64, is32, is16, is8, isXmm, is64To8, is32To8, is16To8, \
31 isTrunc8Rcvr, isAhRcvr, aliases) \
31 val, 32 val,
32 REGX8664_TABLE 33 REGX8664_TABLE
33 #undef X 34 #undef X
34 Reg_NUM, 35 Reg_NUM
35 #define X(val, init) val init,
36 REGX8664_TABLE_BOUNDS
37 #undef X
38 }; 36 };
39 37
40 /// An enum of GPR Registers. The enum value does match the encoding used to 38 /// An enum of GPR Registers. The enum value does match the encoding used to
41 /// binary encode register operands in instructions. 39 /// binary encode register operands in instructions.
42 enum GPRRegister { 40 enum GPRRegister {
43 #define X(val, encode, name64, name, name16, name8, scratch, preserved, \ 41 #define X(val, encode, name, base, scratch, preserved, stackptr, frameptr, \
44 stackptr, frameptr, isInt, isFP) \ 42 isGPR, is64, is32, is16, is8, isXmm, is64To8, is32To8, is16To8, \
45 Encoded_##val encode, 43 isTrunc8Rcvr, isAhRcvr, aliases) \
44 Encoded_##val = encode,
46 REGX8664_GPR_TABLE 45 REGX8664_GPR_TABLE
47 #undef X 46 #undef X
48 Encoded_Not_GPR = -1 47 Encoded_Not_GPR = -1
49 }; 48 };
50 49
51 /// An enum of XMM Registers. The enum value does match the encoding used to 50 /// An enum of XMM Registers. The enum value does match the encoding used to
52 /// binary encode register operands in instructions. 51 /// binary encode register operands in instructions.
53 enum XmmRegister { 52 enum XmmRegister {
54 #define X(val, encode, name64, name, name16, name8, scratch, preserved, \ 53 #define X(val, encode, name, base, scratch, preserved, stackptr, frameptr, \
55 stackptr, frameptr, isInt, isFP) \ 54 isGPR, is64, is32, is16, is8, isXmm, is64To8, is32To8, is16To8, \
56 Encoded_##val encode, 55 isTrunc8Rcvr, isAhRcvr, aliases) \
56 Encoded_##val = encode,
57 REGX8664_XMM_TABLE 57 REGX8664_XMM_TABLE
58 #undef X 58 #undef X
59 Encoded_Not_Xmm = -1 59 Encoded_Not_Xmm = -1
60 }; 60 };
61 61
62 /// An enum of Byte Registers. The enum value does match the encoding used to 62 /// An enum of Byte Registers. The enum value does match the encoding used to
63 /// binary encode register operands in instructions. 63 /// binary encode register operands in instructions.
64 enum ByteRegister { 64 enum ByteRegister {
65 #define X(val, encode) Encoded_##val encode, 65 #define X(val, encode, name, base, scratch, preserved, stackptr, frameptr, \
66 isGPR, is64, is32, is16, is8, isXmm, is64To8, is32To8, is16To8, \
67 isTrunc8Rcvr, isAhRcvr, aliases) \
68 Encoded_8_##val = encode,
66 REGX8664_BYTEREG_TABLE 69 REGX8664_BYTEREG_TABLE
67 #undef X 70 #undef X
68 Encoded_Not_ByteReg = -1 71 Encoded_Not_ByteReg = -1
69 }; 72 };
70
71 static inline GPRRegister getEncodedGPR(int32_t RegNum) {
72 assert(Reg_GPR_First <= RegNum);
73 assert(RegNum <= Reg_GPR_Last);
74 return GPRRegister(RegNum - Reg_GPR_First);
75 }
76
77 static inline XmmRegister getEncodedXmm(int32_t RegNum) {
78 assert(Reg_XMM_First <= RegNum);
79 assert(RegNum <= Reg_XMM_Last);
80 return XmmRegister(RegNum - Reg_XMM_First);
81 }
82
83 static inline ByteRegister getEncodedByteReg(int32_t RegNum) {
84 assert(Reg_GPR_First <= RegNum);
85 assert(RegNum <= Reg_GPR_Last);
86 return ByteRegister(RegNum - Reg_GPR_First);
87 }
88
89 static inline GPRRegister getEncodedByteRegOrGPR(Type Ty, int32_t RegNum) {
90 if (isByteSizedType(Ty))
91 return GPRRegister(getEncodedByteReg(RegNum));
92 else
93 return getEncodedGPR(RegNum);
94 }
95 }; 73 };
96 74
97 } // end of namespace Ice 75 } // end of namespace Ice
98 76
99 #endif // SUBZERO_SRC_ICEREGISTERSX8664_H 77 #endif // SUBZERO_SRC_ICEREGISTERSX8664_H
OLDNEW
« no previous file with comments | « src/IceRegistersX8632.h ('k') | src/IceTargetLowering.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698