Check-in [5913b29fcd]

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

Overview
Comment:Avoid type promotion on jumpTrue and jumpFalse.
Timelines: family | ancestors | descendants | both | kbk-domain-check | notworking
Files: files | file ages | folders
SHA3-256:5913b29fcd697e44191c1793e0c99b6665c4d86e9c44a4f1ce48ade48508c210
User & Date: kbk 2018-03-26 02:10:06
Context
2018-03-26
02:36
Add test cases for && and ||. Note that the LAND and LOR instructions are never generated, since they are intrinsically buggy. check-in: 67f26787c0 user: kbk tags: kbk-domain-check, notworing
02:10
Avoid type promotion on jumpTrue and jumpFalse. check-in: 5913b29fcd user: kbk tags: kbk-domain-check, notworking
00:42
Correct the type name for boolean strings. Add a better 'isNumericOrBoolean' check check-in: c5f9a2da90 user: kbk tags: kbk-domain-check, notworking
Changes

Changes to codegen/build.tcl.

4489
4490
4491
4492
4493
4494
4495
















































































4496
4497
4498
4499
4500
4501
4502
    #
    # Results:
    #	An LLVM INT value reference containing a boolean value.

    method isBoolean(STRING) {value {name ""}} {
	my call ${tcl.isBoolean} [list $value] $name
    }

















































































    # Builder:land(INT,INT) --
    #
    #	Generate code to compute the logical and of two INTs.  Quadcode
    #	implementation ('land').
    #
    # Parameters:







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
    #
    # Results:
    #	An LLVM INT value reference containing a boolean value.

    method isBoolean(STRING) {value {name ""}} {
	my call ${tcl.isBoolean} [list $value] $name
    }

    # Builder:isTrue(INT BOOLEAN) --
    #
    #	Tests whether a given value will cause 'jumpTrue' to jump;
    #	Quadcode implementation('jumpTrue', 'jumpFalse')
    #
    # Parameters:
    #	value - The value to test, as an LLVM value reference.
    #	name (optional) - A name to give to the result value.
    #
    # Results:
    #	An LLVM ZEROONE value reference.

    method isTrue(INT\040BOOLEAN) {value {name ""}} {
	my eq $value [Const 0 int64]
    }

    # Builder:isTrue(DOUBLE) --
    #
    #	Tests whether a given value will cause 'jumpTrue' to jump;
    #	Quadcode implementation('jumpTrue', 'jumpFalse')
    #
    # Parameters:
    #	value - The value to test, as an LLVM value reference.
    #	name (optional) - A name to give to the result value.
    #
    # Results:
    #	An LLVM ZEROONE value reference.

    method isTrue(DOUBLE) {value {name ""}} {
	my eq $value [Const 0.0 double]
    }

    # Builder:isTrue(NUMERIC) --
    #
    #	Tests whether a given value will cause 'jumpTrue' to jump;
    #	Quadcode implementation('jumpTrue', 'jumpFalse')
    #
    # Parameters:
    #	value - The value to test, as an LLVM value reference.
    #	name (optional) - A name to give to the result value.
    #
    # Results:
    #	An LLVM ZEROONE value reference.

    method isTrue(NUMERIC) {value name} {
	my call ${tcl.isTrue.numeric} [list $value] $name
    }

    # Builder:isTrue(NUMERIC BOOLEAN) --
    #
    #	Tests whether a given value will cause 'jumpTrue' to jump;
    #	Quadcode implementation('jumpTrue', 'jumpFalse')
    #
    # Parameters:
    #	value - The value to test, as an LLVM value reference.
    #	name (optional) - A name to give to the result value.
    #
    # Results:
    #	An LLVM ZEROONE value reference.

    method isTrue(NUMERIC\040BOOLEAN) {value name} {
	my call ${tcl.isTrue.numericOrBoolean} [list $value] $name
    }

    # Builder:isTrue(ZEROONE) --
    #
    #	Tests whether a given value will cause 'jumpTrue' to jump;
    #	Quadcode implementation('jumpTrue', 'jumpFalse')
    #
    # Parameters:
    #	value - The value to test, as an LLVM value reference.
    #	name (optional) - A name to give to the result value.
    #
    # Results:
    #	An LLVM ZEROONE value reference.

    method isTrue(ZEROONE) {value name} {
	return $value
    }

    # Builder:land(INT,INT) --
    #
    #	Generate code to compute the logical and of two INTs.  Quadcode
    #	implementation ('land').
    #
    # Parameters:

