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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [gcc/] [java/] [javaop.h] - Blame information for rev 16

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 12 jlechner
/* Utility macros to handle Java(TM) byte codes.
2
 
3
   Copyright (C) 1996, 1998, 1999, 2003 Free Software Foundation, Inc.
4
 
5
This file is part of GCC.
6
 
7
GCC is free software; you can redistribute it and/or modify
8
it under the terms of the GNU General Public License as published by
9
the Free Software Foundation; either version 2, or (at your option)
10
any later version.
11
 
12
GCC is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
GNU General Public License for more details.
16
 
17
You should have received a copy of the GNU General Public License
18
along with GCC; see the file COPYING.  If not, write to
19
the Free Software Foundation, 51 Franklin Street, Fifth Floor,
20
Boston, MA 02110-1301, USA.
21
 
22
Java and all Java-based marks are trademarks or registered trademarks
23
of Sun Microsystems, Inc. in the United States and other countries.
24
The Free Software Foundation is independent of Sun Microsystems, Inc.  */
25
 
26
/* Written by Per Bothner <bothner@cygnus.com>, February 1996. */
27
 
28
#ifndef GCC_JAVAOP_H
29
#define GCC_JAVAOP_H
30
 
31
typedef unsigned char   uint8;
32
#ifndef int16
33
#define int16 short
34
#endif
35
typedef unsigned int16  uint16;
36
 
37
#ifndef int32
38
#define int32 long
39
#endif
40
typedef unsigned int32  uint32;
41
 
42
/* A signed 64-bit (or more) integral type, suitable for Java's 'long'.  */
43
#ifndef int64
44
#define int64 long long
45
#endif
46
/* An unsigned 64-bit (or more) integral type, same length as int64. */
47
#ifndef uint64
48
#define uint64 unsigned int64
49
#endif
50
 
51
typedef uint16                  jchar;
52
typedef signed char             jbyte;
53
typedef int16                   jshort;
54
typedef int32                   jint;
55
typedef int64                   jlong;
56
typedef void*                   jref;
57
 
58
/* A 32-bit big-endian IEEE single-precision float. */
59
typedef struct _jfloat {
60
  unsigned int negative : 1;
61
  unsigned int exponent : 8;
62
  unsigned int mantissa : 23;
63
} jfloat;
64
#define JFLOAT_FINITE(f) ((f).exponent != 0xFF)
65
#define JFLOAT_QNAN_MASK 0x400000
66
#define JFLOAT_EXP_BIAS 0x7f
67
 
68
/* A 32-bit big-endian IEEE double-precision float. */
69
typedef struct _jdouble {
70
  unsigned int negative : 1;
71
  unsigned int exponent : 11;
72
  unsigned int mantissa0: 20;
73
  unsigned int mantissa1: 32;
74
} jdouble;
75
#define JDOUBLE_FINITE(f) ((f).exponent != 0x7FF)
76
#define JDOUBLE_QNAN_MASK 0x80000  /* apply to mantissa0 */
77
#define JDOUBLE_EXP_BIAS 0x3ff
78
 
79
/* A jword is an unsigned integral type big enough for a 32-bit jint
80
   or jfloat *or* a pointer.  It is the type appropriate for stack
81
   locations and local variables in a Java interpreter. */
82
 
83
 
84
#ifndef jword
85
#define jword uint32
86
#endif
87
 
88
#ifndef IMMEDIATE_u1
89
#define IMMEDIATE_u1 (PC++, CHECK_PC_IN_RANGE(PC), BCODE[PC-1])
90
#endif
91
#ifndef IMMEDIATE_s1
92
#define IMMEDIATE_s1 (PC++, CHECK_PC_IN_RANGE(PC), (signed char)BCODE[PC-1])
93
#endif
94
#ifndef IMMEDIATE_s2
95
#define IMMEDIATE_s2 (PC+=2, CHECK_PC_IN_RANGE(PC), \
96
  (signed char) BCODE[PC-2] * 256 + BCODE[PC-1])
97
#endif
98
#ifndef IMMEDIATE_u2
99
#define IMMEDIATE_u2 (PC+=2, CHECK_PC_IN_RANGE(PC),\
100
  (BCODE[PC-2] * 256 + BCODE[PC-1]))
101
#endif
102
#ifndef IMMEDIATE_s4
103
#define IMMEDIATE_s4 (PC+=4, CHECK_PC_IN_RANGE(PC), \
104
  (WORD_TO_INT((BCODE[PC-4] << 24) | (BCODE[PC-3] << 16) \
105
         | (BCODE[PC-2] << 8) | (BCODE[PC-1]))))
106
#endif
107
 
108
static inline jfloat
109
WORD_TO_FLOAT(jword w)
110
{
111
  jfloat f;
112
 
113
  f.negative = (w & 0x80000000) >> 31;
114
  f.exponent = (w & 0x7f800000) >> 23;
115
  f.mantissa = (w & 0x007fffff);
116
 
117
  return f;
118
}
119
 
120
/* Sign extend w.  If the host on which this cross-compiler runs uses
121
   a 64-bit type for jword the appropriate sign extension is
122
   performed; if it's a 32-bit type the arithmetic does nothing but is
123
   harmless.  */
124
static inline jint
125
WORD_TO_INT(jword w)
126
{
127
  jint n = w & 0xffffffff; /* Mask lower 32 bits.  */
128
  n ^= (jint)1 << 31;
129
  n -= (jint)1 << 31; /* Sign extend lower 32 bits to upper.  */
130
  return n;
131
}
132
 
133
static inline jlong
134
WORDS_TO_LONG(jword hi, jword lo)
135
{
136
  return ((jlong) hi << 32) | ((jlong)lo & (((jlong)1 << 32) -1));
137
}
138
 
139
static inline jdouble
140
WORDS_TO_DOUBLE(jword hi, jword lo)
141
{
142
  jdouble d;
143
 
144
  d.negative  = (hi & 0x80000000) >> 31;
145
  d.exponent  = (hi & 0x7ff00000) >> 20;
146
  d.mantissa0 = (hi & 0x000fffff);
147
  d.mantissa1 = lo;
148
 
149
  return d;
150
}
151
 
152
/* If PREFIX_CHAR is the first character of the Utf8 encoding of a character,
153
   return the number of bytes taken by the encoding.
154
   Return -1 for a continuation character.  */
155
#define UT8_CHAR_LENGTH(PREFIX_CHAR) \
156
  ((unsigned char)(PREFIX_CHAR) < 128 ? 1 \
157
   : ((PREFIX_CHAR) & 0x40) == 0 ? -1 \
158
   : ((PREFIX_CHAR) & 0x20) == 0 ? 2 \
159
   : ((PREFIX_CHAR) & 0x10) == 0 ? 3 \
160
   : ((PREFIX_CHAR) & 0x08) == 0 ? 4 : 5)
161
 
162
#endif /* ! GCC_JAVAOP_H */

powered by: WebSVN 2.1.0

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