cg386add.pas 89 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923
  1. {
  2. $Id$
  3. Copyright (c) 1993-98 by Florian Klaempfl
  4. Generate i386 assembler for in add node
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************
  17. }
  18. unit cg386add;
  19. interface
  20. {$define usecreateset}
  21. uses
  22. tree;
  23. procedure secondadd(var p : ptree);
  24. implementation
  25. uses
  26. globtype,systems,
  27. cobjects,verbose,globals,
  28. symtable,aasm,types,
  29. hcodegen,temp_gen,pass_2,
  30. i386,cgai386,tgeni386;
  31. {*****************************************************************************
  32. Helpers
  33. *****************************************************************************}
  34. function getresflags(p : ptree;unsigned : boolean) : tresflags;
  35. begin
  36. if not(unsigned) then
  37. begin
  38. if p^.swaped then
  39. case p^.treetype of
  40. equaln : getresflags:=F_E;
  41. unequaln : getresflags:=F_NE;
  42. ltn : getresflags:=F_G;
  43. lten : getresflags:=F_GE;
  44. gtn : getresflags:=F_L;
  45. gten : getresflags:=F_LE;
  46. end
  47. else
  48. case p^.treetype of
  49. equaln : getresflags:=F_E;
  50. unequaln : getresflags:=F_NE;
  51. ltn : getresflags:=F_L;
  52. lten : getresflags:=F_LE;
  53. gtn : getresflags:=F_G;
  54. gten : getresflags:=F_GE;
  55. end;
  56. end
  57. else
  58. begin
  59. if p^.swaped then
  60. case p^.treetype of
  61. equaln : getresflags:=F_E;
  62. unequaln : getresflags:=F_NE;
  63. ltn : getresflags:=F_A;
  64. lten : getresflags:=F_AE;
  65. gtn : getresflags:=F_B;
  66. gten : getresflags:=F_BE;
  67. end
  68. else
  69. case p^.treetype of
  70. equaln : getresflags:=F_E;
  71. unequaln : getresflags:=F_NE;
  72. ltn : getresflags:=F_B;
  73. lten : getresflags:=F_BE;
  74. gtn : getresflags:=F_A;
  75. gten : getresflags:=F_AE;
  76. end;
  77. end;
  78. end;
  79. procedure SetResultLocation(cmpop,unsigned:boolean;var p :ptree);
  80. begin
  81. { remove temporary location if not a set or string }
  82. { that's a bad hack (FK) who did this ? }
  83. if (p^.left^.resulttype^.deftype<>stringdef) and
  84. ((p^.left^.resulttype^.deftype<>setdef) or (psetdef(p^.left^.resulttype)^.settype=smallset)) and
  85. (p^.left^.location.loc in [LOC_MEM,LOC_REFERENCE]) then
  86. ungetiftemp(p^.left^.location.reference);
  87. if (p^.right^.resulttype^.deftype<>stringdef) and
  88. ((p^.right^.resulttype^.deftype<>setdef) or (psetdef(p^.right^.resulttype)^.settype=smallset)) and
  89. (p^.right^.location.loc in [LOC_MEM,LOC_REFERENCE]) then
  90. ungetiftemp(p^.right^.location.reference);
  91. { in case of comparison operation the put result in the flags }
  92. if cmpop then
  93. begin
  94. clear_location(p^.location);
  95. p^.location.loc:=LOC_FLAGS;
  96. p^.location.resflags:=getresflags(p,unsigned);
  97. end;
  98. end;
  99. {*****************************************************************************
  100. Addstring
  101. *****************************************************************************}
  102. procedure addstring(var p : ptree);
  103. var
  104. pushedregs : tpushed;
  105. href : treference;
  106. pushed,
  107. cmpop : boolean;
  108. savedunused : tregisterset;
  109. hr : treference;
  110. oldrl : plinkedlist;
  111. begin
  112. { string operations are not commutative }
  113. if p^.swaped then
  114. swaptree(p);
  115. case pstringdef(p^.left^.resulttype)^.string_typ of
  116. st_ansistring:
  117. begin
  118. case p^.treetype of
  119. addn:
  120. begin
  121. oldrl:=temptoremove;
  122. temptoremove:=new(plinkedlist,init);
  123. cmpop:=false;
  124. secondpass(p^.left);
  125. pushed:=maybe_push(p^.right^.registers32,p);
  126. secondpass(p^.right);
  127. if pushed then restore(p);
  128. { release used registers }
  129. case p^.right^.location.loc of
  130. LOC_REFERENCE,LOC_MEM:
  131. del_reference(p^.right^.location.reference);
  132. LOC_REGISTER,LOC_CREGISTER:
  133. ungetregister32(p^.right^.location.register);
  134. end;
  135. case p^.left^.location.loc of
  136. LOC_REFERENCE,LOC_MEM:
  137. del_reference(p^.left^.location.reference);
  138. LOC_REGISTER,LOC_CREGISTER:
  139. ungetregister32(p^.left^.location.register);
  140. end;
  141. savedunused:=unused;
  142. { push the still used registers }
  143. pushusedregisters(pushedregs,$ff);
  144. { push data }
  145. emit_push_loc(p^.right^.location);
  146. emit_push_loc(p^.left^.location);
  147. emitcall('FPC_ANSISTR_CONCAT',true);
  148. unused:=savedunused;
  149. clear_location(p^.location);
  150. p^.location.register:=getexplicitregister32(R_EAX);
  151. p^.location.loc:=LOC_REGISTER;
  152. emit_reg_reg(A_MOV,S_L,R_EAX,p^.location.register);
  153. { unused:=unused-[R_EAX]; }
  154. removetemps(exprasmlist,temptoremove);
  155. dispose(temptoremove,done);
  156. temptoremove:=oldrl;
  157. { unused:=unused+[R_EAX]; }
  158. popusedregisters(pushedregs);
  159. maybe_loadesi;
  160. ungetiftemp(p^.left^.location.reference);
  161. ungetiftemp(p^.right^.location.reference);
  162. reset_reference(hr);
  163. gettempansistringreference(hr);
  164. addtemptodestroy(p^.resulttype,hr);
  165. exprasmlist^.concat(new(pai386,op_reg_ref(A_MOV,S_L,p^.location.register,
  166. newreference(hr))));
  167. end;
  168. ltn,lten,gtn,gten,
  169. equaln,unequaln:
  170. begin
  171. oldrl:=temptoremove;
  172. temptoremove:=new(plinkedlist,init);
  173. secondpass(p^.left);
  174. pushed:=maybe_push(p^.right^.registers32,p);
  175. secondpass(p^.right);
  176. if pushed then restore(p);
  177. { release used registers }
  178. case p^.right^.location.loc of
  179. LOC_REFERENCE,LOC_MEM:
  180. del_reference(p^.right^.location.reference);
  181. LOC_REGISTER,LOC_CREGISTER:
  182. ungetregister32(p^.right^.location.register);
  183. end;
  184. case p^.left^.location.loc of
  185. LOC_REFERENCE,LOC_MEM:
  186. del_reference(p^.left^.location.reference);
  187. LOC_REGISTER,LOC_CREGISTER:
  188. ungetregister32(p^.left^.location.register);
  189. end;
  190. { push the still used registers }
  191. pushusedregisters(pushedregs,$ff);
  192. { push data }
  193. case p^.right^.location.loc of
  194. LOC_REFERENCE,LOC_MEM:
  195. emit_push_mem(p^.right^.location.reference);
  196. LOC_REGISTER,LOC_CREGISTER:
  197. exprasmlist^.concat(new(pai386,op_reg(A_PUSH,S_L,p^.right^.location.register)));
  198. end;
  199. case p^.left^.location.loc of
  200. LOC_REFERENCE,LOC_MEM:
  201. emit_push_mem(p^.left^.location.reference);
  202. LOC_REGISTER,LOC_CREGISTER:
  203. exprasmlist^.concat(new(pai386,op_reg(A_PUSH,S_L,p^.left^.location.register)));
  204. end;
  205. emitcall('FPC_ANSISTR_COMPARE',true);
  206. unused:=unused-[R_EAX];
  207. removetemps(exprasmlist,temptoremove);
  208. dispose(temptoremove,done);
  209. temptoremove:=oldrl;
  210. unused:=unused+[R_EAX];
  211. emit_reg_reg(A_OR,S_L,R_EAX,R_EAX);
  212. popusedregisters(pushedregs);
  213. maybe_loadesi;
  214. ungetiftemp(p^.left^.location.reference);
  215. ungetiftemp(p^.right^.location.reference);
  216. end;
  217. end;
  218. { the result of ansicompare is signed }
  219. SetResultLocation(cmpop,false,p);
  220. end;
  221. st_shortstring:
  222. begin
  223. case p^.treetype of
  224. addn:
  225. begin
  226. cmpop:=false;
  227. secondpass(p^.left);
  228. { if str_concat is set in expr
  229. s:=s+ ... no need to create a temp string (PM) }
  230. if (p^.left^.treetype<>addn) and not (p^.use_strconcat) then
  231. begin
  232. { can only reference be }
  233. { string in register would be funny }
  234. { therefore produce a temporary string }
  235. { release the registers }
  236. del_reference(p^.left^.location.reference);
  237. gettempofsizereference(256,href);
  238. copyshortstring(href,p^.left^.location.reference,255,false);
  239. ungetiftemp(p^.left^.location.reference);
  240. { does not hurt: }
  241. clear_location(p^.left^.location);
  242. p^.left^.location.loc:=LOC_MEM;
  243. p^.left^.location.reference:=href;
  244. end;
  245. secondpass(p^.right);
  246. { on the right we do not need the register anymore too }
  247. del_reference(p^.right^.location.reference);
  248. pushusedregisters(pushedregs,$ff);
  249. emitpushreferenceaddr(exprasmlist,p^.left^.location.reference);
  250. emitpushreferenceaddr(exprasmlist,p^.right^.location.reference);
  251. emitcall('FPC_SHORTSTR_CONCAT',true);
  252. maybe_loadesi;
  253. popusedregisters(pushedregs);
  254. set_location(p^.location,p^.left^.location);
  255. ungetiftemp(p^.right^.location.reference);
  256. end;
  257. ltn,lten,gtn,gten,
  258. equaln,unequaln :
  259. begin
  260. cmpop:=true;
  261. { generate better code for s='' and s<>'' }
  262. if (p^.treetype in [equaln,unequaln]) and
  263. (((p^.left^.treetype=stringconstn) and (str_length(p^.left)=0)) or
  264. ((p^.right^.treetype=stringconstn) and (str_length(p^.right)=0))) then
  265. begin
  266. secondpass(p^.left);
  267. { are too few registers free? }
  268. pushed:=maybe_push(p^.right^.registers32,p);
  269. secondpass(p^.right);
  270. if pushed then restore(p);
  271. del_reference(p^.right^.location.reference);
  272. del_reference(p^.left^.location.reference);
  273. { only one node can be stringconstn }
  274. { else pass 1 would have evaluted }
  275. { this node }
  276. if p^.left^.treetype=stringconstn then
  277. exprasmlist^.concat(new(pai386,op_const_ref(
  278. A_CMP,S_B,0,newreference(p^.right^.location.reference))))
  279. else
  280. exprasmlist^.concat(new(pai386,op_const_ref(
  281. A_CMP,S_B,0,newreference(p^.left^.location.reference))));
  282. end
  283. else
  284. begin
  285. pushusedregisters(pushedregs,$ff);
  286. secondpass(p^.left);
  287. del_reference(p^.left^.location.reference);
  288. emitpushreferenceaddr(exprasmlist,p^.left^.location.reference);
  289. secondpass(p^.right);
  290. del_reference(p^.right^.location.reference);
  291. emitpushreferenceaddr(exprasmlist,p^.right^.location.reference);
  292. emitcall('FPC_SHORTSTR_COMPARE',true);
  293. maybe_loadesi;
  294. popusedregisters(pushedregs);
  295. end;
  296. ungetiftemp(p^.left^.location.reference);
  297. ungetiftemp(p^.right^.location.reference);
  298. end;
  299. else CGMessage(type_e_mismatch);
  300. end;
  301. SetResultLocation(cmpop,true,p);
  302. end;
  303. end;
  304. end;
  305. {*****************************************************************************
  306. Addset
  307. *****************************************************************************}
  308. procedure addset(var p : ptree);
  309. var
  310. createset,
  311. cmpop,
  312. pushed : boolean;
  313. href : treference;
  314. pushedregs : tpushed;
  315. begin
  316. cmpop:=false;
  317. { not commutative }
  318. if p^.swaped then
  319. swaptree(p);
  320. { optimize first loading of a set }
  321. {$ifdef usecreateset}
  322. if (p^.right^.treetype=setelementn) and
  323. is_emptyset(p^.left) then
  324. createset:=true
  325. else
  326. {$endif}
  327. begin
  328. createset:=false;
  329. secondpass(p^.left);
  330. end;
  331. { are too few registers free? }
  332. pushed:=maybe_push(p^.right^.registers32,p);
  333. secondpass(p^.right);
  334. if codegenerror then
  335. exit;
  336. if pushed then
  337. restore(p);
  338. set_location(p^.location,p^.left^.location);
  339. { handle operations }
  340. case p^.treetype of
  341. equaln,
  342. unequaln
  343. {$IfNDef NoSetInclusion}
  344. ,lten, gten
  345. {$EndIf NoSetInclusion}
  346. : begin
  347. cmpop:=true;
  348. del_reference(p^.left^.location.reference);
  349. del_reference(p^.right^.location.reference);
  350. pushusedregisters(pushedregs,$ff);
  351. {$IfNDef NoSetInclusion}
  352. If (p^.treetype in [equaln, unequaln, lten]) Then
  353. Begin
  354. {$EndIf NoSetInclusion}
  355. emitpushreferenceaddr(exprasmlist,p^.right^.location.reference);
  356. emitpushreferenceaddr(exprasmlist,p^.left^.location.reference);
  357. {$IfNDef NoSetInclusion}
  358. End
  359. Else {gten = lten, if the arguments are reversed}
  360. Begin
  361. emitpushreferenceaddr(exprasmlist,p^.left^.location.reference);
  362. emitpushreferenceaddr(exprasmlist,p^.right^.location.reference);
  363. End;
  364. Case p^.treetype of
  365. equaln, unequaln:
  366. {$EndIf NoSetInclusion}
  367. emitcall('FPC_SET_COMP_SETS',true);
  368. {$IfNDef NoSetInclusion}
  369. lten, gten: emitcall('FPC_SET_CONTAINS_SETS',true)
  370. End;
  371. {$EndIf NoSetInclusion}
  372. maybe_loadesi;
  373. popusedregisters(pushedregs);
  374. ungetiftemp(p^.left^.location.reference);
  375. ungetiftemp(p^.right^.location.reference);
  376. end;
  377. addn : begin
  378. { add can be an other SET or Range or Element ! }
  379. del_reference(p^.left^.location.reference);
  380. del_reference(p^.right^.location.reference);
  381. pushusedregisters(pushedregs,$ff);
  382. href.symbol:=nil;
  383. gettempofsizereference(32,href);
  384. if createset then
  385. begin
  386. pushsetelement(p^.right^.left);
  387. emitpushreferenceaddr(exprasmlist,href);
  388. emitcall('FPC_SET_CREATE_ELEMENT',true);
  389. end
  390. else
  391. begin
  392. { add a range or a single element? }
  393. if p^.right^.treetype=setelementn then
  394. begin
  395. concatcopy(p^.left^.location.reference,href,32,false,false);
  396. if assigned(p^.right^.right) then
  397. begin
  398. pushsetelement(p^.right^.right);
  399. pushsetelement(p^.right^.left);
  400. emitpushreferenceaddr(exprasmlist,href);
  401. emitcall('FPC_SET_SET_RANGE',true);
  402. end
  403. else
  404. begin
  405. pushsetelement(p^.right^.left);
  406. emitpushreferenceaddr(exprasmlist,href);
  407. emitcall('FPC_SET_SET_BYTE',true);
  408. end;
  409. end
  410. else
  411. begin
  412. { must be an other set }
  413. emitpushreferenceaddr(exprasmlist,href);
  414. emitpushreferenceaddr(exprasmlist,p^.right^.location.reference);
  415. emitpushreferenceaddr(exprasmlist,p^.left^.location.reference);
  416. emitcall('FPC_SET_ADD_SETS',true);
  417. end;
  418. end;
  419. maybe_loadesi;
  420. popusedregisters(pushedregs);
  421. ungetiftemp(p^.left^.location.reference);
  422. ungetiftemp(p^.right^.location.reference);
  423. p^.location.loc:=LOC_MEM;
  424. stringdispose(p^.location.reference.symbol);
  425. p^.location.reference:=href;
  426. end;
  427. subn,
  428. symdifn,
  429. muln : begin
  430. del_reference(p^.left^.location.reference);
  431. del_reference(p^.right^.location.reference);
  432. href.symbol:=nil;
  433. pushusedregisters(pushedregs,$ff);
  434. gettempofsizereference(32,href);
  435. emitpushreferenceaddr(exprasmlist,href);
  436. emitpushreferenceaddr(exprasmlist,p^.right^.location.reference);
  437. emitpushreferenceaddr(exprasmlist,p^.left^.location.reference);
  438. case p^.treetype of
  439. subn : emitcall('FPC_SET_SUB_SETS',true);
  440. symdifn : emitcall('FPC_SET_SYMDIF_SETS',true);
  441. muln : emitcall('FPC_SET_MUL_SETS',true);
  442. end;
  443. maybe_loadesi;
  444. popusedregisters(pushedregs);
  445. ungetiftemp(p^.left^.location.reference);
  446. ungetiftemp(p^.right^.location.reference);
  447. p^.location.loc:=LOC_MEM;
  448. stringdispose(p^.location.reference.symbol);
  449. p^.location.reference:=href;
  450. end;
  451. else
  452. CGMessage(type_e_mismatch);
  453. end;
  454. SetResultLocation(cmpop,true,p);
  455. end;
  456. {*****************************************************************************
  457. SecondAdd
  458. *****************************************************************************}
  459. procedure secondadd(var p : ptree);
  460. { is also being used for xor, and "mul", "sub, or and comparative }
  461. { operators }
  462. label do_normal;
  463. var
  464. hregister,hregister2 : tregister;
  465. noswap,popeax,popedx,
  466. pushed,mboverflow,cmpop : boolean;
  467. op,op2 : tasmop;
  468. flags : tresflags;
  469. otl,ofl : plabel;
  470. power : longint;
  471. opsize : topsize;
  472. hl4: plabel;
  473. hr : preference;
  474. { true, if unsigned types are compared }
  475. unsigned : boolean;
  476. { true, if a small set is handled with the longint code }
  477. is_set : boolean;
  478. { is_in_dest if the result is put directly into }
  479. { the resulting refernce or varregister }
  480. is_in_dest : boolean;
  481. { true, if for sets subtractions the extra not should generated }
  482. extra_not : boolean;
  483. {$ifdef SUPPORT_MMX}
  484. mmxbase : tmmxtype;
  485. {$endif SUPPORT_MMX}
  486. pushedreg : tpushed;
  487. begin
  488. { to make it more readable, string and set (not smallset!) have their
  489. own procedures }
  490. case p^.left^.resulttype^.deftype of
  491. stringdef : begin
  492. addstring(p);
  493. exit;
  494. end;
  495. setdef : begin
  496. { normalsets are handled separate }
  497. if not(psetdef(p^.left^.resulttype)^.settype=smallset) then
  498. begin
  499. addset(p);
  500. exit;
  501. end;
  502. end;
  503. end;
  504. { defaults }
  505. unsigned:=false;
  506. is_in_dest:=false;
  507. extra_not:=false;
  508. noswap:=false;
  509. opsize:=S_L;
  510. { are we a (small)set, must be set here because the side can be
  511. swapped ! (PFV) }
  512. is_set:=(p^.left^.resulttype^.deftype=setdef);
  513. { calculate the operator which is more difficult }
  514. firstcomplex(p);
  515. { handling boolean expressions extra: }
  516. if ((p^.left^.resulttype^.deftype=orddef) and
  517. (porddef(p^.left^.resulttype)^.typ in [bool8bit,bool16bit,bool32bit])) or
  518. ((p^.right^.resulttype^.deftype=orddef) and
  519. (porddef(p^.right^.resulttype)^.typ in [bool8bit,bool16bit,bool32bit])) then
  520. begin
  521. if (porddef(p^.left^.resulttype)^.typ=bool8bit) or
  522. (porddef(p^.right^.resulttype)^.typ=bool8bit) then
  523. opsize:=S_B
  524. else
  525. if (porddef(p^.left^.resulttype)^.typ=bool16bit) or
  526. (porddef(p^.right^.resulttype)^.typ=bool16bit) then
  527. opsize:=S_W
  528. else
  529. opsize:=S_L;
  530. case p^.treetype of
  531. andn,
  532. orn : begin
  533. clear_location(p^.location);
  534. p^.location.loc:=LOC_JUMP;
  535. cmpop:=false;
  536. case p^.treetype of
  537. andn : begin
  538. otl:=truelabel;
  539. getlabel(truelabel);
  540. secondpass(p^.left);
  541. maketojumpbool(p^.left);
  542. emitl(A_LABEL,truelabel);
  543. truelabel:=otl;
  544. end;
  545. orn : begin
  546. ofl:=falselabel;
  547. getlabel(falselabel);
  548. secondpass(p^.left);
  549. maketojumpbool(p^.left);
  550. emitl(A_LABEL,falselabel);
  551. falselabel:=ofl;
  552. end;
  553. else
  554. CGMessage(type_e_mismatch);
  555. end;
  556. secondpass(p^.right);
  557. maketojumpbool(p^.right);
  558. end;
  559. unequaln,
  560. equaln,xorn : begin
  561. if p^.left^.treetype=ordconstn then
  562. swaptree(p);
  563. secondpass(p^.left);
  564. set_location(p^.location,p^.left^.location);
  565. {p^.location:=p^.left^.location;
  566. created a bug !!! PM
  567. because symbol was used twice }
  568. { are enough registers free ? }
  569. pushed:=maybe_push(p^.right^.registers32,p);
  570. secondpass(p^.right);
  571. if pushed then restore(p);
  572. goto do_normal;
  573. end
  574. else
  575. CGMessage(type_e_mismatch);
  576. end
  577. end
  578. else
  579. begin
  580. { in case of constant put it to the left }
  581. if (p^.left^.treetype=ordconstn) then
  582. swaptree(p);
  583. secondpass(p^.left);
  584. { this will be complicated as
  585. a lot of code below assumes that
  586. p^.location and p^.left^.location are the same }
  587. {$ifdef test_dest_loc}
  588. if dest_loc_known and (dest_loc_tree=p) and
  589. ((dest_loc.loc=LOC_REGISTER) or (dest_loc.loc=LOC_CREGISTER)) then
  590. begin
  591. set_location(p^.location,dest_loc);
  592. in_dest_loc:=true;
  593. is_in_dest:=true;
  594. end
  595. else
  596. {$endif test_dest_loc}
  597. set_location(p^.location,p^.left^.location);
  598. { are too few registers free? }
  599. pushed:=maybe_push(p^.right^.registers32,p);
  600. secondpass(p^.right);
  601. if pushed then
  602. restore(p);
  603. if (p^.left^.resulttype^.deftype=pointerdef) or
  604. (p^.right^.resulttype^.deftype=pointerdef) or
  605. ((p^.right^.resulttype^.deftype=objectdef) and
  606. pobjectdef(p^.right^.resulttype)^.isclass and
  607. (p^.left^.resulttype^.deftype=objectdef) and
  608. pobjectdef(p^.left^.resulttype)^.isclass
  609. ) or
  610. (p^.left^.resulttype^.deftype=classrefdef) or
  611. (p^.left^.resulttype^.deftype=procvardef) or
  612. (p^.left^.resulttype^.deftype=enumdef) or
  613. ((p^.left^.resulttype^.deftype=orddef) and
  614. (porddef(p^.left^.resulttype)^.typ=s32bit)) or
  615. ((p^.right^.resulttype^.deftype=orddef) and
  616. (porddef(p^.right^.resulttype)^.typ=s32bit)) or
  617. ((p^.left^.resulttype^.deftype=orddef) and
  618. (porddef(p^.left^.resulttype)^.typ=u32bit)) or
  619. ((p^.right^.resulttype^.deftype=orddef) and
  620. (porddef(p^.right^.resulttype)^.typ=u32bit)) or
  621. { as well as small sets }
  622. is_set then
  623. begin
  624. do_normal:
  625. mboverflow:=false;
  626. cmpop:=false;
  627. if (p^.left^.resulttype^.deftype=pointerdef) or
  628. (p^.right^.resulttype^.deftype=pointerdef) or
  629. ((p^.left^.resulttype^.deftype=orddef) and
  630. (porddef(p^.left^.resulttype)^.typ=u32bit)) or
  631. ((p^.right^.resulttype^.deftype=orddef) and
  632. (porddef(p^.right^.resulttype)^.typ=u32bit)) then
  633. unsigned:=true;
  634. case p^.treetype of
  635. addn : begin
  636. if is_set then
  637. begin
  638. { adding elements is not commutative }
  639. if p^.swaped and (p^.left^.treetype=setelementn) then
  640. swaptree(p);
  641. { are we adding set elements ? }
  642. if p^.right^.treetype=setelementn then
  643. begin
  644. { no range support for smallsets! }
  645. if assigned(p^.right^.right) then
  646. internalerror(43244);
  647. { bts requires both elements to be registers }
  648. if p^.left^.location.loc in [LOC_MEM,LOC_REFERENCE] then
  649. begin
  650. ungetiftemp(p^.left^.location.reference);
  651. del_reference(p^.left^.location.reference);
  652. hregister:=getregister32;
  653. exprasmlist^.concat(new(pai386,op_ref_reg(A_MOV,opsize,
  654. newreference(p^.left^.location.reference),hregister)));
  655. clear_location(p^.left^.location);
  656. p^.left^.location.loc:=LOC_REGISTER;
  657. p^.left^.location.register:=hregister;
  658. set_location(p^.location,p^.left^.location);
  659. end;
  660. if p^.right^.location.loc in [LOC_MEM,LOC_REFERENCE] then
  661. begin
  662. ungetiftemp(p^.right^.location.reference);
  663. del_reference(p^.right^.location.reference);
  664. hregister:=getregister32;
  665. exprasmlist^.concat(new(pai386,op_ref_reg(A_MOV,opsize,
  666. newreference(p^.right^.location.reference),hregister)));
  667. clear_location(p^.right^.location);
  668. p^.right^.location.loc:=LOC_REGISTER;
  669. p^.right^.location.register:=hregister;
  670. end;
  671. op:=A_BTS;
  672. noswap:=true;
  673. end
  674. else
  675. op:=A_OR;
  676. mboverflow:=false;
  677. unsigned:=false;
  678. end
  679. else
  680. begin
  681. op:=A_ADD;
  682. mboverflow:=true;
  683. end;
  684. end;
  685. symdifn : begin
  686. { the symetric diff is only for sets }
  687. if is_set then
  688. begin
  689. op:=A_XOR;
  690. mboverflow:=false;
  691. unsigned:=false;
  692. end
  693. else
  694. CGMessage(type_e_mismatch);
  695. end;
  696. muln : begin
  697. if is_set then
  698. begin
  699. op:=A_AND;
  700. mboverflow:=false;
  701. unsigned:=false;
  702. end
  703. else
  704. begin
  705. if unsigned then
  706. op:=A_MUL
  707. else
  708. op:=A_IMUL;
  709. mboverflow:=true;
  710. end;
  711. end;
  712. subn : begin
  713. if is_set then
  714. begin
  715. op:=A_AND;
  716. mboverflow:=false;
  717. unsigned:=false;
  718. extra_not:=true;
  719. end
  720. else
  721. begin
  722. op:=A_SUB;
  723. mboverflow:=true;
  724. end;
  725. end;
  726. ltn,lten,
  727. gtn,gten,
  728. equaln,unequaln : begin
  729. op:=A_CMP;
  730. cmpop:=true;
  731. end;
  732. xorn : op:=A_XOR;
  733. orn : op:=A_OR;
  734. andn : op:=A_AND;
  735. else
  736. CGMessage(type_e_mismatch);
  737. end;
  738. { filter MUL, which requires special handling }
  739. if op=A_MUL then
  740. begin
  741. popeax:=false;
  742. popedx:=false;
  743. { here you need to free the symbol first }
  744. clear_location(p^.location);
  745. p^.location.register:=getregister32;
  746. p^.location.loc:=LOC_REGISTER;
  747. if not(R_EAX in unused) and (p^.location.register<>R_EAX) then
  748. begin
  749. exprasmlist^.concat(new(pai386,op_reg(A_PUSH,S_L,R_EAX)));
  750. popeax:=true;
  751. end;
  752. if not(R_EDX in unused) and (p^.location.register<>R_EDX) then
  753. begin
  754. exprasmlist^.concat(new(pai386,op_reg(A_PUSH,S_L,R_EDX)));
  755. popedx:=true;
  756. end;
  757. emitloadord2reg(p^.left^.location,u32bitdef,R_EDI,true);
  758. emitloadord2reg(p^.right^.location,u32bitdef,R_EAX,true);
  759. exprasmlist^.concat(new(pai386,op_reg(A_MUL,S_L,R_EDI)));
  760. emit_reg_reg(A_MOV,S_L,R_EAX,p^.location.register);
  761. if popedx then
  762. exprasmlist^.concat(new(pai386,op_reg(A_POP,S_L,R_EDX)));
  763. if popeax then
  764. exprasmlist^.concat(new(pai386,op_reg(A_POP,S_L,R_EAX)));
  765. SetResultLocation(false,true,p);
  766. exit;
  767. end;
  768. { left and right no register? }
  769. { then one must be demanded }
  770. if (p^.left^.location.loc<>LOC_REGISTER) and
  771. (p^.right^.location.loc<>LOC_REGISTER) then
  772. begin
  773. { register variable ? }
  774. if (p^.left^.location.loc=LOC_CREGISTER) then
  775. begin
  776. { it is OK if this is the destination }
  777. if is_in_dest then
  778. begin
  779. hregister:=p^.location.register;
  780. emit_reg_reg(A_MOV,opsize,p^.left^.location.register,
  781. hregister);
  782. end
  783. else
  784. if cmpop then
  785. begin
  786. { do not disturb the register }
  787. hregister:=p^.location.register;
  788. end
  789. else
  790. begin
  791. case opsize of
  792. S_L : hregister:=getregister32;
  793. S_B : hregister:=reg32toreg8(getregister32);
  794. end;
  795. emit_reg_reg(A_MOV,opsize,p^.left^.location.register,
  796. hregister);
  797. end
  798. end
  799. else
  800. begin
  801. ungetiftemp(p^.left^.location.reference);
  802. del_reference(p^.left^.location.reference);
  803. if is_in_dest then
  804. begin
  805. hregister:=p^.location.register;
  806. exprasmlist^.concat(new(pai386,op_ref_reg(A_MOV,opsize,
  807. newreference(p^.left^.location.reference),hregister)));
  808. end
  809. else
  810. begin
  811. { first give free, then demand new register }
  812. case opsize of
  813. S_L : hregister:=getregister32;
  814. S_W : hregister:=reg32toreg16(getregister32);
  815. S_B : hregister:=reg32toreg8(getregister32);
  816. end;
  817. exprasmlist^.concat(new(pai386,op_ref_reg(A_MOV,opsize,
  818. newreference(p^.left^.location.reference),hregister)));
  819. end;
  820. end;
  821. clear_location(p^.location);
  822. p^.location.loc:=LOC_REGISTER;
  823. p^.location.register:=hregister;
  824. end
  825. else
  826. { if on the right the register then swap }
  827. if not(noswap) and (p^.right^.location.loc=LOC_REGISTER) then
  828. begin
  829. swap_location(p^.location,p^.right^.location);
  830. { newly swapped also set swapped flag }
  831. p^.swaped:=not(p^.swaped);
  832. end;
  833. { at this point, p^.location.loc should be LOC_REGISTER }
  834. { and p^.location.register should be a valid register }
  835. { containing the left result }
  836. if p^.right^.location.loc<>LOC_REGISTER then
  837. begin
  838. if (p^.treetype=subn) and p^.swaped then
  839. begin
  840. if p^.right^.location.loc=LOC_CREGISTER then
  841. begin
  842. if extra_not then
  843. exprasmlist^.concat(new(pai386,op_reg(A_NOT,opsize,p^.location.register)));
  844. emit_reg_reg(A_MOV,opsize,p^.right^.location.register,R_EDI);
  845. emit_reg_reg(op,opsize,p^.location.register,R_EDI);
  846. emit_reg_reg(A_MOV,opsize,R_EDI,p^.location.register);
  847. end
  848. else
  849. begin
  850. if extra_not then
  851. exprasmlist^.concat(new(pai386,op_reg(A_NOT,opsize,p^.location.register)));
  852. exprasmlist^.concat(new(pai386,op_ref_reg(A_MOV,opsize,
  853. newreference(p^.right^.location.reference),R_EDI)));
  854. exprasmlist^.concat(new(pai386,op_reg_reg(op,opsize,p^.location.register,R_EDI)));
  855. exprasmlist^.concat(new(pai386,op_reg_reg(A_MOV,opsize,R_EDI,p^.location.register)));
  856. ungetiftemp(p^.right^.location.reference);
  857. del_reference(p^.right^.location.reference);
  858. end;
  859. end
  860. else
  861. begin
  862. if (p^.right^.treetype=ordconstn) and
  863. (op=A_CMP) and
  864. (p^.right^.value=0) then
  865. begin
  866. exprasmlist^.concat(new(pai386,op_reg_reg(A_TEST,opsize,p^.location.register,
  867. p^.location.register)));
  868. end
  869. else if (p^.right^.treetype=ordconstn) and
  870. (op=A_ADD) and
  871. (p^.right^.value=1) and
  872. not(cs_check_overflow in aktlocalswitches) then
  873. begin
  874. exprasmlist^.concat(new(pai386,op_reg(A_INC,opsize,
  875. p^.location.register)));
  876. end
  877. else if (p^.right^.treetype=ordconstn) and
  878. (op=A_SUB) and
  879. (p^.right^.value=1) and
  880. not(cs_check_overflow in aktlocalswitches) then
  881. begin
  882. exprasmlist^.concat(new(pai386,op_reg(A_DEC,opsize,
  883. p^.location.register)));
  884. end
  885. else if (p^.right^.treetype=ordconstn) and
  886. (op=A_IMUL) and
  887. (ispowerof2(p^.right^.value,power)) and
  888. not(cs_check_overflow in aktlocalswitches) then
  889. begin
  890. exprasmlist^.concat(new(pai386,op_const_reg(A_SHL,opsize,power,
  891. p^.location.register)));
  892. end
  893. else
  894. begin
  895. if (p^.right^.location.loc=LOC_CREGISTER) then
  896. begin
  897. if extra_not then
  898. begin
  899. emit_reg_reg(A_MOV,S_L,p^.right^.location.register,R_EDI);
  900. exprasmlist^.concat(new(pai386,op_reg(A_NOT,S_L,R_EDI)));
  901. emit_reg_reg(A_AND,S_L,R_EDI,
  902. p^.location.register);
  903. end
  904. else
  905. begin
  906. emit_reg_reg(op,opsize,p^.right^.location.register,
  907. p^.location.register);
  908. end;
  909. end
  910. else
  911. begin
  912. if extra_not then
  913. begin
  914. exprasmlist^.concat(new(pai386,op_ref_reg(A_MOV,S_L,newreference(
  915. p^.right^.location.reference),R_EDI)));
  916. exprasmlist^.concat(new(pai386,op_reg(A_NOT,S_L,R_EDI)));
  917. emit_reg_reg(A_AND,S_L,R_EDI,
  918. p^.location.register);
  919. end
  920. else
  921. begin
  922. exprasmlist^.concat(new(pai386,op_ref_reg(op,opsize,newreference(
  923. p^.right^.location.reference),p^.location.register)));
  924. end;
  925. ungetiftemp(p^.right^.location.reference);
  926. del_reference(p^.right^.location.reference);
  927. end;
  928. end;
  929. end;
  930. end
  931. else
  932. begin
  933. { when swapped another result register }
  934. if (p^.treetype=subn) and p^.swaped then
  935. begin
  936. if extra_not then
  937. exprasmlist^.concat(new(pai386,op_reg(A_NOT,S_L,p^.location.register)));
  938. exprasmlist^.concat(new(pai386,op_reg_reg(op,opsize,
  939. p^.location.register,p^.right^.location.register)));
  940. swap_location(p^.location,p^.right^.location);
  941. { newly swapped also set swapped flag }
  942. { just to maintain ordering }
  943. p^.swaped:=not(p^.swaped);
  944. end
  945. else
  946. begin
  947. if extra_not then
  948. exprasmlist^.concat(new(pai386,op_reg(A_NOT,S_L,p^.right^.location.register)));
  949. exprasmlist^.concat(new(pai386,op_reg_reg(op,opsize,
  950. p^.right^.location.register,
  951. p^.location.register)));
  952. end;
  953. case opsize of
  954. S_L : ungetregister32(p^.right^.location.register);
  955. S_B : ungetregister32(reg8toreg32(p^.right^.location.register));
  956. end;
  957. end;
  958. if cmpop then
  959. case opsize of
  960. S_L : ungetregister32(p^.location.register);
  961. S_B : ungetregister32(reg8toreg32(p^.location.register));
  962. end;
  963. { only in case of overflow operations }
  964. { produce overflow code }
  965. { we must put it here directly, because sign of operation }
  966. { is in unsigned VAR!! }
  967. if mboverflow then
  968. begin
  969. if cs_check_overflow in aktlocalswitches then
  970. begin
  971. getlabel(hl4);
  972. if unsigned then
  973. emitl(A_JNB,hl4)
  974. else
  975. emitl(A_JNO,hl4);
  976. emitcall('FPC_OVERFLOW',true);
  977. emitl(A_LABEL,hl4);
  978. end;
  979. end;
  980. end
  981. else
  982. { Char type }
  983. if ((p^.left^.resulttype^.deftype=orddef) and
  984. (porddef(p^.left^.resulttype)^.typ=uchar)) then
  985. begin
  986. case p^.treetype of
  987. ltn,lten,gtn,gten,
  988. equaln,unequaln :
  989. cmpop:=true;
  990. else CGMessage(type_e_mismatch);
  991. end;
  992. unsigned:=true;
  993. { left and right no register? }
  994. { the one must be demanded }
  995. if (p^.location.loc<>LOC_REGISTER) and
  996. (p^.right^.location.loc<>LOC_REGISTER) then
  997. begin
  998. if p^.location.loc=LOC_CREGISTER then
  999. begin
  1000. if cmpop then
  1001. { do not disturb register }
  1002. hregister:=p^.location.register
  1003. else
  1004. begin
  1005. hregister:=reg32toreg8(getregister32);
  1006. emit_reg_reg(A_MOV,S_B,p^.location.register,
  1007. hregister);
  1008. end;
  1009. end
  1010. else
  1011. begin
  1012. del_reference(p^.location.reference);
  1013. { first give free then demand new register }
  1014. hregister:=reg32toreg8(getregister32);
  1015. exprasmlist^.concat(new(pai386,op_ref_reg(A_MOV,S_B,newreference(p^.location.reference),
  1016. hregister)));
  1017. end;
  1018. clear_location(p^.location);
  1019. p^.location.loc:=LOC_REGISTER;
  1020. p^.location.register:=hregister;
  1021. end;
  1022. { now p always a register }
  1023. if (p^.right^.location.loc=LOC_REGISTER) and
  1024. (p^.location.loc<>LOC_REGISTER) then
  1025. begin
  1026. swap_location(p^.location,p^.right^.location);
  1027. { newly swapped also set swapped flag }
  1028. p^.swaped:=not(p^.swaped);
  1029. end;
  1030. if p^.right^.location.loc<>LOC_REGISTER then
  1031. begin
  1032. if p^.right^.location.loc=LOC_CREGISTER then
  1033. begin
  1034. emit_reg_reg(A_CMP,S_B,
  1035. p^.right^.location.register,p^.location.register);
  1036. end
  1037. else
  1038. begin
  1039. exprasmlist^.concat(new(pai386,op_ref_reg(A_CMP,S_B,newreference(
  1040. p^.right^.location.reference),p^.location.register)));
  1041. del_reference(p^.right^.location.reference);
  1042. end;
  1043. end
  1044. else
  1045. begin
  1046. emit_reg_reg(A_CMP,S_B,p^.right^.location.register,
  1047. p^.location.register);
  1048. ungetregister32(reg8toreg32(p^.right^.location.register));
  1049. end;
  1050. ungetregister32(reg8toreg32(p^.location.register));
  1051. end
  1052. else
  1053. { 64 bit types }
  1054. if is_64bitint(p^.left^.resulttype) then
  1055. begin
  1056. mboverflow:=false;
  1057. cmpop:=false;
  1058. unsigned:=((p^.left^.resulttype^.deftype=orddef) and
  1059. (porddef(p^.left^.resulttype)^.typ=u64bit)) or
  1060. ((p^.right^.resulttype^.deftype=orddef) and
  1061. (porddef(p^.right^.resulttype)^.typ=u64bit));
  1062. case p^.treetype of
  1063. addn : begin
  1064. begin
  1065. op:=A_ADD;
  1066. op2:=A_ADC;
  1067. mboverflow:=true;
  1068. end;
  1069. end;
  1070. subn : begin
  1071. op:=A_SUB;
  1072. op2:=A_SBB;
  1073. mboverflow:=true;
  1074. end;
  1075. ltn,lten,
  1076. gtn,gten,
  1077. equaln,unequaln:
  1078. begin
  1079. op:=A_CMP;
  1080. op2:=A_CMP;
  1081. cmpop:=true;
  1082. end;
  1083. xorn:
  1084. begin
  1085. op:=A_XOR;
  1086. op2:=A_XOR;
  1087. end;
  1088. orn:
  1089. begin
  1090. op:=A_OR;
  1091. op2:=A_OR;
  1092. end;
  1093. andn:
  1094. begin
  1095. op:=A_AND;
  1096. op2:=A_AND;
  1097. end;
  1098. muln:
  1099. ;
  1100. else
  1101. CGMessage(type_e_mismatch);
  1102. end;
  1103. if p^.treetype=muln then
  1104. begin
  1105. release_qword_loc(p^.left^.location);
  1106. release_qword_loc(p^.right^.location);
  1107. p^.location.registerlow:=getexplicitregister32(R_EAX);
  1108. p^.location.registerhigh:=getexplicitregister32(R_EDX);
  1109. pushusedregisters(pushedreg,$ff
  1110. and not($80 shr byte(p^.location.registerlow))
  1111. and not($80 shr byte(p^.location.registerhigh)));
  1112. if cs_check_overflow in aktlocalswitches then
  1113. push_int(1)
  1114. else
  1115. push_int(0);
  1116. emit_pushq_loc(p^.left^.location);
  1117. emit_pushq_loc(p^.right^.location);
  1118. if porddef(p^.resulttype)^.typ=u64bit then
  1119. emitcall('FPC_MUL_QWORD',true)
  1120. else
  1121. emitcall('FPC_MUL_INT64',true);
  1122. emit_reg_reg(A_MOV,S_L,R_EAX,p^.location.registerlow);
  1123. emit_reg_reg(A_MOV,S_L,R_EDX,p^.location.registerhigh);
  1124. popusedregisters(pushedreg);
  1125. p^.location.loc:=LOC_REGISTER;
  1126. end
  1127. else
  1128. begin
  1129. { left and right no register? }
  1130. { then one must be demanded }
  1131. if (p^.left^.location.loc<>LOC_REGISTER) and
  1132. (p^.right^.location.loc<>LOC_REGISTER) then
  1133. begin
  1134. { register variable ? }
  1135. if (p^.left^.location.loc=LOC_CREGISTER) then
  1136. begin
  1137. { it is OK if this is the destination }
  1138. if is_in_dest then
  1139. begin
  1140. hregister:=p^.location.registerlow;
  1141. hregister2:=p^.location.registerhigh;
  1142. emit_reg_reg(A_MOV,S_L,p^.left^.location.registerlow,
  1143. hregister);
  1144. emit_reg_reg(A_MOV,S_L,p^.left^.location.registerlow,
  1145. hregister2);
  1146. end
  1147. else
  1148. if cmpop then
  1149. begin
  1150. { do not disturb the register }
  1151. hregister:=p^.location.registerlow;
  1152. hregister2:=p^.location.registerhigh;
  1153. end
  1154. else
  1155. begin
  1156. hregister:=getregister32;
  1157. hregister2:=getregister32;
  1158. emit_reg_reg(A_MOV,S_L,p^.left^.location.registerlow,
  1159. hregister);
  1160. emit_reg_reg(A_MOV,S_L,p^.left^.location.registerhigh,
  1161. hregister2);
  1162. end
  1163. end
  1164. else
  1165. begin
  1166. ungetiftemp(p^.left^.location.reference);
  1167. del_reference(p^.left^.location.reference);
  1168. if is_in_dest then
  1169. begin
  1170. hregister:=p^.location.registerlow;
  1171. hregister2:=p^.location.registerhigh;
  1172. exprasmlist^.concat(new(pai386,op_ref_reg(A_MOV,S_L,
  1173. newreference(p^.left^.location.reference),hregister)));
  1174. hr:=newreference(p^.left^.location.reference);
  1175. inc(hr^.offset,4);
  1176. exprasmlist^.concat(new(pai386,op_ref_reg(A_MOV,S_L,
  1177. hr,hregister2)));
  1178. end
  1179. else
  1180. begin
  1181. hregister:=getregister32;
  1182. hregister2:=getregister32;
  1183. exprasmlist^.concat(new(pai386,op_ref_reg(A_MOV,S_L,
  1184. newreference(p^.left^.location.reference),hregister)));
  1185. hr:=newreference(p^.left^.location.reference);
  1186. inc(hr^.offset,4);
  1187. exprasmlist^.concat(new(pai386,op_ref_reg(A_MOV,S_L,
  1188. hr,hregister2)));
  1189. end;
  1190. end;
  1191. clear_location(p^.location);
  1192. p^.location.loc:=LOC_REGISTER;
  1193. p^.location.registerlow:=hregister;
  1194. p^.location.registerhigh:=hregister2;
  1195. end
  1196. else
  1197. { if on the right the register then swap }
  1198. if not(noswap) and (p^.right^.location.loc=LOC_REGISTER) then
  1199. begin
  1200. swap_location(p^.location,p^.right^.location);
  1201. { newly swapped also set swapped flag }
  1202. p^.swaped:=not(p^.swaped);
  1203. end;
  1204. { at this point, p^.location.loc should be LOC_REGISTER }
  1205. { and p^.location.register should be a valid register }
  1206. { containing the left result }
  1207. if p^.right^.location.loc<>LOC_REGISTER then
  1208. begin
  1209. if (p^.treetype=subn) and p^.swaped then
  1210. begin
  1211. if p^.right^.location.loc=LOC_CREGISTER then
  1212. begin
  1213. emit_reg_reg(A_MOV,opsize,p^.right^.location.register,R_EDI);
  1214. emit_reg_reg(op,opsize,p^.location.register,R_EDI);
  1215. emit_reg_reg(A_MOV,opsize,R_EDI,p^.location.register);
  1216. end
  1217. else
  1218. begin
  1219. exprasmlist^.concat(new(pai386,op_ref_reg(A_MOV,opsize,
  1220. newreference(p^.right^.location.reference),R_EDI)));
  1221. exprasmlist^.concat(new(pai386,op_reg_reg(op,opsize,p^.location.register,R_EDI)));
  1222. exprasmlist^.concat(new(pai386,op_reg_reg(A_MOV,opsize,R_EDI,p^.location.register)));
  1223. ungetiftemp(p^.right^.location.reference);
  1224. del_reference(p^.right^.location.reference);
  1225. end;
  1226. end
  1227. else if cmpop then
  1228. begin
  1229. if (p^.right^.location.loc=LOC_CREGISTER) then
  1230. begin
  1231. emit_reg_reg(A_CMP,S_L,p^.right^.location.registerhigh,
  1232. p^.location.registerhigh);
  1233. emitl(flag_2_jmp[getresflags(p,unsigned)],truelabel);
  1234. emit_reg_reg(A_CMP,S_L,p^.right^.location.registerlow,
  1235. p^.location.registerlow);
  1236. emitl(flag_2_jmp[getresflags(p,unsigned)],truelabel);
  1237. emitl(A_JMP,falselabel);
  1238. end
  1239. else
  1240. begin
  1241. hr:=newreference(p^.right^.location.reference);
  1242. inc(hr^.offset,4);
  1243. exprasmlist^.concat(new(pai386,op_ref_reg(A_CMP,S_L,
  1244. hr,p^.location.registerhigh)));
  1245. emitl(flag_2_jmp[getresflags(p,unsigned)],truelabel);
  1246. exprasmlist^.concat(new(pai386,op_ref_reg(A_CMP,S_L,newreference(
  1247. p^.right^.location.reference),p^.location.registerlow)));
  1248. emitl(flag_2_jmp[getresflags(p,unsigned)],truelabel);
  1249. emitl(A_JMP,falselabel);
  1250. ungetiftemp(p^.right^.location.reference);
  1251. del_reference(p^.right^.location.reference);
  1252. end;
  1253. end
  1254. else
  1255. begin
  1256. {
  1257. if (p^.right^.treetype=ordconstn) and
  1258. (op=A_CMP) and
  1259. (p^.right^.value=0) then
  1260. begin
  1261. exprasmlist^.concat(new(pai386,op_reg_reg(A_TEST,opsize,p^.location.register,
  1262. p^.location.register)));
  1263. end
  1264. else if (p^.right^.treetype=ordconstn) and
  1265. (op=A_IMUL) and
  1266. (ispowerof2(p^.right^.value,power)) then
  1267. begin
  1268. exprasmlist^.concat(new(pai386,op_const_reg(A_SHL,opsize,power,
  1269. p^.location.register)));
  1270. end
  1271. else
  1272. }
  1273. begin
  1274. if (p^.right^.location.loc=LOC_CREGISTER) then
  1275. begin
  1276. emit_reg_reg(op,S_L,p^.right^.location.registerlow,
  1277. p^.location.registerlow);
  1278. emit_reg_reg(op2,S_L,p^.right^.location.registerhigh,
  1279. p^.location.registerhigh);
  1280. end
  1281. else
  1282. begin
  1283. exprasmlist^.concat(new(pai386,op_ref_reg(op,S_L,newreference(
  1284. p^.right^.location.reference),p^.location.registerlow)));
  1285. hr:=newreference(p^.right^.location.reference);
  1286. inc(hr^.offset,4);
  1287. exprasmlist^.concat(new(pai386,op_ref_reg(op2,S_L,
  1288. hr,p^.location.registerhigh)));
  1289. ungetiftemp(p^.right^.location.reference);
  1290. del_reference(p^.right^.location.reference);
  1291. end;
  1292. end;
  1293. end;
  1294. end
  1295. else
  1296. begin
  1297. { when swapped another result register }
  1298. if (p^.treetype=subn) and p^.swaped then
  1299. begin
  1300. exprasmlist^.concat(new(pai386,op_reg_reg(op,opsize,
  1301. p^.location.register,p^.right^.location.register)));
  1302. swap_location(p^.location,p^.right^.location);
  1303. { newly swapped also set swapped flag }
  1304. { just to maintain ordering }
  1305. p^.swaped:=not(p^.swaped);
  1306. end
  1307. else if cmpop then
  1308. begin
  1309. exprasmlist^.concat(new(pai386,op_reg_reg(A_CMP,S_L,
  1310. p^.right^.location.registerhigh,
  1311. p^.location.registerhigh)));
  1312. emitl(flag_2_jmp[getresflags(p,unsigned)],truelabel);
  1313. exprasmlist^.concat(new(pai386,op_reg_reg(A_CMP,S_L,
  1314. p^.right^.location.registerlow,
  1315. p^.location.registerlow)));
  1316. emitl(flag_2_jmp[getresflags(p,unsigned)],truelabel);
  1317. emitl(A_JMP,falselabel);
  1318. end
  1319. else
  1320. begin
  1321. exprasmlist^.concat(new(pai386,op_reg_reg(op,S_L,
  1322. p^.right^.location.registerlow,
  1323. p^.location.registerlow)));
  1324. exprasmlist^.concat(new(pai386,op_reg_reg(op2,S_L,
  1325. p^.right^.location.registerhigh,
  1326. p^.location.registerhigh)));
  1327. end;
  1328. ungetregister32(p^.right^.location.registerlow);
  1329. ungetregister32(p^.right^.location.registerhigh);
  1330. end;
  1331. if cmpop then
  1332. begin
  1333. ungetregister32(p^.location.registerlow);
  1334. ungetregister32(p^.location.registerhigh);
  1335. end;
  1336. { only in case of overflow operations }
  1337. { produce overflow code }
  1338. { we must put it here directly, because sign of operation }
  1339. { is in unsigned VAR!! }
  1340. if mboverflow then
  1341. begin
  1342. if cs_check_overflow in aktlocalswitches then
  1343. begin
  1344. getlabel(hl4);
  1345. if unsigned then
  1346. emitl(A_JNB,hl4)
  1347. else
  1348. emitl(A_JNO,hl4);
  1349. emitcall('FPC_OVERFLOW',true);
  1350. emitl(A_LABEL,hl4);
  1351. end;
  1352. end;
  1353. { we have LOC_JUMP as result }
  1354. if cmpop then
  1355. begin
  1356. clear_location(p^.location);
  1357. p^.location.loc:=LOC_JUMP;
  1358. cmpop:=false;
  1359. end;
  1360. end;
  1361. end
  1362. else
  1363. { Floating point }
  1364. if (p^.left^.resulttype^.deftype=floatdef) and
  1365. (pfloatdef(p^.left^.resulttype)^.typ<>f32bit) then
  1366. begin
  1367. { real constants to the left }
  1368. if p^.left^.treetype=realconstn then
  1369. swaptree(p);
  1370. cmpop:=false;
  1371. case p^.treetype of
  1372. addn : op:=A_FADDP;
  1373. muln : op:=A_FMULP;
  1374. subn : op:=A_FSUBP;
  1375. slashn : op:=A_FDIVP;
  1376. ltn,lten,gtn,gten,
  1377. equaln,unequaln : begin
  1378. op:=A_FCOMPP;
  1379. cmpop:=true;
  1380. end;
  1381. else CGMessage(type_e_mismatch);
  1382. end;
  1383. if (p^.right^.location.loc<>LOC_FPU) then
  1384. begin
  1385. floatload(pfloatdef(p^.right^.resulttype)^.typ,p^.right^.location.reference);
  1386. if (p^.left^.location.loc<>LOC_FPU) then
  1387. floatload(pfloatdef(p^.left^.resulttype)^.typ,p^.left^.location.reference)
  1388. { left was on the stack => swap }
  1389. else
  1390. p^.swaped:=not(p^.swaped);
  1391. { releases the right reference }
  1392. del_reference(p^.right^.location.reference);
  1393. end
  1394. { the nominator in st0 }
  1395. else if (p^.left^.location.loc<>LOC_FPU) then
  1396. floatload(pfloatdef(p^.left^.resulttype)^.typ,p^.left^.location.reference)
  1397. { fpu operands are always in the wrong order on the stack }
  1398. else
  1399. p^.swaped:=not(p^.swaped);
  1400. { releases the left reference }
  1401. if (p^.left^.location.loc<>LOC_FPU) then
  1402. del_reference(p^.left^.location.reference);
  1403. { if we swaped the tree nodes, then use the reverse operator }
  1404. if p^.swaped then
  1405. begin
  1406. if (p^.treetype=slashn) then
  1407. op:=A_FDIVRP
  1408. else if (p^.treetype=subn) then
  1409. op:=A_FSUBRP;
  1410. end;
  1411. { to avoid the pentium bug
  1412. if (op=FDIVP) and (opt_processors=pentium) then
  1413. exprasmlist^.concat(new(pai386,op_CALL,S_NO,'EMUL_FDIVP')
  1414. else
  1415. }
  1416. { the Intel assemblers want operands }
  1417. if op<>A_FCOMPP then
  1418. exprasmlist^.concat(new(pai386,op_reg_reg(op,S_NO,R_ST,R_ST1)))
  1419. else
  1420. exprasmlist^.concat(new(pai386,op_none(op,S_NO)));
  1421. { on comparison load flags }
  1422. if cmpop then
  1423. begin
  1424. if not(R_EAX in unused) then
  1425. emit_reg_reg(A_MOV,S_L,R_EAX,R_EDI);
  1426. exprasmlist^.concat(new(pai386,op_reg(A_FNSTSW,S_NO,R_AX)));
  1427. exprasmlist^.concat(new(pai386,op_none(A_SAHF,S_NO)));
  1428. if not(R_EAX in unused) then
  1429. emit_reg_reg(A_MOV,S_L,R_EDI,R_EAX);
  1430. if p^.swaped then
  1431. begin
  1432. case p^.treetype of
  1433. equaln : flags:=F_E;
  1434. unequaln : flags:=F_NE;
  1435. ltn : flags:=F_A;
  1436. lten : flags:=F_AE;
  1437. gtn : flags:=F_B;
  1438. gten : flags:=F_BE;
  1439. end;
  1440. end
  1441. else
  1442. begin
  1443. case p^.treetype of
  1444. equaln : flags:=F_E;
  1445. unequaln : flags:=F_NE;
  1446. ltn : flags:=F_B;
  1447. lten : flags:=F_BE;
  1448. gtn : flags:=F_A;
  1449. gten : flags:=F_AE;
  1450. end;
  1451. end;
  1452. clear_location(p^.location);
  1453. p^.location.loc:=LOC_FLAGS;
  1454. p^.location.resflags:=flags;
  1455. cmpop:=false;
  1456. end
  1457. else
  1458. begin
  1459. clear_location(p^.location);
  1460. p^.location.loc:=LOC_FPU;
  1461. end;
  1462. end
  1463. {$ifdef SUPPORT_MMX}
  1464. else
  1465. { MMX Arrays }
  1466. if is_mmx_able_array(p^.left^.resulttype) then
  1467. begin
  1468. cmpop:=false;
  1469. mmxbase:=mmx_type(p^.left^.resulttype);
  1470. case p^.treetype of
  1471. addn : begin
  1472. if (cs_mmx_saturation in aktlocalswitches) then
  1473. begin
  1474. case mmxbase of
  1475. mmxs8bit:
  1476. op:=A_PADDSB;
  1477. mmxu8bit:
  1478. op:=A_PADDUSB;
  1479. mmxs16bit,mmxfixed16:
  1480. op:=A_PADDSB;
  1481. mmxu16bit:
  1482. op:=A_PADDUSW;
  1483. end;
  1484. end
  1485. else
  1486. begin
  1487. case mmxbase of
  1488. mmxs8bit,mmxu8bit:
  1489. op:=A_PADDB;
  1490. mmxs16bit,mmxu16bit,mmxfixed16:
  1491. op:=A_PADDW;
  1492. mmxs32bit,mmxu32bit:
  1493. op:=A_PADDD;
  1494. end;
  1495. end;
  1496. end;
  1497. muln : begin
  1498. case mmxbase of
  1499. mmxs16bit,mmxu16bit:
  1500. op:=A_PMULLW;
  1501. mmxfixed16:
  1502. op:=A_PMULHW;
  1503. end;
  1504. end;
  1505. subn : begin
  1506. if (cs_mmx_saturation in aktlocalswitches) then
  1507. begin
  1508. case mmxbase of
  1509. mmxs8bit:
  1510. op:=A_PSUBSB;
  1511. mmxu8bit:
  1512. op:=A_PSUBUSB;
  1513. mmxs16bit,mmxfixed16:
  1514. op:=A_PSUBSB;
  1515. mmxu16bit:
  1516. op:=A_PSUBUSW;
  1517. end;
  1518. end
  1519. else
  1520. begin
  1521. case mmxbase of
  1522. mmxs8bit,mmxu8bit:
  1523. op:=A_PSUBB;
  1524. mmxs16bit,mmxu16bit,mmxfixed16:
  1525. op:=A_PSUBW;
  1526. mmxs32bit,mmxu32bit:
  1527. op:=A_PSUBD;
  1528. end;
  1529. end;
  1530. end;
  1531. {
  1532. ltn,lten,gtn,gten,
  1533. equaln,unequaln :
  1534. begin
  1535. op:=A_CMP;
  1536. cmpop:=true;
  1537. end;
  1538. }
  1539. xorn:
  1540. op:=A_PXOR;
  1541. orn:
  1542. op:=A_POR;
  1543. andn:
  1544. op:=A_PAND;
  1545. else CGMessage(type_e_mismatch);
  1546. end;
  1547. { left and right no register? }
  1548. { then one must be demanded }
  1549. if (p^.left^.location.loc<>LOC_MMXREGISTER) and
  1550. (p^.right^.location.loc<>LOC_MMXREGISTER) then
  1551. begin
  1552. { register variable ? }
  1553. if (p^.left^.location.loc=LOC_CMMXREGISTER) then
  1554. begin
  1555. { it is OK if this is the destination }
  1556. if is_in_dest then
  1557. begin
  1558. hregister:=p^.location.register;
  1559. emit_reg_reg(A_MOVQ,S_NO,p^.left^.location.register,
  1560. hregister);
  1561. end
  1562. else
  1563. begin
  1564. hregister:=getregistermmx;
  1565. emit_reg_reg(A_MOVQ,S_NO,p^.left^.location.register,
  1566. hregister);
  1567. end
  1568. end
  1569. else
  1570. begin
  1571. del_reference(p^.left^.location.reference);
  1572. if is_in_dest then
  1573. begin
  1574. hregister:=p^.location.register;
  1575. exprasmlist^.concat(new(pai386,op_ref_reg(A_MOVQ,S_NO,
  1576. newreference(p^.left^.location.reference),hregister)));
  1577. end
  1578. else
  1579. begin
  1580. hregister:=getregistermmx;
  1581. exprasmlist^.concat(new(pai386,op_ref_reg(A_MOVQ,S_NO,
  1582. newreference(p^.left^.location.reference),hregister)));
  1583. end;
  1584. end;
  1585. clear_location(p^.location);
  1586. p^.location.loc:=LOC_MMXREGISTER;
  1587. p^.location.register:=hregister;
  1588. end
  1589. else
  1590. { if on the right the register then swap }
  1591. if (p^.right^.location.loc=LOC_MMXREGISTER) then
  1592. begin
  1593. swap_location(p^.location,p^.right^.location);
  1594. { newly swapped also set swapped flag }
  1595. p^.swaped:=not(p^.swaped);
  1596. end;
  1597. { at this point, p^.location.loc should be LOC_MMXREGISTER }
  1598. { and p^.location.register should be a valid register }
  1599. { containing the left result }
  1600. if p^.right^.location.loc<>LOC_MMXREGISTER then
  1601. begin
  1602. if (p^.treetype=subn) and p^.swaped then
  1603. begin
  1604. if p^.right^.location.loc=LOC_CMMXREGISTER then
  1605. begin
  1606. emit_reg_reg(A_MOVQ,S_NO,p^.right^.location.register,R_MM7);
  1607. emit_reg_reg(op,S_NO,p^.location.register,R_EDI);
  1608. emit_reg_reg(A_MOVQ,S_NO,R_MM7,p^.location.register);
  1609. end
  1610. else
  1611. begin
  1612. exprasmlist^.concat(new(pai386,op_ref_reg(A_MOVQ,S_NO,
  1613. newreference(p^.right^.location.reference),R_MM7)));
  1614. exprasmlist^.concat(new(pai386,op_reg_reg(op,S_NO,p^.location.register,
  1615. R_MM7)));
  1616. exprasmlist^.concat(new(pai386,op_reg_reg(A_MOVQ,S_NO,
  1617. R_MM7,p^.location.register)));
  1618. del_reference(p^.right^.location.reference);
  1619. end;
  1620. end
  1621. else
  1622. begin
  1623. if (p^.right^.location.loc=LOC_CREGISTER) then
  1624. begin
  1625. emit_reg_reg(op,S_NO,p^.right^.location.register,
  1626. p^.location.register);
  1627. end
  1628. else
  1629. begin
  1630. exprasmlist^.concat(new(pai386,op_ref_reg(op,S_NO,newreference(
  1631. p^.right^.location.reference),p^.location.register)));
  1632. del_reference(p^.right^.location.reference);
  1633. end;
  1634. end;
  1635. end
  1636. else
  1637. begin
  1638. { when swapped another result register }
  1639. if (p^.treetype=subn) and p^.swaped then
  1640. begin
  1641. exprasmlist^.concat(new(pai386,op_reg_reg(op,S_NO,
  1642. p^.location.register,p^.right^.location.register)));
  1643. swap_location(p^.location,p^.right^.location);
  1644. { newly swapped also set swapped flag }
  1645. { just to maintain ordering }
  1646. p^.swaped:=not(p^.swaped);
  1647. end
  1648. else
  1649. begin
  1650. exprasmlist^.concat(new(pai386,op_reg_reg(op,S_NO,
  1651. p^.right^.location.register,
  1652. p^.location.register)));
  1653. end;
  1654. ungetregistermmx(p^.right^.location.register);
  1655. end;
  1656. end
  1657. {$endif SUPPORT_MMX}
  1658. else CGMessage(type_e_mismatch);
  1659. end;
  1660. SetResultLocation(cmpop,unsigned,p);
  1661. end;
  1662. end.
  1663. {
  1664. $Log$
  1665. Revision 1.40 1999-01-20 17:39:22 jonas
  1666. + fixed bug0163 (set1 <= set2 support)
  1667. Revision 1.39 1999/01/19 10:18:58 florian
  1668. * bug with mul. of dwords fixed, reported by Alexander Stohr
  1669. * some changes to compile with TP
  1670. + small enhancements for the new code generator
  1671. Revision 1.38 1999/01/05 17:03:36 jonas
  1672. * don't output inc/dec if cs_check_overflow is on, because inc/dec don't change
  1673. the carry flag
  1674. Revision 1.37 1998/12/22 13:10:56 florian
  1675. * memory leaks for ansistring type casts fixed
  1676. Revision 1.36 1998/12/19 00:23:40 florian
  1677. * ansistring memory leaks fixed
  1678. Revision 1.35 1998/12/11 23:36:06 florian
  1679. + again more stuff for int64/qword:
  1680. - comparision operators
  1681. - code generation for: str, read(ln), write(ln)
  1682. Revision 1.34 1998/12/11 00:02:46 peter
  1683. + globtype,tokens,version unit splitted from globals
  1684. Revision 1.33 1998/12/10 11:16:00 florian
  1685. + some basic operations with qwords and int64 added: +, xor, and, or;
  1686. the register allocation works fine
  1687. Revision 1.32 1998/12/10 09:47:13 florian
  1688. + basic operations with int64/qord (compiler with -dint64)
  1689. + rtti of enumerations extended: names are now written
  1690. Revision 1.31 1998/11/30 09:42:59 pierre
  1691. * some range check bugs fixed (still not working !)
  1692. + added DLL writing support for win32 (also accepts variables)
  1693. + TempAnsi for code that could be used for Temporary ansi strings
  1694. handling
  1695. Revision 1.30 1998/11/24 12:52:40 peter
  1696. * sets are not written twice anymore
  1697. * optimize for emptyset+single element which uses a new routine from
  1698. set.inc FPC_SET_CREATE_ELEMENT
  1699. Revision 1.29 1998/11/18 15:44:05 peter
  1700. * VALUEPARA for tp7 compatible value parameters
  1701. Revision 1.28 1998/11/18 09:18:01 pierre
  1702. + automatic loading of profile unit with -pg option
  1703. in go32v2 mode (also defines FPC_PROFILE)
  1704. * some memory leaks removed
  1705. * unreleased temp problem with sets solved
  1706. Revision 1.27 1998/11/17 00:36:38 peter
  1707. * more ansistring fixes
  1708. Revision 1.26 1998/11/16 16:17:16 peter
  1709. * fixed ansistring temp which forgot a reset
  1710. Revision 1.25 1998/11/16 15:35:35 peter
  1711. * rename laod/copystring -> load/copyshortstring
  1712. * fixed int-bool cnv bug
  1713. + char-ansistring conversion
  1714. Revision 1.24 1998/11/07 12:49:30 peter
  1715. * fixed ansicompare which returns signed
  1716. Revision 1.23 1998/10/29 15:42:43 florian
  1717. + partial disposing of temp. ansistrings
  1718. Revision 1.22 1998/10/28 18:26:12 pierre
  1719. * removed some erros after other errors (introduced by useexcept)
  1720. * stabs works again correctly (for how long !)
  1721. Revision 1.21 1998/10/25 23:32:48 peter
  1722. * fixed unsigned mul
  1723. Revision 1.20 1998/10/21 08:39:56 florian
  1724. + ansistring operator +
  1725. + $h and string[n] for n>255 added
  1726. * small problem with TP fixed
  1727. Revision 1.19 1998/10/20 15:09:21 florian
  1728. + binary operators for ansi strings
  1729. Revision 1.18 1998/10/20 08:06:38 pierre
  1730. * several memory corruptions due to double freemem solved
  1731. => never use p^.loc.location:=p^.left^.loc.location;
  1732. + finally I added now by default
  1733. that ra386dir translates global and unit symbols
  1734. + added a first field in tsymtable and
  1735. a nextsym field in tsym
  1736. (this allows to obtain ordered type info for
  1737. records and objects in gdb !)
  1738. Revision 1.17 1998/10/09 11:47:45 pierre
  1739. * still more memory leaks fixes !!
  1740. Revision 1.16 1998/10/09 08:56:21 pierre
  1741. * several memory leaks fixed
  1742. Revision 1.15 1998/10/08 17:17:10 pierre
  1743. * current_module old scanner tagged as invalid if unit is recompiled
  1744. + added ppheap for better info on tracegetmem of heaptrc
  1745. (adds line column and file index)
  1746. * several memory leaks removed ith help of heaptrc !!
  1747. Revision 1.14 1998/09/28 16:57:13 pierre
  1748. * changed all length(p^.value_str^) into str_length(p)
  1749. to get it work with and without ansistrings
  1750. * changed sourcefiles field of tmodule to a pointer
  1751. Revision 1.13 1998/09/17 09:42:09 peter
  1752. + pass_2 for cg386
  1753. * Message() -> CGMessage() for pass_1/pass_2
  1754. Revision 1.12 1998/09/14 10:43:44 peter
  1755. * all internal RTL functions start with FPC_
  1756. Revision 1.11 1998/09/07 18:45:52 peter
  1757. * update smartlinking, uses getdatalabel
  1758. * renamed ptree.value vars to value_str,value_real,value_set
  1759. Revision 1.10 1998/09/04 10:05:04 florian
  1760. * ugly fix for STRCAT, nevertheless it needs more fixing !!!!!!!
  1761. we need an new version of STRCAT which takes a length parameter
  1762. Revision 1.9 1998/09/04 08:41:36 peter
  1763. * updated some error CGMessages
  1764. Revision 1.8 1998/08/28 10:54:18 peter
  1765. * fixed smallset generation from elements, it has never worked before!
  1766. Revision 1.7 1998/08/19 14:56:59 peter
  1767. * forgot to removed some unused code in addset for set<>set
  1768. Revision 1.6 1998/08/18 09:24:35 pierre
  1769. * small warning position bug fixed
  1770. * support_mmx switches splitting was missing
  1771. * rhide error and warning output corrected
  1772. Revision 1.5 1998/08/14 18:18:37 peter
  1773. + dynamic set contruction
  1774. * smallsets are now working (always longint size)
  1775. Revision 1.4 1998/08/10 14:49:42 peter
  1776. + localswitches, moduleswitches, globalswitches splitting
  1777. Revision 1.3 1998/06/25 08:48:04 florian
  1778. * first version of rtti support
  1779. Revision 1.2 1998/06/08 13:13:28 pierre
  1780. + temporary variables now in temp_gen.pas unit
  1781. because it is processor independent
  1782. * mppc68k.bat modified to undefine i386 and support_mmx
  1783. (which are defaults for i386)
  1784. Revision 1.1 1998/06/05 17:44:10 peter
  1785. * splitted cgi386
  1786. }