~ubuntu-branches/ubuntu/feisty/fpc/feisty

« back to all changes in this revision

Viewing changes to rtl/i386/set.inc

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2007-01-27 20:08:50 UTC
  • mfrom: (1.2.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20070127200850-9mrptaqqjsx9nwa7
Tags: 2.0.4-5
* Fixed Build-Depends.
* Add myself to Uploaders in debian/control.
* Make sure that the sources are really patched before building them.
* Build unit 'libc' on powerpc too.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
{
2
 
    $Id: set.inc,v 1.19 2005/02/14 17:13:22 peter Exp $
3
2
    This file is part of the Free Pascal run time library.
4
3
    Copyright (c) 1999-2000 by the Free Pascal development team
5
4
 
16
15
 
17
16
 
18
17
{$define FPC_SYSTEM_HAS_FPC_SET_LOAD_SMALL}
19
 
function fpc_set_load_small(l: fpc_small_set): fpc_normal_set;assembler;[public,alias:'FPC_SET_LOAD_SMALL']; {$ifdef hascompilerproc} compilerproc; {$endif}
 
18
function fpc_set_load_small(l: fpc_small_set): fpc_normal_set;assembler;[public,alias:'FPC_SET_LOAD_SMALL']; compilerproc;
20
19
{
21
20
  load a normal set p from a smallset l
22
21
}
36
35
 
37
36
{$define FPC_SYSTEM_HAS_FPC_SET_CREATE_ELEMENT}
38
37
 
39
 
function fpc_set_create_element(b : byte): fpc_normal_set;assembler;[public,alias:'FPC_SET_CREATE_ELEMENT']; {$ifdef hascompilerproc} compilerproc; {$endif}
 
38
function fpc_set_create_element(b : byte): fpc_normal_set;assembler;[public,alias:'FPC_SET_CREATE_ELEMENT']; compilerproc;
40
39
{
41
40
  create a new set in p from an element b
42
41
}
43
42
var
44
43
  saveedi : longint;
45
44
asm
46
 
{$ifndef hascompilerproc}
47
 
        pushl   %eax
48
 
        pushl   %ecx
49
 
{$endif not hascompilerproc}
50
45
        movl    %edi,saveedi
51
46
        movl    __RESULT,%edi
52
47
        movzbl  b,%edx
57
52
        leal    -32(%edi),%eax
58
53
        btsl    %edx,(%eax)
59
54
        movl    saveedi,%edi
60
 
{$ifndef hascompilerproc}
61
 
        popl    %ecx
62
 
        popl    %eax
63
 
{$endif hascompilerproc}
64
55
end;
65
56
 
66
57
 
67
58
{$define FPC_SYSTEM_HAS_FPC_SET_SET_BYTE}
68
 
{$ifdef hascompilerproc}
69
59
function fpc_set_set_byte(const source: fpc_normal_set; b : byte): fpc_normal_set;assembler; compilerproc;
70
60
{
71
61
  add the element b to the set pointed by source
86
76
        movl    saveedi,%edi
87
77
        movl    saveesi,%esi
88
78
end;
89
 
{$else hascompilerproc}
90
 
function fpc_set_set_byte(b : byte): fpc_normal_set;assembler;[public,alias:'FPC_SET_SET_BYTE'];
91
 
{
92
 
  add the element b to the set pointed by p
93
 
}
94
 
asm
95
 
       pushl %eax
96
 
       movl __RESULT,%edi
97
 
       movb b,%al
98
 
       andl $0xf8,%eax
99
 
       shrl $3,%eax
100
 
       addl %eax,%edi
101
 
       movb b,%al
102
 
       andl $7,%eax
103
 
       btsl %eax,(%edi)
104
 
       popl %eax
105
 
end;
106
 
{$endif hascompilerproc}
107
 
 
108
79
 
109
80
{$define FPC_SYSTEM_HAS_FPC_SET_UNSET_BYTE}
110
 
{$ifdef hascompilerproc}
111
81
function fpc_set_unset_byte(const source: fpc_normal_set; b : byte): fpc_normal_set;assembler; compilerproc;
112
82
{
113
83
  add the element b to the set pointed by source
128
98
        movl    saveedi,%edi
129
99
        movl    saveesi,%esi
130
100
end;
131
 
{$else hascompilerproc}
132
 
function fpc_set_unset_byte(b : byte): fpc_normal_set;assembler;[public,alias:'FPC_SET_UNSET_BYTE']; {$ifdef hascompilerproc} compilerproc; {$endif}
133
 
{
134
 
  suppresses the element b to the set pointed by p
135
 
  used for exclude(set,element)
136
 
}
137
 
asm
138
 
       pushl %eax
139
 
       movl __RESULT,%edi
140
 
       movb b,%al
141
 
       andl $0xf8,%eax
142
 
       shrl $3,%eax
143
 
       addl %eax,%edi
144
 
       movb b,%al
145
 
       andl $7,%eax
146
 
       btrl %eax,(%edi)
147
 
       popl %eax
148
 
end;
149
 
{$endif hascompilerproc}
150
 
 
151
101
 
152
102
{$define FPC_SYSTEM_HAS_FPC_SET_SET_RANGE}
153
103
 
154
 
{$ifdef hascompilerproc}
155
104
function fpc_set_set_range(const orgset: fpc_normal_set; l,h : byte): fpc_normal_set;assembler; compilerproc;
156
105
{
157
106
  adds the range [l..h] to the set pointed to by p
211
160
        movl    saveebx,%ebx
212
161
end;
213
162
 
214
 
{$else hascompilerproc}
215
 
 
216
 
function fpc_set_set_range(l,h : byte): fpc_normal_set;assembler;[public,alias:'FPC_SET_SET_RANGE'];
217
 
{
218
 
  adds the range [l..h] to the set pointed to by p
219
 
}
220
 
asm
221
 
        movl    __RESULT,%edi               // set address in edi
222
 
        movzbl  l,%eax              // lowest bit to be set in eax
223
 
        movzbl  h,%ebx              // highest in ebx
224
 
        cmpl   %eax,%ebx
225
 
        jb     .Lset_range_done
226
 
        movl   %eax,%ecx            // lowest also in ecx
227
 
        shrl   $3,%eax              // divide by 8 to get starting and ending byte
228
 
        shrl   $3,%ebx              // address
229
 
        andb   $31,%cl              // low five bits of lo determine start of bit mask
230
 
        movl   $0x0ffffffff,%edx    // edx = bitmask to be inserted
231
 
        andl   $0x0fffffffc,%eax    // clear two lowest bits to get start/end longint
232
 
        andl   $0x0fffffffc,%ebx    // address * 4
233
 
        shll   %cl,%edx             // shift bitmask to clear bits below lo
234
 
        addl   %eax,%edi            // go to starting pos in set
235
 
        subl   %eax,%ebx            // are bit lo and hi in the same longint?
236
 
        jz     .Lset_range_hi       // yes, keep current mask and adjust for hi bit
237
 
        orl    %edx,(%edi)          // no, store current mask
238
 
        movl   $0x0ffffffff,%edx    // new mask
239
 
        addl   $4,%edi              // next longint of set
240
 
        subl   $4,%ebx              // bit hi in this longint?
241
 
        jz     .Lset_range_hi       // yes, keep full mask and adjust for hi bit
242
 
.Lset_range_loop:
243
 
        movl   %edx,(%edi)          // no, fill longints in between with full mask
244
 
        addl   $4,%edi
245
 
        subl   $4,%ebx
246
 
        jnz    .Lset_range_loop
247
 
.Lset_range_hi:
248
 
        movb   h,%cl
249
 
        movl   %edx,%ebx            // save current bitmask
250
 
        andb   $31,%cl
251
 
        subb   $31,%cl              // cl := (31 - (hi and 31)) = shift count to
252
 
        negb   %cl                  // adjust bitmask for hi bit
253
 
        shrl   %cl,%edx             // shift bitmask to clear bits higher than hi
254
 
        andl   %edx,%ebx            // combine both bitmasks
255
 
        orl    %ebx,(%edi)          // store to set
256
 
.Lset_range_done:
257
 
end;
258
 
{$endif hascompilerproc}
259
 
 
260
 
 
261
163
{$define FPC_SYSTEM_HAS_FPC_SET_IN_BYTE}
262
164
 
263
 
function fpc_set_in_byte(const p: fpc_normal_set; b: byte): boolean; assembler; [public,alias:'FPC_SET_IN_BYTE']; {$ifdef hascompilerproc} compilerproc; {$else} {$ifndef NOSAVEREGISTERS}saveregisters;{$endif} {$endif}
 
165
function fpc_set_in_byte(const p: fpc_normal_set; b: byte): boolean; assembler; [public,alias:'FPC_SET_IN_BYTE']; compilerproc;
264
166
{
265
167
  tests if the element b is in the set p the carryflag is set if it present
266
168
}
267
169
asm
268
 
{$ifdef hascompilerproc}
269
170
{$ifdef REGCALL}
270
171
        xchgl %edx,%eax
271
172
        andl $0xff,%eax
274
175
       movzbl b,%eax
275
176
{$endif}
276
177
       btl %eax,(%edx)
277
 
{$else hascompilerproc}
278
 
       pushl %eax
279
 
       movl   p,%edi
280
 
       movzbl b,%eax
281
 
       btl %eax,(%edi)
282
 
       popl %eax
283
 
{$endif hascompilerproc}
284
178
end;
285
179
 
286
180
 
287
181
{$define FPC_SYSTEM_HAS_FPC_SET_ADD_SETS}
288
182
 
289
 
{$ifdef hascompilerproc}
290
183
function fpc_set_add_sets(const set1,set2: fpc_normal_set): fpc_normal_set;assembler;[public,alias:'FPC_SET_ADD_SETS']; compilerproc;
291
 
{$else hascompilerproc}
292
 
procedure fpc_set_add_sets(set1,set2,dest : pointer);assembler;[public,alias:'FPC_SET_ADD_SETS'];
293
 
{$endif hascompilerproc}
294
184
{
295
185
  adds set1 and set2 into set dest
296
186
}
306
196
{$else}
307
197
      movl set1,%esi
308
198
      movl set2,%edx
309
 
{$ifdef hascompilerproc}
310
199
      movl __RESULT,%edi
311
 
{$else hascompilerproc}
312
 
      movl dest,%edi
313
 
{$endif hascompilerproc}
314
200
{$endif}
315
201
      movl $8,%ecx
316
202
   .LMADDSETS1:
327
213
 
328
214
{$define FPC_SYSTEM_HAS_FPC_SET_MUL_SETS}
329
215
 
330
 
{$ifdef hascompilerproc}
331
216
function fpc_set_mul_sets(const set1,set2: fpc_normal_set): fpc_normal_set;assembler;[public,alias:'FPC_SET_MUL_SETS']; compilerproc;
332
 
{$else hascompilerproc}
333
 
procedure fpc_set_mul_sets(set1,set2,dest:pointer);assembler;[public,alias:'FPC_SET_MUL_SETS'];
334
 
{$endif hascompilerproc}
335
217
{
336
218
  multiplies (takes common elements of) set1 and set2 result put in dest
337
219
}
347
229
{$else}
348
230
      movl set1,%esi
349
231
      movl set2,%edx
350
 
{$ifdef hascompilerproc}
351
232
      movl __RESULT,%edi
352
 
{$else hascompilerproc}
353
 
      movl dest,%edi
354
 
{$endif hascompilerproc}
355
233
{$endif}
356
234
      movl $8,%ecx
357
235
  .LMMULSETS1:
368
246
 
369
247
{$define FPC_SYSTEM_HAS_FPC_SET_SUB_SETS}
370
248
 
371
 
{$ifdef hascompilerproc}
372
249
function fpc_set_sub_sets(const set1,set2: fpc_normal_set): fpc_normal_set;assembler;[public,alias:'FPC_SET_SUB_SETS']; compilerproc;
373
 
{$else hascompilerproc}
374
 
procedure fpc_set_sub_sets(set1,set2,dest:pointer);assembler;[public,alias:'FPC_SET_SUB_SETS'];
375
 
{$endif hascompilerproc}
376
250
{
377
251
  computes the diff from set1 to set2 result in dest
378
252
}
389
263
{$else}
390
264
        movl set1,%esi
391
265
        movl set2,%ebx
392
 
{$ifdef hascompilerproc}
393
266
      movl __RESULT,%edi
394
 
{$else hascompilerproc}
395
 
      movl dest,%edi
396
 
{$endif hascompilerproc}
397
267
{$endif}
398
268
        movl $8,%ecx
399
269
    .LMSUBSETS1:
413
283
 
414
284
{$define FPC_SYSTEM_HAS_FPC_SET_SYMDIF_SETS}
415
285
 
416
 
{$ifdef hascompilerproc}
417
286
function fpc_set_symdif_sets(const set1,set2: fpc_normal_set): fpc_normal_set;assembler;[public,alias:'FPC_SET_SYMDIF_SETS']; compilerproc;
418
 
{$else hascompilerproc}
419
 
procedure fpc_set_symdif_sets(set1,set2,dest:pointer);assembler;[public,alias:'FPC_SET_SYMDIF_SETS'];
420
 
{$endif hascompilerproc}
421
287
{
422
288
   computes the symetric diff from set1 to set2 result in dest
423
289
}
433
299
{$else}
434
300
        movl set1,%esi
435
301
        movl set2,%edx
436
 
{$ifdef hascompilerproc}
437
302
      movl __RESULT,%edi
438
 
{$else hascompilerproc}
439
 
      movl dest,%edi
440
 
{$endif hascompilerproc}
441
303
{$endif}
442
304
        movl $8,%ecx
443
305
    .LMSYMDIFSETS1:
454
316
 
455
317
{$define FPC_SYSTEM_HAS_FPC_SET_COMP_SETS}
456
318
 
457
 
function fpc_set_comp_sets(const set1,set2: fpc_normal_set): boolean;assembler;[public,alias:'FPC_SET_COMP_SETS']; {$ifdef hascompilerproc} compilerproc; {$endif}
 
319
function fpc_set_comp_sets(const set1,set2: fpc_normal_set): boolean;assembler;[public,alias:'FPC_SET_COMP_SETS']; compilerproc;
458
320
{
459
321
  compares set1 and set2 zeroflag is set if they are equal
460
322
}
478
340
        { we are here only if the two sets are equal
479
341
          we have zero flag set, and that what is expected }
480
342
    .LMCOMPSETEND:
481
 
{$ifdef hascompilerproc}
482
343
        seteb %al
483
 
{$endif hascompilerproc}
484
344
        movl    saveedi,%edi
485
345
        movl    saveesi,%esi
486
346
end;
488
348
 
489
349
{$define FPC_SYSTEM_HAS_FPC_SET_CONTAINS_SET}
490
350
 
491
 
function fpc_set_contains_sets(const set1,set2: fpc_normal_set): boolean;assembler;[public,alias:'FPC_SET_CONTAINS_SETS']; {$ifdef hascompilerproc} compilerproc; {$endif}
 
351
function fpc_set_contains_sets(const set1,set2: fpc_normal_set): boolean;assembler;[public,alias:'FPC_SET_CONTAINS_SETS']; compilerproc;
492
352
{
493
353
  on exit, zero flag is set if set1 <= set2 (set2 contains set1)
494
354
}
513
373
        { we are here only if set2 contains set1
514
374
          we have zero flag set, and that what is expected }
515
375
    .LMCONTAINSSETEND:
516
 
{$ifdef hascompilerproc}
517
376
        seteb %al
518
 
{$endif hascompilerproc}
519
377
        movl    saveedi,%edi
520
378
        movl    saveesi,%esi
521
379
end;
525
383
 
526
384
{$error Needs to be fixed for register calling first!}
527
385
 
528
 
procedure fpc_largeset_set_word(p : pointer;b : word);assembler;[public,alias:'FPC_LARGESET_SET_WORD']; {$ifdef hascompilerproc} compilerproc; {$endif}
 
386
procedure fpc_largeset_set_word(p : pointer;b : word);assembler;[public,alias:'FPC_LARGESET_SET_WORD']; compilerproc;
529
387
{
530
388
  sets the element b in set p works for sets larger than 256 elements
531
389
  not yet use by the compiler so
544
402
end;
545
403
 
546
404
 
547
 
procedure fpc_largeset_in_word(p : pointer;b : word);assembler;[public,alias:'FPC_LARGESET_IN_WORD']; {$ifdef hascompilerproc} compilerproc; {$endif}
 
405
procedure fpc_largeset_in_word(p : pointer;b : word);assembler;[public,alias:'FPC_LARGESET_IN_WORD']; compilerproc;
548
406
{
549
407
  tests if the element b is in the set p the carryflag is set if it present
550
408
  works for sets larger than 256 elements
563
421
end;
564
422
 
565
423
 
566
 
procedure fpc_largeset_add_sets(set1,set2,dest : pointer;size : longint);assembler;[public,alias:'FPC_LARGESET_ADD_SETS']; {$ifdef hascompilerproc} compilerproc; {$endif}
 
424
procedure fpc_largeset_add_sets(set1,set2,dest : pointer;size : longint);assembler;[public,alias:'FPC_LARGESET_ADD_SETS']; compilerproc;
567
425
{
568
426
  adds set1 and set2 into set dest size is the number of bytes in the set
569
427
}
582
440
end;
583
441
 
584
442
 
585
 
procedure fpc_largeset_mul_sets(set1,set2,dest : pointer;size : longint);assembler;[public,alias:'FPC_LARGESET_MUL_SETS']; {$ifdef hascompilerproc} compilerproc; {$endif}
 
443
procedure fpc_largeset_mul_sets(set1,set2,dest : pointer;size : longint);assembler;[public,alias:'FPC_LARGESET_MUL_SETS']; compilerproc;
586
444
{
587
445
  multiplies (i.E. takes common elements of) set1 and set2 result put in
588
446
  dest size is the number of bytes in the set
602
460
end;
603
461
 
604
462
 
605
 
procedure fpc_largeset_sub_sets(set1,set2,dest : pointer;size : longint);assembler;[public,alias:'FPC_LARGESET_SUB_SETS']; {$ifdef hascompilerproc} compilerproc; {$endif}
 
463
procedure fpc_largeset_sub_sets(set1,set2,dest : pointer;size : longint);assembler;[public,alias:'FPC_LARGESET_SUB_SETS']; compilerproc;
606
464
asm
607
465
         movl set1,%esi
608
466
         movl set2,%ebx
620
478
end;
621
479
 
622
480
 
623
 
procedure fpc_largeset_symdif_sets(set1,set2,dest : pointer;size : longint);assembler;[public,alias:'FPC_LARGESET_SYMDIF_SETS']; {$ifdef hascompilerproc} compilerproc; {$endif}
 
481
procedure fpc_largeset_symdif_sets(set1,set2,dest : pointer;size : longint);assembler;[public,alias:'FPC_LARGESET_SYMDIF_SETS']; compilerproc;
624
482
{
625
483
   computes the symetric diff from set1 to set2 result in dest
626
484
}
640
498
end;
641
499
 
642
500
 
643
 
procedure fpc_largeset_comp_sets(set1,set2 : pointer;size : longint);assembler;[public,alias:'FPC_LARGESET_COMP_SETS']; {$ifdef hascompilerproc} compilerproc; {$endif}
 
501
procedure fpc_largeset_comp_sets(set1,set2 : pointer;size : longint);assembler;[public,alias:'FPC_LARGESET_COMP_SETS']; compilerproc;
644
502
asm
645
503
      movl set1,%esi
646
504
      movl set2,%edi
658
516
  .LMCOMPSETSIZEEND:
659
517
end;
660
518
 
661
 
procedure fpc_largeset_contains_sets(set1,set2 : pointer; size: longint);assembler;[public,alias:'FPC_LARGESET_CONTAINS_SETS']; {$ifdef hascompilerproc} compilerproc; {$endif}
 
519
procedure fpc_largeset_contains_sets(set1,set2 : pointer; size: longint);assembler;[public,alias:'FPC_LARGESET_CONTAINS_SETS']; compilerproc;
662
520
{
663
521
  on exit, zero flag is set if set1 <= set2 (set2 contains set1)
664
522
}
684
542
 
685
543
{$endif LARGESET}
686
544
 
687
 
{
688
 
  $Log: set.inc,v $
689
 
  Revision 1.19  2005/02/14 17:13:22  peter
690
 
    * truncate log
691
 
 
692
 
}