[M3devel] TInt.ToInt overflow

Tony Hosking hosking at cs.purdue.edu
Wed Feb 24 15:43:18 CET 2010


I suspect that your backend code is not obeying the type conversions in the CG code.  Here is line 202 from RTAllocator -- it has a lot of conversions (with implied sign extension).  Does this give any clues?

                                        -----LINE 202  -----
        declare_temp     4 4 Struct T v.159
        load_integer     Int.32 0
        load             v.159 0 Word.8 Int.32
        swap             Int.32 Int.32
        insert_mn        Int.32 0 1
        store            v.159 0 Int.32 Word.8
        load             v.67 0 Addr Addr
        load_indirect    0 Int.32 Int.32
        check_range      Int.32 0 1048575 1
        load             v.159 0 Word.32 Int.32
        swap             Int.32 Int.32
        insert_mn        Int.32 1 20
        store            v.159 0 Int.32 Word.32
        load_integer     Int.32 1
        load             v.159 2 Word.8 Int.32
        swap             Int.32 Int.32
        insert_mn        Int.32 5 1
        store            v.159 2 Int.32 Word.8
        load_integer     Int.32 0
        load             v.159 2 Word.8 Int.32
        swap             Int.32 Int.32
        insert_mn        Int.32 6 1
        store            v.159 2 Int.32 Word.8
        load_integer     Int.32 0
        load             v.159 2 Word.8 Int.32
        swap             Int.32 Int.32
        insert_mn        Int.32 7 1
        store            v.159 2 Int.32 Word.8
        load_integer     Int.32 0
        load             v.159 3 Word.8 Int.32
        swap             Int.32 Int.32
        insert_mn        Int.32 0 1
        store            v.159 3 Int.32 Word.8
        load_integer     Int.32 0
        load             v.159 3 Word.8 Int.32
        swap             Int.32 Int.32
        insert_mn        Int.32 1 1
        store            v.159 3 Int.32 Word.8
        load_integer     Int.32 0
        load             v.159 3 Word.8 Int.32
        swap             Int.32 Int.32
        insert_mn        Int.32 2 6
        store            v.159 3 Int.32 Word.8
        load             v.65 0 Addr Addr
        load_integer     Int.32 4
        index_address    Int.32 -1
        load_address     v.159 0
        copy             1 Int.32 F


On 24 Feb 2010, at 08:41, Jay K wrote:

