10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 52227Sjfrank * Common Development and Distribution License (the "License"). 62227Sjfrank * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*3729Swh94709 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 270Sstevel@tonic-gate 280Sstevel@tonic-gate /* VIS floating point instruction simulator for Sparc FPU simulator. */ 290Sstevel@tonic-gate 300Sstevel@tonic-gate #include <sys/types.h> 310Sstevel@tonic-gate #include <sys/systm.h> 320Sstevel@tonic-gate #include <sys/fpu/fpusystm.h> 330Sstevel@tonic-gate #include <sys/fpu/fpu_simulator.h> 340Sstevel@tonic-gate #include <sys/vis_simulator.h> 350Sstevel@tonic-gate #include <sys/fpu/globals.h> 360Sstevel@tonic-gate #include <sys/privregs.h> 370Sstevel@tonic-gate #include <sys/sun4asi.h> 380Sstevel@tonic-gate #include <sys/machasi.h> 390Sstevel@tonic-gate #include <sys/debug.h> 400Sstevel@tonic-gate #include <sys/cpu_module.h> 410Sstevel@tonic-gate #include <sys/systm.h> 420Sstevel@tonic-gate 430Sstevel@tonic-gate #define FPU_REG_FIELD uint32_reg /* Coordinate with FPU_REGS_TYPE. */ 440Sstevel@tonic-gate #define FPU_DREG_FIELD uint64_reg /* Coordinate with FPU_DREGS_TYPE. */ 450Sstevel@tonic-gate #define FPU_FSR_FIELD uint64_reg /* Coordinate with V9_FPU_FSR_TYPE. */ 460Sstevel@tonic-gate 471246Skalai extern uint_t get_subcc_ccr(uint64_t, uint64_t); 481246Skalai 490Sstevel@tonic-gate static enum ftt_type vis_array(fp_simd_type *, vis_inst_type, struct regs *, 500Sstevel@tonic-gate void *); 510Sstevel@tonic-gate static enum ftt_type vis_alignaddr(fp_simd_type *, vis_inst_type, 520Sstevel@tonic-gate struct regs *, void *, kfpu_t *); 530Sstevel@tonic-gate static enum ftt_type vis_edge(fp_simd_type *, vis_inst_type, struct regs *, 540Sstevel@tonic-gate void *); 550Sstevel@tonic-gate static enum ftt_type vis_faligndata(fp_simd_type *, fp_inst_type, 560Sstevel@tonic-gate kfpu_t *); 570Sstevel@tonic-gate static enum ftt_type vis_bmask(fp_simd_type *, vis_inst_type, struct regs *, 580Sstevel@tonic-gate void *, kfpu_t *); 590Sstevel@tonic-gate static enum ftt_type vis_bshuffle(fp_simd_type *, fp_inst_type, 600Sstevel@tonic-gate kfpu_t *); 610Sstevel@tonic-gate static enum ftt_type vis_siam(fp_simd_type *, vis_inst_type, kfpu_t *); 620Sstevel@tonic-gate static enum ftt_type vis_fcmp(fp_simd_type *, vis_inst_type, struct regs *, 630Sstevel@tonic-gate void *); 640Sstevel@tonic-gate static enum ftt_type vis_fmul(fp_simd_type *, vis_inst_type); 650Sstevel@tonic-gate static enum ftt_type vis_fpixel(fp_simd_type *, vis_inst_type, kfpu_t *); 660Sstevel@tonic-gate static enum ftt_type vis_fpaddsub(fp_simd_type *, vis_inst_type); 670Sstevel@tonic-gate static enum ftt_type vis_pdist(fp_simd_type *, fp_inst_type); 680Sstevel@tonic-gate static enum ftt_type vis_prtl_fst(fp_simd_type *, vis_inst_type, struct regs *, 690Sstevel@tonic-gate void *, uint_t); 700Sstevel@tonic-gate static enum ftt_type vis_short_fls(fp_simd_type *, vis_inst_type, 710Sstevel@tonic-gate struct regs *, void *, uint_t); 720Sstevel@tonic-gate static enum ftt_type vis_blk_fldst(fp_simd_type *, vis_inst_type, 730Sstevel@tonic-gate struct regs *, void *, uint_t); 740Sstevel@tonic-gate 750Sstevel@tonic-gate /* 760Sstevel@tonic-gate * Simulator for VIS instructions with op3 == 0x36 that get fp_disabled 770Sstevel@tonic-gate * traps. 780Sstevel@tonic-gate */ 790Sstevel@tonic-gate enum ftt_type 800Sstevel@tonic-gate vis_fpu_simulator( 810Sstevel@tonic-gate fp_simd_type *pfpsd, /* FPU simulator data. */ 820Sstevel@tonic-gate fp_inst_type pinst, /* FPU instruction to simulate. */ 830Sstevel@tonic-gate struct regs *pregs, /* Pointer to PCB image of registers. */ 840Sstevel@tonic-gate void *prw, /* Pointer to locals and ins. */ 850Sstevel@tonic-gate kfpu_t *fp) /* Need to fp to access gsr reg */ 860Sstevel@tonic-gate { 870Sstevel@tonic-gate uint_t nrs1, nrs2, nrd; /* Register number fields. */ 880Sstevel@tonic-gate uint_t us1, us2, usr; 890Sstevel@tonic-gate uint64_t lus1, lus2, lusr; 900Sstevel@tonic-gate enum ftt_type ftt = ftt_none; 910Sstevel@tonic-gate union { 920Sstevel@tonic-gate vis_inst_type inst; 930Sstevel@tonic-gate fp_inst_type pinst; 940Sstevel@tonic-gate } f; 950Sstevel@tonic-gate 960Sstevel@tonic-gate ASSERT(USERMODE(pregs->r_tstate)); 970Sstevel@tonic-gate nrs1 = pinst.rs1; 980Sstevel@tonic-gate nrs2 = pinst.rs2; 990Sstevel@tonic-gate nrd = pinst.rd; 1000Sstevel@tonic-gate f.pinst = pinst; 1010Sstevel@tonic-gate if ((f.inst.opf & 1) == 0) { /* double precision */ 1020Sstevel@tonic-gate if ((nrs1 & 1) == 1) /* fix register encoding */ 1030Sstevel@tonic-gate nrs1 = (nrs1 & 0x1e) | 0x20; 1040Sstevel@tonic-gate if ((nrs2 & 1) == 1) 1050Sstevel@tonic-gate nrs2 = (nrs2 & 0x1e) | 0x20; 1060Sstevel@tonic-gate if ((nrd & 1) == 1) 1070Sstevel@tonic-gate nrd = (nrd & 0x1e) | 0x20; 1080Sstevel@tonic-gate } 1090Sstevel@tonic-gate 1100Sstevel@tonic-gate switch (f.inst.opf) { 1110Sstevel@tonic-gate /* these instr's do not use fp regs */ 1120Sstevel@tonic-gate case edge8: 1130Sstevel@tonic-gate case edge8l: 1140Sstevel@tonic-gate case edge8n: 1150Sstevel@tonic-gate case edge8ln: 1160Sstevel@tonic-gate case edge16: 1170Sstevel@tonic-gate case edge16l: 1180Sstevel@tonic-gate case edge16n: 1190Sstevel@tonic-gate case edge16ln: 1200Sstevel@tonic-gate case edge32: 1210Sstevel@tonic-gate case edge32l: 1220Sstevel@tonic-gate case edge32n: 1230Sstevel@tonic-gate case edge32ln: 1240Sstevel@tonic-gate ftt = vis_edge(pfpsd, f.inst, pregs, prw); 1250Sstevel@tonic-gate break; 1260Sstevel@tonic-gate case array8: 1270Sstevel@tonic-gate case array16: 1280Sstevel@tonic-gate case array32: 1290Sstevel@tonic-gate ftt = vis_array(pfpsd, f.inst, pregs, prw); 1300Sstevel@tonic-gate break; 1310Sstevel@tonic-gate case alignaddr: 1320Sstevel@tonic-gate case alignaddrl: 1330Sstevel@tonic-gate ftt = vis_alignaddr(pfpsd, f.inst, pregs, prw, fp); 1340Sstevel@tonic-gate break; 1350Sstevel@tonic-gate case bmask: 1360Sstevel@tonic-gate ftt = vis_bmask(pfpsd, f.inst, pregs, prw, fp); 1370Sstevel@tonic-gate break; 1380Sstevel@tonic-gate case fcmple16: 1390Sstevel@tonic-gate case fcmpne16: 1400Sstevel@tonic-gate case fcmpgt16: 1410Sstevel@tonic-gate case fcmpeq16: 1420Sstevel@tonic-gate case fcmple32: 1430Sstevel@tonic-gate case fcmpne32: 1440Sstevel@tonic-gate case fcmpgt32: 1450Sstevel@tonic-gate case fcmpeq32: 1460Sstevel@tonic-gate ftt = vis_fcmp(pfpsd, f.inst, pregs, prw); 1470Sstevel@tonic-gate break; 1480Sstevel@tonic-gate case fmul8x16: 1490Sstevel@tonic-gate case fmul8x16au: 1500Sstevel@tonic-gate case fmul8x16al: 1510Sstevel@tonic-gate case fmul8sux16: 1520Sstevel@tonic-gate case fmul8ulx16: 1530Sstevel@tonic-gate case fmuld8sux16: 1540Sstevel@tonic-gate case fmuld8ulx16: 1550Sstevel@tonic-gate ftt = vis_fmul(pfpsd, f.inst); 1560Sstevel@tonic-gate break; 1570Sstevel@tonic-gate case fpack16: 1580Sstevel@tonic-gate case fpack32: 1590Sstevel@tonic-gate case fpackfix: 1600Sstevel@tonic-gate case fexpand: 1610Sstevel@tonic-gate case fpmerge: 1620Sstevel@tonic-gate ftt = vis_fpixel(pfpsd, f.inst, fp); 1630Sstevel@tonic-gate break; 1640Sstevel@tonic-gate case pdist: 1650Sstevel@tonic-gate ftt = vis_pdist(pfpsd, pinst); 1660Sstevel@tonic-gate break; 1670Sstevel@tonic-gate case faligndata: 1680Sstevel@tonic-gate ftt = vis_faligndata(pfpsd, pinst, fp); 1690Sstevel@tonic-gate break; 1700Sstevel@tonic-gate case bshuffle: 1710Sstevel@tonic-gate ftt = vis_bshuffle(pfpsd, pinst, fp); 1720Sstevel@tonic-gate break; 1730Sstevel@tonic-gate case fpadd16: 1740Sstevel@tonic-gate case fpadd16s: 1750Sstevel@tonic-gate case fpadd32: 1760Sstevel@tonic-gate case fpadd32s: 1770Sstevel@tonic-gate case fpsub16: 1780Sstevel@tonic-gate case fpsub16s: 1790Sstevel@tonic-gate case fpsub32: 1800Sstevel@tonic-gate case fpsub32s: 1810Sstevel@tonic-gate ftt = vis_fpaddsub(pfpsd, f.inst); 1820Sstevel@tonic-gate break; 1830Sstevel@tonic-gate case fzero: 1840Sstevel@tonic-gate lusr = 0; 1850Sstevel@tonic-gate _fp_pack_extword(pfpsd, &lusr, nrd); 1860Sstevel@tonic-gate break; 1870Sstevel@tonic-gate case fzeros: 1880Sstevel@tonic-gate usr = 0; 1890Sstevel@tonic-gate _fp_pack_word(pfpsd, &usr, nrd); 1900Sstevel@tonic-gate break; 1910Sstevel@tonic-gate case fnor: 1920Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lus1, nrs1); 1930Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lus2, nrs2); 1940Sstevel@tonic-gate lusr = ~(lus1 | lus2); 1950Sstevel@tonic-gate _fp_pack_extword(pfpsd, &lusr, nrd); 1960Sstevel@tonic-gate break; 1970Sstevel@tonic-gate case fnors: 1980Sstevel@tonic-gate _fp_unpack_word(pfpsd, &us1, nrs1); 1990Sstevel@tonic-gate _fp_unpack_word(pfpsd, &us2, nrs2); 2000Sstevel@tonic-gate usr = ~(us1 | us2); 2010Sstevel@tonic-gate _fp_pack_word(pfpsd, &usr, nrd); 2020Sstevel@tonic-gate break; 2030Sstevel@tonic-gate case fandnot2: 2040Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lus1, nrs1); 2050Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lus2, nrs2); 2060Sstevel@tonic-gate lusr = (lus1 & ~lus2); 2070Sstevel@tonic-gate _fp_pack_extword(pfpsd, &lusr, nrd); 2080Sstevel@tonic-gate break; 2090Sstevel@tonic-gate case fandnot2s: 2100Sstevel@tonic-gate _fp_unpack_word(pfpsd, &us1, nrs1); 2110Sstevel@tonic-gate _fp_unpack_word(pfpsd, &us2, nrs2); 2120Sstevel@tonic-gate usr = (us1 & ~us2); 2130Sstevel@tonic-gate _fp_pack_word(pfpsd, &usr, nrd); 2140Sstevel@tonic-gate break; 2150Sstevel@tonic-gate case fnot2: 2160Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lus2, nrs2); 2170Sstevel@tonic-gate lusr = ~lus2; 2180Sstevel@tonic-gate _fp_pack_extword(pfpsd, &lusr, nrd); 2190Sstevel@tonic-gate break; 2200Sstevel@tonic-gate case fnot2s: 2210Sstevel@tonic-gate _fp_unpack_word(pfpsd, &us2, nrs2); 2220Sstevel@tonic-gate usr = ~us2; 2230Sstevel@tonic-gate _fp_pack_word(pfpsd, &usr, nrd); 2240Sstevel@tonic-gate break; 2250Sstevel@tonic-gate case fandnot1: 2260Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lus1, nrs1); 2270Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lus2, nrs2); 2280Sstevel@tonic-gate lusr = (~lus1 & lus2); 2290Sstevel@tonic-gate _fp_pack_extword(pfpsd, &lusr, nrd); 2300Sstevel@tonic-gate break; 2310Sstevel@tonic-gate case fandnot1s: 2320Sstevel@tonic-gate _fp_unpack_word(pfpsd, &us1, nrs1); 2330Sstevel@tonic-gate _fp_unpack_word(pfpsd, &us2, nrs2); 2340Sstevel@tonic-gate usr = (~us1 & us2); 2350Sstevel@tonic-gate _fp_pack_word(pfpsd, &usr, nrd); 2360Sstevel@tonic-gate break; 2370Sstevel@tonic-gate case fnot1: 2380Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lus1, nrs1); 2390Sstevel@tonic-gate lusr = ~lus1; 2400Sstevel@tonic-gate _fp_pack_extword(pfpsd, &lusr, nrd); 2410Sstevel@tonic-gate break; 2420Sstevel@tonic-gate case fnot1s: 2430Sstevel@tonic-gate _fp_unpack_word(pfpsd, &us1, nrs1); 2440Sstevel@tonic-gate usr = ~us1; 2450Sstevel@tonic-gate _fp_pack_word(pfpsd, &usr, nrd); 2460Sstevel@tonic-gate break; 2470Sstevel@tonic-gate case fxor: 2480Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lus1, nrs1); 2490Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lus2, nrs2); 2500Sstevel@tonic-gate lusr = (lus1 ^ lus2); 2510Sstevel@tonic-gate _fp_pack_extword(pfpsd, &lusr, nrd); 2520Sstevel@tonic-gate break; 2530Sstevel@tonic-gate case fxors: 2540Sstevel@tonic-gate _fp_unpack_word(pfpsd, &us1, nrs1); 2550Sstevel@tonic-gate _fp_unpack_word(pfpsd, &us2, nrs2); 2560Sstevel@tonic-gate usr = (us1 ^ us2); 2570Sstevel@tonic-gate _fp_pack_word(pfpsd, &usr, nrd); 2580Sstevel@tonic-gate break; 2590Sstevel@tonic-gate case fnand: 2600Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lus1, nrs1); 2610Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lus2, nrs2); 2620Sstevel@tonic-gate lusr = ~(lus1 & lus2); 2630Sstevel@tonic-gate _fp_pack_extword(pfpsd, &lusr, nrd); 2640Sstevel@tonic-gate break; 2650Sstevel@tonic-gate case fnands: 2660Sstevel@tonic-gate _fp_unpack_word(pfpsd, &us1, nrs1); 2670Sstevel@tonic-gate _fp_unpack_word(pfpsd, &us2, nrs2); 2680Sstevel@tonic-gate usr = ~(us1 & us2); 2690Sstevel@tonic-gate _fp_pack_word(pfpsd, &usr, nrd); 2700Sstevel@tonic-gate break; 2710Sstevel@tonic-gate case fand: 2720Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lus1, nrs1); 2730Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lus2, nrs2); 2740Sstevel@tonic-gate lusr = (lus1 & lus2); 2750Sstevel@tonic-gate _fp_pack_extword(pfpsd, &lusr, nrd); 2760Sstevel@tonic-gate break; 2770Sstevel@tonic-gate case fands: 2780Sstevel@tonic-gate _fp_unpack_word(pfpsd, &us1, nrs1); 2790Sstevel@tonic-gate _fp_unpack_word(pfpsd, &us2, nrs2); 2800Sstevel@tonic-gate usr = (us1 & us2); 2810Sstevel@tonic-gate _fp_pack_word(pfpsd, &usr, nrd); 2820Sstevel@tonic-gate break; 2830Sstevel@tonic-gate case fxnor: 2840Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lus1, nrs1); 2850Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lus2, nrs2); 2860Sstevel@tonic-gate lusr = ~(lus1 ^ lus2); 2870Sstevel@tonic-gate _fp_pack_extword(pfpsd, &lusr, nrd); 2880Sstevel@tonic-gate break; 2890Sstevel@tonic-gate case fxnors: 2900Sstevel@tonic-gate _fp_unpack_word(pfpsd, &us1, nrs1); 2910Sstevel@tonic-gate _fp_unpack_word(pfpsd, &us2, nrs2); 2920Sstevel@tonic-gate usr = ~(us1 ^ us2); 2930Sstevel@tonic-gate _fp_pack_word(pfpsd, &usr, nrd); 2940Sstevel@tonic-gate break; 2950Sstevel@tonic-gate case fsrc1: 2960Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lusr, nrs1); 2970Sstevel@tonic-gate _fp_pack_extword(pfpsd, &lusr, nrd); 2980Sstevel@tonic-gate break; 2990Sstevel@tonic-gate case fsrc1s: 3000Sstevel@tonic-gate _fp_unpack_word(pfpsd, &usr, nrs1); 3010Sstevel@tonic-gate _fp_pack_word(pfpsd, &usr, nrd); 3020Sstevel@tonic-gate break; 3030Sstevel@tonic-gate case fornot2: 3040Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lus1, nrs1); 3050Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lus2, nrs2); 3060Sstevel@tonic-gate lusr = (lus1 | ~lus2); 3070Sstevel@tonic-gate _fp_pack_extword(pfpsd, &lusr, nrd); 3080Sstevel@tonic-gate break; 3090Sstevel@tonic-gate case fornot2s: 3100Sstevel@tonic-gate _fp_unpack_word(pfpsd, &us1, nrs1); 3110Sstevel@tonic-gate _fp_unpack_word(pfpsd, &us2, nrs2); 3120Sstevel@tonic-gate usr = (us1 | ~us2); 3130Sstevel@tonic-gate _fp_pack_word(pfpsd, &usr, nrd); 3140Sstevel@tonic-gate break; 3150Sstevel@tonic-gate case fsrc2: 3160Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lusr, nrs2); 3170Sstevel@tonic-gate _fp_pack_extword(pfpsd, &lusr, nrd); 3180Sstevel@tonic-gate break; 3190Sstevel@tonic-gate case fsrc2s: 3200Sstevel@tonic-gate _fp_unpack_word(pfpsd, &usr, nrs2); 3210Sstevel@tonic-gate _fp_pack_word(pfpsd, &usr, nrd); 3220Sstevel@tonic-gate break; 3230Sstevel@tonic-gate case fornot1: 3240Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lus1, nrs1); 3250Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lus2, nrs2); 3260Sstevel@tonic-gate lusr = (~lus1 | lus2); 3270Sstevel@tonic-gate _fp_pack_extword(pfpsd, &lusr, nrd); 3280Sstevel@tonic-gate break; 3290Sstevel@tonic-gate case fornot1s: 3300Sstevel@tonic-gate _fp_unpack_word(pfpsd, &us1, nrs1); 3310Sstevel@tonic-gate _fp_unpack_word(pfpsd, &us2, nrs2); 3320Sstevel@tonic-gate usr = (~us1 | us2); 3330Sstevel@tonic-gate _fp_pack_word(pfpsd, &usr, nrd); 3340Sstevel@tonic-gate break; 3350Sstevel@tonic-gate case for_op: 3360Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lus1, nrs1); 3370Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lus2, nrs2); 3380Sstevel@tonic-gate lusr = (lus1 | lus2); 3390Sstevel@tonic-gate _fp_pack_extword(pfpsd, &lusr, nrd); 3400Sstevel@tonic-gate break; 3410Sstevel@tonic-gate case fors_op: 3420Sstevel@tonic-gate _fp_unpack_word(pfpsd, &us1, nrs1); 3430Sstevel@tonic-gate _fp_unpack_word(pfpsd, &us2, nrs2); 3440Sstevel@tonic-gate usr = (us1 | us2); 3450Sstevel@tonic-gate _fp_pack_word(pfpsd, &usr, nrd); 3460Sstevel@tonic-gate break; 3470Sstevel@tonic-gate case fone: 3480Sstevel@tonic-gate lusr = 0xffffffffffffffff; 3490Sstevel@tonic-gate _fp_pack_extword(pfpsd, &lusr, nrd); 3500Sstevel@tonic-gate break; 3510Sstevel@tonic-gate case fones: 3520Sstevel@tonic-gate usr = 0xffffffffUL; 3530Sstevel@tonic-gate _fp_pack_word(pfpsd, &usr, nrd); 3540Sstevel@tonic-gate break; 3550Sstevel@tonic-gate case siam: 3560Sstevel@tonic-gate ftt = vis_siam(pfpsd, f.inst, fp); 3570Sstevel@tonic-gate break; 3580Sstevel@tonic-gate default: 3590Sstevel@tonic-gate return (ftt_unimplemented); 3600Sstevel@tonic-gate } 3610Sstevel@tonic-gate 3620Sstevel@tonic-gate pregs->r_pc = pregs->r_npc; /* Do not retry emulated instruction. */ 3630Sstevel@tonic-gate pregs->r_npc += 4; 3640Sstevel@tonic-gate return (ftt); 3650Sstevel@tonic-gate } 3660Sstevel@tonic-gate 3670Sstevel@tonic-gate /* 3680Sstevel@tonic-gate * Simulator for edge instructions 3690Sstevel@tonic-gate */ 3700Sstevel@tonic-gate static enum ftt_type 3710Sstevel@tonic-gate vis_edge( 3720Sstevel@tonic-gate fp_simd_type *pfpsd, /* FPU simulator data. */ 3730Sstevel@tonic-gate vis_inst_type inst, /* FPU instruction to simulate. */ 3740Sstevel@tonic-gate struct regs *pregs, /* Pointer to PCB image of registers. */ 3750Sstevel@tonic-gate void *prw) /* Pointer to locals and ins. */ 3760Sstevel@tonic-gate 3770Sstevel@tonic-gate { 3780Sstevel@tonic-gate uint_t nrs1, nrs2, nrd; /* Register number fields. */ 3790Sstevel@tonic-gate enum ftt_type ftt; 3800Sstevel@tonic-gate uint64_t addrl, addrr, mask; 3810Sstevel@tonic-gate uint64_t ah61l, ah61r; /* Higher 61 bits of address */ 3820Sstevel@tonic-gate int al3l, al3r; /* Lower 3 bits of address */ 3830Sstevel@tonic-gate int am32; /* Whether PSTATE.AM == 1 */ 3841246Skalai uint_t ccr; 3850Sstevel@tonic-gate 3860Sstevel@tonic-gate nrs1 = inst.rs1; 3870Sstevel@tonic-gate nrs2 = inst.rs2; 3880Sstevel@tonic-gate nrd = inst.rd; 3890Sstevel@tonic-gate 3900Sstevel@tonic-gate ftt = read_iureg(pfpsd, nrs1, pregs, prw, &addrl); 3910Sstevel@tonic-gate if (ftt != ftt_none) 3920Sstevel@tonic-gate return (ftt); 3930Sstevel@tonic-gate ftt = read_iureg(pfpsd, nrs2, pregs, prw, &addrr); 3940Sstevel@tonic-gate if (ftt != ftt_none) 3950Sstevel@tonic-gate return (ftt); 3960Sstevel@tonic-gate 3970Sstevel@tonic-gate /* Get PSTATE.AM to determine 32-bit vs 64-bit addressing */ 3987Sdf157793 am32 = pregs->r_tstate & TSTATE_AM; 3990Sstevel@tonic-gate if (am32 == 1) { 4007Sdf157793 ah61l = addrl & 0xffffffff8; 4017Sdf157793 ah61r = addrr & 0xffffffff8; 4020Sstevel@tonic-gate } else { 4030Sstevel@tonic-gate ah61l = addrl & ~0x7; 4040Sstevel@tonic-gate ah61r = addrr & ~0x7; 4050Sstevel@tonic-gate } 4060Sstevel@tonic-gate 4070Sstevel@tonic-gate 4080Sstevel@tonic-gate switch (inst.opf) { 4090Sstevel@tonic-gate case edge8: 4100Sstevel@tonic-gate case edge8n: 4110Sstevel@tonic-gate case edge8l: 4120Sstevel@tonic-gate case edge8ln: 4130Sstevel@tonic-gate al3l = addrl & 0x7; 4140Sstevel@tonic-gate switch (inst.opf) { 4150Sstevel@tonic-gate case edge8: 4160Sstevel@tonic-gate case edge8n: 4170Sstevel@tonic-gate if (inst.opf == edge8) { 4180Sstevel@tonic-gate VISINFO_KSTAT(vis_edge8); 4190Sstevel@tonic-gate } else { 4200Sstevel@tonic-gate VISINFO_KSTAT(vis_edge8n); 4210Sstevel@tonic-gate } 4227Sdf157793 mask = 0xff >> al3l; 4230Sstevel@tonic-gate if (ah61l == ah61r) { 4240Sstevel@tonic-gate al3r = addrr & 0x7; 4257Sdf157793 mask &= (0xff << (0x7 - al3r)) & 0xff; 4260Sstevel@tonic-gate } 4270Sstevel@tonic-gate break; 4280Sstevel@tonic-gate case edge8l: 4290Sstevel@tonic-gate case edge8ln: 4300Sstevel@tonic-gate if (inst.opf == edge8l) { 4310Sstevel@tonic-gate VISINFO_KSTAT(vis_edge8l); 4320Sstevel@tonic-gate } else { 4330Sstevel@tonic-gate VISINFO_KSTAT(vis_edge8ln); 4340Sstevel@tonic-gate } 4357Sdf157793 mask = (0xff << al3l) & 0xff; 4360Sstevel@tonic-gate if (ah61l == ah61r) { 4370Sstevel@tonic-gate al3r = addrr & 0x7; 4387Sdf157793 mask &= 0xff >> (0x7 - al3r); 4390Sstevel@tonic-gate } 4400Sstevel@tonic-gate break; 4410Sstevel@tonic-gate } 4420Sstevel@tonic-gate break; 4430Sstevel@tonic-gate case edge16: 4440Sstevel@tonic-gate case edge16l: 4450Sstevel@tonic-gate case edge16n: 4460Sstevel@tonic-gate case edge16ln: 4470Sstevel@tonic-gate al3l = addrl & 0x6; 4487Sdf157793 al3l >>= 0x1; 4490Sstevel@tonic-gate switch (inst.opf) { 4500Sstevel@tonic-gate case edge16: 4510Sstevel@tonic-gate case edge16n: 4520Sstevel@tonic-gate if (inst.opf == edge16) { 4530Sstevel@tonic-gate VISINFO_KSTAT(vis_edge16); 4540Sstevel@tonic-gate 4550Sstevel@tonic-gate } else { 4560Sstevel@tonic-gate VISINFO_KSTAT(vis_edge16n); 4570Sstevel@tonic-gate } 4587Sdf157793 mask = 0xf >> al3l; 4590Sstevel@tonic-gate if (ah61l == ah61r) { 4600Sstevel@tonic-gate al3r = addrr & 0x6; 4617Sdf157793 al3r >>= 0x1; 4627Sdf157793 mask &= (0xf << (0x3 - al3r)) & 0xf; 4630Sstevel@tonic-gate } 4640Sstevel@tonic-gate break; 4650Sstevel@tonic-gate case edge16l: 4660Sstevel@tonic-gate case edge16ln: 4670Sstevel@tonic-gate if (inst.opf == edge16l) { 4680Sstevel@tonic-gate VISINFO_KSTAT(vis_edge16l); 4690Sstevel@tonic-gate 4700Sstevel@tonic-gate } else { 4710Sstevel@tonic-gate VISINFO_KSTAT(vis_edge16ln); 4720Sstevel@tonic-gate } 4737Sdf157793 4747Sdf157793 mask = (0xf << al3l) & 0xf; 4750Sstevel@tonic-gate if (ah61l == ah61r) { 4760Sstevel@tonic-gate al3r = addrr & 0x6; 4777Sdf157793 al3r >>= 0x1; 4787Sdf157793 mask &= 0xf >> (0x3 - al3r); 4790Sstevel@tonic-gate } 4800Sstevel@tonic-gate break; 4810Sstevel@tonic-gate } 4820Sstevel@tonic-gate break; 4830Sstevel@tonic-gate case edge32: 4840Sstevel@tonic-gate case edge32l: 4850Sstevel@tonic-gate case edge32n: 4860Sstevel@tonic-gate case edge32ln: 4870Sstevel@tonic-gate al3l = addrl & 0x4; 4887Sdf157793 al3l >>= 0x2; 4897Sdf157793 4900Sstevel@tonic-gate switch (inst.opf) { 4910Sstevel@tonic-gate case edge32: 4920Sstevel@tonic-gate case edge32n: 4930Sstevel@tonic-gate if (inst.opf == edge32) { 4940Sstevel@tonic-gate VISINFO_KSTAT(vis_edge32); 4950Sstevel@tonic-gate 4960Sstevel@tonic-gate } else { 4970Sstevel@tonic-gate VISINFO_KSTAT(vis_edge32n); 4980Sstevel@tonic-gate } 4997Sdf157793 mask = 0x3 >> al3l; 5000Sstevel@tonic-gate if (ah61l == ah61r) { 5010Sstevel@tonic-gate al3r = addrr & 0x4; 5027Sdf157793 al3r >>= 0x2; 5037Sdf157793 mask &= (0x3 << (0x1 - al3r)) & 0x3; 5040Sstevel@tonic-gate } 5050Sstevel@tonic-gate break; 5060Sstevel@tonic-gate case edge32l: 5070Sstevel@tonic-gate case edge32ln: 5080Sstevel@tonic-gate if (inst.opf == edge32l) { 5090Sstevel@tonic-gate VISINFO_KSTAT(vis_edge32l); 5100Sstevel@tonic-gate 5110Sstevel@tonic-gate } else { 5120Sstevel@tonic-gate VISINFO_KSTAT(vis_edge32ln); 5130Sstevel@tonic-gate } 5147Sdf157793 mask = (0x3 << al3l) & 0x3; 5150Sstevel@tonic-gate if (ah61l == ah61r) { 5160Sstevel@tonic-gate al3r = addrr & 0x4; 5177Sdf157793 al3r >>= 0x2; 5187Sdf157793 mask &= 0x3 >> (0x1 - al3r); 5190Sstevel@tonic-gate } 5200Sstevel@tonic-gate break; 5210Sstevel@tonic-gate } 5220Sstevel@tonic-gate break; 5230Sstevel@tonic-gate } 5247Sdf157793 5250Sstevel@tonic-gate ftt = write_iureg(pfpsd, nrd, pregs, prw, &mask); 5260Sstevel@tonic-gate 5270Sstevel@tonic-gate switch (inst.opf) { 5280Sstevel@tonic-gate case edge8: 5290Sstevel@tonic-gate case edge8l: 5300Sstevel@tonic-gate case edge16: 5310Sstevel@tonic-gate case edge16l: 5320Sstevel@tonic-gate case edge32: 5330Sstevel@tonic-gate case edge32l: 5340Sstevel@tonic-gate 5351246Skalai /* Update flags per SUBcc outcome */ 5361246Skalai pregs->r_tstate &= ~((uint64_t)TSTATE_CCR_MASK 5371246Skalai << TSTATE_CCR_SHIFT); 5381246Skalai ccr = get_subcc_ccr(addrl, addrr); /* get subcc cond. codes */ 5391246Skalai pregs->r_tstate |= ((uint64_t)ccr << TSTATE_CCR_SHIFT); 5401246Skalai 5410Sstevel@tonic-gate break; 5420Sstevel@tonic-gate } 5430Sstevel@tonic-gate return (ftt); 5441246Skalai } 5451246Skalai 5460Sstevel@tonic-gate /* 5470Sstevel@tonic-gate * Simulator for three dimentional array addressing instructions. 5480Sstevel@tonic-gate */ 5490Sstevel@tonic-gate static enum ftt_type 5500Sstevel@tonic-gate vis_array( 5510Sstevel@tonic-gate fp_simd_type *pfpsd, /* FPU simulator data. */ 5520Sstevel@tonic-gate vis_inst_type inst, /* FPU instruction to simulate. */ 5530Sstevel@tonic-gate struct regs *pregs, /* Pointer to PCB image of registers. */ 5540Sstevel@tonic-gate void *prw) /* Pointer to locals and ins. */ 5550Sstevel@tonic-gate 5560Sstevel@tonic-gate { 5570Sstevel@tonic-gate uint_t nrs1, nrs2, nrd; /* Register number fields. */ 5580Sstevel@tonic-gate enum ftt_type ftt; 5590Sstevel@tonic-gate uint64_t laddr, bsize, baddr; 5600Sstevel@tonic-gate uint64_t nbit; 5610Sstevel@tonic-gate int oy, oz; 5620Sstevel@tonic-gate 5630Sstevel@tonic-gate nrs1 = inst.rs1; 5640Sstevel@tonic-gate nrs2 = inst.rs2; 5650Sstevel@tonic-gate nrd = inst.rd; 5660Sstevel@tonic-gate 5670Sstevel@tonic-gate ftt = read_iureg(pfpsd, nrs1, pregs, prw, &laddr); 5680Sstevel@tonic-gate if (ftt != ftt_none) 5690Sstevel@tonic-gate return (ftt); 5700Sstevel@tonic-gate ftt = read_iureg(pfpsd, nrs2, pregs, prw, &bsize); 5710Sstevel@tonic-gate if (ftt != ftt_none) 5720Sstevel@tonic-gate return (ftt); 5730Sstevel@tonic-gate 5740Sstevel@tonic-gate if (bsize > 5) { 5750Sstevel@tonic-gate bsize = 5; 5760Sstevel@tonic-gate } 5770Sstevel@tonic-gate nbit = (1 << bsize) - 1; /* Number of bits for XY<6+n-1:6> */ 5780Sstevel@tonic-gate oy = 17 + bsize; /* Offset of Y<6+n-1:6> */ 5790Sstevel@tonic-gate oz = 17 + 2 * bsize; /* Offset of Z<8:5> */ 5800Sstevel@tonic-gate 5810Sstevel@tonic-gate baddr = 0; 5820Sstevel@tonic-gate baddr |= (laddr >> (11 - 0)) & (0x03 << 0); /* X_integer<1:0> */ 5830Sstevel@tonic-gate baddr |= (laddr >> (33 - 2)) & (0x03 << 2); /* Y_integer<1:0> */ 5840Sstevel@tonic-gate baddr |= (laddr >> (55 - 4)) & (0x01 << 4); /* Z_integer<0> */ 5850Sstevel@tonic-gate baddr |= (laddr >> (13 - 5)) & (0x0f << 5); /* X_integer<5:2> */ 5860Sstevel@tonic-gate baddr |= (laddr >> (35 - 9)) & (0x0f << 9); /* Y_integer<5:2> */ 5870Sstevel@tonic-gate baddr |= (laddr >> (56 - 13)) & (0x0f << 13); /* Z_integer<4:1> */ 5880Sstevel@tonic-gate baddr |= (laddr >> (17 - 17)) & (nbit << 17); /* X_integer<6+n-1:6> */ 5890Sstevel@tonic-gate baddr |= (laddr >> (39 - oy)) & (nbit << oy); /* Y_integer<6+n-1:6> */ 5900Sstevel@tonic-gate baddr |= (laddr >> (60 - oz)) & (0x0f << oz); /* Z_integer<8:5> */ 5910Sstevel@tonic-gate 5920Sstevel@tonic-gate switch (inst.opf) { 5930Sstevel@tonic-gate case array8: 5940Sstevel@tonic-gate VISINFO_KSTAT(vis_array8); 5950Sstevel@tonic-gate break; 5960Sstevel@tonic-gate case array16: 5970Sstevel@tonic-gate VISINFO_KSTAT(vis_array16); 5980Sstevel@tonic-gate baddr <<= 1; 5990Sstevel@tonic-gate break; 6000Sstevel@tonic-gate case array32: 6010Sstevel@tonic-gate VISINFO_KSTAT(vis_array32); 6020Sstevel@tonic-gate baddr <<= 2; 6030Sstevel@tonic-gate break; 6040Sstevel@tonic-gate } 6050Sstevel@tonic-gate 6060Sstevel@tonic-gate ftt = write_iureg(pfpsd, nrd, pregs, prw, &baddr); 6070Sstevel@tonic-gate 6080Sstevel@tonic-gate return (ftt); 6090Sstevel@tonic-gate } 6100Sstevel@tonic-gate 6110Sstevel@tonic-gate /* 6120Sstevel@tonic-gate * Simulator for alignaddr and alignaddrl instructions. 6130Sstevel@tonic-gate */ 6140Sstevel@tonic-gate static enum ftt_type 6150Sstevel@tonic-gate vis_alignaddr( 6160Sstevel@tonic-gate fp_simd_type *pfpsd, /* FPU simulator data. */ 6170Sstevel@tonic-gate vis_inst_type inst, /* FPU instruction to simulate. */ 6180Sstevel@tonic-gate struct regs *pregs, /* Pointer to PCB image of registers. */ 6190Sstevel@tonic-gate void *prw, /* Pointer to locals and ins. */ 6200Sstevel@tonic-gate kfpu_t *fp) /* Need to fp to access gsr reg */ 6210Sstevel@tonic-gate { 6220Sstevel@tonic-gate uint_t nrs1, nrs2, nrd; /* Register number fields. */ 6230Sstevel@tonic-gate enum ftt_type ftt; 6240Sstevel@tonic-gate uint64_t ea, tea, g, r; 6250Sstevel@tonic-gate short s; 6260Sstevel@tonic-gate 6270Sstevel@tonic-gate nrs1 = inst.rs1; 6280Sstevel@tonic-gate nrs2 = inst.rs2; 6290Sstevel@tonic-gate nrd = inst.rd; 6300Sstevel@tonic-gate 6310Sstevel@tonic-gate ftt = read_iureg(pfpsd, nrs1, pregs, prw, &ea); 6320Sstevel@tonic-gate if (ftt != ftt_none) 6330Sstevel@tonic-gate return (ftt); 6340Sstevel@tonic-gate ftt = read_iureg(pfpsd, nrs2, pregs, prw, &tea); 6350Sstevel@tonic-gate if (ftt != ftt_none) 6360Sstevel@tonic-gate return (ftt); 6370Sstevel@tonic-gate ea += tea; 6380Sstevel@tonic-gate r = ea & ~0x7; /* zero least 3 significant bits */ 6390Sstevel@tonic-gate ftt = write_iureg(pfpsd, nrd, pregs, prw, &r); 6400Sstevel@tonic-gate 6410Sstevel@tonic-gate 6427Sdf157793 g = pfpsd->fp_current_read_gsr(fp); 6430Sstevel@tonic-gate g &= ~(GSR_ALIGN_MASK); /* zero the align offset */ 6440Sstevel@tonic-gate r = ea & 0x7; 6450Sstevel@tonic-gate if (inst.opf == alignaddrl) { 6460Sstevel@tonic-gate s = (short)(~r); /* 2's complement for alignaddrl */ 6470Sstevel@tonic-gate if (s < 0) 6480Sstevel@tonic-gate r = (uint64_t)((s + 1) & 0x7); 6490Sstevel@tonic-gate else 6500Sstevel@tonic-gate r = (uint64_t)(s & 0x7); 6510Sstevel@tonic-gate } 6520Sstevel@tonic-gate g |= (r << GSR_ALIGN_SHIFT) & GSR_ALIGN_MASK; 6537Sdf157793 pfpsd->fp_current_write_gsr(g, fp); 6540Sstevel@tonic-gate 6550Sstevel@tonic-gate return (ftt); 6560Sstevel@tonic-gate } 6570Sstevel@tonic-gate 6580Sstevel@tonic-gate /* 6590Sstevel@tonic-gate * Simulator for bmask instruction. 6600Sstevel@tonic-gate */ 6610Sstevel@tonic-gate static enum ftt_type 6620Sstevel@tonic-gate vis_bmask( 6630Sstevel@tonic-gate fp_simd_type *pfpsd, /* FPU simulator data. */ 6640Sstevel@tonic-gate vis_inst_type inst, /* FPU instruction to simulate. */ 6650Sstevel@tonic-gate struct regs *pregs, /* Pointer to PCB image of registers. */ 6660Sstevel@tonic-gate void *prw, /* Pointer to locals and ins. */ 6670Sstevel@tonic-gate kfpu_t *fp) /* Need to fp to access gsr reg */ 6680Sstevel@tonic-gate { 6690Sstevel@tonic-gate uint_t nrs1, nrs2, nrd; /* Register number fields. */ 6700Sstevel@tonic-gate enum ftt_type ftt; 6710Sstevel@tonic-gate uint64_t ea, tea, g; 6720Sstevel@tonic-gate 6730Sstevel@tonic-gate VISINFO_KSTAT(vis_bmask); 6740Sstevel@tonic-gate nrs1 = inst.rs1; 6750Sstevel@tonic-gate nrs2 = inst.rs2; 6760Sstevel@tonic-gate nrd = inst.rd; 6770Sstevel@tonic-gate 6780Sstevel@tonic-gate ftt = read_iureg(pfpsd, nrs1, pregs, prw, &ea); 6790Sstevel@tonic-gate if (ftt != ftt_none) 6800Sstevel@tonic-gate return (ftt); 6810Sstevel@tonic-gate ftt = read_iureg(pfpsd, nrs2, pregs, prw, &tea); 6820Sstevel@tonic-gate if (ftt != ftt_none) 6830Sstevel@tonic-gate return (ftt); 6840Sstevel@tonic-gate ea += tea; 6850Sstevel@tonic-gate ftt = write_iureg(pfpsd, nrd, pregs, prw, &ea); 6860Sstevel@tonic-gate 6877Sdf157793 g = pfpsd->fp_current_read_gsr(fp); 6880Sstevel@tonic-gate g &= ~(GSR_MASK_MASK); /* zero the mask offset */ 6890Sstevel@tonic-gate 6900Sstevel@tonic-gate /* Put the least significant 32 bits of ea in GSR.mask */ 6910Sstevel@tonic-gate g |= (ea << GSR_MASK_SHIFT) & GSR_MASK_MASK; 6927Sdf157793 pfpsd->fp_current_write_gsr(g, fp); 6930Sstevel@tonic-gate return (ftt); 6940Sstevel@tonic-gate } 6950Sstevel@tonic-gate 6960Sstevel@tonic-gate /* 6970Sstevel@tonic-gate * Simulator for fp[add|sub]* instruction. 6980Sstevel@tonic-gate */ 6990Sstevel@tonic-gate static enum ftt_type 7000Sstevel@tonic-gate vis_fpaddsub( 7010Sstevel@tonic-gate fp_simd_type *pfpsd, /* FPU simulator data. */ 7020Sstevel@tonic-gate vis_inst_type inst) /* FPU instruction to simulate. */ 7030Sstevel@tonic-gate { 7040Sstevel@tonic-gate uint_t nrs1, nrs2, nrd; /* Register number fields. */ 7050Sstevel@tonic-gate union { 7060Sstevel@tonic-gate uint64_t ll; 7070Sstevel@tonic-gate uint32_t i[2]; 7080Sstevel@tonic-gate uint16_t s[4]; 7090Sstevel@tonic-gate } lrs1, lrs2, lrd; 7100Sstevel@tonic-gate union { 7110Sstevel@tonic-gate uint32_t i; 7120Sstevel@tonic-gate uint16_t s[2]; 7130Sstevel@tonic-gate } krs1, krs2, krd; 7140Sstevel@tonic-gate int i; 7150Sstevel@tonic-gate 7160Sstevel@tonic-gate nrs1 = inst.rs1; 7170Sstevel@tonic-gate nrs2 = inst.rs2; 7180Sstevel@tonic-gate nrd = inst.rd; 7190Sstevel@tonic-gate if ((inst.opf & 1) == 0) { /* double precision */ 7200Sstevel@tonic-gate if ((nrs1 & 1) == 1) /* fix register encoding */ 7210Sstevel@tonic-gate nrs1 = (nrs1 & 0x1e) | 0x20; 7220Sstevel@tonic-gate if ((nrs2 & 1) == 1) 7230Sstevel@tonic-gate nrs2 = (nrs2 & 0x1e) | 0x20; 7240Sstevel@tonic-gate if ((nrd & 1) == 1) 7250Sstevel@tonic-gate nrd = (nrd & 0x1e) | 0x20; 7260Sstevel@tonic-gate } 7270Sstevel@tonic-gate switch (inst.opf) { 7280Sstevel@tonic-gate case fpadd16: 7290Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lrs1.ll, nrs1); 7300Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lrs2.ll, nrs2); 7310Sstevel@tonic-gate for (i = 0; i <= 3; i++) { 7320Sstevel@tonic-gate lrd.s[i] = lrs1.s[i] + lrs2.s[i]; 7330Sstevel@tonic-gate } 7340Sstevel@tonic-gate _fp_pack_extword(pfpsd, &lrd.ll, nrd); 7350Sstevel@tonic-gate break; 7360Sstevel@tonic-gate case fpadd16s: 7370Sstevel@tonic-gate _fp_unpack_word(pfpsd, &krs1.i, nrs1); 7380Sstevel@tonic-gate _fp_unpack_word(pfpsd, &krs2.i, nrs2); 7390Sstevel@tonic-gate for (i = 0; i <= 1; i++) { 7400Sstevel@tonic-gate krd.s[i] = krs1.s[i] + krs2.s[i]; 7410Sstevel@tonic-gate } 7420Sstevel@tonic-gate _fp_pack_word(pfpsd, &krd.i, nrd); 7430Sstevel@tonic-gate break; 7440Sstevel@tonic-gate case fpadd32: 7450Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lrs1.ll, nrs1); 7460Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lrs2.ll, nrs2); 7470Sstevel@tonic-gate for (i = 0; i <= 1; i++) { 7480Sstevel@tonic-gate lrd.i[i] = lrs1.i[i] + lrs2.i[i]; 7490Sstevel@tonic-gate } 7500Sstevel@tonic-gate _fp_pack_extword(pfpsd, &lrd.ll, nrd); 7510Sstevel@tonic-gate break; 7520Sstevel@tonic-gate case fpadd32s: 7530Sstevel@tonic-gate _fp_unpack_word(pfpsd, &krs1.i, nrs1); 7540Sstevel@tonic-gate _fp_unpack_word(pfpsd, &krs2.i, nrs2); 7550Sstevel@tonic-gate krd.i = krs1.i + krs2.i; 7560Sstevel@tonic-gate _fp_pack_word(pfpsd, &krd.i, nrd); 7570Sstevel@tonic-gate break; 7580Sstevel@tonic-gate case fpsub16: 7590Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lrs1.ll, nrs1); 7600Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lrs2.ll, nrs2); 7610Sstevel@tonic-gate for (i = 0; i <= 3; i++) { 7620Sstevel@tonic-gate lrd.s[i] = lrs1.s[i] - lrs2.s[i]; 7630Sstevel@tonic-gate } 7640Sstevel@tonic-gate _fp_pack_extword(pfpsd, &lrd.ll, nrd); 7650Sstevel@tonic-gate break; 7660Sstevel@tonic-gate case fpsub16s: 7670Sstevel@tonic-gate _fp_unpack_word(pfpsd, &krs1.i, nrs1); 7680Sstevel@tonic-gate _fp_unpack_word(pfpsd, &krs2.i, nrs2); 7690Sstevel@tonic-gate for (i = 0; i <= 1; i++) { 7700Sstevel@tonic-gate krd.s[i] = krs1.s[i] - krs2.s[i]; 7710Sstevel@tonic-gate } 7720Sstevel@tonic-gate _fp_pack_word(pfpsd, &krd.i, nrd); 7730Sstevel@tonic-gate break; 7740Sstevel@tonic-gate case fpsub32: 7750Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lrs1.ll, nrs1); 7760Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lrs2.ll, nrs2); 7770Sstevel@tonic-gate for (i = 0; i <= 1; i++) { 7780Sstevel@tonic-gate lrd.i[i] = lrs1.i[i] - lrs2.i[i]; 7790Sstevel@tonic-gate } 7800Sstevel@tonic-gate _fp_pack_extword(pfpsd, &lrd.ll, nrd); 7810Sstevel@tonic-gate break; 7820Sstevel@tonic-gate case fpsub32s: 7830Sstevel@tonic-gate _fp_unpack_word(pfpsd, &krs1.i, nrs1); 7840Sstevel@tonic-gate _fp_unpack_word(pfpsd, &krs2.i, nrs2); 7850Sstevel@tonic-gate krd.i = krs1.i - krs2.i; 7860Sstevel@tonic-gate _fp_pack_word(pfpsd, &krd.i, nrd); 7870Sstevel@tonic-gate break; 7880Sstevel@tonic-gate } 7890Sstevel@tonic-gate return (ftt_none); 7900Sstevel@tonic-gate } 7910Sstevel@tonic-gate 7920Sstevel@tonic-gate /* 7930Sstevel@tonic-gate * Simulator for fcmp* instruction. 7940Sstevel@tonic-gate */ 7950Sstevel@tonic-gate static enum ftt_type 7960Sstevel@tonic-gate vis_fcmp( 7970Sstevel@tonic-gate fp_simd_type *pfpsd, /* FPU simulator data. */ 7980Sstevel@tonic-gate vis_inst_type inst, /* FPU instruction to simulate. */ 7990Sstevel@tonic-gate struct regs *pregs, /* Pointer to PCB image of registers. */ 8000Sstevel@tonic-gate void *prw) /* Pointer to locals and ins. */ 8010Sstevel@tonic-gate { 8020Sstevel@tonic-gate uint_t nrs1, nrs2, nrd; /* Register number fields. */ 8030Sstevel@tonic-gate union { 8040Sstevel@tonic-gate uint64_t ll; 8050Sstevel@tonic-gate uint32_t i[2]; 8060Sstevel@tonic-gate uint16_t s[4]; 8070Sstevel@tonic-gate } krs1, krs2, krd; 8080Sstevel@tonic-gate enum ftt_type ftt; 8090Sstevel@tonic-gate short sr1, sr2; 8100Sstevel@tonic-gate int i, ir1, ir2; 8110Sstevel@tonic-gate 8120Sstevel@tonic-gate nrs1 = inst.rs1; 8130Sstevel@tonic-gate nrs2 = inst.rs2; 8140Sstevel@tonic-gate nrd = inst.rd; 8150Sstevel@tonic-gate krd.ll = 0; 8160Sstevel@tonic-gate if ((nrs1 & 1) == 1) /* fix register encoding */ 8170Sstevel@tonic-gate nrs1 = (nrs1 & 0x1e) | 0x20; 8180Sstevel@tonic-gate if ((nrs2 & 1) == 1) 8190Sstevel@tonic-gate nrs2 = (nrs2 & 0x1e) | 0x20; 8200Sstevel@tonic-gate 8210Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &krs1.ll, nrs1); 8220Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &krs2.ll, nrs2); 8230Sstevel@tonic-gate switch (inst.opf) { 8240Sstevel@tonic-gate case fcmple16: 8250Sstevel@tonic-gate VISINFO_KSTAT(vis_fcmple16); 8260Sstevel@tonic-gate for (i = 0; i <= 3; i++) { 8270Sstevel@tonic-gate sr1 = (short)krs1.s[i]; 8280Sstevel@tonic-gate sr2 = (short)krs2.s[i]; 8290Sstevel@tonic-gate if (sr1 <= sr2) 8300Sstevel@tonic-gate krd.ll += (0x8 >> i); 8310Sstevel@tonic-gate } 8320Sstevel@tonic-gate break; 8330Sstevel@tonic-gate case fcmpne16: 8340Sstevel@tonic-gate VISINFO_KSTAT(vis_fcmpne16); 8350Sstevel@tonic-gate for (i = 0; i <= 3; i++) { 8360Sstevel@tonic-gate sr1 = (short)krs1.s[i]; 8370Sstevel@tonic-gate sr2 = (short)krs2.s[i]; 8380Sstevel@tonic-gate if (sr1 != sr2) 8390Sstevel@tonic-gate krd.ll += (0x8 >> i); 8400Sstevel@tonic-gate } 8410Sstevel@tonic-gate break; 8420Sstevel@tonic-gate case fcmpgt16: 8430Sstevel@tonic-gate VISINFO_KSTAT(vis_fcmpgt16); 8440Sstevel@tonic-gate for (i = 0; i <= 3; i++) { 8450Sstevel@tonic-gate sr1 = (short)krs1.s[i]; 8460Sstevel@tonic-gate sr2 = (short)krs2.s[i]; 8470Sstevel@tonic-gate if (sr1 > sr2) 8480Sstevel@tonic-gate krd.ll += (0x8 >> i); 8490Sstevel@tonic-gate } 8500Sstevel@tonic-gate break; 8510Sstevel@tonic-gate case fcmpeq16: 8520Sstevel@tonic-gate VISINFO_KSTAT(vis_fcmpeq16); 8530Sstevel@tonic-gate for (i = 0; i <= 3; i++) { 8540Sstevel@tonic-gate sr1 = (short)krs1.s[i]; 8550Sstevel@tonic-gate sr2 = (short)krs2.s[i]; 8560Sstevel@tonic-gate if (sr1 == sr2) 8570Sstevel@tonic-gate krd.ll += (0x8 >> i); 8580Sstevel@tonic-gate } 8590Sstevel@tonic-gate break; 8600Sstevel@tonic-gate case fcmple32: 8610Sstevel@tonic-gate VISINFO_KSTAT(vis_fcmple32); 8620Sstevel@tonic-gate for (i = 0; i <= 1; i++) { 8630Sstevel@tonic-gate ir1 = (int)krs1.i[i]; 8640Sstevel@tonic-gate ir2 = (int)krs2.i[i]; 8650Sstevel@tonic-gate if (ir1 <= ir2) 8660Sstevel@tonic-gate krd.ll += (0x2 >> i); 8670Sstevel@tonic-gate } 8680Sstevel@tonic-gate break; 8690Sstevel@tonic-gate case fcmpne32: 8700Sstevel@tonic-gate VISINFO_KSTAT(vis_fcmpne32); 8710Sstevel@tonic-gate for (i = 0; i <= 1; i++) { 8720Sstevel@tonic-gate ir1 = (int)krs1.i[i]; 8730Sstevel@tonic-gate ir2 = (int)krs2.i[i]; 8740Sstevel@tonic-gate if (ir1 != ir2) 8750Sstevel@tonic-gate krd.ll += (0x2 >> i); 8760Sstevel@tonic-gate } 8770Sstevel@tonic-gate break; 8780Sstevel@tonic-gate case fcmpgt32: 8790Sstevel@tonic-gate VISINFO_KSTAT(vis_fcmpgt32); 8800Sstevel@tonic-gate for (i = 0; i <= 1; i++) { 8810Sstevel@tonic-gate ir1 = (int)krs1.i[i]; 8820Sstevel@tonic-gate ir2 = (int)krs2.i[i]; 8830Sstevel@tonic-gate if (ir1 > ir2) 8840Sstevel@tonic-gate krd.ll += (0x2 >> i); 8850Sstevel@tonic-gate } 8860Sstevel@tonic-gate break; 8870Sstevel@tonic-gate case fcmpeq32: 8880Sstevel@tonic-gate VISINFO_KSTAT(vis_fcmpeq32); 8890Sstevel@tonic-gate for (i = 0; i <= 1; i++) { 8900Sstevel@tonic-gate ir1 = (int)krs1.i[i]; 8910Sstevel@tonic-gate ir2 = (int)krs2.i[i]; 8920Sstevel@tonic-gate if (ir1 == ir2) 8930Sstevel@tonic-gate krd.ll += (0x2 >> i); 8940Sstevel@tonic-gate } 8950Sstevel@tonic-gate break; 8960Sstevel@tonic-gate } 8970Sstevel@tonic-gate ftt = write_iureg(pfpsd, nrd, pregs, prw, &krd.ll); 8980Sstevel@tonic-gate return (ftt); 8990Sstevel@tonic-gate } 9000Sstevel@tonic-gate 9010Sstevel@tonic-gate /* 9020Sstevel@tonic-gate * Simulator for fmul* instruction. 9030Sstevel@tonic-gate */ 9040Sstevel@tonic-gate static enum ftt_type 9050Sstevel@tonic-gate vis_fmul( 9060Sstevel@tonic-gate fp_simd_type *pfpsd, /* FPU simulator data. */ 9070Sstevel@tonic-gate vis_inst_type inst) /* FPU instruction to simulate. */ 9080Sstevel@tonic-gate { 9090Sstevel@tonic-gate uint_t nrs1, nrs2, nrd; /* Register number fields. */ 9100Sstevel@tonic-gate union { 9110Sstevel@tonic-gate uint64_t ll; 9120Sstevel@tonic-gate uint32_t i[2]; 9130Sstevel@tonic-gate uint16_t s[4]; 9140Sstevel@tonic-gate uint8_t c[8]; 9150Sstevel@tonic-gate } lrs1, lrs2, lrd; 9160Sstevel@tonic-gate union { 9170Sstevel@tonic-gate uint32_t i; 9180Sstevel@tonic-gate uint16_t s[2]; 9190Sstevel@tonic-gate uint8_t c[4]; 9200Sstevel@tonic-gate } krs1, krs2, kres; 9210Sstevel@tonic-gate short s1, s2, sres; 9220Sstevel@tonic-gate ushort_t us1; 9230Sstevel@tonic-gate char c1; 9240Sstevel@tonic-gate int i; 9250Sstevel@tonic-gate 9260Sstevel@tonic-gate nrs1 = inst.rs1; 9270Sstevel@tonic-gate nrs2 = inst.rs2; 9280Sstevel@tonic-gate nrd = inst.rd; 9290Sstevel@tonic-gate if ((inst.opf & 1) == 0) { /* double precision */ 9300Sstevel@tonic-gate if ((nrd & 1) == 1) /* fix register encoding */ 9310Sstevel@tonic-gate nrd = (nrd & 0x1e) | 0x20; 9320Sstevel@tonic-gate } 9330Sstevel@tonic-gate 9340Sstevel@tonic-gate switch (inst.opf) { 9350Sstevel@tonic-gate case fmul8x16: 9360Sstevel@tonic-gate VISINFO_KSTAT(vis_fmul8x16); 9370Sstevel@tonic-gate _fp_unpack_word(pfpsd, &krs1.i, nrs1); 9380Sstevel@tonic-gate if ((nrs2 & 1) == 1) 9390Sstevel@tonic-gate nrs2 = (nrs2 & 0x1e) | 0x20; 9400Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lrs2.ll, nrs2); 9410Sstevel@tonic-gate for (i = 0; i <= 3; i++) { 9420Sstevel@tonic-gate us1 = (ushort_t)krs1.c[i]; 9430Sstevel@tonic-gate s2 = (short)lrs2.s[i]; 9440Sstevel@tonic-gate kres.i = us1 * s2; 9450Sstevel@tonic-gate sres = (short)((kres.c[1] << 8) | kres.c[2]); 9460Sstevel@tonic-gate if (kres.c[3] >= 0x80) 9470Sstevel@tonic-gate sres++; 9480Sstevel@tonic-gate lrd.s[i] = sres; 9490Sstevel@tonic-gate } 9500Sstevel@tonic-gate _fp_pack_extword(pfpsd, &lrd.ll, nrd); 9510Sstevel@tonic-gate break; 9520Sstevel@tonic-gate case fmul8x16au: 9530Sstevel@tonic-gate VISINFO_KSTAT(vis_fmul8x16au); 9540Sstevel@tonic-gate _fp_unpack_word(pfpsd, &krs1.i, nrs1); 9550Sstevel@tonic-gate _fp_unpack_word(pfpsd, &krs2.i, nrs2); 9560Sstevel@tonic-gate for (i = 0; i <= 3; i++) { 9570Sstevel@tonic-gate us1 = (ushort_t)krs1.c[i]; 9580Sstevel@tonic-gate s2 = (short)krs2.s[0]; 9590Sstevel@tonic-gate kres.i = us1 * s2; 9600Sstevel@tonic-gate sres = (short)((kres.c[1] << 8) | kres.c[2]); 9610Sstevel@tonic-gate if (kres.c[3] >= 0x80) 9620Sstevel@tonic-gate sres++; 9630Sstevel@tonic-gate lrd.s[i] = sres; 9640Sstevel@tonic-gate } 9650Sstevel@tonic-gate _fp_pack_extword(pfpsd, &lrd.ll, nrd); 9660Sstevel@tonic-gate break; 9670Sstevel@tonic-gate case fmul8x16al: 9680Sstevel@tonic-gate VISINFO_KSTAT(vis_fmul8x16al); 9690Sstevel@tonic-gate _fp_unpack_word(pfpsd, &krs1.i, nrs1); 9700Sstevel@tonic-gate _fp_unpack_word(pfpsd, &krs2.i, nrs2); 9710Sstevel@tonic-gate for (i = 0; i <= 3; i++) { 9720Sstevel@tonic-gate us1 = (ushort_t)krs1.c[i]; 9730Sstevel@tonic-gate s2 = (short)krs2.s[1]; 9740Sstevel@tonic-gate kres.i = us1 * s2; 9750Sstevel@tonic-gate sres = (short)((kres.c[1] << 8) | kres.c[2]); 9760Sstevel@tonic-gate if (kres.c[3] >= 0x80) 9770Sstevel@tonic-gate sres++; 9780Sstevel@tonic-gate lrd.s[i] = sres; 9790Sstevel@tonic-gate } 9800Sstevel@tonic-gate _fp_pack_extword(pfpsd, &lrd.ll, nrd); 9810Sstevel@tonic-gate break; 9820Sstevel@tonic-gate case fmul8sux16: 9830Sstevel@tonic-gate VISINFO_KSTAT(vis_fmul8sux16); 9840Sstevel@tonic-gate if ((nrs1 & 1) == 1) /* fix register encoding */ 9850Sstevel@tonic-gate nrs1 = (nrs1 & 0x1e) | 0x20; 9860Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lrs1.ll, nrs1); 9870Sstevel@tonic-gate if ((nrs2 & 1) == 1) 9880Sstevel@tonic-gate nrs2 = (nrs2 & 0x1e) | 0x20; 9890Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lrs2.ll, nrs2); 9900Sstevel@tonic-gate for (i = 0; i <= 3; i++) { 9910Sstevel@tonic-gate c1 = lrs1.c[(i*2)]; 9920Sstevel@tonic-gate s1 = (short)c1; /* keeps the sign alive */ 9930Sstevel@tonic-gate s2 = (short)lrs2.s[i]; 9940Sstevel@tonic-gate kres.i = s1 * s2; 9950Sstevel@tonic-gate sres = (short)((kres.c[1] << 8) | kres.c[2]); 9960Sstevel@tonic-gate if (kres.c[3] >= 0x80) 9970Sstevel@tonic-gate sres++; 9980Sstevel@tonic-gate if (sres < 0) 9990Sstevel@tonic-gate lrd.s[i] = (sres & 0xFFFF); 10000Sstevel@tonic-gate else 10010Sstevel@tonic-gate lrd.s[i] = sres; 10020Sstevel@tonic-gate } 10030Sstevel@tonic-gate _fp_pack_extword(pfpsd, &lrd.ll, nrd); 10040Sstevel@tonic-gate break; 10050Sstevel@tonic-gate case fmul8ulx16: 10060Sstevel@tonic-gate VISINFO_KSTAT(vis_fmul8ulx16); 10070Sstevel@tonic-gate if ((nrs1 & 1) == 1) /* fix register encoding */ 10080Sstevel@tonic-gate nrs1 = (nrs1 & 0x1e) | 0x20; 10090Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lrs1.ll, nrs1); 10100Sstevel@tonic-gate if ((nrs2 & 1) == 1) 10110Sstevel@tonic-gate nrs2 = (nrs2 & 0x1e) | 0x20; 10120Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lrs2.ll, nrs2); 10130Sstevel@tonic-gate for (i = 0; i <= 3; i++) { 10140Sstevel@tonic-gate us1 = (ushort_t)lrs1.c[(i*2)+1]; 10150Sstevel@tonic-gate s2 = (short)lrs2.s[i]; 10160Sstevel@tonic-gate kres.i = us1 * s2; 10170Sstevel@tonic-gate sres = (short)kres.s[0]; 10180Sstevel@tonic-gate if (kres.s[1] >= 0x8000) 10190Sstevel@tonic-gate sres++; 10200Sstevel@tonic-gate lrd.s[i] = sres; 10210Sstevel@tonic-gate } 10220Sstevel@tonic-gate _fp_pack_extword(pfpsd, &lrd.ll, nrd); 10230Sstevel@tonic-gate break; 10240Sstevel@tonic-gate case fmuld8sux16: 10250Sstevel@tonic-gate VISINFO_KSTAT(vis_fmuld8sux16); 10260Sstevel@tonic-gate _fp_unpack_word(pfpsd, &krs1.i, nrs1); 10270Sstevel@tonic-gate _fp_unpack_word(pfpsd, &krs2.i, nrs2); 10280Sstevel@tonic-gate for (i = 0; i <= 1; i++) { 10290Sstevel@tonic-gate c1 = krs1.c[(i*2)]; 10300Sstevel@tonic-gate s1 = (short)c1; /* keeps the sign alive */ 10310Sstevel@tonic-gate s2 = (short)krs2.s[i]; 10320Sstevel@tonic-gate kres.i = s1 * s2; 10330Sstevel@tonic-gate lrd.i[i] = kres.i << 8; 10340Sstevel@tonic-gate } 10350Sstevel@tonic-gate _fp_pack_extword(pfpsd, &lrd.ll, nrd); 10360Sstevel@tonic-gate break; 10370Sstevel@tonic-gate case fmuld8ulx16: 10380Sstevel@tonic-gate VISINFO_KSTAT(vis_fmuld8ulx16); 10390Sstevel@tonic-gate _fp_unpack_word(pfpsd, &krs1.i, nrs1); 10400Sstevel@tonic-gate _fp_unpack_word(pfpsd, &krs2.i, nrs2); 10410Sstevel@tonic-gate for (i = 0; i <= 1; i++) { 10420Sstevel@tonic-gate us1 = (ushort_t)krs1.c[(i*2)+1]; 10430Sstevel@tonic-gate s2 = (short)krs2.s[i]; 10440Sstevel@tonic-gate lrd.i[i] = us1 * s2; 10450Sstevel@tonic-gate } 10460Sstevel@tonic-gate _fp_pack_extword(pfpsd, &lrd.ll, nrd); 10470Sstevel@tonic-gate break; 10480Sstevel@tonic-gate } 10490Sstevel@tonic-gate return (ftt_none); 10500Sstevel@tonic-gate } 10510Sstevel@tonic-gate 10520Sstevel@tonic-gate /* 10530Sstevel@tonic-gate * Simulator for fpixel formatting instructions. 10540Sstevel@tonic-gate */ 10550Sstevel@tonic-gate static enum ftt_type 10560Sstevel@tonic-gate vis_fpixel( 10570Sstevel@tonic-gate fp_simd_type *pfpsd, /* FPU simulator data. */ 10580Sstevel@tonic-gate vis_inst_type inst, /* FPU instruction to simulate. */ 10590Sstevel@tonic-gate kfpu_t *fp) /* Need to fp to access gsr reg */ 10600Sstevel@tonic-gate { 10610Sstevel@tonic-gate uint_t nrs1, nrs2, nrd; /* Register number fields. */ 10620Sstevel@tonic-gate int i, j, k, sf; 10630Sstevel@tonic-gate union { 10640Sstevel@tonic-gate uint64_t ll; 10650Sstevel@tonic-gate uint32_t i[2]; 10660Sstevel@tonic-gate uint16_t s[4]; 10670Sstevel@tonic-gate uint8_t c[8]; 10680Sstevel@tonic-gate } lrs1, lrs2, lrd; 10690Sstevel@tonic-gate union { 10700Sstevel@tonic-gate uint32_t i; 10710Sstevel@tonic-gate uint16_t s[2]; 10720Sstevel@tonic-gate uint8_t c[4]; 10730Sstevel@tonic-gate } krs1, krs2, krd; 10740Sstevel@tonic-gate uint64_t r; 10750Sstevel@tonic-gate int64_t l, m; 10760Sstevel@tonic-gate short s; 10770Sstevel@tonic-gate uchar_t uc; 10780Sstevel@tonic-gate 10790Sstevel@tonic-gate nrs1 = inst.rs1; 10800Sstevel@tonic-gate nrs2 = inst.rs2; 10810Sstevel@tonic-gate nrd = inst.rd; 10820Sstevel@tonic-gate if ((inst.opf != fpack16) && (inst.opf != fpackfix)) { 10830Sstevel@tonic-gate if ((nrd & 1) == 1) /* fix register encoding */ 10840Sstevel@tonic-gate nrd = (nrd & 0x1e) | 0x20; 10850Sstevel@tonic-gate } 10860Sstevel@tonic-gate 10870Sstevel@tonic-gate switch (inst.opf) { 10880Sstevel@tonic-gate case fpack16: 10890Sstevel@tonic-gate VISINFO_KSTAT(vis_fpack16); 10900Sstevel@tonic-gate if ((nrs2 & 1) == 1) /* fix register encoding */ 10910Sstevel@tonic-gate nrs2 = (nrs2 & 0x1e) | 0x20; 10920Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lrs2.ll, nrs2); 10937Sdf157793 r = pfpsd->fp_current_read_gsr(fp); 10940Sstevel@tonic-gate /* fpack16 ignores GSR.scale msb */ 10950Sstevel@tonic-gate sf = (int)(GSR_SCALE(r) & 0xf); 10960Sstevel@tonic-gate for (i = 0; i <= 3; i++) { 10970Sstevel@tonic-gate s = (short)lrs2.s[i]; /* preserve the sign */ 10980Sstevel@tonic-gate j = ((int)s << sf); 10990Sstevel@tonic-gate k = j >> 7; 11000Sstevel@tonic-gate if (k < 0) { 11010Sstevel@tonic-gate uc = 0; 11020Sstevel@tonic-gate } else if (k > 255) { 11030Sstevel@tonic-gate uc = 255; 11040Sstevel@tonic-gate } else { 11050Sstevel@tonic-gate uc = (uchar_t)k; 11060Sstevel@tonic-gate } 11070Sstevel@tonic-gate krd.c[i] = uc; 11080Sstevel@tonic-gate } 11090Sstevel@tonic-gate _fp_pack_word(pfpsd, &krd.i, nrd); 11100Sstevel@tonic-gate break; 11110Sstevel@tonic-gate case fpack32: 11120Sstevel@tonic-gate VISINFO_KSTAT(vis_fpack32); 11130Sstevel@tonic-gate if ((nrs1 & 1) == 1) /* fix register encoding */ 11140Sstevel@tonic-gate nrs1 = (nrs1 & 0x1e) | 0x20; 11150Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lrs1.ll, nrs1); 11160Sstevel@tonic-gate if ((nrs2 & 1) == 1) 11170Sstevel@tonic-gate nrs2 = (nrs2 & 0x1e) | 0x20; 11180Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lrs2.ll, nrs2); 11190Sstevel@tonic-gate 11207Sdf157793 r = pfpsd->fp_current_read_gsr(fp); 11210Sstevel@tonic-gate sf = (int)GSR_SCALE(r); 11220Sstevel@tonic-gate lrd.ll = lrs1.ll << 8; 11230Sstevel@tonic-gate for (i = 0, k = 3; i <= 1; i++, k += 4) { 11240Sstevel@tonic-gate j = (int)lrs2.i[i]; /* preserve the sign */ 11250Sstevel@tonic-gate l = ((int64_t)j << sf); 11260Sstevel@tonic-gate m = l >> 23; 11270Sstevel@tonic-gate if (m < 0) { 11280Sstevel@tonic-gate uc = 0; 11290Sstevel@tonic-gate } else if (m > 255) { 11300Sstevel@tonic-gate uc = 255; 11310Sstevel@tonic-gate } else { 11320Sstevel@tonic-gate uc = (uchar_t)m; 11330Sstevel@tonic-gate } 11340Sstevel@tonic-gate lrd.c[k] = uc; 11350Sstevel@tonic-gate } 11360Sstevel@tonic-gate _fp_pack_extword(pfpsd, &lrd.ll, nrd); 11370Sstevel@tonic-gate break; 11380Sstevel@tonic-gate case fpackfix: 11390Sstevel@tonic-gate VISINFO_KSTAT(vis_fpackfix); 11400Sstevel@tonic-gate if ((nrs2 & 1) == 1) 11410Sstevel@tonic-gate nrs2 = (nrs2 & 0x1e) | 0x20; 11420Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lrs2.ll, nrs2); 11430Sstevel@tonic-gate 11447Sdf157793 r = pfpsd->fp_current_read_gsr(fp); 11450Sstevel@tonic-gate sf = (int)GSR_SCALE(r); 11460Sstevel@tonic-gate for (i = 0; i <= 1; i++) { 11470Sstevel@tonic-gate j = (int)lrs2.i[i]; /* preserve the sign */ 11480Sstevel@tonic-gate l = ((int64_t)j << sf); 11490Sstevel@tonic-gate m = l >> 16; 11500Sstevel@tonic-gate if (m < -32768) { 11510Sstevel@tonic-gate s = -32768; 11520Sstevel@tonic-gate } else if (m > 32767) { 11530Sstevel@tonic-gate s = 32767; 11540Sstevel@tonic-gate } else { 11550Sstevel@tonic-gate s = (short)m; 11560Sstevel@tonic-gate } 11570Sstevel@tonic-gate krd.s[i] = s; 11580Sstevel@tonic-gate } 11590Sstevel@tonic-gate _fp_pack_word(pfpsd, &krd.i, nrd); 11600Sstevel@tonic-gate break; 11610Sstevel@tonic-gate case fexpand: 11620Sstevel@tonic-gate VISINFO_KSTAT(vis_fexpand); 11630Sstevel@tonic-gate _fp_unpack_word(pfpsd, &krs2.i, nrs2); 11640Sstevel@tonic-gate for (i = 0; i <= 3; i++) { 11650Sstevel@tonic-gate uc = krs2.c[i]; 11660Sstevel@tonic-gate lrd.s[i] = (ushort_t)(uc << 4); 11670Sstevel@tonic-gate } 11680Sstevel@tonic-gate _fp_pack_extword(pfpsd, &lrd.ll, nrd); 11690Sstevel@tonic-gate break; 11700Sstevel@tonic-gate case fpmerge: 11710Sstevel@tonic-gate VISINFO_KSTAT(vis_fpmerge); 11720Sstevel@tonic-gate _fp_unpack_word(pfpsd, &krs1.i, nrs1); 11730Sstevel@tonic-gate _fp_unpack_word(pfpsd, &krs2.i, nrs2); 11740Sstevel@tonic-gate for (i = 0, j = 0; i <= 3; i++, j += 2) { 11750Sstevel@tonic-gate lrd.c[j] = krs1.c[i]; 11760Sstevel@tonic-gate lrd.c[j+1] = krs2.c[i]; 11770Sstevel@tonic-gate } 11780Sstevel@tonic-gate _fp_pack_extword(pfpsd, &lrd.ll, nrd); 11790Sstevel@tonic-gate break; 11800Sstevel@tonic-gate } 11810Sstevel@tonic-gate return (ftt_none); 11820Sstevel@tonic-gate } 11830Sstevel@tonic-gate 11840Sstevel@tonic-gate /* 11850Sstevel@tonic-gate * Simulator for pdist instruction. 11860Sstevel@tonic-gate */ 11870Sstevel@tonic-gate enum ftt_type 11880Sstevel@tonic-gate vis_pdist( 11890Sstevel@tonic-gate fp_simd_type *pfpsd, /* FPU simulator data. */ 11900Sstevel@tonic-gate fp_inst_type pinst) /* FPU instruction to simulate. */ 11910Sstevel@tonic-gate { 11920Sstevel@tonic-gate uint_t nrs1, nrs2, nrd; /* Register number fields. */ 11930Sstevel@tonic-gate int i; 11940Sstevel@tonic-gate short s; 11950Sstevel@tonic-gate union { 11960Sstevel@tonic-gate uint64_t ll; 11970Sstevel@tonic-gate uint8_t c[8]; 11980Sstevel@tonic-gate } lrs1, lrs2, lrd; 11990Sstevel@tonic-gate 12000Sstevel@tonic-gate nrs1 = pinst.rs1; 12010Sstevel@tonic-gate nrs2 = pinst.rs2; 12020Sstevel@tonic-gate nrd = pinst.rd; 12030Sstevel@tonic-gate VISINFO_KSTAT(vis_pdist); 12040Sstevel@tonic-gate if ((nrs1 & 1) == 1) /* fix register encoding */ 12050Sstevel@tonic-gate nrs1 = (nrs1 & 0x1e) | 0x20; 12060Sstevel@tonic-gate if ((nrs2 & 1) == 1) 12070Sstevel@tonic-gate nrs2 = (nrs2 & 0x1e) | 0x20; 12080Sstevel@tonic-gate if ((nrd & 1) == 1) 12090Sstevel@tonic-gate nrd = (nrd & 0x1e) | 0x20; 12100Sstevel@tonic-gate 12110Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lrs1.ll, nrs1); 12120Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lrs2.ll, nrs2); 12130Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lrd.ll, nrd); 12140Sstevel@tonic-gate 12150Sstevel@tonic-gate for (i = 0; i <= 7; i++) { 12160Sstevel@tonic-gate s = (short)(lrs1.c[i] - lrs2.c[i]); 12170Sstevel@tonic-gate if (s < 0) 12180Sstevel@tonic-gate s = ~s + 1; 12190Sstevel@tonic-gate lrd.ll += s; 12200Sstevel@tonic-gate } 12210Sstevel@tonic-gate 12220Sstevel@tonic-gate _fp_pack_extword(pfpsd, &lrd.ll, nrd); 12230Sstevel@tonic-gate return (ftt_none); 12240Sstevel@tonic-gate } 12250Sstevel@tonic-gate 12260Sstevel@tonic-gate /* 12270Sstevel@tonic-gate * Simulator for faligndata instruction. 12280Sstevel@tonic-gate */ 12290Sstevel@tonic-gate static enum ftt_type 12300Sstevel@tonic-gate vis_faligndata( 12310Sstevel@tonic-gate fp_simd_type *pfpsd, /* FPU simulator data. */ 12320Sstevel@tonic-gate fp_inst_type pinst, /* FPU instruction to simulate. */ 12330Sstevel@tonic-gate kfpu_t *fp) /* Need to fp to access gsr reg */ 12340Sstevel@tonic-gate { 12350Sstevel@tonic-gate uint_t nrs1, nrs2, nrd; /* Register number fields. */ 12360Sstevel@tonic-gate int i, j, k, ao; 12370Sstevel@tonic-gate union { 12380Sstevel@tonic-gate uint64_t ll; 12390Sstevel@tonic-gate uint8_t c[8]; 12400Sstevel@tonic-gate } lrs1, lrs2, lrd; 12410Sstevel@tonic-gate uint64_t r; 12420Sstevel@tonic-gate 12430Sstevel@tonic-gate nrs1 = pinst.rs1; 12440Sstevel@tonic-gate nrs2 = pinst.rs2; 12450Sstevel@tonic-gate nrd = pinst.rd; 12460Sstevel@tonic-gate if ((nrs1 & 1) == 1) /* fix register encoding */ 12470Sstevel@tonic-gate nrs1 = (nrs1 & 0x1e) | 0x20; 12480Sstevel@tonic-gate if ((nrs2 & 1) == 1) 12490Sstevel@tonic-gate nrs2 = (nrs2 & 0x1e) | 0x20; 12500Sstevel@tonic-gate if ((nrd & 1) == 1) 12510Sstevel@tonic-gate nrd = (nrd & 0x1e) | 0x20; 12520Sstevel@tonic-gate 12530Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lrs1.ll, nrs1); 12540Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lrs2.ll, nrs2); 12550Sstevel@tonic-gate 12567Sdf157793 r = pfpsd->fp_current_read_gsr(fp); 12570Sstevel@tonic-gate ao = (int)GSR_ALIGN(r); 12580Sstevel@tonic-gate 12590Sstevel@tonic-gate for (i = 0, j = ao, k = 0; i <= 7; i++) 12600Sstevel@tonic-gate if (j <= 7) { 12610Sstevel@tonic-gate lrd.c[i] = lrs1.c[j++]; 12620Sstevel@tonic-gate } else { 12630Sstevel@tonic-gate lrd.c[i] = lrs2.c[k++]; 12640Sstevel@tonic-gate } 12650Sstevel@tonic-gate _fp_pack_extword(pfpsd, &lrd.ll, nrd); 12660Sstevel@tonic-gate 12670Sstevel@tonic-gate return (ftt_none); 12680Sstevel@tonic-gate } 12690Sstevel@tonic-gate 12700Sstevel@tonic-gate /* 12710Sstevel@tonic-gate * Simulator for bshuffle instruction. 12720Sstevel@tonic-gate */ 12730Sstevel@tonic-gate static enum ftt_type 12740Sstevel@tonic-gate vis_bshuffle( 12750Sstevel@tonic-gate fp_simd_type *pfpsd, /* FPU simulator data. */ 12760Sstevel@tonic-gate fp_inst_type pinst, /* FPU instruction to simulate. */ 12770Sstevel@tonic-gate kfpu_t *fp) /* Need to fp to access gsr reg */ 12780Sstevel@tonic-gate { 12790Sstevel@tonic-gate uint_t nrs1, nrs2, nrd; /* Register number fields. */ 12800Sstevel@tonic-gate int i, j, ao; 12810Sstevel@tonic-gate union { 12820Sstevel@tonic-gate uint64_t ll; 12830Sstevel@tonic-gate uint8_t c[8]; 12840Sstevel@tonic-gate } lrs1, lrs2, lrd; 12850Sstevel@tonic-gate uint64_t r; 12860Sstevel@tonic-gate 12870Sstevel@tonic-gate VISINFO_KSTAT(vis_bshuffle); 12880Sstevel@tonic-gate nrs1 = pinst.rs1; 12890Sstevel@tonic-gate nrs2 = pinst.rs2; 12900Sstevel@tonic-gate nrd = pinst.rd; 12910Sstevel@tonic-gate if ((nrs1 & 1) == 1) /* fix register encoding */ 12920Sstevel@tonic-gate nrs1 = (nrs1 & 0x1e) | 0x20; 12930Sstevel@tonic-gate if ((nrs2 & 1) == 1) 12940Sstevel@tonic-gate nrs2 = (nrs2 & 0x1e) | 0x20; 12950Sstevel@tonic-gate if ((nrd & 1) == 1) 12960Sstevel@tonic-gate nrd = (nrd & 0x1e) | 0x20; 12970Sstevel@tonic-gate 12980Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lrs1.ll, nrs1); 12990Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lrs2.ll, nrs2); 13000Sstevel@tonic-gate 13017Sdf157793 r = pfpsd->fp_current_read_gsr(fp); 13020Sstevel@tonic-gate ao = (int)GSR_MASK(r); 13030Sstevel@tonic-gate 13040Sstevel@tonic-gate /* 13050Sstevel@tonic-gate * BSHUFFLE Destination Byte Selection 13060Sstevel@tonic-gate * rd Byte Source 13070Sstevel@tonic-gate * 0 rs byte[GSR.mask<31..28>] 13080Sstevel@tonic-gate * 1 rs byte[GSR.mask<27..24>] 13090Sstevel@tonic-gate * 2 rs byte[GSR.mask<23..20>] 13100Sstevel@tonic-gate * 3 rs byte[GSR.mask<19..16>] 13110Sstevel@tonic-gate * 4 rs byte[GSR.mask<15..12>] 13120Sstevel@tonic-gate * 5 rs byte[GSR.mask<11..8>] 13130Sstevel@tonic-gate * 6 rs byte[GSR.mask<7..4>] 13140Sstevel@tonic-gate * 7 rs byte[GSR.mask<3..0>] 13150Sstevel@tonic-gate * P.S. rs1 is the upper half and rs2 is the lower half 13160Sstevel@tonic-gate * Bytes in the source value are numbered from most to 13170Sstevel@tonic-gate * least significant 13180Sstevel@tonic-gate */ 13190Sstevel@tonic-gate for (i = 7; i >= 0; i--, ao = (ao >> 4)) { 13200Sstevel@tonic-gate j = ao & 0xf; /* get byte number */ 13210Sstevel@tonic-gate if (j < 8) { 13220Sstevel@tonic-gate lrd.c[i] = lrs1.c[j]; 13230Sstevel@tonic-gate } else { 13240Sstevel@tonic-gate lrd.c[i] = lrs2.c[j - 8]; 13250Sstevel@tonic-gate } 13260Sstevel@tonic-gate } 13270Sstevel@tonic-gate _fp_pack_extword(pfpsd, &lrd.ll, nrd); 13280Sstevel@tonic-gate 13290Sstevel@tonic-gate return (ftt_none); 13300Sstevel@tonic-gate } 13310Sstevel@tonic-gate 13320Sstevel@tonic-gate /* 13330Sstevel@tonic-gate * Simulator for siam instruction. 13340Sstevel@tonic-gate */ 13350Sstevel@tonic-gate static enum ftt_type 13360Sstevel@tonic-gate vis_siam( 13370Sstevel@tonic-gate fp_simd_type *pfpsd, /* FPU simulator data. */ 13380Sstevel@tonic-gate vis_inst_type inst, /* FPU instruction to simulate. */ 13390Sstevel@tonic-gate kfpu_t *fp) /* Need to fp to access gsr reg */ 13400Sstevel@tonic-gate { 13410Sstevel@tonic-gate uint_t nrs2; /* Register number fields. */ 13420Sstevel@tonic-gate uint64_t g, r; 13430Sstevel@tonic-gate nrs2 = inst.rs2; 13440Sstevel@tonic-gate 13457Sdf157793 g = pfpsd->fp_current_read_gsr(fp); 13460Sstevel@tonic-gate g &= ~(GSR_IM_IRND_MASK); /* zero the IM and IRND fields */ 13470Sstevel@tonic-gate r = nrs2 & 0x7; /* get mode(3 bit) */ 13480Sstevel@tonic-gate g |= (r << GSR_IRND_SHIFT); 13497Sdf157793 pfpsd->fp_current_write_gsr(g, fp); 13500Sstevel@tonic-gate return (ftt_none); 13510Sstevel@tonic-gate } 13520Sstevel@tonic-gate 13530Sstevel@tonic-gate /* 13540Sstevel@tonic-gate * Simulator for VIS loads and stores between floating-point unit and memory. 13550Sstevel@tonic-gate */ 13560Sstevel@tonic-gate enum ftt_type 13570Sstevel@tonic-gate vis_fldst( 13580Sstevel@tonic-gate fp_simd_type *pfpsd, /* FPU simulator data. */ 13590Sstevel@tonic-gate fp_inst_type pinst, /* FPU instruction to simulate. */ 13600Sstevel@tonic-gate struct regs *pregs, /* Pointer to PCB image of registers. */ 13610Sstevel@tonic-gate void *prw, /* Pointer to locals and ins. */ 13620Sstevel@tonic-gate uint_t asi) /* asi to emulate! */ 13630Sstevel@tonic-gate { 13640Sstevel@tonic-gate union { 13650Sstevel@tonic-gate vis_inst_type inst; 13660Sstevel@tonic-gate fp_inst_type pinst; 13670Sstevel@tonic-gate } i; 13680Sstevel@tonic-gate 13690Sstevel@tonic-gate ASSERT(USERMODE(pregs->r_tstate)); 13700Sstevel@tonic-gate i.pinst = pinst; 13710Sstevel@tonic-gate switch (asi) { 13720Sstevel@tonic-gate case ASI_PST8_P: 13730Sstevel@tonic-gate case ASI_PST8_S: 13740Sstevel@tonic-gate case ASI_PST16_P: 13750Sstevel@tonic-gate case ASI_PST16_S: 13760Sstevel@tonic-gate case ASI_PST32_P: 13770Sstevel@tonic-gate case ASI_PST32_S: 13780Sstevel@tonic-gate case ASI_PST8_PL: 13790Sstevel@tonic-gate case ASI_PST8_SL: 13800Sstevel@tonic-gate case ASI_PST16_PL: 13810Sstevel@tonic-gate case ASI_PST16_SL: 13820Sstevel@tonic-gate case ASI_PST32_PL: 13830Sstevel@tonic-gate case ASI_PST32_SL: 13840Sstevel@tonic-gate return (vis_prtl_fst(pfpsd, i.inst, pregs, 13850Sstevel@tonic-gate prw, asi)); 13860Sstevel@tonic-gate case ASI_FL8_P: 13870Sstevel@tonic-gate case ASI_FL8_S: 13880Sstevel@tonic-gate case ASI_FL8_PL: 13890Sstevel@tonic-gate case ASI_FL8_SL: 13900Sstevel@tonic-gate case ASI_FL16_P: 13910Sstevel@tonic-gate case ASI_FL16_S: 13920Sstevel@tonic-gate case ASI_FL16_PL: 13930Sstevel@tonic-gate case ASI_FL16_SL: 13940Sstevel@tonic-gate return (vis_short_fls(pfpsd, i.inst, pregs, 13950Sstevel@tonic-gate prw, asi)); 13960Sstevel@tonic-gate case ASI_BLK_AIUP: 13970Sstevel@tonic-gate case ASI_BLK_AIUS: 13980Sstevel@tonic-gate case ASI_BLK_AIUPL: 13990Sstevel@tonic-gate case ASI_BLK_AIUSL: 14000Sstevel@tonic-gate case ASI_BLK_P: 14010Sstevel@tonic-gate case ASI_BLK_S: 14020Sstevel@tonic-gate case ASI_BLK_PL: 14030Sstevel@tonic-gate case ASI_BLK_SL: 14040Sstevel@tonic-gate case ASI_BLK_COMMIT_P: 14050Sstevel@tonic-gate case ASI_BLK_COMMIT_S: 14060Sstevel@tonic-gate return (vis_blk_fldst(pfpsd, i.inst, pregs, 14070Sstevel@tonic-gate prw, asi)); 14080Sstevel@tonic-gate default: 14090Sstevel@tonic-gate return (ftt_unimplemented); 14100Sstevel@tonic-gate } 14110Sstevel@tonic-gate } 14120Sstevel@tonic-gate 14130Sstevel@tonic-gate /* 14140Sstevel@tonic-gate * Simulator for partial stores between floating-point unit and memory. 14150Sstevel@tonic-gate */ 14160Sstevel@tonic-gate static enum ftt_type 14170Sstevel@tonic-gate vis_prtl_fst( 14180Sstevel@tonic-gate fp_simd_type *pfpsd, /* FPU simulator data. */ 14190Sstevel@tonic-gate vis_inst_type inst, /* ISE instruction to simulate. */ 14200Sstevel@tonic-gate struct regs *pregs, /* Pointer to PCB image of registers. */ 14210Sstevel@tonic-gate void *prw, /* Pointer to locals and ins. */ 14220Sstevel@tonic-gate uint_t asi) /* asi to emulate! */ 14230Sstevel@tonic-gate { 14240Sstevel@tonic-gate uint_t nrs1, nrs2, nrd; /* Register number fields. */ 14250Sstevel@tonic-gate uint_t opf, msk; 14260Sstevel@tonic-gate int h, i, j; 14270Sstevel@tonic-gate uint64_t ea, tmsk; 14280Sstevel@tonic-gate union { 14290Sstevel@tonic-gate freg_type f; 14300Sstevel@tonic-gate uint64_t ll; 14310Sstevel@tonic-gate uint32_t i[2]; 14320Sstevel@tonic-gate uint16_t s[4]; 14330Sstevel@tonic-gate uint8_t c[8]; 14340Sstevel@tonic-gate } k, l, res; 14350Sstevel@tonic-gate enum ftt_type ftt; 14360Sstevel@tonic-gate 14370Sstevel@tonic-gate nrs1 = inst.rs1; 14380Sstevel@tonic-gate nrs2 = inst.rs2; 14390Sstevel@tonic-gate nrd = inst.rd; 14400Sstevel@tonic-gate if ((nrd & 1) == 1) /* fix register encoding */ 14410Sstevel@tonic-gate nrd = (nrd & 0x1e) | 0x20; 14420Sstevel@tonic-gate opf = inst.opf; 14430Sstevel@tonic-gate res.ll = 0; 14440Sstevel@tonic-gate if ((opf & 0x100) == 0) { /* effective address = rs1 */ 14450Sstevel@tonic-gate ftt = read_iureg(pfpsd, nrs1, pregs, prw, &ea); 14460Sstevel@tonic-gate if (ftt != ftt_none) 14470Sstevel@tonic-gate return (ftt); 14480Sstevel@tonic-gate ftt = read_iureg(pfpsd, nrs2, pregs, prw, &tmsk); 14490Sstevel@tonic-gate if (ftt != ftt_none) 14500Sstevel@tonic-gate return (ftt); 14510Sstevel@tonic-gate msk = (uint_t)tmsk; 14520Sstevel@tonic-gate } else { 14530Sstevel@tonic-gate pfpsd->fp_trapaddr = (caddr_t)pregs->r_pc; 14540Sstevel@tonic-gate return (ftt_unimplemented); 14550Sstevel@tonic-gate } 14560Sstevel@tonic-gate 14570Sstevel@tonic-gate pfpsd->fp_trapaddr = (caddr_t)ea; /* setup bad addr in case we trap */ 14580Sstevel@tonic-gate if ((ea & 0x3) != 0) 14590Sstevel@tonic-gate return (ftt_alignment); /* Require 32 bit-alignment. */ 14600Sstevel@tonic-gate 14610Sstevel@tonic-gate switch (asi) { 14620Sstevel@tonic-gate case ASI_PST8_P: 14630Sstevel@tonic-gate case ASI_PST8_S: 14640Sstevel@tonic-gate ftt = _fp_read_extword((uint64_t *)ea, &l.ll, pfpsd); 14650Sstevel@tonic-gate if (ftt != ftt_none) 14660Sstevel@tonic-gate return (ftt); 14670Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &k.f.FPU_DREG_FIELD, nrd); 14680Sstevel@tonic-gate for (i = 0, j = 0x80; i <= 7; i++, j >>= 1) { 14690Sstevel@tonic-gate if ((msk & j) == j) 14700Sstevel@tonic-gate res.c[i] = k.c[i]; 14710Sstevel@tonic-gate else 14720Sstevel@tonic-gate res.c[i] = l.c[i]; 14730Sstevel@tonic-gate } 14740Sstevel@tonic-gate ftt = _fp_write_extword((uint64_t *)ea, res.ll, pfpsd); 14750Sstevel@tonic-gate if (ftt != ftt_none) 14760Sstevel@tonic-gate return (ftt); 14770Sstevel@tonic-gate break; 14780Sstevel@tonic-gate case ASI_PST8_PL: /* little-endian */ 14790Sstevel@tonic-gate case ASI_PST8_SL: 14800Sstevel@tonic-gate ftt = _fp_read_extword((uint64_t *)ea, &l.ll, pfpsd); 14810Sstevel@tonic-gate if (ftt != ftt_none) 14820Sstevel@tonic-gate return (ftt); 14830Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &k.f.FPU_DREG_FIELD, nrd); 14842227Sjfrank for (h = 7, i = 0, j = 1; i <= 7; h--, i++, j <<= 1) { 14850Sstevel@tonic-gate if ((msk & j) == j) 14862227Sjfrank res.c[i] = k.c[h]; 14870Sstevel@tonic-gate else 14882227Sjfrank res.c[i] = l.c[i]; 14890Sstevel@tonic-gate } 14900Sstevel@tonic-gate ftt = _fp_write_extword((uint64_t *)ea, res.ll, pfpsd); 14910Sstevel@tonic-gate if (ftt != ftt_none) 14920Sstevel@tonic-gate return (ftt); 14930Sstevel@tonic-gate break; 14940Sstevel@tonic-gate case ASI_PST16_P: 14950Sstevel@tonic-gate case ASI_PST16_S: 14960Sstevel@tonic-gate ftt = _fp_read_extword((uint64_t *)ea, &l.ll, pfpsd); 14970Sstevel@tonic-gate if (ftt != ftt_none) 14980Sstevel@tonic-gate return (ftt); 14990Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &k.f.FPU_DREG_FIELD, nrd); 15000Sstevel@tonic-gate for (i = 0, j = 0x8; i <= 3; i++, j >>= 1) { 15010Sstevel@tonic-gate if ((msk & j) == j) 15020Sstevel@tonic-gate res.s[i] = k.s[i]; 15030Sstevel@tonic-gate else 15040Sstevel@tonic-gate res.s[i] = l.s[i]; 15050Sstevel@tonic-gate } 15060Sstevel@tonic-gate ftt = _fp_write_extword((uint64_t *)ea, res.ll, pfpsd); 15070Sstevel@tonic-gate if (ftt != ftt_none) 15080Sstevel@tonic-gate return (ftt); 15090Sstevel@tonic-gate break; 15100Sstevel@tonic-gate case ASI_PST16_PL: 15110Sstevel@tonic-gate case ASI_PST16_SL: 15120Sstevel@tonic-gate ftt = _fp_read_extword((uint64_t *)ea, &l.ll, pfpsd); 15130Sstevel@tonic-gate if (ftt != ftt_none) 15140Sstevel@tonic-gate return (ftt); 15150Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &k.f.FPU_DREG_FIELD, nrd); 15162227Sjfrank for (h = 7, i = 0, j = 1; i <= 6; h -= 2, i += 2, j <<= 1) { 15170Sstevel@tonic-gate if ((msk & j) == j) { 15182227Sjfrank res.c[i] = k.c[h]; 15192227Sjfrank res.c[i+1] = k.c[h-1]; 15200Sstevel@tonic-gate } else { 15212227Sjfrank res.c[i] = l.c[i]; 15222227Sjfrank res.c[i+1] = l.c[i+1]; 15230Sstevel@tonic-gate } 15240Sstevel@tonic-gate } 15250Sstevel@tonic-gate ftt = _fp_write_extword((uint64_t *)ea, res.ll, pfpsd); 15260Sstevel@tonic-gate if (ftt != ftt_none) 15270Sstevel@tonic-gate return (ftt); 15280Sstevel@tonic-gate break; 15290Sstevel@tonic-gate case ASI_PST32_P: 15300Sstevel@tonic-gate case ASI_PST32_S: 15310Sstevel@tonic-gate ftt = _fp_read_extword((uint64_t *)ea, &l.ll, pfpsd); 15320Sstevel@tonic-gate if (ftt != ftt_none) 15330Sstevel@tonic-gate return (ftt); 15340Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &k.f.FPU_DREG_FIELD, nrd); 15350Sstevel@tonic-gate for (i = 0, j = 0x2; i <= 1; i++, j >>= 1) { 15360Sstevel@tonic-gate if ((msk & j) == j) 15370Sstevel@tonic-gate res.i[i] = k.i[i]; 15380Sstevel@tonic-gate else 15390Sstevel@tonic-gate res.i[i] = l.i[i]; 15400Sstevel@tonic-gate } 15410Sstevel@tonic-gate ftt = _fp_write_extword((uint64_t *)ea, res.ll, pfpsd); 15420Sstevel@tonic-gate if (ftt != ftt_none) 15430Sstevel@tonic-gate return (ftt); 15440Sstevel@tonic-gate break; 15450Sstevel@tonic-gate case ASI_PST32_PL: 15460Sstevel@tonic-gate case ASI_PST32_SL: 15470Sstevel@tonic-gate ftt = _fp_read_extword((uint64_t *)ea, &l.ll, pfpsd); 15480Sstevel@tonic-gate if (ftt != ftt_none) 15490Sstevel@tonic-gate return (ftt); 15500Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &k.f.FPU_DREG_FIELD, nrd); 15512227Sjfrank for (h = 7, i = 0, j = 1; i <= 4; h -= 4, i += 4, j <<= 1) { 15520Sstevel@tonic-gate if ((msk & j) == j) { 15532227Sjfrank res.c[i] = k.c[h]; 15542227Sjfrank res.c[i+1] = k.c[h-1]; 15552227Sjfrank res.c[i+2] = k.c[h-2]; 15562227Sjfrank res.c[i+3] = k.c[h-3]; 15570Sstevel@tonic-gate } else { 15582227Sjfrank res.c[i] = l.c[i]; 15592227Sjfrank res.c[i+1] = l.c[i+1]; 15602227Sjfrank res.c[i+2] = l.c[i+2]; 15612227Sjfrank res.c[i+3] = l.c[i+3]; 15620Sstevel@tonic-gate } 15630Sstevel@tonic-gate } 15640Sstevel@tonic-gate ftt = _fp_write_extword((uint64_t *)ea, res.ll, pfpsd); 15650Sstevel@tonic-gate if (ftt != ftt_none) 15660Sstevel@tonic-gate return (ftt); 15670Sstevel@tonic-gate break; 15680Sstevel@tonic-gate } 15690Sstevel@tonic-gate 15700Sstevel@tonic-gate pregs->r_pc = pregs->r_npc; /* Do not retry emulated instruction. */ 15710Sstevel@tonic-gate pregs->r_npc += 4; 15720Sstevel@tonic-gate return (ftt_none); 15730Sstevel@tonic-gate } 15740Sstevel@tonic-gate 15750Sstevel@tonic-gate /* 15760Sstevel@tonic-gate * Simulator for short load/stores between floating-point unit and memory. 15770Sstevel@tonic-gate */ 15780Sstevel@tonic-gate static enum ftt_type 15790Sstevel@tonic-gate vis_short_fls( 15800Sstevel@tonic-gate fp_simd_type *pfpsd, /* FPU simulator data. */ 15810Sstevel@tonic-gate vis_inst_type inst, /* ISE instruction to simulate. */ 15820Sstevel@tonic-gate struct regs *pregs, /* Pointer to PCB image of registers. */ 15830Sstevel@tonic-gate void *prw, /* Pointer to locals and ins. */ 15840Sstevel@tonic-gate uint_t asi) /* asi to emulate! */ 15850Sstevel@tonic-gate { 15860Sstevel@tonic-gate uint_t nrs1, nrs2, nrd; /* Register number fields. */ 15870Sstevel@tonic-gate uint_t opf; 15880Sstevel@tonic-gate uint64_t ea, tea; 15890Sstevel@tonic-gate union { 15900Sstevel@tonic-gate freg_type f; 15910Sstevel@tonic-gate uint64_t ll; 15920Sstevel@tonic-gate uint32_t i[2]; 15930Sstevel@tonic-gate uint16_t s[4]; 15940Sstevel@tonic-gate uint8_t c[8]; 15950Sstevel@tonic-gate } k; 15960Sstevel@tonic-gate union { 15970Sstevel@tonic-gate vis_inst_type inst; 15980Sstevel@tonic-gate int i; 15990Sstevel@tonic-gate } fp; 16000Sstevel@tonic-gate enum ftt_type ftt = ftt_none; 16010Sstevel@tonic-gate ushort_t us; 16020Sstevel@tonic-gate uchar_t uc; 16030Sstevel@tonic-gate 16040Sstevel@tonic-gate nrs1 = inst.rs1; 16050Sstevel@tonic-gate nrs2 = inst.rs2; 16060Sstevel@tonic-gate nrd = inst.rd; 16070Sstevel@tonic-gate if ((nrd & 1) == 1) /* fix register encoding */ 16080Sstevel@tonic-gate nrd = (nrd & 0x1e) | 0x20; 16090Sstevel@tonic-gate opf = inst.opf; 16100Sstevel@tonic-gate fp.inst = inst; 16110Sstevel@tonic-gate if ((opf & 0x100) == 0) { /* effective address = rs1 + rs2 */ 16120Sstevel@tonic-gate ftt = read_iureg(pfpsd, nrs1, pregs, prw, &ea); 16130Sstevel@tonic-gate if (ftt != ftt_none) 16140Sstevel@tonic-gate return (ftt); 16150Sstevel@tonic-gate ftt = read_iureg(pfpsd, nrs2, pregs, prw, &tea); 16160Sstevel@tonic-gate if (ftt != ftt_none) 16170Sstevel@tonic-gate return (ftt); 16180Sstevel@tonic-gate ea += tea; 16190Sstevel@tonic-gate } else { /* effective address = rs1 + imm13 */ 16200Sstevel@tonic-gate fp.inst = inst; 16210Sstevel@tonic-gate ea = (fp.i << 19) >> 19; /* Extract simm13 field. */ 16220Sstevel@tonic-gate ftt = read_iureg(pfpsd, nrs1, pregs, prw, &tea); 16230Sstevel@tonic-gate if (ftt != ftt_none) 16240Sstevel@tonic-gate return (ftt); 16250Sstevel@tonic-gate ea += tea; 16260Sstevel@tonic-gate } 16270Sstevel@tonic-gate if (get_udatamodel() == DATAMODEL_ILP32) 16280Sstevel@tonic-gate ea = (uint64_t)(caddr32_t)ea; 16290Sstevel@tonic-gate 16300Sstevel@tonic-gate pfpsd->fp_trapaddr = (caddr_t)ea; /* setup bad addr in case we trap */ 16310Sstevel@tonic-gate switch (asi) { 16320Sstevel@tonic-gate case ASI_FL8_P: 16330Sstevel@tonic-gate case ASI_FL8_S: 16340Sstevel@tonic-gate case ASI_FL8_PL: /* little-endian */ 16350Sstevel@tonic-gate case ASI_FL8_SL: 16360Sstevel@tonic-gate if ((inst.op3 & 7) == 3) { /* load byte */ 16370Sstevel@tonic-gate if (fuword8((void *)ea, &uc) == -1) 16380Sstevel@tonic-gate return (ftt_fault); 16390Sstevel@tonic-gate k.ll = 0; 16400Sstevel@tonic-gate k.c[7] = uc; 16410Sstevel@tonic-gate _fp_pack_extword(pfpsd, &k.f.FPU_DREG_FIELD, nrd); 16420Sstevel@tonic-gate } else { /* store byte */ 16430Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &k.f.FPU_DREG_FIELD, nrd); 16440Sstevel@tonic-gate uc = k.c[7]; 16450Sstevel@tonic-gate if (subyte((caddr_t)ea, uc) == -1) 16460Sstevel@tonic-gate return (ftt_fault); 16470Sstevel@tonic-gate } 16480Sstevel@tonic-gate break; 16490Sstevel@tonic-gate case ASI_FL16_P: 16500Sstevel@tonic-gate case ASI_FL16_S: 16510Sstevel@tonic-gate if ((ea & 1) == 1) 16520Sstevel@tonic-gate return (ftt_alignment); 16530Sstevel@tonic-gate if ((inst.op3 & 7) == 3) { /* load short */ 16540Sstevel@tonic-gate if (fuword16((void *)ea, &us) == -1) 16550Sstevel@tonic-gate return (ftt_fault); 16560Sstevel@tonic-gate k.ll = 0; 16570Sstevel@tonic-gate k.s[3] = us; 16580Sstevel@tonic-gate _fp_pack_extword(pfpsd, &k.f.FPU_DREG_FIELD, nrd); 16590Sstevel@tonic-gate } else { /* store short */ 16600Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &k.f.FPU_DREG_FIELD, nrd); 16610Sstevel@tonic-gate us = k.s[3]; 16620Sstevel@tonic-gate if (suword16((caddr_t)ea, us) == -1) 16630Sstevel@tonic-gate return (ftt_fault); 16640Sstevel@tonic-gate } 16650Sstevel@tonic-gate break; 16660Sstevel@tonic-gate case ASI_FL16_PL: /* little-endian */ 16670Sstevel@tonic-gate case ASI_FL16_SL: 16680Sstevel@tonic-gate if ((ea & 1) == 1) 16690Sstevel@tonic-gate return (ftt_alignment); 16700Sstevel@tonic-gate if ((inst.op3 & 7) == 3) { /* load short */ 16710Sstevel@tonic-gate if (fuword16((void *)ea, &us) == -1) 16720Sstevel@tonic-gate return (ftt_fault); 16730Sstevel@tonic-gate k.ll = 0; 16740Sstevel@tonic-gate k.c[6] = (uchar_t)us; 16750Sstevel@tonic-gate k.c[7] = (uchar_t)((us & 0xff00) >> 8); 16760Sstevel@tonic-gate _fp_pack_extword(pfpsd, &k.f.FPU_DREG_FIELD, nrd); 16770Sstevel@tonic-gate } else { /* store short */ 16780Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &k.f.FPU_DREG_FIELD, nrd); 16790Sstevel@tonic-gate uc = k.c[7]; 16800Sstevel@tonic-gate us = (ushort_t)((uc << 8) | k.c[6]); 16810Sstevel@tonic-gate if (suword16((void *)ea, us) == -1) 16820Sstevel@tonic-gate return (ftt_fault); 16830Sstevel@tonic-gate } 16840Sstevel@tonic-gate break; 16850Sstevel@tonic-gate } 16860Sstevel@tonic-gate 16870Sstevel@tonic-gate pregs->r_pc = pregs->r_npc; /* Do not retry emulated instruction. */ 16880Sstevel@tonic-gate pregs->r_npc += 4; 16890Sstevel@tonic-gate return (ftt_none); 16900Sstevel@tonic-gate } 16910Sstevel@tonic-gate 16920Sstevel@tonic-gate /* 16930Sstevel@tonic-gate * Simulator for block loads and stores between floating-point unit and memory. 1694*3729Swh94709 * We pass the addrees of ea to sync_data_memory() to flush the Ecache. 1695*3729Swh94709 * Sync_data_memory() calls platform dependent code to flush the Ecache. 16960Sstevel@tonic-gate */ 16970Sstevel@tonic-gate static enum ftt_type 16980Sstevel@tonic-gate vis_blk_fldst( 16990Sstevel@tonic-gate fp_simd_type *pfpsd, /* FPU simulator data. */ 17000Sstevel@tonic-gate vis_inst_type inst, /* ISE instruction to simulate. */ 17010Sstevel@tonic-gate struct regs *pregs, /* Pointer to PCB image of registers. */ 17020Sstevel@tonic-gate void *prw, /* Pointer to locals and ins. */ 17030Sstevel@tonic-gate uint_t asi) /* asi to emulate! */ 17040Sstevel@tonic-gate { 17050Sstevel@tonic-gate uint_t nrs1, nrs2, nrd; /* Register number fields. */ 17060Sstevel@tonic-gate uint_t opf, h, i, j; 17070Sstevel@tonic-gate uint64_t ea, tea; 17080Sstevel@tonic-gate union { 17090Sstevel@tonic-gate freg_type f; 17100Sstevel@tonic-gate uint64_t ll; 17110Sstevel@tonic-gate uint8_t c[8]; 17120Sstevel@tonic-gate } k, l; 17130Sstevel@tonic-gate union { 17140Sstevel@tonic-gate vis_inst_type inst; 17150Sstevel@tonic-gate int32_t i; 17160Sstevel@tonic-gate } fp; 17170Sstevel@tonic-gate enum ftt_type ftt; 17180Sstevel@tonic-gate boolean_t little_endian = B_FALSE; 17190Sstevel@tonic-gate 17200Sstevel@tonic-gate nrs1 = inst.rs1; 17210Sstevel@tonic-gate nrs2 = inst.rs2; 17220Sstevel@tonic-gate nrd = inst.rd; 17230Sstevel@tonic-gate if ((nrd & 1) == 1) /* fix register encoding */ 17240Sstevel@tonic-gate nrd = (nrd & 0x1e) | 0x20; 17250Sstevel@tonic-gate 17260Sstevel@tonic-gate /* ensure register is 8-double precision aligned */ 17270Sstevel@tonic-gate if ((nrd & 0xf) != 0) 17280Sstevel@tonic-gate return (ftt_unimplemented); 17290Sstevel@tonic-gate 17300Sstevel@tonic-gate opf = inst.opf; 17310Sstevel@tonic-gate if ((opf & 0x100) == 0) { /* effective address = rs1 + rs2 */ 17320Sstevel@tonic-gate ftt = read_iureg(pfpsd, nrs1, pregs, prw, &ea); 17330Sstevel@tonic-gate if (ftt != ftt_none) 17340Sstevel@tonic-gate return (ftt); 17350Sstevel@tonic-gate ftt = read_iureg(pfpsd, nrs2, pregs, prw, &tea); 17360Sstevel@tonic-gate if (ftt != ftt_none) 17370Sstevel@tonic-gate return (ftt); 17380Sstevel@tonic-gate ea += tea; 17390Sstevel@tonic-gate } else { /* effective address = rs1 + imm13 */ 17400Sstevel@tonic-gate fp.inst = inst; 17410Sstevel@tonic-gate ea = (fp.i << 19) >> 19; /* Extract simm13 field. */ 17420Sstevel@tonic-gate ftt = read_iureg(pfpsd, nrs1, pregs, prw, &tea); 17430Sstevel@tonic-gate if (ftt != ftt_none) 17440Sstevel@tonic-gate return (ftt); 17450Sstevel@tonic-gate ea += tea; 17460Sstevel@tonic-gate } 17470Sstevel@tonic-gate if ((ea & 0x3F) != 0) /* Require 64 byte-alignment. */ 17480Sstevel@tonic-gate return (ftt_alignment); 17490Sstevel@tonic-gate 17500Sstevel@tonic-gate pfpsd->fp_trapaddr = (caddr_t)ea; /* setup bad addr in case we trap */ 17510Sstevel@tonic-gate switch (asi) { 17520Sstevel@tonic-gate case ASI_BLK_AIUPL: 17530Sstevel@tonic-gate case ASI_BLK_AIUSL: 17540Sstevel@tonic-gate case ASI_BLK_PL: 17550Sstevel@tonic-gate case ASI_BLK_SL: 17560Sstevel@tonic-gate little_endian = B_TRUE; 17570Sstevel@tonic-gate /* FALLTHROUGH */ 17580Sstevel@tonic-gate case ASI_BLK_AIUP: 17590Sstevel@tonic-gate case ASI_BLK_AIUS: 17600Sstevel@tonic-gate case ASI_BLK_P: 17610Sstevel@tonic-gate case ASI_BLK_S: 17620Sstevel@tonic-gate case ASI_BLK_COMMIT_P: 17630Sstevel@tonic-gate case ASI_BLK_COMMIT_S: 17640Sstevel@tonic-gate if ((inst.op3 & 7) == 3) { /* lddf */ 1765*3729Swh94709 for (i = 0; i < 8; i++, nrd += 2) { 17660Sstevel@tonic-gate ftt = _fp_read_extword((uint64_t *)ea, &k.ll, pfpsd); 17670Sstevel@tonic-gate if (ftt != ftt_none) 17680Sstevel@tonic-gate return (ftt); 17690Sstevel@tonic-gate if (little_endian) { 17700Sstevel@tonic-gate for (j = 0, h = 7; j < 8; j++, h--) 17710Sstevel@tonic-gate l.c[h] = k.c[j]; 17720Sstevel@tonic-gate k.ll = l.ll; 17730Sstevel@tonic-gate } 17740Sstevel@tonic-gate _fp_pack_extword(pfpsd, &k.f.FPU_DREG_FIELD, nrd); 1775*3729Swh94709 ea += 8; 17760Sstevel@tonic-gate } 17770Sstevel@tonic-gate } else { /* stdf */ 1778*3729Swh94709 for (i = 0; i < 8; i++, nrd += 2) { 17790Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &k.f.FPU_DREG_FIELD, nrd); 17800Sstevel@tonic-gate if (little_endian) { 17810Sstevel@tonic-gate for (j = 0, h = 7; j < 8; j++, h--) 17820Sstevel@tonic-gate l.c[h] = k.c[j]; 17830Sstevel@tonic-gate k.ll = l.ll; 17840Sstevel@tonic-gate } 17850Sstevel@tonic-gate ftt = _fp_write_extword((uint64_t *)ea, k.ll, pfpsd); 17860Sstevel@tonic-gate if (ftt != ftt_none) 17870Sstevel@tonic-gate return (ftt); 1788*3729Swh94709 ea += 8; 17890Sstevel@tonic-gate } 17900Sstevel@tonic-gate } 17910Sstevel@tonic-gate if ((asi == ASI_BLK_COMMIT_P) || (asi == ASI_BLK_COMMIT_S)) 1792*3729Swh94709 sync_data_memory((caddr_t)(ea - 64), 64); 17930Sstevel@tonic-gate break; 17940Sstevel@tonic-gate default: 17950Sstevel@tonic-gate /* addr of unimp inst */ 17960Sstevel@tonic-gate pfpsd->fp_trapaddr = (caddr_t)pregs->r_pc; 17970Sstevel@tonic-gate return (ftt_unimplemented); 17980Sstevel@tonic-gate } 17990Sstevel@tonic-gate 18000Sstevel@tonic-gate pregs->r_pc = pregs->r_npc; /* Do not retry emulated instruction. */ 18010Sstevel@tonic-gate pregs->r_npc += 4; 18020Sstevel@tonic-gate return (ftt_none); 18030Sstevel@tonic-gate } 18040Sstevel@tonic-gate 18050Sstevel@tonic-gate /* 18060Sstevel@tonic-gate * Simulator for rd %gsr instruction. 18070Sstevel@tonic-gate */ 18080Sstevel@tonic-gate enum ftt_type 18090Sstevel@tonic-gate vis_rdgsr( 18100Sstevel@tonic-gate fp_simd_type *pfpsd, /* FPU simulator data. */ 18110Sstevel@tonic-gate fp_inst_type pinst, /* FPU instruction to simulate. */ 18120Sstevel@tonic-gate struct regs *pregs, /* Pointer to PCB image of registers. */ 18130Sstevel@tonic-gate void *prw, /* Pointer to locals and ins. */ 18140Sstevel@tonic-gate kfpu_t *fp) /* Need to fp to access gsr reg */ 18150Sstevel@tonic-gate { 18160Sstevel@tonic-gate uint_t nrd; 18170Sstevel@tonic-gate uint64_t r; 18180Sstevel@tonic-gate enum ftt_type ftt = ftt_none; 18190Sstevel@tonic-gate 18200Sstevel@tonic-gate nrd = pinst.rd; 18210Sstevel@tonic-gate 18227Sdf157793 r = pfpsd->fp_current_read_gsr(fp); 18230Sstevel@tonic-gate ftt = write_iureg(pfpsd, nrd, pregs, prw, &r); 18240Sstevel@tonic-gate pregs->r_pc = pregs->r_npc; /* Do not retry emulated instruction. */ 18250Sstevel@tonic-gate pregs->r_npc += 4; 18260Sstevel@tonic-gate return (ftt); 18270Sstevel@tonic-gate } 18280Sstevel@tonic-gate 18290Sstevel@tonic-gate /* 18300Sstevel@tonic-gate * Simulator for wr %gsr instruction. 18310Sstevel@tonic-gate */ 18320Sstevel@tonic-gate enum ftt_type 18330Sstevel@tonic-gate vis_wrgsr( 18340Sstevel@tonic-gate fp_simd_type *pfpsd, /* FPU simulator data. */ 18350Sstevel@tonic-gate fp_inst_type pinst, /* FPU instruction to simulate. */ 18360Sstevel@tonic-gate struct regs *pregs, /* Pointer to PCB image of registers. */ 18370Sstevel@tonic-gate void *prw, /* Pointer to locals and ins. */ 18380Sstevel@tonic-gate kfpu_t *fp) /* Need to fp to access gsr reg */ 18390Sstevel@tonic-gate { 18400Sstevel@tonic-gate uint_t nrs1; 18410Sstevel@tonic-gate uint64_t r, r1, r2; 18420Sstevel@tonic-gate enum ftt_type ftt = ftt_none; 18430Sstevel@tonic-gate 18440Sstevel@tonic-gate nrs1 = pinst.rs1; 18450Sstevel@tonic-gate ftt = read_iureg(pfpsd, nrs1, pregs, prw, &r1); 18460Sstevel@tonic-gate if (ftt != ftt_none) 18470Sstevel@tonic-gate return (ftt); 18480Sstevel@tonic-gate if (pinst.ibit == 0) { /* copy the value in r[rs2] */ 18490Sstevel@tonic-gate uint_t nrs2; 18500Sstevel@tonic-gate 18510Sstevel@tonic-gate nrs2 = pinst.rs2; 18520Sstevel@tonic-gate ftt = read_iureg(pfpsd, nrs2, pregs, prw, &r2); 18530Sstevel@tonic-gate if (ftt != ftt_none) 18540Sstevel@tonic-gate return (ftt); 18550Sstevel@tonic-gate } else { /* use sign_ext(simm13) */ 18560Sstevel@tonic-gate union { 18570Sstevel@tonic-gate fp_inst_type inst; 18580Sstevel@tonic-gate uint32_t i; 18590Sstevel@tonic-gate } fp; 18600Sstevel@tonic-gate 18610Sstevel@tonic-gate fp.inst = pinst; /* Extract simm13 field */ 18620Sstevel@tonic-gate r2 = (fp.i << 19) >> 19; 18630Sstevel@tonic-gate } 18640Sstevel@tonic-gate r = r1 ^ r2; 18657Sdf157793 pfpsd->fp_current_write_gsr(r, fp); 18660Sstevel@tonic-gate pregs->r_pc = pregs->r_npc; /* Do not retry emulated instruction. */ 18670Sstevel@tonic-gate pregs->r_npc += 4; 18680Sstevel@tonic-gate return (ftt); 18690Sstevel@tonic-gate } 18700Sstevel@tonic-gate 18710Sstevel@tonic-gate /* 18720Sstevel@tonic-gate * This is the loadable module wrapper. 18730Sstevel@tonic-gate */ 18740Sstevel@tonic-gate #include <sys/errno.h> 18750Sstevel@tonic-gate #include <sys/modctl.h> 18760Sstevel@tonic-gate 18770Sstevel@tonic-gate /* 18780Sstevel@tonic-gate * Module linkage information for the kernel. 18790Sstevel@tonic-gate */ 18800Sstevel@tonic-gate extern struct mod_ops mod_miscops; 18810Sstevel@tonic-gate 18820Sstevel@tonic-gate static struct modlmisc modlmisc = { 18830Sstevel@tonic-gate &mod_miscops, 18840Sstevel@tonic-gate "vis fp simulation", 18850Sstevel@tonic-gate }; 18860Sstevel@tonic-gate 18870Sstevel@tonic-gate static struct modlinkage modlinkage = { 18880Sstevel@tonic-gate MODREV_1, (void *)&modlmisc, NULL 18890Sstevel@tonic-gate }; 18900Sstevel@tonic-gate 18910Sstevel@tonic-gate int 18920Sstevel@tonic-gate _init(void) 18930Sstevel@tonic-gate { 18940Sstevel@tonic-gate return (mod_install(&modlinkage)); 18950Sstevel@tonic-gate } 18960Sstevel@tonic-gate 18970Sstevel@tonic-gate int 18980Sstevel@tonic-gate _info(struct modinfo *modinfop) 18990Sstevel@tonic-gate { 19000Sstevel@tonic-gate return (mod_info(&modlinkage, modinfop)); 19010Sstevel@tonic-gate } 1902