1 /* brig-arg-block-handler.cc -- brig arg block start/end directive handling
2 Copyright (C) 2016-2018 Free Software Foundation, Inc.
3 Contributed by Pekka Jaaskelainen <pekka.jaaskelainen@parmance.com>
4 for General Processor Tech.
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
22 #include "brig-code-entry-handler.h"
23 #include "tree-iterator.h"
27 #include "tree-pretty-print.h"
28 #include "print-tree.h"
31 brig_directive_arg_block_handler::operator () (const BrigBase
*base
)
33 if (base
->kind
== BRIG_KIND_DIRECTIVE_ARG_BLOCK_START
)
35 /* Initiate a new code block for the call site. */
36 tree stmt_list
= alloc_stmt_list ();
38 = build3 (BIND_EXPR
, void_type_node
, NULL
, stmt_list
, NULL
);
39 tree block
= make_node (BLOCK
);
40 BIND_EXPR_BLOCK (bind_expr
) = block
;
41 static int block_id
= 0;
42 BLOCK_NUMBER (block
) = block_id
++;
43 TREE_USED (block
) = 1;
44 tree m_parentblock
= DECL_INITIAL (m_parent
.m_cf
->m_func_decl
);
45 BLOCK_SUPERCONTEXT (block
) = m_parentblock
;
47 chainon (BLOCK_SUBBLOCKS (m_parentblock
), block
);
49 m_parent
.m_cf
->m_current_bind_expr
= bind_expr
;
50 m_parent
.m_cf
->m_generating_arg_block
= true;
52 else if (base
->kind
== BRIG_KIND_DIRECTIVE_ARG_BLOCK_END
)
54 /* Restore the used bind expression back to the function
56 tree new_bind_expr
= m_parent
.m_cf
->m_current_bind_expr
;
57 m_parent
.m_cf
->m_current_bind_expr
58 = DECL_SAVED_TREE (m_parent
.m_cf
->m_func_decl
);
59 m_parent
.m_cf
->append_statement (new_bind_expr
);
60 m_parent
.m_cf
->m_generating_arg_block
= false;
65 return base
->byteCount
;