Commit cacc154e by Alexandre Petit-Bianco Committed by Alexandre Petit-Bianco

jcf-write.c: (RELOCATION_VALUE_0): New macro.

Tue Sep 14 16:24:19 1999  Alexandre Petit-Bianco  <apbianco@cygnus.com>

        * jcf-write.c: (RELOCATION_VALUE_0): New macro.
        (RELOCATION_VALUE_1): Likewise.
        (emit_iinc, emit_reloc, push_constant1, push_constant2,
        push_in_const, push_long_const): Prototyped.
        (push_constant1): Argument `index' is of type HOST_WIDE_INT.
        (push_constant2): Likewise.
        (push_int_const): Cast find_constant1's integer arguments to `jword'.
        (find_constant_wide): Cast find_constant2's integer arguments to
        `jword'.
        (find_constant_index): Cast find_constant2's and find_constant2's
        integer arguments to `jword'.
        (emit_pop): Argument `value' is of type HOST_WIDE_INT.
        (emit_switch_reloc): Use RELOCATION_VALUE_0.
        (emit_if): Use RELOCATION_VALUE_1.
        (emit_goto): Likewise.
        (emit_jsr): Likewise.
        (generate_bytecode_insns): Use RELOCATION_VALUE_0. Cast second
        argument to push_long_const to HOST_WIDE_INT.

(This is a forgotten patch.)

From-SVN: r29932
parent 006d4a9b
...@@ -35,6 +35,27 @@ Fri Sep 24 10:48:10 1999 Bernd Schmidt <bernds@cygnus.co.uk> ...@@ -35,6 +35,27 @@ Fri Sep 24 10:48:10 1999 Bernd Schmidt <bernds@cygnus.co.uk>
(WORDS_TO_LONG): Likewise. (WORDS_TO_LONG): Likewise.
(WORDS_TO_DOUBLE): Likewise. (WORDS_TO_DOUBLE): Likewise.
Tue Sep 14 16:24:19 1999 Alexandre Petit-Bianco <apbianco@cygnus.com>
* jcf-write.c: (RELOCATION_VALUE_0): New macro.
(RELOCATION_VALUE_1): Likewise.
(emit_iinc, emit_reloc, push_constant1, push_constant2,
push_in_const, push_long_const): Prototyped.
(push_constant1): Argument `index' is of type HOST_WIDE_INT.
(push_constant2): Likewise.
(push_int_const): Cast find_constant1's integer arguments to `jword'.
(find_constant_wide): Cast find_constant2's integer arguments to
`jword'.
(find_constant_index): Cast find_constant2's and find_constant2's
integer arguments to `jword'.
(emit_pop): Argument `value' is of type HOST_WIDE_INT.
(emit_switch_reloc): Use RELOCATION_VALUE_0.
(emit_if): Use RELOCATION_VALUE_1.
(emit_goto): Likewise.
(emit_jsr): Likewise.
(generate_bytecode_insns): Use RELOCATION_VALUE_0. Cast second
argument to push_long_const to HOST_WIDE_INT.
1999-09-15 Andreas Schwab <schwab@suse.de> 1999-09-15 Andreas Schwab <schwab@suse.de>
* Makefile.in (parse.o): Depend on $(JAVA_TREE_H). * Makefile.in (parse.o): Depend on $(JAVA_TREE_H).
......
...@@ -186,6 +186,9 @@ struct jcf_relocation ...@@ -186,6 +186,9 @@ struct jcf_relocation
struct jcf_block *label; struct jcf_block *label;
}; };
#define RELOCATION_VALUE_0 ((HOST_WIDE_INT)0)
#define RELOCATION_VALUE_1 ((HOST_WIDE_INT)0)
/* State for single catch clause. */ /* State for single catch clause. */
struct jcf_handler struct jcf_handler
...@@ -302,11 +305,16 @@ static struct chunk * generate_classfile PROTO ((tree, struct jcf_partial *)); ...@@ -302,11 +305,16 @@ static struct chunk * generate_classfile PROTO ((tree, struct jcf_partial *));
static struct jcf_handler *alloc_handler PROTO ((struct jcf_block *, static struct jcf_handler *alloc_handler PROTO ((struct jcf_block *,
struct jcf_block *, struct jcf_block *,
struct jcf_partial *)); struct jcf_partial *));
static void push_constant1 PROTO ((int, struct jcf_partial *)); static void emit_iinc PROTO ((tree, HOST_WIDE_INT, struct jcf_partial *));
static void push_constant2 PROTO ((int, struct jcf_partial *)); static void emit_reloc PROTO ((HOST_WIDE_INT, int, struct jcf_block *,
struct jcf_partial *));
static void push_constant1 PROTO ((HOST_WIDE_INT, struct jcf_partial *));
static void push_constant2 PROTO ((HOST_WIDE_INT, struct jcf_partial *));
static void push_int_const PROTO ((HOST_WIDE_INT, struct jcf_partial *)); static void push_int_const PROTO ((HOST_WIDE_INT, struct jcf_partial *));
static int find_constant_wide PROTO ((HOST_WIDE_INT, HOST_WIDE_INT, static int find_constant_wide PROTO ((HOST_WIDE_INT, HOST_WIDE_INT,
struct jcf_partial *)); struct jcf_partial *));
static void push_long_const PROTO ((HOST_WIDE_INT, HOST_WIDE_INT,
struct jcf_partial *));
static int find_constant_index PROTO ((tree, struct jcf_partial *)); static int find_constant_index PROTO ((tree, struct jcf_partial *));
static void push_long_const PROTO ((HOST_WIDE_INT, HOST_WIDE_INT, static void push_long_const PROTO ((HOST_WIDE_INT, HOST_WIDE_INT,
struct jcf_partial *)); struct jcf_partial *));
...@@ -704,7 +712,7 @@ write_chunks (stream, chunks) ...@@ -704,7 +712,7 @@ write_chunks (stream, chunks)
static void static void
push_constant1 (index, state) push_constant1 (index, state)
int index; HOST_WIDE_INT index;
struct jcf_partial *state; struct jcf_partial *state;
{ {
RESERVE (3); RESERVE (3);
...@@ -725,7 +733,7 @@ push_constant1 (index, state) ...@@ -725,7 +733,7 @@ push_constant1 (index, state)
static void static void
push_constant2 (index, state) push_constant2 (index, state)
int index; HOST_WIDE_INT index;
struct jcf_partial *state; struct jcf_partial *state;
{ {
RESERVE (3); RESERVE (3);
...@@ -756,7 +764,8 @@ push_int_const (i, state) ...@@ -756,7 +764,8 @@ push_int_const (i, state)
} }
else else
{ {
i = find_constant1 (&state->cpool, CONSTANT_Integer, i & 0xFFFFFFFF); i = find_constant1 (&state->cpool, CONSTANT_Integer,
(jword)(i & 0xFFFFFFFF));
push_constant1 (i, state); push_constant1 (i, state);
} }
} }
...@@ -769,7 +778,7 @@ find_constant_wide (lo, hi, state) ...@@ -769,7 +778,7 @@ find_constant_wide (lo, hi, state)
HOST_WIDE_INT w1, w2; HOST_WIDE_INT w1, w2;
lshift_double (lo, hi, -32, 64, &w1, &w2, 1); lshift_double (lo, hi, -32, 64, &w1, &w2, 1);
return find_constant2 (&state->cpool, CONSTANT_Long, return find_constant2 (&state->cpool, CONSTANT_Long,
w1 & 0xFFFFFFFF, lo & 0xFFFFFFFF); (jword)(w1 & 0xFFFFFFFF), (jword)(lo & 0xFFFFFFFF));
} }
/* Find or allocate a constant pool entry for the given VALUE. /* Find or allocate a constant pool entry for the given VALUE.
...@@ -784,7 +793,7 @@ find_constant_index (value, state) ...@@ -784,7 +793,7 @@ find_constant_index (value, state)
{ {
if (TYPE_PRECISION (TREE_TYPE (value)) <= 32) if (TYPE_PRECISION (TREE_TYPE (value)) <= 32)
return find_constant1 (&state->cpool, CONSTANT_Integer, return find_constant1 (&state->cpool, CONSTANT_Integer,
TREE_INT_CST_LOW (value) & 0xFFFFFFFF); (jword)(TREE_INT_CST_LOW (value) & 0xFFFFFFFF));
else else
return find_constant_wide (TREE_INT_CST_LOW (value), return find_constant_wide (TREE_INT_CST_LOW (value),
TREE_INT_CST_HIGH (value), state); TREE_INT_CST_HIGH (value), state);
...@@ -795,14 +804,17 @@ find_constant_index (value, state) ...@@ -795,14 +804,17 @@ find_constant_index (value, state)
if (TYPE_PRECISION (TREE_TYPE (value)) == 32) if (TYPE_PRECISION (TREE_TYPE (value)) == 32)
{ {
words[0] = etarsingle (TREE_REAL_CST (value)) & 0xFFFFFFFF; words[0] = etarsingle (TREE_REAL_CST (value)) & 0xFFFFFFFF;
return find_constant1 (&state->cpool, CONSTANT_Float, words[0]); return find_constant1 (&state->cpool, CONSTANT_Float,
(jword)words[0]);
} }
else else
{ {
etardouble (TREE_REAL_CST (value), words); etardouble (TREE_REAL_CST (value), words);
return find_constant2 (&state->cpool, CONSTANT_Double, return find_constant2 (&state->cpool, CONSTANT_Double,
words[1-FLOAT_WORDS_BIG_ENDIAN] & 0xFFFFFFFF, (jword)(words[1-FLOAT_WORDS_BIG_ENDIAN] &
words[FLOAT_WORDS_BIG_ENDIAN] & 0xFFFFFFFF); 0xFFFFFFFF),
(jword)(words[FLOAT_WORDS_BIG_ENDIAN] &
0xFFFFFFFF));
} }
} }
else if (TREE_CODE (value) == STRING_CST) else if (TREE_CODE (value) == STRING_CST)
...@@ -945,7 +957,7 @@ emit_pop (size, state) ...@@ -945,7 +957,7 @@ emit_pop (size, state)
static void static void
emit_iinc (var, value, state) emit_iinc (var, value, state)
tree var; tree var;
int value; HOST_WIDE_INT value;
struct jcf_partial *state; struct jcf_partial *state;
{ {
int slot = DECL_LOCAL_INDEX (var); int slot = DECL_LOCAL_INDEX (var);
...@@ -1051,7 +1063,7 @@ emit_switch_reloc (label, state) ...@@ -1051,7 +1063,7 @@ emit_switch_reloc (label, state)
struct jcf_block *label; struct jcf_block *label;
struct jcf_partial *state; struct jcf_partial *state;
{ {
emit_reloc (0, BLOCK_START_RELOC, label, state); emit_reloc (RELOCATION_VALUE_0, BLOCK_START_RELOC, label, state);
} }
/* Similar to emit_switch_reloc, /* Similar to emit_switch_reloc,
...@@ -1081,7 +1093,7 @@ emit_if (target, opcode, inv_opcode, state) ...@@ -1081,7 +1093,7 @@ emit_if (target, opcode, inv_opcode, state)
{ {
OP1 (opcode); OP1 (opcode);
/* value is 1 byte from reloc back to start of instruction. */ /* value is 1 byte from reloc back to start of instruction. */
emit_reloc (1, - inv_opcode, target, state); emit_reloc (RELOCATION_VALUE_1, - inv_opcode, target, state);
} }
static void static void
...@@ -1091,7 +1103,7 @@ emit_goto (target, state) ...@@ -1091,7 +1103,7 @@ emit_goto (target, state)
{ {
OP1 (OPCODE_goto); OP1 (OPCODE_goto);
/* Value is 1 byte from reloc back to start of instruction. */ /* Value is 1 byte from reloc back to start of instruction. */
emit_reloc (1, OPCODE_goto_w, target, state); emit_reloc (RELOCATION_VALUE_1, OPCODE_goto_w, target, state);
} }
static void static void
...@@ -1101,7 +1113,7 @@ emit_jsr (target, state) ...@@ -1101,7 +1113,7 @@ emit_jsr (target, state)
{ {
OP1 (OPCODE_jsr); OP1 (OPCODE_jsr);
/* Value is 1 byte from reloc back to start of instruction. */ /* Value is 1 byte from reloc back to start of instruction. */
emit_reloc (1, OPCODE_jsr_w, target, state); emit_reloc (RELOCATION_VALUE_1, OPCODE_jsr_w, target, state);
} }
/* Generate code to evaluate EXP. If the result is true, /* Generate code to evaluate EXP. If the result is true,
...@@ -1729,7 +1741,8 @@ generate_bytecode_insns (exp, target, state) ...@@ -1729,7 +1741,8 @@ generate_bytecode_insns (exp, target, state)
int index = 0; int index = 0;
RESERVE (13 + 4 * (sw_state.max_case - sw_state.min_case + 1)); RESERVE (13 + 4 * (sw_state.max_case - sw_state.min_case + 1));
OP1 (OPCODE_tableswitch); OP1 (OPCODE_tableswitch);
emit_reloc (0, SWITCH_ALIGN_RELOC, NULL, state); emit_reloc (RELOCATION_VALUE_0,
SWITCH_ALIGN_RELOC, NULL, state);
emit_switch_reloc (sw_state.default_label, state); emit_switch_reloc (sw_state.default_label, state);
OP4 (sw_state.min_case); OP4 (sw_state.min_case);
OP4 (sw_state.max_case); OP4 (sw_state.max_case);
...@@ -1752,7 +1765,8 @@ generate_bytecode_insns (exp, target, state) ...@@ -1752,7 +1765,8 @@ generate_bytecode_insns (exp, target, state)
{ /* Use lookupswitch. */ { /* Use lookupswitch. */
RESERVE(9 + 8 * sw_state.num_cases); RESERVE(9 + 8 * sw_state.num_cases);
OP1 (OPCODE_lookupswitch); OP1 (OPCODE_lookupswitch);
emit_reloc (0, SWITCH_ALIGN_RELOC, NULL, state); emit_reloc (RELOCATION_VALUE_0,
SWITCH_ALIGN_RELOC, NULL, state);
emit_switch_reloc (sw_state.default_label, state); emit_switch_reloc (sw_state.default_label, state);
OP4 (sw_state.num_cases); OP4 (sw_state.num_cases);
for (i = 0; i < sw_state.num_cases; i++) for (i = 0; i < sw_state.num_cases; i++)
...@@ -1925,7 +1939,7 @@ generate_bytecode_insns (exp, target, state) ...@@ -1925,7 +1939,7 @@ generate_bytecode_insns (exp, target, state)
if (size == 1) if (size == 1)
push_int_const (value, state); push_int_const (value, state);
else else
push_long_const (value, value >= 0 ? 0 : -1, state); push_long_const (value, (HOST_WIDE_INT)(value >= 0 ? 0 : -1), state);
NOTE_PUSH (size); NOTE_PUSH (size);
emit_binop (OPCODE_iadd + adjust_typed_op (type, 3), type, state); emit_binop (OPCODE_iadd + adjust_typed_op (type, 3), type, state);
if (target != IGNORE_TARGET && ! post_op) if (target != IGNORE_TARGET && ! post_op)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment