OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc1/] [gcc/] [java/] [javaop.h] - Diff between revs 287 and 338

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 287 Rev 338
/* Utility macros to handle Java(TM) byte codes.
/* Utility macros to handle Java(TM) byte codes.
 
 
   Copyright (C) 1996, 1998, 1999, 2003, 2007 Free Software Foundation, Inc.
   Copyright (C) 1996, 1998, 1999, 2003, 2007 Free Software Foundation, Inc.
 
 
This file is part of GCC.
This file is part of GCC.
 
 
GCC is free software; you can redistribute it and/or modify
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
the Free Software Foundation; either version 3, or (at your option)
any later version.
any later version.
 
 
GCC is distributed in the hope that it will be useful,
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
GNU General Public License for more details.
 
 
You should have received a copy of the GNU General Public License
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.
<http://www.gnu.org/licenses/>.
 
 
Java and all Java-based marks are trademarks or registered trademarks
Java and all Java-based marks are trademarks or registered trademarks
of Sun Microsystems, Inc. in the United States and other countries.
of Sun Microsystems, Inc. in the United States and other countries.
The Free Software Foundation is independent of Sun Microsystems, Inc.  */
The Free Software Foundation is independent of Sun Microsystems, Inc.  */
 
 
/* Written by Per Bothner <bothner@cygnus.com>, February 1996. */
/* Written by Per Bothner <bothner@cygnus.com>, February 1996. */
 
 
#ifndef GCC_JAVAOP_H
#ifndef GCC_JAVAOP_H
#define GCC_JAVAOP_H
#define GCC_JAVAOP_H
 
 
typedef unsigned char   uint8;
typedef unsigned char   uint8;
#ifndef int16
#ifndef int16
#if __SHRT_MAX__ == 32767
#if __SHRT_MAX__ == 32767
#define int16 short
#define int16 short
#elif __INT_MAX__ == 32767
#elif __INT_MAX__ == 32767
#define int16 int
#define int16 int
#elif __LONG_MAX__ == 32767
#elif __LONG_MAX__ == 32767
#define int16 long
#define int16 long
#else
#else
#define int16 short
#define int16 short
#endif
#endif
#endif
#endif
typedef unsigned int16  uint16;
typedef unsigned int16  uint16;
 
 
#ifndef int32
#ifndef int32
#if __INT_MAX__ == 2147483647
#if __INT_MAX__ == 2147483647
#define int32 int
#define int32 int
#elif __LONG_MAX__ == 2147483647
#elif __LONG_MAX__ == 2147483647
#define int32 long
#define int32 long
#elif __SHRT_MAX__ == 2147483647
#elif __SHRT_MAX__ == 2147483647
#define int32 short
#define int32 short
#else
#else
#define int32 int
#define int32 int
#endif
#endif
#endif
#endif
typedef unsigned int32  uint32;
typedef unsigned int32  uint32;
 
 
/* A signed 64-bit (or more) integral type, suitable for Java's 'long'.  */
/* A signed 64-bit (or more) integral type, suitable for Java's 'long'.  */
#ifndef int64
#ifndef int64
#if __LONG_MAX__ == 9223372036854775807LL
#if __LONG_MAX__ == 9223372036854775807LL
#define int64 long
#define int64 long
#elif __LONG_LONG_MAX__ == 9223372036854775807LL
#elif __LONG_LONG_MAX__ == 9223372036854775807LL
#define int64 long long
#define int64 long long
#else
#else
#define int64 long long
#define int64 long long
#endif
#endif
#endif
#endif
/* An unsigned 64-bit (or more) integral type, same length as int64. */
/* An unsigned 64-bit (or more) integral type, same length as int64. */
#ifndef uint64
#ifndef uint64
#define uint64 unsigned int64
#define uint64 unsigned int64
#endif
#endif
 
 
typedef uint16                  jchar;
typedef uint16                  jchar;
typedef signed char             jbyte;
typedef signed char             jbyte;
typedef int16                   jshort;
typedef int16                   jshort;
typedef int32                   jint;
typedef int32                   jint;
typedef int64                   jlong;
typedef int64                   jlong;
typedef void*                   jref;
typedef void*                   jref;
 
 
/* A 32-bit big-endian IEEE single-precision float. */
/* A 32-bit big-endian IEEE single-precision float. */
typedef struct _jfloat {
typedef struct _jfloat {
  unsigned int negative : 1;
  unsigned int negative : 1;
  unsigned int exponent : 8;
  unsigned int exponent : 8;
  unsigned int mantissa : 23;
  unsigned int mantissa : 23;
} jfloat;
} jfloat;
#define JFLOAT_FINITE(f) ((f).exponent != 0xFF)
#define JFLOAT_FINITE(f) ((f).exponent != 0xFF)
#define JFLOAT_QNAN_MASK 0x400000
#define JFLOAT_QNAN_MASK 0x400000
#define JFLOAT_EXP_BIAS 0x7f
#define JFLOAT_EXP_BIAS 0x7f
 
 
/* A 32-bit big-endian IEEE double-precision float. */
/* A 32-bit big-endian IEEE double-precision float. */
typedef struct _jdouble {
typedef struct _jdouble {
  unsigned int negative : 1;
  unsigned int negative : 1;
  unsigned int exponent : 11;
  unsigned int exponent : 11;
  unsigned int mantissa0: 20;
  unsigned int mantissa0: 20;
  unsigned int mantissa1: 32;
  unsigned int mantissa1: 32;
} jdouble;
} jdouble;
#define JDOUBLE_FINITE(f) ((f).exponent != 0x7FF)
#define JDOUBLE_FINITE(f) ((f).exponent != 0x7FF)
#define JDOUBLE_QNAN_MASK 0x80000  /* apply to mantissa0 */
#define JDOUBLE_QNAN_MASK 0x80000  /* apply to mantissa0 */
#define JDOUBLE_EXP_BIAS 0x3ff
#define JDOUBLE_EXP_BIAS 0x3ff
 
 
/* A jword is an unsigned integral type big enough for a 32-bit jint
/* A jword is an unsigned integral type big enough for a 32-bit jint
   or jfloat *or* a pointer.  It is the type appropriate for stack
   or jfloat *or* a pointer.  It is the type appropriate for stack
   locations and local variables in a Java interpreter. */
   locations and local variables in a Java interpreter. */
 
 
 
 
