* cpu/ChangeLog.or1k

2012-10-24  Stefan Kristiansson <[email protected]>

        * or1k.opc (parse_disp26): New function. Parsing for plt().
        (parse_simm16): Add parsing for got(), gotoffhi() and gotofflo().
        * or1korbis.cpu (disp26): Use custom handler.
---
 cpu/ChangeLog.or1k |    6 +++
 cpu/or1k.opc       |  115 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 cpu/or1korbis.cpu  |   10 ++++-
 3 files changed, 130 insertions(+), 1 deletion(-)

diff --git a/cpu/ChangeLog.or1k b/cpu/ChangeLog.or1k
index 897e27e..467488e 100644
--- a/cpu/ChangeLog.or1k
+++ b/cpu/ChangeLog.or1k
@@ -1,3 +1,9 @@
+2012-10-24  Stefan Kristiansson <[email protected]>
+
+       * or1k.opc (parse_disp26): New function. Parsing for plt().
+       (parse_simm16): Add parsing for got(), gotoffhi() and gotofflo().
+       * or1korbis.cpu (disp26): Use custom handler.
+
 2012-09-11  Stefan Kristiansson <[email protected]>
 
        fix regression on 32-bit machines
diff --git a/cpu/or1k.opc b/cpu/or1k.opc
index 65a2f9a..0971df9 100644
--- a/cpu/or1k.opc
+++ b/cpu/or1k.opc
@@ -54,6 +54,36 @@ static const char * MISSING_CLOSING_PARENTHESIS = 
N_("missing `)'");
 #define CGEN_VERBOSE_ASSEMBLER_ERRORS
 
 static const char *
+parse_disp26 (CGEN_CPU_DESC cd,
+              const char ** strp,
+              int opindex,
+              int opinfo,
+              enum cgen_parse_operand_result * resultp,
+              bfd_vma * valuep)
+{
+  const char *errmsg = NULL;
+  enum cgen_parse_operand_result result_type;
+
+  if (strncasecmp (*strp, "plt(", 4) == 0)
+    {
+      bfd_vma value;
+
+      *strp += 4;
+      errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_OR1K_PLT26,
+                                   & result_type, & value);
+      if (**strp != ')')
+        return MISSING_CLOSING_PARENTHESIS;
+      ++*strp;
+      if (errmsg == NULL
+          && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER)
+        value = (value >> 2) & 0xffff;
+      *valuep = value;
+      return errmsg;
+    }
+  return cgen_parse_address (cd, strp, opindex, opinfo, resultp, valuep);
+}
+
+static const char *
 parse_simm16 (CGEN_CPU_DESC cd, const char ** strp, int opindex, long * valuep)
 {
   const char *errmsg;
@@ -102,6 +132,91 @@ parse_simm16 (CGEN_CPU_DESC cd, const char ** strp, int 
opindex, long * valuep)
       }
       
     }
+  else if (strncasecmp (*strp, "got(", 4) == 0)
+    {
+      bfd_vma value;
+
+      *strp += 4;
+      errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_OR1K_GOT16,
+                                   & result_type, & value);
+      if (**strp != ')')
+        return MISSING_CLOSING_PARENTHESIS;
+      ++*strp;
+      if (errmsg == NULL
+          && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER)
+        value &= 0xffff;
+      *valuep = value;
+      return errmsg;
+    }
+  else if (strncasecmp (*strp, "gotpchi(", 8) == 0)
+    {
+      bfd_vma value;
+
+      *strp += 8;
+      errmsg = cgen_parse_address (cd, strp, opindex,
+                                   BFD_RELOC_OR1K_GOTPC_HI16,
+                                   & result_type, & value);
+      if (**strp != ')')
+        return MISSING_CLOSING_PARENTHESIS;
+      ++*strp;
+      if (errmsg == NULL
+          && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER)
+        value = (value >> 16) & 0xffff;
+      *valuep = value;
+      return errmsg;
+    }
+  else if (strncasecmp (*strp, "gotpclo(", 8) == 0)
+    {
+      bfd_vma value;
+
+      *strp += 8;
+      errmsg = cgen_parse_address (cd, strp, opindex,
+                                   BFD_RELOC_OR1K_GOTPC_LO16,
+                                   &result_type, &value);
+      if (**strp != ')')
+        return MISSING_CLOSING_PARENTHESIS;
+      ++*strp;
+      if (errmsg == NULL
+          && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER)
+        value &= 0xffff;
+      *valuep = value;
+      return errmsg;
+    }
+  else if (strncasecmp (*strp, "gotoffhi(", 9) == 0)
+    {
+      bfd_vma value;
+
+      *strp += 9;
+      errmsg = cgen_parse_address (cd, strp, opindex,
+                                   BFD_RELOC_OR1K_GOTOFF_HI16,
+                                   & result_type, & value);
+
+      if (**strp != ')')
+        return MISSING_CLOSING_PARENTHESIS;
+      ++*strp;
+      if (errmsg == NULL
+          && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER)
+        value = (value >> 16) & 0xffff;
+      *valuep = value;
+      return errmsg;
+    }
+  else if (strncasecmp (*strp, "gotofflo(", 9) == 0)
+    {
+      bfd_vma value;
+
+      *strp += 9;
+      errmsg = cgen_parse_address (cd, strp, opindex,
+                                   BFD_RELOC_OR1K_GOTOFF_LO16,
+                                   &result_type, &value);
+      if (**strp != ')')
+        return MISSING_CLOSING_PARENTHESIS;
+      ++*strp;
+      if (errmsg == NULL
+          && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER)
+        value &= 0xffff;
+      *valuep = value;
+      return errmsg;
+    }
   else
     {
       long value;
diff --git a/cpu/or1korbis.cpu b/cpu/or1korbis.cpu
index bf30f84..c2a2efa 100644
--- a/cpu/or1korbis.cpu
+++ b/cpu/or1korbis.cpu
@@ -273,7 +273,6 @@
 (dnop mac-machi         "MAC HI result register"           ((MACH ORBIS-MACHS) 
SEM-ONLY) h-mac-machi         f-nil)
 (dnop mac-maclo         "MAC LO result register"           ((MACH ORBIS-MACHS) 
SEM-ONLY) h-mac-maclo         f-nil)
 
-(dnop disp26            "pc-rel 26 bit"                    ((MACH 
ORBIS-MACHS))          h-iaddr             f-disp26)
 (dnop uimm6             "uimm6"                            ((MACH 
ORBIS-MACHS))          h-uimm6             f-uimm6)
 
 (dnop rD                "destination register"             ((MACH 
ORBIS-MACHS))          h-gpr               f-r1)
@@ -281,6 +280,15 @@
 (dnop rB                "source register B"                ((MACH 
ORBIS-MACHS))          h-gpr               f-r3)
 
 (define-operand
+  (name disp26)
+  (comment "pc-rel 26 bit")
+  (attrs (MACH ORBIS-MACHS))
+  (type h-iaddr)
+  (index f-disp26)
+  (handlers (parse "disp26"))
+  )
+
+(define-operand
   (name simm16)
   (comment "16-bit signed immediate")
   (attrs (MACH ORBIS-MACHS) SIGN-OPT)
-- 
1.7.9.5

_______________________________________________
OpenRISC mailing list
[email protected]
http://lists.openrisc.net/listinfo/openrisc

Reply via email to