*/
#include "config.h"
-#ifdef HAVE_STDLIB_H
-# include <stdlib.h>
-#endif
-#ifdef HAVE_STRING_H
-# include <string.h>
-#endif
+#include <stdlib.h>
+#include <string.h>
-# include <stddef.h>
+#include <stddef.h>
-# include "irprog_t.h"
-# include "irmode_t.h"
-# include "ident.h"
-# include "tv_t.h"
-# include "obst.h"
-# include "irhooks.h"
-# include "irtools.h"
-# include "array.h"
+#include "irprog_t.h"
+#include "irmode_t.h"
+#include "ident.h"
+#include "tv_t.h"
+#include "obst.h"
+#include "irhooks.h"
+#include "irtools.h"
+#include "array.h"
+#include "error.h"
/** Obstack to hold all modes. */
static struct obstack modes;
/** The list of all currently existing modes. */
static ir_mode **mode_list;
+const char *get_mode_arithmetic_name(ir_mode_arithmetic ari)
+{
+#define X(a) case a: return #a
+ switch (ari) {
+ X(irma_uninitialized);
+ X(irma_none);
+ X(irma_twos_complement);
+ X(irma_ones_complement);
+ X(irma_int_BCD);
+ X(irma_ieee754);
+ X(irma_float_BCD);
+ default: return "<unknown>";
+ }
+#undef X
+}
+
/**
* Compare modes that don't need to have their code field
* correctly set
*
* TODO: Add other fields
**/
-static INLINE int modes_are_equal(const ir_mode *m, const ir_mode *n) {
+static inline int modes_are_equal(const ir_mode *m, const ir_mode *n) {
if (m == n) return 1;
if (m->sort == n->sort &&
m->arithmetic == n->arithmetic &&
case irms_control_flow:
case irms_memory:
case irms_internal_boolean:
- assert(0 && "internal modes cannot be user defined");
- break;
+ panic("internal modes cannot be user defined");
case irms_float_number:
case irms_int_number:
case irms_reference:
mode = register_mode(&mode_tmpl);
+ break;
}
+ assert(mode != NULL);
return mode;
}
case irms_control_flow:
case irms_memory:
case irms_internal_boolean:
- assert(0 && "internal modes cannot be user defined");
- break;
+ panic("internal modes cannot be user defined");
case irms_reference:
- assert(0 && "only integer and floating point modes can be vectorized");
- break;
+ panic("only integer and floating point modes can be vectorized");
case irms_float_number:
- assert(0 && "not yet implemented");
- break;
+ panic("not yet implemented");
case irms_int_number:
mode = register_mode(&mode_tmpl);
}
+ assert(mode != NULL);
return mode;
}
return get_tarval_nan(mode);
}
-int is_mode(void *thing) {
- if (get_kind(thing) == k_ir_mode)
- return 1;
- else
- return 0;
+int is_mode(const void *thing) {
+ return get_kind(thing) == k_ir_mode;
}
int (mode_is_signed)(const ir_mode *mode) {
break;
case irms_reference:
- /* do exist machines out there with different pointer lenghts ?*/
+ /* do exist machines out there with different pointer lengths ?*/
return 0;
case irms_internal_boolean:
newmode.name = new_id_from_chars("E", 1);
newmode.code = irm_E;
newmode.sign = 1;
- newmode.size = 80;
+ /* note that the tarval module is calculating with 80 bits, but we use
+ * 96 bits, as that is what will be stored to memory by most hardware */
+ newmode.size = 96;
mode_E = register_mode(&newmode);