cg386add.pas 87 KB

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