Open64 (mfef90, whirl2f, and IR tools)
TAG: version-openad; SVN changeset: 916
|
00001 /* 00002 00003 Copyright (C) 2000, 2001 Silicon Graphics, Inc. All Rights Reserved. 00004 00005 This program is free software; you can redistribute it and/or modify it 00006 under the terms of version 2 of the GNU General Public License as 00007 published by the Free Software Foundation. 00008 00009 This program is distributed in the hope that it would be useful, but 00010 WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00012 00013 Further, this software is distributed without any warranty that it is 00014 free of the rightful claim of any third person regarding infringement 00015 or the like. Any license provided herein, whether implied or 00016 otherwise, applies only to this software file. Patent licenses, if 00017 any, provided herein do not apply to combinations of this program with 00018 other software, or any other product whatsoever. 00019 00020 You should have received a copy of the GNU General Public License along 00021 with this program; if not, write the Free Software Foundation, Inc., 59 00022 Temple Place - Suite 330, Boston MA 02111-1307, USA. 00023 00024 Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pky, 00025 Mountain View, CA 94043, or: 00026 00027 http://www.sgi.com 00028 00029 For further information regarding this notice, see: 00030 00031 http://oss.sgi.com/projects/GenInfo/NoticeExplan 00032 00033 */ 00034 00035 00036 #ifndef __WHIRL2F_H__ 00037 #define __WHIRL2F_H__ 00038 00039 00040 00041 /* Assuming two's complement representation, we do this as follows 00042 * for a 32 bits integral type: 00043 * 00044 * i >> n ==> ((-(2**n) | (i>>n)) 00045 */ 00046 #define I4ASHR(v1, v2) \ 00047 IOR(ISHFT(IAND('80000000'X, v1), -31)*ISHFT(-1, 32-v2), ISHFT(v1, -v2)) 00048 #define I8ASHR(v1, v2) \ 00049 IOR(ISHFT(IAND('8000000000000000'X, v1), -63_8)*ISHFT(-1, 64-v2), ISHFT(v1, -v2)) 00050 #define U4ASHR(v1, v2) I4ASHR(v1, v2) 00051 #define U8ASHR(v1, v2) I8ASHR(v1, v2) 00052 00053 00054 /* See whirl2c.h for comments on this implementation of DIVFLOOR and 00055 * DIVCEIL. 00056 */ 00057 #define _I4SIGN(y) (2 * I4ASHR(y, 31) + 1) 00058 #define _I4MASK(x, y, v) IAND(I4ASHR(IEOR(x,y), 31), v) 00059 #define _I8SIGN(y) (2_8 * I8ASHR(y, 63) + 1_8) 00060 #define _I8MASK(x, y, v) IAND(I8ASHR(IEOR(x,y), 63), v) 00061 00062 #define INTRN_I4DIVFLOOR(v1, v2) \ 00063 ((v1) + _I4MASK(v1, v2, _I4SIGN(v2) - (v2))) / (v2) 00064 #define INTRN_I8DIVFLOOR(v1, v2) \ 00065 ((v1) + _I8MASK(v1, v2, _I8SIGN(v2) - (v2))) / (v2) 00066 #define INTRN_U4DIVFLOOR(v1, v2) I4DIVFLOOR(v1, v2) 00067 #define INTRN_U8DIVFLOOR(v1, v2) I8DIVFLOOR(v1, v2) 00068 00069 #define INTRN_I4DIVCEIL(v1, v2) -I4DIVFLOOR(-(v1), v2) 00070 #define INTRN_I8DIVCEIL(v1, v2) -I8DIVFLOOR(-(v1), v2) 00071 #define INTRN_U4DIVCEIL(v1, v2) ((v1)+(v2)-1)/(v2) 00072 #define INTRN_U8DIVCEIL(v1, v2) ((v1)+(v2)-1)/(v2) 00073 00074 #define INTRN_I4MODFLOOR(v1, v2) (v1 - v2*I4DIVFLOOR(v1, v2)) 00075 #define INTRN_I8MODFLOOR(v1, v2) (v1 - v2*I8DIVFLOOR(v1, v2)) 00076 #define INTRN_U4MODFLOOR(v1, v2) (v1 - v2*(v1/v2)) 00077 #define INTRN_U8MODFLOOR(v1, v2) (v1 - v2*(v1/v2)) 00078 00079 #define INTRN_I4MODCEIL(v1, v2) (v1 - v2*I4DIVCEIL(v1, v2)) 00080 #define INTRN_I8MODCEIL(v1, v2) (v1 - v2*I8DIVCEIL(v1, v2)) 00081 #define INTRN_U4MODCEIL(v1, v2) (v1 - v2*U4DIVCEIL(v1, v2)) 00082 #define INTRN_U8MODCEIL(v1, v2) (v1 - v2*U8DIVCEIL(v1, v2)) 00083 00084 00085 /* How do we do this without writing a function? 00086 */ 00087 #define CEIL(v) '?????TODO(CEIL)?????' 00088 #define FLOOR(v) '?????TODO(FLOOR)?????' 00089 00090 #endif __WHIRL2F_H__