summaryrefslogtreecommitdiff
path: root/examples/jit/ojprogram.h
blob: db87814705a8f350de6d017b39b69d37d8c4781b (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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57

#ifndef _OJ_PROGRAM_H_
#define _OJ_PROGRAM_H_

#include <glib.h>


typedef struct _OJVariable {
  char *name;
} OJVariable;

typedef struct _OJArgument {
  OJVariable *var;
  int is_indirect;
  int is_indexed;
  OJVariable *index_var;
  int index_scale;
  int type; // remove
  int index; // remove
  int offset;
} OJArgument;

typedef struct _OJInstruction {
  int opcode;

  OJArgument args[3];
} OJInstruction;

typedef struct _OJProgram {
  OJInstruction insns[100];
  int n_insns;

  OJVariable vars[100];
  int n_vars;

  /* parsing state */
  char *s;
  char *error;

  OJInstruction *insn;

}OJProgram;

typedef struct _OJOpcode {
  char *name;
  int n_args;
} OJOpcode;


OJProgram * oj_program_new (void);
int oj_opcode_lookup (const char *s, int len);
void oj_program_parse (OJProgram *p, const char *program);
void oj_program_output_mmx (OJProgram *p);
void oj_program_free (OJProgram *program);

#endif