1 /* From NetBSD: gencode.h,v 1.2 1995/03/06 11:38:24 mycroft Exp */
4 * Copyright (c) 1990, 1991, 1992, 1993, 1994
5 * The Regents of the University of California. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that: (1) source code distributions
9 * retain the above copyright notice and this paragraph in its entirety, (2)
10 * distributions including binary code include the above copyright notice and
11 * this paragraph in its entirety in the documentation or other materials
12 * provided with the distribution, and (3) all advertising materials mentioning
13 * features or use of this software display the following acknowledgement:
14 * ``This product includes software developed by the University of California,
15 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
16 * the University nor the names of its contributors may be used to endorse
17 * or promote products derived from this software without specific prior
19 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
20 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
21 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
23 * @(#) Header: gencode.h,v 1.20 94/06/12 14:29:30 leres Exp (LBL)
26 /* $Id: gencode.h,v 1.1 1996/04/04 04:22:26 paulus Exp $ */
28 /* Address qualifers. */
35 /* Protocol qualifiers. */
43 /* Directional qualifers. */
64 * A bit vector to represent definition sets. We assume TOT_REGISTERS
65 * is smaller than 8*sizeof(atomset).
67 typedef unsigned long atomset;
68 #define ATOMMASK(n) (1 << (n))
69 #define ATOMELEM(d, n) (d & ATOMMASK(n))
74 typedef unsigned long *uset;
77 * Total number of atomic entities, including accumulator (A) and index (X).
78 * We treat all these guys similarly during flow analysis.
80 #define N_ATOMS (BPF_MEMWORDS+2)
88 struct edge *next; /* link list of incoming edges for a node */
93 struct slist *stmts; /* side effect stmts */
94 struct stmt s; /* branch stmt */
102 struct block *link; /* link field used by optimizer */
105 struct edge *in_edges;
114 struct block *b; /* protocol checks */
115 struct slist *s; /* stmt list */
116 int regno; /* virtual register number of result */
130 struct arth *gen_loadi __P((int));
131 struct arth *gen_load __P((int, struct arth *, int));
132 struct arth *gen_loadlen __P((void));
133 struct arth *gen_neg __P((struct arth *));
134 struct arth *gen_arth __P((int, struct arth *, struct arth *));
136 void gen_and __P((struct block *, struct block *));
137 void gen_or __P((struct block *, struct block *));
138 void gen_not __P((struct block *));
140 struct block *gen_scode __P((char *, struct qual));
141 struct block *gen_ecode __P((unsigned char *, struct qual));
142 struct block *gen_ncode __P((unsigned long, struct qual));
143 struct block *gen_proto_abbrev __P((int));
144 struct block *gen_relation __P((int, struct arth *, struct arth *, int));
145 struct block *gen_less __P((int));
146 struct block *gen_greater __P((int));
147 struct block *gen_byteop __P((int, int, int));
148 struct block *gen_broadcast __P((int));
149 struct block *gen_multicast __P((int));
150 struct block *gen_inbound __P((int));
152 void bpf_optimize __P((struct block **));
153 volatile void bpf_error __P((char *, ...));
155 void finish_parse __P((struct block *));
156 char *sdup __P((char *));
158 struct bpf_insn *icode_to_fcode __P((struct block *, int *));
159 int pcap_parse __P((void));
160 void lex_init __P((char *));
161 void sappend __P((struct slist *, struct slist *));
164 #define JT(b) ((b)->et.succ)
165 #define JF(b) ((b)->ef.succ)