2009-12-05 14:44:23 +03:00
|
|
|
/*
|
|
|
|
* Tiny Code Generator for QEMU
|
|
|
|
*
|
|
|
|
* Copyright (c) 2009 Ulrich Hecht <uli@suse.de>
|
2010-06-29 06:15:37 +04:00
|
|
|
* Copyright (c) 2009 Alexander Graf <agraf@suse.de>
|
|
|
|
* Copyright (c) 2010 Richard Henderson <rth@twiddle.net>
|
2009-12-05 14:44:23 +03:00
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
* THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
2021-08-04 03:08:57 +03:00
|
|
|
#include "../tcg-ldst.c.inc"
|
2020-02-04 14:41:01 +03:00
|
|
|
#include "../tcg-pool.c.inc"
|
2013-06-07 18:43:33 +04:00
|
|
|
#include "elf.h"
|
|
|
|
|
2022-12-08 21:06:03 +03:00
|
|
|
#define TCG_CT_CONST_S16 (1 << 8)
|
|
|
|
#define TCG_CT_CONST_S32 (1 << 9)
|
|
|
|
#define TCG_CT_CONST_S33 (1 << 10)
|
|
|
|
#define TCG_CT_CONST_ZERO (1 << 11)
|
|
|
|
#define TCG_CT_CONST_P32 (1 << 12)
|
|
|
|
#define TCG_CT_CONST_INV (1 << 13)
|
|
|
|
#define TCG_CT_CONST_INVRISBG (1 << 14)
|
2010-06-29 06:15:37 +04:00
|
|
|
|
2020-10-17 06:09:02 +03:00
|
|
|
#define ALL_GENERAL_REGS MAKE_64BIT_MASK(0, 16)
|
2020-09-15 02:33:14 +03:00
|
|
|
#define ALL_VECTOR_REGS MAKE_64BIT_MASK(32, 32)
|
|
|
|
|
2010-06-29 06:15:37 +04:00
|
|
|
/* Several places within the instruction set 0 means "no register"
|
|
|
|
rather than TCG_REG_R0. */
|
|
|
|
#define TCG_REG_NONE 0
|
|
|
|
|
|
|
|
/* A scratch register that may be be used throughout the backend. */
|
2016-11-16 18:10:37 +03:00
|
|
|
#define TCG_TMP0 TCG_REG_R1
|
2010-06-29 06:15:37 +04:00
|
|
|
|
|
|
|
#define TCG_GUEST_BASE_REG TCG_REG_R13
|
|
|
|
|
|
|
|
/* All of the following instructions are prefixed with their instruction
|
|
|
|
format, and are defined as 8- or 16-bit quantities, even when the two
|
|
|
|
halves of the 16-bit quantity may appear 32 bits apart in the insn.
|
|
|
|
This makes it easy to copy the values from the tables in Appendix B. */
|
|
|
|
typedef enum S390Opcode {
|
|
|
|
RIL_AFI = 0xc209,
|
|
|
|
RIL_AGFI = 0xc208,
|
2013-03-27 00:41:45 +04:00
|
|
|
RIL_ALFI = 0xc20b,
|
2010-06-29 06:15:37 +04:00
|
|
|
RIL_ALGFI = 0xc20a,
|
|
|
|
RIL_BRASL = 0xc005,
|
|
|
|
RIL_BRCL = 0xc004,
|
|
|
|
RIL_CFI = 0xc20d,
|
|
|
|
RIL_CGFI = 0xc20c,
|
|
|
|
RIL_CLFI = 0xc20f,
|
|
|
|
RIL_CLGFI = 0xc20e,
|
2017-07-26 03:10:29 +03:00
|
|
|
RIL_CLRL = 0xc60f,
|
|
|
|
RIL_CLGRL = 0xc60a,
|
|
|
|
RIL_CRL = 0xc60d,
|
|
|
|
RIL_CGRL = 0xc608,
|
2010-06-29 06:15:37 +04:00
|
|
|
RIL_IIHF = 0xc008,
|
|
|
|
RIL_IILF = 0xc009,
|
|
|
|
RIL_LARL = 0xc000,
|
|
|
|
RIL_LGFI = 0xc001,
|
|
|
|
RIL_LGRL = 0xc408,
|
|
|
|
RIL_LLIHF = 0xc00e,
|
|
|
|
RIL_LLILF = 0xc00f,
|
|
|
|
RIL_LRL = 0xc40d,
|
|
|
|
RIL_MSFI = 0xc201,
|
|
|
|
RIL_MSGFI = 0xc200,
|
|
|
|
RIL_NIHF = 0xc00a,
|
|
|
|
RIL_NILF = 0xc00b,
|
|
|
|
RIL_OIHF = 0xc00c,
|
|
|
|
RIL_OILF = 0xc00d,
|
2013-03-27 00:41:45 +04:00
|
|
|
RIL_SLFI = 0xc205,
|
2013-03-27 22:23:26 +04:00
|
|
|
RIL_SLGFI = 0xc204,
|
2010-06-29 06:15:37 +04:00
|
|
|
RIL_XIHF = 0xc006,
|
|
|
|
RIL_XILF = 0xc007,
|
|
|
|
|
|
|
|
RI_AGHI = 0xa70b,
|
|
|
|
RI_AHI = 0xa70a,
|
|
|
|
RI_BRC = 0xa704,
|
2017-07-26 03:10:29 +03:00
|
|
|
RI_CHI = 0xa70e,
|
|
|
|
RI_CGHI = 0xa70f,
|
2010-06-29 06:15:37 +04:00
|
|
|
RI_IIHH = 0xa500,
|
|
|
|
RI_IIHL = 0xa501,
|
|
|
|
RI_IILH = 0xa502,
|
|
|
|
RI_IILL = 0xa503,
|
|
|
|
RI_LGHI = 0xa709,
|
|
|
|
RI_LLIHH = 0xa50c,
|
|
|
|
RI_LLIHL = 0xa50d,
|
|
|
|
RI_LLILH = 0xa50e,
|
|
|
|
RI_LLILL = 0xa50f,
|
|
|
|
RI_MGHI = 0xa70d,
|
|
|
|
RI_MHI = 0xa70c,
|
|
|
|
RI_NIHH = 0xa504,
|
|
|
|
RI_NIHL = 0xa505,
|
|
|
|
RI_NILH = 0xa506,
|
|
|
|
RI_NILL = 0xa507,
|
|
|
|
RI_OIHH = 0xa508,
|
|
|
|
RI_OIHL = 0xa509,
|
|
|
|
RI_OILH = 0xa50a,
|
|
|
|
RI_OILL = 0xa50b,
|
2021-08-04 03:08:57 +03:00
|
|
|
RI_TMLL = 0xa701,
|
2010-06-29 06:15:37 +04:00
|
|
|
|
2022-02-24 05:00:42 +03:00
|
|
|
RIEb_CGRJ = 0xec64,
|
|
|
|
RIEb_CLGRJ = 0xec65,
|
|
|
|
RIEb_CLRJ = 0xec77,
|
|
|
|
RIEb_CRJ = 0xec76,
|
|
|
|
|
|
|
|
RIEc_CGIJ = 0xec7c,
|
|
|
|
RIEc_CIJ = 0xec7e,
|
|
|
|
RIEc_CLGIJ = 0xec7d,
|
|
|
|
RIEc_CLIJ = 0xec7f,
|
|
|
|
|
|
|
|
RIEf_RISBG = 0xec55,
|
|
|
|
|
|
|
|
RIEg_LOCGHI = 0xec46,
|
2010-06-29 06:15:37 +04:00
|
|
|
|
|
|
|
RRE_AGR = 0xb908,
|
2013-03-27 00:41:45 +04:00
|
|
|
RRE_ALGR = 0xb90a,
|
|
|
|
RRE_ALCR = 0xb998,
|
|
|
|
RRE_ALCGR = 0xb988,
|
2023-04-03 09:14:53 +03:00
|
|
|
RRE_ALGFR = 0xb91a,
|
2010-06-29 06:15:37 +04:00
|
|
|
RRE_CGR = 0xb920,
|
|
|
|
RRE_CLGR = 0xb921,
|
|
|
|
RRE_DLGR = 0xb987,
|
|
|
|
RRE_DLR = 0xb997,
|
|
|
|
RRE_DSGFR = 0xb91d,
|
|
|
|
RRE_DSGR = 0xb90d,
|
2016-11-16 18:10:37 +03:00
|
|
|
RRE_FLOGR = 0xb983,
|
2010-06-29 06:15:37 +04:00
|
|
|
RRE_LGBR = 0xb906,
|
|
|
|
RRE_LCGR = 0xb903,
|
|
|
|
RRE_LGFR = 0xb914,
|
|
|
|
RRE_LGHR = 0xb907,
|
|
|
|
RRE_LGR = 0xb904,
|
|
|
|
RRE_LLGCR = 0xb984,
|
|
|
|
RRE_LLGFR = 0xb916,
|
|
|
|
RRE_LLGHR = 0xb985,
|
|
|
|
RRE_LRVR = 0xb91f,
|
|
|
|
RRE_LRVGR = 0xb90f,
|
|
|
|
RRE_LTGR = 0xb902,
|
2013-03-27 00:50:29 +04:00
|
|
|
RRE_MLGR = 0xb986,
|
2010-06-29 06:15:37 +04:00
|
|
|
RRE_MSGR = 0xb90c,
|
|
|
|
RRE_MSR = 0xb252,
|
|
|
|
RRE_NGR = 0xb980,
|
|
|
|
RRE_OGR = 0xb981,
|
|
|
|
RRE_SGR = 0xb909,
|
2013-03-27 00:41:45 +04:00
|
|
|
RRE_SLGR = 0xb90b,
|
|
|
|
RRE_SLBR = 0xb999,
|
|
|
|
RRE_SLBGR = 0xb989,
|
2010-06-29 06:15:37 +04:00
|
|
|
RRE_XGR = 0xb982,
|
|
|
|
|
2022-02-24 04:35:43 +03:00
|
|
|
RRFa_MGRK = 0xb9ec,
|
2022-02-24 04:28:44 +03:00
|
|
|
RRFa_MSRKC = 0xb9fd,
|
|
|
|
RRFa_MSGRKC = 0xb9ed,
|
2022-02-24 03:04:25 +03:00
|
|
|
RRFa_NCRK = 0xb9f5,
|
|
|
|
RRFa_NCGRK = 0xb9e5,
|
|
|
|
RRFa_NNRK = 0xb974,
|
|
|
|
RRFa_NNGRK = 0xb964,
|
|
|
|
RRFa_NORK = 0xb976,
|
|
|
|
RRFa_NOGRK = 0xb966,
|
2022-02-24 03:48:52 +03:00
|
|
|
RRFa_NRK = 0xb9f4,
|
|
|
|
RRFa_NGRK = 0xb9e4,
|
2022-02-24 03:04:25 +03:00
|
|
|
RRFa_NXRK = 0xb977,
|
|
|
|
RRFa_NXGRK = 0xb967,
|
|
|
|
RRFa_OCRK = 0xb975,
|
|
|
|
RRFa_OCGRK = 0xb965,
|
2022-02-24 03:48:52 +03:00
|
|
|
RRFa_ORK = 0xb9f6,
|
|
|
|
RRFa_OGRK = 0xb9e6,
|
|
|
|
RRFa_SRK = 0xb9f9,
|
|
|
|
RRFa_SGRK = 0xb9e9,
|
|
|
|
RRFa_SLRK = 0xb9fb,
|
|
|
|
RRFa_SLGRK = 0xb9eb,
|
|
|
|
RRFa_XRK = 0xb9f7,
|
|
|
|
RRFa_XGRK = 0xb9e7,
|
|
|
|
|
2022-12-02 07:05:38 +03:00
|
|
|
RRFam_SELGR = 0xb9e3,
|
|
|
|
|
2022-02-24 03:48:52 +03:00
|
|
|
RRFc_LOCR = 0xb9f2,
|
|
|
|
RRFc_LOCGR = 0xb9e2,
|
2022-02-24 03:43:18 +03:00
|
|
|
RRFc_POPCNT = 0xb9e1,
|
2013-03-27 01:28:52 +04:00
|
|
|
|
2010-06-29 06:15:37 +04:00
|
|
|
RR_AR = 0x1a,
|
2013-03-27 00:41:45 +04:00
|
|
|
RR_ALR = 0x1e,
|
2010-06-29 06:15:37 +04:00
|
|
|
RR_BASR = 0x0d,
|
|
|
|
RR_BCR = 0x07,
|
|
|
|
RR_CLR = 0x15,
|
|
|
|
RR_CR = 0x19,
|
|
|
|
RR_DR = 0x1d,
|
|
|
|
RR_LCR = 0x13,
|
|
|
|
RR_LR = 0x18,
|
|
|
|
RR_LTR = 0x12,
|
|
|
|
RR_NR = 0x14,
|
|
|
|
RR_OR = 0x16,
|
|
|
|
RR_SR = 0x1b,
|
2013-03-27 00:41:45 +04:00
|
|
|
RR_SLR = 0x1f,
|
2010-06-29 06:15:37 +04:00
|
|
|
RR_XR = 0x17,
|
|
|
|
|
|
|
|
RSY_RLL = 0xeb1d,
|
|
|
|
RSY_RLLG = 0xeb1c,
|
|
|
|
RSY_SLLG = 0xeb0d,
|
2017-06-16 23:43:17 +03:00
|
|
|
RSY_SLLK = 0xebdf,
|
2010-06-29 06:15:37 +04:00
|
|
|
RSY_SRAG = 0xeb0a,
|
2017-06-16 23:43:17 +03:00
|
|
|
RSY_SRAK = 0xebdc,
|
2010-06-29 06:15:37 +04:00
|
|
|
RSY_SRLG = 0xeb0c,
|
2017-06-16 23:43:17 +03:00
|
|
|
RSY_SRLK = 0xebde,
|
2010-06-29 06:15:37 +04:00
|
|
|
|
|
|
|
RS_SLL = 0x89,
|
|
|
|
RS_SRA = 0x8a,
|
|
|
|
RS_SRL = 0x88,
|
|
|
|
|
|
|
|
RXY_AG = 0xe308,
|
|
|
|
RXY_AY = 0xe35a,
|
|
|
|
RXY_CG = 0xe320,
|
2017-07-26 03:10:29 +03:00
|
|
|
RXY_CLG = 0xe321,
|
|
|
|
RXY_CLY = 0xe355,
|
2010-06-29 06:15:37 +04:00
|
|
|
RXY_CY = 0xe359,
|
2013-03-27 22:23:26 +04:00
|
|
|
RXY_LAY = 0xe371,
|
2010-06-29 06:15:37 +04:00
|
|
|
RXY_LB = 0xe376,
|
|
|
|
RXY_LG = 0xe304,
|
|
|
|
RXY_LGB = 0xe377,
|
|
|
|
RXY_LGF = 0xe314,
|
|
|
|
RXY_LGH = 0xe315,
|
|
|
|
RXY_LHY = 0xe378,
|
|
|
|
RXY_LLGC = 0xe390,
|
|
|
|
RXY_LLGF = 0xe316,
|
|
|
|
RXY_LLGH = 0xe391,
|
|
|
|
RXY_LMG = 0xeb04,
|
2023-04-19 18:58:23 +03:00
|
|
|
RXY_LPQ = 0xe38f,
|
2010-06-29 06:15:37 +04:00
|
|
|
RXY_LRV = 0xe31e,
|
|
|
|
RXY_LRVG = 0xe30f,
|
|
|
|
RXY_LRVH = 0xe31f,
|
|
|
|
RXY_LY = 0xe358,
|
2017-07-26 01:59:13 +03:00
|
|
|
RXY_NG = 0xe380,
|
2017-07-26 02:21:36 +03:00
|
|
|
RXY_OG = 0xe381,
|
2010-06-29 06:15:37 +04:00
|
|
|
RXY_STCY = 0xe372,
|
|
|
|
RXY_STG = 0xe324,
|
|
|
|
RXY_STHY = 0xe370,
|
|
|
|
RXY_STMG = 0xeb24,
|
2023-04-19 18:58:23 +03:00
|
|
|
RXY_STPQ = 0xe38e,
|
2010-06-29 06:15:37 +04:00
|
|
|
RXY_STRV = 0xe33e,
|
|
|
|
RXY_STRVG = 0xe32f,
|
|
|
|
RXY_STRVH = 0xe33f,
|
|
|
|
RXY_STY = 0xe350,
|
2017-07-26 02:42:51 +03:00
|
|
|
RXY_XG = 0xe382,
|
2010-06-29 06:15:37 +04:00
|
|
|
|
|
|
|
RX_A = 0x5a,
|
|
|
|
RX_C = 0x59,
|
|
|
|
RX_L = 0x58,
|
2013-03-27 22:23:26 +04:00
|
|
|
RX_LA = 0x41,
|
2010-06-29 06:15:37 +04:00
|
|
|
RX_LH = 0x48,
|
|
|
|
RX_ST = 0x50,
|
|
|
|
RX_STC = 0x42,
|
|
|
|
RX_STH = 0x40,
|
2016-04-22 19:08:48 +03:00
|
|
|
|
2020-09-15 03:25:52 +03:00
|
|
|
VRIa_VGBM = 0xe744,
|
|
|
|
VRIa_VREPI = 0xe745,
|
|
|
|
VRIb_VGM = 0xe746,
|
|
|
|
VRIc_VREP = 0xe74d,
|
|
|
|
|
2020-09-15 04:23:16 +03:00
|
|
|
VRRa_VLC = 0xe7de,
|
|
|
|
VRRa_VLP = 0xe7df,
|
2020-09-15 03:12:18 +03:00
|
|
|
VRRa_VLR = 0xe756,
|
2020-09-15 04:08:00 +03:00
|
|
|
VRRc_VA = 0xe7f3,
|
|
|
|
VRRc_VCEQ = 0xe7f8, /* we leave the m5 cs field 0 */
|
|
|
|
VRRc_VCH = 0xe7fb, /* " */
|
|
|
|
VRRc_VCHL = 0xe7f9, /* " */
|
2020-09-15 05:00:38 +03:00
|
|
|
VRRc_VERLLV = 0xe773,
|
|
|
|
VRRc_VESLV = 0xe770,
|
|
|
|
VRRc_VESRAV = 0xe77a,
|
|
|
|
VRRc_VESRLV = 0xe778,
|
2020-09-15 04:33:47 +03:00
|
|
|
VRRc_VML = 0xe7a2,
|
2020-09-15 05:07:16 +03:00
|
|
|
VRRc_VMN = 0xe7fe,
|
|
|
|
VRRc_VMNL = 0xe7fc,
|
|
|
|
VRRc_VMX = 0xe7ff,
|
|
|
|
VRRc_VMXL = 0xe7fd,
|
2020-09-15 04:08:00 +03:00
|
|
|
VRRc_VN = 0xe768,
|
2020-09-15 04:23:16 +03:00
|
|
|
VRRc_VNC = 0xe769,
|
2021-12-18 05:59:02 +03:00
|
|
|
VRRc_VNN = 0xe76e,
|
2020-09-15 04:23:16 +03:00
|
|
|
VRRc_VNO = 0xe76b,
|
2021-12-18 05:59:02 +03:00
|
|
|
VRRc_VNX = 0xe76c,
|
2020-09-15 04:08:00 +03:00
|
|
|
VRRc_VO = 0xe76a,
|
2020-09-15 04:23:16 +03:00
|
|
|
VRRc_VOC = 0xe76f,
|
2020-09-15 06:17:29 +03:00
|
|
|
VRRc_VPKS = 0xe797, /* we leave the m5 cs field 0 */
|
2020-09-15 04:08:00 +03:00
|
|
|
VRRc_VS = 0xe7f7,
|
2020-09-15 06:17:29 +03:00
|
|
|
VRRa_VUPH = 0xe7d7,
|
|
|
|
VRRa_VUPL = 0xe7d6,
|
2020-09-15 04:08:00 +03:00
|
|
|
VRRc_VX = 0xe76d,
|
2020-09-15 06:36:36 +03:00
|
|
|
VRRe_VSEL = 0xe78d,
|
2020-09-15 03:25:52 +03:00
|
|
|
VRRf_VLVGP = 0xe762,
|
2020-09-15 03:12:18 +03:00
|
|
|
|
2020-09-15 05:00:38 +03:00
|
|
|
VRSa_VERLL = 0xe733,
|
|
|
|
VRSa_VESL = 0xe730,
|
|
|
|
VRSa_VESRA = 0xe73a,
|
|
|
|
VRSa_VESRL = 0xe738,
|
2020-09-15 03:12:18 +03:00
|
|
|
VRSb_VLVG = 0xe722,
|
|
|
|
VRSc_VLGV = 0xe721,
|
|
|
|
|
2020-09-15 03:04:22 +03:00
|
|
|
VRX_VL = 0xe706,
|
|
|
|
VRX_VLLEZ = 0xe704,
|
2020-09-15 03:25:52 +03:00
|
|
|
VRX_VLREP = 0xe705,
|
2020-09-15 03:04:22 +03:00
|
|
|
VRX_VST = 0xe70e,
|
|
|
|
VRX_VSTEF = 0xe70b,
|
|
|
|
VRX_VSTEG = 0xe70a,
|
|
|
|
|
2016-04-22 19:08:48 +03:00
|
|
|
NOP = 0x0707,
|
2010-06-29 06:15:37 +04:00
|
|
|
} S390Opcode;
|
|
|
|
|
2016-04-21 11:48:50 +03:00
|
|
|
#ifdef CONFIG_DEBUG_TCG
|
2010-06-29 06:15:37 +04:00
|
|
|
static const char * const tcg_target_reg_names[TCG_TARGET_NB_REGS] = {
|
2020-09-15 02:33:14 +03:00
|
|
|
"%r0", "%r1", "%r2", "%r3", "%r4", "%r5", "%r6", "%r7",
|
|
|
|
"%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15",
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
"%v0", "%v1", "%v2", "%v3", "%v4", "%v5", "%v6", "%v7",
|
|
|
|
"%v8", "%v9", "%v10", "%v11", "%v12", "%v13", "%v14", "%v15",
|
|
|
|
"%v16", "%v17", "%v18", "%v19", "%v20", "%v21", "%v22", "%v23",
|
|
|
|
"%v24", "%v25", "%v26", "%v27", "%v28", "%v29", "%v30", "%v31",
|
2010-06-29 06:15:37 +04:00
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Since R6 is a potential argument register, choose it last of the
|
|
|
|
call-saved registers. Likewise prefer the call-clobbered registers
|
|
|
|
in reverse order to maximize the chance of avoiding the arguments. */
|
2009-12-05 14:44:23 +03:00
|
|
|
static const int tcg_target_reg_alloc_order[] = {
|
2014-03-24 00:36:00 +04:00
|
|
|
/* Call saved registers. */
|
2010-06-29 06:15:37 +04:00
|
|
|
TCG_REG_R13,
|
|
|
|
TCG_REG_R12,
|
|
|
|
TCG_REG_R11,
|
|
|
|
TCG_REG_R10,
|
|
|
|
TCG_REG_R9,
|
|
|
|
TCG_REG_R8,
|
|
|
|
TCG_REG_R7,
|
|
|
|
TCG_REG_R6,
|
2014-03-24 00:36:00 +04:00
|
|
|
/* Call clobbered registers. */
|
2010-06-29 06:15:37 +04:00
|
|
|
TCG_REG_R14,
|
|
|
|
TCG_REG_R0,
|
|
|
|
TCG_REG_R1,
|
2014-03-24 00:36:00 +04:00
|
|
|
/* Argument registers, in reverse order of allocation. */
|
2010-06-29 06:15:37 +04:00
|
|
|
TCG_REG_R5,
|
|
|
|
TCG_REG_R4,
|
|
|
|
TCG_REG_R3,
|
|
|
|
TCG_REG_R2,
|
2020-09-15 02:33:14 +03:00
|
|
|
|
|
|
|
/* V8-V15 are call saved, and omitted. */
|
|
|
|
TCG_REG_V0,
|
|
|
|
TCG_REG_V1,
|
|
|
|
TCG_REG_V2,
|
|
|
|
TCG_REG_V3,
|
|
|
|
TCG_REG_V4,
|
|
|
|
TCG_REG_V5,
|
|
|
|
TCG_REG_V6,
|
|
|
|
TCG_REG_V7,
|
|
|
|
TCG_REG_V16,
|
|
|
|
TCG_REG_V17,
|
|
|
|
TCG_REG_V18,
|
|
|
|
TCG_REG_V19,
|
|
|
|
TCG_REG_V20,
|
|
|
|
TCG_REG_V21,
|
|
|
|
TCG_REG_V22,
|
|
|
|
TCG_REG_V23,
|
|
|
|
TCG_REG_V24,
|
|
|
|
TCG_REG_V25,
|
|
|
|
TCG_REG_V26,
|
|
|
|
TCG_REG_V27,
|
|
|
|
TCG_REG_V28,
|
|
|
|
TCG_REG_V29,
|
|
|
|
TCG_REG_V30,
|
|
|
|
TCG_REG_V31,
|
2009-12-05 14:44:23 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
static const int tcg_target_call_iarg_regs[] = {
|
2010-06-29 06:15:37 +04:00
|
|
|
TCG_REG_R2,
|
|
|
|
TCG_REG_R3,
|
|
|
|
TCG_REG_R4,
|
|
|
|
TCG_REG_R5,
|
|
|
|
TCG_REG_R6,
|
2009-12-05 14:44:23 +03:00
|
|
|
};
|
|
|
|
|
2022-10-19 17:55:36 +03:00
|
|
|
static TCGReg tcg_target_call_oarg_reg(TCGCallReturnKind kind, int slot)
|
|
|
|
{
|
|
|
|
tcg_debug_assert(kind == TCG_CALL_RET_NORMAL);
|
|
|
|
tcg_debug_assert(slot == 0);
|
|
|
|
return TCG_REG_R2;
|
|
|
|
}
|
2010-06-29 06:15:37 +04:00
|
|
|
|
|
|
|
#define S390_CC_EQ 8
|
|
|
|
#define S390_CC_LT 4
|
|
|
|
#define S390_CC_GT 2
|
|
|
|
#define S390_CC_OV 1
|
|
|
|
#define S390_CC_NE (S390_CC_LT | S390_CC_GT)
|
|
|
|
#define S390_CC_LE (S390_CC_LT | S390_CC_EQ)
|
|
|
|
#define S390_CC_GE (S390_CC_GT | S390_CC_EQ)
|
|
|
|
#define S390_CC_NEVER 0
|
|
|
|
#define S390_CC_ALWAYS 15
|
|
|
|
|
|
|
|
/* Condition codes that result from a COMPARE and COMPARE LOGICAL. */
|
2012-09-25 01:21:40 +04:00
|
|
|
static const uint8_t tcg_cond_to_s390_cond[] = {
|
2010-06-29 06:15:37 +04:00
|
|
|
[TCG_COND_EQ] = S390_CC_EQ,
|
|
|
|
[TCG_COND_NE] = S390_CC_NE,
|
|
|
|
[TCG_COND_LT] = S390_CC_LT,
|
|
|
|
[TCG_COND_LE] = S390_CC_LE,
|
|
|
|
[TCG_COND_GT] = S390_CC_GT,
|
|
|
|
[TCG_COND_GE] = S390_CC_GE,
|
|
|
|
[TCG_COND_LTU] = S390_CC_LT,
|
|
|
|
[TCG_COND_LEU] = S390_CC_LE,
|
|
|
|
[TCG_COND_GTU] = S390_CC_GT,
|
|
|
|
[TCG_COND_GEU] = S390_CC_GE,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Condition codes that result from a LOAD AND TEST. Here, we have no
|
|
|
|
unsigned instruction variation, however since the test is vs zero we
|
|
|
|
can re-map the outcomes appropriately. */
|
2012-09-25 01:21:40 +04:00
|
|
|
static const uint8_t tcg_cond_to_ltr_cond[] = {
|
2010-06-29 06:15:37 +04:00
|
|
|
[TCG_COND_EQ] = S390_CC_EQ,
|
|
|
|
[TCG_COND_NE] = S390_CC_NE,
|
|
|
|
[TCG_COND_LT] = S390_CC_LT,
|
|
|
|
[TCG_COND_LE] = S390_CC_LE,
|
|
|
|
[TCG_COND_GT] = S390_CC_GT,
|
|
|
|
[TCG_COND_GE] = S390_CC_GE,
|
|
|
|
[TCG_COND_LTU] = S390_CC_NEVER,
|
|
|
|
[TCG_COND_LEU] = S390_CC_EQ,
|
|
|
|
[TCG_COND_GTU] = S390_CC_NE,
|
|
|
|
[TCG_COND_GEU] = S390_CC_ALWAYS,
|
|
|
|
};
|
|
|
|
|
2020-11-05 07:56:16 +03:00
|
|
|
static const tcg_insn_unit *tb_ret_addr;
|
2020-09-15 02:33:14 +03:00
|
|
|
uint64_t s390_facilities[3];
|
2009-12-05 14:44:23 +03:00
|
|
|
|
2020-09-15 03:04:22 +03:00
|
|
|
static inline bool is_general_reg(TCGReg r)
|
|
|
|
{
|
|
|
|
return r <= TCG_REG_R15;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool is_vector_reg(TCGReg r)
|
|
|
|
{
|
|
|
|
return r >= TCG_REG_V0 && r <= TCG_REG_V31;
|
|
|
|
}
|
|
|
|
|
2020-11-05 07:56:16 +03:00
|
|
|
static bool patch_reloc(tcg_insn_unit *src_rw, int type,
|
2013-08-21 02:30:10 +04:00
|
|
|
intptr_t value, intptr_t addend)
|
2009-12-05 14:44:23 +03:00
|
|
|
{
|
2020-11-05 07:56:16 +03:00
|
|
|
const tcg_insn_unit *src_rx = tcg_splitwx_to_rx(src_rw);
|
2017-07-30 23:58:01 +03:00
|
|
|
intptr_t pcrel2;
|
2017-08-01 05:16:02 +03:00
|
|
|
uint32_t old;
|
2017-07-30 23:58:01 +03:00
|
|
|
|
|
|
|
value += addend;
|
2020-11-05 07:56:16 +03:00
|
|
|
pcrel2 = (tcg_insn_unit *)value - src_rx;
|
2010-06-29 06:15:37 +04:00
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case R_390_PC16DBL:
|
2018-12-01 00:41:51 +03:00
|
|
|
if (pcrel2 == (int16_t)pcrel2) {
|
2020-11-05 07:56:16 +03:00
|
|
|
tcg_patch16(src_rw, pcrel2);
|
2018-12-01 00:41:51 +03:00
|
|
|
return true;
|
|
|
|
}
|
2010-06-29 06:15:37 +04:00
|
|
|
break;
|
|
|
|
case R_390_PC32DBL:
|
2018-12-01 00:41:51 +03:00
|
|
|
if (pcrel2 == (int32_t)pcrel2) {
|
2020-11-05 07:56:16 +03:00
|
|
|
tcg_patch32(src_rw, pcrel2);
|
2018-12-01 00:41:51 +03:00
|
|
|
return true;
|
|
|
|
}
|
2010-06-29 06:15:37 +04:00
|
|
|
break;
|
2017-08-01 05:16:02 +03:00
|
|
|
case R_390_20:
|
2018-12-01 00:41:51 +03:00
|
|
|
if (value == sextract64(value, 0, 20)) {
|
2020-11-05 07:56:16 +03:00
|
|
|
old = *(uint32_t *)src_rw & 0xf00000ff;
|
2018-12-01 00:41:51 +03:00
|
|
|
old |= ((value & 0xfff) << 16) | ((value & 0xff000) >> 4);
|
2020-11-05 07:56:16 +03:00
|
|
|
tcg_patch32(src_rw, old);
|
2018-12-01 00:41:51 +03:00
|
|
|
return true;
|
|
|
|
}
|
2017-08-01 05:16:02 +03:00
|
|
|
break;
|
2010-06-29 06:15:37 +04:00
|
|
|
default:
|
2017-07-30 23:58:01 +03:00
|
|
|
g_assert_not_reached();
|
2010-06-29 06:15:37 +04:00
|
|
|
}
|
2018-12-01 00:41:51 +03:00
|
|
|
return false;
|
2009-12-05 14:44:23 +03:00
|
|
|
}
|
|
|
|
|
2022-12-08 20:28:19 +03:00
|
|
|
static int is_const_p16(uint64_t val)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < 4; ++i) {
|
|
|
|
uint64_t mask = 0xffffull << (i * 16);
|
|
|
|
if ((val & ~mask) == 0) {
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int is_const_p32(uint64_t val)
|
|
|
|
{
|
|
|
|
if ((val & 0xffffffff00000000ull) == 0) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if ((val & 0x00000000ffffffffull) == 0) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2022-12-08 21:06:03 +03:00
|
|
|
/*
|
|
|
|
* Accept bit patterns like these:
|
|
|
|
* 0....01....1
|
|
|
|
* 1....10....0
|
|
|
|
* 1..10..01..1
|
|
|
|
* 0..01..10..0
|
|
|
|
* Copied from gcc sources.
|
|
|
|
*/
|
|
|
|
static bool risbg_mask(uint64_t c)
|
|
|
|
{
|
|
|
|
uint64_t lsb;
|
|
|
|
/* We don't change the number of transitions by inverting,
|
|
|
|
so make sure we start with the LSB zero. */
|
|
|
|
if (c & 1) {
|
|
|
|
c = ~c;
|
|
|
|
}
|
|
|
|
/* Reject all zeros or all ones. */
|
|
|
|
if (c == 0) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
/* Find the first transition. */
|
|
|
|
lsb = c & -c;
|
|
|
|
/* Invert to look for a second transition. */
|
|
|
|
c = ~c;
|
|
|
|
/* Erase the first transition. */
|
|
|
|
c &= -lsb;
|
|
|
|
/* Find the second transition, if any. */
|
|
|
|
lsb = c & -c;
|
|
|
|
/* Match if all the bits are 1's, or if c is zero. */
|
|
|
|
return c == -lsb;
|
|
|
|
}
|
|
|
|
|
2009-12-05 14:44:23 +03:00
|
|
|
/* Test if a constant matches the constraint. */
|
2023-09-08 05:21:10 +03:00
|
|
|
static bool tcg_target_const_match(int64_t val, TCGType type, int ct, int vece)
|
2009-12-05 14:44:23 +03:00
|
|
|
{
|
2010-06-29 06:15:37 +04:00
|
|
|
if (ct & TCG_CT_CONST) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2014-03-31 10:25:26 +04:00
|
|
|
if (type == TCG_TYPE_I32) {
|
2010-06-29 06:15:37 +04:00
|
|
|
val = (int32_t)val;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The following are mutually exclusive. */
|
2017-06-17 00:52:32 +03:00
|
|
|
if (ct & TCG_CT_CONST_S16) {
|
|
|
|
return val == (int16_t)val;
|
|
|
|
} else if (ct & TCG_CT_CONST_S32) {
|
|
|
|
return val == (int32_t)val;
|
2017-06-17 00:59:55 +03:00
|
|
|
} else if (ct & TCG_CT_CONST_S33) {
|
|
|
|
return val >= -0xffffffffll && val <= 0xffffffffll;
|
2016-10-18 03:00:46 +03:00
|
|
|
} else if (ct & TCG_CT_CONST_ZERO) {
|
|
|
|
return val == 0;
|
2010-06-29 06:15:37 +04:00
|
|
|
}
|
|
|
|
|
2022-12-08 21:06:03 +03:00
|
|
|
if (ct & TCG_CT_CONST_INV) {
|
|
|
|
val = ~val;
|
|
|
|
}
|
2022-12-08 20:28:19 +03:00
|
|
|
/*
|
|
|
|
* Note that is_const_p16 is a subset of is_const_p32,
|
|
|
|
* so we don't need both constraints.
|
|
|
|
*/
|
|
|
|
if ((ct & TCG_CT_CONST_P32) && is_const_p32(val) >= 0) {
|
|
|
|
return true;
|
|
|
|
}
|
2022-12-08 21:06:03 +03:00
|
|
|
if ((ct & TCG_CT_CONST_INVRISBG) && risbg_mask(~val)) {
|
|
|
|
return true;
|
|
|
|
}
|
2022-12-08 20:28:19 +03:00
|
|
|
|
2009-12-05 14:44:23 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-06-29 06:15:37 +04:00
|
|
|
/* Emit instructions according to the given instruction format. */
|
|
|
|
|
|
|
|
static void tcg_out_insn_RR(TCGContext *s, S390Opcode op, TCGReg r1, TCGReg r2)
|
|
|
|
{
|
|
|
|
tcg_out16(s, (op << 8) | (r1 << 4) | r2);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void tcg_out_insn_RRE(TCGContext *s, S390Opcode op,
|
|
|
|
TCGReg r1, TCGReg r2)
|
|
|
|
{
|
|
|
|
tcg_out32(s, (op << 16) | (r1 << 4) | r2);
|
|
|
|
}
|
|
|
|
|
2022-12-02 07:05:38 +03:00
|
|
|
/* RRF-a without the m4 field */
|
2022-02-24 03:48:52 +03:00
|
|
|
static void tcg_out_insn_RRFa(TCGContext *s, S390Opcode op,
|
|
|
|
TCGReg r1, TCGReg r2, TCGReg r3)
|
|
|
|
{
|
|
|
|
tcg_out32(s, (op << 16) | (r3 << 12) | (r1 << 4) | r2);
|
|
|
|
}
|
|
|
|
|
2022-12-02 07:05:38 +03:00
|
|
|
/* RRF-a with the m4 field */
|
|
|
|
static void tcg_out_insn_RRFam(TCGContext *s, S390Opcode op,
|
|
|
|
TCGReg r1, TCGReg r2, TCGReg r3, int m4)
|
|
|
|
{
|
|
|
|
tcg_out32(s, (op << 16) | (r3 << 12) | (m4 << 8) | (r1 << 4) | r2);
|
|
|
|
}
|
|
|
|
|
2022-02-24 03:48:52 +03:00
|
|
|
static void tcg_out_insn_RRFc(TCGContext *s, S390Opcode op,
|
|
|
|
TCGReg r1, TCGReg r2, int m3)
|
2013-03-27 01:28:52 +04:00
|
|
|
{
|
|
|
|
tcg_out32(s, (op << 16) | (m3 << 12) | (r1 << 4) | r2);
|
|
|
|
}
|
|
|
|
|
2010-06-29 06:15:37 +04:00
|
|
|
static void tcg_out_insn_RI(TCGContext *s, S390Opcode op, TCGReg r1, int i2)
|
|
|
|
{
|
|
|
|
tcg_out32(s, (op << 16) | (r1 << 20) | (i2 & 0xffff));
|
|
|
|
}
|
|
|
|
|
2022-02-24 05:00:42 +03:00
|
|
|
static void tcg_out_insn_RIEg(TCGContext *s, S390Opcode op, TCGReg r1,
|
2017-06-17 01:33:28 +03:00
|
|
|
int i2, int m3)
|
|
|
|
{
|
|
|
|
tcg_out16(s, (op & 0xff00) | (r1 << 4) | m3);
|
|
|
|
tcg_out32(s, (i2 << 16) | (op & 0xff));
|
|
|
|
}
|
|
|
|
|
2010-06-29 06:15:37 +04:00
|
|
|
static void tcg_out_insn_RIL(TCGContext *s, S390Opcode op, TCGReg r1, int i2)
|
|
|
|
{
|
|
|
|
tcg_out16(s, op | (r1 << 4));
|
|
|
|
tcg_out32(s, i2);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void tcg_out_insn_RS(TCGContext *s, S390Opcode op, TCGReg r1,
|
|
|
|
TCGReg b2, TCGReg r3, int disp)
|
|
|
|
{
|
|
|
|
tcg_out32(s, (op << 24) | (r1 << 20) | (r3 << 16) | (b2 << 12)
|
|
|
|
| (disp & 0xfff));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void tcg_out_insn_RSY(TCGContext *s, S390Opcode op, TCGReg r1,
|
|
|
|
TCGReg b2, TCGReg r3, int disp)
|
|
|
|
{
|
|
|
|
tcg_out16(s, (op & 0xff00) | (r1 << 4) | r3);
|
|
|
|
tcg_out32(s, (op & 0xff) | (b2 << 28)
|
|
|
|
| ((disp & 0xfff) << 16) | ((disp & 0xff000) >> 4));
|
|
|
|
}
|
|
|
|
|
|
|
|
#define tcg_out_insn_RX tcg_out_insn_RS
|
|
|
|
#define tcg_out_insn_RXY tcg_out_insn_RSY
|
|
|
|
|
2020-09-15 03:04:22 +03:00
|
|
|
static int RXB(TCGReg v1, TCGReg v2, TCGReg v3, TCGReg v4)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Shift bit 4 of each regno to its corresponding bit of RXB.
|
|
|
|
* RXB itself begins at bit 8 of the instruction so 8 - 4 = 4
|
|
|
|
* is the left-shift of the 4th operand.
|
|
|
|
*/
|
|
|
|
return ((v1 & 0x10) << (4 + 3))
|
|
|
|
| ((v2 & 0x10) << (4 + 2))
|
|
|
|
| ((v3 & 0x10) << (4 + 1))
|
|
|
|
| ((v4 & 0x10) << (4 + 0));
|
|
|
|
}
|
|
|
|
|
2020-09-15 03:25:52 +03:00
|
|
|
static void tcg_out_insn_VRIa(TCGContext *s, S390Opcode op,
|
|
|
|
TCGReg v1, uint16_t i2, int m3)
|
|
|
|
{
|
|
|
|
tcg_debug_assert(is_vector_reg(v1));
|
|
|
|
tcg_out16(s, (op & 0xff00) | ((v1 & 0xf) << 4));
|
|
|
|
tcg_out16(s, i2);
|
|
|
|
tcg_out16(s, (op & 0x00ff) | RXB(v1, 0, 0, 0) | (m3 << 12));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void tcg_out_insn_VRIb(TCGContext *s, S390Opcode op,
|
|
|
|
TCGReg v1, uint8_t i2, uint8_t i3, int m4)
|
|
|
|
{
|
|
|
|
tcg_debug_assert(is_vector_reg(v1));
|
|
|
|
tcg_out16(s, (op & 0xff00) | ((v1 & 0xf) << 4));
|
|
|
|
tcg_out16(s, (i2 << 8) | (i3 & 0xff));
|
|
|
|
tcg_out16(s, (op & 0x00ff) | RXB(v1, 0, 0, 0) | (m4 << 12));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void tcg_out_insn_VRIc(TCGContext *s, S390Opcode op,
|
|
|
|
TCGReg v1, uint16_t i2, TCGReg v3, int m4)
|
|
|
|
{
|
|
|
|
tcg_debug_assert(is_vector_reg(v1));
|
|
|
|
tcg_debug_assert(is_vector_reg(v3));
|
|
|
|
tcg_out16(s, (op & 0xff00) | ((v1 & 0xf) << 4) | (v3 & 0xf));
|
|
|
|
tcg_out16(s, i2);
|
|
|
|
tcg_out16(s, (op & 0x00ff) | RXB(v1, 0, v3, 0) | (m4 << 12));
|
|
|
|
}
|
|
|
|
|
2020-09-15 03:12:18 +03:00
|
|
|
static void tcg_out_insn_VRRa(TCGContext *s, S390Opcode op,
|
|
|
|
TCGReg v1, TCGReg v2, int m3)
|
|
|
|
{
|
|
|
|
tcg_debug_assert(is_vector_reg(v1));
|
|
|
|
tcg_debug_assert(is_vector_reg(v2));
|
|
|
|
tcg_out16(s, (op & 0xff00) | ((v1 & 0xf) << 4) | (v2 & 0xf));
|
|
|
|
tcg_out32(s, (op & 0x00ff) | RXB(v1, v2, 0, 0) | (m3 << 12));
|
|
|
|
}
|
|
|
|
|
2020-09-15 04:08:00 +03:00
|
|
|
static void tcg_out_insn_VRRc(TCGContext *s, S390Opcode op,
|
|
|
|
TCGReg v1, TCGReg v2, TCGReg v3, int m4)
|
|
|
|
{
|
|
|
|
tcg_debug_assert(is_vector_reg(v1));
|
|
|
|
tcg_debug_assert(is_vector_reg(v2));
|
|
|
|
tcg_debug_assert(is_vector_reg(v3));
|
|
|
|
tcg_out16(s, (op & 0xff00) | ((v1 & 0xf) << 4) | (v2 & 0xf));
|
|
|
|
tcg_out16(s, v3 << 12);
|
|
|
|
tcg_out16(s, (op & 0x00ff) | RXB(v1, v2, v3, 0) | (m4 << 12));
|
|
|
|
}
|
|
|
|
|
2020-09-15 06:36:36 +03:00
|
|
|
static void tcg_out_insn_VRRe(TCGContext *s, S390Opcode op,
|
|
|
|
TCGReg v1, TCGReg v2, TCGReg v3, TCGReg v4)
|
|
|
|
{
|
|
|
|
tcg_debug_assert(is_vector_reg(v1));
|
|
|
|
tcg_debug_assert(is_vector_reg(v2));
|
|
|
|
tcg_debug_assert(is_vector_reg(v3));
|
|
|
|
tcg_debug_assert(is_vector_reg(v4));
|
|
|
|
tcg_out16(s, (op & 0xff00) | ((v1 & 0xf) << 4) | (v2 & 0xf));
|
|
|
|
tcg_out16(s, v3 << 12);
|
|
|
|
tcg_out16(s, (op & 0x00ff) | RXB(v1, v2, v3, v4) | (v4 << 12));
|
|
|
|
}
|
|
|
|
|
2020-09-15 03:25:52 +03:00
|
|
|
static void tcg_out_insn_VRRf(TCGContext *s, S390Opcode op,
|
|
|
|
TCGReg v1, TCGReg r2, TCGReg r3)
|
|
|
|
{
|
|
|
|
tcg_debug_assert(is_vector_reg(v1));
|
|
|
|
tcg_debug_assert(is_general_reg(r2));
|
|
|
|
tcg_debug_assert(is_general_reg(r3));
|
|
|
|
tcg_out16(s, (op & 0xff00) | ((v1 & 0xf) << 4) | r2);
|
|
|
|
tcg_out16(s, r3 << 12);
|
|
|
|
tcg_out16(s, (op & 0x00ff) | RXB(v1, 0, 0, 0));
|
|
|
|
}
|
|
|
|
|
2020-09-15 05:00:38 +03:00
|
|
|
static void tcg_out_insn_VRSa(TCGContext *s, S390Opcode op, TCGReg v1,
|
|
|
|
intptr_t d2, TCGReg b2, TCGReg v3, int m4)
|
|
|
|
{
|
|
|
|
tcg_debug_assert(is_vector_reg(v1));
|
|
|
|
tcg_debug_assert(d2 >= 0 && d2 <= 0xfff);
|
|
|
|
tcg_debug_assert(is_general_reg(b2));
|
|
|
|
tcg_debug_assert(is_vector_reg(v3));
|
|
|
|
tcg_out16(s, (op & 0xff00) | ((v1 & 0xf) << 4) | (v3 & 0xf));
|
|
|
|
tcg_out16(s, b2 << 12 | d2);
|
|
|
|
tcg_out16(s, (op & 0x00ff) | RXB(v1, 0, v3, 0) | (m4 << 12));
|
|
|
|
}
|
|
|
|
|
2020-09-15 03:12:18 +03:00
|
|
|
static void tcg_out_insn_VRSb(TCGContext *s, S390Opcode op, TCGReg v1,
|
|
|
|
intptr_t d2, TCGReg b2, TCGReg r3, int m4)
|
|
|
|
{
|
|
|
|
tcg_debug_assert(is_vector_reg(v1));
|
|
|
|
tcg_debug_assert(d2 >= 0 && d2 <= 0xfff);
|
|
|
|
tcg_debug_assert(is_general_reg(b2));
|
|
|
|
tcg_debug_assert(is_general_reg(r3));
|
|
|
|
tcg_out16(s, (op & 0xff00) | ((v1 & 0xf) << 4) | r3);
|
|
|
|
tcg_out16(s, b2 << 12 | d2);
|
|
|
|
tcg_out16(s, (op & 0x00ff) | RXB(v1, 0, 0, 0) | (m4 << 12));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void tcg_out_insn_VRSc(TCGContext *s, S390Opcode op, TCGReg r1,
|
|
|
|
intptr_t d2, TCGReg b2, TCGReg v3, int m4)
|
|
|
|
{
|
|
|
|
tcg_debug_assert(is_general_reg(r1));
|
|
|
|
tcg_debug_assert(d2 >= 0 && d2 <= 0xfff);
|
|
|
|
tcg_debug_assert(is_general_reg(b2));
|
|
|
|
tcg_debug_assert(is_vector_reg(v3));
|
|
|
|
tcg_out16(s, (op & 0xff00) | (r1 << 4) | (v3 & 0xf));
|
|
|
|
tcg_out16(s, b2 << 12 | d2);
|
|
|
|
tcg_out16(s, (op & 0x00ff) | RXB(0, 0, v3, 0) | (m4 << 12));
|
|
|
|
}
|
|
|
|
|
2020-09-15 03:04:22 +03:00
|
|
|
static void tcg_out_insn_VRX(TCGContext *s, S390Opcode op, TCGReg v1,
|
|
|
|
TCGReg b2, TCGReg x2, intptr_t d2, int m3)
|
|
|
|
{
|
|
|
|
tcg_debug_assert(is_vector_reg(v1));
|
|
|
|
tcg_debug_assert(d2 >= 0 && d2 <= 0xfff);
|
|
|
|
tcg_debug_assert(is_general_reg(x2));
|
|
|
|
tcg_debug_assert(is_general_reg(b2));
|
|
|
|
tcg_out16(s, (op & 0xff00) | ((v1 & 0xf) << 4) | x2);
|
|
|
|
tcg_out16(s, (b2 << 12) | d2);
|
|
|
|
tcg_out16(s, (op & 0x00ff) | RXB(v1, 0, 0, 0) | (m3 << 12));
|
|
|
|
}
|
|
|
|
|
2010-06-29 06:15:37 +04:00
|
|
|
/* Emit an opcode with "type-checking" of the format. */
|
|
|
|
#define tcg_out_insn(S, FMT, OP, ...) \
|
|
|
|
glue(tcg_out_insn_,FMT)(S, glue(glue(FMT,_),OP), ## __VA_ARGS__)
|
|
|
|
|
|
|
|
|
|
|
|
/* emit 64-bit shifts */
|
|
|
|
static void tcg_out_sh64(TCGContext* s, S390Opcode op, TCGReg dest,
|
|
|
|
TCGReg src, TCGReg sh_reg, int sh_imm)
|
|
|
|
{
|
|
|
|
tcg_out_insn_RSY(s, op, dest, sh_reg, src, sh_imm);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* emit 32-bit shifts */
|
|
|
|
static void tcg_out_sh32(TCGContext* s, S390Opcode op, TCGReg dest,
|
|
|
|
TCGReg sh_reg, int sh_imm)
|
|
|
|
{
|
|
|
|
tcg_out_insn_RS(s, op, dest, sh_reg, 0, sh_imm);
|
|
|
|
}
|
|
|
|
|
2019-03-16 20:48:18 +03:00
|
|
|
static bool tcg_out_mov(TCGContext *s, TCGType type, TCGReg dst, TCGReg src)
|
2010-06-29 06:15:37 +04:00
|
|
|
{
|
2020-09-15 03:12:18 +03:00
|
|
|
if (src == dst) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
switch (type) {
|
|
|
|
case TCG_TYPE_I32:
|
|
|
|
if (likely(is_general_reg(dst) && is_general_reg(src))) {
|
2010-06-29 06:15:37 +04:00
|
|
|
tcg_out_insn(s, RR, LR, dst, src);
|
2020-09-15 03:12:18 +03:00
|
|
|
break;
|
2010-06-29 06:15:37 +04:00
|
|
|
}
|
2020-09-15 03:12:18 +03:00
|
|
|
/* fallthru */
|
|
|
|
|
|
|
|
case TCG_TYPE_I64:
|
|
|
|
if (likely(is_general_reg(dst))) {
|
|
|
|
if (likely(is_general_reg(src))) {
|
|
|
|
tcg_out_insn(s, RRE, LGR, dst, src);
|
|
|
|
} else {
|
|
|
|
tcg_out_insn(s, VRSc, VLGV, dst, 0, 0, src, 3);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
} else if (is_general_reg(src)) {
|
|
|
|
tcg_out_insn(s, VRSb, VLVG, dst, 0, 0, src, 3);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* fallthru */
|
|
|
|
|
|
|
|
case TCG_TYPE_V64:
|
|
|
|
case TCG_TYPE_V128:
|
|
|
|
tcg_out_insn(s, VRRa, VLR, dst, src, 0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
2010-06-29 06:15:37 +04:00
|
|
|
}
|
2019-03-16 20:48:18 +03:00
|
|
|
return true;
|
2010-06-29 06:15:37 +04:00
|
|
|
}
|
|
|
|
|
2022-12-08 23:53:38 +03:00
|
|
|
static const S390Opcode li_insns[4] = {
|
2017-08-01 05:16:02 +03:00
|
|
|
RI_LLILL, RI_LLILH, RI_LLIHL, RI_LLIHH
|
|
|
|
};
|
2022-12-09 02:05:03 +03:00
|
|
|
static const S390Opcode oi_insns[4] = {
|
|
|
|
RI_OILL, RI_OILH, RI_OIHL, RI_OIHH
|
|
|
|
};
|
2022-12-08 23:53:38 +03:00
|
|
|
static const S390Opcode lif_insns[2] = {
|
|
|
|
RIL_LLILF, RIL_LLIHF,
|
|
|
|
};
|
2010-06-29 06:15:37 +04:00
|
|
|
|
2022-12-08 23:53:38 +03:00
|
|
|
/* load a register with an immediate value */
|
|
|
|
static void tcg_out_movi(TCGContext *s, TCGType type,
|
|
|
|
TCGReg ret, tcg_target_long sval)
|
2017-08-01 05:16:02 +03:00
|
|
|
{
|
2010-06-29 06:15:37 +04:00
|
|
|
tcg_target_ulong uval = sval;
|
2022-12-08 23:53:38 +03:00
|
|
|
ptrdiff_t pc_off;
|
2010-06-29 06:15:37 +04:00
|
|
|
int i;
|
|
|
|
|
|
|
|
if (type == TCG_TYPE_I32) {
|
|
|
|
uval = (uint32_t)sval;
|
|
|
|
sval = (int32_t)sval;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Try all 32-bit insns that can load it in one go. */
|
|
|
|
if (sval >= -0x8000 && sval < 0x8000) {
|
|
|
|
tcg_out_insn(s, RI, LGHI, ret, sval);
|
2017-08-01 05:16:02 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-12-08 23:53:38 +03:00
|
|
|
i = is_const_p16(uval);
|
|
|
|
if (i >= 0) {
|
|
|
|
tcg_out_insn_RI(s, li_insns[i], ret, uval >> (i * 16));
|
|
|
|
return;
|
2017-08-01 05:16:02 +03:00
|
|
|
}
|
|
|
|
|
2010-06-29 06:15:37 +04:00
|
|
|
/* Try all 48-bit insns that can load it in one go. */
|
2022-12-07 19:28:07 +03:00
|
|
|
if (sval == (int32_t)sval) {
|
|
|
|
tcg_out_insn(s, RIL, LGFI, ret, sval);
|
|
|
|
return;
|
|
|
|
}
|
2022-12-08 23:53:38 +03:00
|
|
|
|
|
|
|
i = is_const_p32(uval);
|
|
|
|
if (i >= 0) {
|
|
|
|
tcg_out_insn_RIL(s, lif_insns[i], ret, uval >> (i * 32));
|
2022-12-07 19:28:07 +03:00
|
|
|
return;
|
2010-06-29 06:15:37 +04:00
|
|
|
}
|
|
|
|
|
2022-11-30 04:27:28 +03:00
|
|
|
/* Try for PC-relative address load. For odd addresses, add one. */
|
|
|
|
pc_off = tcg_pcrel_diff(s, (void *)sval) >> 1;
|
|
|
|
if (pc_off == (int32_t)pc_off) {
|
|
|
|
tcg_out_insn(s, RIL, LARL, ret, pc_off);
|
|
|
|
if (sval & 1) {
|
|
|
|
tcg_out_insn(s, RI, AGHI, ret, 1);
|
2010-06-29 06:15:37 +04:00
|
|
|
}
|
2022-11-30 04:27:28 +03:00
|
|
|
return;
|
2010-06-29 06:15:37 +04:00
|
|
|
}
|
|
|
|
|
2022-12-09 02:05:03 +03:00
|
|
|
/* Otherwise, load it by parts. */
|
|
|
|
i = is_const_p16((uint32_t)uval);
|
|
|
|
if (i >= 0) {
|
|
|
|
tcg_out_insn_RI(s, li_insns[i], ret, uval >> (i * 16));
|
|
|
|
} else {
|
|
|
|
tcg_out_insn(s, RIL, LLILF, ret, uval);
|
|
|
|
}
|
|
|
|
uval >>= 32;
|
|
|
|
i = is_const_p16(uval);
|
|
|
|
if (i >= 0) {
|
|
|
|
tcg_out_insn_RI(s, oi_insns[i + 2], ret, uval >> (i * 16));
|
|
|
|
} else {
|
|
|
|
tcg_out_insn(s, RIL, OIHF, ret, uval);
|
|
|
|
}
|
2010-06-29 06:15:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Emit a load/store type instruction. Inputs are:
|
|
|
|
DATA: The register to be loaded or stored.
|
|
|
|
BASE+OFS: The effective address.
|
|
|
|
OPC_RX: If the operation has an RX format opcode (e.g. STC), otherwise 0.
|
|
|
|
OPC_RXY: The RXY format opcode for the operation (e.g. STCY). */
|
|
|
|
|
|
|
|
static void tcg_out_mem(TCGContext *s, S390Opcode opc_rx, S390Opcode opc_rxy,
|
|
|
|
TCGReg data, TCGReg base, TCGReg index,
|
|
|
|
tcg_target_long ofs)
|
|
|
|
{
|
|
|
|
if (ofs < -0x80000 || ofs >= 0x80000) {
|
2013-03-27 22:37:42 +04:00
|
|
|
/* Combine the low 20 bits of the offset with the actual load insn;
|
|
|
|
the high 44 bits must come from an immediate load. */
|
|
|
|
tcg_target_long low = ((ofs & 0xfffff) ^ 0x80000) - 0x80000;
|
|
|
|
tcg_out_movi(s, TCG_TYPE_PTR, TCG_TMP0, ofs - low);
|
|
|
|
ofs = low;
|
2010-06-29 06:15:37 +04:00
|
|
|
|
|
|
|
/* If we were already given an index register, add it in. */
|
|
|
|
if (index != TCG_REG_NONE) {
|
|
|
|
tcg_out_insn(s, RRE, AGR, TCG_TMP0, index);
|
|
|
|
}
|
|
|
|
index = TCG_TMP0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (opc_rx && ofs >= 0 && ofs < 0x1000) {
|
|
|
|
tcg_out_insn_RX(s, opc_rx, data, base, index, ofs);
|
|
|
|
} else {
|
|
|
|
tcg_out_insn_RXY(s, opc_rxy, data, base, index, ofs);
|
|
|
|
}
|
2009-12-05 14:44:23 +03:00
|
|
|
}
|
|
|
|
|
2020-09-15 03:04:22 +03:00
|
|
|
static void tcg_out_vrx_mem(TCGContext *s, S390Opcode opc_vrx,
|
|
|
|
TCGReg data, TCGReg base, TCGReg index,
|
|
|
|
tcg_target_long ofs, int m3)
|
|
|
|
{
|
|
|
|
if (ofs < 0 || ofs >= 0x1000) {
|
|
|
|
if (ofs >= -0x80000 && ofs < 0x80000) {
|
|
|
|
tcg_out_insn(s, RXY, LAY, TCG_TMP0, base, index, ofs);
|
|
|
|
base = TCG_TMP0;
|
|
|
|
index = TCG_REG_NONE;
|
|
|
|
ofs = 0;
|
|
|
|
} else {
|
|
|
|
tcg_out_movi(s, TCG_TYPE_PTR, TCG_TMP0, ofs);
|
|
|
|
if (index != TCG_REG_NONE) {
|
|
|
|
tcg_out_insn(s, RRE, AGR, TCG_TMP0, index);
|
|
|
|
}
|
|
|
|
index = TCG_TMP0;
|
|
|
|
ofs = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
tcg_out_insn_VRX(s, opc_vrx, data, base, index, ofs, m3);
|
|
|
|
}
|
2010-06-29 06:15:37 +04:00
|
|
|
|
2009-12-05 14:44:23 +03:00
|
|
|
/* load data without address translation or endianness conversion */
|
2020-09-15 03:04:22 +03:00
|
|
|
static void tcg_out_ld(TCGContext *s, TCGType type, TCGReg data,
|
|
|
|
TCGReg base, intptr_t ofs)
|
2009-12-05 14:44:23 +03:00
|
|
|
{
|
2020-09-15 03:04:22 +03:00
|
|
|
switch (type) {
|
|
|
|
case TCG_TYPE_I32:
|
|
|
|
if (likely(is_general_reg(data))) {
|
|
|
|
tcg_out_mem(s, RX_L, RXY_LY, data, base, TCG_REG_NONE, ofs);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
tcg_out_vrx_mem(s, VRX_VLLEZ, data, base, TCG_REG_NONE, ofs, MO_32);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TCG_TYPE_I64:
|
|
|
|
if (likely(is_general_reg(data))) {
|
|
|
|
tcg_out_mem(s, 0, RXY_LG, data, base, TCG_REG_NONE, ofs);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* fallthru */
|
|
|
|
|
|
|
|
case TCG_TYPE_V64:
|
|
|
|
tcg_out_vrx_mem(s, VRX_VLLEZ, data, base, TCG_REG_NONE, ofs, MO_64);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TCG_TYPE_V128:
|
|
|
|
/* Hint quadword aligned. */
|
|
|
|
tcg_out_vrx_mem(s, VRX_VL, data, base, TCG_REG_NONE, ofs, 4);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
2010-06-29 06:15:37 +04:00
|
|
|
}
|
2009-12-05 14:44:23 +03:00
|
|
|
}
|
|
|
|
|
2020-09-15 03:04:22 +03:00
|
|
|
static void tcg_out_st(TCGContext *s, TCGType type, TCGReg data,
|
|
|
|
TCGReg base, intptr_t ofs)
|
2009-12-05 14:44:23 +03:00
|
|
|
{
|
2020-09-15 03:04:22 +03:00
|
|
|
switch (type) {
|
|
|
|
case TCG_TYPE_I32:
|
|
|
|
if (likely(is_general_reg(data))) {
|
|
|
|
tcg_out_mem(s, RX_ST, RXY_STY, data, base, TCG_REG_NONE, ofs);
|
|
|
|
} else {
|
|
|
|
tcg_out_vrx_mem(s, VRX_VSTEF, data, base, TCG_REG_NONE, ofs, 1);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TCG_TYPE_I64:
|
|
|
|
if (likely(is_general_reg(data))) {
|
|
|
|
tcg_out_mem(s, 0, RXY_STG, data, base, TCG_REG_NONE, ofs);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* fallthru */
|
|
|
|
|
|
|
|
case TCG_TYPE_V64:
|
|
|
|
tcg_out_vrx_mem(s, VRX_VSTEG, data, base, TCG_REG_NONE, ofs, 0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TCG_TYPE_V128:
|
|
|
|
/* Hint quadword aligned. */
|
|
|
|
tcg_out_vrx_mem(s, VRX_VST, data, base, TCG_REG_NONE, ofs, 4);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
2010-06-29 06:15:37 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-20 08:59:13 +03:00
|
|
|
static inline bool tcg_out_sti(TCGContext *s, TCGType type, TCGArg val,
|
|
|
|
TCGReg base, intptr_t ofs)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2023-04-06 07:39:54 +03:00
|
|
|
static bool tcg_out_xchg(TCGContext *s, TCGType type, TCGReg r1, TCGReg r2)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-10-18 14:28:04 +03:00
|
|
|
static void tcg_out_addi_ptr(TCGContext *s, TCGReg rd, TCGReg rs,
|
|
|
|
tcg_target_long imm)
|
|
|
|
{
|
|
|
|
/* This function is only used for passing structs by reference. */
|
|
|
|
tcg_out_mem(s, RX_LA, RXY_LAY, rd, rs, TCG_REG_NONE, imm);
|
|
|
|
}
|
|
|
|
|
2013-03-27 20:28:22 +04:00
|
|
|
static inline void tcg_out_risbg(TCGContext *s, TCGReg dest, TCGReg src,
|
|
|
|
int msb, int lsb, int ofs, int z)
|
|
|
|
{
|
|
|
|
/* Format RIE-f */
|
2022-02-24 05:00:42 +03:00
|
|
|
tcg_out16(s, (RIEf_RISBG & 0xff00) | (dest << 4) | src);
|
2013-03-27 20:28:22 +04:00
|
|
|
tcg_out16(s, (msb << 8) | (z << 7) | lsb);
|
2022-02-24 05:00:42 +03:00
|
|
|
tcg_out16(s, (ofs << 8) | (RIEf_RISBG & 0xff));
|
2013-03-27 20:28:22 +04:00
|
|
|
}
|
|
|
|
|
2023-04-05 21:17:01 +03:00
|
|
|
static void tcg_out_ext8s(TCGContext *s, TCGType type, TCGReg dest, TCGReg src)
|
2010-06-29 06:15:37 +04:00
|
|
|
{
|
2022-12-07 19:28:07 +03:00
|
|
|
tcg_out_insn(s, RRE, LGBR, dest, src);
|
2010-06-29 06:15:37 +04:00
|
|
|
}
|
|
|
|
|
2023-04-05 23:26:51 +03:00
|
|
|
static void tcg_out_ext8u(TCGContext *s, TCGReg dest, TCGReg src)
|
2010-06-29 06:15:37 +04:00
|
|
|
{
|
2022-12-07 19:28:07 +03:00
|
|
|
tcg_out_insn(s, RRE, LLGCR, dest, src);
|
2010-06-29 06:15:37 +04:00
|
|
|
}
|
|
|
|
|
2023-04-06 00:49:59 +03:00
|
|
|
static void tcg_out_ext16s(TCGContext *s, TCGType type, TCGReg dest, TCGReg src)
|
2010-06-29 06:15:37 +04:00
|
|
|
{
|
2022-12-07 19:28:07 +03:00
|
|
|
tcg_out_insn(s, RRE, LGHR, dest, src);
|
2010-06-29 06:15:37 +04:00
|
|
|
}
|
|
|
|
|
2023-04-06 02:25:22 +03:00
|
|
|
static void tcg_out_ext16u(TCGContext *s, TCGReg dest, TCGReg src)
|
2010-06-29 06:15:37 +04:00
|
|
|
{
|
2022-12-07 19:28:07 +03:00
|
|
|
tcg_out_insn(s, RRE, LLGHR, dest, src);
|
2010-06-29 06:15:37 +04:00
|
|
|
}
|
|
|
|
|
2023-04-06 03:50:09 +03:00
|
|
|
static void tcg_out_ext32s(TCGContext *s, TCGReg dest, TCGReg src)
|
2010-06-29 06:15:37 +04:00
|
|
|
{
|
|
|
|
tcg_out_insn(s, RRE, LGFR, dest, src);
|
|
|
|
}
|
|
|
|
|
2023-04-06 04:07:05 +03:00
|
|
|
static void tcg_out_ext32u(TCGContext *s, TCGReg dest, TCGReg src)
|
2010-06-29 06:15:37 +04:00
|
|
|
{
|
|
|
|
tcg_out_insn(s, RRE, LLGFR, dest, src);
|
|
|
|
}
|
|
|
|
|
2023-04-06 04:30:56 +03:00
|
|
|
static void tcg_out_exts_i32_i64(TCGContext *s, TCGReg dest, TCGReg src)
|
|
|
|
{
|
|
|
|
tcg_out_ext32s(s, dest, src);
|
|
|
|
}
|
|
|
|
|
2023-04-06 04:56:28 +03:00
|
|
|
static void tcg_out_extu_i32_i64(TCGContext *s, TCGReg dest, TCGReg src)
|
|
|
|
{
|
|
|
|
tcg_out_ext32u(s, dest, src);
|
|
|
|
}
|
|
|
|
|
2023-04-06 05:58:35 +03:00
|
|
|
static void tcg_out_extrl_i64_i32(TCGContext *s, TCGReg dest, TCGReg src)
|
|
|
|
{
|
|
|
|
tcg_out_mov(s, TCG_TYPE_I32, dest, src);
|
|
|
|
}
|
|
|
|
|
tcg-s390: Use more risbg in the tlb sequence
Elides two insns from the sequence. The resulting tlb compare
sequence is satisfyingly minimal:
risbg %r2,%r8,51,186,56
risbg %r3,%r8,61,178,0
cg %r3,904(%r10,%r2)
lg %r2,920(%r10,%r2)
jlh tlb_miss
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-03-24 03:35:44 +04:00
|
|
|
static void tgen_andi_risbg(TCGContext *s, TCGReg out, TCGReg in, uint64_t val)
|
|
|
|
{
|
|
|
|
int msb, lsb;
|
|
|
|
if ((val & 0x8000000000000001ull) == 0x8000000000000001ull) {
|
|
|
|
/* Achieve wraparound by swapping msb and lsb. */
|
|
|
|
msb = 64 - ctz64(~val);
|
|
|
|
lsb = clz64(~val) - 1;
|
|
|
|
} else {
|
|
|
|
msb = clz64(val);
|
|
|
|
lsb = 63 - ctz64(val);
|
|
|
|
}
|
|
|
|
tcg_out_risbg(s, out, in, msb, lsb, 0, 1);
|
|
|
|
}
|
|
|
|
|
2013-03-27 19:47:54 +04:00
|
|
|
static void tgen_andi(TCGContext *s, TCGType type, TCGReg dest, uint64_t val)
|
2010-06-29 06:15:37 +04:00
|
|
|
{
|
|
|
|
static const S390Opcode ni_insns[4] = {
|
|
|
|
RI_NILL, RI_NILH, RI_NIHL, RI_NIHH
|
|
|
|
};
|
|
|
|
static const S390Opcode nif_insns[2] = {
|
|
|
|
RIL_NILF, RIL_NIHF
|
|
|
|
};
|
2013-03-27 19:47:54 +04:00
|
|
|
uint64_t valid = (type == TCG_TYPE_I32 ? 0xffffffffull : -1ull);
|
2010-06-29 06:15:37 +04:00
|
|
|
int i;
|
|
|
|
|
|
|
|
/* Look for the zero-extensions. */
|
2013-03-27 19:47:54 +04:00
|
|
|
if ((val & valid) == 0xffffffff) {
|
2023-04-06 04:07:05 +03:00
|
|
|
tcg_out_ext32u(s, dest, dest);
|
2010-06-29 06:15:37 +04:00
|
|
|
return;
|
|
|
|
}
|
2022-12-07 19:28:07 +03:00
|
|
|
if ((val & valid) == 0xff) {
|
2023-04-05 23:26:51 +03:00
|
|
|
tcg_out_ext8u(s, dest, dest);
|
2022-12-07 19:28:07 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ((val & valid) == 0xffff) {
|
2023-04-06 02:25:22 +03:00
|
|
|
tcg_out_ext16u(s, dest, dest);
|
2022-12-07 19:28:07 +03:00
|
|
|
return;
|
2013-03-27 19:47:54 +04:00
|
|
|
}
|
2010-06-29 06:15:37 +04:00
|
|
|
|
2022-12-08 21:06:03 +03:00
|
|
|
i = is_const_p16(~val & valid);
|
|
|
|
if (i >= 0) {
|
|
|
|
tcg_out_insn_RI(s, ni_insns[i], dest, val >> (i * 16));
|
|
|
|
return;
|
2013-03-27 19:47:54 +04:00
|
|
|
}
|
2010-06-29 06:15:37 +04:00
|
|
|
|
2022-12-08 21:06:03 +03:00
|
|
|
i = is_const_p32(~val & valid);
|
|
|
|
tcg_debug_assert(i == 0 || type != TCG_TYPE_I32);
|
|
|
|
if (i >= 0) {
|
|
|
|
tcg_out_insn_RIL(s, nif_insns[i], dest, val >> (i * 32));
|
|
|
|
return;
|
2013-03-27 19:47:54 +04:00
|
|
|
}
|
2022-12-08 21:06:03 +03:00
|
|
|
|
2022-12-07 19:51:27 +03:00
|
|
|
if (risbg_mask(val)) {
|
tcg-s390: Use more risbg in the tlb sequence
Elides two insns from the sequence. The resulting tlb compare
sequence is satisfyingly minimal:
risbg %r2,%r8,51,186,56
risbg %r3,%r8,61,178,0
cg %r3,904(%r10,%r2)
lg %r2,920(%r10,%r2)
jlh tlb_miss
Signed-off-by: Richard Henderson <rth@twiddle.net>
2014-03-24 03:35:44 +04:00
|
|
|
tgen_andi_risbg(s, dest, dest, val);
|
2013-03-27 20:28:22 +04:00
|
|
|
return;
|
|
|
|
}
|
2010-06-29 06:15:37 +04:00
|
|
|
|
2022-12-08 21:06:03 +03:00
|
|
|
g_assert_not_reached();
|
2010-06-29 06:15:37 +04:00
|
|
|
}
|
|
|
|
|
2022-12-08 20:28:19 +03:00
|
|
|
static void tgen_ori(TCGContext *s, TCGReg dest, uint64_t val)
|
2010-06-29 06:15:37 +04:00
|
|
|
{
|
2017-07-26 02:21:36 +03:00
|
|
|
static const S390Opcode oif_insns[2] = {
|
2010-06-29 06:15:37 +04:00
|
|
|
RIL_OILF, RIL_OIHF
|
|
|
|
};
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
2022-12-08 20:28:19 +03:00
|
|
|
i = is_const_p16(val);
|
|
|
|
if (i >= 0) {
|
|
|
|
tcg_out_insn_RI(s, oi_insns[i], dest, val >> (i * 16));
|
2010-06-29 06:15:37 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-12-08 20:28:19 +03:00
|
|
|
i = is_const_p32(val);
|
|
|
|
if (i >= 0) {
|
|
|
|
tcg_out_insn_RIL(s, oif_insns[i], dest, val >> (i * 32));
|
|
|
|
return;
|
2017-07-26 02:21:36 +03:00
|
|
|
}
|
2010-06-29 06:15:37 +04:00
|
|
|
|
2022-12-08 20:28:19 +03:00
|
|
|
g_assert_not_reached();
|
2010-06-29 06:15:37 +04:00
|
|
|
}
|
|
|
|
|
2022-12-08 20:28:19 +03:00
|
|
|
static void tgen_xori(TCGContext *s, TCGReg dest, uint64_t val)
|
2010-06-29 06:15:37 +04:00
|
|
|
{
|
2022-12-08 20:28:19 +03:00
|
|
|
switch (is_const_p32(val)) {
|
|
|
|
case 0:
|
2022-12-07 19:28:07 +03:00
|
|
|
tcg_out_insn(s, RIL, XILF, dest, val);
|
2022-12-08 20:28:19 +03:00
|
|
|
break;
|
|
|
|
case 1:
|
2022-12-07 19:28:07 +03:00
|
|
|
tcg_out_insn(s, RIL, XIHF, dest, val >> 32);
|
2022-12-08 20:28:19 +03:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
2010-06-29 06:15:37 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-24 06:38:03 +03:00
|
|
|
static int tgen_cmp2(TCGContext *s, TCGType type, TCGCond c, TCGReg r1,
|
|
|
|
TCGArg c2, bool c2const, bool need_carry, int *inv_cc)
|
2010-06-29 06:15:37 +04:00
|
|
|
{
|
2012-09-25 01:21:39 +04:00
|
|
|
bool is_unsigned = is_unsigned_cond(c);
|
2022-02-24 06:38:03 +03:00
|
|
|
TCGCond inv_c = tcg_invert_cond(c);
|
2017-07-26 03:10:29 +03:00
|
|
|
S390Opcode op;
|
|
|
|
|
2010-06-29 06:15:37 +04:00
|
|
|
if (c2const) {
|
|
|
|
if (c2 == 0) {
|
2016-12-07 06:00:57 +03:00
|
|
|
if (!(is_unsigned && need_carry)) {
|
|
|
|
if (type == TCG_TYPE_I32) {
|
|
|
|
tcg_out_insn(s, RR, LTR, r1, r1);
|
|
|
|
} else {
|
|
|
|
tcg_out_insn(s, RRE, LTGR, r1, r1);
|
|
|
|
}
|
2022-02-24 06:38:03 +03:00
|
|
|
*inv_cc = tcg_cond_to_ltr_cond[inv_c];
|
2016-12-07 06:00:57 +03:00
|
|
|
return tcg_cond_to_ltr_cond[c];
|
|
|
|
}
|
|
|
|
}
|
2017-07-26 03:10:29 +03:00
|
|
|
|
|
|
|
if (!is_unsigned && c2 == (int16_t)c2) {
|
|
|
|
op = (type == TCG_TYPE_I32 ? RI_CHI : RI_CGHI);
|
|
|
|
tcg_out_insn_RI(s, op, r1, c2);
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2022-12-07 19:28:07 +03:00
|
|
|
if (type == TCG_TYPE_I32) {
|
|
|
|
op = (is_unsigned ? RIL_CLFI : RIL_CFI);
|
|
|
|
tcg_out_insn_RIL(s, op, r1, c2);
|
|
|
|
goto exit;
|
|
|
|
}
|
2022-12-09 00:48:00 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Constraints are for a signed 33-bit operand, which is a
|
|
|
|
* convenient superset of this signed/unsigned test.
|
|
|
|
*/
|
2022-12-07 19:28:07 +03:00
|
|
|
if (c2 == (is_unsigned ? (TCGArg)(uint32_t)c2 : (TCGArg)(int32_t)c2)) {
|
|
|
|
op = (is_unsigned ? RIL_CLGFI : RIL_CGFI);
|
|
|
|
tcg_out_insn_RIL(s, op, r1, c2);
|
|
|
|
goto exit;
|
2010-06-29 06:15:37 +04:00
|
|
|
}
|
2017-07-26 03:10:29 +03:00
|
|
|
|
2022-12-09 00:48:00 +03:00
|
|
|
/* Load everything else into a register. */
|
|
|
|
tcg_out_movi(s, TCG_TYPE_I64, TCG_TMP0, c2);
|
|
|
|
c2 = TCG_TMP0;
|
2010-06-29 06:15:37 +04:00
|
|
|
}
|
2017-07-26 03:10:29 +03:00
|
|
|
|
|
|
|
if (type == TCG_TYPE_I32) {
|
|
|
|
op = (is_unsigned ? RR_CLR : RR_CR);
|
|
|
|
tcg_out_insn_RR(s, op, r1, c2);
|
|
|
|
} else {
|
|
|
|
op = (is_unsigned ? RRE_CLGR : RRE_CGR);
|
|
|
|
tcg_out_insn_RRE(s, op, r1, c2);
|
|
|
|
}
|
|
|
|
|
|
|
|
exit:
|
2022-02-24 06:38:03 +03:00
|
|
|
*inv_cc = tcg_cond_to_s390_cond[inv_c];
|
2010-06-29 06:15:37 +04:00
|
|
|
return tcg_cond_to_s390_cond[c];
|
|
|
|
}
|
|
|
|
|
2022-02-24 06:38:03 +03:00
|
|
|
static int tgen_cmp(TCGContext *s, TCGType type, TCGCond c, TCGReg r1,
|
|
|
|
TCGArg c2, bool c2const, bool need_carry)
|
|
|
|
{
|
|
|
|
int inv_cc;
|
|
|
|
return tgen_cmp2(s, type, c, r1, c2, c2const, need_carry, &inv_cc);
|
|
|
|
}
|
|
|
|
|
2014-03-31 20:57:06 +04:00
|
|
|
static void tgen_setcond(TCGContext *s, TCGType type, TCGCond cond,
|
2023-08-05 21:55:54 +03:00
|
|
|
TCGReg dest, TCGReg c1, TCGArg c2,
|
|
|
|
bool c2const, bool neg)
|
2010-06-29 06:15:37 +04:00
|
|
|
{
|
2014-03-31 20:57:06 +04:00
|
|
|
int cc;
|
|
|
|
|
2017-06-17 01:33:28 +03:00
|
|
|
/* With LOC2, we can always emit the minimum 3 insns. */
|
2019-04-28 02:51:09 +03:00
|
|
|
if (HAVE_FACILITY(LOAD_ON_COND2)) {
|
2017-06-17 01:33:28 +03:00
|
|
|
/* Emit: d = 0, d = (cc ? 1 : d). */
|
|
|
|
cc = tgen_cmp(s, type, cond, c1, c2, c2const, false);
|
|
|
|
tcg_out_movi(s, TCG_TYPE_I64, dest, 0);
|
2023-08-05 21:55:54 +03:00
|
|
|
tcg_out_insn(s, RIEg, LOCGHI, dest, neg ? -1 : 1, cc);
|
2017-06-17 01:33:28 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-08-05 21:55:54 +03:00
|
|
|
switch (cond) {
|
|
|
|
case TCG_COND_GEU:
|
|
|
|
case TCG_COND_LTU:
|
|
|
|
case TCG_COND_LT:
|
|
|
|
case TCG_COND_GE:
|
|
|
|
/* Swap operands so that we can use LEU/GTU/GT/LE. */
|
|
|
|
if (!c2const) {
|
|
|
|
TCGReg t = c1;
|
|
|
|
c1 = c2;
|
|
|
|
c2 = t;
|
|
|
|
cond = tcg_swap_cond(cond);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-03-31 20:57:06 +04:00
|
|
|
switch (cond) {
|
2017-07-26 06:09:17 +03:00
|
|
|
case TCG_COND_NE:
|
|
|
|
/* X != 0 is X > 0. */
|
|
|
|
if (c2const && c2 == 0) {
|
|
|
|
cond = TCG_COND_GTU;
|
|
|
|
} else {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* fallthru */
|
|
|
|
|
2014-03-31 20:57:06 +04:00
|
|
|
case TCG_COND_GTU:
|
|
|
|
case TCG_COND_GT:
|
2023-08-05 21:55:54 +03:00
|
|
|
/*
|
|
|
|
* The result of a compare has CC=2 for GT and CC=3 unused.
|
|
|
|
* ADD LOGICAL WITH CARRY considers (CC & 2) the carry bit.
|
|
|
|
*/
|
2016-12-07 06:00:57 +03:00
|
|
|
tgen_cmp(s, type, cond, c1, c2, c2const, true);
|
2014-03-31 20:57:06 +04:00
|
|
|
tcg_out_movi(s, type, dest, 0);
|
|
|
|
tcg_out_insn(s, RRE, ALCGR, dest, dest);
|
2023-08-05 21:55:54 +03:00
|
|
|
if (neg) {
|
|
|
|
if (type == TCG_TYPE_I32) {
|
|
|
|
tcg_out_insn(s, RR, LCR, dest, dest);
|
|
|
|
} else {
|
|
|
|
tcg_out_insn(s, RRE, LCGR, dest, dest);
|
|
|
|
}
|
|
|
|
}
|
2014-03-31 20:57:06 +04:00
|
|
|
return;
|
|
|
|
|
2017-07-26 06:09:17 +03:00
|
|
|
case TCG_COND_EQ:
|
|
|
|
/* X == 0 is X <= 0. */
|
|
|
|
if (c2const && c2 == 0) {
|
|
|
|
cond = TCG_COND_LEU;
|
2014-03-31 20:57:06 +04:00
|
|
|
} else {
|
2017-07-26 06:09:17 +03:00
|
|
|
break;
|
2014-03-31 20:57:06 +04:00
|
|
|
}
|
2017-07-26 06:09:17 +03:00
|
|
|
/* fallthru */
|
2014-03-31 20:57:06 +04:00
|
|
|
|
|
|
|
case TCG_COND_LEU:
|
2017-07-26 06:09:17 +03:00
|
|
|
case TCG_COND_LE:
|
2023-08-05 21:55:54 +03:00
|
|
|
/*
|
|
|
|
* As above, but we're looking for borrow, or !carry.
|
|
|
|
* The second insn computes d - d - borrow, or -1 for true
|
|
|
|
* and 0 for false. So we must mask to 1 bit afterward.
|
|
|
|
*/
|
2017-07-26 06:09:17 +03:00
|
|
|
tgen_cmp(s, type, cond, c1, c2, c2const, true);
|
|
|
|
tcg_out_insn(s, RRE, SLBGR, dest, dest);
|
2023-08-05 21:55:54 +03:00
|
|
|
if (!neg) {
|
|
|
|
tgen_andi(s, type, dest, 1);
|
2014-03-31 20:57:06 +04:00
|
|
|
}
|
2023-08-05 21:55:54 +03:00
|
|
|
return;
|
2010-06-29 06:15:37 +04:00
|
|
|
|
2014-03-31 20:57:06 +04:00
|
|
|
default:
|
2017-07-26 06:09:17 +03:00
|
|
|
g_assert_not_reached();
|
2014-03-31 20:57:06 +04:00
|
|
|
}
|
|
|
|
|
2016-12-07 06:00:57 +03:00
|
|
|
cc = tgen_cmp(s, type, cond, c1, c2, c2const, false);
|
2022-12-07 20:38:42 +03:00
|
|
|
/* Emit: d = 0, t = 1, d = (cc ? t : d). */
|
|
|
|
tcg_out_movi(s, TCG_TYPE_I64, dest, 0);
|
2023-08-05 21:55:54 +03:00
|
|
|
tcg_out_movi(s, TCG_TYPE_I64, TCG_TMP0, neg ? -1 : 1);
|
2022-02-24 03:48:52 +03:00
|
|
|
tcg_out_insn(s, RRFc, LOCGR, dest, TCG_TMP0, cc);
|
2010-06-29 06:15:37 +04:00
|
|
|
}
|
|
|
|
|
2022-02-24 03:24:05 +03:00
|
|
|
static void tgen_movcond_int(TCGContext *s, TCGType type, TCGReg dest,
|
|
|
|
TCGArg v3, int v3const, TCGReg v4,
|
|
|
|
int cc, int inv_cc)
|
|
|
|
{
|
|
|
|
TCGReg src;
|
|
|
|
|
|
|
|
if (v3const) {
|
|
|
|
if (dest == v4) {
|
|
|
|
if (HAVE_FACILITY(LOAD_ON_COND2)) {
|
|
|
|
/* Emit: if (cc) dest = v3. */
|
|
|
|
tcg_out_insn(s, RIEg, LOCGHI, dest, v3, cc);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
tcg_out_insn(s, RI, LGHI, TCG_TMP0, v3);
|
|
|
|
src = TCG_TMP0;
|
|
|
|
} else {
|
|
|
|
/* LGR+LOCGHI is larger than LGHI+LOCGR. */
|
|
|
|
tcg_out_insn(s, RI, LGHI, dest, v3);
|
|
|
|
cc = inv_cc;
|
|
|
|
src = v4;
|
|
|
|
}
|
|
|
|
} else {
|
2022-12-02 07:05:38 +03:00
|
|
|
if (HAVE_FACILITY(MISC_INSN_EXT3)) {
|
|
|
|
/* Emit: dest = cc ? v3 : v4. */
|
|
|
|
tcg_out_insn(s, RRFam, SELGR, dest, v3, v4, cc);
|
|
|
|
return;
|
|
|
|
}
|
2022-02-24 03:24:05 +03:00
|
|
|
if (dest == v4) {
|
|
|
|
src = v3;
|
|
|
|
} else {
|
|
|
|
tcg_out_mov(s, type, dest, v3);
|
|
|
|
cc = inv_cc;
|
|
|
|
src = v4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Emit: if (cc) dest = src. */
|
|
|
|
tcg_out_insn(s, RRFc, LOCGR, dest, src, cc);
|
|
|
|
}
|
|
|
|
|
2013-03-27 01:28:52 +04:00
|
|
|
static void tgen_movcond(TCGContext *s, TCGType type, TCGCond c, TCGReg dest,
|
2017-06-17 01:33:28 +03:00
|
|
|
TCGReg c1, TCGArg c2, int c2const,
|
2022-02-24 03:24:05 +03:00
|
|
|
TCGArg v3, int v3const, TCGReg v4)
|
2013-03-27 01:28:52 +04:00
|
|
|
{
|
2022-02-24 06:38:03 +03:00
|
|
|
int cc, inv_cc;
|
|
|
|
|
|
|
|
cc = tgen_cmp2(s, type, c, c1, c2, c2const, false, &inv_cc);
|
2022-02-24 03:24:05 +03:00
|
|
|
tgen_movcond_int(s, type, dest, v3, v3const, v4, cc, inv_cc);
|
2013-03-27 01:28:52 +04:00
|
|
|
}
|
|
|
|
|
2016-11-16 18:10:37 +03:00
|
|
|
static void tgen_clz(TCGContext *s, TCGReg dest, TCGReg a1,
|
|
|
|
TCGArg a2, int a2const)
|
|
|
|
{
|
|
|
|
/* Since this sets both R and R+1, we have no choice but to store the
|
|
|
|
result into R0, allowing R1 == TCG_TMP0 to be clobbered as well. */
|
|
|
|
QEMU_BUILD_BUG_ON(TCG_TMP0 != TCG_REG_R1);
|
|
|
|
tcg_out_insn(s, RRE, FLOGR, TCG_REG_R0, a1);
|
|
|
|
|
|
|
|
if (a2const && a2 == 64) {
|
|
|
|
tcg_out_mov(s, TCG_TYPE_I64, dest, TCG_REG_R0);
|
2022-02-24 06:03:20 +03:00
|
|
|
return;
|
2016-11-16 18:10:37 +03:00
|
|
|
}
|
2022-02-24 06:03:20 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Conditions from FLOGR are:
|
|
|
|
* 2 -> one bit found
|
|
|
|
* 8 -> no one bit found
|
|
|
|
*/
|
|
|
|
tgen_movcond_int(s, TCG_TYPE_I64, dest, a2, a2const, TCG_REG_R0, 8, 2);
|
2016-11-16 18:10:37 +03:00
|
|
|
}
|
|
|
|
|
2022-02-24 03:43:18 +03:00
|
|
|
static void tgen_ctpop(TCGContext *s, TCGType type, TCGReg dest, TCGReg src)
|
|
|
|
{
|
|
|
|
/* With MIE3, and bit 0 of m4 set, we get the complete result. */
|
|
|
|
if (HAVE_FACILITY(MISC_INSN_EXT3)) {
|
|
|
|
if (type == TCG_TYPE_I32) {
|
2023-04-06 04:07:05 +03:00
|
|
|
tcg_out_ext32u(s, dest, src);
|
2022-02-24 03:43:18 +03:00
|
|
|
src = dest;
|
|
|
|
}
|
|
|
|
tcg_out_insn(s, RRFc, POPCNT, dest, src, 8);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Without MIE3, each byte gets the count of bits for the byte. */
|
|
|
|
tcg_out_insn(s, RRFc, POPCNT, dest, src, 0);
|
|
|
|
|
|
|
|
/* Multiply to sum each byte at the top of the word. */
|
|
|
|
if (type == TCG_TYPE_I32) {
|
|
|
|
tcg_out_insn(s, RIL, MSFI, dest, 0x01010101);
|
|
|
|
tcg_out_sh32(s, RS_SRL, dest, TCG_REG_NONE, 24);
|
|
|
|
} else {
|
|
|
|
tcg_out_movi(s, TCG_TYPE_I64, TCG_TMP0, 0x0101010101010101ull);
|
|
|
|
tcg_out_insn(s, RRE, MSGR, dest, TCG_TMP0);
|
|
|
|
tcg_out_sh64(s, RSY_SRLG, dest, dest, TCG_REG_NONE, 56);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-27 17:30:58 +04:00
|
|
|
static void tgen_deposit(TCGContext *s, TCGReg dest, TCGReg src,
|
2016-10-18 03:00:46 +03:00
|
|
|
int ofs, int len, int z)
|
2013-03-27 17:30:58 +04:00
|
|
|
{
|
|
|
|
int lsb = (63 - ofs);
|
|
|
|
int msb = lsb - (len - 1);
|
2016-10-18 03:00:46 +03:00
|
|
|
tcg_out_risbg(s, dest, src, msb, lsb, ofs, z);
|
2013-03-27 17:30:58 +04:00
|
|
|
}
|
|
|
|
|
2016-10-14 22:26:40 +03:00
|
|
|
static void tgen_extract(TCGContext *s, TCGReg dest, TCGReg src,
|
|
|
|
int ofs, int len)
|
|
|
|
{
|
|
|
|
tcg_out_risbg(s, dest, src, 64 - len, 63, 64 - ofs, 1);
|
|
|
|
}
|
|
|
|
|
2020-10-31 01:55:28 +03:00
|
|
|
static void tgen_gotoi(TCGContext *s, int cc, const tcg_insn_unit *dest)
|
2010-06-29 06:15:37 +04:00
|
|
|
{
|
2020-11-05 07:56:16 +03:00
|
|
|
ptrdiff_t off = tcg_pcrel_diff(s, dest) >> 1;
|
2014-04-25 18:18:59 +04:00
|
|
|
if (off == (int16_t)off) {
|
2010-06-29 06:15:37 +04:00
|
|
|
tcg_out_insn(s, RI, BRC, cc, off);
|
|
|
|
} else if (off == (int32_t)off) {
|
|
|
|
tcg_out_insn(s, RIL, BRCL, cc, off);
|
|
|
|
} else {
|
2014-04-25 18:18:59 +04:00
|
|
|
tcg_out_movi(s, TCG_TYPE_PTR, TCG_TMP0, (uintptr_t)dest);
|
2010-06-29 06:15:37 +04:00
|
|
|
tcg_out_insn(s, RR, BCR, cc, TCG_TMP0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-14 00:39:54 +03:00
|
|
|
static void tgen_branch(TCGContext *s, int cc, TCGLabel *l)
|
2010-06-29 06:15:37 +04:00
|
|
|
{
|
|
|
|
if (l->has_value) {
|
2014-04-25 18:18:59 +04:00
|
|
|
tgen_gotoi(s, cc, l->u.value_ptr);
|
2010-06-29 06:15:37 +04:00
|
|
|
} else {
|
|
|
|
tcg_out16(s, RI_BRC | (cc << 4));
|
2017-07-30 23:58:01 +03:00
|
|
|
tcg_out_reloc(s, s->code_ptr, R_390_PC16DBL, l, 2);
|
2014-04-25 18:18:59 +04:00
|
|
|
s->code_ptr += 1;
|
2010-06-29 06:15:37 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void tgen_compare_branch(TCGContext *s, S390Opcode opc, int cc,
|
2015-02-14 00:39:54 +03:00
|
|
|
TCGReg r1, TCGReg r2, TCGLabel *l)
|
2010-06-29 06:15:37 +04:00
|
|
|
{
|
2020-11-05 07:56:16 +03:00
|
|
|
tcg_out_reloc(s, s->code_ptr + 1, R_390_PC16DBL, l, 2);
|
2022-02-24 05:00:42 +03:00
|
|
|
/* Format RIE-b */
|
2010-06-29 06:15:37 +04:00
|
|
|
tcg_out16(s, (opc & 0xff00) | (r1 << 4) | r2);
|
2020-11-05 07:56:16 +03:00
|
|
|
tcg_out16(s, 0);
|
2010-06-29 06:15:37 +04:00
|
|
|
tcg_out16(s, cc << 12 | (opc & 0xff));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void tgen_compare_imm_branch(TCGContext *s, S390Opcode opc, int cc,
|
2015-02-14 00:39:54 +03:00
|
|
|
TCGReg r1, int i2, TCGLabel *l)
|
2010-06-29 06:15:37 +04:00
|
|
|
{
|
2020-11-05 07:56:16 +03:00
|
|
|
tcg_out_reloc(s, s->code_ptr + 1, R_390_PC16DBL, l, 2);
|
2022-02-24 05:00:42 +03:00
|
|
|
/* Format RIE-c */
|
2010-06-29 06:15:37 +04:00
|
|
|
tcg_out16(s, (opc & 0xff00) | (r1 << 4) | cc);
|
2020-11-05 07:56:16 +03:00
|
|
|
tcg_out16(s, 0);
|
2010-06-29 06:15:37 +04:00
|
|
|
tcg_out16(s, (i2 << 8) | (opc & 0xff));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void tgen_brcond(TCGContext *s, TCGType type, TCGCond c,
|
2015-02-14 00:39:54 +03:00
|
|
|
TCGReg r1, TCGArg c2, int c2const, TCGLabel *l)
|
2010-06-29 06:15:37 +04:00
|
|
|
{
|
|
|
|
int cc;
|
2022-12-07 19:51:27 +03:00
|
|
|
bool is_unsigned = is_unsigned_cond(c);
|
|
|
|
bool in_range;
|
|
|
|
S390Opcode opc;
|
2010-06-29 06:15:37 +04:00
|
|
|
|
2022-12-07 19:51:27 +03:00
|
|
|
cc = tcg_cond_to_s390_cond[c];
|
2010-06-29 06:15:37 +04:00
|
|
|
|
2022-12-07 19:51:27 +03:00
|
|
|
if (!c2const) {
|
|
|
|
opc = (type == TCG_TYPE_I32
|
2022-02-24 05:00:42 +03:00
|
|
|
? (is_unsigned ? RIEb_CLRJ : RIEb_CRJ)
|
|
|
|
: (is_unsigned ? RIEb_CLGRJ : RIEb_CGRJ));
|
2022-12-07 19:51:27 +03:00
|
|
|
tgen_compare_branch(s, opc, cc, r1, c2, l);
|
|
|
|
return;
|
|
|
|
}
|
2010-06-29 06:15:37 +04:00
|
|
|
|
2022-12-07 19:51:27 +03:00
|
|
|
/*
|
|
|
|
* COMPARE IMMEDIATE AND BRANCH RELATIVE has an 8-bit immediate field.
|
|
|
|
* If the immediate we've been given does not fit that range, we'll
|
|
|
|
* fall back to separate compare and branch instructions using the
|
|
|
|
* larger comparison range afforded by COMPARE IMMEDIATE.
|
|
|
|
*/
|
|
|
|
if (type == TCG_TYPE_I32) {
|
|
|
|
if (is_unsigned) {
|
2022-02-24 05:00:42 +03:00
|
|
|
opc = RIEc_CLIJ;
|
2022-12-07 19:51:27 +03:00
|
|
|
in_range = (uint32_t)c2 == (uint8_t)c2;
|
2010-06-29 06:15:37 +04:00
|
|
|
} else {
|
2022-02-24 05:00:42 +03:00
|
|
|
opc = RIEc_CIJ;
|
2022-12-07 19:51:27 +03:00
|
|
|
in_range = (int32_t)c2 == (int8_t)c2;
|
2010-06-29 06:15:37 +04:00
|
|
|
}
|
2022-12-07 19:51:27 +03:00
|
|
|
} else {
|
|
|
|
if (is_unsigned) {
|
2022-02-24 05:00:42 +03:00
|
|
|
opc = RIEc_CLGIJ;
|
2022-12-07 19:51:27 +03:00
|
|
|
in_range = (uint64_t)c2 == (uint8_t)c2;
|
|
|
|
} else {
|
2022-02-24 05:00:42 +03:00
|
|
|
opc = RIEc_CGIJ;
|
2022-12-07 19:51:27 +03:00
|
|
|
in_range = (int64_t)c2 == (int8_t)c2;
|
2010-06-29 06:15:37 +04:00
|
|
|
}
|
|
|
|
}
|
2022-12-07 19:51:27 +03:00
|
|
|
if (in_range) {
|
|
|
|
tgen_compare_imm_branch(s, opc, cc, r1, c2, l);
|
|
|
|
return;
|
|
|
|
}
|
2010-06-29 06:15:37 +04:00
|
|
|
|
2016-12-07 06:00:57 +03:00
|
|
|
cc = tgen_cmp(s, type, c, r1, c2, c2const, false);
|
2015-02-14 00:39:54 +03:00
|
|
|
tgen_branch(s, cc, l);
|
2010-06-29 06:15:37 +04:00
|
|
|
}
|
|
|
|
|
2022-10-18 10:51:41 +03:00
|
|
|
static void tcg_out_call_int(TCGContext *s, const tcg_insn_unit *dest)
|
2010-06-29 06:15:37 +04:00
|
|
|
{
|
2020-11-05 07:56:16 +03:00
|
|
|
ptrdiff_t off = tcg_pcrel_diff(s, dest) >> 1;
|
2010-06-29 06:15:37 +04:00
|
|
|
if (off == (int32_t)off) {
|
|
|
|
tcg_out_insn(s, RIL, BRASL, TCG_REG_R14, off);
|
|
|
|
} else {
|
2014-04-25 18:18:59 +04:00
|
|
|
tcg_out_movi(s, TCG_TYPE_PTR, TCG_TMP0, (uintptr_t)dest);
|
2010-06-29 06:15:37 +04:00
|
|
|
tcg_out_insn(s, RR, BASR, TCG_REG_R14, TCG_TMP0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-18 10:51:41 +03:00
|
|
|
static void tcg_out_call(TCGContext *s, const tcg_insn_unit *dest,
|
|
|
|
const TCGHelperInfo *info)
|
|
|
|
{
|
|
|
|
tcg_out_call_int(s, dest);
|
|
|
|
}
|
|
|
|
|
2023-04-23 23:28:57 +03:00
|
|
|
typedef struct {
|
|
|
|
TCGReg base;
|
|
|
|
TCGReg index;
|
|
|
|
int disp;
|
2023-04-19 17:21:55 +03:00
|
|
|
TCGAtomAlign aa;
|
2023-04-23 23:28:57 +03:00
|
|
|
} HostAddress;
|
|
|
|
|
2023-04-19 13:43:17 +03:00
|
|
|
bool tcg_target_has_memory_bswap(MemOp memop)
|
|
|
|
{
|
2023-04-19 18:58:23 +03:00
|
|
|
TCGAtomAlign aa;
|
|
|
|
|
|
|
|
if ((memop & MO_SIZE) <= MO_64) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Reject 16-byte memop with 16-byte atomicity,
|
|
|
|
* but do allow a pair of 64-bit operations.
|
|
|
|
*/
|
|
|
|
aa = atom_and_align_for_opc(tcg_ctx, memop, MO_ATOM_IFALIGN, true);
|
|
|
|
return aa.atom <= MO_64;
|
2023-04-19 13:43:17 +03:00
|
|
|
}
|
|
|
|
|
2019-08-23 21:10:58 +03:00
|
|
|
static void tcg_out_qemu_ld_direct(TCGContext *s, MemOp opc, TCGReg data,
|
2023-04-23 23:28:57 +03:00
|
|
|
HostAddress h)
|
2010-06-29 06:15:37 +04:00
|
|
|
{
|
2015-07-30 23:13:26 +03:00
|
|
|
switch (opc & (MO_SSIZE | MO_BSWAP)) {
|
2014-03-24 00:15:50 +04:00
|
|
|
case MO_UB:
|
2023-04-23 23:28:57 +03:00
|
|
|
tcg_out_insn(s, RXY, LLGC, data, h.base, h.index, h.disp);
|
2010-06-29 06:15:37 +04:00
|
|
|
break;
|
2014-03-24 00:15:50 +04:00
|
|
|
case MO_SB:
|
2023-04-23 23:28:57 +03:00
|
|
|
tcg_out_insn(s, RXY, LGB, data, h.base, h.index, h.disp);
|
2010-06-29 06:15:37 +04:00
|
|
|
break;
|
2014-03-24 00:24:53 +04:00
|
|
|
|
|
|
|
case MO_UW | MO_BSWAP:
|
|
|
|
/* swapped unsigned halfword load with upper bits zeroed */
|
2023-04-23 23:28:57 +03:00
|
|
|
tcg_out_insn(s, RXY, LRVH, data, h.base, h.index, h.disp);
|
2023-04-06 02:25:22 +03:00
|
|
|
tcg_out_ext16u(s, data, data);
|
2014-03-24 00:24:53 +04:00
|
|
|
break;
|
2014-03-24 00:15:50 +04:00
|
|
|
case MO_UW:
|
2023-04-23 23:28:57 +03:00
|
|
|
tcg_out_insn(s, RXY, LLGH, data, h.base, h.index, h.disp);
|
2014-03-24 00:24:53 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MO_SW | MO_BSWAP:
|
|
|
|
/* swapped sign-extended halfword load */
|
2023-04-23 23:28:57 +03:00
|
|
|
tcg_out_insn(s, RXY, LRVH, data, h.base, h.index, h.disp);
|
2023-04-06 00:49:59 +03:00
|
|
|
tcg_out_ext16s(s, TCG_TYPE_REG, data, data);
|
2010-06-29 06:15:37 +04:00
|
|
|
break;
|
2014-03-24 00:15:50 +04:00
|
|
|
case MO_SW:
|
2023-04-23 23:28:57 +03:00
|
|
|
tcg_out_insn(s, RXY, LGH, data, h.base, h.index, h.disp);
|
2014-03-24 00:24:53 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MO_UL | MO_BSWAP:
|
|
|
|
/* swapped unsigned int load with upper bits zeroed */
|
2023-04-23 23:28:57 +03:00
|
|
|
tcg_out_insn(s, RXY, LRV, data, h.base, h.index, h.disp);
|
2023-04-06 04:07:05 +03:00
|
|
|
tcg_out_ext32u(s, data, data);
|
2010-06-29 06:15:37 +04:00
|
|
|
break;
|
2014-03-24 00:15:50 +04:00
|
|
|
case MO_UL:
|
2023-04-23 23:28:57 +03:00
|
|
|
tcg_out_insn(s, RXY, LLGF, data, h.base, h.index, h.disp);
|
2014-03-24 00:24:53 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MO_SL | MO_BSWAP:
|
|
|
|
/* swapped sign-extended int load */
|
2023-04-23 23:28:57 +03:00
|
|
|
tcg_out_insn(s, RXY, LRV, data, h.base, h.index, h.disp);
|
2023-04-06 03:50:09 +03:00
|
|
|
tcg_out_ext32s(s, data, data);
|
2010-06-29 06:15:37 +04:00
|
|
|
break;
|
2014-03-24 00:15:50 +04:00
|
|
|
case MO_SL:
|
2023-04-23 23:28:57 +03:00
|
|
|
tcg_out_insn(s, RXY, LGF, data, h.base, h.index, h.disp);
|
2014-03-24 00:24:53 +04:00
|
|
|
break;
|
|
|
|
|
2022-01-07 00:00:51 +03:00
|
|
|
case MO_UQ | MO_BSWAP:
|
2023-04-23 23:28:57 +03:00
|
|
|
tcg_out_insn(s, RXY, LRVG, data, h.base, h.index, h.disp);
|
2010-06-29 06:15:37 +04:00
|
|
|
break;
|
2022-01-07 00:00:51 +03:00
|
|
|
case MO_UQ:
|
2023-04-23 23:28:57 +03:00
|
|
|
tcg_out_insn(s, RXY, LG, data, h.base, h.index, h.disp);
|
2010-06-29 06:15:37 +04:00
|
|
|
break;
|
2014-03-24 00:24:53 +04:00
|
|
|
|
2010-06-29 06:15:37 +04:00
|
|
|
default:
|
2023-04-05 22:09:14 +03:00
|
|
|
g_assert_not_reached();
|
2010-06-29 06:15:37 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-23 21:10:58 +03:00
|
|
|
static void tcg_out_qemu_st_direct(TCGContext *s, MemOp opc, TCGReg data,
|
2023-04-23 23:28:57 +03:00
|
|
|
HostAddress h)
|
2010-06-29 06:15:37 +04:00
|
|
|
{
|
2015-07-30 23:13:26 +03:00
|
|
|
switch (opc & (MO_SIZE | MO_BSWAP)) {
|
2014-03-24 00:15:50 +04:00
|
|
|
case MO_UB:
|
2023-04-23 23:28:57 +03:00
|
|
|
if (h.disp >= 0 && h.disp < 0x1000) {
|
|
|
|
tcg_out_insn(s, RX, STC, data, h.base, h.index, h.disp);
|
2010-06-29 06:15:37 +04:00
|
|
|
} else {
|
2023-04-23 23:28:57 +03:00
|
|
|
tcg_out_insn(s, RXY, STCY, data, h.base, h.index, h.disp);
|
2010-06-29 06:15:37 +04:00
|
|
|
}
|
|
|
|
break;
|
2014-03-24 00:24:53 +04:00
|
|
|
|
|
|
|
case MO_UW | MO_BSWAP:
|
2023-04-23 23:28:57 +03:00
|
|
|
tcg_out_insn(s, RXY, STRVH, data, h.base, h.index, h.disp);
|
2014-03-24 00:24:53 +04:00
|
|
|
break;
|
2014-03-24 00:15:50 +04:00
|
|
|
case MO_UW:
|
2023-04-23 23:28:57 +03:00
|
|
|
if (h.disp >= 0 && h.disp < 0x1000) {
|
|
|
|
tcg_out_insn(s, RX, STH, data, h.base, h.index, h.disp);
|
2010-06-29 06:15:37 +04:00
|
|
|
} else {
|
2023-04-23 23:28:57 +03:00
|
|
|
tcg_out_insn(s, RXY, STHY, data, h.base, h.index, h.disp);
|
2010-06-29 06:15:37 +04:00
|
|
|
}
|
|
|
|
break;
|
2014-03-24 00:24:53 +04:00
|
|
|
|
|
|
|
case MO_UL | MO_BSWAP:
|
2023-04-23 23:28:57 +03:00
|
|
|
tcg_out_insn(s, RXY, STRV, data, h.base, h.index, h.disp);
|
2014-03-24 00:24:53 +04:00
|
|
|
break;
|
2014-03-24 00:15:50 +04:00
|
|
|
case MO_UL:
|
2023-04-23 23:28:57 +03:00
|
|
|
if (h.disp >= 0 && h.disp < 0x1000) {
|
|
|
|
tcg_out_insn(s, RX, ST, data, h.base, h.index, h.disp);
|
2010-06-29 06:15:37 +04:00
|
|
|
} else {
|
2023-04-23 23:28:57 +03:00
|
|
|
tcg_out_insn(s, RXY, STY, data, h.base, h.index, h.disp);
|
2010-06-29 06:15:37 +04:00
|
|
|
}
|
|
|
|
break;
|
2014-03-24 00:24:53 +04:00
|
|
|
|
2022-01-07 00:00:51 +03:00
|
|
|
case MO_UQ | MO_BSWAP:
|
2023-04-23 23:28:57 +03:00
|
|
|
tcg_out_insn(s, RXY, STRVG, data, h.base, h.index, h.disp);
|
2014-03-24 00:24:53 +04:00
|
|
|
break;
|
2022-01-07 00:00:51 +03:00
|
|
|
case MO_UQ:
|
2023-04-23 23:28:57 +03:00
|
|
|
tcg_out_insn(s, RXY, STG, data, h.base, h.index, h.disp);
|
2010-06-29 06:15:37 +04:00
|
|
|
break;
|
2014-03-24 00:24:53 +04:00
|
|
|
|
2010-06-29 06:15:37 +04:00
|
|
|
default:
|
2023-04-05 22:09:14 +03:00
|
|
|
g_assert_not_reached();
|
2010-06-29 06:15:37 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-10 22:23:08 +03:00
|
|
|
static const TCGLdstHelperParam ldst_helper_param = {
|
|
|
|
.ntmp = 1, .tmp = { TCG_TMP0 }
|
|
|
|
};
|
|
|
|
|
2019-04-22 00:51:00 +03:00
|
|
|
static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *lb)
|
2014-03-24 01:26:15 +04:00
|
|
|
{
|
2023-04-10 22:23:08 +03:00
|
|
|
MemOp opc = get_memop(lb->oi);
|
2010-06-29 06:15:37 +04:00
|
|
|
|
2019-04-22 00:51:00 +03:00
|
|
|
if (!patch_reloc(lb->label_ptr[0], R_390_PC16DBL,
|
2020-11-05 07:56:16 +03:00
|
|
|
(intptr_t)tcg_splitwx_to_rx(s->code_ptr), 2)) {
|
2019-04-22 00:51:00 +03:00
|
|
|
return false;
|
|
|
|
}
|
2010-06-29 06:15:37 +04:00
|
|
|
|
2023-04-10 22:23:08 +03:00
|
|
|
tcg_out_ld_helper_args(s, lb, &ldst_helper_param);
|
2022-11-01 04:51:04 +03:00
|
|
|
tcg_out_call_int(s, qemu_ld_helpers[opc & MO_SIZE]);
|
2023-04-10 22:23:08 +03:00
|
|
|
tcg_out_ld_helper_ret(s, lb, false, &ldst_helper_param);
|
2013-03-27 21:04:26 +04:00
|
|
|
|
2014-03-24 01:26:15 +04:00
|
|
|
tgen_gotoi(s, S390_CC_ALWAYS, lb->raddr);
|
2019-04-22 00:51:00 +03:00
|
|
|
return true;
|
2010-06-29 06:15:37 +04:00
|
|
|
}
|
|
|
|
|
2019-04-22 00:51:00 +03:00
|
|
|
static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *lb)
|
2010-06-29 06:15:37 +04:00
|
|
|
{
|
2023-04-10 22:23:08 +03:00
|
|
|
MemOp opc = get_memop(lb->oi);
|
2014-03-24 01:26:15 +04:00
|
|
|
|
2019-04-22 00:51:00 +03:00
|
|
|
if (!patch_reloc(lb->label_ptr[0], R_390_PC16DBL,
|
2020-11-05 07:56:16 +03:00
|
|
|
(intptr_t)tcg_splitwx_to_rx(s->code_ptr), 2)) {
|
2019-04-22 00:51:00 +03:00
|
|
|
return false;
|
|
|
|
}
|
2014-03-24 01:26:15 +04:00
|
|
|
|
2023-04-10 22:23:08 +03:00
|
|
|
tcg_out_st_helper_args(s, lb, &ldst_helper_param);
|
2022-11-01 04:51:04 +03:00
|
|
|
tcg_out_call_int(s, qemu_st_helpers[opc & MO_SIZE]);
|
2014-03-24 01:26:15 +04:00
|
|
|
|
|
|
|
tgen_gotoi(s, S390_CC_ALWAYS, lb->raddr);
|
2019-04-22 00:51:00 +03:00
|
|
|
return true;
|
2010-06-29 06:15:37 +04:00
|
|
|
}
|
2021-08-04 03:08:57 +03:00
|
|
|
|
2023-03-28 02:07:15 +03:00
|
|
|
/* We're expecting to use a 20-bit negative offset on the tlb memory ops. */
|
|
|
|
#define MIN_TLB_MASK_TABLE_OFS -(1 << 19)
|
|
|
|
|
2023-04-23 23:46:46 +03:00
|
|
|
/*
|
2023-10-04 12:06:20 +03:00
|
|
|
* For system-mode, perform the TLB load and compare.
|
|
|
|
* For user-mode, perform any required alignment tests.
|
2023-04-23 23:46:46 +03:00
|
|
|
* In both cases, return a TCGLabelQemuLdst structure if the slow path
|
|
|
|
* is required and fill in @h with the host address for the fast path.
|
|
|
|
*/
|
|
|
|
static TCGLabelQemuLdst *prepare_host_addr(TCGContext *s, HostAddress *h,
|
|
|
|
TCGReg addr_reg, MemOpIdx oi,
|
|
|
|
bool is_ld)
|
2010-06-29 06:15:37 +04:00
|
|
|
{
|
2023-04-27 18:39:09 +03:00
|
|
|
TCGType addr_type = s->addr_type;
|
2023-04-23 23:46:46 +03:00
|
|
|
TCGLabelQemuLdst *ldst = NULL;
|
|
|
|
MemOp opc = get_memop(oi);
|
2023-04-19 18:58:23 +03:00
|
|
|
MemOp s_bits = opc & MO_SIZE;
|
2023-04-19 17:21:55 +03:00
|
|
|
unsigned a_mask;
|
|
|
|
|
2023-04-19 18:58:23 +03:00
|
|
|
h->aa = atom_and_align_for_opc(s, opc, MO_ATOM_IFALIGN, s_bits == MO_128);
|
2023-04-19 17:21:55 +03:00
|
|
|
a_mask = (1 << h->aa.align) - 1;
|
2023-04-23 23:46:46 +03:00
|
|
|
|
2023-10-02 00:16:32 +03:00
|
|
|
if (tcg_use_softmmu) {
|
|
|
|
unsigned s_mask = (1 << s_bits) - 1;
|
|
|
|
int mem_index = get_mmuidx(oi);
|
|
|
|
int fast_off = tlb_mask_table_ofs(s, mem_index);
|
|
|
|
int mask_off = fast_off + offsetof(CPUTLBDescFast, mask);
|
|
|
|
int table_off = fast_off + offsetof(CPUTLBDescFast, table);
|
|
|
|
int ofs, a_off;
|
|
|
|
uint64_t tlb_mask;
|
2023-04-23 23:46:46 +03:00
|
|
|
|
2023-10-02 00:16:32 +03:00
|
|
|
ldst = new_ldst_label(s);
|
|
|
|
ldst->is_ld = is_ld;
|
|
|
|
ldst->oi = oi;
|
|
|
|
ldst->addrlo_reg = addr_reg;
|
2023-04-23 23:46:46 +03:00
|
|
|
|
2023-10-02 00:16:32 +03:00
|
|
|
tcg_out_sh64(s, RSY_SRLG, TCG_TMP0, addr_reg, TCG_REG_NONE,
|
|
|
|
s->page_bits - CPU_TLB_ENTRY_BITS);
|
2023-04-23 23:46:46 +03:00
|
|
|
|
2023-10-02 00:16:32 +03:00
|
|
|
tcg_out_insn(s, RXY, NG, TCG_TMP0, TCG_AREG0, TCG_REG_NONE, mask_off);
|
|
|
|
tcg_out_insn(s, RXY, AG, TCG_TMP0, TCG_AREG0, TCG_REG_NONE, table_off);
|
2023-04-23 23:46:46 +03:00
|
|
|
|
2023-10-02 00:16:32 +03:00
|
|
|
/*
|
|
|
|
* For aligned accesses, we check the first byte and include the
|
|
|
|
* alignment bits within the address. For unaligned access, we
|
|
|
|
* check that we don't cross pages using the address of the last
|
|
|
|
* byte of the access.
|
|
|
|
*/
|
|
|
|
a_off = (a_mask >= s_mask ? 0 : s_mask - a_mask);
|
|
|
|
tlb_mask = (uint64_t)s->page_mask | a_mask;
|
|
|
|
if (a_off == 0) {
|
|
|
|
tgen_andi_risbg(s, TCG_REG_R0, addr_reg, tlb_mask);
|
|
|
|
} else {
|
|
|
|
tcg_out_insn(s, RX, LA, TCG_REG_R0, addr_reg, TCG_REG_NONE, a_off);
|
|
|
|
tgen_andi(s, addr_type, TCG_REG_R0, tlb_mask);
|
|
|
|
}
|
2023-04-23 23:28:57 +03:00
|
|
|
|
2023-10-02 00:16:32 +03:00
|
|
|
if (is_ld) {
|
|
|
|
ofs = offsetof(CPUTLBEntry, addr_read);
|
|
|
|
} else {
|
|
|
|
ofs = offsetof(CPUTLBEntry, addr_write);
|
|
|
|
}
|
|
|
|
if (addr_type == TCG_TYPE_I32) {
|
|
|
|
ofs += HOST_BIG_ENDIAN * 4;
|
|
|
|
tcg_out_insn(s, RX, C, TCG_REG_R0, TCG_TMP0, TCG_REG_NONE, ofs);
|
|
|
|
} else {
|
|
|
|
tcg_out_insn(s, RXY, CG, TCG_REG_R0, TCG_TMP0, TCG_REG_NONE, ofs);
|
|
|
|
}
|
2023-04-23 23:46:46 +03:00
|
|
|
|
2023-10-02 00:16:32 +03:00
|
|
|
tcg_out16(s, RI_BRC | (S390_CC_NE << 4));
|
|
|
|
ldst->label_ptr[0] = s->code_ptr++;
|
2023-04-23 23:46:46 +03:00
|
|
|
|
2023-10-02 00:16:32 +03:00
|
|
|
h->index = TCG_TMP0;
|
|
|
|
tcg_out_insn(s, RXY, LG, h->index, TCG_TMP0, TCG_REG_NONE,
|
|
|
|
offsetof(CPUTLBEntry, addend));
|
2023-04-23 23:46:46 +03:00
|
|
|
|
2023-10-02 00:16:32 +03:00
|
|
|
if (addr_type == TCG_TYPE_I32) {
|
|
|
|
tcg_out_insn(s, RRE, ALGFR, h->index, addr_reg);
|
|
|
|
h->base = TCG_REG_NONE;
|
|
|
|
} else {
|
|
|
|
h->base = addr_reg;
|
|
|
|
}
|
|
|
|
h->disp = 0;
|
2023-04-03 09:14:53 +03:00
|
|
|
} else {
|
2023-10-02 00:16:32 +03:00
|
|
|
if (a_mask) {
|
|
|
|
ldst = new_ldst_label(s);
|
|
|
|
ldst->is_ld = is_ld;
|
|
|
|
ldst->oi = oi;
|
|
|
|
ldst->addrlo_reg = addr_reg;
|
2023-04-23 23:46:46 +03:00
|
|
|
|
2023-10-02 00:16:32 +03:00
|
|
|
/* We are expecting a_bits to max out at 7, much lower than TMLL. */
|
|
|
|
tcg_debug_assert(a_mask <= 0xffff);
|
|
|
|
tcg_out_insn(s, RI, TMLL, addr_reg, a_mask);
|
2023-04-23 23:46:46 +03:00
|
|
|
|
2023-10-02 00:16:32 +03:00
|
|
|
tcg_out16(s, RI_BRC | (7 << 4)); /* CC in {1,2,3} */
|
|
|
|
ldst->label_ptr[0] = s->code_ptr++;
|
|
|
|
}
|
2023-04-23 23:46:46 +03:00
|
|
|
|
2023-10-02 00:16:32 +03:00
|
|
|
h->base = addr_reg;
|
|
|
|
if (addr_type == TCG_TYPE_I32) {
|
|
|
|
tcg_out_ext32u(s, TCG_TMP0, addr_reg);
|
|
|
|
h->base = TCG_TMP0;
|
|
|
|
}
|
|
|
|
if (guest_base < 0x80000) {
|
|
|
|
h->index = TCG_REG_NONE;
|
|
|
|
h->disp = guest_base;
|
|
|
|
} else {
|
|
|
|
h->index = TCG_GUEST_BASE_REG;
|
|
|
|
h->disp = 0;
|
|
|
|
}
|
2010-06-29 06:15:37 +04:00
|
|
|
}
|
2023-04-23 23:46:46 +03:00
|
|
|
|
|
|
|
return ldst;
|
2010-06-29 06:15:37 +04:00
|
|
|
}
|
|
|
|
|
2014-03-24 00:36:00 +04:00
|
|
|
static void tcg_out_qemu_ld(TCGContext* s, TCGReg data_reg, TCGReg addr_reg,
|
2023-04-06 22:57:43 +03:00
|
|
|
MemOpIdx oi, TCGType data_type)
|
2010-06-29 06:15:37 +04:00
|
|
|
{
|
2023-04-23 23:46:46 +03:00
|
|
|
TCGLabelQemuLdst *ldst;
|
2023-04-23 23:28:57 +03:00
|
|
|
HostAddress h;
|
|
|
|
|
2023-04-23 23:46:46 +03:00
|
|
|
ldst = prepare_host_addr(s, &h, addr_reg, oi, true);
|
|
|
|
tcg_out_qemu_ld_direct(s, get_memop(oi), data_reg, h);
|
2014-03-24 01:26:15 +04:00
|
|
|
|
2023-04-23 23:46:46 +03:00
|
|
|
if (ldst) {
|
|
|
|
ldst->type = data_type;
|
|
|
|
ldst->datalo_reg = data_reg;
|
|
|
|
ldst->raddr = tcg_splitwx_to_rx(s->code_ptr);
|
2021-08-04 03:08:57 +03:00
|
|
|
}
|
2010-06-29 06:15:37 +04:00
|
|
|
}
|
|
|
|
|
2014-03-24 00:36:00 +04:00
|
|
|
static void tcg_out_qemu_st(TCGContext* s, TCGReg data_reg, TCGReg addr_reg,
|
2023-04-06 22:57:43 +03:00
|
|
|
MemOpIdx oi, TCGType data_type)
|
2010-06-29 06:15:37 +04:00
|
|
|
{
|
2023-04-23 23:46:46 +03:00
|
|
|
TCGLabelQemuLdst *ldst;
|
2023-04-23 23:28:57 +03:00
|
|
|
HostAddress h;
|
|
|
|
|
2023-04-23 23:46:46 +03:00
|
|
|
ldst = prepare_host_addr(s, &h, addr_reg, oi, false);
|
|
|
|
tcg_out_qemu_st_direct(s, get_memop(oi), data_reg, h);
|
2010-06-29 06:15:37 +04:00
|
|
|
|
2023-04-23 23:46:46 +03:00
|
|
|
if (ldst) {
|
|
|
|
ldst->type = data_type;
|
|
|
|
ldst->datalo_reg = data_reg;
|
|
|
|
ldst->raddr = tcg_splitwx_to_rx(s->code_ptr);
|
2021-08-04 03:08:57 +03:00
|
|
|
}
|
2009-12-05 14:44:23 +03:00
|
|
|
}
|
|
|
|
|
2023-04-19 18:58:23 +03:00
|
|
|
static void tcg_out_qemu_ldst_i128(TCGContext *s, TCGReg datalo, TCGReg datahi,
|
|
|
|
TCGReg addr_reg, MemOpIdx oi, bool is_ld)
|
|
|
|
{
|
|
|
|
TCGLabel *l1 = NULL, *l2 = NULL;
|
|
|
|
TCGLabelQemuLdst *ldst;
|
|
|
|
HostAddress h;
|
|
|
|
bool need_bswap;
|
|
|
|
bool use_pair;
|
|
|
|
S390Opcode insn;
|
|
|
|
|
|
|
|
ldst = prepare_host_addr(s, &h, addr_reg, oi, is_ld);
|
|
|
|
|
|
|
|
use_pair = h.aa.atom < MO_128;
|
|
|
|
need_bswap = get_memop(oi) & MO_BSWAP;
|
|
|
|
|
|
|
|
if (!use_pair) {
|
|
|
|
/*
|
|
|
|
* Atomicity requires we use LPQ. If we've already checked for
|
|
|
|
* 16-byte alignment, that's all we need. If we arrive with
|
|
|
|
* lesser alignment, we have determined that less than 16-byte
|
|
|
|
* alignment can be satisfied with two 8-byte loads.
|
|
|
|
*/
|
|
|
|
if (h.aa.align < MO_128) {
|
|
|
|
use_pair = true;
|
|
|
|
l1 = gen_new_label();
|
|
|
|
l2 = gen_new_label();
|
|
|
|
|
|
|
|
tcg_out_insn(s, RI, TMLL, addr_reg, 15);
|
|
|
|
tgen_branch(s, 7, l1); /* CC in {1,2,3} */
|
|
|
|
}
|
|
|
|
|
|
|
|
tcg_debug_assert(!need_bswap);
|
|
|
|
tcg_debug_assert(datalo & 1);
|
|
|
|
tcg_debug_assert(datahi == datalo - 1);
|
|
|
|
insn = is_ld ? RXY_LPQ : RXY_STPQ;
|
|
|
|
tcg_out_insn_RXY(s, insn, datahi, h.base, h.index, h.disp);
|
|
|
|
|
|
|
|
if (use_pair) {
|
|
|
|
tgen_branch(s, S390_CC_ALWAYS, l2);
|
|
|
|
tcg_out_label(s, l1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (use_pair) {
|
|
|
|
TCGReg d1, d2;
|
|
|
|
|
|
|
|
if (need_bswap) {
|
|
|
|
d1 = datalo, d2 = datahi;
|
|
|
|
insn = is_ld ? RXY_LRVG : RXY_STRVG;
|
|
|
|
} else {
|
|
|
|
d1 = datahi, d2 = datalo;
|
|
|
|
insn = is_ld ? RXY_LG : RXY_STG;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (h.base == d1 || h.index == d1) {
|
|
|
|
tcg_out_insn(s, RXY, LAY, TCG_TMP0, h.base, h.index, h.disp);
|
|
|
|
h.base = TCG_TMP0;
|
|
|
|
h.index = TCG_REG_NONE;
|
|
|
|
h.disp = 0;
|
|
|
|
}
|
|
|
|
tcg_out_insn_RXY(s, insn, d1, h.base, h.index, h.disp);
|
|
|
|
tcg_out_insn_RXY(s, insn, d2, h.base, h.index, h.disp + 8);
|
|
|
|
}
|
|
|
|
if (l2) {
|
|
|
|
tcg_out_label(s, l2);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ldst) {
|
|
|
|
ldst->type = TCG_TYPE_I128;
|
|
|
|
ldst->datalo_reg = datalo;
|
|
|
|
ldst->datahi_reg = datahi;
|
|
|
|
ldst->raddr = tcg_splitwx_to_rx(s->code_ptr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-26 23:42:06 +03:00
|
|
|
static void tcg_out_exit_tb(TCGContext *s, uintptr_t a0)
|
|
|
|
{
|
|
|
|
/* Reuse the zeroing that exists for goto_ptr. */
|
|
|
|
if (a0 == 0) {
|
|
|
|
tgen_gotoi(s, S390_CC_ALWAYS, tcg_code_gen_epilogue);
|
|
|
|
} else {
|
|
|
|
tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_R2, a0);
|
|
|
|
tgen_gotoi(s, S390_CC_ALWAYS, tb_ret_addr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-27 04:14:05 +03:00
|
|
|
static void tcg_out_goto_tb(TCGContext *s, int which)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Branch displacement must be aligned for atomic patching;
|
|
|
|
* see if we need to add extra nop before branch
|
|
|
|
*/
|
|
|
|
if (!QEMU_PTR_IS_ALIGNED(s->code_ptr + 1, 4)) {
|
|
|
|
tcg_out16(s, NOP);
|
|
|
|
}
|
|
|
|
tcg_out16(s, RIL_BRCL | (S390_CC_ALWAYS << 4));
|
|
|
|
set_jmp_insn_offset(s, which);
|
|
|
|
s->code_ptr += 2;
|
|
|
|
set_jmp_reset_offset(s, which);
|
|
|
|
}
|
|
|
|
|
2022-12-05 20:31:20 +03:00
|
|
|
void tb_target_set_jmp_target(const TranslationBlock *tb, int n,
|
|
|
|
uintptr_t jmp_rx, uintptr_t jmp_rw)
|
|
|
|
{
|
2022-12-06 01:55:40 +03:00
|
|
|
if (!HAVE_FACILITY(GEN_INST_EXT)) {
|
|
|
|
return;
|
|
|
|
}
|
2022-12-05 20:31:20 +03:00
|
|
|
/* patch the branch destination */
|
|
|
|
uintptr_t addr = tb->jmp_target_addr[n];
|
|
|
|
intptr_t disp = addr - (jmp_rx - 2);
|
|
|
|
qatomic_set((int32_t *)jmp_rw, disp / 2);
|
|
|
|
/* no need to flush icache explicitly */
|
|
|
|
}
|
|
|
|
|
2010-06-29 06:15:37 +04:00
|
|
|
# define OP_32_64(x) \
|
|
|
|
case glue(glue(INDEX_op_,x),_i32): \
|
|
|
|
case glue(glue(INDEX_op_,x),_i64)
|
|
|
|
|
2010-03-19 21:12:29 +03:00
|
|
|
static inline void tcg_out_op(TCGContext *s, TCGOpcode opc,
|
2021-03-12 15:14:18 +03:00
|
|
|
const TCGArg args[TCG_MAX_OP_ARGS],
|
|
|
|
const int const_args[TCG_MAX_OP_ARGS])
|
2009-12-05 14:44:23 +03:00
|
|
|
{
|
2017-06-16 23:43:17 +03:00
|
|
|
S390Opcode op, op2;
|
2013-03-27 22:23:26 +04:00
|
|
|
TCGArg a0, a1, a2;
|
2010-06-29 06:15:37 +04:00
|
|
|
|
|
|
|
switch (opc) {
|
2017-04-27 01:40:59 +03:00
|
|
|
case INDEX_op_goto_ptr:
|
2017-07-25 21:53:50 +03:00
|
|
|
a0 = args[0];
|
|
|
|
tcg_out_insn(s, RR, BCR, S390_CC_ALWAYS, a0);
|
2017-04-27 01:40:59 +03:00
|
|
|
break;
|
|
|
|
|
2010-06-29 06:15:37 +04:00
|
|
|
OP_32_64(ld8u):
|
|
|
|
/* ??? LLC (RXY format) is only present with the extended-immediate
|
|
|
|
facility, whereas LLGC is always present. */
|
|
|
|
tcg_out_mem(s, 0, RXY_LLGC, args[0], args[1], TCG_REG_NONE, args[2]);
|
|
|
|
break;
|
|
|
|
|
|
|
|
OP_32_64(ld8s):
|
|
|
|
/* ??? LB is no smaller than LGB, so no point to using it. */
|
|
|
|
tcg_out_mem(s, 0, RXY_LGB, args[0], args[1], TCG_REG_NONE, args[2]);
|
|
|
|
break;
|
|
|
|
|
|
|
|
OP_32_64(ld16u):
|
|
|
|
/* ??? LLH (RXY format) is only present with the extended-immediate
|
|
|
|
facility, whereas LLGH is always present. */
|
|
|
|
tcg_out_mem(s, 0, RXY_LLGH, args[0], args[1], TCG_REG_NONE, args[2]);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case INDEX_op_ld16s_i32:
|
|
|
|
tcg_out_mem(s, RX_LH, RXY_LHY, args[0], args[1], TCG_REG_NONE, args[2]);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case INDEX_op_ld_i32:
|
|
|
|
tcg_out_ld(s, TCG_TYPE_I32, args[0], args[1], args[2]);
|
|
|
|
break;
|
|
|
|
|
|
|
|
OP_32_64(st8):
|
|
|
|
tcg_out_mem(s, RX_STC, RXY_STCY, args[0], args[1],
|
|
|
|
TCG_REG_NONE, args[2]);
|
|
|
|
break;
|
|
|
|
|
|
|
|
OP_32_64(st16):
|
|
|
|
tcg_out_mem(s, RX_STH, RXY_STHY, args[0], args[1],
|
|
|
|
TCG_REG_NONE, args[2]);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case INDEX_op_st_i32:
|
|
|
|
tcg_out_st(s, TCG_TYPE_I32, args[0], args[1], args[2]);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case INDEX_op_add_i32:
|
2013-03-27 22:23:26 +04:00
|
|
|
a0 = args[0], a1 = args[1], a2 = (int32_t)args[2];
|
2010-06-29 06:15:37 +04:00
|
|
|
if (const_args[2]) {
|
2013-03-27 22:23:26 +04:00
|
|
|
do_addi_32:
|
|
|
|
if (a0 == a1) {
|
|
|
|
if (a2 == (int16_t)a2) {
|
|
|
|
tcg_out_insn(s, RI, AHI, a0, a2);
|
|
|
|
break;
|
|
|
|
}
|
2022-12-07 19:28:07 +03:00
|
|
|
tcg_out_insn(s, RIL, AFI, a0, a2);
|
|
|
|
break;
|
2013-03-27 22:23:26 +04:00
|
|
|
}
|
|
|
|
tcg_out_mem(s, RX_LA, RXY_LAY, a0, a1, TCG_REG_NONE, a2);
|
|
|
|
} else if (a0 == a1) {
|
|
|
|
tcg_out_insn(s, RR, AR, a0, a2);
|
2010-06-29 06:15:37 +04:00
|
|
|
} else {
|
2013-03-27 22:23:26 +04:00
|
|
|
tcg_out_insn(s, RX, LA, a0, a1, a2, 0);
|
2010-06-29 06:15:37 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case INDEX_op_sub_i32:
|
2013-03-27 22:23:26 +04:00
|
|
|
a0 = args[0], a1 = args[1], a2 = (int32_t)args[2];
|
2010-06-29 06:15:37 +04:00
|
|
|
if (const_args[2]) {
|
2013-03-27 22:23:26 +04:00
|
|
|
a2 = -a2;
|
|
|
|
goto do_addi_32;
|
2017-06-16 23:43:17 +03:00
|
|
|
} else if (a0 == a1) {
|
|
|
|
tcg_out_insn(s, RR, SR, a0, a2);
|
|
|
|
} else {
|
2022-02-24 03:48:52 +03:00
|
|
|
tcg_out_insn(s, RRFa, SRK, a0, a1, a2);
|
2010-06-29 06:15:37 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case INDEX_op_and_i32:
|
2017-06-16 23:43:17 +03:00
|
|
|
a0 = args[0], a1 = args[1], a2 = (uint32_t)args[2];
|
2010-06-29 06:15:37 +04:00
|
|
|
if (const_args[2]) {
|
2017-06-16 23:43:17 +03:00
|
|
|
tcg_out_mov(s, TCG_TYPE_I32, a0, a1);
|
|
|
|
tgen_andi(s, TCG_TYPE_I32, a0, a2);
|
|
|
|
} else if (a0 == a1) {
|
|
|
|
tcg_out_insn(s, RR, NR, a0, a2);
|
2010-06-29 06:15:37 +04:00
|
|
|
} else {
|
2022-02-24 03:48:52 +03:00
|
|
|
tcg_out_insn(s, RRFa, NRK, a0, a1, a2);
|
2010-06-29 06:15:37 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case INDEX_op_or_i32:
|
2017-06-16 23:43:17 +03:00
|
|
|
a0 = args[0], a1 = args[1], a2 = (uint32_t)args[2];
|
2010-06-29 06:15:37 +04:00
|
|
|
if (const_args[2]) {
|
2017-06-16 23:43:17 +03:00
|
|
|
tcg_out_mov(s, TCG_TYPE_I32, a0, a1);
|
2022-12-08 20:28:19 +03:00
|
|
|
tgen_ori(s, a0, a2);
|
2017-06-16 23:43:17 +03:00
|
|
|
} else if (a0 == a1) {
|
|
|
|
tcg_out_insn(s, RR, OR, a0, a2);
|
2010-06-29 06:15:37 +04:00
|
|
|
} else {
|
2022-02-24 03:48:52 +03:00
|
|
|
tcg_out_insn(s, RRFa, ORK, a0, a1, a2);
|
2010-06-29 06:15:37 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case INDEX_op_xor_i32:
|
2017-06-16 23:43:17 +03:00
|
|
|
a0 = args[0], a1 = args[1], a2 = (uint32_t)args[2];
|
2010-06-29 06:15:37 +04:00
|
|
|
if (const_args[2]) {
|
2017-06-16 23:43:17 +03:00
|
|
|
tcg_out_mov(s, TCG_TYPE_I32, a0, a1);
|
2022-12-08 20:03:15 +03:00
|
|
|
tcg_out_insn(s, RIL, XILF, a0, a2);
|
2017-06-16 23:43:17 +03:00
|
|
|
} else if (a0 == a1) {
|
2010-06-29 06:15:37 +04:00
|
|
|
tcg_out_insn(s, RR, XR, args[0], args[2]);
|
2017-06-16 23:43:17 +03:00
|
|
|
} else {
|
2022-02-24 03:48:52 +03:00
|
|
|
tcg_out_insn(s, RRFa, XRK, a0, a1, a2);
|
2010-06-29 06:15:37 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2022-02-24 03:04:25 +03:00
|
|
|
case INDEX_op_andc_i32:
|
|
|
|
a0 = args[0], a1 = args[1], a2 = (uint32_t)args[2];
|
|
|
|
if (const_args[2]) {
|
|
|
|
tcg_out_mov(s, TCG_TYPE_I32, a0, a1);
|
|
|
|
tgen_andi(s, TCG_TYPE_I32, a0, (uint32_t)~a2);
|
|
|
|
} else {
|
|
|
|
tcg_out_insn(s, RRFa, NCRK, a0, a1, a2);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case INDEX_op_orc_i32:
|
|
|
|
a0 = args[0], a1 = args[1], a2 = (uint32_t)args[2];
|
|
|
|
if (const_args[2]) {
|
|
|
|
tcg_out_mov(s, TCG_TYPE_I32, a0, a1);
|
|
|
|
tgen_ori(s, a0, (uint32_t)~a2);
|
|
|
|
} else {
|
|
|
|
tcg_out_insn(s, RRFa, OCRK, a0, a1, a2);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case INDEX_op_eqv_i32:
|
|
|
|
a0 = args[0], a1 = args[1], a2 = (uint32_t)args[2];
|
|
|
|
if (const_args[2]) {
|
|
|
|
tcg_out_mov(s, TCG_TYPE_I32, a0, a1);
|
|
|
|
tcg_out_insn(s, RIL, XILF, a0, ~a2);
|
|
|
|
} else {
|
|
|
|
tcg_out_insn(s, RRFa, NXRK, a0, a1, a2);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case INDEX_op_nand_i32:
|
|
|
|
tcg_out_insn(s, RRFa, NNRK, args[0], args[1], args[2]);
|
|
|
|
break;
|
|
|
|
case INDEX_op_nor_i32:
|
|
|
|
tcg_out_insn(s, RRFa, NORK, args[0], args[1], args[2]);
|
|
|
|
break;
|
|
|
|
|
2010-06-29 06:15:37 +04:00
|
|
|
case INDEX_op_neg_i32:
|
|
|
|
tcg_out_insn(s, RR, LCR, args[0], args[1]);
|
|
|
|
break;
|
2022-02-24 03:04:25 +03:00
|
|
|
case INDEX_op_not_i32:
|
|
|
|
tcg_out_insn(s, RRFa, NORK, args[0], args[1], args[1]);
|
|
|
|
break;
|
2010-06-29 06:15:37 +04:00
|
|
|
|
|
|
|
case INDEX_op_mul_i32:
|
2022-02-24 04:28:44 +03:00
|
|
|
a0 = args[0], a1 = args[1], a2 = (int32_t)args[2];
|
2010-06-29 06:15:37 +04:00
|
|
|
if (const_args[2]) {
|
2022-02-24 04:28:44 +03:00
|
|
|
tcg_out_mov(s, TCG_TYPE_I32, a0, a1);
|
|
|
|
if (a2 == (int16_t)a2) {
|
|
|
|
tcg_out_insn(s, RI, MHI, a0, a2);
|
2010-06-29 06:15:37 +04:00
|
|
|
} else {
|
2022-02-24 04:28:44 +03:00
|
|
|
tcg_out_insn(s, RIL, MSFI, a0, a2);
|
2010-06-29 06:15:37 +04:00
|
|
|
}
|
2022-02-24 04:28:44 +03:00
|
|
|
} else if (a0 == a1) {
|
|
|
|
tcg_out_insn(s, RRE, MSR, a0, a2);
|
2010-06-29 06:15:37 +04:00
|
|
|
} else {
|
2022-02-24 04:28:44 +03:00
|
|
|
tcg_out_insn(s, RRFa, MSRKC, a0, a1, a2);
|
2010-06-29 06:15:37 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case INDEX_op_div2_i32:
|
2022-10-10 18:41:15 +03:00
|
|
|
tcg_debug_assert(args[0] == args[2]);
|
|
|
|
tcg_debug_assert(args[1] == args[3]);
|
|
|
|
tcg_debug_assert((args[1] & 1) == 0);
|
|
|
|
tcg_debug_assert(args[0] == args[1] + 1);
|
|
|
|
tcg_out_insn(s, RR, DR, args[1], args[4]);
|
2010-06-29 06:15:37 +04:00
|
|
|
break;
|
|
|
|
case INDEX_op_divu2_i32:
|
2022-10-10 18:41:15 +03:00
|
|
|
tcg_debug_assert(args[0] == args[2]);
|
|
|
|
tcg_debug_assert(args[1] == args[3]);
|
|
|
|
tcg_debug_assert((args[1] & 1) == 0);
|
|
|
|
tcg_debug_assert(args[0] == args[1] + 1);
|
|
|
|
tcg_out_insn(s, RRE, DLR, args[1], args[4]);
|
2010-06-29 06:15:37 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case INDEX_op_shl_i32:
|
|
|
|
op = RS_SLL;
|
2017-06-16 23:43:17 +03:00
|
|
|
op2 = RSY_SLLK;
|
2010-06-29 06:15:37 +04:00
|
|
|
do_shift32:
|
2017-06-16 23:43:17 +03:00
|
|
|
a0 = args[0], a1 = args[1], a2 = (int32_t)args[2];
|
|
|
|
if (a0 == a1) {
|
|
|
|
if (const_args[2]) {
|
|
|
|
tcg_out_sh32(s, op, a0, TCG_REG_NONE, a2);
|
|
|
|
} else {
|
|
|
|
tcg_out_sh32(s, op, a0, a2, 0);
|
|
|
|
}
|
2010-06-29 06:15:37 +04:00
|
|
|
} else {
|
2017-06-16 23:43:17 +03:00
|
|
|
/* Using tcg_out_sh64 here for the format; it is a 32-bit shift. */
|
|
|
|
if (const_args[2]) {
|
|
|
|
tcg_out_sh64(s, op2, a0, a1, TCG_REG_NONE, a2);
|
|
|
|
} else {
|
|
|
|
tcg_out_sh64(s, op2, a0, a1, a2, 0);
|
|
|
|
}
|
2010-06-29 06:15:37 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case INDEX_op_shr_i32:
|
|
|
|
op = RS_SRL;
|
2017-06-16 23:43:17 +03:00
|
|
|
op2 = RSY_SRLK;
|
2010-06-29 06:15:37 +04:00
|
|
|
goto do_shift32;
|
|
|
|
case INDEX_op_sar_i32:
|
|
|
|
op = RS_SRA;
|
2017-06-16 23:43:17 +03:00
|
|
|
op2 = RSY_SRAK;
|
2010-06-29 06:15:37 +04:00
|
|
|
goto do_shift32;
|
|
|
|
|
|
|
|
case INDEX_op_rotl_i32:
|
|
|
|
/* ??? Using tcg_out_sh64 here for the format; it is a 32-bit rol. */
|
|
|
|
if (const_args[2]) {
|
|
|
|
tcg_out_sh64(s, RSY_RLL, args[0], args[1], TCG_REG_NONE, args[2]);
|
|
|
|
} else {
|
|
|
|
tcg_out_sh64(s, RSY_RLL, args[0], args[1], args[2], 0);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case INDEX_op_rotr_i32:
|
|
|
|
if (const_args[2]) {
|
|
|
|
tcg_out_sh64(s, RSY_RLL, args[0], args[1],
|
|
|
|
TCG_REG_NONE, (32 - args[2]) & 31);
|
|
|
|
} else {
|
|
|
|
tcg_out_insn(s, RR, LCR, TCG_TMP0, args[2]);
|
|
|
|
tcg_out_sh64(s, RSY_RLL, args[0], args[1], TCG_TMP0, 0);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2021-06-13 21:15:41 +03:00
|
|
|
case INDEX_op_bswap16_i32:
|
|
|
|
a0 = args[0], a1 = args[1], a2 = args[2];
|
|
|
|
tcg_out_insn(s, RRE, LRVR, a0, a1);
|
|
|
|
if (a2 & TCG_BSWAP_OS) {
|
|
|
|
tcg_out_sh32(s, RS_SRA, a0, TCG_REG_NONE, 16);
|
|
|
|
} else {
|
|
|
|
tcg_out_sh32(s, RS_SRL, a0, TCG_REG_NONE, 16);
|
|
|
|
}
|
2010-06-29 06:15:37 +04:00
|
|
|
break;
|
2021-06-13 21:15:41 +03:00
|
|
|
case INDEX_op_bswap16_i64:
|
|
|
|
a0 = args[0], a1 = args[1], a2 = args[2];
|
|
|
|
tcg_out_insn(s, RRE, LRVGR, a0, a1);
|
|
|
|
if (a2 & TCG_BSWAP_OS) {
|
|
|
|
tcg_out_sh64(s, RSY_SRAG, a0, a0, TCG_REG_NONE, 48);
|
|
|
|
} else {
|
|
|
|
tcg_out_sh64(s, RSY_SRLG, a0, a0, TCG_REG_NONE, 48);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case INDEX_op_bswap32_i32:
|
2010-06-29 06:15:37 +04:00
|
|
|
tcg_out_insn(s, RRE, LRVR, args[0], args[1]);
|
|
|
|
break;
|
2021-06-13 21:15:41 +03:00
|
|
|
case INDEX_op_bswap32_i64:
|
|
|
|
a0 = args[0], a1 = args[1], a2 = args[2];
|
|
|
|
tcg_out_insn(s, RRE, LRVR, a0, a1);
|
|
|
|
if (a2 & TCG_BSWAP_OS) {
|
2023-04-06 03:50:09 +03:00
|
|
|
tcg_out_ext32s(s, a0, a0);
|
2021-06-13 21:15:41 +03:00
|
|
|
} else if ((a2 & (TCG_BSWAP_IZ | TCG_BSWAP_OZ)) == TCG_BSWAP_OZ) {
|
2023-04-06 04:07:05 +03:00
|
|
|
tcg_out_ext32u(s, a0, a0);
|
2021-06-13 21:15:41 +03:00
|
|
|
}
|
|
|
|
break;
|
2010-06-29 06:15:37 +04:00
|
|
|
|
2013-03-27 00:41:45 +04:00
|
|
|
case INDEX_op_add2_i32:
|
2014-03-31 11:16:37 +04:00
|
|
|
if (const_args[4]) {
|
|
|
|
tcg_out_insn(s, RIL, ALFI, args[0], args[4]);
|
|
|
|
} else {
|
|
|
|
tcg_out_insn(s, RR, ALR, args[0], args[4]);
|
|
|
|
}
|
2013-03-27 00:41:45 +04:00
|
|
|
tcg_out_insn(s, RRE, ALCR, args[1], args[5]);
|
|
|
|
break;
|
|
|
|
case INDEX_op_sub2_i32:
|
2014-03-31 11:16:37 +04:00
|
|
|
if (const_args[4]) {
|
|
|
|
tcg_out_insn(s, RIL, SLFI, args[0], args[4]);
|
|
|
|
} else {
|
|
|
|
tcg_out_insn(s, RR, SLR, args[0], args[4]);
|
|
|
|
}
|
2013-03-27 00:41:45 +04:00
|
|
|
tcg_out_insn(s, RRE, SLBR, args[1], args[5]);
|
|
|
|
break;
|
|
|
|
|
2010-06-29 06:15:37 +04:00
|
|
|
case INDEX_op_br:
|
2015-02-14 00:39:54 +03:00
|
|
|
tgen_branch(s, S390_CC_ALWAYS, arg_label(args[0]));
|
2010-06-29 06:15:37 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case INDEX_op_brcond_i32:
|
|
|
|
tgen_brcond(s, TCG_TYPE_I32, args[2], args[0],
|
2015-02-14 00:39:54 +03:00
|
|
|
args[1], const_args[1], arg_label(args[3]));
|
2010-06-29 06:15:37 +04:00
|
|
|
break;
|
|
|
|
case INDEX_op_setcond_i32:
|
|
|
|
tgen_setcond(s, TCG_TYPE_I32, args[3], args[0], args[1],
|
2023-08-05 21:55:54 +03:00
|
|
|
args[2], const_args[2], false);
|
|
|
|
break;
|
|
|
|
case INDEX_op_negsetcond_i32:
|
|
|
|
tgen_setcond(s, TCG_TYPE_I32, args[3], args[0], args[1],
|
|
|
|
args[2], const_args[2], true);
|
2010-06-29 06:15:37 +04:00
|
|
|
break;
|
2013-03-27 01:28:52 +04:00
|
|
|
case INDEX_op_movcond_i32:
|
|
|
|
tgen_movcond(s, TCG_TYPE_I32, args[5], args[0], args[1],
|
2022-02-24 03:24:05 +03:00
|
|
|
args[2], const_args[2], args[3], const_args[3], args[4]);
|
2013-03-27 01:28:52 +04:00
|
|
|
break;
|
2010-06-29 06:15:37 +04:00
|
|
|
|
2023-05-17 06:07:20 +03:00
|
|
|
case INDEX_op_qemu_ld_a32_i32:
|
|
|
|
case INDEX_op_qemu_ld_a64_i32:
|
2023-04-06 22:57:43 +03:00
|
|
|
tcg_out_qemu_ld(s, args[0], args[1], args[2], TCG_TYPE_I32);
|
|
|
|
break;
|
2023-05-17 06:07:20 +03:00
|
|
|
case INDEX_op_qemu_ld_a32_i64:
|
|
|
|
case INDEX_op_qemu_ld_a64_i64:
|
2023-04-06 22:57:43 +03:00
|
|
|
tcg_out_qemu_ld(s, args[0], args[1], args[2], TCG_TYPE_I64);
|
2010-06-29 06:15:37 +04:00
|
|
|
break;
|
2023-05-17 06:07:20 +03:00
|
|
|
case INDEX_op_qemu_st_a32_i32:
|
|
|
|
case INDEX_op_qemu_st_a64_i32:
|
2023-04-06 22:57:43 +03:00
|
|
|
tcg_out_qemu_st(s, args[0], args[1], args[2], TCG_TYPE_I32);
|
|
|
|
break;
|
2023-05-17 06:07:20 +03:00
|
|
|
case INDEX_op_qemu_st_a32_i64:
|
|
|
|
case INDEX_op_qemu_st_a64_i64:
|
2023-04-06 22:57:43 +03:00
|
|
|
tcg_out_qemu_st(s, args[0], args[1], args[2], TCG_TYPE_I64);
|
2010-06-29 06:15:37 +04:00
|
|
|
break;
|
2023-04-19 18:58:23 +03:00
|
|
|
case INDEX_op_qemu_ld_a32_i128:
|
|
|
|
case INDEX_op_qemu_ld_a64_i128:
|
|
|
|
tcg_out_qemu_ldst_i128(s, args[0], args[1], args[2], args[3], true);
|
|
|
|
break;
|
|
|
|
case INDEX_op_qemu_st_a32_i128:
|
|
|
|
case INDEX_op_qemu_st_a64_i128:
|
|
|
|
tcg_out_qemu_ldst_i128(s, args[0], args[1], args[2], args[3], false);
|
|
|
|
break;
|
2010-06-29 06:15:37 +04:00
|
|
|
|
|
|
|
case INDEX_op_ld16s_i64:
|
|
|
|
tcg_out_mem(s, 0, RXY_LGH, args[0], args[1], TCG_REG_NONE, args[2]);
|
|
|
|
break;
|
|
|
|
case INDEX_op_ld32u_i64:
|
|
|
|
tcg_out_mem(s, 0, RXY_LLGF, args[0], args[1], TCG_REG_NONE, args[2]);
|
|
|
|
break;
|
|
|
|
case INDEX_op_ld32s_i64:
|
|
|
|
tcg_out_mem(s, 0, RXY_LGF, args[0], args[1], TCG_REG_NONE, args[2]);
|
|
|
|
break;
|
|
|
|
case INDEX_op_ld_i64:
|
|
|
|
tcg_out_ld(s, TCG_TYPE_I64, args[0], args[1], args[2]);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case INDEX_op_st32_i64:
|
|
|
|
tcg_out_st(s, TCG_TYPE_I32, args[0], args[1], args[2]);
|
|
|
|
break;
|
|
|
|
case INDEX_op_st_i64:
|
|
|
|
tcg_out_st(s, TCG_TYPE_I64, args[0], args[1], args[2]);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case INDEX_op_add_i64:
|
2013-03-27 22:23:26 +04:00
|
|
|
a0 = args[0], a1 = args[1], a2 = args[2];
|
2010-06-29 06:15:37 +04:00
|
|
|
if (const_args[2]) {
|
2013-03-27 22:23:26 +04:00
|
|
|
do_addi_64:
|
|
|
|
if (a0 == a1) {
|
|
|
|
if (a2 == (int16_t)a2) {
|
|
|
|
tcg_out_insn(s, RI, AGHI, a0, a2);
|
|
|
|
break;
|
|
|
|
}
|
2022-12-07 19:28:07 +03:00
|
|
|
if (a2 == (int32_t)a2) {
|
|
|
|
tcg_out_insn(s, RIL, AGFI, a0, a2);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (a2 == (uint32_t)a2) {
|
|
|
|
tcg_out_insn(s, RIL, ALGFI, a0, a2);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (-a2 == (uint32_t)-a2) {
|
|
|
|
tcg_out_insn(s, RIL, SLGFI, a0, -a2);
|
|
|
|
break;
|
2013-03-27 22:23:26 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
tcg_out_mem(s, RX_LA, RXY_LAY, a0, a1, TCG_REG_NONE, a2);
|
|
|
|
} else if (a0 == a1) {
|
|
|
|
tcg_out_insn(s, RRE, AGR, a0, a2);
|
2010-06-29 06:15:37 +04:00
|
|
|
} else {
|
2013-03-27 22:23:26 +04:00
|
|
|
tcg_out_insn(s, RX, LA, a0, a1, a2, 0);
|
2010-06-29 06:15:37 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case INDEX_op_sub_i64:
|
2013-03-27 22:23:26 +04:00
|
|
|
a0 = args[0], a1 = args[1], a2 = args[2];
|
2010-06-29 06:15:37 +04:00
|
|
|
if (const_args[2]) {
|
2013-03-27 22:23:26 +04:00
|
|
|
a2 = -a2;
|
|
|
|
goto do_addi_64;
|
2010-06-29 06:15:37 +04:00
|
|
|
} else {
|
2022-02-24 03:48:52 +03:00
|
|
|
tcg_out_insn(s, RRFa, SGRK, a0, a1, a2);
|
2010-06-29 06:15:37 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case INDEX_op_and_i64:
|
2017-06-16 23:43:17 +03:00
|
|
|
a0 = args[0], a1 = args[1], a2 = args[2];
|
2010-06-29 06:15:37 +04:00
|
|
|
if (const_args[2]) {
|
2017-06-16 23:43:17 +03:00
|
|
|
tcg_out_mov(s, TCG_TYPE_I64, a0, a1);
|
2013-03-27 19:47:54 +04:00
|
|
|
tgen_andi(s, TCG_TYPE_I64, args[0], args[2]);
|
2017-06-16 23:43:17 +03:00
|
|
|
} else {
|
2022-02-24 03:48:52 +03:00
|
|
|
tcg_out_insn(s, RRFa, NGRK, a0, a1, a2);
|
2010-06-29 06:15:37 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case INDEX_op_or_i64:
|
2017-06-16 23:43:17 +03:00
|
|
|
a0 = args[0], a1 = args[1], a2 = args[2];
|
2010-06-29 06:15:37 +04:00
|
|
|
if (const_args[2]) {
|
2017-06-16 23:43:17 +03:00
|
|
|
tcg_out_mov(s, TCG_TYPE_I64, a0, a1);
|
2022-12-08 20:28:19 +03:00
|
|
|
tgen_ori(s, a0, a2);
|
2010-06-29 06:15:37 +04:00
|
|
|
} else {
|
2022-02-24 03:48:52 +03:00
|
|
|
tcg_out_insn(s, RRFa, OGRK, a0, a1, a2);
|
2010-06-29 06:15:37 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case INDEX_op_xor_i64:
|
2017-06-16 23:43:17 +03:00
|
|
|
a0 = args[0], a1 = args[1], a2 = args[2];
|
2010-06-29 06:15:37 +04:00
|
|
|
if (const_args[2]) {
|
2017-06-16 23:43:17 +03:00
|
|
|
tcg_out_mov(s, TCG_TYPE_I64, a0, a1);
|
2022-12-08 20:28:19 +03:00
|
|
|
tgen_xori(s, a0, a2);
|
2010-06-29 06:15:37 +04:00
|
|
|
} else {
|
2022-02-24 03:48:52 +03:00
|
|
|
tcg_out_insn(s, RRFa, XGRK, a0, a1, a2);
|
2010-06-29 06:15:37 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2022-02-24 03:04:25 +03:00
|
|
|
case INDEX_op_andc_i64:
|
|
|
|
a0 = args[0], a1 = args[1], a2 = args[2];
|
|
|
|
if (const_args[2]) {
|
|
|
|
tcg_out_mov(s, TCG_TYPE_I64, a0, a1);
|
|
|
|
tgen_andi(s, TCG_TYPE_I64, a0, ~a2);
|
|
|
|
} else {
|
|
|
|
tcg_out_insn(s, RRFa, NCGRK, a0, a1, a2);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case INDEX_op_orc_i64:
|
|
|
|
a0 = args[0], a1 = args[1], a2 = args[2];
|
|
|
|
if (const_args[2]) {
|
|
|
|
tcg_out_mov(s, TCG_TYPE_I64, a0, a1);
|
|
|
|
tgen_ori(s, a0, ~a2);
|
|
|
|
} else {
|
|
|
|
tcg_out_insn(s, RRFa, OCGRK, a0, a1, a2);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case INDEX_op_eqv_i64:
|
|
|
|
a0 = args[0], a1 = args[1], a2 = args[2];
|
|
|
|
if (const_args[2]) {
|
|
|
|
tcg_out_mov(s, TCG_TYPE_I64, a0, a1);
|
|
|
|
tgen_xori(s, a0, ~a2);
|
|
|
|
} else {
|
|
|
|
tcg_out_insn(s, RRFa, NXGRK, a0, a1, a2);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case INDEX_op_nand_i64:
|
|
|
|
tcg_out_insn(s, RRFa, NNGRK, args[0], args[1], args[2]);
|
|
|
|
break;
|
|
|
|
case INDEX_op_nor_i64:
|
|
|
|
tcg_out_insn(s, RRFa, NOGRK, args[0], args[1], args[2]);
|
|
|
|
break;
|
|
|
|
|
2010-06-29 06:15:37 +04:00
|
|
|
case INDEX_op_neg_i64:
|
|
|
|
tcg_out_insn(s, RRE, LCGR, args[0], args[1]);
|
|
|
|
break;
|
2022-02-24 03:04:25 +03:00
|
|
|
case INDEX_op_not_i64:
|
|
|
|
tcg_out_insn(s, RRFa, NOGRK, args[0], args[1], args[1]);
|
|
|
|
break;
|
2010-06-29 06:15:37 +04:00
|
|
|
case INDEX_op_bswap64_i64:
|
|
|
|
tcg_out_insn(s, RRE, LRVGR, args[0], args[1]);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case INDEX_op_mul_i64:
|
2022-02-24 04:28:44 +03:00
|
|
|
a0 = args[0], a1 = args[1], a2 = args[2];
|
2010-06-29 06:15:37 +04:00
|
|
|
if (const_args[2]) {
|
2022-02-24 04:28:44 +03:00
|
|
|
tcg_out_mov(s, TCG_TYPE_I64, a0, a1);
|
|
|
|
if (a2 == (int16_t)a2) {
|
|
|
|
tcg_out_insn(s, RI, MGHI, a0, a2);
|
2010-06-29 06:15:37 +04:00
|
|
|
} else {
|
2022-02-24 04:28:44 +03:00
|
|
|
tcg_out_insn(s, RIL, MSGFI, a0, a2);
|
2010-06-29 06:15:37 +04:00
|
|
|
}
|
2022-02-24 04:28:44 +03:00
|
|
|
} else if (a0 == a1) {
|
|
|
|
tcg_out_insn(s, RRE, MSGR, a0, a2);
|
2010-06-29 06:15:37 +04:00
|
|
|
} else {
|
2022-02-24 04:28:44 +03:00
|
|
|
tcg_out_insn(s, RRFa, MSGRKC, a0, a1, a2);
|
2010-06-29 06:15:37 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case INDEX_op_div2_i64:
|
2022-10-10 18:41:15 +03:00
|
|
|
/*
|
|
|
|
* ??? We get an unnecessary sign-extension of the dividend
|
|
|
|
* into op0 with this definition, but as we do in fact always
|
|
|
|
* produce both quotient and remainder using INDEX_op_div_i64
|
|
|
|
* instead requires jumping through even more hoops.
|
|
|
|
*/
|
|
|
|
tcg_debug_assert(args[0] == args[2]);
|
|
|
|
tcg_debug_assert(args[1] == args[3]);
|
|
|
|
tcg_debug_assert((args[1] & 1) == 0);
|
|
|
|
tcg_debug_assert(args[0] == args[1] + 1);
|
|
|
|
tcg_out_insn(s, RRE, DSGR, args[1], args[4]);
|
2010-06-29 06:15:37 +04:00
|
|
|
break;
|
|
|
|
case INDEX_op_divu2_i64:
|
2022-10-10 18:41:15 +03:00
|
|
|
tcg_debug_assert(args[0] == args[2]);
|
|
|
|
tcg_debug_assert(args[1] == args[3]);
|
|
|
|
tcg_debug_assert((args[1] & 1) == 0);
|
|
|
|
tcg_debug_assert(args[0] == args[1] + 1);
|
|
|
|
tcg_out_insn(s, RRE, DLGR, args[1], args[4]);
|
2010-06-29 06:15:37 +04:00
|
|
|
break;
|
2013-03-27 00:50:29 +04:00
|
|
|
case INDEX_op_mulu2_i64:
|
2022-10-10 18:41:15 +03:00
|
|
|
tcg_debug_assert(args[0] == args[2]);
|
|
|
|
tcg_debug_assert((args[1] & 1) == 0);
|
|
|
|
tcg_debug_assert(args[0] == args[1] + 1);
|
|
|
|
tcg_out_insn(s, RRE, MLGR, args[1], args[3]);
|
2013-03-27 00:50:29 +04:00
|
|
|
break;
|
2022-02-24 04:35:43 +03:00
|
|
|
case INDEX_op_muls2_i64:
|
|
|
|
tcg_debug_assert((args[1] & 1) == 0);
|
|
|
|
tcg_debug_assert(args[0] == args[1] + 1);
|
|
|
|
tcg_out_insn(s, RRFa, MGRK, args[1], args[2], args[3]);
|
|
|
|
break;
|
2010-06-29 06:15:37 +04:00
|
|
|
|
|
|
|
case INDEX_op_shl_i64:
|
|
|
|
op = RSY_SLLG;
|
|
|
|
do_shift64:
|
|
|
|
if (const_args[2]) {
|
|
|
|
tcg_out_sh64(s, op, args[0], args[1], TCG_REG_NONE, args[2]);
|
|
|
|
} else {
|
|
|
|
tcg_out_sh64(s, op, args[0], args[1], args[2], 0);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case INDEX_op_shr_i64:
|
|
|
|
op = RSY_SRLG;
|
|
|
|
goto do_shift64;
|
|
|
|
case INDEX_op_sar_i64:
|
|
|
|
op = RSY_SRAG;
|
|
|
|
goto do_shift64;
|
|
|
|
|
|
|
|
case INDEX_op_rotl_i64:
|
|
|
|
if (const_args[2]) {
|
|
|
|
tcg_out_sh64(s, RSY_RLLG, args[0], args[1],
|
|
|
|
TCG_REG_NONE, args[2]);
|
|
|
|
} else {
|
|
|
|
tcg_out_sh64(s, RSY_RLLG, args[0], args[1], args[2], 0);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case INDEX_op_rotr_i64:
|
|
|
|
if (const_args[2]) {
|
|
|
|
tcg_out_sh64(s, RSY_RLLG, args[0], args[1],
|
|
|
|
TCG_REG_NONE, (64 - args[2]) & 63);
|
|
|
|
} else {
|
|
|
|
/* We can use the smaller 32-bit negate because only the
|
|
|
|
low 6 bits are examined for the rotate. */
|
|
|
|
tcg_out_insn(s, RR, LCR, TCG_TMP0, args[2]);
|
|
|
|
tcg_out_sh64(s, RSY_RLLG, args[0], args[1], TCG_TMP0, 0);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2013-03-27 00:41:45 +04:00
|
|
|
case INDEX_op_add2_i64:
|
2014-03-31 11:16:37 +04:00
|
|
|
if (const_args[4]) {
|
|
|
|
if ((int64_t)args[4] >= 0) {
|
|
|
|
tcg_out_insn(s, RIL, ALGFI, args[0], args[4]);
|
|
|
|
} else {
|
|
|
|
tcg_out_insn(s, RIL, SLGFI, args[0], -args[4]);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
tcg_out_insn(s, RRE, ALGR, args[0], args[4]);
|
|
|
|
}
|
2013-03-27 00:41:45 +04:00
|
|
|
tcg_out_insn(s, RRE, ALCGR, args[1], args[5]);
|
|
|
|
break;
|
|
|
|
case INDEX_op_sub2_i64:
|
2014-03-31 11:16:37 +04:00
|
|
|
if (const_args[4]) {
|
|
|
|
if ((int64_t)args[4] >= 0) {
|
|
|
|
tcg_out_insn(s, RIL, SLGFI, args[0], args[4]);
|
|
|
|
} else {
|
|
|
|
tcg_out_insn(s, RIL, ALGFI, args[0], -args[4]);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
tcg_out_insn(s, RRE, SLGR, args[0], args[4]);
|
|
|
|
}
|
2013-03-27 00:41:45 +04:00
|
|
|
tcg_out_insn(s, RRE, SLBGR, args[1], args[5]);
|
|
|
|
break;
|
|
|
|
|
2010-06-29 06:15:37 +04:00
|
|
|
case INDEX_op_brcond_i64:
|
|
|
|
tgen_brcond(s, TCG_TYPE_I64, args[2], args[0],
|
2015-02-14 00:39:54 +03:00
|
|
|
args[1], const_args[1], arg_label(args[3]));
|
2010-06-29 06:15:37 +04:00
|
|
|
break;
|
|
|
|
case INDEX_op_setcond_i64:
|
|
|
|
tgen_setcond(s, TCG_TYPE_I64, args[3], args[0], args[1],
|
2023-08-05 21:55:54 +03:00
|
|
|
args[2], const_args[2], false);
|
|
|
|
break;
|
|
|
|
case INDEX_op_negsetcond_i64:
|
|
|
|
tgen_setcond(s, TCG_TYPE_I64, args[3], args[0], args[1],
|
|
|
|
args[2], const_args[2], true);
|
2010-06-29 06:15:37 +04:00
|
|
|
break;
|
2013-03-27 01:28:52 +04:00
|
|
|
case INDEX_op_movcond_i64:
|
|
|
|
tgen_movcond(s, TCG_TYPE_I64, args[5], args[0], args[1],
|
2022-02-24 03:24:05 +03:00
|
|
|
args[2], const_args[2], args[3], const_args[3], args[4]);
|
2013-03-27 01:28:52 +04:00
|
|
|
break;
|
2010-06-29 06:15:37 +04:00
|
|
|
|
2013-03-27 17:30:58 +04:00
|
|
|
OP_32_64(deposit):
|
2016-10-18 03:00:46 +03:00
|
|
|
a0 = args[0], a1 = args[1], a2 = args[2];
|
|
|
|
if (const_args[1]) {
|
|
|
|
tgen_deposit(s, a0, a2, args[3], args[4], 1);
|
|
|
|
} else {
|
|
|
|
/* Since we can't support "0Z" as a constraint, we allow a1 in
|
|
|
|
any register. Fix things up as if a matching constraint. */
|
|
|
|
if (a0 != a1) {
|
|
|
|
TCGType type = (opc == INDEX_op_deposit_i64);
|
|
|
|
if (a0 == a2) {
|
|
|
|
tcg_out_mov(s, type, TCG_TMP0, a2);
|
|
|
|
a2 = TCG_TMP0;
|
|
|
|
}
|
|
|
|
tcg_out_mov(s, type, a0, a1);
|
|
|
|
}
|
|
|
|
tgen_deposit(s, a0, a2, args[3], args[4], 0);
|
|
|
|
}
|
2013-03-27 17:30:58 +04:00
|
|
|
break;
|
2016-10-18 03:00:46 +03:00
|
|
|
|
2016-10-14 22:26:40 +03:00
|
|
|
OP_32_64(extract):
|
|
|
|
tgen_extract(s, args[0], args[1], args[2], args[3]);
|
|
|
|
break;
|
2013-03-27 17:30:58 +04:00
|
|
|
|
2016-11-16 18:10:37 +03:00
|
|
|
case INDEX_op_clz_i64:
|
|
|
|
tgen_clz(s, args[0], args[1], args[2], const_args[2]);
|
|
|
|
break;
|
|
|
|
|
2022-02-24 03:43:18 +03:00
|
|
|
case INDEX_op_ctpop_i32:
|
|
|
|
tgen_ctpop(s, TCG_TYPE_I32, args[0], args[1]);
|
|
|
|
break;
|
|
|
|
case INDEX_op_ctpop_i64:
|
|
|
|
tgen_ctpop(s, TCG_TYPE_I64, args[0], args[1]);
|
|
|
|
break;
|
|
|
|
|
2016-07-14 23:20:20 +03:00
|
|
|
case INDEX_op_mb:
|
|
|
|
/* The host memory model is quite strong, we simply need to
|
|
|
|
serialize the instruction stream. */
|
|
|
|
if (args[0] & TCG_MO_ST_LD) {
|
2022-12-07 20:43:35 +03:00
|
|
|
/* fast-bcr-serialization facility (45) is present */
|
|
|
|
tcg_out_insn(s, RR, BCR, 14, 0);
|
2016-07-14 23:20:20 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2014-04-25 23:19:33 +04:00
|
|
|
case INDEX_op_mov_i32: /* Always emitted via tcg_out_mov. */
|
|
|
|
case INDEX_op_mov_i64:
|
|
|
|
case INDEX_op_call: /* Always emitted via tcg_out_call. */
|
2022-11-26 23:42:06 +03:00
|
|
|
case INDEX_op_exit_tb: /* Always emitted via tcg_out_exit_tb. */
|
2022-11-27 04:14:05 +03:00
|
|
|
case INDEX_op_goto_tb: /* Always emitted via tcg_out_goto_tb. */
|
2023-04-05 21:17:01 +03:00
|
|
|
case INDEX_op_ext8s_i32: /* Always emitted via tcg_reg_alloc_op. */
|
|
|
|
case INDEX_op_ext8s_i64:
|
2023-04-05 23:26:51 +03:00
|
|
|
case INDEX_op_ext8u_i32:
|
|
|
|
case INDEX_op_ext8u_i64:
|
2023-04-06 00:49:59 +03:00
|
|
|
case INDEX_op_ext16s_i32:
|
|
|
|
case INDEX_op_ext16s_i64:
|
2023-04-06 02:25:22 +03:00
|
|
|
case INDEX_op_ext16u_i32:
|
|
|
|
case INDEX_op_ext16u_i64:
|
2023-04-06 03:50:09 +03:00
|
|
|
case INDEX_op_ext32s_i64:
|
2023-04-06 04:07:05 +03:00
|
|
|
case INDEX_op_ext32u_i64:
|
2023-04-06 04:30:56 +03:00
|
|
|
case INDEX_op_ext_i32_i64:
|
2023-04-06 04:56:28 +03:00
|
|
|
case INDEX_op_extu_i32_i64:
|
2023-04-06 05:58:35 +03:00
|
|
|
case INDEX_op_extrl_i64_i32:
|
2010-06-29 06:15:37 +04:00
|
|
|
default:
|
2023-04-05 22:09:14 +03:00
|
|
|
g_assert_not_reached();
|
2010-06-29 06:15:37 +04:00
|
|
|
}
|
2009-12-05 14:44:23 +03:00
|
|
|
}
|
|
|
|
|
2020-09-15 02:33:14 +03:00
|
|
|
static bool tcg_out_dup_vec(TCGContext *s, TCGType type, unsigned vece,
|
|
|
|
TCGReg dst, TCGReg src)
|
|
|
|
{
|
2020-09-15 03:25:52 +03:00
|
|
|
if (is_general_reg(src)) {
|
|
|
|
/* Replicate general register into two MO_64. */
|
|
|
|
tcg_out_insn(s, VRRf, VLVGP, dst, src, src);
|
|
|
|
if (vece == MO_64) {
|
|
|
|
return true;
|
|
|
|
}
|
2022-03-03 03:26:50 +03:00
|
|
|
src = dst;
|
2020-09-15 03:25:52 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Recall that the "standard" integer, within a vector, is the
|
|
|
|
* rightmost element of the leftmost doubleword, a-la VLLEZ.
|
|
|
|
*/
|
|
|
|
tcg_out_insn(s, VRIc, VREP, dst, (8 >> vece) - 1, src, vece);
|
|
|
|
return true;
|
2020-09-15 02:33:14 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool tcg_out_dupm_vec(TCGContext *s, TCGType type, unsigned vece,
|
|
|
|
TCGReg dst, TCGReg base, intptr_t offset)
|
|
|
|
{
|
2020-09-15 03:25:52 +03:00
|
|
|
tcg_out_vrx_mem(s, VRX_VLREP, dst, base, TCG_REG_NONE, offset, vece);
|
|
|
|
return true;
|
2020-09-15 02:33:14 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void tcg_out_dupi_vec(TCGContext *s, TCGType type, unsigned vece,
|
|
|
|
TCGReg dst, int64_t val)
|
|
|
|
{
|
2020-09-15 03:25:52 +03:00
|
|
|
int i, mask, msb, lsb;
|
|
|
|
|
|
|
|
/* Look for int16_t elements. */
|
|
|
|
if (vece <= MO_16 ||
|
|
|
|
(vece == MO_32 ? (int32_t)val : val) == (int16_t)val) {
|
|
|
|
tcg_out_insn(s, VRIa, VREPI, dst, val, vece);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Look for bit masks. */
|
|
|
|
if (vece == MO_32) {
|
|
|
|
if (risbg_mask((int32_t)val)) {
|
|
|
|
/* Handle wraparound by swapping msb and lsb. */
|
|
|
|
if ((val & 0x80000001u) == 0x80000001u) {
|
|
|
|
msb = 32 - ctz32(~val);
|
|
|
|
lsb = clz32(~val) - 1;
|
|
|
|
} else {
|
|
|
|
msb = clz32(val);
|
|
|
|
lsb = 31 - ctz32(val);
|
|
|
|
}
|
2022-03-03 03:05:05 +03:00
|
|
|
tcg_out_insn(s, VRIb, VGM, dst, msb, lsb, MO_32);
|
2020-09-15 03:25:52 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (risbg_mask(val)) {
|
|
|
|
/* Handle wraparound by swapping msb and lsb. */
|
|
|
|
if ((val & 0x8000000000000001ull) == 0x8000000000000001ull) {
|
|
|
|
/* Handle wraparound by swapping msb and lsb. */
|
|
|
|
msb = 64 - ctz64(~val);
|
|
|
|
lsb = clz64(~val) - 1;
|
|
|
|
} else {
|
|
|
|
msb = clz64(val);
|
|
|
|
lsb = 63 - ctz64(val);
|
|
|
|
}
|
2022-03-03 03:05:05 +03:00
|
|
|
tcg_out_insn(s, VRIb, VGM, dst, msb, lsb, MO_64);
|
2020-09-15 03:25:52 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Look for all bytes 0x00 or 0xff. */
|
|
|
|
for (i = mask = 0; i < 8; i++) {
|
|
|
|
uint8_t byte = val >> (i * 8);
|
|
|
|
if (byte == 0xff) {
|
|
|
|
mask |= 1 << i;
|
|
|
|
} else if (byte != 0) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (i == 8) {
|
|
|
|
tcg_out_insn(s, VRIa, VGBM, dst, mask * 0x0101, 0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Otherwise, stuff it in the constant pool. */
|
|
|
|
tcg_out_insn(s, RIL, LARL, TCG_TMP0, 0);
|
|
|
|
new_pool_label(s, val, R_390_PC32DBL, s->code_ptr - 2, 2);
|
|
|
|
tcg_out_insn(s, VRX, VLREP, dst, TCG_TMP0, TCG_REG_NONE, 0, MO_64);
|
2020-09-15 02:33:14 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc,
|
|
|
|
unsigned vecl, unsigned vece,
|
2021-10-27 11:56:29 +03:00
|
|
|
const TCGArg args[TCG_MAX_OP_ARGS],
|
|
|
|
const int const_args[TCG_MAX_OP_ARGS])
|
2020-09-15 02:33:14 +03:00
|
|
|
{
|
2020-09-15 04:08:00 +03:00
|
|
|
TCGType type = vecl + TCG_TYPE_V64;
|
|
|
|
TCGArg a0 = args[0], a1 = args[1], a2 = args[2];
|
|
|
|
|
|
|
|
switch (opc) {
|
|
|
|
case INDEX_op_ld_vec:
|
|
|
|
tcg_out_ld(s, type, a0, a1, a2);
|
|
|
|
break;
|
|
|
|
case INDEX_op_st_vec:
|
|
|
|
tcg_out_st(s, type, a0, a1, a2);
|
|
|
|
break;
|
|
|
|
case INDEX_op_dupm_vec:
|
|
|
|
tcg_out_dupm_vec(s, type, vece, a0, a1, a2);
|
|
|
|
break;
|
|
|
|
|
2020-09-15 04:23:16 +03:00
|
|
|
case INDEX_op_abs_vec:
|
|
|
|
tcg_out_insn(s, VRRa, VLP, a0, a1, vece);
|
|
|
|
break;
|
|
|
|
case INDEX_op_neg_vec:
|
|
|
|
tcg_out_insn(s, VRRa, VLC, a0, a1, vece);
|
|
|
|
break;
|
|
|
|
case INDEX_op_not_vec:
|
|
|
|
tcg_out_insn(s, VRRc, VNO, a0, a1, a1, 0);
|
|
|
|
break;
|
|
|
|
|
2020-09-15 04:08:00 +03:00
|
|
|
case INDEX_op_add_vec:
|
|
|
|
tcg_out_insn(s, VRRc, VA, a0, a1, a2, vece);
|
|
|
|
break;
|
|
|
|
case INDEX_op_sub_vec:
|
|
|
|
tcg_out_insn(s, VRRc, VS, a0, a1, a2, vece);
|
|
|
|
break;
|
|
|
|
case INDEX_op_and_vec:
|
|
|
|
tcg_out_insn(s, VRRc, VN, a0, a1, a2, 0);
|
|
|
|
break;
|
2020-09-15 04:23:16 +03:00
|
|
|
case INDEX_op_andc_vec:
|
|
|
|
tcg_out_insn(s, VRRc, VNC, a0, a1, a2, 0);
|
|
|
|
break;
|
2020-09-15 04:33:47 +03:00
|
|
|
case INDEX_op_mul_vec:
|
|
|
|
tcg_out_insn(s, VRRc, VML, a0, a1, a2, vece);
|
|
|
|
break;
|
2020-09-15 04:08:00 +03:00
|
|
|
case INDEX_op_or_vec:
|
|
|
|
tcg_out_insn(s, VRRc, VO, a0, a1, a2, 0);
|
|
|
|
break;
|
2020-09-15 04:23:16 +03:00
|
|
|
case INDEX_op_orc_vec:
|
|
|
|
tcg_out_insn(s, VRRc, VOC, a0, a1, a2, 0);
|
|
|
|
break;
|
2020-09-15 04:08:00 +03:00
|
|
|
case INDEX_op_xor_vec:
|
|
|
|
tcg_out_insn(s, VRRc, VX, a0, a1, a2, 0);
|
|
|
|
break;
|
2021-12-18 05:59:02 +03:00
|
|
|
case INDEX_op_nand_vec:
|
|
|
|
tcg_out_insn(s, VRRc, VNN, a0, a1, a2, 0);
|
|
|
|
break;
|
|
|
|
case INDEX_op_nor_vec:
|
|
|
|
tcg_out_insn(s, VRRc, VNO, a0, a1, a2, 0);
|
|
|
|
break;
|
|
|
|
case INDEX_op_eqv_vec:
|
|
|
|
tcg_out_insn(s, VRRc, VNX, a0, a1, a2, 0);
|
|
|
|
break;
|
2020-09-15 04:08:00 +03:00
|
|
|
|
2020-09-15 05:00:38 +03:00
|
|
|
case INDEX_op_shli_vec:
|
|
|
|
tcg_out_insn(s, VRSa, VESL, a0, a2, TCG_REG_NONE, a1, vece);
|
|
|
|
break;
|
|
|
|
case INDEX_op_shri_vec:
|
|
|
|
tcg_out_insn(s, VRSa, VESRL, a0, a2, TCG_REG_NONE, a1, vece);
|
|
|
|
break;
|
|
|
|
case INDEX_op_sari_vec:
|
|
|
|
tcg_out_insn(s, VRSa, VESRA, a0, a2, TCG_REG_NONE, a1, vece);
|
|
|
|
break;
|
|
|
|
case INDEX_op_rotli_vec:
|
|
|
|
tcg_out_insn(s, VRSa, VERLL, a0, a2, TCG_REG_NONE, a1, vece);
|
|
|
|
break;
|
|
|
|
case INDEX_op_shls_vec:
|
|
|
|
tcg_out_insn(s, VRSa, VESL, a0, 0, a2, a1, vece);
|
|
|
|
break;
|
|
|
|
case INDEX_op_shrs_vec:
|
|
|
|
tcg_out_insn(s, VRSa, VESRL, a0, 0, a2, a1, vece);
|
|
|
|
break;
|
|
|
|
case INDEX_op_sars_vec:
|
|
|
|
tcg_out_insn(s, VRSa, VESRA, a0, 0, a2, a1, vece);
|
|
|
|
break;
|
|
|
|
case INDEX_op_rotls_vec:
|
|
|
|
tcg_out_insn(s, VRSa, VERLL, a0, 0, a2, a1, vece);
|
|
|
|
break;
|
|
|
|
case INDEX_op_shlv_vec:
|
|
|
|
tcg_out_insn(s, VRRc, VESLV, a0, a1, a2, vece);
|
|
|
|
break;
|
|
|
|
case INDEX_op_shrv_vec:
|
|
|
|
tcg_out_insn(s, VRRc, VESRLV, a0, a1, a2, vece);
|
|
|
|
break;
|
|
|
|
case INDEX_op_sarv_vec:
|
|
|
|
tcg_out_insn(s, VRRc, VESRAV, a0, a1, a2, vece);
|
|
|
|
break;
|
|
|
|
case INDEX_op_rotlv_vec:
|
|
|
|
tcg_out_insn(s, VRRc, VERLLV, a0, a1, a2, vece);
|
|
|
|
break;
|
|
|
|
|
2020-09-15 05:07:16 +03:00
|
|
|
case INDEX_op_smin_vec:
|
|
|
|
tcg_out_insn(s, VRRc, VMN, a0, a1, a2, vece);
|
|
|
|
break;
|
|
|
|
case INDEX_op_smax_vec:
|
|
|
|
tcg_out_insn(s, VRRc, VMX, a0, a1, a2, vece);
|
|
|
|
break;
|
|
|
|
case INDEX_op_umin_vec:
|
|
|
|
tcg_out_insn(s, VRRc, VMNL, a0, a1, a2, vece);
|
|
|
|
break;
|
|
|
|
case INDEX_op_umax_vec:
|
|
|
|
tcg_out_insn(s, VRRc, VMXL, a0, a1, a2, vece);
|
|
|
|
break;
|
|
|
|
|
2020-09-15 06:36:36 +03:00
|
|
|
case INDEX_op_bitsel_vec:
|
2022-03-03 03:09:35 +03:00
|
|
|
tcg_out_insn(s, VRRe, VSEL, a0, a2, args[3], a1);
|
2020-09-15 06:36:36 +03:00
|
|
|
break;
|
|
|
|
|
2020-09-15 04:08:00 +03:00
|
|
|
case INDEX_op_cmp_vec:
|
|
|
|
switch ((TCGCond)args[3]) {
|
|
|
|
case TCG_COND_EQ:
|
|
|
|
tcg_out_insn(s, VRRc, VCEQ, a0, a1, a2, vece);
|
|
|
|
break;
|
|
|
|
case TCG_COND_GT:
|
|
|
|
tcg_out_insn(s, VRRc, VCH, a0, a1, a2, vece);
|
|
|
|
break;
|
|
|
|
case TCG_COND_GTU:
|
|
|
|
tcg_out_insn(s, VRRc, VCHL, a0, a1, a2, vece);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2020-09-15 06:17:29 +03:00
|
|
|
case INDEX_op_s390_vuph_vec:
|
|
|
|
tcg_out_insn(s, VRRa, VUPH, a0, a1, vece);
|
|
|
|
break;
|
|
|
|
case INDEX_op_s390_vupl_vec:
|
|
|
|
tcg_out_insn(s, VRRa, VUPL, a0, a1, vece);
|
|
|
|
break;
|
|
|
|
case INDEX_op_s390_vpks_vec:
|
|
|
|
tcg_out_insn(s, VRRc, VPKS, a0, a1, a2, vece);
|
|
|
|
break;
|
|
|
|
|
2020-09-15 04:08:00 +03:00
|
|
|
case INDEX_op_mov_vec: /* Always emitted via tcg_out_mov. */
|
|
|
|
case INDEX_op_dup_vec: /* Always emitted via tcg_out_dup_vec. */
|
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
|
|
|
}
|
2020-09-15 02:33:14 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int tcg_can_emit_vec_op(TCGOpcode opc, TCGType type, unsigned vece)
|
|
|
|
{
|
2020-09-15 04:08:00 +03:00
|
|
|
switch (opc) {
|
2020-09-15 04:23:16 +03:00
|
|
|
case INDEX_op_abs_vec:
|
2020-09-15 04:08:00 +03:00
|
|
|
case INDEX_op_add_vec:
|
|
|
|
case INDEX_op_and_vec:
|
2020-09-15 04:23:16 +03:00
|
|
|
case INDEX_op_andc_vec:
|
2020-09-15 06:36:36 +03:00
|
|
|
case INDEX_op_bitsel_vec:
|
2021-12-18 05:59:02 +03:00
|
|
|
case INDEX_op_eqv_vec:
|
|
|
|
case INDEX_op_nand_vec:
|
2020-09-15 04:23:16 +03:00
|
|
|
case INDEX_op_neg_vec:
|
2021-12-18 05:59:02 +03:00
|
|
|
case INDEX_op_nor_vec:
|
2020-09-15 04:23:16 +03:00
|
|
|
case INDEX_op_not_vec:
|
2020-09-15 04:08:00 +03:00
|
|
|
case INDEX_op_or_vec:
|
2020-09-15 04:23:16 +03:00
|
|
|
case INDEX_op_orc_vec:
|
2020-09-15 05:00:38 +03:00
|
|
|
case INDEX_op_rotli_vec:
|
|
|
|
case INDEX_op_rotls_vec:
|
|
|
|
case INDEX_op_rotlv_vec:
|
|
|
|
case INDEX_op_sari_vec:
|
|
|
|
case INDEX_op_sars_vec:
|
|
|
|
case INDEX_op_sarv_vec:
|
|
|
|
case INDEX_op_shli_vec:
|
|
|
|
case INDEX_op_shls_vec:
|
|
|
|
case INDEX_op_shlv_vec:
|
|
|
|
case INDEX_op_shri_vec:
|
|
|
|
case INDEX_op_shrs_vec:
|
|
|
|
case INDEX_op_shrv_vec:
|
2020-09-15 05:07:16 +03:00
|
|
|
case INDEX_op_smax_vec:
|
|
|
|
case INDEX_op_smin_vec:
|
2020-09-15 04:08:00 +03:00
|
|
|
case INDEX_op_sub_vec:
|
2020-09-15 05:07:16 +03:00
|
|
|
case INDEX_op_umax_vec:
|
|
|
|
case INDEX_op_umin_vec:
|
2020-09-15 04:08:00 +03:00
|
|
|
case INDEX_op_xor_vec:
|
|
|
|
return 1;
|
|
|
|
case INDEX_op_cmp_vec:
|
2020-09-15 06:44:53 +03:00
|
|
|
case INDEX_op_cmpsel_vec:
|
2020-09-15 05:00:38 +03:00
|
|
|
case INDEX_op_rotrv_vec:
|
2020-09-15 04:08:00 +03:00
|
|
|
return -1;
|
2020-09-15 04:33:47 +03:00
|
|
|
case INDEX_op_mul_vec:
|
|
|
|
return vece < MO_64;
|
2020-09-15 06:17:29 +03:00
|
|
|
case INDEX_op_ssadd_vec:
|
|
|
|
case INDEX_op_sssub_vec:
|
|
|
|
return vece < MO_64 ? -1 : 0;
|
2020-09-15 04:08:00 +03:00
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool expand_vec_cmp_noinv(TCGType type, unsigned vece, TCGv_vec v0,
|
|
|
|
TCGv_vec v1, TCGv_vec v2, TCGCond cond)
|
|
|
|
{
|
|
|
|
bool need_swap = false, need_inv = false;
|
|
|
|
|
|
|
|
switch (cond) {
|
|
|
|
case TCG_COND_EQ:
|
|
|
|
case TCG_COND_GT:
|
|
|
|
case TCG_COND_GTU:
|
|
|
|
break;
|
|
|
|
case TCG_COND_NE:
|
|
|
|
case TCG_COND_LE:
|
|
|
|
case TCG_COND_LEU:
|
|
|
|
need_inv = true;
|
|
|
|
break;
|
|
|
|
case TCG_COND_LT:
|
|
|
|
case TCG_COND_LTU:
|
|
|
|
need_swap = true;
|
|
|
|
break;
|
|
|
|
case TCG_COND_GE:
|
|
|
|
case TCG_COND_GEU:
|
|
|
|
need_swap = need_inv = true;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (need_inv) {
|
|
|
|
cond = tcg_invert_cond(cond);
|
|
|
|
}
|
|
|
|
if (need_swap) {
|
|
|
|
TCGv_vec t1;
|
|
|
|
t1 = v1, v1 = v2, v2 = t1;
|
|
|
|
cond = tcg_swap_cond(cond);
|
|
|
|
}
|
|
|
|
|
|
|
|
vec_gen_4(INDEX_op_cmp_vec, type, vece, tcgv_vec_arg(v0),
|
|
|
|
tcgv_vec_arg(v1), tcgv_vec_arg(v2), cond);
|
|
|
|
|
|
|
|
return need_inv;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void expand_vec_cmp(TCGType type, unsigned vece, TCGv_vec v0,
|
|
|
|
TCGv_vec v1, TCGv_vec v2, TCGCond cond)
|
|
|
|
{
|
|
|
|
if (expand_vec_cmp_noinv(type, vece, v0, v1, v2, cond)) {
|
|
|
|
tcg_gen_not_vec(vece, v0, v0);
|
|
|
|
}
|
2020-09-15 02:33:14 +03:00
|
|
|
}
|
|
|
|
|
2020-09-15 06:44:53 +03:00
|
|
|
static void expand_vec_cmpsel(TCGType type, unsigned vece, TCGv_vec v0,
|
|
|
|
TCGv_vec c1, TCGv_vec c2,
|
|
|
|
TCGv_vec v3, TCGv_vec v4, TCGCond cond)
|
|
|
|
{
|
|
|
|
TCGv_vec t = tcg_temp_new_vec(type);
|
|
|
|
|
|
|
|
if (expand_vec_cmp_noinv(type, vece, t, c1, c2, cond)) {
|
|
|
|
/* Invert the sense of the compare by swapping arguments. */
|
|
|
|
tcg_gen_bitsel_vec(vece, v0, t, v4, v3);
|
|
|
|
} else {
|
|
|
|
tcg_gen_bitsel_vec(vece, v0, t, v3, v4);
|
|
|
|
}
|
|
|
|
tcg_temp_free_vec(t);
|
|
|
|
}
|
|
|
|
|
2020-09-15 06:17:29 +03:00
|
|
|
static void expand_vec_sat(TCGType type, unsigned vece, TCGv_vec v0,
|
|
|
|
TCGv_vec v1, TCGv_vec v2, TCGOpcode add_sub_opc)
|
|
|
|
{
|
|
|
|
TCGv_vec h1 = tcg_temp_new_vec(type);
|
|
|
|
TCGv_vec h2 = tcg_temp_new_vec(type);
|
|
|
|
TCGv_vec l1 = tcg_temp_new_vec(type);
|
|
|
|
TCGv_vec l2 = tcg_temp_new_vec(type);
|
|
|
|
|
|
|
|
tcg_debug_assert (vece < MO_64);
|
|
|
|
|
|
|
|
/* Unpack with sign-extension. */
|
|
|
|
vec_gen_2(INDEX_op_s390_vuph_vec, type, vece,
|
|
|
|
tcgv_vec_arg(h1), tcgv_vec_arg(v1));
|
|
|
|
vec_gen_2(INDEX_op_s390_vuph_vec, type, vece,
|
|
|
|
tcgv_vec_arg(h2), tcgv_vec_arg(v2));
|
|
|
|
|
|
|
|
vec_gen_2(INDEX_op_s390_vupl_vec, type, vece,
|
|
|
|
tcgv_vec_arg(l1), tcgv_vec_arg(v1));
|
|
|
|
vec_gen_2(INDEX_op_s390_vupl_vec, type, vece,
|
|
|
|
tcgv_vec_arg(l2), tcgv_vec_arg(v2));
|
|
|
|
|
|
|
|
/* Arithmetic on a wider element size. */
|
|
|
|
vec_gen_3(add_sub_opc, type, vece + 1, tcgv_vec_arg(h1),
|
|
|
|
tcgv_vec_arg(h1), tcgv_vec_arg(h2));
|
|
|
|
vec_gen_3(add_sub_opc, type, vece + 1, tcgv_vec_arg(l1),
|
|
|
|
tcgv_vec_arg(l1), tcgv_vec_arg(l2));
|
|
|
|
|
|
|
|
/* Pack with saturation. */
|
|
|
|
vec_gen_3(INDEX_op_s390_vpks_vec, type, vece + 1,
|
|
|
|
tcgv_vec_arg(v0), tcgv_vec_arg(h1), tcgv_vec_arg(l1));
|
|
|
|
|
|
|
|
tcg_temp_free_vec(h1);
|
|
|
|
tcg_temp_free_vec(h2);
|
|
|
|
tcg_temp_free_vec(l1);
|
|
|
|
tcg_temp_free_vec(l2);
|
|
|
|
}
|
|
|
|
|
2020-09-15 02:33:14 +03:00
|
|
|
void tcg_expand_vec_op(TCGOpcode opc, TCGType type, unsigned vece,
|
|
|
|
TCGArg a0, ...)
|
|
|
|
{
|
2020-09-15 04:08:00 +03:00
|
|
|
va_list va;
|
2020-09-15 06:44:53 +03:00
|
|
|
TCGv_vec v0, v1, v2, v3, v4, t0;
|
2020-09-15 04:08:00 +03:00
|
|
|
|
|
|
|
va_start(va, a0);
|
|
|
|
v0 = temp_tcgv_vec(arg_temp(a0));
|
|
|
|
v1 = temp_tcgv_vec(arg_temp(va_arg(va, TCGArg)));
|
|
|
|
v2 = temp_tcgv_vec(arg_temp(va_arg(va, TCGArg)));
|
|
|
|
|
|
|
|
switch (opc) {
|
|
|
|
case INDEX_op_cmp_vec:
|
|
|
|
expand_vec_cmp(type, vece, v0, v1, v2, va_arg(va, TCGArg));
|
|
|
|
break;
|
|
|
|
|
2020-09-15 06:44:53 +03:00
|
|
|
case INDEX_op_cmpsel_vec:
|
|
|
|
v3 = temp_tcgv_vec(arg_temp(va_arg(va, TCGArg)));
|
|
|
|
v4 = temp_tcgv_vec(arg_temp(va_arg(va, TCGArg)));
|
|
|
|
expand_vec_cmpsel(type, vece, v0, v1, v2, v3, v4, va_arg(va, TCGArg));
|
|
|
|
break;
|
|
|
|
|
2020-09-15 05:00:38 +03:00
|
|
|
case INDEX_op_rotrv_vec:
|
|
|
|
t0 = tcg_temp_new_vec(type);
|
|
|
|
tcg_gen_neg_vec(vece, t0, v2);
|
|
|
|
tcg_gen_rotlv_vec(vece, v0, v1, t0);
|
|
|
|
tcg_temp_free_vec(t0);
|
|
|
|
break;
|
|
|
|
|
2020-09-15 06:17:29 +03:00
|
|
|
case INDEX_op_ssadd_vec:
|
|
|
|
expand_vec_sat(type, vece, v0, v1, v2, INDEX_op_add_vec);
|
|
|
|
break;
|
|
|
|
case INDEX_op_sssub_vec:
|
|
|
|
expand_vec_sat(type, vece, v0, v1, v2, INDEX_op_sub_vec);
|
|
|
|
break;
|
|
|
|
|
2020-09-15 04:08:00 +03:00
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
|
|
|
}
|
|
|
|
va_end(va);
|
2020-09-15 02:33:14 +03:00
|
|
|
}
|
|
|
|
|
2020-10-17 21:15:40 +03:00
|
|
|
static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op)
|
2016-11-18 11:31:40 +03:00
|
|
|
{
|
2017-06-16 22:44:18 +03:00
|
|
|
switch (op) {
|
|
|
|
case INDEX_op_goto_ptr:
|
2020-10-17 21:15:40 +03:00
|
|
|
return C_O0_I1(r);
|
2017-06-16 22:44:18 +03:00
|
|
|
|
|
|
|
case INDEX_op_ld8u_i32:
|
|
|
|
case INDEX_op_ld8u_i64:
|
|
|
|
case INDEX_op_ld8s_i32:
|
|
|
|
case INDEX_op_ld8s_i64:
|
|
|
|
case INDEX_op_ld16u_i32:
|
|
|
|
case INDEX_op_ld16u_i64:
|
|
|
|
case INDEX_op_ld16s_i32:
|
|
|
|
case INDEX_op_ld16s_i64:
|
|
|
|
case INDEX_op_ld_i32:
|
|
|
|
case INDEX_op_ld32u_i64:
|
|
|
|
case INDEX_op_ld32s_i64:
|
|
|
|
case INDEX_op_ld_i64:
|
2020-10-17 21:15:40 +03:00
|
|
|
return C_O1_I1(r, r);
|
|
|
|
|
2017-06-16 22:44:18 +03:00
|
|
|
case INDEX_op_st8_i32:
|
|
|
|
case INDEX_op_st8_i64:
|
|
|
|
case INDEX_op_st16_i32:
|
|
|
|
case INDEX_op_st16_i64:
|
|
|
|
case INDEX_op_st_i32:
|
|
|
|
case INDEX_op_st32_i64:
|
|
|
|
case INDEX_op_st_i64:
|
2020-10-17 21:15:40 +03:00
|
|
|
return C_O0_I2(r, r);
|
2017-06-16 22:44:18 +03:00
|
|
|
|
|
|
|
case INDEX_op_add_i32:
|
|
|
|
case INDEX_op_add_i64:
|
2020-10-17 21:15:40 +03:00
|
|
|
case INDEX_op_shl_i64:
|
|
|
|
case INDEX_op_shr_i64:
|
|
|
|
case INDEX_op_sar_i64:
|
|
|
|
case INDEX_op_rotl_i32:
|
|
|
|
case INDEX_op_rotl_i64:
|
|
|
|
case INDEX_op_rotr_i32:
|
|
|
|
case INDEX_op_rotr_i64:
|
|
|
|
case INDEX_op_setcond_i32:
|
2023-08-05 21:55:54 +03:00
|
|
|
case INDEX_op_negsetcond_i32:
|
2020-10-17 21:15:40 +03:00
|
|
|
return C_O1_I2(r, r, ri);
|
2022-12-09 00:48:00 +03:00
|
|
|
case INDEX_op_setcond_i64:
|
2023-08-05 21:55:54 +03:00
|
|
|
case INDEX_op_negsetcond_i64:
|
2022-12-09 00:48:00 +03:00
|
|
|
return C_O1_I2(r, r, rA);
|
2020-10-17 21:15:40 +03:00
|
|
|
|
2022-02-24 06:03:20 +03:00
|
|
|
case INDEX_op_clz_i64:
|
|
|
|
return C_O1_I2(r, r, rI);
|
|
|
|
|
2017-06-16 22:44:18 +03:00
|
|
|
case INDEX_op_sub_i32:
|
|
|
|
case INDEX_op_sub_i64:
|
2017-07-26 01:59:13 +03:00
|
|
|
case INDEX_op_and_i32:
|
2017-07-26 02:21:36 +03:00
|
|
|
case INDEX_op_or_i32:
|
2017-07-26 02:42:51 +03:00
|
|
|
case INDEX_op_xor_i32:
|
2022-12-07 20:50:15 +03:00
|
|
|
return C_O1_I2(r, r, ri);
|
2022-12-08 21:06:03 +03:00
|
|
|
case INDEX_op_and_i64:
|
|
|
|
return C_O1_I2(r, r, rNKR);
|
2022-12-08 20:28:19 +03:00
|
|
|
case INDEX_op_or_i64:
|
|
|
|
case INDEX_op_xor_i64:
|
|
|
|
return C_O1_I2(r, r, rK);
|
2017-06-17 00:52:32 +03:00
|
|
|
|
2022-02-24 03:04:25 +03:00
|
|
|
case INDEX_op_andc_i32:
|
|
|
|
case INDEX_op_orc_i32:
|
|
|
|
case INDEX_op_eqv_i32:
|
|
|
|
return C_O1_I2(r, r, ri);
|
|
|
|
case INDEX_op_andc_i64:
|
|
|
|
return C_O1_I2(r, r, rKR);
|
|
|
|
case INDEX_op_orc_i64:
|
|
|
|
case INDEX_op_eqv_i64:
|
|
|
|
return C_O1_I2(r, r, rNK);
|
|
|
|
|
|
|
|
case INDEX_op_nand_i32:
|
|
|
|
case INDEX_op_nand_i64:
|
|
|
|
case INDEX_op_nor_i32:
|
|
|
|
case INDEX_op_nor_i64:
|
|
|
|
return C_O1_I2(r, r, r);
|
|
|
|
|
2017-06-16 22:44:18 +03:00
|
|
|
case INDEX_op_mul_i32:
|
2022-02-24 04:28:44 +03:00
|
|
|
return (HAVE_FACILITY(MISC_INSN_EXT2)
|
|
|
|
? C_O1_I2(r, r, ri)
|
|
|
|
: C_O1_I2(r, 0, ri));
|
2017-06-16 22:44:18 +03:00
|
|
|
case INDEX_op_mul_i64:
|
2022-02-24 04:28:44 +03:00
|
|
|
return (HAVE_FACILITY(MISC_INSN_EXT2)
|
|
|
|
? C_O1_I2(r, r, rJ)
|
|
|
|
: C_O1_I2(r, 0, rJ));
|
2017-06-17 00:52:32 +03:00
|
|
|
|
2017-06-16 22:44:18 +03:00
|
|
|
case INDEX_op_shl_i32:
|
|
|
|
case INDEX_op_shr_i32:
|
|
|
|
case INDEX_op_sar_i32:
|
2022-12-07 20:50:15 +03:00
|
|
|
return C_O1_I2(r, r, ri);
|
2017-06-16 22:44:18 +03:00
|
|
|
|
|
|
|
case INDEX_op_brcond_i32:
|
2020-10-17 21:15:40 +03:00
|
|
|
return C_O0_I2(r, ri);
|
2022-12-09 00:48:00 +03:00
|
|
|
case INDEX_op_brcond_i64:
|
|
|
|
return C_O0_I2(r, rA);
|
2017-06-16 22:44:18 +03:00
|
|
|
|
|
|
|
case INDEX_op_bswap16_i32:
|
|
|
|
case INDEX_op_bswap16_i64:
|
|
|
|
case INDEX_op_bswap32_i32:
|
|
|
|
case INDEX_op_bswap32_i64:
|
|
|
|
case INDEX_op_bswap64_i64:
|
|
|
|
case INDEX_op_neg_i32:
|
|
|
|
case INDEX_op_neg_i64:
|
2022-02-24 03:04:25 +03:00
|
|
|
case INDEX_op_not_i32:
|
|
|
|
case INDEX_op_not_i64:
|
2017-06-16 22:44:18 +03:00
|
|
|
case INDEX_op_ext8s_i32:
|
|
|
|
case INDEX_op_ext8s_i64:
|
|
|
|
case INDEX_op_ext8u_i32:
|
|
|
|
case INDEX_op_ext8u_i64:
|
|
|
|
case INDEX_op_ext16s_i32:
|
|
|
|
case INDEX_op_ext16s_i64:
|
|
|
|
case INDEX_op_ext16u_i32:
|
|
|
|
case INDEX_op_ext16u_i64:
|
|
|
|
case INDEX_op_ext32s_i64:
|
|
|
|
case INDEX_op_ext32u_i64:
|
|
|
|
case INDEX_op_ext_i32_i64:
|
|
|
|
case INDEX_op_extu_i32_i64:
|
|
|
|
case INDEX_op_extract_i32:
|
|
|
|
case INDEX_op_extract_i64:
|
2022-02-24 03:43:18 +03:00
|
|
|
case INDEX_op_ctpop_i32:
|
|
|
|
case INDEX_op_ctpop_i64:
|
2020-10-17 21:15:40 +03:00
|
|
|
return C_O1_I1(r, r);
|
2017-06-16 22:44:18 +03:00
|
|
|
|
2023-05-17 06:07:20 +03:00
|
|
|
case INDEX_op_qemu_ld_a32_i32:
|
|
|
|
case INDEX_op_qemu_ld_a64_i32:
|
|
|
|
case INDEX_op_qemu_ld_a32_i64:
|
|
|
|
case INDEX_op_qemu_ld_a64_i64:
|
2023-04-08 00:16:12 +03:00
|
|
|
return C_O1_I1(r, r);
|
2023-05-17 06:07:20 +03:00
|
|
|
case INDEX_op_qemu_st_a32_i64:
|
|
|
|
case INDEX_op_qemu_st_a64_i64:
|
|
|
|
case INDEX_op_qemu_st_a32_i32:
|
|
|
|
case INDEX_op_qemu_st_a64_i32:
|
2023-04-08 00:16:12 +03:00
|
|
|
return C_O0_I2(r, r);
|
2023-04-19 18:58:23 +03:00
|
|
|
case INDEX_op_qemu_ld_a32_i128:
|
|
|
|
case INDEX_op_qemu_ld_a64_i128:
|
|
|
|
return C_O2_I1(o, m, r);
|
|
|
|
case INDEX_op_qemu_st_a32_i128:
|
|
|
|
case INDEX_op_qemu_st_a64_i128:
|
|
|
|
return C_O0_I3(o, m, r);
|
2016-11-18 11:31:40 +03:00
|
|
|
|
2017-06-16 22:44:18 +03:00
|
|
|
case INDEX_op_deposit_i32:
|
|
|
|
case INDEX_op_deposit_i64:
|
2020-10-17 21:15:40 +03:00
|
|
|
return C_O1_I2(r, rZ, r);
|
|
|
|
|
2017-06-16 22:44:18 +03:00
|
|
|
case INDEX_op_movcond_i32:
|
2022-02-24 03:24:05 +03:00
|
|
|
return C_O1_I4(r, r, ri, rI, r);
|
2022-12-09 00:48:00 +03:00
|
|
|
case INDEX_op_movcond_i64:
|
|
|
|
return C_O1_I4(r, r, rA, rI, r);
|
2020-10-17 21:15:40 +03:00
|
|
|
|
2017-06-16 22:44:18 +03:00
|
|
|
case INDEX_op_div2_i32:
|
|
|
|
case INDEX_op_div2_i64:
|
|
|
|
case INDEX_op_divu2_i32:
|
|
|
|
case INDEX_op_divu2_i64:
|
2022-10-10 18:41:15 +03:00
|
|
|
return C_O2_I3(o, m, 0, 1, r);
|
2020-10-17 21:15:40 +03:00
|
|
|
|
2017-06-16 22:44:18 +03:00
|
|
|
case INDEX_op_mulu2_i64:
|
2022-10-10 18:41:15 +03:00
|
|
|
return C_O2_I2(o, m, 0, r);
|
2022-02-24 04:35:43 +03:00
|
|
|
case INDEX_op_muls2_i64:
|
|
|
|
return C_O2_I2(o, m, r, r);
|
2017-06-17 00:59:55 +03:00
|
|
|
|
2017-06-16 22:44:18 +03:00
|
|
|
case INDEX_op_add2_i32:
|
|
|
|
case INDEX_op_sub2_i32:
|
tcg/{i386, s390x}: Add earlyclobber to the op_add2's first output
i386 and s390x implementations of op_add2 require an earlyclobber,
which is currently missing. This breaks VCKSM in s390x guests. E.g., on
x86_64 the following op:
add2_i32 tmp2,tmp3,tmp2,tmp3,tmp3,tmp2 dead: 0 2 3 4 5 pref=none,0xffff
is translated to:
addl %ebx, %r12d
adcl %r12d, %ebx
Introduce a new C_N1_O1_I4 constraint, and make sure that earlyclobber
of aliased outputs is honored.
Cc: qemu-stable@nongnu.org
Fixes: 82790a870992 ("tcg: Add markup for output requires new register")
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20230719221310.1968845-7-iii@linux.ibm.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2023-07-20 01:11:18 +03:00
|
|
|
return C_N1_O1_I4(r, r, 0, 1, ri, r);
|
2020-10-17 21:15:40 +03:00
|
|
|
|
2017-06-17 00:59:55 +03:00
|
|
|
case INDEX_op_add2_i64:
|
2017-06-16 22:44:18 +03:00
|
|
|
case INDEX_op_sub2_i64:
|
tcg/{i386, s390x}: Add earlyclobber to the op_add2's first output
i386 and s390x implementations of op_add2 require an earlyclobber,
which is currently missing. This breaks VCKSM in s390x guests. E.g., on
x86_64 the following op:
add2_i32 tmp2,tmp3,tmp2,tmp3,tmp3,tmp2 dead: 0 2 3 4 5 pref=none,0xffff
is translated to:
addl %ebx, %r12d
adcl %r12d, %ebx
Introduce a new C_N1_O1_I4 constraint, and make sure that earlyclobber
of aliased outputs is honored.
Cc: qemu-stable@nongnu.org
Fixes: 82790a870992 ("tcg: Add markup for output requires new register")
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20230719221310.1968845-7-iii@linux.ibm.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2023-07-20 01:11:18 +03:00
|
|
|
return C_N1_O1_I4(r, r, 0, 1, rA, r);
|
2017-06-16 22:44:18 +03:00
|
|
|
|
2020-09-15 02:33:14 +03:00
|
|
|
case INDEX_op_st_vec:
|
|
|
|
return C_O0_I2(v, r);
|
|
|
|
case INDEX_op_ld_vec:
|
|
|
|
case INDEX_op_dupm_vec:
|
|
|
|
return C_O1_I1(v, r);
|
|
|
|
case INDEX_op_dup_vec:
|
|
|
|
return C_O1_I1(v, vr);
|
2020-09-15 04:23:16 +03:00
|
|
|
case INDEX_op_abs_vec:
|
|
|
|
case INDEX_op_neg_vec:
|
|
|
|
case INDEX_op_not_vec:
|
2020-09-15 05:00:38 +03:00
|
|
|
case INDEX_op_rotli_vec:
|
|
|
|
case INDEX_op_sari_vec:
|
|
|
|
case INDEX_op_shli_vec:
|
|
|
|
case INDEX_op_shri_vec:
|
2020-09-15 06:17:29 +03:00
|
|
|
case INDEX_op_s390_vuph_vec:
|
|
|
|
case INDEX_op_s390_vupl_vec:
|
2020-09-15 04:23:16 +03:00
|
|
|
return C_O1_I1(v, v);
|
2020-09-15 02:33:14 +03:00
|
|
|
case INDEX_op_add_vec:
|
|
|
|
case INDEX_op_sub_vec:
|
|
|
|
case INDEX_op_and_vec:
|
2020-09-15 04:23:16 +03:00
|
|
|
case INDEX_op_andc_vec:
|
2020-09-15 02:33:14 +03:00
|
|
|
case INDEX_op_or_vec:
|
2020-09-15 04:23:16 +03:00
|
|
|
case INDEX_op_orc_vec:
|
2020-09-15 02:33:14 +03:00
|
|
|
case INDEX_op_xor_vec:
|
2021-12-18 05:59:02 +03:00
|
|
|
case INDEX_op_nand_vec:
|
|
|
|
case INDEX_op_nor_vec:
|
|
|
|
case INDEX_op_eqv_vec:
|
2020-09-15 02:33:14 +03:00
|
|
|
case INDEX_op_cmp_vec:
|
2020-09-15 04:33:47 +03:00
|
|
|
case INDEX_op_mul_vec:
|
2020-09-15 05:00:38 +03:00
|
|
|
case INDEX_op_rotlv_vec:
|
|
|
|
case INDEX_op_rotrv_vec:
|
|
|
|
case INDEX_op_shlv_vec:
|
|
|
|
case INDEX_op_shrv_vec:
|
|
|
|
case INDEX_op_sarv_vec:
|
2020-09-15 05:07:16 +03:00
|
|
|
case INDEX_op_smax_vec:
|
|
|
|
case INDEX_op_smin_vec:
|
|
|
|
case INDEX_op_umax_vec:
|
|
|
|
case INDEX_op_umin_vec:
|
2020-09-15 06:17:29 +03:00
|
|
|
case INDEX_op_s390_vpks_vec:
|
2020-09-15 02:33:14 +03:00
|
|
|
return C_O1_I2(v, v, v);
|
2020-09-15 05:00:38 +03:00
|
|
|
case INDEX_op_rotls_vec:
|
|
|
|
case INDEX_op_shls_vec:
|
|
|
|
case INDEX_op_shrs_vec:
|
|
|
|
case INDEX_op_sars_vec:
|
|
|
|
return C_O1_I2(v, v, r);
|
2020-09-15 06:36:36 +03:00
|
|
|
case INDEX_op_bitsel_vec:
|
|
|
|
return C_O1_I3(v, v, v, v);
|
2020-09-15 02:33:14 +03:00
|
|
|
|
2017-06-16 22:44:18 +03:00
|
|
|
default:
|
2020-10-17 21:15:40 +03:00
|
|
|
g_assert_not_reached();
|
2016-11-18 11:31:40 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-15 02:33:14 +03:00
|
|
|
/*
|
|
|
|
* Mainline glibc added HWCAP_S390_VX before it was kernel abi.
|
|
|
|
* Some distros have fixed this up locally, others have not.
|
|
|
|
*/
|
|
|
|
#ifndef HWCAP_S390_VXRS
|
|
|
|
#define HWCAP_S390_VXRS 2048
|
|
|
|
#endif
|
|
|
|
|
2016-10-17 18:24:38 +03:00
|
|
|
static void query_s390_facilities(void)
|
2010-06-29 06:15:37 +04:00
|
|
|
{
|
2013-06-07 18:43:33 +04:00
|
|
|
unsigned long hwcap = qemu_getauxval(AT_HWCAP);
|
2022-12-07 19:08:46 +03:00
|
|
|
const char *which;
|
2010-06-29 06:15:37 +04:00
|
|
|
|
2013-06-07 18:43:33 +04:00
|
|
|
/* Is STORE FACILITY LIST EXTENDED available? Honestly, I believe this
|
|
|
|
is present on all 64-bit systems, but let's check for it anyway. */
|
|
|
|
if (hwcap & HWCAP_S390_STFLE) {
|
2019-04-28 02:51:09 +03:00
|
|
|
register int r0 __asm__("0") = ARRAY_SIZE(s390_facilities) - 1;
|
|
|
|
register void *r1 __asm__("1") = s390_facilities;
|
2010-06-29 06:15:37 +04:00
|
|
|
|
2013-06-07 18:43:33 +04:00
|
|
|
/* stfle 0(%r1) */
|
|
|
|
asm volatile(".word 0xb2b0,0x1000"
|
2019-04-28 02:51:09 +03:00
|
|
|
: "=r"(r0) : "r"(r0), "r"(r1) : "memory", "cc");
|
2010-06-29 06:15:37 +04:00
|
|
|
}
|
2020-09-15 02:33:14 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Use of vector registers requires os support beyond the facility bit.
|
|
|
|
* If the kernel does not advertise support, disable the facility bits.
|
|
|
|
* There is nothing else we currently care about in the 3rd word, so
|
|
|
|
* disable VECTOR with one store.
|
|
|
|
*/
|
2020-09-15 04:08:00 +03:00
|
|
|
if (!(hwcap & HWCAP_S390_VXRS)) {
|
2020-09-15 02:33:14 +03:00
|
|
|
s390_facilities[2] = 0;
|
|
|
|
}
|
2022-12-07 19:08:46 +03:00
|
|
|
|
|
|
|
/*
|
2022-12-07 20:38:42 +03:00
|
|
|
* Minimum supported cpu revision is z196.
|
2022-12-07 19:08:46 +03:00
|
|
|
* Check for all required facilities.
|
|
|
|
* ZARCH_ACTIVE is done via preprocessor check for 64-bit.
|
|
|
|
*/
|
|
|
|
if (!HAVE_FACILITY(LONG_DISP)) {
|
|
|
|
which = "long-displacement";
|
|
|
|
goto fail;
|
|
|
|
}
|
2022-12-07 19:28:07 +03:00
|
|
|
if (!HAVE_FACILITY(EXT_IMM)) {
|
|
|
|
which = "extended-immediate";
|
|
|
|
goto fail;
|
|
|
|
}
|
2022-12-07 19:51:27 +03:00
|
|
|
if (!HAVE_FACILITY(GEN_INST_EXT)) {
|
|
|
|
which = "general-instructions-extension";
|
|
|
|
goto fail;
|
|
|
|
}
|
2022-12-07 20:38:42 +03:00
|
|
|
/*
|
|
|
|
* Facility 45 is a big bin that contains: distinct-operands,
|
|
|
|
* fast-BCR-serialization, high-word, population-count,
|
|
|
|
* interlocked-access-1, and load/store-on-condition-1
|
|
|
|
*/
|
|
|
|
if (!HAVE_FACILITY(45)) {
|
|
|
|
which = "45";
|
|
|
|
goto fail;
|
|
|
|
}
|
2022-12-07 19:08:46 +03:00
|
|
|
return;
|
|
|
|
|
|
|
|
fail:
|
|
|
|
error_report("%s: missing required facility %s", __func__, which);
|
|
|
|
exit(EXIT_FAILURE);
|
2010-06-29 06:15:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void tcg_target_init(TCGContext *s)
|
2009-12-05 14:44:23 +03:00
|
|
|
{
|
2016-10-17 18:24:38 +03:00
|
|
|
query_s390_facilities();
|
2010-06-29 06:15:37 +04:00
|
|
|
|
2017-09-11 22:44:30 +03:00
|
|
|
tcg_target_available_regs[TCG_TYPE_I32] = 0xffff;
|
|
|
|
tcg_target_available_regs[TCG_TYPE_I64] = 0xffff;
|
2020-09-15 02:33:14 +03:00
|
|
|
if (HAVE_FACILITY(VECTOR)) {
|
|
|
|
tcg_target_available_regs[TCG_TYPE_V64] = 0xffffffff00000000ull;
|
|
|
|
tcg_target_available_regs[TCG_TYPE_V128] = 0xffffffff00000000ull;
|
|
|
|
}
|
2010-06-29 06:15:37 +04:00
|
|
|
|
2017-09-11 21:25:55 +03:00
|
|
|
tcg_target_call_clobber_regs = 0;
|
2010-06-29 06:15:37 +04:00
|
|
|
tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_R0);
|
|
|
|
tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_R1);
|
|
|
|
tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_R2);
|
|
|
|
tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_R3);
|
|
|
|
tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_R4);
|
|
|
|
tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_R5);
|
2014-03-24 00:36:00 +04:00
|
|
|
/* The r6 register is technically call-saved, but it's also a parameter
|
|
|
|
register, so it can get killed by setup for the qemu_st helper. */
|
|
|
|
tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_R6);
|
2010-06-29 06:15:37 +04:00
|
|
|
/* The return register can be considered call-clobbered. */
|
|
|
|
tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_R14);
|
|
|
|
|
2020-09-15 02:33:14 +03:00
|
|
|
tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_V0);
|
|
|
|
tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_V1);
|
|
|
|
tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_V2);
|
|
|
|
tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_V3);
|
|
|
|
tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_V4);
|
|
|
|
tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_V5);
|
|
|
|
tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_V6);
|
|
|
|
tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_V7);
|
|
|
|
tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_V16);
|
|
|
|
tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_V17);
|
|
|
|
tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_V18);
|
|
|
|
tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_V19);
|
|
|
|
tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_V20);
|
|
|
|
tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_V21);
|
|
|
|
tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_V22);
|
|
|
|
tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_V23);
|
|
|
|
tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_V24);
|
|
|
|
tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_V25);
|
|
|
|
tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_V26);
|
|
|
|
tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_V27);
|
|
|
|
tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_V28);
|
|
|
|
tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_V29);
|
|
|
|
tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_V30);
|
|
|
|
tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_V31);
|
|
|
|
|
2017-09-11 21:25:55 +03:00
|
|
|
s->reserved_regs = 0;
|
2010-06-29 06:15:37 +04:00
|
|
|
tcg_regset_set_reg(s->reserved_regs, TCG_TMP0);
|
|
|
|
/* XXX many insns can't be used with R0, so we better avoid it for now */
|
|
|
|
tcg_regset_set_reg(s->reserved_regs, TCG_REG_R0);
|
|
|
|
tcg_regset_set_reg(s->reserved_regs, TCG_REG_CALL_STACK);
|
2009-12-05 14:44:23 +03:00
|
|
|
}
|
|
|
|
|
2014-03-24 05:04:40 +04:00
|
|
|
#define FRAME_SIZE ((int)(TCG_TARGET_CALL_STACK_OFFSET \
|
|
|
|
+ TCG_STATIC_CALL_ARGS_SIZE \
|
|
|
|
+ CPU_TEMP_BUF_NLONGS * sizeof(long)))
|
|
|
|
|
2010-06-29 06:15:37 +04:00
|
|
|
static void tcg_target_qemu_prologue(TCGContext *s)
|
2009-12-05 14:44:23 +03:00
|
|
|
{
|
2010-06-29 06:15:37 +04:00
|
|
|
/* stmg %r6,%r15,48(%r15) (save registers) */
|
|
|
|
tcg_out_insn(s, RXY, STMG, TCG_REG_R6, TCG_REG_R15, TCG_REG_R15, 48);
|
|
|
|
|
2013-03-26 07:54:30 +04:00
|
|
|
/* aghi %r15,-frame_size */
|
2014-03-24 05:04:40 +04:00
|
|
|
tcg_out_insn(s, RI, AGHI, TCG_REG_R15, -FRAME_SIZE);
|
2013-03-26 07:54:30 +04:00
|
|
|
|
|
|
|
tcg_set_frame(s, TCG_REG_CALL_STACK,
|
|
|
|
TCG_STATIC_CALL_ARGS_SIZE + TCG_TARGET_CALL_STACK_OFFSET,
|
|
|
|
CPU_TEMP_BUF_NLONGS * sizeof(long));
|
2010-06-29 06:15:37 +04:00
|
|
|
|
2023-10-02 00:16:32 +03:00
|
|
|
if (!tcg_use_softmmu && guest_base >= 0x80000) {
|
2022-11-30 03:17:50 +03:00
|
|
|
tcg_out_movi(s, TCG_TYPE_PTR, TCG_GUEST_BASE_REG, guest_base);
|
2010-06-29 06:15:37 +04:00
|
|
|
tcg_regset_set_reg(s->reserved_regs, TCG_GUEST_BASE_REG);
|
|
|
|
}
|
|
|
|
|
2011-05-15 20:03:25 +04:00
|
|
|
tcg_out_mov(s, TCG_TYPE_PTR, TCG_AREG0, tcg_target_call_iarg_regs[0]);
|
2017-07-25 21:53:50 +03:00
|
|
|
|
2011-05-15 20:03:25 +04:00
|
|
|
/* br %r3 (go to TB) */
|
|
|
|
tcg_out_insn(s, RR, BCR, S390_CC_ALWAYS, tcg_target_call_iarg_regs[1]);
|
2010-06-29 06:15:37 +04:00
|
|
|
|
2017-04-27 01:40:59 +03:00
|
|
|
/*
|
|
|
|
* Return path for goto_ptr. Set return value to 0, a-la exit_tb,
|
|
|
|
* and fall through to the rest of the epilogue.
|
|
|
|
*/
|
2020-11-06 02:41:38 +03:00
|
|
|
tcg_code_gen_epilogue = tcg_splitwx_to_rx(s->code_ptr);
|
2017-04-27 01:40:59 +03:00
|
|
|
tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_R2, 0);
|
|
|
|
|
|
|
|
/* TB epilogue */
|
2020-11-05 07:56:16 +03:00
|
|
|
tb_ret_addr = tcg_splitwx_to_rx(s->code_ptr);
|
2010-06-29 06:15:37 +04:00
|
|
|
|
2013-03-26 07:54:30 +04:00
|
|
|
/* lmg %r6,%r15,fs+48(%r15) (restore registers) */
|
|
|
|
tcg_out_insn(s, RXY, LMG, TCG_REG_R6, TCG_REG_R15, TCG_REG_R15,
|
2014-03-24 05:04:40 +04:00
|
|
|
FRAME_SIZE + 48);
|
2010-06-29 06:15:37 +04:00
|
|
|
|
|
|
|
/* br %r14 (return) */
|
|
|
|
tcg_out_insn(s, RR, BCR, S390_CC_ALWAYS, TCG_REG_R14);
|
2009-12-05 14:44:23 +03:00
|
|
|
}
|
2014-03-24 05:04:40 +04:00
|
|
|
|
2023-08-15 19:34:59 +03:00
|
|
|
static void tcg_out_tb_start(TCGContext *s)
|
|
|
|
{
|
|
|
|
/* nothing to do */
|
|
|
|
}
|
|
|
|
|
2017-08-01 05:16:02 +03:00
|
|
|
static void tcg_out_nop_fill(tcg_insn_unit *p, int count)
|
|
|
|
{
|
|
|
|
memset(p, 0x07, count * sizeof(tcg_insn_unit));
|
|
|
|
}
|
|
|
|
|
2014-03-24 05:04:40 +04:00
|
|
|
typedef struct {
|
2014-05-15 23:49:42 +04:00
|
|
|
DebugFrameHeader h;
|
2014-03-24 05:04:40 +04:00
|
|
|
uint8_t fde_def_cfa[4];
|
|
|
|
uint8_t fde_reg_ofs[18];
|
|
|
|
} DebugFrame;
|
|
|
|
|
|
|
|
/* We're expecting a 2 byte uleb128 encoded value. */
|
|
|
|
QEMU_BUILD_BUG_ON(FRAME_SIZE >= (1 << 14));
|
|
|
|
|
|
|
|
#define ELF_HOST_MACHINE EM_S390
|
|
|
|
|
2014-05-15 23:49:42 +04:00
|
|
|
static const DebugFrame debug_frame = {
|
|
|
|
.h.cie.len = sizeof(DebugFrameCIE)-4, /* length after .len member */
|
|
|
|
.h.cie.id = -1,
|
|
|
|
.h.cie.version = 1,
|
|
|
|
.h.cie.code_align = 1,
|
|
|
|
.h.cie.data_align = 8, /* sleb128 8 */
|
|
|
|
.h.cie.return_column = TCG_REG_R14,
|
2014-03-24 05:04:40 +04:00
|
|
|
|
|
|
|
/* Total FDE size does not include the "len" member. */
|
2014-05-15 23:49:42 +04:00
|
|
|
.h.fde.len = sizeof(DebugFrame) - offsetof(DebugFrame, h.fde.cie_offset),
|
2014-03-24 05:04:40 +04:00
|
|
|
|
|
|
|
.fde_def_cfa = {
|
|
|
|
12, TCG_REG_CALL_STACK, /* DW_CFA_def_cfa %r15, ... */
|
|
|
|
(FRAME_SIZE & 0x7f) | 0x80, /* ... uleb128 FRAME_SIZE */
|
|
|
|
(FRAME_SIZE >> 7)
|
|
|
|
},
|
|
|
|
.fde_reg_ofs = {
|
|
|
|
0x86, 6, /* DW_CFA_offset, %r6, 48 */
|
|
|
|
0x87, 7, /* DW_CFA_offset, %r7, 56 */
|
|
|
|
0x88, 8, /* DW_CFA_offset, %r8, 64 */
|
|
|
|
0x89, 9, /* DW_CFA_offset, %r92, 72 */
|
|
|
|
0x8a, 10, /* DW_CFA_offset, %r10, 80 */
|
|
|
|
0x8b, 11, /* DW_CFA_offset, %r11, 88 */
|
|
|
|
0x8c, 12, /* DW_CFA_offset, %r12, 96 */
|
|
|
|
0x8d, 13, /* DW_CFA_offset, %r13, 104 */
|
|
|
|
0x8e, 14, /* DW_CFA_offset, %r14, 112 */
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-10-29 19:17:30 +03:00
|
|
|
void tcg_register_jit(const void *buf, size_t buf_size)
|
2014-03-24 05:04:40 +04:00
|
|
|
{
|
|
|
|
tcg_register_jit_int(buf, buf_size, &debug_frame, sizeof(debug_frame));
|
|
|
|
}
|