FreeBASIC  0.91.0
emit.bas
Go to the documentation of this file.
1 '' emit abstract interface
2 ''
3 '' chng: jun/2005 written [v1ctor]
4 ''
5 
6 #include once "fb.bi"
7 #include once "fbint.bi"
8 #include once "reg.bi"
9 #include once "ir.bi"
10 #include once "rtl.bi"
11 #include once "emit.bi"
12 #include once "symb.bi"
13 
14 declare function emitGasX86_ctor _
15  ( _
16  ) as integer
17 
18 '' globals
19  dim shared emit as EMITCTX
20 
21 function emitInit( ) as integer
22  if( emit.inited ) then
23  return TRUE
24  end if
25 
27 
28  flistInit( @emit.nodeTB, EMIT_INITNODES, len( EMIT_NODE ) )
29  flistInit( @emit.vregTB, EMIT_INITVREGNODES, len( IRVREG ) )
30 
31  emit.inited = TRUE
32  emit.pos = 0
33 
34  function = emit.vtbl.init( )
35 end function
36 
37 sub emitEnd( )
38  if( emit.inited = FALSE ) then
39  exit sub
40  end if
41 
42  emit.vtbl.end( )
43  emit.inited = FALSE
44 end sub
45 
46 '':::::
47 sub emitWriteStr _
48  ( _
49  byval s as const zstring ptr, _
50  byval addtab as integer _
51  )
52 
53  static as string ostr
54 
55  if( addtab ) then
56  ostr = TABCHAR
57  ostr += *s
58  else
59  ostr = *s
60  end if
61 
62  ostr += NEWLINE
63 
64  if( put( #env.outf.num, , ostr ) <> 0 ) then
65  '' ...
66  end if
67 
68 end sub
69 
70 '':::::
71 sub emitReset( ) static
72  dim as integer c
73 
74  flistReset( @emit.nodeTB )
75  flistReset( @emit.vregTB )
76 
77  emit.curnode = NULL
78 
79  '' reset reg usage
80  for c = 0 to EMIT_REGCLASSES-1
81  EMIT_REGCLEARALL( c )
82  next
83 
84 end sub
85 
86 '':::::
87 function hOptSYMOP _
88  ( _
89  byval p as EMIT_NODE ptr, _
90  byval n as EMIT_NODE ptr _
91  ) as EMIT_NODE ptr
92 
93  select case n->sop.op
94  case EMIT_OP_LABEL
95  if( p <> NULL ) then
96  '' convert "jxx foo \n foo:" to "foo:"
97  if( p->class = EMIT_NODECLASS_BRC ) then
98  select case p->brc.op
99  case EMIT_OP_BRANCH, EMIT_OP_JUMP
100  if( p->brc.sym = n->sop.sym ) then
101  p->class = EMIT_NODECLASS_NOP
102  end if
103  end select
104  end if
105  end if
106 
107  '' don't count the label so "jmp foo \n bar: \n foo:" could be handled
108  return p
109  end select
110 
111  function = n
112 
113 end function
114 
115 '':::::
117  dim as EMIT_NODE ptr n = any, p = any
118 
119  p = NULL
120  n = flistGetHead( @emit.nodeTB )
121  do while( n <> NULL )
122 
123  select case as const n->class
124  case EMIT_NODECLASS_SOP
125  p = hOptSYMOP( p, n )
126 
127  case EMIT_NODECLASS_DBG
128  '' don't count debugging nodes, they won't gen any code
129 
130  case EMIT_NODECLASS_LIT
131  '' don't count literal text, unless it's inline asm
132  if( n->lit.isasm ) then
133  p = n
134  end if
135 
136  case else
137  p = n
138  end select
139 
140  n = flistGetNext( n )
141  loop
142 
143 end sub
144 
145 '':::::
146 sub emitFlush( )
147  dim as EMIT_NODE ptr n = any
148 
149  hPeepHoleOpt( )
150 
151  n = flistGetHead( @emit.nodeTB )
152  do while( n <> NULL )
153 
154  emit.curnode = n
155 
156  select case as const n->class
157  case EMIT_NODECLASS_NOP
158 
159  case EMIT_NODECLASS_BOP
160  cast( EMIT_BOPCB, emit.opFnTb[n->bop.op] )( n->bop.dvreg, _
161  n->bop.svreg )
162 
163  case EMIT_NODECLASS_UOP
164  cast( EMIT_UOPCB, emit.opFnTb[n->uop.op ] )( n->uop.dvreg )
165 
166  case EMIT_NODECLASS_REL
167  cast( EMIT_RELCB, emit.opFnTb[n->rel.op] )( n->rel.rvreg, _
168  n->rel.label, _
169  n->rel.dvreg, _
170  n->rel.svreg )
171 
172  case EMIT_NODECLASS_STK
173  cast( EMIT_STKCB, emit.opFnTb[n->stk.op] )( n->stk.vreg, _
174  n->stk.extra )
175 
176  case EMIT_NODECLASS_BRC
177  cast( EMIT_BRCCB, emit.opFnTb[n->brc.op] )( n->brc.vreg, _
178  n->brc.sym, _
179  n->brc.extra )
180 
181  case EMIT_NODECLASS_SOP
182  cast( EMIT_SOPCB, emit.opFnTb[n->sop.op] )( n->sop.sym )
183 
184  case EMIT_NODECLASS_LIT
185  cast( EMIT_LITCB, emit.opFnTb[EMIT_OP_LIT] )( n->lit.text )
186 
187  ZstrFree( n->lit.text )
188 
189  case EMIT_NODECLASS_JTB
190  cast( EMIT_JTBCB, emit.opFnTb[EMIT_OP_JMPTB] )( n->jtb.tbsym, _
191  n->jtb.values, n->jtb.labels, _
192  n->jtb.labelcount, n->jtb.deflabel, _
193  n->jtb.minval, n->jtb.maxval )
194 
195  deallocate( n->jtb.values )
196  deallocate( n->jtb.labels )
197 
198  case EMIT_NODECLASS_MEM
199  cast( EMIT_MEMCB, emit.opFnTb[n->mem.op] )( n->mem.dvreg, _
200  n->mem.svreg, _
201  n->mem.bytes, _
202  n->mem.extra )
203 
204  case EMIT_NODECLASS_DBG
205  cast( EMIT_DBGCB, emit.opFnTb[n->dbg.op] )( n->dbg.sym, _
206  n->dbg.lnum, _
207  n->dbg.pos )
208 
209  end select
210 
211  n = flistGetNext( n )
212  loop
213 
214 end sub
215 
216 '':::::
217 function emitGetRegClass _
218  ( _
219  byval dclass as integer _
220  ) as REGCLASS ptr
221 
222  function = emit.regTB(dclass)
223 
224 end function
225 
226 ''::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
227 '' node creation
228 ''::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
229 
230 '':::::
231 function hNewVR _
232  ( _
233  byval v as IRVREG ptr _
234  ) as IRVREG ptr
235 
236  dim as IRVREG ptr n = any
237  dim as integer dclass = any
238 
239  if( v = NULL ) then
240  return NULL
241  end if
242 
243  n = flistNewItem( @emit.vregTB )
244 
245  n->typ = v->typ
246  astGetFullType( n ) = v->dtype
247  n->sym = v->sym
248  n->ofs = v->ofs
249  n->mult = v->mult
250  n->value = v->value
251 
252  n->regFamily = v->regFamily
253  n->vector = v->vector
254 
255  if( v->typ = IR_VREGTYPE_REG ) then
256  dclass = typeGetClass( v->dtype )
257  n->reg = emit.regTB(dclass)->getRealReg( emit.regTB(dclass), v->reg )
258  assert( n->reg <> INVALID )
259  EMIT_REGSETUSED( dclass, n->reg )
260  end if
261 
262  '' recursive
263  n->vaux = hNewVR( v->vaux )
264  n->vidx = hNewVR( v->vidx )
265 
266  function = n
267 
268 end function
269 
270 '':::::
271 function hNewNode _
272  ( _
273  byval class_ as EMIT_NODECLASS_ENUM, _
274  byval updatepos as integer = TRUE _
275  ) as EMIT_NODE ptr static
276 
277  dim as EMIT_NODE ptr n
278  dim as integer i
279 
280  n = flistNewItem( @emit.nodeTB )
281 
282  n->class = class_
283 
284  '' save register's state
285  for i = 0 to EMIT_REGCLASSES-1
286  n->regFreeTB(i) = emit.regTB(i)->regctx.freeTB
287  next
288 
289  if( updatepos ) then
290  emit.pos += 1
291  end if
292 
293  function = n
294 
295 end function
296 
297 '':::::
298 function hNewBOP _
299  ( _
300  byval op as integer, _
301  byval dvreg as IRVREG ptr, _
302  byval svreg as IRVREG ptr _
303  ) as EMIT_NODE ptr static
304 
305  dim as EMIT_NODE ptr n
306 
307  n = hNewNode( EMIT_NODECLASS_BOP )
308 
309  n->bop.op = op
310  n->bop.dvreg = hNewVR( dvreg )
311  n->bop.svreg = hNewVR( svreg )
312 
313  function = n
314 
315 end function
316 
317 '':::::
318 function hNewUOP _
319  ( _
320  byval op as integer, _
321  byval dvreg as IRVREG ptr _
322  ) as EMIT_NODE ptr static
323 
324  dim as EMIT_NODE ptr n
325 
326  n = hNewNode( EMIT_NODECLASS_UOP )
327 
328  n->uop.op = op
329  n->uop.dvreg = hNewVR( dvreg )
330 
331  function = n
332 
333 end function
334 
335 '':::::
336 function hNewREL _
337  ( _
338  byval op as integer, _
339  byval rvreg as IRVREG ptr, _
340  byval label as FBSYMBOL ptr, _
341  byval dvreg as IRVREG ptr, _
342  byval svreg as IRVREG ptr _
343  ) as EMIT_NODE ptr static
344 
345  dim as EMIT_NODE ptr n
346 
347  n = hNewNode( EMIT_NODECLASS_REL )
348 
349  n->rel.op = op
350  n->rel.rvreg = hNewVR( rvreg )
351  n->rel.label = label
352  n->rel.dvreg = hNewVR( dvreg )
353  n->rel.svreg = hNewVR( svreg )
354 
355  function = n
356 
357 end function
358 
359 '':::::
360 function hNewSTK _
361  ( _
362  byval op as integer, _
363  byval vreg as IRVREG ptr, _
364  byval extra as integer = 0 _
365  ) as EMIT_NODE ptr static
366 
367  dim as EMIT_NODE ptr n
368 
369  n = hNewNode( EMIT_NODECLASS_STK )
370 
371  n->stk.op = op
372  n->stk.vreg = hNewVR( vreg )
373  n->stk.extra = extra
374 
375  function = n
376 
377 end function
378 
379 '':::::
380 function hNewBRANCH _
381  ( _
382  byval op as integer, _
383  byval vreg as IRVREG ptr, _
384  byval sym as FBSYMBOL ptr, _
385  byval extra as integer = 0 _
386  ) as EMIT_NODE ptr static
387 
388  dim as EMIT_NODE ptr n
389 
390  n = hNewNode( EMIT_NODECLASS_BRC )
391 
392  n->brc.op = op
393  n->brc.sym = sym
394  n->brc.vreg = hNewVR( vreg )
395  n->brc.extra = extra
396 
397  function = n
398 
399 end function
400 
401 '':::::
402 function hNewSYMOP _
403  ( _
404  byval op as integer, _
405  byval sym as FBSYMBOL ptr _
406  ) as EMIT_NODE ptr static
407 
408  dim as EMIT_NODE ptr n
409 
410  n = hNewNode( EMIT_NODECLASS_SOP, FALSE )
411 
412  n->sop.op = op
413  n->sop.sym = sym
414 
415  function = n
416 
417 end function
418 
419 sub hNewLIT( byval text as zstring ptr, byval isasm as integer )
420  dim as EMIT_NODE ptr n = any
421 
422  n = hNewNode( EMIT_NODECLASS_LIT, isasm )
423 
424  n->lit.isasm = isasm
425  n->lit.text = ZstrAllocate( len( *text ) )
426  *n->lit.text = *text
427 end sub
428 
429 '':::::
430 function hNewMEM _
431  ( _
432  byval op as integer, _
433  byval dvreg as IRVREG ptr, _
434  byval svreg as IRVREG ptr, _
435  byval bytes as integer, _
436  byval extra as integer = 0 _
437  ) as EMIT_NODE ptr static
438 
439  dim as EMIT_NODE ptr n
440 
441  n = hNewNode( EMIT_NODECLASS_MEM )
442 
443  n->mem.op = op
444  n->mem.dvreg = hNewVR( dvreg )
445  n->mem.svreg = hNewVR( svreg )
446  n->mem.bytes = bytes
447  n->mem.extra = extra
448 
449  function = n
450 
451 end function
452 
453 '':::::
454 function hNewDBG _
455  ( _
456  byval op as integer, _
457  byval sym as FBSYMBOL ptr, _
458  byval lnum as integer = 0, _
459  byval pos_ as integer = 0 _
460  ) as EMIT_NODE ptr static
461 
462  dim as EMIT_NODE ptr n
463 
464  n = hNewNode( EMIT_NODECLASS_DBG, FALSE )
465 
466  n->dbg.op = op
467  n->dbg.sym = sym
468  n->dbg.lnum = lnum
469  n->dbg.pos = pos_
470 
471  function = n
472 
473 end function
474 
475 ''::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
476 '' load & store
477 ''::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
478 
479 '':::::
480 function emitLOAD _
481  ( _
482  byval dvreg as IRVREG ptr, _
483  byval svreg as IRVREG ptr _
484  ) as EMIT_NODE ptr static
485 
486  select case as const dvreg->dtype
487  '' longint?
488  case FB_DATATYPE_LONGINT, FB_DATATYPE_ULONGINT
489 
490  select case as const svreg->dtype
491  '' longint?
492  case FB_DATATYPE_LONGINT, FB_DATATYPE_ULONGINT
493  function = hNewBOP( EMIT_OP_LOADL2L, dvreg, svreg )
494 
495  '' float?
496  case FB_DATATYPE_SINGLE, FB_DATATYPE_DOUBLE
497  function = hNewBOP( EMIT_OP_LOADF2L, dvreg, svreg )
498 
499  case else
500  function = hNewBOP( EMIT_OP_LOADI2L, dvreg, svreg )
501  end select
502 
503  '' float?
504  case FB_DATATYPE_SINGLE, FB_DATATYPE_DOUBLE
505 
506  select case as const svreg->dtype
507  '' longint?
508  case FB_DATATYPE_LONGINT, FB_DATATYPE_ULONGINT
509  function = hNewBOP( EMIT_OP_LOADL2F, dvreg, svreg )
510 
511  '' float?
512  case FB_DATATYPE_SINGLE, FB_DATATYPE_DOUBLE
513  function = hNewBOP( EMIT_OP_LOADF2F, dvreg, svreg )
514 
515  case else
516  function = hNewBOP( EMIT_OP_LOADI2F, dvreg, svreg )
517  end select
518 
519  case else
520 
521  select case as const svreg->dtype
522  '' longint?
523  case FB_DATATYPE_LONGINT, FB_DATATYPE_ULONGINT
524  function = hNewBOP( EMIT_OP_LOADL2I, dvreg, svreg )
525 
526  '' float?
527  case FB_DATATYPE_SINGLE, FB_DATATYPE_DOUBLE
528  function = hNewBOP( EMIT_OP_LOADF2I, dvreg, svreg )
529 
530  case else
531  function = hNewBOP( EMIT_OP_LOADI2I, dvreg, svreg )
532  end select
533 
534  end select
535 
536 end function
537 
538 '':::::
539 function emitSTORE _
540  ( _
541  byval dvreg as IRVREG ptr, _
542  byval svreg as IRVREG ptr _
543  ) as EMIT_NODE ptr static
544 
545  select case as const dvreg->dtype
546  '' longint?
547  case FB_DATATYPE_LONGINT, FB_DATATYPE_ULONGINT
548 
549  select case as const svreg->dtype
550  '' longint?
551  case FB_DATATYPE_LONGINT, FB_DATATYPE_ULONGINT
552  function = hNewBOP( EMIT_OP_STORL2L, dvreg, svreg )
553 
554  '' float?
555  case FB_DATATYPE_SINGLE, FB_DATATYPE_DOUBLE
556  function = hNewBOP( EMIT_OP_STORF2L, dvreg, svreg )
557 
558  case else
559  function = hNewBOP( EMIT_OP_STORI2L, dvreg, svreg )
560  end select
561 
562  '' float?
563  case FB_DATATYPE_SINGLE, FB_DATATYPE_DOUBLE
564 
565  select case as const svreg->dtype
566  '' longint?
567  case FB_DATATYPE_LONGINT, FB_DATATYPE_ULONGINT
568  function = hNewBOP( EMIT_OP_STORL2F, dvreg, svreg )
569 
570  '' float?
571  case FB_DATATYPE_SINGLE, FB_DATATYPE_DOUBLE
572  function = hNewBOP( EMIT_OP_STORF2F, dvreg, svreg )
573 
574  case else
575  function = hNewBOP( EMIT_OP_STORI2F, dvreg, svreg )
576  end select
577 
578  case else
579 
580  select case as const svreg->dtype
581  '' longint?
582  case FB_DATATYPE_LONGINT, FB_DATATYPE_ULONGINT
583  function = hNewBOP( EMIT_OP_STORL2I, dvreg, svreg )
584 
585  '' float?
586  case FB_DATATYPE_SINGLE, FB_DATATYPE_DOUBLE
587  function = hNewBOP( EMIT_OP_STORF2I, dvreg, svreg )
588 
589  case else
590  function = hNewBOP( EMIT_OP_STORI2I, dvreg, svreg )
591  end select
592 
593  end select
594 
595 end function
596 
597 ''::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
598 '' BOP
599 ''::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
600 
601 '':::::
602 function emitMOV _
603  ( _
604  byval dvreg as IRVREG ptr, _
605  byval svreg as IRVREG ptr _
606  ) as EMIT_NODE ptr static
607 
608  select case as const dvreg->dtype
609  '' longint?
610  case FB_DATATYPE_LONGINT, FB_DATATYPE_ULONGINT
611  function = hNewBOP( EMIT_OP_MOVL, dvreg, svreg )
612 
613  '' float?
614  case FB_DATATYPE_SINGLE, FB_DATATYPE_DOUBLE
615  function = hNewBOP( EMIT_OP_MOVF, dvreg, svreg )
616 
617  case else
618  function = hNewBOP( EMIT_OP_MOVI, dvreg, svreg )
619  end select
620 
621 end function
622 
623 '':::::
624 function emitADD _
625  ( _
626  byval dvreg as IRVREG ptr, _
627  byval svreg as IRVREG ptr _
628  ) as EMIT_NODE ptr static
629 
630  select case as const dvreg->dtype
631  '' longint?
632  case FB_DATATYPE_LONGINT, FB_DATATYPE_ULONGINT
633  function = hNewBOP( EMIT_OP_ADDL, dvreg, svreg )
634 
635  '' float?
636  case FB_DATATYPE_SINGLE, FB_DATATYPE_DOUBLE
637  function = hNewBOP( EMIT_OP_ADDF, dvreg, svreg )
638 
639  case else
640  function = hNewBOP( EMIT_OP_ADDI, dvreg, svreg )
641  end select
642 
643 end function
644 
645 '':::::
646 function emitSUB _
647  ( _
648  byval dvreg as IRVREG ptr, _
649  byval svreg as IRVREG ptr _
650  ) as EMIT_NODE ptr static
651 
652  select case as const dvreg->dtype
653  '' longint?
654  case FB_DATATYPE_LONGINT, FB_DATATYPE_ULONGINT
655  function = hNewBOP( EMIT_OP_SUBL, dvreg, svreg )
656 
657  '' float?
658  case FB_DATATYPE_SINGLE, FB_DATATYPE_DOUBLE
659  function = hNewBOP( EMIT_OP_SUBF, dvreg, svreg )
660 
661  case else
662  function = hNewBOP( EMIT_OP_SUBI, dvreg, svreg )
663  end select
664 
665 end function
666 
667 '':::::
668 function emitMUL _
669  ( _
670  byval dvreg as IRVREG ptr, _
671  byval svreg as IRVREG ptr _
672  ) as EMIT_NODE ptr static
673 
674  select case as const dvreg->dtype
675  '' longint?
676  case FB_DATATYPE_LONGINT, FB_DATATYPE_ULONGINT
677  function = hNewBOP( EMIT_OP_MULL, dvreg, svreg )
678 
679  '' float?
680  case FB_DATATYPE_SINGLE, FB_DATATYPE_DOUBLE
681  function = hNewBOP( EMIT_OP_MULF, dvreg, svreg )
682 
683  case else
684  function = hNewBOP( EMIT_OP_MULI, dvreg, svreg )
685  end select
686 
687 end function
688 
689 '':::::
690 function emitDIV _
691  ( _
692  byval dvreg as IRVREG ptr, _
693  byval svreg as IRVREG ptr _
694  ) as EMIT_NODE ptr static
695 
696  function = hNewBOP( EMIT_OP_DIVF, dvreg, svreg )
697 
698 end function
699 
700 '':::::
701 function emitINTDIV _
702  ( _
703  byval dvreg as IRVREG ptr, _
704  byval svreg as IRVREG ptr _
705  ) as EMIT_NODE ptr static
706 
707  function = hNewBOP( EMIT_OP_DIVI, dvreg, svreg )
708 
709 end function
710 
711 '':::::
712 function emitMOD _
713  ( _
714  byval dvreg as IRVREG ptr, _
715  byval svreg as IRVREG ptr _
716  ) as EMIT_NODE ptr static
717 
718  function = hNewBOP( EMIT_OP_MODI, dvreg, svreg )
719 
720 end function
721 
722 '':::::
723 function emitSHL _
724  ( _
725  byval dvreg as IRVREG ptr, _
726  byval svreg as IRVREG ptr _
727  ) as EMIT_NODE ptr static
728 
729  select case dvreg->dtype
730  '' longint?
731  case FB_DATATYPE_LONGINT, FB_DATATYPE_ULONGINT
732  function = hNewBOP( EMIT_OP_SHLL, dvreg, svreg )
733 
734  case else
735  function = hNewBOP( EMIT_OP_SHLI, dvreg, svreg )
736  end select
737 
738 end function
739 
740 '':::::
741 function emitSHR _
742  ( _
743  byval dvreg as IRVREG ptr, _
744  byval svreg as IRVREG ptr _
745  ) as EMIT_NODE ptr static
746 
747  select case dvreg->dtype
748  '' longint?
749  case FB_DATATYPE_LONGINT, FB_DATATYPE_ULONGINT
750  function = hNewBOP( EMIT_OP_SHRL, dvreg, svreg )
751 
752  case else
753  function = hNewBOP( EMIT_OP_SHRI, dvreg, svreg )
754  end select
755 
756 end function
757 
758 '':::::
759 function emitAND _
760  ( _
761  byval dvreg as IRVREG ptr, _
762  byval svreg as IRVREG ptr _
763  ) as EMIT_NODE ptr static
764 
765  select case dvreg->dtype
766  '' longint?
767  case FB_DATATYPE_LONGINT, FB_DATATYPE_ULONGINT
768  function = hNewBOP( EMIT_OP_ANDL, dvreg, svreg )
769 
770  case else
771  function = hNewBOP( EMIT_OP_ANDI, dvreg, svreg )
772  end select
773 
774 end function
775 
776 '':::::
777 function emitOR _
778  ( _
779  byval dvreg as IRVREG ptr, _
780  byval svreg as IRVREG ptr _
781  ) as EMIT_NODE ptr static
782 
783  select case dvreg->dtype
784  '' longint?
785  case FB_DATATYPE_LONGINT, FB_DATATYPE_ULONGINT
786  function = hNewBOP( EMIT_OP_ORL, dvreg, svreg )
787 
788  case else
789  function = hNewBOP( EMIT_OP_ORI, dvreg, svreg )
790  end select
791 
792 end function
793 
794 '':::::
795 function emitXOR _
796  ( _
797  byval dvreg as IRVREG ptr, _
798  byval svreg as IRVREG ptr _
799  ) as EMIT_NODE ptr static
800 
801  select case dvreg->dtype
802  '' longint?
803  case FB_DATATYPE_LONGINT, FB_DATATYPE_ULONGINT
804  function = hNewBOP( EMIT_OP_XORL, dvreg, svreg )
805 
806  case else
807  function = hNewBOP( EMIT_OP_XORI, dvreg, svreg )
808  end select
809 
810 end function
811 
812 '':::::
813 function emitEQV _
814  ( _
815  byval dvreg as IRVREG ptr, _
816  byval svreg as IRVREG ptr _
817  ) as EMIT_NODE ptr static
818 
819  select case dvreg->dtype
820  '' longint?
821  case FB_DATATYPE_LONGINT, FB_DATATYPE_ULONGINT
822  function = hNewBOP( EMIT_OP_EQVL, dvreg, svreg )
823 
824  case else
825  function = hNewBOP( EMIT_OP_EQVI, dvreg, svreg )
826  end select
827 
828 end function
829 
830 '':::::
831 function emitIMP _
832  ( _
833  byval dvreg as IRVREG ptr, _
834  byval svreg as IRVREG ptr _
835  ) as EMIT_NODE ptr static
836 
837  select case dvreg->dtype
838  '' longint?
839  case FB_DATATYPE_LONGINT, FB_DATATYPE_ULONGINT
840  function = hNewBOP( EMIT_OP_IMPL, dvreg, svreg )
841 
842  case else
843  function = hNewBOP( EMIT_OP_IMPI, dvreg, svreg )
844  end select
845 
846 end function
847 
848 '':::::
849 function emitATN2 _
850  ( _
851  byval dvreg as IRVREG ptr, _
852  byval svreg as IRVREG ptr _
853  ) as EMIT_NODE ptr static
854 
855  function = hNewBOP( EMIT_OP_ATN2, dvreg, svreg )
856 
857 end function
858 
859 '':::::
860 function emitPOW _
861  ( _
862  byval dvreg as IRVREG ptr, _
863  byval svreg as IRVREG ptr _
864  ) as EMIT_NODE ptr static
865 
866  function = hNewBOP( EMIT_OP_POW, dvreg, svreg )
867 
868 end function
869 
870 '':::::
871 function emitADDROF _
872  ( _
873  byval dvreg as IRVREG ptr, _
874  byval svreg as IRVREG ptr _
875  ) as EMIT_NODE ptr static
876 
877  function = hNewBOP( EMIT_OP_ADDROF, dvreg, svreg )
878 
879 end function
880 
881 '':::::
882 function emitDEREF _
883  ( _
884  byval dvreg as IRVREG ptr, _
885  byval svreg as IRVREG ptr _
886  ) as EMIT_NODE ptr static
887 
888  function = hNewBOP( EMIT_OP_DEREF, dvreg, svreg )
889 
890 end function
891 
892 ''::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
893 '' REL
894 ''::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
895 
896 '':::::
897 function emitGT _
898  ( _
899  byval rvreg as IRVREG ptr, _
900  byval label as FBSYMBOL ptr, _
901  byval dvreg as IRVREG ptr, _
902  byval svreg as IRVREG ptr _
903  ) as EMIT_NODE ptr static
904 
905  select case as const dvreg->dtype
906  '' longint?
907  case FB_DATATYPE_LONGINT, FB_DATATYPE_ULONGINT
908  function = hNewREL( EMIT_OP_CGTL, rvreg, label, dvreg, svreg )
909 
910  '' float?
911  case FB_DATATYPE_SINGLE, FB_DATATYPE_DOUBLE
912  function = hNewREL( EMIT_OP_CGTF, rvreg, label, dvreg, svreg )
913 
914  case else
915  function = hNewREL( EMIT_OP_CGTI, rvreg, label, dvreg, svreg )
916  end select
917 
918 end function
919 
920 '':::::
921 function emitLT _
922  ( _
923  byval rvreg as IRVREG ptr, _
924  byval label as FBSYMBOL ptr, _
925  byval dvreg as IRVREG ptr, _
926  byval svreg as IRVREG ptr _
927  ) as EMIT_NODE ptr static
928 
929  select case as const dvreg->dtype
930  '' longint?
931  case FB_DATATYPE_LONGINT, FB_DATATYPE_ULONGINT
932  function = hNewREL( EMIT_OP_CLTL, rvreg, label, dvreg, svreg )
933 
934  '' float?
935  case FB_DATATYPE_SINGLE, FB_DATATYPE_DOUBLE
936  function = hNewREL( EMIT_OP_CLTF, rvreg, label, dvreg, svreg )
937 
938  case else
939  function = hNewREL( EMIT_OP_CLTI, rvreg, label, dvreg, svreg )
940  end select
941 
942 end function
943 
944 '':::::
945 function emitEQ _
946  ( _
947  byval rvreg as IRVREG ptr, _
948  byval label as FBSYMBOL ptr, _
949  byval dvreg as IRVREG ptr, _
950  byval svreg as IRVREG ptr _
951  ) as EMIT_NODE ptr static
952 
953  select case as const dvreg->dtype
954  '' longint?
955  case FB_DATATYPE_LONGINT, FB_DATATYPE_ULONGINT
956  function = hNewREL( EMIT_OP_CEQL, rvreg, label, dvreg, svreg )
957 
958  '' float?
959  case FB_DATATYPE_SINGLE, FB_DATATYPE_DOUBLE
960  function = hNewREL( EMIT_OP_CEQF, rvreg, label, dvreg, svreg )
961 
962  case else
963  function = hNewREL( EMIT_OP_CEQI, rvreg, label, dvreg, svreg )
964  end select
965 
966 end function
967 
968 '':::::
969 function emitNE _
970  ( _
971  byval rvreg as IRVREG ptr, _
972  byval label as FBSYMBOL ptr, _
973  byval dvreg as IRVREG ptr, _
974  byval svreg as IRVREG ptr _
975  ) as EMIT_NODE ptr static
976 
977  select case as const dvreg->dtype
978  '' longint?
979  case FB_DATATYPE_LONGINT, FB_DATATYPE_ULONGINT
980  function = hNewREL( EMIT_OP_CNEL, rvreg, label, dvreg, svreg )
981 
982  '' float?
983  case FB_DATATYPE_SINGLE, FB_DATATYPE_DOUBLE
984  function = hNewREL( EMIT_OP_CNEF, rvreg, label, dvreg, svreg )
985 
986  case else
987  function = hNewREL( EMIT_OP_CNEI, rvreg, label, dvreg, svreg )
988  end select
989 
990 end function
991 
992 '':::::
993 function emitGE _
994  ( _
995  byval rvreg as IRVREG ptr, _
996  byval label as FBSYMBOL ptr, _
997  byval dvreg as IRVREG ptr, _
998  byval svreg as IRVREG ptr _
999  ) as EMIT_NODE ptr static
1000 
1001  select case as const dvreg->dtype
1002  '' longint?
1003  case FB_DATATYPE_LONGINT, FB_DATATYPE_ULONGINT
1004  function = hNewREL( EMIT_OP_CGEL, rvreg, label, dvreg, svreg )
1005 
1006  '' float?
1007  case FB_DATATYPE_SINGLE, FB_DATATYPE_DOUBLE
1008  function = hNewREL( EMIT_OP_CGEF, rvreg, label, dvreg, svreg )
1009 
1010  case else
1011  function = hNewREL( EMIT_OP_CGEI, rvreg, label, dvreg, svreg )
1012  end select
1013 
1014 end function
1015 
1016 '':::::
1017 function emitLE _
1018  ( _
1019  byval rvreg as IRVREG ptr, _
1020  byval label as FBSYMBOL ptr, _
1021  byval dvreg as IRVREG ptr, _
1022  byval svreg as IRVREG ptr _
1023  ) as EMIT_NODE ptr static
1024 
1025  select case as const dvreg->dtype
1026  '' longint?
1027  case FB_DATATYPE_LONGINT, FB_DATATYPE_ULONGINT
1028  function = hNewREL( EMIT_OP_CLEL, rvreg, label, dvreg, svreg )
1029 
1030  '' float?
1031  case FB_DATATYPE_SINGLE, FB_DATATYPE_DOUBLE
1032  function = hNewREL( EMIT_OP_CLEF, rvreg, label, dvreg, svreg )
1033 
1034  case else
1035  function = hNewREL( EMIT_OP_CLEI, rvreg, label, dvreg, svreg )
1036  end select
1037 
1038 end function
1039 
1040 ''::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
1041 '' UOP
1042 ''::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
1043 
1044 '':::::
1045 function emitNEG _
1046  ( _
1047  byval dvreg as IRVREG ptr _
1048  ) as EMIT_NODE ptr static
1049 
1050  select case as const dvreg->dtype
1051  '' longint?
1052  case FB_DATATYPE_LONGINT, FB_DATATYPE_ULONGINT
1053  function = hNewUOP( EMIT_OP_NEGL, dvreg )
1054 
1055  '' float?
1056  case FB_DATATYPE_SINGLE, FB_DATATYPE_DOUBLE
1057  function = hNewUOP( EMIT_OP_NEGF, dvreg )
1058 
1059  case else
1060  function = hNewUOP( EMIT_OP_NEGI, dvreg )
1061  end select
1062 
1063 end function
1064 
1065 '':::::
1066 function emitNOT _
1067  ( _
1068  byval dvreg as IRVREG ptr _
1069  ) as EMIT_NODE ptr static
1070 
1071  select case dvreg->dtype
1072  '' longint?
1073  case FB_DATATYPE_LONGINT, FB_DATATYPE_ULONGINT
1074  function = hNewUOP( EMIT_OP_NOTL, dvreg )
1075 
1076  case else
1077  function = hNewUOP( EMIT_OP_NOTI, dvreg )
1078  end select
1079 
1080 end function
1081 
1082 '':::::
1083 function emitHADD _
1084  ( _
1085  byval dvreg as IRVREG ptr _
1086  ) as EMIT_NODE ptr static
1087 
1088  select case as const dvreg->dtype
1089  '' float?
1090  case FB_DATATYPE_SINGLE, FB_DATATYPE_DOUBLE
1091  function = hNewUOP( EMIT_OP_HADDF, dvreg )
1092 
1093  case else
1094  'function = hNewUOP( EMIT_OP_HADDI, dvreg )
1095  end select
1096 
1097 end function
1098 
1099 '':::::
1100 function emitABS _
1101  ( _
1102  byval dvreg as IRVREG ptr _
1103  ) as EMIT_NODE ptr static
1104 
1105  select case as const dvreg->dtype
1106  '' longint?
1107  case FB_DATATYPE_LONGINT, FB_DATATYPE_ULONGINT
1108  function = hNewUOP( EMIT_OP_ABSL, dvreg )
1109 
1110  '' float?
1111  case FB_DATATYPE_SINGLE, FB_DATATYPE_DOUBLE
1112  function = hNewUOP( EMIT_OP_ABSF, dvreg )
1113 
1114  case else
1115  function = hNewUOP( EMIT_OP_ABSI, dvreg )
1116  end select
1117 
1118 end function
1119 
1120 '':::::
1121 function emitSGN _
1122  ( _
1123  byval dvreg as IRVREG ptr _
1124  ) as EMIT_NODE ptr static
1125 
1126  select case as const dvreg->dtype
1127  '' longint?
1128  case FB_DATATYPE_LONGINT, FB_DATATYPE_ULONGINT
1129  function = hNewUOP( EMIT_OP_SGNL, dvreg )
1130 
1131  '' float?
1132  case FB_DATATYPE_SINGLE, FB_DATATYPE_DOUBLE
1133  function = hNewUOP( EMIT_OP_SGNF, dvreg )
1134 
1135  case else
1136  function = hNewUOP( EMIT_OP_SGNI, dvreg )
1137  end select
1138 
1139 end function
1140 
1141 '':::::
1142 function emitFIX _
1143  ( _
1144  byval dvreg as IRVREG ptr _
1145  ) as EMIT_NODE ptr static
1146 
1147  function = hNewUOP( EMIT_OP_FIX, dvreg )
1148 
1149 end function
1150 
1151 '':::::
1152 function emitFRAC _
1153  ( _
1154  byval dvreg as IRVREG ptr _
1155  ) as EMIT_NODE ptr static
1156 
1157  function = hNewUOP( EMIT_OP_FRAC, dvreg )
1158 
1159 end function
1160 
1161 function emitCONVFD2FS( byval dvreg as IRVREG ptr ) as EMIT_NODE ptr
1162  function = hNewUOP( EMIT_OP_CONVFD2FS, dvreg )
1163 end function
1164 
1165 '':::::
1166 function emitSIN _
1167  ( _
1168  byval dvreg as IRVREG ptr _
1169  ) as EMIT_NODE ptr static
1170 
1171  function = hNewUOP( EMIT_OP_SIN, dvreg )
1172 
1173 end function
1174 
1175 '':::::
1176 function emitASIN _
1177  ( _
1178  byval dvreg as IRVREG ptr _
1179  ) as EMIT_NODE ptr static
1180 
1181  function = hNewUOP( EMIT_OP_ASIN, dvreg )
1182 
1183 end function
1184 
1185 '':::::
1186 function emitCOS _
1187  ( _
1188  byval dvreg as IRVREG ptr _
1189  ) as EMIT_NODE ptr static
1190 
1191  function = hNewUOP( EMIT_OP_COS, dvreg )
1192 
1193 end function
1194 
1195 '':::::
1196 function emitACOS _
1197  ( _
1198  byval dvreg as IRVREG ptr _
1199  ) as EMIT_NODE ptr static
1200 
1201  function = hNewUOP( EMIT_OP_ACOS, dvreg )
1202 
1203 end function
1204 
1205 '':::::
1206 function emitTAN _
1207  ( _
1208  byval dvreg as IRVREG ptr _
1209  ) as EMIT_NODE ptr static
1210 
1211  function = hNewUOP( EMIT_OP_TAN, dvreg )
1212 
1213 end function
1214 
1215 '':::::
1216 function emitATAN _
1217  ( _
1218  byval dvreg as IRVREG ptr _
1219  ) as EMIT_NODE ptr static
1220 
1221  function = hNewUOP( EMIT_OP_ATAN, dvreg )
1222 
1223 end function
1224 
1225 '':::::
1226 function emitSQRT _
1227  ( _
1228  byval dvreg as IRVREG ptr _
1229  ) as EMIT_NODE ptr static
1230 
1231  function = hNewUOP( EMIT_OP_SQRT, dvreg )
1232 
1233 end function
1234 
1235 '':::::
1236 function emitRSQRT _
1237  ( _
1238  byval dvreg as IRVREG ptr _
1239  ) as EMIT_NODE ptr static
1240 
1241  function = hNewUOP( EMIT_OP_RSQRT, dvreg )
1242 
1243 end function
1244 
1245 '':::::
1246 function emitRCP _
1247  ( _
1248  byval dvreg as IRVREG ptr _
1249  ) as EMIT_NODE ptr static
1250 
1251  function = hNewUOP( EMIT_OP_RCP, dvreg )
1252 
1253 end function
1254 
1255 '':::::
1256 function emitLOG _
1257  ( _
1258  byval dvreg as IRVREG ptr _
1259  ) as EMIT_NODE ptr static
1260 
1261  function = hNewUOP( EMIT_OP_LOG, dvreg )
1262 
1263 end function
1264 
1265 '':::::
1266 function emitEXP _
1267  ( _
1268  byval dvreg as IRVREG ptr _
1269  ) as EMIT_NODE ptr static
1270 
1271  function = hNewUOP( EMIT_OP_EXP, dvreg )
1272 
1273 end function
1274 
1275 '':::::
1276 function emitFLOOR _
1277  ( _
1278  byval dvreg as IRVREG ptr _
1279  ) as EMIT_NODE ptr static
1280 
1281  function = hNewUOP( EMIT_OP_FLOOR, dvreg )
1282 
1283 end function
1284 
1285 '':::::
1286 function emitXchgTOS _
1287  ( _
1288  byval svreg as IRVREG ptr _
1289  ) as EMIT_NODE ptr static
1290 
1291  function = hNewUOP( EMIT_OP_XCHGTOS, svreg )
1292 
1293 end function
1294 
1295 '':::::
1296 function emitSWZREP _
1297  ( _
1298  byval dvreg as IRVREG ptr _
1299  ) as EMIT_NODE ptr static
1300 
1301  function = hNewUOP( EMIT_OP_SWZREP, dvreg )
1302 
1303 end function
1304 
1305 ''::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
1306 '' STK
1307 ''::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
1308 
1309 function emitSTACKALIGN( byval bytes as integer ) as EMIT_NODE ptr
1310  dim as IRVREG vr
1311 
1312  vr.typ = IR_VREGTYPE_IMM
1313  vr.value.i = bytes
1314 
1315  function = hNewSTK( EMIT_OP_STACKALIGN, @vr )
1316 end function
1317 
1318 '':::::
1319 function emitPUSH _
1320  ( _
1321  byval svreg as IRVREG ptr _
1322  ) as EMIT_NODE ptr static
1323 
1324  select case as const svreg->dtype
1325  '' longint?
1326  case FB_DATATYPE_LONGINT, FB_DATATYPE_ULONGINT
1327  function = hNewSTK( EMIT_OP_PUSHL, svreg )
1328 
1329  '' float?
1330  case FB_DATATYPE_SINGLE, FB_DATATYPE_DOUBLE
1331  function = hNewSTK( EMIT_OP_PUSHF, svreg )
1332 
1333  case else
1334  function = hNewSTK( EMIT_OP_PUSHI, svreg )
1335  end select
1336 
1337 end function
1338 
1339 '':::::
1340 function emitPOP _
1341  ( _
1342  byval dvreg as IRVREG ptr _
1343  ) as EMIT_NODE ptr static
1344 
1345  select case as const dvreg->dtype
1346  '' longint?
1347  case FB_DATATYPE_LONGINT, FB_DATATYPE_ULONGINT
1348  function = hNewSTK( EMIT_OP_POPL, dvreg )
1349 
1350  '' float?
1351  case FB_DATATYPE_SINGLE, FB_DATATYPE_DOUBLE
1352  function = hNewSTK( EMIT_OP_POPF, dvreg )
1353 
1354  case else
1355  function = hNewSTK( EMIT_OP_POPI, dvreg )
1356  end select
1357 
1358 end function
1359 
1360 '':::::
1361 function emitPUSHUDT _
1362  ( _
1363  byval svreg as IRVREG ptr, _
1364  byval sdsize as integer _
1365  ) as EMIT_NODE ptr static
1366 
1367  function = hNewSTK( EMIT_OP_PUSHUDT, svreg, sdsize )
1368 
1369 end function
1370 
1371 ''::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
1372 '' MISC
1373 ''::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
1374 
1375 sub emitCOMMENT( byval text as zstring ptr )
1376  hNewLIT( "##" + *text, FALSE )
1377 end sub
1378 
1379 sub emitASM( byval text as zstring ptr )
1380  hNewLIT( text, TRUE )
1381 
1382  '' reset reg usage
1383  for c as integer = 0 to EMIT_REGCLASSES-1
1384  EMIT_REGTRASHALL( c ) '' can't check the reg usage
1385  next
1386 end sub
1387 
1388 function emitJMPTB _
1389  ( _
1390  byval tbsym as FBSYMBOL ptr, _
1391  byval values1 as ulongint ptr, _
1392  byval labels1 as FBSYMBOL ptr ptr, _
1393  byval labelcount as integer, _
1394  byval deflabel as FBSYMBOL ptr, _
1395  byval minval as ulongint, _
1396  byval maxval as ulongint _
1397  ) as EMIT_NODE ptr
1398 
1399  dim as EMIT_NODE ptr n = any
1400  dim as ulongint ptr values = any
1401  dim as FBSYMBOL ptr ptr labels = any
1402 
1403  assert( labelcount > 0 )
1404 
1405  '' Duplicate the values/labels arrays
1406  values = callocate( sizeof( *values ) * labelcount )
1407  labels = callocate( sizeof( *labels ) * labelcount )
1408  for i as integer = 0 to labelcount - 1
1409  values[i] = values1[i]
1410  labels[i] = labels1[i]
1411  next
1412 
1413  n = hNewNode( EMIT_NODECLASS_JTB, FALSE )
1414 
1415  n->jtb.tbsym = tbsym
1416  n->jtb.values = values
1417  n->jtb.labels = labels
1418  n->jtb.labelcount = labelcount
1419  n->jtb.deflabel = deflabel
1420  n->jtb.minval = minval
1421  n->jtb.maxval = maxval
1422 
1423  function = n
1424 end function
1425 
1426 '':::::
1427 function emitCALL _
1428  ( _
1429  byval label as FBSYMBOL ptr, _
1430  byval bytestopop as integer _
1431  ) as EMIT_NODE ptr static
1432 
1433  function = hNewBRANCH( EMIT_OP_CALL, NULL, label, bytestopop )
1434 
1435 end function
1436 
1437 '':::::
1438 function emitCALLPTR _
1439  ( _
1440  byval svreg as IRVREG ptr, _
1441  byval bytestopop as integer _
1442  ) as EMIT_NODE ptr static
1443 
1444  function = hNewBRANCH( EMIT_OP_CALLPTR, svreg, NULL, bytestopop )
1445 
1446 end function
1447 
1448 '':::::
1449 function emitBRANCH _
1450  ( _
1451  byval op as integer, _
1452  byval label as FBSYMBOL ptr _
1453  ) as EMIT_NODE ptr static
1454 
1455  function = hNewBRANCH( EMIT_OP_BRANCH, NULL, label, op )
1456 
1457 end function
1458 
1459 '':::::
1460 function emitJUMP _
1461  ( _
1462  byval label as FBSYMBOL ptr _
1463  ) as EMIT_NODE ptr static
1464 
1465  function = hNewBRANCH( EMIT_OP_JUMP, NULL, label )
1466 
1467 end function
1468 
1469 '':::::
1470 function emitJUMPPTR _
1471  ( _
1472  byval svreg as IRVREG ptr _
1473  ) as EMIT_NODE ptr static
1474 
1475  function = hNewBRANCH( EMIT_OP_JUMPPTR, svreg, NULL )
1476 
1477 end function
1478 
1479 function emitRET( byval bytestopop as integer ) as EMIT_NODE ptr
1480  dim as IRVREG vr
1481 
1482  vr.typ = IR_VREGTYPE_IMM
1483  vr.value.i = bytestopop
1484 
1485  function = hNewUOP( EMIT_OP_RET, @vr )
1486 end function
1487 
1488 '':::::
1489 function emitLABEL _
1490  ( _
1491  byval label as FBSYMBOL ptr _
1492  ) as EMIT_NODE ptr static
1493 
1494  function = hNewSYMOP( EMIT_OP_LABEL, label )
1495 
1496 end function
1497 
1498 '':::::
1499 function emitPUBLIC _
1500  ( _
1501  byval label as FBSYMBOL ptr _
1502  ) as EMIT_NODE ptr static
1503 
1504  function = hNewSYMOP( EMIT_OP_PUBLIC, label )
1505 
1506 end function
1507 
1508 
1509 ''::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
1510 '' MEM
1511 ''::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
1512 
1513 '':::::
1514 function emitMEMMOVE _
1515  ( _
1516  byval dvreg as IRVREG ptr, _
1517  byval svreg as IRVREG ptr, _
1518  byval bytes as integer _
1519  ) as EMIT_NODE ptr static
1520 
1521  function = hNewMEM( EMIT_OP_MEMMOVE, dvreg, svreg, bytes )
1522 
1523 end function
1524 
1525 '':::::
1526 function emitMEMSWAP _
1527  ( _
1528  byval dvreg as IRVREG ptr, _
1529  byval svreg as IRVREG ptr, _
1530  byval bytes as integer _
1531  ) as EMIT_NODE ptr static
1532 
1533  function = hNewMEM( EMIT_OP_MEMSWAP, dvreg, svreg, bytes )
1534 
1535 end function
1536 
1537 '':::::
1538 function emitMEMCLEAR _
1539  ( _
1540  byval dvreg as IRVREG ptr, _
1541  byval bytes_vreg as IRVREG ptr _
1542  ) as EMIT_NODE ptr static
1543 
1544  function = hNewMEM( EMIT_OP_MEMCLEAR, dvreg, bytes_vreg, 0 )
1545 
1546 end function
1547 
1548 '':::::
1549 function emitSTKCLEAR _
1550  ( _
1551  byval bytes as integer, _
1552  byval baseofs as integer _
1553  ) as EMIT_NODE ptr static
1554 
1555  function = hNewMEM( EMIT_OP_STKCLEAR, NULL, NULL, bytes, baseofs )
1556 
1557 end function
1558 
1559 ''::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
1560 '' DBG
1561 ''::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
1562 
1563 '':::::
1564 function emitDBGLineBegin _
1565  ( _
1566  byval proc as FBSYMBOL ptr, _
1567  byval lnum as integer _
1568  ) as EMIT_NODE ptr
1569 
1570  function = hNewDBG( EMIT_OP_LINEINI, proc, lnum, emit.pos )
1571 
1572 end function
1573 
1574 '':::::
1575 function emitDBGLineEnd _
1576  ( _
1577  byval proc as FBSYMBOL ptr, _
1578  byval lnum as integer _
1579  ) as EMIT_NODE ptr
1580 
1581  function = hNewDBG( EMIT_OP_LINEEND, proc, lnum, emit.pos )
1582 
1583 end function
1584 
1585 '':::::
1586 function emitDBGScopeBegin _
1587  ( _
1588  byval sym as FBSYMBOL ptr _
1589  ) as EMIT_NODE ptr
1590 
1591  function = hNewDBG( EMIT_OP_SCOPEINI, sym )
1592 
1593 end function
1594 
1595 '':::::
1596 function emitDBGScopeEnd _
1597  ( _
1598  byval sym as FBSYMBOL ptr _
1599  ) as EMIT_NODE ptr
1600 
1601  function = hNewDBG( EMIT_OP_SCOPEEND, sym )
1602 
1603 end function
1604 
1605 
1606