OSDN Git Service

* cpu/xstormy16.cpu (imm16): Call handler immediate16.
authordj <dj>
Tue, 17 Dec 2002 03:54:40 +0000 (03:54 +0000)
committerdj <dj>
Tue, 17 Dec 2002 03:54:40 +0000 (03:54 +0000)
* cpu/xstormy16.opc (parse_small_immediate): Return on '@'.
(parse_immediate16): Handle immediate16 values, which now include
@hi(label) and @lo(label)

cgen/ChangeLog
cgen/cpu/xstormy16.cpu
cgen/cpu/xstormy16.opc

index 8b0e312..aa9aebb 100644 (file)
@@ -1,3 +1,10 @@
+2002-12-16  Andrew MacLeod  <amacleod@redhat.com>
+
+       * cpu/xstormy16.cpu (imm16): Call handler immediate16.
+       * cpu/xstormy16.opc (parse_small_immediate): Return on '@'.
+       (parse_immediate16): Handle immediate16 values, which now include
+       @hi(label) and @lo(label)
+
 2002-12-03  Alan Modra  <amodra@bigpond.net.au>
 
        * desc-cpu.scm (gen-maybe-multi-ifld): Remove superfluous parens.
index 14cbc1b..d92d1ec 100644 (file)
 (dnop imm12 "12 bit signed immediate" () h-sint f-imm12)
 
 (dnf f-imm16 "16 bit" (SIGN-OPT) 16 16)
-(dnop imm16 "16 bit immediate" () h-uint f-imm16)
+(define-operand
+  (name imm16)
+  (comment "16 bit immediate")
+  (attrs)
+  (type h-uint)
+  (index f-imm16) 
+  (handlers (parse "immediate16"))
+)
 
 (dnf f-lmem8  "8 bit unsigned low memory" (ABS-ADDR) 8 8)
 (define-operand 
index d42c8c4..331beee 100644 (file)
@@ -91,6 +91,9 @@ parse_small_immediate (cd, strp, opindex, valuep)
   enum cgen_parse_operand_result result;
   const char *errmsg;
 
+  if (**strp == '@')
+    return _("No relocation for small immediate");
+
   errmsg = (* cd->parse_operand_fn)
     (cd, CGEN_PARSE_OPERAND_INTEGER, strp, opindex, BFD_RELOC_NONE,
      &result, &value);
@@ -104,4 +107,52 @@ parse_small_immediate (cd, strp, opindex, valuep)
   *valuep = value;
   return NULL;
 }
+
+/* Literal scan be either a normal literal, a @hi() or @lo relocation. */
+   
+static const char *
+parse_immediate16 (cd, strp, opindex, valuep)
+     CGEN_CPU_DESC cd;
+     const char **strp;
+     int opindex;
+     unsigned long *valuep;
+{
+  const char *errmsg;
+  enum cgen_parse_operand_result result;
+  bfd_reloc_code_real_type code = BFD_RELOC_NONE;
+  bfd_vma value;
+
+  if (strncmp (*strp, "@hi(", 4) == 0)
+    {
+      *strp += 4;
+      code = BFD_RELOC_HI16;
+    }
+  else
+  if (strncmp (*strp, "@lo(", 4) == 0)
+    {
+      *strp += 4;
+      code = BFD_RELOC_LO16;
+    }
+
+  if (code == BFD_RELOC_NONE)
+    errmsg = cgen_parse_unsigned_integer (cd, strp, opindex, valuep);
+  else
+    {
+      errmsg = cgen_parse_address (cd, strp, opindex, code, &result, &value);
+      if ((errmsg == NULL) &&
+         (result != CGEN_PARSE_OPERAND_RESULT_QUEUED))
+       errmsg = _("Operand is not a symbol");
+
+      *valuep = value;
+      if ((code == BFD_RELOC_HI16 || code == BFD_RELOC_LO16)
+         && **strp == ')')        
+       *strp += 1;
+      else
+        {
+         errmsg = _("Syntax error: No trailing ')'");
+         return errmsg;
+       }
+    }
+  return errmsg;
+}
 /* -- */