Commit graph

25 commits

Author SHA1 Message Date
George Koehler
0b0c3d5b60 Add csa 8, csb 8 for i386, m68020.
This allows `long long x; switch (x) {...}` in C.  Add test in C.

This adapts the code for csa 8 and csb 8 from the existing code for
csa 4 and csb 4, for both i386 and m68020.
2019-09-27 12:15:10 -04:00
George Koehler
bbaed6bdba Edit i386 rules for 8-byte shift, conversion.
Shifts that drop an EM word don't need to coerce the word to REG.
Some arithmetic right shifts can use _cdq_.

Drop rules for illegal integer conversions.  Sizes below a word are
illegal in EM, except as the source size of _cii_.
2019-09-25 12:29:41 -04:00
George Koehler
f0a2c84d93 Tweak i386 rules for adi 8, sli 8, sru 8.
Add EXACT to the rule for adi 8, in the same way that the old rules
for and 8, ior 8, xor 8 have EXACT.

Add rules for sli 8 and sru 8 when shifting 32 bits, and add
assertions in llshift_e.c to test these rules.
2019-09-18 14:09:51 -04:00
George Koehler
f6a1e08218 Test long long division and remainder; fix i386.
My i386 code from 893df4b gave the wrong sign to some 8-byte
remainders.  Fix by splitting .dvi8 and .rmi8 so each has its own code
to pick the sign.  They and .dvu8 and .rmu8 share a private sub
.divrem8 for unsigned division.

Improve the i386 code by using instructions like _bsr_ and _shrd_.
Change the helpers to yield a quotient in ebx:eax or a remainder in
ecx:edx; this seems more convenient, because _div_ puts its quotient
in eax and remainder in edx.
2019-09-16 20:19:36 -04:00
George Koehler
04427e65dc Add and test rol 8, ror 8 for linux386.
These tests are in core/rotate_e.e with the other rotation tests, and
only run on platforms where _EM_LLSIZE == 8.
2019-09-12 19:47:51 -04:00
George Koehler
fb9f5387b5 Add long long comparisons, shifts for linux386.
Add tests for comparisons and shifts.  Also add enough integer
conversions to compile the shift test (llshift_e.c), and disable
some wrong rules for ldc and conversions.
2019-09-07 16:20:33 -04:00
George Koehler
893df4b79b Experiment with 8-byte integers in ncg i386.
This provides adi, sbi, mli, dvi, rmi, ngi, dvu, rmu 8, but is missing
shifts and rotates.  It is also missing conversions between 8-byte
integers and other sizes of integers or floats.  The code might not be
all correct, but works at least some of the time.

I adapted this from how ncg i86 does 4-byte integers, but I use a
different algorithm when dividing by a large value: i86 avoids the div
instruction and uses a shift-and-subtract loop; but I use the div
instruction to estimate a quotient, which is more like how big integer
libraries do division.  My .dvi8 and .dvu8 also set ecx:ebx to the
remainder; this might be a bad idea, because it requires .dvi8 and
.dvu8 to always calculate the remainder, even when the caller only
wants the quotient.

To play with 8-byte integers, I wrote EM procedures like

     mes 2, 4, 4
     exp $ngi
     pro $ngi,0
     ldl 4
     ngi 8
     lol 0
     sti 8
     lol 0
     ret 4
     end
     exp $adi
     pro $adi,0
     ldl 4
     ldl 12
     adi 8
     lol 0
     sti 8
     lol 0
     ret 4
     end

and called them from C like

    typedef struct { int l; int h; } q;
    q ngi(q);
    q adi(q, q);
2019-08-20 13:38:18 -04:00
ceriel
71da2cdda9 Fixed some bugs with the setxx instructions 1995-09-12 12:09:08 +00:00
ceriel
34b3d1fb52 Fix: produced jgt instead of jg 1995-07-25 13:21:53 +00:00
ceriel
5e03b1bebb Fixes: some conditionals were evaluated wrong due to the overflow bit 1995-07-21 12:05:26 +00:00
ceriel
65353b1417 Fix: description of setxx should write arg 1995-02-24 11:53:43 +00:00
ceriel
1db6a3029b Header --> Id 1994-06-24 14:02:31 +00:00
ceriel
5fbaff533c Use test instruction for testing 1992-12-17 12:58:05 +00:00
ceriel
bc2744ca5c Several fixes: SDF was wrong, and shifts do NOT set contition codes properly 1992-12-14 16:37:35 +00:00
ceriel
248ca45fc0 Use 80386 SET instruction 1992-09-17 14:15:20 +00:00
ceriel
d18493b0ac Some minor modifications reflecting some changes in the peephole optimizer 1992-09-01 10:19:21 +00:00
ceriel
be802650ca Added labeldef stuff 1991-11-18 09:51:35 +00:00
ceriel
7c167d29d2 Added some patterns 1991-10-14 13:04:29 +00:00
ceriel
564cbc6eba Only call NOP routine when debugging table 1991-09-04 10:55:52 +00:00
ceriel
8afda7422e Fix NOP 1991-06-26 17:33:16 +00:00
ceriel
736108572f produce commons, fix bug with mov-extend instructions 1990-06-25 15:48:49 +00:00
ceriel
2465ad8ed8 fixed bug: sometimes destroyed contents of register variable 1989-11-28 14:42:56 +00:00
ceriel
d25472bbfb many fixes; now passes the tests 1989-10-10 10:44:26 +00:00
ceriel
3c8a8f0349 fixes: you cannot do stack-references in EM replacements! 1989-05-11 11:25:16 +00:00
ceriel
4da1930ff4 Initial revision 1989-02-15 16:39:58 +00:00