aboutsummaryrefslogtreecommitdiff
path: root/gcc/go/gofrontend/dataflow.h
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2010-12-03 04:34:57 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2010-12-03 04:34:57 +0000
commit7a9389330e91acc3ed05deac2d198af25d13cf3c (patch)
tree38fe54a4f38ede5d949c915d66191f24a6fe5153 /gcc/go/gofrontend/dataflow.h
parent1aa6700378e5188a853c018256113ce6e1fb5c05 (diff)
downloadgcc-7a9389330e91acc3ed05deac2d198af25d13cf3c.zip
gcc-7a9389330e91acc3ed05deac2d198af25d13cf3c.tar.gz
gcc-7a9389330e91acc3ed05deac2d198af25d13cf3c.tar.bz2
Add Go frontend, libgo library, and Go testsuite.
gcc/: * gcc.c (default_compilers): Add entry for ".go". * common.opt: Add -static-libgo as a driver option. * doc/install.texi (Configuration): Mention libgo as an option for --enable-shared. Mention go as an option for --enable-languages. * doc/invoke.texi (Overall Options): Mention .go as a file name suffix. Mention go as a -x option. * doc/frontends.texi (G++ and GCC): Mention Go as a supported language. * doc/sourcebuild.texi (Top Level): Mention libgo. * doc/standards.texi (Standards): Add section on Go language. Move references for other languages into their own section. * doc/contrib.texi (Contributors): Mention that I contributed the Go frontend. gcc/testsuite/: * lib/go.exp: New file. * lib/go-dg.exp: New file. * lib/go-torture.exp: New file. * lib/target-supports.exp (check_compile): Match // Go. From-SVN: r167407
Diffstat (limited to 'gcc/go/gofrontend/dataflow.h')
-rw-r--r--gcc/go/gofrontend/dataflow.h91
1 files changed, 91 insertions, 0 deletions
diff --git a/gcc/go/gofrontend/dataflow.h b/gcc/go/gofrontend/dataflow.h
new file mode 100644
index 0000000..a75c8e6
--- /dev/null
+++ b/gcc/go/gofrontend/dataflow.h
@@ -0,0 +1,91 @@
+// dataflow.h -- Go frontend dataflow. -*- C++ -*-
+
+// Copyright 2009 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.
+
+#ifndef GO_DATAFLOW_H
+#define GO_DATAFLOW_H
+
+class Expression;
+class Named_object;
+class Statement;
+
+// Dataflow information about the Go program.
+
+class Dataflow
+{
+ public:
+ // A variable definition.
+ struct Def
+ {
+ // The statement where the variable is defined.
+ Statement* statement;
+ // The value to which the variable is set. This may be NULL.
+ Expression* val;
+ // Whether this is an initialization of the variable.
+ bool is_init;
+ };
+
+ // A variable reference.
+ struct Ref
+ {
+ // The statement where the variable is referenced.
+ Statement* statement;
+ };
+
+ // A list of defs.
+ typedef std::vector<Def> Defs;
+
+ // A list of refs.
+ typedef std::vector<Ref> Refs;
+
+ Dataflow();
+
+ // Initialize the dataflow information.
+ void
+ initialize(Gogo*);
+
+ // Add a definition of a variable. STATEMENT assigns a value to
+ // VAR. VAL is the value if it is known, NULL otherwise.
+ void
+ add_def(Named_object* var, Expression* val, Statement* statement,
+ bool is_init);
+
+ // Add a reference to a variable. VAR is the variable, and
+ // STATEMENT is the statement which refers to it.
+ void
+ add_ref(Named_object* var, Statement* statement);
+
+ // Return the definitions of VAR--the places where it is set.
+ const Defs*
+ find_defs(Named_object* var) const;
+
+ // Return the references to VAR--the places where it is used.
+ const Refs*
+ find_refs(Named_object* var) const;
+
+ private:
+ // Order variables in the map.
+ struct Compare_vars
+ {
+ bool
+ operator()(const Named_object*, const Named_object*) const;
+ };
+
+ // Map from variables to a list of defs of the variable. We use a
+ // map rather than a hash table because the order in which we
+ // process variables may affect the resulting code.
+ typedef std::map<Named_object*, Defs*, Compare_vars> Defmap;
+
+ // Map from variables to a list of refs to the vairable.
+ typedef std::map<Named_object*, Refs*, Compare_vars> Refmap;
+
+ // Variable defs.
+ Defmap defs_;
+ // Variable refs;
+ Refmap refs_;
+};
+
+
+#endif // !defined(GO_DATAFLOW_H)