• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===- subzero/src/IceRegistersX8632.h - Register information ---*- C++ -*-===//
2 //
3 //                        The Subzero Code Generator
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 ///
10 /// \file
11 /// \brief Declares the registers and their encodings for x86-32.
12 ///
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef SUBZERO_SRC_ICEREGISTERSX8632_H
16 #define SUBZERO_SRC_ICEREGISTERSX8632_H
17 
18 #include "IceDefs.h"
19 #include "IceInstX8632.def"
20 #include "IceTypes.h"
21 
22 namespace Ice {
23 
24 class RegX8632 {
25 public:
26   /// An enum of every register. The enum value may not match the encoding used
27   /// to binary encode register operands in instructions.
28   enum AllRegisters {
29 #define X(val, encode, name, base, scratch, preserved, stackptr, frameptr,     \
30           isGPR, is64, is32, is16, is8, isXmm, is64To8, is32To8, is16To8,      \
31           isTrunc8Rcvr, isAhRcvr, aliases)                                     \
32   val,
33     REGX8632_TABLE
34 #undef X
35         Reg_NUM
36   };
37 
38   /// An enum of GPR Registers. The enum value does match the encoding used to
39   /// binary encode register operands in instructions.
40   enum GPRRegister {
41 #define X(val, encode, name, base, scratch, preserved, stackptr, frameptr,     \
42           isGPR, is64, is32, is16, is8, isXmm, is64To8, is32To8, is16To8,      \
43           isTrunc8Rcvr, isAhRcvr, aliases)                                     \
44   Encoded_##val = encode,
45     REGX8632_GPR_TABLE
46 #undef X
47         Encoded_Not_GPR = -1
48   };
49 
50   /// An enum of XMM Registers. The enum value does match the encoding used to
51   /// binary encode register operands in instructions.
52   enum XmmRegister {
53 #define X(val, encode, name, base, scratch, preserved, stackptr, frameptr,     \
54           isGPR, is64, is32, is16, is8, isXmm, is64To8, is32To8, is16To8,      \
55           isTrunc8Rcvr, isAhRcvr, aliases)                                     \
56   Encoded_##val = encode,
57     REGX8632_XMM_TABLE
58 #undef X
59         Encoded_Not_Xmm = -1
60   };
61 
62   /// An enum of Byte Registers. The enum value does match the encoding used to
63   /// binary encode register operands in instructions.
64   enum ByteRegister {
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,
69     REGX8632_BYTEREG_TABLE
70 #undef X
71         Encoded_Not_ByteReg = -1
72   };
73 
74   /// An enum of X87 Stack Registers. The enum value does match the encoding
75   /// used to binary encode register operands in instructions.
76   enum X87STRegister {
77 #define X(val, encode, name) Encoded_##val = encode,
78     X87ST_REGX8632_TABLE
79 #undef X
80         Encoded_Not_X87STReg = -1
81   };
82 
getEncodedSTReg(uint32_t X87RegNum)83   static inline X87STRegister getEncodedSTReg(uint32_t X87RegNum) {
84     assert(int(Encoded_X87ST_First) <= int(X87RegNum));
85     assert(X87RegNum <= Encoded_X87ST_Last);
86     return X87STRegister(X87RegNum);
87   }
88 };
89 
90 } // end of namespace Ice
91 
92 #endif // SUBZERO_SRC_ICEREGISTERSX8632_H
93