private static void DoAllocation(Code c, Stack <StackItem> stack, target.Target t) { long alloced = 0; int stack_loc = 0; foreach (var si in stack) { if (si.ct == Opcode.ct_vt) { si.reg = t.AllocateValueType(c, si.ts, ref alloced, ref stack_loc); } else if (si.has_address_taken) { int size = 0; if (si.ts.IsValueType) { size = layout.Layout.GetTypeSize(si.ts, t, false); } else { size = t.GetPointerSize(); } si.reg = t.AllocateStackLocation(c, size, ref stack_loc); } else { DoAllocation(c, si, t, ref alloced, ref stack_loc); } if (si.reg != null) { c.regs_used |= si.reg.mask; } } }
internal static target.Target.Reg DoAllocation(Code c, int ct, target.Target t, ref long alloced, ref int cur_stack) { // rationalise thread-local addresses to use the same registers as normal ones if (ct == Opcode.ct_tls_int32) { ct = Opcode.ct_int32; } else if (ct == Opcode.ct_tls_int64) { ct = Opcode.ct_int64; } else if (ct == Opcode.ct_tls_intptr) { ct = Opcode.ct_intptr; } long avail = t.ct_regs[ct] & ~alloced; if (avail != 0) { // We have a valid allocation to use int idx = 0; while ((avail & 0x1) == 0) { idx++; avail >>= 1; } var reg = t.regs[idx]; alloced |= (1L << idx); return(reg); } else { return(t.AllocateStackLocation(c, t.GetCTSize(ct), ref cur_stack)); } }