fix formatting
[deliverable/binutils-gdb.git] / gas / cgen.c
index bcd59ef1b8498dc5edfc56d01c136e5345412bc0..a4ef083ca6a3122c7d3aa373910c75efb73fe4b5 100644 (file)
@@ -1,5 +1,5 @@
 /* GAS interface for targets using CGEN: Cpu tools GENerator.
-   Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+   Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
 
 This file is part of GAS, the GNU Assembler.
 
@@ -81,6 +81,7 @@ gas_cgen_init_parse ()
 static void
 queue_fixup (opindex, opinfo, expP)
      int           opindex;
+     int           opinfo;
      expressionS * expP;
 {
   /* We need to generate a fixup for this expression.  */
@@ -184,9 +185,9 @@ gas_cgen_record_fixup (frag, where, insn, length, operand, opinfo, symbol, offse
                  CGEN_OPERAND_ATTR_VALUE (operand, CGEN_OPERAND_PCREL_ADDR),
                  (bfd_reloc_code_real_type)
                    ((int) BFD_RELOC_UNUSED
-                    + CGEN_OPERAND_INDEX (gas_cgen_cpu_desc, operand)));
-  fixP->tc_fix_data.insn   = (PTR) insn;
-  fixP->tc_fix_data.opinfo = opinfo;
+                    + (int) operand->type));
+  fixP->fx_cgen.insn = insn;
+  fixP->fx_cgen.opinfo = opinfo;
 
   return fixP;
 }
@@ -223,15 +224,16 @@ gas_cgen_record_fixup_exp (frag, where, insn, length, operand, opinfo, exp)
                      CGEN_OPERAND_ATTR_VALUE (operand, CGEN_OPERAND_PCREL_ADDR),
                      (bfd_reloc_code_real_type)
                        ((int) BFD_RELOC_UNUSED
-                        + CGEN_OPERAND_INDEX (gas_cgen_cpu_desc, operand)));
-  fixP->tc_fix_data.insn = (PTR) insn;
-  fixP->tc_fix_data.opinfo = opinfo;
+                        + (int) operand->type));
+  fixP->fx_cgen.insn = insn;
+  fixP->fx_cgen.opinfo = opinfo;
 
   return fixP;
 }
 
 /* Used for communication between the next two procedures.  */
 static jmp_buf expr_jmp_buf;
+static int expr_jmp_buf_p;
 
 /* Callback for cgen interface.  Parse the expression at *STRP.
    The result is an error message or NULL for success (in which case
@@ -246,7 +248,7 @@ static jmp_buf expr_jmp_buf;
 
 const char *
 gas_cgen_parse_operand (cd, want, strP, opindex, opinfo, resultP, valueP)
-     CGEN_CPU_DESC cd;
+     CGEN_CPU_DESC cd ATTRIBUTE_UNUSED;
      enum cgen_parse_operand_type want;
      const char ** strP;
      int opindex;
@@ -279,12 +281,15 @@ gas_cgen_parse_operand (cd, want, strP, opindex, opinfo, resultP, valueP)
      This is done via gas_cgen_md_operand.  */
   if (setjmp (expr_jmp_buf) != 0)
     {
+      expr_jmp_buf_p = 0;
       input_line_pointer = (char *) hold;
       * resultP_1 = CGEN_PARSE_OPERAND_RESULT_ERROR;
       return "illegal operand";
     }
 
+  expr_jmp_buf_p = 1;
   expression (& exp);
+  expr_jmp_buf_p = 0;
 
   * strP = input_line_pointer;
   input_line_pointer = hold;
@@ -326,9 +331,11 @@ gas_cgen_parse_operand (cd, want, strP, opindex, opinfo, resultP, valueP)
 
 void
 gas_cgen_md_operand (expressionP)
