107 byval dtype
as integer, _
108 byval subtype
as FBSYMBOL
ptr, _
109 byval is_result
as integer =
FALSE _
116 byval op as integer, _
117 byval proc as FBSYMBOL
ptr, _
118 byval ex
as integer _
121 declare function hVregToStr(
byval vreg
as IRVREG
ptr )
as string
122 declare sub _emitConvert(
byval v1
as IRVREG
ptr,
byval v2
as IRVREG
ptr )
123 declare sub _emitStore(
byval v1
as IRVREG
ptr,
byval v2
as IRVREG
ptr )
127 byval op as integer, _
128 byval v1
as IRVREG
ptr, _
129 byval v2
as IRVREG
ptr, _
130 byval vr as IRVREG
ptr, _
131 byval ex
as FBSYMBOL
ptr _
142 irSetOption( IR_OPT_CPUSELFBOPS
or IR_OPT_FPUIMMEDIATES
or IR_OPT_NOINLINEOPS )
198 if( fbCpuTypeIsX86( ) =
FALSE )
then
202 select case as const( symbGetProcMode(
proc ) )
203 case FB_FUNCMODE_STDCALL, FB_FUNCMODE_STDCALL_MS, FB_FUNCMODE_PASCAL
204 function =
"x86_stdcallcc "
210 byval proc as FBSYMBOL
ptr, _
211 byval is_proto
as integer _
216 assert( symbIsProc(
proc ) )
222 symbGetProcRealSubtype(
proc ), TRUE )
233 dim as FBSYMBOL
ptr hidden = NULL
236 hidden = symbGetSubType(
proc )
237 ln +=
hEmitType( typeAddrOf( symbGetType( hidden ) ), hidden )
240 ln +=
hEmitType( typeAddrOf( symbGetType( hidden ) ), symbGetSubtype( hidden ) )
244 if( symbGetProcParams(
proc ) > 0 )
then
249 var param = symbGetProcLastParam(
proc )
251 if( symbGetParamMode( param ) = FB_PARAMMODE_VARARG )
then
254 var dtype = symbGetType( param )
255 var subtype = param->subtype
259 if( is_proto =
FALSE )
then
266 param = symbGetProcPrevParam(
proc, param )
279 if(
proc->attrib
and FB_SYMBATTRIB_NAKED )
then
287 dim as FBSYMBOL
ptr ns = symbGetNamespace( sym )
290 do until( ns = @symbGetGlobalNamespc( ) )
291 s += *symbGetName( ns )
293 ns = symbGetNamespace( ns )
296 if( sym->id.
alias <> NULL )
then
299 s += *symbGetName( sym )
310 if( symbGetIsEmitted( s ) )
then
315 if( symbIsLocal( s ) =
FALSE )
then
319 select case as const( symbGetClass( s ) )
320 case FB_SYMBCLASS_ENUM
321 symbSetIsEmitted( s )
324 case FB_SYMBCLASS_STRUCT
327 case FB_SYMBCLASS_PROC
328 if( symbGetIsFuncPtr( s ) )
then
330 symbSetIsEmitted( s )
345 select case( symbGetClass( sym ) )
346 case FB_SYMBCLASS_VAR, FB_SYMBCLASS_FIELD
347 if( (symbGetIsDynamic( sym ) =
FALSE)
and _
348 (symbGetArrayDimensions( sym ) <> 0) )
then
349 dim as FBVARDIM
ptr d = symbGetArrayFirstDim( sym )
352 s +=
"[" +
str( d->upper - d->lower + 1 ) +
"]"
360 dim as integer length = 0
361 select case( symbGetType( sym ) )
362 case FB_DATATYPE_FIXSTR, FB_DATATYPE_CHAR
363 length = symbGetStrLen( sym )
364 case FB_DATATYPE_WCHAR
365 length = symbGetWstrLen( sym )
367 if( length > 0 )
then
368 s +=
"[" +
str( length ) +
"]"
376 byref ln as string, _
377 byval wantedlength
as integer, _
378 byval z
as zstring ptr, _
379 byval length
as integer _
382 dim as integer ch =
any
396 if( length > wantedlength )
then
398 length = wantedlength
401 for i
as integer = 0
to length - 1
407 ln += $
"\" +
hex( ch, 2 )
415 while( length < wantedlength )
423 byref ln as string, _
424 byval wantedlength
as integer, _
425 byval w
as wstring ptr, _
426 byval length
as integer _
429 dim as uinteger ch =
any, wcharsize =
any
439 wcharsize = typeGetSize( FB_DATATYPE_WCHAR )
442 if( length > wantedlength )
then
444 length = wantedlength
447 for i
as integer = 0
to length - 1
451 if( wcharsize >= 1 )
then
452 ln += $
"\" +
hex( (ch )
and &hFF, 2 )
454 if( wcharsize >= 2 )
then
455 ln += $
"\" +
hex( (ch
shr 8)
and &hFF, 2 )
457 if( wcharsize >= 4 )
then
458 ln += $
"\" +
hex( (ch
shr 16)
and &hFF, 2 )
459 ln += $
"\" +
hex( (ch
shr 24)
and &hFF, 2 )
464 for j
as integer = 2
to wcharsize
471 while( length < wantedlength )
473 for j
as integer = 1
to wcharsize
481 function =
"[" +
str( length ) +
" x i8]"
485 select case( symbGetType( sym ) )
486 case FB_DATATYPE_FIXSTR, FB_DATATYPE_CHAR, FB_DATATYPE_WCHAR
489 function =
hEmitType( symbGetType( sym ), symbGetSubtype( sym ) )
495 dim as integer is_global =
any, length =
any
498 if( symbGetVarIsAllocated( sym ) )
then
502 symbSetVarIsAllocated( sym )
505 if( symbGetIsLiteral( sym ) )
then
506 if( symbGetIsAccessed( sym ) =
FALSE )
then
510 select case( symbGetType( sym ) )
511 case FB_DATATYPE_CHAR, FB_DATATYPE_WCHAR
516 ln +=
"private constant "
519 if( symbGetType( sym ) = FB_DATATYPE_WCHAR )
then
520 length = symbGetWstrLen( sym )
523 length = symbGetStrLen( sym )
537 if( symbGetIsInitialized( sym )
and (symbIsLocal( sym ) =
FALSE or symbIsStatic( sym )) )
then
539 if( symbIsExtern( sym ) )
then
544 if( symbIsLocal( sym ) =
FALSE )
then
545 if( symbGetIsAccessed( sym ) =
FALSE )
then
547 if( symbIsPublic( sym ) =
FALSE )
then
553 astTypeIniFlush( sym->var_.initree, sym, AST_INIOPT_ISINI
or AST_INIOPT_ISSTATIC )
554 sym->var_.initree = NULL
559 if( symbGetIsDynamic( sym ) )
then
564 if( symbGetLen( sym ) <= 0 )
then
568 is_global = symbGetAttrib( sym )
and _
569 (FB_SYMBATTRIB_COMMON
or FB_SYMBATTRIB_PUBLIC
or _
570 FB_SYMBATTRIB_EXTERN
or FB_SYMBATTRIB_STATIC
or _
571 FB_SYMBATTRIB_SHARED)
587 ln +=
" zeroinitializer"
593 if( symbGetIsAccessed( s ) =
FALSE )
then
605 if( symbGetIsGccBuiltin( s ) )
then
607 var param = symbGetProcLastParam( s )
609 do while( param <> NULL )
610 params +=
"temp_ppparam$" & cnt
612 param = symbGetProcPrevParam( s, param )
623 dim as string ln =
"declare "
626 if( symbGetIsGlobalCtor( s ) )
then
627 ln +=
" __attribute__ ((constructor)) "
628 elseif( symbGetIsGlobalDtor( s ) )
then
629 ln +=
" __attribute__ ((destructor)) "
639 dim as FBSYMBOL
ptr fld =
any
661 if( symbGetIsBeingEmitted( s ) )
then
665 symbSetIsBeingEmitted( s )
675 if( symbGetIsEmitted( s ) )
then
680 symbSetIsEmitted( s )
685 if( symbGetName( s ) )
then
695 if( s->udt.align > 0 )
then
696 if( s->udt.align = 1 )
then
697 attrib =
" __attribute__((packed))"
699 attrib =
" __attribute__((aligned (" & s->udt.align &
")))"
721 symbResetIsBeingEmitted( s )
726 select case as const( symbGetClass( s ) )
727 case FB_SYMBCLASS_NAMESPACE
728 hEmitDecls( symbGetNamespaceTbHead( s ), procs )
730 case FB_SYMBCLASS_STRUCT
731 hEmitDecls( symbGetCompSymbTb( s ).head, procs )
733 case FB_SYMBCLASS_SCOPE
734 hEmitDecls( symbGetScopeSymbTbHead( s ), procs )
736 case FB_SYMBCLASS_VAR
737 if( procs =
FALSE )
then
741 case FB_SYMBCLASS_PROC
743 if( symbGetIsFuncPtr( s ) =
FALSE )
then
755 var s = astGetLastDataStmtSymbol( )
758 s = s->var_.
data.prev
778 byref fname
as string, _
779 byval rtype
as integer, _
780 byval ptype
as integer _
783 dim as string rtype_str, rtype_suffix
785 case FB_DATATYPE_INTEGER
786 rtype_str =
"integer"
789 case FB_DATATYPE_LONGINT
790 rtype_str =
"longint"
794 dim as string ptype_str, ptype_suffix
796 case FB_DATATYPE_SINGLE
800 case FB_DATATYPE_DOUBLE
806 hWriteLine(
"static inline " & rtype_str &
" fb_" & fname &
" ( " & ptype_str & !
" value ) {\n" & _
807 !
"\tvolatile " & rtype_str & !
" result;\n" & _
809 !
"\t\t\"fld" & ptype_suffix & !
" %1;\"\n" & _
810 !
"\t\t\"fistp" & rtype_suffix & !
" %0;\"\n" & _
811 !
"\t\t:\"=m\" (result)\n" & _
812 !
"\t\t:\"m\" (value)\n" & _
814 !
"\treturn result;\n" & _
841 if( symbGetIsAccessed( PROCLOOKUP( FTOSL ) )
or _
842 symbGetIsAccessed( PROCLOOKUP( FTOUL ) )
or _
843 symbGetIsAccessed( PROCLOOKUP( FTOUI ) ) )
then
844 hWriteFTOI(
"ftosl", FB_DATATYPE_LONGINT, FB_DATATYPE_SINGLE )
847 if( symbGetIsAccessed( PROCLOOKUP( FTOUL ) ) )
then
848 hWriteLine(
"#define fb_ftoul( v ) (ulongint)fb_ftosl( v )" )
851 if( symbGetIsAccessed( PROCLOOKUP( FTOUI ) ) )
then
852 hWriteLine(
"#define fb_ftoui( v ) (uinteger)fb_ftosl( v )" )
855 if( symbGetIsAccessed( PROCLOOKUP( FTOSI ) )
or _
856 symbGetIsAccessed( PROCLOOKUP( FTOSS ) )
or _
857 symbGetIsAccessed( PROCLOOKUP( FTOUS ) )
or _
858 symbGetIsAccessed( PROCLOOKUP( FTOSB ) )
or _
859 symbGetIsAccessed( PROCLOOKUP( FTOUB ) ) )
then
860 hWriteFTOI(
"ftosi", FB_DATATYPE_INTEGER, FB_DATATYPE_SINGLE )
863 if( symbGetIsAccessed( PROCLOOKUP( FTOSS ) ) )
then
864 hWriteLine(
"#define fb_ftoss( v ) (short)fb_ftosi( v )" )
867 if( symbGetIsAccessed( PROCLOOKUP( FTOUS ) ) )
then
868 hWriteLine(
"#define fb_ftous( v ) (ushort)fb_ftosi( v )" )
871 if( symbGetIsAccessed( PROCLOOKUP( FTOSB ) ) )
then
872 hWriteLine(
"#define fb_ftosb( v ) (byte)fb_ftosi( v )" )
875 if( symbGetIsAccessed( PROCLOOKUP( FTOUB ) ) )
then
876 hWriteLine(
"#define fb_ftoub( v ) (ubyte)fb_ftosi( v )" )
880 if( symbGetIsAccessed( PROCLOOKUP( DTOSL ) )
or _
881 symbGetIsAccessed( PROCLOOKUP( DTOUL ) )
or _
882 symbGetIsAccessed( PROCLOOKUP( DTOUI ) ) )
then
883 hWriteFTOI(
"dtosl", FB_DATATYPE_LONGINT, FB_DATATYPE_DOUBLE )
886 if( symbGetIsAccessed( PROCLOOKUP( DTOUL ) ) )
then
887 hWriteLine(
"#define fb_dtoul( v ) (ulongint)fb_dtosl( v )" )
890 if( symbGetIsAccessed( PROCLOOKUP( DTOUI ) ) )
then
891 hWriteLine(
"#define fb_dtoui( v ) (uinteger)fb_dtosl( v )" )
894 if( symbGetIsAccessed( PROCLOOKUP( DTOSI ) )
or _
895 symbGetIsAccessed( PROCLOOKUP( DTOSS ) )
or _
896 symbGetIsAccessed( PROCLOOKUP( DTOUS ) )
or _
897 symbGetIsAccessed( PROCLOOKUP( DTOSB ) )
or _
898 symbGetIsAccessed( PROCLOOKUP( DTOUB ) ) )
then
899 hWriteFTOI(
"dtosi", FB_DATATYPE_INTEGER, FB_DATATYPE_DOUBLE )
902 if( symbGetIsAccessed( PROCLOOKUP( DTOSS ) ) )
then
903 hWriteLine(
"#define fb_dtoss( v ) (short)fb_dtosi( v )" )
906 if( symbGetIsAccessed( PROCLOOKUP( DTOUS ) ) )
then
907 hWriteLine(
"#define fb_dtous( v ) (ushort)fb_dtosi( v )" )
910 if( symbGetIsAccessed( PROCLOOKUP( DTOSB ) ) )
then
911 hWriteLine(
"#define fb_dtosb( v ) (byte)fb_dtosi( v )" )
914 if( symbGetIsAccessed( PROCLOOKUP( DTOUB ) ) )
then
915 hWriteLine(
"#define fb_dtoub( v ) (ubyte)fb_dtosi( v )" )
925 env.outf.num =
freefile
926 if(
open( env.outf.
name,
for binary,
access read write,
as #env.outf.num ) <> 0 )
then
942 if( env.clopt.debug )
then
943 _emitDBG( AST_OP_DBG_LINEINI, NULL, 0 )
946 hWriteLine(
"; Compilation of " + env.inf.
name +
" started at " +
time( ) +
" on " +
date( ) )
958 hWriteLine(
"%string = type { i8*, i32, i32 }" )
961 hWriteLine(
"%wchar = type i" +
str( typeGetBits( FB_DATATYPE_WCHAR ) ) )
973 hWriteLine(
"declare void @llvm.memset.p0i8.i32(i8*, i8, i32, i32, i1) nounwind" )
976 hWriteLine(
"declare void @llvm.memmove.p0i8.p0i8.i32(i8*, i8*, i32, i32, i1) nounwind" )
996 hWriteLine(
"; Total compilation time: " & tottime &
" seconds. " )
999 if(
put( #env.outf.num, ,
ctx.
head_txt ) <> 0 )
then
1001 if(
put( #env.outf.num, ,
ctx.
body_txt ) <> 0 )
then
1003 if(
put( #env.outf.num, ,
ctx.
foot_txt ) <> 0 )
then
1006 if(
close( #env.outf.num ) <> 0 )
then
1015 case IR_OPTIONVALUE_MAXMEMBLOCKLEN
1023 proc->
proc.ext->dbg.iniline = lexLineNum( )
1027 proc->
proc.ext->dbg.endline = lexLineNum( )
1032 byval proc as FBSYMBOL
ptr, _
1033 byval sym
as FBSYMBOL
ptr _
1037 dim as integer parammode =
any
1049 if( symbIsParamByref( sym ) )
then
1050 parammode = FB_PARAMMODE_BYREF
1051 elseif( symbIsParamBydesc( sym ) )
then
1052 parammode = FB_PARAMMODE_BYDESC
1054 assert( symbIsParamByval( sym ) )
1055 parammode = FB_PARAMMODE_BYVAL
1058 var dtype = symbGetType( sym )
1059 var subtype = sym->subtype
1078 byval proc as FBSYMBOL
ptr, _
1079 byval sym
as FBSYMBOL
ptr _
1098 byval dtype
as integer, _
1099 byval subtype
as FBSYMBOL
ptr, _
1100 byval vtype
as integer _
1103 dim as IRVREG
ptr v =
any
1109 v->subtype = subtype
1111 if( vtype = IR_VREGTYPE_REG )
then
1125 byval dtype
as integer, _
1126 byval subtype
as FBSYMBOL
ptr _
1129 function =
hNewVR( dtype, subtype, IR_VREGTYPE_REG )
1135 byval dtype
as integer, _
1136 byval subtype
as FBSYMBOL
ptr, _
1137 byval value
as longint _
1140 dim as IRVREG
ptr vr =
any
1142 vr =
hNewVR( dtype, subtype, IR_VREGTYPE_IMM )
1150 byval dtype
as integer, _
1151 byval subtype
as FBSYMBOL
ptr, _
1152 byval value
as double _
1155 dim as IRVREG
ptr vr =
any
1157 vr =
hNewVR( dtype, subtype, IR_VREGTYPE_IMM )
1165 byval dtype
as integer, _
1166 byval subtype
as FBSYMBOL
ptr, _
1167 byval symbol
as FBSYMBOL
ptr, _
1168 byval ofs
as longint _
1171 dim as IRVREG
ptr vr =
hNewVR( dtype, subtype, IR_VREGTYPE_VAR )
1182 byval dtype
as integer, _
1183 byval subtype
as FBSYMBOL
ptr, _
1184 byval symbol
as FBSYMBOL
ptr, _
1185 byval ofs
as longint, _
1186 byval mult
as integer, _
1187 byval vidx
as IRVREG
ptr _
1190 dim as IRVREG
ptr vr =
hNewVR( dtype, subtype, IR_VREGTYPE_IDX )
1202 byval dtype
as integer, _
1203 byval subtype
as FBSYMBOL
ptr, _
1204 byval ofs
as longint, _
1205 byval vidx
as IRVREG
ptr _
1208 dim as IRVREG
ptr vr =
hNewVR( dtype, subtype, IR_VREGTYPE_PTR )
1219 byval dtype
as integer, _
1220 byval subtype
as FBSYMBOL
ptr, _
1221 byval symbol
as FBSYMBOL
ptr, _
1222 byval ofs
as longint _
1225 dim as IRVREG
ptr vr =
hNewVR( dtype, subtype, IR_VREGTYPE_OFS )
1236 byval v
as IRVREG
ptr, _
1237 byval dtype
as integer, _
1238 byval subtype
as FBSYMBOL
ptr _
1241 dim as IRVREG
ptr temp0 =
any
1243 if( (v->dtype <> dtype)
or (v->subtype <> subtype) )
then
1252 dim as integer dtype =
any, ofs =
any
1253 dim as FBSYMBOL
ptr subtype =
any
1254 dim as IRVREG
ptr vidx =
any, temp0 =
any
1256 assert( (v->typ = IR_VREGTYPE_VAR)
or _
1257 (v->typ = IR_VREGTYPE_IDX)
or _
1258 (v->typ = IR_VREGTYPE_PTR) )
1264 subtype = v->subtype
1268 select case( v->typ )
1269 case IR_VREGTYPE_PTR
1270 assert( irIsREG( vidx ) )
1273 v->typ = IR_VREGTYPE_REG
1274 v->dtype = typeAddrOf( v->dtype )
1279 if( (vidx <> NULL)
or (ofs <> 0) )
then
1281 temp0 =
_allocVreg( FB_DATATYPE_INTEGER, NULL )
1298 dim as IRVREG
ptr temp0 =
any
1305 select case( v->typ )
1306 case IR_VREGTYPE_REG, IR_VREGTYPE_IMM
1308 case IR_VREGTYPE_OFS
1319 if( v->ofs <> 0 )
then
1321 temp0 =
_allocVreg( FB_DATATYPE_INTEGER, NULL )
1325 _emitBop( AST_OP_ADD, temp0,
_allocVrImm( FB_DATATYPE_INTEGER, NULL, v->ofs ), NULL, NULL )
1339 temp0 =
_allocVreg( typeDeref( v->dtype ), v->subtype )
1348 byval dtype
as integer, _
1349 byval subtype
as FBSYMBOL
ptr, _
1350 byval is_result
as integer _
1354 static as const zstring ptr dtypeName(0
to FB_DATATYPES-1) = _
1383 dim as integer ptrcount = typeGetPtrCnt( dtype )
1384 dtype = typeGetDtOnly( dtype )
1386 select case as const( dtype )
1387 case FB_DATATYPE_STRUCT, FB_DATATYPE_ENUM
1391 elseif( dtype = FB_DATATYPE_ENUM )
then
1392 dtype = FB_DATATYPE_INTEGER
1394 dtype = FB_DATATYPE_VOID
1397 case FB_DATATYPE_FUNCTION
1402 case FB_DATATYPE_STRING, FB_DATATYPE_WCHAR
1403 if( is_result )
then
1404 if( ptrcount = 0 )
then
1409 case FB_DATATYPE_BITFIELD
1411 dtype = symbGetType( subtype )
1413 dtype = FB_DATATYPE_INTEGER
1416 case FB_DATATYPE_VOID
1420 if( ptrcount = 0 )
then
1426 if(
len( s ) = 0 )
then
1427 s = *dtypeName(dtype)
1430 if( ptrcount > 0 )
then
1431 s +=
string( ptrcount,
"*" )
1439 byval dtype
as integer, _
1440 byval subtype
as FBSYMBOL
ptr, _
1441 byval value
as integer _
1446 select case( dtype )
1447 case FB_DATATYPE_INTEGER, FB_DATATYPE_UINT, _
1448 FB_DATATYPE_LONG, FB_DATATYPE_ULONG, _
1457 if( typeIsPtr( dtype ) )
then
1463 s +=
hEmitType( FB_DATATYPE_INTEGER, NULL ) +
" " +
str( value )
1464 s +=
" to " +
hEmitType( dtype, subtype )
1472 function =
str( value )
1481 function =
"0x" +
hex( *
cptr(
ulongint ptr, @value ), 16 )
1486 dim as FBSYMBOL
ptr sym =
any
1488 select case as const( v->typ )
1489 case IR_VREGTYPE_VAR, IR_VREGTYPE_IDX, IR_VREGTYPE_PTR
1492 case IR_VREGTYPE_OFS
1493 assert( v->ofs = 0 )
1496 if( symbGetIsLiteral( sym ) )
then
1503 s +=
hEmitType( typeAddrOf( symbGetType( sym ) ), NULL )
1509 case IR_VREGTYPE_IMM
1510 if( typeGetClass( v->dtype ) = FB_DATACLASS_FPOINT )
then
1512 elseif( typeGetSize( v->dtype ) = 8 )
then
1515 s =
hEmitInt( v->dtype, v->subtype, v->value.i )
1518 case IR_VREGTYPE_REG
1522 s =
"%vr" +
str( v->reg )
1540 byval op as integer, _
1541 byval dtype
as integer _
1544 select case as const(
op )
1546 if( typeGetClass( dtype ) = FB_DATACLASS_FPOINT )
then
1552 if( typeGetClass( dtype ) = FB_DATACLASS_FPOINT )
then
1558 if( typeGetClass( dtype ) = FB_DATACLASS_FPOINT )
then
1568 if( typeGetClass( dtype ) = FB_DATACLASS_FPOINT )
then
1584 function = @
"icmp eq"
1586 function = @
"icmp ne"
1588 function = @
"icmp sgt"
1590 function = @
"icmp slt"
1592 function = @
"icmp sge"
1594 function = @
"icmp sle"
1608 byval op as integer, _
1609 byval v1
as IRVREG
ptr, _
1610 byval v2
as IRVREG
ptr, _
1611 byval vr as IRVREG
ptr, _
1612 byval ex
as FBSYMBOL
ptr _
1615 dim as string ln, falselabel
1616 dim as IRVREG
ptr vresult =
any, vtemp =
any
1617 dim as integer is_comparison =
any
1621 case AST_OP_EQ, AST_OP_NE, AST_OP_GT, AST_OP_LT, AST_OP_GE, AST_OP_LE
1622 is_comparison = TRUE
1624 is_comparison =
FALSE
1628 if( is_comparison
and (
vr = NULL) )
then
1632 vresult =
_allocVreg( FB_DATATYPE_INTEGER, NULL )
1657 ln +=
"label %" + falselabel
1669 assert( irIsREG(
vr ) )
1673 vresult =
_allocVreg( v1->dtype, v1->subtype )
1685 ln +=
hEmitType( vresult->dtype, vresult->subtype )
1694 if( is_comparison )
then
1695 vtemp =
_allocVreg( vresult->dtype, vresult->subtype )
1700 ln +=
hEmitType( vresult->dtype, vresult->subtype )
1706 if(
vr = NULL )
then
1707 if( irIsREG( v1 ) )
then
1717 byval op as integer, _
1718 byval v1
as IRVREG
ptr, _
1719 byval vr as IRVREG
ptr _
1722 dim as IRVREG
ptr v2 =
any
1741 dim as integer ldtype =
any, rdtype =
any, lptr =
any, rptr =
any
1742 dim as zstring ptr op =
any
1743 dim as IRVREG
ptr v0 =
any
1747 assert( (ldtype <> rdtype)
or (v1->subtype <> v2->subtype) )
1749 if( typeGetClass( ldtype ) = FB_DATACLASS_FPOINT )
then
1750 if( typeGetClass( rdtype ) = FB_DATACLASS_FPOINT )
then
1753 if( typeGetSize( ldtype ) < typeGetSize( rdtype ) )
then
1756 assert( typeGetSize( ldtype ) > typeGetSize( rdtype ) )
1761 if( typeIsSigned( rdtype ) )
then
1768 if( typeGetClass( rdtype ) = FB_DATACLASS_FPOINT )
then
1770 if( typeIsSigned( ldtype ) )
then
1777 if( typeIsPtr( ldtype ) )
then
1778 if( typeIsPtr( rdtype ) )
then
1786 if( typeIsPtr( rdtype ) )
then
1789 if( typeGetSize( ldtype ) = typeGetSize( rdtype ) )
then
1793 if( typeGetSize( ldtype ) < typeGetSize( rdtype ) )
then
1796 if( typeIsSigned( ldtype ) )
then
1808 if( irIsREG( v1 ) )
then
1823 if( irIsREG( v1 ) =
FALSE )
then
1828 sub _emitStore(
byval l as IRVREG
ptr,
byval r
as IRVREG
ptr )
1854 byval v1
as IRVREG
ptr, _
1855 byval vr as IRVREG
ptr _
1867 byval param
as FBSYMBOL
ptr, _
1868 byval vr as IRVREG
ptr, _
1869 byval udtlen
as longint, _
1870 byval level as integer _
1883 byval op as integer, _
1884 byval v1
as IRVREG
ptr, _
1885 byval vr as IRVREG
ptr _
1900 assert( irIsREG(
vr ) )
1906 assert( v1->typ = IR_VREGTYPE_VAR )
1907 assert( v1->ofs = 0 )
1908 assert( v1->vidx = NULL )
1909 v1->typ = IR_VREGTYPE_REG
1910 v1->dtype = typeAddrOf( v1->dtype )
1914 if( (
vr->dtype <> v1->dtype)
or (
vr->subtype <> v1->subtype) )
then
1926 assert( irIsREG(
vr )
and irIsREG( v1 ) )
1935 byval pname
as zstring ptr, _
1936 byval proc as FBSYMBOL
ptr, _
1937 byval bytestopop
as integer, _
1938 byval vr as IRVREG
ptr, _
1939 byval level as integer _
1943 dim as IRCALLARG ptr arg =
any, prev =
any
1944 dim as IRVREG
ptr varg =
any, v0 =
any
1946 assert( symbIsProc(
proc ) )
1948 if(
vr = NULL )
then
1951 if( symbGetType(
proc ) <> FB_DATATYPE_VOID )
then
1953 symbGetProcRealSubtype(
proc ) )
1958 if( irIsREG(
vr ) )
then
2000 if( irIsREG(
vr ) =
FALSE )
then
2008 byval proc as FBSYMBOL
ptr, _
2009 byval bytestopop
as integer, _
2010 byval vr as IRVREG
ptr, _
2011 byval level as integer _
2020 byval v1
as IRVREG
ptr, _
2021 byval vr as IRVREG
ptr, _
2022 byval bytestopop
as integer, _
2023 byval level as integer _
2026 dim as FBSYMBOL
ptr proc =
any
2028 assert( v1->dtype = typeAddrOf( FB_DATATYPE_FUNCTION ) )
2043 assert(
op = AST_OP_JMP )
2054 byval v1
as IRVREG
ptr, _
2055 byval tbsym
as FBSYMBOL
ptr, _
2056 byval values
as ulongint ptr, _
2057 byval labels
as FBSYMBOL
ptr ptr, _
2058 byval labelcount
as integer, _
2059 byval deflabel
as FBSYMBOL
ptr, _
2060 byval minval
as ulongint, _
2061 byval maxval
as ulongint _
2066 assert( labelcount > 0 )
2078 for i
as integer = 0
to labelcount - 1
2079 ln =
"%integer " +
str( values[i] ) +
", "
2091 byval op as integer, _
2092 byval v1
as IRVREG
ptr, _
2093 byval v2
as IRVREG
ptr, _
2094 byval bytes
as longint _
2102 case AST_OP_MEMCLEAR
2110 ln +=
"@llvm.memset.p0i8.i32( "
2123 ln +=
"@llvm.memmove.p0i8.p0i8.i32( "
2126 ln +=
"i32 " +
str( cunsg( bytes ) ) +
", "
2130 ln +=
"i32 1, i1 false )"
2141 byval op as integer, _
2142 byval proc as FBSYMBOL
ptr, _
2143 byval ex
as integer _
2146 if(
op = AST_OP_DBG_LINEINI )
then
2167 if( symbGetOfs( sym ) > 0 )
then
2169 elseif( symbGetOfs( sym ) < 0 )
then
2193 byval dtype
as integer, _
2194 byval subtype
as FBSYMBOL
ptr _
2208 var dtype = symbGetType( sym )
2210 if( typeGetSize( dtype ) = 8 )
then
2219 var dtype = symbGetType( sym )
2232 byval varlength
as longint, _
2233 byval literal
as zstring ptr, _
2234 byval litlength
as longint _
2249 byval varlength
as longint, _
2250 byval literal
as wstring ptr, _
2251 byval litlength
as longint _
2278 if(
right(
ctx.
varini, 2 ) =
", " )
then
2306 ln =
"@__fbctinf = internal constant "
2309 ln +=
", section ""." + FB_INFOSEC_NAME +
""""
2314 ln =
"@llvm.used = appending global [1 x i8*] "
2318 ln +=
", section ""llvm.metadata"""
2327 byval proc as FBSYMBOL
ptr, _
2328 byval initlabel
as FBSYMBOL
ptr _
2336 if( symbIsExport(
proc ) )
then
2338 elseif( symbIsPrivate(
proc ) )
then
2353 byval proc as FBSYMBOL
ptr, _
2354 byval initlabel
as FBSYMBOL
ptr, _
2355 byval exitlabel
as FBSYMBOL
ptr _
2359 if( symbGetType(
proc ) = FB_DATATYPE_VOID )
then