📄 x-cvsweb-markup(46)
字号:
*/#define _FP_PACK_RAW_1(fs, val, X) \ do { \ union _FP_UNION_##fs _flo; \ \ _flo.bits.frac = X##_f; \ _flo.bits.exp = X##_e; \ _flo.bits.sign = X##_s; \ \ (val) = _flo.flt; \ } while (0)#define _FP_PACK_RAW_1_P(fs, val, X) \ do { \ union _FP_UNION_##fs *_flo = \ (union _FP_UNION_##fs *)(val); \ \ _flo->bits.frac = X##_f; \ _flo->bits.exp = X##_e; \ _flo->bits.sign = X##_s; \ } while (0)/* * Multiplication algorithms: *//* Basic. Assuming the host word size is >= 2*FRACBITS, we can do the multiplication immediately. */#define _FP_MUL_MEAT_1_imm(wfracbits, R, X, Y) \ do { \ R##_f = X##_f * Y##_f; \ /* Normalize since we know where the msb of the multiplicands \ were (bit B), we know that the msb of the of the product is \ at either 2B or 2B-1. */ \ _FP_FRAC_SRS_1(R, wfracbits-1, 2*wfracbits); \ } while (0)/* Given a 1W * 1W => 2W primitive, do the extended multiplication. */#define _FP_MUL_MEAT_1_wide(wfracbits, R, X, Y, doit) \ do { \ _FP_W_TYPE _Z_f0, _Z_f1; \ doit(_Z_f1, _Z_f0, X##_f, Y##_f); \ /* Normalize since we know where the msb of the multiplicands \ were (bit B), we know that the msb of the of the product is \ at either 2B or 2B-1. */ \ _FP_FRAC_SRS_2(_Z, wfracbits-1, 2*wfracbits); \ R##_f = _Z_f0; \ } while (0)/* Finally, a simple widening multiply algorithm. What fun! */#define _FP_MUL_MEAT_1_hard(wfracbits, R, X, Y) \ do { \ _FP_W_TYPE _xh, _xl, _yh, _yl, _z_f0, _z_f1, _a_f0, _a_f1; \ \ /* split the words in half */ \ _xh = X##_f >> (_FP_W_TYPE_SIZE/2); \ _xl = X##_f & (((_FP_W_TYPE)1 << (_FP_W_TYPE_SIZE/2)) - 1); \ _yh = Y##_f >> (_FP_W_TYPE_SIZE/2); \ _yl = Y##_f & (((_FP_W_TYPE)1 << (_FP_W_TYPE_SIZE/2)) - 1); \ \ /* multiply the pieces */ \ _z_f0 = _xl * _yl; \ _a_f0 = _xh * _yl; \ _a_f1 = _xl * _yh; \ _z_f1 = _xh * _yh; \ \ /* reassemble into two full words */ \ if ((_a_f0 += _a_f1) < _a_f1) \ _z_f1 += (_FP_W_TYPE)1 << (_FP_W_TYPE_SIZE/2); \ _a_f1 = _a_f0 >> (_FP_W_TYPE_SIZE/2); \ _a_f0 = _a_f0 << (_FP_W_TYPE_SIZE/2); \ _FP_FRAC_ADD_2(_z, _z, _a); \ \ /* normalize */ \ _FP_FRAC_SRS_2(_z, wfracbits - 1, 2*wfracbits); \ R##_f = _z_f0; \ } while (0)/* * Division algorithms: *//* Basic. Assuming the host word size is >= 2*FRACBITS, we can do the division immediately. Give this macro either _FP_DIV_HELP_imm for C primitives or _FP_DIV_HELP_ldiv for the ISO function. Which you choose will depend on what the compiler does with divrem4. */#define _FP_DIV_MEAT_1_imm(fs, R, X, Y, doit) \ do { \ _FP_W_TYPE _q, _r; \ X##_f <<= (X##_f < Y##_f \ ? R##_e--, _FP_WFRACBITS_##fs \ : _FP_WFRACBITS_##fs - 1); \ doit(_q, _r, X##_f, Y##_f); \ R##_f = _q | (_r != 0); \ } while (0)/* GCC's longlong.h defines a 2W / 1W => (1W,1W) primitive udiv_qrnnd
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -