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