summaryrefslogtreecommitdiffstats
path: root/opcode.h
blob: ee956e275c48f4d83fc817a0e893c971dfe5b1b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#ifndef OPCODE_H
#define OPCODE_H
#include <assert.h>

typedef enum {
#define OP(name, imm, in, out) name,
#include "opcode_list.h"
#undef OP
} opcode;

enum {
  NUM_OPCODES = 
#define OP(name, imm, in, out) +1
#include "opcode_list.h"
#undef OP
};

enum {
  OP_HAS_CONSTANT = 2,
  OP_HAS_VARIABLE = 4,
  OP_HAS_BRANCH = 8,
  OP_HAS_CFUNC = 32,
  OP_HAS_UFUNC = 64,
  OP_IS_CALL_PSEUDO = 128,
  OP_HAS_BINDING = 1024,
};
struct opcode_description {
  opcode op;
  const char* name;

  int flags;

  // length in 16-bit units
  int length;

  int stack_in, stack_out;
};

const struct opcode_description* opcode_describe(opcode op);

#endif