Check-in [fd2ea3e6f1]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Remove vestiges of the old node splitter from 'inline.tcl'. Make console dribble in 'jumpthread.tcl' contingent on debug-jumpthread.
Timelines: family | ancestors | descendants | both | notworking | kbk-jumpthread
Files: files | file ages | folders
SHA3-256: fd2ea3e6f11005623ea4c87c10d1c73884ac9bd2892f31130b596b3f16028334
User & Date: kbk 2018-12-10 04:51:23.960
Context
2018-12-16
04:43
Finish forward analysis in the jump threading pass. check-in: dc90afa15d user: kbk tags: notworking, kbk-jumpthread
2018-12-10
04:51
Remove vestiges of the old node splitter from 'inline.tcl'. Make console dribble in 'jumpthread.tcl' contingent on debug-jumpthread. check-in: fd2ea3e6f1 user: kbk tags: notworking, kbk-jumpthread
04:09
OOPS! Didn't add the new 'jumpthread.tcl' module! Remove the old 'nodesplit.tcl', and remove the 'renameTemps' pass since 'nodesplit' was the only thing that ever depended on it. check-in: 67b989853b user: kbk tags: notworking, kbk-jumpthread
Changes
Unified Diff Ignore Whitespace Patch
Changes to quadcode/inline.tcl.
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236

oo::define quadcode::transformer method expandOneInline {b bb pc q toInline} {

    my debug-inline {
	puts "inline: expand $b:$pc: $q"
    }

    # Remember the number of split markers, so as to be able to
    # adjust the split markers in the inline code.

    set nSplits [llength [my countSplits]]
    my debug-inline {
	puts "inline: $nSplits splits"
    }

    # Save aside the source context for the inlined call

    lassign [my sourceInfo $b $pc] sfile slines sscript sctx

    # Make a basic block for the continuation. Link flow control to
    # the new block. If there are phis in the new block's successors, relink
    # them to the new block.







<
<
<
<
<
<
<
<







215
216
217
218
219
220
221








222
223
224
225
226
227
228

oo::define quadcode::transformer method expandOneInline {b bb pc q toInline} {

    my debug-inline {
	puts "inline: expand $b:$pc: $q"
    }









    # Save aside the source context for the inlined call

    lassign [my sourceInfo $b $pc] sfile slines sscript sctx

    # Make a basic block for the continuation. Link flow control to
    # the new block. If there are phis in the new block's successors, relink
    # them to the new block.
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
    my debug-inline {
	puts "inline: $b:$pc [lindex $bb $pc]"
    }

    # Rewrite the inline code to fit in with the calling procedure, and
    # retrieve the set of jumps that replace the 'return' quadcodes.

    my rewriteInline $eb $cb $nSplits $q

}

# quadcode::transformer method rewriteInline --
#
#	Rewrites code that has just been brought inline from another procedure
#	to fit in the basic block.
#
# Parameters:
#	startBlock - Basic block number of the first inlined block
#	exitBlock - Basic block number of the block to which 'return'
#	            quadcodes will redirect
#	nSplits - Number of distinct split markers in the calling procedure
#	          before inlining
#	iq - Quadcode instruction that invoked the inlined procedure.
#
# Results:
#	None
#
# The inlining at this point is extremely simple minded. It cannot cope
# with callframe operations at all, nor can it cope with procedures that







|












<
<







299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318


319
320
321
322
323
324
325
    my debug-inline {
	puts "inline: $b:$pc [lindex $bb $pc]"
    }

    # Rewrite the inline code to fit in with the calling procedure, and
    # retrieve the set of jumps that replace the 'return' quadcodes.

    my rewriteInline $eb $cb $q

}

# quadcode::transformer method rewriteInline --
#
#	Rewrites code that has just been brought inline from another procedure
#	to fit in the basic block.
#
# Parameters:
#	startBlock - Basic block number of the first inlined block
#	exitBlock - Basic block number of the block to which 'return'
#	            quadcodes will redirect


#	iq - Quadcode instruction that invoked the inlined procedure.
#
# Results:
#	None
#
# The inlining at this point is extremely simple minded. It cannot cope
# with callframe operations at all, nor can it cope with procedures that
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
#	    cannot be critical edges, since 'return' is always the only
#	    exit from its basic block.
#	(4) All variables and temporaries that appear in the inlined code
#	    are replaced with fresh instances (and of course have their
#	    ud- and du-chains created.
#	(5) Basic block references are renumbered to reflect the position
#	    of the inlined code.
#	(6) 'split' quadcodes are renumbered so that any further node
#	    splitting will have the correct counts.
#
# Following a pass that does this, the dominance hierarchy is reconstructed,
# and 'repairSSAVariable' is called to restore SSA consistency to the
# variable that contains the procedure's return value
#
# FIXME: 'repairSSAVariable' is overkill here. We shouldn't have to introduce
#        copies for the return operations; instead, the exit block should
#        start with a 'phi' for the result variable, and each jump from
#        a return point can add an argument to the 'phi'.
#
#        This will all change when error returns are implemented. What we
#        will have to rewrite in that case is possibly the sequence
#        'moveToCallFrame; invoke; retrieveResult; extractCallframe;
#        moveFromCallFrame*; jumpMaybe.  This is because there are several
#        places in the code that assume a CALLFRAME FAIL <RESULTTYPE>
#	 will be sorted out and only the <RESULTTYPE> will arrive at
#	 a phi. (In particular, moveFromCallFrame needs to be able to find
#        a unique operation that produced the callframe in question.)