> Tony, it looks like basically all/many negative values are representeded as large positive values.
>   Something is chopping the sign maybe?
> Here are the errors I get compiling m3core if I don't "ignore" overflow from TInt.ToInt.
>   (for values that are under Integer.Word32.max).
> It isn't always clear how the source traffics in these numbers. I could get callstacks if it really helps.
>  
> "..\src\runtime\common\RTAllocator.m3", line 202: immOp1: unable to convert immediate to INTEGER:n:8,x:fe,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTAllocator.m3", line 202: immOp1: unable to convert immediate to INTEGER:n:8,x:1,0,e0,ff,0,0,0,0
> "..\src\runtime\common\RTAllocator.m3", line 202: immOp1: unable to convert immediate to INTEGER:n:8,x:df,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTAllocator.m3", line 202: immOp1: unable to convert immediate to INTEGER:n:8,x:bf,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTAllocator.m3", line 202: immOp1: unable to convert immediate to INTEGER:n:8,x:7f,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTAllocator.m3", line 202: immOp1: unable to convert immediate to INTEGER:n:8,x:fe,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTAllocator.m3", line 202: immOp1: unable to convert immediate to INTEGER:n:8,x:fd,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTAllocator.m3", line 202: immOp1: unable to convert immediate to INTEGER:n:8,x:3,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTAllocator.m3", line 224: immOp1: unable to convert immediate to INTEGER:n:8,x:fe,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTAllocator.m3", line 224: immOp1: unable to convert immediate to INTEGER:n:8,x:1,0,e0,ff,0,0,0,0
> "..\src\runtime\common\RTAllocator.m3", line 224: immOp1: unable to convert immediate to INTEGER:n:8,x:df,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTAllocator.m3", line 224: immOp1: unable to convert immediate to INTEGER:n:8,x:bf,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTAllocator.m3", line 224: immOp1: unable to convert immediate to INTEGER:n:8,x:7f,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTAllocator.m3", line 224: immOp1: unable to convert immediate to INTEGER:n:8,x:fe,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTAllocator.m3", line 224: immOp1: unable to convert immediate to INTEGER:n:8,x:fd,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTAllocator.m3", line 224: immOp1: unable to convert immediate to INTEGER:n:8,x:3,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTAllocator.m3", line 263: immOp1: unable to convert immediate to INTEGER:n:8,x:fe,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTAllocator.m3", line 263: immOp1: unable to convert immediate to INTEGER:n:8,x:1,0,e0,ff,0,0,0,0
> "..\src\runtime\common\RTAllocator.m3", line 263: immOp1: unable to convert immediate to INTEGER:n:8,x:df,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTAllocator.m3", line 263: immOp1: unable to convert immediate to INTEGER:n:8,x:bf,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTAllocator.m3", line 263: immOp1: unable to convert immediate to INTEGER:n:8,x:7f,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTAllocator.m3", line 263: immOp1: unable to convert immediate to INTEGER:n:8,x:fe,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTAllocator.m3", line 263: immOp1: unable to convert immediate to INTEGER:n:8,x:fd,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTAllocator.m3", line 263: immOp1: unable to convert immediate to INTEGER:n:8,x:3,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTAllocator.m3", line 294: immOp1: unable to convert immediate to INTEGER:n:8,x:fe,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTAllocator.m3", line 294: immOp1: unable to convert immediate to INTEGER:n:8,x:1,0,e0,ff,0,0,0,0
> "..\src\runtime\common\RTAllocator.m3", line 294: immOp1: unable to convert immediate to INTEGER:n:8,x:df,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTAllocator.m3", line 294: immOp1: unable to convert immediate to INTEGER:n:8,x:bf,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTAllocator.m3", line 294: immOp1: unable to convert immediate to INTEGER:n:8,x:7f,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTAllocator.m3", line 294: immOp1: unable to convert immediate to INTEGER:n:8,x:fe,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTAllocator.m3", line 294: immOp1: unable to convert immediate to INTEGER:n:8,x:fd,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTAllocator.m3", line 294: immOp1: unable to convert immediate to INTEGER:n:8,x:3,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTAllocStats.m3", line 117: immOp1: unable to convert immediate to INTEGER:n:8,x:3,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 452: immOp1: unable to convert immediate to INTEGER:n:8,x:df,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 463: immOp1: unable to convert immediate to INTEGER:n:8,x:bf,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 464: immOp1: unable to convert immediate to INTEGER:n:8,x:df,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 471: immOp1: unable to convert immediate to INTEGER:n:8,x:fe,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 549: immOp1: unable to convert immediate to INTEGER:n:8,x:fb,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 550: immOp1: unable to convert immediate to INTEGER:n:8,x:fc,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 555: immOp1: unable to convert immediate to INTEGER:n:8,x:8f,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 556: immOp1: unable to convert immediate to INTEGER:n:8,x:f7,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 556: immOp1: unable to convert immediate to INTEGER:n:8,x:7f,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 556: immOp1: unable to convert immediate to INTEGER:n:8,x:fe,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 558: immOp1: unable to convert immediate to INTEGER:n:8,x:8f,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 559: immOp1: unable to convert immediate to INTEGER:n:8,x:f7,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 559: immOp1: unable to convert immediate to INTEGER:n:8,x:7f,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 559: immOp1: unable to convert immediate to INTEGER:n:8,x:fe,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 561: immOp1: unable to convert immediate to INTEGER:n:8,x:8f,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 562: immOp1: unable to convert immediate to INTEGER:n:8,x:f7,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 562: immOp1: unable to convert immediate to INTEGER:n:8,x:7f,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 562: immOp1: unable to convert immediate to INTEGER:n:8,x:fe,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 566: immOp1: unable to convert immediate to INTEGER:n:8,x:8f,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 567: immOp1: unable to convert immediate to INTEGER:n:8,x:f7,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 567: immOp1: unable to convert immediate to INTEGER:n:8,x:7f,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 567: immOp1: unable to convert immediate to INTEGER:n:8,x:fe,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 569: immOp1: unable to convert immediate to INTEGER:n:8,x:8f,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 570: immOp1: unable to convert immediate to INTEGER:n:8,x:f7,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 570: immOp1: unable to convert immediate to INTEGER:n:8,x:7f,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 570: immOp1: unable to convert immediate to INTEGER:n:8,x:fe,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 574: immOp1: unable to convert immediate to INTEGER:n:8,x:8f,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 575: immOp1: unable to convert immediate to INTEGER:n:8,x:f7,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 575: immOp1: unable to convert immediate to INTEGER:n:8,x:7f,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 575: immOp1: unable to convert immediate to INTEGER:n:8,x:fe,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 577: immOp1: unable to convert immediate to INTEGER:n:8,x:8f,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 578: immOp1: unable to convert immediate to INTEGER:n:8,x:f7,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 578: immOp1: unable to convert immediate to INTEGER:n:8,x:7f,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 578: immOp1: unable to convert immediate to INTEGER:n:8,x:fe,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 592: immOp1: unable to convert immediate to INTEGER:n:8,x:df,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 593: immOp1: unable to convert immediate to INTEGER:n:8,x:bf,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 801: immOp1: unable to convert immediate to INTEGER:n:8,x:fc,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 952: immOp1: unable to convert immediate to INTEGER:n:8,x:fc,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 964: immOp1: unable to convert immediate to INTEGER:n:8,x:7f,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 970: immOp1: unable to convert immediate to INTEGER:n:8,x:fe,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 1016: immOp1: unable to convert immediate to INTEGER:n:8,x:ff,3,0,fc,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 1071: immOp1: unable to convert immediate to INTEGER:n:8,x:7f,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 1077: immOp1: unable to convert immediate to INTEGER:n:8,x:fe,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 1089: immOp1: unable to convert immediate to INTEGER:n:8,x:fe,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 1090: immOp1: unable to convert immediate to INTEGER:n:8,x:fd,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 1092: immOp1: unable to convert immediate to INTEGER:n:8,x:bf,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 1094: immOp1: unable to convert immediate to INTEGER:n:8,x:df,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 1186: immOp1: unable to convert immediate to INTEGER:n:8,x:fd,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 1208: immOp1: unable to convert immediate to INTEGER:n:8,x:fd,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 1209: immOp1: unable to convert immediate to INTEGER:n:8,x:fe,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 1242: immOp1: unable to convert immediate to INTEGER:n:8,x:7f,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 1446: immOp1: unable to convert immediate to INTEGER:n:8,x:fc,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 1446: immOp1: unable to convert immediate to INTEGER:n:8,x:fb,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 1446: immOp1: unable to convert immediate to INTEGER:n:8,x:f7,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 1446: immOp1: unable to convert immediate to INTEGER:n:8,x:8f,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 1446: immOp1: unable to convert immediate to INTEGER:n:8,x:7f,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 1446: immOp1: unable to convert immediate to INTEGER:n:8,x:fe,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 1446: immOp1: unable to convert immediate to INTEGER:n:8,x:fd,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 1446: immOp1: unable to convert immediate to INTEGER:n:8,x:ff,3,0,fc,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 1455: immOp1: unable to convert immediate to INTEGER:n:8,x:fc,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 1455: immOp1: unable to convert immediate to INTEGER:n:8,x:fb,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 1455: immOp1: unable to convert immediate to INTEGER:n:8,x:f7,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 1455: immOp1: unable to convert immediate to INTEGER:n:8,x:8f,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 1455: immOp1: unable to convert immediate to INTEGER:n:8,x:7f,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 1455: immOp1: unable to convert immediate to INTEGER:n:8,x:fe,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 1455: immOp1: unable to convert immediate to INTEGER:n:8,x:fd,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 1455: immOp1: unable to convert immdiate to INTEGER:n:8,x:ff,3,0,fc,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 1702: immOp1: unable to convert immediate to INTEGER:n:8,x:0,0,f0,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 1724: immOp1: unable to convert immediate to INTEGER:n:8,x:0,0,f0,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 2056: immOp1: unable to convert immediate to INTEGER:n:8,x:7f,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 2257: immOp1: unable to convert immediate to INTEGER:n:8,x:df,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 2259: immOp1: unable to convert immediate to INTEGER:n:8,x:fe,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 2365: immOp1: unable to convert immediate to INTEGER:n:8,x:ff,3,0,fc,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 2386: immOp1: unable to convert immediate to INTEGER:n:8,x:fc,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 2398: immOp1: unable to convert immediate to INTEGER:n:8,x:fc,ff,ff,ff,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 2418: immOp1: unable to convert immediate to INTEGER:n:8,x:ff,3,0,fc,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 2420: immOp1: unable to convert immediate to INTEGER:n:8,x:ff,3,0,fc,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 2425: immOp1: unable to convert immediate to INTEGER:n:8,x:ff,3,0,fc,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 2442: immOp1: unable to convert immediate to INTEGER:n:8,x:ff,3,0,fc,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 2446: immOp1: unable to convert immediate to INTEGER:n:8,x:ff,3,0,fc,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 2482: immOp1: unable to convert immediate to INTEGER:n:8,x:ff,3,0,fc,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 2498: immOp1: unable to convert immediate to INTEGER:n:8,x:ff,3,0,fc,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 2520: immOp1: unable to convert immediate to INTEGER:n:8,x:ff,3,0,fc,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 2525: immOp1: unable to convert immediate to INTEGER:n:8,x:ff,3,0,fc,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 2541: immOp1: unable to convert immediate to INTEGER:n:8,x:ff,3,0,fc,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 2543: immOp1: unable to convert immediate to INTEGER:n:8,x:ff,3,0,fc,0,0,0,0
> "..\src\runtime\common\RTCollector.m3", line 2697: immOp1: unable to convert immediate to INTEGER:n:8,x:fc,ff,ff,ff,0,0,0,0
> "..\src\float\IEEE\RealFloat.m3", line 72: immOp1: unable to convert immediate to INTEGER:n:8,x:0,0,80,ff,0,0,0,0
> "..\src\float\IEEE\RealFloat.m3", line 72: immOp1: unable to convert immediate to INTEGER:n:8,x:7f,80,ff,ff,0,0,0,0
> "..\src\float\IEEE\RealFloat.m3", line 72: immOp1: unable to convert immediate to INTEGER:n:8,x:7f,ff,ff,ff,0,0,0,0
> "..\src\float\IEEE\RealFloat.m3", line 78: immOp1: unable to convert immediate to INTEGER:n:8,x:0,0,80,ff,0,0,0,0
> "..\src\float\IEEE\RealFloat.m3", line 79: immOp1: unable to convert immediate to INTEGER:n:8,x:7f,80,ff,ff,0,0,0,0
> "..\src\float\IEEE\RealFloat.m3", line 83: immOp1: unable to convert immediate to INTEGER:n:8,x:0,0,80,ff,0,0,0,0
> "..\src\float\IEEE\RealFloat.m3", line 86: immOp1: unable to convert immediate to INTEGER:n:8,x:0,0,80,ff,0,0,0,0
> "..\src\float\IEEE\RealFloat.m3", line 87: immOp1: unable to convert immediate to INTEGER:n:8,x:7f,80,ff,ff,0,0,0,0
> "..\src\float\IEEE\RealFloat.m3", line 91: immOp1: unable to convert immediate to INTEGER:n:8,x:0,0,80,ff,0,0,0,0
> "..\src\float\IEEE\RealFloat.m3", line 99: immOp1: unable to convert immediate to INTEGER:n:8,x:7f,ff,ff,ff,0,0,0,0
> "..\src\float\IEEE\LongFloat.m3", line 81: immOp1: unable to convert immediate to INTEGER:n:8,x:7f,ff,ff,ff,0,0,0,0
> "..\src\float\IEEE\LongFloat.m3", line 82: immOp1: unable to convert immediate to INTEGER:n:8,x:f,80,ff,ff,0,0,0,0
> "..\src\float\IEEE\LongFloat.m3", line 83: immOp1: unable to convert immediate to INTEGER:n:8,x:0,0,f0,ff,0,0,0,0
> "..\src\float\IEEE\LongFloat.m3", line 89: immOp1: unable to convert immediate to INTEGER:n:8,x:0,0,f0,ff,0,0,0,0
> "..\src\float\IEEE\LongFloat.m3", line 91: immOp1: unable to convert immediate to INTEGER:n:8,x:f,80,ff,ff,0,0,0,0
> "..\src\float\IEEE\LongFloat.m3", line 96: immOp1: unable to convert immediate to INTEGER:n:8,x:0,0,f0,ff,0,0,0,0
> "..\src\float\IEEE\LongFloat.m3", line 101: immOp1: unable to convert immediate to INTEGER:n:8,x:0,0,f0,ff,0,0,0,0
> "..\src\float\IEEE\LongFloat.m3", line 103: immOp1: unable to convert immediate to INTEGER:n:8,x:f,80,ff,ff,0,0,0,0
> "..\src\float\IEEE\LongFloat.m3", line 108: immOp1: unable to convert immediate to INTEGER:n:8,x:0,0,f0,ff,0,0,0,0
> "..\src\float\IEEE\LongFloat.m3", line 119: immOp1: unable to convert immediate to INTEGER:n:8,x:7f,ff,ff,ff,0,0,0,0
> "..\src\convert\Convert.m3", line 117: immOp1: unable to convert immediate to INTEGER:n:8,x:0,0,0,80,0,0,0,0
> "..\src\convert\Convert.m3", line 496: pushOp: unable to convert immediate to INTEGER:n:8,x:0,0,0,80,0,0,0,0
> "..\src\convert\Convert.m3", line 503: pushOp: unable to convert immediate to INTEGER:n:8,x:ff,ff,ff,ff,0,0,0,0
> "..\src\convert\Convert.m3", line 551: pushOp: unable to convert immediate to INTEGER:n:8,x:ff,ff,ff,ff,0,0,0,0
> "..\src\convert\Convert.m3", line 551: pushOp: unable to convert immediate to INTEGER:n:8,x:ff,ff,ff,ff,0,0,0,0
> 
>  - Jay
> 
>  
> From: jay.krell at cornell.edu
> To: hosking at cs.purdue.edu
> CC: m3commit at elegosoft.com
> Subject: RE: [M3commit] CVS Update: cm3
> Date: Tue, 23 Feb 2010 23:08:32 +0000
> 
> I'll have to show you where the values are coming from. I don't know offhand.
>   Could be from m3back, or m3front, I don't know.
>  
> This stuff largely is runnable/testable from arbitrary hosts.
>   cd scripts/python
>   ./do-cm3-std.py realclean NT386
>   ./do-cm3-std.py buildship NT386
>  
>  
> to get the data we are interested in, would want to change this code e.g.:
>  
>  
> C:\dev2\cm3.2\m3-sys\m3back\src\Codex86.m3(386):    IF (NOT M3BackInt.ToInt(imm, ins.imm)) AND (NOT M3BackWord.LE(imm, M3BackInt.Word32.max)) THEN
> 
>  
> Note that most of the uses of ToInt in m3back don't do that, e.g.:
>  
>  
>       IF shiftCount.loc = OLoc.imm THEN
>         IF NOT M3BackInt.ToInt(shiftCount.imm, ins.imm) THEN
>           t.Err("binOp: unable to convert immediate to INTEGER:" & M3BackInt.ToDiagnosticText(shiftCount.imm));
>         END;
>         ins.imsize := 1;
>  
>  
> And at least one of these examples is so far unreachable -- the one in bitTestAndSet that I added yesterday.
> But some are not, I didn't go here randomly.
>   bitTestAndSet seems unusual but ok in that many x86 instructions can take a one byte signed immediate value, but bitTestAndSet seems to take a one byte unsigned immediate value.
>  
>  
>  - Jay
>  
> From: hosking at cs.purdue.edu
> Date: Tue, 23 Feb 2010 14:00:07 -0500
> To: jay.krell at cornell.edu
> CC: m3commit at elegosoft.com
> Subject: Re: [M3commit] CVS Update: cm3
> 
> I guess I am uncertain what it is you are trying to achieve.  The Modula-3 frontend never generates unsigned integers.  Everything is signed.  If you want to represent (unsigned) then, yes, I guess you want TWord.TBytes.
> 
> 
> On 23 Feb 2010, at 13:15, Jay K wrote:
> 
> So we need TWord.ToBytes?
>  
>  - Jay
>  
> From: hosking at cs.purdue.edu
> Date: Tue, 23 Feb 2010 12:39:49 -0500
> To: hosking at cs.purdue.edu
> CC: m3commit at elegosoft.com; jay.krell at cornell.edu
> Subject: Re: [M3commit] CVS Update: cm3
> 
> Actually, on second thought, of course it cannot be fixed.  The signed value 128 *does* require 2 bytes to represent.   (char)128 == -128.  (short)128 == 128.
> These TInt functions should be interpreted as having C arithmetic semantics.
> 
> On 23 Feb 2010, at 08:35, Tony Hosking wrote:
> 
> That can be fixed...
> 
> On 22 Feb 2010, at 21:30, Jay K wrote:
> 
> 
> ToBytes claims the value 128 requires 2 bytes. Which is reasonable. But not always expected. There should be an unsigned version that claims 1 byte?
> I can look into Chop and ToBytes more, but I am at least currently reusing add/subtract/multiple/div/mod/shift/rotate/toint/fromint/tochars, not bad.
> 
> 
> - Jay
> 
> 
> ----------------------------------------
> From: hosking at cs.purdue.edu
> Date: Mon, 22 Feb 2010 21:10:10 -0500
> To: jay.krell at cornell.edu
> CC: m3commit at elegosoft.com
> Subject: Re: [M3commit] CVS Update: cm3
> 
> On 22 Feb 2010, at 20:30, Jay K wrote:
> 
> I'm still a bit leary of Chop and ToBytes.
> 
> Chop is just the same as a C cast.
> i.e., (char)0xFFFFFFFF and (char)0x000000FF return the same value (char)-1.
> 
> ToBytes simply returns the significant bytes.
> 
> I *suspect* we need a bit more in TWord to make this all hold together.
> 
> I don't see the need. I think this speaks to confusion on your part...
> 
> Look at my current M3BackInt.m3. It is almost entirely now delegating to TInt/TWord, except it has its own conversions back and forth. It applies Widen before every operation, chop after every one. They are different for unsigned vs. signed. (Hm, unsigned narrow should probably check that the value fits, and the caller can ignore that or not.)
> 
> 
> I don't entirely ignore ToInt's boolean.
> I then check if the value fits in Word32. If it does, I ignore the overflow, knowing the value converted "reasonably". If it doesn't, I error.
> 
> 
> I think TWord.ToWord, which doesn't exist, would do what I want -- allow for 0-2^n and fail otherwise.
> 
> 
> Further, I should chose TWord.ToWord vs. TInt.ToInt based on the types I have. And then the frontend shouldn't claim 255 is an Int8. And such.
> (I'm not sure how I'm getting away with this currently, maybe something odd in my ToBytes.)
> 
> 
> What is there now is in pretty good shape, and M3BackInt/Word reinvent exceedingly little code now. I'd be plenty ok moving to other stuff now, such as atomic8/16/64 (and more testing of atomic32, which I think are done and working). I wasn't too keen spending the time adapting to the TInt/TWord changes, but I also didn't want the two nearly identical copies, esp. since I haven't read through DivMod to understand it.
> 
> 
> And then rewriting hand.c in Modula-3.
> 
> 
> And then other stuff.
> 
> 
> ..Jay
> 
> 
> ________________________________
> From: hosking at cs.purdue.edu
> Date: Mon, 22 Feb 2010 20:03:03 -0500
> To: hosking at cs.purdue.edu
> CC: m3commit at elegosoft.com
> Subject: Re: [M3commit] CVS Update: cm3
> 
> 
> 
> P.S. The assumption is that results from operations that overflow should be discarded.
> 
> 
> Antony Hosking | Associate Professor | Computer Science | Purdue University
> 305 N. University Street | West Lafayette | IN 47907 | USA
> Office +1 765 494 6001 | Mobile +1 765 427 5484
> 
> 
> 
> 
> 
> 
> On 22 Feb 2010, at 20:01, Tony Hosking wrote:
> 
> Jay, If you want that behavior, just do:
> 
> TInt.Chop(x, BYTESIZE(INTEGER), x);
> TInt.ToInt(x, i)
> 
> On 22 Feb 2010, at 23:57, Jay Krell wrote:
> 
> CVSROOT: /usr/cvs
> Changes by: jkrell at birch. 10/02/22 23:57:21
> 
> Modified files:
> cm3/m3-sys/m3back/src/: M3BackInt.m3
> 
> Log message:
> remove local versions of ToInt and FromInt now that TInt.ToInt packs the bytes even if there is overflow (the right solution I suspect it TWord.ToWord)
> 
> 
>     
> 
> 
> 
> 
> 




More information about the M3devel mailing list