OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [go/] [gofrontend/] [dataflow.h] - Blame information for rev 720

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 714 jeremybenn
// dataflow.h -- Go frontend dataflow.    -*- C++ -*-
2
 
3
// Copyright 2009 The Go Authors. All rights reserved.
4
// Use of this source code is governed by a BSD-style
5
// license that can be found in the LICENSE file.
6
 
7
#ifndef GO_DATAFLOW_H
8
#define GO_DATAFLOW_H
9
 
10
class Expression;
11
class Named_object;
12
class Statement;
13
 
14
// Dataflow information about the Go program.
15
 
16
class Dataflow
17
{
18
 public:
19
  // A variable definition.
20
  struct Def
21
  {
22
    // The statement where the variable is defined.
23
    Statement* statement;
24
    // The value to which the variable is set.  This may be NULL.
25
    Expression* val;
26
    // Whether this is an initialization of the variable.
27
    bool is_init;
28
  };
29
 
30
  // A variable reference.
31
  struct Ref
32
  {
33
    // The statement where the variable is referenced.
34
    Statement* statement;
35
  };
36
 
37
  // A list of defs.
38
  typedef std::vector<Def> Defs;
39
 
40
  // A list of refs.
41
  typedef std::vector<Ref> Refs;
42
 
43
  Dataflow();
44
 
45
  // Initialize the dataflow information.
46
  void
47
  initialize(Gogo*);
48
 
49
  // Add a definition of a variable.  STATEMENT assigns a value to
50
  // VAR.  VAL is the value if it is known, NULL otherwise.
51
  void
52
  add_def(Named_object* var, Expression* val, Statement* statement,
53
          bool is_init);
54
 
55
  // Add a reference to a variable.  VAR is the variable, and
56
  // STATEMENT is the statement which refers to it.
57
  void
58
  add_ref(Named_object* var, Statement* statement);
59
 
60
  // Return the definitions of VAR--the places where it is set.
61
  const Defs*
62
  find_defs(Named_object* var) const;
63
 
64
  // Return the references to VAR--the places where it is used.
65
  const Refs*
66
  find_refs(Named_object* var) const;
67
 
68
 private:
69
  // Order variables in the map.
70
  struct Compare_vars
71
  {
72
    bool
73
    operator()(const Named_object*, const Named_object*) const;
74
  };
75
 
76
  // Map from variables to a list of defs of the variable.  We use a
77
  // map rather than a hash table because the order in which we
78
  // process variables may affect the resulting code.
79
  typedef std::map<Named_object*, Defs*, Compare_vars> Defmap;
80
 
81
  // Map from variables to a list of refs to the vairable.
82
  typedef std::map<Named_object*, Refs*, Compare_vars> Refmap;
83
 
84
  // Variable defs.
85
  Defmap defs_;
86
  // Variable refs;
87
  Refmap refs_;
88
};
89
 
90
 
91
#endif // !defined(GO_DATAFLOW_H)

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.