+}
+
+#define ALIGN_SPILL_AREA 16
+#define pset_foreach(pset, elm) for(elm=pset_first(pset); elm; elm=pset_next(pset))
+
+/**
+ * Returns a spill type for a mode. Keep them in a map to reduce
+ * the number of types.
+ */
+static ir_type *get_spill_type(pmap *types, ir_mode *mode) {
+ pmap_entry *e = pmap_find(types, mode);
+ ir_type *res;
+
+ if (! e) {
+ char buf[64];
+ snprintf(buf, sizeof(buf), "spill_slot_type_%s", get_mode_name(mode));
+ res = new_type_primitive(new_id_from_str(buf), mode);
+ pmap_insert(types, mode, res);
+ }
+ else
+ res = e->value;
+ return res;
+}
+
+static void assign_entities(ss_env_t *ssenv, int n, spill_slot_t **ss) {
+ int i, offset;
+ ir_type *frame = get_irg_frame_type(ssenv->cenv->irg);
+
+ /* aligning by increasing frame size */
+ offset = get_type_size_bits(frame) / 8;
+ offset = round_up2(offset, ALIGN_SPILL_AREA);
+ set_type_size_bytes(frame, -1);
+
+ /* create entities and assign offsets according to size and alignment*/
+ for (i=0; i<n; ++i) {
+ char buf[64];
+ ident *name;
+ entity *spill_ent;
+ ir_node *irn;
+
+ /* build entity */
+ snprintf(buf, sizeof(buf), "spill_slot_%d", i);
+ name = new_id_from_str(buf);