Esempio n. 1
0
static void sparc_sp_sim(ir_node *const node, stack_pointer_state_t *state)
{
	sparc_determine_frameoffset(node, state->offset);

	if (is_sparc_Save(node)) {
		sparc_attr_t *const attr = get_sparc_attr(node);
		if (get_irn_arity(node) == 3)
			panic("no support for _reg variant yet");

		/* Adjust for alignment */
		assert(state->misalign == 0);
		int const prev_offset = state->offset;
		int const new_offset  = prev_offset - state->align_padding
		                        - attr->immediate_value;
		int const aligned     = round_up2(new_offset, 1u << state->p2align);
		attr->immediate_value = -(aligned - prev_offset);
		state->align_padding  = aligned - new_offset;
		state->offset         = aligned;
	} else if (is_sparc_SubSP(node) || is_sparc_AddSP(node)) {
		state->align_padding = 0;
	} else if (is_sparc_RestoreZero(node)) {
		state->offset        = 0;
		state->align_padding = 0;
	}
}
Esempio n. 2
0
static void process_bias(ir_node *block, bool omit_fp, int bias, int free_bytes)
{
	mark_Block_block_visited(block);

	/* process schedule */
	sched_foreach(block, irn) {
		/* set bias to nodes with entities */
		ir_entity *entity = sparc_get_frame_entity(irn);
		if (entity != NULL) {
			int offset = get_entity_offset(entity);
			if (omit_fp)
				offset += bias + SPARC_MIN_STACKSIZE;
			sparc_set_frame_offset(irn, offset);
		}

		/* The additional alignment bytes cannot be used
		 * anymore after alloca. */
		if (is_sparc_SubSP(irn)) {
			free_bytes = 0;
		} else if (is_sparc_AddSP(irn)) {
			assert(free_bytes == 0);
		}

		int irn_bias = sparc_get_sp_bias(irn);
		if (irn_bias == 0) {
			/* do nothing */
		} else if (irn_bias == SP_BIAS_RESET) {
			bias = 0;
		} else {
			/* adjust values to respect stack alignment */
			irn_bias -= free_bytes;

			int new_bias_unaligned = bias + irn_bias;
			int new_bias_aligned
				= round_up2(new_bias_unaligned, SPARC_STACK_ALIGNMENT);
			free_bytes = new_bias_aligned - new_bias_unaligned;
			set_irn_sp_bias(irn, new_bias_aligned - bias);
			bias = new_bias_aligned;
		}
	}