Commit ef2bc44f authored by Christoph Mallon's avatar Christoph Mallon
Browse files

be: Expand '{name}' in the attribute 'emit' to the name of the operation.

This way node templates can also provide an emitter.
If present, the attribute 'name' is used, otherwise the key name of the node.
parent 257aea31
......@@ -33,6 +33,9 @@ foreach my $op (sort(keys(%nodes))) {
my $n = $nodes{$op};
my $emit = $n->{emit};
if (!defined($emit) && defined($n->{template})) {
$emit = $n->{template}->{emit};
}
if (defined($emit)) {
my $emit_func;
if ($emit eq "") {
......@@ -42,6 +45,8 @@ foreach my $op (sort(keys(%nodes))) {
$obst_func .= "static void $emit_func(ir_node const *const node)\n";
$obst_func .= "{\n";
my $name = $n->{name} // lc($op);
$emit =~ s/{name}/$name/g;
foreach my $template (split(/\n/, $emit)) {
if ($template ne '') {
$obst_func .= "\t${arch}_emitf(node, \"$template\");\n";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment