cgx86.pas 59 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl
  4. This unit implements the common parts of the code generator for the i386 and the x86-64.
  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. { This unit implements the common parts of the code generator for the i386 and the x86-64.
  19. }
  20. unit cgx86;
  21. {$i fpcdefs.inc}
  22. interface
  23. uses
  24. globtype,
  25. cgbase,cgutils,cgobj,
  26. aasmbase,aasmtai,aasmcpu,
  27. cpubase,cpuinfo,rgobj,rgx86,rgcpu,
  28. symconst,symtype;
  29. type
  30. tcgx86 = class(tcg)
  31. rgfpu : Trgx86fpu;
  32. procedure done_register_allocators;override;
  33. function getfpuregister(list:Taasmoutput;size:Tcgsize):Tregister;override;
  34. function getmmxregister(list:Taasmoutput):Tregister;
  35. procedure getcpuregister(list:Taasmoutput;r:Tregister);override;
  36. procedure ungetcpuregister(list:Taasmoutput;r:Tregister);override;
  37. procedure alloccpuregisters(list:Taasmoutput;rt:Tregistertype;r:Tcpuregisterset);override;
  38. procedure dealloccpuregisters(list:Taasmoutput;rt:Tregistertype;r:Tcpuregisterset);override;
  39. function uses_registers(rt:Tregistertype):boolean;override;
  40. procedure add_reg_instruction(instr:Tai;r:tregister);override;
  41. procedure dec_fpu_stack;
  42. procedure inc_fpu_stack;
  43. procedure a_call_name(list : taasmoutput;const s : string);override;
  44. procedure a_call_reg(list : taasmoutput;reg : tregister);override;
  45. procedure a_op_const_reg(list : taasmoutput; Op: TOpCG; size: TCGSize; a: aint; reg: TRegister); override;
  46. procedure a_op_const_ref(list : taasmoutput; Op: TOpCG; size: TCGSize; a: aint; const ref: TReference); override;
  47. procedure a_op_reg_reg(list : taasmoutput; Op: TOpCG; size: TCGSize; src, dst: TRegister); override;
  48. procedure a_op_ref_reg(list : taasmoutput; Op: TOpCG; size: TCGSize; const ref: TReference; reg: TRegister); override;
  49. procedure a_op_reg_ref(list : taasmoutput; Op: TOpCG; size: TCGSize;reg: TRegister; const ref: TReference); override;
  50. procedure a_op_const_reg_reg(list: taasmoutput; op: TOpCg;
  51. size: tcgsize; a: aint; src, dst: tregister); override;
  52. procedure a_op_reg_reg_reg(list: taasmoutput; op: TOpCg;
  53. size: tcgsize; src1, src2, dst: tregister); override;
  54. { move instructions }
  55. procedure a_load_const_reg(list : taasmoutput; tosize: tcgsize; a : aint;reg : tregister);override;
  56. procedure a_load_const_ref(list : taasmoutput; tosize: tcgsize; a : aint;const ref : treference);override;
  57. procedure a_load_reg_ref(list : taasmoutput;fromsize,tosize: tcgsize; reg : tregister;const ref : treference);override;
  58. procedure a_load_ref_reg(list : taasmoutput;fromsize,tosize: tcgsize;const ref : treference;reg : tregister);override;
  59. procedure a_load_reg_reg(list : taasmoutput;fromsize,tosize: tcgsize;reg1,reg2 : tregister);override;
  60. procedure a_loadaddr_ref_reg(list : taasmoutput;const ref : treference;r : tregister);override;
  61. { fpu move instructions }
  62. procedure a_loadfpu_reg_reg(list: taasmoutput; size: tcgsize; reg1, reg2: tregister); override;
  63. procedure a_loadfpu_ref_reg(list: taasmoutput; size: tcgsize; const ref: treference; reg: tregister); override;
  64. procedure a_loadfpu_reg_ref(list: taasmoutput; size: tcgsize; reg: tregister; const ref: treference); override;
  65. { vector register move instructions }
  66. procedure a_loadmm_reg_reg(list: taasmoutput; fromsize, tosize : tcgsize;reg1, reg2: tregister;shuffle : pmmshuffle); override;
  67. procedure a_loadmm_ref_reg(list: taasmoutput; fromsize, tosize : tcgsize;const ref: treference; reg: tregister;shuffle : pmmshuffle); override;
  68. procedure a_loadmm_reg_ref(list: taasmoutput; fromsize, tosize : tcgsize;reg: tregister; const ref: treference;shuffle : pmmshuffle); override;
  69. procedure a_opmm_ref_reg(list: taasmoutput; Op: TOpCG; size : tcgsize;const ref: treference; reg: tregister;shuffle : pmmshuffle); override;
  70. procedure a_opmm_reg_reg(list: taasmoutput; Op: TOpCG; size : tcgsize;src,dst: tregister;shuffle : pmmshuffle);override;
  71. { comparison operations }
  72. procedure a_cmp_const_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;a : aint;reg : tregister;
  73. l : tasmlabel);override;
  74. procedure a_cmp_const_ref_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;a : aint;const ref : treference;
  75. l : tasmlabel);override;
  76. procedure a_cmp_reg_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;reg1,reg2 : tregister;l : tasmlabel); override;
  77. procedure a_cmp_ref_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;const ref: treference; reg : tregister; l : tasmlabel); override;
  78. procedure a_cmp_reg_ref_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;reg : tregister; const ref: treference; l : tasmlabel); override;
  79. procedure a_jmp_name(list : taasmoutput;const s : string);override;
  80. procedure a_jmp_always(list : taasmoutput;l: tasmlabel); override;
  81. procedure a_jmp_flags(list : taasmoutput;const f : TResFlags;l: tasmlabel); override;
  82. procedure g_flags2reg(list: taasmoutput; size: TCgSize; const f: tresflags; reg: TRegister); override;
  83. procedure g_flags2ref(list: taasmoutput; size: TCgSize; const f: tresflags; const ref: TReference); override;
  84. procedure g_concatcopy(list : taasmoutput;const source,dest : treference;len : aint);override;
  85. { entry/exit code helpers }
  86. procedure g_releasevaluepara_openarray(list : taasmoutput;const ref:treference);override;
  87. procedure g_profilecode(list : taasmoutput);override;
  88. procedure g_stackpointer_alloc(list : taasmoutput;localsize : longint);override;
  89. procedure g_proc_entry(list : taasmoutput;localsize : longint;nostackframe:boolean);override;
  90. procedure g_overflowcheck(list: taasmoutput; const l:tlocation;def:tdef);override;
  91. protected
  92. procedure a_jmp_cond(list : taasmoutput;cond : TOpCmp;l: tasmlabel);
  93. procedure check_register_size(size:tcgsize;reg:tregister);
  94. procedure opmm_loc_reg(list: taasmoutput; Op: TOpCG; size : tcgsize;loc : tlocation;dst: tregister; shuffle : pmmshuffle);
  95. private
  96. procedure sizes2load(s1,s2 : tcgsize;var op: tasmop; var s3: topsize);
  97. procedure floatload(list: taasmoutput; t : tcgsize;const ref : treference);
  98. procedure floatstore(list: taasmoutput; t : tcgsize;const ref : treference);
  99. procedure floatloadops(t : tcgsize;var op : tasmop;var s : topsize);
  100. procedure floatstoreops(t : tcgsize;var op : tasmop;var s : topsize);
  101. end;
  102. function use_sse(def : tdef) : boolean;
  103. const
  104. {$ifdef x86_64}
  105. TCGSize2OpSize: Array[tcgsize] of topsize =
  106. (S_NO,S_B,S_W,S_L,S_Q,S_Q,S_B,S_W,S_L,S_Q,S_Q,
  107. S_FS,S_FL,S_FX,S_IQ,S_FXX,
  108. S_NO,S_NO,S_NO,S_MD,S_NO,S_NO,S_NO,S_NO,S_NO,S_NO);
  109. {$else x86_64}
  110. TCGSize2OpSize: Array[tcgsize] of topsize =
  111. (S_NO,S_B,S_W,S_L,S_L,S_L,S_B,S_W,S_L,S_L,S_L,
  112. S_FS,S_FL,S_FX,S_IQ,S_FXX,
  113. S_NO,S_NO,S_NO,S_MD,S_NO,S_NO,S_NO,S_NO,S_NO,S_NO);
  114. {$endif x86_64}
  115. {$ifndef NOTARGETWIN32}
  116. winstackpagesize = 4096;
  117. {$endif NOTARGETWIN32}
  118. implementation
  119. uses
  120. globals,verbose,systems,cutils,
  121. dwarf,
  122. symdef,defutil,paramgr,procinfo;
  123. const
  124. TOpCG2AsmOp: Array[topcg] of TAsmOp = (A_NONE,A_ADD,A_AND,A_DIV,
  125. A_IDIV,A_MUL, A_IMUL, A_NEG,A_NOT,A_OR,
  126. A_SAR,A_SHL,A_SHR,A_SUB,A_XOR);
  127. TOpCmp2AsmCond: Array[topcmp] of TAsmCond = (C_NONE,
  128. C_E,C_G,C_L,C_GE,C_LE,C_NE,C_BE,C_B,C_AE,C_A);
  129. function use_sse(def : tdef) : boolean;
  130. begin
  131. use_sse:=(is_single(def) and (aktfputype in sse_singlescalar)) or
  132. (is_double(def) and (aktfputype in sse_doublescalar));
  133. end;
  134. procedure Tcgx86.done_register_allocators;
  135. begin
  136. rg[R_INTREGISTER].free;
  137. rg[R_MMREGISTER].free;
  138. rg[R_MMXREGISTER].free;
  139. rgfpu.free;
  140. inherited done_register_allocators;
  141. end;
  142. function Tcgx86.getfpuregister(list:Taasmoutput;size:Tcgsize):Tregister;
  143. begin
  144. result:=rgfpu.getregisterfpu(list);
  145. end;
  146. function Tcgx86.getmmxregister(list:Taasmoutput):Tregister;
  147. begin
  148. if not assigned(rg[R_MMXREGISTER]) then
  149. internalerror(200312124);
  150. result:=rg[R_MMXREGISTER].getregister(list,R_SUBNONE);
  151. end;
  152. procedure Tcgx86.getcpuregister(list:Taasmoutput;r:Tregister);
  153. begin
  154. if getregtype(r)=R_FPUREGISTER then
  155. internalerror(2003121210)
  156. else
  157. inherited getcpuregister(list,r);
  158. end;
  159. procedure tcgx86.ungetcpuregister(list:Taasmoutput;r:Tregister);
  160. begin
  161. if getregtype(r)=R_FPUREGISTER then
  162. rgfpu.ungetregisterfpu(list,r)
  163. else
  164. inherited ungetcpuregister(list,r);
  165. end;
  166. procedure Tcgx86.alloccpuregisters(list:Taasmoutput;rt:Tregistertype;r:Tcpuregisterset);
  167. begin
  168. if rt<>R_FPUREGISTER then
  169. inherited alloccpuregisters(list,rt,r);
  170. end;
  171. procedure Tcgx86.dealloccpuregisters(list:Taasmoutput;rt:Tregistertype;r:Tcpuregisterset);
  172. begin
  173. if rt<>R_FPUREGISTER then
  174. inherited dealloccpuregisters(list,rt,r);
  175. end;
  176. function Tcgx86.uses_registers(rt:Tregistertype):boolean;
  177. begin
  178. if rt=R_FPUREGISTER then
  179. result:=false
  180. else
  181. result:=inherited uses_registers(rt);
  182. end;
  183. procedure tcgx86.add_reg_instruction(instr:Tai;r:tregister);
  184. begin
  185. if getregtype(r)<>R_FPUREGISTER then
  186. inherited add_reg_instruction(instr,r);
  187. end;
  188. procedure tcgx86.dec_fpu_stack;
  189. begin
  190. dec(rgfpu.fpuvaroffset);
  191. end;
  192. procedure tcgx86.inc_fpu_stack;
  193. begin
  194. inc(rgfpu.fpuvaroffset);
  195. end;
  196. {****************************************************************************
  197. This is private property, keep out! :)
  198. ****************************************************************************}
  199. procedure tcgx86.sizes2load(s1,s2 : tcgsize; var op: tasmop; var s3: topsize);
  200. begin
  201. case s2 of
  202. OS_8,OS_S8 :
  203. if S1 in [OS_8,OS_S8] then
  204. s3 := S_B
  205. else
  206. internalerror(200109221);
  207. OS_16,OS_S16:
  208. case s1 of
  209. OS_8,OS_S8:
  210. s3 := S_BW;
  211. OS_16,OS_S16:
  212. s3 := S_W;
  213. else
  214. internalerror(200109222);
  215. end;
  216. OS_32,OS_S32:
  217. case s1 of
  218. OS_8,OS_S8:
  219. s3 := S_BL;
  220. OS_16,OS_S16:
  221. s3 := S_WL;
  222. OS_32,OS_S32:
  223. s3 := S_L;
  224. else
  225. internalerror(200109223);
  226. end;
  227. {$ifdef x86_64}
  228. OS_64,OS_S64:
  229. case s1 of
  230. OS_8:
  231. s3 := S_BL;
  232. OS_S8:
  233. s3 := S_BQ;
  234. OS_16:
  235. s3 := S_WL;
  236. OS_S16:
  237. s3 := S_WQ;
  238. OS_32:
  239. s3 := S_L;
  240. OS_S32:
  241. s3 := S_LQ;
  242. OS_64,OS_S64:
  243. s3 := S_Q;
  244. else
  245. internalerror(200304302);
  246. end;
  247. {$endif x86_64}
  248. else
  249. internalerror(200109227);
  250. end;
  251. if s3 in [S_B,S_W,S_L,S_Q] then
  252. op := A_MOV
  253. else if s1 in [OS_8,OS_16,OS_32,OS_64] then
  254. op := A_MOVZX
  255. else
  256. {$ifdef x86_64}
  257. if s3 in [S_LQ] then
  258. op := A_MOVSXD
  259. else
  260. {$endif x86_64}
  261. op := A_MOVSX;
  262. end;
  263. procedure tcgx86.floatloadops(t : tcgsize;var op : tasmop;var s : topsize);
  264. begin
  265. case t of
  266. OS_F32 :
  267. begin
  268. op:=A_FLD;
  269. s:=S_FS;
  270. end;
  271. OS_F64 :
  272. begin
  273. op:=A_FLD;
  274. s:=S_FL;
  275. end;
  276. OS_F80 :
  277. begin
  278. op:=A_FLD;
  279. s:=S_FX;
  280. end;
  281. OS_C64 :
  282. begin
  283. op:=A_FILD;
  284. s:=S_IQ;
  285. end;
  286. else
  287. internalerror(200204041);
  288. end;
  289. end;
  290. procedure tcgx86.floatload(list: taasmoutput; t : tcgsize;const ref : treference);
  291. var
  292. op : tasmop;
  293. s : topsize;
  294. begin
  295. floatloadops(t,op,s);
  296. list.concat(Taicpu.Op_ref(op,s,ref));
  297. inc_fpu_stack;
  298. end;
  299. procedure tcgx86.floatstoreops(t : tcgsize;var op : tasmop;var s : topsize);
  300. begin
  301. case t of
  302. OS_F32 :
  303. begin
  304. op:=A_FSTP;
  305. s:=S_FS;
  306. end;
  307. OS_F64 :
  308. begin
  309. op:=A_FSTP;
  310. s:=S_FL;
  311. end;
  312. OS_F80 :
  313. begin
  314. op:=A_FSTP;
  315. s:=S_FX;
  316. end;
  317. OS_C64 :
  318. begin
  319. op:=A_FISTP;
  320. s:=S_IQ;
  321. end;
  322. else
  323. internalerror(200204042);
  324. end;
  325. end;
  326. procedure tcgx86.floatstore(list: taasmoutput; t : tcgsize;const ref : treference);
  327. var
  328. op : tasmop;
  329. s : topsize;
  330. begin
  331. floatstoreops(t,op,s);
  332. list.concat(Taicpu.Op_ref(op,s,ref));
  333. dec_fpu_stack;
  334. end;
  335. procedure tcgx86.check_register_size(size:tcgsize;reg:tregister);
  336. begin
  337. if TCGSize2OpSize[size]<>TCGSize2OpSize[reg_cgsize(reg)] then
  338. internalerror(200306031);
  339. end;
  340. {****************************************************************************
  341. Assembler code
  342. ****************************************************************************}
  343. procedure tcgx86.a_jmp_name(list : taasmoutput;const s : string);
  344. begin
  345. list.concat(taicpu.op_sym(A_JMP,S_NO,objectlibrary.newasmsymbol(s,AB_EXTERNAL,AT_FUNCTION)));
  346. end;
  347. procedure tcgx86.a_jmp_always(list : taasmoutput;l: tasmlabel);
  348. begin
  349. a_jmp_cond(list, OC_NONE, l);
  350. end;
  351. procedure tcgx86.a_call_name(list : taasmoutput;const s : string);
  352. begin
  353. list.concat(taicpu.op_sym(A_CALL,S_NO,objectlibrary.newasmsymbol(s,AB_EXTERNAL,AT_FUNCTION)));
  354. end;
  355. procedure tcgx86.a_call_reg(list : taasmoutput;reg : tregister);
  356. begin
  357. list.concat(taicpu.op_reg(A_CALL,S_NO,reg));
  358. end;
  359. {********************** load instructions ********************}
  360. procedure tcgx86.a_load_const_reg(list : taasmoutput; tosize: TCGSize; a : aint; reg : TRegister);
  361. begin
  362. check_register_size(tosize,reg);
  363. { the optimizer will change it to "xor reg,reg" when loading zero, }
  364. { no need to do it here too (JM) }
  365. list.concat(taicpu.op_const_reg(A_MOV,TCGSize2OpSize[tosize],a,reg))
  366. end;
  367. procedure tcgx86.a_load_const_ref(list : taasmoutput; tosize: tcgsize; a : aint;const ref : treference);
  368. {$ifdef x86_64}
  369. var
  370. href : treference;
  371. {$endif x86_64}
  372. begin
  373. {$ifdef x86_64}
  374. { x86_64 only supports signed 32 bits constants directly }
  375. if (tosize in [OS_S64,OS_64]) and
  376. ((a<low(longint)) or (a>high(longint))) then
  377. begin
  378. href:=ref;
  379. a_load_const_ref(list,OS_32,longint(a and $ffffffff),href);
  380. inc(href.offset,4);
  381. a_load_const_ref(list,OS_32,longint(a shr 32),href);
  382. end
  383. else
  384. {$endif x86_64}
  385. list.concat(taicpu.op_const_ref(A_MOV,TCGSize2OpSize[tosize],a,ref));
  386. end;
  387. procedure tcgx86.a_load_reg_ref(list : taasmoutput; fromsize,tosize: TCGSize; reg : tregister;const ref : treference);
  388. var
  389. op: tasmop;
  390. s: topsize;
  391. tmpsize : tcgsize;
  392. tmpreg : tregister;
  393. begin
  394. check_register_size(fromsize,reg);
  395. sizes2load(fromsize,tosize,op,s);
  396. case s of
  397. {$ifdef x86_64}
  398. S_BQ,S_WQ,S_LQ,
  399. {$endif x86_64}
  400. S_BW,S_BL,S_WL :
  401. begin
  402. tmpreg:=getintregister(list,tosize);
  403. {$ifdef x86_64}
  404. { zero extensions to 64 bit on the x86_64 are simply done by writting to the lower 32 bit
  405. which clears the upper 64 bit too, so it could be that s is S_L while the reg is
  406. 64 bit (FK) }
  407. if s in [S_BL,S_WL,S_L] then
  408. begin
  409. tmpreg:=makeregsize(list,tmpreg,OS_32);
  410. tmpsize:=OS_32;
  411. end
  412. else
  413. {$endif x86_64}
  414. tmpsize:=tosize;
  415. list.concat(taicpu.op_reg_reg(op,s,reg,tmpreg));
  416. a_load_reg_ref(list,tmpsize,tosize,tmpreg,ref);
  417. end;
  418. else
  419. list.concat(taicpu.op_reg_ref(op,s,reg,ref));
  420. end;
  421. end;
  422. procedure tcgx86.a_load_ref_reg(list : taasmoutput;fromsize,tosize : tcgsize;const ref: treference;reg : tregister);
  423. var
  424. op: tasmop;
  425. s: topsize;
  426. begin
  427. check_register_size(tosize,reg);
  428. sizes2load(fromsize,tosize,op,s);
  429. {$ifdef x86_64}
  430. { zero extensions to 64 bit on the x86_64 are simply done by writting to the lower 32 bit
  431. which clears the upper 64 bit too, so it could be that s is S_L while the reg is
  432. 64 bit (FK) }
  433. if s in [S_BL,S_WL,S_L] then
  434. reg:=makeregsize(list,reg,OS_32);
  435. {$endif x86_64}
  436. list.concat(taicpu.op_ref_reg(op,s,ref,reg));
  437. end;
  438. procedure tcgx86.a_load_reg_reg(list : taasmoutput;fromsize,tosize : tcgsize;reg1,reg2 : tregister);
  439. var
  440. op: tasmop;
  441. s: topsize;
  442. instr:Taicpu;
  443. begin
  444. check_register_size(fromsize,reg1);
  445. check_register_size(tosize,reg2);
  446. if tcgsize2size[fromsize]>tcgsize2size[tosize] then
  447. begin
  448. reg1:=makeregsize(list,reg1,tosize);
  449. s:=tcgsize2opsize[tosize];
  450. op:=A_MOV;
  451. end
  452. else
  453. sizes2load(fromsize,tosize,op,s);
  454. {$ifdef x86_64}
  455. { zero extensions to 64 bit on the x86_64 are simply done by writting to the lower 32 bit
  456. which clears the upper 64 bit too, so it could be that s is S_L while the reg is
  457. 64 bit (FK) }
  458. if s in [S_BL,S_WL,S_L] then
  459. reg2:=makeregsize(list,reg2,OS_32);
  460. {$endif x86_64}
  461. if (reg1<>reg2) then
  462. begin
  463. instr:=taicpu.op_reg_reg(op,s,reg1,reg2);
  464. { Notify the register allocator that we have written a move instruction so
  465. it can try to eliminate it. }
  466. add_move_instruction(instr);
  467. list.concat(instr);
  468. end;
  469. end;
  470. procedure tcgx86.a_loadaddr_ref_reg(list : taasmoutput;const ref : treference;r : tregister);
  471. begin
  472. with ref do
  473. if (base=NR_NO) and (index=NR_NO) then
  474. begin
  475. if assigned(ref.symbol) then
  476. list.concat(Taicpu.op_sym_ofs_reg(A_MOV,tcgsize2opsize[OS_ADDR],symbol,offset,r))
  477. else
  478. a_load_const_reg(list,OS_ADDR,offset,r);
  479. end
  480. else if (base=NR_NO) and (index<>NR_NO) and
  481. (offset=0) and (scalefactor=0) and (symbol=nil) then
  482. a_load_reg_reg(list,OS_ADDR,OS_ADDR,index,r)
  483. else if (base<>NR_NO) and (index=NR_NO) and
  484. (offset=0) and (symbol=nil) then
  485. a_load_reg_reg(list,OS_ADDR,OS_ADDR,base,r)
  486. else
  487. list.concat(taicpu.op_ref_reg(A_LEA,tcgsize2opsize[OS_ADDR],ref,r));
  488. end;
  489. { all fpu load routines expect that R_ST[0-7] means an fpu regvar and }
  490. { R_ST means "the current value at the top of the fpu stack" (JM) }
  491. procedure tcgx86.a_loadfpu_reg_reg(list: taasmoutput; size: tcgsize; reg1, reg2: tregister);
  492. begin
  493. if (reg1<>NR_ST) then
  494. begin
  495. list.concat(taicpu.op_reg(A_FLD,S_NO,rgfpu.correct_fpuregister(reg1,rgfpu.fpuvaroffset)));
  496. inc_fpu_stack;
  497. end;
  498. if (reg2<>NR_ST) then
  499. begin
  500. list.concat(taicpu.op_reg(A_FSTP,S_NO,rgfpu.correct_fpuregister(reg2,rgfpu.fpuvaroffset)));
  501. dec_fpu_stack;
  502. end;
  503. end;
  504. procedure tcgx86.a_loadfpu_ref_reg(list: taasmoutput; size: tcgsize; const ref: treference; reg: tregister);
  505. begin
  506. floatload(list,size,ref);
  507. if (reg<>NR_ST) then
  508. a_loadfpu_reg_reg(list,size,NR_ST,reg);
  509. end;
  510. procedure tcgx86.a_loadfpu_reg_ref(list: taasmoutput; size: tcgsize; reg: tregister; const ref: treference);
  511. begin
  512. if reg<>NR_ST then
  513. a_loadfpu_reg_reg(list,size,reg,NR_ST);
  514. floatstore(list,size,ref);
  515. end;
  516. function get_scalar_mm_op(fromsize,tosize : tcgsize) : tasmop;
  517. const
  518. convertop : array[OS_F32..OS_F128,OS_F32..OS_F128] of tasmop = (
  519. (A_MOVSS,A_CVTSS2SD,A_NONE,A_NONE,A_NONE),
  520. (A_CVTSD2SS,A_MOVSD,A_NONE,A_NONE,A_NONE),
  521. (A_NONE,A_NONE,A_NONE,A_NONE,A_NONE),
  522. (A_NONE,A_NONE,A_NONE,A_MOVQ,A_NONE),
  523. (A_NONE,A_NONE,A_NONE,A_NONE,A_NONE));
  524. begin
  525. result:=convertop[fromsize,tosize];
  526. if result=A_NONE then
  527. internalerror(200312205);
  528. end;
  529. procedure tcgx86.a_loadmm_reg_reg(list: taasmoutput; fromsize, tosize : tcgsize;reg1, reg2: tregister;shuffle : pmmshuffle);
  530. begin
  531. if shuffle=nil then
  532. begin
  533. if fromsize=tosize then
  534. list.concat(taicpu.op_reg_reg(A_MOVAPS,S_NO,reg1,reg2))
  535. else
  536. internalerror(200312202);
  537. end
  538. else if shufflescalar(shuffle) then
  539. list.concat(taicpu.op_reg_reg(get_scalar_mm_op(fromsize,tosize),S_NO,reg1,reg2))
  540. else
  541. internalerror(200312201);
  542. end;
  543. procedure tcgx86.a_loadmm_ref_reg(list: taasmoutput; fromsize, tosize : tcgsize;const ref: treference; reg: tregister;shuffle : pmmshuffle);
  544. begin
  545. if shuffle=nil then
  546. begin
  547. list.concat(taicpu.op_ref_reg(A_MOVQ,S_NO,ref,reg));
  548. end
  549. else if shufflescalar(shuffle) then
  550. list.concat(taicpu.op_ref_reg(get_scalar_mm_op(fromsize,tosize),S_NO,ref,reg))
  551. else
  552. internalerror(200312252);
  553. end;
  554. procedure tcgx86.a_loadmm_reg_ref(list: taasmoutput; fromsize, tosize : tcgsize;reg: tregister; const ref: treference;shuffle : pmmshuffle);
  555. var
  556. hreg : tregister;
  557. begin
  558. if shuffle=nil then
  559. begin
  560. list.concat(taicpu.op_reg_ref(A_MOVQ,S_NO,reg,ref));
  561. end
  562. else if shufflescalar(shuffle) then
  563. begin
  564. if tosize<>fromsize then
  565. begin
  566. hreg:=getmmregister(list,tosize);
  567. list.concat(taicpu.op_reg_reg(get_scalar_mm_op(fromsize,tosize),S_NO,reg,hreg));
  568. list.concat(taicpu.op_reg_ref(get_scalar_mm_op(tosize,tosize),S_NO,hreg,ref));
  569. end
  570. else
  571. list.concat(taicpu.op_reg_ref(get_scalar_mm_op(fromsize,tosize),S_NO,reg,ref))
  572. end
  573. else
  574. internalerror(200312252);
  575. end;
  576. procedure tcgx86.a_opmm_ref_reg(list: taasmoutput; Op: TOpCG; size : tcgsize;const ref: treference; reg: tregister;shuffle : pmmshuffle);
  577. var
  578. l : tlocation;
  579. begin
  580. l.loc:=LOC_REFERENCE;
  581. l.reference:=ref;
  582. l.size:=size;
  583. opmm_loc_reg(list,op,size,l,reg,shuffle);
  584. end;
  585. procedure tcgx86.a_opmm_reg_reg(list: taasmoutput; Op: TOpCG; size : tcgsize;src,dst: tregister;shuffle : pmmshuffle);
  586. var
  587. l : tlocation;
  588. begin
  589. l.loc:=LOC_MMREGISTER;
  590. l.register:=src;
  591. l.size:=size;
  592. opmm_loc_reg(list,op,size,l,dst,shuffle);
  593. end;
  594. procedure tcgx86.opmm_loc_reg(list: taasmoutput; Op: TOpCG; size : tcgsize;loc : tlocation;dst: tregister; shuffle : pmmshuffle);
  595. const
  596. opmm2asmop : array[0..1,OS_F32..OS_F64,topcg] of tasmop = (
  597. ( { scalar }
  598. ( { OS_F32 }
  599. A_NOP,A_ADDSS,A_NOP,A_DIVSS,A_NOP,A_NOP,A_MULSS,A_NOP,A_NOP,A_NOP,A_NOP,A_NOP,A_NOP,A_SUBSS,A_NOP
  600. ),
  601. ( { OS_F64 }
  602. A_NOP,A_ADDSD,A_NOP,A_DIVSD,A_NOP,A_NOP,A_MULSD,A_NOP,A_NOP,A_NOP,A_NOP,A_NOP,A_NOP,A_SUBSD,A_NOP
  603. )
  604. ),
  605. ( { vectorized/packed }
  606. { because the logical packed single instructions have shorter op codes, we use always
  607. these
  608. }
  609. ( { OS_F32 }
  610. A_NOP,A_ADDPS,A_NOP,A_NOP,A_NOP,A_NOP,A_NOP,A_NOP,A_NOP,A_NOP,A_NOP,A_NOP,A_NOP,A_NOP,A_XORPS
  611. ),
  612. ( { OS_F64 }
  613. A_NOP,A_ADDPD,A_NOP,A_NOP,A_NOP,A_NOP,A_NOP,A_NOP,A_NOP,A_NOP,A_NOP,A_NOP,A_NOP,A_NOP,A_XORPS
  614. )
  615. )
  616. );
  617. var
  618. resultreg : tregister;
  619. asmop : tasmop;
  620. begin
  621. { this is an internally used procedure so the parameters have
  622. some constrains
  623. }
  624. if loc.size<>size then
  625. internalerror(200312213);
  626. resultreg:=dst;
  627. { deshuffle }
  628. //!!!
  629. if (shuffle<>nil) and not(shufflescalar(shuffle)) then
  630. begin
  631. end
  632. else if (shuffle=nil) then
  633. asmop:=opmm2asmop[1,size,op]
  634. else if shufflescalar(shuffle) then
  635. begin
  636. asmop:=opmm2asmop[0,size,op];
  637. { no scalar operation available? }
  638. if asmop=A_NOP then
  639. begin
  640. { do vectorized and shuffle finally }
  641. //!!!
  642. end;
  643. end
  644. else
  645. internalerror(200312211);
  646. if asmop=A_NOP then
  647. internalerror(200312215);
  648. case loc.loc of
  649. LOC_CREFERENCE,LOC_REFERENCE:
  650. list.concat(taicpu.op_ref_reg(asmop,S_NO,loc.reference,resultreg));
  651. LOC_CMMREGISTER,LOC_MMREGISTER:
  652. list.concat(taicpu.op_reg_reg(asmop,S_NO,loc.register,resultreg));
  653. else
  654. internalerror(200312214);
  655. end;
  656. { shuffle }
  657. if resultreg<>dst then
  658. begin
  659. internalerror(200312212);
  660. end;
  661. end;
  662. procedure tcgx86.a_op_const_reg(list : taasmoutput; Op: TOpCG; size: TCGSize; a: aint; reg: TRegister);
  663. var
  664. opcode : tasmop;
  665. power : longint;
  666. {$ifdef x86_64}
  667. tmpreg : tregister;
  668. {$endif x86_64}
  669. begin
  670. {$ifdef x86_64}
  671. { x86_64 only supports signed 32 bits constants directly }
  672. if (size in [OS_S64,OS_64]) and
  673. ((a<low(longint)) or (a>high(longint))) then
  674. begin
  675. tmpreg:=getintregister(list,size);
  676. a_load_const_reg(list,size,a,tmpreg);
  677. a_op_reg_reg(list,op,size,tmpreg,reg);
  678. exit;
  679. end;
  680. {$endif x86_64}
  681. check_register_size(size,reg);
  682. case op of
  683. OP_DIV, OP_IDIV:
  684. begin
  685. if ispowerof2(int64(a),power) then
  686. begin
  687. case op of
  688. OP_DIV:
  689. opcode := A_SHR;
  690. OP_IDIV:
  691. opcode := A_SAR;
  692. end;
  693. list.concat(taicpu.op_const_reg(opcode,TCgSize2OpSize[size],power,reg));
  694. exit;
  695. end;
  696. { the rest should be handled specifically in the code }
  697. { generator because of the silly register usage restraints }
  698. internalerror(200109224);
  699. end;
  700. OP_MUL,OP_IMUL:
  701. begin
  702. if not(cs_check_overflow in aktlocalswitches) and
  703. ispowerof2(int64(a),power) then
  704. begin
  705. list.concat(taicpu.op_const_reg(A_SHL,TCgSize2OpSize[size],power,reg));
  706. exit;
  707. end;
  708. if op = OP_IMUL then
  709. list.concat(taicpu.op_const_reg(A_IMUL,TCgSize2OpSize[size],a,reg))
  710. else
  711. { OP_MUL should be handled specifically in the code }
  712. { generator because of the silly register usage restraints }
  713. internalerror(200109225);
  714. end;
  715. OP_ADD, OP_AND, OP_OR, OP_SUB, OP_XOR:
  716. if not(cs_check_overflow in aktlocalswitches) and
  717. (a = 1) and
  718. (op in [OP_ADD,OP_SUB]) then
  719. if op = OP_ADD then
  720. list.concat(taicpu.op_reg(A_INC,TCgSize2OpSize[size],reg))
  721. else
  722. list.concat(taicpu.op_reg(A_DEC,TCgSize2OpSize[size],reg))
  723. else if (a = 0) then
  724. if (op <> OP_AND) then
  725. exit
  726. else
  727. list.concat(taicpu.op_const_reg(A_MOV,TCgSize2OpSize[size],0,reg))
  728. else if (aword(a) = high(aword)) and
  729. (op in [OP_AND,OP_OR,OP_XOR]) then
  730. begin
  731. case op of
  732. OP_AND:
  733. exit;
  734. OP_OR:
  735. list.concat(taicpu.op_const_reg(A_MOV,TCgSize2OpSize[size],aint(high(aword)),reg));
  736. OP_XOR:
  737. list.concat(taicpu.op_reg(A_NOT,TCgSize2OpSize[size],reg));
  738. end
  739. end
  740. else
  741. list.concat(taicpu.op_const_reg(TOpCG2AsmOp[op],TCgSize2OpSize[size],a,reg));
  742. OP_SHL,OP_SHR,OP_SAR:
  743. begin
  744. if (a and 31) <> 0 Then
  745. list.concat(taicpu.op_const_reg(TOpCG2AsmOp[op],TCgSize2OpSize[size],a and 31,reg));
  746. if (a shr 5) <> 0 Then
  747. internalerror(68991);
  748. end
  749. else internalerror(68992);
  750. end;
  751. end;
  752. procedure tcgx86.a_op_const_ref(list : taasmoutput; Op: TOpCG; size: TCGSize; a: aint; const ref: TReference);
  753. var
  754. opcode: tasmop;
  755. power: longint;
  756. {$ifdef x86_64}
  757. tmpreg : tregister;
  758. {$endif x86_64}
  759. begin
  760. {$ifdef x86_64}
  761. { x86_64 only supports signed 32 bits constants directly }
  762. if (size in [OS_S64,OS_64]) and
  763. ((a<low(longint)) or (a>high(longint))) then
  764. begin
  765. tmpreg:=getintregister(list,size);
  766. a_load_const_reg(list,size,a,tmpreg);
  767. a_op_reg_ref(list,op,size,tmpreg,ref);
  768. exit;
  769. end;
  770. {$endif x86_64}
  771. Case Op of
  772. OP_DIV, OP_IDIV:
  773. Begin
  774. if ispowerof2(int64(a),power) then
  775. begin
  776. case op of
  777. OP_DIV:
  778. opcode := A_SHR;
  779. OP_IDIV:
  780. opcode := A_SAR;
  781. end;
  782. list.concat(taicpu.op_const_ref(opcode,
  783. TCgSize2OpSize[size],power,ref));
  784. exit;
  785. end;
  786. { the rest should be handled specifically in the code }
  787. { generator because of the silly register usage restraints }
  788. internalerror(200109231);
  789. End;
  790. OP_MUL,OP_IMUL:
  791. begin
  792. if not(cs_check_overflow in aktlocalswitches) and
  793. ispowerof2(int64(a),power) then
  794. begin
  795. list.concat(taicpu.op_const_ref(A_SHL,TCgSize2OpSize[size],
  796. power,ref));
  797. exit;
  798. end;
  799. { can't multiply a memory location directly with a constant }
  800. if op = OP_IMUL then
  801. inherited a_op_const_ref(list,op,size,a,ref)
  802. else
  803. { OP_MUL should be handled specifically in the code }
  804. { generator because of the silly register usage restraints }
  805. internalerror(200109232);
  806. end;
  807. OP_ADD, OP_AND, OP_OR, OP_SUB, OP_XOR:
  808. if not(cs_check_overflow in aktlocalswitches) and
  809. (a = 1) and
  810. (op in [OP_ADD,OP_SUB]) then
  811. if op = OP_ADD then
  812. list.concat(taicpu.op_ref(A_INC,TCgSize2OpSize[size],ref))
  813. else
  814. list.concat(taicpu.op_ref(A_DEC,TCgSize2OpSize[size],ref))
  815. else if (a = 0) then
  816. if (op <> OP_AND) then
  817. exit
  818. else
  819. a_load_const_ref(list,size,0,ref)
  820. else if (aword(a) = high(aword)) and
  821. (op in [OP_AND,OP_OR,OP_XOR]) then
  822. begin
  823. case op of
  824. OP_AND:
  825. exit;
  826. OP_OR:
  827. list.concat(taicpu.op_const_ref(A_MOV,TCgSize2OpSize[size],aint(high(aword)),ref));
  828. OP_XOR:
  829. list.concat(taicpu.op_ref(A_NOT,TCgSize2OpSize[size],ref));
  830. end
  831. end
  832. else
  833. list.concat(taicpu.op_const_ref(TOpCG2AsmOp[op],
  834. TCgSize2OpSize[size],a,ref));
  835. OP_SHL,OP_SHR,OP_SAR:
  836. begin
  837. if (a and 31) <> 0 then
  838. list.concat(taicpu.op_const_ref(
  839. TOpCG2AsmOp[op],TCgSize2OpSize[size],a and 31,ref));
  840. if (a shr 5) <> 0 Then
  841. internalerror(68991);
  842. end
  843. else internalerror(68992);
  844. end;
  845. end;
  846. procedure tcgx86.a_op_reg_reg(list : taasmoutput; Op: TOpCG; size: TCGSize; src, dst: TRegister);
  847. var
  848. dstsize: topsize;
  849. instr:Taicpu;
  850. begin
  851. check_register_size(size,src);
  852. check_register_size(size,dst);
  853. dstsize := tcgsize2opsize[size];
  854. case op of
  855. OP_NEG,OP_NOT:
  856. begin
  857. if src<>dst then
  858. a_load_reg_reg(list,size,size,src,dst);
  859. list.concat(taicpu.op_reg(TOpCG2AsmOp[op],dstsize,dst));
  860. end;
  861. OP_MUL,OP_DIV,OP_IDIV:
  862. { special stuff, needs separate handling inside code }
  863. { generator }
  864. internalerror(200109233);
  865. OP_SHR,OP_SHL,OP_SAR:
  866. begin
  867. getcpuregister(list,NR_CL);
  868. a_load_reg_reg(list,OS_8,OS_8,makeregsize(list,src,OS_8),NR_CL);
  869. list.concat(taicpu.op_reg_reg(Topcg2asmop[op],tcgsize2opsize[size],NR_CL,src));
  870. ungetcpuregister(list,NR_CL);
  871. end;
  872. else
  873. begin
  874. if reg2opsize(src) <> dstsize then
  875. internalerror(200109226);
  876. instr:=taicpu.op_reg_reg(TOpCG2AsmOp[op],dstsize,src,dst);
  877. list.concat(instr);
  878. end;
  879. end;
  880. end;
  881. procedure tcgx86.a_op_ref_reg(list : taasmoutput; Op: TOpCG; size: TCGSize; const ref: TReference; reg: TRegister);
  882. begin
  883. check_register_size(size,reg);
  884. case op of
  885. OP_NEG,OP_NOT,OP_IMUL:
  886. begin
  887. inherited a_op_ref_reg(list,op,size,ref,reg);
  888. end;
  889. OP_MUL,OP_DIV,OP_IDIV:
  890. { special stuff, needs separate handling inside code }
  891. { generator }
  892. internalerror(200109239);
  893. else
  894. begin
  895. reg := makeregsize(list,reg,size);
  896. list.concat(taicpu.op_ref_reg(TOpCG2AsmOp[op],tcgsize2opsize[size],ref,reg));
  897. end;
  898. end;
  899. end;
  900. procedure tcgx86.a_op_reg_ref(list : taasmoutput; Op: TOpCG; size: TCGSize;reg: TRegister; const ref: TReference);
  901. begin
  902. check_register_size(size,reg);
  903. case op of
  904. OP_NEG,OP_NOT:
  905. begin
  906. if reg<>NR_NO then
  907. internalerror(200109237);
  908. list.concat(taicpu.op_ref(TOpCG2AsmOp[op],tcgsize2opsize[size],ref));
  909. end;
  910. OP_IMUL:
  911. begin
  912. { this one needs a load/imul/store, which is the default }
  913. inherited a_op_ref_reg(list,op,size,ref,reg);
  914. end;
  915. OP_MUL,OP_DIV,OP_IDIV:
  916. { special stuff, needs separate handling inside code }
  917. { generator }
  918. internalerror(200109238);
  919. else
  920. begin
  921. list.concat(taicpu.op_reg_ref(TOpCG2AsmOp[op],tcgsize2opsize[size],reg,ref));
  922. end;
  923. end;
  924. end;
  925. procedure tcgx86.a_op_const_reg_reg(list: taasmoutput; op: TOpCg; size: tcgsize; a: aint; src, dst: tregister);
  926. var
  927. tmpref: treference;
  928. power: longint;
  929. {$ifdef x86_64}
  930. tmpreg : tregister;
  931. {$endif x86_64}
  932. begin
  933. {$ifdef x86_64}
  934. { x86_64 only supports signed 32 bits constants directly }
  935. if (size in [OS_S64,OS_64]) and
  936. ((a<low(longint)) or (a>high(longint))) then
  937. begin
  938. tmpreg:=getintregister(list,size);
  939. a_load_const_reg(list,size,a,tmpreg);
  940. a_op_reg_reg_reg(list,op,size,tmpreg,src,dst);
  941. exit;
  942. end;
  943. {$endif x86_64}
  944. check_register_size(size,src);
  945. check_register_size(size,dst);
  946. if tcgsize2size[size]<>tcgsize2size[OS_INT] then
  947. begin
  948. inherited a_op_const_reg_reg(list,op,size,a,src,dst);
  949. exit;
  950. end;
  951. { if we get here, we have to do a 32 bit calculation, guaranteed }
  952. case op of
  953. OP_DIV, OP_IDIV, OP_MUL, OP_AND, OP_OR, OP_XOR, OP_SHL, OP_SHR,
  954. OP_SAR:
  955. { can't do anything special for these }
  956. inherited a_op_const_reg_reg(list,op,size,a,src,dst);
  957. OP_IMUL:
  958. begin
  959. if not(cs_check_overflow in aktlocalswitches) and
  960. ispowerof2(int64(a),power) then
  961. { can be done with a shift }
  962. begin
  963. inherited a_op_const_reg_reg(list,op,size,a,src,dst);
  964. exit;
  965. end;
  966. list.concat(taicpu.op_const_reg_reg(A_IMUL,tcgsize2opsize[size],a,src,dst));
  967. end;
  968. OP_ADD, OP_SUB:
  969. if (a = 0) then
  970. a_load_reg_reg(list,size,size,src,dst)
  971. else
  972. begin
  973. reference_reset(tmpref);
  974. tmpref.base := src;
  975. tmpref.offset := longint(a);
  976. if op = OP_SUB then
  977. tmpref.offset := -tmpref.offset;
  978. list.concat(taicpu.op_ref_reg(A_LEA,tcgsize2opsize[size],tmpref,dst));
  979. end
  980. else internalerror(200112302);
  981. end;
  982. end;
  983. procedure tcgx86.a_op_reg_reg_reg(list: taasmoutput; op: TOpCg;size: tcgsize; src1, src2, dst: tregister);
  984. var
  985. tmpref: treference;
  986. begin
  987. check_register_size(size,src1);
  988. check_register_size(size,src2);
  989. check_register_size(size,dst);
  990. if tcgsize2size[size]<>tcgsize2size[OS_INT] then
  991. begin
  992. inherited a_op_reg_reg_reg(list,op,size,src1,src2,dst);
  993. exit;
  994. end;
  995. { if we get here, we have to do a 32 bit calculation, guaranteed }
  996. Case Op of
  997. OP_DIV, OP_IDIV, OP_MUL, OP_AND, OP_OR, OP_XOR, OP_SHL, OP_SHR,
  998. OP_SAR,OP_SUB,OP_NOT,OP_NEG:
  999. { can't do anything special for these }
  1000. inherited a_op_reg_reg_reg(list,op,size,src1,src2,dst);
  1001. OP_IMUL:
  1002. list.concat(taicpu.op_reg_reg_reg(A_IMUL,tcgsize2opsize[size],src1,src2,dst));
  1003. OP_ADD:
  1004. begin
  1005. reference_reset(tmpref);
  1006. tmpref.base := src1;
  1007. tmpref.index := src2;
  1008. tmpref.scalefactor := 1;
  1009. list.concat(taicpu.op_ref_reg(A_LEA,tcgsize2opsize[size],tmpref,dst));
  1010. end
  1011. else internalerror(200112303);
  1012. end;
  1013. end;
  1014. {*************** compare instructructions ****************}
  1015. procedure tcgx86.a_cmp_const_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;a : aint;reg : tregister;
  1016. l : tasmlabel);
  1017. {$ifdef x86_64}
  1018. var
  1019. tmpreg : tregister;
  1020. {$endif x86_64}
  1021. begin
  1022. {$ifdef x86_64}
  1023. { x86_64 only supports signed 32 bits constants directly }
  1024. if (size in [OS_S64,OS_64]) and
  1025. ((a<low(longint)) or (a>high(longint))) then
  1026. begin
  1027. tmpreg:=getintregister(list,size);
  1028. a_load_const_reg(list,size,a,tmpreg);
  1029. a_cmp_reg_reg_label(list,size,cmp_op,tmpreg,reg,l);
  1030. exit;
  1031. end;
  1032. {$endif x86_64}
  1033. if (a = 0) then
  1034. list.concat(taicpu.op_reg_reg(A_TEST,tcgsize2opsize[size],reg,reg))
  1035. else
  1036. list.concat(taicpu.op_const_reg(A_CMP,tcgsize2opsize[size],a,reg));
  1037. a_jmp_cond(list,cmp_op,l);
  1038. end;
  1039. procedure tcgx86.a_cmp_const_ref_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;a : aint;const ref : treference;
  1040. l : tasmlabel);
  1041. {$ifdef x86_64}
  1042. var
  1043. tmpreg : tregister;
  1044. {$endif x86_64}
  1045. begin
  1046. {$ifdef x86_64}
  1047. { x86_64 only supports signed 32 bits constants directly }
  1048. if (size in [OS_S64,OS_64]) and
  1049. ((a<low(longint)) or (a>high(longint))) then
  1050. begin
  1051. tmpreg:=getintregister(list,size);
  1052. a_load_const_reg(list,size,a,tmpreg);
  1053. a_cmp_reg_ref_label(list,size,cmp_op,tmpreg,ref,l);
  1054. exit;
  1055. end;
  1056. {$endif x86_64}
  1057. list.concat(taicpu.op_const_ref(A_CMP,TCgSize2OpSize[size],a,ref));
  1058. a_jmp_cond(list,cmp_op,l);
  1059. end;
  1060. procedure tcgx86.a_cmp_reg_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;
  1061. reg1,reg2 : tregister;l : tasmlabel);
  1062. begin
  1063. check_register_size(size,reg1);
  1064. check_register_size(size,reg2);
  1065. list.concat(taicpu.op_reg_reg(A_CMP,TCgSize2OpSize[size],reg1,reg2));
  1066. a_jmp_cond(list,cmp_op,l);
  1067. end;
  1068. procedure tcgx86.a_cmp_ref_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;const ref: treference; reg : tregister;l : tasmlabel);
  1069. begin
  1070. check_register_size(size,reg);
  1071. list.concat(taicpu.op_ref_reg(A_CMP,TCgSize2OpSize[size],ref,reg));
  1072. a_jmp_cond(list,cmp_op,l);
  1073. end;
  1074. procedure tcgx86.a_cmp_reg_ref_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;reg : tregister;const ref: treference; l : tasmlabel);
  1075. begin
  1076. check_register_size(size,reg);
  1077. list.concat(taicpu.op_reg_ref(A_CMP,TCgSize2OpSize[size],reg,ref));
  1078. a_jmp_cond(list,cmp_op,l);
  1079. end;
  1080. procedure tcgx86.a_jmp_cond(list : taasmoutput;cond : TOpCmp;l: tasmlabel);
  1081. var
  1082. ai : taicpu;
  1083. begin
  1084. if cond=OC_None then
  1085. ai := Taicpu.Op_sym(A_JMP,S_NO,l)
  1086. else
  1087. begin
  1088. ai:=Taicpu.Op_sym(A_Jcc,S_NO,l);
  1089. ai.SetCondition(TOpCmp2AsmCond[cond]);
  1090. end;
  1091. ai.is_jmp:=true;
  1092. list.concat(ai);
  1093. end;
  1094. procedure tcgx86.a_jmp_flags(list : taasmoutput;const f : TResFlags;l: tasmlabel);
  1095. var
  1096. ai : taicpu;
  1097. begin
  1098. ai := Taicpu.op_sym(A_Jcc,S_NO,l);
  1099. ai.SetCondition(flags_to_cond(f));
  1100. ai.is_jmp := true;
  1101. list.concat(ai);
  1102. end;
  1103. procedure tcgx86.g_flags2reg(list: taasmoutput; size: TCgSize; const f: tresflags; reg: TRegister);
  1104. var
  1105. ai : taicpu;
  1106. hreg : tregister;
  1107. begin
  1108. hreg:=makeregsize(list,reg,OS_8);
  1109. ai:=Taicpu.op_reg(A_SETcc,S_B,hreg);
  1110. ai.setcondition(flags_to_cond(f));
  1111. list.concat(ai);
  1112. if (reg<>hreg) then
  1113. a_load_reg_reg(list,OS_8,size,hreg,reg);
  1114. end;
  1115. procedure tcgx86.g_flags2ref(list: taasmoutput; size: TCgSize; const f: tresflags; const ref: TReference);
  1116. var
  1117. ai : taicpu;
  1118. begin
  1119. if not(size in [OS_8,OS_S8]) then
  1120. a_load_const_ref(list,size,0,ref);
  1121. ai:=Taicpu.op_ref(A_SETcc,S_B,ref);
  1122. ai.setcondition(flags_to_cond(f));
  1123. list.concat(ai);
  1124. end;
  1125. { ************* concatcopy ************ }
  1126. procedure Tcgx86.g_concatcopy(list:Taasmoutput;const source,dest:Treference;len:aint);
  1127. const
  1128. {$ifdef cpu64bit}
  1129. REGCX=NR_RCX;
  1130. REGSI=NR_RSI;
  1131. REGDI=NR_RDI;
  1132. {$else cpu64bit}
  1133. REGCX=NR_ECX;
  1134. REGSI=NR_ESI;
  1135. REGDI=NR_EDI;
  1136. {$endif cpu64bit}
  1137. type copymode=(copy_move,copy_mmx,copy_string);
  1138. var srcref,dstref:Treference;
  1139. r,r0,r1,r2,r3:Tregister;
  1140. helpsize:aint;
  1141. copysize:byte;
  1142. cgsize:Tcgsize;
  1143. cm:copymode;
  1144. begin
  1145. cm:=copy_move;
  1146. helpsize:=12;
  1147. if cs_littlesize in aktglobalswitches then
  1148. helpsize:=8;
  1149. if (cs_mmx in aktlocalswitches) and
  1150. not(pi_uses_fpu in current_procinfo.flags) and
  1151. ((len=8) or (len=16) or (len=24) or (len=32)) then
  1152. cm:=copy_mmx;
  1153. if (len>helpsize) then
  1154. cm:=copy_string;
  1155. if (cs_littlesize in aktglobalswitches) and
  1156. not((len<=16) and (cm=copy_mmx)) then
  1157. cm:=copy_string;
  1158. case cm of
  1159. copy_move:
  1160. begin
  1161. dstref:=dest;
  1162. srcref:=source;
  1163. copysize:=sizeof(aint);
  1164. cgsize:=int_cgsize(copysize);
  1165. while len<>0 do
  1166. begin
  1167. if len<2 then
  1168. begin
  1169. copysize:=1;
  1170. cgsize:=OS_8;
  1171. end
  1172. else if len<4 then
  1173. begin
  1174. copysize:=2;
  1175. cgsize:=OS_16;
  1176. end
  1177. else if len<8 then
  1178. begin
  1179. copysize:=4;
  1180. cgsize:=OS_32;
  1181. end;
  1182. dec(len,copysize);
  1183. r:=getintregister(list,cgsize);
  1184. a_load_ref_reg(list,cgsize,cgsize,srcref,r);
  1185. a_load_reg_ref(list,cgsize,cgsize,r,dstref);
  1186. inc(srcref.offset,copysize);
  1187. inc(dstref.offset,copysize);
  1188. end;
  1189. end;
  1190. copy_mmx:
  1191. begin
  1192. dstref:=dest;
  1193. srcref:=source;
  1194. r0:=getmmxregister(list);
  1195. a_loadmm_ref_reg(list,OS_M64,OS_M64,srcref,r0,nil);
  1196. if len>=16 then
  1197. begin
  1198. inc(srcref.offset,8);
  1199. r1:=getmmxregister(list);
  1200. a_loadmm_ref_reg(list,OS_M64,OS_M64,srcref,r1,nil);
  1201. end;
  1202. if len>=24 then
  1203. begin
  1204. inc(srcref.offset,8);
  1205. r2:=getmmxregister(list);
  1206. a_loadmm_ref_reg(list,OS_M64,OS_M64,srcref,r2,nil);
  1207. end;
  1208. if len>=32 then
  1209. begin
  1210. inc(srcref.offset,8);
  1211. r3:=getmmxregister(list);
  1212. a_loadmm_ref_reg(list,OS_M64,OS_M64,srcref,r3,nil);
  1213. end;
  1214. a_loadmm_reg_ref(list,OS_M64,OS_M64,r0,dstref,nil);
  1215. if len>=16 then
  1216. begin
  1217. inc(dstref.offset,8);
  1218. a_loadmm_reg_ref(list,OS_M64,OS_M64,r1,dstref,nil);
  1219. end;
  1220. if len>=24 then
  1221. begin
  1222. inc(dstref.offset,8);
  1223. a_loadmm_reg_ref(list,OS_M64,OS_M64,r2,dstref,nil);
  1224. end;
  1225. if len>=32 then
  1226. begin
  1227. inc(dstref.offset,8);
  1228. a_loadmm_reg_ref(list,OS_M64,OS_M64,r3,dstref,nil);
  1229. end;
  1230. end
  1231. else {copy_string, should be a good fallback in case of unhandled}
  1232. begin
  1233. getcpuregister(list,REGDI);
  1234. a_loadaddr_ref_reg(list,dest,REGDI);
  1235. getcpuregister(list,REGSI);
  1236. a_loadaddr_ref_reg(list,source,REGSI);
  1237. getcpuregister(list,REGCX);
  1238. list.concat(Taicpu.op_none(A_CLD,S_NO));
  1239. if cs_littlesize in aktglobalswitches then
  1240. begin
  1241. a_load_const_reg(list,OS_INT,len,REGCX);
  1242. list.concat(Taicpu.op_none(A_REP,S_NO));
  1243. list.concat(Taicpu.op_none(A_MOVSB,S_NO));
  1244. end
  1245. else
  1246. begin
  1247. helpsize:=len div sizeof(aint);
  1248. len:=len mod sizeof(aint);
  1249. if helpsize>1 then
  1250. begin
  1251. a_load_const_reg(list,OS_INT,helpsize,REGCX);
  1252. list.concat(Taicpu.op_none(A_REP,S_NO));
  1253. end;
  1254. if helpsize>0 then
  1255. begin
  1256. {$ifdef cpu64bit}
  1257. if sizeof(aint)=8 then
  1258. list.concat(Taicpu.op_none(A_MOVSQ,S_NO))
  1259. else
  1260. {$endif cpu64bit}
  1261. list.concat(Taicpu.op_none(A_MOVSD,S_NO));
  1262. end;
  1263. if len>=4 then
  1264. begin
  1265. dec(len,4);
  1266. list.concat(Taicpu.op_none(A_MOVSD,S_NO));
  1267. end;
  1268. if len>=2 then
  1269. begin
  1270. dec(len,2);
  1271. list.concat(Taicpu.op_none(A_MOVSW,S_NO));
  1272. end;
  1273. if len=1 then
  1274. list.concat(Taicpu.op_none(A_MOVSB,S_NO));
  1275. end;
  1276. ungetcpuregister(list,REGCX);
  1277. ungetcpuregister(list,REGSI);
  1278. ungetcpuregister(list,REGDI);
  1279. end;
  1280. end;
  1281. end;
  1282. {****************************************************************************
  1283. Entry/Exit Code Helpers
  1284. ****************************************************************************}
  1285. procedure tcgx86.g_releasevaluepara_openarray(list : taasmoutput;const ref:treference);
  1286. begin
  1287. { Nothing to release }
  1288. end;
  1289. procedure tcgx86.g_profilecode(list : taasmoutput);
  1290. var
  1291. pl : tasmlabel;
  1292. mcountprefix : String[4];
  1293. begin
  1294. case target_info.system of
  1295. {$ifndef NOTARGETWIN32}
  1296. system_i386_win32,
  1297. {$endif}
  1298. system_i386_freebsd,
  1299. system_i386_netbsd,
  1300. // system_i386_openbsd,
  1301. system_i386_wdosx :
  1302. begin
  1303. Case target_info.system Of
  1304. system_i386_freebsd : mcountprefix:='.';
  1305. system_i386_netbsd : mcountprefix:='__';
  1306. // system_i386_openbsd : mcountprefix:='.';
  1307. else
  1308. mcountPrefix:='';
  1309. end;
  1310. objectlibrary.getaddrlabel(pl);
  1311. new_section(list,sec_data,lower(current_procinfo.procdef.mangledname),sizeof(aint));
  1312. list.concat(Tai_label.Create(pl));
  1313. list.concat(Tai_const.Create_32bit(0));
  1314. new_section(list,sec_code,lower(current_procinfo.procdef.mangledname),0);
  1315. list.concat(Taicpu.Op_reg(A_PUSH,S_L,NR_EDX));
  1316. list.concat(Taicpu.Op_sym_ofs_reg(A_MOV,S_L,pl,0,NR_EDX));
  1317. a_call_name(list,target_info.Cprefix+mcountprefix+'mcount');
  1318. list.concat(Taicpu.Op_reg(A_POP,S_L,NR_EDX));
  1319. end;
  1320. system_i386_linux:
  1321. a_call_name(list,target_info.Cprefix+'mcount');
  1322. system_i386_go32v2,system_i386_watcom:
  1323. begin
  1324. a_call_name(list,'MCOUNT');
  1325. end;
  1326. end;
  1327. end;
  1328. procedure tcgx86.g_stackpointer_alloc(list : taasmoutput;localsize : longint);
  1329. {$ifdef i386}
  1330. {$ifndef NOTARGETWIN32}
  1331. var
  1332. href : treference;
  1333. i : integer;
  1334. again : tasmlabel;
  1335. {$endif NOTARGETWIN32}
  1336. {$endif i386}
  1337. begin
  1338. if localsize>0 then
  1339. begin
  1340. {$ifdef i386}
  1341. {$ifndef NOTARGETWIN32}
  1342. { windows guards only a few pages for stack growing, }
  1343. { so we have to access every page first }
  1344. if (target_info.system=system_i386_win32) and
  1345. (localsize>=winstackpagesize) then
  1346. begin
  1347. if localsize div winstackpagesize<=5 then
  1348. begin
  1349. list.concat(Taicpu.Op_const_reg(A_SUB,S_L,localsize-4,NR_ESP));
  1350. for i:=1 to localsize div winstackpagesize do
  1351. begin
  1352. reference_reset_base(href,NR_ESP,localsize-i*winstackpagesize);
  1353. list.concat(Taicpu.op_const_ref(A_MOV,S_L,0,href));
  1354. end;
  1355. list.concat(Taicpu.op_reg(A_PUSH,S_L,NR_EAX));
  1356. end
  1357. else
  1358. begin
  1359. objectlibrary.getlabel(again);
  1360. getcpuregister(list,NR_EDI);
  1361. list.concat(Taicpu.op_const_reg(A_MOV,S_L,localsize div winstackpagesize,NR_EDI));
  1362. a_label(list,again);
  1363. list.concat(Taicpu.op_const_reg(A_SUB,S_L,winstackpagesize-4,NR_ESP));
  1364. list.concat(Taicpu.op_reg(A_PUSH,S_L,NR_EAX));
  1365. list.concat(Taicpu.op_reg(A_DEC,S_L,NR_EDI));
  1366. a_jmp_cond(list,OC_NE,again);
  1367. ungetcpuregister(list,NR_EDI);
  1368. list.concat(Taicpu.op_const_reg(A_SUB,S_L,localsize mod winstackpagesize,NR_ESP));
  1369. end
  1370. end
  1371. else
  1372. {$endif NOTARGETWIN32}
  1373. {$endif i386}
  1374. list.concat(Taicpu.Op_const_reg(A_SUB,tcgsize2opsize[OS_ADDR],localsize,NR_STACK_POINTER_REG));
  1375. end;
  1376. end;
  1377. procedure tcgx86.g_proc_entry(list : taasmoutput;localsize : longint;nostackframe:boolean);
  1378. begin
  1379. {$ifdef i386}
  1380. { interrupt support for i386 }
  1381. if (po_interrupt in current_procinfo.procdef.procoptions) then
  1382. begin
  1383. { .... also the segment registers }
  1384. list.concat(Taicpu.Op_reg(A_PUSH,S_W,NR_GS));
  1385. list.concat(Taicpu.Op_reg(A_PUSH,S_W,NR_FS));
  1386. list.concat(Taicpu.Op_reg(A_PUSH,S_W,NR_ES));
  1387. list.concat(Taicpu.Op_reg(A_PUSH,S_W,NR_DS));
  1388. { save the registers of an interrupt procedure }
  1389. list.concat(Taicpu.Op_reg(A_PUSH,S_L,NR_EDI));
  1390. list.concat(Taicpu.Op_reg(A_PUSH,S_L,NR_ESI));
  1391. list.concat(Taicpu.Op_reg(A_PUSH,S_L,NR_EDX));
  1392. list.concat(Taicpu.Op_reg(A_PUSH,S_L,NR_ECX));
  1393. list.concat(Taicpu.Op_reg(A_PUSH,S_L,NR_EBX));
  1394. list.concat(Taicpu.Op_reg(A_PUSH,S_L,NR_EAX));
  1395. end;
  1396. {$endif i386}
  1397. { save old framepointer }
  1398. if not nostackframe then
  1399. begin
  1400. if (current_procinfo.framepointer=NR_STACK_POINTER_REG) then
  1401. CGmessage(cg_d_stackframe_omited)
  1402. else
  1403. begin
  1404. list.concat(tai_regalloc.alloc(NR_FRAME_POINTER_REG,nil));
  1405. include(rg[R_INTREGISTER].preserved_by_proc,RS_FRAME_POINTER_REG);
  1406. list.concat(Taicpu.op_reg(A_PUSH,tcgsize2opsize[OS_ADDR],NR_FRAME_POINTER_REG));
  1407. { Return address and FP are both on stack }
  1408. dwarfcfi.cfa_def_cfa_offset(list,2*sizeof(aint));
  1409. dwarfcfi.cfa_offset(list,NR_FRAME_POINTER_REG,-(2*sizeof(aint)));
  1410. list.concat(Taicpu.op_reg_reg(A_MOV,tcgsize2opsize[OS_ADDR],NR_STACK_POINTER_REG,NR_FRAME_POINTER_REG));
  1411. dwarfcfi.cfa_def_cfa_register(list,NR_FRAME_POINTER_REG);
  1412. end;
  1413. { allocate stackframe space }
  1414. if localsize<>0 then
  1415. begin
  1416. cg.g_stackpointer_alloc(list,localsize);
  1417. end;
  1418. end;
  1419. { allocate PIC register }
  1420. if cs_create_pic in aktmoduleswitches then
  1421. begin
  1422. a_call_name(list,'FPC_GETEIPINEBX');
  1423. list.concat(taicpu.op_sym_ofs_reg(A_ADD,tcgsize2opsize[OS_ADDR],objectlibrary.newasmsymbol('_GLOBAL_OFFSET_TABLE_',AB_EXTERNAL,AT_DATA),0,NR_PIC_OFFSET_REG));
  1424. list.concat(tai_regalloc.alloc(NR_PIC_OFFSET_REG,nil));
  1425. end;
  1426. end;
  1427. { produces if necessary overflowcode }
  1428. procedure tcgx86.g_overflowcheck(list: taasmoutput; const l:tlocation;def:tdef);
  1429. var
  1430. hl : tasmlabel;
  1431. ai : taicpu;
  1432. cond : TAsmCond;
  1433. begin
  1434. if not(cs_check_overflow in aktlocalswitches) then
  1435. exit;
  1436. objectlibrary.getlabel(hl);
  1437. if not ((def.deftype=pointerdef) or
  1438. ((def.deftype=orddef) and
  1439. (torddef(def).typ in [u64bit,u16bit,u32bit,u8bit,uchar,
  1440. bool8bit,bool16bit,bool32bit]))) then
  1441. cond:=C_NO
  1442. else
  1443. cond:=C_NB;
  1444. ai:=Taicpu.Op_Sym(A_Jcc,S_NO,hl);
  1445. ai.SetCondition(cond);
  1446. ai.is_jmp:=true;
  1447. list.concat(ai);
  1448. a_call_name(list,'FPC_OVERFLOW');
  1449. a_label(list,hl);
  1450. end;
  1451. end.
  1452. {
  1453. $Log$
  1454. Revision 1.135 2004-11-01 15:42:47 florian
  1455. * cvt*2* can't write to memory location, fixed
  1456. Revision 1.134 2004/11/01 10:30:06 peter
  1457. * fixed uninited var in a_load_reg_ref
  1458. Revision 1.133 2004/10/31 21:45:04 peter
  1459. * generic tlocation
  1460. * move tlocation to cgutils
  1461. Revision 1.132 2004/10/25 15:36:47 peter
  1462. * save standard registers moved to tcgobj
  1463. Revision 1.131 2004/10/24 20:10:08 peter
  1464. * -Or fixes
  1465. Revision 1.130 2004/10/24 11:44:28 peter
  1466. * small regvar fixes
  1467. * loadref parameter removed from concatcopy,incrrefcount,etc
  1468. Revision 1.129 2004/10/06 19:27:35 jonas
  1469. * regvar fixes from Peter
  1470. Revision 1.128 2004/10/05 20:41:02 peter
  1471. * more spilling rewrites
  1472. Revision 1.127 2004/10/04 20:46:22 peter
  1473. * spilling code rewritten for x86. It now used the generic
  1474. spilling routines. Special x86 optimization still needs
  1475. to be added.
  1476. * Spilling fixed when both operands needed to be spilled
  1477. * Cleanup of spilling routine, do_spill_readwritten removed
  1478. Revision 1.126 2004/10/03 12:42:22 florian
  1479. * made sqrt, sqr and abs internal for the sparc
  1480. Revision 1.125 2004/09/25 14:23:55 peter
  1481. * ungetregister is now only used for cpuregisters, renamed to
  1482. ungetcpuregister
  1483. * renamed (get|unget)explicitregister(s) to ..cpuregister
  1484. * removed location-release/reference_release
  1485. Revision 1.124 2004/06/20 08:55:32 florian
  1486. * logs truncated
  1487. Revision 1.123 2004/06/16 20:07:11 florian
  1488. * dwarf branch merged
  1489. Revision 1.122 2004/05/22 23:34:28 peter
  1490. tai_regalloc.allocation changed to ratype to notify rgobj of register size changes
  1491. Revision 1.121 2004/04/28 15:19:03 florian
  1492. + syscall directive support for MorphOS added
  1493. Revision 1.120 2004/04/09 14:36:05 peter
  1494. * A_MOVSL renamed to A_MOVSD
  1495. Revision 1.119.2.22 2004/05/28 20:29:50 florian
  1496. * fixed currency trouble on x86-64
  1497. }