Ejemplo n.º 1
0
static void
assert_emit_target_for_backward_branches(unsigned char expected_prefix,
					 unsigned char expected_opc,
					 enum insn_type insn_type)
{
	struct basic_block *target_bb;
	struct compilation_unit *cu;
	struct var_info *eax, *ebx;

	cu = compilation_unit_alloc(&method);
	eax = get_fixed_var(cu, MACH_REG_EAX);
	ebx = get_fixed_var(cu, MACH_REG_EBX);

	target_bb = get_basic_block(cu, 0, 1);

	bb_add_insn(target_bb, imm_reg_insn(INSN_ADD_IMM_REG, 0x01, eax));
	assert_emits_branch_target(expected_prefix, expected_opc, 0xf8, 0xff, 0xff, 0xff, target_bb, insn_type);

	bb_add_insn(target_bb, imm_reg_insn(INSN_ADD_IMM_REG, 0x02, ebx));
	assert_emits_branch_target(expected_prefix, expected_opc, 0xf5, 0xff, 0xff, 0xff, target_bb, insn_type);

	free_compilation_unit(cu);
}
Ejemplo n.º 2
0
void test_honors_fixed_interval_register_constraint_for_overlapping_intervals(void)
{
	struct compilation_unit *cu;
	struct var_info *v1, *v2;

	cu = compilation_unit_alloc(&method);

	v1 = get_fixed_var(cu, R0);
	v1->interval->range.start = 0;
	v1->interval->range.end   = 2;

	v2 = get_var(cu);
	v2->interval->range.start = 0;
	v2->interval->range.end   = 2;

	allocate_registers(cu);

	assert_int_equals(R0, v1->interval->reg);
	assert_int_equals(R1, v2->interval->reg);

	free_compilation_unit(cu);
}
Ejemplo n.º 3
0
static void
assert_backpatches_unresolved_branches_when_emitting_target(
		unsigned char expected_prefix,
		unsigned char expected_opc,
		enum insn_type insn_type)
{
	struct basic_block *target_bb, *branch_bb;
	struct compilation_unit *cu;
	struct var_info *eax;

	cu = compilation_unit_alloc(&method);
	eax = get_fixed_var(cu, MACH_REG_EAX);

	branch_bb = get_basic_block(cu, 0, 1);
	target_bb = get_basic_block(cu, 1, 2);

	bb_add_insn(branch_bb, branch_insn(insn_type, target_bb));
	assert_backpatches_branches(expected_prefix, expected_opc, 0x00, branch_bb, target_bb);

	bb_add_insn(branch_bb, imm_reg_insn(INSN_ADD_IMM_REG, 0x01, eax));
	assert_backpatches_branches(expected_prefix, expected_opc, 0x03, branch_bb, target_bb);

	free_compilation_unit(cu);
}