dn = src->dag_node;
v0 = dn->var;
- if (v0->nb_pointers + v0->nb_dimentions + (v0->type >= SCF_STRUCT) < 2)
- continue;
-
- if (i - 1 >= f2->argv->size)
- continue;
-
- scf_variable_t* v1 = f2->argv->data[i - 1];
-
- if (!v1->auto_gc_flag)
- continue;
-
- scf_logd("f2: %s, v0: %s, v1: %s\n",
- f2->node.w->text->data, v0->w->text->data, v1->w->text->data);
-
while (dn) {
if (SCF_OP_TYPE_CAST == dn->type)
dn = dn->childs->data[0];
break;
}
+ if (v0->nb_pointers + v0->nb_dimentions + (v0->type >= SCF_STRUCT) < 2) {
+ continue;
+ }
+
+ if (i - 1 >= f2->argv->size)
+ continue;
+
+ scf_variable_t* v1 = f2->argv->data[i - 1];
+
+ scf_logw("f2: %s, v0: %s, v1: %s\n",
+ f2->node.w->text->data, v0->w->text->data, v1->w->text->data);
+
+ if (!v1->auto_gc_flag)
+ continue;
+
ds_obj = NULL;
int ret;
{SCF_EDA_Battery, 0, SCF_EDA_Battery_POS, 0, 0, 0, 0, 0, 0, 0},
{SCF_EDA_Resistor, 0, 0, 0, 0, 10 * 1000, 0, 0, 0, 0},
- {SCF_EDA_Capacitor, 0, 0, 0, 0, 0, 0, 0.1, 0, 0},
+ {SCF_EDA_Capacitor, 0, 0, 0, 0, 1e12, 0, 0.1, 0, 0},
{SCF_EDA_Inductor, 0, 0, 0, 0, 0, 0, 0, 1000, 0},
};
void usage(char* path)
{
- fprintf(stderr, "Usage: %s [-c] [-a arch] [-o out] src0 [src1]\n\n", path);
- fprintf(stderr, "-c: only compile, not link\n");
+ fprintf(stderr, "Usage: %s [-c] [-t] [-a arch] [-o out] src0 [src1]\n\n", path);
+ fprintf(stderr, "-c: only compile, not link\n");
+ fprintf(stderr, "-t: only 3ac code, not compile\n");
fprintf(stderr, "-a: select cpu arch (x64, arm64, naja, or eda), default is x64\n");
}
char* out = NULL;
char* arch = "x64";
int link = 1;
+ int _3ac = 0;
int i;
continue;
}
+ if ('t' == argv[i][1]) {
+ link = 0;
+ _3ac = 1;
+ continue;
+ }
+
if ('a' == argv[i][1]) {
if (++i >= argc) {
exec = out;
}
- if (scf_parse_compile(parse, obj, arch) < 0) {
+ if (scf_parse_compile(parse, obj, arch, _3ac) < 0) {
scf_loge("\n");
return -1;
}
return 0;
}
-int scf_parse_compile_functions(scf_parse_t* parse, scf_native_t* native, scf_vector_t* functions)
+int scf_parse_compile_functions(scf_parse_t* parse, scf_vector_t* functions)
{
scf_function_t* f;
- int64_t tv0 = gettime();
int i;
for (i = 0; i < functions->size; i++) {
f = functions->data[i];
assert(scf_list_empty(&h));
scf_basic_block_print_list(&f->basic_block_list_head);
}
- int64_t tv1 = gettime();
- scf_logw("tv1 - tv0: %ld\n", tv1 - tv0);
int ret = scf_optimize(parse->ast, functions);
if (ret < 0) {
return ret;
}
- int64_t tv2 = gettime();
- scf_logw("tv2 - tv1: %ld\n", tv2 - tv1);
-#if 1
- for (i = 0; i < functions->size; i++) {
- f = functions->data[i];
-
- if (!f->node.define_flag)
- continue;
-
- int ret = scf_native_select_inst(native, f);
- if (ret < 0) {
- scf_loge("\n");
- return ret;
- }
- }
-#endif
-
- int64_t tv3 = gettime();
- scf_logw("tv3 - tv2: %ld\n", tv3 - tv2);
return 0;
}
return 0;
}
-int scf_parse_compile(scf_parse_t* parse, const char* out, const char* arch)
+int scf_parse_native_functions(scf_parse_t* parse, scf_vector_t* functions, scf_native_t* native)
+{
+ scf_function_t* f;
+
+ int i;
+
+ for (i = 0; i < functions->size; i++) {
+ f = functions->data[i];
+
+ if (!f->node.define_flag)
+ continue;
+
+ int ret = scf_native_select_inst(native, f);
+ if (ret < 0) {
+ scf_loge("\n");
+ return ret;
+ }
+ }
+
+ return 0;
+}
+
+int scf_parse_compile(scf_parse_t* parse, const char* out, const char* arch, int _3ac)
{
scf_block_t* b = parse->ast->root_block;
if (!b)
goto open_native_error;
}
- ret = scf_parse_compile_functions(parse, native, functions);
+ ret = scf_parse_compile_functions(parse, functions);
+ if (ret < 0) {
+ scf_loge("\n");
+ goto open_native_error;
+ }
+
+ if (_3ac)
+ return 0;
+
+ ret = scf_parse_native_functions(parse, functions, native);
if (ret < 0) {
scf_loge("\n");
goto open_native_error;
int scf_parse_file(scf_parse_t* parse, const char* path);
-int scf_parse_compile(scf_parse_t* parse, const char* out, const char* arch);
+int scf_parse_compile(scf_parse_t* parse, const char* out, const char* arch, int _3ac);
int _find_global_var(scf_node_t* node, void* arg, scf_vector_t* vec);
int _find_function (scf_node_t* node, void* arg, scf_vector_t* vec);