// SDB-CGEN V2.6.2
#include <ctype.h>
#include <stdio.h>
#include <string.h>

struct kv { const char *name; const char *value; };
static const struct kv kvs[] = {
// gcc -DMAIN=1 arc.c ; ./a.out > arc.h
	{"abs", "absolute value"},
	{"abs_s", "absolute value (saturated)"},
	{"abss", "absolute and saturate"},
	{"abssw", "absolute and saturate of word"},
	{"adc", "add with carry"},
	{"add", "add"},
	{"add1", "add with left shift by 1 bit"},
	{"add1_s", "add with left shift by 1 bit (saturated)"},
	{"add2", "add with left shift by 2 bits"},
	{"add2_s", "add with left shift by 2 bits (saturated)"},
	{"add3", "add with left shift by 3 bits"},
	{"add3_s", "add with left shift by 3 bits (saturated)"},
	{"add_s", "add (saturated)"},
	{"adds", "add and saturate"},
	{"addsdw", "add and saturate dual word"},
	{"and", "logical and"},
	{"and_s", "logical and (saturated)"},
	{"asl", "arithmetic shift left"},
	{"asl_s", "arithmetic shift left (saturated)"},
	{"asls", "arithmetic shift left and saturate"},
	{"asr", "arithmetic shift right"},
	{"asr_s", "arithmetic shift right (saturated)"},
	{"asrs", "arithmetic shift right and saturate"},
	{"b", "unconditional branch"},
	{"bbit0", "branch if bit cleared to 0"},
	{"bbit1", "branch if bit set to 1"},
	{"bcc", "branch if condition true"},
	{"bcc_s", "branch if condition true (saturated)"},
	{"bclr", "clear specified bit (to 0)"},
	{"bclr_s", "clear specified bit (to 0) (saturated)"},
	{"bic", "bit-wise inverted and"},
	{"bic_s", "bit-wise inverted and (saturated)"},
	{"bl", "branch and link"},
	{"bl_s", "branch and link (saturated)"},
	{"blcc", "branch and link conditionally"},
	{"bmsk", "bit mask"},
	{"bmsk_s", "bit mask (saturated)"},
	{"brcc", "branch on compare"},
	{"brcc_s", "branch on compare (saturated)"},
	{"brk", "break (halt) processor"},
	{"brk_s", "break (halt) processor (saturated)"},
	{"brkpt", "breakpoint"},
	{"bset", "set specified bit (to 1)"},
	{"bset_s", "set specified bit (to 1) (saturated)"},
	{"btst", "test value of specified bit"},
	{"btst_s", "test value of specified bit (saturated)"},
	{"bxor", "bit xor"},
	{"call", "call subroutine"},
	{"cdp", "coprocessor data processing"},
	{"clz", "count leading zeros"},
	{"cmp", "compare"},
	{"cmp_s", "compare (saturated)"},
	{"dbg", "debug"},
	{"di", "disable interrupts"},
	{"div", "divide"},
	{"divaw", "division assist"},
	{"divu", "divide unsigned"},
	{"ei", "enable interrupts"},
	{"enter", "function entry"},
	{"ex", "atomic exchange"},
	{"ext", "unsigned extend"},
	{"ext_s", "unsigned extend (saturated)"},
	{"ffs", "find first set bit"},
	{"flag", "write to status register"},
	{"fls", "find least significant set bit"},
	{"fms", "find most significant set bit"},
	{"iret", "return from interrupt"},
	{"jcc", "jump conditionally"},
	{"jcc_s", "jump conditionally (saturated)"},
	{"jl_s", "jump and link (saturated)"},
	{"jlcc", "jump and link conditionally"},
	{"jmp", "unconditional jump"},
	{"ld", "load from memory"},
	{"ld_s", "load from memory (saturated)"},
	{"lda", "load address"},
	{"ldb", "load byte"},
	{"ldc", "load coprocessor"},
	{"ldd", "load doubleword"},
	{"ldh", "load halfword"},
	{"ldm", "load multiple registers"},
	{"ldw", "load word"},
	{"leave", "function exit"},
	{"lpcc", "loop (zero-overhead loops)"},
	{"lr", "load from auxiliary memory"},
	{"lsr", "logical shift left"},
	{"lsr_s", "logical shift right (saturated)"},
	{"max", "return maximum"},
	{"mcr", "move to coprocessor from register"},
	{"min", "return minimum"},
	{"mod", "modulo"},
	{"mov", "move (copy) to register"},
	{"mov_s", "move (copy) to register (saturated)"},
	{"mpy", "32 x 32 signed multiply (low)"},
	{"mpyh", "32 x 32 signed multiply (high)"},
	{"mpyhu", "32 x 32 unsigned multiply (high)"},
	{"mpyu", "32 x 32 unsigned multiply (low)"},
	{"mrc", "move to register from coprocessor"},
	{"mul64", "32 x 32 signed multiply"},
	{"mul64_s", "32 x 32 multiply (saturated)"},
	{"mulu64", "32 x 32 unsigned multiply"},
	{"neg", "negate"},
	{"neg_s", "negate (saturated)"},
	{"negs", "negate and saturate"},
	{"negsw", "negate and saturate of word"},
	{"nop", "no operation"},
	{"nop_s", "no operation (saturated)"},
	{"norm", "normalize to 32 bits"},
	{"normw", "normalize to 16 bits"},
	{"not", "logical bit inversion"},
	{"not_s", "logical bit inversion (saturated)"},
	{"or", "logical or"},
	{"or_s", "logical or (saturated)"},
	{"pop", "restore register value from stack"},
	{"pop_s", "restore register value from stack (saturated)"},
	{"prefetch", "prefetch from memory"},
	{"push", "store register value on stack"},
	{"push_s", "store register value on stack (saturated)"},
	{"rcmp", "reverse compare"},
	{"rem", "remainder"},
	{"remu", "remainder unsigned"},
	{"ret", "return from subroutine"},
	{"rlc", "rotate left through carry"},
	{"rnd16", "round to word"},
	{"ror", "rotate right"},
	{"rrc", "rotate right through carry"},
	{"rsub", "reverse subtraction"},
	{"rtie", "return from interrupt/exception"},
	{"sat16", "saturate to word"},
	{"sbc", "subtract with carry"},
	{"seq", "set if equal"},
	{"sev", "send event"},
	{"sev_lite", "send event lite"},
	{"sex", "signed extend"},
	{"sex_s", "signed extend (saturated)"},
	{"sge", "set if greater or equal"},
	{"sgeu", "set if greater or equal unsigned"},
	{"sgt", "set if greater than"},
	{"sgtu", "set if greater than unsigned"},
	{"sle", "set if less or equal"},
	{"sleep", "put processor in sleep mode"},
	{"sleu", "set if less or equal unsigned"},
	{"slt", "set if less than"},
	{"sltu", "set if less than unsigned"},
	{"sne", "set if not equal"},
	{"sr", "store to auxiliary memory"},
	{"st", "store to memory"},
	{"st_s", "store to memory (saturated)"},
	{"sta", "store address"},
	{"stb", "store byte"},
	{"stc", "store coprocessor"},
	{"std", "store doubleword"},
	{"sth", "store halfword"},
	{"stm", "store multiple registers"},
	{"stw", "store word"},
	{"sub", "subtract"},
	{"sub1", "subtract with left shift by 1 bit"},
	{"sub2", "subtract with left shift by 2 bits"},
	{"sub3", "subtract with left shift by 3 bits"},
	{"sub_s", "subtract (saturated)"},
	{"subs", "subtract and saturate"},
	{"subsdw", "subtract and saturate dual word"},
	{"swap", "swap 16 x 16"},
	{"swi", "software interrupt"},
	{"sync", "synchronize"},
	{"trap", "raise exception"},
	{"trap0", "raise exception with param. 0"},
	{"trap_s", "raise exception (saturated)"},
	{"tst", "test"},
	{"tst_s", "test (saturated)"},
	{"unimp_s", "unimplemented instruction"},
	{"wait", "wait for event"},
	{"wfe", "wait for event"},
	{"wfi", "wait for interrupt"},
	{"xor", "logical exclusive-or"},
	{"xor_s", "logical exclusive-or (saturated)"},
  {NULL, NULL}
};
typedef int (*GperfForeachCallback)(void *user, const char *k, const char *v);
int gperf_arc_foreach(GperfForeachCallback cb, void *user) {
  int i = 0; while (kvs[i].name) {
  cb (user, kvs[i].name, kvs[i].value);
  i++;}
  return 0;
}
const char *gperf_arc_get(const char *s) {
  int i = 0; while (kvs[i].name) {
  if (!strcmp (s, kvs[i].name)) return kvs[i].value;
  i++;}
  return NULL;
}
#define sdb_hash_c_arc(x,y) gperf_arc_hash(x)
const unsigned int gperf_arc_hash(const char *s) {
  int sum = strlen (s);
  while (*s) { sum += *s; s++; }
  return sum;
}
struct {const char *name;void *get;void *hash;void *foreach;} gperf_arc = {
  .name = "arc",
  .get = &gperf_arc_get,
  .hash = &gperf_arc_hash,
  .foreach = &gperf_arc_foreach
};

#if MAIN
int main () {
	const char *s = ((char*(*)(char*))gperf_arc.get)("foo");
	printf ("%s\n", s);
}
#endif
