1b35637a050d995634a21a126d37957f7bcee03a6petarj#include <stdio.h> 2eec22de88dd1b33cf85214fe08964baa2bb3efd2dejanj#include <math.h> 3b35637a050d995634a21a126d37957f7bcee03a6petarj#include "rounding_mode.h" 4b35637a050d995634a21a126d37957f7bcee03a6petarj#include "macro_fpu.h" 5b35637a050d995634a21a126d37957f7bcee03a6petarj 61dade8e2779ef99f57655a8913138709986ea9d0petarj#if defined(__mips_hard_float) 7b35637a050d995634a21a126d37957f7bcee03a6petarjint arithmeticOperations(flt_art_op_t op) 8b35637a050d995634a21a126d37957f7bcee03a6petarj{ 9b35637a050d995634a21a126d37957f7bcee03a6petarj double fd_d = 0; 10b35637a050d995634a21a126d37957f7bcee03a6petarj float fd_f = 0; 11b35637a050d995634a21a126d37957f7bcee03a6petarj int i = 0; 124164a8177ff1867390e0ff38d900c99c3101544cdejanj int fcsr = 0; 13b35637a050d995634a21a126d37957f7bcee03a6petarj round_mode_t rm; 14b35637a050d995634a21a126d37957f7bcee03a6petarj for (rm = TO_NEAREST; rm <= TO_MINUS_INFINITY; rm ++) { 15b35637a050d995634a21a126d37957f7bcee03a6petarj set_rounding_mode(rm); 16b35637a050d995634a21a126d37957f7bcee03a6petarj printf("roundig mode: %s\n", round_mode_name[rm]); 17b35637a050d995634a21a126d37957f7bcee03a6petarj for (i = 0; i < MAX_ARR; i++) { 18b35637a050d995634a21a126d37957f7bcee03a6petarj switch(op) { 19b35637a050d995634a21a126d37957f7bcee03a6petarj case ABSS: 20b35637a050d995634a21a126d37957f7bcee03a6petarj UNOPff("abs.s"); 21eec22de88dd1b33cf85214fe08964baa2bb3efd2dejanj printf("%s %f %f\n", flt_art_op_names[op], fd_f, fs_f[i]); 22b35637a050d995634a21a126d37957f7bcee03a6petarj break; 23b35637a050d995634a21a126d37957f7bcee03a6petarj case ABSD: 24b35637a050d995634a21a126d37957f7bcee03a6petarj UNOPdd("abs.d"); 25eec22de88dd1b33cf85214fe08964baa2bb3efd2dejanj printf("%s %lf %lf\n", flt_art_op_names[op], fd_d, fs_d[i]); 26b35637a050d995634a21a126d37957f7bcee03a6petarj break; 27b35637a050d995634a21a126d37957f7bcee03a6petarj case ADDS: 28b35637a050d995634a21a126d37957f7bcee03a6petarj BINOPf("add.s"); 29eec22de88dd1b33cf85214fe08964baa2bb3efd2dejanj printf("%s %f %f %f\n", 30b35637a050d995634a21a126d37957f7bcee03a6petarj flt_art_op_names[op], fd_f, fs_f[i], ft_f[i]); 31b35637a050d995634a21a126d37957f7bcee03a6petarj break; 32b35637a050d995634a21a126d37957f7bcee03a6petarj case ADDD: 33b35637a050d995634a21a126d37957f7bcee03a6petarj BINOPd("add.d"); 34eec22de88dd1b33cf85214fe08964baa2bb3efd2dejanj printf("%s %lf %lf %lf\n", 35b35637a050d995634a21a126d37957f7bcee03a6petarj flt_art_op_names[op], fd_d, fs_d[i], ft_d[i]); 36b35637a050d995634a21a126d37957f7bcee03a6petarj break; 37b35637a050d995634a21a126d37957f7bcee03a6petarj case DIVS: 38b35637a050d995634a21a126d37957f7bcee03a6petarj BINOPf("div.s"); 39eec22de88dd1b33cf85214fe08964baa2bb3efd2dejanj printf("%s %f %f %f\n", 40eec22de88dd1b33cf85214fe08964baa2bb3efd2dejanj flt_art_op_names[op], roundf(fd_f), fs_f[i], ft_f[i]); 41b35637a050d995634a21a126d37957f7bcee03a6petarj break; 42b35637a050d995634a21a126d37957f7bcee03a6petarj case DIVD: 43b35637a050d995634a21a126d37957f7bcee03a6petarj BINOPd("div.d"); 44eec22de88dd1b33cf85214fe08964baa2bb3efd2dejanj printf("%s %lf %lf %lf\n", 45eec22de88dd1b33cf85214fe08964baa2bb3efd2dejanj flt_art_op_names[op], round(fd_d), fs_d[i], ft_d[i]); 46b35637a050d995634a21a126d37957f7bcee03a6petarj break; 47b35637a050d995634a21a126d37957f7bcee03a6petarj case MULS: 48b35637a050d995634a21a126d37957f7bcee03a6petarj BINOPf("mul.s"); 49eec22de88dd1b33cf85214fe08964baa2bb3efd2dejanj printf("%s %f %f %f\n", 50eec22de88dd1b33cf85214fe08964baa2bb3efd2dejanj flt_art_op_names[op], roundf(fd_f), fs_f[i], ft_f[i]); 51b35637a050d995634a21a126d37957f7bcee03a6petarj break; 52b35637a050d995634a21a126d37957f7bcee03a6petarj case MULD: 53b35637a050d995634a21a126d37957f7bcee03a6petarj BINOPd("mul.d"); 54eec22de88dd1b33cf85214fe08964baa2bb3efd2dejanj printf("%s %lf %lf %lf\n", 55eec22de88dd1b33cf85214fe08964baa2bb3efd2dejanj flt_art_op_names[op], round(fd_d), fs_d[i], ft_d[i]); 56b35637a050d995634a21a126d37957f7bcee03a6petarj break; 57b35637a050d995634a21a126d37957f7bcee03a6petarj case NEGS: 58b35637a050d995634a21a126d37957f7bcee03a6petarj UNOPff("neg.s"); 59eec22de88dd1b33cf85214fe08964baa2bb3efd2dejanj printf("%s %f %f\n", flt_art_op_names[op], fd_f, fs_f[i]); 60b35637a050d995634a21a126d37957f7bcee03a6petarj break; 61b35637a050d995634a21a126d37957f7bcee03a6petarj case NEGD: 62b35637a050d995634a21a126d37957f7bcee03a6petarj UNOPdd("neg.d"); 63eec22de88dd1b33cf85214fe08964baa2bb3efd2dejanj printf("%s %lf %lf\n", flt_art_op_names[op], fd_d, fs_d[i]); 64b35637a050d995634a21a126d37957f7bcee03a6petarj break; 65b35637a050d995634a21a126d37957f7bcee03a6petarj case SQRTS: 66b35637a050d995634a21a126d37957f7bcee03a6petarj UNOPff("sqrt.s"); 67eec22de88dd1b33cf85214fe08964baa2bb3efd2dejanj printf("%s %f %f\n", 68eec22de88dd1b33cf85214fe08964baa2bb3efd2dejanj flt_art_op_names[op], roundf(fd_f), fs_f[i]); 69b35637a050d995634a21a126d37957f7bcee03a6petarj break; 70b35637a050d995634a21a126d37957f7bcee03a6petarj case SQRTD: 71b35637a050d995634a21a126d37957f7bcee03a6petarj UNOPdd("sqrt.d"); 72eec22de88dd1b33cf85214fe08964baa2bb3efd2dejanj printf("%s %lf %lf\n", 73eec22de88dd1b33cf85214fe08964baa2bb3efd2dejanj flt_art_op_names[op], round(fd_d), fs_d[i]); 74b35637a050d995634a21a126d37957f7bcee03a6petarj break; 75b35637a050d995634a21a126d37957f7bcee03a6petarj case SUBS: 76b35637a050d995634a21a126d37957f7bcee03a6petarj BINOPf("sub.s"); 77eec22de88dd1b33cf85214fe08964baa2bb3efd2dejanj printf("%s %f %f %f\n", 78b35637a050d995634a21a126d37957f7bcee03a6petarj flt_art_op_names[op], fd_f, fs_f[i], ft_f[i]); 79b35637a050d995634a21a126d37957f7bcee03a6petarj break; 80b35637a050d995634a21a126d37957f7bcee03a6petarj case SUBD: 81b35637a050d995634a21a126d37957f7bcee03a6petarj BINOPd("sub.d"); 82eec22de88dd1b33cf85214fe08964baa2bb3efd2dejanj printf("%s %lf %lf %lf\n", 83b35637a050d995634a21a126d37957f7bcee03a6petarj flt_art_op_names[op], fd_d, fs_d[i], ft_d[i]); 84b35637a050d995634a21a126d37957f7bcee03a6petarj break; 85b35637a050d995634a21a126d37957f7bcee03a6petarj case RECIPS: 86b35637a050d995634a21a126d37957f7bcee03a6petarj UNOPff("recip.s"); 87eec22de88dd1b33cf85214fe08964baa2bb3efd2dejanj printf("%s %f %f\n", 88eec22de88dd1b33cf85214fe08964baa2bb3efd2dejanj flt_art_op_names[op], roundf(fd_f), fs_f[i]); 89b35637a050d995634a21a126d37957f7bcee03a6petarj break; 90b35637a050d995634a21a126d37957f7bcee03a6petarj case RECIPD: 91b35637a050d995634a21a126d37957f7bcee03a6petarj UNOPdd("recip.d"); 92eec22de88dd1b33cf85214fe08964baa2bb3efd2dejanj printf("%s %lf %lf\n", 93eec22de88dd1b33cf85214fe08964baa2bb3efd2dejanj flt_art_op_names[op], round(fd_d), fs_d[i]); 94b35637a050d995634a21a126d37957f7bcee03a6petarj break; 95b35637a050d995634a21a126d37957f7bcee03a6petarj case RSQRTS: 96b35637a050d995634a21a126d37957f7bcee03a6petarj if (fs_f[i] >= 0) { 97b35637a050d995634a21a126d37957f7bcee03a6petarj UNOPff("rsqrt.s"); 98eec22de88dd1b33cf85214fe08964baa2bb3efd2dejanj printf("%s %f %f\n", 99eec22de88dd1b33cf85214fe08964baa2bb3efd2dejanj flt_art_op_names[op], roundf(fd_f), fs_f[i]); 100b35637a050d995634a21a126d37957f7bcee03a6petarj } 101b35637a050d995634a21a126d37957f7bcee03a6petarj break; 102b35637a050d995634a21a126d37957f7bcee03a6petarj case RSQRTD: 103b35637a050d995634a21a126d37957f7bcee03a6petarj if (fs_d[i] >= 0) { 104b35637a050d995634a21a126d37957f7bcee03a6petarj UNOPdd("rsqrt.d"); 105eec22de88dd1b33cf85214fe08964baa2bb3efd2dejanj printf("%s %lf %lf\n", 106eec22de88dd1b33cf85214fe08964baa2bb3efd2dejanj flt_art_op_names[op], round(fd_d), fs_d[i]); 107b35637a050d995634a21a126d37957f7bcee03a6petarj } 108b35637a050d995634a21a126d37957f7bcee03a6petarj break; 109b35637a050d995634a21a126d37957f7bcee03a6petarj case MSUBS: 110b35637a050d995634a21a126d37957f7bcee03a6petarj TRIOPf("msub.s"); 111eec22de88dd1b33cf85214fe08964baa2bb3efd2dejanj printf("%s %f %f %f %f\n",flt_art_op_names[op], roundf(fd_f), 112eec22de88dd1b33cf85214fe08964baa2bb3efd2dejanj fr_f[i], fs_f[i], ft_f[i]); 113b35637a050d995634a21a126d37957f7bcee03a6petarj break; 114b35637a050d995634a21a126d37957f7bcee03a6petarj case MSUBD: 115b35637a050d995634a21a126d37957f7bcee03a6petarj TRIOPd("msub.d"); 116eec22de88dd1b33cf85214fe08964baa2bb3efd2dejanj printf("%s %lf %lf %lf %lf\n", flt_art_op_names[op], round(fd_d), 117eec22de88dd1b33cf85214fe08964baa2bb3efd2dejanj fr_d[i], fs_d[i], ft_d[i]); 118b35637a050d995634a21a126d37957f7bcee03a6petarj break; 119b35637a050d995634a21a126d37957f7bcee03a6petarj case MADDS: 120b35637a050d995634a21a126d37957f7bcee03a6petarj TRIOPf("madd.s"); 121eec22de88dd1b33cf85214fe08964baa2bb3efd2dejanj printf("%s %f %f %f %f\n", flt_art_op_names[op], roundf(fd_f), 122eec22de88dd1b33cf85214fe08964baa2bb3efd2dejanj fr_f[i], fs_f[i], ft_f[i]); 123b35637a050d995634a21a126d37957f7bcee03a6petarj break; 124b35637a050d995634a21a126d37957f7bcee03a6petarj case MADDD: 125b35637a050d995634a21a126d37957f7bcee03a6petarj TRIOPd("madd.d"); 126eec22de88dd1b33cf85214fe08964baa2bb3efd2dejanj printf("%s %lf %lf %lf %lf\n", flt_art_op_names[op], round(fd_d), 127eec22de88dd1b33cf85214fe08964baa2bb3efd2dejanj fr_d[i], fs_d[i], ft_d[i]); 128b35637a050d995634a21a126d37957f7bcee03a6petarj break; 129b35637a050d995634a21a126d37957f7bcee03a6petarj case NMADDS: 130b35637a050d995634a21a126d37957f7bcee03a6petarj TRIOPf("nmadd.s"); 131eec22de88dd1b33cf85214fe08964baa2bb3efd2dejanj printf("%s %f %f %f %f\n", flt_art_op_names[op], roundf(fd_f), 132eec22de88dd1b33cf85214fe08964baa2bb3efd2dejanj fr_f[i], fs_f[i], ft_f[i]); 133b35637a050d995634a21a126d37957f7bcee03a6petarj break; 134b35637a050d995634a21a126d37957f7bcee03a6petarj case NMADDD: 135b35637a050d995634a21a126d37957f7bcee03a6petarj TRIOPd("nmadd.d"); 136eec22de88dd1b33cf85214fe08964baa2bb3efd2dejanj printf("%s %lf %lf %lf %lf\n", flt_art_op_names[op], round(fd_d), 137eec22de88dd1b33cf85214fe08964baa2bb3efd2dejanj fr_d[i], fs_d[i], ft_d[i]); 138b35637a050d995634a21a126d37957f7bcee03a6petarj break; 139b35637a050d995634a21a126d37957f7bcee03a6petarj case NMSUBS: 140b35637a050d995634a21a126d37957f7bcee03a6petarj TRIOPf("nmsub.s"); 141eec22de88dd1b33cf85214fe08964baa2bb3efd2dejanj printf("%s %f %f %f %f\n", flt_art_op_names[op], roundf(fd_f), 142eec22de88dd1b33cf85214fe08964baa2bb3efd2dejanj fr_f[i], fs_f[i], ft_f[i]); 143b35637a050d995634a21a126d37957f7bcee03a6petarj break; 144b35637a050d995634a21a126d37957f7bcee03a6petarj case NMSUBD: 145b35637a050d995634a21a126d37957f7bcee03a6petarj TRIOPd("nmsub.d"); 146eec22de88dd1b33cf85214fe08964baa2bb3efd2dejanj printf("%s 0x%lf %lf %lf %lf\n", flt_art_op_names[op], 147eec22de88dd1b33cf85214fe08964baa2bb3efd2dejanj round(fd_d), fr_d[i], fs_d[i], 148eec22de88dd1b33cf85214fe08964baa2bb3efd2dejanj ft_d[i]); 149b35637a050d995634a21a126d37957f7bcee03a6petarj break; 150b35637a050d995634a21a126d37957f7bcee03a6petarj default: 151b35637a050d995634a21a126d37957f7bcee03a6petarj printf("error\n"); 152b35637a050d995634a21a126d37957f7bcee03a6petarj break; 153b35637a050d995634a21a126d37957f7bcee03a6petarj } 154b35637a050d995634a21a126d37957f7bcee03a6petarj } 155b35637a050d995634a21a126d37957f7bcee03a6petarj } 156b35637a050d995634a21a126d37957f7bcee03a6petarj return 0; 157b35637a050d995634a21a126d37957f7bcee03a6petarj} 1581dade8e2779ef99f57655a8913138709986ea9d0petarj#endif 159b35637a050d995634a21a126d37957f7bcee03a6petarj 160b35637a050d995634a21a126d37957f7bcee03a6petarjint main() 161b35637a050d995634a21a126d37957f7bcee03a6petarj{ 1621dade8e2779ef99f57655a8913138709986ea9d0petarj#if defined(__mips_hard_float) 163b35637a050d995634a21a126d37957f7bcee03a6petarj flt_art_op_t op; 164b35637a050d995634a21a126d37957f7bcee03a6petarj 165b35637a050d995634a21a126d37957f7bcee03a6petarj printf("-------------------------- %s --------------------------\n", 166b35637a050d995634a21a126d37957f7bcee03a6petarj "test FPU Arithmetic Operations"); 167b35637a050d995634a21a126d37957f7bcee03a6petarj for (op = ABSS; op <= NMSUBD; op++) { 168b35637a050d995634a21a126d37957f7bcee03a6petarj arithmeticOperations(op); 169b35637a050d995634a21a126d37957f7bcee03a6petarj } 1701dade8e2779ef99f57655a8913138709986ea9d0petarj#endif 171b35637a050d995634a21a126d37957f7bcee03a6petarj return 0; 172b35637a050d995634a21a126d37957f7bcee03a6petarj} 173