#include "config.h"
#include "errors.h"
#include "system.h"
#include "coretypes.h"
#include "tm.h"
#include "tree.h"
#include "tree-inline.h"
#include "c-tree.h"
#include "c-common.h"
#include "diagnostic.h"
#include "output.h"
#include "varray.h"
#include "tree-mudflap.h"
#include "target.h"
#include "flags.h"
#include "rtl.h"
#include "toplev.h"
#include "function.h"
tree
mflang_lookup_decl (const char* name)
{
tree decl = lookup_name (get_identifier (name));
if (decl == NULL_TREE)
internal_error ("mudflap: cannot find declaration of `%s' from mf-runtime.h",
name);
return decl;
}
void
mflang_flush_calls (tree enqueued_call_stmt_chain)
{
tree fnname, t1, t2, body, block, scope;
if (enqueued_call_stmt_chain == NULL_TREE)
return;
fnname = get_identifier ("__mudflap_static_initializer");
t1 = build_tree_list (NULL_TREE, void_type_node);
t2 = tree_cons (NULL, NULL, t1);
start_function (t1, build_nt (CALL_EXPR, fnname, t2, NULL), NULL);
store_parm_decls ();
DECL_STATIC_CONSTRUCTOR (current_function_decl) = 1;
TREE_PUBLIC (current_function_decl) = 0;
TREE_USED (current_function_decl) = 1;
mf_mark (current_function_decl);
body = c_begin_compound_stmt ();
push_scope ();
clear_last_expr ();
add_scope_stmt (1, 0);
c_expand_expr_stmt (enqueued_call_stmt_chain);
scope = add_scope_stmt (0, 0);
block = pop_scope ();
SCOPE_STMT_BLOCK (TREE_PURPOSE (scope)) = block;
SCOPE_STMT_BLOCK (TREE_VALUE (scope)) = block;
RECHAIN_STMTS (body, COMPOUND_BODY (body));
finish_function ();
}