/* go-lang.c -- Go frontend gcc interface.
- Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
+ Copyright (C) 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
This file is part of GCC.
#include "langhooks-def.h"
#include "except.h"
#include "target.h"
+#include "common/common-target.h"
#include <mpfr.h>
/* The resulting tree type. */
union GTY((desc ("TREE_CODE (&%h.generic) == IDENTIFIER_NODE"),
- chain_next ("(union lang_tree_node *) TREE_CHAIN (&%h.generic)")))
+ chain_next ("CODE_CONTAINS_STRUCT (TREE_CODE (&%h.generic), TS_COMMON) ? ((union lang_tree_node *) TREE_CHAIN (&%h.generic)) : NULL")))
lang_tree_node
{
union tree_node GTY((tag ("0"),
int dummy;
};
+/* Option information we need to pass to go_create_gogo. */
+
+static const char *go_pkgpath = NULL;
+static const char *go_prefix = NULL;
+
/* Language hooks. */
static bool
go_langhook_init (void)
{
- build_common_tree_nodes (false);
-
- /* The sizetype may be "unsigned long" or "unsigned long long". */
- if (TYPE_MODE (long_unsigned_type_node) == ptr_mode)
- size_type_node = long_unsigned_type_node;
- else if (TYPE_MODE (long_long_unsigned_type_node) == ptr_mode)
- size_type_node = long_long_unsigned_type_node;
- else
- size_type_node = long_unsigned_type_node;
- set_sizetype (size_type_node);
+ build_common_tree_nodes (false, false);
- build_common_tree_nodes_2 (0);
+ /* I don't know why this has to be done explicitly. */
+ void_list_node = build_tree_list (NULL_TREE, void_type_node);
/* We must create the gogo IR after calling build_common_tree_nodes
(because Gogo::define_builtin_function_trees refers indirectly
to, e.g., unsigned_char_type_node) but before calling
build_common_builtin_nodes (because it calls, indirectly,
go_type_for_size). */
- go_create_gogo (INT_TYPE_SIZE, POINTER_SIZE);
+ go_create_gogo (INT_TYPE_SIZE, POINTER_SIZE, go_pkgpath, go_prefix);
build_common_builtin_nodes ();
- /* I don't know why this is not done by any of the above. */
- void_list_node = build_tree_list (NULL_TREE, void_type_node);
-
/* The default precision for floating point numbers. This is used
for floating point constants with abstract type. This may
eventually be controllable by a command line option. */
- mpfr_set_default_prec (128);
+ mpfr_set_default_prec (256);
/* Go uses exceptions. */
using_eh_for_cleanups ();
/* The builtin math functions should not set errno. */
opts->x_flag_errno_math = 0;
-
- /* By default assume that floating point math does not trap. */
- opts->x_flag_trapping_math = 0;
+ opts->frontend_set_flag_errno_math = true;
/* We turn on stack splitting if we can. */
- if (targetm.supports_split_stack (false, opts))
+ if (targetm_common.supports_split_stack (false, opts))
opts->x_flag_split_stack = 1;
/* Exceptions are used to handle recovering from panics. */
ret = go_enable_dump (arg) ? true : false;
break;
+ case OPT_fgo_optimize_:
+ ret = go_enable_optimize (arg) ? true : false;
+ break;
+
+ case OPT_fgo_pkgpath_:
+ go_pkgpath = arg;
+ break;
+
case OPT_fgo_prefix_:
- go_set_prefix (arg);
+ go_prefix = arg;
break;
default:
static tree
go_langhook_type_for_mode (enum machine_mode mode, int unsignedp)
{
+ tree type;
/* Go has no vector types. Build them here. FIXME: It does not
make sense for the middle-end to ask the frontend for a type
which the frontend does not support. However, at least for now
return NULL_TREE;
}
- return go_type_for_mode (mode, unsignedp);
+ type = go_type_for_mode (mode, unsignedp);
+ if (type)
+ return type;
+
+#if HOST_BITS_PER_WIDE_INT >= 64
+ /* The middle-end and some backends rely on TImode being supported
+ for 64-bit HWI. */
+ if (mode == TImode)
+ {
+ type = build_nonstandard_integer_type (GET_MODE_BITSIZE (TImode),
+ unsignedp);
+ if (type && TYPE_MODE (type) == TImode)
+ return type;
+ }
+#endif
+ return NULL_TREE;
}
/* Record a builtin function. We just ignore builtin functions. */
return decl;
}
-static int
+/* Return true if we are in the global binding level. */
+
+static bool
go_langhook_global_bindings_p (void)
{
- return current_function_decl == NULL ? 1 : 0;
+ return current_function_decl == NULL_TREE;
}
/* Push a declaration into the current binding level. We can't