Added callback mechanism to determine compilerlib function names.
authorManuel Mohr <manuel.mohr@kit.edu>
Thu, 22 Sep 2011 14:34:55 +0000 (16:34 +0200)
committerManuel Mohr <manuel.mohr@kit.edu>
Thu, 22 Sep 2011 17:04:54 +0000 (19:04 +0200)
include/libfirm/iroptimize.h
ir/ir/ircomplib.c [new file with mode: 0644]
ir/lower/lower_copyb.c

index 7f4a762..eb088ca 100644 (file)
@@ -1082,6 +1082,29 @@ FIRM_API ir_value_classify_sign classify_value_sign(ir_node *n);
 FIRM_API ir_tarval *computed_value_Cmp_Confirm(
        const ir_node *cmp, ir_node *left, ir_node *right, ir_relation relation);
 
+typedef ir_entity *(*compilerlib_entity_creator_t)(ident *id, ir_type *mt);
+/**
+ * Set the compilerlib entity creation callback that is used to create
+ * compilerlib function entities.
+ *
+ * @param cb  the new compilerlib entity creation callback
+ */
+FIRM_API void set_compilerlib_entity_creator(compilerlib_entity_creator_t c);
+
+/**
+ * Get the compilerlib entity creation callback.
+ */
+FIRM_API compilerlib_entity_creator_t get_compilerlib_entity_creator();
+
+/**
+ * Construct the entity for a given function using the current compilerlib
+ * entity creation callback.
+ *
+ * @param id  the identifier of the compilerlib function
+ * @param mt  the method type of the compilerlib function
+ */
+FIRM_API ir_entity *create_compilerlib_entity(ident *id, ir_type *mt);
+
 #include "end.h"
 
 #endif
diff --git a/ir/ir/ircomplib.c b/ir/ir/ircomplib.c
new file mode 100644 (file)
index 0000000..da069d2
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 1995-2011 University of Karlsruhe.  All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief   Compilerlib entity creation related functions.
+ * @date    2011-09-22
+ * @author  Manuel Mohr
+ * @version $Id$
+ */
+#include "config.h"
+
+#include "irprog.h"
+#include "iroptimize.h"
+#include "typerep.h"
+
+#include <stddef.h>
+#include <assert.h>
+
+/* The default implementation does not set a different ld name. */
+static ir_entity *compilerlib_entity_def_creator(ident *id, ir_type *mt)
+{
+       return new_entity(get_glob_type(), id, mt);
+}
+
+static compilerlib_entity_creator_t creator = compilerlib_entity_def_creator;
+
+void set_compilerlib_entity_creator(compilerlib_entity_creator_t c)
+{
+       assert(c != NULL);
+
+       creator = c;
+}
+
+compilerlib_entity_creator_t get_compilerlib_entity_creator()
+{
+       return creator;
+}
+
+ir_entity *create_compilerlib_entity(ident *id, ir_type *mt)
+{
+       return creator(id, mt);
+}
index 6bf7b7b..b4b114c 100644 (file)
@@ -187,12 +187,10 @@ static ir_node *get_memcpy_symconst(ir_graph *irg)
 {
        ident     *id  = new_id_from_str("memcpy");
        ir_type   *mt  = get_memcpy_methodtype();
-       ir_entity *ent = new_entity(get_glob_type(), id, mt);
+       ir_entity *ent = create_compilerlib_entity(id, mt);
        symconst_symbol sym;
 
-       set_entity_ld_ident(ent, get_entity_ident(ent));
        sym.entity_p = ent;
-
        return new_r_SymConst(irg, mode_P_code, sym, symconst_addr_ent);
 }