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*8829SSree.Vemuri@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate /* VIS floating point instruction simulator for Sparc FPU simulator. */ 270Sstevel@tonic-gate 280Sstevel@tonic-gate #include <sys/types.h> 290Sstevel@tonic-gate #include <sys/systm.h> 300Sstevel@tonic-gate #include <sys/fpu/fpusystm.h> 310Sstevel@tonic-gate #include <sys/fpu/fpu_simulator.h> 320Sstevel@tonic-gate #include <sys/vis_simulator.h> 330Sstevel@tonic-gate #include <sys/fpu/globals.h> 340Sstevel@tonic-gate #include <sys/privregs.h> 350Sstevel@tonic-gate #include <sys/sun4asi.h> 360Sstevel@tonic-gate #include <sys/machasi.h> 370Sstevel@tonic-gate #include <sys/debug.h> 380Sstevel@tonic-gate #include <sys/cpu_module.h> 390Sstevel@tonic-gate #include <sys/systm.h> 400Sstevel@tonic-gate 410Sstevel@tonic-gate #define FPU_REG_FIELD uint32_reg /* Coordinate with FPU_REGS_TYPE. */ 420Sstevel@tonic-gate #define FPU_DREG_FIELD uint64_reg /* Coordinate with FPU_DREGS_TYPE. */ 430Sstevel@tonic-gate #define FPU_FSR_FIELD uint64_reg /* Coordinate with V9_FPU_FSR_TYPE. */ 440Sstevel@tonic-gate 451246Skalai extern uint_t get_subcc_ccr(uint64_t, uint64_t); 461246Skalai 470Sstevel@tonic-gate static enum ftt_type vis_array(fp_simd_type *, vis_inst_type, struct regs *, 480Sstevel@tonic-gate void *); 490Sstevel@tonic-gate static enum ftt_type vis_alignaddr(fp_simd_type *, vis_inst_type, 500Sstevel@tonic-gate struct regs *, void *, kfpu_t *); 510Sstevel@tonic-gate static enum ftt_type vis_edge(fp_simd_type *, vis_inst_type, struct regs *, 520Sstevel@tonic-gate void *); 530Sstevel@tonic-gate static enum ftt_type vis_faligndata(fp_simd_type *, fp_inst_type, 540Sstevel@tonic-gate kfpu_t *); 550Sstevel@tonic-gate static enum ftt_type vis_bmask(fp_simd_type *, vis_inst_type, struct regs *, 560Sstevel@tonic-gate void *, kfpu_t *); 570Sstevel@tonic-gate static enum ftt_type vis_bshuffle(fp_simd_type *, fp_inst_type, 580Sstevel@tonic-gate kfpu_t *); 590Sstevel@tonic-gate static enum ftt_type vis_siam(fp_simd_type *, vis_inst_type, kfpu_t *); 600Sstevel@tonic-gate static enum ftt_type vis_fcmp(fp_simd_type *, vis_inst_type, struct regs *, 610Sstevel@tonic-gate void *); 620Sstevel@tonic-gate static enum ftt_type vis_fmul(fp_simd_type *, vis_inst_type); 630Sstevel@tonic-gate static enum ftt_type vis_fpixel(fp_simd_type *, vis_inst_type, kfpu_t *); 640Sstevel@tonic-gate static enum ftt_type vis_fpaddsub(fp_simd_type *, vis_inst_type); 65*8829SSree.Vemuri@Sun.COM static enum ftt_type vis_pdist(fp_simd_type *, fp_inst_type, struct regs *, 66*8829SSree.Vemuri@Sun.COM void *, uint_t); 670Sstevel@tonic-gate static enum ftt_type vis_prtl_fst(fp_simd_type *, vis_inst_type, struct regs *, 680Sstevel@tonic-gate void *, uint_t); 690Sstevel@tonic-gate static enum ftt_type vis_short_fls(fp_simd_type *, vis_inst_type, 700Sstevel@tonic-gate struct regs *, void *, uint_t); 710Sstevel@tonic-gate static enum ftt_type vis_blk_fldst(fp_simd_type *, vis_inst_type, 720Sstevel@tonic-gate struct regs *, void *, uint_t); 730Sstevel@tonic-gate 740Sstevel@tonic-gate /* 750Sstevel@tonic-gate * Simulator for VIS instructions with op3 == 0x36 that get fp_disabled 760Sstevel@tonic-gate * traps. 770Sstevel@tonic-gate */ 780Sstevel@tonic-gate enum ftt_type 790Sstevel@tonic-gate vis_fpu_simulator( 800Sstevel@tonic-gate fp_simd_type *pfpsd, /* FPU simulator data. */ 810Sstevel@tonic-gate fp_inst_type pinst, /* FPU instruction to simulate. */ 820Sstevel@tonic-gate struct regs *pregs, /* Pointer to PCB image of registers. */ 830Sstevel@tonic-gate void *prw, /* Pointer to locals and ins. */ 840Sstevel@tonic-gate kfpu_t *fp) /* Need to fp to access gsr reg */ 850Sstevel@tonic-gate { 860Sstevel@tonic-gate uint_t nrs1, nrs2, nrd; /* Register number fields. */ 870Sstevel@tonic-gate uint_t us1, us2, usr; 880Sstevel@tonic-gate uint64_t lus1, lus2, lusr; 890Sstevel@tonic-gate enum ftt_type ftt = ftt_none; 900Sstevel@tonic-gate union { 910Sstevel@tonic-gate vis_inst_type inst; 920Sstevel@tonic-gate fp_inst_type pinst; 930Sstevel@tonic-gate } f; 940Sstevel@tonic-gate 950Sstevel@tonic-gate ASSERT(USERMODE(pregs->r_tstate)); 960Sstevel@tonic-gate nrs1 = pinst.rs1; 970Sstevel@tonic-gate nrs2 = pinst.rs2; 980Sstevel@tonic-gate nrd = pinst.rd; 990Sstevel@tonic-gate f.pinst = pinst; 1000Sstevel@tonic-gate if ((f.inst.opf & 1) == 0) { /* double precision */ 1010Sstevel@tonic-gate if ((nrs1 & 1) == 1) /* fix register encoding */ 1020Sstevel@tonic-gate nrs1 = (nrs1 & 0x1e) | 0x20; 1030Sstevel@tonic-gate if ((nrs2 & 1) == 1) 1040Sstevel@tonic-gate nrs2 = (nrs2 & 0x1e) | 0x20; 1050Sstevel@tonic-gate if ((nrd & 1) == 1) 1060Sstevel@tonic-gate nrd = (nrd & 0x1e) | 0x20; 1070Sstevel@tonic-gate } 1080Sstevel@tonic-gate 1090Sstevel@tonic-gate switch (f.inst.opf) { 1100Sstevel@tonic-gate /* these instr's do not use fp regs */ 1110Sstevel@tonic-gate case edge8: 1120Sstevel@tonic-gate case edge8l: 1130Sstevel@tonic-gate case edge8n: 1140Sstevel@tonic-gate case edge8ln: 1150Sstevel@tonic-gate case edge16: 1160Sstevel@tonic-gate case edge16l: 1170Sstevel@tonic-gate case edge16n: 1180Sstevel@tonic-gate case edge16ln: 1190Sstevel@tonic-gate case edge32: 1200Sstevel@tonic-gate case edge32l: 1210Sstevel@tonic-gate case edge32n: 1220Sstevel@tonic-gate case edge32ln: 1230Sstevel@tonic-gate ftt = vis_edge(pfpsd, f.inst, pregs, prw); 1240Sstevel@tonic-gate break; 1250Sstevel@tonic-gate case array8: 1260Sstevel@tonic-gate case array16: 1270Sstevel@tonic-gate case array32: 1280Sstevel@tonic-gate ftt = vis_array(pfpsd, f.inst, pregs, prw); 1290Sstevel@tonic-gate break; 1300Sstevel@tonic-gate case alignaddr: 1310Sstevel@tonic-gate case alignaddrl: 1320Sstevel@tonic-gate ftt = vis_alignaddr(pfpsd, f.inst, pregs, prw, fp); 1330Sstevel@tonic-gate break; 1340Sstevel@tonic-gate case bmask: 1350Sstevel@tonic-gate ftt = vis_bmask(pfpsd, f.inst, pregs, prw, fp); 1360Sstevel@tonic-gate break; 1370Sstevel@tonic-gate case fcmple16: 1380Sstevel@tonic-gate case fcmpne16: 1390Sstevel@tonic-gate case fcmpgt16: 1400Sstevel@tonic-gate case fcmpeq16: 1410Sstevel@tonic-gate case fcmple32: 1420Sstevel@tonic-gate case fcmpne32: 1430Sstevel@tonic-gate case fcmpgt32: 1440Sstevel@tonic-gate case fcmpeq32: 1450Sstevel@tonic-gate ftt = vis_fcmp(pfpsd, f.inst, pregs, prw); 1460Sstevel@tonic-gate break; 1470Sstevel@tonic-gate case fmul8x16: 1480Sstevel@tonic-gate case fmul8x16au: 1490Sstevel@tonic-gate case fmul8x16al: 1500Sstevel@tonic-gate case fmul8sux16: 1510Sstevel@tonic-gate case fmul8ulx16: 1520Sstevel@tonic-gate case fmuld8sux16: 1530Sstevel@tonic-gate case fmuld8ulx16: 1540Sstevel@tonic-gate ftt = vis_fmul(pfpsd, f.inst); 1550Sstevel@tonic-gate break; 1560Sstevel@tonic-gate case fpack16: 1570Sstevel@tonic-gate case fpack32: 1580Sstevel@tonic-gate case fpackfix: 1590Sstevel@tonic-gate case fexpand: 1600Sstevel@tonic-gate case fpmerge: 1610Sstevel@tonic-gate ftt = vis_fpixel(pfpsd, f.inst, fp); 1620Sstevel@tonic-gate break; 1630Sstevel@tonic-gate case pdist: 164*8829SSree.Vemuri@Sun.COM case pdistn: 165*8829SSree.Vemuri@Sun.COM ftt = vis_pdist(pfpsd, pinst, pregs, prw, f.inst.opf); 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 */ 3831246Skalai uint_t ccr; 3840Sstevel@tonic-gate 3850Sstevel@tonic-gate nrs1 = inst.rs1; 3860Sstevel@tonic-gate nrs2 = inst.rs2; 3870Sstevel@tonic-gate nrd = inst.rd; 3880Sstevel@tonic-gate 3890Sstevel@tonic-gate ftt = read_iureg(pfpsd, nrs1, pregs, prw, &addrl); 3900Sstevel@tonic-gate if (ftt != ftt_none) 3910Sstevel@tonic-gate return (ftt); 3920Sstevel@tonic-gate ftt = read_iureg(pfpsd, nrs2, pregs, prw, &addrr); 3930Sstevel@tonic-gate if (ftt != ftt_none) 3940Sstevel@tonic-gate return (ftt); 3950Sstevel@tonic-gate 3965008Sarutz /* Test PSTATE.AM to determine 32-bit vs 64-bit addressing */ 3975008Sarutz if ((pregs->r_tstate & TSTATE_AM) != 0) { 3985008Sarutz ah61l = addrl & 0xfffffff8; 3995008Sarutz ah61r = addrr & 0xfffffff8; 4000Sstevel@tonic-gate } else { 4010Sstevel@tonic-gate ah61l = addrl & ~0x7; 4020Sstevel@tonic-gate ah61r = addrr & ~0x7; 4030Sstevel@tonic-gate } 4040Sstevel@tonic-gate 4050Sstevel@tonic-gate 4060Sstevel@tonic-gate switch (inst.opf) { 4070Sstevel@tonic-gate case edge8: 4080Sstevel@tonic-gate case edge8n: 4090Sstevel@tonic-gate case edge8l: 4100Sstevel@tonic-gate case edge8ln: 4110Sstevel@tonic-gate al3l = addrl & 0x7; 4120Sstevel@tonic-gate switch (inst.opf) { 4130Sstevel@tonic-gate case edge8: 4140Sstevel@tonic-gate case edge8n: 4150Sstevel@tonic-gate if (inst.opf == edge8) { 4160Sstevel@tonic-gate VISINFO_KSTAT(vis_edge8); 4170Sstevel@tonic-gate } else { 4180Sstevel@tonic-gate VISINFO_KSTAT(vis_edge8n); 4190Sstevel@tonic-gate } 4207Sdf157793 mask = 0xff >> al3l; 4210Sstevel@tonic-gate if (ah61l == ah61r) { 4220Sstevel@tonic-gate al3r = addrr & 0x7; 4237Sdf157793 mask &= (0xff << (0x7 - al3r)) & 0xff; 4240Sstevel@tonic-gate } 4250Sstevel@tonic-gate break; 4260Sstevel@tonic-gate case edge8l: 4270Sstevel@tonic-gate case edge8ln: 4280Sstevel@tonic-gate if (inst.opf == edge8l) { 4290Sstevel@tonic-gate VISINFO_KSTAT(vis_edge8l); 4300Sstevel@tonic-gate } else { 4310Sstevel@tonic-gate VISINFO_KSTAT(vis_edge8ln); 4320Sstevel@tonic-gate } 4337Sdf157793 mask = (0xff << al3l) & 0xff; 4340Sstevel@tonic-gate if (ah61l == ah61r) { 4350Sstevel@tonic-gate al3r = addrr & 0x7; 4367Sdf157793 mask &= 0xff >> (0x7 - al3r); 4370Sstevel@tonic-gate } 4380Sstevel@tonic-gate break; 4390Sstevel@tonic-gate } 4400Sstevel@tonic-gate break; 4410Sstevel@tonic-gate case edge16: 4420Sstevel@tonic-gate case edge16l: 4430Sstevel@tonic-gate case edge16n: 4440Sstevel@tonic-gate case edge16ln: 4450Sstevel@tonic-gate al3l = addrl & 0x6; 4467Sdf157793 al3l >>= 0x1; 4470Sstevel@tonic-gate switch (inst.opf) { 4480Sstevel@tonic-gate case edge16: 4490Sstevel@tonic-gate case edge16n: 4500Sstevel@tonic-gate if (inst.opf == edge16) { 4510Sstevel@tonic-gate VISINFO_KSTAT(vis_edge16); 4520Sstevel@tonic-gate 4530Sstevel@tonic-gate } else { 4540Sstevel@tonic-gate VISINFO_KSTAT(vis_edge16n); 4550Sstevel@tonic-gate } 4567Sdf157793 mask = 0xf >> al3l; 4570Sstevel@tonic-gate if (ah61l == ah61r) { 4580Sstevel@tonic-gate al3r = addrr & 0x6; 4597Sdf157793 al3r >>= 0x1; 4607Sdf157793 mask &= (0xf << (0x3 - al3r)) & 0xf; 4610Sstevel@tonic-gate } 4620Sstevel@tonic-gate break; 4630Sstevel@tonic-gate case edge16l: 4640Sstevel@tonic-gate case edge16ln: 4650Sstevel@tonic-gate if (inst.opf == edge16l) { 4660Sstevel@tonic-gate VISINFO_KSTAT(vis_edge16l); 4670Sstevel@tonic-gate 4680Sstevel@tonic-gate } else { 4690Sstevel@tonic-gate VISINFO_KSTAT(vis_edge16ln); 4700Sstevel@tonic-gate } 4717Sdf157793 4727Sdf157793 mask = (0xf << al3l) & 0xf; 4730Sstevel@tonic-gate if (ah61l == ah61r) { 4740Sstevel@tonic-gate al3r = addrr & 0x6; 4757Sdf157793 al3r >>= 0x1; 4767Sdf157793 mask &= 0xf >> (0x3 - al3r); 4770Sstevel@tonic-gate } 4780Sstevel@tonic-gate break; 4790Sstevel@tonic-gate } 4800Sstevel@tonic-gate break; 4810Sstevel@tonic-gate case edge32: 4820Sstevel@tonic-gate case edge32l: 4830Sstevel@tonic-gate case edge32n: 4840Sstevel@tonic-gate case edge32ln: 4850Sstevel@tonic-gate al3l = addrl & 0x4; 4867Sdf157793 al3l >>= 0x2; 4877Sdf157793 4880Sstevel@tonic-gate switch (inst.opf) { 4890Sstevel@tonic-gate case edge32: 4900Sstevel@tonic-gate case edge32n: 4910Sstevel@tonic-gate if (inst.opf == edge32) { 4920Sstevel@tonic-gate VISINFO_KSTAT(vis_edge32); 4930Sstevel@tonic-gate 4940Sstevel@tonic-gate } else { 4950Sstevel@tonic-gate VISINFO_KSTAT(vis_edge32n); 4960Sstevel@tonic-gate } 4977Sdf157793 mask = 0x3 >> al3l; 4980Sstevel@tonic-gate if (ah61l == ah61r) { 4990Sstevel@tonic-gate al3r = addrr & 0x4; 5007Sdf157793 al3r >>= 0x2; 5017Sdf157793 mask &= (0x3 << (0x1 - al3r)) & 0x3; 5020Sstevel@tonic-gate } 5030Sstevel@tonic-gate break; 5040Sstevel@tonic-gate case edge32l: 5050Sstevel@tonic-gate case edge32ln: 5060Sstevel@tonic-gate if (inst.opf == edge32l) { 5070Sstevel@tonic-gate VISINFO_KSTAT(vis_edge32l); 5080Sstevel@tonic-gate 5090Sstevel@tonic-gate } else { 5100Sstevel@tonic-gate VISINFO_KSTAT(vis_edge32ln); 5110Sstevel@tonic-gate } 5127Sdf157793 mask = (0x3 << al3l) & 0x3; 5130Sstevel@tonic-gate if (ah61l == ah61r) { 5140Sstevel@tonic-gate al3r = addrr & 0x4; 5157Sdf157793 al3r >>= 0x2; 5167Sdf157793 mask &= 0x3 >> (0x1 - al3r); 5170Sstevel@tonic-gate } 5180Sstevel@tonic-gate break; 5190Sstevel@tonic-gate } 5200Sstevel@tonic-gate break; 5210Sstevel@tonic-gate } 5227Sdf157793 5230Sstevel@tonic-gate ftt = write_iureg(pfpsd, nrd, pregs, prw, &mask); 5240Sstevel@tonic-gate 5250Sstevel@tonic-gate switch (inst.opf) { 5260Sstevel@tonic-gate case edge8: 5270Sstevel@tonic-gate case edge8l: 5280Sstevel@tonic-gate case edge16: 5290Sstevel@tonic-gate case edge16l: 5300Sstevel@tonic-gate case edge32: 5310Sstevel@tonic-gate case edge32l: 5320Sstevel@tonic-gate 5331246Skalai /* Update flags per SUBcc outcome */ 5341246Skalai pregs->r_tstate &= ~((uint64_t)TSTATE_CCR_MASK 5351246Skalai << TSTATE_CCR_SHIFT); 5361246Skalai ccr = get_subcc_ccr(addrl, addrr); /* get subcc cond. codes */ 5371246Skalai pregs->r_tstate |= ((uint64_t)ccr << TSTATE_CCR_SHIFT); 5381246Skalai 5390Sstevel@tonic-gate break; 5400Sstevel@tonic-gate } 5410Sstevel@tonic-gate return (ftt); 5421246Skalai } 5431246Skalai 5440Sstevel@tonic-gate /* 5450Sstevel@tonic-gate * Simulator for three dimentional array addressing instructions. 5460Sstevel@tonic-gate */ 5470Sstevel@tonic-gate static enum ftt_type 5480Sstevel@tonic-gate vis_array( 5490Sstevel@tonic-gate fp_simd_type *pfpsd, /* FPU simulator data. */ 5500Sstevel@tonic-gate vis_inst_type inst, /* FPU instruction to simulate. */ 5510Sstevel@tonic-gate struct regs *pregs, /* Pointer to PCB image of registers. */ 5520Sstevel@tonic-gate void *prw) /* Pointer to locals and ins. */ 5530Sstevel@tonic-gate 5540Sstevel@tonic-gate { 5550Sstevel@tonic-gate uint_t nrs1, nrs2, nrd; /* Register number fields. */ 5560Sstevel@tonic-gate enum ftt_type ftt; 5570Sstevel@tonic-gate uint64_t laddr, bsize, baddr; 5580Sstevel@tonic-gate uint64_t nbit; 5590Sstevel@tonic-gate int oy, oz; 5600Sstevel@tonic-gate 5610Sstevel@tonic-gate nrs1 = inst.rs1; 5620Sstevel@tonic-gate nrs2 = inst.rs2; 5630Sstevel@tonic-gate nrd = inst.rd; 5640Sstevel@tonic-gate 5650Sstevel@tonic-gate ftt = read_iureg(pfpsd, nrs1, pregs, prw, &laddr); 5660Sstevel@tonic-gate if (ftt != ftt_none) 5670Sstevel@tonic-gate return (ftt); 5680Sstevel@tonic-gate ftt = read_iureg(pfpsd, nrs2, pregs, prw, &bsize); 5690Sstevel@tonic-gate if (ftt != ftt_none) 5700Sstevel@tonic-gate return (ftt); 5710Sstevel@tonic-gate 5720Sstevel@tonic-gate if (bsize > 5) { 5730Sstevel@tonic-gate bsize = 5; 5740Sstevel@tonic-gate } 5750Sstevel@tonic-gate nbit = (1 << bsize) - 1; /* Number of bits for XY<6+n-1:6> */ 5760Sstevel@tonic-gate oy = 17 + bsize; /* Offset of Y<6+n-1:6> */ 5770Sstevel@tonic-gate oz = 17 + 2 * bsize; /* Offset of Z<8:5> */ 5780Sstevel@tonic-gate 5790Sstevel@tonic-gate baddr = 0; 5800Sstevel@tonic-gate baddr |= (laddr >> (11 - 0)) & (0x03 << 0); /* X_integer<1:0> */ 5810Sstevel@tonic-gate baddr |= (laddr >> (33 - 2)) & (0x03 << 2); /* Y_integer<1:0> */ 5820Sstevel@tonic-gate baddr |= (laddr >> (55 - 4)) & (0x01 << 4); /* Z_integer<0> */ 5830Sstevel@tonic-gate baddr |= (laddr >> (13 - 5)) & (0x0f << 5); /* X_integer<5:2> */ 5840Sstevel@tonic-gate baddr |= (laddr >> (35 - 9)) & (0x0f << 9); /* Y_integer<5:2> */ 5850Sstevel@tonic-gate baddr |= (laddr >> (56 - 13)) & (0x0f << 13); /* Z_integer<4:1> */ 5860Sstevel@tonic-gate baddr |= (laddr >> (17 - 17)) & (nbit << 17); /* X_integer<6+n-1:6> */ 5870Sstevel@tonic-gate baddr |= (laddr >> (39 - oy)) & (nbit << oy); /* Y_integer<6+n-1:6> */ 5880Sstevel@tonic-gate baddr |= (laddr >> (60 - oz)) & (0x0f << oz); /* Z_integer<8:5> */ 5890Sstevel@tonic-gate 5900Sstevel@tonic-gate switch (inst.opf) { 5910Sstevel@tonic-gate case array8: 5920Sstevel@tonic-gate VISINFO_KSTAT(vis_array8); 5930Sstevel@tonic-gate break; 5940Sstevel@tonic-gate case array16: 5950Sstevel@tonic-gate VISINFO_KSTAT(vis_array16); 5960Sstevel@tonic-gate baddr <<= 1; 5970Sstevel@tonic-gate break; 5980Sstevel@tonic-gate case array32: 5990Sstevel@tonic-gate VISINFO_KSTAT(vis_array32); 6000Sstevel@tonic-gate baddr <<= 2; 6010Sstevel@tonic-gate break; 6020Sstevel@tonic-gate } 6030Sstevel@tonic-gate 6040Sstevel@tonic-gate ftt = write_iureg(pfpsd, nrd, pregs, prw, &baddr); 6050Sstevel@tonic-gate 6060Sstevel@tonic-gate return (ftt); 6070Sstevel@tonic-gate } 6080Sstevel@tonic-gate 6090Sstevel@tonic-gate /* 6100Sstevel@tonic-gate * Simulator for alignaddr and alignaddrl instructions. 6110Sstevel@tonic-gate */ 6120Sstevel@tonic-gate static enum ftt_type 6130Sstevel@tonic-gate vis_alignaddr( 6140Sstevel@tonic-gate fp_simd_type *pfpsd, /* FPU simulator data. */ 6150Sstevel@tonic-gate vis_inst_type inst, /* FPU instruction to simulate. */ 6160Sstevel@tonic-gate struct regs *pregs, /* Pointer to PCB image of registers. */ 6170Sstevel@tonic-gate void *prw, /* Pointer to locals and ins. */ 6180Sstevel@tonic-gate kfpu_t *fp) /* Need to fp to access gsr reg */ 6190Sstevel@tonic-gate { 6200Sstevel@tonic-gate uint_t nrs1, nrs2, nrd; /* Register number fields. */ 6210Sstevel@tonic-gate enum ftt_type ftt; 6220Sstevel@tonic-gate uint64_t ea, tea, g, r; 6230Sstevel@tonic-gate short s; 6240Sstevel@tonic-gate 6250Sstevel@tonic-gate nrs1 = inst.rs1; 6260Sstevel@tonic-gate nrs2 = inst.rs2; 6270Sstevel@tonic-gate nrd = inst.rd; 6280Sstevel@tonic-gate 6290Sstevel@tonic-gate ftt = read_iureg(pfpsd, nrs1, pregs, prw, &ea); 6300Sstevel@tonic-gate if (ftt != ftt_none) 6310Sstevel@tonic-gate return (ftt); 6320Sstevel@tonic-gate ftt = read_iureg(pfpsd, nrs2, pregs, prw, &tea); 6330Sstevel@tonic-gate if (ftt != ftt_none) 6340Sstevel@tonic-gate return (ftt); 6350Sstevel@tonic-gate ea += tea; 6360Sstevel@tonic-gate r = ea & ~0x7; /* zero least 3 significant bits */ 6370Sstevel@tonic-gate ftt = write_iureg(pfpsd, nrd, pregs, prw, &r); 6380Sstevel@tonic-gate 6390Sstevel@tonic-gate 6407Sdf157793 g = pfpsd->fp_current_read_gsr(fp); 6410Sstevel@tonic-gate g &= ~(GSR_ALIGN_MASK); /* zero the align offset */ 6420Sstevel@tonic-gate r = ea & 0x7; 6430Sstevel@tonic-gate if (inst.opf == alignaddrl) { 6440Sstevel@tonic-gate s = (short)(~r); /* 2's complement for alignaddrl */ 6450Sstevel@tonic-gate if (s < 0) 6460Sstevel@tonic-gate r = (uint64_t)((s + 1) & 0x7); 6470Sstevel@tonic-gate else 6480Sstevel@tonic-gate r = (uint64_t)(s & 0x7); 6490Sstevel@tonic-gate } 6500Sstevel@tonic-gate g |= (r << GSR_ALIGN_SHIFT) & GSR_ALIGN_MASK; 6517Sdf157793 pfpsd->fp_current_write_gsr(g, fp); 6520Sstevel@tonic-gate 6530Sstevel@tonic-gate return (ftt); 6540Sstevel@tonic-gate } 6550Sstevel@tonic-gate 6560Sstevel@tonic-gate /* 6570Sstevel@tonic-gate * Simulator for bmask instruction. 6580Sstevel@tonic-gate */ 6590Sstevel@tonic-gate static enum ftt_type 6600Sstevel@tonic-gate vis_bmask( 6610Sstevel@tonic-gate fp_simd_type *pfpsd, /* FPU simulator data. */ 6620Sstevel@tonic-gate vis_inst_type inst, /* FPU instruction to simulate. */ 6630Sstevel@tonic-gate struct regs *pregs, /* Pointer to PCB image of registers. */ 6640Sstevel@tonic-gate void *prw, /* Pointer to locals and ins. */ 6650Sstevel@tonic-gate kfpu_t *fp) /* Need to fp to access gsr reg */ 6660Sstevel@tonic-gate { 6670Sstevel@tonic-gate uint_t nrs1, nrs2, nrd; /* Register number fields. */ 6680Sstevel@tonic-gate enum ftt_type ftt; 6690Sstevel@tonic-gate uint64_t ea, tea, g; 6700Sstevel@tonic-gate 6710Sstevel@tonic-gate VISINFO_KSTAT(vis_bmask); 6720Sstevel@tonic-gate nrs1 = inst.rs1; 6730Sstevel@tonic-gate nrs2 = inst.rs2; 6740Sstevel@tonic-gate nrd = inst.rd; 6750Sstevel@tonic-gate 6760Sstevel@tonic-gate ftt = read_iureg(pfpsd, nrs1, pregs, prw, &ea); 6770Sstevel@tonic-gate if (ftt != ftt_none) 6780Sstevel@tonic-gate return (ftt); 6790Sstevel@tonic-gate ftt = read_iureg(pfpsd, nrs2, pregs, prw, &tea); 6800Sstevel@tonic-gate if (ftt != ftt_none) 6810Sstevel@tonic-gate return (ftt); 6820Sstevel@tonic-gate ea += tea; 6830Sstevel@tonic-gate ftt = write_iureg(pfpsd, nrd, pregs, prw, &ea); 6840Sstevel@tonic-gate 6857Sdf157793 g = pfpsd->fp_current_read_gsr(fp); 6860Sstevel@tonic-gate g &= ~(GSR_MASK_MASK); /* zero the mask offset */ 6870Sstevel@tonic-gate 6880Sstevel@tonic-gate /* Put the least significant 32 bits of ea in GSR.mask */ 6890Sstevel@tonic-gate g |= (ea << GSR_MASK_SHIFT) & GSR_MASK_MASK; 6907Sdf157793 pfpsd->fp_current_write_gsr(g, fp); 6910Sstevel@tonic-gate return (ftt); 6920Sstevel@tonic-gate } 6930Sstevel@tonic-gate 6940Sstevel@tonic-gate /* 6950Sstevel@tonic-gate * Simulator for fp[add|sub]* instruction. 6960Sstevel@tonic-gate */ 6970Sstevel@tonic-gate static enum ftt_type 6980Sstevel@tonic-gate vis_fpaddsub( 6990Sstevel@tonic-gate fp_simd_type *pfpsd, /* FPU simulator data. */ 7000Sstevel@tonic-gate vis_inst_type inst) /* FPU instruction to simulate. */ 7010Sstevel@tonic-gate { 7020Sstevel@tonic-gate uint_t nrs1, nrs2, nrd; /* Register number fields. */ 7030Sstevel@tonic-gate union { 7040Sstevel@tonic-gate uint64_t ll; 7050Sstevel@tonic-gate uint32_t i[2]; 7060Sstevel@tonic-gate uint16_t s[4]; 7070Sstevel@tonic-gate } lrs1, lrs2, lrd; 7080Sstevel@tonic-gate union { 7090Sstevel@tonic-gate uint32_t i; 7100Sstevel@tonic-gate uint16_t s[2]; 7110Sstevel@tonic-gate } krs1, krs2, krd; 7120Sstevel@tonic-gate int i; 7130Sstevel@tonic-gate 7140Sstevel@tonic-gate nrs1 = inst.rs1; 7150Sstevel@tonic-gate nrs2 = inst.rs2; 7160Sstevel@tonic-gate nrd = inst.rd; 7170Sstevel@tonic-gate if ((inst.opf & 1) == 0) { /* double precision */ 7180Sstevel@tonic-gate if ((nrs1 & 1) == 1) /* fix register encoding */ 7190Sstevel@tonic-gate nrs1 = (nrs1 & 0x1e) | 0x20; 7200Sstevel@tonic-gate if ((nrs2 & 1) == 1) 7210Sstevel@tonic-gate nrs2 = (nrs2 & 0x1e) | 0x20; 7220Sstevel@tonic-gate if ((nrd & 1) == 1) 7230Sstevel@tonic-gate nrd = (nrd & 0x1e) | 0x20; 7240Sstevel@tonic-gate } 7250Sstevel@tonic-gate switch (inst.opf) { 7260Sstevel@tonic-gate case fpadd16: 7270Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lrs1.ll, nrs1); 7280Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lrs2.ll, nrs2); 7290Sstevel@tonic-gate for (i = 0; i <= 3; i++) { 7300Sstevel@tonic-gate lrd.s[i] = lrs1.s[i] + lrs2.s[i]; 7310Sstevel@tonic-gate } 7320Sstevel@tonic-gate _fp_pack_extword(pfpsd, &lrd.ll, nrd); 7330Sstevel@tonic-gate break; 7340Sstevel@tonic-gate case fpadd16s: 7350Sstevel@tonic-gate _fp_unpack_word(pfpsd, &krs1.i, nrs1); 7360Sstevel@tonic-gate _fp_unpack_word(pfpsd, &krs2.i, nrs2); 7370Sstevel@tonic-gate for (i = 0; i <= 1; i++) { 7380Sstevel@tonic-gate krd.s[i] = krs1.s[i] + krs2.s[i]; 7390Sstevel@tonic-gate } 7400Sstevel@tonic-gate _fp_pack_word(pfpsd, &krd.i, nrd); 7410Sstevel@tonic-gate break; 7420Sstevel@tonic-gate case fpadd32: 7430Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lrs1.ll, nrs1); 7440Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lrs2.ll, nrs2); 7450Sstevel@tonic-gate for (i = 0; i <= 1; i++) { 7460Sstevel@tonic-gate lrd.i[i] = lrs1.i[i] + lrs2.i[i]; 7470Sstevel@tonic-gate } 7480Sstevel@tonic-gate _fp_pack_extword(pfpsd, &lrd.ll, nrd); 7490Sstevel@tonic-gate break; 7500Sstevel@tonic-gate case fpadd32s: 7510Sstevel@tonic-gate _fp_unpack_word(pfpsd, &krs1.i, nrs1); 7520Sstevel@tonic-gate _fp_unpack_word(pfpsd, &krs2.i, nrs2); 7530Sstevel@tonic-gate krd.i = krs1.i + krs2.i; 7540Sstevel@tonic-gate _fp_pack_word(pfpsd, &krd.i, nrd); 7550Sstevel@tonic-gate break; 7560Sstevel@tonic-gate case fpsub16: 7570Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lrs1.ll, nrs1); 7580Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lrs2.ll, nrs2); 7590Sstevel@tonic-gate for (i = 0; i <= 3; i++) { 7600Sstevel@tonic-gate lrd.s[i] = lrs1.s[i] - lrs2.s[i]; 7610Sstevel@tonic-gate } 7620Sstevel@tonic-gate _fp_pack_extword(pfpsd, &lrd.ll, nrd); 7630Sstevel@tonic-gate break; 7640Sstevel@tonic-gate case fpsub16s: 7650Sstevel@tonic-gate _fp_unpack_word(pfpsd, &krs1.i, nrs1); 7660Sstevel@tonic-gate _fp_unpack_word(pfpsd, &krs2.i, nrs2); 7670Sstevel@tonic-gate for (i = 0; i <= 1; i++) { 7680Sstevel@tonic-gate krd.s[i] = krs1.s[i] - krs2.s[i]; 7690Sstevel@tonic-gate } 7700Sstevel@tonic-gate _fp_pack_word(pfpsd, &krd.i, nrd); 7710Sstevel@tonic-gate break; 7720Sstevel@tonic-gate case fpsub32: 7730Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lrs1.ll, nrs1); 7740Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lrs2.ll, nrs2); 7750Sstevel@tonic-gate for (i = 0; i <= 1; i++) { 7760Sstevel@tonic-gate lrd.i[i] = lrs1.i[i] - lrs2.i[i]; 7770Sstevel@tonic-gate } 7780Sstevel@tonic-gate _fp_pack_extword(pfpsd, &lrd.ll, nrd); 7790Sstevel@tonic-gate break; 7800Sstevel@tonic-gate case fpsub32s: 7810Sstevel@tonic-gate _fp_unpack_word(pfpsd, &krs1.i, nrs1); 7820Sstevel@tonic-gate _fp_unpack_word(pfpsd, &krs2.i, nrs2); 7830Sstevel@tonic-gate krd.i = krs1.i - krs2.i; 7840Sstevel@tonic-gate _fp_pack_word(pfpsd, &krd.i, nrd); 7850Sstevel@tonic-gate break; 7860Sstevel@tonic-gate } 7870Sstevel@tonic-gate return (ftt_none); 7880Sstevel@tonic-gate } 7890Sstevel@tonic-gate 7900Sstevel@tonic-gate /* 7910Sstevel@tonic-gate * Simulator for fcmp* instruction. 7920Sstevel@tonic-gate */ 7930Sstevel@tonic-gate static enum ftt_type 7940Sstevel@tonic-gate vis_fcmp( 7950Sstevel@tonic-gate fp_simd_type *pfpsd, /* FPU simulator data. */ 7960Sstevel@tonic-gate vis_inst_type inst, /* FPU instruction to simulate. */ 7970Sstevel@tonic-gate struct regs *pregs, /* Pointer to PCB image of registers. */ 7980Sstevel@tonic-gate void *prw) /* Pointer to locals and ins. */ 7990Sstevel@tonic-gate { 8000Sstevel@tonic-gate uint_t nrs1, nrs2, nrd; /* Register number fields. */ 8010Sstevel@tonic-gate union { 8020Sstevel@tonic-gate uint64_t ll; 8030Sstevel@tonic-gate uint32_t i[2]; 8040Sstevel@tonic-gate uint16_t s[4]; 8050Sstevel@tonic-gate } krs1, krs2, krd; 8060Sstevel@tonic-gate enum ftt_type ftt; 8070Sstevel@tonic-gate short sr1, sr2; 8080Sstevel@tonic-gate int i, ir1, ir2; 8090Sstevel@tonic-gate 8100Sstevel@tonic-gate nrs1 = inst.rs1; 8110Sstevel@tonic-gate nrs2 = inst.rs2; 8120Sstevel@tonic-gate nrd = inst.rd; 8130Sstevel@tonic-gate krd.ll = 0; 8140Sstevel@tonic-gate if ((nrs1 & 1) == 1) /* fix register encoding */ 8150Sstevel@tonic-gate nrs1 = (nrs1 & 0x1e) | 0x20; 8160Sstevel@tonic-gate if ((nrs2 & 1) == 1) 8170Sstevel@tonic-gate nrs2 = (nrs2 & 0x1e) | 0x20; 8180Sstevel@tonic-gate 8190Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &krs1.ll, nrs1); 8200Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &krs2.ll, nrs2); 8210Sstevel@tonic-gate switch (inst.opf) { 8220Sstevel@tonic-gate case fcmple16: 8230Sstevel@tonic-gate VISINFO_KSTAT(vis_fcmple16); 8240Sstevel@tonic-gate for (i = 0; i <= 3; i++) { 8250Sstevel@tonic-gate sr1 = (short)krs1.s[i]; 8260Sstevel@tonic-gate sr2 = (short)krs2.s[i]; 8270Sstevel@tonic-gate if (sr1 <= sr2) 8280Sstevel@tonic-gate krd.ll += (0x8 >> i); 8290Sstevel@tonic-gate } 8300Sstevel@tonic-gate break; 8310Sstevel@tonic-gate case fcmpne16: 8320Sstevel@tonic-gate VISINFO_KSTAT(vis_fcmpne16); 8330Sstevel@tonic-gate for (i = 0; i <= 3; i++) { 8340Sstevel@tonic-gate sr1 = (short)krs1.s[i]; 8350Sstevel@tonic-gate sr2 = (short)krs2.s[i]; 8360Sstevel@tonic-gate if (sr1 != sr2) 8370Sstevel@tonic-gate krd.ll += (0x8 >> i); 8380Sstevel@tonic-gate } 8390Sstevel@tonic-gate break; 8400Sstevel@tonic-gate case fcmpgt16: 8410Sstevel@tonic-gate VISINFO_KSTAT(vis_fcmpgt16); 8420Sstevel@tonic-gate for (i = 0; i <= 3; i++) { 8430Sstevel@tonic-gate sr1 = (short)krs1.s[i]; 8440Sstevel@tonic-gate sr2 = (short)krs2.s[i]; 8450Sstevel@tonic-gate if (sr1 > sr2) 8460Sstevel@tonic-gate krd.ll += (0x8 >> i); 8470Sstevel@tonic-gate } 8480Sstevel@tonic-gate break; 8490Sstevel@tonic-gate case fcmpeq16: 8500Sstevel@tonic-gate VISINFO_KSTAT(vis_fcmpeq16); 8510Sstevel@tonic-gate for (i = 0; i <= 3; i++) { 8520Sstevel@tonic-gate sr1 = (short)krs1.s[i]; 8530Sstevel@tonic-gate sr2 = (short)krs2.s[i]; 8540Sstevel@tonic-gate if (sr1 == sr2) 8550Sstevel@tonic-gate krd.ll += (0x8 >> i); 8560Sstevel@tonic-gate } 8570Sstevel@tonic-gate break; 8580Sstevel@tonic-gate case fcmple32: 8590Sstevel@tonic-gate VISINFO_KSTAT(vis_fcmple32); 8600Sstevel@tonic-gate for (i = 0; i <= 1; i++) { 8610Sstevel@tonic-gate ir1 = (int)krs1.i[i]; 8620Sstevel@tonic-gate ir2 = (int)krs2.i[i]; 8630Sstevel@tonic-gate if (ir1 <= ir2) 8640Sstevel@tonic-gate krd.ll += (0x2 >> i); 8650Sstevel@tonic-gate } 8660Sstevel@tonic-gate break; 8670Sstevel@tonic-gate case fcmpne32: 8680Sstevel@tonic-gate VISINFO_KSTAT(vis_fcmpne32); 8690Sstevel@tonic-gate for (i = 0; i <= 1; i++) { 8700Sstevel@tonic-gate ir1 = (int)krs1.i[i]; 8710Sstevel@tonic-gate ir2 = (int)krs2.i[i]; 8720Sstevel@tonic-gate if (ir1 != ir2) 8730Sstevel@tonic-gate krd.ll += (0x2 >> i); 8740Sstevel@tonic-gate } 8750Sstevel@tonic-gate break; 8760Sstevel@tonic-gate case fcmpgt32: 8770Sstevel@tonic-gate VISINFO_KSTAT(vis_fcmpgt32); 8780Sstevel@tonic-gate for (i = 0; i <= 1; i++) { 8790Sstevel@tonic-gate ir1 = (int)krs1.i[i]; 8800Sstevel@tonic-gate ir2 = (int)krs2.i[i]; 8810Sstevel@tonic-gate if (ir1 > ir2) 8820Sstevel@tonic-gate krd.ll += (0x2 >> i); 8830Sstevel@tonic-gate } 8840Sstevel@tonic-gate break; 8850Sstevel@tonic-gate case fcmpeq32: 8860Sstevel@tonic-gate VISINFO_KSTAT(vis_fcmpeq32); 8870Sstevel@tonic-gate for (i = 0; i <= 1; i++) { 8880Sstevel@tonic-gate ir1 = (int)krs1.i[i]; 8890Sstevel@tonic-gate ir2 = (int)krs2.i[i]; 8900Sstevel@tonic-gate if (ir1 == ir2) 8910Sstevel@tonic-gate krd.ll += (0x2 >> i); 8920Sstevel@tonic-gate } 8930Sstevel@tonic-gate break; 8940Sstevel@tonic-gate } 8950Sstevel@tonic-gate ftt = write_iureg(pfpsd, nrd, pregs, prw, &krd.ll); 8960Sstevel@tonic-gate return (ftt); 8970Sstevel@tonic-gate } 8980Sstevel@tonic-gate 8990Sstevel@tonic-gate /* 9000Sstevel@tonic-gate * Simulator for fmul* instruction. 9010Sstevel@tonic-gate */ 9020Sstevel@tonic-gate static enum ftt_type 9030Sstevel@tonic-gate vis_fmul( 9040Sstevel@tonic-gate fp_simd_type *pfpsd, /* FPU simulator data. */ 9050Sstevel@tonic-gate vis_inst_type inst) /* FPU instruction to simulate. */ 9060Sstevel@tonic-gate { 9070Sstevel@tonic-gate uint_t nrs1, nrs2, nrd; /* Register number fields. */ 9080Sstevel@tonic-gate union { 9090Sstevel@tonic-gate uint64_t ll; 9100Sstevel@tonic-gate uint32_t i[2]; 9110Sstevel@tonic-gate uint16_t s[4]; 9120Sstevel@tonic-gate uint8_t c[8]; 9130Sstevel@tonic-gate } lrs1, lrs2, lrd; 9140Sstevel@tonic-gate union { 9150Sstevel@tonic-gate uint32_t i; 9160Sstevel@tonic-gate uint16_t s[2]; 9170Sstevel@tonic-gate uint8_t c[4]; 9180Sstevel@tonic-gate } krs1, krs2, kres; 9190Sstevel@tonic-gate short s1, s2, sres; 9200Sstevel@tonic-gate ushort_t us1; 9210Sstevel@tonic-gate char c1; 9220Sstevel@tonic-gate int i; 9230Sstevel@tonic-gate 9240Sstevel@tonic-gate nrs1 = inst.rs1; 9250Sstevel@tonic-gate nrs2 = inst.rs2; 9260Sstevel@tonic-gate nrd = inst.rd; 9270Sstevel@tonic-gate if ((inst.opf & 1) == 0) { /* double precision */ 9280Sstevel@tonic-gate if ((nrd & 1) == 1) /* fix register encoding */ 9290Sstevel@tonic-gate nrd = (nrd & 0x1e) | 0x20; 9300Sstevel@tonic-gate } 9310Sstevel@tonic-gate 9320Sstevel@tonic-gate switch (inst.opf) { 9330Sstevel@tonic-gate case fmul8x16: 9340Sstevel@tonic-gate VISINFO_KSTAT(vis_fmul8x16); 9350Sstevel@tonic-gate _fp_unpack_word(pfpsd, &krs1.i, nrs1); 9360Sstevel@tonic-gate if ((nrs2 & 1) == 1) 9370Sstevel@tonic-gate nrs2 = (nrs2 & 0x1e) | 0x20; 9380Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lrs2.ll, nrs2); 9390Sstevel@tonic-gate for (i = 0; i <= 3; i++) { 9400Sstevel@tonic-gate us1 = (ushort_t)krs1.c[i]; 9410Sstevel@tonic-gate s2 = (short)lrs2.s[i]; 9420Sstevel@tonic-gate kres.i = us1 * s2; 9430Sstevel@tonic-gate sres = (short)((kres.c[1] << 8) | kres.c[2]); 9440Sstevel@tonic-gate if (kres.c[3] >= 0x80) 9450Sstevel@tonic-gate sres++; 9460Sstevel@tonic-gate lrd.s[i] = sres; 9470Sstevel@tonic-gate } 9480Sstevel@tonic-gate _fp_pack_extword(pfpsd, &lrd.ll, nrd); 9490Sstevel@tonic-gate break; 9500Sstevel@tonic-gate case fmul8x16au: 9510Sstevel@tonic-gate VISINFO_KSTAT(vis_fmul8x16au); 9520Sstevel@tonic-gate _fp_unpack_word(pfpsd, &krs1.i, nrs1); 9530Sstevel@tonic-gate _fp_unpack_word(pfpsd, &krs2.i, nrs2); 9540Sstevel@tonic-gate for (i = 0; i <= 3; i++) { 9550Sstevel@tonic-gate us1 = (ushort_t)krs1.c[i]; 9560Sstevel@tonic-gate s2 = (short)krs2.s[0]; 9570Sstevel@tonic-gate kres.i = us1 * s2; 9580Sstevel@tonic-gate sres = (short)((kres.c[1] << 8) | kres.c[2]); 9590Sstevel@tonic-gate if (kres.c[3] >= 0x80) 9600Sstevel@tonic-gate sres++; 9610Sstevel@tonic-gate lrd.s[i] = sres; 9620Sstevel@tonic-gate } 9630Sstevel@tonic-gate _fp_pack_extword(pfpsd, &lrd.ll, nrd); 9640Sstevel@tonic-gate break; 9650Sstevel@tonic-gate case fmul8x16al: 9660Sstevel@tonic-gate VISINFO_KSTAT(vis_fmul8x16al); 9670Sstevel@tonic-gate _fp_unpack_word(pfpsd, &krs1.i, nrs1); 9680Sstevel@tonic-gate _fp_unpack_word(pfpsd, &krs2.i, nrs2); 9690Sstevel@tonic-gate for (i = 0; i <= 3; i++) { 9700Sstevel@tonic-gate us1 = (ushort_t)krs1.c[i]; 9710Sstevel@tonic-gate s2 = (short)krs2.s[1]; 9720Sstevel@tonic-gate kres.i = us1 * s2; 9730Sstevel@tonic-gate sres = (short)((kres.c[1] << 8) | kres.c[2]); 9740Sstevel@tonic-gate if (kres.c[3] >= 0x80) 9750Sstevel@tonic-gate sres++; 9760Sstevel@tonic-gate lrd.s[i] = sres; 9770Sstevel@tonic-gate } 9780Sstevel@tonic-gate _fp_pack_extword(pfpsd, &lrd.ll, nrd); 9790Sstevel@tonic-gate break; 9800Sstevel@tonic-gate case fmul8sux16: 9810Sstevel@tonic-gate VISINFO_KSTAT(vis_fmul8sux16); 9820Sstevel@tonic-gate if ((nrs1 & 1) == 1) /* fix register encoding */ 9830Sstevel@tonic-gate nrs1 = (nrs1 & 0x1e) | 0x20; 9840Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lrs1.ll, nrs1); 9850Sstevel@tonic-gate if ((nrs2 & 1) == 1) 9860Sstevel@tonic-gate nrs2 = (nrs2 & 0x1e) | 0x20; 9870Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lrs2.ll, nrs2); 9880Sstevel@tonic-gate for (i = 0; i <= 3; i++) { 9890Sstevel@tonic-gate c1 = lrs1.c[(i*2)]; 9900Sstevel@tonic-gate s1 = (short)c1; /* keeps the sign alive */ 9910Sstevel@tonic-gate s2 = (short)lrs2.s[i]; 9920Sstevel@tonic-gate kres.i = s1 * s2; 9930Sstevel@tonic-gate sres = (short)((kres.c[1] << 8) | kres.c[2]); 9940Sstevel@tonic-gate if (kres.c[3] >= 0x80) 9950Sstevel@tonic-gate sres++; 9960Sstevel@tonic-gate if (sres < 0) 9970Sstevel@tonic-gate lrd.s[i] = (sres & 0xFFFF); 9980Sstevel@tonic-gate else 9990Sstevel@tonic-gate lrd.s[i] = sres; 10000Sstevel@tonic-gate } 10010Sstevel@tonic-gate _fp_pack_extword(pfpsd, &lrd.ll, nrd); 10020Sstevel@tonic-gate break; 10030Sstevel@tonic-gate case fmul8ulx16: 10040Sstevel@tonic-gate VISINFO_KSTAT(vis_fmul8ulx16); 10050Sstevel@tonic-gate if ((nrs1 & 1) == 1) /* fix register encoding */ 10060Sstevel@tonic-gate nrs1 = (nrs1 & 0x1e) | 0x20; 10070Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lrs1.ll, nrs1); 10080Sstevel@tonic-gate if ((nrs2 & 1) == 1) 10090Sstevel@tonic-gate nrs2 = (nrs2 & 0x1e) | 0x20; 10100Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lrs2.ll, nrs2); 10110Sstevel@tonic-gate for (i = 0; i <= 3; i++) { 10120Sstevel@tonic-gate us1 = (ushort_t)lrs1.c[(i*2)+1]; 10130Sstevel@tonic-gate s2 = (short)lrs2.s[i]; 10140Sstevel@tonic-gate kres.i = us1 * s2; 10150Sstevel@tonic-gate sres = (short)kres.s[0]; 10160Sstevel@tonic-gate if (kres.s[1] >= 0x8000) 10170Sstevel@tonic-gate sres++; 10180Sstevel@tonic-gate lrd.s[i] = sres; 10190Sstevel@tonic-gate } 10200Sstevel@tonic-gate _fp_pack_extword(pfpsd, &lrd.ll, nrd); 10210Sstevel@tonic-gate break; 10220Sstevel@tonic-gate case fmuld8sux16: 10230Sstevel@tonic-gate VISINFO_KSTAT(vis_fmuld8sux16); 10240Sstevel@tonic-gate _fp_unpack_word(pfpsd, &krs1.i, nrs1); 10250Sstevel@tonic-gate _fp_unpack_word(pfpsd, &krs2.i, nrs2); 10260Sstevel@tonic-gate for (i = 0; i <= 1; i++) { 10270Sstevel@tonic-gate c1 = krs1.c[(i*2)]; 10280Sstevel@tonic-gate s1 = (short)c1; /* keeps the sign alive */ 10290Sstevel@tonic-gate s2 = (short)krs2.s[i]; 10300Sstevel@tonic-gate kres.i = s1 * s2; 10310Sstevel@tonic-gate lrd.i[i] = kres.i << 8; 10320Sstevel@tonic-gate } 10330Sstevel@tonic-gate _fp_pack_extword(pfpsd, &lrd.ll, nrd); 10340Sstevel@tonic-gate break; 10350Sstevel@tonic-gate case fmuld8ulx16: 10360Sstevel@tonic-gate VISINFO_KSTAT(vis_fmuld8ulx16); 10370Sstevel@tonic-gate _fp_unpack_word(pfpsd, &krs1.i, nrs1); 10380Sstevel@tonic-gate _fp_unpack_word(pfpsd, &krs2.i, nrs2); 10390Sstevel@tonic-gate for (i = 0; i <= 1; i++) { 10400Sstevel@tonic-gate us1 = (ushort_t)krs1.c[(i*2)+1]; 10410Sstevel@tonic-gate s2 = (short)krs2.s[i]; 10420Sstevel@tonic-gate lrd.i[i] = us1 * s2; 10430Sstevel@tonic-gate } 10440Sstevel@tonic-gate _fp_pack_extword(pfpsd, &lrd.ll, nrd); 10450Sstevel@tonic-gate break; 10460Sstevel@tonic-gate } 10470Sstevel@tonic-gate return (ftt_none); 10480Sstevel@tonic-gate } 10490Sstevel@tonic-gate 10500Sstevel@tonic-gate /* 10510Sstevel@tonic-gate * Simulator for fpixel formatting instructions. 10520Sstevel@tonic-gate */ 10530Sstevel@tonic-gate static enum ftt_type 10540Sstevel@tonic-gate vis_fpixel( 10550Sstevel@tonic-gate fp_simd_type *pfpsd, /* FPU simulator data. */ 10560Sstevel@tonic-gate vis_inst_type inst, /* FPU instruction to simulate. */ 10570Sstevel@tonic-gate kfpu_t *fp) /* Need to fp to access gsr reg */ 10580Sstevel@tonic-gate { 10590Sstevel@tonic-gate uint_t nrs1, nrs2, nrd; /* Register number fields. */ 10600Sstevel@tonic-gate int i, j, k, sf; 10610Sstevel@tonic-gate union { 10620Sstevel@tonic-gate uint64_t ll; 10630Sstevel@tonic-gate uint32_t i[2]; 10640Sstevel@tonic-gate uint16_t s[4]; 10650Sstevel@tonic-gate uint8_t c[8]; 10660Sstevel@tonic-gate } lrs1, lrs2, lrd; 10670Sstevel@tonic-gate union { 10680Sstevel@tonic-gate uint32_t i; 10690Sstevel@tonic-gate uint16_t s[2]; 10700Sstevel@tonic-gate uint8_t c[4]; 10710Sstevel@tonic-gate } krs1, krs2, krd; 10720Sstevel@tonic-gate uint64_t r; 10730Sstevel@tonic-gate int64_t l, m; 10740Sstevel@tonic-gate short s; 10750Sstevel@tonic-gate uchar_t uc; 10760Sstevel@tonic-gate 10770Sstevel@tonic-gate nrs1 = inst.rs1; 10780Sstevel@tonic-gate nrs2 = inst.rs2; 10790Sstevel@tonic-gate nrd = inst.rd; 10800Sstevel@tonic-gate if ((inst.opf != fpack16) && (inst.opf != fpackfix)) { 10810Sstevel@tonic-gate if ((nrd & 1) == 1) /* fix register encoding */ 10820Sstevel@tonic-gate nrd = (nrd & 0x1e) | 0x20; 10830Sstevel@tonic-gate } 10840Sstevel@tonic-gate 10850Sstevel@tonic-gate switch (inst.opf) { 10860Sstevel@tonic-gate case fpack16: 10870Sstevel@tonic-gate VISINFO_KSTAT(vis_fpack16); 10880Sstevel@tonic-gate if ((nrs2 & 1) == 1) /* fix register encoding */ 10890Sstevel@tonic-gate nrs2 = (nrs2 & 0x1e) | 0x20; 10900Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lrs2.ll, nrs2); 10917Sdf157793 r = pfpsd->fp_current_read_gsr(fp); 10920Sstevel@tonic-gate /* fpack16 ignores GSR.scale msb */ 10930Sstevel@tonic-gate sf = (int)(GSR_SCALE(r) & 0xf); 10940Sstevel@tonic-gate for (i = 0; i <= 3; i++) { 10950Sstevel@tonic-gate s = (short)lrs2.s[i]; /* preserve the sign */ 10960Sstevel@tonic-gate j = ((int)s << sf); 10970Sstevel@tonic-gate k = j >> 7; 10980Sstevel@tonic-gate if (k < 0) { 10990Sstevel@tonic-gate uc = 0; 11000Sstevel@tonic-gate } else if (k > 255) { 11010Sstevel@tonic-gate uc = 255; 11020Sstevel@tonic-gate } else { 11030Sstevel@tonic-gate uc = (uchar_t)k; 11040Sstevel@tonic-gate } 11050Sstevel@tonic-gate krd.c[i] = uc; 11060Sstevel@tonic-gate } 11070Sstevel@tonic-gate _fp_pack_word(pfpsd, &krd.i, nrd); 11080Sstevel@tonic-gate break; 11090Sstevel@tonic-gate case fpack32: 11100Sstevel@tonic-gate VISINFO_KSTAT(vis_fpack32); 11110Sstevel@tonic-gate if ((nrs1 & 1) == 1) /* fix register encoding */ 11120Sstevel@tonic-gate nrs1 = (nrs1 & 0x1e) | 0x20; 11130Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lrs1.ll, nrs1); 11140Sstevel@tonic-gate if ((nrs2 & 1) == 1) 11150Sstevel@tonic-gate nrs2 = (nrs2 & 0x1e) | 0x20; 11160Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lrs2.ll, nrs2); 11170Sstevel@tonic-gate 11187Sdf157793 r = pfpsd->fp_current_read_gsr(fp); 11190Sstevel@tonic-gate sf = (int)GSR_SCALE(r); 11200Sstevel@tonic-gate lrd.ll = lrs1.ll << 8; 11210Sstevel@tonic-gate for (i = 0, k = 3; i <= 1; i++, k += 4) { 11220Sstevel@tonic-gate j = (int)lrs2.i[i]; /* preserve the sign */ 11230Sstevel@tonic-gate l = ((int64_t)j << sf); 11240Sstevel@tonic-gate m = l >> 23; 11250Sstevel@tonic-gate if (m < 0) { 11260Sstevel@tonic-gate uc = 0; 11270Sstevel@tonic-gate } else if (m > 255) { 11280Sstevel@tonic-gate uc = 255; 11290Sstevel@tonic-gate } else { 11300Sstevel@tonic-gate uc = (uchar_t)m; 11310Sstevel@tonic-gate } 11320Sstevel@tonic-gate lrd.c[k] = uc; 11330Sstevel@tonic-gate } 11340Sstevel@tonic-gate _fp_pack_extword(pfpsd, &lrd.ll, nrd); 11350Sstevel@tonic-gate break; 11360Sstevel@tonic-gate case fpackfix: 11370Sstevel@tonic-gate VISINFO_KSTAT(vis_fpackfix); 11380Sstevel@tonic-gate if ((nrs2 & 1) == 1) 11390Sstevel@tonic-gate nrs2 = (nrs2 & 0x1e) | 0x20; 11400Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lrs2.ll, nrs2); 11410Sstevel@tonic-gate 11427Sdf157793 r = pfpsd->fp_current_read_gsr(fp); 11430Sstevel@tonic-gate sf = (int)GSR_SCALE(r); 11440Sstevel@tonic-gate for (i = 0; i <= 1; i++) { 11450Sstevel@tonic-gate j = (int)lrs2.i[i]; /* preserve the sign */ 11460Sstevel@tonic-gate l = ((int64_t)j << sf); 11470Sstevel@tonic-gate m = l >> 16; 11480Sstevel@tonic-gate if (m < -32768) { 11490Sstevel@tonic-gate s = -32768; 11500Sstevel@tonic-gate } else if (m > 32767) { 11510Sstevel@tonic-gate s = 32767; 11520Sstevel@tonic-gate } else { 11530Sstevel@tonic-gate s = (short)m; 11540Sstevel@tonic-gate } 11550Sstevel@tonic-gate krd.s[i] = s; 11560Sstevel@tonic-gate } 11570Sstevel@tonic-gate _fp_pack_word(pfpsd, &krd.i, nrd); 11580Sstevel@tonic-gate break; 11590Sstevel@tonic-gate case fexpand: 11600Sstevel@tonic-gate VISINFO_KSTAT(vis_fexpand); 11610Sstevel@tonic-gate _fp_unpack_word(pfpsd, &krs2.i, nrs2); 11620Sstevel@tonic-gate for (i = 0; i <= 3; i++) { 11630Sstevel@tonic-gate uc = krs2.c[i]; 11640Sstevel@tonic-gate lrd.s[i] = (ushort_t)(uc << 4); 11650Sstevel@tonic-gate } 11660Sstevel@tonic-gate _fp_pack_extword(pfpsd, &lrd.ll, nrd); 11670Sstevel@tonic-gate break; 11680Sstevel@tonic-gate case fpmerge: 11690Sstevel@tonic-gate VISINFO_KSTAT(vis_fpmerge); 11700Sstevel@tonic-gate _fp_unpack_word(pfpsd, &krs1.i, nrs1); 11710Sstevel@tonic-gate _fp_unpack_word(pfpsd, &krs2.i, nrs2); 11720Sstevel@tonic-gate for (i = 0, j = 0; i <= 3; i++, j += 2) { 11730Sstevel@tonic-gate lrd.c[j] = krs1.c[i]; 11740Sstevel@tonic-gate lrd.c[j+1] = krs2.c[i]; 11750Sstevel@tonic-gate } 11760Sstevel@tonic-gate _fp_pack_extword(pfpsd, &lrd.ll, nrd); 11770Sstevel@tonic-gate break; 11780Sstevel@tonic-gate } 11790Sstevel@tonic-gate return (ftt_none); 11800Sstevel@tonic-gate } 11810Sstevel@tonic-gate 11820Sstevel@tonic-gate /* 11830Sstevel@tonic-gate * Simulator for pdist instruction. 11840Sstevel@tonic-gate */ 11850Sstevel@tonic-gate enum ftt_type 11860Sstevel@tonic-gate vis_pdist( 11870Sstevel@tonic-gate fp_simd_type *pfpsd, /* FPU simulator data. */ 1188*8829SSree.Vemuri@Sun.COM fp_inst_type pinst, /* FPU instruction to simulate. */ 1189*8829SSree.Vemuri@Sun.COM struct regs *pregs, /* Pointer to PCB image of registers. */ 1190*8829SSree.Vemuri@Sun.COM void *prw, /* Pointer to locals and ins. */ 1191*8829SSree.Vemuri@Sun.COM uint_t op) /* Opcode pdist or pdistn */ 11920Sstevel@tonic-gate { 11930Sstevel@tonic-gate uint_t nrs1, nrs2, nrd; /* Register number fields. */ 11940Sstevel@tonic-gate int i; 11950Sstevel@tonic-gate short s; 11960Sstevel@tonic-gate union { 11970Sstevel@tonic-gate uint64_t ll; 11980Sstevel@tonic-gate uint8_t c[8]; 11990Sstevel@tonic-gate } lrs1, lrs2, lrd; 12000Sstevel@tonic-gate 12010Sstevel@tonic-gate nrs1 = pinst.rs1; 12020Sstevel@tonic-gate nrs2 = pinst.rs2; 12030Sstevel@tonic-gate nrd = pinst.rd; 1204*8829SSree.Vemuri@Sun.COM 12050Sstevel@tonic-gate if ((nrs1 & 1) == 1) /* fix register encoding */ 12060Sstevel@tonic-gate nrs1 = (nrs1 & 0x1e) | 0x20; 12070Sstevel@tonic-gate if ((nrs2 & 1) == 1) 12080Sstevel@tonic-gate nrs2 = (nrs2 & 0x1e) | 0x20; 12090Sstevel@tonic-gate if ((nrd & 1) == 1) 12100Sstevel@tonic-gate nrd = (nrd & 0x1e) | 0x20; 12110Sstevel@tonic-gate 12120Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lrs1.ll, nrs1); 12130Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lrs2.ll, nrs2); 1214*8829SSree.Vemuri@Sun.COM 1215*8829SSree.Vemuri@Sun.COM if (op == pdist) { 1216*8829SSree.Vemuri@Sun.COM VISINFO_KSTAT(vis_pdist); 1217*8829SSree.Vemuri@Sun.COM _fp_unpack_extword(pfpsd, &lrd.ll, nrd); 1218*8829SSree.Vemuri@Sun.COM } else { 1219*8829SSree.Vemuri@Sun.COM /* pdistn */ 1220*8829SSree.Vemuri@Sun.COM VISINFO_KSTAT(vis_pdistn); 1221*8829SSree.Vemuri@Sun.COM lrd.ll = 0; 1222*8829SSree.Vemuri@Sun.COM } 12230Sstevel@tonic-gate 12240Sstevel@tonic-gate for (i = 0; i <= 7; i++) { 12250Sstevel@tonic-gate s = (short)(lrs1.c[i] - lrs2.c[i]); 12260Sstevel@tonic-gate if (s < 0) 12270Sstevel@tonic-gate s = ~s + 1; 12280Sstevel@tonic-gate lrd.ll += s; 12290Sstevel@tonic-gate } 12300Sstevel@tonic-gate 1231*8829SSree.Vemuri@Sun.COM if (op == pdist) 1232*8829SSree.Vemuri@Sun.COM _fp_pack_extword(pfpsd, &lrd.ll, nrd); 1233*8829SSree.Vemuri@Sun.COM else 1234*8829SSree.Vemuri@Sun.COM /* pdistn */ 1235*8829SSree.Vemuri@Sun.COM (void) write_iureg(pfpsd, nrd, pregs, prw, &lrd.ll); 12360Sstevel@tonic-gate return (ftt_none); 12370Sstevel@tonic-gate } 12380Sstevel@tonic-gate 12390Sstevel@tonic-gate /* 12400Sstevel@tonic-gate * Simulator for faligndata instruction. 12410Sstevel@tonic-gate */ 12420Sstevel@tonic-gate static enum ftt_type 12430Sstevel@tonic-gate vis_faligndata( 12440Sstevel@tonic-gate fp_simd_type *pfpsd, /* FPU simulator data. */ 12450Sstevel@tonic-gate fp_inst_type pinst, /* FPU instruction to simulate. */ 12460Sstevel@tonic-gate kfpu_t *fp) /* Need to fp to access gsr reg */ 12470Sstevel@tonic-gate { 12480Sstevel@tonic-gate uint_t nrs1, nrs2, nrd; /* Register number fields. */ 12490Sstevel@tonic-gate int i, j, k, ao; 12500Sstevel@tonic-gate union { 12510Sstevel@tonic-gate uint64_t ll; 12520Sstevel@tonic-gate uint8_t c[8]; 12530Sstevel@tonic-gate } lrs1, lrs2, lrd; 12540Sstevel@tonic-gate uint64_t r; 12550Sstevel@tonic-gate 12560Sstevel@tonic-gate nrs1 = pinst.rs1; 12570Sstevel@tonic-gate nrs2 = pinst.rs2; 12580Sstevel@tonic-gate nrd = pinst.rd; 12590Sstevel@tonic-gate if ((nrs1 & 1) == 1) /* fix register encoding */ 12600Sstevel@tonic-gate nrs1 = (nrs1 & 0x1e) | 0x20; 12610Sstevel@tonic-gate if ((nrs2 & 1) == 1) 12620Sstevel@tonic-gate nrs2 = (nrs2 & 0x1e) | 0x20; 12630Sstevel@tonic-gate if ((nrd & 1) == 1) 12640Sstevel@tonic-gate nrd = (nrd & 0x1e) | 0x20; 12650Sstevel@tonic-gate 12660Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lrs1.ll, nrs1); 12670Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lrs2.ll, nrs2); 12680Sstevel@tonic-gate 12697Sdf157793 r = pfpsd->fp_current_read_gsr(fp); 12700Sstevel@tonic-gate ao = (int)GSR_ALIGN(r); 12710Sstevel@tonic-gate 12720Sstevel@tonic-gate for (i = 0, j = ao, k = 0; i <= 7; i++) 12730Sstevel@tonic-gate if (j <= 7) { 12740Sstevel@tonic-gate lrd.c[i] = lrs1.c[j++]; 12750Sstevel@tonic-gate } else { 12760Sstevel@tonic-gate lrd.c[i] = lrs2.c[k++]; 12770Sstevel@tonic-gate } 12780Sstevel@tonic-gate _fp_pack_extword(pfpsd, &lrd.ll, nrd); 12790Sstevel@tonic-gate 12800Sstevel@tonic-gate return (ftt_none); 12810Sstevel@tonic-gate } 12820Sstevel@tonic-gate 12830Sstevel@tonic-gate /* 12840Sstevel@tonic-gate * Simulator for bshuffle instruction. 12850Sstevel@tonic-gate */ 12860Sstevel@tonic-gate static enum ftt_type 12870Sstevel@tonic-gate vis_bshuffle( 12880Sstevel@tonic-gate fp_simd_type *pfpsd, /* FPU simulator data. */ 12890Sstevel@tonic-gate fp_inst_type pinst, /* FPU instruction to simulate. */ 12900Sstevel@tonic-gate kfpu_t *fp) /* Need to fp to access gsr reg */ 12910Sstevel@tonic-gate { 12920Sstevel@tonic-gate uint_t nrs1, nrs2, nrd; /* Register number fields. */ 12930Sstevel@tonic-gate int i, j, ao; 12940Sstevel@tonic-gate union { 12950Sstevel@tonic-gate uint64_t ll; 12960Sstevel@tonic-gate uint8_t c[8]; 12970Sstevel@tonic-gate } lrs1, lrs2, lrd; 12980Sstevel@tonic-gate uint64_t r; 12990Sstevel@tonic-gate 13000Sstevel@tonic-gate VISINFO_KSTAT(vis_bshuffle); 13010Sstevel@tonic-gate nrs1 = pinst.rs1; 13020Sstevel@tonic-gate nrs2 = pinst.rs2; 13030Sstevel@tonic-gate nrd = pinst.rd; 13040Sstevel@tonic-gate if ((nrs1 & 1) == 1) /* fix register encoding */ 13050Sstevel@tonic-gate nrs1 = (nrs1 & 0x1e) | 0x20; 13060Sstevel@tonic-gate if ((nrs2 & 1) == 1) 13070Sstevel@tonic-gate nrs2 = (nrs2 & 0x1e) | 0x20; 13080Sstevel@tonic-gate if ((nrd & 1) == 1) 13090Sstevel@tonic-gate nrd = (nrd & 0x1e) | 0x20; 13100Sstevel@tonic-gate 13110Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lrs1.ll, nrs1); 13120Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &lrs2.ll, nrs2); 13130Sstevel@tonic-gate 13147Sdf157793 r = pfpsd->fp_current_read_gsr(fp); 13150Sstevel@tonic-gate ao = (int)GSR_MASK(r); 13160Sstevel@tonic-gate 13170Sstevel@tonic-gate /* 13180Sstevel@tonic-gate * BSHUFFLE Destination Byte Selection 13190Sstevel@tonic-gate * rd Byte Source 13200Sstevel@tonic-gate * 0 rs byte[GSR.mask<31..28>] 13210Sstevel@tonic-gate * 1 rs byte[GSR.mask<27..24>] 13220Sstevel@tonic-gate * 2 rs byte[GSR.mask<23..20>] 13230Sstevel@tonic-gate * 3 rs byte[GSR.mask<19..16>] 13240Sstevel@tonic-gate * 4 rs byte[GSR.mask<15..12>] 13250Sstevel@tonic-gate * 5 rs byte[GSR.mask<11..8>] 13260Sstevel@tonic-gate * 6 rs byte[GSR.mask<7..4>] 13270Sstevel@tonic-gate * 7 rs byte[GSR.mask<3..0>] 13280Sstevel@tonic-gate * P.S. rs1 is the upper half and rs2 is the lower half 13290Sstevel@tonic-gate * Bytes in the source value are numbered from most to 13300Sstevel@tonic-gate * least significant 13310Sstevel@tonic-gate */ 13320Sstevel@tonic-gate for (i = 7; i >= 0; i--, ao = (ao >> 4)) { 13330Sstevel@tonic-gate j = ao & 0xf; /* get byte number */ 13340Sstevel@tonic-gate if (j < 8) { 13350Sstevel@tonic-gate lrd.c[i] = lrs1.c[j]; 13360Sstevel@tonic-gate } else { 13370Sstevel@tonic-gate lrd.c[i] = lrs2.c[j - 8]; 13380Sstevel@tonic-gate } 13390Sstevel@tonic-gate } 13400Sstevel@tonic-gate _fp_pack_extword(pfpsd, &lrd.ll, nrd); 13410Sstevel@tonic-gate 13420Sstevel@tonic-gate return (ftt_none); 13430Sstevel@tonic-gate } 13440Sstevel@tonic-gate 13450Sstevel@tonic-gate /* 13460Sstevel@tonic-gate * Simulator for siam instruction. 13470Sstevel@tonic-gate */ 13480Sstevel@tonic-gate static enum ftt_type 13490Sstevel@tonic-gate vis_siam( 13500Sstevel@tonic-gate fp_simd_type *pfpsd, /* FPU simulator data. */ 13510Sstevel@tonic-gate vis_inst_type inst, /* FPU instruction to simulate. */ 13520Sstevel@tonic-gate kfpu_t *fp) /* Need to fp to access gsr reg */ 13530Sstevel@tonic-gate { 13540Sstevel@tonic-gate uint_t nrs2; /* Register number fields. */ 13550Sstevel@tonic-gate uint64_t g, r; 13560Sstevel@tonic-gate nrs2 = inst.rs2; 13570Sstevel@tonic-gate 13587Sdf157793 g = pfpsd->fp_current_read_gsr(fp); 13590Sstevel@tonic-gate g &= ~(GSR_IM_IRND_MASK); /* zero the IM and IRND fields */ 13600Sstevel@tonic-gate r = nrs2 & 0x7; /* get mode(3 bit) */ 13610Sstevel@tonic-gate g |= (r << GSR_IRND_SHIFT); 13627Sdf157793 pfpsd->fp_current_write_gsr(g, fp); 13630Sstevel@tonic-gate return (ftt_none); 13640Sstevel@tonic-gate } 13650Sstevel@tonic-gate 13660Sstevel@tonic-gate /* 13670Sstevel@tonic-gate * Simulator for VIS loads and stores between floating-point unit and memory. 13680Sstevel@tonic-gate */ 13690Sstevel@tonic-gate enum ftt_type 13700Sstevel@tonic-gate vis_fldst( 13710Sstevel@tonic-gate fp_simd_type *pfpsd, /* FPU simulator data. */ 13720Sstevel@tonic-gate fp_inst_type pinst, /* FPU instruction to simulate. */ 13730Sstevel@tonic-gate struct regs *pregs, /* Pointer to PCB image of registers. */ 13740Sstevel@tonic-gate void *prw, /* Pointer to locals and ins. */ 13750Sstevel@tonic-gate uint_t asi) /* asi to emulate! */ 13760Sstevel@tonic-gate { 13770Sstevel@tonic-gate union { 13780Sstevel@tonic-gate vis_inst_type inst; 13790Sstevel@tonic-gate fp_inst_type pinst; 13800Sstevel@tonic-gate } i; 13810Sstevel@tonic-gate 13820Sstevel@tonic-gate ASSERT(USERMODE(pregs->r_tstate)); 13830Sstevel@tonic-gate i.pinst = pinst; 13840Sstevel@tonic-gate switch (asi) { 13850Sstevel@tonic-gate case ASI_PST8_P: 13860Sstevel@tonic-gate case ASI_PST8_S: 13870Sstevel@tonic-gate case ASI_PST16_P: 13880Sstevel@tonic-gate case ASI_PST16_S: 13890Sstevel@tonic-gate case ASI_PST32_P: 13900Sstevel@tonic-gate case ASI_PST32_S: 13910Sstevel@tonic-gate case ASI_PST8_PL: 13920Sstevel@tonic-gate case ASI_PST8_SL: 13930Sstevel@tonic-gate case ASI_PST16_PL: 13940Sstevel@tonic-gate case ASI_PST16_SL: 13950Sstevel@tonic-gate case ASI_PST32_PL: 13960Sstevel@tonic-gate case ASI_PST32_SL: 13970Sstevel@tonic-gate return (vis_prtl_fst(pfpsd, i.inst, pregs, 13985008Sarutz prw, asi)); 13990Sstevel@tonic-gate case ASI_FL8_P: 14000Sstevel@tonic-gate case ASI_FL8_S: 14010Sstevel@tonic-gate case ASI_FL8_PL: 14020Sstevel@tonic-gate case ASI_FL8_SL: 14030Sstevel@tonic-gate case ASI_FL16_P: 14040Sstevel@tonic-gate case ASI_FL16_S: 14050Sstevel@tonic-gate case ASI_FL16_PL: 14060Sstevel@tonic-gate case ASI_FL16_SL: 14070Sstevel@tonic-gate return (vis_short_fls(pfpsd, i.inst, pregs, 14085008Sarutz prw, asi)); 14090Sstevel@tonic-gate case ASI_BLK_AIUP: 14100Sstevel@tonic-gate case ASI_BLK_AIUS: 14110Sstevel@tonic-gate case ASI_BLK_AIUPL: 14120Sstevel@tonic-gate case ASI_BLK_AIUSL: 14130Sstevel@tonic-gate case ASI_BLK_P: 14140Sstevel@tonic-gate case ASI_BLK_S: 14150Sstevel@tonic-gate case ASI_BLK_PL: 14160Sstevel@tonic-gate case ASI_BLK_SL: 14170Sstevel@tonic-gate case ASI_BLK_COMMIT_P: 14180Sstevel@tonic-gate case ASI_BLK_COMMIT_S: 14190Sstevel@tonic-gate return (vis_blk_fldst(pfpsd, i.inst, pregs, 14205008Sarutz prw, asi)); 14210Sstevel@tonic-gate default: 14220Sstevel@tonic-gate return (ftt_unimplemented); 14230Sstevel@tonic-gate } 14240Sstevel@tonic-gate } 14250Sstevel@tonic-gate 14260Sstevel@tonic-gate /* 14270Sstevel@tonic-gate * Simulator for partial stores between floating-point unit and memory. 14280Sstevel@tonic-gate */ 14290Sstevel@tonic-gate static enum ftt_type 14300Sstevel@tonic-gate vis_prtl_fst( 14310Sstevel@tonic-gate fp_simd_type *pfpsd, /* FPU simulator data. */ 14320Sstevel@tonic-gate vis_inst_type inst, /* ISE instruction to simulate. */ 14330Sstevel@tonic-gate struct regs *pregs, /* Pointer to PCB image of registers. */ 14340Sstevel@tonic-gate void *prw, /* Pointer to locals and ins. */ 14350Sstevel@tonic-gate uint_t asi) /* asi to emulate! */ 14360Sstevel@tonic-gate { 14370Sstevel@tonic-gate uint_t nrs1, nrs2, nrd; /* Register number fields. */ 14380Sstevel@tonic-gate uint_t opf, msk; 14390Sstevel@tonic-gate int h, i, j; 14400Sstevel@tonic-gate uint64_t ea, tmsk; 14410Sstevel@tonic-gate union { 14420Sstevel@tonic-gate freg_type f; 14430Sstevel@tonic-gate uint64_t ll; 14440Sstevel@tonic-gate uint32_t i[2]; 14450Sstevel@tonic-gate uint16_t s[4]; 14460Sstevel@tonic-gate uint8_t c[8]; 14470Sstevel@tonic-gate } k, l, res; 14480Sstevel@tonic-gate enum ftt_type ftt; 14490Sstevel@tonic-gate 14500Sstevel@tonic-gate nrs1 = inst.rs1; 14510Sstevel@tonic-gate nrs2 = inst.rs2; 14520Sstevel@tonic-gate nrd = inst.rd; 14530Sstevel@tonic-gate if ((nrd & 1) == 1) /* fix register encoding */ 14540Sstevel@tonic-gate nrd = (nrd & 0x1e) | 0x20; 14550Sstevel@tonic-gate opf = inst.opf; 14560Sstevel@tonic-gate res.ll = 0; 14570Sstevel@tonic-gate if ((opf & 0x100) == 0) { /* effective address = rs1 */ 14580Sstevel@tonic-gate ftt = read_iureg(pfpsd, nrs1, pregs, prw, &ea); 14590Sstevel@tonic-gate if (ftt != ftt_none) 14600Sstevel@tonic-gate return (ftt); 14610Sstevel@tonic-gate ftt = read_iureg(pfpsd, nrs2, pregs, prw, &tmsk); 14620Sstevel@tonic-gate if (ftt != ftt_none) 14630Sstevel@tonic-gate return (ftt); 14640Sstevel@tonic-gate msk = (uint_t)tmsk; 14650Sstevel@tonic-gate } else { 14660Sstevel@tonic-gate pfpsd->fp_trapaddr = (caddr_t)pregs->r_pc; 14670Sstevel@tonic-gate return (ftt_unimplemented); 14680Sstevel@tonic-gate } 14690Sstevel@tonic-gate 14700Sstevel@tonic-gate pfpsd->fp_trapaddr = (caddr_t)ea; /* setup bad addr in case we trap */ 14710Sstevel@tonic-gate if ((ea & 0x3) != 0) 14720Sstevel@tonic-gate return (ftt_alignment); /* Require 32 bit-alignment. */ 14730Sstevel@tonic-gate 14740Sstevel@tonic-gate switch (asi) { 14750Sstevel@tonic-gate case ASI_PST8_P: 14760Sstevel@tonic-gate case ASI_PST8_S: 14770Sstevel@tonic-gate ftt = _fp_read_extword((uint64_t *)ea, &l.ll, pfpsd); 14780Sstevel@tonic-gate if (ftt != ftt_none) 14790Sstevel@tonic-gate return (ftt); 14800Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &k.f.FPU_DREG_FIELD, nrd); 14810Sstevel@tonic-gate for (i = 0, j = 0x80; i <= 7; i++, j >>= 1) { 14820Sstevel@tonic-gate if ((msk & j) == j) 14830Sstevel@tonic-gate res.c[i] = k.c[i]; 14840Sstevel@tonic-gate else 14850Sstevel@tonic-gate res.c[i] = l.c[i]; 14860Sstevel@tonic-gate } 14870Sstevel@tonic-gate ftt = _fp_write_extword((uint64_t *)ea, res.ll, pfpsd); 14880Sstevel@tonic-gate if (ftt != ftt_none) 14890Sstevel@tonic-gate return (ftt); 14900Sstevel@tonic-gate break; 14910Sstevel@tonic-gate case ASI_PST8_PL: /* little-endian */ 14920Sstevel@tonic-gate case ASI_PST8_SL: 14930Sstevel@tonic-gate ftt = _fp_read_extword((uint64_t *)ea, &l.ll, pfpsd); 14940Sstevel@tonic-gate if (ftt != ftt_none) 14950Sstevel@tonic-gate return (ftt); 14960Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &k.f.FPU_DREG_FIELD, nrd); 14972227Sjfrank for (h = 7, i = 0, j = 1; i <= 7; h--, i++, j <<= 1) { 14980Sstevel@tonic-gate if ((msk & j) == j) 14992227Sjfrank res.c[i] = k.c[h]; 15000Sstevel@tonic-gate else 15012227Sjfrank res.c[i] = l.c[i]; 15020Sstevel@tonic-gate } 15030Sstevel@tonic-gate ftt = _fp_write_extword((uint64_t *)ea, res.ll, pfpsd); 15040Sstevel@tonic-gate if (ftt != ftt_none) 15050Sstevel@tonic-gate return (ftt); 15060Sstevel@tonic-gate break; 15070Sstevel@tonic-gate case ASI_PST16_P: 15080Sstevel@tonic-gate case ASI_PST16_S: 15090Sstevel@tonic-gate ftt = _fp_read_extword((uint64_t *)ea, &l.ll, pfpsd); 15100Sstevel@tonic-gate if (ftt != ftt_none) 15110Sstevel@tonic-gate return (ftt); 15120Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &k.f.FPU_DREG_FIELD, nrd); 15130Sstevel@tonic-gate for (i = 0, j = 0x8; i <= 3; i++, j >>= 1) { 15140Sstevel@tonic-gate if ((msk & j) == j) 15150Sstevel@tonic-gate res.s[i] = k.s[i]; 15160Sstevel@tonic-gate else 15170Sstevel@tonic-gate res.s[i] = l.s[i]; 15180Sstevel@tonic-gate } 15190Sstevel@tonic-gate ftt = _fp_write_extword((uint64_t *)ea, res.ll, pfpsd); 15200Sstevel@tonic-gate if (ftt != ftt_none) 15210Sstevel@tonic-gate return (ftt); 15220Sstevel@tonic-gate break; 15230Sstevel@tonic-gate case ASI_PST16_PL: 15240Sstevel@tonic-gate case ASI_PST16_SL: 15250Sstevel@tonic-gate ftt = _fp_read_extword((uint64_t *)ea, &l.ll, pfpsd); 15260Sstevel@tonic-gate if (ftt != ftt_none) 15270Sstevel@tonic-gate return (ftt); 15280Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &k.f.FPU_DREG_FIELD, nrd); 15292227Sjfrank for (h = 7, i = 0, j = 1; i <= 6; h -= 2, i += 2, j <<= 1) { 15300Sstevel@tonic-gate if ((msk & j) == j) { 15312227Sjfrank res.c[i] = k.c[h]; 15322227Sjfrank res.c[i+1] = k.c[h-1]; 15330Sstevel@tonic-gate } else { 15342227Sjfrank res.c[i] = l.c[i]; 15352227Sjfrank res.c[i+1] = l.c[i+1]; 15360Sstevel@tonic-gate } 15370Sstevel@tonic-gate } 15380Sstevel@tonic-gate ftt = _fp_write_extword((uint64_t *)ea, res.ll, pfpsd); 15390Sstevel@tonic-gate if (ftt != ftt_none) 15400Sstevel@tonic-gate return (ftt); 15410Sstevel@tonic-gate break; 15420Sstevel@tonic-gate case ASI_PST32_P: 15430Sstevel@tonic-gate case ASI_PST32_S: 15440Sstevel@tonic-gate ftt = _fp_read_extword((uint64_t *)ea, &l.ll, pfpsd); 15450Sstevel@tonic-gate if (ftt != ftt_none) 15460Sstevel@tonic-gate return (ftt); 15470Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &k.f.FPU_DREG_FIELD, nrd); 15480Sstevel@tonic-gate for (i = 0, j = 0x2; i <= 1; i++, j >>= 1) { 15490Sstevel@tonic-gate if ((msk & j) == j) 15500Sstevel@tonic-gate res.i[i] = k.i[i]; 15510Sstevel@tonic-gate else 15520Sstevel@tonic-gate res.i[i] = l.i[i]; 15530Sstevel@tonic-gate } 15540Sstevel@tonic-gate ftt = _fp_write_extword((uint64_t *)ea, res.ll, pfpsd); 15550Sstevel@tonic-gate if (ftt != ftt_none) 15560Sstevel@tonic-gate return (ftt); 15570Sstevel@tonic-gate break; 15580Sstevel@tonic-gate case ASI_PST32_PL: 15590Sstevel@tonic-gate case ASI_PST32_SL: 15600Sstevel@tonic-gate ftt = _fp_read_extword((uint64_t *)ea, &l.ll, pfpsd); 15610Sstevel@tonic-gate if (ftt != ftt_none) 15620Sstevel@tonic-gate return (ftt); 15630Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &k.f.FPU_DREG_FIELD, nrd); 15642227Sjfrank for (h = 7, i = 0, j = 1; i <= 4; h -= 4, i += 4, j <<= 1) { 15650Sstevel@tonic-gate if ((msk & j) == j) { 15662227Sjfrank res.c[i] = k.c[h]; 15672227Sjfrank res.c[i+1] = k.c[h-1]; 15682227Sjfrank res.c[i+2] = k.c[h-2]; 15692227Sjfrank res.c[i+3] = k.c[h-3]; 15700Sstevel@tonic-gate } else { 15712227Sjfrank res.c[i] = l.c[i]; 15722227Sjfrank res.c[i+1] = l.c[i+1]; 15732227Sjfrank res.c[i+2] = l.c[i+2]; 15742227Sjfrank res.c[i+3] = l.c[i+3]; 15750Sstevel@tonic-gate } 15760Sstevel@tonic-gate } 15770Sstevel@tonic-gate ftt = _fp_write_extword((uint64_t *)ea, res.ll, pfpsd); 15780Sstevel@tonic-gate if (ftt != ftt_none) 15790Sstevel@tonic-gate return (ftt); 15800Sstevel@tonic-gate break; 15810Sstevel@tonic-gate } 15820Sstevel@tonic-gate 15830Sstevel@tonic-gate pregs->r_pc = pregs->r_npc; /* Do not retry emulated instruction. */ 15840Sstevel@tonic-gate pregs->r_npc += 4; 15850Sstevel@tonic-gate return (ftt_none); 15860Sstevel@tonic-gate } 15870Sstevel@tonic-gate 15880Sstevel@tonic-gate /* 15890Sstevel@tonic-gate * Simulator for short load/stores between floating-point unit and memory. 15900Sstevel@tonic-gate */ 15910Sstevel@tonic-gate static enum ftt_type 15920Sstevel@tonic-gate vis_short_fls( 15930Sstevel@tonic-gate fp_simd_type *pfpsd, /* FPU simulator data. */ 15940Sstevel@tonic-gate vis_inst_type inst, /* ISE instruction to simulate. */ 15950Sstevel@tonic-gate struct regs *pregs, /* Pointer to PCB image of registers. */ 15960Sstevel@tonic-gate void *prw, /* Pointer to locals and ins. */ 15970Sstevel@tonic-gate uint_t asi) /* asi to emulate! */ 15980Sstevel@tonic-gate { 15990Sstevel@tonic-gate uint_t nrs1, nrs2, nrd; /* Register number fields. */ 16000Sstevel@tonic-gate uint_t opf; 16010Sstevel@tonic-gate uint64_t ea, tea; 16020Sstevel@tonic-gate union { 16030Sstevel@tonic-gate freg_type f; 16040Sstevel@tonic-gate uint64_t ll; 16050Sstevel@tonic-gate uint32_t i[2]; 16060Sstevel@tonic-gate uint16_t s[4]; 16070Sstevel@tonic-gate uint8_t c[8]; 16080Sstevel@tonic-gate } k; 16090Sstevel@tonic-gate union { 16100Sstevel@tonic-gate vis_inst_type inst; 16110Sstevel@tonic-gate int i; 16120Sstevel@tonic-gate } fp; 16130Sstevel@tonic-gate enum ftt_type ftt = ftt_none; 16140Sstevel@tonic-gate ushort_t us; 16150Sstevel@tonic-gate uchar_t uc; 16160Sstevel@tonic-gate 16170Sstevel@tonic-gate nrs1 = inst.rs1; 16180Sstevel@tonic-gate nrs2 = inst.rs2; 16190Sstevel@tonic-gate nrd = inst.rd; 16200Sstevel@tonic-gate if ((nrd & 1) == 1) /* fix register encoding */ 16210Sstevel@tonic-gate nrd = (nrd & 0x1e) | 0x20; 16220Sstevel@tonic-gate opf = inst.opf; 16230Sstevel@tonic-gate fp.inst = inst; 16240Sstevel@tonic-gate if ((opf & 0x100) == 0) { /* effective address = rs1 + rs2 */ 16250Sstevel@tonic-gate ftt = read_iureg(pfpsd, nrs1, pregs, prw, &ea); 16260Sstevel@tonic-gate if (ftt != ftt_none) 16270Sstevel@tonic-gate return (ftt); 16280Sstevel@tonic-gate ftt = read_iureg(pfpsd, nrs2, pregs, prw, &tea); 16290Sstevel@tonic-gate if (ftt != ftt_none) 16300Sstevel@tonic-gate return (ftt); 16310Sstevel@tonic-gate ea += tea; 16320Sstevel@tonic-gate } else { /* effective address = rs1 + imm13 */ 16330Sstevel@tonic-gate fp.inst = inst; 16340Sstevel@tonic-gate ea = (fp.i << 19) >> 19; /* Extract simm13 field. */ 16350Sstevel@tonic-gate ftt = read_iureg(pfpsd, nrs1, pregs, prw, &tea); 16360Sstevel@tonic-gate if (ftt != ftt_none) 16370Sstevel@tonic-gate return (ftt); 16380Sstevel@tonic-gate ea += tea; 16390Sstevel@tonic-gate } 16400Sstevel@tonic-gate if (get_udatamodel() == DATAMODEL_ILP32) 16410Sstevel@tonic-gate ea = (uint64_t)(caddr32_t)ea; 16420Sstevel@tonic-gate 16430Sstevel@tonic-gate pfpsd->fp_trapaddr = (caddr_t)ea; /* setup bad addr in case we trap */ 16440Sstevel@tonic-gate switch (asi) { 16450Sstevel@tonic-gate case ASI_FL8_P: 16460Sstevel@tonic-gate case ASI_FL8_S: 16470Sstevel@tonic-gate case ASI_FL8_PL: /* little-endian */ 16480Sstevel@tonic-gate case ASI_FL8_SL: 16490Sstevel@tonic-gate if ((inst.op3 & 7) == 3) { /* load byte */ 16500Sstevel@tonic-gate if (fuword8((void *)ea, &uc) == -1) 16510Sstevel@tonic-gate return (ftt_fault); 16520Sstevel@tonic-gate k.ll = 0; 16530Sstevel@tonic-gate k.c[7] = uc; 16540Sstevel@tonic-gate _fp_pack_extword(pfpsd, &k.f.FPU_DREG_FIELD, nrd); 16550Sstevel@tonic-gate } else { /* store byte */ 16560Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &k.f.FPU_DREG_FIELD, nrd); 16570Sstevel@tonic-gate uc = k.c[7]; 16580Sstevel@tonic-gate if (subyte((caddr_t)ea, uc) == -1) 16590Sstevel@tonic-gate return (ftt_fault); 16600Sstevel@tonic-gate } 16610Sstevel@tonic-gate break; 16620Sstevel@tonic-gate case ASI_FL16_P: 16630Sstevel@tonic-gate case ASI_FL16_S: 16640Sstevel@tonic-gate if ((ea & 1) == 1) 16650Sstevel@tonic-gate return (ftt_alignment); 16660Sstevel@tonic-gate if ((inst.op3 & 7) == 3) { /* load short */ 16670Sstevel@tonic-gate if (fuword16((void *)ea, &us) == -1) 16680Sstevel@tonic-gate return (ftt_fault); 16690Sstevel@tonic-gate k.ll = 0; 16700Sstevel@tonic-gate k.s[3] = us; 16710Sstevel@tonic-gate _fp_pack_extword(pfpsd, &k.f.FPU_DREG_FIELD, nrd); 16720Sstevel@tonic-gate } else { /* store short */ 16730Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &k.f.FPU_DREG_FIELD, nrd); 16740Sstevel@tonic-gate us = k.s[3]; 16750Sstevel@tonic-gate if (suword16((caddr_t)ea, us) == -1) 16760Sstevel@tonic-gate return (ftt_fault); 16770Sstevel@tonic-gate } 16780Sstevel@tonic-gate break; 16790Sstevel@tonic-gate case ASI_FL16_PL: /* little-endian */ 16800Sstevel@tonic-gate case ASI_FL16_SL: 16810Sstevel@tonic-gate if ((ea & 1) == 1) 16820Sstevel@tonic-gate return (ftt_alignment); 16830Sstevel@tonic-gate if ((inst.op3 & 7) == 3) { /* load short */ 16840Sstevel@tonic-gate if (fuword16((void *)ea, &us) == -1) 16850Sstevel@tonic-gate return (ftt_fault); 16860Sstevel@tonic-gate k.ll = 0; 16870Sstevel@tonic-gate k.c[6] = (uchar_t)us; 16880Sstevel@tonic-gate k.c[7] = (uchar_t)((us & 0xff00) >> 8); 16890Sstevel@tonic-gate _fp_pack_extword(pfpsd, &k.f.FPU_DREG_FIELD, nrd); 16900Sstevel@tonic-gate } else { /* store short */ 16910Sstevel@tonic-gate _fp_unpack_extword(pfpsd, &k.f.FPU_DREG_FIELD, nrd); 16920Sstevel@tonic-gate uc = k.c[7]; 16930Sstevel@tonic-gate us = (ushort_t)((uc << 8) | k.c[6]); 16940Sstevel@tonic-gate if (suword16((void *)ea, us) == -1) 16950Sstevel@tonic-gate return (ftt_fault); 16960Sstevel@tonic-gate } 16970Sstevel@tonic-gate break; 16980Sstevel@tonic-gate } 16990Sstevel@tonic-gate 17000Sstevel@tonic-gate pregs->r_pc = pregs->r_npc; /* Do not retry emulated instruction. */ 17010Sstevel@tonic-gate pregs->r_npc += 4; 17020Sstevel@tonic-gate return (ftt_none); 17030Sstevel@tonic-gate } 17040Sstevel@tonic-gate 17050Sstevel@tonic-gate /* 17060Sstevel@tonic-gate * Simulator for block loads and stores between floating-point unit and memory. 17073729Swh94709 * We pass the addrees of ea to sync_data_memory() to flush the Ecache. 17083729Swh94709 * Sync_data_memory() calls platform dependent code to flush the Ecache. 17090Sstevel@tonic-gate */ 17100Sstevel@tonic-gate static enum ftt_type 17110Sstevel@tonic-gate vis_blk_fldst( 17120Sstevel@tonic-gate fp_simd_type *pfpsd, /* FPU simulator data. */ 17130Sstevel@tonic-gate vis_inst_type inst, /* ISE instruction to simulate. */ 17140Sstevel@tonic-gate struct regs *pregs, /* Pointer to PCB image of registers. */ 17150Sstevel@tonic-gate void *prw, /* Pointer to locals and ins. */ 17160Sstevel@tonic-gate uint_t asi) /* asi to emulate! */ 17170Sstevel@tonic-gate { 17180Sstevel@tonic-gate uint_t nrs1, nrs2, nrd; /* Register number fields. */ 17190Sstevel@tonic-gate uint_t opf, h, i, j; 17200Sstevel@tonic-gate uint64_t ea, tea; 17210Sstevel@tonic-gate union { 17220Sstevel@tonic-gate freg_type f; 17230Sstevel@tonic-gate uint64_t ll; 17240Sstevel@tonic-gate uint8_t c[8]; 17250Sstevel@tonic-gate } k, l; 17260Sstevel@tonic-gate union { 17270Sstevel@tonic-gate vis_inst_type inst; 17280Sstevel@tonic-gate int32_t i; 17290Sstevel@tonic-gate } fp; 17300Sstevel@tonic-gate enum ftt_type ftt; 17310Sstevel@tonic-gate boolean_t little_endian = B_FALSE; 17320Sstevel@tonic-gate 17330Sstevel@tonic-gate nrs1 = inst.rs1; 17340Sstevel@tonic-gate nrs2 = inst.rs2; 17350Sstevel@tonic-gate nrd = inst.rd; 17360Sstevel@tonic-gate if ((nrd & 1) == 1) /* fix register encoding */ 17370Sstevel@tonic-gate nrd = (nrd & 0x1e) | 0x20; 17380Sstevel@tonic-gate 17390Sstevel@tonic-gate /* ensure register is 8-double precision aligned */ 17400Sstevel@tonic-gate if ((nrd & 0xf) != 0) 17410Sstevel@tonic-gate return (ftt_unimplemented); 17420Sstevel@tonic-gate 17430Sstevel@tonic-gate opf = inst.opf; 17440Sstevel@tonic-gate if ((opf & 0x100) == 0) { /* effective address = rs1 + rs2 */ 17450Sstevel@tonic-gate ftt = read_iureg(pfpsd, nrs1, pregs, prw, &ea); 17460Sstevel@tonic-gate if (ftt != ftt_none) 17470Sstevel@tonic-gate return (ftt); 17480Sstevel@tonic-gate ftt = read_iureg(pfpsd, nrs2, pregs, prw, &tea); 17490Sstevel@tonic-gate if (ftt != ftt_none) 17500Sstevel@tonic-gate return (ftt); 17510Sstevel@tonic-gate ea += tea; 17520Sstevel@tonic-gate } else { /* effective address = rs1 + imm13 */ 17530Sstevel@tonic-gate fp.inst = inst; 17540Sstevel@tonic-gate ea = (fp.i << 19) >> 19; /* Extract simm13 field. */ 17550Sstevel@tonic-gate ftt = read_iureg(pfpsd, nrs1, pregs, prw, &tea); 17560Sstevel@tonic-gate if (ftt != ftt_none) 17570Sstevel@tonic-gate return (ftt); 17580Sstevel@tonic-gate ea += tea; 17590Sstevel@tonic-gate } 17600Sstevel@tonic-gate if ((ea & 0x3F) != 0) /* Require 64 byte-alignment. */ 17610Sstevel@tonic-gate return (ftt_alignment); 17620Sstevel@tonic-gate 17630Sstevel@tonic-gate pfpsd->fp_trapaddr = (caddr_t)ea; /* setup bad addr in case we trap */ 17640Sstevel@tonic-gate switch (asi) { 17650Sstevel@tonic-gate case ASI_BLK_AIUPL: 17660Sstevel@tonic-gate case ASI_BLK_AIUSL: 17670Sstevel@tonic-gate case ASI_BLK_PL: 17680Sstevel@tonic-gate case ASI_BLK_SL: 17690Sstevel@tonic-gate little_endian = B_TRUE; 17700Sstevel@tonic-gate /* FALLTHROUGH */ 17710Sstevel@tonic-gate case ASI_BLK_AIUP: 17720Sstevel@tonic-gate case ASI_BLK_AIUS: 17730Sstevel@tonic-gate case ASI_BLK_P: 17740Sstevel@tonic-gate case ASI_BLK_S: 17750Sstevel@tonic-gate case ASI_BLK_COMMIT_P: 17760Sstevel@tonic-gate case ASI_BLK_COMMIT_S: 17770Sstevel@tonic-gate if ((inst.op3 & 7) == 3) { /* lddf */ 17785008Sarutz for (i = 0; i < 8; i++, nrd += 2) { 17795008Sarutz ftt = _fp_read_extword((uint64_t *)ea, &k.ll, 17805008Sarutz pfpsd); 17815008Sarutz if (ftt != ftt_none) 17825008Sarutz return (ftt); 17835008Sarutz if (little_endian) { 17845008Sarutz for (j = 0, h = 7; j < 8; j++, h--) 17855008Sarutz l.c[h] = k.c[j]; 17865008Sarutz k.ll = l.ll; 17875008Sarutz } 17885008Sarutz _fp_pack_extword(pfpsd, &k.f.FPU_DREG_FIELD, 17895008Sarutz nrd); 17905008Sarutz ea += 8; 17910Sstevel@tonic-gate } 17920Sstevel@tonic-gate } else { /* stdf */ 17935008Sarutz for (i = 0; i < 8; i++, nrd += 2) { 17945008Sarutz _fp_unpack_extword(pfpsd, &k.f.FPU_DREG_FIELD, 17955008Sarutz nrd); 17965008Sarutz if (little_endian) { 17975008Sarutz for (j = 0, h = 7; j < 8; j++, h--) 17985008Sarutz l.c[h] = k.c[j]; 17995008Sarutz k.ll = l.ll; 18005008Sarutz } 18015008Sarutz ftt = _fp_write_extword((uint64_t *)ea, k.ll, 18025008Sarutz pfpsd); 18035008Sarutz if (ftt != ftt_none) 18045008Sarutz return (ftt); 18055008Sarutz ea += 8; 18060Sstevel@tonic-gate } 18070Sstevel@tonic-gate } 18080Sstevel@tonic-gate if ((asi == ASI_BLK_COMMIT_P) || (asi == ASI_BLK_COMMIT_S)) 18093729Swh94709 sync_data_memory((caddr_t)(ea - 64), 64); 18100Sstevel@tonic-gate break; 18110Sstevel@tonic-gate default: 18120Sstevel@tonic-gate /* addr of unimp inst */ 18130Sstevel@tonic-gate pfpsd->fp_trapaddr = (caddr_t)pregs->r_pc; 18140Sstevel@tonic-gate return (ftt_unimplemented); 18150Sstevel@tonic-gate } 18160Sstevel@tonic-gate 18170Sstevel@tonic-gate pregs->r_pc = pregs->r_npc; /* Do not retry emulated instruction. */ 18180Sstevel@tonic-gate pregs->r_npc += 4; 18190Sstevel@tonic-gate return (ftt_none); 18200Sstevel@tonic-gate } 18210Sstevel@tonic-gate 18220Sstevel@tonic-gate /* 18230Sstevel@tonic-gate * Simulator for rd %gsr instruction. 18240Sstevel@tonic-gate */ 18250Sstevel@tonic-gate enum ftt_type 18260Sstevel@tonic-gate vis_rdgsr( 18270Sstevel@tonic-gate fp_simd_type *pfpsd, /* FPU simulator data. */ 18280Sstevel@tonic-gate fp_inst_type pinst, /* FPU instruction to simulate. */ 18290Sstevel@tonic-gate struct regs *pregs, /* Pointer to PCB image of registers. */ 18300Sstevel@tonic-gate void *prw, /* Pointer to locals and ins. */ 18310Sstevel@tonic-gate kfpu_t *fp) /* Need to fp to access gsr reg */ 18320Sstevel@tonic-gate { 18330Sstevel@tonic-gate uint_t nrd; 18340Sstevel@tonic-gate uint64_t r; 18350Sstevel@tonic-gate enum ftt_type ftt = ftt_none; 18360Sstevel@tonic-gate 18370Sstevel@tonic-gate nrd = pinst.rd; 18380Sstevel@tonic-gate 18397Sdf157793 r = pfpsd->fp_current_read_gsr(fp); 18400Sstevel@tonic-gate ftt = write_iureg(pfpsd, nrd, pregs, prw, &r); 18410Sstevel@tonic-gate pregs->r_pc = pregs->r_npc; /* Do not retry emulated instruction. */ 18420Sstevel@tonic-gate pregs->r_npc += 4; 18430Sstevel@tonic-gate return (ftt); 18440Sstevel@tonic-gate } 18450Sstevel@tonic-gate 18460Sstevel@tonic-gate /* 18470Sstevel@tonic-gate * Simulator for wr %gsr instruction. 18480Sstevel@tonic-gate */ 18490Sstevel@tonic-gate enum ftt_type 18500Sstevel@tonic-gate vis_wrgsr( 18510Sstevel@tonic-gate fp_simd_type *pfpsd, /* FPU simulator data. */ 18520Sstevel@tonic-gate fp_inst_type pinst, /* FPU instruction to simulate. */ 18530Sstevel@tonic-gate struct regs *pregs, /* Pointer to PCB image of registers. */ 18540Sstevel@tonic-gate void *prw, /* Pointer to locals and ins. */ 18550Sstevel@tonic-gate kfpu_t *fp) /* Need to fp to access gsr reg */ 18560Sstevel@tonic-gate { 18570Sstevel@tonic-gate uint_t nrs1; 18580Sstevel@tonic-gate uint64_t r, r1, r2; 18590Sstevel@tonic-gate enum ftt_type ftt = ftt_none; 18600Sstevel@tonic-gate 18610Sstevel@tonic-gate nrs1 = pinst.rs1; 18620Sstevel@tonic-gate ftt = read_iureg(pfpsd, nrs1, pregs, prw, &r1); 18630Sstevel@tonic-gate if (ftt != ftt_none) 18640Sstevel@tonic-gate return (ftt); 18650Sstevel@tonic-gate if (pinst.ibit == 0) { /* copy the value in r[rs2] */ 18660Sstevel@tonic-gate uint_t nrs2; 18670Sstevel@tonic-gate 18680Sstevel@tonic-gate nrs2 = pinst.rs2; 18690Sstevel@tonic-gate ftt = read_iureg(pfpsd, nrs2, pregs, prw, &r2); 18700Sstevel@tonic-gate if (ftt != ftt_none) 18710Sstevel@tonic-gate return (ftt); 18720Sstevel@tonic-gate } else { /* use sign_ext(simm13) */ 18730Sstevel@tonic-gate union { 18740Sstevel@tonic-gate fp_inst_type inst; 18750Sstevel@tonic-gate uint32_t i; 18760Sstevel@tonic-gate } fp; 18770Sstevel@tonic-gate 18780Sstevel@tonic-gate fp.inst = pinst; /* Extract simm13 field */ 18790Sstevel@tonic-gate r2 = (fp.i << 19) >> 19; 18800Sstevel@tonic-gate } 18810Sstevel@tonic-gate r = r1 ^ r2; 18827Sdf157793 pfpsd->fp_current_write_gsr(r, fp); 18830Sstevel@tonic-gate pregs->r_pc = pregs->r_npc; /* Do not retry emulated instruction. */ 18840Sstevel@tonic-gate pregs->r_npc += 4; 18850Sstevel@tonic-gate return (ftt); 18860Sstevel@tonic-gate } 18870Sstevel@tonic-gate 18880Sstevel@tonic-gate /* 18890Sstevel@tonic-gate * This is the loadable module wrapper. 18900Sstevel@tonic-gate */ 18910Sstevel@tonic-gate #include <sys/errno.h> 18920Sstevel@tonic-gate #include <sys/modctl.h> 18930Sstevel@tonic-gate 18940Sstevel@tonic-gate /* 18950Sstevel@tonic-gate * Module linkage information for the kernel. 18960Sstevel@tonic-gate */ 18970Sstevel@tonic-gate extern struct mod_ops mod_miscops; 18980Sstevel@tonic-gate 18990Sstevel@tonic-gate static struct modlmisc modlmisc = { 19000Sstevel@tonic-gate &mod_miscops, 19010Sstevel@tonic-gate "vis fp simulation", 19020Sstevel@tonic-gate }; 19030Sstevel@tonic-gate 19040Sstevel@tonic-gate static struct modlinkage modlinkage = { 19050Sstevel@tonic-gate MODREV_1, (void *)&modlmisc, NULL 19060Sstevel@tonic-gate }; 19070Sstevel@tonic-gate 19080Sstevel@tonic-gate int 19090Sstevel@tonic-gate _init(void) 19100Sstevel@tonic-gate { 19110Sstevel@tonic-gate return (mod_install(&modlinkage)); 19120Sstevel@tonic-gate } 19130Sstevel@tonic-gate 19140Sstevel@tonic-gate int 19150Sstevel@tonic-gate _info(struct modinfo *modinfop) 19160Sstevel@tonic-gate { 19170Sstevel@tonic-gate return (mod_info(&modlinkage, modinfop)); 19180Sstevel@tonic-gate } 1919