// File: /workspace/github_c_makefile_star2_O3/lucvoo[P]sparse-dev/liveness.c
// Function: track_instruction_usage
static void track_instruction_usage(struct basic_block *bb, struct instruction *insn,
	void (*def)(struct basic_block *, pseudo_t),
	void (*use)(struct basic_block *, pseudo_t))
{
	pseudo_t pseudo;

	#define USES(x)		use(bb, insn->x)
	#define DEFINES(x)	def(bb, insn->x)

	switch (insn->opcode) {
	case OP_RET:
	case OP_COMPUTEDGOTO:
		USES(src);
		break;

	case OP_CBR:
	case OP_SWITCH:
		USES(cond);
		break;

	/* Binary */
	case OP_BINARY ... OP_BINARY_END:
	case OP_FPCMP ... OP_FPCMP_END:
	case OP_BINCMP ... OP_BINCMP_END:
		USES(src1); USES(src2); DEFINES(target);
		break;

	/* Uni */
	case OP_UNOP ... OP_UNOP_END:
	case OP_SYMADDR:
	case OP_SLICE:
		USES(src); DEFINES(target);
		break;

	case OP_SEL:
		USES(src1); USES(src2); USES(src3); DEFINES(target);
		break;
	
	/* Memory */
	case OP_LOAD:
		USES(src); DEFINES(target);
		break;

	case OP_STORE:
		USES(src); USES(target);
		break;

	case OP_LABEL:
	case OP_SETVAL:
	case OP_SETFVAL:
		DEFINES(target);
		break;

	/* Other */
	case OP_PHI:
		/* Phi-nodes are "backwards" nodes. Their def doesn't matter */
		phi_defines(insn, insn->target, def);
		break;

	case OP_PHISOURCE:
		/*
		 * We don't care about the phi-source define, they get set
		 * up and expanded by the OP_PHI
		 */
		USES(phi_src);
		break;

	case OP_CALL:
		USES(func);
		if (insn->target != VOID)
			DEFINES(target);
		FOR_EACH_PTR(insn->arguments, pseudo) {
			use(bb, pseudo);
		} END_FOR_EACH_PTR(pseudo);
		break;

	case OP_ASM:
		asm_liveness(bb, insn, def, use);
		break;

	case OP_RANGE:
		USES(src1); USES(src2); USES(src3);
		break;

	case OP_BADOP:
	case OP_NOP:
	case OP_CONTEXT:
		break;
	}
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movl (%rsi), %eax
andl $0x7f, %eax
addl $-0x2, %eax
cmpl $0x4e, %eax
ja 0x3dcea
movq %rcx, %r13
movq %rsi, %r14
movq %rdi, %rbx
leaq 0xd8b7(%rip), %rcx      # 0x4b4c4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x30(%r14), %rsi
movq %rbx, %rdi
movq %rdx, %r15
callq *%r13
movq 0x38(%r14), %rsi
movq %rbx, %rdi
jmp 0x3dc36
movq 0x30(%r14), %rsi
movq %rbx, %rdi
movq %rdx, %r15
callq *%r13
movq 0x20(%r14), %rsi
movq %rbx, %rdi
movq %r15, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmpq *%rax
movq 0x30(%r14), %rsi
movq %rbx, %rdi
movq %r13, %rax
jmp 0x3dc43
movq 0x20(%r14), %rsi
movq %rbx, %rdi
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmpq *%rdx
movq 0x30(%r14), %rsi
movq %rbx, %rdi
callq *%r13
movq 0x20(%r14), %rsi
jmp 0x3dc52
movq %rdx, %r15
movq 0x30(%r14), %rsi
movq %rbx, %rdi
callq *%r13
movq 0x20(%r14), %rsi
cmpq 0x22304(%rip), %rsi     # 0x5ff98
je 0x3dc9c
movq %rbx, %rdi
callq *%r15
movq 0x38(%r14), %r14
testq %r14, %r14
je 0x3dcea
movq %r14, %r15
movzwl (%r15), %eax
testb %al, %al
jle 0x3dce1
xorl %r12d, %r12d
movq 0x18(%r15,%r12,8), %rsi
movzwl %ax, %ecx
cmpl $0x100, %ecx            # imm = 0x100
jb 0x3dcc8
testq %rsi, %rsi
je 0x3dcd2
movq %rbx, %rdi
callq *%r13
movzwl (%r15), %eax
incq %r12
movzwl %ax, %ecx
movsbq %cl, %rcx
cmpq %rcx, %r12
jl 0x3dcb3
movq 0x10(%r15), %r15
cmpq %r14, %r15
jne 0x3dca8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq 0x30(%r14), %rsi
movq %rbx, %rdi
movq %rdx, %r15
callq *%r13
movq 0x38(%r14), %rsi
movq %rbx, %rdi
callq *%r13
movq 0x40(%r14), %rsi
jmp 0x3dc27
movq 0x30(%r14), %rsi
movq %rbx, %rdi
callq *%r13
movq 0x38(%r14), %rsi
movq %rbx, %rdi
callq *%r13
movq 0x40(%r14), %rsi
jmp 0x3dc52
movq 0x20(%r14), %rsi
movq 0x38(%r14), %rdi
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x3e23a
movq %rbx, %rdi
movq %r14, %rsi
movq %r13, %rcx
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x3e2d1