summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2020-07-18 11:07:49 +0200
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2020-07-18 11:07:49 +0200
commite8dc61312304363144da2c2062367360dd4671bd (patch)
tree33025ca54312250debd9de7ea6b0ffa36ce0b8d9
parent78c929fb325927a103d239e8181abdb0524f9dca (diff)
-rw-r--r--src/bin/eolian/sources.c20
-rw-r--r--src/compiler-plugins/myplugin.cc28
2 files changed, 28 insertions, 20 deletions
diff --git a/src/bin/eolian/sources.c b/src/bin/eolian/sources.c
index f4f5185476..564fd334a5 100644
--- a/src/bin/eolian/sources.c
+++ b/src/bin/eolian/sources.c
@@ -930,7 +930,6 @@ _gen_func(const Eolian_Class *cl, const Eolian_Function *fid,
930 if (internal && !eolian_function_is_static(fid) && !eolian_implement_is_pure_virtual(impl, ftype) && !is_empty) 930 if (internal && !eolian_function_is_static(fid) && !eolian_implement_is_pure_virtual(impl, ftype) && !is_empty)
931 { 931 {
932 /* T _class_name[_orig_class]_func_name_suffix */ 932 /* T _class_name[_orig_class]_func_name_suffix */
933 eina_strbuf_append(buf, "EAPI ");
934 eina_strbuf_append(buf, rtpn); 933 eina_strbuf_append(buf, rtpn);
935 if (rtpn[strlen(rtpn) - 1] != '*') 934 if (rtpn[strlen(rtpn) - 1] != '*')
936 eina_strbuf_append_char(buf, ' '); 935 eina_strbuf_append_char(buf, ' ');
@@ -1182,14 +1181,15 @@ _is_function_type_compatible(const Eolian_Function_Type t1, const Eolian_Functio
1182 * 1181 *
1183 */ 1182 */
1184static void 1183static void
1185_gen_next_super_implementation_registering(Eina_Array *call_chain, const Eolian_Class *impl_klass, const Eolian_Implement *impl, const Eolian_Function_Type ftype, const Eolian_Function *fid, Eina_Strbuf *buf) 1184_gen_next_super_implementation_registering(Eina_Array *call_chain, const Eolian_Class *current, const Eolian_Implement *impl, const Eolian_Function_Type ftype, const Eolian_Function *fid, Eina_Strbuf *buf)
1186{ 1185{
1187 const Eolian_Class *next_implemen_class = NULL; 1186 const Eolian_Class *next_implemen_class = NULL;
1188 const Eolian_Class *definition_class = eolian_function_class_get(fid); 1187 const Eolian_Class *definition_class = eolian_function_class_get(fid);
1189 char *impl_name; 1188 char *impl_name;
1190 char *defi_name; 1189 char *defi_name;
1190 char *current_name;
1191 1191
1192 if (eolian_class_type_get(impl_klass) == EOLIAN_CLASS_MIXIN) 1192 if (eolian_class_type_get(current) == EOLIAN_CLASS_MIXIN)
1193 { 1193 {
1194 //mixins cannot fast forward to a fixed implementation, so we cannot register there anything sane 1194 //mixins cannot fast forward to a fixed implementation, so we cannot register there anything sane
1195 return; 1195 return;
@@ -1213,6 +1213,7 @@ _gen_next_super_implementation_registering(Eina_Array *call_chain, const Eolian_
1213 1213
1214 if (!next_implemen_class) return; 1214 if (!next_implemen_class) return;
1215 1215
1216 eo_gen_class_names_get(current, NULL, NULL, &current_name);
1216 eo_gen_class_names_get(next_implemen_class, NULL, NULL, &impl_name); 1217 eo_gen_class_names_get(next_implemen_class, NULL, NULL, &impl_name);
1217 eo_gen_class_names_get(definition_class, NULL, NULL, &defi_name); 1218 eo_gen_class_names_get(definition_class, NULL, NULL, &defi_name);
1218 1219
@@ -1225,7 +1226,12 @@ _gen_next_super_implementation_registering(Eina_Array *call_chain, const Eolian_
1225 else if (ftype == EOLIAN_PROP_SET) 1226 else if (ftype == EOLIAN_PROP_SET)
1226 prefix = "_set"; 1227 prefix = "_set";
1227 1228
1228 eina_strbuf_append_printf(buf, "COMPILER_PLUGIN_REGISTER_NEXT(\"%s\", \"%s\", ", eolian_function_full_c_name_get(fid, ftype), class_name); 1229 eina_strbuf_append_printf(buf, "COMPILER_PLUGIN_REGISTER_NEXT(\"%s\", ", eolian_function_full_c_name_get(fid, ftype));
1230 eina_strbuf_append_printf(buf, "\"%s_pd_offset\", ", current_name);
1231 if (eolian_class_type_get(next_implemen_class) == EOLIAN_CLASS_MIXIN)
1232 eina_strbuf_append_printf(buf, "\"%s_%s_pd_offset\", ", current_name, class_name);
1233 else
1234 eina_strbuf_append_printf(buf, "\"%s_pd_offset\", ", class_name);
1229 eina_strbuf_append_printf(buf, "\"_NEVA_USE_ME_internal_%s", impl_name); 1235 eina_strbuf_append_printf(buf, "\"_NEVA_USE_ME_internal_%s", impl_name);
1230 if (definition_class != next_implemen_class) 1236 if (definition_class != next_implemen_class)
1231 eina_strbuf_append_printf(buf, "_%s", defi_name); 1237 eina_strbuf_append_printf(buf, "_%s", defi_name);
@@ -1356,7 +1362,7 @@ eo_gen_source_gen(const Eolian_Class *cl, Eina_Strbuf *buf)
1356 { 1362 {
1357 Eolian_Class *called = eina_array_data_get(call_chain, i); 1363 Eolian_Class *called = eina_array_data_get(call_chain, i);
1358 if (eolian_class_type_get(called) != EOLIAN_CLASS_MIXIN) 1364 if (eolian_class_type_get(called) != EOLIAN_CLASS_MIXIN)
1359 break; 1365 continue;
1360 eina_strbuf_append_printf(name, "unsigned int %s_%s_pd_offset = -1;\n", eolian_class_c_name_get(cl), eolian_class_c_name_get(called)); 1366 eina_strbuf_append_printf(name, "unsigned int %s_%s_pd_offset = -1;\n", eolian_class_c_name_get(cl), eolian_class_c_name_get(called));
1361 eina_strbuf_tolower(name); 1367 eina_strbuf_tolower(name);
1362 eina_strbuf_append_buffer(buf, name); 1368 eina_strbuf_append_buffer(buf, name);
@@ -1417,9 +1423,9 @@ eo_gen_source_gen(const Eolian_Class *cl, Eina_Strbuf *buf)
1417 1423
1418 /* create macro for COMPILER_PLUGIN_REGISTER_NEXT */ 1424 /* create macro for COMPILER_PLUGIN_REGISTER_NEXT */
1419 eina_strbuf_append(buf, "#ifdef COMPILER_PLUGIN_REGISTER_NEXT_SUPPORT\n"); 1425 eina_strbuf_append(buf, "#ifdef COMPILER_PLUGIN_REGISTER_NEXT_SUPPORT\n");
1420 eina_strbuf_append(buf, " #define COMPILER_PLUGIN_REGISTER_NEXT(a, b, c, d) __attribute__((register_next(a, b, c, d)))\n"); 1426 eina_strbuf_append(buf, " #define COMPILER_PLUGIN_REGISTER_NEXT(a, b, c, d, e) __attribute__((register_next(a, b, c, d)))\n");
1421 eina_strbuf_append(buf, "#else\n"); 1427 eina_strbuf_append(buf, "#else\n");
1422 eina_strbuf_append(buf, " #define COMPILER_PLUGIN_REGISTER_NEXT(a, b, c, d) /* NOP */\n"); 1428 eina_strbuf_append(buf, " #define COMPILER_PLUGIN_REGISTER_NEXT(a, b, c, d, e) /* NOP */\n");
1423 eina_strbuf_append(buf, "#endif\n"); 1429 eina_strbuf_append(buf, "#endif\n");
1424 1430
1425 1431
diff --git a/src/compiler-plugins/myplugin.cc b/src/compiler-plugins/myplugin.cc
index b183432f6e..d7b084721e 100644
--- a/src/compiler-plugins/myplugin.cc
+++ b/src/compiler-plugins/myplugin.cc
@@ -125,8 +125,12 @@ static Caller fetch_efl_super_class(const_gimple stmt)
125 125
126struct Registered_Api{ 126struct Registered_Api{
127 bool valid; 127 bool valid;
128 tree call;
129 tree pd_minus_field;
130 tree pd_plus_field;
128 tree replacement_candidate; 131 tree replacement_candidate;
129 tree provider_of_replacement_candidate; 132
133 bool is_mixin;
130}; 134};
131 135
132static Registered_Api 136static Registered_Api
@@ -145,12 +149,12 @@ fetch_replacement_api(tree klass_decl, const char* called_api)
145 continue; 149 continue;
146 //this here assumes a special tree_list structure 150 //this here assumes a special tree_list structure
147 tree attribute_arguments = TREE_VALUE(attribute); 151 tree attribute_arguments = TREE_VALUE(attribute);
148 tree call = TREE_VALUE(attribute_arguments); 152 result.call = TREE_VALUE(attribute_arguments);
149 tree providing_class = TREE_VALUE(TREE_CHAIN(attribute_arguments)); 153 result.pd_minus_field = TREE_VALUE(TREE_CHAIN(attribute_arguments));
150 tree implementation = TREE_VALUE(TREE_CHAIN(TREE_CHAIN(attribute_arguments))); 154 result.pd_plus_field = TREE_VALUE(TREE_CHAIN(TREE_CHAIN(attribute_arguments)));
151 if (!!strncmp(TREE_STRING_POINTER(call), called_api, strlen(called_api))) continue; 155 result.replacement_candidate = TREE_VALUE(TREE_CHAIN(TREE_CHAIN(TREE_CHAIN(attribute_arguments))));
152 result.provider_of_replacement_candidate = providing_class; 156 //result.is_mixin = !!(TREE_VALUE(TREE_CHAIN(TREE_CHAIN(TREE_CHAIN(TREE_CHAIN(attribute_arguments))))));
153 result.replacement_candidate = implementation; 157 if (!!strncmp(TREE_STRING_POINTER(result.call), called_api, strlen(called_api))) continue;
154 result.valid = true; 158 result.valid = true;
155 break; 159 break;
156 } 160 }
@@ -171,6 +175,7 @@ static unsigned int eo_execute(void)
171 gcc_assert(single_succ_p(ENTRY_BLOCK_PTR_FOR_FN(cfun))); 175 gcc_assert(single_succ_p(ENTRY_BLOCK_PTR_FOR_FN(cfun)));
172 entry_bb = single_succ(ENTRY_BLOCK_PTR_FOR_FN(cfun)); 176 entry_bb = single_succ(ENTRY_BLOCK_PTR_FOR_FN(cfun));
173 177
178 //FIXME this is jerky but we are checking if args are more than 2, if so we might be a eo op, and thats fine
174 for (tree argument = DECL_ARGUMENTS(cfun->decl); argument; argument = DECL_CHAIN(argument)) 179 for (tree argument = DECL_ARGUMENTS(cfun->decl); argument; argument = DECL_CHAIN(argument))
175 { 180 {
176 length ++; 181 length ++;
@@ -197,9 +202,6 @@ static unsigned int eo_execute(void)
197 fprintf(stderr, "Replace! %s %s\n", c.called_api, TREE_STRING_POINTER(api.replacement_candidate)); 202 fprintf(stderr, "Replace! %s %s\n", c.called_api, TREE_STRING_POINTER(api.replacement_candidate));
198 203
199 //Create a new call to the found replacement candidate 204 //Create a new call to the found replacement candidate
200#if 1
201 //FIXME we need here:
202 //add another argument "pd - <my_class>_pd_offset + <providing_class>_pd_offset" (TODO check if these are mixins)
203 /* 205 /*
204 * Create function declaration 206 * Create function declaration
205 */ 207 */
@@ -227,10 +229,10 @@ static unsigned int eo_execute(void)
227 new_arguments.create(gimple_call_num_args(stmt) + 1); 229 new_arguments.create(gimple_call_num_args(stmt) + 1);
228 new_arguments.safe_push(DECL_ARGUMENTS(cfun->decl)); 230 new_arguments.safe_push(DECL_ARGUMENTS(cfun->decl));
229 231
230 tree field1 = build_decl(UNKNOWN_LOCATION, VAR_DECL, get_identifier("efl_object_pd_offset"), integer_type_node); //FIXME wrong field 232 tree field1 = build_decl(UNKNOWN_LOCATION, VAR_DECL, get_identifier(TREE_STRING_POINTER(api.pd_minus_field)), integer_type_node);
231 DECL_EXTERNAL(field1) = 1; 233 DECL_EXTERNAL(field1) = 1;
232 TREE_PUBLIC(field1) = 1; 234 TREE_PUBLIC(field1) = 1;
233 tree field2 = build_decl(UNKNOWN_LOCATION, VAR_DECL, get_identifier("efl_loop_consumer_pd_offset"), integer_type_node); //FIXME wrong field 235 tree field2 = build_decl(UNKNOWN_LOCATION, VAR_DECL, get_identifier(TREE_STRING_POINTER(api.pd_plus_field)), integer_type_node);
234 DECL_EXTERNAL(field2) = 1; 236 DECL_EXTERNAL(field2) = 1;
235 TREE_PUBLIC(field2) = 1; 237 TREE_PUBLIC(field2) = 1;
236 tree tmp1 = build2(MINUS_EXPR, integer_type_node, DECL_CHAIN(DECL_ARGUMENTS(cfun->decl)), field1); 238 tree tmp1 = build2(MINUS_EXPR, integer_type_node, DECL_CHAIN(DECL_ARGUMENTS(cfun->decl)), field1);
@@ -253,7 +255,7 @@ static unsigned int eo_execute(void)
253 gsi_remove(&removal, false); 255 gsi_remove(&removal, false);
254 removal = gsi_for_stmt(c.class_get_call); 256 removal = gsi_for_stmt(c.class_get_call);
255 gsi_remove(&removal, false); 257 gsi_remove(&removal, false);
256#endif 258
257 } 259 }
258 } 260 }
259 return 0; 261 return 0;