1999-04-16 01:35:26 +00:00
|
|
|
|
/* Semantics ops support for CGEN-based simulators.
|
2008-01-01 22:53:26 +00:00
|
|
|
|
Copyright (C) 1996, 1997, 1998, 1999, 2002, 2007, 2008
|
2007-01-09 17:59:20 +00:00
|
|
|
|
Free Software Foundation, Inc.
|
1999-04-16 01:35:26 +00:00
|
|
|
|
Contributed by Cygnus Solutions.
|
|
|
|
|
|
|
|
|
|
This file is part of the GNU Simulators.
|
|
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2007-08-24 14:30:15 +00:00
|
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
|
|
|
(at your option) any later version.
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
2007-08-24 14:30:15 +00:00
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef CGEN_SEM_OPS_H
|
|
|
|
|
#define CGEN_SEM_OPS_H
|
|
|
|
|
|
2000-11-19 22:27:14 +00:00
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
1999-04-26 18:34:20 +00:00
|
|
|
|
#if defined (__GNUC__) && ! defined (SEMOPS_DEFINE_INLINE)
|
|
|
|
|
#define SEMOPS_DEFINE_INLINE
|
|
|
|
|
#define SEMOPS_INLINE extern inline
|
|
|
|
|
#else
|
|
|
|
|
#define SEMOPS_INLINE
|
|
|
|
|
#endif
|
|
|
|
|
|
1999-04-16 01:35:26 +00:00
|
|
|
|
/* Semantic operations.
|
|
|
|
|
At one point this file was machine generated. Maybe it will be again. */
|
|
|
|
|
|
1999-07-05 17:58:44 +00:00
|
|
|
|
/* TODO: Lazy encoding/decoding of fp values. */
|
|
|
|
|
|
1999-04-16 01:35:26 +00:00
|
|
|
|
/* These don't really have a mode. */
|
|
|
|
|
#define ANDIF(x, y) ((x) && (y))
|
|
|
|
|
#define ORIF(x, y) ((x) || (y))
|
|
|
|
|
|
2000-11-19 22:27:14 +00:00
|
|
|
|
#define SUBBI(x, y) ((x) - (y))
|
1999-04-16 01:35:26 +00:00
|
|
|
|
#define ANDBI(x, y) ((x) & (y))
|
|
|
|
|
#define ORBI(x, y) ((x) | (y))
|
|
|
|
|
#define XORBI(x, y) ((x) ^ (y))
|
|
|
|
|
#define NEGBI(x) (- (x))
|
|
|
|
|
#define NOTBI(x) (! (BI) (x))
|
|
|
|
|
#define INVBI(x) (~ (x))
|
|
|
|
|
#define EQBI(x, y) ((BI) (x) == (BI) (y))
|
|
|
|
|
#define NEBI(x, y) ((BI) (x) != (BI) (y))
|
|
|
|
|
#define LTBI(x, y) ((BI) (x) < (BI) (y))
|
|
|
|
|
#define LEBI(x, y) ((BI) (x) <= (BI) (y))
|
|
|
|
|
#define GTBI(x, y) ((BI) (x) > (BI) (y))
|
|
|
|
|
#define GEBI(x, y) ((BI) (x) >= (BI) (y))
|
|
|
|
|
#define LTUBI(x, y) ((BI) (x) < (BI) (y))
|
|
|
|
|
#define LEUBI(x, y) ((BI) (x) <= (BI) (y))
|
|
|
|
|
#define GTUBI(x, y) ((BI) (x) > (BI) (y))
|
|
|
|
|
#define GEUBI(x, y) ((BI) (x) >= (BI) (y))
|
1999-07-05 17:58:44 +00:00
|
|
|
|
|
1999-04-16 01:35:26 +00:00
|
|
|
|
#define ADDQI(x, y) ((x) + (y))
|
|
|
|
|
#define SUBQI(x, y) ((x) - (y))
|
|
|
|
|
#define MULQI(x, y) ((x) * (y))
|
|
|
|
|
#define DIVQI(x, y) ((QI) (x) / (QI) (y))
|
|
|
|
|
#define UDIVQI(x, y) ((UQI) (x) / (UQI) (y))
|
|
|
|
|
#define MODQI(x, y) ((QI) (x) % (QI) (y))
|
|
|
|
|
#define UMODQI(x, y) ((UQI) (x) % (UQI) (y))
|
|
|
|
|
#define SRAQI(x, y) ((QI) (x) >> (y))
|
|
|
|
|
#define SRLQI(x, y) ((UQI) (x) >> (y))
|
|
|
|
|
#define SLLQI(x, y) ((UQI) (x) << (y))
|
1999-07-05 17:58:44 +00:00
|
|
|
|
extern QI RORQI (QI, int);
|
|
|
|
|
extern QI ROLQI (QI, int);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
#define ANDQI(x, y) ((x) & (y))
|
|
|
|
|
#define ORQI(x, y) ((x) | (y))
|
|
|
|
|
#define XORQI(x, y) ((x) ^ (y))
|
|
|
|
|
#define NEGQI(x) (- (x))
|
|
|
|
|
#define NOTQI(x) (! (QI) (x))
|
|
|
|
|
#define INVQI(x) (~ (x))
|
2000-01-25 02:40:50 +00:00
|
|
|
|
#define ABSQI(x) ((x) < 0 ? -(x) : (x))
|
1999-04-16 01:35:26 +00:00
|
|
|
|
#define EQQI(x, y) ((QI) (x) == (QI) (y))
|
|
|
|
|
#define NEQI(x, y) ((QI) (x) != (QI) (y))
|
|
|
|
|
#define LTQI(x, y) ((QI) (x) < (QI) (y))
|
|
|
|
|
#define LEQI(x, y) ((QI) (x) <= (QI) (y))
|
|
|
|
|
#define GTQI(x, y) ((QI) (x) > (QI) (y))
|
|
|
|
|
#define GEQI(x, y) ((QI) (x) >= (QI) (y))
|
|
|
|
|
#define LTUQI(x, y) ((UQI) (x) < (UQI) (y))
|
|
|
|
|
#define LEUQI(x, y) ((UQI) (x) <= (UQI) (y))
|
|
|
|
|
#define GTUQI(x, y) ((UQI) (x) > (UQI) (y))
|
|
|
|
|
#define GEUQI(x, y) ((UQI) (x) >= (UQI) (y))
|
1999-07-05 17:58:44 +00:00
|
|
|
|
|
1999-04-16 01:35:26 +00:00
|
|
|
|
#define ADDHI(x, y) ((x) + (y))
|
|
|
|
|
#define SUBHI(x, y) ((x) - (y))
|
|
|
|
|
#define MULHI(x, y) ((x) * (y))
|
|
|
|
|
#define DIVHI(x, y) ((HI) (x) / (HI) (y))
|
|
|
|
|
#define UDIVHI(x, y) ((UHI) (x) / (UHI) (y))
|
|
|
|
|
#define MODHI(x, y) ((HI) (x) % (HI) (y))
|
|
|
|
|
#define UMODHI(x, y) ((UHI) (x) % (UHI) (y))
|
|
|
|
|
#define SRAHI(x, y) ((HI) (x) >> (y))
|
|
|
|
|
#define SRLHI(x, y) ((UHI) (x) >> (y))
|
|
|
|
|
#define SLLHI(x, y) ((UHI) (x) << (y))
|
1999-07-05 17:58:44 +00:00
|
|
|
|
extern HI RORHI (HI, int);
|
|
|
|
|
extern HI ROLHI (HI, int);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
#define ANDHI(x, y) ((x) & (y))
|
|
|
|
|
#define ORHI(x, y) ((x) | (y))
|
|
|
|
|
#define XORHI(x, y) ((x) ^ (y))
|
|
|
|
|
#define NEGHI(x) (- (x))
|
|
|
|
|
#define NOTHI(x) (! (HI) (x))
|
|
|
|
|
#define INVHI(x) (~ (x))
|
2000-01-25 02:40:50 +00:00
|
|
|
|
#define ABSHI(x) ((x) < 0 ? -(x) : (x))
|
1999-04-16 01:35:26 +00:00
|
|
|
|
#define EQHI(x, y) ((HI) (x) == (HI) (y))
|
|
|
|
|
#define NEHI(x, y) ((HI) (x) != (HI) (y))
|
|
|
|
|
#define LTHI(x, y) ((HI) (x) < (HI) (y))
|
|
|
|
|
#define LEHI(x, y) ((HI) (x) <= (HI) (y))
|
|
|
|
|
#define GTHI(x, y) ((HI) (x) > (HI) (y))
|
|
|
|
|
#define GEHI(x, y) ((HI) (x) >= (HI) (y))
|
|
|
|
|
#define LTUHI(x, y) ((UHI) (x) < (UHI) (y))
|
|
|
|
|
#define LEUHI(x, y) ((UHI) (x) <= (UHI) (y))
|
|
|
|
|
#define GTUHI(x, y) ((UHI) (x) > (UHI) (y))
|
|
|
|
|
#define GEUHI(x, y) ((UHI) (x) >= (UHI) (y))
|
1999-07-05 17:58:44 +00:00
|
|
|
|
|
1999-04-16 01:35:26 +00:00
|
|
|
|
#define ADDSI(x, y) ((x) + (y))
|
|
|
|
|
#define SUBSI(x, y) ((x) - (y))
|
|
|
|
|
#define MULSI(x, y) ((x) * (y))
|
|
|
|
|
#define DIVSI(x, y) ((SI) (x) / (SI) (y))
|
|
|
|
|
#define UDIVSI(x, y) ((USI) (x) / (USI) (y))
|
|
|
|
|
#define MODSI(x, y) ((SI) (x) % (SI) (y))
|
|
|
|
|
#define UMODSI(x, y) ((USI) (x) % (USI) (y))
|
|
|
|
|
#define SRASI(x, y) ((SI) (x) >> (y))
|
|
|
|
|
#define SRLSI(x, y) ((USI) (x) >> (y))
|
|
|
|
|
#define SLLSI(x, y) ((USI) (x) << (y))
|
1999-07-05 17:58:44 +00:00
|
|
|
|
extern SI RORSI (SI, int);
|
|
|
|
|
extern SI ROLSI (SI, int);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
#define ANDSI(x, y) ((x) & (y))
|
|
|
|
|
#define ORSI(x, y) ((x) | (y))
|
|
|
|
|
#define XORSI(x, y) ((x) ^ (y))
|
|
|
|
|
#define NEGSI(x) (- (x))
|
|
|
|
|
#define NOTSI(x) (! (SI) (x))
|
|
|
|
|
#define INVSI(x) (~ (x))
|
2000-01-25 02:40:50 +00:00
|
|
|
|
#define ABSSI(x) ((x) < 0 ? -(x) : (x))
|
1999-04-16 01:35:26 +00:00
|
|
|
|
#define EQSI(x, y) ((SI) (x) == (SI) (y))
|
|
|
|
|
#define NESI(x, y) ((SI) (x) != (SI) (y))
|
|
|
|
|
#define LTSI(x, y) ((SI) (x) < (SI) (y))
|
|
|
|
|
#define LESI(x, y) ((SI) (x) <= (SI) (y))
|
|
|
|
|
#define GTSI(x, y) ((SI) (x) > (SI) (y))
|
|
|
|
|
#define GESI(x, y) ((SI) (x) >= (SI) (y))
|
|
|
|
|
#define LTUSI(x, y) ((USI) (x) < (USI) (y))
|
|
|
|
|
#define LEUSI(x, y) ((USI) (x) <= (USI) (y))
|
|
|
|
|
#define GTUSI(x, y) ((USI) (x) > (USI) (y))
|
|
|
|
|
#define GEUSI(x, y) ((USI) (x) >= (USI) (y))
|
1999-07-05 17:58:44 +00:00
|
|
|
|
|
1999-04-16 01:35:26 +00:00
|
|
|
|
#ifdef DI_FN_SUPPORT
|
1999-07-05 17:58:44 +00:00
|
|
|
|
extern DI ADDDI (DI, DI);
|
|
|
|
|
extern DI SUBDI (DI, DI);
|
|
|
|
|
extern DI MULDI (DI, DI);
|
|
|
|
|
extern DI DIVDI (DI, DI);
|
|
|
|
|
extern DI UDIVDI (DI, DI);
|
|
|
|
|
extern DI MODDI (DI, DI);
|
|
|
|
|
extern DI UMODDI (DI, DI);
|
|
|
|
|
extern DI SRADI (DI, int);
|
|
|
|
|
extern UDI SRLDI (UDI, int);
|
|
|
|
|
extern UDI SLLDI (UDI, int);
|
|
|
|
|
extern DI RORDI (DI, int);
|
|
|
|
|
extern DI ROLDI (DI, int);
|
|
|
|
|
extern DI ANDDI (DI, DI);
|
|
|
|
|
extern DI ORDI (DI, DI);
|
|
|
|
|
extern DI XORDI (DI, DI);
|
|
|
|
|
extern DI NEGDI (DI);
|
|
|
|
|
extern int NOTDI (DI);
|
|
|
|
|
extern DI INVDI (DI);
|
|
|
|
|
extern int EQDI (DI, DI);
|
|
|
|
|
extern int NEDI (DI, DI);
|
|
|
|
|
extern int LTDI (DI, DI);
|
|
|
|
|
extern int LEDI (DI, DI);
|
|
|
|
|
extern int GTDI (DI, DI);
|
|
|
|
|
extern int GEDI (DI, DI);
|
|
|
|
|
extern int LTUDI (UDI, UDI);
|
|
|
|
|
extern int LEUDI (UDI, UDI);
|
|
|
|
|
extern int GTUDI (UDI, UDI);
|
|
|
|
|
extern int GEUDI (UDI, UDI);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
#else /* ! DI_FN_SUPPORT */
|
|
|
|
|
#define ADDDI(x, y) ((x) + (y))
|
|
|
|
|
#define SUBDI(x, y) ((x) - (y))
|
|
|
|
|
#define MULDI(x, y) ((x) * (y))
|
|
|
|
|
#define DIVDI(x, y) ((DI) (x) / (DI) (y))
|
|
|
|
|
#define UDIVDI(x, y) ((UDI) (x) / (UDI) (y))
|
|
|
|
|
#define MODDI(x, y) ((DI) (x) % (DI) (y))
|
|
|
|
|
#define UMODDI(x, y) ((UDI) (x) % (UDI) (y))
|
|
|
|
|
#define SRADI(x, y) ((DI) (x) >> (y))
|
|
|
|
|
#define SRLDI(x, y) ((UDI) (x) >> (y))
|
|
|
|
|
#define SLLDI(x, y) ((UDI) (x) << (y))
|
1999-07-05 17:58:44 +00:00
|
|
|
|
extern DI RORDI (DI, int);
|
|
|
|
|
extern DI ROLDI (DI, int);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
#define ANDDI(x, y) ((x) & (y))
|
|
|
|
|
#define ORDI(x, y) ((x) | (y))
|
|
|
|
|
#define XORDI(x, y) ((x) ^ (y))
|
|
|
|
|
#define NEGDI(x) (- (x))
|
|
|
|
|
#define NOTDI(x) (! (DI) (x))
|
|
|
|
|
#define INVDI(x) (~ (x))
|
2000-01-25 02:40:50 +00:00
|
|
|
|
#define ABSDI(x) ((x) < 0 ? -(x) : (x))
|
1999-04-16 01:35:26 +00:00
|
|
|
|
#define EQDI(x, y) ((DI) (x) == (DI) (y))
|
|
|
|
|
#define NEDI(x, y) ((DI) (x) != (DI) (y))
|
|
|
|
|
#define LTDI(x, y) ((DI) (x) < (DI) (y))
|
|
|
|
|
#define LEDI(x, y) ((DI) (x) <= (DI) (y))
|
|
|
|
|
#define GTDI(x, y) ((DI) (x) > (DI) (y))
|
|
|
|
|
#define GEDI(x, y) ((DI) (x) >= (DI) (y))
|
|
|
|
|
#define LTUDI(x, y) ((UDI) (x) < (UDI) (y))
|
|
|
|
|
#define LEUDI(x, y) ((UDI) (x) <= (UDI) (y))
|
|
|
|
|
#define GTUDI(x, y) ((UDI) (x) > (UDI) (y))
|
|
|
|
|
#define GEUDI(x, y) ((UDI) (x) >= (UDI) (y))
|
|
|
|
|
#endif /* DI_FN_SUPPORT */
|
1999-07-05 17:58:44 +00:00
|
|
|
|
|
1999-04-16 01:35:26 +00:00
|
|
|
|
#define EXTBIQI(x) ((QI) (BI) (x))
|
|
|
|
|
#define EXTBIHI(x) ((HI) (BI) (x))
|
|
|
|
|
#define EXTBISI(x) ((SI) (BI) (x))
|
|
|
|
|
#if defined (DI_FN_SUPPORT)
|
1999-07-05 17:58:44 +00:00
|
|
|
|
extern DI EXTBIDI (BI);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
#else
|
|
|
|
|
#define EXTBIDI(x) ((DI) (BI) (x))
|
|
|
|
|
#endif
|
|
|
|
|
#define EXTQIHI(x) ((HI) (QI) (x))
|
|
|
|
|
#define EXTQISI(x) ((SI) (QI) (x))
|
|
|
|
|
#if defined (DI_FN_SUPPORT)
|
1999-07-05 17:58:44 +00:00
|
|
|
|
extern DI EXTQIDI (QI);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
#else
|
|
|
|
|
#define EXTQIDI(x) ((DI) (QI) (x))
|
|
|
|
|
#endif
|
2000-01-26 21:49:14 +00:00
|
|
|
|
#define EXTHIHI(x) ((HI) (HI) (x))
|
1999-04-16 01:35:26 +00:00
|
|
|
|
#define EXTHISI(x) ((SI) (HI) (x))
|
2000-01-25 02:40:50 +00:00
|
|
|
|
#define EXTSISI(x) ((SI) (SI) (x))
|
1999-04-16 01:35:26 +00:00
|
|
|
|
#if defined (DI_FN_SUPPORT)
|
1999-07-05 17:58:44 +00:00
|
|
|
|
extern DI EXTHIDI (HI);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
#else
|
|
|
|
|
#define EXTHIDI(x) ((DI) (HI) (x))
|
|
|
|
|
#endif
|
|
|
|
|
#if defined (DI_FN_SUPPORT)
|
1999-07-05 17:58:44 +00:00
|
|
|
|
extern DI EXTSIDI (SI);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
#else
|
|
|
|
|
#define EXTSIDI(x) ((DI) (SI) (x))
|
|
|
|
|
#endif
|
1999-07-05 17:58:44 +00:00
|
|
|
|
|
1999-04-16 01:35:26 +00:00
|
|
|
|
#define ZEXTBIQI(x) ((QI) (BI) (x))
|
|
|
|
|
#define ZEXTBIHI(x) ((HI) (BI) (x))
|
|
|
|
|
#define ZEXTBISI(x) ((SI) (BI) (x))
|
|
|
|
|
#if defined (DI_FN_SUPPORT)
|
1999-07-05 17:58:44 +00:00
|
|
|
|
extern DI ZEXTBIDI (BI);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
#else
|
|
|
|
|
#define ZEXTBIDI(x) ((DI) (BI) (x))
|
|
|
|
|
#endif
|
|
|
|
|
#define ZEXTQIHI(x) ((HI) (UQI) (x))
|
|
|
|
|
#define ZEXTQISI(x) ((SI) (UQI) (x))
|
|
|
|
|
#if defined (DI_FN_SUPPORT)
|
1999-07-05 17:58:44 +00:00
|
|
|
|
extern DI ZEXTQIDI (QI);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
#else
|
|
|
|
|
#define ZEXTQIDI(x) ((DI) (UQI) (x))
|
|
|
|
|
#endif
|
|
|
|
|
#define ZEXTHISI(x) ((SI) (UHI) (x))
|
2000-01-25 02:40:50 +00:00
|
|
|
|
#define ZEXTHIHI(x) ((HI) (UHI) (x))
|
|
|
|
|
#define ZEXTSISI(x) ((SI) (USI) (x))
|
1999-04-16 01:35:26 +00:00
|
|
|
|
#if defined (DI_FN_SUPPORT)
|
1999-07-05 17:58:44 +00:00
|
|
|
|
extern DI ZEXTHIDI (HI);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
#else
|
|
|
|
|
#define ZEXTHIDI(x) ((DI) (UHI) (x))
|
|
|
|
|
#endif
|
|
|
|
|
#if defined (DI_FN_SUPPORT)
|
1999-07-05 17:58:44 +00:00
|
|
|
|
extern DI ZEXTSIDI (SI);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
#else
|
|
|
|
|
#define ZEXTSIDI(x) ((DI) (USI) (x))
|
|
|
|
|
#endif
|
1999-07-05 17:58:44 +00:00
|
|
|
|
|
1999-04-16 01:35:26 +00:00
|
|
|
|
#define TRUNCQIBI(x) ((BI) (QI) (x))
|
|
|
|
|
#define TRUNCHIBI(x) ((BI) (HI) (x))
|
|
|
|
|
#define TRUNCHIQI(x) ((QI) (HI) (x))
|
|
|
|
|
#define TRUNCSIBI(x) ((BI) (SI) (x))
|
|
|
|
|
#define TRUNCSIQI(x) ((QI) (SI) (x))
|
|
|
|
|
#define TRUNCSIHI(x) ((HI) (SI) (x))
|
2000-03-13 23:51:48 +00:00
|
|
|
|
#define TRUNCSISI(x) ((SI) (SI) (x))
|
1999-04-16 01:35:26 +00:00
|
|
|
|
#if defined (DI_FN_SUPPORT)
|
1999-07-05 17:58:44 +00:00
|
|
|
|
extern BI TRUNCDIBI (DI);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
#else
|
|
|
|
|
#define TRUNCDIBI(x) ((BI) (DI) (x))
|
|
|
|
|
#endif
|
|
|
|
|
#if defined (DI_FN_SUPPORT)
|
1999-07-05 17:58:44 +00:00
|
|
|
|
extern QI TRUNCDIQI (DI);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
#else
|
|
|
|
|
#define TRUNCDIQI(x) ((QI) (DI) (x))
|
|
|
|
|
#endif
|
|
|
|
|
#if defined (DI_FN_SUPPORT)
|
1999-07-05 17:58:44 +00:00
|
|
|
|
extern HI TRUNCDIHI (DI);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
#else
|
|
|
|
|
#define TRUNCDIHI(x) ((HI) (DI) (x))
|
|
|
|
|
#endif
|
|
|
|
|
#if defined (DI_FN_SUPPORT)
|
1999-07-05 17:58:44 +00:00
|
|
|
|
extern SI TRUNCDISI (DI);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
#else
|
|
|
|
|
#define TRUNCDISI(x) ((SI) (DI) (x))
|
|
|
|
|
#endif
|
|
|
|
|
|
1999-09-28 21:55:21 +00:00
|
|
|
|
/* Composing/decomposing the various types.
|
|
|
|
|
Word ordering is endian-independent. Words are specified most to least
|
|
|
|
|
significant and word number 0 is the most significant word.
|
|
|
|
|
??? May also wish an endian-dependent version. Later. */
|
1999-07-05 17:58:44 +00:00
|
|
|
|
|
1999-04-16 01:35:26 +00:00
|
|
|
|
#ifdef SEMOPS_DEFINE_INLINE
|
1999-04-26 18:34:20 +00:00
|
|
|
|
|
|
|
|
|
SEMOPS_INLINE SF
|
1999-09-28 21:55:21 +00:00
|
|
|
|
SUBWORDSISF (SI in)
|
1999-04-26 18:34:20 +00:00
|
|
|
|
{
|
|
|
|
|
union { SI in; SF out; } x;
|
|
|
|
|
x.in = in;
|
|
|
|
|
return x.out;
|
|
|
|
|
}
|
|
|
|
|
|
2000-11-19 22:27:14 +00:00
|
|
|
|
SEMOPS_INLINE DF
|
|
|
|
|
SUBWORDDIDF (DI in)
|
|
|
|
|
{
|
|
|
|
|
union { DI in; DF out; } x;
|
|
|
|
|
x.in = in;
|
|
|
|
|
return x.out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SEMOPS_INLINE QI
|
|
|
|
|
SUBWORDSIQI (SI in, int byte)
|
|
|
|
|
{
|
|
|
|
|
assert (byte >= 0 && byte <= 3);
|
2000-12-04 04:05:45 +00:00
|
|
|
|
return (UQI) (in >> (8 * (3 - byte))) & 0xFF;
|
2000-11-19 22:27:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SEMOPS_INLINE UQI
|
|
|
|
|
SUBWORDSIUQI (SI in, int byte)
|
|
|
|
|
{
|
|
|
|
|
assert (byte >= 0 && byte <= 3);
|
2000-12-04 04:05:45 +00:00
|
|
|
|
return (UQI) (in >> (8 * (3 - byte))) & 0xFF;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SEMOPS_INLINE QI
|
|
|
|
|
SUBWORDDIQI (DI in, int byte)
|
|
|
|
|
{
|
|
|
|
|
assert (byte >= 0 && byte <= 7);
|
|
|
|
|
return (UQI) (in >> (8 * (7 - byte))) & 0xFF;
|
2000-11-19 22:27:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SEMOPS_INLINE HI
|
|
|
|
|
SUBWORDDIHI (DI in, int word)
|
|
|
|
|
{
|
|
|
|
|
assert (word >= 0 && word <= 3);
|
2000-12-04 04:05:45 +00:00
|
|
|
|
return (UHI) (in >> (16 * (3 - word))) & 0xFFFF;
|
2000-11-19 22:27:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SEMOPS_INLINE HI
|
|
|
|
|
SUBWORDSIHI (SI in, int word)
|
|
|
|
|
{
|
|
|
|
|
if (word == 0)
|
|
|
|
|
return (USI) in >> 16;
|
|
|
|
|
else
|
|
|
|
|
return in;
|
|
|
|
|
}
|
|
|
|
|
|
1999-04-26 18:34:20 +00:00
|
|
|
|
SEMOPS_INLINE SI
|
1999-09-28 21:55:21 +00:00
|
|
|
|
SUBWORDSFSI (SF in)
|
1999-04-26 18:34:20 +00:00
|
|
|
|
{
|
|
|
|
|
union { SF in; SI out; } x;
|
|
|
|
|
x.in = in;
|
|
|
|
|
return x.out;
|
|
|
|
|
}
|
|
|
|
|
|
2000-12-11 07:14:34 +00:00
|
|
|
|
SEMOPS_INLINE DI
|
|
|
|
|
SUBWORDDFDI (DF in)
|
|
|
|
|
{
|
|
|
|
|
union { DF in; DI out; } x;
|
|
|
|
|
x.in = in;
|
|
|
|
|
return x.out;
|
|
|
|
|
}
|
|
|
|
|
|
2000-11-19 22:27:14 +00:00
|
|
|
|
SEMOPS_INLINE UQI
|
|
|
|
|
SUBWORDDIUQI (DI in, int byte)
|
|
|
|
|
{
|
|
|
|
|
assert (byte >= 0 && byte <= 7);
|
|
|
|
|
return (UQI) (in >> (8 * (7 - byte)));
|
|
|
|
|
}
|
|
|
|
|
|
1999-04-26 18:34:20 +00:00
|
|
|
|
SEMOPS_INLINE SI
|
1999-09-28 21:55:21 +00:00
|
|
|
|
SUBWORDDISI (DI in, int word)
|
1999-04-26 18:34:20 +00:00
|
|
|
|
{
|
1999-09-28 21:55:21 +00:00
|
|
|
|
if (word == 0)
|
|
|
|
|
return (UDI) in >> 32;
|
1999-04-26 18:34:20 +00:00
|
|
|
|
else
|
1999-09-28 21:55:21 +00:00
|
|
|
|
return in;
|
1999-04-26 18:34:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SEMOPS_INLINE SI
|
1999-09-28 21:55:21 +00:00
|
|
|
|
SUBWORDDFSI (DF in, int word)
|
1999-04-26 18:34:20 +00:00
|
|
|
|
{
|
1999-09-28 21:55:21 +00:00
|
|
|
|
/* Note: typedef UDI DF; */
|
|
|
|
|
if (word == 0)
|
|
|
|
|
return (UDI) in >> 32;
|
1999-04-26 18:34:20 +00:00
|
|
|
|
else
|
1999-09-28 21:55:21 +00:00
|
|
|
|
return in;
|
1999-04-26 18:34:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-07-05 17:58:44 +00:00
|
|
|
|
SEMOPS_INLINE SI
|
1999-09-28 21:55:21 +00:00
|
|
|
|
SUBWORDXFSI (XF in, int word)
|
1999-07-05 17:58:44 +00:00
|
|
|
|
{
|
1999-09-28 21:55:21 +00:00
|
|
|
|
/* Note: typedef struct { SI parts[3]; } XF; */
|
1999-07-05 17:58:44 +00:00
|
|
|
|
union { XF in; SI out[3]; } x;
|
|
|
|
|
x.in = in;
|
1999-09-28 21:55:21 +00:00
|
|
|
|
return x.out[word];
|
1999-07-05 17:58:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-04-26 18:34:20 +00:00
|
|
|
|
SEMOPS_INLINE SI
|
1999-09-28 21:55:21 +00:00
|
|
|
|
SUBWORDTFSI (TF in, int word)
|
1999-04-26 18:34:20 +00:00
|
|
|
|
{
|
1999-09-28 21:55:21 +00:00
|
|
|
|
/* Note: typedef struct { SI parts[4]; } TF; */
|
1999-04-26 18:34:20 +00:00
|
|
|
|
union { TF in; SI out[4]; } x;
|
|
|
|
|
x.in = in;
|
1999-09-28 21:55:21 +00:00
|
|
|
|
return x.out[word];
|
1999-04-26 18:34:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SEMOPS_INLINE DI
|
1999-09-28 21:55:21 +00:00
|
|
|
|
JOINSIDI (SI x0, SI x1)
|
1999-04-26 18:34:20 +00:00
|
|
|
|
{
|
|
|
|
|
if (CURRENT_TARGET_BYTE_ORDER == BIG_ENDIAN)
|
|
|
|
|
return MAKEDI (x0, x1);
|
|
|
|
|
else
|
|
|
|
|
return MAKEDI (x1, x0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SEMOPS_INLINE DF
|
1999-09-28 21:55:21 +00:00
|
|
|
|
JOINSIDF (SI x0, SI x1)
|
1999-04-26 18:34:20 +00:00
|
|
|
|
{
|
|
|
|
|
union { SI in[2]; DF out; } x;
|
|
|
|
|
if (CURRENT_TARGET_BYTE_ORDER == BIG_ENDIAN)
|
|
|
|
|
x.in[0] = x0, x.in[1] = x1;
|
|
|
|
|
else
|
|
|
|
|
x.in[1] = x0, x.in[0] = x1;
|
|
|
|
|
return x.out;
|
|
|
|
|
}
|
|
|
|
|
|
1999-07-05 17:58:44 +00:00
|
|
|
|
SEMOPS_INLINE XF
|
1999-09-28 21:55:21 +00:00
|
|
|
|
JOINSIXF (SI x0, SI x1, SI x2)
|
1999-07-05 17:58:44 +00:00
|
|
|
|
{
|
|
|
|
|
union { SI in[3]; XF out; } x;
|
|
|
|
|
if (CURRENT_TARGET_BYTE_ORDER == BIG_ENDIAN)
|
|
|
|
|
x.in[0] = x0, x.in[1] = x1, x.in[2] = x2;
|
|
|
|
|
else
|
|
|
|
|
x.in[2] = x0, x.in[1] = x1, x.in[0] = x2;
|
|
|
|
|
return x.out;
|
|
|
|
|
}
|
|
|
|
|
|
1999-04-26 18:34:20 +00:00
|
|
|
|
SEMOPS_INLINE TF
|
1999-09-28 21:55:21 +00:00
|
|
|
|
JOINSITF (SI x0, SI x1, SI x2, SI x3)
|
1999-04-26 18:34:20 +00:00
|
|
|
|
{
|
|
|
|
|
union { SI in[4]; TF out; } x;
|
|
|
|
|
if (CURRENT_TARGET_BYTE_ORDER == BIG_ENDIAN)
|
|
|
|
|
x.in[0] = x0, x.in[1] = x1, x.in[2] = x2, x.in[3] = x3;
|
|
|
|
|
else
|
|
|
|
|
x.in[3] = x0, x.in[2] = x1, x.in[1] = x2, x.in[0] = x3;
|
|
|
|
|
return x.out;
|
|
|
|
|
}
|
|
|
|
|
|
1999-04-16 01:35:26 +00:00
|
|
|
|
#else
|
1999-04-26 18:34:20 +00:00
|
|
|
|
|
2000-11-19 22:27:14 +00:00
|
|
|
|
QI SUBWORDSIQI (SI);
|
|
|
|
|
HI SUBWORDSIHI (HI);
|
1999-09-28 21:55:21 +00:00
|
|
|
|
SI SUBWORDSFSI (SF);
|
2000-11-19 22:27:14 +00:00
|
|
|
|
SF SUBWORDSISF (SI);
|
2000-12-11 07:14:34 +00:00
|
|
|
|
DI SUBWORDDFDI (DF);
|
2000-11-19 22:27:14 +00:00
|
|
|
|
DF SUBWORDDIDF (DI);
|
2000-12-04 04:05:45 +00:00
|
|
|
|
QI SUBWORDDIQI (DI, int);
|
2000-11-19 22:27:14 +00:00
|
|
|
|
HI SUBWORDDIHI (DI, int);
|
1999-09-28 21:55:21 +00:00
|
|
|
|
SI SUBWORDDISI (DI, int);
|
|
|
|
|
SI SUBWORDDFSI (DF, int);
|
|
|
|
|
SI SUBWORDXFSI (XF, int);
|
|
|
|
|
SI SUBWORDTFSI (TF, int);
|
1999-04-26 18:34:20 +00:00
|
|
|
|
|
2000-11-19 22:27:14 +00:00
|
|
|
|
UQI SUBWORDSIUQI (SI);
|
|
|
|
|
UQI SUBWORDDIUQI (DI);
|
|
|
|
|
|
1999-09-28 21:55:21 +00:00
|
|
|
|
DI JOINSIDI (SI, SI);
|
|
|
|
|
DF JOINSIDF (SI, SI);
|
|
|
|
|
XF JOINSIXF (SI, SI, SI);
|
|
|
|
|
TF JOINSITF (SI, SI, SI, SI);
|
1999-04-26 18:34:20 +00:00
|
|
|
|
|
|
|
|
|
#endif /* SUBWORD,JOIN */
|
|
|
|
|
|
|
|
|
|
/* Semantic support utilities. */
|
|
|
|
|
|
|
|
|
|
#ifdef SEMOPS_DEFINE_INLINE
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
SEMOPS_INLINE SI
|
|
|
|
|
ADDCSI (SI a, SI b, BI c)
|
|
|
|
|
{
|
|
|
|
|
SI res = ADDSI (a, ADDSI (b, c));
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SEMOPS_INLINE BI
|
|
|
|
|
ADDCFSI (SI a, SI b, BI c)
|
|
|
|
|
{
|
|
|
|
|
SI tmp = ADDSI (a, ADDSI (b, c));
|
|
|
|
|
BI res = ((USI) tmp < (USI) a) || (c && tmp == a);
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SEMOPS_INLINE BI
|
|
|
|
|
ADDOFSI (SI a, SI b, BI c)
|
|
|
|
|
{
|
|
|
|
|
SI tmp = ADDSI (a, ADDSI (b, c));
|
|
|
|
|
BI res = (((a < 0) == (b < 0))
|
|
|
|
|
&& ((a < 0) != (tmp < 0)));
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SEMOPS_INLINE SI
|
|
|
|
|
SUBCSI (SI a, SI b, BI c)
|
|
|
|
|
{
|
|
|
|
|
SI res = SUBSI (a, ADDSI (b, c));
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SEMOPS_INLINE BI
|
|
|
|
|
SUBCFSI (SI a, SI b, BI c)
|
|
|
|
|
{
|
|
|
|
|
BI res = ((USI) a < (USI) b) || (c && a == b);
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SEMOPS_INLINE BI
|
|
|
|
|
SUBOFSI (SI a, SI b, BI c)
|
|
|
|
|
{
|
|
|
|
|
SI tmp = SUBSI (a, ADDSI (b, c));
|
|
|
|
|
BI res = (((a < 0) != (b < 0))
|
|
|
|
|
&& ((a < 0) != (tmp < 0)));
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
2000-01-25 02:40:50 +00:00
|
|
|
|
SEMOPS_INLINE HI
|
|
|
|
|
ADDCHI (HI a, HI b, BI c)
|
|
|
|
|
{
|
|
|
|
|
HI res = ADDHI (a, ADDHI (b, c));
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SEMOPS_INLINE BI
|
|
|
|
|
ADDCFHI (HI a, HI b, BI c)
|
|
|
|
|
{
|
|
|
|
|
HI tmp = ADDHI (a, ADDHI (b, c));
|
|
|
|
|
BI res = ((UHI) tmp < (UHI) a) || (c && tmp == a);
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SEMOPS_INLINE BI
|
|
|
|
|
ADDOFHI (HI a, HI b, BI c)
|
|
|
|
|
{
|
|
|
|
|
HI tmp = ADDHI (a, ADDHI (b, c));
|
|
|
|
|
BI res = (((a < 0) == (b < 0))
|
|
|
|
|
&& ((a < 0) != (tmp < 0)));
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SEMOPS_INLINE HI
|
|
|
|
|
SUBCHI (HI a, HI b, BI c)
|
|
|
|
|
{
|
|
|
|
|
HI res = SUBHI (a, ADDHI (b, c));
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SEMOPS_INLINE BI
|
|
|
|
|
SUBCFHI (HI a, HI b, BI c)
|
|
|
|
|
{
|
|
|
|
|
BI res = ((UHI) a < (UHI) b) || (c && a == b);
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SEMOPS_INLINE BI
|
|
|
|
|
SUBOFHI (HI a, HI b, BI c)
|
|
|
|
|
{
|
|
|
|
|
HI tmp = SUBHI (a, ADDHI (b, c));
|
|
|
|
|
BI res = (((a < 0) != (b < 0))
|
|
|
|
|
&& ((a < 0) != (tmp < 0)));
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
2002-01-31 17:55:16 +00:00
|
|
|
|
SEMOPS_INLINE QI
|
|
|
|
|
ADDCQI (QI a, QI b, BI c)
|
|
|
|
|
{
|
|
|
|
|
QI res = ADDQI (a, ADDQI (b, c));
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SEMOPS_INLINE BI
|
|
|
|
|
ADDCFQI (QI a, QI b, BI c)
|
|
|
|
|
{
|
|
|
|
|
QI tmp = ADDQI (a, ADDQI (b, c));
|
|
|
|
|
BI res = ((UQI) tmp < (UQI) a) || (c && tmp == a);
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SEMOPS_INLINE BI
|
|
|
|
|
ADDOFQI (QI a, QI b, BI c)
|
|
|
|
|
{
|
|
|
|
|
QI tmp = ADDQI (a, ADDQI (b, c));
|
|
|
|
|
BI res = (((a < 0) == (b < 0))
|
|
|
|
|
&& ((a < 0) != (tmp < 0)));
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SEMOPS_INLINE QI
|
|
|
|
|
SUBCQI (QI a, QI b, BI c)
|
|
|
|
|
{
|
|
|
|
|
QI res = SUBQI (a, ADDQI (b, c));
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SEMOPS_INLINE BI
|
|
|
|
|
SUBCFQI (QI a, QI b, BI c)
|
|
|
|
|
{
|
|
|
|
|
BI res = ((UQI) a < (UQI) b) || (c && a == b);
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SEMOPS_INLINE BI
|
|
|
|
|
SUBOFQI (QI a, QI b, BI c)
|
|
|
|
|
{
|
|
|
|
|
QI tmp = SUBQI (a, ADDQI (b, c));
|
|
|
|
|
BI res = (((a < 0) != (b < 0))
|
|
|
|
|
&& ((a < 0) != (tmp < 0)));
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
1999-04-16 01:35:26 +00:00
|
|
|
|
#else
|
|
|
|
|
|
|
|
|
|
SI ADDCSI (SI, SI, BI);
|
|
|
|
|
UBI ADDCFSI (SI, SI, BI);
|
|
|
|
|
UBI ADDOFSI (SI, SI, BI);
|
|
|
|
|
SI SUBCSI (SI, SI, BI);
|
|
|
|
|
UBI SUBCFSI (SI, SI, BI);
|
|
|
|
|
UBI SUBOFSI (SI, SI, BI);
|
2000-01-25 02:40:50 +00:00
|
|
|
|
HI ADDCHI (HI, HI, BI);
|
|
|
|
|
UBI ADDCFHI (HI, HI, BI);
|
|
|
|
|
UBI ADDOFHI (HI, HI, BI);
|
|
|
|
|
HI SUBCHI (HI, HI, BI);
|
|
|
|
|
UBI SUBCFHI (HI, HI, BI);
|
|
|
|
|
UBI SUBOFHI (HI, HI, BI);
|
2002-01-31 17:55:16 +00:00
|
|
|
|
QI ADDCQI (QI, QI, BI);
|
|
|
|
|
UBI ADDCFQI (QI, QI, BI);
|
|
|
|
|
UBI ADDOFQI (QI, QI, BI);
|
|
|
|
|
QI SUBCQI (QI, QI, BI);
|
|
|
|
|
UBI SUBCFQI (QI, QI, BI);
|
|
|
|
|
UBI SUBOFQI (QI, QI, BI);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#endif /* CGEN_SEM_OPS_H */
|