Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Zwinkau
libfirm
Commits
5d1afe77
Commit
5d1afe77
authored
Apr 29, 2013
by
Matthias Braun
Browse files
merge some generated c files, rework generators/templates
the templates are now friendlier for usage outside of libfirm
parent
53e92032
Changes
21
Hide whitespace changes
Inline
Side-by-side
.gitignore
View file @
5d1afe77
Makefile.in
firm_revision.h
/aclocal.m4
/autom4te.cache/
/build
/config.guess
/config.h.in
/config.h
/config.h.in
/config.mak
/build
/config.sub
/configure
/depcomp
/include/libfirm/nodes.h
/install-sh
/ir/ir/gen_irdump.c.inl
/ir/ir/gen_irio.c.inl
/ir/ir/gen_irnode.c
/ir/ir/gen_irnode.h
/ltmain.sh
/missing
/win32/vc2010/firm.opensdf
/win32/vc2010/firm.sdf
/win32/vc2010/firm.suo
/win32/vc2010/firm.vcxproj.user
/win32/vc2010/firm.sdf
/win32/vc2010/firm.opensdf
/win32/vc2010/win32/
/include/libfirm/nodes.h
Makefile.in
firm_revision.h
Makefile
View file @
5d1afe77
...
...
@@ -73,6 +73,8 @@ EMITTER_GENERATOR = $(srcdir)ir/be/scripts/generate_emitter.pl
REGALLOC_IF_GENERATOR
=
$(srcdir)
ir/be/scripts/generate_regalloc_if.pl
OPCODES_GENERATOR
=
$(srcdir)
ir/be/scripts/generate_new_opcodes.pl
GENERATED_FILES
=
define
backend_template
$(1)_SOURCES
=
$
$(
wildcard
ir/be/
$(1)
/
*
.c
)
$(1)_SOURCES
:=
$
$(
filter-out
ir/be/
$(1)
/gen_%.c,
$$
(
$(1)
_SOURCES
))
...
...
@@ -85,17 +87,20 @@ $$(srcdir)ir/be/$(1)/gen_$(1)_emitter.h $$(srcdir)ir/be/$(1)/gen_$(1)_emitter.c:
$(Q)
$
$(EMITTER_GENERATOR)
$$
(
$(1)
_SPEC
)
$
$(srcdir)
ir/be/
$(1)
$(1)_SOURCES
+=
ir/be/
$(1)
/gen_
$(1)
_emitter.c
$(1)_GEN_HEADERS
+=
ir/be/
$(1)
/gen_
$(1)
_emitter.h
GENERATED_FILES
+=
ir/be/
$(1)
/gen_
$(1)
_emitter.c ir/be/
$(1)
/gen_
$(1)
_emitter.h
$$(srcdir)ir/be/$(1)/gen_$(1)_regalloc_if.h $$(srcdir)ir/be/$(1)/gen_$(1)_regalloc_if.c
:
$$($(1)_SPEC) $$(REGALLOC_IF_GENERATOR)
@
echo
GEN
$$
@
$(Q)
$
$(REGALLOC_IF_GENERATOR)
$$
(
$(1)
_SPEC
)
$
$(srcdir)
ir/be/
$(1)
$(1)_SOURCES
+=
ir/be/
$(1)
/gen_
$(1)
_regalloc_if.c
$(1)_GEN_HEADERS
+=
ir/be/
$(1)
/gen_
$(1)
_regalloc_if.h
GENERATED_FILES
+=
ir/be/
$(1)
/gen_
$(1)
_regalloc_if.c ir/be/
$(1)
/gen_
$(1)
_regalloc_if.h
$$(srcdir)ir/be/$(1)/gen_$(1)_new_nodes.h $$(srcdir)ir/be/$(1)/gen_$(1)_new_nodes.c.inl
:
$$($(1)_SPEC) $$(OPCODES_GENERATOR)
@
echo
GEN
$$
@
$(Q)
$
$(OPCODES_GENERATOR)
$$
(
$(1)
_SPEC
)
$
$(srcdir)
ir/be/
$(1)
$(1)_GEN_HEADERS
+=
ir/be/
$(1)
/gen_
$(1)
_new_nodes.h
GENERATED_FILES
+=
ir/be/
$(1)
/gen_
$(1)
_new_nodes.h ir/be/
$(1)
/gen_
$(1)
_new_nodes.c.inl
ir/be/$(1)/$(1)_new_nodes.c
:
ir/be/$(1)/gen_$(1)_new_nodes.c.inl
...
...
@@ -103,6 +108,7 @@ ir/be/$(1)/$(1)_new_nodes.c: ir/be/$(1)/gen_$(1)_new_nodes.c.inl
$(1)_OBJECTS
=
$$
(
$(1)
_SOURCES:%.c
=
$
$(builddir)
/%.o
)
$$($(1)_OBJECTS)
:
$$($(1)_GEN_HEADERS)
libfirm_SOURCES
+=
$$
(
$(1)
_SOURCES
)
libfirm_DIRS
+=
ir/be/
$(1)
endef
...
...
@@ -110,17 +116,19 @@ endef
$(foreach
backend,$(backends),$(eval
$(call
backend_template,$(backend))))
# generators
IR_SPEC_GENERATED_
FIL
ES
:=
\
IR_SPEC_GENERATED_
INCLUD
ES
:=
\
include/libfirm/nodes.h
\
ir/ir/gen_ir_cons.c.inl
\
ir/ir/gen_irdump.c.inl
\
ir/ir/gen_irnode.c.inl
\
ir/ir/gen_irnode.h
\
ir/ir/gen_irop.c.inl
ir/ir/gen_irnode.h
GENERATED_FILES
+=
$(IR_SPEC_GENERATED_INCLUDES)
IR_SPEC_GENERATOR
:=
scripts/gen_ir.py
IR_SPEC_GENERATOR_DEPS
:=
$(IR_SPEC_GENERATOR)
scripts/spec_util.py scripts/filters.py
IR_SPEC
:=
scripts/ir_spec.py
libfirm_SOURCES
:=
$(
filter-out
ir/ir/gen_%.c,
$(libfirm_SOURCES)
)
libfirm_SOURCES
:=
$(libfirm_SOURCES)
ir/ir/gen_irnode.c
GENERATED_FILES
+=
ir/ir/gen_irnode.c
ir/ir/%
:
scripts/templates/% $(IR_SPEC_GENERATOR_DEPS) $(IR_SPEC)
@
echo
GEN
$@
$(Q)$(IR_SPEC_GENERATOR)
$(IR_SPEC)
$<
>
$@
...
...
@@ -132,6 +140,7 @@ include/libfirm/% : scripts/templates/% $(IR_SPEC_GENERATOR_DEPS) $(IR_SPEC)
IR_IO_GENERATED_FILES
:=
ir/ir/gen_irio.c.inl
IR_IO_GENERATOR
:=
scripts/gen_ir_io.py
IR_IO_GENERATOR_DEPS
:=
$(IR_IO_GENERATOR)
scripts/spec_util.py scripts/filters.py
GENERATED_FILES
+=
$(IR_IO_GENERATED_FILES)
ir/ir/irio.c
:
ir/ir/gen_irio.c.inl
...
...
@@ -157,12 +166,12 @@ UNUSED := $(shell mkdir -p $(libfirm_DIRS:%=$(builddir)/%))
QUICKCHECK
?=
$(
shell
which cparser-beta
||
echo true
)
-fsyntax-only
QUICKCHECK_FLAGS
?=
-Wno-shadow
-Wno-shadow-local
$(builddir)/%.o
:
%.c $(IR_SPEC_GENERATED_
FIL
ES)
$(builddir)/%.o
:
%.c $(IR_SPEC_GENERATED_
INCLUD
ES)
@
echo
CC
$@
$(Q)$(QUICKCHECK)
$(CFLAGS)
$(CPPFLAGS)
$(libfirm_CPPFLAGS)
$(QUICKCHECK_FLAGS)
$<
$(Q)$(CC)
$(CFLAGS)
$(CPPFLAGS)
$(libfirm_CPPFLAGS)
-MMD
-c
-o
$@
$<
$(docdir)/libfirm.tag
:
$(IR_SPEC_GENERATED_
FIL
ES) Doxyfile $(wildcard include/libfirm/*.h) $(wildcard include/libfirm/adt/*.h)
$(docdir)/libfirm.tag
:
$(IR_SPEC_GENERATED_
INCLUD
ES) Doxyfile $(wildcard include/libfirm/*.h) $(wildcard include/libfirm/adt/*.h)
@
echo
Doxygen
$@
$(Q)$(DOXYGEN)
...
...
@@ -178,7 +187,7 @@ doc: $(docdir)/libfirm.tag $(docdir)/html/nodes.html
.PHONY
:
clean
clean
:
@
echo
CLEAN
$(Q)
rm
-fr
$(builddir)
$(
shell
find ir/
-name
"gen_*.[ch]"
)
$(Q)
rm
-fr
$(builddir)
$(
GENERATED_FILES
)
# This rule is necessary so that make does not abort if headers get deleted
# (the deleted header might still be referenced in a .d file)
...
...
include/libfirm/irgopt.h
View file @
5d1afe77
...
...
@@ -27,6 +27,13 @@
*/
FIRM_API
void
local_optimize_node
(
ir_node
*
n
);
/** Applies local optimizations to a single node.
*
* Node constructors call this function, so you should not need to call this
* manually.
*/
FIRM_API
ir_node
*
optimize_node
(
ir_node
*
n
);
/** Applies local optimizations (see iropt.h) to all nodes in the graph.
*
* @param irg The graph to be optimized.
...
...
include/libfirm/irop.h
View file @
5d1afe77
...
...
@@ -266,6 +266,13 @@ FIRM_API ir_op *new_ir_op(unsigned code, const char *name, op_pin_state p,
irop_flags
flags
,
op_arity
opar
,
int
op_index
,
size_t
attr_size
);
/**
* Frees an ir operation.
*
* Obviously nodes with this op mustn't exist at this point.
*/
FIRM_API
void
free_ir_op
(
ir_op
*
code
);
/** Returns one more than the highest opcode code in use. */
FIRM_API
unsigned
ir_get_n_opcodes
(
void
);
...
...
ir/be/benode.c
View file @
5d1afe77
...
...
@@ -35,6 +35,7 @@
#include
"iropt_t.h"
#include
"irbackedge_t.h"
#include
"irverify_t.h"
#include
"irgopt.h"
#include
"be_t.h"
#include
"belive_t.h"
...
...
ir/be/scripts/generate_new_opcodes.pl
View file @
5d1afe77
...
...
@@ -696,6 +696,7 @@ print OUT<<EOF;
#include "gen_$arch\_regalloc_if.h"
#include "irverify_t.h"
#include "fourcc.h"
#include "irgopt.h"
$obst_cmp_attr
$obst_opvar
...
...
ir/ir/.gitignore
deleted
100644 → 0
View file @
53e92032
/gen_*.h
/gen_*.inl
ir/ir/ircons.c
View file @
5d1afe77
...
...
@@ -26,8 +26,7 @@
#include
"iredges_t.h"
#include
"irflag_t.h"
#include
"error.h"
#include
"gen_ir_cons.c.inl"
#include
"irgopt.h"
/**
* Language dependent variable initialization callback.
...
...
@@ -480,7 +479,7 @@ ir_node *get_r_cur_block(ir_graph *irg)
return
irg
->
current_block
;
}
ir_node
*
get_cur_block
(
void
)
ir_node
*
(
get_cur_block
)
(
void
)
{
return
get_r_cur_block
(
current_ir_graph
);
}
...
...
ir/ir/ircons_t.h
View file @
5d1afe77
...
...
@@ -15,6 +15,13 @@
#include
"ircons.h"
#include
"irgraph_t.h"
#define get_cur_block() _get_cur_block()
static
inline
ir_node
*
_get_cur_block
(
void
)
{
return
current_ir_graph
->
current_block
;
}
/**
* Creates a new Anchor node.
*/
...
...
ir/ir/irnode.c
View file @
5d1afe77
...
...
@@ -23,6 +23,7 @@
#include
"iredges_t.h"
#include
"ircons.h"
#include
"error.h"
#include
"irverify.h"
#include
"irhooks.h"
#include
"util.h"
...
...
@@ -1213,6 +1214,3 @@ bool only_used_by_keepalive(const ir_node *node)
return
kept
;
}
/* include generated code */
#include
"gen_irnode.c.inl"
ir/ir/irop.c
View file @
5d1afe77
...
...
@@ -22,6 +22,7 @@
#include
"xmalloc.h"
#include
"benode.h"
#include
"irnode_t.h"
static
ir_op
**
opcodes
;
/** the available next opcode */
...
...
@@ -607,13 +608,10 @@ void set_op_dump(ir_op *op, dump_node_func func)
op
->
ops
.
dump_node
=
func
;
}
static
void
generated_init_op
(
void
);
static
void
generated_finish_op
(
void
);
void
firm_init_op
(
void
)
{
opcodes
=
NEW_ARR_F
(
ir_op
*
,
0
);
generated
_init_op
();
ir
_init_op
codes
();
be_init_op
();
set_op_cmp_attr
(
op_ASM
,
node_cmp_attr_ASM
);
...
...
@@ -653,9 +651,7 @@ void firm_init_op(void)
void
firm_finish_op
(
void
)
{
be_finish_op
();
generated
_finish_op
();
ir
_finish_op
codes
();
DEL_ARR_F
(
opcodes
);
opcodes
=
NULL
;
}
#include
"gen_irop.c.inl"
ir/ir/irop_t.h
View file @
5d1afe77
...
...
@@ -29,11 +29,6 @@
#define set_generic_function_ptr(op, func) set_generic_function_ptr_((op), (op_func)(func))
#define get_generic_function_ptr(type, op) ((type*)get_generic_function_ptr_((op)))
/**
* Frees a newly created ir operation.
*/
void
free_ir_op
(
ir_op
*
code
);
/** Initialize the irop module. */
void
firm_init_op
(
void
);
...
...
ir/ir/iropt.c
View file @
5d1afe77
...
...
@@ -18,6 +18,7 @@
#include
"iropt_t.h"
#include
"ircons_t.h"
#include
"irgmod.h"
#include
"irgopt.h"
#include
"irverify.h"
#include
"iroptimize.h"
#include
"tv_t.h"
...
...
ir/ir/iropt_t.h
View file @
5d1afe77
...
...
@@ -75,8 +75,6 @@ void visit_all_identities(ir_graph *irg, irg_walk_func visit, void *env);
*/
void
ir_normalize_node
(
ir_node
*
n
);
ir_node
*
optimize_node
(
ir_node
*
n
);
ir_node
*
optimize_in_place_2
(
ir_node
*
n
);
/**
...
...
ir/opt/reassoc.c
View file @
5d1afe77
...
...
@@ -15,6 +15,7 @@
#include
"irmode_t.h"
#include
"ircons_t.h"
#include
"irgmod.h"
#include
"irgopt.h"
#include
"iropt_dbg.h"
#include
"irflag_t.h"
#include
"irgwalk.h"
...
...
scripts/gen_ir.py
View file @
5d1afe77
...
...
@@ -68,7 +68,7 @@ def format_curblock(node):
return
""
return
"current_ir_graph"
else
:
return
"
current_ir_graph->current
_block"
return
"
get_cur
_block
()
"
def
format_insdecl
(
node
):
arity
=
node
.
arity
...
...
@@ -223,7 +223,7 @@ def preprocess_node(node):
node
.
mode
=
"mode"
for
attr
in
node
.
attrs
:
attr
[
"fqname"
]
=
"."
+
attr
[
"name"
]
attr
[
"fqname"
]
=
attr
[
"name"
]
if
"init"
in
attr
:
continue
arguments
.
append
(
attr
)
...
...
@@ -232,7 +232,7 @@ def preprocess_node(node):
if
is_dynamic_pinned
(
node
):
if
hasattr
(
node
,
"pinned_init"
):
initattrs
.
append
(
dict
(
fqname
=
"
.
exc.pin_state"
,
fqname
=
"exc.pin_state"
,
init
=
node
.
pinned_init
))
else
:
...
...
@@ -244,12 +244,12 @@ def preprocess_node(node):
)
)
initattrs
.
append
(
dict
(
fqname
=
"
.
exc.pin_state"
,
fqname
=
"exc.pin_state"
,
init
=
"pin_state"
))
if
hasattr
(
node
,
"throws_init"
):
initattrs
.
append
(
dict
(
fqname
=
"
.
exc.throws_exception"
,
fqname
=
"exc.throws_exception"
,
init
=
node
.
throws_init
))
...
...
@@ -285,6 +285,7 @@ def main(argv):
env
.
globals
[
'nodes'
]
=
real_nodes
env
.
globals
[
'spec'
]
=
spec
env
.
globals
[
'len'
]
=
len
env
.
globals
[
'warning'
]
=
"/* Warning: automatically generated file */"
template
=
env
.
get_template
(
templatefile
)
...
...
scripts/templates/gen_ir
_cons.c.inl
→
scripts/templates/gen_ir
node.c
View file @
5d1afe77
{{
warning
}}
{%- for node in nodes %}
#include
<assert.h>
{
%
if
spec
.
external
%
}
#include
"gen_irnode.h"
#include
<libfirm/firm_types.h>
#include
<libfirm/irnode.h>
#include
<libfirm/irop.h>
#include
<libfirm/irgopt.h>
#include
<libfirm/ircons.h>
#include
<libfirm/irverify.h>
#include
<libfirm/irgraph.h>
#include
"{{spec.external}}/nodes.h"
{
%
else
%
}
#include
"irnode_t.h"
#include
"irop_t.h"
#include
"irverify_t.h"
#include
"iropt_t.h"
#include
"ircons_t.h"
#include
"array_t.h"
#include
"irgraph_t.h"
#include
"irbackedge_t.h"
#include
"irgopt.h"
{
%
endif
%
}
{
%
if
spec
.
external
%
}
static
unsigned
{{
spec
.
name
}}
_opcode_start
;
int
is_
{{
spec
.
name
}}
_node
(
const
ir_node
*
node
)
{
unsigned
start
=
{{
spec
.
name
}}
_opcode_start
;
unsigned
opc
=
get_irn_opcode
(
node
);
return
opc
>
start
&&
opc
-
start
<=
{{
spec
.
name
}}
o_last
;
}
{{
spec
.
name
}}
_opcode
get_
{{
spec
.
name
}}
_irn_opcode
(
const
ir_node
*
node
)
{
assert
(
is_
{{
spec
.
name
}}
_node
(
node
));
return
({{
spec
.
name
}}
_opcode
)
(
get_irn_opcode
(
node
)
-
{{
spec
.
name
}}
_opcode_start
);
}
{
%
endif
%
}
{
%
for
node
in
nodes
%
}
{
%-
if
not
node
.
noconstructor
%
}
ir_node
*
new_rd_
{{
node
.
name
}}(
{
%-
filter
parameters
%
}
...
...
@@ -25,15 +66,22 @@ ir_node *new_rd_{{node.name}}(
add_irn_n
(
res
,
in
[
i
]);
}
{
%-
endif
%
}
{
%
if
len
(
node
.
attrs
)
+
len
(
node
.
initattrs
)
>
0
-%
}
{
%
if
spec
.
external
-%
}
{{
node
.
attr_struct
}}
*
attr
=
({{
node
.
attr_struct
}}
*
)
get_irn_generic_attr
(
res
);
{
%-
else
-%
}
{{
node
.
attr_struct
}}
*
attr
=
&
res
->
attr
.{{
node
.
attrs_name
}};
{
%-
endif
%
}
{
%-
for
attr
in
node
.
attrs
%
}
res->attr.{{node.attrs_name}}
{{attr["fqname"]}} =
attr
->
{{
attr
[
"fqname"
]}}
=
{
%-
if
"init"
in
attr
%
}
{{
attr
[
"init"
]
-
}};
{
%-
else
%
}
{{
attr
[
"name"
]
-
}};
{
%-
endif
%
}
{
%-
endfor
%
}
{
%-
for
attr
in
node
.
initattrs
%
}
res->attr.{{node.attrs_name}}
{{attr["fqname"]}} = {{ attr["init"] -}};
attr
->
{{
attr
[
"fqname"
]}}
=
{{
attr
[
"init"
]
-
}};
{
%-
endfor
%
}
{
%-
endif
%
}
{{
-
node
.
init
}}
irn_verify_irg
(
res
,
irg
);
res
=
optimize_node
(
res
);
...
...
@@ -83,4 +131,94 @@ ir_node *new_{{node.name}}(
{
%
endfilter
%
});
}
{
%
endif
%
}
{%- endfor %}
int
(
is_
{{
node
.
name
}})(
const
ir_node
*
node
)
{
return
is_
{{
node
.
name
}}
_
(
node
);
}
{
%
for
attr
in
node
.
attrs
|
hasnot
(
"noprop"
)
%
}
{{
attr
.
type
}}
(
get_
{{
node
.
name
}}
_
{{
attr
.
name
}})(
const
ir_node
*
node
)
{
return
get_
{{
node
.
name
}}
_
{{
attr
.
name
}}
_
(
node
);
}
void
(
set_
{{
node
.
name
}}
_
{{
attr
.
name
}})(
ir_node
*
node
,
{{
attr
.
type
}}
{{
attr
.
name
}})
{
set_
{{
node
.
name
}}
_
{{
attr
.
name
}}
_
(
node
,
{{
attr
.
name
}});
}
{
%
endfor
-%
}
{
%-
for
input
in
node
.
ins
%
}
ir_node
*
(
get_
{{
node
.
name
}}
_
{{
input
[
0
]}})(
const
ir_node
*
node
)
{
return
get_
{{
node
.
name
}}
_
{{
input
[
0
]}}(
node
);
}
void
(
set_
{{
node
.
name
}}
_
{{
input
[
0
]}})(
ir_node
*
node
,
ir_node
*
{{
input
[
0
]
|
escape_keywords
}})
{
set_
{{
node
.
name
}}
_
{{
input
[
0
]}}
_
(
node
,
{{
input
[
0
]
|
escape_keywords
}});
}
{
%
endfor
%
}
{
%-
if
node
.
input_name
%
}
int
(
get_
{{
node
.
name
}}
_n_
{{
node
.
input_name
}}
s
)(
ir_node
const
*
node
)
{
return
get_
{{
node
.
name
}}
_n_
{{
node
.
input_name
}}
s_
(
node
);
}
ir_node
*
(
get_
{{
node
.
name
}}
_
{{
node
.
input_name
}})(
ir_node
const
*
node
,
int
pos
)
{
return
get_
{{
node
.
name
}}
_
{{
node
.
input_name
}}
_
(
node
,
pos
);
}
void
(
set_
{{
node
.
name
}}
_
{{
node
.
input_name
}})(
ir_node
*
node
,
int
pos
,
ir_node
*
{{
node
.
input_name
}})
{
set_
{{
node
.
name
}}
_
{{
node
.
input_name
}}
_
(
node
,
pos
,
{{
node
.
input_name
}});
}
ir_node
**
(
get_
{{
node
.
name
}}
_
{{
node
.
input_name
}}
_arr
)(
ir_node
*
node
)
{
return
get_
{{
node
.
name
}}
_
{{
node
.
input_name
}}
_arr_
(
node
);
}
{
%
endif
-%
}
ir_op
*
op_
{{
node
.
name
}};
ir_op
*
get_op_
{{
node
.
name
}}(
void
)
{
return
op_
{{
node
.
name
}};
}
{
%
endfor
%
}
void
{{
spec
.
name
}}
_init_opcodes
(
void
)
{
{
%-
if
spec
.
external
%
}
{{
spec
.
name
}}
_opcode_start
=
get_next_ir_opcodes
({{
spec
.
name
}}
o_last
+
1
);
unsigned
o
=
{{
spec
.
name
}}
_opcode_start
;
{
%
endif
-%
}
{
%-
for
node
in
nodes
%
}
op_
{{
node
.
name
}}
=
new_ir_op
(
{
%-
filter
arguments
%
}
{
%-
if
spec
.
external
-%
}
o
+
{
%-
endif
-%
}
{{
spec
.
name
}}
o_
{{
node
.
name
}}
"{{node.name}}"
{{
node
|
pinned
}}
{{
node
|
flags
}}
{{
node
|
arity
}}
{{
node
|
opindex
}}
{{
node
|
attr_size
}}
{
%
endfilter
%
});
{
%-
if
"uses_memory"
in
node
.
flags
:
%
}
ir_op_set_memory_index
(
op_
{{
node
.
name
}},
n_
{{
node
.
name
}}
_mem
);
{
%-
endif
-%
}
{
%-
if
"fragile"
in
node
.
flags
:
%
}
ir_op_set_fragile_indices
(
op_
{{
node
.
name
}},
pn_
{{
node
.
name
}}
_X_regular
,
pn_
{{
node
.
name
}}
_X_except
);
{
%-
endif
-%
}
{
%-
endfor
%
}
}
void
{{
spec
.
name
}}
_finish_opcodes
(
void
)
{
{
%-
for
node
in
nodes
%
}
free_ir_op
(
op_
{{
node
.
name
}});
op_
{{
node
.
name
}}
=
NULL
;
{
%-
endfor
%
}
}
scripts/templates/gen_irnode.c.inl
deleted
100644 → 0
View file @
53e92032
{{warning}}
{%- for node in nodes %}
int (is_{{node.name}})(const ir_node *node)
{
return is_{{node.name}}_(node);
}
{% for attr in node.attrs|hasnot("noprop") %}
{{attr.type}} (get_{{node.name}}_{{attr.name}})(const ir_node *node)
{
return get_{{node.name}}_{{attr.name}}_(node);
}
void (set_{{node.name}}_{{attr.name}})(ir_node *node, {{attr.type}} {{attr.name}})
{
set_{{node.name}}_{{attr.name}}_(node, {{attr.name}});
}
{% endfor -%}
{%- for input in node.ins %}
ir_node *(get_{{node.name}}_{{input[0]}})(const ir_node *node)
{
return get_{{node.name}}_{{input[0]}}(node);
}
void (set_{{node.name}}_{{input[0]}})(ir_node *node, ir_node *{{input[0]|escape_keywords}})
{
set_{{node.name}}_{{input[0]}}_(node, {{input[0]|escape_keywords}});
}
{% endfor %}
{%- if node.input_name %}
int (get_{{node.name}}_n_{{node.input_name}}s)(ir_node const *node)
{
return get_{{node.name}}_n_{{node.input_name}}s_(node);
}
ir_node *(get_{{node.name}}_{{node.input_name}})(ir_node const *node, int pos)
{
return get_{{node.name}}_{{node.input_name}}_(node, pos);
}
void (set_{{node.name}}_{{node.input_name}})(ir_node *node, int pos, ir_node *{{node.input_name}})
{
set_{{node.name}}_{{node.input_name}}_(node, pos, {{node.input_name}});
}
ir_node **(get_{{node.name}}_{{node.input_name}}_arr)(ir_node *node)
{
return get_{{node.name}}_{{node.input_name}}_arr_(node);
}
{%- endif -%}
{%- endfor -%}
scripts/templates/gen_irnode.h
View file @
5d1afe77
{{
warning
}}
#ifndef {{spec.name|upper}}_GEN_IRNODE_H
#define {{spec.name|upper}}_GEN_IRNODE_H
#include
<assert.h>
{
%
if
spec
.
external
%
}
#include
<libfirm/firm_types.h>
#include
<libfirm/irnode.h>
#include
<{{spec.external}}/nodes.h>
#include
"nodes_attr.h"
{
%
endif
%
}
{
%
for
node
in
nodes
%
}
#define is_{{node.name}}(node) is_{{node.name}}_(node)
{
%-
for
attr
in
node
.
attrs
|
hasnot
(
"noprop"
)
%
}
...
...
@@ -26,13 +37,23 @@ static inline int is_{{node.name}}_(const ir_node *node)
static
inline
{{
attr
.
type
}}
get_
{{
node
.
name
}}
_
{{
attr
.
name
}}
_
(
const
ir_node
*
node
)
{
assert
(
is_
{{
node
.
name
}}(
node
));
{
%
if
spec
.
external
-%
}
{{
node
.
attr_struct
}}
const
*
const
attr
=
({{
node
.
attr_struct
}}
const
*
)
get_irn_generic_attr_const
(
node
);
return
attr
->
{{
attr
.
name
}};
{
%-
else
-%
}
return
node
->
attr
.{{
node
.
attrs_name
}}.{{
attr
.
name
}};
{
%-
endif
%
}
}
static
inline
void
set_
{{
node
.
name
}}
_
{{
attr
.
name
}}
_
(
ir_node
*
node
,
{{
attr
.
type
}}
{{
attr
.
name
}})
{
assert
(
is_
{{
node
.
name
}}(
node
));
{
%
if
spec
.
external
-%
}
{{
node
.
attr_struct
}}
*
attr
=
({{
node
.
attr_struct
}}
*
)
get_irn_generic_attr
(
node
);
attr
->
{{
attr
.
name
}}
=
{{
attr
.
name
}};
{
%-
else
-%
}
node
->
attr
.{{
node
.
attrs_name
}}.{{
attr
.
name
}}
=
{{
attr
.
name
}};
{
%
endif
%
}
}
{
%
endfor
-%
}
...
...
@@ -76,3 +97,8 @@ static inline ir_node **get_{{node.name}}_{{node.input_name}}_arr_(ir_node *node
}
{
%
endif
-%
}
{
%
endfor
-%
}
void
{{
spec
.
name
}}
_init_opcodes
(
void
);
void
{{
spec
.
name
}}
_finish_opcodes
(
void
);
#endif
scripts/templates/gen_irop.c.inl
deleted
100644 → 0
View file @
53e92032
{{warning}}
{% for node in nodes %}
ir_op *op_{{node.name}}; ir_op *get_op_{{node.name}}(void) { return op_{{node.name}}; }
{%- endfor %}
static void generated_init_op(void)