#ifndef jword
#ifndef jword
#if defined (__LP64__) || defined (__alpha__) || defined (__MMIX__) \
#if defined (__LP64__) || defined (__alpha__) || defined (__MMIX__) \
    || (defined (_ARCH_PPC) && defined (__64BIT__)) \
    || (defined (_ARCH_PPC) && defined (__64BIT__)) \
    || defined (__powerpc64__) || defined (__s390x__) || defined (__x86_64__) \
    || defined (__powerpc64__) || defined (__s390x__) || defined (__x86_64__) \
    || defined (__sparcv9) || (defined (__sparc__) && defined (__arch64__))
    || defined (__sparcv9) || (defined (__sparc__) && defined (__arch64__))
#define jword uint64
#define jword uint64
#else
#else
#define jword uint32
#define jword uint32
#endif
#endif
#endif
#endif
 
 
#ifndef IMMEDIATE_u1
#ifndef IMMEDIATE_u1
#define IMMEDIATE_u1 (PC++, CHECK_PC_IN_RANGE(PC), BCODE[PC-1])
#define IMMEDIATE_u1 (PC++, CHECK_PC_IN_RANGE(PC), BCODE[PC-1])
#endif
#endif
#ifndef IMMEDIATE_s1
#ifndef IMMEDIATE_s1
#define IMMEDIATE_s1 (PC++, CHECK_PC_IN_RANGE(PC), (signed char)BCODE[PC-1])
#define IMMEDIATE_s1 (PC++, CHECK_PC_IN_RANGE(PC), (signed char)BCODE[PC-1])
#endif
#endif
#ifndef IMMEDIATE_s2
#ifndef IMMEDIATE_s2
#define IMMEDIATE_s2 (PC+=2, CHECK_PC_IN_RANGE(PC), \
#define IMMEDIATE_s2 (PC+=2, CHECK_PC_IN_RANGE(PC), \
  (signed char) BCODE[PC-2] * 256 + BCODE[PC-1])
  (signed char) BCODE[PC-2] * 256 + BCODE[PC-1])
#endif
#endif
#ifndef IMMEDIATE_u2
#ifndef IMMEDIATE_u2
#define IMMEDIATE_u2 (PC+=2, CHECK_PC_IN_RANGE(PC),\
#define IMMEDIATE_u2 (PC+=2, CHECK_PC_IN_RANGE(PC),\
  (BCODE[PC-2] * 256 + BCODE[PC-1]))
  (BCODE[PC-2] * 256 + BCODE[PC-1]))
