// 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 nds32.c ; ./a.out > nds32.h
	{"addi", "Add immediate"},
	{"addi.gp", "Add to GP register"},
	{"addi10s", "Add immediate short"},
	{"addi45", "Add immediate"},
	{"addri36.sp", "Add immediate to stack pointer"},
	{"andi", "AND immediate"},
	{"andi45", "AND immediate"},
	{"beq", "Branch if equal"},
	{"beqc", "Branch if equal to constant"},
	{"beqz38", "Branch if register is zero"},
	{"beqzs8", "Branch if register is zero"},
	{"bitci", "Bit clear immediate"},
	{"bnec", "Branch if not equal"},
	{"bnez38", "Branch if register is not zero"},
	{"bnezs8", "Branch if not zero"},
	{"break", "Breakpoint"},
	{"divr", "Divide"},
	{"j8", "Jump to label"},
	{"jal", "Jump and link"},
	{"jr", "Jump to register"},
	{"jr5", "Jump to register"},
	{"jral5", "Jump and link register"},
	{"lbi", "Load byte from immediate address"},
	{"lbi333", "Load byte with base register and offset"},
	{"lmw.bi", "Load multiple words before increment"},
	{"lwi", "Load word from immediate address"},
	{"lwi.gp", "Load word from GP-relative address"},
	{"lwi333", "Load word from memory with base register and offset"},
	{"lwsi.bi", "Load word signed before increment"},
	{"maddr32", "Multiply-add"},
	{"mfsr", "Move from special register"},
	{"mov55", "Move register to register"},
	{"movd44", "Move double register"},
	{"movi", "Move immediate"},
	{"movi55", "Move immediate value to register"},
	{"movpi45", "Move position-independent immediate"},
	{"nop", "No operation"},
	{"or33", "OR operation"},
	{"or_slli", "OR with shift left immediate"},
	{"ori", "OR immediate"},
	{"ori45", "OR immediate"},
	{"pop25", "Pop register from stack"},
	{"push25", "Push register onto stack"},
	{"ret", "Return"},
	{"ret5", "Return to register"},
	{"sbi", "Store byte to immediate address"},
	{"sbi.gp", "Store byte to GP-relative address"},
	{"sbi333", "Store byte with base register and offset"},
	{"sethi", "Set high immediate"},
	{"shi.bi", "Store halfword before increment"},
	{"shi.gp", "Store halfword to GP-relative address"},
	{"slli", "Shift left logical immediate"},
	{"slti45", "Set if less than immediate"},
	{"sltsi45", "Set if less than immediate signed"},
	{"smw.bi", "Store multiple words before increment"},
	{"srai45", "Arithmetic shift right immediate"},
	{"srli45", "Logical shift right immediate"},
	{"subri", "Subtract immediate reverse"},
	{"subri45", "Subtract immediate reverse"},
	{"swi", "Store word to immediate address"},
	{"swi.gp", "Store word to GP-relative address"},
	{"swi333", "Store word to memory with base register and offset"},
	{"swi45", "Store word with base register and offset"},
	{"swi450", "Store word with base register and offset"},
	{"syscall", "System call"},
	{"xlsb33", "Extract least significant bit"},
	{"xori45", "XOR immediate"},
	{"zeh33", "Zero extend halfword"},
  {NULL, NULL}
};
typedef int (*GperfForeachCallback)(void *user, const char *k, const char *v);
int gperf_nds32_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_nds32_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_nds32(x,y) gperf_nds32_hash(x)
const unsigned int gperf_nds32_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_nds32 = {
  .name = "nds32",
  .get = &gperf_nds32_get,
  .hash = &gperf_nds32_hash,
  .foreach = &gperf_nds32_foreach
};

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