+
+/* Literal scan be either a normal literal, a @hi() or @lo relocation. */
+
+static const char *
+parse_immediate16 (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;
+}