Clean up type expression syntax.
[smatch.git] / linearize.h
blobf0968baa2ad4c6a23b120dfc1e40e6729b9919a8
1 #ifndef LINEARIZE_H
2 #define LINEARIZE_H
4 #include "lib.h"
5 #include "token.h"
6 #include "parse.h"
7 #include "symbol.h"
9 /* Silly pseudo define. Do this right some day */
10 typedef struct {
11 int nr;
12 } pseudo_t;
14 static inline pseudo_t to_pseudo(int nr)
16 pseudo_t a;
17 a.nr = nr;
18 return a;
21 #define VOID (to_pseudo(0))
23 struct instruction {
24 struct symbol *type;
25 int opcode;
26 pseudo_t target;
27 union {
28 struct /* unops */ {
29 struct symbol *orig_type; /* casts */
30 pseudo_t src;
32 struct /* binops */ {
33 pseudo_t src1, src2;
35 struct /* multijump */ {
36 int begin, end;
38 struct expression *val;
39 struct symbol *address;
43 enum opcode {
44 OP_BADOP,
45 OP_CONDTRUE,
46 OP_CONDFALSE,
47 OP_SETVAL,
48 OP_MULTIVALUE,
49 OP_MULTIJUMP,
50 OP_LOAD,
51 OP_STORE,
52 OP_MOVE,
53 OP_ARGUMENT,
54 OP_CALL,
55 OP_INDCALL,
56 OP_CAST,
57 OP_UNOP = 0x200,
58 OP_LASTUNOP = 0x3ff,
59 OP_BINOP = 0x400,
60 OP_LASTBINOP = 0x5ff,
63 struct basic_block_list;
64 struct instruction_list;
67 * Basic block flags. Right now we only have one, which keeps
68 * track (at build time) whether the basic block has been branched
69 * out of yet.
71 #define BB_HASBRANCH 0x00000001
73 struct basic_block {
74 unsigned long flags; /* BB status flags */
75 struct symbol *this; /* Points to the symbol that owns "this" basic block - NULL if unreachable */
76 struct instruction_list *insns; /* Linear list of instructions */
77 struct symbol *next; /* Points to the symbol that describes the fallthrough */
80 static inline void add_bb(struct basic_block_list **list, struct basic_block *bb)
82 add_ptr_list((struct ptr_list **)list, bb);
85 static inline void add_instruction(struct instruction_list **list, struct instruction *insn)
87 add_ptr_list((struct ptr_list **)list, insn);
90 struct entrypoint {
91 struct symbol *name;
92 struct symbol_list *syms;
93 struct basic_block_list *bbs;
94 struct basic_block *active;
97 void linearize_symbol(struct symbol *sym);
99 #endif /* LINEARIZE_H */