Jan Voung | bd385e4 | 2014-09-18 18:18:10 -0700 | [diff] [blame] | 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 | //===----------------------------------------------------------------------===// |
Andrew Scull | 9612d32 | 2015-07-06 14:53:25 -0700 | [diff] [blame] | 9 | /// |
| 10 | /// \file |
Jim Stichnoth | 92a6e5b | 2015-12-02 16:52:44 -0800 | [diff] [blame] | 11 | /// \brief Declares the registers and their encodings for x86-32. |
Andrew Scull | 9612d32 | 2015-07-06 14:53:25 -0700 | [diff] [blame] | 12 | /// |
Jan Voung | bd385e4 | 2014-09-18 18:18:10 -0700 | [diff] [blame] | 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #ifndef SUBZERO_SRC_ICEREGISTERSX8632_H |
| 16 | #define SUBZERO_SRC_ICEREGISTERSX8632_H |
| 17 | |
| 18 | #include "IceDefs.h" |
| 19 | #include "IceInstX8632.def" |
Jan Voung | 3b43b89 | 2014-09-24 13:32:39 -0700 | [diff] [blame] | 20 | #include "IceTypes.h" |
Jan Voung | bd385e4 | 2014-09-18 18:18:10 -0700 | [diff] [blame] | 21 | |
| 22 | namespace Ice { |
| 23 | |
John Porto | 5d0acff | 2015-06-30 15:29:21 -0700 | [diff] [blame] | 24 | class RegX8632 { |
| 25 | public: |
Andrew Scull | 57e1268 | 2015-09-16 11:30:19 -0700 | [diff] [blame] | 26 | /// An enum of every register. The enum value may not match the encoding used |
| 27 | /// to binary encode register operands in instructions. |
John Porto | 5d0acff | 2015-06-30 15:29:21 -0700 | [diff] [blame] | 28 | enum AllRegisters { |
Jim Stichnoth | 5bff61c | 2015-10-28 09:26:00 -0700 | [diff] [blame] | 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) \ |
Jan Voung | bd385e4 | 2014-09-18 18:18:10 -0700 | [diff] [blame] | 32 | val, |
John Porto | 5d0acff | 2015-06-30 15:29:21 -0700 | [diff] [blame] | 33 | REGX8632_TABLE |
Jan Voung | bd385e4 | 2014-09-18 18:18:10 -0700 | [diff] [blame] | 34 | #undef X |
Jim Stichnoth | 5bff61c | 2015-10-28 09:26:00 -0700 | [diff] [blame] | 35 | Reg_NUM |
John Porto | 5d0acff | 2015-06-30 15:29:21 -0700 | [diff] [blame] | 36 | }; |
Jan Voung | bd385e4 | 2014-09-18 18:18:10 -0700 | [diff] [blame] | 37 | |
Andrew Scull | 57e1268 | 2015-09-16 11:30:19 -0700 | [diff] [blame] | 38 | /// An enum of GPR Registers. The enum value does match the encoding used to |
| 39 | /// binary encode register operands in instructions. |
John Porto | 5d0acff | 2015-06-30 15:29:21 -0700 | [diff] [blame] | 40 | enum GPRRegister { |
Jim Stichnoth | 5bff61c | 2015-10-28 09:26:00 -0700 | [diff] [blame] | 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) \ |
Jim Stichnoth | 728c1d4 | 2015-07-15 09:00:07 -0700 | [diff] [blame] | 44 | Encoded_##val = encode, |
John Porto | 5d0acff | 2015-06-30 15:29:21 -0700 | [diff] [blame] | 45 | REGX8632_GPR_TABLE |
Jan Voung | 8acded0 | 2014-09-22 18:02:25 -0700 | [diff] [blame] | 46 | #undef X |
John Porto | 5d0acff | 2015-06-30 15:29:21 -0700 | [diff] [blame] | 47 | Encoded_Not_GPR = -1 |
| 48 | }; |
Jan Voung | 8acded0 | 2014-09-22 18:02:25 -0700 | [diff] [blame] | 49 | |
Andrew Scull | 57e1268 | 2015-09-16 11:30:19 -0700 | [diff] [blame] | 50 | /// An enum of XMM Registers. The enum value does match the encoding used to |
| 51 | /// binary encode register operands in instructions. |
John Porto | 5d0acff | 2015-06-30 15:29:21 -0700 | [diff] [blame] | 52 | enum XmmRegister { |
Jim Stichnoth | 5bff61c | 2015-10-28 09:26:00 -0700 | [diff] [blame] | 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) \ |
Jim Stichnoth | 728c1d4 | 2015-07-15 09:00:07 -0700 | [diff] [blame] | 56 | Encoded_##val = encode, |
John Porto | 5d0acff | 2015-06-30 15:29:21 -0700 | [diff] [blame] | 57 | REGX8632_XMM_TABLE |
Jan Voung | 8acded0 | 2014-09-22 18:02:25 -0700 | [diff] [blame] | 58 | #undef X |
John Porto | 5d0acff | 2015-06-30 15:29:21 -0700 | [diff] [blame] | 59 | Encoded_Not_Xmm = -1 |
| 60 | }; |
Jan Voung | 8acded0 | 2014-09-22 18:02:25 -0700 | [diff] [blame] | 61 | |
Andrew Scull | 57e1268 | 2015-09-16 11:30:19 -0700 | [diff] [blame] | 62 | /// An enum of Byte Registers. The enum value does match the encoding used to |
| 63 | /// binary encode register operands in instructions. |
John Porto | 5d0acff | 2015-06-30 15:29:21 -0700 | [diff] [blame] | 64 | enum ByteRegister { |
Jim Stichnoth | 5bff61c | 2015-10-28 09:26:00 -0700 | [diff] [blame] | 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, |
John Porto | 5d0acff | 2015-06-30 15:29:21 -0700 | [diff] [blame] | 69 | REGX8632_BYTEREG_TABLE |
Jan Voung | 8acded0 | 2014-09-22 18:02:25 -0700 | [diff] [blame] | 70 | #undef X |
John Porto | 5d0acff | 2015-06-30 15:29:21 -0700 | [diff] [blame] | 71 | Encoded_Not_ByteReg = -1 |
| 72 | }; |
Jan Voung | 8acded0 | 2014-09-22 18:02:25 -0700 | [diff] [blame] | 73 | |
Andrew Scull | 87f80c1 | 2015-07-20 10:19:16 -0700 | [diff] [blame] | 74 | /// An enum of X87 Stack Registers. The enum value does match the encoding |
| 75 | /// used to binary encode register operands in instructions. |
John Porto | 5d0acff | 2015-06-30 15:29:21 -0700 | [diff] [blame] | 76 | enum X87STRegister { |
Jim Stichnoth | 5bff61c | 2015-10-28 09:26:00 -0700 | [diff] [blame] | 77 | #define X(val, encode, name) Encoded_##val = encode, |
John Porto | 5d0acff | 2015-06-30 15:29:21 -0700 | [diff] [blame] | 78 | X87ST_REGX8632_TABLE |
Jan Voung | 479e563 | 2014-10-08 21:05:27 -0700 | [diff] [blame] | 79 | #undef X |
John Porto | 5d0acff | 2015-06-30 15:29:21 -0700 | [diff] [blame] | 80 | Encoded_Not_X87STReg = -1 |
| 81 | }; |
| 82 | |
Jim Stichnoth | 8aa3966 | 2016-02-10 11:20:30 -0800 | [diff] [blame] | 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); |
John Porto | 5d0acff | 2015-06-30 15:29:21 -0700 | [diff] [blame] | 87 | } |
Jan Voung | 479e563 | 2014-10-08 21:05:27 -0700 | [diff] [blame] | 88 | }; |
| 89 | |
Jan Voung | bd385e4 | 2014-09-18 18:18:10 -0700 | [diff] [blame] | 90 | } // end of namespace Ice |
| 91 | |
| 92 | #endif // SUBZERO_SRC_ICEREGISTERSX8632_H |