oo::define quadcode::transformer method rewriteInline {startBlock exitBlock
						       nSplits iq} {

    set argv [lassign $iq - resultVar cfin command]
    my debug-inline {
	puts "inline: pulling in an invocation of $command"
	puts "        with result $resultVar and args $argv"
	puts "        code starts at $startBlock and returns to $exitBlock"
    }







<
<




















|







335
336
337
338
339
340
341


342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
#	    cannot be critical edges, since 'return' is always the only
#	    exit from its basic block.
#	(4) All variables and temporaries that appear in the inlined code
#	    are replaced with fresh instances (and of course have their
#	    ud- and du-chains created.
#	(5) Basic block references are renumbered to reflect the position
#	    of the inlined code.


#
# Following a pass that does this, the dominance hierarchy is reconstructed,
# and 'repairSSAVariable' is called to restore SSA consistency to the
# variable that contains the procedure's return value
#
# FIXME: 'repairSSAVariable' is overkill here. We shouldn't have to introduce
#        copies for the return operations; instead, the exit block should
#        start with a 'phi' for the result variable, and each jump from
#        a return point can add an argument to the 'phi'.
#
#        This will all change when error returns are implemented. What we
#        will have to rewrite in that case is possibly the sequence
#        'moveToCallFrame; invoke; retrieveResult; extractCallframe;
#        moveFromCallFrame*; jumpMaybe.  This is because there are several
#        places in the code that assume a CALLFRAME FAIL <RESULTTYPE>
#	 will be sorted out and only the <RESULTTYPE> will arrive at
#	 a phi. (In particular, moveFromCallFrame needs to be able to find
#        a unique operation that produced the callframe in question.)

oo::define quadcode::transformer method rewriteInline {startBlock exitBlock
						       iq} {

    set argv [lassign $iq - resultVar cfin command]
    my debug-inline {
	puts "inline: pulling in an invocation of $command"
	puts "        with result $resultVar and args $argv"
	puts "        code starts at $startBlock and returns to $exitBlock"
    }
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
		    lappend newbb [list copy $resultVar $rsource]
		    my addUse $rsource $b
		    lappend newbb [list jump [list bb $exitBlock]]
		    my bblink $b $exitBlock
		    dict incr resultAssignments $b
		}

		split {
		    set splitNum [expr {[lindex $q 2 1] + $nSplits}]
		    lappend newbb [list split {} [list literal $splitNum]]
		}

		default {
		    set newq [list [lindex $q 0]]
		    set first 1
		    foreach arg [lrange $q 1 end] {
			switch -exact [lindex $arg 0] {
			    bb {
				set nb [expr {$startBlock + [lindex $arg 1]}]







<
<
<
<
<







412
413
414
415
416
417
418





419
420
421
422
423
424
425
		    lappend newbb [list copy $resultVar $rsource]
		    my addUse $rsource $b
		    lappend newbb [list jump [list bb $exitBlock]]
		    my bblink $b $exitBlock
		    dict incr resultAssignments $b
		}






		default {
		    set newq [list [lindex $q 0]]
		    set first 1
		    foreach arg [lrange $q 1 end] {
			switch -exact [lindex $arg 0] {
			    bb {
				set nb [expr {$startBlock + [lindex $arg 1]}]
Changes to quadcode/jumpthread.tcl.
513
514
515
516
517
518
519

520
521

522
523
524
525
526
527
528
        if {$op eq "copy" && [dict exists $asserted $operand1]} {
            dict set asserted $result [dict get $asserted $operand1]
        }
        if {[dict exists $asserted $result]} {
            set ty [my jt_applyAssertions $ty [dict get $asserted $result]]
        }


        puts "    type of $result is [format %#x $ty]\
                  ([quadcode::nameOfType $ty])"

        dict set localtypes $result $ty

    }

    # TODO - Look at and phi-translate the ANTIN for each successor block.
    #        Compare against first localtypes, then typeOfOperand, to
    #	     get the type of the input. Find out which constraints the







>
|
|
>







513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
        if {$op eq "copy" && [dict exists $asserted $operand1]} {
            dict set asserted $result [dict get $asserted $operand1]
        }
        if {[dict exists $asserted $result]} {
            set ty [my jt_applyAssertions $ty [dict get $asserted $result]]
        }

        my debug-jt {
            puts "    type of $result is [format %#x $ty]\
                      ([quadcode::nameOfType $ty])"
        }
        dict set localtypes $result $ty

    }

    # TODO - Look at and phi-translate the ANTIN for each successor block.
    #        Compare against first localtypes, then typeOfOperand, to
    #	     get the type of the input. Find out which constraints the