#endif
#endif
#ifndef IMMEDIATE_s4
#ifndef IMMEDIATE_s4
#define IMMEDIATE_s4 (PC+=4, CHECK_PC_IN_RANGE(PC), \
#define IMMEDIATE_s4 (PC+=4, CHECK_PC_IN_RANGE(PC), \
  (WORD_TO_INT((BCODE[PC-4] << 24) | (BCODE[PC-3] << 16) \
  (WORD_TO_INT((BCODE[PC-4] << 24) | (BCODE[PC-3] << 16) \
         | (BCODE[PC-2] << 8) | (BCODE[PC-1]))))
         | (BCODE[PC-2] << 8) | (BCODE[PC-1]))))
#endif
#endif
 
 
static inline jfloat
static inline jfloat
WORD_TO_FLOAT(jword w)
WORD_TO_FLOAT(jword w)
{
{
  jfloat f;
  jfloat f;
 
 
  f.negative = (w & 0x80000000) >> 31;
  f.negative = (w & 0x80000000) >> 31;
  f.exponent = (w & 0x7f800000) >> 23;
  f.exponent = (w & 0x7f800000) >> 23;
  f.mantissa = (w & 0x007fffff);
  f.mantissa = (w & 0x007fffff);
 
 
  return f;
  return f;
}
}
 
 
/* Sign extend w.  If the host on which this cross-compiler runs uses
/* Sign extend w.  If the host on which this cross-compiler runs uses
   a 64-bit type for jword the appropriate sign extension is
   a 64-bit type for jword the appropriate sign extension is
   performed; if it's a 32-bit type the arithmetic does nothing but is
   performed; if it's a 32-bit type the arithmetic does nothing but is
   harmless.  */
   harmless.  */
static inline jint
static inline jint
WORD_TO_INT(jword w)
WORD_TO_INT(jword w)
{
{
  jint n = w & 0xffffffff; /* Mask lower 32 bits.  */
  jint n = w & 0xffffffff; /* Mask lower 32 bits.  */
  n ^= (jint)1 << 31;
  n ^= (jint)1 << 31;
  n -= (jint)1 << 31; /* Sign extend lower 32 bits to upper.  */
  n -= (jint)1 << 31; /* Sign extend lower 32 bits to upper.  */
  return n;
  return n;
}
}
 
 
static inline jlong
static inline jlong
WORDS_TO_LONG(jword hi, jword lo)
WORDS_TO_LONG(jword hi, jword lo)
{
{
  return ((jlong) hi << 32) | ((jlong)lo & (((jlong)1 << 32) -1));
  return ((jlong) hi << 32) | ((jlong)lo & (((jlong)1 << 32) -1));
}
}
 
 
static inline jdouble
static inline jdouble
WORDS_TO_DOUBLE(jword hi, jword lo)
WORDS_TO_DOUBLE(jword hi, jword lo)
{
{
  jdouble d;
  jdouble d;
 
 
  d.negative  = (hi & 0x80000000) >> 31;
  d.negative  = (hi & 0x80000000) >> 31;
  d.exponent  = (hi & 0x7ff00000) >> 20;
  d.exponent  = (hi & 0x7ff00000) >> 20;
  d.mantissa0 = (hi & 0x000fffff);
  d.mantissa0 = (hi & 0x000fffff);
  d.mantissa1 = lo;
  d.mantissa1 = lo;
 
 
  return d;
  return d;
}
}
 
 
/* If PREFIX_CHAR is the first character of the Utf8 encoding of a character,
/* If PREFIX_CHAR is the first character of the Utf8 encoding of a character,
   return the number of bytes taken by the encoding.
   return the number of bytes taken by the encoding.
   Return -1 for a continuation character.  */
   Return -1 for a continuation character.  */
#define UT8_CHAR_LENGTH(PREFIX_CHAR) \
#define UT8_CHAR_LENGTH(PREFIX_CHAR) \
  ((unsigned char)(PREFIX_CHAR) < 128 ? 1 \
  ((unsigned char)(PREFIX_CHAR) < 128 ? 1 \
   : ((PREFIX_CHAR) & 0x40) == 0 ? -1 \
   : ((PREFIX_CHAR) & 0x40) == 0 ? -1 \
   : ((PREFIX_CHAR) & 0x20) == 0 ? 2 \
   : ((PREFIX_CHAR) & 0x20) == 0 ? 2 \
   : ((PREFIX_CHAR) & 0x10) == 0 ? 3 \
   : ((PREFIX_CHAR) & 0x10) == 0 ? 3 \
   : ((PREFIX_CHAR) & 0x08) == 0 ? 4 : 5)
   : ((PREFIX_CHAR) & 0x08) == 0 ? 4 : 5)
 
 
#endif /* ! GCC_JAVAOP_H */
#endif /* ! GCC_JAVAOP_H */
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.