blob: cc9b10b274c07413ff6f710caef6ca142be5b35d [file] [log] [blame]
John Porto2b186872015-06-26 13:41:00 -07001//===- subzero/src/IceInstX8664.def - X-macros for x86-64 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-64 instructions in the
11// form of x-macros.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef SUBZERO_SRC_ICEINSTX8664_DEF
16#define SUBZERO_SRC_ICEINSTX8664_DEF
17
Jim Stichnoth5bff61c2015-10-28 09:26:00 -070018#include "IceRegList.h"
John Porto2b186872015-06-26 13:41:00 -070019
Nicolas Capens73ae4fd2016-10-28 11:24:50 -040020// System V AMD64 ABI:
Jim Stichnoth5bff61c2015-10-28 09:26:00 -070021// Scratch GPRs: rax, rcx, rdx, rsi, rdi, r8, r9, r10, r11
22// Callee-save GPRs: rbx, rbp, r12, r13, r14, r15
23// Scratch XMMs: xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7,
24// xmm8, xmm9, xmm10, xmm11, xmm12, xmm13, xmm14, xmm15
Nicolas Capens73ae4fd2016-10-28 11:24:50 -040025// Microsoft x86-64 ABI:
26// Scratch GPRs: rax, rcx, rdx, r8, r9, r10, r11
27// Callee-save GPRs: rbx, rbp, rsi, rdi, r12, r13, r14, r15
28// Scratch XMMs: xmm0, xmm1, xmm2, xmm3, xmm4, xmm5
29// Callee-save XMMs: xmm6-xmm15
Manasij Mukherjeefe2caab2016-06-27 15:42:12 -070030// Scratch registers are listed first, followed by preserved registers, so
31// that the register allocator will favor scratch registers.
Jim Stichnoth5bff61c2015-10-28 09:26:00 -070032// Key to table columns:
33// val: Enum value, when a specific register is needed during lowering.
34// encode: Encoding in the integrated assembler.
35// name: Name used for the external assembler.
36// scratch: Scratch (caller-save) register.
37// preserved: Preserved (callee-save) register.
38// stackptr: This register is used as the stack pointer.
39// frameptr: This register is used as the frame pointer if needed.
John Porto56958cb2016-01-14 09:18:18 -080040// sboxres: This register is reserved in sandboxing.
Jim Stichnoth5bff61c2015-10-28 09:26:00 -070041// isGPR: This is a GPR (integer-type).
42// is64: This is a 64-bit GPR.
43// is32: This is a 32-bit GPR.
44// is16: This is a 16-bit GPR.
45// is8: This is an 8-bit GPR.
46// isXmm: This is an XMM register for FP and vector ops.
47// is64To8: A 64-bit GPR truncable to 8-bit.
48// is32To8: A 32-bit GPR truncable to 8-bit.
49// is16To8: A 16-bit GPR truncable to 8-bit.
50// isTrunc8Rcvr: An 8-bit GPR that a wider GPR trivially truncates to.
51// isAhRcvr: An 8-bit GPR that register "ah" can be assigned to.
52// aliases: List of register aliases, which need not include this register.
Nicolas Capens73ae4fd2016-10-28 11:24:50 -040053#define REGX8664_BYTEREG_TABLE2(U, W) \
John Porto56958cb2016-01-14 09:18:18 -080054 /* val, encode, name, base, scratch,preserved,stackptr,frameptr,sboxres, \
Jim Stichnoth5bff61c2015-10-28 09:26:00 -070055 isGPR,is64,is32,is16,is8, isXmm, \
56 is64To8,is32To8,is16To8,isTrunc8Rcvr,isAhRcvr, aliases */ \
57 /* 8-bit registers */ \
John Porto56958cb2016-01-14 09:18:18 -080058 X(Reg_al, 0, "al", Reg_rax, 1,0,0,0,0, 1,0,0,0,1, 0, 0,0,0,1,1, \
Jim Stichnoth5bff61c2015-10-28 09:26:00 -070059 REGLIST3(RegX8664, rax, eax, ax)) \
John Porto56958cb2016-01-14 09:18:18 -080060 X(Reg_cl, 1, "cl", Reg_rcx, 1,0,0,0,0, 1,0,0,0,1, 0, 0,0,0,1,1, \
Jim Stichnoth5bff61c2015-10-28 09:26:00 -070061 REGLIST3(RegX8664, rcx, ecx, cx)) \
John Porto56958cb2016-01-14 09:18:18 -080062 X(Reg_dl, 2, "dl", Reg_rdx, 1,0,0,0,0, 1,0,0,0,1, 0, 0,0,0,1,1, \
Jim Stichnoth5bff61c2015-10-28 09:26:00 -070063 REGLIST3(RegX8664, rdx, edx, dx)) \
John Porto56958cb2016-01-14 09:18:18 -080064 X(Reg_r8l, 8, "r8b", Reg_r8, 1,0,0,0,0, 1,0,0,0,1, 0, 0,0,0,1,0, \
Jim Stichnoth5bff61c2015-10-28 09:26:00 -070065 REGLIST3(RegX8664, r8, r8d, r8w)) \
John Porto56958cb2016-01-14 09:18:18 -080066 X(Reg_r9l, 9, "r9b", Reg_r9, 1,0,0,0,0, 1,0,0,0,1, 0, 0,0,0,1,0, \
Jim Stichnoth5bff61c2015-10-28 09:26:00 -070067 REGLIST3(RegX8664, r9, r9d, r9w)) \
John Porto56958cb2016-01-14 09:18:18 -080068 X(Reg_r10l, 10, "r10b", Reg_r10, 1,0,0,0,0, 1,0,0,0,1, 0, 0,0,0,1,0, \
Jim Stichnoth5bff61c2015-10-28 09:26:00 -070069 REGLIST3(RegX8664, r10, r10d, r10w)) \
John Porto56958cb2016-01-14 09:18:18 -080070 X(Reg_r11l, 11, "r11b", Reg_r11, 1,0,0,0,0, 1,0,0,0,1, 0, 0,0,0,1,0, \
Jim Stichnoth5bff61c2015-10-28 09:26:00 -070071 REGLIST3(RegX8664, r11, r11d, r11w)) \
Nicolas Capens73ae4fd2016-10-28 11:24:50 -040072 X(Reg_sil, 6, "sil", Reg_rsi, U,W,0,0,0, 1,0,0,0,1, 0, 0,0,0,1,0, \
73 REGLIST3(RegX8664, rsi, esi, si)) \
74 X(Reg_dil, 7, "dil", Reg_rdi, U,W,0,0,0, 1,0,0,0,1, 0, 0,0,0,1,0, \
75 REGLIST3(RegX8664, rdi, edi, di)) \
Manasij Mukherjeefe2caab2016-06-27 15:42:12 -070076 X(Reg_bl, 3, "bl", Reg_rbx, 0,1,0,0,0, 1,0,0,0,1, 0, 0,0,0,1,1, \
77 REGLIST3(RegX8664, rbx, ebx, bx)) \
78 X(Reg_spl, 4, "spl", Reg_rsp, 0,0,1,0,0, 1,0,0,0,0, 0, 0,0,0,0,0, \
79 REGLIST3(RegX8664, rsp, esp, sp)) \
80 X(Reg_bpl, 5, "bpl", Reg_rbp, 0,1,0,1,1, 1,0,0,0,1, 0, 0,0,0,1,0, \
81 REGLIST3(RegX8664, rbp, ebp, bp)) \
John Porto56958cb2016-01-14 09:18:18 -080082 X(Reg_r12l, 12, "r12b", Reg_r12, 0,1,0,0,0, 1,0,0,0,1, 0, 0,0,0,1,0, \
Jim Stichnoth5bff61c2015-10-28 09:26:00 -070083 REGLIST3(RegX8664, r12, r12d, r12w)) \
John Porto56958cb2016-01-14 09:18:18 -080084 X(Reg_r13l, 13, "r13b", Reg_r13, 0,1,0,0,0, 1,0,0,0,1, 0, 0,0,0,1,0, \
Jim Stichnoth5bff61c2015-10-28 09:26:00 -070085 REGLIST3(RegX8664, r13, r13d, r13w)) \
John Porto56958cb2016-01-14 09:18:18 -080086 X(Reg_r14l, 14, "r14b", Reg_r14, 0,1,0,0,0, 1,0,0,0,1, 0, 0,0,0,1,0, \
Jim Stichnoth5bff61c2015-10-28 09:26:00 -070087 REGLIST3(RegX8664, r14, r14d, r14w)) \
John Porto56958cb2016-01-14 09:18:18 -080088 X(Reg_r15l, 15, "r15b", Reg_r15, 0,1,0,0,1, 1,0,0,0,1, 0, 0,0,0,1,0, \
Jim Stichnoth5bff61c2015-10-28 09:26:00 -070089 REGLIST3(RegX8664, r15, r15d, r15w)) \
90 /* High 8-bit registers. None are allowed for register allocation. */ \
Jim Stichnoth2655d962016-04-21 05:38:15 -070091 X(Reg_ah, 4, "ah", Reg_rax, 1,0,0,0,0, 1,0,0,0,0, 0, 0,0,0,0,0, \
Jim Stichnoth5bff61c2015-10-28 09:26:00 -070092 REGLIST3(RegX8664, rax, eax, ax)) \
Jim Stichnoth2655d962016-04-21 05:38:15 -070093 X(Reg_ch, 5, "ch", Reg_rcx, 1,0,0,0,0, 1,0,0,0,0, 0, 0,0,0,0,0, \
Jim Stichnoth5bff61c2015-10-28 09:26:00 -070094 REGLIST3(RegX8664, rcx, ecx, cx)) \
Jim Stichnoth2655d962016-04-21 05:38:15 -070095 X(Reg_dh, 6, "dh", Reg_rdx, 1,0,0,0,0, 1,0,0,0,0, 0, 0,0,0,0,0, \
Jim Stichnoth5bff61c2015-10-28 09:26:00 -070096 REGLIST3(RegX8664, rdx, edx, dx)) \
Jim Stichnoth2655d962016-04-21 05:38:15 -070097 X(Reg_bh, 7, "bh", Reg_rbx, 0,1,0,0,0, 1,0,0,0,0, 0, 0,0,0,0,0, \
Jim Stichnoth5bff61c2015-10-28 09:26:00 -070098 REGLIST3(RegX8664, rbx, ebx, bx)) \
99 /* End of 8-bit register set */
100//#define X(val, encode, name, base, scratch, preserved, stackptr, frameptr,
John Porto56958cb2016-01-14 09:18:18 -0800101// sboxres, isGPR, is64, is32, is16, is8, isXmm, is64To8, is32To8,
102// is16To8, isTrunc8Rcvr, isAhRcvr, aliases)
Jim Stichnoth5bff61c2015-10-28 09:26:00 -0700103
Nicolas Capens73ae4fd2016-10-28 11:24:50 -0400104#define REGX8664_GPR_TABLE2(U, W) \
Jim Stichnoth5bff61c2015-10-28 09:26:00 -0700105 /* val, encode, name, base, scratch,preserved,stackptr,frameptr, \
106 isGPR,is64,is32,is16,is8, isXmm, \
107 is64To8,is32To8,is16To8,isTrunc8Rcvr,isAhRcvr, aliases */ \
108 /* 64-bit registers */ \
John Porto56958cb2016-01-14 09:18:18 -0800109 X(Reg_rax, 0, "rax", Reg_rax, 1,0,0,0,0, 1,1,0,0,0, 0, 1,0,0,0,0, \
Jim Stichnoth5bff61c2015-10-28 09:26:00 -0700110 REGLIST4(RegX8664, eax, ax, al, ah)) \
John Porto56958cb2016-01-14 09:18:18 -0800111 X(Reg_rcx, 1, "rcx", Reg_rcx, 1,0,0,0,0, 1,1,0,0,0, 0, 1,0,0,0,0, \
Jim Stichnoth5bff61c2015-10-28 09:26:00 -0700112 REGLIST4(RegX8664, ecx, cx, cl, ch)) \
John Porto56958cb2016-01-14 09:18:18 -0800113 X(Reg_rdx, 2, "rdx", Reg_rdx, 1,0,0,0,0, 1,1,0,0,0, 0, 1,0,0,0,0, \
Jim Stichnoth5bff61c2015-10-28 09:26:00 -0700114 REGLIST4(RegX8664, edx, dx, dl, dh)) \
John Porto56958cb2016-01-14 09:18:18 -0800115 X(Reg_r8, 8, "r8", Reg_r8, 1,0,0,0,0, 1,1,0,0,0, 0, 1,0,0,0,0, \
Jim Stichnoth5bff61c2015-10-28 09:26:00 -0700116 REGLIST3(RegX8664, r8d, r8w, r8l)) \
John Porto56958cb2016-01-14 09:18:18 -0800117 X(Reg_r9, 9, "r9", Reg_r9, 1,0,0,0,0, 1,1,0,0,0, 0, 1,0,0,0,0, \
Jim Stichnoth5bff61c2015-10-28 09:26:00 -0700118 REGLIST3(RegX8664, r9d, r9w, r9l)) \
John Porto56958cb2016-01-14 09:18:18 -0800119 X(Reg_r10, 10, "r10", Reg_r10, 1,0,0,0,0, 1,1,0,0,0, 0, 1,0,0,0,0, \
Jim Stichnoth5bff61c2015-10-28 09:26:00 -0700120 REGLIST3(RegX8664, r10d, r10w, r10l)) \
John Porto56958cb2016-01-14 09:18:18 -0800121 X(Reg_r11, 11, "r11", Reg_r11, 1,0,0,0,0, 1,1,0,0,0, 0, 1,0,0,0,0, \
Jim Stichnoth5bff61c2015-10-28 09:26:00 -0700122 REGLIST3(RegX8664, r11d, r11w, r11l)) \
Nicolas Capens73ae4fd2016-10-28 11:24:50 -0400123 X(Reg_rsi, 6, "rsi", Reg_rsi, U,W,0,0,0, 1,1,0,0,0, 0, 1,0,0,0,0, \
124 REGLIST3(RegX8664, esi, si, sil)) \
125 X(Reg_rdi, 7, "rdi", Reg_rdi, U,W,0,0,0, 1,1,0,0,0, 0, 1,0,0,0,0, \
126 REGLIST3(RegX8664, edi, di, dil)) \
Manasij Mukherjeefe2caab2016-06-27 15:42:12 -0700127 X(Reg_rbx, 3, "rbx", Reg_rbx, 0,1,0,0,0, 1,1,0,0,0, 0, 1,0,0,0,0, \
128 REGLIST4(RegX8664, ebx, bx, bl, bh)) \
129 X(Reg_rsp, 4, "rsp", Reg_rsp, 0,0,1,0,0, 1,0,0,0,0, 0, 1,0,0,0,0, \
130 REGLIST3(RegX8664, esp, sp, spl)) \
131 X(Reg_rbp, 5, "rbp", Reg_rbp, 0,1,0,1,1, 1,1,0,0,0, 0, 1,0,0,0,0, \
132 REGLIST3(RegX8664, ebp, bp, bpl)) \
John Porto56958cb2016-01-14 09:18:18 -0800133 X(Reg_r12, 12, "r12", Reg_r12, 0,1,0,0,0, 1,1,0,0,0, 0, 1,0,0,0,0, \
Jim Stichnoth5bff61c2015-10-28 09:26:00 -0700134 REGLIST3(RegX8664, r12d, r12w, r12l)) \
John Porto56958cb2016-01-14 09:18:18 -0800135 X(Reg_r13, 13, "r13", Reg_r13, 0,1,0,0,0, 1,1,0,0,0, 0, 1,0,0,0,0, \
Jim Stichnoth5bff61c2015-10-28 09:26:00 -0700136 REGLIST3(RegX8664, r13d, r13w, r13l)) \
John Porto56958cb2016-01-14 09:18:18 -0800137 X(Reg_r14, 14, "r14", Reg_r14, 0,1,0,0,0, 1,1,0,0,0, 0, 1,0,0,0,0, \
Jim Stichnoth5bff61c2015-10-28 09:26:00 -0700138 REGLIST3(RegX8664, r14d, r14w, r14l)) \
John Porto56958cb2016-01-14 09:18:18 -0800139 X(Reg_r15, 15, "r15", Reg_r15, 0,1,0,0,1, 1,1,0,0,0, 0, 1,0,0,0,0, \
Jim Stichnoth5bff61c2015-10-28 09:26:00 -0700140 REGLIST3(RegX8664, r15d, r15w, r15l)) \
141 /* 32-bit registers */ \
John Porto56958cb2016-01-14 09:18:18 -0800142 X(Reg_eax, 0, "eax", Reg_rax, 1,0,0,0,0, 1,0,1,0,0, 0, 0,1,0,0,0, \
Jim Stichnoth5bff61c2015-10-28 09:26:00 -0700143 REGLIST4(RegX8664, rax, ax, al, ah)) \
John Porto56958cb2016-01-14 09:18:18 -0800144 X(Reg_ecx, 1, "ecx", Reg_rcx, 1,0,0,0,0, 1,0,1,0,0, 0, 0,1,0,0,0, \
Jim Stichnoth5bff61c2015-10-28 09:26:00 -0700145 REGLIST4(RegX8664, rcx, cx, cl, ch)) \
John Porto56958cb2016-01-14 09:18:18 -0800146 X(Reg_edx, 2, "edx", Reg_rdx, 1,0,0,0,0, 1,0,1,0,0, 0, 0,1,0,0,0, \
Jim Stichnoth5bff61c2015-10-28 09:26:00 -0700147 REGLIST4(RegX8664, rdx, dx, dl, dh)) \
John Porto56958cb2016-01-14 09:18:18 -0800148 X(Reg_r8d, 8, "r8d", Reg_r8, 1,0,0,0,0, 1,0,1,0,0, 0, 0,1,0,0,0, \
Jim Stichnoth5bff61c2015-10-28 09:26:00 -0700149 REGLIST3(RegX8664, r8, r8w, r8l)) \
John Porto56958cb2016-01-14 09:18:18 -0800150 X(Reg_r9d, 9, "r9d", Reg_r9, 1,0,0,0,0, 1,0,1,0,0, 0, 0,1,0,0,0, \
Jim Stichnoth5bff61c2015-10-28 09:26:00 -0700151 REGLIST3(RegX8664, r9, r9w, r9l)) \
John Porto56958cb2016-01-14 09:18:18 -0800152 X(Reg_r10d, 10, "r10d", Reg_r10, 1,0,0,1,0, 1,0,1,0,0, 0, 0,1,0,0,0, \
Jim Stichnoth5bff61c2015-10-28 09:26:00 -0700153 REGLIST3(RegX8664, r10, r10w, r10l)) \
John Porto56958cb2016-01-14 09:18:18 -0800154 X(Reg_r11d, 11, "r11d", Reg_r11, 1,0,0,0,0, 1,0,1,0,0, 0, 0,1,0,0,0, \
Jim Stichnoth5bff61c2015-10-28 09:26:00 -0700155 REGLIST3(RegX8664, r11, r11w, r11l)) \
Nicolas Capens73ae4fd2016-10-28 11:24:50 -0400156 X(Reg_esi, 6, "esi", Reg_rsi, U,W,0,0,0, 1,0,1,0,0, 0, 0,1,0,0,0, \
157 REGLIST3(RegX8664, rsi, si, sil)) \
158 X(Reg_edi, 7, "edi", Reg_rdi, U,W,0,0,0, 1,0,1,0,0, 0, 0,1,0,0,0, \
159 REGLIST3(RegX8664, rdi, di, dil)) \
Manasij Mukherjeefe2caab2016-06-27 15:42:12 -0700160 X(Reg_ebx, 3, "ebx", Reg_rbx, 0,1,0,0,0, 1,0,1,0,0, 0, 0,1,0,0,0, \
161 REGLIST4(RegX8664, rbx, bx, bl, bh)) \
162 X(Reg_esp, 4, "esp", Reg_rsp, 0,0,1,0,0, 1,0,0,0,0, 0, 0,0,0,0,0, \
163 REGLIST3(RegX8664, rsp, sp, spl)) \
164 X(Reg_ebp, 5, "ebp", Reg_rbp, 0,1,0,1,1, 1,0,1,0,0, 0, 0,1,0,0,0, \
165 REGLIST3(RegX8664, rbp, bp, bpl)) \
John Porto56958cb2016-01-14 09:18:18 -0800166 X(Reg_r12d, 12, "r12d", Reg_r12, 0,1,0,0,0, 1,0,1,0,0, 0, 0,1,0,0,0, \
Jim Stichnoth5bff61c2015-10-28 09:26:00 -0700167 REGLIST3(RegX8664, r12, r12w, r12l)) \
John Porto56958cb2016-01-14 09:18:18 -0800168 X(Reg_r13d, 13, "r13d", Reg_r13, 0,1,0,0,0, 1,0,1,0,0, 0, 0,1,0,0,0, \
Jim Stichnoth5bff61c2015-10-28 09:26:00 -0700169 REGLIST3(RegX8664, r13, r13w, r13l)) \
John Porto56958cb2016-01-14 09:18:18 -0800170 X(Reg_r14d, 14, "r14d", Reg_r14, 0,1,0,0,0, 1,0,1,0,0, 0, 0,1,0,0,0, \
Jim Stichnoth5bff61c2015-10-28 09:26:00 -0700171 REGLIST3(RegX8664, r14, r14w, r14l)) \
John Porto56958cb2016-01-14 09:18:18 -0800172 X(Reg_r15d, 15, "r15d", Reg_r15, 0,1,0,0,1, 1,0,1,0,0, 0, 0,1,0,0,0, \
Jim Stichnoth5bff61c2015-10-28 09:26:00 -0700173 REGLIST3(RegX8664, r15, r15w, r15l)) \
174 /* 16-bit registers */ \
John Porto56958cb2016-01-14 09:18:18 -0800175 X(Reg_ax, 0, "ax", Reg_rax, 1,0,0,0,0, 1,0,0,1,0, 0, 0,0,1,0,0, \
Jim Stichnoth5bff61c2015-10-28 09:26:00 -0700176 REGLIST4(RegX8664, rax, eax, al, ah)) \
John Porto56958cb2016-01-14 09:18:18 -0800177 X(Reg_cx, 1, "cx", Reg_rcx, 1,0,0,0,0, 1,0,0,1,0, 0, 0,0,1,0,0, \
Jim Stichnoth5bff61c2015-10-28 09:26:00 -0700178 REGLIST4(RegX8664, rcx, ecx, cl, ch)) \
John Porto56958cb2016-01-14 09:18:18 -0800179 X(Reg_dx, 2, "dx", Reg_rdx, 1,0,0,0,0, 1,0,0,1,0, 0, 0,0,1,0,0, \
Jim Stichnoth5bff61c2015-10-28 09:26:00 -0700180 REGLIST4(RegX8664, rdx, edx, dl, dh)) \
John Porto56958cb2016-01-14 09:18:18 -0800181 X(Reg_r8w, 8, "r8w", Reg_r8, 1,0,0,0,0, 1,0,0,1,0, 0, 0,0,1,0,0, \
Jim Stichnoth5bff61c2015-10-28 09:26:00 -0700182 REGLIST3(RegX8664, r8, r8d, r8l)) \
John Porto56958cb2016-01-14 09:18:18 -0800183 X(Reg_r9w, 9, "r9w", Reg_r9, 1,0,0,0,0, 1,0,0,1,0, 0, 0,0,1,0,0, \
Jim Stichnoth5bff61c2015-10-28 09:26:00 -0700184 REGLIST3(RegX8664, r9, r9d, r9l)) \
John Porto56958cb2016-01-14 09:18:18 -0800185 X(Reg_r10w, 10, "r10w", Reg_r10, 1,0,0,0,0, 1,0,0,1,0, 0, 0,0,1,0,0, \
Jim Stichnoth5bff61c2015-10-28 09:26:00 -0700186 REGLIST3(RegX8664, r10, r10d, r10l)) \
John Porto56958cb2016-01-14 09:18:18 -0800187 X(Reg_r11w, 11, "r11w", Reg_r11, 1,0,0,0,0, 1,0,0,1,0, 0, 0,0,1,0,0, \
Jim Stichnoth5bff61c2015-10-28 09:26:00 -0700188 REGLIST3(RegX8664, r11, r11d, r11l)) \
Nicolas Capens73ae4fd2016-10-28 11:24:50 -0400189 X(Reg_si, 6, "si", Reg_rsi, U,W,0,0,0, 1,0,0,1,0, 0, 0,0,1,0,0, \
190 REGLIST3(RegX8664, rsi, esi, sil)) \
191 X(Reg_di, 7, "di", Reg_rdi, U,W,0,0,0, 1,0,0,1,0, 0, 0,0,1,0,0, \
192 REGLIST3(RegX8664, rdi, edi, dil)) \
Manasij Mukherjeefe2caab2016-06-27 15:42:12 -0700193 X(Reg_bx, 3, "bx", Reg_rbx, 0,1,0,0,0, 1,0,0,1,0, 0, 0,0,1,0,0, \
194 REGLIST4(RegX8664, rbx, ebx, bl, bh)) \
195 X(Reg_sp, 4, "sp", Reg_rsp, 0,0,1,0,0, 1,0,0,0,0, 0, 0,0,0,0,0, \
196 REGLIST3(RegX8664, rsp, esp, spl)) \
197 X(Reg_bp, 5, "bp", Reg_rbp, 0,1,0,1,1, 1,0,0,1,0, 0, 0,0,1,0,0, \
198 REGLIST3(RegX8664, rbp, ebp, bpl)) \
John Porto56958cb2016-01-14 09:18:18 -0800199 X(Reg_r12w, 12, "r12w", Reg_r12, 0,1,0,0,0, 1,0,0,1,0, 0, 0,0,1,0,0, \
Jim Stichnoth5bff61c2015-10-28 09:26:00 -0700200 REGLIST3(RegX8664, r12, r12d, r12l)) \
John Porto56958cb2016-01-14 09:18:18 -0800201 X(Reg_r13w, 13, "r13w", Reg_r13, 0,1,0,0,0, 1,0,0,1,0, 0, 0,0,1,0,0, \
Jim Stichnoth5bff61c2015-10-28 09:26:00 -0700202 REGLIST3(RegX8664, r13, r13d, r13l)) \
John Porto56958cb2016-01-14 09:18:18 -0800203 X(Reg_r14w, 14, "r14w", Reg_r14, 0,1,0,0,0, 1,0,0,1,0, 0, 0,0,1,0,0, \
Jim Stichnoth5bff61c2015-10-28 09:26:00 -0700204 REGLIST3(RegX8664, r14, r14d, r14l)) \
John Porto56958cb2016-01-14 09:18:18 -0800205 X(Reg_r15w, 15, "r15w", Reg_r15, 0,1,0,0,1, 1,0,0,1,0, 0, 0,0,1,0,0, \
Jim Stichnoth5bff61c2015-10-28 09:26:00 -0700206 REGLIST3(RegX8664, r15, r15d, r15l)) \
207 /* 8-bit registers */ \
208 REGX8664_BYTEREG_TABLE \
209 /* End of GPR register set */
210//#define X(val, encode, name, base, scratch, preserved, stackptr, frameptr,
John Porto56958cb2016-01-14 09:18:18 -0800211// sboxres, isGPR, is64, is32, is16, is8, isXmm, is64To8, is32To8,
212// is16To8, isTrunc8Rcvr, isAhRcvr, aliases)
Jim Stichnoth5bff61c2015-10-28 09:26:00 -0700213
Nicolas Capens4e679e52017-01-12 17:01:06 -0500214#if defined(SUBZERO_USE_MICROSOFT_ABI) // Microsoft x86-64 ABI
Nicolas Capens73ae4fd2016-10-28 11:24:50 -0400215#define REGX8664_BYTEREG_TABLE REGX8664_BYTEREG_TABLE2(0, 1)
216#define REGX8664_GPR_TABLE REGX8664_GPR_TABLE2(0, 1)
Nicolas Capens4b1bdae2017-01-06 18:19:17 -0500217#else // System V AMD64 ABI
Nicolas Capens73ae4fd2016-10-28 11:24:50 -0400218#define REGX8664_BYTEREG_TABLE REGX8664_BYTEREG_TABLE2(1, 0)
219#define REGX8664_GPR_TABLE REGX8664_GPR_TABLE2(1, 0)
Nicolas Capens73ae4fd2016-10-28 11:24:50 -0400220#endif
221
Jim Stichnoth5bff61c2015-10-28 09:26:00 -0700222// Note: It would be more appropriate to list the xmm register aliases as
223// REGLIST0(), but the corresponding empty initializer gives a syntax error, so
224// we use REGLIST1() to redundantly assign the register itself as an alias.
Stephen White17078c72019-02-27 14:39:14 -0500225#define REGX8664_XMM_TABLE2(U, W) \
John Porto56958cb2016-01-14 09:18:18 -0800226 /* val, encode, name, base, scratch,preserved,stackptr,frameptr,sboxres, \
Jim Stichnoth5bff61c2015-10-28 09:26:00 -0700227 isGPR,is64,is32,is16,is8, isXmm, \
228 is64To8,is32To8,is16To8,isTrunc8Rcvr,isAhRcvr, aliases */ \
229 /* xmm registers */ \
John Porto56958cb2016-01-14 09:18:18 -0800230 X(Reg_xmm0, 0, "xmm0", Reg_xmm0, 1,0,0,0,0, 0,0,0,0,0, 1, 0,0,0,0,0, \
John Porto4a308ce2015-12-30 09:55:04 -0800231 NO_ALIASES()) \
John Porto56958cb2016-01-14 09:18:18 -0800232 X(Reg_xmm1, 1, "xmm1", Reg_xmm1, 1,0,0,0,0, 0,0,0,0,0, 1, 0,0,0,0,0, \
John Porto4a308ce2015-12-30 09:55:04 -0800233 NO_ALIASES()) \
John Porto56958cb2016-01-14 09:18:18 -0800234 X(Reg_xmm2, 2, "xmm2", Reg_xmm2, 1,0,0,0,0, 0,0,0,0,0, 1, 0,0,0,0,0, \
John Porto4a308ce2015-12-30 09:55:04 -0800235 NO_ALIASES()) \
John Porto56958cb2016-01-14 09:18:18 -0800236 X(Reg_xmm3, 3, "xmm3", Reg_xmm3, 1,0,0,0,0, 0,0,0,0,0, 1, 0,0,0,0,0, \
John Porto4a308ce2015-12-30 09:55:04 -0800237 NO_ALIASES()) \
John Porto56958cb2016-01-14 09:18:18 -0800238 X(Reg_xmm4, 4, "xmm4", Reg_xmm4, 1,0,0,0,0, 0,0,0,0,0, 1, 0,0,0,0,0, \
John Porto4a308ce2015-12-30 09:55:04 -0800239 NO_ALIASES()) \
John Porto56958cb2016-01-14 09:18:18 -0800240 X(Reg_xmm5, 5, "xmm5", Reg_xmm5, 1,0,0,0,0, 0,0,0,0,0, 1, 0,0,0,0,0, \
John Porto4a308ce2015-12-30 09:55:04 -0800241 NO_ALIASES()) \
Stephen White17078c72019-02-27 14:39:14 -0500242 X(Reg_xmm6, 6, "xmm6", Reg_xmm6, U,W,0,0,0, 0,0,0,0,0, 1, 0,0,0,0,0, \
John Porto4a308ce2015-12-30 09:55:04 -0800243 NO_ALIASES()) \
Stephen White17078c72019-02-27 14:39:14 -0500244 X(Reg_xmm7, 7, "xmm7", Reg_xmm7, U,W,0,0,0, 0,0,0,0,0, 1, 0,0,0,0,0, \
John Porto4a308ce2015-12-30 09:55:04 -0800245 NO_ALIASES()) \
Stephen White17078c72019-02-27 14:39:14 -0500246 X(Reg_xmm8, 8, "xmm8", Reg_xmm8, U,W,0,0,0, 0,0,0,0,0, 1, 0,0,0,0,0, \
John Porto4a308ce2015-12-30 09:55:04 -0800247 NO_ALIASES()) \
Stephen White17078c72019-02-27 14:39:14 -0500248 X(Reg_xmm9, 9, "xmm9", Reg_xmm9, U,W,0,0,0, 0,0,0,0,0, 1, 0,0,0,0,0, \
John Porto4a308ce2015-12-30 09:55:04 -0800249 NO_ALIASES()) \
Stephen White17078c72019-02-27 14:39:14 -0500250 X(Reg_xmm10, 10, "xmm10", Reg_xmm10, U,W,0,0,0, 0,0,0,0,0, 1, 0,0,0,0,0, \
John Porto4a308ce2015-12-30 09:55:04 -0800251 NO_ALIASES()) \
Stephen White17078c72019-02-27 14:39:14 -0500252 X(Reg_xmm11, 11, "xmm11", Reg_xmm11, U,W,0,0,0, 0,0,0,0,0, 1, 0,0,0,0,0, \
John Porto4a308ce2015-12-30 09:55:04 -0800253 NO_ALIASES()) \
Stephen White17078c72019-02-27 14:39:14 -0500254 X(Reg_xmm12, 12, "xmm12", Reg_xmm12, U,W,0,0,0, 0,0,0,0,0, 1, 0,0,0,0,0, \
John Porto4a308ce2015-12-30 09:55:04 -0800255 NO_ALIASES()) \
Stephen White17078c72019-02-27 14:39:14 -0500256 X(Reg_xmm13, 13, "xmm13", Reg_xmm13, U,W,0,0,0, 0,0,0,0,0, 1, 0,0,0,0,0, \
John Porto4a308ce2015-12-30 09:55:04 -0800257 NO_ALIASES()) \
Stephen White17078c72019-02-27 14:39:14 -0500258 X(Reg_xmm14, 14, "xmm14", Reg_xmm14, U,W,0,0,0, 0,0,0,0,0, 1, 0,0,0,0,0, \
John Porto4a308ce2015-12-30 09:55:04 -0800259 NO_ALIASES()) \
Stephen White17078c72019-02-27 14:39:14 -0500260 X(Reg_xmm15, 15, "xmm15", Reg_xmm15, U,W,0,0,0, 0,0,0,0,0, 1, 0,0,0,0,0, \
John Porto4a308ce2015-12-30 09:55:04 -0800261 NO_ALIASES()) \
Jim Stichnoth5bff61c2015-10-28 09:26:00 -0700262 /* End of xmm register set */
263//#define X(val, encode, name, base, scratch, preserved, stackptr, frameptr,
John Porto56958cb2016-01-14 09:18:18 -0800264// sboxres, isGPR, is64, is32, is16, is8, isXmm, is64To8, is32To8,
265// is16To8, isTrunc8Rcvr, isAhRcvr, aliases)
John Porto2b186872015-06-26 13:41:00 -0700266
Stephen White17078c72019-02-27 14:39:14 -0500267#if defined(SUBZERO_USE_MICROSOFT_ABI) // Microsoft x86-64 ABI
268#define REGX8664_XMM_TABLE REGX8664_XMM_TABLE2(0, 1)
269#else // System V AMD64 ABI
270#define REGX8664_XMM_TABLE REGX8664_XMM_TABLE2(1, 0)
271#endif
272
John Porto2b186872015-06-26 13:41:00 -0700273// We also provide a combined table, so that there is a namespace where
274// all of the registers are considered and have distinct numberings.
275// This is in contrast to the above, where the "encode" is based on how
276// the register numbers will be encoded in binaries and values can overlap.
John Porto2b186872015-06-26 13:41:00 -0700277#define REGX8664_TABLE \
John Porto2b186872015-06-26 13:41:00 -0700278 REGX8664_GPR_TABLE \
John Porto2b186872015-06-26 13:41:00 -0700279 REGX8664_XMM_TABLE
Jim Stichnoth5bff61c2015-10-28 09:26:00 -0700280//#define X(val, encode, name, base, scratch, preserved, stackptr, frameptr,
John Porto56958cb2016-01-14 09:18:18 -0800281// sboxres, isGPR, is64, is32, is16, is8, isXmm, is64To8, is32To8,
282// is16To8, isTrunc8Rcvr, isAhRcvr, aliases)
John Porto2b186872015-06-26 13:41:00 -0700283
284#define ICEINSTX8664BR_TABLE \
Jim Stichnoth5bff61c2015-10-28 09:26:00 -0700285 /* val, encode, opposite, dump, emit */ \
286 X(Br_o, 0, Br_no, "o", "jo") \
287 X(Br_no, 1, Br_o, "no", "jno") \
288 X(Br_b, 2, Br_ae, "b", "jb") \
289 X(Br_ae, 3, Br_b, "ae", "jae") \
290 X(Br_e, 4, Br_ne, "e", "je") \
291 X(Br_ne, 5, Br_e, "ne", "jne") \
292 X(Br_be, 6, Br_a, "be", "jbe") \
293 X(Br_a, 7, Br_be, "a", "ja") \
294 X(Br_s, 8, Br_ns, "s", "js") \
295 X(Br_ns, 9, Br_s, "ns", "jns") \
296 X(Br_p, 10, Br_np, "p", "jp") \
297 X(Br_np, 11, Br_p, "np", "jnp") \
298 X(Br_l, 12, Br_ge, "l", "jl") \
299 X(Br_ge, 13, Br_l, "ge", "jge") \
300 X(Br_le, 14, Br_g, "le", "jle") \
301 X(Br_g, 15, Br_le, "g", "jg")
302//#define X(val, encode, opp, dump, emit)
John Porto2b186872015-06-26 13:41:00 -0700303
304#define ICEINSTX8664CMPPS_TABLE \
Jim Stichnoth5bff61c2015-10-28 09:26:00 -0700305 /* val, emit */ \
306 X(Cmpps_eq, "eq") \
307 X(Cmpps_lt, "lt") \
308 X(Cmpps_le, "le") \
John Porto2b186872015-06-26 13:41:00 -0700309 X(Cmpps_unord, "unord") \
Jim Stichnoth5bff61c2015-10-28 09:26:00 -0700310 X(Cmpps_neq, "neq") \
311 X(Cmpps_nlt, "nlt") \
312 X(Cmpps_nle, "nle") \
313 X(Cmpps_ord, "ord")
314//#define X(val, emit)
John Porto2b186872015-06-26 13:41:00 -0700315
316#define ICETYPEX8664_TABLE \
Nicolas Capens7638e272016-10-06 11:33:55 -0400317 /* tag, elty, cvt, sdss, pdps, spsd, int_, unpack, pack, width, fld */ \
318 X(void, void, "?", "", "", "", "", "", "", "", "") \
319 X(i1, void, "si", "", "", "", "", "", "", "b", "") \
320 X(i8, void, "si", "", "", "", "", "", "", "b", "") \
321 X(i16, void, "si", "", "", "", "", "", "", "w", "") \
322 X(i32, void, "si", "", "", "", "", "", "", "l", "") \
323 X(i64, void, "si", "", "", "", "", "", "", "q", "") \
324 X(f32, void, "ss", "ss", "ps", "ss", "d", "", "", "", "s") \
325 X(f64, void, "sd", "sd", "pd", "sd", "q", "", "", "", "l") \
326 X(v4i1, i32, "?", "", "", "", "d", "dq", "", "", "") \
327 X(v8i1, i16, "?", "", "", "", "w", "wd", "", "", "") \
328 X(v16i1, i8, "?", "", "", "", "b", "bw", "", "", "") \
329 X(v16i8, i8, "?", "", "", "", "b", "bw", "", "", "") \
330 X(v8i16, i16, "?", "", "", "", "w", "wd", "wb", "", "") \
331 X(v4i32, i32, "dq", "", "", "", "d", "dq", "dw", "", "") \
332 X(v4f32, f32, "ps", "", "ps", "ps", "d", "dq", "", "", "")
333//#define X(tag, elty, cvt, sdss, pdps, spsd, int_, unpack, pack, width, fld)
John Porto2b186872015-06-26 13:41:00 -0700334
335#endif // SUBZERO_SRC_ICEINSTX8664_DEF