示例#1
0
void test_instruction_positions_are_computed_in_basic_block_order(void)
{
	struct compilation_unit *cu = compilation_unit_alloc(&method);
	struct basic_block *b1, *b2;
	struct insn *insns[4];
	unsigned long i;

	for (i = 0; i < ARRAY_SIZE(insns); i++)
		insns[i] = alloc_insn(INSN_ADD);

	b1 = get_basic_block(cu, 0, ARRAY_SIZE(insns)/2);
	for (i = 0 ; i < ARRAY_SIZE(insns) / 2; i++)
		bb_add_insn(b1, insns[i]);

	b2 = get_basic_block(cu, ARRAY_SIZE(insns) / 2, ARRAY_SIZE(insns));
	for (i = ARRAY_SIZE(insns) / 2 ; i < ARRAY_SIZE(insns); i++)
		bb_add_insn(b2, insns[i]);

	compute_insn_positions(cu);

	for (i = 0; i < ARRAY_SIZE(insns); i++)
		assert_int_equals(i * 2, insns[i]->lir_pos);

	free_compilation_unit(cu);
}
示例#2
0
文件: instruction.c 项目: th2o/jato
struct insn *reverse_reg_insn(enum insn_type insn_type, struct var_info *reg)
{
	struct insn *insn = alloc_insn(insn_type);

	if (insn)
		init_reg_operand(insn, &insn->dest, reg);

	return insn;
}
示例#3
0
文件: instruction.c 项目: th2o/jato
struct insn *membase_insn(enum insn_type insn_type, struct var_info *src_base_reg, long src_disp)
{
	struct insn *insn = alloc_insn(insn_type);

	if (insn)
		init_membase_operand(insn, &insn->operand, src_base_reg, src_disp);

	return insn;
}
示例#4
0
文件: instruction.c 项目: th2o/jato
struct insn *reverse_memindex_insn(enum insn_type insn_type, struct var_info *dst_base_reg, struct var_info *dst_index_reg, unsigned char dst_shift)
{
	struct insn *insn = alloc_insn(insn_type);

	if (insn)
		init_memindex_operand(insn, &insn->dest, dst_base_reg, dst_index_reg, dst_shift);

	return insn;
}
示例#5
0
文件: instruction.c 项目: th2o/jato
struct insn *memindex_insn(enum insn_type insn_type, struct var_info *src_base_reg, struct var_info *src_index_reg, unsigned char src_shift)
{
	struct insn *insn = alloc_insn(insn_type);

	if (insn)
		init_memindex_operand(insn, &insn->operand, src_base_reg, src_index_reg, src_shift);

	return insn;
}
示例#6
0
文件: instruction.c 项目: th2o/jato
struct insn *reverse_membase_insn(enum insn_type insn_type, struct var_info *dst_base_reg, long dst_disp)
{
	struct insn *insn = alloc_insn(insn_type);

	if (insn)
		init_membase_operand(insn, &insn->dest, dst_base_reg, dst_disp);

	return insn;
}
示例#7
0
文件: instruction.c 项目: th2o/jato
struct insn *reg_reg_insn(enum insn_type insn_type, struct var_info *src, struct var_info *dest)
{
	struct insn *insn = alloc_insn(insn_type);

	if (insn) {
		init_reg_operand(insn, &insn->src, src);
		init_reg_operand(insn, &insn->dest, dest);
	}
	return insn;
}
示例#8
0
文件: instruction.c 项目: th2o/jato
struct insn *membase_reg_insn(enum insn_type insn_type, struct var_info *src_base_reg,
			      long src_disp, struct var_info *dest_reg)
{
	struct insn *insn = alloc_insn(insn_type);

	if (insn) {
		init_membase_operand(insn, &insn->src, src_base_reg, src_disp);
		init_reg_operand(insn, &insn->dest, dest_reg);
	}
	return insn;
}
示例#9
0
文件: instruction.c 项目: th2o/jato
struct insn *memindex_reg_insn(enum insn_type insn_type,
			       struct var_info *src_base_reg, struct var_info *src_index_reg,
			       unsigned char src_shift, struct var_info *dest_reg)
{
	struct insn *insn = alloc_insn(insn_type);

	if (insn) {
		init_memindex_operand(insn, &insn->src, src_base_reg, src_index_reg, src_shift);
		init_reg_operand(insn, &insn->dest, dest_reg);
	}
	return insn;
}
示例#10
0
文件: instruction.c 项目: th2o/jato
struct insn *rel_insn(enum insn_type insn_type, unsigned long rel)
{
	struct insn *insn = alloc_insn(insn_type);

	if (insn) {
		insn->operand	= (struct operand) {
			.type		= OPERAND_REL,
			{
				.rel		= rel,
			}
		};
	}
	return insn;
}
示例#11
0
文件: instruction.c 项目: th2o/jato
struct insn *imm_insn(enum insn_type insn_type, unsigned long imm)
{
	struct insn *insn = alloc_insn(insn_type);

	if (insn) {
		insn->operand	= (struct operand) {
			.type		= OPERAND_IMM,
			{
				.imm		= imm,
			}
		};
	}
	return insn;
}
示例#12
0
文件: instruction.c 项目: th2o/jato
struct insn *branch_insn(enum insn_type insn_type, struct basic_block *if_true)
{
	struct insn *insn = alloc_insn(insn_type);

