21 byval s
as FBSYMBOL
ptr _
26 byval section
as integer, _
27 byval priority
as integer _
28 )
as const zstring ptr
32 byval section
as integer, _
33 byval priority
as integer _
36 declare function _getTypeString(
byval dtype
as integer )
as const zstring ptr
41 dim shared rnameTB(0
to EMIT_MAXRTABLES-1, 0
to EMIT_MAXRNAMES-1)
as zstring * 7+1 => _
43 {
"dl",
"di",
"si",
"cl",
"bl",
"al",
"bp",
"sp" }, _
44 {
"dx",
"di",
"si",
"cx",
"bx",
"ax",
"bp",
"sp" }, _
45 {
"edx",
"edi",
"esi",
"ecx",
"ebx",
"eax",
"ebp",
"esp" }, _
46 {
"st(0)",
"st(1)",
"st(2)",
"st(3)",
"st(4)",
"st(5)",
"st(6)",
"st(7)" } _
76 ( 3,
"xmmword ptr" ) _
83 @
"st", @
"cs", @
"ds", @
"es", @
"fs", @
"gs", @
"ss", _
84 @
"mm0", @
"mm1", @
"mm2", @
"mm3", @
"mm4", @
"mm5", @
"mm6", @
"mm7", _
85 @
"xmm0", @
"xmm1", @
"xmm2", @
"xmm3", @
"xmm4", @
"xmm5", @
"xmm6", @
"xmm7", _
86 @
"byte", @
"word", @
"dword", @
"qword", _
88 @
"aaa", @
"aad", @
"aam", @
"aas", @
"adc", @
"add", @
"addpd", @
"addps", @
"addsd", @
"addss", @
"and", @
"andpd", @
"andps", _
89 @
"andnpd", @
"andnps", @
"arpl", @
"bound", @
"bsf", @
"bsr", @
"bswap", @
"bt", @
"btc", @
"btr", @
"bts", @
"call", @
"cbw", _
90 @
"cwde", @
"cdq", @
"clc", @
"cld", @
"clflush", @
"cli", @
"clts", @
"cmc", @
"cmova", @
"cmovae", @
"cmovb", @
"cmovbe", _
91 @
"cmovc", @
"cmove", @
"cmovg", @
"cmovge", @
"cmovl", @
"cmovle", @
"cmovna", @
"cmovnae", @
"cmovnb", @
"cmovnbe", _
92 @
"cmovnc", @
"cmovne", @
"cmovng", @
"cmovnge", @
"cmovnl", @
"cmovnle", @
"cmovno", @
"cmovnp", @
"cmovns", @
"cmovnz", _
93 @
"cmovo", @
"cmovp", @
"cmovpe", @
"cmovpe", @
"cmovpo", @
"cmovs", @
"cmovz", @
"cmp", @
"cmppd", @
"cmpps", @
"cmps", _
94 @
"cmpsb", @
"cmpsw", @
"cmpsd", @
"cmpss", @
"cmpxchg", @
"cmpxchg8b", @
"comisd", @
"comiss", @
"cpuid", @
"cvtdq2pd", _
95 @
"cvtdq2ps", @
"cvtpd2dq", @
"cvtpd2pi", @
"cvtpd2ps", @
"cvtpi2pd", @
"cvtpi2ps", @
"cvtps2dq", @
"cvtps2pd", _
96 @
"cvtps2pi", @
"cvtsd2si", @
"cvtsd2ss", @
"cvtsi2sd", @
"cvtsi2ss", @
"cvtss2sd", @
"cvtss2si", @
"cvttpd2pi", _
97 @
"cvttpd2dq", @
"cvttps2dq", @
"cvttps2pi", @
"cvttsd2si", @
"cvttss2si", @
"cwd", @
"daa", @
"das", @
"dec", @
"div", _
98 @
"divpd", @
"divps", @
"divss", @
"emms", @
"enter", @
"f2xm1", @
"fabs", @
"fadd", @
"faddp", @
"fiadd", @
"fbld", _
99 @
"fbstp", @
"fchs", @
"fclex", @
"fnclex", @
"fcmovb", @
"fcmove", @
"fcmovbe", @
"fcmovu", @
"fcmovnb", @
"fcmovne", _
100 @
"fcmovnbe", @
"fcmovnu", @
"fcom", @
"fcomp", @
"fcompp", @
"fcomi", @
"fcomip", @
"fucomi", @
"fucomip", @
"fcos", _
101 @
"fdecstp", @
"fdiv", @
"fdivp", @
"fidiv", @
"fdivr", @
"fdivrp", @
"fidivr", @
"ffree", @
"ficom", @
"ficomp", _
102 @
"fild", @
"fincstp", @
"finit", @
"fninit", @
"fist", @
"fistp", @
"fld", @
"fld1", @
"fldl2t", @
"fldl2e", @
"fldpi", _
103 @
"fldlg2", @
"fldln2", @
"fldz", @
"fldcw", @
"fldenv", @
"fmul", @
"fmulp", @
"fimul", @
"fnop", @
"fpatan", @
"fprem", _
104 @
"fprem1", @
"fptan", @
"frndint", @
"frstor", @
"fsave", @
"fnsave", @
"fscale", @
"fsin", @
"fsincos", @
"fsqrt", _
105 @
"fst", @
"fstp", @
"fstcw", @
"fnstcw", @
"fstenv", @
"fnstenv", @
"fstsw", @
"fnstsw", @
"fsub", @
"fsubp", @
"fisub", _
106 @
"fsubr", @
"fsubrp", @
"fisubr", @
"ftst", @
"fucom", @
"fucomp", @
"fucompp", @
"fwait", @
"fxam", @
"fxch", @
"fxrstor", _
107 @
"fxsave", @
"fxtract", @
"fyl2x", @
"fyl2xp1", @
"hlt", @
"idiv", @
"imul", @
"in", @
"inc", @
"ins", @
"insb", @
"insw", _
108 @
"insd", @
"int", @
"into", @
"invd", @
"invlpg", @
"iret", @
"iretd", @
"ja", @
"jae", @
"jb", @
"jbe", @
"jc", @
"jcxz", _
109 @
"jecxz", @
"je", @
"jg", @
"jge", @
"jl", @
"jle", @
"jna", @
"jnae", @
"jnb", @
"jnbe", @
"jnc", @
"jne", @
"jng", @
"jnge", _
110 @
"jnl", @
"jnle", @
"jno", @
"jnp", @
"jns", @
"jnz", @
"jo", @
"jp", @
"jpe", @
"jpo", @
"js", @
"jz", @
"jmp", @
"lahf", @
"lar", _
111 @
"ldmxcsr", @
"lds", @
"les", @
"lfs", @
"lgs", @
"lss", @
"lea", @
"leave", @
"lfence", @
"lgdt", @
"lidt", @
"lldt", @
"lmsw", _
112 @
"lock", @
"lods", @
"lodsb", @
"lodsw", @
"lodsd", @
"loop", @
"loope", @
"loopz", @
"loopne", @
"loopnz", @
"lsl", @
"ltr", _
113 @
"maskmovdqu", @
"maskmovq", @
"maxpd", @
"maxps", @
"maxsd", @
"maxss", @
"mfence", @
"minpd", @
"minps", @
"minsd", _
114 @
"minss", @
"mov", @
"movapd", @
"movaps", @
"movd", @
"movdqa", @
"movdqu", @
"movdq2q", @
"movhlps", @
"movhpd", _
115 @
"movhps", @
"movlhps", @
"movlpd", @
"movlps", @
"movmskpd", @
"movmskps", @
"movntdq", @
"movnti", @
"movntpd", _
116 @
"movntps", @
"movntq", @
"movq", @
"movq2dq", @
"movs", @
"movsb", @
"movsw", @
"movsd", @
"movss", @
"movsx", @
"movupd", _
117 @
"movups", @
"movzx", @
"mul", @
"mulpd", @
"mulps", @
"mulsd", @
"mulss", @
"neg", @
"nop", @
"not", @
"or", @
"orpd", _
118 @
"orps", @
"out", @
"outs", @
"outsb", @
"outsw", @
"outsd", @
"packsswb", @
"packssdw", @
"packuswb", @
"paddb", _
119 @
"paddw", @
"paddd", @
"paddq", @
"paddsb", @
"paddsw", @
"paddusb", @
"paddusw", @
"pand", @
"pandn", @
"pause", _
120 @
"pavgb", @
"pavgw", @
"pcmpeqb", @
"pcmpeqw", @
"pcmpeqd", @
"pcmpgtb", @
"pcmpgtw", @
"pcmpgtd", @
"pextrw", _
121 @
"pinsrw", @
"pmaddwd", @
"pmaxsw", @
"pmaxub", @
"pminsw", @
"pminub", @
"pmovmskb", @
"pmulhuv", @
"pmulhw", _
122 @
"pmullw", @
"pmuludq", @
"pop", @
"popa", @
"popad", @
"popf", @
"popfd", @
"por", @
"prefetcht0", @
"prefetcht1", _
123 @
"prefetcht2", @
"prefetchnta", @
"psadbw", @
"pshufd", @
"pshufhw", @
"pshuflw", @
"pshufw", @
"psllw", @
"pslld", _
124 @
"psllq", @
"psraw", @
"psrad", @
"psrldq", @
"psrlw", @
"psrld", @
"psrlq", @
"psubb", @
"psubw", @
"psubd", @
"psubq", _
125 @
"psubsb", @
"psubsw", @
"psubusb", @
"psubusw", @
"punpckhbw", @
"punpckhwd", @
"punpckhdq", @
"punpckhqdq", _
126 @
"punpcklbw", @
"punpcklwd", @
"punpckldq", @
"punpcklqdq", @
"push", @
"pusha", @
"pushad", @
"pushf", @
"pushfd", _
127 @
"pxor", @
"rcl", @
"rcr", @
"rol", @
"ror", @
"rcpps", @
"rcpss", @
"rdmsr", @
"rdpmc", @
"rdtsc", @
"rep", @
"repe", _
128 @
"repz", @
"repne", @
"repnz", @
"ret", @
"rsm", @
"rsqrtps", @
"rsqrtss", @
"sahf", @
"sal", @
"sar", @
"shl", @
"shr", _
129 @
"sbb", @
"scas", @
"scasb", @
"scasw", @
"scasd", @
"seta", @
"setae", @
"setb", @
"setbe", @
"setc", @
"sete", @
"setg", _
130 @
"setge", @
"setl", @
"setle", @
"setna", @
"setnae", @
"setnb", @
"setnbe", @
"setnc", @
"setne", @
"setng", @
"setnge", _
131 @
"setnl", @
"setnle", @
"setno", @
"setnp", @
"setns", @
"setnz", @
"seto", @
"setp", @
"setpe", @
"setpo", @
"sets", _
132 @
"setz", @
"sfence", @
"sgdt", @
"sidt", @
"shld", @
"shrd", @
"shufpd", @
"shufps", @
"sldt", @
"smsw", @
"sqrtpd", _
133 @
"sqrtps", @
"sqrtsd", @
"sqrtss", @
"stc", @
"std", @
"sti", @
"stmxcsr", @
"stos", @
"stosb", @
"stosw", @
"stosd", _
134 @
"str", @
"sub", @
"subpd", @
"subps", @
"subsd", @
"subss", @
"sysenter", @
"sysexit", @
"test", @
"ucomisd", _
135 @
"ucomiss", @
"ud2", @
"unpckhpd", @
"unpckhps", @
"unpcklpd", @
"unpcklps", @
"verr", @
"verw", @
"wait", @
"wbinvd", _
136 @
"wrmsr", @
"xadd", @
"xchg", @
"xlat", @
"xlatb", @
"xor", @
"xorpd", @
"xorps", _
137 @
"pavgusb", @
"pfadd", @
"pfsub", @
"pfsubr", @
"pfacc", @
"pfcmpge", @
"pfcmpgt", @
"pfcmpeq", @
"pfmin", @
"pfmax", _
138 @
"pi2fw", @
"pi2fd", @
"pf2iw", @
"pf2id", @
"pfrcp", @
"pfrsqrt", @
"pfmul", @
"pfrcpit1", @
"pfrsqit1", @
"pfrcpit2", _
139 @
"pmulhrw", @
"pswapw", @
"femms", @
"prefetch", @
"prefetchw", @
"pfnacc", @
"pfpnacc", @
"pswapd", @
"pmulhuw", _
158 #define hEmitConstHeader( )
_setSection( IR_SECTION_CONST, 0 )
167 #define hEmitExportHeader( )
_setSection( IR_SECTION_DIRECTIVE, 0 )
178 byval dclass
as integer, _
179 byval reg
as integer _
184 if( dclass = FB_DATACLASS_INTEGER )
then
186 case EMIT_REG_EBX, EMIT_REG_ESI, EMIT_REG_EDI
187 if( EMIT_REGISUSED( FB_DATACLASS_INTEGER, reg ) =
FALSE )
then
193 assert( dclass < EMIT_REGCLASSES )
196 EMIT_REGSETUSED( dclass, reg )
198 function = REG_ISFREE( emit.curnode->regFreeTB(dclass), reg )
209 byval vreg
as IRVREG
ptr, _
210 byval noSIDI
as integer =
FALSE _
213 dim as integer r =
any, reg =
any, reg2 =
any, regs =
any
219 select case vreg->typ
222 case IR_VREGTYPE_IDX, IR_VREGTYPE_PTR
223 if( vreg->vidx <> NULL )
then
224 if( vreg->vidx->typ = IR_VREGTYPE_REG )
then
225 reg = vreg->vidx->reg
232 if( vreg->vaux <> NULL )
then
233 if( vreg->vaux->typ = IR_VREGTYPE_REG )
then
234 reg2 = vreg->vaux->reg
238 regs = emit.regTB(FB_DATACLASS_INTEGER)->getMaxRegs( emit.regTB(FB_DATACLASS_INTEGER) )
240 if( reg2 = INVALID )
then
241 if( noSIDI =
FALSE )
then
242 for r
as integer = regs-1
to 0 step -1
245 if(
hIsRegFree( FB_DATACLASS_INTEGER, r ) )
then
252 for r
as integer = regs-1
to 0 step -1
254 if( r <> EMIT_REG_ESI )
then
255 if( r <> EMIT_REG_EDI )
then
257 if(
hIsRegFree( FB_DATACLASS_INTEGER, r ) )
then
267 if( noSIDI =
FALSE )
then
268 for r
as integer = regs-1
to 0 step -1
269 if( (r <> reg)
and (r <> reg2) )
then
271 if(
hIsRegFree( FB_DATACLASS_INTEGER, r ) )
then
278 for r = regs-1
to 0 step -1
279 if( (r <> reg)
and (r <> reg2) )
then
280 if( r <> EMIT_REG_ESI )
then
281 if( r <> EMIT_REG_EDI )
then
283 if(
hIsRegFree( FB_DATACLASS_INTEGER, r ) )
then
299 for r
as integer = emit.regTB(dclass)->getMaxRegs( emit.regTB(dclass) )-1
to 0 step -1
309 byval vreg
as IRVREG
ptr, _
310 byval reg
as integer _
315 select case vreg->typ
317 if( vreg->reg = reg )
then
321 case IR_VREGTYPE_IDX, IR_VREGTYPE_PTR
322 if( vreg->vidx <> NULL )
then
323 if( vreg->vidx->typ = IR_VREGTYPE_REG )
then
324 if( vreg->vidx->reg = reg )
then
332 if( vreg->vaux <> NULL )
then
333 if( vreg->vaux->typ = IR_VREGTYPE_REG )
then
334 if( vreg->vaux->reg = reg )
then
345 byval dtype
as integer, _
346 byval reg
as integer _
349 if( reg = INVALID )
then
352 dim as integer tb =
dtypeTB(typeGet( dtype )).rnametb
362 byval vreg
as IRVREG
ptr _
363 )
as zstring ptr static
365 static as zstring * FB_MAXINTNAMELEN+1+8+1+1+1+8+1 iname
366 dim as FBSYMBOL
ptr sym
368 dim as integer addone, mult
369 dim as zstring ptr rname
374 if( sym = NULL )
then
384 if( vi <> NULL )
then
393 if( vi <> NULL )
then
424 assert( (mult >= 1)
and (mult <= 9) )
425 assert( (mult <> 6)
and (mult <> 7) )
439 assert( vreg->ofs = 0 )
453 byval vreg
as IRVREG
ptr, _
454 byref operand
as string, _
456 byval ofs
as integer = 0, _
457 byval isaux
as integer =
FALSE, _
458 byval addprefix
as integer =
TRUE _
461 if( vreg = NULL )
then
470 select case as const vreg->typ
471 case IR_VREGTYPE_VAR, IR_VREGTYPE_IDX, IR_VREGTYPE_PTR
484 dim as zstring ptr idx_op
485 if( vreg->typ = IR_VREGTYPE_VAR )
then
491 if( idx_op <> NULL )
then
502 if( idx_op <> NULL )
then
505 operand +=
str( ofs )
507 elseif( ofs < 0 )
then
508 operand +=
str( ofs )
511 if( idx_op = NULL )
then
521 if( vreg->ofs <> 0 )
then
523 operand +=
str( vreg->ofs )
527 if( isaux =
FALSE )
then
534 if( isaux =
FALSE )
then
535 operand =
str( vreg->value.i )
537 operand =
str( vreg->vaux->value.i )
549 byval vreg
as IRVREG
ptr, _
550 byref operand1
as string, _
551 byref operand2
as string _
562 byval s
as zstring ptr, _
563 byval bytes
as integer = 0 _
570 if(
put( #env.outf.num, , *s, bytes ) = 0 )
then
578 byval s
as zstring ptr _
581 static as string ostr
583 if( env.clopt.debug )
then
592 outEX( ostr,
len( ostr ) )
599 byval mnemonic
as zstring ptr, _
600 byval label
as zstring ptr _
615 byval rname
as zstring ptr _
629 byval rname
as zstring ptr _
643 byval dname
as zstring ptr, _
644 byval sname
as zstring ptr _
660 byval dname
as zstring ptr, _
661 byval sname
as zstring ptr _
677 byval s
as zstring ptr _
692 byval label
as zstring ptr, _
693 byval isexport
as integer _
698 ostr = NEWLINE +
".globl "
721 byval label
as zstring ptr _
727 ostr +=
":" + NEWLINE
735 byval bytes
as integer _
740 ostr =
".balign " +
str( bytes ) + NEWLINE
747 dim as integer lastclass, regs, i
752 static as REG_SIZEMASK int_bitsmask(0
to int_regs-1) = _
754 REG_SIZEMASK_8
or REG_SIZEMASK_16
or REG_SIZEMASK_32, _
755 REG_SIZEMASK_16
or REG_SIZEMASK_32, _
756 REG_SIZEMASK_16
or REG_SIZEMASK_32, _
757 REG_SIZEMASK_8
or REG_SIZEMASK_16
or REG_SIZEMASK_32, _
758 REG_SIZEMASK_8
or REG_SIZEMASK_16
or REG_SIZEMASK_32, _
759 REG_SIZEMASK_8
or REG_SIZEMASK_16
or REG_SIZEMASK_32 _
762 emit.regTB(FB_DATACLASS_INTEGER) = _
771 static as REG_SIZEMASK flt_bitsmask(0
to flt_regs-1) = _
773 REG_SIZEMASK_32
or REG_SIZEMASK_64, _
774 REG_SIZEMASK_32
or REG_SIZEMASK_64, _
775 REG_SIZEMASK_32
or REG_SIZEMASK_64, _
776 REG_SIZEMASK_32
or REG_SIZEMASK_64, _
777 REG_SIZEMASK_32
or REG_SIZEMASK_64, _
778 REG_SIZEMASK_32
or REG_SIZEMASK_64, _
779 REG_SIZEMASK_32
or REG_SIZEMASK_64 _
783 if( env.clopt.fputype = FB_FPUTYPE_SSE )
then
784 emit.regTB(FB_DATACLASS_FPOINT) = _
791 for i = 0
to EMIT_MAXRNAMES - 1
792 rnameTB(EMIT_MAXRTABLES-1, i) =
"xmm" +
Str(i)
795 emit.regTB(FB_DATACLASS_FPOINT) = _
808 for i = 0
to EMIT_REGCLASSES-1
821 for t = 0
to EMIT_MAXRTABLES-1
822 for i = 0
to EMIT_MAXRNAMES-1
823 if(
len(
rnameTB(t,i) ) > 0 )
then
824 hashAdd( @emit.keyhash, @
rnameTB(t,i),
cast(
any ptr, INVALID ), INVALID )
838 emit.keyinited =
TRUE
845 if( emit.keyinited )
then
849 emit.keyinited =
FALSE
856 byval s
as FBSYMBOL
ptr _
859 dim as string alloc, ostr
860 dim as integer attrib, elements
862 attrib = symbGetAttrib( s )
865 if( symbGetArrayDimensions( s ) > 0 )
then
866 elements = symbGetArrayElements( s )
872 if( (attrib
and FB_SYMBATTRIB_COMMON) = 0 )
then
873 if( (attrib
and FB_SYMBATTRIB_PUBLIC) > 0 )
then
883 if( symbGetType( s ) = FB_DATATYPE_DOUBLE )
then
891 ostr = alloc + TABCHAR
893 ostr +=
"," +
str( symbGetLen( s ) * elements )
897 if( (attrib
and (FB_SYMBATTRIB_SHARED
or _
898 FB_SYMBATTRIB_COMMON
or _
899 FB_SYMBATTRIB_PUBLIC)) > 0 )
then
914 hCOMMENT( env.inf.
name +
"' compilation started at " +
time +
" (" + FB_SIGN +
")" )
920 select case( symbGetClass( s ) )
922 case FB_SYMBCLASS_NAMESPACE
926 case FB_SYMBCLASS_STRUCT
928 if( symbGetIsUnique( s ) )
then
933 case FB_SYMBCLASS_SCOPE
937 case FB_SYMBCLASS_VAR
949 byval s
as FBSYMBOL
ptr _
952 dim as string stext, stype, ostr
955 dtype = symbGetType( s )
957 select case as const dtype
958 case FB_DATATYPE_CHAR
960 stext += *
hEscape( symbGetVarLitText( s ) )
961 stext += RSLASH +
"0" + QUOTE
963 case FB_DATATYPE_WCHAR
965 stext += *
hEscapeW( symbGetVarLitTextW( s ) )
966 for i
as integer = 1
to typeGetSize( FB_DATATYPE_WCHAR )
967 stext += RSLASH +
"0"
972 stext = *symbGetVarLitText( s )
978 if( s->var_.align )
then
981 if( dtype = FB_DATATYPE_DOUBLE )
then
991 ostr += (
":" + TABCHAR) + stype + TABCHAR + stext
998 select case( symbGetClass( s ) )
1000 case FB_SYMBCLASS_NAMESPACE
1004 case FB_SYMBCLASS_STRUCT
1006 if( symbGetIsUnique( s ) )
then
1011 case FB_SYMBCLASS_SCOPE
1015 case FB_SYMBCLASS_VAR
1025 select case( symbGetClass( s ) )
1027 case FB_SYMBCLASS_NAMESPACE
1031 case FB_SYMBCLASS_STRUCT
1033 if( symbGetIsUnique( s ) )
then
1038 case FB_SYMBCLASS_SCOPE
1042 case FB_SYMBCLASS_VAR
1054 byval proc_head
as FB_GLOBCTORLIST_ITEM
ptr, _
1055 byval is_ctor
as integer _
1058 if( proc_head = NULL )
then
1064 if( symbGetProcIsEmitted( proc_head->sym ) )
then
1066 IR_SECTION_CONSTRUCTOR, _
1067 IR_SECTION_DESTRUCTOR ), _
1068 symbGetProcPriority( proc_head->sym ) )
1072 proc_head = proc_head->
next
1073 loop while( proc_head <> NULL )
1078 if( symbIsExport( s ) )
then
1079 hEmitExportHeader( )
1082 if( env.target.options
and FB_TARGETOPT_UNDERSCORE )
then
1087 *sname + (QUOTE + NEWLINE), _
1097 select case symbGetClass( s )
1099 case FB_SYMBCLASS_NAMESPACE
1102 case FB_SYMBCLASS_STRUCT
1104 dim as FBSYMBOL
ptr walk = symbGetUDTSymbTbHead( s )
1107 walk = symbGetNext( walk )
1110 case FB_SYMBCLASS_PROC
1111 if( symbGetIsDeclared( s ) )
then
1124 byval s
as FBSYMBOL
ptr _
1128 if( symbGetVarIsAllocated( s ) )
then
1132 symbSetVarIsAllocated( s )
1135 if( symbGetIsLiteral( s ) )
then
1137 select case symbGetType( s )
1139 case FB_DATATYPE_STRUCT
1143 case FB_DATATYPE_CHAR, FB_DATATYPE_WCHAR
1144 if( symbGetIsAccessed( s ) =
FALSE )
then
1150 if( symbGetLen( s ) <= 0 )
then
1161 if( symbGetIsInitialized( s ) )
then
1164 if( symbIsExtern( s ) )
then
1166 elseif( symbGetIsJumpTb( s ) )
then
1171 if( symbGetIsAccessed( s ) =
FALSE )
then
1173 if( symbIsPublic( s ) =
FALSE )
then
1181 AST_INIOPT_ISINI
or AST_INIOPT_ISSTATIC )
1187 if( (s->attrib
and (FB_SYMBATTRIB_EXTERN
or _
1188 FB_SYMBATTRIB_DYNAMIC)) <> 0 )
then
1193 if( symbGetLen( s ) <= 0 )
then
1204 byval bytestoclear
as integer, _
1205 byval baseoffset
as integer _
1211 if( bytestoclear = 0 )
then
1215 if( env.clopt.cputype >= FB_CPUTYPE_686 )
then
1216 if( cunsg(bytestoclear) \ 8 > 7 )
then
1218 if( EMIT_REGISUSED( FB_DATACLASS_INTEGER, EMIT_REG_EDI ) =
FALSE )
then
1222 outp(
"lea edi, [ebp-" & baseoffset + bytestoclear &
"]" )
1223 outp(
"mov ecx," & cunsg(bytestoclear) \ 8 )
1224 outp(
"pxor mm0, mm0" )
1227 outp(
"movq [edi], mm0" )
1228 outp(
"add edi, 8" )
1230 outp(
"jnz " + lname )
1233 if( EMIT_REGISUSED( FB_DATACLASS_INTEGER, EMIT_REG_EDI ) =
FALSE )
then
1237 elseif( cunsg(bytestoclear) \ 8 > 0 )
then
1238 outp(
"pxor mm0, mm0" )
1239 for i = cunsg(bytestoclear) \ 8
to 1 step -1
1240 outp(
"movq [ebp-" & ( i*8 ) &
"], mm0" )
1246 if( bytestoclear
and 4 )
then
1247 outp(
"mov dword ptr [ebp-" & baseoffset + bytestoclear &
"], 0" )
1253 if( cunsg(bytestoclear) \ 4 > 6 )
then
1255 if( EMIT_REGISUSED( FB_DATACLASS_INTEGER, EMIT_REG_EDI ) =
FALSE )
then
1259 outp(
"lea edi, [ebp-" & baseoffset + bytestoclear &
"]" )
1260 outp(
"mov ecx," & cunsg(bytestoclear) \ 4 )
1261 outp(
"xor eax, eax" )
1264 if( EMIT_REGISUSED( FB_DATACLASS_INTEGER, EMIT_REG_EDI ) =
FALSE )
then
1269 for i = cunsg(bytestoclear) \ 4
to 1 step -1
1270 outp(
"mov dword ptr [ebp-" & baseoffset + ( i*4 ) &
"], 0" )
1279 byval proc as FBSYMBOL
ptr _
1282 dim as integer bytestoalloc, bytestoclear
1283 dim as zstring ptr lprof
1288 bytestoalloc = ((
proc->
proc.ext->stk.localmax - EMIT_LOCSTART) + 3)
and (
not 3)
1290 if( (bytestoalloc <> 0)
or _
1291 (
proc->
proc.ext->stk.argofs <> EMIT_ARGSTART)
or _
1292 symbGetIsMainProc(
proc )
or _
1293 env.clopt.debug
or _
1294 env.clopt.profile )
then
1297 outp(
"mov ebp, esp" )
1299 if( symbGetIsMainProc(
proc ) )
then
1300 outp(
"and esp, 0xFFFFFFF0" )
1303 if( bytestoalloc > 0 )
then
1304 outp(
"sub esp, " +
str( bytestoalloc ) )
1308 if( env.clopt.target = FB_COMPTARGET_DOS )
then
1309 if( env.clopt.profile )
then
1312 outEx(
".section .data" + NEWLINE )
1313 outEx(
".balign 4" + NEWLINE )
1314 outEx(
"." + *lprof +
":" + NEWLINE )
1316 outEx(
".section .text" + NEWLINE )
1317 outp(
"mov edx, offset ." + *lprof )
1318 outp(
"call _mcount" )
1322 if( EMIT_REGISUSED( FB_DATACLASS_INTEGER, EMIT_REG_EBX ) )
then
1325 if( EMIT_REGISUSED( FB_DATACLASS_INTEGER, EMIT_REG_ESI ) )
then
1328 if( EMIT_REGISUSED( FB_DATACLASS_INTEGER, EMIT_REG_EDI ) )
then
1336 bytestoclear = ((
proc->
proc.ext->stk.localofs - EMIT_LOCSTART) + 3)
and (
not 3)
1346 byval proc as FBSYMBOL
ptr, _
1347 byval bytestopop
as integer _
1353 dim as integer bytestoalloc
1355 bytestoalloc = ((
proc->
proc.ext->stk.localmax - EMIT_LOCSTART) + 3)
and (
not 3)
1357 if( EMIT_REGISUSED( FB_DATACLASS_INTEGER, EMIT_REG_EDI ) )
then
1360 if( EMIT_REGISUSED( FB_DATACLASS_INTEGER, EMIT_REG_ESI ) )
then
1363 if( EMIT_REGISUSED( FB_DATACLASS_INTEGER, EMIT_REG_EBX ) )
then
1367 if( (bytestoalloc <> 0)
or _
1368 (
proc->
proc.ext->stk.argofs <> EMIT_ARGSTART)
or _
1369 symbGetIsMainProc(
proc )
or _
1370 env.clopt.debug
or _
1371 env.clopt.profile )
then
1372 outp(
"mov esp, ebp" )
1376 if( bytestopop > 0 )
then
1377 outp(
"ret " +
str( bytestopop ) )
1384 if( env.clopt.target = FB_COMPTARGET_LINUX )
then
1402 byval tbsym
as FBSYMBOL
ptr, _
1403 byval values1
as ulongint ptr, _
1404 byval labels1
as FBSYMBOL
ptr ptr, _
1405 byval labelcount
as integer, _
1406 byval deflabel
as FBSYMBOL
ptr, _
1407 byval minval
as ulongint, _
1408 byval maxval
as ulongint _
1411 dim as FBSYMBOL
ptr label =
any
1412 dim as string deflabelname, tb
1413 dim as integer i =
any
1417 assert( labelcount > 0 )
1434 outEx( tb +
":" + NEWLINE )
1436 for value
as ulongint = minval
to maxval
1437 assert( i < labelcount )
1438 if( value = values1[i] )
then
1452 byval unused
as IRVREG
ptr, _
1453 byval label
as FBSYMBOL
ptr, _
1454 byval bytestopop
as integer _
1463 if( bytestopop <> 0 )
then
1464 ostr =
"add esp, " +
str( bytestopop )
1473 byval svreg
as IRVREG
ptr, _
1474 byval unused
as FBSYMBOL
ptr, _
1475 byval bytestopop
as integer _
1483 ostr =
"call " + src
1486 if( bytestopop <> 0 )
then
1487 ostr =
"add esp, " +
str( bytestopop )
1496 byval unused
as IRVREG
ptr, _
1497 byval label
as FBSYMBOL
ptr, _
1498 byval op as integer _
1503 select case as const op
1526 byval unused1
as IRVREG
ptr, _
1527 byval label
as FBSYMBOL
ptr, _
1528 byval unused2
as integer _
1542 byval svreg
as IRVREG
ptr, _
1543 byval unused1
as FBSYMBOL
ptr, _
1544 byval unused2
as integer _
1560 byval vreg
as IRVREG
ptr _
1565 ostr =
"ret " +
str( vreg->value.i )
1573 byval label
as FBSYMBOL
ptr _
1578 ostr = NEWLINE +
".globl "
1588 byval label
as FBSYMBOL
ptr _
1594 ostr +=
":" + NEWLINE
1614 byval svreg
as IRVREG
ptr _
1617 dim as string label, aux, ostr
1622 ostr =
"cmp " + aux +
", 0"
1625 ostr =
"jns " + label
1628 hPUSH(
"0x80000000" )
1640 byval dvreg
as IRVREG
ptr, _
1641 byval svreg
as IRVREG
ptr _
1644 dim as string dst1, dst2, src1, src2, ostr
1649 ostr =
"mov " + dst1 + COMMA + src1
1652 ostr =
"mov " + dst2 + COMMA + src2
1660 byval dvreg
as IRVREG
ptr, _
1661 byval svreg
as IRVREG
ptr _
1664 dim as string dst1, dst2, src1, ext, ostr
1665 dim sdsize
as integer
1667 sdsize = typeGetSize( svreg->dtype )
1674 if( svreg->typ = IR_VREGTYPE_IMM )
then
1678 if( typeIsSigned( svreg->dtype )
and (svreg->value.i < 0) )
then
1688 if( sdsize < 4 )
then
1689 ext = *
hGetRegName( FB_DATATYPE_INTEGER, svreg->reg )
1691 if( typeIsSigned( svreg->dtype ) )
then
1696 ostr += ext + COMMA + src1
1703 ostr =
"mov " + dst1 + COMMA + ext
1706 if( typeIsSigned( svreg->dtype ) )
then
1710 ostr =
"sar " + ext +
", 31"
1713 ostr =
"mov " + dst2 + COMMA + ext
1719 ostr =
"mov " + dst2 +
", 0"
1729 byval dvreg
as IRVREG
ptr, _
1730 byval svreg
as IRVREG
ptr _
1739 if( typeIsSigned( dvreg->dtype ) )
then
1740 ostr =
"fistp " + dst
1751 byval dvreg
as IRVREG
ptr, _
1752 byval svreg
as IRVREG
ptr _
1755 dim as string dst, src
1756 dim as integer ddsize, sdsize
1762 ddsize = typeGetSize( dvreg->dtype )
1763 sdsize = typeGetSize( svreg->dtype )
1765 if( ddsize = 1 )
then
1766 if( svreg->typ = IR_VREGTYPE_IMM )
then
1772 if( (svreg->typ = IR_VREGTYPE_IMM)
or (ddsize = sdsize) )
then
1773 ostr =
"mov " + dst + COMMA + src
1782 if( ddsize > sdsize )
then
1783 if( typeIsSigned( svreg->dtype ) )
then
1788 ostr += aux + COMMA + src
1791 ostr =
"mov " + dst + COMMA + aux
1797 dim as integer is_disi
1800 if( ddsize = 1 )
then
1801 if( svreg->typ = IR_VREGTYPE_REG )
then
1802 is_disi = (svreg->reg = EMIT_REG_ESI)
or (svreg->reg = EMIT_REG_EDI)
1808 dim as integer reg, isfree
1815 isfree =
hIsRegFree(FB_DATACLASS_INTEGER, reg )
1816 if( isfree =
FALSE )
then
1820 ostr =
"mov " + aux + COMMA + src
1823 ostr =
"mov " + dst + COMMA + aux8
1826 if( isfree =
FALSE )
then
1831 ostr =
"mov " + dst + COMMA + aux
1842 byval dvreg
as IRVREG
ptr, _
1843 byval svreg
as IRVREG
ptr _
1855 byval dvreg
as IRVREG
ptr, _
1856 byval svreg
as IRVREG
ptr _
1859 dim as string dst, src
1860 dim as integer ddsize
1866 ddsize = typeGetSize( dvreg->dtype )
1869 if( ddsize = 1 )
then
1872 outp "fistp dword ptr [esp]"
1875 if( dvreg->typ = IR_VREGTYPE_REG )
then
1877 hMOV dst,
"byte ptr [esp]"
1882 dim as integer reg, isfree
1883 dim as string aux, aux8
1890 isfree =
hIsRegFree( FB_DATACLASS_INTEGER, reg )
1892 if( isfree =
FALSE )
then
1893 hXCHG aux,
"dword ptr [esp]"
1895 hMOV aux8,
"byte ptr [esp]"
1900 if( isfree =
FALSE )
then
1910 if( typeIsSigned( dvreg->dtype ) )
then
1911 ostr =
"fistp " + dst
1917 if( ddsize = 4 )
then
1919 outp "fistp qword ptr [esp]"
1926 outp "fistp dword ptr [esp]"
1941 byval dvreg
as IRVREG
ptr, _
1942 byval svreg
as IRVREG
ptr _
1945 dim as string dst, src, aux
1951 if( (svreg->typ = IR_VREGTYPE_REG)
or (svreg->typ = IR_VREGTYPE_IMM) )
then
1954 if( typeIsSigned( svreg->dtype ) )
then
1961 ostr =
"fild " +
dtypeTB(svreg->dtype).mname +
" [esp]"
1971 outp "fild qword ptr [esp]"
1980 if( typeIsSigned( svreg->dtype ) )
then
1981 ostr =
"fild " + src
1986 ostr =
"fild " + src
1993 ostr =
"fstp " + dst
2003 byval dvreg
as IRVREG
ptr, _
2004 byval svreg
as IRVREG
ptr _
2007 dim as string dst, src
2008 dim as integer sdsize
2014 sdsize = typeGetSize( svreg->dtype )
2017 if( sdsize = 1 )
then
2019 dim as integer reg, isfree
2025 isfree =
hIsRegFree( FB_DATACLASS_INTEGER, reg )
2027 if( isfree =
FALSE )
then
2031 if( typeIsSigned( svreg->dtype ) )
then
2036 ostr += aux + COMMA + src
2040 outp "fild dword ptr [esp]"
2043 if( isfree =
FALSE )
then
2047 ostr =
"fstp " + dst
2054 if( (svreg->typ = IR_VREGTYPE_REG)
or (svreg->typ = IR_VREGTYPE_IMM) )
then
2057 if( typeIsSigned( svreg->dtype ) )
then
2060 if( (svreg->typ = IR_VREGTYPE_REG)
and (sdsize < 4) )
then
2061 src = *
hGetRegName( FB_DATATYPE_INTEGER, svreg->reg )
2066 ostr =
"fild " +
dtypeTB(svreg->dtype).mname +
" [esp]"
2075 if( sdsize = 4 )
then
2078 outp "fild qword ptr [esp]"
2083 if( svreg->typ <> IR_VREGTYPE_IMM )
then
2088 outp "fild dword ptr [esp]"
2090 if( svreg->typ <> IR_VREGTYPE_IMM )
then
2103 if( typeIsSigned( svreg->dtype ) )
then
2104 ostr =
"fild " + src
2110 if( sdsize = 4 )
then
2113 outp "fild qword ptr [esp]"
2120 outp "fild dword ptr [esp]"
2127 ostr =
"fstp " + dst
2137 byval dvreg
as IRVREG
ptr, _
2138 byval svreg
as IRVREG
ptr _
2141 dim as string dst, src
2142 dim as integer ddsize, sdsize
2148 ddsize = typeGetSize( dvreg->dtype )
2149 sdsize = typeGetSize( svreg->dtype )
2152 if( svreg->typ = IR_VREGTYPE_REG )
then
2153 ostr =
"fstp " + dst
2158 if( sdsize = ddsize )
then
2161 ostr =
"push " + src
2164 if( sdsize > 4 )
then
2166 ostr =
"push " + src
2183 ostr =
"fstp " + dst
2197 byval dvreg
as IRVREG
ptr, _
2198 byval svreg
as IRVREG
ptr _
2201 dim as string dst1, dst2, src1, src2
2207 ostr =
"mov " + dst1 + COMMA + src1
2210 ostr =
"mov " + dst2 + COMMA + src2
2218 byval dvreg
as IRVREG
ptr, _
2219 byval svreg
as IRVREG
ptr _
2222 dim as string dst1, dst2, src1
2223 dim as integer sdsize
2226 sdsize = typeGetSize( svreg->dtype )
2233 if( svreg->typ = IR_VREGTYPE_IMM )
then
2237 if( typeIsSigned( svreg->dtype )
and (svreg->value.i < 0) )
then
2247 if( typeIsSigned( svreg->dtype ) )
then
2249 if( sdsize < 4 )
then
2250 ostr =
"movsx " + dst1 + COMMA + src1
2258 ostr =
"sar " + dst2 +
", 31"
2263 if( sdsize < 4 )
then
2264 ostr =
"movzx " + dst1 + COMMA + src1
2281 byval dvreg
as IRVREG
ptr, _
2282 byval svreg
as IRVREG
ptr _
2285 dim as string dst, src, aux
2291 if( svreg->typ <> IR_VREGTYPE_REG )
then
2299 if( typeIsSigned( dvreg->dtype ) )
then
2303 ostr =
"fistp " +
dtypeTB(dvreg->dtype).mname +
" [esp]"
2311 dim as string label_geq, label_done
2312 dim as integer iseaxfree =
any
2318 iseaxfree =
hIsRegFree( FB_DATACLASS_INTEGER, EMIT_REG_EAX )
2322 outp "mov dword ptr [esp], 0x5F000000"
2323 outp "fcom dword ptr [esp]"
2325 if( iseaxfree )
then
2338 outp "fistp qword ptr [esp]"
2346 outp "fsub dword ptr [esp]"
2347 outp "fistp qword ptr [esp]"
2350 outp "xor " + aux +
", 0x80000000"
2362 byval dvreg
as IRVREG
ptr, _
2363 byval svreg
as IRVREG
ptr _
2366 dim as string dst, src
2367 dim as integer ddsize, sdsize
2373 ddsize = typeGetSize( dvreg->dtype )
2374 sdsize = typeGetSize( svreg->dtype )
2376 if( ddsize = 1 )
then
2377 if( svreg->typ = IR_VREGTYPE_IMM )
then
2383 if( ddsize = sdsize )
then
2384 ostr =
"mov " + dst + COMMA + src
2388 if( ddsize > sdsize )
then
2389 if( typeIsSigned( svreg->dtype ) )
then
2394 ostr += dst + COMMA + src
2400 if( svreg->typ = IR_VREGTYPE_REG )
then
2402 if( svreg->reg <> dvreg->reg )
then
2404 dim as integer dtype
2406 dtype = dvreg->dtype
2409 if( ddsize = 1 )
then
2410 if( (svreg->reg = EMIT_REG_ESI)
or _
2411 (svreg->reg = EMIT_REG_EDI) )
then
2413 dtype = FB_DATATYPE_INTEGER
2419 ostr =
"mov " + dst + COMMA + aux
2427 ostr =
"mov " + dst + COMMA + src
2438 byval dvreg
as IRVREG
ptr, _
2439 byval svreg
as IRVREG
ptr _
2451 byval dvreg
as IRVREG
ptr, _
2452 byval svreg
as IRVREG
ptr _
2455 dim as string dst, src
2456 dim as integer ddsize
2462 ddsize = typeGetSize( dvreg->dtype )
2464 if( svreg->typ <> IR_VREGTYPE_REG )
then
2470 if( ddsize = 1 )
then
2473 outp "fistp dword ptr [esp]"
2476 if( dvreg->typ = IR_VREGTYPE_REG )
then
2477 hMOV dst,
"byte ptr [esp]"
2482 dim as string aux, aux8
2483 dim as integer reg, isfree
2490 isfree =
hIsRegFree( FB_DATACLASS_INTEGER, reg )
2492 if( isfree =
FALSE )
then
2493 hXCHG aux,
"dword ptr [esp]"
2495 hMOV aux8,
"byte ptr [esp]"
2500 if( isfree =
FALSE )
then
2511 if( typeIsSigned( dvreg->dtype ) )
then
2515 ostr =
"fistp " +
dtypeTB(dvreg->dtype).mname +
" [esp]"
2519 if( ddsize < 4 )
then
2520 dst = *
hGetRegName( FB_DATATYPE_INTEGER, dvreg->reg )
2529 if( ddsize = 4 )
then
2531 outp "fistp qword ptr [esp]"
2538 outp "fistp dword ptr [esp]"
2553 byval dvreg
as IRVREG
ptr, _
2554 byval svreg
as IRVREG
ptr _
2557 dim as string dst, src, aux
2563 if( (svreg->typ = IR_VREGTYPE_REG)
or (svreg->typ = IR_VREGTYPE_IMM) )
then
2566 if( typeIsSigned( svreg->dtype ) )
then
2573 ostr =
"fild " +
dtypeTB(svreg->dtype).mname +
" [esp]"
2584 outp "fild qword ptr [esp]"
2594 if( typeIsSigned( svreg->dtype ) )
then
2595 ostr =
"fild " + src
2600 ostr =
"fild " + src
2615 byval dvreg
as IRVREG
ptr, _
2616 byval svreg
as IRVREG
ptr _
2619 dim as string dst, src
2620 dim as integer sdsize
2626 sdsize = typeGetSize( svreg->dtype )
2629 if( sdsize = 1 )
then
2631 dim as integer isfree, reg
2637 isfree =
hIsRegFree( FB_DATACLASS_INTEGER, reg )
2639 if( isfree =
FALSE )
then
2643 if( typeIsSigned( svreg->dtype ) )
then
2644 ostr =
"movsx " + aux + COMMA + src
2647 ostr =
"movzx " + aux + COMMA + src
2652 outp "fild dword ptr [esp]"
2655 if( isfree =
FALSE )
then
2663 if( (svreg->typ = IR_VREGTYPE_REG)
or (svreg->typ = IR_VREGTYPE_IMM) )
then
2666 if( typeIsSigned( svreg->dtype ) )
then
2669 if( (svreg->typ = IR_VREGTYPE_REG)
and (sdsize < 4) )
then
2670 src = *
hGetRegName( FB_DATATYPE_INTEGER, svreg->reg )
2675 ostr =
"fild " +
dtypeTB(svreg->dtype).mname +
" [esp]"
2684 if( sdsize = 4 )
then
2687 outp "fild qword ptr [esp]"
2692 if( svreg->typ <> IR_VREGTYPE_IMM )
then
2697 outp "fild dword ptr [esp]"
2699 if( svreg->typ <> IR_VREGTYPE_IMM )
then
2712 if( typeIsSigned( svreg->dtype ) )
then
2713 ostr =
"fild " + src
2719 if( sdsize = 4 )
then
2722 outp "fild qword ptr [esp]"
2729 outp "fild dword ptr [esp]"
2743 byval dvreg
as IRVREG
ptr, _
2744 byval svreg
as IRVREG
ptr _
2764 byval dvreg
as IRVREG
ptr, _
2765 byval svreg
as IRVREG
ptr _
2768 dim as string dst1, dst2, src1, src2, ostr
2773 ostr =
"mov " + dst1 + COMMA + src1
2776 ostr =
"mov " + dst2 + COMMA + src2
2784 byval dvreg
as IRVREG
ptr, _
2785 byval svreg
as IRVREG
ptr _
2788 dim as string dst, src, ostr
2791 if( typeGetSize( dvreg->dtype ) = 1 )
then
2793 dst = *
hGetRegName( FB_DATATYPE_INTEGER, dvreg->reg )
2794 src = *
hGetRegName( FB_DATATYPE_INTEGER, svreg->reg )
2800 ostr =
"mov " + dst + COMMA + src
2809 byval dvreg
as IRVREG
ptr, _
2810 byval svreg
as IRVREG
ptr _
2820 byval dvreg
as IRVREG
ptr, _
2821 byval svreg
as IRVREG
ptr _
2824 dim dst1
as string, dst2
as string, src1
as string, src2
as string
2830 ostr =
"add " + dst1 + COMMA + src1
2833 ostr =
"adc " + dst2 + COMMA + src2
2841 byval dvreg
as IRVREG
ptr, _
2842 byval svreg
as IRVREG
ptr _
2845 dim dst
as string, src
as string
2846 dim doinc
as integer, dodec
as integer
2854 if( svreg->typ = IR_VREGTYPE_IMM )
then
2855 select case svreg->value.i
2866 elseif( dodec )
then
2870 ostr =
"add " + dst + COMMA + src
2881 byval dvreg
as IRVREG
ptr, _
2882 byval svreg
as IRVREG
ptr _
2890 if( svreg->typ = IR_VREGTYPE_REG )
then
2894 if( typeGetClass( svreg->dtype ) = FB_DATACLASS_FPOINT )
then
2895 ostr =
"fadd " + src
2899 assert( (typeGetSize( svreg->dtype ) = 2)
or (typeGetSize( svreg->dtype ) = 4) )
2900 ostr =
"fiadd " + src
2910 byval dvreg
as IRVREG
ptr, _
2911 byval svreg
as IRVREG
ptr _
2914 dim dst1
as string, dst2
as string, src1
as string, src2
as string
2920 ostr =
"sub " + dst1 + COMMA + src1
2923 ostr =
"sbb " + dst2 + COMMA + src2
2931 byval dvreg
as IRVREG
ptr, _
2932 byval svreg
as IRVREG
ptr _
2935 dim dst
as string, src
as string
2936 dim doinc
as integer, dodec
as integer
2944 if( svreg->typ = IR_VREGTYPE_IMM )
then
2945 select case svreg->value.i
2956 elseif( doinc )
then
2960 ostr =
"sub " + dst + COMMA + src
2971 byval dvreg
as IRVREG
ptr, _
2972 byval svreg
as IRVREG
ptr _
2976 dim doinc
as integer, dodec
as integer
2981 if( svreg->typ = IR_VREGTYPE_REG )
then
2984 if( typeGetClass( svreg->dtype ) = FB_DATACLASS_FPOINT )
then
2985 ostr =
"fsub " + src
2989 assert( (typeGetSize( svreg->dtype ) = 2)
or (typeGetSize( svreg->dtype ) = 4) )
2990 ostr =
"fisub " + src
3000 byval dvreg
as IRVREG
ptr, _
3001 byval svreg
as IRVREG
ptr _
3004 dim dst1
as string, dst2
as string, src1
as string, src2
as string
3005 dim iseaxfree
as integer, isedxfree
as integer
3006 dim eaxindest
as integer, edxindest
as integer
3012 iseaxfree =
hIsRegFree( FB_DATACLASS_INTEGER, EMIT_REG_EAX )
3013 isedxfree =
hIsRegFree( FB_DATACLASS_INTEGER, EMIT_REG_EDX )
3025 if( edxindest )
then
3026 if( dvreg->typ <> IR_VREGTYPE_REG )
then
3031 if( isedxfree =
FALSE )
then
3037 if( eaxindest )
then
3038 if( dvreg->typ <> IR_VREGTYPE_REG )
then
3043 if( iseaxfree =
FALSE )
then
3050 outp "mov eax, [esp+" +
str( 0+ofs ) +
"]"
3051 outp "mul dword ptr [esp+" +
str( 8+ofs ) +
"]"
3054 outp "xchg eax, [esp+" +
str ( 0+ofs ) +
"]"
3056 outp "imul eax, [esp+" +
str ( 12+ofs ) +
"]"
3060 outp "mov edx, [esp+" +
str( 4+ofs ) +
"]"
3061 outp "imul edx, [esp+" +
str( 8+ofs ) +
"]"
3063 outp "mov [esp+" +
str( 4+ofs ) +
"], edx"
3065 if( eaxindest )
then
3066 if( dvreg->typ <> IR_VREGTYPE_REG )
then
3070 if( iseaxfree =
FALSE )
then
3075 if( edxindest )
then
3076 if( dvreg->typ <> IR_VREGTYPE_REG )
then
3080 if( isedxfree =
FALSE )
then
3109 byval dvreg
as IRVREG
ptr, _
3110 byval svreg
as IRVREG
ptr _
3113 dim reg
as integer, isfree
as integer, rname
as string
3115 dim dst
as string, src
as string
3120 if( dvreg->typ <> IR_VREGTYPE_REG )
then
3125 isfree =
hIsRegFree( FB_DATACLASS_INTEGER, reg )
3127 if( isfree =
FALSE )
then
3132 ostr =
"imul " + rname + COMMA + src
3136 if( isfree =
FALSE )
then
3141 ostr =
"imul " + dst + COMMA + src
3152 byval dvreg
as IRVREG
ptr, _
3153 byval svreg
as IRVREG
ptr _
3161 if( svreg->typ = IR_VREGTYPE_REG )
then
3164 if( typeGetClass( svreg->dtype ) = FB_DATACLASS_FPOINT )
then
3165 ostr =
"fmul " + src
3169 assert( (typeGetSize( svreg->dtype ) = 2)
or (typeGetSize( svreg->dtype ) = 4) )
3170 ostr =
"fimul " + src
3182 byval dvreg
as IRVREG
ptr, _
3183 byval svreg
as IRVREG
ptr _
3191 if( svreg->typ = IR_VREGTYPE_REG )
then
3194 if( typeGetClass( svreg->dtype ) = FB_DATACLASS_FPOINT )
then
3195 ostr =
"fdiv " + src
3199 assert( (typeGetSize( svreg->dtype ) = 2)
or (typeGetSize( svreg->dtype ) = 4) )
3200 ostr =
"fidiv " + src
3210 byval dvreg
as IRVREG
ptr, _
3211 byval svreg
as IRVREG
ptr _
3214 dim as string dst, src
3215 dim as integer ecxtrashed
3216 dim as integer eaxfree, ecxfree, edxfree
3217 dim as integer eaxindest, ecxindest, edxindest
3218 dim as integer eaxinsource, edxinsource
3219 dim as string eax, ecx, edx
3225 if( typeGetSize( dvreg->dtype ) = 4 )
then
3237 eaxfree =
hIsRegFree( FB_DATACLASS_INTEGER, EMIT_REG_EAX )
3238 ecxfree =
hIsRegFree( FB_DATACLASS_INTEGER, EMIT_REG_ECX )
3239 edxfree =
hIsRegFree( FB_DATACLASS_INTEGER, EMIT_REG_EDX )
3247 if( (eaxinsource)
or (edxinsource)
or (svreg->typ = IR_VREGTYPE_IMM) )
then
3249 if( ecxindest )
then
3251 if( dvreg->typ <> IR_VREGTYPE_REG )
then
3255 elseif( ecxfree =
FALSE )
then
3262 if( eaxindest =
FALSE )
then
3263 if( (ecxindest)
and (ecxtrashed) )
then
3264 if( eaxfree =
FALSE )
then
3265 outp "xchg eax, [esp]"
3270 if( eaxfree =
FALSE )
then
3277 if( dvreg->typ <> IR_VREGTYPE_REG )
then
3283 if( edxindest )
then
3284 if( dvreg->typ <> IR_VREGTYPE_REG )
then
3287 elseif( edxfree =
FALSE )
then
3291 if( typeIsSigned( dvreg->dtype ) )
then
3292 if( typeGetSize( dvreg->dtype ) = 4 )
then
3298 ostr =
"idiv " + src
3302 ostr =
"xor " + edx +
", " + edx
3309 if( edxindest )
then
3310 if( dvreg->typ <> IR_VREGTYPE_REG )
then
3313 elseif( edxfree =
FALSE )
then
3317 if( eaxindest =
FALSE )
then
3318 if( ecxindest
and ecxtrashed )
then
3319 if( dvreg->typ <> IR_VREGTYPE_REG )
then
3320 if( eaxfree =
FALSE )
then
3322 outp "xchg ecx, [esp]"
3331 if( eaxfree =
FALSE )
then
3336 if( dvreg->typ <> IR_VREGTYPE_REG )
then
3337 if( (ecxfree =
FALSE)
and (ecxtrashed =
FALSE) )
then
3338 outp "xchg ecx, [esp]"
3339 outp "xchg ecx, eax"
3347 if( (ecxfree =
FALSE)
and (ecxtrashed =
FALSE) )
then
3353 if( ecxtrashed )
then
3354 if( (ecxfree =
FALSE)
and (ecxindest =
FALSE) )
then
3364 byval dvreg
as IRVREG
ptr, _
3365 byval svreg
as IRVREG
ptr _
3368 dim as string dst, src
3369 dim as integer ecxtrashed
3370 dim as integer eaxfree, ecxfree, edxfree
3371 dim as integer eaxindest, ecxindest, edxindest
3372 dim as integer eaxinsource, edxinsource
3373 dim as string eax, ecx, edx
3379 if( typeGetSize( dvreg->dtype ) = 4 )
then
3391 eaxfree =
hIsRegFree( FB_DATACLASS_INTEGER, EMIT_REG_EAX )
3392 ecxfree =
hIsRegFree( FB_DATACLASS_INTEGER, EMIT_REG_ECX )
3393 edxfree =
hIsRegFree( FB_DATACLASS_INTEGER, EMIT_REG_EDX )
3401 if( (eaxinsource)
or (edxinsource)
or (svreg->typ = IR_VREGTYPE_IMM) )
then
3403 if( ecxindest )
then
3405 if( dvreg->typ <> IR_VREGTYPE_REG )
then
3409 elseif( ecxfree =
FALSE )
then
3416 if( eaxindest =
FALSE )
then
3417 if( (ecxindest)
and (ecxtrashed) )
then
3418 if( eaxfree =
FALSE )
then
3419 outp "xchg eax, [esp]"
3424 if( eaxfree =
FALSE )
then
3431 if( dvreg->typ <> IR_VREGTYPE_REG )
then
3437 if( edxindest )
then
3438 if( dvreg->typ <> IR_VREGTYPE_REG )
then
3441 elseif( edxfree =
FALSE )
then
3445 if( typeIsSigned( dvreg->dtype ) )
then
3446 if( typeGetSize( dvreg->dtype ) = 4 )
then
3452 ostr =
"idiv " + src
3456 ostr =
"xor " + edx +
", " + edx
3465 if( edxindest )
then
3466 if( dvreg->typ <> IR_VREGTYPE_REG )
then
3469 elseif( edxfree =
FALSE )
then
3473 if( eaxindest =
FALSE )
then
3474 if( ecxindest
and ecxtrashed )
then
3475 if( dvreg->typ <> IR_VREGTYPE_REG )
then
3476 if( eaxfree =
FALSE )
then
3478 outp "xchg ecx, [esp]"
3487 if( eaxfree =
FALSE )
then
3492 if( dvreg->typ <> IR_VREGTYPE_REG )
then
3493 if( (ecxfree =
FALSE)
and (ecxtrashed =
FALSE) )
then
3494 outp "xchg ecx, [esp]"
3495 outp "xchg ecx, eax"
3503 if( (ecxfree =
FALSE)
and (ecxtrashed =
FALSE) )
then
3509 if( ecxtrashed )
then
3510 if( (ecxfree =
FALSE)
and (ecxindest =
FALSE) )
then
3520 byval op as integer, _
3521 byval dvreg
as IRVREG
ptr, _
3522 byval svreg
as IRVREG
ptr _
3525 dim as string dst1, dst2, src, label, mnemonic32, mnemonic64
3526 dim as integer tmpreg, tmpisfree
3527 dim as string tmpregname
3529 dim as IRVREG
ptr av, bv
3532 if(
op = AST_OP_SHL )
then
3535 mnemonic64 =
"shld "
3537 if( typeIsSigned( dvreg->dtype ) )
then
3542 mnemonic64 =
"shrd "
3549 if(
op = AST_OP_SHL )
then
3561 if( svreg->typ = IR_VREGTYPE_IMM )
then
3562 if( svreg->value.i >= 64 )
then
3564 if( bv->typ = IR_VREGTYPE_REG )
then
3565 outp "xor " + b +
", " + b
3567 outp "mov " + b +
", 0"
3570 if( av->typ = IR_VREGTYPE_REG )
then
3571 outp "xor " + a +
", " + a
3573 outp "mov " + a +
", 0"
3575 elseif( svreg->value.i >= 32 )
then
3577 if( (bv->typ = IR_VREGTYPE_REG)
or (av->typ = IR_VREGTYPE_REG) )
then
3579 outp "mov " + a +
", " + b
3583 if( tmpreg = INVALID )
then
3589 tmpregname = *
hGetRegName( FB_DATATYPE_INTEGER, tmpreg )
3590 if( tmpisfree =
FALSE )
then
3593 outp "mov " + tmpregname +
", " + b
3594 outp "mov " + a +
", " + tmpregname
3597 if( (
op = AST_OP_SHR)
and typeIsSigned( dvreg->dtype ) )
then
3598 outp "sar " + b +
", 31"
3599 elseif( bv->typ = IR_VREGTYPE_REG )
then
3600 outp "xor " + b +
", " + b
3602 outp "mov " + b +
", 0"
3605 if( svreg->value.i > 32 )
then
3606 src =
str( svreg->value.i - 32 )
3607 outp mnemonic32 + a +
", " + src
3610 if( tmpisfree =
FALSE )
then
3615 if( bv->typ = IR_VREGTYPE_REG )
then
3616 outp mnemonic64 + a +
", " + b +
", " + src
3617 outp mnemonic32 + b +
", " + src
3618 elseif( av->typ = IR_VREGTYPE_REG )
then
3619 outp "xchg " + a +
", " + b
3620 outp mnemonic64 + b +
", " + a +
", " + src
3621 outp mnemonic32 + a +
", " + src
3622 outp "xchg " + a +
", " + b
3625 if( tmpreg = INVALID )
then
3633 tmpregname = *
hGetRegName( FB_DATATYPE_INTEGER, tmpreg )
3634 if( tmpisfree =
FALSE )
then
3637 outp "mov " + tmpregname +
", " + b
3638 outp mnemonic64 + a +
", " + tmpregname +
", " + src
3639 outp mnemonic32 + tmpregname +
", " + src
3640 outp "mov " + b +
", " + tmpregname
3641 if( tmpisfree =
FALSE )
then
3649 dim as integer iseaxfree, isedxfree, isecxfree
3650 dim as integer eaxindest, edxindest, ecxindest
3659 iseaxfree =
hIsRegFree( FB_DATACLASS_INTEGER, EMIT_REG_EAX )
3660 isedxfree =
hIsRegFree( FB_DATACLASS_INTEGER, EMIT_REG_EDX )
3661 isecxfree =
hIsRegFree( FB_DATACLASS_INTEGER, EMIT_REG_ECX )
3667 if( (svreg->typ <> IR_VREGTYPE_REG)
or (svreg->reg <> EMIT_REG_ECX) )
then
3669 if( typeGetSize( svreg->dtype ) <> 4 )
then
3671 if( svreg->typ = IR_VREGTYPE_REG )
then
3672 src = *
hGetRegName( FB_DATATYPE_INTEGER, svreg->reg )
3676 if( isecxfree =
FALSE )
then
3677 if( ecxindest
and dvreg->typ = IR_VREGTYPE_REG )
then
3682 outp "xchg ecx, [esp]"
3693 if( eaxindest )
then
3694 if( dvreg->typ <> IR_VREGTYPE_REG )
then
3695 outp "xchg eax, [esp+" +
str( ofs+0 ) +
"]"
3697 outp "mov eax, [esp+" +
str( ofs+0 ) +
"]"
3700 if( iseaxfree =
FALSE )
then
3701 outp "xchg eax, [esp+" +
str( ofs+0 ) +
"]"
3703 outp "mov eax, [esp+" +
str( ofs+0 ) +
"]"
3708 if( edxindest )
then
3709 if( dvreg->typ <> IR_VREGTYPE_REG )
then
3710 outp "xchg edx, [esp+" +
str( ofs+4 ) +
"]"
3712 outp "mov edx, [esp+" +
str( ofs+4 ) +
"]"
3715 if( isedxfree =
FALSE )
then
3716 outp "xchg edx, [esp+" +
str( ofs+4 ) +
"]"
3718 outp "mov edx, [esp+" +
str( ofs+4 ) +
"]"
3722 if(
op = AST_OP_SHL )
then
3723 outp "shld edx, eax, cl"
3724 outp mnemonic32 +
" eax, cl"
3726 outp "shrd eax, edx, cl"
3727 outp mnemonic32 +
" edx, cl"
3733 if(
op = AST_OP_SHL )
then
3738 if( typeIsSigned( dvreg->dtype ) )
then
3747 if( isecxfree =
FALSE )
then
3752 if( edxindest )
then
3753 if( dvreg->typ <> IR_VREGTYPE_REG )
then
3754 outp "xchg edx, [esp+4]"
3756 outp "mov [esp+4], edx"
3759 if( isedxfree =
FALSE )
then
3760 outp "xchg edx, [esp+4]"
3762 outp "mov [esp+4], edx"
3767 if( eaxindest )
then
3768 if( dvreg->typ <> IR_VREGTYPE_REG )
then
3769 outp "xchg eax, [esp+0]"
3771 outp "mov [esp+0], eax"
3774 if( iseaxfree =
FALSE )
then
3775 outp "xchg eax, [esp+0]"
3777 outp "mov [esp+0], eax"
3790 byval op as integer, _
3791 byval dvreg
as IRVREG
ptr, _
3792 byval svreg
as IRVREG
ptr _
3795 dim eaxpreserved
as integer, ecxpreserved
as integer
3796 dim eaxfree
as integer, ecxfree
as integer
3798 dim ecxindest
as integer
3799 dim as string ostr, dst, src, tmp, mnemonic
3802 if( typeIsSigned( dvreg->dtype ) )
then
3803 if(
op = AST_OP_SHL )
then
3809 if(
op = AST_OP_SHL )
then
3820 eaxpreserved =
FALSE
3821 ecxpreserved =
FALSE
3823 if( svreg->typ = IR_VREGTYPE_IMM )
then
3828 eaxfree =
hIsRegFree( FB_DATACLASS_INTEGER, EMIT_REG_EAX )
3829 ecxfree =
hIsRegFree( FB_DATACLASS_INTEGER, EMIT_REG_ECX )
3831 if( svreg->typ = IR_VREGTYPE_REG )
then
3840 if( ecxindest )
then
3844 if( dvreg->typ <> IR_VREGTYPE_REG )
then
3850 elseif( (reg <> EMIT_REG_ECX)
and (ecxfree =
FALSE) )
then
3856 if( svreg->typ <> IR_VREGTYPE_REG )
then
3861 if( reg <> EMIT_REG_ECX )
then
3867 if( ecxindest )
then
3869 if( eaxfree =
FALSE )
then
3871 outp "xchg eax, [esp]"
3886 ostr = mnemonic +
" " + tmp + COMMA + src
3889 if( ecxindest )
then
3890 if( dvreg->typ <> IR_VREGTYPE_REG )
then
3892 if( eaxpreserved )
then
3893 outp "xchg ecx, [esp]"
3899 if( eaxpreserved )
then
3903 if( ecxpreserved )
then
3912 byval dvreg
as IRVREG
ptr, _
3913 byval svreg
as IRVREG
ptr _
3916 hSHIFTL( AST_OP_SHL, dvreg, svreg )
3923 byval dvreg
as IRVREG
ptr, _
3924 byval svreg
as IRVREG
ptr _
3927 hSHIFTI( AST_OP_SHL, dvreg, svreg )
3934 byval dvreg
as IRVREG
ptr, _
3935 byval svreg
as IRVREG
ptr _
3938 hSHIFTL( AST_OP_SHR, dvreg, svreg )
3945 byval dvreg
as IRVREG
ptr, _
3946 byval svreg
as IRVREG
ptr _
3949 hSHIFTI( AST_OP_SHR, dvreg, svreg )
3956 byval dvreg
as IRVREG
ptr, _
3957 byval svreg
as IRVREG
ptr _
3960 dim dst1
as string, dst2
as string, src1
as string, src2
as string
3966 ostr =
"and " + dst1 + COMMA + src1
3969 ostr =
"and " + dst2 + COMMA + src2
3977 byval dvreg
as IRVREG
ptr, _
3978 byval svreg
as IRVREG
ptr _
3981 dim dst
as string, src
as string
3987 ostr =
"and " + dst + COMMA + src
3995 byval dvreg
as IRVREG
ptr, _
3996 byval svreg
as IRVREG
ptr _
3999 dim dst1
as string, dst2
as string, src1
as string, src2
as string
4005 ostr =
"or " + dst1 + COMMA + src1
4008 ostr =
"or " + dst2 + COMMA + src2
4016 byval dvreg
as IRVREG
ptr, _
4017 byval svreg
as IRVREG
ptr _
4020 dim dst
as string, src
as string
4026 ostr =
"or " + dst + COMMA + src
4034 byval dvreg
as IRVREG
ptr, _
4035 byval svreg
as IRVREG
ptr _
4038 dim dst1
as string, dst2
as string, src1
as string, src2
as string
4044 ostr =
"xor " + dst1 + COMMA + src1
4047 ostr =
"xor " + dst2 + COMMA + src2
4055 byval dvreg
as IRVREG
ptr, _
4056 byval svreg
as IRVREG
ptr _
4059 dim dst
as string, src
as string
4065 ostr =
"xor " + dst + COMMA + src
4073 byval dvreg
as IRVREG
ptr, _
4074 byval svreg
as IRVREG
ptr _
4077 dim dst1
as string, dst2
as string, src1
as string, src2
as string
4083 ostr =
"xor " + dst1 + COMMA + src1
4086 ostr =
"xor " + dst2 + COMMA + src2
4089 ostr =
"not " + dst1
4092 ostr =
"not " + dst2
4100 byval dvreg
as IRVREG
ptr, _
4101 byval svreg
as IRVREG
ptr _
4104 dim dst
as string, src
as string
4110 ostr =
"xor " + dst + COMMA + src
4121 byval dvreg
as IRVREG
ptr, _
4122 byval svreg
as IRVREG
ptr _
4125 dim dst1
as string, dst2
as string, src1
as string, src2
as string
4131 ostr =
"not " + dst1
4134 ostr =
"not " + dst2
4137 ostr =
"or " + dst1 + COMMA + src1
4140 ostr =
"or " + dst2 + COMMA + src2
4148 byval dvreg
as IRVREG
ptr, _
4149 byval svreg
as IRVREG
ptr _
4152 dim dst
as string, src
as string
4161 ostr =
"or " + dst + COMMA + src
4170 byval dvreg
as IRVREG
ptr, _
4171 byval svreg
as IRVREG
ptr _
4179 if( svreg->typ <> IR_VREGTYPE_REG )
then
4192 byval dvreg
as IRVREG
ptr, _
4193 byval svreg
as IRVREG
ptr _
4201 if( svreg->typ <> IR_VREGTYPE_REG )
then
4211 outp "fsub st(1), st(0)"
4228 byval rvreg
as IRVREG
ptr, _
4229 byval label
as FBSYMBOL
ptr, _
4230 byval mnemonic
as zstring ptr, _
4231 byval rev_mnemonic
as zstring ptr, _
4232 byval usg_mnemonic
as zstring ptr, _
4233 byval dvreg
as IRVREG
ptr, _
4234 byval svreg
as IRVREG
ptr, _
4235 byval isinverse
as integer =
FALSE _
4238 dim as string dst1, dst2, src1, src2, rname, ostr, lname, falselabel
4243 if( label = NULL )
then
4250 ostr =
"cmp " + dst2 + COMMA + src2
4256 if( rvreg <> NULL )
then
4261 ostr =
"j" + *mnemonic
4262 if( isinverse =
FALSE )
then
4268 if(
len( *rev_mnemonic ) > 0 )
then
4269 ostr =
"j" + *rev_mnemonic
4274 ostr =
"cmp " + dst1 + COMMA + src1
4277 ostr =
"j" + *usg_mnemonic
4280 hLabel( falselabel )
4282 if( rvreg <> NULL )
then
4283 ostr =
"xor " + rname + COMMA + rname
4294 byval rvreg
as IRVREG
ptr, _
4295 byval label
as FBSYMBOL
ptr, _
4296 byval mnemonic
as zstring ptr, _
4297 byval dvreg
as IRVREG
ptr, _
4298 byval svreg
as IRVREG
ptr _
4301 dim as string rname, rname8, dst, src, ostr, lname
4302 dim as integer isedxfree, dotest
4307 if( label = NULL )
then
4315 if( (svreg->typ = IR_VREGTYPE_IMM)
and (dvreg->typ = IR_VREGTYPE_REG) )
then
4316 if( svreg->value.i = 0 )
then
4322 ostr =
"test " + dst + COMMA + dst
4325 ostr =
"cmp " + dst + COMMA + src
4330 if( rvreg = NULL )
then
4331 ostr =
"j" + *mnemonic
4339 if( (env.clopt.cputype >= FB_CPUTYPE_486)
and (rvreg->typ = IR_VREGTYPE_REG) )
then
4341 rname8 = *
hGetRegName( FB_DATATYPE_BYTE, rvreg->reg )
4344 if( (rvreg->reg = EMIT_REG_ESI)
or (rvreg->reg = EMIT_REG_EDI) )
then
4346 isedxfree =
hIsRegFree( FB_DATACLASS_INTEGER, EMIT_REG_EDX )
4347 if( isedxfree =
FALSE )
then
4348 ostr =
"xchg edx, " + rname
4352 ostr =
"set" + *mnemonic +
" dl"
4355 if( isedxfree =
FALSE )
then
4356 ostr =
"xchg edx, " + rname
4363 ostr =
"set" + *mnemonic +
" " + rname8
4368 ostr =
"shr " + rname +
", 1"
4371 ostr =
"sbb " + rname + COMMA + rname
4377 ostr =
"mov " + rname +
", -1"
4380 ostr =
"j" + *mnemonic
4383 ostr =
"xor " + rname + COMMA + rname
4395 byval rvreg
as IRVREG
ptr, _
4396 byval label
as FBSYMBOL
ptr, _
4397 byval mnemonic
as zstring ptr, _
4398 byval mask
as zstring ptr, _
4399 byval dvreg
as IRVREG
ptr, _
4400 byval svreg
as IRVREG
ptr _
4403 dim as string rname, rname8, dst, src, ostr, lname
4404 dim as integer iseaxfree, isedxfree
4409 if( label = NULL )
then
4416 if( svreg->typ = IR_VREGTYPE_REG )
then
4420 if( typeGetClass( svreg->dtype ) = FB_DATACLASS_FPOINT )
then
4421 ostr =
"fcomp " + src
4424 ostr =
"ficomp " + src
4429 iseaxfree =
hIsRegFree( FB_DATACLASS_INTEGER, EMIT_REG_EAX )
4430 if( rvreg <> NULL )
then
4431 iseaxfree = (rvreg->reg = EMIT_REG_EAX)
4434 if( iseaxfree =
FALSE )
then
4440 if(
len( *mask ) > 0 )
then
4441 ostr =
"test ah, " + *mask
4447 if( iseaxfree =
FALSE )
then
4452 if( rvreg = NULL )
then
4453 ostr =
"j" + *mnemonic
4461 if( env.clopt.cputype >= FB_CPUTYPE_486 )
then
4462 rname8 = *
hGetRegName( FB_DATATYPE_BYTE, rvreg->reg )
4465 if( (rvreg->reg = EMIT_REG_ESI)
or (rvreg->reg = EMIT_REG_EDI) )
then
4467 isedxfree =
hIsRegFree( FB_DATACLASS_INTEGER, EMIT_REG_EDX )
4468 if( isedxfree =
FALSE )
then
4469 ostr =
"xchg edx, " + rname
4473 ostr =
"set" + *mnemonic + (TABCHAR +
"dl")
4476 if( isedxfree =
FALSE )
then
4477 ostr =
"xchg edx, " + rname
4483 ostr =
"set" + *mnemonic +
" " + rname8
4488 ostr =
"shr " + rname +
", 1"
4491 ostr =
"sbb " + rname + COMMA + rname
4496 ostr =
"mov " + rname +
", -1"
4499 ostr =
"j" + *mnemonic
4502 ostr =
"xor " + rname + COMMA + rname
4513 byval rvreg
as IRVREG
ptr, _
4514 byval label
as FBSYMBOL
ptr, _
4515 byval dvreg
as IRVREG
ptr, _
4516 byval svreg
as IRVREG
ptr _
4519 dim jmp
as string, rjmp
as string
4521 if( typeIsSigned( dvreg->dtype ) )
then
4529 hCMPL( rvreg, label, jmp, rjmp,
"a", dvreg, svreg )
4536 byval rvreg
as IRVREG
ptr, _
4537 byval label
as FBSYMBOL
ptr, _
4538 byval dvreg
as IRVREG
ptr, _
4539 byval svreg
as IRVREG
ptr _
4544 if( typeIsSigned( dvreg->dtype ) )
then
4550 hCMPI( rvreg, label, jmp, dvreg, svreg )
4559 byval rvreg
as IRVREG
ptr, _
4560 byval label
as FBSYMBOL
ptr, _
4561 byval dvreg
as IRVREG
ptr, _
4562 byval svreg
as IRVREG
ptr _
4565 hCMPF( rvreg, label,
"z",
"0b01000001", dvreg, svreg )
4572 byval rvreg
as IRVREG
ptr, _
4573 byval label
as FBSYMBOL
ptr, _
4574 byval dvreg
as IRVREG
ptr, _
4575 byval svreg
as IRVREG
ptr _
4578 dim jmp
as string, rjmp
as string
4580 if( typeIsSigned( dvreg->dtype ) )
then
4588 hCMPL( rvreg, label, jmp, rjmp,
"b", dvreg, svreg )
4595 byval rvreg
as IRVREG
ptr, _
4596 byval label
as FBSYMBOL
ptr, _
4597 byval dvreg
as IRVREG
ptr, _
4598 byval svreg
as IRVREG
ptr _
4603 if( typeIsSigned( dvreg->dtype ) )
then
4609 hCMPI( rvreg, label, jmp, dvreg, svreg )
4617 byval rvreg
as IRVREG
ptr, _
4618 byval label
as FBSYMBOL
ptr, _
4619 byval dvreg
as IRVREG
ptr, _
4620 byval svreg
as IRVREG
ptr _
4623 hCMPF( rvreg, label,
"nz",
"0b00000001", dvreg, svreg )
4630 byval rvreg
as IRVREG
ptr, _
4631 byval label
as FBSYMBOL
ptr, _
4632 byval dvreg
as IRVREG
ptr, _
4633 byval svreg
as IRVREG
ptr _
4636 hCMPL( rvreg, label,
"ne",
"",
"e", dvreg, svreg,
TRUE )
4643 byval rvreg
as IRVREG
ptr, _
4644 byval label
as FBSYMBOL
ptr, _
4645 byval dvreg
as IRVREG
ptr, _
4646 byval svreg
as IRVREG
ptr _
4649 hCMPI( rvreg, label,
"e", dvreg, svreg )
4657 byval rvreg
as IRVREG
ptr, _
4658 byval label
as FBSYMBOL
ptr, _
4659 byval dvreg
as IRVREG
ptr, _
4660 byval svreg
as IRVREG
ptr _
4663 hCMPF( rvreg, label,
"nz",
"0b01000000", dvreg, svreg )
4670 byval rvreg
as IRVREG
ptr, _
4671 byval label
as FBSYMBOL
ptr, _
4672 byval dvreg
as IRVREG
ptr, _
4673 byval svreg
as IRVREG
ptr _
4676 hCMPL( rvreg, label,
"ne",
"",
"ne", dvreg, svreg )
4683 byval rvreg
as IRVREG
ptr, _
4684 byval label
as FBSYMBOL
ptr, _
4685 byval dvreg
as IRVREG
ptr, _
4686 byval svreg
as IRVREG
ptr _
4689 hCMPI( rvreg, label,
"ne", dvreg, svreg )
4697 byval rvreg
as IRVREG
ptr, _
4698 byval label
as FBSYMBOL
ptr, _
4699 byval dvreg
as IRVREG
ptr, _
4700 byval svreg
as IRVREG
ptr _
4703 hCMPF( rvreg, label,
"z",
"0b01000000", dvreg, svreg )
4710 byval rvreg
as IRVREG
ptr, _
4711 byval label
as FBSYMBOL
ptr, _
4712 byval dvreg
as IRVREG
ptr, _
4713 byval svreg
as IRVREG
ptr _
4716 dim jmp
as string, rjmp
as string
4718 if( typeIsSigned( dvreg->dtype ) )
then
4726 hCMPL( rvreg, label, jmp, rjmp,
"be", dvreg, svreg )
4733 byval rvreg
as IRVREG
ptr, _
4734 byval label
as FBSYMBOL
ptr, _
4735 byval dvreg
as IRVREG
ptr, _
4736 byval svreg
as IRVREG
ptr _
4741 if( typeIsSigned( dvreg->dtype ) )
then
4747 hCMPI( rvreg, label, jmp, dvreg, svreg )
4755 byval rvreg
as IRVREG
ptr, _
4756 byval label
as FBSYMBOL
ptr, _
4757 byval dvreg
as IRVREG
ptr, _
4758 byval svreg
as IRVREG
ptr _
4761 hCMPF( rvreg, label,
"nz",
"0b01000001", dvreg, svreg )
4769 byval rvreg
as IRVREG
ptr, _
4770 byval label
as FBSYMBOL
ptr, _
4771 byval dvreg
as IRVREG
ptr, _
4772 byval svreg
as IRVREG
ptr _
4775 dim jmp
as string, rjmp
as string
4777 if( typeIsSigned( dvreg->dtype ) )
then
4785 hCMPL( rvreg, label, jmp, rjmp,
"ae", dvreg, svreg )
4792 byval rvreg
as IRVREG
ptr, _
4793 byval label
as FBSYMBOL
ptr, _
4794 byval dvreg
as IRVREG
ptr, _
4795 byval svreg
as IRVREG
ptr _
4800 if( typeIsSigned( dvreg->dtype ) )
then
4806 hCMPI( rvreg, label, jmp, dvreg, svreg )
4814 byval rvreg
as IRVREG
ptr, _
4815 byval label
as FBSYMBOL
ptr, _
4816 byval dvreg
as IRVREG
ptr, _
4817 byval svreg
as IRVREG
ptr _
4820 hCMPF( rvreg, label,
"ae",
"", dvreg, svreg )
4832 byval dvreg
as IRVREG
ptr _
4835 dim dst1
as string, dst2
as string
4840 ostr =
"neg " + dst1
4843 ostr =
"adc " + dst2 +
", 0"
4846 ostr =
"neg " + dst2
4854 byval dvreg
as IRVREG
ptr _
4871 byval dvreg
as IRVREG
ptr _
4881 byval dvreg
as IRVREG
ptr _
4884 dim dst1
as string, dst2
as string
4889 ostr =
"not " + dst1
4892 ostr =
"not " + dst2
4900 byval dvreg
as IRVREG
ptr _
4916 byval dvreg
as IRVREG
ptr _
4919 dim dst1
as string, dst2
as string
4920 dim reg
as integer, isfree
as integer, rname
as string
4928 isfree =
hIsRegFree( FB_DATACLASS_INTEGER, reg )
4930 if( isfree =
FALSE )
then
4936 ostr =
"sar " + rname +
", 31"
4939 ostr =
"xor " + dst1 + COMMA + rname
4942 ostr =
"xor " + dst2 + COMMA + rname
4945 ostr =
"sub " + dst1 + COMMA + rname
4948 ostr =
"sbb " + dst2 + COMMA + rname
4951 if( isfree =
FALSE )
then
4960 byval dvreg
as IRVREG
ptr _
4964 dim reg
as integer, isfree
as integer, rname
as string, bits
as integer
4972 isfree =
hIsRegFree( FB_DATACLASS_INTEGER, reg )
4974 if( isfree =
FALSE )
then
4978 bits = typeGetBits( dvreg->dtype ) - 1
4982 ostr =
"sar " + rname + COMMA +
str( bits )
4985 ostr =
"xor " + dst + COMMA + rname
4988 ostr =
"sub " + dst + COMMA + rname
4991 if( isfree =
FALSE )
then
5001 byval dvreg
as IRVREG
ptr _
5011 byval dvreg
as IRVREG
ptr _
5014 dim dst1
as string, dst2
as string
5016 dim label1
as string, label2
as string
5023 ostr =
"cmp " + dst2 +
", 0"
5027 ostr =
"cmp " + dst1 +
", 0"
5045 byval dvreg
as IRVREG
ptr _
5048 dim as string dst, label, ostr
5054 ostr =
"cmp " + dst +
", 0"
5070 byval dvreg
as IRVREG
ptr _
5073 dim as string dst, label, ostr
5074 dim as integer iseaxfree
5080 iseaxfree =
hIsRegFree( FB_DATACLASS_INTEGER, EMIT_REG_EAX )
5082 if( iseaxfree =
FALSE )
then
5090 if( iseaxfree =
FALSE )
then
5110 byval dvreg
as IRVREG
ptr _
5120 byval dvreg
as IRVREG
ptr _
5125 outp "fmul st(0), st(0)"
5136 byval dvreg
as IRVREG
ptr _
5146 byval dvreg
as IRVREG
ptr _
5151 outp "fmul st(0), st(0)"
5163 byval dvreg
as IRVREG
ptr _
5174 byval dvreg
as IRVREG
ptr _
5185 byval dvreg
as IRVREG
ptr _
5195 byval dvreg
as IRVREG
ptr _
5209 byval dvreg
as IRVREG
ptr _
5213 outp "fmulp st(1), st"
5216 outp "fsub st(1), st"
5220 hPUSH(
"0x3f800000" )
5221 outp "fadd dword ptr [esp]"
5228 outp(
"sub esp, 4" )
5229 outp(
"fnstcw [esp]" )
5230 hMOV( regname,
"[esp]" )
5231 if( *mode <>
"11" )
then
5232 outp(
"and " + regname +
", 0b1111001111111111" )
5234 outp(
"or " + regname + (
", 0b0000" + *mode +
"0000000000") )
5236 outp(
"fldcw [esp]" )
5237 outp(
"add esp, 4" )
5241 dim as integer reg =
any, isregfree =
any
5242 dim as string regname
5245 if( reg = INVALID )
then
5252 regname = *
hGetRegName( FB_DATATYPE_INTEGER, reg )
5254 if( isregfree =
FALSE )
then
5279 outp(
"fldcw [esp]" )
5280 outp(
"add esp, 4" )
5282 if( isregfree =
FALSE )
then
5300 assert( dvreg->typ = IR_VREGTYPE_REG )
5301 assert( dvreg->regFamily = IR_REG_FPU_STACK )
5306 outp(
"sub esp, 4" )
5307 outp(
"fstp dword ptr [esp]" )
5308 outp(
"fld dword ptr [esp]" )
5309 outp(
"add esp, 4" )
5315 byval svreg
as IRVREG
ptr _
5323 ostr =
"fxch " + src
5333 if( vreg->value.i > 0 )
then
5334 outp(
"sub esp, " +
str( vreg->value.i ) )
5336 outp(
"add esp, " +
str( -vreg->value.i ) )
5343 byval svreg
as IRVREG
ptr, _
5344 byval unused
as integer _
5347 dim src1
as string, src2
as string
5352 ostr =
"push " + src2
5355 ostr =
"push " + src1
5360 sub _emitPUSHI(
byval svreg
as IRVREG
ptr,
byval unused
as integer )
5361 dim as string src, tmp32
5362 dim as integer sdsize =
any, tmpreg =
any, istmpfree =
any
5366 sdsize = typeGetSize( svreg->dtype )
5371 select case( svreg->typ )
5372 case IR_VREGTYPE_REG
5373 if( sdsize < 4 )
then
5377 src = *
hGetRegName( FB_DATATYPE_INTEGER, svreg->reg )
5379 outp(
"push " + src )
5381 case IR_VREGTYPE_IMM
5382 outp(
"push " + src )
5385 if( sdsize < 4 )
then
5391 istmpfree =
hIsRegFree( FB_DATACLASS_INTEGER, tmpreg )
5392 tmp32 = *
hGetRegName( FB_DATATYPE_INTEGER, tmpreg )
5394 if( istmpfree =
FALSE )
then
5401 outp(
"movzx " + tmp32 +
", " + src )
5404 outp(
"push " + tmp32 )
5406 if( istmpfree =
FALSE )
then
5410 assert( sdsize = 4 )
5411 outp(
"push " + src )
5420 byval svreg
as IRVREG
ptr, _
5421 byval unused
as integer _
5424 dim src
as string, sdsize
as integer
5429 sdsize = typeGetSize( svreg->dtype )
5431 if( svreg->typ <> IR_VREGTYPE_REG )
then
5432 if( svreg->dtype = FB_DATATYPE_SINGLE )
then
5433 ostr =
"push " + src
5437 ostr =
"push " + src
5441 ostr =
"push " + src
5445 ostr =
"sub esp," +
str( sdsize )
5448 ostr =
"fstp " +
dtypeTB(svreg->dtype).mname +
" [esp]"
5455 dim as string src, tmp32, tmp16
5456 dim as integer ofs =
any, tmpreg =
any, istmpfree =
any, remainder =
any
5485 remainder = sdsize
and (4-1)
5486 if( remainder > 0 )
then
5492 istmpfree =
hIsRegFree( FB_DATACLASS_INTEGER, tmpreg )
5493 tmp32 = *
hGetRegName( FB_DATATYPE_INTEGER, tmpreg )
5495 if( istmpfree =
FALSE )
then
5499 select case( remainder )
5510 hPrepOperand( svreg, src, FB_DATATYPE_BYTE, sdsize - 1 )
5511 outp(
"movzx " + tmp32 +
", " + src )
5515 outp(
"shl " + tmp32 +
", 16" )
5522 hPrepOperand( svreg, src, FB_DATATYPE_SHORT, sdsize - 3 )
5523 outp(
"mov " + tmp16 +
", " + src )
5536 outp(
"movzx " + tmp32 +
", " + src )
5543 outp(
"movzx " + tmp32 +
", " + src )
5549 outp(
"push " + tmp32 )
5551 if( istmpfree =
FALSE )
then
5563 outp(
"push " + src )
5572 byval dvreg
as IRVREG
ptr, _
5573 byval unused
as integer _
5576 dim dst1
as string, dst2
as string
5581 ostr =
"pop " + dst1
5584 ostr =
"pop " + dst2
5592 byval dvreg
as IRVREG
ptr, _
5593 byval unused
as integer _
5596 dim as string dst, ostr
5597 dim as integer dsize
5601 dsize = typeGetSize( dvreg->dtype )
5603 if( dvreg->typ = IR_VREGTYPE_IMM )
then
5607 if( dvreg->value.i = 4 )
then
5608 if(
hIsRegFree( FB_DATACLASS_INTEGER, EMIT_REG_EAX ) )
then
5614 ostr =
"add esp, " +
str( dvreg->value.i )
5618 elseif( dsize = 4 )
then
5624 if( dvreg->typ = IR_VREGTYPE_REG )
then
5625 dst = *
hGetRegName( FB_DATATYPE_INTEGER, dvreg->reg )
5629 dim as integer reg, isfree
5630 dim as string aux8, aux16, aux32
5632 assert( (dsize = 1)
or (dsize = 2) )
5640 isfree =
hIsRegFree( FB_DATACLASS_INTEGER, reg )
5644 hMOV aux32,
"dword ptr [esp]"
5650 hXCHG aux32,
"dword ptr [esp]"
5654 if( dsize = 1 )
then
5677 byval dvreg
as IRVREG
ptr, _
5678 byval unused
as integer _
5681 dim as string dst, ostr
5682 dim as integer dsize
5686 dsize = typeGetSize( dvreg->dtype )
5688 if( dvreg->typ <> IR_VREGTYPE_REG )
then
5689 if( dvreg->dtype = FB_DATATYPE_SINGLE )
then
5702 ostr =
"fld " +
dtypeTB(dvreg->dtype).mname +
" [esp]"
5705 ostr =
"add esp," +
str( dsize )
5718 byval dvreg
as IRVREG
ptr, _
5719 byval svreg
as IRVREG
ptr _
5722 dim as string dst, src
5728 ostr =
"lea " + dst +
", " + src
5736 byval dvreg
as IRVREG
ptr, _
5737 byval svreg
as IRVREG
ptr _
5740 dim as string dst, src
5746 ostr =
"mov " + dst + COMMA + src
5758 byval dvreg
as IRVREG
ptr, _
5759 byval svreg
as IRVREG
ptr, _
5760 byval bytes
as integer _
5763 dim as string dst, src
5765 dim as integer ecxfree, edifree, esifree
5766 dim as integer ediinsrc, ecxinsrc
5771 ecxfree =
hIsRegFree( FB_DATACLASS_INTEGER, EMIT_REG_ECX )
5772 edifree =
hIsRegFree( FB_DATACLASS_INTEGER, EMIT_REG_EDI )
5773 esifree =
hIsRegFree( FB_DATACLASS_INTEGER, EMIT_REG_ESI )
5778 if( ecxfree =
FALSE )
then
5781 if( edifree =
FALSE )
then
5784 if( esifree =
FALSE )
then
5788 if( ediinsrc =
FALSE )
then
5789 if( dvreg->typ <> IR_VREGTYPE_REG )
then
5793 if( dvreg->reg <> EMIT_REG_EDI )
then
5806 outp "xchg ecx, [esp]"
5810 if( svreg->typ <> IR_VREGTYPE_REG )
then
5814 if( svreg->reg <> EMIT_REG_ESI )
then
5820 if( ecxinsrc =
FALSE )
then
5821 hMOV(
"edi",
"ecx" )
5827 if( bytes > 4 )
then
5828 ostr =
"mov ecx, " +
str( cunsg(bytes) \ 4 )
5832 elseif( bytes = 4 )
then
5833 outp "mov ecx, [esi]"
5834 outp "mov [edi], ecx"
5835 if( (bytes
and 3) > 0 )
then
5842 if( bytes > 0 )
then
5843 if( bytes >= 2 )
then
5844 outp "mov cx, [esi]"
5845 outp "mov [edi], cx"
5846 if( bytes = 3 )
then
5852 if( (bytes
and 1) <> 0 )
then
5853 outp "mov cl, [esi]"
5854 outp "mov [edi], cl"
5858 if( esifree =
FALSE )
then
5861 if( edifree =
FALSE )
then
5864 if( ecxfree =
FALSE )
then
5873 byval dvreg
as IRVREG
ptr, _
5874 byval svreg
as IRVREG
ptr, _
5875 byval bytes
as integer _
5878 dim as string dst, src, aux
5879 dim as integer i, ofs, reg, isfree
5891 isfree =
hIsRegFree( FB_DATACLASS_INTEGER, reg )
5892 if( isfree =
FALSE )
then
5898 for i = 1
to cunsg(bytes) \ 4
5907 if( (bytes
and 2) <> 0 )
then
5917 if( (bytes
and 1) <> 0 )
then
5925 if( isfree =
FALSE )
then
5934 byval dvreg
as IRVREG
ptr, _
5935 byval svreg
as IRVREG
ptr, _
5936 byval bytes
as integer, _
5937 byval extra
as integer _
5941 if(
culng( bytes ) > EMIT_MEMBLOCK_MAXLEN )
then
5952 byval dvreg
as IRVREG
ptr, _
5953 byval svreg
as IRVREG
ptr, _
5954 byval bytes
as integer, _
5955 byval extra
as integer _
5965 byval dvreg
as IRVREG
ptr, _
5966 byval bytes
as ulong _
5971 dim as integer eaxfree, ecxfree, edifree
5975 eaxfree =
hIsRegFree( FB_DATACLASS_INTEGER, EMIT_REG_EAX )
5976 ecxfree =
hIsRegFree( FB_DATACLASS_INTEGER, EMIT_REG_ECX )
5977 edifree =
hIsRegFree( FB_DATACLASS_INTEGER, EMIT_REG_EDI )
5979 if( eaxfree =
FALSE )
then
5982 if( ecxfree =
FALSE )
then
5985 if( edifree =
FALSE )
then
5989 if( dvreg->typ <> IR_VREGTYPE_REG )
then
5993 if( dvreg->reg <> EMIT_REG_EDI )
then
6000 if( bytes > 4 )
then
6001 ostr =
"mov ecx, " +
str( bytes \ 4 )
6005 elseif( bytes = 4 )
then
6006 outp "mov dword ptr [edi], eax"
6007 if( (bytes
and 3) > 0 )
then
6013 if( bytes > 0 )
then
6014 if( bytes >= 2 )
then
6015 outp "mov word ptr [edi], ax"
6016 if( bytes = 3 )
then
6021 if( (bytes
and 1) <> 0 )
then
6022 outp "mov byte ptr [edi], al"
6026 if( edifree =
FALSE )
then
6029 if( ecxfree =
FALSE )
then
6032 if( eaxfree =
FALSE )
then
6041 byval dvreg
as IRVREG
ptr, _
6042 byval bytes
as ulong _
6046 dim as integer i, ofs
6050 for i = 1
to bytes \ 4
6057 if( (bytes
and 2) <> 0 )
then
6064 if( (bytes
and 1) <> 0 )
then
6074 byval dvreg
as IRVREG
ptr, _
6075 byval bytes_vreg
as IRVREG
ptr _
6078 dim as string dst, bytes
6080 dim as integer eaxfree, ecxfree, edifree
6085 eaxfree =
hIsRegFree( FB_DATACLASS_INTEGER, EMIT_REG_EAX )
6086 ecxfree =
hIsRegFree( FB_DATACLASS_INTEGER, EMIT_REG_ECX )
6087 edifree =
hIsRegFree( FB_DATACLASS_INTEGER, EMIT_REG_EDI )
6089 if( eaxfree =
FALSE )
then
6092 if( ecxfree =
FALSE )
then
6095 if( edifree =
FALSE )
then
6100 if( dvreg->typ <> IR_VREGTYPE_REG )
then
6104 if( dvreg->reg <> EMIT_REG_EDI )
then
6109 if( bytes_vreg->typ <> IR_VREGTYPE_REG )
then
6110 hMOV(
"ecx", bytes )
6113 if( bytes_vreg->reg <> EMIT_REG_ECX )
then
6114 hMOV(
"ecx", bytes )
6121 ostr =
"lea edi, " + dst
6136 if( edifree =
FALSE )
then
6139 if( ecxfree =
FALSE )
then
6142 if( eaxfree =
FALSE )
then
6151 byval dvreg
as IRVREG
ptr, _
6152 byval svreg
as IRVREG
ptr, _
6153 byval unused
as integer, _
6154 byval extra
as integer _
6158 if( irIsIMM( svreg ) )
then
6159 dim as ulong bytes = svreg->value.i
6160 if( bytes > EMIT_MEMBLOCK_MAXLEN )
then
6175 byval dvreg
as IRVREG
ptr, _
6176 byval svreg
as IRVREG
ptr, _
6177 byval bytes
as integer, _
6178 byval baseofs
as integer _
6192 byval proc as FBSYMBOL
ptr, _
6193 byval lnum
as integer, _
6194 byval pos_
as integer _
6204 byval proc as FBSYMBOL
ptr, _
6205 byval lnum
as integer, _
6206 byval pos_
as integer _
6216 byval sym
as FBSYMBOL
ptr, _
6217 byval lnum
as integer, _
6218 byval pos_
as integer _
6228 byval sym
as FBSYMBOL
ptr, _
6229 byval lnum
as integer, _
6230 byval pos_
as integer _
6249 if( symbGetType( sym ) = FB_DATATYPE_DOUBLE )
then
6256 if( symbIsPublic( sym ) )
then
6277 static as string ostr
6289 static as string ostr
6290 ostr =
".ascii " + QUOTE
6292 ostr += RSLASH +
"0" + QUOTE + NEWLINE
6297 static as string ostr
6298 ostr =
".ascii " + QUOTE
6300 for i
as integer = 1
to typeGetSize( FB_DATATYPE_WCHAR )
6301 ostr += RSLASH +
"0"
6303 ostr += QUOTE + NEWLINE
6308 outEx(
".skip " +
str( bytes ) +
",0" + NEWLINE )
6317 ln = *emit.vtbl.getTypeString( FB_DATATYPE_CHAR )
6318 ln +=
" """ + *s + $
"\0"""
6330 #define EMIT_CBENTRY(
op) @_emit##op##
6333 dim shared _opFnTB(0
to EMIT_MAXOPS-1)
as any ptr => _
6335 EMIT_CBENTRY(NOP), _
6337 EMIT_CBENTRY(LOADI2I), EMIT_CBENTRY(LOADF2I), EMIT_CBENTRY(LOADL2I), _
6338 EMIT_CBENTRY(LOADI2F), EMIT_CBENTRY(LOADF2F), EMIT_CBENTRY(LOADL2F), _
6339 EMIT_CBENTRY(LOADI2L), EMIT_CBENTRY(LOADF2L), EMIT_CBENTRY(LOADL2L), _
6341 EMIT_CBENTRY(STORI2I), EMIT_CBENTRY(STORF2I), EMIT_CBENTRY(STORL2I), _
6342 EMIT_CBENTRY(STORI2F), EMIT_CBENTRY(STORF2F), EMIT_CBENTRY(STORL2F), _
6343 EMIT_CBENTRY(STORI2L), EMIT_CBENTRY(STORF2L), EMIT_CBENTRY(STORL2L), _
6345 EMIT_CBENTRY(MOVI), EMIT_CBENTRY(MOVF), EMIT_CBENTRY(MOVL), _
6346 EMIT_CBENTRY(ADDI), EMIT_CBENTRY(ADDF), EMIT_CBENTRY(ADDL), _
6347 EMIT_CBENTRY(SUBI), EMIT_CBENTRY(SUBF), EMIT_CBENTRY(SUBL), _
6348 EMIT_CBENTRY(MULI), EMIT_CBENTRY(MULF), EMIT_CBENTRY(MULL), _
6349 EMIT_CBENTRY(DIVI), EMIT_CBENTRY(DIVF), NULL , _
6350 EMIT_CBENTRY(MODI), NULL , NULL , _
6351 EMIT_CBENTRY(SHLI), EMIT_CBENTRY(SHLL), _
6352 EMIT_CBENTRY(SHRI), EMIT_CBENTRY(SHRL), _
6353 EMIT_CBENTRY(ANDI), EMIT_CBENTRY(ANDL), _
6354 EMIT_CBENTRY(ORI) , EMIT_CBENTRY(ORL) , _
6355 EMIT_CBENTRY(XORI), EMIT_CBENTRY(XORL), _
6356 EMIT_CBENTRY(EQVI), EMIT_CBENTRY(EQVL), _
6357 EMIT_CBENTRY(IMPI), EMIT_CBENTRY(IMPL), _
6358 EMIT_CBENTRY(ATN2), _
6359 EMIT_CBENTRY(POW), _
6360 EMIT_CBENTRY(ADDROF), _
6361 EMIT_CBENTRY(DEREF), _
6363 EMIT_CBENTRY(CGTI), EMIT_CBENTRY(CGTF), EMIT_CBENTRY(CGTL), _
6364 EMIT_CBENTRY(CLTI), EMIT_CBENTRY(CLTF), EMIT_CBENTRY(CLTL), _
6365 EMIT_CBENTRY(CEQI), EMIT_CBENTRY(CEQF), EMIT_CBENTRY(CEQL), _
6366 EMIT_CBENTRY(CNEI), EMIT_CBENTRY(CNEF), EMIT_CBENTRY(CNEL), _
6367 EMIT_CBENTRY(CGEI), EMIT_CBENTRY(CGEF), EMIT_CBENTRY(CGEL), _
6368 EMIT_CBENTRY(CLEI), EMIT_CBENTRY(CLEF), EMIT_CBENTRY(CLEL), _
6370 EMIT_CBENTRY(NEGI), EMIT_CBENTRY(NEGF), EMIT_CBENTRY(NEGL), _
6371 EMIT_CBENTRY(NOTI), EMIT_CBENTRY(NOTL), _
6375 EMIT_CBENTRY(ABSI), EMIT_CBENTRY(ABSF), EMIT_CBENTRY(ABSL), _
6376 EMIT_CBENTRY(SGNI), EMIT_CBENTRY(SGNF), EMIT_CBENTRY(SGNL), _
6378 EMIT_CBENTRY(
FIX), _
6379 EMIT_CBENTRY(
FRAC), _
6380 EMIT_CBENTRY(CONVFD2FS), _
6384 EMIT_CBENTRY(
SIN), EMIT_CBENTRY(
ASIN), _
6385 EMIT_CBENTRY(
COS), EMIT_CBENTRY(
ACOS), _
6386 EMIT_CBENTRY(
TAN), EMIT_CBENTRY(ATAN), _
6387 EMIT_CBENTRY(SQRT), _
6392 EMIT_CBENTRY(
LOG), _
6393 EMIT_CBENTRY(
EXP), _
6394 EMIT_CBENTRY(FLOOR), _
6395 EMIT_CBENTRY(XCHGTOS), _
6397 EMIT_CBENTRY(STACKALIGN), _
6398 EMIT_CBENTRY(PUSHI), EMIT_CBENTRY(PUSHF), EMIT_CBENTRY(PUSHL), _
6399 EMIT_CBENTRY(POPI), EMIT_CBENTRY(POPF), EMIT_CBENTRY(POPL), _
6400 EMIT_CBENTRY(PUSHUDT), _
6402 EMIT_CBENTRY(
CALL), _
6403 EMIT_CBENTRY(CALLPTR), _
6404 EMIT_CBENTRY(BRANCH), _
6405 EMIT_CBENTRY(JUMP), _
6406 EMIT_CBENTRY(JUMPPTR), _
6407 EMIT_CBENTRY(RET), _
6409 EMIT_CBENTRY(LABEL), _
6410 EMIT_CBENTRY(
PUBLIC), _
6411 EMIT_CBENTRY(LIT), _
6412 EMIT_CBENTRY(JMPTB), _
6414 EMIT_CBENTRY(MEMMOVE), _
6415 EMIT_CBENTRY(MEMSWAP), _
6416 EMIT_CBENTRY(MEMCLEAR), _
6417 EMIT_CBENTRY(STKCLEAR), _
6419 EMIT_CBENTRY(LINEINI), _
6420 EMIT_CBENTRY(LINEEND), _
6421 EMIT_CBENTRY(SCOPEINI), _
6422 EMIT_CBENTRY(SCOPEEND) _
6443 emit.keyinited =
FALSE
6446 emit.lastsection = INVALID
6447 emit.lastpriority = INVALID
6449 dim as uinteger iroptions = _
6450 IR_OPT_CPUSELFBOPS
or IR_OPT_CPUBOPFLAGS
or _
6453 if( env.clopt.fputype = FB_FPUTYPE_SSE )
then
6454 iroptions
or= IR_OPT_FPUCONV
6457 irSetOption( iroptions )
6469 emit.lastsection = INVALID
6470 emit.lastpriority = INVALID
6482 byval opt
as IR_OPTIONVALUE _
6486 case IR_OPTIONVALUE_MAXMEMBLOCKLEN
6487 return EMIT_MEMBLOCK_MAXLEN
6506 env.outf.num =
freefile
6507 if(
open( env.outf.
name,
for binary,
access read write,
as #env.outf.num ) <> 0 )
then
6521 byval tottime
as double _
6524 hCOMMENT( env.inf.
name +
"' compilation took " +
str( tottime ) +
" secs" )
6540 if( env.clopt.
export and (env.target.options
and FB_TARGETOPT_EXPORT) )
then
6552 if(
close( #env.outf.num ) <> 0 )
then
6563 )
as const zstring ptr
6565 static as zstring * 3+1 sname =
"ebp"
6574 byval dclass
as integer, _
6575 byval reg
as integer _
6579 if( dclass = FB_DATACLASS_FPOINT )
then
6583 select case as const reg
6584 case EMIT_REG_EAX, EMIT_REG_ECX, EMIT_REG_EDX
6595 byval dtype
as integer, _
6596 byval dclass
as integer, _
6597 byref r1
as integer, _
6598 byref r2
as integer _
6601 if( dclass = FB_DATACLASS_INTEGER )
then
6603 if( ISLONGINT( typeGet( dtype ) ) )
then
6618 byval dclass
as integer, _
6619 byval dtype
as integer _
6625 if( dclass = FB_DATACLASS_FPOINT )
then
6630 if( emit.regTB(dclass)->isFree( emit.regTB(dclass), EMIT_REG_EBX ) )
then
6631 function = EMIT_REG_EBX
6633 elseif( emit.regTB(dclass)->isFree( emit.regTB(dclass), EMIT_REG_ESI ) )
then
6634 if( typeGetSize( dtype ) <> 1 )
then
6635 function = EMIT_REG_ESI
6638 elseif( emit.regTB(dclass)->isFree( emit.regTB(dclass), EMIT_REG_EDI ) )
then
6639 if( typeGetSize( dtype ) <> 1 )
then
6640 function = EMIT_REG_EDI
6649 byval text
as zstring ptr _
6652 if( emit.keyinited =
FALSE )
then
6656 function = (
hashLookup( @emit.keyhash, text ) <> NULL)
6663 byval proc as FBSYMBOL
ptr _
6666 proc->
proc.ext->stk.localofs = EMIT_LOCSTART
6667 proc->
proc.ext->stk.localmax = EMIT_LOCSTART
6668 proc->
proc.ext->stk.argofs = EMIT_ARGSTART
6677 byval proc as FBSYMBOL
ptr _
6686 select case( symbGetClass( s ) )
6688 case FB_SYMBCLASS_SCOPE
6692 case FB_SYMBCLASS_VAR
6694 if( symbIsStatic( s ) )
then
6699 s = symbGetNext( s )
6705 byval proc as FBSYMBOL
ptr, _
6706 byval sym
as FBSYMBOL
ptr _
6709 dim as integer ofs =
any, lgt =
any
6711 lgt = symbGetLen( sym ) * symbGetArrayElements( sym )
6713 proc->
proc.ext->stk.localofs += ((lgt + 3)
and not 3)
6715 ofs = -
proc->
proc.ext->stk.localofs
6717 if( -ofs >
proc->
proc.ext->stk.localmax )
then
6718 proc->
proc.ext->stk.localmax = -ofs
6727 byval proc as FBSYMBOL
ptr, _
6728 byval sym
as FBSYMBOL
ptr _
6731 dim as integer lgt =
any
6733 assert( symbIsParam( sym ) )
6735 if( symbIsParamByVal( sym ) )
then
6736 lgt = symbGetLen( sym )
6741 sym->ofs =
proc->
proc.ext->stk.argofs
6742 proc->
proc.ext->stk.argofs += ((lgt + 3)
and not 3)
6749 byval proc as FBSYMBOL
ptr, _
6750 byval initlabel
as FBSYMBOL
ptr _
6764 byval proc as FBSYMBOL
ptr, _
6765 byval bytestopop
as integer, _
6766 byval initlabel
as FBSYMBOL
ptr, _
6767 byval exitlabel
as FBSYMBOL
ptr _
6770 dim as integer oldpos =
any, ispublic =
any
6772 ispublic = symbIsPublic(
proc )
6788 if( env.clopt.target = FB_COMPTARGET_LINUX )
then
6812 byval s
as FBSYMBOL
ptr _
6822 byval s
as FBSYMBOL
ptr _
6832 byval section
as integer, _
6833 byval priority
as integer _
6837 if( sec = NULL )
then
6841 static as string ostr
6851 select case as const typeGet( dtype )
6852 case FB_DATATYPE_UBYTE, FB_DATATYPE_BYTE
6854 case FB_DATATYPE_USHORT, FB_DATATYPE_SHORT
6855 function = @
".short"
6856 case FB_DATATYPE_INTEGER, FB_DATATYPE_UINT, FB_DATATYPE_ENUM
6858 case FB_DATATYPE_LONG, FB_DATATYPE_ULONG, FB_DATATYPE_SINGLE
6864 case FB_DATATYPE_LONGINT, FB_DATATYPE_ULONGINT, FB_DATATYPE_DOUBLE
6867 case FB_DATATYPE_FIXSTR, FB_DATATYPE_CHAR, FB_DATATYPE_WCHAR
6869 function = @
".ascii"
6870 case FB_DATATYPE_STRING, FB_DATATYPE_STRUCT
6871 function = @
".INVALID"
6872 case FB_DATATYPE_POINTER
6875 function = @
".INVALID"
6882 byval section
as integer, _
6883 byval priority
as integer _
6884 )
as const zstring ptr
6886 static as string ostr
6888 if( (section = emit.lastsection)
and (priority = emit.lastpriority) )
then
6895 if (
fbGetOption( FB_COMPOPT_TARGET ) <> FB_COMPTARGET_DARWIN)
then
6901 select case as const section
6902 case IR_SECTION_CONST
6903 select case as const fbGetOption( FB_COMPOPT_TARGET )
6904 case FB_COMPTARGET_CYGWIN, FB_COMPTARGET_DOS, _
6905 FB_COMPTARGET_WIN32, FB_COMPTARGET_XBOX
6908 case FB_COMPTARGET_DARWIN
6916 case IR_SECTION_DATA
6922 case IR_SECTION_CODE
6925 case IR_SECTION_DIRECTIVE
6928 case IR_SECTION_INFO
6929 ostr += FB_INFOSEC_NAME
6931 case IR_SECTION_CONSTRUCTOR
6933 if( priority > 0 )
then
6934 ostr +=
"." +
right(
"00000" +
str( 65535 - priority ), 5 )
6936 if( env.clopt.target = FB_COMPTARGET_LINUX )
then
6937 ostr +=
", " + QUOTE +
"aw" + QUOTE +
", @progbits"
6940 case IR_SECTION_DESTRUCTOR
6942 if( priority > 0 )
then
6943 ostr +=
"." +
right(
"00000" +
str( 65535 - priority ), 5 )
6945 if( env.clopt.target = FB_COMPTARGET_LINUX )
then
6946 ostr +=
", " + QUOTE +
"aw" + QUOTE +
", @progbits"
6951 function =
strptr( ostr )
6953 emit.lastsection = section
6954 emit.lastpriority = priority
6968 static as EMIT_VTBL _vtbl = _
6997 if( env.clopt.fputype >= FB_FPUTYPE_SSE )
then