VM/Assembler.pm

filter: Statementstmt 7.2% 56 / 772 Branchbran 0.0% 0 / 414 Conditioncond 0.0% 0 / 357 MC/DCmcdc 0.0% 0 / 181 Subroutinesub 25.5% 11 / 43 Podpod 100% 3 / 3 totaltotal 3.9% 70 / 1770 CC 377 SCAR 106.4
CC
377
Cov
4%
_proc_parts
67340.0
run
600.0
_get_value_type
210.0
CRAP 41686.5
↑ Summary VM/Opcode.pm »
1 # Copyright (c) 2025-2026 Philipp Schafft
2  
3 # licensed under Artistic License 2.0 (see LICENSE file)
4  
5 # ABSTRACT: module for assembling SIRTX VM code
6  
7  
8 package SIRTX::VM::Assembler;
9  
10 1 ▶use v5.16;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use Encode ();
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use Fcntl qw(SEEK_SET SEEK_CUR SEEK_END);
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use List::Util qw(uniq);
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 1 ▶use String::Super;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 1 ▶use SIRTX::VM::RegisterFile;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶use SIRTX::VM::Opcode;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 1 ▶use parent 'Data::Identifier::Interface::Userdata';
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 1 our $VERSION = v0.13;
27  
28 1 my %_escapes = (
29 '\\' => '\\',
30 '0' => chr(0x00),
31 'n' => chr(0x0A),
32 'r' => chr(0x0D),
33 't' => chr(0x09),
34 'e' => chr(0x1B),
35 );
36 1 my %_type_to_sni = %SIRTX::VM::Opcode::_logicals_to_sni; # copy
37 0 my %_sni_to_type = map {$_type_to_sni{$_} => $_} keys %_type_to_sni;
38  
39 1 my %_header_ids = (
40 init => 1,
41 header => 2,
42 rodata => 3,
43 text => 4,
44 trailer => 5,
45 resources => 6,
46 );
47  
48 1 our %_header_ids_rev = reverse %_header_ids;
49  
50 1 my @_section_order = qw(header init text rodata resources trailer);
51 1 my @_section_text = qw(header init text);
52 1 my @_section_load = (@_section_text, qw(rodata resources));
53  
54 my %_disabled_sections = (
55 1 'resources_only' => {map {$_ => 1} qw(init text)},
56 );
57  
58 1 my %_info = map {$_ => 1} (
59 qw(.author .license .copyright_years .copyright_holder),
60 qw(.description .comment .displayname .displaycolour .icon .icontext),
61 qw(.subject_webpage .vendor_webpage .author_webpage .webpage),
62 qw(.repo_uri),
63 );
64  
65 1 my %_profiles = (
66 default => 0,
67 resources_only => 1,
68 minimal => 2,
69 );
70  
71 my %_synthetic = (
72 default => {
73 mul => [['"out"' => 'undef', reg => 1, '"arg"' => 'undef'] => ['user*' => 2] => [
74 ['open', \2, 0],
75 ['control', \2, 'sni:81', \1],
76 ],
77 ['"out"' => 'undef', reg => 1, reg => 2] => ['arg' => 3] => [
78 ['replace', \3, \2],
79 ['mul', 'out', \1, \3],
80 ],
81 ['"out"' => 'undef', reg => 1, int => 2] => ['arg' => 3] => [
82 ['open', \3, \2],
83 ['mul', 'out', \1, \3],
84 ]],
85 contents => [[reg => 1, int => 2] => ['user*' => 3] => [
86 ['open_function*', \3, \2],
87 ['contents*', \1, \3],
88 ],
89 [reg => 1, id => 2] => ['user*' => 3] => [
90 ['open*', \3, \2],
91 ['contents*', \1, \3],
92 ]],
93 call => [[reg => 1, int => 2] => ['user*' => 3] => [
94 ['open_function*', \3, \2],
95 ['call*', \1, \3]
96 ],
97 [reg => 1, id => 2] => ['user*' => 3] => [
98 ['open*', \3, \2],
99 ['call*', \1, \3],
100 ],
101 [[qw(reg int id)] => 1] => ['user*' => 2] => [
102 ['open_context*', \2],
103 ['call*', \2, \1],
104 ]],
105 transfer => [[reg => 1, string => 2] => ['user*' => 3] => [
106 ['open', \3, \2],
107 ['transfer', \1, \3],
108 ]],
109 control => [[reg => 1, [qw(reg sni:)] => 2, [qw(string bool)] => 3] => ['user*' => 4] => [
110 ['open', \4, \3],
111 ['control', \1, \2, \4],
112 ],
113 [reg => 1, [qw(reg sni:)] => 2, [qw(string bool)] => 3, reg => 4] => ['user*' => 5, 'arg' => 6] => [
114 ['open', \5, \3],
115 ['replace', \6, \4],
116 ['control', \1, \2, \5],
117 ],
118 [reg => 1, [qw(reg sni:)] => 2, [qw(string bool)] => 3, any => 4] => ['user*' => 5, 'arg' => 6] => [
119 ['open', \5, \3],
120 ['open', \6, \4],
121 ['control', \1, \2, \5],
122 ],
123 [any => 1, any => 2, any => 3, reg => 4] => ['arg' => 5] => [
124 ['replace', \5, \4],
125 ['control', \1, \2, \3, \5],
126 ],
127 [any => 1, any => 2, any => 3, any => 4] => ['arg' => 5] => [
128 ['open', \5, \4],
129 ['control', \1, \2, \3, \5],
130 ]],
131 push => [[any => 1, string => 2] => ['user*' => 3] => [
132 ['open', \3, \2],
133 ['push', \1, \3],
134 ],
135 [any => 1, any => 2] => ['user*' => 3] => [
136 ['open', \3, \2],
137 ['push', \1, \3],
138 ],
139 [any => 1, [qw(int id string bool)] => 2, '"arg"' => 3] => ['user*' => 4] => [
140 ['open', \4, \2],
141 ['control', \1, 'sni:180', \4, \3],
142 ],
143 [any => 1, reg => 2, '"arg"' => 3] => [] => [
144 ['control', \1, 'sni:180', \2, \3],
145 ],
146 [any => 1, [qw(int id string bool)] => 2, reg => 3] => ['user*' => 4, 'arg' => 5] => [
147 ['open', \4, \2],
148 ['replace', \5, \3],
149 ['control', \1, 'sni:180', \4, \3],
150 ],
151 [any => 1, reg => 2, reg => 3] => ['arg' => 4] => [
152 ['replace', \4, \3],
153 ['control', \1, 'sni:180', \2, \4],
154 ],
155 [any => 1, [qw(int id string bool)] => 2, any => 3] => ['user*' => 4, 'arg' => 5] => [
156 ['open', \4, \2],
157 ['open', \5, \3],
158 ['control', \1, 'sni:180', \4, \3],
159 ],
160 [any => 1, reg => 2, any => 3] => ['arg' => 4] => [
161 ['open', \4, \3],
162 ['control', \1, 'sni:180', \2, \4],
163 ]],
164 pop => [[reg => 1, reg => 2] => [] => [
165 ['control', \2, 'sni:181'],
166 ['replace', \1, 'out'],
167 ]],
168 setvalue => [
169 [reg => 1, reg => 2, '"arg"' => 3] => [] => [
170 ['control', \1, 'sni:102', \2, \3],
171 ],
172 [reg => 1, any => 2, '"arg"' => 3] => ['user*' => 4] => [
173 ['open', \4, \2],
174 ['control', \1, 'sni:102', \4, \3],
175 ],
176 [reg => 1, reg => 2, reg => 3] => ['arg' => 4] => [
177 ['replace', \4, \3],
178 ['control', \1, 'sni:102', \2, \4],
179 ],
180 [reg => 1, any => 2, reg => 3] => ['arg' => 4, 'user*' => 5] => [
181 ['replace', \4, \3],
182 ['open', \5, \2],
183 ['control', \1, 'sni:102', \5, \4],
184 ],
185 [reg => 1, reg => 2, any => 3] => ['arg' => 4] => [
186 ['open', \4, \3],
187 ['control', \1, 'sni:102', \2, \4],
188 ],
189 [reg => 1, any => 2, any => 3] => ['arg' => 4, 'user*' => 5] => [
190 ['open', \4, \3],
191 ['open', \5, \2],
192 ['control', \1, 'sni:102', \5, \4],
193 ]],
194 getvalue => [
195 ['"out"' => 1, reg => 2, any => 3] => ['user*' => 4] => [
196 ['open', \4, \3],
197 ['getvalue', \1, \2, \4],
198 ],
199 [reg => 1, reg => 2, reg => 3] => [] => [
200 ['getvalue', 'out', \2, \3],
201 ['replace', \1, 'out'],
202 ],
203 [reg => 1, reg => 2, any => 3] => ['user*' => 4] => [
204 ['open', \4, \3],
205 ['getvalue', 'out', \2, \4],
206 ['replace', \1, 'out'],
207 ]],
208 relations => [[alias => 1, reg => 2, id => 3, any => 4] => ['user*' => 5, 'user*' => 6] => [
209 ['.force_mapped', \5],
210 ['open_function', \5, \1],
211 ['open', \6, \3],
212 ['relations', \5, \2, \6, \4],
213 ]],
214 write_be8 => [
215 [reg => 1, reg => 2] => [arg => 3] => [
216 ['replace', \3, \2],
217 ['control', \1, 'sni:144', '8'],
218 ],
219 [reg => 1, any => 2] => [arg => 3] => [
220 ['open', \3, \2],
221 ['control', \1, 'sni:144', '8'],
222 ]],
223 write_be16 => [
224 [reg => 1, reg => 2] => [arg => 3] => [
225 ['replace', \3, \2],
226 ['control', \1, 'sni:144', '16'],
227 ],
228 [reg => 1, any => 2] => [arg => 3] => [
229 ['open', \3, \2],
230 ['control', \1, 'sni:144', '16'],
231 ]],
232 '.autosectionstart' => [['"header"' => 1] => [] => [
233 ['.section', \1, '"VM\\r\\n\\xc0\\n"'],
234 ['filesize', 'size$out$'],
235 ['text_boundary', 'end$boundary$text'],
236 ['load_boundary', 'end$boundary$load'],
237 1 (map {['section_pointer', 'section$'.$_.'//section$header']} @_section_order),
238 ],
239 ['"rodata"' => 1] => [] => [
240 ['.section', \1],
241 ['.rodata'], # INTERNAL COMMAND, NOT FOR DOCS!
242 ['.align', 2],
243 ],
244 [any => 1] => [] => [
245 ['.section', \1]
246 ]],
247 '.autosection' => [[any => 1] => [] => [
248 ['.autosectionstart', \1],
249 ['.endsection']
250 ]],
251 '.filechunk' => [[string => 1, 'any...' => 2] => [] => [
252 ['.chunk', \2],
253 ['.cat', \1],
254 ['.endchunk'],
255 ]],
256 '.paddingchunk' => [['any...' => 1] => [] => [
257 ['.chunk', 'of', 'sni:237'],
258 ['.org', \1],
259 ['.endchunk'],
260 ]],
261 },
262 minimal => {
263 '.autosection' => [
264 ['"rodata"' => 1] => [] => [
265 ['data_start_marker'],
266 ['.rodata'], # INTERNAL COMMAND, NOT FOR DOCS!
267 ],
268 [any => 1] => [] => [
269 ]],
270 },
271 );
272  
273 1 my %_section_order_bad;
274  
275 {
276 1 my @got;
277 1 foreach my $section (reverse @_section_order) {
278 6 $_section_order_bad{$section} = {map {$_ => 1} @got};
279 6 push(@got, $section);
280 }
281 }
282  
283  
284 0 ▶sub new {
Subroutine new: not called CC=13 SCAR=52.0
Pod documented
285 0 my ($pkg, %opts) = @_;
286 0 my $self = bless({
287 alive => 1,
288 alignment => 1024,
289 aliases => {},
290 current => {},
291 rf => SIRTX::VM::RegisterFile->new,
292 rf_stored => [],
293 regmap_last_used_c => 0,
294 regmap_last_used => {},
295 regmap_mapped => {},
296 sections => {},
297 pushback => [],
298 settings => {
299 synthetic_auto_unref => 1,
300 regmap_auto => undef,
301 },
302 rodata => String::Super->new,
303 alias_rodata_idx => {},
304 auto_host_defined => undef,
305 profiles => [],
306 profiles_hash => undef,
307 }, $pkg);
308  
309 {
310 0 my $in = delete $opts{in};
311 0 ▶ croak 'No input given' unless defined $in;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $in 0 0 0
312  
313 0 ▶ if (ref($in) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $in eq 'ARRAY') { } 0 0 0
314 0 $in = [@{$in}]; # shallow copy we have our own array.
315 } else {
316 0 $in = [$in];
317 }
318  
319 0 foreach my $fh (@{$in}) {
320 0 ▶ unless (ref $fh) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $fh) 0 0 0
321 0 ▶ open(my $x, '<', $fh) or die $!;
Branch: 1 branch
BranchTrueFalseTotal
open my $x, "<", $fh or die $! 0 0 0
322 0 $fh = $x;
323 }
324  
325 0 $fh->binmode;
326 0 $fh->binmode(':utf8');
327 }
328 0 $self->{in} = $in;
329 }
330  
331 {
332 0 my $fh = delete $opts{out};
333 0 ▶ croak 'No output given' unless defined $fh;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $fh 0 0 0
334  
335 0 ▶ unless (ref $fh) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $fh) 0 0 0
336 0 ▶ open(my $x, '>', $fh) or die $!;
Branch: 1 branch
BranchTrueFalseTotal
open my $x, ">", $fh or die $! 0 0 0
337 0 $fh = $x;
338 }
339  
340 0 $fh->binmode;
341 0 $self->{out} = $fh;
342 }
343  
344 0 $self->_join_profile('default');
345  
346 0 ▶ if (defined(my $profile = delete $opts{profile})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $profile = delete $opts{"profile"})) 0 0 0
347 0 ▶ $profile = [$profile] unless ref $profile;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $profile 0 0 0
348  
349 0 foreach my $p (@{$profile}) {
350 0 $self->_join_profile(split(/(?:\s*,\s*|\s+)/, $p));
351 }
352 }
353  
354 0 ▶ croak 'Stray options passed' if scalar keys %opts;
Branch: 1 branch
BranchTrueFalseTotal
if scalar keys %opts 0 0 0
355  
356 0 return $self;
357 }
358  
359  
360 0 ▶sub run {
Subroutine run: not called CC=24 SCAR=64.0
Pod documented
361 0 my ($self, @opts) = @_;
362  
363 0 ▶ croak 'Stray options passed' if scalar @opts;
Branch: 1 branch
BranchTrueFalseTotal
if scalar @opts 0 0 0
364  
365 0 $self->_save_position('out$');
366 0 $self->_proc_input($_) foreach @{$self->{in}};
367  
368 0 eval {
369 0 my $size;
370 0 $self->{out}->seek(0, SEEK_END);
371 0 $size = $self->{out}->tell;
372 0 ▶ if ($size & 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($size & 1) 0 0 0
373 0 carp sprintf('WARNING: Final file size is %u bytes, this is a odd number', $size);
374 }
375 0 $self->_save_endposition('out$');
376 };
377  
378 {
379 0 my $boundary = 0;
380  
381 0 foreach my $section (@_section_text) {
382 0 ▶ my $s = $self->{aliases}{'end$inner$section$'.$section} // next;
Condition0%0/2
$self->{"aliases"}{'end$inner$section$' . $section} // (next)
l!l
00
MC/DC0%0/1
$self->{"aliases"}{'end$inner$section$' . $section} // (next)
$self->{"aliases"}{'end$inner$section$' . $section}
Truth table0%0/2
A
A= $self->{"aliases"}{'end$inner$section$' . $section}
Aresult
11
00
383 0 ▶ $boundary = $s->[-1] if $boundary < $s->[-1];
Branch: 1 branch
BranchTrueFalseTotal
if $boundary < $s->[-1] 0 0 0
384 }
385  
386 0 ▶ if ($boundary & 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($boundary & 1) 0 0 0
387 0 ▶ if (defined($self->{aliases}{'size$out$'}) && $self->{aliases}{'size$out$'}[-1] > $boundary) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'aliases'}{'size$out$'} and $self->{'aliases'}{'size$out$'}[-1] > $boundary) { } 0 0 0
Condition0%0/3
defined $self->{"aliases"}{"size\$out\$"} and $self->{"aliases"}{"size\$out\$"}[-1] > $boundary
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->{"aliases"}{"size\$out\$"} and $self->{"aliases"}{"size\$out\$"}[-1] > $boundary
defined $self->{"aliases"}{"size\$out\$"} $self->{"aliases"}{"size\$out\$"}[-1] > $boundary
Truth table0%0/3
A and B
A= defined $self->{"aliases"}{"size\$out\$"}B= $self->{"aliases"}{"size\$out\$"}[-1] > $boundary
ABresult
0X0
100
111
388 0 $boundary++;
389 } else {
390 0 croak sprintf('Error: Text boundary has odd size and output size is invalid/too low');
391 }
392 }
393  
394 0 ▶ push(@{$self->{aliases}{'boundary$text'} //= []}, 0);
Condition0%0/2
$self->{"aliases"}{"boundary\$text"} //= []
l!l
00
MC/DC0%0/1
$self->{"aliases"}{"boundary\$text"} //= []
$self->{"aliases"}{"boundary\$text"}
Truth table0%0/2
A
A= $self->{"aliases"}{"boundary\$text"}
Aresult
11
00
395 0 ▶ push(@{$self->{aliases}{'end$boundary$text'} //= []}, $boundary);
Condition0%0/2
$self->{"aliases"}{"end\$boundary\$text"} //= []
l!l
00
MC/DC0%0/1
$self->{"aliases"}{"end\$boundary\$text"} //= []
$self->{"aliases"}{"end\$boundary\$text"}
Truth table0%0/2
A
A= $self->{"aliases"}{"end\$boundary\$text"}
Aresult
11
00
396 }
397  
398 {
399 0 my $boundary = 0;
400  
401 0 foreach my $section (@_section_load) {
402 0 ▶ my $s = $self->{aliases}{'end$inner$section$'.$section} // next;
Condition0%0/2
$self->{"aliases"}{'end$inner$section$' . $section} // (next)
l!l
00
MC/DC0%0/1
$self->{"aliases"}{'end$inner$section$' . $section} // (next)
$self->{"aliases"}{'end$inner$section$' . $section}
Truth table0%0/2
A
A= $self->{"aliases"}{'end$inner$section$' . $section}
Aresult
11
00
403 0 ▶ $boundary = $s->[-1] if $boundary < $s->[-1];
Branch: 1 branch
BranchTrueFalseTotal
if $boundary < $s->[-1] 0 0 0
404 }
405  
406 0 ▶ if ($boundary & 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($boundary & 1) 0 0 0
407 0 ▶ if (defined($self->{aliases}{'size$out$'}) && $self->{aliases}{'size$out$'}[-1] > $boundary) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'aliases'}{'size$out$'} and $self->{'aliases'}{'size$out$'}[-1] > $boundary) { } 0 0 0
Condition0%0/3
defined $self->{"aliases"}{"size\$out\$"} and $self->{"aliases"}{"size\$out\$"}[-1] > $boundary
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->{"aliases"}{"size\$out\$"} and $self->{"aliases"}{"size\$out\$"}[-1] > $boundary
defined $self->{"aliases"}{"size\$out\$"} $self->{"aliases"}{"size\$out\$"}[-1] > $boundary
Truth table0%0/3
A and B
A= defined $self->{"aliases"}{"size\$out\$"}B= $self->{"aliases"}{"size\$out\$"}[-1] > $boundary
ABresult
0X0
100
111
408 0 $boundary++;
409 } else {
410 0 croak sprintf('Error: Load boundary has odd size and output size is invalid/too low');
411 }
412 }
413  
414 0 ▶ push(@{$self->{aliases}{'boundary$load'} //= []}, 0);
Condition0%0/2
$self->{"aliases"}{"boundary\$load"} //= []
l!l
00
MC/DC0%0/1
$self->{"aliases"}{"boundary\$load"} //= []
$self->{"aliases"}{"boundary\$load"}
Truth table0%0/2
A
A= $self->{"aliases"}{"boundary\$load"}
Aresult
11
00
415 0 ▶ push(@{$self->{aliases}{'end$boundary$load'} //= []}, $boundary);
Condition0%0/2
$self->{"aliases"}{"end\$boundary\$load"} //= []
l!l
00
MC/DC0%0/1
$self->{"aliases"}{"end\$boundary\$load"} //= []
$self->{"aliases"}{"end\$boundary\$load"}
Truth table0%0/2
A
A= $self->{"aliases"}{"end\$boundary\$load"}
Aresult
11
00
416 }
417  
418 # We are past the first pass.
419 # We disable automapping here. If there is still mapping needed there is a bug somewhere as this all should be resolved by now.
420 # So turning it off to let any requests fail is the safest option.
421 0 $self->{settings}{regmap_auto} = undef;
422  
423 {
424 0 my $pushback = $self->{pushback};
425  
426 0 $self->{pushback} = []; # reset
427  
428 0 foreach my $entry (@{$pushback}) {
429 0 local $self->{rf} = $entry->{rf};
430 0 $self->{out}->seek($entry->{pos}, SEEK_SET);
431 0 ▶ $entry->{update}->($self, $entry) if defined $entry->{update};
Branch: 1 branch
BranchTrueFalseTotal
if defined $entry->{"update"} 0 0 0
432 0 $self->_proc_parts($entry->{parts}, $entry->{opts}, undef, 1);
433 }
434 }
435  
436 0 ▶ if (scalar(@{$self->{pushback}})) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{$self->{"pushback"};}) 0 0 0
437 0 foreach my $entry (@{$self->{pushback}}) {
438 0 carp sprintf('Warning: Still active pushback from line %u', $entry->{opts}{line});
439 }
440  
441 0 croak sprintf('Error: There are still %u open pushbacks', scalar(@{$self->{pushback}}));
442 }
443 }
444  
445  
446 0 ▶sub dump {
Subroutine dump: not called CC=13 SCAR=52.0
Pod documented
447 0 my ($self, $dumpfilename, @opts) = @_;
448 0 my $aliases = $self->{aliases};
449 0 my $rf = $self->{rf};
450 0 my $dumpfh;
451  
452 0 ▶ croak 'Stray options passed' if scalar @opts;
Branch: 1 branch
BranchTrueFalseTotal
if scalar @opts 0 0 0
453  
454 0 ▶ if (ref($dumpfilename)) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $dumpfilename) { } 0 0 0
455 0 $dumpfh = $dumpfilename;
456 } else {
457 0 $dumpfh = $self->_open_file($dumpfilename, '>');
458 }
459 0 $dumpfh->binmode;
460 0 $dumpfh->binmode(':utf8');
461  
462 0 say $dumpfh '; Profiles:';
463 0 foreach my $key (@{$self->{profiles}}) {
464 0 printf $dumpfh "; %s\n", $key;
465 }
466  
467 0 say $dumpfh '';
468 0 say $dumpfh '; Settings:';
469 0 foreach my $key (sort keys %{$self->{settings}}) {
470 0 ▶ printf $dumpfh "; %-32s -> %s\n", $key, $self->{settings}{$key} // '<undef>';
Condition0%0/2
$self->{"settings"}{$key} // "<undef>"
l!l
00
MC/DC0%0/1
$self->{"settings"}{$key} // "<undef>"
$self->{"settings"}{$key}
Truth table0%0/2
A
A= $self->{"settings"}{$key}
Aresult
11
00
471 }
472  
473 0 say $dumpfh '';
474 0 say $dumpfh '; Register map:';
475 0 foreach my $reg ($rf->expand('r*')) {
476 0 ▶ printf $dumpfh "; %-32s -> %s\n", $reg, scalar(eval {$rf->get_physical_by_name($reg)->name}) // '<none>';
Condition0%0/2
scalar eval { do { $rf->get_physical_by_name($reg)->name } } // "<none>"
l!l
00
MC/DC0%0/1
scalar eval { do { $rf->get_physical_by_name($reg)->name } } // "<none>"
scalar eval { do { $rf->get_physical_by_name($reg)->name } }
Truth table0%0/2
A
A= scalar eval { do { $rf->get_physical_by_name($reg)->name } }
Aresult
11
00
477 }
478  
479 0 say $dumpfh '';
480 0 say $dumpfh '; Register attributes:';
481 0 foreach my $reg ($rf->expand('r*', 'user*', 'system*')) {
482 0 my $physical = eval { $rf->get_physical_by_name($reg)->physical };
483 0 my $temperature = $rf->register_temperature($reg);
484 0 my $owner = $rf->register_owner($reg);
485 0 ▶ printf $dumpfh "; %-32s -> %6s: %8s %8s %8u\n", $reg, $physical // '<none>', $temperature, $owner, $self->{regmap_last_used}{$physical // ''} // 0;
Condition0%0/6
$physical // "<none>"
l!l
00
$self->{"regmap_last_used"}{$physical // ""} // 0
l!l
00
$physical // ""
l!l
00
MC/DC0%0/1
$physical // "<none>"
$physical
MC/DC0%0/1
$self->{"regmap_last_used"}{$physical // ""} // 0
$self->{"regmap_last_used"}{$physical // ""}
MC/DC0%0/1
$physical // ""
$physical
Truth table0%0/2
A
A= $physical
Aresult
11
00
Truth table0%0/2
A
A= $self->{"regmap_last_used"}{$physical // ""}
Aresult
11
00
Truth table0%0/2
A
A= $physical
Aresult
11
00
486 }
487  
488 0 say $dumpfh '';
489 0 say $dumpfh '; Aliases:';
490 0 foreach my $key (sort keys %{$aliases}) {
491 0 printf $dumpfh "; %-32s = %s\n", $key, join(', ', @{$aliases->{$key}});
492 }
493 }
494 # ---- Private helpers ----
495 0 ▶sub _open_file {
Subroutine _open_file: not called CC=3 SCAR=24.8
496 0 my ($self, $filename, $mode) = @_;
497 0 ▶ $mode //= '<';
Condition0%0/2
$mode //= "<"
l!l
00
MC/DC0%0/1
$mode //= "<"
$mode
Truth table0%0/2
A
A= $mode
Aresult
11
00
498 0 ▶ open(my $fh, $mode, $filename) or die $!;
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, $mode, $filename or die $! 0 0 0
499 0 return $fh;
500 }
501  
502 0 ▶sub _alive {
Subroutine _alive: not called CC=1 SCAR=6.9
503 0 my ($self) = @_;
504 0 return $self->{alive};
505 }
506  
507 0 ▶sub _quit {
Subroutine _quit: not called CC=1 SCAR=6.9
508 0 my ($self) = @_;
509 0 delete $self->{alive};
510 }
511  
512 0 ▶sub _join_profile {
Subroutine _join_profile: not called CC=3 SCAR=24.8
513 0 my ($self, @profiles) = @_;
514 0 push(@profiles, @{$self->{profiles}});
515  
516 0 ▶ $self->{profiles} = [uniq sort {($_profiles{$b} // croak 'Bad profile: '.$b) <=> ($_profiles{$a} // croak 'Bad profile: '.$a)} @profiles];
Condition0%0/4
$_profiles{$b} // croak('Bad profile: ' . $b)
l!l
00
$_profiles{$a} // croak('Bad profile: ' . $a)
l!l
00
MC/DC0%0/1
$_profiles{$b} // croak('Bad profile: ' . $b)
$_profiles{$b}
MC/DC0%0/1
$_profiles{$a} // croak('Bad profile: ' . $a)
$_profiles{$a}
Truth table0%0/2
A
A= $_profiles{$b}
Aresult
11
00
Truth table0%0/2
A
A= $_profiles{$a}
Aresult
11
00
517 0 $self->{profiles_hash} = {map {$_ => 1} @{$self->{profiles}}};
518 }
519  
520 0 ▶sub _using_profile {
Subroutine _using_profile: not called CC=3 SCAR=24.8
521 0 my ($self, @profile) = @_;
522 0 my $hash = $self->{profiles_hash};
523  
524 0 foreach my $profile (@profile) {
525 0 ▶ return 1 if $hash->{$profile};
Branch: 1 branch
BranchTrueFalseTotal
if $hash->{$profile} 0 0 0
526 }
527  
528 0 return undef;
529 }
530  
531 0 ▶sub _get_synthetic {
Subroutine _get_synthetic: not called CC=3 SCAR=24.8
532 0 my ($self, $cmd) = @_;
533  
534 0 foreach my $profile (@{$self->{profiles}}) {
535 0 ▶ if (defined(my $entry = $_synthetic{$profile}{$cmd})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $entry = $_synthetic{$profile}{$cmd})) 0 0 0
536 0 return $entry;
537 }
538 }
539  
540 0 return undef;
541 }
542  
543 0 ▶sub _align {
Subroutine _align: not called CC=6 SCAR=37.4
544 0 my ($self, $req, $warn) = @_;
545 0 ▶ if ($self->{alignment} % $req) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"alignment"} % $req) 0 0 0
546 0 my $pos = $self->{out}->tell;
547 0 my $error = $pos % $req;
548 0 ▶ if ($error) {
Branch: 1 branch
BranchTrueFalseTotal
if ($error) 0 0 0
549 0 ▶ $warn //= 0;
Condition0%0/2
$warn //= 0
l!l
00
MC/DC0%0/1
$warn //= 0
$warn
Truth table0%0/2
A
A= $warn
Aresult
11
00
550 0 ▶ if ($warn > 1) {
Branch: 2 branches
BranchTrueFalseTotal
if ($warn > 1) { } 0 0 0
elsif ($warn) { } 0 0 0
551 0 croak sprintf('Fatal alignment missmatch would need to skip %u bytes', $req - $error);
552 } elsif ($warn) {
553 0 carp sprintf('Alignment missmatch, auto skipping %u bytes', $req - $error);
554 }
555 0 $self->{out}->seek($req - $error, SEEK_CUR);
556 0 $self->{alignment} = $req;
557 }
558 }
559 }
560  
561 0 ▶sub _set_alignment {
Subroutine _set_alignment: not called CC=1 SCAR=6.9
562 0 my ($self, $value) = @_;
563 0 $self->{alignment} = $value;
564 }
565  
566 0 ▶sub _save_position {
Subroutine _save_position: not called CC=2 SCAR=17.9
567 0 my ($self, $name) = @_;
568 0 ▶ push(@{$self->{aliases}{$name} //= []}, $self->{out}->tell);
Condition0%0/2
$self->{"aliases"}{$name} //= []
l!l
00
MC/DC0%0/1
$self->{"aliases"}{$name} //= []
$self->{"aliases"}{$name}
Truth table0%0/2
A
A= $self->{"aliases"}{$name}
Aresult
11
00
569 }
570 0 ▶sub _save_endposition {
Subroutine _save_endposition: not called CC=4 SCAR=30.0
571 0 my ($self, $name) = @_;
572 0 ▶ push(@{$self->{aliases}{'end$' .$name} //= []}, $self->{out}->tell);
Condition0%0/2
$self->{"aliases"}{'end$' . $name} //= []
l!l
00
MC/DC0%0/1
$self->{"aliases"}{'end$' . $name} //= []
$self->{"aliases"}{'end$' . $name}
Truth table0%0/2
A
A= $self->{"aliases"}{'end$' . $name}
Aresult
11
00
573 0 ▶ push(@{$self->{aliases}{'size$'.$name} //= []}, $self->{aliases}{'end$'.$name}->[-1] - $self->{aliases}{$name}->[-1]) if defined $self->{aliases}{$name};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"aliases"}{$name} 0 0 0
Condition0%0/2
$self->{"aliases"}{'size$' . $name} //= []
l!l
00
MC/DC0%0/1
$self->{"aliases"}{'size$' . $name} //= []
$self->{"aliases"}{'size$' . $name}
Truth table0%0/2
A
A= $self->{"aliases"}{'size$' . $name}
Aresult
11
00
574 }
575  
576 0 ▶sub _write_opcode {
Subroutine _write_opcode: not called CC=1 SCAR=6.9
577 0 my ($self, $opcode) = @_;
578 0 $self->_align($opcode->required_alignment, 1);
579 0 $opcode->write($self->{out});
580 0 $self->_set_alignment($opcode->new_alignment);
581 }
582  
583 0 ▶sub _reg_map {
Subroutine _reg_map: not called CC=2 SCAR=17.9
584 0 my ($self, $loc, $phy) = @_;
585 0 my $rf = $self->{rf};
586 0 $loc = $rf->get_logical_by_name($loc);
587 0 ▶ if ($phy eq '_unknown_') {
Branch: 1 branch
BranchTrueFalseTotal
if ($phy eq '_unknown_') { } 0 0 0
588 0 $rf->unmap($loc);
589 } else {
590 0 $phy = $rf->get_physical_by_name($phy);
591 0 $rf->map($loc, $phy);
592 }
593 0 return ($loc, $phy);
594 }
595 0 ▶sub _reg_map_and_write {
Subroutine _reg_map_and_write: not called CC=1 SCAR=6.9
596 0 my ($self, @args) = @_;
597 0 my ($loc, $phy) = $self->_reg_map(@args);
598 0 $self->_write_opcode(SIRTX::VM::Opcode->new(code => 0, codeX => 3, P => $loc, ST => $phy->physical));
599 }
600  
601 0 ▶sub _force_mapped {
Subroutine _force_mapped: not called CC=9 SCAR=45.0
602 0 my ($self, $register) = @_;
603 0 my $regmap_last_used = $self->{regmap_last_used};
604 0 my $rf = $self->{rf};
605 0 my $loc = eval {$rf->get_logical_by_name($register)};
606 0 my $inc = 5;
607  
608 0 ▶ unless (defined $loc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $loc) 0 0 0
609 0 ▶ if ($self->{settings}{regmap_auto}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"settings"}{"regmap_auto"}) 0 0 0
610 # Try to auto-map a register.
611 0 my $regmap_mapped = $self->{regmap_mapped};
612 0 my @candidates = grep {$rf->register_owner($_) eq SIRTX::VM::Register::OWNER_YOURS()} grep {!$regmap_mapped->{$_}} $rf->expand('r*');
613 0 my ($reg) = (grep {!eval {$rf->get_physical_by_name($_)}} @candidates);
614  
615 0 ▶ warn $reg if defined $reg;
Branch: 1 branch
BranchTrueFalseTotal
if defined $reg 0 0 0
616  
617 0 ▶ $reg //= (map {'r'.$rf->get_logical_by_physical($_)} sort {($regmap_last_used->{$a} // 0) <=> ($regmap_last_used->{$b} // 0)} map {$_->physical} grep {defined} map {eval {$rf->get_physical_by_name($_)}} @candidates)[0];
Condition0%0/7
$reg //= (map {'r' . $rf->get_logical_by_physical($_);} (sort {($regmap_last_used->{$a} // 0) <=> ($regmap_last_used->{$b} // 0);} map({$_->physical;} grep({defined $_;} map({eval { do { $rf->get_physical_by_name($_) } };} @candidates)))))[0]
l!l&&r!l&&!r
000
$regmap_last_used->{$a} // 0
l!l
00
$regmap_last_used->{$b} // 0
l!l
00
MC/DC0%0/2
$reg //= (map {'r' . $rf->get_logical_by_physical($_);} (sort {($regmap_last_used->{$a} // 0) <=> ($regmap_last_used->{$b} // 0);} map({$_->physical;} grep({defined $_;} map({eval { do { $rf->get_physical_by_name($_) } };} @candidates)))))[0]
$reg (map {'r' . $rf->get_logical_by_physical($_);} (sort {($regmap_last_used->{$a} // 0) <=> ($regmap_last_used->{$b} // 0);} map({$_->physical;} grep({defined $_;} map({eval { do { $rf->get_physical_by_name($_) } };} @candidates)))))[0]
MC/DC0%0/1
$regmap_last_used->{$a} // 0
$regmap_last_used->{$a}
MC/DC0%0/1
$regmap_last_used->{$b} // 0
$regmap_last_used->{$b}
Truth table0%0/3
A //= B
A= $regB= (map {'r' . $rf->get_logical_by_physical($_);} (sort {($regmap_last_used->{$a} // 0) <=> ($regmap_last_used->{$b} // 0);} map({$_->physical;} grep({defined $_;} map({eval { do { $rf->get_physical_by_name($_) } };} @candidates)))))[0]
ABresult
1X1
011
000
Truth table0%0/2
A
A= $regmap_last_used->{$a}
Aresult
11
00
Truth table0%0/2
A
A= $regmap_last_used->{$b}
Aresult
11
00
618  
619 0 ▶ croak 'No suitable register found for auto mapping, did you set enough registers with .yours?' unless defined $reg;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $reg 0 0 0
620  
621 0 $regmap_mapped->{$reg} = 1;
622 0 $self->_reg_map_and_write($reg, $register);
623  
624 0 $loc = $rf->get_logical_by_name($reg);
625 }
626  
627 0 ▶ croak 'Cannot map register: '.$register unless defined $loc;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $loc 0 0 0
628 }
629  
630 {
631 0 my $physical = $rf->get_logical($loc)->physical;
632 0 $regmap_last_used->{$physical} = $self->{regmap_last_used_c} + $inc;
633 0 $self->{regmap_last_used_c} += 5;
634 }
635 0 return $loc;
636 }
637  
638 0 ▶sub _reheat_mappings {
Subroutine _reheat_mappings: not called CC=2 SCAR=17.9
639 0 my ($self, @registers) = @_;
640 0 my $rf = $self->{rf};
641  
642 # Perform a force map for those registers that are already mapped. This will reheat them.
643 0 foreach my $register (
644 0 grep {defined eval {$rf->get_logical_by_name($_)}}
645 0 map {$rf->expand($_)}
646 @registers
647 ) {
648 0 $self->_force_mapped($register);
649 }
650 }
651  
652 # Note: All places that use this function to allocate new registers should also consider using _reheat_mappings()!
653 0 ▶sub _reg_alloc_phy {
Subroutine _reg_alloc_phy: not called CC=4 SCAR=30.0
654 0 my ($self, @names) = @_;
655 0 my $regmap_mapped = $self->{regmap_mapped};
656 0 my $rf = $self->{rf};
657 0 ▶ my ($reg) = sort {(eval {$rf->get_logical_by_name($a)} // 999) <=> (eval {$rf->get_logical_by_name($b)} // 999)}
Condition0%0/4
eval { do { $rf->get_logical_by_name($a) } } // 999
l!l
00
eval { do { $rf->get_logical_by_name($b) } } // 999
l!l
00
MC/DC0%0/1
eval { do { $rf->get_logical_by_name($a) } } // 999
eval { do { $rf->get_logical_by_name($a) } }
MC/DC0%0/1
eval { do { $rf->get_logical_by_name($b) } } // 999
eval { do { $rf->get_logical_by_name($b) } }
Truth table0%0/2
A
A= eval { do { $rf->get_logical_by_name($a) } }
Aresult
11
00
Truth table0%0/2
A
A= eval { do { $rf->get_logical_by_name($b) } }
Aresult
11
00
658 0 grep {$rf->register_owner($_) eq SIRTX::VM::Register::OWNER_YOURS()}
659 0 grep {!$regmap_mapped->{$_}}
660 $rf->expand(@names);
661  
662 0 ▶ croak 'No suitable physical register found for auto mapping, did you set enough registers with .yours?' unless defined $reg;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $reg 0 0 0
663  
664 0 $regmap_mapped->{$reg} = 1;
665  
666 0 return $reg;
667 }
668  
669 0 ▶sub _autostring_allocate {
Subroutine _autostring_allocate: not called CC=2 SCAR=17.9
670 0 my ($self, $str) = @_;
671 0 state $autostring = 0;
672 0 my $key = sprintf('autostring$%u', $autostring++);
673  
674 0 $self->{alias_rodata_idx}{$key} = $self->{rodata}->add_blob($str);
675 0 ▶ push(@{$self->{aliases}{'size$'.$key} //= []}, length($str));
Condition0%0/2
$self->{"aliases"}{'size$' . $key} //= []
l!l
00
MC/DC0%0/1
$self->{"aliases"}{'size$' . $key} //= []
$self->{"aliases"}{'size$' . $key}
Truth table0%0/2
A
A= $self->{"aliases"}{'size$' . $key}
Aresult
11
00
676  
677 0 return $key;
678 }
679  
680 0 ▶sub _auto_host_defined {
Subroutine _auto_host_defined: not called CC=4 SCAR=30.0
681 0 my ($self) = @_;
682 0 my $auto_host_defined = $self->{auto_host_defined};
683 0 my $res;
684  
685 0 ▶ croak 'No auto host defined IDs available' unless defined($auto_host_defined) && defined($auto_host_defined->[2]);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $auto_host_defined and defined $auto_host_defined->[2] 0 0 0
Condition0%0/3
defined $auto_host_defined and defined $auto_host_defined->[2]
!ll&&!rl&&r
000
MC/DC0%0/2
defined $auto_host_defined and defined $auto_host_defined->[2]
defined $auto_host_defined defined $auto_host_defined->[2]
Truth table0%0/3
A and B
A= defined $auto_host_definedB= defined $auto_host_defined->[2]
ABresult
0X0
100
111
686  
687 0 $res = $auto_host_defined->[2]++;
688  
689 0 ▶ if ($auto_host_defined->[2] > $auto_host_defined->[1]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($auto_host_defined->[2] > $auto_host_defined->[1]) 0 0 0
690 0 $auto_host_defined->[2] = undef;
691 }
692  
693 0 return '~'.$res;
694 }
695  
696 0 ▶sub _pushback {
Subroutine _pushback: not called CC=1 SCAR=6.9
697 0 my ($self, %opts) = @_;
698 0 $opts{rf} = $self->{rf}->clone;
699 0 push(@{$self->{pushback}}, \%opts);
700 }
701  
702 0 ▶sub _proc_input {
Subroutine _proc_input: not called CC=11 SCAR=48.8
703 0 my ($self, $in) = @_;
704  
705 0 ▶ while ($self->_alive && defined(my $line = <$in>)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_alive and defined(my $line = readline $in)) 0 0 0
Condition0%0/3
$self->_alive and defined(my $line = readline $in)
!ll&&!rl&&r
000
MC/DC0%0/2
$self->_alive and defined(my $line = readline $in)
$self->_alive defined(my $line = readline $in)
Truth table0%0/3
A and B
A= $self->_aliveB= defined(my $line = readline $in)
ABresult
0X0
100
111
706 0 my @parts;
707 my %opts;
708 0 my $autodie;
709  
710 0 $line =~ s/\r?\n$//;
711 0 $line =~ s/^\s+//;
712 0 $line =~ s/\s+$//;
713 0 $line =~ s/^(?:;|\/\/|#).*$//;
714 0 $line =~ s/\s+/ /g;
715  
716 0 ▶ next if $line eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $line eq "" 0 0 0
717  
718 0 ▶ while (length($line)) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $line) 0 0 0
719 0 ▶ if ($line =~ s/^("[^"]*")//) {
Branch: 3 branches
BranchTrueFalseTotal
if ($line =~ s/^("[^"]*")//u) { } 0 0 0
elsif ($line =~ m[^(?:;|//|#)]u) { } 0 0 0
elsif ($line =~ s/^([^\s,=]+)//u) { } 0 0 0
720 0 push(@parts, $1);
721 } elsif ($line =~ /^(?:;|\/\/|#)/) {
722 # this is a comment, so just leave the rest alone
723 0 last;
724 } elsif ($line =~ s/^([^\s,=]+)//) {
725 0 push(@parts, $1);
726 } else {
727 0 croak 'Bad line: '.$in->input_line_number;
728 }
729  
730 0 $line =~ s/^\s*[,=]\s*//;
731 0 $line =~ s/^\s+//;
732 }
733  
734 0 ▶ next unless scalar @parts;
Branch: 1 branch
BranchTrueFalseTotal
unless scalar @parts 0 0 0
735  
736 0 $autodie = undef;
737 0 ▶ if ($parts[0] =~ s/([\?\!])$//) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parts[0] =~ s/([\?\!])$//u) 0 0 0
738 0 ▶ if ($1 eq '!') {
Branch: 1 branch
BranchTrueFalseTotal
if ($1 eq "!") 0 0 0
739 0 $autodie = 1;
740 }
741 }
742  
743 0 %opts = (line => $in->input_line_number);
744  
745 0 $self->{regmap_mapped} = {};
746 0 $self->_proc_parts(\@parts, \%opts, \$autodie);
747 }
748 }
749  
750 0 ▶sub _proc_parts {
Subroutine _proc_parts: not called CC=259 SCAR=111.2
751 0 my ($self, $parts, $opts, $autodie, $allow_alts) = @_;
752 0 my $out = $self->{out};
753 0 my ($cmd, @args) = @{$parts};
754 0 my $was_return;
755 my $opcode;
756  
757 0 ▶ $autodie //= do { \my $x };
Condition0%0/3
$autodie //= do { \my $x }
l!l&&r!l&&!r
000
MC/DC0%0/2
$autodie //= do { \my $x }
$autodie do { \my $x }
Truth table0%0/3
A //= B
A= $autodieB= do { \my $x }
ABresult
1X1
011
000
758  
759 0 ▶ if ($cmd ne '.pushname' && $cmd ne '.popname') {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd ne ".pushname" and $cmd ne ".popname") 0 0 0
Condition0%0/3
$cmd ne ".pushname" and $cmd ne ".popname"
!ll&&!rl&&r
000
MC/DC0%0/2
$cmd ne ".pushname" and $cmd ne ".popname"
$cmd ne ".pushname" $cmd ne ".popname"
Truth table0%0/3
A and B
A= $cmd ne ".pushname"B= $cmd ne ".popname"
ABresult
0X0
100
111
760 0 foreach my $part (@{$parts}) {
761 0 my @alts;
762  
763 0 ▶ next unless $part =~ /^[a-z0-9]*\$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $part =~ /^[a-z0-9]*\$/u 0 0 0
764  
765 0 @alts = split(m#//#, $part);
766  
767 0 ▶ if ($allow_alts) {
Branch: 1 branch
BranchTrueFalseTotal
if ($allow_alts) { } 0 0 0
768 0 foreach my $alt (@alts) {
769 0 ▶ if (defined $self->{aliases}{$alt}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"aliases"}{$alt}) 0 0 0
770 0 $part = $self->{aliases}{$alt}[-1];
771 0 last;
772 }
773 }
774 } else {
775 0 ▶ $part = $self->{aliases}{$alts[0]}[-1] if defined $self->{aliases}{$alts[0]};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"aliases"}{$alts[0]} 0 0 0
776 }
777 }
778 0 ($cmd, @args) = @{$parts};
779 }
780  
781 0 foreach my $arg (@args) {
782 0 ▶ if ($arg eq '~auto') {
Branch: 1 branch
BranchTrueFalseTotal
if ($arg eq "~auto") 0 0 0
783 0 $arg = $self->_auto_host_defined;
784 }
785 }
786  
787 0 ▶ if ($cmd eq '.quit' && scalar(@args) == 0) {
Branch: 45 branches
BranchTrueFalseTotal
if ($cmd eq '.quit' and scalar @args == 0) { } 0 0 0
elsif ($cmd eq '.profile' and scalar @args > 0) { } 0 0 0
elsif ($cmd eq '.pushname' and not scalar @args & 1) { } 0 0 0
elsif ($cmd eq '.popname') { } 0 0 0
elsif ($cmd eq '.tag' and scalar @args == 2 and $args[0] =~ /^[0-9a-zA-Z_]+$/u and defined $_type_to_sni{$args[1]}) { } 0 0 0
elsif ($cmd eq '.tag' and scalar @args == 2 and $args[0] =~ /^[0-9a-zA-Z_]+$/u and $self->_get_value_type($args[1]) =~ /:$/u) { } 0 0 0
elsif ($cmd eq '.tag' and scalar @args == 2 and $args[0] =~ /^[0-9a-zA-Z_]+$/u and $self->_get_value_type($args[1]) eq 'int') { } 0 0 0
elsif ($cmd eq '.tag' and scalar @args == 3 and $args[0] =~ /^[0-9a-zA-Z_]+$/u and $args[1] =~ /^[0-9a-zA-Z_]+$/u and $self->_get_value_type($args[2]) eq 'int') { } 0 0 0
elsif ($cmd eq '.utf8') { } 0 0 0
elsif ($cmd eq '.byte') { } 0 0 0
elsif ($cmd eq '.uint16') { } 0 0 0
elsif ($cmd eq '.uint16_half_up') { } 0 0 0
elsif ($cmd eq '.string' and scalar @args >= 2) { } 0 0 0
elsif ($cmd eq 'open' and scalar @args == 2 and $self->_get_value_type($args[0]) eq 'reg' and $self->_get_value_type($args[1]) eq 'string') { } 0 0 0
elsif ($cmd eq 'open' and scalar @args == 2 and $self->_get_value_type($args[0]) eq 'reg' and $self->_get_value_type($args[1]) eq 'port') { } 0 0 0
elsif ($cmd eq 'byte_transfer' and scalar @args == 2 and $self->_get_value_type($args[0]) eq 'reg' and $self->_get_value_type($args[1]) eq 'string') { } 0 0 0
elsif ($cmd eq '.rodata' and scalar @args == 0) { } 0 0 0
elsif ($cmd eq '.include') { } 0 0 0
elsif ($cmd eq '.cat') { } 0 0 0
elsif ($cmd eq '.noops' and scalar @args == 1) { } 0 0 0
elsif ($cmd eq '.org' and scalar @args == 1) { } 0 0 0
elsif ($cmd eq '.align' and scalar @args == 1) { } 0 0 0
elsif ($cmd eq '.host_defined_auto_range' and scalar @args == 2 and $self->_get_value_type($args[0]) eq 'int' and $self->_get_value_type($args[1]) eq 'int') { } 0 0 0
elsif ($cmd eq '.label' and scalar @args == 1 || scalar @args == 3 and $args[0] =~ /^[a-z0-9A-Z_]+$/u and scalar @args == 1 || $args[1] eq 'as' && $args[2] =~ /^~[0-9]+$/u) { } 0 0 0
elsif ($cmd eq '.endlabel' and scalar @args == 0 and defined $self->{'current'}{'label'}) { } 0 0 0
elsif ($cmd eq '.function' and scalar @args == 1 || scalar @args == 3 and $args[0] =~ /^[a-z0-9A-Z_]+$/u and scalar @args == 1 || $args[1] eq 'as' && $args[2] =~ /^~[0-9]+$/u) { } 0 0 0
elsif ($cmd eq '.endfunction' and scalar @args == 0 and defined $self->{'current'}{'function'}) { } 0 0 0
elsif ($cmd eq '.section' and scalar @args == 1 || scalar @args == 2 and not defined $self->{'current'}{'section'}) { } 0 0 0
elsif ($cmd eq '.endsection' and scalar @args == 0 and defined(my $section = $self->{'current'}{'section'})) { } 0 0 0
elsif ($cmd eq '.chunk' and scalar @args >= 2) { } 0 0 0
elsif ($cmd eq '.endchunk' and scalar @args == 0 and defined $self->{'current'}{'chunk'}) { } 0 0 0
elsif ($cmd =~ /^\.(regmap_auto|synthetic_auto_unref)$/u and scalar @args == 1) { } 0 0 0
elsif ($cmd eq '.map' and scalar @args == 2) { } 0 0 0
elsif ($cmd eq '.forget_mapped') { } 0 0 0
elsif ($cmd eq '.forget_register_state') { } 0 0 0
elsif ($cmd eq '.force_mapped') { } 0 0 0
elsif ($cmd eq '.register_file_store' and scalar @args == 1) { } 0 0 0
elsif ($cmd eq '.register_file_restore' and scalar @args == 1) { } 0 0 0
elsif ($cmd eq '.mine' or $cmd eq '.yours' or $cmd eq '.theirs') { } 0 0 0
elsif ($cmd eq '.hot' or $cmd eq '.cold' or $cmd eq '.lukewarm') { } 0 0 0
elsif ($cmd eq '.regattr' and scalar @args >= 1) { } 0 0 0
elsif ($cmd eq 'map' and scalar @args == 2) { } 0 0 0
elsif (defined($opcode = eval { do { 'SIRTX::VM::Opcode'->from_template('parts', $parts, 'assembler', $self, 'size', $opts->{'size'}, 'line', $opts->{'line'}, 'out', $out, 'autodie', $autodie) } })) { } 0 0 0
elsif (defined($opcode = eval { do { 'SIRTX::VM::Opcode'->from_template('parts', [$parts->[0], map({scalar eval { do { $self->_get_value_type($_) eq 'alias' } } ? 65520 : $_;} @$parts[1 .. scalar(@{$parts;}) - 1])], 'assembler', $self, 'size', $opts->{'size'}, 'line', $opts->{'line'}, 'out', $out, 'autodie', $autodie) } })) { } 0 0 0
elsif (defined $_info{$cmd} and scalar @args > 1 and $args[0] =~ /^~0?$/u) { } 0 0 0
Condition0%0/3
$cmd eq ".quit" and scalar @args == 0
!ll&&!rl&&r
000
MC/DC0%0/2
$cmd eq ".quit" and scalar @args == 0
$cmd eq ".quit" scalar @args == 0
Truth table0%0/3
A and B
A= $cmd eq ".quit"B= scalar @args == 0
ABresult
0X0
100
111
788 0 $self->_quit;
789 ▶ } elsif ($cmd eq '.profile' && scalar(@args) > 0) {
Condition0%0/3
$cmd eq ".profile" and scalar @args > 0
!ll&&!rl&&r
000
MC/DC0%0/2
$cmd eq ".profile" and scalar @args > 0
$cmd eq ".profile" scalar @args > 0
Truth table0%0/3
A and B
A= $cmd eq ".profile"B= scalar @args > 0
ABresult
0X0
100
111
790 0 $self->_join_profile(@args);
791 ▶ } elsif ($cmd eq '.pushname' && !(scalar(@args) & 1)) {
Condition0%0/3
$cmd eq ".pushname" and not scalar @args & 1
!ll&&!rl&&r
000
MC/DC0%0/2
$cmd eq ".pushname" and not scalar @args & 1
$cmd eq ".pushname" not scalar @args & 1
Truth table0%0/3
A and not(B)
A= $cmd eq ".pushname"B= not scalar @args & 1
ABresult
0X0
100
111
792 0 ▶ for (my $i = 0; $i < scalar(@args); $i += 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @args) 0 0 0
793 0 my $key = $args[$i + 0];
794 0 my $value = $args[$i + 1];
795  
796 0 $key =~ s/^\$?/\$/; # ensure it starts with a '$'.
797 0 ▶ if ($key !~ /^\$[0-9a-zA-Z_]+/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($key =~ /^\$[0-9a-zA-Z_]+/u) 0 0 0
798 0 croak sprintf('Bad key name: line %s: key %s', $opts->{line}, $key);
799 }
800 0 ▶ push(@{$self->{aliases}{$key} //= []}, $value);
Condition0%0/2
$self->{"aliases"}{$key} //= []
l!l
00
MC/DC0%0/1
$self->{"aliases"}{$key} //= []
$self->{"aliases"}{$key}
Truth table0%0/2
A
A= $self->{"aliases"}{$key}
Aresult
11
00
801 }
802 } elsif ($cmd eq '.popname') {
803 0 foreach my $key (@args) {
804 0 $key =~ s/^\$?/\$/; # ensure it starts with a '$'.
805 0 ▶ unless (defined $self->{aliases}{$key}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"aliases"}{$key}) 0 0 0
806 0 croak sprintf('Bad/unknown key name: line %s: key %s', $opts->{line}, $key);
807 }
808  
809 0 pop(@{$self->{aliases}{$key}});
810 0 ▶ delete $self->{aliases}{$key} unless scalar @{$self->{aliases}{$key}};
Branch: 1 branch
BranchTrueFalseTotal
unless scalar @{$self->{"aliases"}{$key};} 0 0 0
811 }
812 ▶ } elsif ($cmd eq '.tag' && scalar(@args) == 2 && $args[0] =~ /^[0-9a-zA-Z_]+$/ && defined($_type_to_sni{$args[1]})) {
Condition0%0/9
$cmd eq ".tag" and scalar @args == 2 and $args[0] =~ /^[0-9a-zA-Z_]+$/u and defined $_type_to_sni{$args[1]}
!ll&&!rl&&r
000
$cmd eq ".tag" and scalar @args == 2 and $args[0] =~ /^[0-9a-zA-Z_]+$/u
!ll&&!rl&&r
000
$cmd eq ".tag" and scalar @args == 2
!ll&&!rl&&r
000
MC/DC0%0/4
$cmd eq ".tag" and scalar @args == 2 and $args[0] =~ /^[0-9a-zA-Z_]+$/u and defined $_type_to_sni{$args[1]}
$cmd eq ".tag" scalar @args == 2 $args[0] =~ /^[0-9a-zA-Z_]+$/u defined $_type_to_sni{$args[1]}
Truth table0%0/5
A and B and C and D
A= $cmd eq ".tag"B= scalar @args == 2C= $args[0] =~ /^[0-9a-zA-Z_]+$/uD= defined $_type_to_sni{$args[1]}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
813 0 ▶ push(@{$self->{aliases}{'tag$'.$args[0]} //= []}, 'sni:'.$_type_to_sni{$args[1]});
Condition0%0/2
$self->{"aliases"}{'tag$' . $args[0]} //= []
l!l
00
MC/DC0%0/1
$self->{"aliases"}{'tag$' . $args[0]} //= []
$self->{"aliases"}{'tag$' . $args[0]}
Truth table0%0/2
A
A= $self->{"aliases"}{'tag$' . $args[0]}
Aresult
11
00
814 ▶ } elsif ($cmd eq '.tag' && scalar(@args) == 2 && $args[0] =~ /^[0-9a-zA-Z_]+$/ && $self->_get_value_type($args[1]) =~ /:$/) {
Condition0%0/9
$cmd eq ".tag" and scalar @args == 2 and $args[0] =~ /^[0-9a-zA-Z_]+$/u and $self->_get_value_type($args[1]) =~ /:$/u
!ll&&!rl&&r
000
$cmd eq ".tag" and scalar @args == 2 and $args[0] =~ /^[0-9a-zA-Z_]+$/u
!ll&&!rl&&r
000
$cmd eq ".tag" and scalar @args == 2
!ll&&!rl&&r
000
MC/DC0%0/4
$cmd eq ".tag" and scalar @args == 2 and $args[0] =~ /^[0-9a-zA-Z_]+$/u and $self->_get_value_type($args[1]) =~ /:$/u
$cmd eq ".tag" scalar @args == 2 $args[0] =~ /^[0-9a-zA-Z_]+$/u $self->_get_value_type($args[1]) =~ /:$/u
Truth table0%0/5
A and B and C and D
A= $cmd eq ".tag"B= scalar @args == 2C= $args[0] =~ /^[0-9a-zA-Z_]+$/uD= $self->_get_value_type($args[1]) =~ /:$/u
ABCDresult
0XXX0
10XX0
110X0
11100
11111
815 0 ▶ push(@{$self->{aliases}{'tag$'.$args[0]} //= []}, $args[1]);
Condition0%0/2
$self->{"aliases"}{'tag$' . $args[0]} //= []
l!l
00
MC/DC0%0/1
$self->{"aliases"}{'tag$' . $args[0]} //= []
$self->{"aliases"}{'tag$' . $args[0]}
Truth table0%0/2
A
A= $self->{"aliases"}{'tag$' . $args[0]}
Aresult
11
00
816 ▶ } elsif ($cmd eq '.tag' && scalar(@args) == 2 && $args[0] =~ /^[0-9a-zA-Z_]+$/ && $self->_get_value_type($args[1]) eq 'int') {
Condition0%0/9
$cmd eq ".tag" and scalar @args == 2 and $args[0] =~ /^[0-9a-zA-Z_]+$/u and $self->_get_value_type($args[1]) eq "int"
!ll&&!rl&&r
000
$cmd eq ".tag" and scalar @args == 2 and $args[0] =~ /^[0-9a-zA-Z_]+$/u
!ll&&!rl&&r
000
$cmd eq ".tag" and scalar @args == 2
!ll&&!rl&&r
000
MC/DC0%0/4
$cmd eq ".tag" and scalar @args == 2 and $args[0] =~ /^[0-9a-zA-Z_]+$/u and $self->_get_value_type($args[1]) eq "int"
$cmd eq ".tag" scalar @args == 2 $args[0] =~ /^[0-9a-zA-Z_]+$/u $self->_get_value_type($args[1]) eq "int"
Truth table0%0/5
A and B and C and D
A= $cmd eq ".tag"B= scalar @args == 2C= $args[0] =~ /^[0-9a-zA-Z_]+$/uD= $self->_get_value_type($args[1]) eq "int"
ABCDresult
0XXX0
10XX0
110X0
11100
11111
817 0 ▶ push(@{$self->{aliases}{'tag$'.$args[0]} //= []}, 'sni:'.$self->_parse_int($args[1]));
Condition0%0/2
$self->{"aliases"}{'tag$' . $args[0]} //= []
l!l
00
MC/DC0%0/1
$self->{"aliases"}{'tag$' . $args[0]} //= []
$self->{"aliases"}{'tag$' . $args[0]}
Truth table0%0/2
A
A= $self->{"aliases"}{'tag$' . $args[0]}
Aresult
11
00
818 ▶ } elsif ($cmd eq '.tag' && scalar(@args) == 3 && $args[0] =~ /^[0-9a-zA-Z_]+$/ && $args[1] =~ /^[0-9a-zA-Z_]+$/ && $self->_get_value_type($args[2]) eq 'int') {
Condition0%0/12
$cmd eq ".tag" and scalar @args == 3 and $args[0] =~ /^[0-9a-zA-Z_]+$/u and $args[1] =~ /^[0-9a-zA-Z_]+$/u and $self->_get_value_type($args[2]) eq "int"
!ll&&!rl&&r
000
$cmd eq ".tag" and scalar @args == 3 and $args[0] =~ /^[0-9a-zA-Z_]+$/u and $args[1] =~ /^[0-9a-zA-Z_]+$/u
!ll&&!rl&&r
000
$cmd eq ".tag" and scalar @args == 3 and $args[0] =~ /^[0-9a-zA-Z_]+$/u
!ll&&!rl&&r
000
$cmd eq ".tag" and scalar @args == 3
!ll&&!rl&&r
000
MC/DC0%0/5
$cmd eq ".tag" and scalar @args == 3 and $args[0] =~ /^[0-9a-zA-Z_]+$/u and $args[1] =~ /^[0-9a-zA-Z_]+$/u and $self->_get_value_type($args[2]) eq "int"
$cmd eq ".tag" scalar @args == 3 $args[0] =~ /^[0-9a-zA-Z_]+$/u $args[1] =~ /^[0-9a-zA-Z_]+$/u $self->_get_value_type($args[2]) eq "int"
Truth table0%0/6
A and B and C and D and E
A= $cmd eq ".tag"B= scalar @args == 3C= $args[0] =~ /^[0-9a-zA-Z_]+$/uD= $args[1] =~ /^[0-9a-zA-Z_]+$/uE= $self->_get_value_type($args[2]) eq "int"
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
819 0 ▶ push(@{$self->{aliases}{'tag$'.$args[0]} //= []}, $args[1].':'.$self->_parse_int($args[2]));
Condition0%0/2
$self->{"aliases"}{'tag$' . $args[0]} //= []
l!l
00
MC/DC0%0/1
$self->{"aliases"}{'tag$' . $args[0]} //= []
$self->{"aliases"}{'tag$' . $args[0]}
Truth table0%0/2
A
A= $self->{"aliases"}{'tag$' . $args[0]}
Aresult
11
00
820 } elsif ($cmd eq '.utf8') {
821 0 foreach my $str (@args) {
822 0 print $out $self->_parse_string($str);
823 }
824 0 $self->_set_alignment(1);
825 } elsif ($cmd eq '.byte') {
826 0 my $last;
827 0 foreach my $str (@args) {
828 0 my $c = $self->_parse_int($str, $last);
829 0 print $out pack('C', $c);
830 0 $last = $c;
831 }
832 0 $self->_set_alignment(1);
833 } elsif ($cmd eq '.uint16') { # INTERNAL COMMAND! NOT FOR DOCS!
834 0 my $last;
835 0 foreach my $str (@args) {
836 0 my $c = $self->_parse_int($str, $last);
837 0 print $out pack('n', $c);
838 0 $last = $c;
839 }
840 0 $self->_set_alignment(1);
841 } elsif ($cmd eq '.uint16_half_up') { # INTERNAL COMMAND! NOT FOR DOCS!
842 0 my $last;
843 0 foreach my $str (@args) {
844 0 my $c = $self->_parse_int($str, $last);
845 0 print $out pack('n', ($c / 2) + ($c & 1));
846 0 $last = $c;
847 }
848 0 $self->_set_alignment(1);
849 ▶ } elsif ($cmd eq '.string' && scalar(@args) >= 2) {
Condition0%0/3
$cmd eq ".string" and scalar @args >= 2
!ll&&!rl&&r
000
MC/DC0%0/2
$cmd eq ".string" and scalar @args >= 2
$cmd eq ".string" scalar @args >= 2
Truth table0%0/3
A and B
A= $cmd eq ".string"B= scalar @args >= 2
ABresult
0X0
100
111
850 0 my $key = 'string$'.$args[0];
851 0 my $catted = '';
852 0 foreach my $str (@args[1..$#args]) {
853 0 $catted .= $self->_parse_string($str);
854 }
855 0 $self->{alias_rodata_idx}{$key} = $self->{rodata}->add_blob($catted);
856 0 ▶ push(@{$self->{aliases}{'size$'.$key} //= []}, length($catted));
Condition0%0/2
$self->{"aliases"}{'size$' . $key} //= []
l!l
00
MC/DC0%0/1
$self->{"aliases"}{'size$' . $key} //= []
$self->{"aliases"}{'size$' . $key}
Truth table0%0/2
A
A= $self->{"aliases"}{'size$' . $key}
Aresult
11
00
857 ▶ } elsif ($cmd eq 'open' && scalar(@args) == 2 && $self->_get_value_type($args[0]) eq 'reg' && $self->_get_value_type($args[1]) eq 'string') {
Condition0%0/9
$cmd eq "open" and scalar @args == 2 and $self->_get_value_type($args[0]) eq "reg" and $self->_get_value_type($args[1]) eq "string"
!ll&&!rl&&r
000
$cmd eq "open" and scalar @args == 2 and $self->_get_value_type($args[0]) eq "reg"
!ll&&!rl&&r
000
$cmd eq "open" and scalar @args == 2
!ll&&!rl&&r
000
MC/DC0%0/4
$cmd eq "open" and scalar @args == 2 and $self->_get_value_type($args[0]) eq "reg" and $self->_get_value_type($args[1]) eq "string"
$cmd eq "open" scalar @args == 2 $self->_get_value_type($args[0]) eq "reg" $self->_get_value_type($args[1]) eq "string"
Truth table0%0/5
A and B and C and D
A= $cmd eq "open"B= scalar @args == 2C= $self->_get_value_type($args[0]) eq "reg"D= $self->_get_value_type($args[1]) eq "string"
ABCDresult
0XXX0
10XX0
110X0
11100
11111
858 0 my $key = $self->_autostring_allocate($self->_parse_string($args[1]));
859 0 $self->_proc_parts(['substr', $args[0], 'program_text', $key, 'end$'.$key], $opts);
860 ▶ } elsif ($cmd eq 'open' && scalar(@args) == 2 && $self->_get_value_type($args[0]) eq 'reg' && $self->_get_value_type($args[1]) eq 'port') {
Condition0%0/9
$cmd eq "open" and scalar @args == 2 and $self->_get_value_type($args[0]) eq "reg" and $self->_get_value_type($args[1]) eq "port"
!ll&&!rl&&r
000
$cmd eq "open" and scalar @args == 2 and $self->_get_value_type($args[0]) eq "reg"
!ll&&!rl&&r
000
$cmd eq "open" and scalar @args == 2
!ll&&!rl&&r
000
MC/DC0%0/4
$cmd eq "open" and scalar @args == 2 and $self->_get_value_type($args[0]) eq "reg" and $self->_get_value_type($args[1]) eq "port"
$cmd eq "open" scalar @args == 2 $self->_get_value_type($args[0]) eq "reg" $self->_get_value_type($args[1]) eq "port"
Truth table0%0/5
A and B and C and D
A= $cmd eq "open"B= scalar @args == 2C= $self->_get_value_type($args[0]) eq "reg"D= $self->_get_value_type($args[1]) eq "port"
ABCDresult
0XXX0
10XX0
110X0
11100
11111
861 0 my $reg = $self->_reg_alloc_phy('user*');
862  
863 0 ▶ $self->_reg_alloc_phy('out') if $args[0] ne 'out';
Branch: 1 branch
BranchTrueFalseTotal
if $args[0] ne "out" 0 0 0
864  
865 0 $self->_reheat_mappings($args[0], $reg, 'out');
866  
867 0 $self->_proc_parts(['open', $reg, $args[1] =~ s/^%//r], $opts);
868 0 $self->_proc_parts(['getvalue', 'out', 'context', $reg], $opts);
869  
870 0 ▶ if ($args[0] ne 'out') {
Branch: 1 branch
BranchTrueFalseTotal
if ($args[0] ne "out") 0 0 0
871 0 $self->_proc_parts(['replace', $args[0], 'out'], $opts);
872 }
873  
874 0 ▶ $self->_proc_parts(['unref', $reg], $opts) if $self->{settings}{synthetic_auto_unref};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"settings"}{"synthetic_auto_unref"} 0 0 0
875 ▶ } elsif ($cmd eq 'byte_transfer' && scalar(@args) == 2 && $self->_get_value_type($args[0]) eq 'reg' && $self->_get_value_type($args[1]) eq 'string') {
Condition0%0/9
$cmd eq "byte_transfer" and scalar @args == 2 and $self->_get_value_type($args[0]) eq "reg" and $self->_get_value_type($args[1]) eq "string"
!ll&&!rl&&r
000
$cmd eq "byte_transfer" and scalar @args == 2 and $self->_get_value_type($args[0]) eq "reg"
!ll&&!rl&&r
000
$cmd eq "byte_transfer" and scalar @args == 2
!ll&&!rl&&r
000
MC/DC0%0/4
$cmd eq "byte_transfer" and scalar @args == 2 and $self->_get_value_type($args[0]) eq "reg" and $self->_get_value_type($args[1]) eq "string"
$cmd eq "byte_transfer" scalar @args == 2 $self->_get_value_type($args[0]) eq "reg" $self->_get_value_type($args[1]) eq "string"
Truth table0%0/5
A and B and C and D
A= $cmd eq "byte_transfer"B= scalar @args == 2C= $self->_get_value_type($args[0]) eq "reg"D= $self->_get_value_type($args[1]) eq "string"
ABCDresult
0XXX0
10XX0
110X0
11100
11111
876 0 my $key = $self->_autostring_allocate($self->_parse_string($args[1]));
877 0 my $reg = $self->_reg_alloc_phy('user*');
878  
879 0 $self->_reheat_mappings($args[0], $reg);
880  
881 0 $self->_proc_parts(['substr', $reg, 'program_text', $key, 'end$'.$key], $opts);
882 0 $self->_proc_parts(['byte_transfer', $args[0], $reg, 'size$'.$key], $opts);
883 0 ▶ $self->_proc_parts(['unref', $reg], $opts) if $self->{settings}{synthetic_auto_unref};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"settings"}{"synthetic_auto_unref"} 0 0 0
884 ▶ } elsif ($cmd eq '.rodata' && scalar(@args) == 0) { # INTERNAL COMMAND! NOT FOR DOCS!
Condition0%0/3
$cmd eq ".rodata" and scalar @args == 0
!ll&&!rl&&r
000
MC/DC0%0/2
$cmd eq ".rodata" and scalar @args == 0
$cmd eq ".rodata" scalar @args == 0
Truth table0%0/3
A and B
A= $cmd eq ".rodata"B= scalar @args == 0
ABresult
0X0
100
111
885 0 my $aliases = $self->{aliases};
886 0 my $rodata = $self->{rodata};
887 0 my $base = $out->tell;
888 0 print $out $rodata->result;
889 0 $self->_set_alignment(1);
890 0 foreach my $key (keys %{$self->{alias_rodata_idx}}) {
891 0 my $idx = $self->{alias_rodata_idx}{$key};
892 0 my $offset = $rodata->offset(index => $idx) + $base;
893 0 my $size = $aliases->{'size$'.$key}[-1];
894 0 ▶ push(@{$aliases->{$key} //= []}, $offset);
Condition0%0/2
$aliases->{$key} //= []
l!l
00
MC/DC0%0/1
$aliases->{$key} //= []
$aliases->{$key}
Truth table0%0/2
A
A= $aliases->{$key}
Aresult
11
00
895 0 ▶ push(@{$aliases->{'end$'.$key} //= []}, $offset + $size) if defined $size;
Branch: 1 branch
BranchTrueFalseTotal
if defined $size 0 0 0
Condition0%0/2
$$aliases{'end$' . $key} //= []
l!l
00
MC/DC0%0/1
$$aliases{'end$' . $key} //= []
$$aliases{'end$' . $key}
Truth table0%0/2
A
A= $$aliases{'end$' . $key}
Aresult
11
00
896 }
897 } elsif ($cmd eq '.include') {
898 0 foreach my $arg (@args) {
899 0 my $fh = $self->_open_file($self->_parse_string($arg));
900 0 $fh->binmode;
901 0 $fh->binmode(':utf8');
902  
903 0 $self->_proc_input($fh);
904 }
905 } elsif ($cmd eq '.cat') {
906 0 local $/ = \4096;
907 0 foreach my $arg (@args) {
908 0 my $fh = $self->_open_file($self->_parse_string($arg));
909 0 $fh->binmode;
910  
911 0 ▶ print $out $_ while <$fh>;
Branch: 1 branch
BranchTrueFalseTotal
defined($_ = readline $fh) and do { print $out $_ } 0 0 0
912 }
913 0 $self->_set_alignment(1);
914 ▶ } elsif ($cmd eq '.noops' && scalar(@args) == 1) {
Condition0%0/3
$cmd eq ".noops" and scalar @args == 1
!ll&&!rl&&r
000
MC/DC0%0/2
$cmd eq ".noops" and scalar @args == 1
$cmd eq ".noops" scalar @args == 1
Truth table0%0/3
A and B
A= $cmd eq ".noops"B= scalar @args == 1
ABresult
0X0
100
111
915 0 my $num = $self->_parse_int($args[0]);
916 0 my $opcode = SIRTX::VM::Opcode->from_template(parts => [qw(noop)], assembler => $self);
917  
918 0 $self->_align($opcode->required_alignment, 1);
919 0 ▶ for (my $i = 0; $i < $num; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $num) 0 0 0
920 0 $opcode->write($out);
921 }
922 0 $self->_set_alignment($opcode->new_alignment);
923 ▶ } elsif ($cmd eq '.org' && scalar(@args) == 1) {
Condition0%0/3
$cmd eq ".org" and scalar @args == 1
!ll&&!rl&&r
000
MC/DC0%0/2
$cmd eq ".org" and scalar @args == 1
$cmd eq ".org" scalar @args == 1
Truth table0%0/3
A and B
A= $cmd eq ".org"B= scalar @args == 1
ABresult
0X0
100
111
924 0 my $p = $self->_parse_int($args[0], $out->tell);
925 0 ▶ carp 'New address in .org is not a multiple of the word size: line '.$opts->{line} if $p & 1;
Branch: 1 branch
BranchTrueFalseTotal
if $p & 1 0 0 0
926 0 $out->seek($p, SEEK_SET);
927 0 $self->_set_alignment(1);
928 ▶ } elsif ($cmd eq '.align' && scalar(@args) == 1) {
Condition0%0/3
$cmd eq ".align" and scalar @args == 1
!ll&&!rl&&r
000
MC/DC0%0/2
$cmd eq ".align" and scalar @args == 1
$cmd eq ".align" scalar @args == 1
Truth table0%0/3
A and B
A= $cmd eq ".align"B= scalar @args == 1
ABresult
0X0
100
111
929 0 my $p = $self->_parse_int($args[0]);
930 0 $self->_align($p);
931 ▶ } elsif ($cmd eq '.host_defined_auto_range' && scalar(@args) == 2 && $self->_get_value_type($args[0]) eq 'int' && $self->_get_value_type($args[1]) eq 'int') {
Condition0%0/9
$cmd eq ".host_defined_auto_range" and scalar @args == 2 and $self->_get_value_type($args[0]) eq "int" and $self->_get_value_type($args[1]) eq "int"
!ll&&!rl&&r
000
$cmd eq ".host_defined_auto_range" and scalar @args == 2 and $self->_get_value_type($args[0]) eq "int"
!ll&&!rl&&r
000
$cmd eq ".host_defined_auto_range" and scalar @args == 2
!ll&&!rl&&r
000
MC/DC0%0/4
$cmd eq ".host_defined_auto_range" and scalar @args == 2 and $self->_get_value_type($args[0]) eq "int" and $self->_get_value_type($args[1]) eq "int"
$cmd eq ".host_defined_auto_range" scalar @args == 2 $self->_get_value_type($args[0]) eq "int" $self->_get_value_type($args[1]) eq "int"
Truth table0%0/5
A and B and C and D
A= $cmd eq ".host_defined_auto_range"B= scalar @args == 2C= $self->_get_value_type($args[0]) eq "int"D= $self->_get_value_type($args[1]) eq "int"
ABCDresult
0XXX0
10XX0
110X0
11100
11111
932 0 my $start = $self->_parse_int($args[0]);
933 0 my $end = $self->_parse_int($args[1], $start);
934 0 ▶ croak 'Invalid range for host defined identifiers: '.$start.' to '.$end if $end < $start || $start < 1;
Branch: 1 branch
BranchTrueFalseTotal
if $end < $start or $start < 1 0 0 0
Condition0%0/3
$end < $start or $start < 1
l!l&&r!l&&!r
000
MC/DC0%0/2
$end < $start or $start < 1
$end < $start $start < 1
Truth table0%0/3
A or B
A= $end < $startB= $start < 1
ABresult
1X1
011
000
935 0 ▶ croak 'Host defined range already set, trying to set it again in line '.$opts->{line} if defined $self->{auto_host_defined};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"auto_host_defined"} 0 0 0
936 0 $self->{auto_host_defined} = [$start, $end, $start];
937 ▶ } elsif ($cmd eq '.label' && (scalar(@args) == 1 || scalar(@args) == 3) && $args[0] =~ /^[a-z0-9A-Z_]+$/ && (scalar(@args) == 1 || ($args[1] eq 'as' && $args[2] =~ /^~[0-9]+$/))) {
Condition0%0/18
$cmd eq ".label" and scalar @args == 1 || scalar @args == 3 and $args[0] =~ /^[a-z0-9A-Z_]+$/u and scalar @args == 1 || $args[1] eq "as" && $args[2] =~ /^~[0-9]+$/u
!ll&&!rl&&r
000
$cmd eq ".label" and scalar @args == 1 || scalar @args == 3 and $args[0] =~ /^[a-z0-9A-Z_]+$/u
!ll&&!rl&&r
000
$cmd eq ".label" and scalar @args == 1 || scalar @args == 3
!ll&&!rl&&r
000
scalar @args == 1 or scalar @args == 3
l!l&&r!l&&!r
000
scalar @args == 1 or $args[1] eq "as" and $args[2] =~ /^~[0-9]+$/u
l!l&&r!l&&!r
000
$args[1] eq "as" and $args[2] =~ /^~[0-9]+$/u
!ll&&!rl&&r
000
MC/DC0%0/7
$cmd eq ".label" and scalar @args == 1 || scalar @args == 3 and $args[0] =~ /^[a-z0-9A-Z_]+$/u and scalar @args == 1 || $args[1] eq "as" && $args[2] =~ /^~[0-9]+$/u
$cmd eq ".label" scalar @args == 1 scalar @args == 3 $args[0] =~ /^[a-z0-9A-Z_]+$/u scalar @args == 1 $args[1] eq "as" $args[2] =~ /^~[0-9]+$/u
Truth table0%0/12
A and B or C and D and E or F and G
A= $cmd eq ".label"B= scalar @args == 1C= scalar @args == 3D= $args[0] =~ /^[a-z0-9A-Z_]+$/uE= scalar @args == 1F= $args[1] eq "as"G= $args[2] =~ /^~[0-9]+$/u
ABCDEFGresult
0XXXXXX0
100XXXX0
11X0XXX0
1010XXX0
11X100X0
11X10100
101100X0
10110100
11X11XX1
11X10111
10111XX1
10110111
938 0 $self->{current}{label} = 'label$'.$args[0];
939 0 $self->_save_position($self->{current}{label});
940 0 ▶ if (scalar(@args) == 3 && $args[1] eq 'as' && $args[2] =~ /^~[0-9]+$/) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @args == 3 and $args[1] eq "as" and $args[2] =~ /^~[0-9]+$/u) 0 0 0
Condition0%0/6
scalar @args == 3 and $args[1] eq "as" and $args[2] =~ /^~[0-9]+$/u
!ll&&!rl&&r
000
scalar @args == 3 and $args[1] eq "as"
!ll&&!rl&&r
000
MC/DC0%0/3
scalar @args == 3 and $args[1] eq "as" and $args[2] =~ /^~[0-9]+$/u
scalar @args == 3 $args[1] eq "as" $args[2] =~ /^~[0-9]+$/u
Truth table0%0/4
A and B and C
A= scalar @args == 3B= $args[1] eq "as"C= $args[2] =~ /^~[0-9]+$/u
ABCresult
0XX0
10X0
1100
1111
941 0 ▶ push(@{$self->{aliases}{'hostdefined$label$'.$self->{current}{label}} //= []}, $args[2]);
Condition0%0/2
$self->{"aliases"}{'hostdefined$label$' . $self->{"current"}{"label"}} //= []
l!l
00
MC/DC0%0/1
$self->{"aliases"}{'hostdefined$label$' . $self->{"current"}{"label"}} //= []
$self->{"aliases"}{'hostdefined$label$' . $self->{"current"}{"label"}}
Truth table0%0/2
A
A= $self->{"aliases"}{'hostdefined$label$' . $self->{"current"}{"label"}}
Aresult
11
00
942 }
943 ▶ } elsif ($cmd eq '.endlabel' && scalar(@args) == 0 && defined($self->{current}{label})) {
Condition0%0/6
$cmd eq ".endlabel" and scalar @args == 0 and defined $self->{"current"}{"label"}
!ll&&!rl&&r
000
$cmd eq ".endlabel" and scalar @args == 0
!ll&&!rl&&r
000
MC/DC0%0/3
$cmd eq ".endlabel" and scalar @args == 0 and defined $self->{"current"}{"label"}
$cmd eq ".endlabel" scalar @args == 0 defined $self->{"current"}{"label"}
Truth table0%0/4
A and B and C
A= $cmd eq ".endlabel"B= scalar @args == 0C= defined $self->{"current"}{"label"}
ABCresult
0XX0
10X0
1100
1111
944 0 $self->_save_endposition($self->{current}{label});
945 0 $self->{current}{label} = undef;
946 ▶ } elsif ($cmd eq '.function' && (scalar(@args) == 1 || scalar(@args) == 3) && $args[0] =~ /^[a-z0-9A-Z_]+$/ && (scalar(@args) == 1 || ($args[1] eq 'as' && $args[2] =~ /^~[0-9]+$/))) {
Condition0%0/18
$cmd eq ".function" and scalar @args == 1 || scalar @args == 3 and $args[0] =~ /^[a-z0-9A-Z_]+$/u and scalar @args == 1 || $args[1] eq "as" && $args[2] =~ /^~[0-9]+$/u
!ll&&!rl&&r
000
$cmd eq ".function" and scalar @args == 1 || scalar @args == 3 and $args[0] =~ /^[a-z0-9A-Z_]+$/u
!ll&&!rl&&r
000
$cmd eq ".function" and scalar @args == 1 || scalar @args == 3
!ll&&!rl&&r
000
scalar @args == 1 or scalar @args == 3
l!l&&r!l&&!r
000
scalar @args == 1 or $args[1] eq "as" and $args[2] =~ /^~[0-9]+$/u
l!l&&r!l&&!r
000
$args[1] eq "as" and $args[2] =~ /^~[0-9]+$/u
!ll&&!rl&&r
000
MC/DC0%0/7
$cmd eq ".function" and scalar @args == 1 || scalar @args == 3 and $args[0] =~ /^[a-z0-9A-Z_]+$/u and scalar @args == 1 || $args[1] eq "as" && $args[2] =~ /^~[0-9]+$/u
$cmd eq ".function" scalar @args == 1 scalar @args == 3 $args[0] =~ /^[a-z0-9A-Z_]+$/u scalar @args == 1 $args[1] eq "as" $args[2] =~ /^~[0-9]+$/u
Truth table0%0/12
A and B or C and D and E or F and G
A= $cmd eq ".function"B= scalar @args == 1C= scalar @args == 3D= $args[0] =~ /^[a-z0-9A-Z_]+$/uE= scalar @args == 1F= $args[1] eq "as"G= $args[2] =~ /^~[0-9]+$/u
ABCDEFGresult
0XXXXXX0
100XXXX0
11X0XXX0
1010XXX0
11X100X0
11X10100
101100X0
10110100
11X11XX1
11X10111
10111XX1
10110111
947 0 $self->_align(2, 1);
948 0 $self->{current}{function} = $args[0];
949 0 $self->_save_position('function$'.$self->{current}{function});
950 0 $self->{rf}->map_reset;
951 0 ▶ if (scalar(@args) == 3 && $args[1] eq 'as' && $args[2] =~ /^~[0-9]+$/) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @args == 3 and $args[1] eq "as" and $args[2] =~ /^~[0-9]+$/u) 0 0 0
Condition0%0/6
scalar @args == 3 and $args[1] eq "as" and $args[2] =~ /^~[0-9]+$/u
!ll&&!rl&&r
000
scalar @args == 3 and $args[1] eq "as"
!ll&&!rl&&r
000
MC/DC0%0/3
scalar @args == 3 and $args[1] eq "as" and $args[2] =~ /^~[0-9]+$/u
scalar @args == 3 $args[1] eq "as" $args[2] =~ /^~[0-9]+$/u
Truth table0%0/4
A and B and C
A= scalar @args == 3B= $args[1] eq "as"C= $args[2] =~ /^~[0-9]+$/u
ABCresult
0XX0
10X0
1100
1111
952 0 ▶ push(@{$self->{aliases}{'hostdefined$function$'.$self->{current}{function}} //= []}, $args[2]);
Condition0%0/2
$self->{"aliases"}{'hostdefined$function$' . $self->{"current"}{"function"}} //= []
l!l
00
MC/DC0%0/1
$self->{"aliases"}{'hostdefined$function$' . $self->{"current"}{"function"}} //= []
$self->{"aliases"}{'hostdefined$function$' . $self->{"current"}{"function"}}
Truth table0%0/2
A
A= $self->{"aliases"}{'hostdefined$function$' . $self->{"current"}{"function"}}
Aresult
11
00
953 }
954 ▶ } elsif ($cmd eq '.endfunction' && scalar(@args) == 0 && defined($self->{current}{function})) {
Condition0%0/6
$cmd eq ".endfunction" and scalar @args == 0 and defined $self->{"current"}{"function"}
!ll&&!rl&&r
000
$cmd eq ".endfunction" and scalar @args == 0
!ll&&!rl&&r
000
MC/DC0%0/3
$cmd eq ".endfunction" and scalar @args == 0 and defined $self->{"current"}{"function"}
$cmd eq ".endfunction" scalar @args == 0 defined $self->{"current"}{"function"}
Truth table0%0/4
A and B and C
A= $cmd eq ".endfunction"B= scalar @args == 0C= defined $self->{"current"}{"function"}
ABCresult
0XX0
10X0
1100
1111
955 0 ▶ unless ($self->{was_return}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"was_return"}) 0 0 0
956 0 $self->_save_position('return$function$'.$self->{current}{function});
957 0 $self->_write_opcode(SIRTX::VM::Opcode->from_template(parts => ['return'], assembler => $self));
958 }
959 0 $self->_save_endposition('function$'.$self->{current}{function});
960 0 $self->{current}{function} = undef;
961 ▶ } elsif ($cmd eq '.section' && (scalar(@args) == 1 || scalar(@args) == 2) && !defined($self->{current}{section})) {
Condition0%0/9
$cmd eq ".section" and scalar @args == 1 || scalar @args == 2 and not defined $self->{"current"}{"section"}
!ll&&!rl&&r
000
$cmd eq ".section" and scalar @args == 1 || scalar @args == 2
!ll&&!rl&&r
000
scalar @args == 1 or scalar @args == 2
l!l&&r!l&&!r
000
MC/DC0%0/4
$cmd eq ".section" and scalar @args == 1 || scalar @args == 2 and not defined $self->{"current"}{"section"}
$cmd eq ".section" scalar @args == 1 scalar @args == 2 not defined $self->{"current"}{"section"}
Truth table0%0/6
A and B or C and not(D)
A= $cmd eq ".section"B= scalar @args == 1C= scalar @args == 2D= not defined $self->{"current"}{"section"}
ABCDresult
0XXX0
100X0
11X00
10100
11X11
10111
962 0 my $S = $_header_ids{$args[0]};
963 0 my $T = 4;
964 0 my $extra;
965 my %tpl;
966  
967 0 ▶ unless (defined $S) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $S) 0 0 0
968 0 croak sprintf('Invalid section: line %s: section %s', $opts->{line}, $args[0]);
969 }
970  
971 0 foreach my $profile (@{$self->{profiles}}) {
972 0 ▶ if (defined(my $disabled = $_disabled_sections{$profile})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $disabled = $_disabled_sections{$profile})) 0 0 0
973 0 ▶ if ($disabled->{$args[0]}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$disabled{$args[0]}) 0 0 0
974 0 croak sprintf('Invalid section for profile: line %s: section %s not allowed in profile %s', $opts->{line}, $args[0], $profile);
975 }
976 }
977 }
978  
979 0 ▶ if (defined(my $bad = $_section_order_bad{$args[0]})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $bad = $_section_order_bad{$args[0]})) 0 0 0
980 0 foreach my $key (@_section_order) {
981 0 ▶ next unless defined $self->{sections}{$key};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"sections"}{$key} 0 0 0
982 0 ▶ croak sprintf('Invalid section: line %s: section %s must not follow section %s', $opts->{line}, $args[0], $key) if defined $bad->{$key};
Branch: 1 branch
BranchTrueFalseTotal
if defined $bad->{$key} 0 0 0
983 }
984 }
985  
986 0 ▶ if (scalar(@args) == 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @args == 2) 0 0 0
987 0 $extra = $self->_parse_string($args[1]);
988 0 my $l = length($extra);
989 0 ▶ croak sprintf('Invalid section magic: line %s: section %s: magic length %u', $opts->{line}, $args[0], $l) if $l != 6 && $l != 4 && $l != 2 && $l != 0;
Branch: 1 branch
BranchTrueFalseTotal
if $l != 6 and $l != 4 and $l != 2 and $l != 0 0 0 0
Condition0%0/9
$l != 6 and $l != 4 and $l != 2 and $l != 0
!ll&&!rl&&r
000
$l != 6 and $l != 4 and $l != 2
!ll&&!rl&&r
000
$l != 6 and $l != 4
!ll&&!rl&&r
000
MC/DC0%0/4
$l != 6 and $l != 4 and $l != 2 and $l != 0
$l != 6 $l != 4 $l != 2 $l != 0
Truth table0%0/5
A and B and C and D
A= $l != 6B= $l != 4C= $l != 2D= $l != 0
ABCDresult
0XXX0
10XX0
110X0
11100
11111
990 0 $T += $l/2;
991 }
992  
993 0 $self->_align(2, 1);
994 0 $self->_save_position('section$'.$args[0]);
995  
996 0 %tpl = (code => 0, P => 0, codeX => 0, S => $S, T => 0);
997  
998 $self->{current}{section} = {
999 0 close_opcode => SIRTX::VM::Opcode->new(%tpl),
1000 name => $args[0],
1001 };
1002  
1003 0 ▶ unless ($self->_using_profile('minimal')) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->_using_profile("minimal")) 0 0 0
1004 0 $self->_write_opcode(SIRTX::VM::Opcode->new(%tpl, T => $T, extra => $extra));
1005 }
1006 0 $self->_save_position('inner$section$'.$args[0]);
1007  
1008 0 $self->{sections}{$args[0]} = {};
1009 ▶ } elsif ($cmd eq '.endsection' && scalar(@args) == 0 && defined(my $section = $self->{current}{section})) {
Condition0%0/6
$cmd eq ".endsection" and scalar @args == 0 and defined(my $section = $self->{"current"}{"section"})
!ll&&!rl&&r
000
$cmd eq ".endsection" and scalar @args == 0
!ll&&!rl&&r
000
MC/DC0%0/3
$cmd eq ".endsection" and scalar @args == 0 and defined(my $section = $self->{"current"}{"section"})
$cmd eq ".endsection" scalar @args == 0 defined(my $section = $self->{"current"}{"section"})
Truth table0%0/4
A and B and C
A= $cmd eq ".endsection"B= scalar @args == 0C= defined(my $section = $self->{"current"}{"section"})
ABCresult
0XX0
10X0
1100
1111
1010 0 my $section_suffix = 'section$'.$section->{name};
1011 0 $self->_save_endposition('inner$'.$section_suffix);
1012 0 ▶ unless ($self->_using_profile('minimal')) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->_using_profile("minimal")) 0 0 0
1013 0 ▶ $self->_write_opcode($section->{close_opcode}) if defined $section->{close_opcode};
Branch: 1 branch
BranchTrueFalseTotal
if defined $section->{"close_opcode"} 0 0 0
1014 }
1015 0 $self->_save_endposition($section_suffix);
1016 0 $self->{current}{section} = undef;
1017 ▶ } elsif ($cmd eq '.chunk' && scalar(@args) >= 2) {
Condition0%0/3
$cmd eq ".chunk" and scalar @args >= 2
!ll&&!rl&&r
000
MC/DC0%0/2
$cmd eq ".chunk" and scalar @args >= 2
$cmd eq ".chunk" scalar @args >= 2
Truth table0%0/3
A and B
A= $cmd eq ".chunk"B= scalar @args >= 2
ABresult
0X0
100
111
1018 0 my @in = @args;
1019 0 my $flags = 0;
1020 0 my $type;
1021 0 my $identifier = 0;
1022 0 my %info;
1023 0 $self->_align(2, 1);
1024  
1025 0 ▶ while (scalar(@in)) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @in) 0 0 0
1026 0 my $c = shift(@in);
1027  
1028 0 ▶ if (($c eq 'of' || $c eq 'as' || $c eq 'name') && scalar(@in)) {
Branch: 2 branches
BranchTrueFalseTotal
if ($c eq 'of' || $c eq 'as' || $c eq 'name' and scalar @in) { } 0 0 0
elsif ($c eq 'standalone') { } 0 0 0
Condition0%0/8
$c eq "of" || $c eq "as" || $c eq "name" and scalar @in
!ll
00
$c eq "of" or $c eq "as" or $c eq "name"
l!l&&r!l&&!r
000
$c eq "of" or $c eq "as"
l!l&&r!l&&!r
000
MC/DC0%0/3
$c eq "of" || $c eq "as" || $c eq "name" and scalar @in
$c eq "of" $c eq "as" $c eq "name"
Truth table0%0/4
A or B or C
A= $c eq "of"B= $c eq "as"C= $c eq "name"
ABCresult
0000
1XX1
01X1
0011
1029 0 $info{$c} = shift(@in);
1030 } elsif ($c eq 'standalone') {
1031 0 $info{$c} = 1;
1032 } else {
1033 0 croak sprintf('Invalid chunk option: line %s: %s', $opts->{line}, $c);
1034 }
1035 }
1036  
1037 0 ▶ if (defined(my $as = $info{as})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $as = $info{"as"})) 0 0 0
1038 0 ▶ if ($as !~ /^~([0-9]+)$/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($as =~ /^~([0-9]+)$/u) 0 0 0
1039 0 croak sprintf('Invalid chunk option: line %s: as %s', $opts->{line}, $as);
1040 }
1041  
1042 0 $identifier = int($1);
1043 }
1044  
1045 0 ▶ if (defined($info{name}) && length($info{name})) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $info{'name'} and length $info{'name'}) { } 0 0 0
elsif ($identifier) { } 0 0 0
Condition0%0/3
defined $info{"name"} and length $info{"name"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $info{"name"} and length $info{"name"}
defined $info{"name"} length $info{"name"}
Truth table0%0/3
A and B
A= defined $info{"name"}B= length $info{"name"}
ABresult
0X0
100
111
1046 0 ▶ unless ($info{name} =~ /^[0-9a-z]+$/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($info{"name"} =~ /^[0-9a-z]+$/u) 0 0 0
1047 0 croak sprintf('Invalid chunk name: line %s: %s', $opts->{line}, $info{name});
1048 }
1049 } elsif ($identifier) {
1050 0 $info{name} = sprintf('idchunk$%u', $identifier);
1051 } else {
1052 0 state $autochunk = 0;
1053 0 $info{name} = sprintf('autochunk$%u', $autochunk++);
1054 }
1055  
1056 # Allow for chunks' ID to be accessed via it's name
1057 0 ▶ push(@{$self->{aliases}{'hostdefined$chunk$'.$info{name}} //= []}, $info{as}) if defined $info{as};
Branch: 1 branch
BranchTrueFalseTotal
if defined $info{"as"} 0 0 0
Condition0%0/2
$self->{"aliases"}{'hostdefined$chunk$' . $info{"name"}} //= []
l!l
00
MC/DC0%0/1
$self->{"aliases"}{'hostdefined$chunk$' . $info{"name"}} //= []
$self->{"aliases"}{'hostdefined$chunk$' . $info{"name"}}
Truth table0%0/2
A
A= $self->{"aliases"}{'hostdefined$chunk$' . $info{"name"}}
Aresult
11
00
1058  
1059 0 ▶ if (defined(my $of = $info{of})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $of = $info{'of'})) { } 0 0 0
1060 0 ▶ if ($of =~ /^~([0-9]+)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($of =~ /^~([0-9]+)$/u) { } 0 0 0
1061 0 $type = int($1);
1062 0 $flags |= 1<<15;
1063 } else {
1064 0 my $t;
1065 0 ($t, $type) = $self->_parse_id($of);
1066  
1067 0 ▶ if ($t eq 'sid') {
Branch: 2 branches
BranchTrueFalseTotal
if ($t eq 'sid') { } 0 0 0
elsif ($t eq 'sni') { } 0 0 0
1068 0 $flags |= 1<<14;
1069 } elsif ($t eq 'sni') {
1070 # no-op
1071 } else {
1072 0 croak sprintf('Invalid chunk type: line %s: of type %s not supported', $opts->{line}, $t);
1073 }
1074 }
1075 } else {
1076 0 croak sprintf('Invalid chunk: line %s: no of (type) given', $opts->{line});
1077 }
1078  
1079 0 ▶ $flags |= 1<<7 if $info{standalone};
Branch: 1 branch
BranchTrueFalseTotal
if $info{"standalone"} 0 0 0
1080 0 ▶ $flags |= 1<<1 if $identifier > 0;
Branch: 1 branch
BranchTrueFalseTotal
if $identifier > 0 0 0 0
1081  
1082 0 print $out chr(0x06), chr(0x38+1);
1083 0 $self->_pushback(pos => $out->tell, parts => ['.uint16_half_up', 'size$chunk$'.$info{name}], opts => {%{$opts}, size => 2});
1084 0 print $out chr(0) x 2;
1085  
1086 0 $self->{current}{chunk} = $info{name};
1087 0 $self->_save_position('chunk$'.$info{name});
1088  
1089 0 ▶ $self->_pushback(pos => $out->tell, parts => ['.uint16', $flags], opts => {%{$opts}, size => 2}, update => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1090 0 my (undef, $entry) = @_;
1091 0 $entry->{parts}[1] |= $self->{aliases}{'size$chunk$'.$info{name}}[-1] & 1; # update padding flag
1092 0 });
1093 0 print $out chr(0) x 2;
1094  
1095 0 print $out pack('n', $type);
1096 0 ▶ print $out pack('n', $identifier) if $identifier > 0;
Branch: 1 branch
BranchTrueFalseTotal
if $identifier > 0 0 0 0
1097 0 $self->_save_position('inner$chunk$'.$info{name});
1098 ▶ } elsif ($cmd eq '.endchunk' && scalar(@args) == 0 && defined($self->{current}{chunk})) {
Condition0%0/6
$cmd eq ".endchunk" and scalar @args == 0 and defined $self->{"current"}{"chunk"}
!ll&&!rl&&r
000
$cmd eq ".endchunk" and scalar @args == 0
!ll&&!rl&&r
000
MC/DC0%0/3
$cmd eq ".endchunk" and scalar @args == 0 and defined $self->{"current"}{"chunk"}
$cmd eq ".endchunk" scalar @args == 0 defined $self->{"current"}{"chunk"}
Truth table0%0/4
A and B and C
A= $cmd eq ".endchunk"B= scalar @args == 0C= defined $self->{"current"}{"chunk"}
ABCresult
0XX0
10X0
1100
1111
1099 0 $self->_save_endposition('inner$chunk$'.$self->{current}{chunk});
1100 0 $self->_save_endposition('chunk$'.$self->{current}{chunk});
1101 0 $self->{current}{chunk} = undef;
1102 0 $self->_align(2);
1103 ▶ } elsif ($cmd =~ /^\.(regmap_auto|synthetic_auto_unref)$/ && scalar(@args) == 1) {
Condition0%0/3
$cmd =~ /^\.(regmap_auto|synthetic_auto_unref)$/u and scalar @args == 1
!ll&&!rl&&r
000
MC/DC0%0/2
$cmd =~ /^\.(regmap_auto|synthetic_auto_unref)$/u and scalar @args == 1
$cmd =~ /^\.(regmap_auto|synthetic_auto_unref)$/u scalar @args == 1
Truth table0%0/3
A and B
A= $cmd =~ /^\.(regmap_auto|synthetic_auto_unref)$/uB= scalar @args == 1
ABresult
0X0
100
111
1104 0 $self->{settings}{$1} = $self->_parse_bool($args[0]);
1105 ▶ } elsif ($cmd eq '.map' && scalar(@args) == 2) {
Condition0%0/3
$cmd eq ".map" and scalar @args == 2
!ll&&!rl&&r
000
MC/DC0%0/2
$cmd eq ".map" and scalar @args == 2
$cmd eq ".map" scalar @args == 2
Truth table0%0/3
A and B
A= $cmd eq ".map"B= scalar @args == 2
ABresult
0X0
100
111
1106 0 $self->_reg_map(@args);
1107 } elsif ($cmd eq '.forget_mapped') {
1108 0 $self->_reg_map($_ => '_unknown_') foreach $self->{rf}->expand(@args);
1109 } elsif ($cmd eq '.forget_register_state') {
1110 0 $self->{rf}->forget_register_state(@args);
1111 } elsif ($cmd eq '.force_mapped') {
1112 0 $self->_force_mapped($_) foreach $self->{rf}->expand(@args);
1113 ▶ } elsif ($cmd eq '.register_file_store' && scalar(@args) == 1) {
Condition0%0/3
$cmd eq ".register_file_store" and scalar @args == 1
!ll&&!rl&&r
000
MC/DC0%0/2
$cmd eq ".register_file_store" and scalar @args == 1
$cmd eq ".register_file_store" scalar @args == 1
Truth table0%0/3
A and B
A= $cmd eq ".register_file_store"B= scalar @args == 1
ABresult
0X0
100
111
1114 0 my $name = 'index$registerfilestore$'.$args[0];
1115 0 ▶ push(@{$self->{aliases}{$name} //= []}, scalar(@{$self->{rf_stored}}));
Condition0%0/2
$self->{"aliases"}{$name} //= []
l!l
00
MC/DC0%0/1
$self->{"aliases"}{$name} //= []
$self->{"aliases"}{$name}
Truth table0%0/2
A
A= $self->{"aliases"}{$name}
Aresult
11
00
1116 0 push(@{$self->{rf_stored}}, $self->{rf}->clone);
1117 ▶ } elsif ($cmd eq '.register_file_restore' && scalar(@args) == 1) {
Condition0%0/3
$cmd eq ".register_file_restore" and scalar @args == 1
!ll&&!rl&&r
000
MC/DC0%0/2
$cmd eq ".register_file_restore" and scalar @args == 1
$cmd eq ".register_file_restore" scalar @args == 1
Truth table0%0/3
A and B
A= $cmd eq ".register_file_restore"B= scalar @args == 1
ABresult
0X0
100
111
1118 0 my $name = 'index$registerfilestore$'.$args[0];
1119 0 ▶ my $index = ($self->{aliases}{$name} // [])->[-1];
Condition0%0/2
$self->{"aliases"}{$name} // []
l!l
00
MC/DC0%0/1
$self->{"aliases"}{$name} // []
$self->{"aliases"}{$name}
Truth table0%0/2
A
A= $self->{"aliases"}{$name}
Aresult
11
00
1120 0 my $rf;
1121 0 ▶ croak 'No such register file store alias: '.$name unless defined $index;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $index 0 0 0
1122 0 $index = $self->_parse_int($index);
1123 0 $rf = $self->{rf_stored}[$index];
1124 0 ▶ croak 'No such register file store index: '.$index unless defined $rf;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $rf 0 0 0
1125 0 $self->{rf} = $rf->clone;
1126 ▶ } elsif ($cmd eq '.mine' || $cmd eq '.yours' || $cmd eq '.theirs') {
Condition0%0/6
$cmd eq ".mine" or $cmd eq ".yours" or $cmd eq ".theirs"
l!l&&r!l&&!r
000
$cmd eq ".mine" or $cmd eq ".yours"
l!l&&r!l&&!r
000
MC/DC0%0/3
$cmd eq ".mine" or $cmd eq ".yours" or $cmd eq ".theirs"
$cmd eq ".mine" $cmd eq ".yours" $cmd eq ".theirs"
Truth table0%0/4
A or B or C
A= $cmd eq ".mine"B= $cmd eq ".yours"C= $cmd eq ".theirs"
ABCresult
1XX1
01X1
0011
0000
1127 0 ▶ my $mode = $cmd eq '.mine' ? SIRTX::VM::Register::OWNER_MINE() : $cmd eq '.yours' ? SIRTX::VM::Register::OWNER_YOURS() : SIRTX::VM::Register::OWNER_THEIRS();
Branch: 2 branches
BranchTrueFalseTotal
$cmd eq '.mine' ? : 0 0 0
$cmd eq '.yours' ? : 0 0 0
1128 0 my $rf = $self->{rf};
1129 0 foreach my $reg ($rf->expand(@args)) {
1130 0 $rf->register_owner($reg, $mode);
1131 }
1132 ▶ } elsif ($cmd eq '.hot' || $cmd eq '.cold' || $cmd eq '.lukewarm') {
Condition0%0/6
$cmd eq ".hot" or $cmd eq ".cold" or $cmd eq ".lukewarm"
l!l&&r!l&&!r
000
$cmd eq ".hot" or $cmd eq ".cold"
l!l&&r!l&&!r
000
MC/DC0%0/3
$cmd eq ".hot" or $cmd eq ".cold" or $cmd eq ".lukewarm"
$cmd eq ".hot" $cmd eq ".cold" $cmd eq ".lukewarm"
Truth table0%0/4
A or B or C
A= $cmd eq ".hot"B= $cmd eq ".cold"C= $cmd eq ".lukewarm"
ABCresult
1XX1
01X1
0011
0000
1133 0 ▶ my $mode = $cmd eq '.hot' ? SIRTX::VM::Register::TEMPERATURE_HOT() : $cmd eq '.cold' ? SIRTX::VM::Register::TEMPERATURE_COLD() : SIRTX::VM::Register::TEMPERATURE_LUKEWARM();
Branch: 2 branches
BranchTrueFalseTotal
$cmd eq '.hot' ? : 0 0 0
$cmd eq '.cold' ? : 0 0 0
1134 0 my $rf = $self->{rf};
1135 0 foreach my $reg ($rf->expand(@args)) {
1136 0 $rf->register_temperature($reg, $mode);
1137 }
1138 ▶ } elsif ($cmd eq '.regattr' && scalar(@args) >= 1) {
Condition0%0/3
$cmd eq ".regattr" and scalar @args >= 1
!ll&&!rl&&r
000
MC/DC0%0/2
$cmd eq ".regattr" and scalar @args >= 1
$cmd eq ".regattr" scalar @args >= 1
Truth table0%0/3
A and B
A= $cmd eq ".regattr"B= scalar @args >= 1
ABresult
0X0
100
111
1139 0 my ($reg, @attrs) = @args;
1140 0 my $rf = $self->{rf};
1141  
1142 0 foreach my $attr (@attrs) {
1143 0 ▶ if ($attr eq 'mine') {
Branch: 7 branches
BranchTrueFalseTotal
if ($attr eq 'mine') { } 0 0 0
elsif ($attr eq 'yours') { } 0 0 0
elsif ($attr eq 'theirs') { } 0 0 0
elsif ($attr eq 'hot') { } 0 0 0
elsif ($attr eq 'cold') { } 0 0 0
elsif ($attr eq 'lukewarm') { } 0 0 0
elsif ($attr eq 'volatile') { } 0 0 0
1144 0 $rf->register_owner($reg, SIRTX::VM::Register::OWNER_MINE());
1145 } elsif ($attr eq 'yours') {
1146 0 $rf->register_owner($reg, SIRTX::VM::Register::OWNER_YOURS());
1147 } elsif ($attr eq 'theirs') {
1148 0 $rf->register_owner($reg, SIRTX::VM::Register::OWNER_THEIRS());
1149 } elsif ($attr eq 'hot') {
1150 0 $rf->register_temperature($reg, SIRTX::VM::Register::TEMPERATURE_HOT());
1151 } elsif ($attr eq 'cold') {
1152 0 $rf->register_temperature($reg, SIRTX::VM::Register::TEMPERATURE_COLD());
1153 } elsif ($attr eq 'lukewarm') {
1154 0 $rf->register_temperature($reg, SIRTX::VM::Register::TEMPERATURE_LUKEWARM());
1155 } elsif ($attr eq 'volatile') {
1156 # No-op
1157 } else {
1158 0 croak sprintf('Invalid register attribute: line %s: register %s: attribute: %s', $opts->{line}, $reg, $attr);
1159 }
1160 }
1161  
1162 ▶ } elsif ($cmd eq 'map' && scalar(@args) == 2) {
Condition0%0/3
$cmd eq "map" and scalar @args == 2
!ll&&!rl&&r
000
MC/DC0%0/2
$cmd eq "map" and scalar @args == 2
$cmd eq "map" scalar @args == 2
Truth table0%0/3
A and B
A= $cmd eq "map"B= scalar @args == 2
ABresult
0X0
100
111
1163 0 $self->_reg_map_and_write(@args);
1164  
1165 0 } elsif (defined($opcode = eval {SIRTX::VM::Opcode->from_template(parts => $parts, assembler => $self, size => $opts->{size}, line => $opts->{line}, out => $out, autodie => $autodie)})) {
1166 0 $self->_write_opcode($opcode);
1167 0 $was_return = $opcode->is_return;
1168 0 ▶ ${$autodie} = undef if $opcode->is_autodie;
Branch: 1 branch
BranchTrueFalseTotal
if $opcode->is_autodie 0 0 0
1169 } elsif (defined($opcode = eval {SIRTX::VM::Opcode->from_template(parts => [
1170 $parts->[0],
1171 0 ▶ map {scalar(eval {$self->_get_value_type($_) eq 'alias'}) ? 0xFFF0 : $_} $parts->@[1 .. (scalar(@{$parts}) - 1)]
Branch: 1 branch
BranchTrueFalseTotal
scalar eval { do { $self->_get_value_type($_) eq 'alias' } } ? : 0 0 0
1172 0 ], assembler => $self, size => $opts->{size}, line => $opts->{line}, out => $out, autodie => $autodie)})) {
1173 0 my $pos;
1174  
1175 # first align, then look where we are.
1176 0 $self->_align($opcode->required_alignment, 1);
1177 0 $pos = $self->{out}->tell;
1178  
1179 0 $self->_write_opcode($opcode);
1180 0 $was_return = $opcode->is_return;
1181 0 ▶ ${$autodie} = undef if $opcode->is_autodie;
Branch: 1 branch
BranchTrueFalseTotal
if $opcode->is_autodie 0 0 0
1182 0 $self->_pushback(pos => $pos, parts => $parts, opts => {%{$opts}, size => $opcode->required_size});
1183 ▶ } elsif (defined($_info{$cmd}) && scalar(@args) > 1 && $args[0] =~ /^~0?$/) {
Condition0%0/6
defined $_info{$cmd} and scalar @args > 1 and $args[0] =~ /^~0?$/u
!ll&&!rl&&r
000
defined $_info{$cmd} and scalar @args > 1
!ll&&!rl&&r
000
MC/DC0%0/3
defined $_info{$cmd} and scalar @args > 1 and $args[0] =~ /^~0?$/u
defined $_info{$cmd} scalar @args > 1 $args[0] =~ /^~0?$/u
Truth table0%0/4
A and B and C
A= defined $_info{$cmd}B= scalar @args > 1C= $args[0] =~ /^~0?$/u
ABCresult
0XX0
10X0
1100
1111
1184 # no-op for now.
1185 } else {
1186 0 my $done;
1187  
1188 0 ▶ if (defined(my $entry = $self->_get_synthetic($cmd))) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $entry = $self->_get_synthetic($cmd))) 0 0 0
1189 outer:
1190 0 ▶ for (my $i = 0; $i < scalar(@{$entry}); $i += 3) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @{$entry;}) 0 0 0
1191 0 my @argmap = @{$entry->[$i]};
1192 0 my @requests = @{$entry->[$i+1]};
1193 0 my %updates;
1194 my @used_registers;
1195 0 my @allocations;
1196 0 my $reset_autodie;
1197  
1198 0 ▶ if (scalar(@argmap) >= 2 && $argmap[-2] eq 'any...') {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @argmap >= 2 and $argmap[-2] eq 'any...') { } 0 0 0
Condition0%0/3
scalar @argmap >= 2 and $argmap[-2] eq "any..."
!ll&&!rl&&r
000
MC/DC0%0/2
scalar @argmap >= 2 and $argmap[-2] eq "any..."
scalar @argmap >= 2 $argmap[-2] eq "any..."
Truth table0%0/3
A and B
A= scalar @argmap >= 2B= $argmap[-2] eq "any..."
ABresult
0X0
100
111
1199 0 ▶ next unless (scalar(@args)*2) >= scalar(@argmap);
Branch: 1 branch
BranchTrueFalseTotal
unless scalar(@args) * 2 >= scalar @argmap 0 0 0
1200 } else {
1201 0 ▶ next unless (scalar(@args)*2) == scalar(@argmap);
Branch: 1 branch
BranchTrueFalseTotal
unless scalar(@args) * 2 == scalar @argmap 0 0 0
1202 }
1203  
1204 # Process argument map:
1205 0 ▶ for (my $j = 0; ($j*2) < scalar(@argmap); $j++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($j * 2 < scalar @argmap) 0 0 0
1206 0 my $type = $argmap[$j*2 + 0];
1207 0 my $dst = $argmap[$j*2 + 1];
1208 0 my $val = $args[$j];
1209  
1210 0 ▶ if ($type =~ /^".+"$/) {
Branch: 3 branches
BranchTrueFalseTotal
if ($type =~ /^".+"$/u) { } 0 0 0
elsif ($type eq 'any') { } 0 0 0
elsif ($type eq 'any...') { } 0 0 0
1211 0 ▶ next outer if $val ne $self->_parse_string($type);
Branch: 1 branch
BranchTrueFalseTotal
if $val ne $self->_parse_string($type) 0 0 0
1212 } elsif ($type eq 'any') {
1213 # no-op.
1214 } elsif ($type eq 'any...') {
1215 0 $val = [@args[$j..$#args]];
1216 } else {
1217 0 my $t = $self->_get_value_type($val);
1218 0 ▶ push(@used_registers, $val) if $t eq 'reg';
Branch: 1 branch
BranchTrueFalseTotal
if $t eq "reg" 0 0 0
1219 0 ▶ if (ref $type) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $type) { } 0 0 0
1220 0 my $found;
1221 inner:
1222 0 foreach my $tw (@{$type}) {
1223 0 ▶ next inner if $t ne $tw && !($t =~ /:$/ && $tw eq 'id');
Branch: 1 branch
BranchTrueFalseTotal
if $t ne $tw and not $t =~ /:$/u && $tw eq "id" 0 0 0
Condition0%0/6
$t ne $tw and not $t =~ /:$/u && $tw eq "id"
!ll&&!rl&&r
000
$t =~ /:$/u && $tw eq 'id'
!ll&&!rl&&r
000
MC/DC0%0/3
$t ne $tw and not $t =~ /:$/u && $tw eq "id"
$t ne $tw $t =~ /:$/u $tw eq 'id'
Truth table0%0/4
A and not(B && C)
A= $t ne $twB= $t =~ /:$/uC= $tw eq 'id'
ABCresult
0XX0
1110
10X1
1101
1224 0 $found = 1;
1225 0 last;
1226 }
1227 0 ▶ next outer unless $found;
Branch: 1 branch
BranchTrueFalseTotal
unless $found 0 0 0
1228 } else {
1229 0 ▶ next outer if $t ne $type && !($t =~ /:$/ && $type eq 'id');
Branch: 1 branch
BranchTrueFalseTotal
if $t ne $type and not $t =~ /:$/u && $type eq "id" 0 0 0
Condition0%0/6
$t ne $type and not $t =~ /:$/u && $type eq "id"
!ll&&!rl&&r
000
$t =~ /:$/u && $type eq 'id'
!ll&&!rl&&r
000
MC/DC0%0/3
$t ne $type and not $t =~ /:$/u && $type eq "id"
$t ne $type $t =~ /:$/u $type eq 'id'
Truth table0%0/4
A and not(B && C)
A= $t ne $typeB= $t =~ /:$/uC= $type eq 'id'
ABCresult
0XX0
1110
10X1
1101
1230 }
1231 }
1232  
1233 0 ▶ if ($dst eq 'undef') {
Branch: 1 branch
BranchTrueFalseTotal
if ($dst eq 'undef') { } 0 0 0
1234 # ignore this value
1235 } else {
1236 0 $updates{$dst} = $val;
1237 }
1238 }
1239  
1240 # Find suitable temp registers:
1241 0 ▶ for (my $j = 0; ($j*2) < scalar(@requests); $j++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($j * 2 < scalar @requests) 0 0 0
1242 0 my $req = $requests[$j*2 + 0];
1243 0 my $dst = $requests[$j*2 + 1];
1244 0 my $found = $self->_reg_alloc_phy($req);
1245  
1246 0 $updates{$dst} = $found;
1247 0 push(@allocations, $found);
1248 }
1249  
1250 0 $self->_reheat_mappings(@used_registers, @allocations);
1251  
1252 # Actually run the parts:
1253 0 foreach my $parts (@{$entry->[$i+2]}) {
1254 0 ▶ my @parts = map {ref ? ref($updates{${$_}}) ? @{$updates{${$_}}} : $updates{${$_}} : $_} @{$parts};
Branch: 2 branches
BranchTrueFalseTotal
ref $_ ? : 0 0 0
ref $updates{${$_;}} ? : 0 0 0
1255 0 my $ad;
1256  
1257 0 ▶ if ($parts[0] =~ s/\*$//) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parts[0] =~ s/\*$//u) 0 0 0
1258 0 $ad = ${$autodie};
1259 0 $reset_autodie = 1;
1260 }
1261  
1262 0 $self->_proc_parts(\@parts, $opts, \$ad);
1263 }
1264  
1265 0 ▶ if ($self->{settings}{synthetic_auto_unref}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"settings"}{"synthetic_auto_unref"}) 0 0 0
1266 0 $self->_proc_parts(['unref', $_], $opts) foreach @allocations;
1267 }
1268  
1269 0 $done = 1;
1270 0 ▶ ${$autodie} = undef if $reset_autodie;
Branch: 1 branch
BranchTrueFalseTotal
if $reset_autodie 0 0 0
1271 0 last outer;
1272 }
1273 }
1274  
1275 0 ▶ croak sprintf('Invalid input: line %s: command %s: arguments: %s', $opts->{line}, $cmd, join(', ', @args)) unless $done;
Branch: 1 branch
BranchTrueFalseTotal
unless $done 0 0 0
1276 }
1277  
1278 0 ▶ if (${$autodie}) {
Branch: 1 branch
BranchTrueFalseTotal
if (${$autodie;}) 0 0 0
1279 0 $opcode = SIRTX::VM::Opcode->from_template(parts => ['autodie'], assembler => $self, line => $opts->{line});
1280 0 $self->_write_opcode($opcode);
1281 }
1282  
1283 0 $self->{was_return} = $was_return;
1284 }
1285  
1286 0 ▶sub _type_to_sni {
Subroutine _type_to_sni: not called CC=2 SCAR=17.9
1287 0 my ($self, $type) = @_;
1288 0 ▶ return $_type_to_sni{$type} // croak 'Unknown type: '.$type;
Condition0%0/2
$_type_to_sni{$type} // croak('Unknown type: ' . $type)
l!l
00
MC/DC0%0/1
$_type_to_sni{$type} // croak('Unknown type: ' . $type)
$_type_to_sni{$type}
Truth table0%0/2
A
A= $_type_to_sni{$type}
Aresult
11
00
1289 }
1290  
1291 0 ▶sub _get_value_type {
Subroutine _get_value_type: not called CC=14 SCAR=53.5
1292 0 my ($self, $value) = @_;
1293 0 ▶ return 'reg' if defined(scalar(eval {$self->{rf}->get_physical_by_name($value)}));
Branch: 1 branch
BranchTrueFalseTotal
if defined scalar eval { do { $self->{"rf"}->get_physical_by_name($value) } } 0 0 0
1294 0 ▶ return 'bool' if $value eq 'true' || $value eq 'false';
Branch: 1 branch
BranchTrueFalseTotal
if $value eq "true" or $value eq "false" 0 0 0
Condition0%0/3
$value eq "true" or $value eq "false"
l!l&&r!l&&!r
000
MC/DC0%0/2
$value eq "true" or $value eq "false"
$value eq "true" $value eq "false"
Truth table0%0/3
A or B
A= $value eq "true"B= $value eq "false"
ABresult
1X1
011
000
1295 0 ▶ return 'undef' if $value eq 'undef';
Branch: 1 branch
BranchTrueFalseTotal
if $value eq "undef" 0 0 0
1296 0 ▶ return 'string' if $value =~ /^(?:"|U\+)/;
Branch: 1 branch
BranchTrueFalseTotal
if $value =~ /^(?:"|U\+)/u 0 0 0
1297 0 ▶ return 'int' if $value =~ /^'?[\+\-]?(?:0|[1-9][0-9]*|0x[0-9a-fA-F]+|0[0-7]+|0b[01]+)$/;
Branch: 1 branch
BranchTrueFalseTotal
if $value =~ /^'?[\+\-]?(?:0|[1-9][0-9]*|0x[0-9a-fA-F]+|0[0-7]+|0b[01]+)$/u 0 0 0
1298 0 ▶ return 'port' if $value =~ /^%[a-zA-Z][:a-zA-Z0-9_]*$/;
Branch: 1 branch
BranchTrueFalseTotal
if $value =~ /^%[a-zA-Z][:a-zA-Z0-9_]*$/u 0 0 0
1299  
1300 0 ▶ if ($value =~ /^([a-z]+):(?:0|[1-9][0-9]*)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value =~ /^([a-z]+):(?:0|[1-9][0-9]*)$/u) 0 0 0
1301 0 my $type = $1;
1302 0 ▶ return $type.':' if defined $_type_to_sni{$type};
Branch: 1 branch
BranchTrueFalseTotal
if defined $_type_to_sni{$type} 0 0 0
1303 }
1304  
1305 0 $value =~ s/^\/(0|[1-9][0-9]*)$/127:$1/;
1306 0 ▶ if ($value =~ /^([1-9][0-9]*):(?:0|[1-9][0-9]*)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value =~ /^([1-9][0-9]*):(?:0|[1-9][0-9]*)$/u) 0 0 0
1307 0 my $type = $1;
1308 0 ▶ if (defined $_sni_to_type{$type}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_sni_to_type{$type}) { } 0 0 0
1309 0 $type = $_sni_to_type{$type};
1310 } else {
1311 0 $_type_to_sni{$type} = $type;
1312 }
1313 0 return $type.':';
1314 }
1315 0 ▶ return 'logical:' if $value =~ /^logical:/;
Branch: 1 branch
BranchTrueFalseTotal
if $value =~ /^logical:/u 0 0 0
1316 0 ▶ return 'alias' if $value =~ /^[a-z0-9]*\$/;
Branch: 1 branch
BranchTrueFalseTotal
if $value =~ /^[a-z0-9]*\$/u 0 0 0
1317 0 die 'Bad value: '.$value;
1318 }
1319  
1320 0 ▶sub _parse_bool {
Subroutine _parse_bool: not called CC=1 SCAR=6.9
1321 0 my ($self, $bool) = @_;
1322 0 return $bool eq 'true';
1323 }
1324  
1325 0 ▶sub _parse_int {
Subroutine _parse_int: not called CC=7 SCAR=40.3
1326 0 my ($self, $val, $rel) = @_;
1327 0 my $neg;
1328  
1329 0 $val =~ s/^'//;
1330  
1331 0 ▶ $rel //= 0;
Condition0%0/2
$rel //= 0
l!l
00
MC/DC0%0/1
$rel //= 0
$rel
Truth table0%0/2
A
A= $rel
Aresult
11
00
1332  
1333 0 ▶ if ($val =~ s/^-//) {
Branch: 2 branches
BranchTrueFalseTotal
if ($val =~ s/^-//u) { } 0 0 0
elsif ($val =~ s/^\+//u) { } 0 0 0
1334 0 $neg = 1;
1335 } elsif ($val =~ s/^\+//) {
1336 # no-op
1337 } else {
1338 0 $rel = 0;
1339 }
1340  
1341 0 ▶ if ($val =~ /^[1-9]/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($val =~ /^[1-9]/u) { } 0 0 0
elsif ($val =~ /^(?:0[0-7]*|0x[0-9a-fA-F]+|0b[01]+)$/u) { } 0 0 0
1342 0 $val = int($val);
1343 } elsif ($val =~ /^(?:0[0-7]*|0x[0-9a-fA-F]+|0b[01]+)$/) {
1344 0 $val = oct($val);
1345 } else {
1346 0 die 'Bad integer';
1347 }
1348  
1349 0 ▶ $val *= -1 if $neg;
Branch: 1 branch
BranchTrueFalseTotal
if $neg 0 0 0
1350  
1351 0 return $val + $rel;
1352 }
1353  
1354 0 ▶sub _parse_escape {
Subroutine _parse_escape: not called CC=3 SCAR=24.8
1355 0 my ($esc) = @_;
1356  
1357 0 ▶ return $_escapes{$esc} if defined $_escapes{$esc};
Branch: 1 branch
BranchTrueFalseTotal
if defined $_escapes{$esc} 0 0 0
1358 0 ▶ return chr(hex($1)) if $esc =~ /^x([0-9a-f]{2})$/;
Branch: 1 branch
BranchTrueFalseTotal
if $esc =~ /^x([0-9a-f]{2})$/u 0 0 0
1359 }
1360  
1361 0 ▶sub _parse_string {
Subroutine _parse_string: not called CC=3 SCAR=24.8
1362 0 my ($self, $str) = @_;
1363  
1364 0 ▶ if ($str =~ s/^"(.*)"$/$1/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($str =~ s/^"(.*)"$/$1/u) { } 0 0 0
elsif ($str =~ /^U\+([0-9a-fA-F]{4,6})$/u) { } 0 0 0
1365 # no-op
1366 } elsif ($str =~ /^U\+([0-9a-fA-F]{4,6})$/) {
1367 0 my $char = chr(hex($1));
1368 0 state $UTF_8 = Encode::find_encoding('UTF-8');
1369 0 return $UTF_8->encode($char);
1370 } else {
1371 0 die 'Bad string';
1372 }
1373  
1374 0 $str =~ s/\\(\\|[0nrte]|x[0-9a-f]{2})/_parse_escape($1)/ge;
1375  
1376 0 return $str;
1377 }
1378  
1379 0 ▶sub _parse_id {
Subroutine _parse_id: not called CC=4 SCAR=30.0
1380 0 my ($self, $str) = @_;
1381  
1382 0 $str =~ s/^\/(0|[1-9][0-9]*)$/127:$1/;
1383  
1384 0 ▶ if ($str =~ /^([a-z]+):(0|[1-9][0-9]*)$/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($str =~ /^([a-z]+):(0|[1-9][0-9]*)$/u) { } 0 0 0
elsif ($str =~ /^([1-9][0-9]*):(0|[1-9][0-9]*)$/u) { } 0 0 0
1385 0 my ($type, $num) = ($1, $2);
1386 0 return ($type, $self->_parse_int($num));
1387 } elsif ($str =~ /^([1-9][0-9]*):(0|[1-9][0-9]*)$/) {
1388 0 my ($type, $num) = ($1, $2);
1389 0 ▶ if (defined $_sni_to_type{$type}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_sni_to_type{$type}) { } 0 0 0
1390 0 $type = $_sni_to_type{$type};
1391 } else {
1392 0 $_type_to_sni{$type} = $type;
1393 }
1394 0 return ($type, $self->_parse_int($num));
1395 } else {
1396 0 die 'Bad ID';
1397 }
1398 }
1399  
1400 1 1;
1401  
1402 __END__
↑ Summary VM/Opcode.pm »