19 byval this_
as REGCLASS
ptr, _
20 sizeTb()
as REG_SIZEMASK _
25 byval this_
as REGCLASS
ptr, _
26 sizeTb()
as REG_SIZEMASK _
32 byval class_
as integer, _
33 byval regs as integer, _
34 sizeTb()
as REG_SIZEMASK, _
35 byval isstack
as integer _
38 dim as REGCLASS
ptr this_
44 this_->isstack = isstack
46 if( this_->isstack = FALSE )
then
59 byval this_
as REGCLASS
ptr _
64 if( this_ = NULL )
then
81 byval this_
as REGCLASS
ptr, _
88 r = this_->regctx.usedtail
90 this_->regctx.usedtail = r->prev
93 r->prev = this_->regctx.freetail
94 this_->regctx.freetail = r
103 byval this_
as REGCLASS
ptr, _
104 byval size as integer _
107 dim as REG_REG
ptr r, last
109 r = this_->regctx.freetail
110 do while( r <> NULL )
112 if( (this_->regctx.sizeTB(r->num)
and size) <> 0 )
then
114 if( this_->regctx.freetail = r )
then
115 this_->regctx.freetail = r->prev
121 r->prev = this_->regctx.usedtail
122 this_->regctx.usedtail = r
138 byval this_
as REGCLASS
ptr, _
142 dim as REG_REG
ptr r, last
144 r = this_->regctx.freetail
145 do while( r <> NULL )
147 if( r->num = n )
then
149 if( this_->regctx.freetail = r )
then
150 this_->regctx.freetail = r->prev
156 r->prev = this_->regctx.usedtail
157 this_->regctx.usedtail = r
174 byval this_
as REGCLASS
ptr _
180 this_->regctx.freeTB = -1
181 this_->regctx.freetail = NULL
182 this_->regctx.usedtail = NULL
184 for n = 0
to this_->
regs - 1
185 this_->vregTB(n) = NULL
186 this_->vauxparent(n) = NULL
187 this_->regctx.nextTB(n) = 0
189 r = @this_->regctx.regTB(n)
192 r->prev = this_->regctx.freetail
193 this_->regctx.freetail = r
203 byval this_
as REGCLASS
ptr, _
204 byval size as integer _
208 dim as uinteger maxdist
214 for n = 0
to this_->
regs - 1
216 if( (this_->regctx.sizeTB(n)
and size) <> 0 )
then
218 if( this_->regctx.nextTB(n) > maxdist )
then
219 maxdist = this_->regctx.nextTB(n)
232 byval this_
as REGCLASS
ptr, _
233 byval vreg
as IRVREG
ptr, _
234 byval vauxparent
as IRVREG
ptr, _
235 byval size as uinteger _
238 dim as integer r =
any
241 if( r = INVALID )
then
245 irStoreVR( this_->vregTB(r), this_->vauxparent(r) )
251 REG_SETUSED( this_->regctx.freeTB, r )
252 this_->vregTB(r) = vreg
253 this_->vauxparent(r) = vauxparent
254 this_->regctx.nextTB(r) = irGetDistance( vreg )
263 byval this_
as REGCLASS
ptr, _
264 byval r
as integer, _
265 byval vreg
as IRVREG
ptr, _
266 byval vauxparent
as IRVREG
ptr _
269 if( REG_ISFREE( this_->regctx.freeTB, r ) )
then
271 REG_SETUSED( this_->regctx.freeTB, r )
274 this_->vregTB(r) = vreg
275 this_->vauxparent(r) = vauxparent
276 this_->regctx.nextTB(r) = irGetDistance( vreg )
285 byval this_
as REGCLASS
ptr, _
286 byval vreg
as IRVREG
ptr, _
287 byval vauxparent
as IRVREG
ptr, _
288 byval size as uinteger _
291 dim as integer r =
any
294 if( r = INVALID )
then
296 irLoadVR( r, vreg, vauxparent )
306 byval this_
as REGCLASS
ptr, _
307 byval r
as integer, _
308 byval vreg
as IRVREG
ptr, _
309 byval vauxparent
as IRVREG
ptr _
312 REG_SETUSED( this_->regctx.freeTB, r )
313 this_->vregTB(r) = vreg
314 this_->vauxparent(r) = vauxparent
315 this_->regctx.nextTB(r) = irGetDistance( vreg )
322 byval this_
as REGCLASS
ptr, _
326 if( REG_ISUSED( this_->regctx.freeTB, r ) )
then
327 REG_SETFREE( this_->regctx.freeTB, r )
328 this_->vregTB(r) = NULL
329 this_->vauxparent(r) = NULL
330 this_->regctx.nextTB(r) = 0
339 byval this_
as REGCLASS
ptr, _
343 function = REG_ISFREE( this_->regctx.freeTB, r )
350 byval this_
as REGCLASS
ptr _
353 function = this_->
regs
360 byval this_
as REGCLASS
ptr _
370 byval this_
as REGCLASS
ptr, _
378 if( r < this_->
regs )
then
388 byval this_
as REGCLASS
ptr, _
389 byval r
as integer, _
390 byref vauxparent
as IRVREG
ptr _
391 )
as IRVREG
ptr static
393 function = this_->vregTB(r)
394 vauxparent = this_->vauxparent(r)
401 byval this_
as REGCLASS
ptr, _
412 byval this_
as REGCLASS
ptr _
415 dim as integer i, cnt
418 for i = 0
to this_->
regs - 1
419 if( REG_ISUSED( this_->regctx.freeTB, i ) )
then
425 if( cnt > 0 )
then print
432 byval this_
as REGCLASS
ptr, _
433 sizeTb()
as REG_SIZEMASK _
440 for i = 0
to this_->
regs - 1
441 this_->regctx.sizeTb(i) = sizeTb(i)
467 byval this_
as REGCLASS
ptr, _
468 byval vreg
as IRVREG
ptr _
475 if( this_->stkctx.fregs = this_->
regs )
then
479 for r = 0
to this_->
regs - 1
480 if( this_->stkctx.regTB(r) <> INVALID )
then
481 if( this_->vregTB(r) = vreg )
then
492 byval this_
as REGCLASS
ptr, _
493 byval r1
as integer _
502 for i = 0
to this_->
regs - 1
503 if( this_->stkctx.regTB(i) = 0 )
then
509 swap this_->stkctx.regTB(r1), this_->stkctx.regTB(r2)
516 byval this_
as REGCLASS
ptr _
523 if( this_->stkctx.fregs = 0 )
then
527 for r = 0
to this_->
regs - 1
528 if( this_->stkctx.regTB(r) = INVALID )
then
538 byval this_
as REGCLASS
ptr _
541 dim as integer r, i, lowest
546 for r = 0
to this_->
regs - 1
547 if( this_->stkctx.regTB(r) <> INVALID )
then
548 if( this_->stkctx.regTB(r) > lowest )
then
549 lowest = this_->stkctx.regTB(r)
562 byval this_
as REGCLASS
ptr _
567 for r = 0
to this_->
regs - 1
568 if( this_->stkctx.regTB(r) = 0 )
then
579 byval this_
as REGCLASS
ptr, _
580 byval vreg
as IRVREG
ptr, _
581 byval vauxparent
as IRVREG
ptr, _
582 byval size as uinteger _
585 dim as integer r =
any
588 if( r = INVALID )
then
591 irStoreVR( this_->vregTB(r), this_->vauxparent(r) )
593 this_->stkctx.fregs -= 1
595 for i
as integer = 0
to this_->
regs - 1
596 if( this_->stkctx.regTB(i) <> INVALID )
then
597 this_->stkctx.regTB(i) += 1
602 this_->vregTB(r) = vreg
603 this_->vauxparent(r) = vauxparent
604 this_->stkctx.regTB(r) = 0
611 byval this_
as REGCLASS
ptr, _
612 byval r
as integer, _
613 byval vreg
as IRVREG
ptr, _
614 byval vauxparent
as IRVREG
ptr _
618 function =
sregAllocate( this_, vreg, vauxparent, REG_SIZEMASK_64 )
624 byval this_
as REGCLASS
ptr, _
625 byval vreg
as IRVREG
ptr, _
626 byval vauxparent
as IRVREG
ptr, _
627 byval size as uinteger _
630 dim as integer r =
any
633 if( r = INVALID )
then
634 r =
sregAllocate( this_, vreg, vauxparent, REG_SIZEMASK_64 )
635 irLoadVR( r, vreg, vauxparent )
637 assert( vreg->reg = r )
638 if( this_->stkctx.regTB(r) <> 0 )
then
648 byval this_
as REGCLASS
ptr, _
652 dim as integer i, realreg
654 if( this_->stkctx.regTB(r) = INVALID )
then
658 realreg = this_->stkctx.regTB(r)
659 this_->stkctx.regTB(r) = INVALID
660 this_->vregTB(r) = NULL
661 this_->vauxparent(r) = NULL
663 for i = 0
to this_->
regs - 1
664 if( this_->stkctx.regTB(i) <> INVALID )
then
665 if( this_->stkctx.regTB(i) > realreg )
then
666 this_->stkctx.regTB(i) -= 1
671 this_->stkctx.fregs += 1
678 byval this_
as REGCLASS
ptr, _
682 function = this_->stkctx.regTB(r) = INVALID
689 byval this_
as REGCLASS
ptr, _
690 byval r
as integer, _
691 byval vreg
as IRVREG
ptr, _
692 byval vauxparent
as IRVREG
ptr _
695 this_->vregTB(r) = vreg
696 this_->vauxparent(r) = vauxparent
703 byval this_
as REGCLASS
ptr, _
707 function = this_->stkctx.regTB(r)
714 byval this_
as REGCLASS
ptr _
717 function = this_->
regs
724 byval this_
as REGCLASS
ptr _
734 byval this_
as REGCLASS
ptr, _
738 if( (r < 0)
or (r >= this_->
regs) )
then
749 byval this_
as REGCLASS
ptr, _
750 byval r
as integer, _
751 byref vauxparent
as IRVREG
ptr _
754 function = this_->vregTB(r)
755 vauxparent = this_->vauxparent(r)
762 byval this_
as REGCLASS
ptr _
765 dim as integer i, cnt
768 for i = 0
to this_->
regs - 1
769 if( this_->stkctx.regTB(i) <> INVALID )
then
775 if( cnt > 0 )
then print
782 byval reg
as REGCLASS
ptr _
785 dim as integer r =
any
787 reg->stkctx.fregs = reg->
regs
789 for r = 0
to reg->
regs - 1
790 reg->stkctx.regTB(r) = INVALID
791 reg->vregTB(r) = NULL
792 reg->vauxparent(r) = NULL
800 byval this_
as REGCLASS
ptr, _
801 sizeTb()
as REG_SIZEMASK _