24 #include "cgen-desc.h"
32 #ifdef OBJ_COMPLEX_RELC
36 static unsigned long gas_cgen_encode_addend
37 (
const unsigned long,
const unsigned long,
const unsigned long, \
38 const unsigned long,
const unsigned long,
const unsigned long, \
41 static char * weak_operand_overflow_check
44 static void queue_fixup_recursively
48 static int rightshift = 0;
177 as_fatal (
"index into stored_fixups[] out of bounds");
193 as_fatal (
"index into stored_fixups[] out of bounds");
199 (
sizeof (stored_fixups[i].fixup_chain[0])) *
num_fixups);
209 as_fatal (
"index into stored_fixups[] out of bounds");
222 struct fixup tmp_fixup;
232 fixups [tmp] = tmp_fixup;
265 fixP =
fix_new (frag, where, length / 8, symbol, offset,
269 + (
int) operand->
type));
270 fixP->fx_cgen.insn =
insn;
271 fixP->fx_cgen.opinfo =
opinfo;
272 fixP->fx_cgen.field =
NULL;
273 fixP->fx_cgen.msb_field_p = 0;
309 + (
int) operand->
type));
310 fixP->fx_cgen.insn =
insn;
311 fixP->fx_cgen.opinfo =
opinfo;
312 fixP->fx_cgen.field =
NULL;
313 fixP->fx_cgen.msb_field_p = 0;
318 #ifdef OBJ_COMPLEX_RELC
333 static jmp_buf expr_jmp_buf;
334 static int expr_jmp_buf_p;
350 #ifdef OBJ_COMPLEX_RELC
364 char *
volatile hold;
366 volatile int opinfo_1;
375 #ifdef OBJ_COMPLEX_RELC
376 volatile int signed_p = 0;
395 if (setjmp (expr_jmp_buf) != 0)
400 return _(
"illegal operand");
411 #ifdef TC_CGEN_PARSE_FIX_EXP
420 errmsg =
_(
"illegal operand");
424 errmsg =
_(
"missing operand");
439 #ifdef OBJ_COMPLEX_RELC
443 errmsg = weak_operand_overflow_check (& exp, operand);
502 rightshift = operand->
length;
503 queue_fixup_recursively (opindex, opinfo_1, & exp,
513 queue_fixup (opindex, opinfo_1, &exp);
534 longjmp (expr_jmp_buf, 1);
555 unsigned int byte_len = length / 8;
592 if (relax_operand != -1)
600 #ifdef TC_CGEN_MAX_RELAX
615 exp = &fixups[relax_operand].
exp;
637 old_frag->fr_cgen.insn =
insn;
638 old_frag->fr_cgen.opindex = fixups[relax_operand].
opindex;
639 old_frag->fr_cgen.opinfo = fixups[relax_operand].
opinfo;
641 result->
frag = old_frag;
655 memcpy (f, buf, byte_len);
676 #ifndef md_cgen_record_fixup_exp
677 #define md_cgen_record_fixup_exp gas_cgen_record_fixup_exp
681 insn, length, operand,
684 fixP->fx_cgen.field = fixups[
i].
field;
697 #ifdef OBJ_COMPLEX_RELC
704 queue_fixup_recursively (
const int opindex,
709 const int part_of_multi)
711 if (field && field->
count)
715 for (i = 0; i < field->
count; ++
i)
716 queue_fixup_recursively (opindex, opinfo, expP,
717 & (field->
val.
multi[i]), signed_p, i);
724 printf (
"queueing fixup for field %s\n",
728 if (field && part_of_multi != -1)
735 new_exp = make_right_shifted_expr (expP, rightshift, signed_p);
742 queue_fixup (opindex, opinfo, new_exp);
749 gas_cgen_encode_addend (
const unsigned long start,
750 const unsigned long len,
751 const unsigned long oplen,
752 const unsigned long wordsz,
753 const unsigned long chunksz,
754 const unsigned long signed_p,
755 const unsigned long trunc_p)
757 unsigned long res = 0
L;
760 res |= (oplen & 0x3F) << 6;
761 res |= (len & 0x3F) << 12;
762 res |= (wordsz & 0xF) << 18;
763 res |= (chunksz & 0xF) << 22;
765 res |= signed_p << 28;
766 res |= trunc_p << 29;
788 const unsigned long len = operand->
length;
790 unsigned long opmask = (((1
L << (len - 1)) - 1) << 1) | 1;
800 return _(
"a reloc on this operand implies an overflow");
817 if (mask && (mask & ~opmask))
820 printf (
"overflow: (mask = %8.8x, ~opmask = %8.8x, AND = %8.8x)\n",
821 mask, ~opmask, (mask & ~opmask));
823 return _(
"operand mask overflow");
877 char *where = fixP->fx_frag->fr_literal + fixP->fx_where;
887 as_bad_where (fixP->fx_file, fixP->fx_line,
_(
"expression too complex"));
897 #ifdef OBJ_COMPLEX_RELC
902 if (fixP->fx_cgen.field)
906 start = fixP->fx_cgen.field->val.leaf->start;
907 length = fixP->fx_cgen.field->val.leaf->length;
912 start = operand->
start;
949 (
unsigned char *) where,
953 as_bad_where (fixP->fx_file, fixP->fx_line,
"%s", errmsg);
965 #ifdef OBJ_COMPLEX_RELC
970 value = gas_cgen_encode_addend (start, operand->
length,
971 length, fixP->fx_size,
974 ! (fixP->fx_cgen.msb_field_p));
983 _(
"unresolved expression that must be resolved"));
988 else if (fixP->fx_done)
992 switch (fixP->fx_r_type)
1008 _(
"internal error: can't install fix for reloc type %d (`%s')"),
1019 fixP->fx_addnumber =
value;
1052 #ifdef GAS_CGEN_PCREL_R_TYPE
1061 _(
"relocation is not supported"));