Changes to codegen/compile.tcl.

735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
			$b br $block($tgt)
		    }
		}
		"jumpTrue" {
		    lassign $l opcode tgt src
		    set name [my LocalVarName $src]
		    set tgt [lindex $tgt 1]
		    set neq neq([my ValueTypes $src],INT)
		    set test [$b $neq [my LoadOrLiteral $src] $0 test_$name]
		    $b condBr $test $block($tgt) $ipath($pc)
		}
		"jumpFalse" {
		    lassign $l opcode tgt src
		    set name [my LocalVarName $src]
		    set tgt [lindex $tgt 1]
		    set neq neq([my ValueTypes $src],INT)
		    set test [$b $neq [my LoadOrLiteral $src] $0 test_$name]
		    $b condBr $test $ipath($pc) $block($tgt)
		}
		"jump" {
		    $b br $block([lindex $l 1 1])
		}
		"return" {
		    lassign $l opcode -> frame src







|
|






|
|







735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
			$b br $block($tgt)
		    }
		}
		"jumpTrue" {
		    lassign $l opcode tgt src
		    set name [my LocalVarName $src]
		    set tgt [lindex $tgt 1]
		    set mth isTrue([my ValueTypes $src])
		    set test [$b $mth [my LoadOrLiteral $src] test_$name]
		    $b condBr $test $block($tgt) $ipath($pc)
		}
		"jumpFalse" {
		    lassign $l opcode tgt src
		    set name [my LocalVarName $src]
		    set tgt [lindex $tgt 1]
		    set mth isTrue([my ValueTypes $src])
		    set test [$b $mth [my LoadOrLiteral $src] test_$name]
		    $b condBr $test $ipath($pc) $block($tgt)
		}
		"jump" {
		    $b br $block([lindex $l 1 1])
		}
		"return" {
		    lassign $l opcode -> frame src

Changes to codegen/mathlib.tcl.

28
29
30
31
32
33
34

35
36
37
38
39
40
41
....
1542
1543
1544
1545
1546
1547
1548










































1549
1550
1551
1552
1553
1554
1555
    variable tcl.add.numeric tcl.sub.numeric tcl.mult.numeric tcl.div.numeric
    variable tcl.pow.numeric tcl.land.numeric tcl.lor.numeric tcl.not.numeric
    variable tcl.not.numericOrBoolean
    variable tcl.neg.numeric tcl.eq.numeric tcl.ne.numeric tcl.lt.numeric
    variable tcl.le.numeric tcl.gt.numeric tcl.ge.numeric
    variable tcl.isBoolean tcl.isDouble tcl.isInteger
    variable tcl.isNumeric tcl.isNumericOrBoolean

    variable tcl.isZeroOneBoolean
    variable tcl.extractNumeric tcl.extractNumericOrBoolean
    variable tcl.extractDouble tcl.extractInteger
    variable tcl.stringify.double tcl.stringify.int
    variable tcl.stringify.numeric
    variable tcl.cmp.strstr tcl.cmp.strnum

................................................................................
	set f [$m local "tcl.extractInteger" INT<-STRING]
	params value
	build {
	    nonnull $value
	    my ret [my packInt64 [my extract [my GetWide $value] 1]]
	}











































	##### Function tcl.cmp.strstr #####
	#
	# Type signature: value1Ptr:STRING * value2Ptr:STRING -> int
	#
	# Returns the relationship between the two string arguments where
	# numeric comparisons are preferred; -1 if 'value1Ptr' precedes in
	# standard ordering, 1 if 'value2Ptr' precedes, and 0 if they are







>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
....
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
    variable tcl.add.numeric tcl.sub.numeric tcl.mult.numeric tcl.div.numeric
    variable tcl.pow.numeric tcl.land.numeric tcl.lor.numeric tcl.not.numeric
    variable tcl.not.numericOrBoolean
    variable tcl.neg.numeric tcl.eq.numeric tcl.ne.numeric tcl.lt.numeric
    variable tcl.le.numeric tcl.gt.numeric tcl.ge.numeric
    variable tcl.isBoolean tcl.isDouble tcl.isInteger
    variable tcl.isNumeric tcl.isNumericOrBoolean
    variable tcl.isTrue.numerc tcl.isTrue.numericOrBoolean
    variable tcl.isZeroOneBoolean
    variable tcl.extractNumeric tcl.extractNumericOrBoolean
    variable tcl.extractDouble tcl.extractInteger
    variable tcl.stringify.double tcl.stringify.int
    variable tcl.stringify.numeric
    variable tcl.cmp.strstr tcl.cmp.strnum

................................................................................
	set f [$m local "tcl.extractInteger" INT<-STRING]
	params value
	build {
	    nonnull $value
	    my ret [my packInt64 [my extract [my GetWide $value] 1]]
	}

	##### Function: tcl.isTrue.numeric #####
	#
	# Type signature: value:STRING->ZEROONE
	#
	# Determines whether a given NUMERIC value represents a value
	# that will cause 'jumpTrue' to jump. Part of the implementation
	# of quadcodes 'jumpTrue' and 'jumpFalse'

	set f [$m local "tcl.isTrue.numeric" ZEROONE<-NUMERIC]
	params value
	build {
	    my condBr [my isNumericInt $value] $doInteger $doDouble
	label doInteger:
	    my ret [my neq(INT,INT) [my numeric.int $value] [my int 0]]
	label doDouble:
	    my ret [my neq(DOUBLE,DOUBLE) \
			[my numericOrBoolean.double $value] [Const 0.0 double]]
	}

	##### Function: tcl.isTrue.numericOrBoolean #####
	#
	# Type signature: value:STRING->ZEROONE
	#
	# Determines whether a given NUMERIC BOOLEAN value represents a value
	# that will cause 'jumpTrue' to jump. Part of the implementation
	# of quadcodes 'jumpTrue' and 'jumpFalse'

	set f [$m local "tcl.isTrue.numericOrBoolean" \
		   {ZEROONE<-NUMERIC BOOLEAN}]
	params value
	build {
	    my switch [my getNumericBooleanKind $value] \
		$doBoolean 0 $doInteger 1 $doDouble
	label doBoolean:
	    my ret [my numericOrBoolean.bool $value]
	label doInteger:
	    my ret [my neq(INT,INT) [my numericOrBoolean.int $value] [my int 0]]
	label doDouble:
	    my ret [my neq(DOUBLE,DOUBLE) \
			[my numericOrBoolean.double $value] [Const 0.0 double]]
	}
	
	##### Function tcl.cmp.strstr #####
	#
	# Type signature: value1Ptr:STRING * value2Ptr:STRING -> int
	#
	# Returns the relationship between the two string arguments where
	# numeric comparisons are preferred; -1 if 'value1Ptr' precedes in
	# standard ordering, 1 if 'value2Ptr' precedes, and 0 if they are

Changes to demos/perftest/tester.tcl.

1984
1985
1986
1987
1988
1989
1990




1991
1992
1993
1994
1995
1996
1997
    {concatenater 7}
    {nottest 1}
    {nottest 0}
    {nottest 2.0}
    {nottest true}
    {list [catch {nottest fruitbat} stat] $stat}
    {iftest yes}




    {iftest 2.0}
    {list [catch {iftest fruitbat} stat] $stat}
    {list [booltest on] [booltest no] [booltest ""] [booltest fruitbat]}
    {stristest ""}
    {stristest x}
    {stristest 0}
    {stristest 1.2}







>
>
>
>







1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
    {concatenater 7}
    {nottest 1}
    {nottest 0}
    {nottest 2.0}
    {nottest true}
    {list [catch {nottest fruitbat} stat] $stat}
    {iftest yes}
    {iftest no}
    {iftest 1}
    {iftest 0}
    {iftest 0.0}
    {iftest 2.0}
    {list [catch {iftest fruitbat} stat] $stat}
    {list [booltest on] [booltest no] [booltest ""] [booltest fruitbat]}
    {stristest ""}
    {stristest x}
    {stristest 0}
    {stristest 1.2}