--- /dev/null
+int printf(const char* fmt, ...);
+
+int Apt(int i, int j);
+
+struct Aops
+{
+ Apt* pt0;
+ Apt* pt1;
+};
+
+int add(int i, int j)
+{
+ return i + j;
+}
+
+int sub(int i, int j)
+{
+ return i - j;
+}
+
+Aops aops =
+{
+ add,
+ sub,
+};
+
+int main()
+{
+ int a = aops->pt0(3, 1);
+ int b = aops->pt1(3, 1);
+
+ printf("a: %d, b: %d\n", a, b);
+ return 0;
+}
} else if (SCF_X64_MUL == OpCode->type
|| SCF_X64_DIV == OpCode->type
|| SCF_X64_IMUL == OpCode->type
- || SCF_X64_IDIV == OpCode->type)
+ || SCF_X64_IDIV == OpCode->type
+ || SCF_X64_CALL == OpCode->type)
inst->src.base = (scf_register_t*)r;
return inst;
} else if (SCF_X64_MUL == OpCode->type
|| SCF_X64_DIV == OpCode->type
|| SCF_X64_IMUL == OpCode->type
- || SCF_X64_IDIV == OpCode->type) {
+ || SCF_X64_IDIV == OpCode->type
+ || SCF_X64_CALL == OpCode->type) {
inst->src.base = (scf_register_t*)r_base;
inst->src.disp = offset;
offset = v_dst->offset;
}
- inst = _x64_make_OpCode(OpCode, v_dst->size, r_src, r_base, NULL);
+ inst = _x64_make_OpCode(OpCode, x64_variable_size(v_dst), r_src, r_base, NULL);
if (!inst)
return NULL;
if (X64_COLOR_CONFLICT(r0->color, rdi->color)
|| X64_COLOR_CONFLICT(r0->color, rsi->color)
|| X64_COLOR_CONFLICT(r0->color, rdx->color)
- || X64_COLOR_CONFLICT(r0->color, rcx->color))
+ || X64_COLOR_CONFLICT(r0->color, rcx->color)
+ || X64_COLOR_CONFLICT(r0->color, r8->color)
+ || X64_COLOR_CONFLICT(r0->color, r9->color))
break;
} else {
if (x64_inst_data_is_reg(&inst2->src)) {
{
scf_variable_t* vb = base ->var;
scf_variable_t* vm = member->var;
- scf_register_t* rb = NULL;
+ scf_register_t* rb = NULL;
scf_x64_OpCode_t* lea;
scf_x64_OpCode_t* mov;
} else if (vb->global_flag) {
scf_rela_t* rela = NULL;
- ret = x64_select_reg(&rb, base, c, f, 0);
+ ret = x64_select_reg(&rb, base, c, f, 1);
if (ret < 0) {
scf_loge("\n");
return ret;
}
- lea = x64_find_OpCode(SCF_X64_LEA, 8, 8, SCF_X64_E2G);
- inst = x64_make_inst_M2G(&rela, lea, rb, NULL, vb);
- X64_INST_ADD_CHECK(c->instructions, inst);
- X64_RELA_ADD_CHECK(f->data_relas, rela, c, vb, NULL);
-
} else {
ret = x64_select_reg(&rb, base, c, f, 0);
if (ret < 0) {
if (0 == base->color)
base->color = -1;
- ret = x64_select_reg(&rb, base, c, f, 0);
+ ret = x64_select_reg(&rb, base, c, f, 1);
if (ret < 0) {
scf_loge("\n");
return ret;
}
- lea = x64_find_OpCode(SCF_X64_LEA, 8, 8, SCF_X64_E2G);
- inst = x64_make_inst_M2G(&rela, lea, rb, NULL, vb);
- X64_INST_ADD_CHECK(c->instructions, inst);
- X64_RELA_ADD_CHECK(f->data_relas, rela, c, vb, NULL);
-
} else {
ret = x64_select_reg(&rb, base, c, f, 0);
if (ret < 0) {
if (!call)
return 0;
- else if (SCF_OP_CALL == call->type) {
- scf_variable_t* v_pf = _scf_operand_get(call->nodes[0]);
+ if (SCF_OP_CALL == call->type) {
+
+ scf_node_t* n_pf = call->nodes[0];
+
+ if (SCF_OP_POINTER == n_pf->type) {
+ assert(2 == n_pf->nb_nodes);
+
+ n_pf = n_pf->nodes[1];
+ }
+
+ scf_variable_t* v_pf = _scf_operand_get(n_pf);
scf_function_t* f = v_pf->func_ptr;
if (f->rets->size <= 1)