popt.h 1.01 KB
Newer Older
1 2 3 4
// Copyright 2013 The Go Authors.  All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

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
typedef struct Flow Flow;
typedef struct Graph Graph;

struct Flow {
	Prog*	prog;   	// actual instruction
	Flow*	p1;     	// predecessors of this instruction: p1,
	Flow*	p2;     	// and then p2 linked though p2link.
	Flow*	p2link;
	Flow*	s1;     	// successors of this instruction (at most two: s1 and s2).
	Flow*	s2;
	Flow*	link;   	// next instruction in function code
	
	int32	active;	// usable by client

	int32	rpo;		// reverse post ordering
	uint16	loop;		// x5 for every loop
	uchar	refset;		// diagnostic generated
};

struct Graph
{
	Flow*	start;
	int	num;
	
	// After calling flowrpo, rpo lists the flow nodes in reverse postorder,
	// and each non-dead Flow node f has g->rpo[f->rpo] == f.
	Flow**	rpo;
};

34
void	fixjmp(Prog*);
35 36 37
Graph*	flowstart(Prog*, int);
void	flowrpo(Graph*);
void	flowend(Graph*);
38
int	noreturn(Prog*);
39 40
Flow*	uniqp(Flow*);
Flow*	uniqs(Flow*);