Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
02110-1301, USA. */
+#include <setjmp.h>
+
+struct svp64_ctx {
+ const struct svp64_desc *desc;
+};
+
+static jmp_buf svp64_exception;
+
+#define svp64_raise(...) \
+ do { \
+ as_bad (__VA_ARGS__); \
+ longjmp (svp64_exception, 1); \
+ } while (0)
+
+#define svp64_raise_if(COND, ...) \
+ do { \
+ if (!!(COND)) \
+ svp64_raise (__VA_ARGS__); \
+ } while (0)
+
+static htab_t svp64_hash;
+
+static void
+svp64_setup_records (void)
+{
+ const struct svp64_record *record;
+ const struct svp64_record *records_end;
+
+ svp64_hash = str_htab_create ();
+
+ records_end = (svp64_records + svp64_nr_records);
+ for (record = svp64_records; record < records_end; ++record)
+ {
+ const struct svp64_desc *desc = &record->desc;
+ const char *name = (record->name + (sizeof ("sv.") - 1));
+
+ if (str_hash_insert (svp64_hash, name, desc, 0) != NULL)
+ as_fatal (_("duplicate %s"), name);
+ }
+}
+
+static char *
+svp64_decode (char *str, struct svp64_ctx *svp64)
+{
+ str += (sizeof ("sv.") - 1);
+ svp64->desc = (const struct svp64_desc *) str_hash_find (svp64_hash, str);
+ if (!svp64->desc)
+ svp64_raise (_("unrecognized opcode: `%s'"), str);
+
+ return str;
+}
+
static void
svp64_assemble (char *str)
{
- as_warn (_("opcode ignored"));
+ struct svp64_ctx svp64;
+
+ if (setjmp (svp64_exception) != 0)
+ return;
+
+ memset (&svp64, 0, sizeof (svp64));
+
+ svp64_decode (str, &svp64);
+
+ as_warn (_("opcode ignored (desc=%p)"), svp64.desc);
memcpy (str, "nop", sizeof ("nop"));
md_assemble (str);
}