aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandreao <andreao@138bc75d-0d04-0410-961f-82ee72b054a4>2009-07-21 09:51:55 +0000
committerandreao <andreao@138bc75d-0d04-0410-961f-82ee72b054a4>2009-07-21 09:51:55 +0000
commitcb707c7cd0428e63e05121041a8f789d126fe683 (patch)
treec04133a3438954751aed21010c6ce5bdf5a65dc8
parente072efd02841406fb24d0f0fb76da4ce7ae1ae3b (diff)
add to cil-types.def supported complex types, void and argiterator
add method type_to_cil_on_stack that returns the cil type on the stack (complex are returned as valuetype, void is not allowed) git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/st/cli-be@149850 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/config/cil32/cil-dump.c56
-rw-r--r--gcc/config/cil32/cil-stack.c105
-rw-r--r--gcc/config/cil32/cil-stack.h3
-rw-r--r--gcc/config/cil32/cil-types.def31
-rw-r--r--gcc/config/cil32/emit-cil.c91
-rw-r--r--gcc/config/cil32/t-cil321
6 files changed, 163 insertions, 124 deletions
diff --git a/gcc/config/cil32/cil-dump.c b/gcc/config/cil32/cil-dump.c
index 0807e84683a..76490a8dd32 100644
--- a/gcc/config/cil32/cil-dump.c
+++ b/gcc/config/cil32/cil-dump.c
@@ -157,43 +157,27 @@ dump_fun (const_tree fun)
static void
dump_type (const_tree type)
{
- if (TYPE_MAIN_VARIANT (type) == cil32_arg_iterator_type)
+ cil_type_t cil_type = type_to_cil (type);
+ switch (cil_type)
{
- printf ("valuetype ArgIterator");
- }
- else if (TREE_CODE (type) == VOID_TYPE)
- {
- printf ("void");
- }
- else if (TREE_CODE (type) == COMPLEX_TYPE)
- {
- printf ("complex_type ");
- dump_type (TREE_TYPE (type));
- }
- else
- {
- cil_type_t cil_type = type_to_cil (type);
- switch (cil_type)
- {
- case CIL_VALUE_TYPE:
- printf ("value_type ");
- dump_valuetype_name (TYPE_MAIN_VARIANT (type));
- break;
- case CIL_POINTER:
- if (TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE)
- {
- printf ("method_pointer");
- }
- else
- {
- dump_type (TREE_TYPE (type));
- printf (" *");
- }
- break;
- default:
- printf ("%s", cil_type_names [cil_type]);
- break;
- }
+ case CIL_VALUE_TYPE:
+ printf ("value_type ");
+ dump_valuetype_name (TYPE_MAIN_VARIANT (type));
+ break;
+ case CIL_POINTER:
+ if (TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE)
+ {
+ printf ("method_pointer");
+ }
+ else
+ {
+ dump_type (TREE_TYPE (type));
+ printf (" *");
+ }
+ break;
+ default:
+ printf ("%s", cil_type_names [cil_type]);
+ break;
}
}
diff --git a/gcc/config/cil32/cil-stack.c b/gcc/config/cil32/cil-stack.c
index 899feb293c1..9c0179db15f 100644
--- a/gcc/config/cil32/cil-stack.c
+++ b/gcc/config/cil32/cil-stack.c
@@ -38,6 +38,7 @@ Erven Rohou <erven.rohou@inria.fr>
#include "tree.h"
#include "vec.h"
+#include "cil-builtins.h"
#include "cil-refs.h"
#include "cil-stack.h"
#include "cil-stmt.h"
@@ -220,7 +221,7 @@ cil_stack_after_stmt (cil_stack stack, cil_stmt stmt)
if (opcode == CIL_LDFLD)
VEC_pop (cil_type_t, vstack);
- VEC_safe_push (cil_type_t, heap, vstack, type_to_cil (type));
+ VEC_safe_push (cil_type_t, heap, vstack, type_to_cil_on_stack (type));
break;
@@ -303,12 +304,12 @@ cil_stack_after_stmt (cil_stack stack, cil_stmt stmt)
case CIL_LDARG:
type = DECL_ARG_TYPE (cil_var (stmt));
- VEC_safe_push (cil_type_t, heap, vstack, type_to_cil (type));
+ VEC_safe_push (cil_type_t, heap, vstack, type_to_cil_on_stack (type));
break;
case CIL_LDLOC:
type = TREE_TYPE (cil_var (stmt));
- VEC_safe_push (cil_type_t, heap, vstack, type_to_cil (type));
+ VEC_safe_push (cil_type_t, heap, vstack, type_to_cil_on_stack (type));
break;
case CIL_LDARGA:
@@ -352,7 +353,7 @@ cil_stack_after_stmt (cil_stack stack, cil_stmt stmt)
type = TREE_TYPE (cil_call_ftype (stmt));
if (!VOID_TYPE_P (type))
- VEC_safe_push (cil_type_t, heap, vstack, type_to_cil (type));
+ VEC_safe_push (cil_type_t, heap, vstack, type_to_cil_on_stack (type));
break;
@@ -470,6 +471,30 @@ cil_float_p (cil_type_t type)
}
}
+/* Return TRUE if the type TYPE is a complex type, FALSE otherwise. */
+
+bool
+cil_complex_p (cil_type_t type)
+{
+ switch (type)
+ {
+ case CIL_CMPLXI8:
+ case CIL_CMPLXI16:
+ case CIL_CMPLXI32:
+ case CIL_CMPLXI64:
+ case CIL_CMPLXU8:
+ case CIL_CMPLXU16:
+ case CIL_CMPLXU32:
+ case CIL_CMPLXU64:
+ case CIL_CMPLXF32:
+ case CIL_CMPLXF64:
+ return true;
+
+ default:
+ return false;
+ }
+}
+
/* Return TRUE if the type TYPE is a vector type, FALSE otherwise. */
bool
@@ -595,7 +620,16 @@ scalar_to_cil (const_tree type)
}
case REAL_TYPE:
- return CIL_FLOAT;
+ size = tree_low_cst (TYPE_SIZE (type), 1);
+
+ switch (size)
+ {
+ case 32: return CIL_FLOAT32;
+ case 64: return CIL_FLOAT64;
+ default:
+ internal_error ("Unsupported float size "
+ HOST_WIDE_INT_PRINT_UNSIGNED"\n", size);
+ }
case BOOLEAN_TYPE:
return CIL_INT8;
@@ -612,6 +646,37 @@ scalar_to_cil (const_tree type)
}
}
+/* Return the CIL stack representation for scalar type TYPE. */
+
+cil_type_t
+complex_to_cil (const_tree type)
+{
+ tree elem_type;
+
+ gcc_assert (TREE_CODE (type) == COMPLEX_TYPE);
+
+ elem_type = TYPE_MAIN_VARIANT (TREE_TYPE (type));
+
+ switch (scalar_to_cil (elem_type))
+ {
+ case CIL_INT8: return CIL_CMPLXI8;
+ case CIL_INT16: return CIL_CMPLXI16;
+ case CIL_INT32: return CIL_CMPLXI32;
+ case CIL_INT64: return CIL_CMPLXI64;
+
+ case CIL_UNSIGNED_INT8: return CIL_CMPLXU8;
+ case CIL_UNSIGNED_INT16: return CIL_CMPLXU16;
+ case CIL_UNSIGNED_INT32: return CIL_CMPLXU32;
+ case CIL_UNSIGNED_INT64: return CIL_CMPLXU64;
+
+ case CIL_FLOAT32: return CIL_CMPLXF32;
+ case CIL_FLOAT64: return CIL_CMPLXF64;
+
+ default:
+ gcc_unreachable ();
+ }
+}
+
/* Return the CIL stack representation for vector type TYPE. */
cil_type_t
@@ -689,9 +754,37 @@ vector_to_cil (const_tree type)
/* Return the CIL stack representation for type TYPE. */
cil_type_t
-type_to_cil (const_tree type)
+type_to_cil_on_stack (const_tree type)
{
+ cil_type_t cil_type;
+
if (value_type_p (type))
+ cil_type = CIL_VALUE_TYPE;
+ else if (vector_type_p (type))
+ cil_type = vector_to_cil(type);
+ else
+ {
+ cil_type = scalar_to_cil(type);
+
+ if (cil_type == CIL_FLOAT32 || cil_type == CIL_FLOAT64)
+ cil_type = CIL_FLOAT;
+ }
+
+ return cil_type;
+}
+
+/* Return the CIL representation for type TYPE. */
+
+cil_type_t
+type_to_cil (const_tree type)
+{
+ if (TYPE_MAIN_VARIANT (type) == cil32_arg_iterator_type)
+ return CIL_ARGITER;
+ else if (TREE_CODE (type) == VOID_TYPE)
+ return CIL_VOID;
+ else if (TREE_CODE (type) == COMPLEX_TYPE)
+ return complex_to_cil(type);
+ else if (value_type_p (type))
return CIL_VALUE_TYPE;
else if (vector_type_p (type))
return vector_to_cil(type);
diff --git a/gcc/config/cil32/cil-stack.h b/gcc/config/cil32/cil-stack.h
index 23253837810..5154a373ee6 100644
--- a/gcc/config/cil32/cil-stack.h
+++ b/gcc/config/cil32/cil-stack.h
@@ -103,14 +103,17 @@ extern void cil_set_stack_for_bb (cil_bb_stacks, basic_block, cil_stack);
extern bool cil_integer_p (cil_type_t);
extern bool cil_native_integer_p (cil_type_t);
+extern bool cil_complex_p (cil_type_t);
extern bool cil_float_p (cil_type_t);
extern bool cil_vector_p (cil_type_t);
extern bool cil_pointer_p (cil_type_t);
extern bool cil_int_or_smaller_p (cil_type_t);
extern bool cil_long_p (cil_type_t);
extern bool cil_unsigned_int_p (cil_type_t);
+extern cil_type_t complex_to_cil (const_tree);
extern cil_type_t scalar_to_cil (const_tree);
extern cil_type_t vector_to_cil (const_tree);
extern cil_type_t type_to_cil (const_tree);
+extern cil_type_t type_to_cil_on_stack (const_tree);
#endif /* CIL_STACK_H */
diff --git a/gcc/config/cil32/cil-types.def b/gcc/config/cil32/cil-types.def
index 68833baf30d..720095c02ce 100644
--- a/gcc/config/cil32/cil-types.def
+++ b/gcc/config/cil32/cil-types.def
@@ -40,6 +40,12 @@ Erven Rohou <erven.rohou@inria.fr>
CIL_TYPEDEF(CIL_NO_TYPE,"no type??")
+/* Void type */
+CIL_TYPEDEF(CIL_VOID,"void")
+
+/* Valuetype Argiterator */
+CIL_TYPEDEF(CIL_ARGITER,"valuetype [mscorlib]System.ArgIterator")
+
CIL_TYPEDEF(CIL_INT8,"int8") /* Signed 8-bit integer */
CIL_TYPEDEF(CIL_INT16,"int16") /* Signed 16-bit integer */
CIL_TYPEDEF(CIL_INT32,"int32") /* Signed 32-bit integer */
@@ -77,3 +83,28 @@ CIL_TYPEDEF(CIL_V8HI,"V8HI") /* Vector of 8 16-bit integers */
CIL_TYPEDEF(CIL_V16QI,"V16QI") /* Vector of 16 8-bit integers */
CIL_TYPEDEF(CIL_V2DF,"V2DF") /* Vector of 2 64-bit double precision floats */
CIL_TYPEDEF(CIL_V4SF,"V4SF") /* Vector of 4 32-bit single precision floats */
+
+/* Integer Complex Types*/
+/* Complex of Signed 8-bit integer */
+CIL_TYPEDEF(CIL_CMPLXI8,"valuetype [gcc4net]gcc4net.complex_char")
+/* Complex of Signed 16-bit integer */
+CIL_TYPEDEF(CIL_CMPLXI16,"valuetype [gcc4net]gcc4net.complex_short")
+/* Complex of Signed 32-bit integer */
+CIL_TYPEDEF(CIL_CMPLXI32,"valuetype [gcc4net]gcc4net.complex_int")
+/* Complex of Signed 64-bit integer */
+CIL_TYPEDEF(CIL_CMPLXI64,"valuetype [gcc4net]gcc4net.complex_long")
+
+/* Complex of Unsigned 8-bit integer */
+CIL_TYPEDEF(CIL_CMPLXU8,"valuetype [gcc4net]gcc4net.complex_uchar")
+/* Complex of Unsigned 16-bit integer */
+CIL_TYPEDEF(CIL_CMPLXU16,"valuetype [gcc4net]gcc4net.complex_ushort")
+/* Complex of Unsigned 32-bit integer */
+CIL_TYPEDEF(CIL_CMPLXU32,"valuetype [gcc4net]gcc4net.complex_uint")
+/* Complex of Unsigned 64-bit integer */
+CIL_TYPEDEF(CIL_CMPLXU64,"valuetype [gcc4net]gcc4net.complex_ulong")
+
+/* floating-point Complex Types*/
+/* Complex of Single precision floating-point */
+CIL_TYPEDEF(CIL_CMPLXF32,"valuetype [gcc4net]gcc4net.complex_float")
+/* Complex of Double precision floating-point */
+CIL_TYPEDEF(CIL_CMPLXF64,"valuetype [gcc4net]gcc4net.complex_double")
diff --git a/gcc/config/cil32/emit-cil.c b/gcc/config/cil32/emit-cil.c
index b061c074c8d..a5c4f893035 100644
--- a/gcc/config/cil32/emit-cil.c
+++ b/gcc/config/cil32/emit-cil.c
@@ -113,8 +113,7 @@ static void dump_method_name(FILE *, tree);
static void dump_string_name (FILE *, tree);
static void dump_string_type (FILE *, tree);
static void dump_label_name (FILE *, tree);
-static void dump_vector_type (FILE *, tree);
-static void dump_complex_type (FILE *, tree);
+static void dump_vector_type (FILE *, cil_type_t);
static void dump_string_decl (FILE *, tree);
static bool dump_type_promoted_type_def (FILE *, tree);
@@ -492,14 +491,9 @@ dump_fun_type (FILE *file, tree fun_type, tree fun, const char *name, bool ref)
/* Dump vector type TYPE.
TYPE must be a type node of type VECTOR_TYPE. */
-
static void
-dump_vector_type (FILE *file, tree node)
+dump_vector_type (FILE *file, cil_type_t cil_type)
{
- cil_type_t cil_type;
-
- cil_type = vector_to_cil (node);
-
if (simd_type == MONO_SIMD)
{
/* Mono.Simd types */
@@ -529,48 +523,6 @@ dump_vector_type (FILE *file, tree node)
}
static void
-dump_complex_type (FILE *file, tree node)
-{
- tree elem_type;
- const char* suffix;
-
- gcc_assert (TREE_CODE (node) == COMPLEX_TYPE);
-
- elem_type = TYPE_MAIN_VARIANT (TREE_TYPE (node));
-
- switch (scalar_to_cil (elem_type))
- {
- case CIL_INT8: suffix = "char"; break;
- case CIL_INT16: suffix = "short"; break;
- case CIL_INT32: suffix = "int"; break;
- case CIL_INT64: suffix = "long"; break;
-
- case CIL_UNSIGNED_INT8: suffix = "uchar"; break;
- case CIL_UNSIGNED_INT16: suffix = "ushort"; break;
- case CIL_UNSIGNED_INT32: suffix = "uint"; break;
- case CIL_UNSIGNED_INT64: suffix = "ulong"; break;
-
- case CIL_FLOAT32: suffix = "float"; break;
- case CIL_FLOAT64: suffix = "double"; break;
-
- case CIL_FLOAT:
- {
- unsigned HOST_WIDE_INT size = tree_low_cst (TYPE_SIZE (elem_type), 1);
- gcc_assert (size == 32 || size == 64);
-
- if (size == 32) suffix = "float";
- else suffix = "double";
- }
- break;
-
- default:
- gcc_unreachable ();
- break;
- }
- fprintf (file, "valuetype [gcc4net]gcc4net.complex_%s", suffix);
-}
-
-static void
emit_enum_decl (FILE *file, tree t)
{
unsigned HOST_WIDE_INT size = tree_low_cst (TYPE_SIZE (t), 1);
@@ -756,23 +708,10 @@ dump_type (FILE *file, tree type, bool ref, bool qualif)
if (type == NULL_TREE || type == error_mark_node)
return;
- if (TYPE_MAIN_VARIANT (type) == cil32_arg_iterator_type)
- {
- fprintf (file, "valuetype [mscorlib]System.ArgIterator");
- return;
- }
- else if (TREE_CODE (type) == VOID_TYPE)
- {
- fprintf (file, "void");
- return;
- }
-
cil_type = type_to_cil (type);
if (cil_vector_p (cil_type))
- dump_vector_type (file, type);
- else if (TREE_CODE (type) == COMPLEX_TYPE)
- dump_complex_type (file, type);
+ dump_vector_type (file, cil_type);
else
switch (cil_type)
{
@@ -786,15 +725,6 @@ dump_type (FILE *file, tree type, bool ref, bool qualif)
dump_valuetype_name (file, TYPE_MAIN_VARIANT (type));
break;
- case CIL_FLOAT:
- {
- unsigned HOST_WIDE_INT size = tree_low_cst (TYPE_SIZE (type), 1);
-
- gcc_assert (size == 32 || size == 64);
- fprintf (file, "float" HOST_WIDE_INT_PRINT_UNSIGNED, size);
- }
- break;
-
case CIL_POINTER:
if (TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE)
{
@@ -913,7 +843,9 @@ dump_type_promoted_type_def (FILE *file, tree node)
cil_type = type_to_cil (node);
- if (cil_type == CIL_VALUE_TYPE)
+ if (cil_vector_p (cil_type))
+ dump_vector_type (file, cil_type);
+ else if (cil_type == CIL_VALUE_TYPE || cil_complex_p (cil_type))
dump_type (file, node, true, false);
else if (cil_int_or_smaller_p(cil_type))
fprintf (file, "class [mscorlib]System.UInt32");
@@ -1617,16 +1549,11 @@ emit_cil_stmt (FILE *file, const_cil_stmt stmt)
break;
case CIL_STRING:
{
- tree t = cil_string (stmt);
- const char *str;
- const char *str2;
- unsigned int len;
-
- str = TREE_STRING_POINTER (t);
- len = TREE_STRING_LENGTH (t);
+ const char *str = TREE_STRING_POINTER (cil_string (stmt));
+ const char *str2 = str;
fprintf (file, "\n\t// BEGIN ASM");
- for (str2 = str; str2[0] && ISSPACE(str2[0]); ++str2)
+ for (;str2[0] && ISSPACE(str2[0]); ++str2)
;
fprintf (file, "\n\t%s%s", (str2[0] == '#') ? "//" : "", str);
fprintf (file,"\n\t// END ASM");
diff --git a/gcc/config/cil32/t-cil32 b/gcc/config/cil32/t-cil32
index b07c6d4d2a5..d66f94913ce 100644
--- a/gcc/config/cil32/t-cil32
+++ b/gcc/config/cil32/t-cil32
@@ -120,6 +120,7 @@ emit-cil.o : $(srcdir)/config/cil32/emit-cil.c \
$(srcdir)/config/cil32/emit-hints.h \
$(srcdir)/config/cil32/cil-instr.def \
$(srcdir)/config/cil32/cil-types.def \
+ $(srcdir)/config/cil32/cil-builtins.h \
$(srcdir)/config/cil32/cil-refs.h \
$(srcdir)/config/cil32/cil-stack.h \
$(srcdir)/config/cil32/cil-stmt.h \