compiler: Remove GCC langhooks from frontend proper.
* go-lang.c (go_langhook_type_for_size): Do it here, rather than calling into Go frontend. (go_langhook_type_for_mode): Likewise. * go-c.h (go_type_for_size, go_type_for_mode): Don't declare. From-SVN: r209945
This commit is contained in:
parent
7211512a5f
commit
ad5b68e0af
|
@ -1,3 +1,10 @@
|
||||||
|
2014-04-30 Chris Manghane <cmang@google.com>
|
||||||
|
|
||||||
|
* go-lang.c (go_langhook_type_for_size): Do it here, rather than
|
||||||
|
calling into Go frontend.
|
||||||
|
(go_langhook_type_for_mode): Likewise.
|
||||||
|
* go-c.h (go_type_for_size, go_type_for_mode): Don't declare.
|
||||||
|
|
||||||
2014-04-30 Chris Manghane <cmang@google.com>
|
2014-04-30 Chris Manghane <cmang@google.com>
|
||||||
|
|
||||||
* go-gcc.cc: #include "langhooks.h".
|
* go-gcc.cc: #include "langhooks.h".
|
||||||
|
|
|
@ -41,9 +41,6 @@ extern void go_parse_input_files (const char**, unsigned int,
|
||||||
bool require_return_statement);
|
bool require_return_statement);
|
||||||
extern void go_write_globals (void);
|
extern void go_write_globals (void);
|
||||||
|
|
||||||
extern tree go_type_for_size (unsigned int bits, int unsignedp);
|
|
||||||
extern tree go_type_for_mode (enum machine_mode, int unsignedp);
|
|
||||||
|
|
||||||
/* Functions defined in the GCC interface called by the Go frontend
|
/* Functions defined in the GCC interface called by the Go frontend
|
||||||
proper. */
|
proper. */
|
||||||
|
|
||||||
|
|
|
@ -288,7 +288,38 @@ go_langhook_parse_file (void)
|
||||||
static tree
|
static tree
|
||||||
go_langhook_type_for_size (unsigned int bits, int unsignedp)
|
go_langhook_type_for_size (unsigned int bits, int unsignedp)
|
||||||
{
|
{
|
||||||
return go_type_for_size (bits, unsignedp);
|
tree type;
|
||||||
|
if (unsignedp)
|
||||||
|
{
|
||||||
|
if (bits == INT_TYPE_SIZE)
|
||||||
|
type = unsigned_type_node;
|
||||||
|
else if (bits == CHAR_TYPE_SIZE)
|
||||||
|
type = unsigned_char_type_node;
|
||||||
|
else if (bits == SHORT_TYPE_SIZE)
|
||||||
|
type = short_unsigned_type_node;
|
||||||
|
else if (bits == LONG_TYPE_SIZE)
|
||||||
|
type = long_unsigned_type_node;
|
||||||
|
else if (bits == LONG_LONG_TYPE_SIZE)
|
||||||
|
type = long_long_unsigned_type_node;
|
||||||
|
else
|
||||||
|
type = make_unsigned_type(bits);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (bits == INT_TYPE_SIZE)
|
||||||
|
type = integer_type_node;
|
||||||
|
else if (bits == CHAR_TYPE_SIZE)
|
||||||
|
type = signed_char_type_node;
|
||||||
|
else if (bits == SHORT_TYPE_SIZE)
|
||||||
|
type = short_integer_type_node;
|
||||||
|
else if (bits == LONG_TYPE_SIZE)
|
||||||
|
type = long_integer_type_node;
|
||||||
|
else if (bits == LONG_LONG_TYPE_SIZE)
|
||||||
|
type = long_long_integer_type_node;
|
||||||
|
else
|
||||||
|
type = make_signed_type(bits);
|
||||||
|
}
|
||||||
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
static tree
|
static tree
|
||||||
|
@ -309,9 +340,40 @@ go_langhook_type_for_mode (enum machine_mode mode, int unsignedp)
|
||||||
return NULL_TREE;
|
return NULL_TREE;
|
||||||
}
|
}
|
||||||
|
|
||||||
type = go_type_for_mode (mode, unsignedp);
|
// FIXME: This static_cast should be in machmode.h.
|
||||||
if (type)
|
enum mode_class mc = static_cast<enum mode_class>(GET_MODE_CLASS(mode));
|
||||||
return type;
|
if (mc == MODE_INT)
|
||||||
|
return go_langhook_type_for_size(GET_MODE_BITSIZE(mode), unsignedp);
|
||||||
|
else if (mc == MODE_FLOAT)
|
||||||
|
{
|
||||||
|
switch (GET_MODE_BITSIZE (mode))
|
||||||
|
{
|
||||||
|
case 32:
|
||||||
|
return float_type_node;
|
||||||
|
case 64:
|
||||||
|
return double_type_node;
|
||||||
|
default:
|
||||||
|
// We have to check for long double in order to support
|
||||||
|
// i386 excess precision.
|
||||||
|
if (mode == TYPE_MODE(long_double_type_node))
|
||||||
|
return long_double_type_node;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (mc == MODE_COMPLEX_FLOAT)
|
||||||
|
{
|
||||||
|
switch (GET_MODE_BITSIZE (mode))
|
||||||
|
{
|
||||||
|
case 64:
|
||||||
|
return complex_float_type_node;
|
||||||
|
case 128:
|
||||||
|
return complex_double_type_node;
|
||||||
|
default:
|
||||||
|
// We have to check for long double in order to support
|
||||||
|
// i386 excess precision.
|
||||||
|
if (mode == TYPE_MODE(complex_long_double_type_node))
|
||||||
|
return complex_long_double_type_node;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#if HOST_BITS_PER_WIDE_INT >= 64
|
#if HOST_BITS_PER_WIDE_INT >= 64
|
||||||
/* The middle-end and some backends rely on TImode being supported
|
/* The middle-end and some backends rely on TImode being supported
|
||||||
|
|
|
@ -35,88 +35,3 @@ saw_errors()
|
||||||
{
|
{
|
||||||
return errorcount != 0 || sorrycount != 0;
|
return errorcount != 0 || sorrycount != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the integer type to use for a size.
|
|
||||||
|
|
||||||
GO_EXTERN_C
|
|
||||||
tree
|
|
||||||
go_type_for_size(unsigned int bits, int unsignedp)
|
|
||||||
{
|
|
||||||
const char* name;
|
|
||||||
switch (bits)
|
|
||||||
{
|
|
||||||
case 8:
|
|
||||||
name = unsignedp ? "uint8" : "int8";
|
|
||||||
break;
|
|
||||||
case 16:
|
|
||||||
name = unsignedp ? "uint16" : "int16";
|
|
||||||
break;
|
|
||||||
case 32:
|
|
||||||
name = unsignedp ? "uint32" : "int32";
|
|
||||||
break;
|
|
||||||
case 64:
|
|
||||||
name = unsignedp ? "uint64" : "int64";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
if (bits == POINTER_SIZE && unsignedp)
|
|
||||||
name = "uintptr";
|
|
||||||
else
|
|
||||||
return NULL_TREE;
|
|
||||||
}
|
|
||||||
Type* type = Type::lookup_integer_type(name);
|
|
||||||
return type_to_tree(type->get_backend(go_get_gogo()));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return the type to use for a mode.
|
|
||||||
|
|
||||||
GO_EXTERN_C
|
|
||||||
tree
|
|
||||||
go_type_for_mode(enum machine_mode mode, int unsignedp)
|
|
||||||
{
|
|
||||||
// FIXME: This static_cast should be in machmode.h.
|
|
||||||
enum mode_class mc = static_cast<enum mode_class>(GET_MODE_CLASS(mode));
|
|
||||||
if (mc == MODE_INT)
|
|
||||||
return go_type_for_size(GET_MODE_BITSIZE(mode), unsignedp);
|
|
||||||
else if (mc == MODE_FLOAT)
|
|
||||||
{
|
|
||||||
Type* type;
|
|
||||||
switch (GET_MODE_BITSIZE (mode))
|
|
||||||
{
|
|
||||||
case 32:
|
|
||||||
type = Type::lookup_float_type("float32");
|
|
||||||
break;
|
|
||||||
case 64:
|
|
||||||
type = Type::lookup_float_type("float64");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
// We have to check for long double in order to support
|
|
||||||
// i386 excess precision.
|
|
||||||
if (mode == TYPE_MODE(long_double_type_node))
|
|
||||||
return long_double_type_node;
|
|
||||||
return NULL_TREE;
|
|
||||||
}
|
|
||||||
return type_to_tree(type->get_backend(go_get_gogo()));
|
|
||||||
}
|
|
||||||
else if (mc == MODE_COMPLEX_FLOAT)
|
|
||||||
{
|
|
||||||
Type *type;
|
|
||||||
switch (GET_MODE_BITSIZE (mode))
|
|
||||||
{
|
|
||||||
case 64:
|
|
||||||
type = Type::lookup_complex_type("complex64");
|
|
||||||
break;
|
|
||||||
case 128:
|
|
||||||
type = Type::lookup_complex_type("complex128");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
// We have to check for long double in order to support
|
|
||||||
// i386 excess precision.
|
|
||||||
if (mode == TYPE_MODE(complex_long_double_type_node))
|
|
||||||
return complex_long_double_type_node;
|
|
||||||
return NULL_TREE;
|
|
||||||
}
|
|
||||||
return type_to_tree(type->get_backend(go_get_gogo()));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return NULL_TREE;
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue