Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1 | //===- subzero/src/IceInstX8632.def - X-macros for x86-32 insts -*- 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 | // This file defines properties of lowered x86-32 instructions in the |
| 11 | // form of x-macros. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #ifndef SUBZERO_SRC_ICEINSTX8632_DEF |
| 16 | #define SUBZERO_SRC_ICEINSTX8632_DEF |
| 17 | |
Jan Voung | 9559899 | 2014-07-09 09:54:25 -0700 | [diff] [blame] | 18 | // NOTE: esp is not considered isInt, to avoid register allocating it. |
Jan Voung | bd385e4 | 2014-09-18 18:18:10 -0700 | [diff] [blame] | 19 | #define REGX8632_GPR_TABLE \ |
| 20 | /* val, encode, name, name16, name8, scratch, preserved, stackptr, \ |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 21 | frameptr, isI8, isInt, isFP */ \ |
| 22 | X(Reg_eax, = 0, "eax", "ax", "al", 1, 0, 0, 0, 1, 1, 0) \ |
| 23 | X(Reg_ecx, = Reg_eax + 1, "ecx", "cx", "cl", 1, 0, 0, 0, 1, 1, 0) \ |
| 24 | X(Reg_edx, = Reg_eax + 2, "edx", "dx", "dl", 1, 0, 0, 0, 1, 1, 0) \ |
| 25 | X(Reg_ebx, = Reg_eax + 3, "ebx", "bx", "bl", 0, 1, 0, 0, 1, 1, 0) \ |
Jan Voung | 9559899 | 2014-07-09 09:54:25 -0700 | [diff] [blame] | 26 | X(Reg_esp, = Reg_eax + 4, "esp", "sp", "" , 0, 0, 1, 0, 0, 0, 0) \ |
Jim Stichnoth | 4376d29 | 2014-05-23 13:39:02 -0700 | [diff] [blame] | 27 | X(Reg_ebp, = Reg_eax + 5, "ebp", "bp", "" , 0, 1, 0, 1, 0, 1, 0) \ |
| 28 | X(Reg_esi, = Reg_eax + 6, "esi", "si", "" , 0, 1, 0, 0, 0, 1, 0) \ |
Jan Voung | bd385e4 | 2014-09-18 18:18:10 -0700 | [diff] [blame] | 29 | X(Reg_edi, = Reg_eax + 7, "edi", "di", "" , 0, 1, 0, 0, 0, 1, 0) |
| 30 | |
| 31 | #define REGX8632_XMM_TABLE \ |
| 32 | X(Reg_xmm0, = 0, "xmm0", "" , "" , 1, 0, 0, 0, 0, 0, 1) \ |
Jim Stichnoth | 4376d29 | 2014-05-23 13:39:02 -0700 | [diff] [blame] | 33 | X(Reg_xmm1, = Reg_xmm0 + 1, "xmm1", "" , "" , 1, 0, 0, 0, 0, 0, 1) \ |
| 34 | X(Reg_xmm2, = Reg_xmm0 + 2, "xmm2", "" , "" , 1, 0, 0, 0, 0, 0, 1) \ |
| 35 | X(Reg_xmm3, = Reg_xmm0 + 3, "xmm3", "" , "" , 1, 0, 0, 0, 0, 0, 1) \ |
| 36 | X(Reg_xmm4, = Reg_xmm0 + 4, "xmm4", "" , "" , 1, 0, 0, 0, 0, 0, 1) \ |
| 37 | X(Reg_xmm5, = Reg_xmm0 + 5, "xmm5", "" , "" , 1, 0, 0, 0, 0, 0, 1) \ |
| 38 | X(Reg_xmm6, = Reg_xmm0 + 6, "xmm6", "" , "" , 1, 0, 0, 0, 0, 0, 1) \ |
| 39 | X(Reg_xmm7, = Reg_xmm0 + 7, "xmm7", "" , "" , 1, 0, 0, 0, 0, 0, 1) \ |
Jan Voung | bd385e4 | 2014-09-18 18:18:10 -0700 | [diff] [blame] | 40 | //#define X(val, encode, name, name16, name8, scratch, preserved, stackptr, |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 41 | // frameptr, isI8, isInt, isFP) |
| 42 | |
Jan Voung | bd385e4 | 2014-09-18 18:18:10 -0700 | [diff] [blame] | 43 | // We also provide a combined table, so that there is a namespace where |
| 44 | // all of the registers are considered and have distinct numberings. |
| 45 | // This is in contrast to the above, where the "encode" is based on how |
| 46 | // the register numbers will be encoded in binaries and values can overlap. |
Jim Stichnoth | ad40353 | 2014-09-25 12:44:17 -0700 | [diff] [blame] | 47 | // Note that the isI8 attributed of Reg_ah is not set. In general we |
| 48 | // don't want the register allocator choosing Reg_ah, in particular |
| 49 | // for lowering insertelement to pinsrb where internally we use an |
| 50 | // 8-bit operand but externally pinsrb uses a 32-bit register, in |
| 51 | // which Reg_ah doesn't map to eax. |
Jan Voung | bd385e4 | 2014-09-18 18:18:10 -0700 | [diff] [blame] | 52 | #define REGX8632_TABLE \ |
| 53 | /* val, encode, name, name16, name8, scratch, preserved, stackptr, \ |
| 54 | frameptr, isI8, isInt, isFP */ \ |
| 55 | REGX8632_GPR_TABLE \ |
Jim Stichnoth | ad40353 | 2014-09-25 12:44:17 -0700 | [diff] [blame] | 56 | X(Reg_ah, = Reg_eax + 4, "???", "" , "ah", 0, 0, 0, 0, 0, 0, 0) \ |
Jan Voung | bd385e4 | 2014-09-18 18:18:10 -0700 | [diff] [blame] | 57 | REGX8632_XMM_TABLE |
| 58 | //#define X(val, encode, name, name16, name8, scratch, preserved, stackptr, |
| 59 | // frameptr, isI8, isInt, isFP) |
| 60 | |
| 61 | #define REGX8632_TABLE_BOUNDS \ |
| 62 | /* val, init */ \ |
| 63 | X(Reg_GPR_First, = Reg_eax) \ |
| 64 | X(Reg_GPR_Last, = Reg_edi) \ |
| 65 | X(Reg_XMM_First, = Reg_xmm0) \ |
| 66 | X(Reg_XMM_Last, = Reg_xmm7) \ |
| 67 | //define X(val, init) |
| 68 | |
| 69 | // We also need the encodings for the Byte registers (other info overlaps |
| 70 | // what is in the REGX8632_GPR_TABLE). |
| 71 | #define REGX8632_BYTEREG_TABLE \ |
| 72 | /* val, encode */ \ |
| 73 | X(Reg_al, = 0) \ |
| 74 | X(Reg_cl, = 1) \ |
| 75 | X(Reg_dl, = 2) \ |
| 76 | X(Reg_bl, = 3) \ |
| 77 | X(Reg_ah, = 4) |
| 78 | //#define X(val, encode) |
| 79 | |
Jan Voung | 3bd9f1a | 2014-06-18 10:50:57 -0700 | [diff] [blame] | 80 | // X86 segment registers. |
Jan Voung | fe14fb8 | 2014-10-13 15:56:32 -0700 | [diff] [blame] | 81 | #define SEG_REGX8632_TABLE \ |
| 82 | /* enum value, name, prefix */ \ |
| 83 | X(SegReg_CS, "cs", 0x2E) \ |
| 84 | X(SegReg_DS, "ds", 0x3E) \ |
| 85 | X(SegReg_ES, "es", 0x26) \ |
| 86 | X(SegReg_SS, "ss", 0x36) \ |
| 87 | X(SegReg_FS, "fs", 0x64) \ |
| 88 | X(SegReg_GS, "gs", 0x65) \ |
| 89 | //#define X(val, name, prefix) |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 90 | |
Jan Voung | 479e563 | 2014-10-08 21:05:27 -0700 | [diff] [blame] | 91 | // X87 ST(n) registers. |
| 92 | #define X87ST_REGX8632_TABLE \ |
| 93 | /* enum value, encode, name */ \ |
| 94 | X(X87ST_First, = 0, "st(0)") \ |
| 95 | X(X87ST_0, = 0, "st(0)") \ |
| 96 | X(X87ST_1, = 1, "st(1)") \ |
| 97 | X(X87ST_2, = 2, "st(2)") \ |
| 98 | X(X87ST_3, = 3, "st(3)") \ |
| 99 | X(X87ST_4, = 4, "st(4)") \ |
| 100 | X(X87ST_5, = 5, "st(5)") \ |
| 101 | X(X87ST_6, = 6, "st(6)") \ |
| 102 | X(X87ST_7, = 7, "st(7)") \ |
| 103 | X(X87ST_Last, = 7, "st(7)") \ |
| 104 | //#define X(val, encode, name) |
| 105 | |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 106 | #define ICEINSTX8632BR_TABLE \ |
Jan Voung | bd385e4 | 2014-09-18 18:18:10 -0700 | [diff] [blame] | 107 | /* enum value, encode, opposite, dump, emit */ \ |
| 108 | X(Br_o, = 0, Br_no, "o", "jo") \ |
| 109 | X(Br_no, = 1, Br_o, "no", "jno") \ |
| 110 | X(Br_b, = 2, Br_ae, "b", "jb") \ |
| 111 | X(Br_ae, = 3, Br_b, "ae", "jae") \ |
| 112 | X(Br_e, = 4, Br_ne, "e", "je") \ |
| 113 | X(Br_ne, = 5, Br_e, "ne", "jne") \ |
| 114 | X(Br_be, = 6, Br_a, "be", "jbe") \ |
| 115 | X(Br_a, = 7, Br_be, "a", "ja") \ |
| 116 | X(Br_s, = 8, Br_ns, "s", "js") \ |
| 117 | X(Br_ns, = 9, Br_s, "ns", "jns") \ |
| 118 | X(Br_p, = 10, Br_np, "p", "jp") \ |
| 119 | X(Br_np, = 11, Br_p, "np", "jnp") \ |
| 120 | X(Br_l, = 12, Br_ge, "l", "jl") \ |
| 121 | X(Br_ge, = 13, Br_l, "ge", "jge") \ |
| 122 | X(Br_le, = 14, Br_g, "le", "jle") \ |
| 123 | X(Br_g, = 15, Br_le, "g", "jg") \ |
| 124 | //#define X(tag, encode, opp, dump, emit) |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 125 | |
Matt Wala | ce0ca8f | 2014-07-24 12:34:20 -0700 | [diff] [blame] | 126 | #define ICEINSTX8632CMPPS_TABLE \ |
| 127 | /* enum value, emit */ \ |
| 128 | X(Cmpps_eq, "eq") \ |
| 129 | X(Cmpps_lt, "lt") \ |
| 130 | X(Cmpps_le, "le") \ |
| 131 | X(Cmpps_unord, "unord") \ |
| 132 | X(Cmpps_neq, "neq") \ |
| 133 | X(Cmpps_nlt, "nlt") \ |
| 134 | X(Cmpps_nle, "nle") \ |
| 135 | X(Cmpps_ord, "ord") \ |
| 136 | //#define X(tag, emit) |
| 137 | |
Jim Stichnoth | bca2f65 | 2014-11-01 10:13:54 -0700 | [diff] [blame] | 138 | #define ICETYPEX8632_TABLE \ |
| 139 | /* tag, element type, cvt, sdss, pack, width, fld */ \ |
| 140 | X(IceType_void, IceType_void, "?" , "" , "" , "", "") \ |
| 141 | X(IceType_i1, IceType_void, "si", "" , "" , "b", "") \ |
| 142 | X(IceType_i8, IceType_void, "si", "" , "" , "b", "") \ |
| 143 | X(IceType_i16, IceType_void, "si", "" , "" , "w", "") \ |
| 144 | X(IceType_i32, IceType_void, "si", "" , "" , "l", "") \ |
| 145 | X(IceType_i64, IceType_void, "si", "" , "" , "q", "") \ |
Jim Stichnoth | 8c980d0 | 2015-03-19 13:01:50 -0700 | [diff] [blame] | 146 | X(IceType_f32, IceType_void, "ss", "ss", "d", "", "s") \ |
| 147 | X(IceType_f64, IceType_void, "sd", "sd", "q", "", "l") \ |
Jim Stichnoth | bca2f65 | 2014-11-01 10:13:54 -0700 | [diff] [blame] | 148 | X(IceType_v4i1, IceType_i32 , "?" , "" , "d", "", "") \ |
| 149 | X(IceType_v8i1, IceType_i16 , "?" , "" , "w", "", "") \ |
| 150 | X(IceType_v16i1, IceType_i8 , "?" , "" , "b", "", "") \ |
| 151 | X(IceType_v16i8, IceType_i8 , "?" , "" , "b", "", "") \ |
| 152 | X(IceType_v8i16, IceType_i16 , "?" , "" , "w", "", "") \ |
| 153 | X(IceType_v4i32, IceType_i32 , "dq", "" , "d", "", "") \ |
Jim Stichnoth | 8c980d0 | 2015-03-19 13:01:50 -0700 | [diff] [blame] | 154 | X(IceType_v4f32, IceType_f32 , "ps", "" , "d", "", "") \ |
Jim Stichnoth | bca2f65 | 2014-11-01 10:13:54 -0700 | [diff] [blame] | 155 | //#define X(tag, elementty, cvt, sdss, pack, width, fld) |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 156 | |
| 157 | #endif // SUBZERO_SRC_ICEINSTX8632_DEF |