	if (insn) {
		insn->operand	= (struct operand) {
			.type		= OPERAND_BRANCH,
			{
				.branch_target	= if_true,
			}
		};
	}
	return insn;
}
示例#13
0
文件: instruction.c 项目: th2o/jato
struct insn *memlocal_insn(enum insn_type insn_type, struct stack_slot *slot)
{
	struct insn *insn = alloc_insn(insn_type);

	if (insn) {
		insn->src	= (struct operand) {
			.type		= OPERAND_MEMLOCAL,
			{
				.slot		= slot,
			}
		};
	}

	return insn;
}
示例#14
0
文件: instruction.c 项目: th2o/jato
struct insn *reg_memdisp_insn(enum insn_type insn_type,
			      struct var_info *src_reg, unsigned long imm)
{
	struct insn *insn = alloc_insn(insn_type);

	if (insn) {
		init_reg_operand(insn, &insn->src, src_reg);
		insn->dest	= (struct operand) {
			.type		= OPERAND_IMM,
			{
				.imm		= imm,
			}
		};
	}
	return insn;
}
示例#15
0
文件: instruction.c 项目: th2o/jato
struct insn *imm_reg_insn(enum insn_type insn_type, unsigned long imm,
			  struct var_info *dest_reg)
{
	struct insn *insn = alloc_insn(insn_type);

	if (insn) {
		insn->src	= (struct operand) {
			.type		= OPERAND_IMM,
			{
				.imm		= imm,
			}
		};
		init_reg_operand(insn, &insn->dest, dest_reg);
	}
	return insn;
}
示例#16
0
文件: instruction.c 项目: th2o/jato
struct insn *phi_insn(enum insn_type insn_type, struct var_info *var, unsigned long nr_srcs)
{
	struct insn *insn = alloc_insn(insn_type);
	unsigned long ndx;

	if (insn) {
		init_phi_reg_operand(insn, &insn->ssa_dest, var);

		insn->ssa_srcs = malloc(nr_srcs * sizeof(struct operand));
		for (ndx = 0; ndx < nr_srcs; ndx++)
			init_phi_reg_operand(insn, &insn->ssa_srcs[ndx], var);

		insn->nr_srcs = nr_srcs;
	}
	return insn;
}
示例#17
0
文件: instruction.c 项目: th2o/jato
struct insn *imm_membase_insn(enum insn_type insn_type, unsigned long imm,
			      struct var_info *base_reg, long disp)
{
	struct insn *insn = alloc_insn(insn_type);

	if (insn) {
		insn->src	= (struct operand) {
			.type		= OPERAND_IMM,
			{
				.imm		= imm,
			}
		};
		init_membase_operand(insn, &insn->dest, base_reg, disp);
	}
	return insn;
}
示例#18
0
文件: instruction.c 项目: th2o/jato
struct insn *
reg_memlocal_insn(enum insn_type insn_type, struct var_info *src_reg,
		  struct stack_slot *dest_slot)
{
	struct insn *insn = alloc_insn(insn_type);

	if (insn) {
		init_reg_operand(insn, &insn->src, src_reg);
		insn->dest	= (struct operand) {
			.type		= OPERAND_MEMLOCAL,
			{
				.slot		= dest_slot,
			}
		};
	}
	return insn;
}
示例#19
0
文件: instruction.c 项目: th2o/jato
struct insn *imm_memdisp_insn(enum insn_type insn_type, long imm, long disp)
{
	struct insn *insn = alloc_insn(insn_type);

	if (insn) {
		insn->src	= (struct operand) {
			.type		= OPERAND_IMM,
			{
				.imm		= imm,
			}
		};
		insn->dest	= (struct operand) {
			.type		= OPERAND_MEMDISP,
		};
		insn->dest.disp		= disp;
	}
	return insn;
}
示例#20
0
文件: instruction.c 项目: th2o/jato
struct insn *imm_memlocal_insn(enum insn_type insn_type,
			       unsigned long imm,
			       struct stack_slot *dst_slot)
{
	struct insn *insn = alloc_insn(insn_type);

	if (insn) {
		insn->src	= (struct operand) {
			.type		= OPERAND_IMM,
			{
				.imm		= imm,
			}
		};
		insn->dest	= (struct operand) {
			.type		= OPERAND_MEMLOCAL,
			{
				.slot		= dst_slot,
			}
		};
	}
	return insn;
}
示例#21
0
文件: instruction.c 项目: th2o/jato
struct insn *insn(enum insn_type insn_type)
{
	return alloc_insn(insn_type);
}
示例#22
0
文件: instruction.c 项目: th2o/jato
				.imm		= imm,
			}
		};
		insn->dest	= (struct operand) {
			.type		= OPERAND_MEMLOCAL,
			{
				.slot		= dst_slot,
			}
		};
	}
	return insn;
}

struct insn *ic_call_insn(struct var_info *this, unsigned long imm)
{
	struct insn *insn = alloc_insn(INSN_IC_CALL);

	if (insn) {
		init_reg_operand(insn, &insn->src, this);
		assert(insn_operand_use_kind(insn, &insn->src) == USE_KIND_INPUT);
		insn->dest	= (struct operand) {
			.type		= OPERAND_IMM,
			{
				.imm		= imm,
			}
		};
	}

	return insn;
}