-     expressionS * expressionP;
+     expressionS * expressionP ATTRIBUTE_UNUSED;
 {
-  longjmp (expr_jmp_buf, 1);
+  /* Don't longjmp if we're not called from within cgen_parse_operand().  */
+  if (expr_jmp_buf_p)
+    longjmp (expr_jmp_buf, 1);
 }
 
 /* Finish assembling instruction INSN.
@@ -376,7 +383,7 @@ gas_cgen_finish_insn (insn, buf, length, relax_p, result)
 
       for (i = 0; i < num_fixups; ++ i)
        {
-         if (CGEN_OPERAND_ATTR_VALUE (& CGEN_CPU_OPERAND_TABLE (gas_cgen_cpu_desc) [fixups[i].opindex],
+         if (CGEN_OPERAND_ATTR_VALUE (cgen_operand_lookup_by_num (gas_cgen_cpu_desc, fixups[i].opindex),
                                       CGEN_OPERAND_RELAX))
            {
              relax_operand = i;
@@ -441,15 +448,16 @@ gas_cgen_finish_insn (insn, buf, length, relax_p, result)
   /* Create any fixups.  */
   for (i = 0; i < num_fixups; ++i)
     {
-      fixS * fixP;
+      fixS *fixP;
+      const CGEN_OPERAND *operand =
+       cgen_operand_lookup_by_num (gas_cgen_cpu_desc, fixups[i].opindex);
 
       /* Don't create fixups for these.  That's done during relaxation.
         We don't need to test for CGEN_INSN_RELAX as they can't get here
         (see above).  */
       if (relax_p
          && CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_RELAXABLE)
-         && CGEN_OPERAND_ATTR_VALUE (& CGEN_CPU_OPERAND_TABLE (gas_cgen_cpu_desc) [fixups[i].opindex],
-                                     CGEN_OPERAND_RELAX))
+         && CGEN_OPERAND_ATTR_VALUE (operand, CGEN_OPERAND_RELAX))
        continue;
 
 #ifndef md_cgen_record_fixup_exp
@@ -457,8 +465,7 @@ gas_cgen_finish_insn (insn, buf, length, relax_p, result)
 #endif
 
        fixP = md_cgen_record_fixup_exp (frag_now, f - frag_now->fr_literal,
-                                        insn, length,
-                                        & CGEN_CPU_OPERAND_TABLE (gas_cgen_cpu_desc) [fixups[i].opindex],
+                                        insn, length, operand,
                                         fixups[i].opinfo,
                                         & fixups[i].exp);
        if (result)
@@ -488,7 +495,7 @@ int
 gas_cgen_md_apply_fix3 (fixP, valueP, seg)
      fixS *   fixP;
      valueT * valueP;
-     segT     seg;
+     segT     seg ATTRIBUTE_UNUSED;
 {
   char * where = fixP->fx_frag->fr_literal + fixP->fx_where;
   valueT value;
@@ -532,11 +539,11 @@ gas_cgen_md_apply_fix3 (fixP, valueP, seg)
   if ((int) fixP->fx_r_type >= (int) BFD_RELOC_UNUSED)
     {
       int opindex = (int) fixP->fx_r_type - (int) BFD_RELOC_UNUSED;
-      const CGEN_OPERAND *operand = & CGEN_CPU_OPERAND_TABLE (cd) [opindex];
+      const CGEN_OPERAND *operand = cgen_operand_lookup_by_num (cd, opindex);
       const char *errmsg;
       bfd_reloc_code_real_type reloc_type;
       CGEN_FIELDS *fields = alloca (CGEN_CPU_SIZEOF_FIELDS (cd));
-      const CGEN_INSN *insn = (CGEN_INSN *) fixP->tc_fix_data.insn;
+      const CGEN_INSN *insn = fixP->fx_cgen.insn;
 
       /* If the reloc has been fully resolved finish the operand here.  */
       /* FIXME: This duplicates the capabilities of code in BFD.  */
@@ -546,7 +553,7 @@ gas_cgen_md_apply_fix3 (fixP, valueP, seg)
          || fixP->fx_pcrel)
        {
          CGEN_CPU_SET_FIELDS_BITSIZE (cd) (fields, CGEN_INSN_BITSIZE (insn));
-         CGEN_CPU_SET_VMA_OPERAND (cd) (opindex, fields, (bfd_vma) value);
+         CGEN_CPU_SET_VMA_OPERAND (cd) (cd, opindex, fields, (bfd_vma) value);
 
 #if CGEN_INT_INSN_P
          {
@@ -631,7 +638,7 @@ gas_cgen_md_apply_fix3 (fixP, valueP, seg)
 
 arelent *
 gas_cgen_tc_gen_reloc (section, fixP)
-     asection * section;
+     asection * section ATTRIBUTE_UNUSED;
      fixS *     fixP;
 {
   arelent * reloc;
@@ -649,7 +656,8 @@ gas_cgen_tc_gen_reloc (section, fixP)
 
   assert (!fixP->fx_pcrel == !reloc->howto->pc_relative);
 
-  reloc->sym_ptr_ptr = & fixP->fx_addsy->bsym;
+  reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
+  *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixP->fx_addsy);
 
   /* Use fx_offset for these cases */
   if (   fixP->fx_r_type == BFD_RELOC_VTABLE_ENTRY
This page took 0.028263 seconds and 4 git commands to generate.