cpupara.pas 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224
  1. {
  2. Copyright (c) 2002 by Florian Klaempfl
  3. Generates the argument location information for x86-64 target
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. ****************************************************************************
  16. }
  17. unit cpupara;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. globtype,
  22. cpubase,cgbase,cgutils,
  23. symconst,symtype,symsym,symdef,
  24. aasmtai,aasmdata,
  25. parabase,paramgr;
  26. type
  27. tx86_64paramanager = class(tparamanager)
  28. private
  29. procedure create_paraloc_info_intern(p : tabstractprocdef; side: tcallercallee;paras:tparalist;
  30. var intparareg,mmparareg,parasize:longint;varargsparas: boolean);
  31. public
  32. function param_use_paraloc(const cgpara:tcgpara):boolean;override;
  33. function push_addr_param(varspez:tvarspez;def : tdef;calloption : tproccalloption) : boolean;override;
  34. function ret_in_param(def : tdef;calloption : tproccalloption) : boolean;override;
  35. procedure getintparaloc(calloption : tproccalloption; nr : longint; def : tdef; var cgpara : tcgpara);override;
  36. function get_volatile_registers_int(calloption : tproccalloption):tcpuregisterset;override;
  37. function get_volatile_registers_mm(calloption : tproccalloption):tcpuregisterset;override;
  38. function get_volatile_registers_fpu(calloption : tproccalloption):tcpuregisterset;override;
  39. function create_paraloc_info(p : tabstractprocdef; side: tcallercallee):longint;override;
  40. function create_varargs_paraloc_info(p : tabstractprocdef; varargspara:tvarargsparalist):longint;override;
  41. function get_funcretloc(p : tabstractprocdef; side: tcallercallee; forcetempdef: tdef): tcgpara;override;
  42. end;
  43. implementation
  44. uses
  45. cutils,verbose,
  46. systems,
  47. defutil,
  48. symtable;
  49. const
  50. paraintsupregs : array[0..5] of tsuperregister = (RS_RDI,RS_RSI,RS_RDX,RS_RCX,RS_R8,RS_R9);
  51. parammsupregs : array[0..7] of tsuperregister = (RS_XMM0,RS_XMM1,RS_XMM2,RS_XMM3,RS_XMM4,RS_XMM5,RS_XMM6,RS_XMM7);
  52. paraintsupregs_winx64 : array[0..3] of tsuperregister = (RS_RCX,RS_RDX,RS_R8,RS_R9);
  53. parammsupregs_winx64 : array[0..3] of tsuperregister = (RS_XMM0,RS_XMM1,RS_XMM2,RS_XMM3);
  54. {
  55. The argument classification code largely comes from libffi:
  56. ffi64.c - Copyright (c) 2002, 2007 Bo Thorsen <[email protected]>
  57. Copyright (c) 2008 Red Hat, Inc.
  58. x86-64 Foreign Function Interface
  59. Permission is hereby granted, free of charge, to any person obtaining
  60. a copy of this software and associated documentation files (the
  61. ``Software''), to deal in the Software without restriction, including
  62. without limitation the rights to use, copy, modify, merge, publish,
  63. distribute, sublicense, and/or sell copies of the Software, and to
  64. permit persons to whom the Software is furnished to do so, subject to
  65. the following conditions:
  66. The above copyright notice and this permission notice shall be included
  67. in all copies or substantial portions of the Software.
  68. THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
  69. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  70. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  71. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  72. HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  73. WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  74. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  75. DEALINGS IN THE SOFTWARE.
  76. ----------------------------------------------------------------------- *)
  77. }
  78. const
  79. MAX_PARA_CLASSES = 4;
  80. type
  81. tx64paraclass = (
  82. X86_64_NO_CLASS,
  83. X86_64_INTEGER_CLASS,X86_64_INTEGERSI_CLASS,
  84. X86_64_SSE_CLASS,X86_64_SSESF_CLASS,X86_64_SSEDF_CLASS,X86_64_SSEUP_CLASS,
  85. X86_64_X87_CLASS,X86_64_X87UP_CLASS,
  86. X86_64_COMPLEX_X87_CLASS,
  87. X86_64_MEMORY_CLASS
  88. );
  89. tx64paraclasses = array[0..MAX_PARA_CLASSES-1] of tx64paraclass;
  90. { Win64-specific helper }
  91. function aggregate_in_registers_win64(varspez:tvarspez;size:longint):boolean;
  92. begin
  93. { TODO: Temporary hack: vs_const parameters are always passed by reference for win64}
  94. result:=(varspez=vs_value) and (size in [1,2,4,8])
  95. end;
  96. (* x86-64 register passing implementation. See x86-64 ABI for details. Goal
  97. of this code is to classify each 8bytes of incoming argument by the register
  98. class and assign registers accordingly. *)
  99. (* Return the union class of CLASS1 and CLASS2.
  100. See the x86-64 PS ABI for details. *)
  101. function merge_classes(class1, class2: tx64paraclass): tx64paraclass;
  102. begin
  103. (* Rule #1: If both classes are equal, this is the resulting class. *)
  104. if (class1=class2) then
  105. exit(class1);
  106. (* Rule #2: If one of the classes is NO_CLASS, the resulting class is
  107. the other class. *)
  108. if (class1=X86_64_NO_CLASS) then
  109. exit(class2);
  110. if (class2=X86_64_NO_CLASS) then
  111. exit(class1);
  112. (* Rule #3: If one of the classes is MEMORY, the result is MEMORY. *)
  113. if (class1=X86_64_MEMORY_CLASS) or
  114. (class2=X86_64_MEMORY_CLASS) then
  115. exit(X86_64_MEMORY_CLASS);
  116. (* Rule #4: If one of the classes is INTEGER, the result is INTEGER. *)
  117. { 32 bit }
  118. if ((class1=X86_64_INTEGERSI_CLASS) and
  119. (class2=X86_64_SSESF_CLASS)) or
  120. ((class2=X86_64_INTEGERSI_CLASS) and
  121. (class1=X86_64_SSESF_CLASS)) then
  122. exit(X86_64_INTEGERSI_CLASS);
  123. { 64 bit }
  124. if (class1 in [X86_64_INTEGER_CLASS,X86_64_INTEGERSI_CLASS]) or
  125. (class2 in [X86_64_INTEGER_CLASS,X86_64_INTEGERSI_CLASS]) then
  126. exit(X86_64_INTEGER_CLASS);
  127. (* Rule #5: If one of the classes is X87, X87UP, or COMPLEX_X87 class,
  128. MEMORY is used. *)
  129. if (class1 in [X86_64_X87_CLASS,X86_64_X87UP_CLASS,X86_64_COMPLEX_X87_CLASS]) or
  130. (class2 in [X86_64_X87_CLASS,X86_64_X87UP_CLASS,X86_64_COMPLEX_X87_CLASS]) then
  131. exit(X86_64_MEMORY_CLASS);
  132. (* Rule #6: Otherwise class SSE is used. *)
  133. result:=X86_64_SSE_CLASS;
  134. end;
  135. (* Classify the argument of type TYPE and mode MODE.
  136. CLASSES will be filled by the register class used to pass each word
  137. of the operand. The number of words is returned. In case the parameter
  138. should be passed in memory, 0 is returned. As a special case for zero
  139. sized containers, classes[0] will be NO_CLASS and 1 is returned.
  140. real_size contains either def.size, or a value derived from
  141. def.bitpackedsize and the field offset denoting the number of bytes
  142. spanned by a bitpacked field
  143. See the x86-64 PS ABI for details.
  144. *)
  145. function classify_as_integer_argument(real_size: aint; var classes: tx64paraclasses; byte_offset: aint): longint;
  146. var
  147. size: aint;
  148. begin
  149. size:=byte_offset+real_size;
  150. if size<=4 then
  151. classes[0]:=X86_64_INTEGERSI_CLASS
  152. else
  153. classes[0]:=X86_64_INTEGER_CLASS;
  154. if size<=8 then
  155. result:=1
  156. else
  157. begin
  158. if size<=12 then
  159. classes[1]:=X86_64_INTEGERSI_CLASS
  160. else if (size<=16) then
  161. classes[1]:=X86_64_INTEGER_CLASS
  162. else
  163. internalerror(2010021401);
  164. result:=2;
  165. end
  166. end;
  167. function classify_argument(def: tdef; varspez: tvarspez; real_size: aint; var classes: tx64paraclasses; byte_offset: aint): longint; forward;
  168. function init_aggregate_classification(def: tdef; varspez: tvarspez; out words: longint; out classes: tx64paraclasses): longint;
  169. var
  170. i: longint;
  171. begin
  172. words:=0;
  173. { win64 follows a different convention here }
  174. if (target_info.system=system_x86_64_win64) then
  175. begin
  176. if aggregate_in_registers_win64(varspez,def.size) then
  177. begin
  178. classes[0]:=X86_64_INTEGER_CLASS;
  179. result:=1;
  180. end
  181. else
  182. result:=0;
  183. exit;
  184. end;
  185. (* If the struct is larger than 32 bytes, pass it on the stack. *)
  186. if def.size > 32 then
  187. exit(0);
  188. words:=(def.size+7) div 8;
  189. (* Zero sized arrays or structures are NO_CLASS. We return 0 to
  190. signal memory class, so handle it as special case. *)
  191. if (words=0) then
  192. begin
  193. classes[0]:=X86_64_NO_CLASS;
  194. exit(1);
  195. end;
  196. { we'll be merging the classes elements with the subclasses
  197. elements, so initialise them first }
  198. for i:=low(classes) to high(classes) do
  199. classes[i]:=X86_64_NO_CLASS;
  200. result:=words;
  201. end;
  202. function classify_aggregate_element(def: tdef; varspez: tvarspez; real_size: aint; var classes: tx64paraclasses; new_byte_offset: aint): longint;
  203. var
  204. subclasses: tx64paraclasses;
  205. i,
  206. pos: longint;
  207. begin
  208. result:=classify_argument(def,varspez,real_size,subclasses,new_byte_offset mod 8);
  209. if (result=0) then
  210. exit;
  211. pos:=new_byte_offset div 8;
  212. if result-1+pos>high(classes) then
  213. internalerror(2010053108);
  214. for i:=0 to result-1 do
  215. begin
  216. classes[i+pos] :=
  217. merge_classes(subclasses[i],classes[i+pos]);
  218. end;
  219. end;
  220. function finalize_aggregate_classification(def: tdef; words: longint; var classes: tx64paraclasses): longint;
  221. var
  222. i: longint;
  223. begin
  224. if (words>2) then
  225. begin
  226. (* When size > 16 bytes, if the first one isn't
  227. X86_64_SSE_CLASS or any other ones aren't
  228. X86_64_SSEUP_CLASS, everything should be passed in
  229. memory. *)
  230. if (classes[0]<>X86_64_SSE_CLASS) then
  231. exit(0);
  232. for i:=1 to words-1 do
  233. if (classes[i]<>X86_64_SSEUP_CLASS) then
  234. exit(0);
  235. end;
  236. (* Final merger cleanup. *)
  237. (* The first one must never be X86_64_SSEUP_CLASS or
  238. X86_64_X87UP_CLASS. *)
  239. if (classes[0]=X86_64_SSEUP_CLASS) or
  240. (classes[0]=X86_64_X87UP_CLASS) then
  241. internalerror(2010021402);
  242. for i:=0 to words-1 do
  243. begin
  244. (* If one class is MEMORY, everything should be passed in
  245. memory. *)
  246. if (classes[i]=X86_64_MEMORY_CLASS) then
  247. exit(0);
  248. (* The X86_64_SSEUP_CLASS should be always preceded by
  249. X86_64_SSE_CLASS or X86_64_SSEUP_CLASS. *)
  250. if (classes[i]=X86_64_SSEUP_CLASS) and
  251. (classes[i-1]<>X86_64_SSE_CLASS) and
  252. (classes[i-1]<>X86_64_SSEUP_CLASS) then
  253. classes[i]:=X86_64_SSE_CLASS;
  254. (* If X86_64_X87UP_CLASS isn't preceded by X86_64_X87_CLASS,
  255. everything should be passed in memory. *)
  256. if (classes[i]=X86_64_X87UP_CLASS) and
  257. (classes[i-1]<>X86_64_X87_CLASS) then
  258. exit(0);
  259. end;
  260. { FIXME: in case a record contains empty padding space, e.g. a
  261. "single" field followed by a "double", then we have a problem
  262. because the cgpara helpers cannot figure out that they should
  263. skip 4 bytes after storing the single (LOC_MMREGISTER with size
  264. OS_F32) to memory before storing the double -> for now scale
  265. such locations always up to 64 bits, although this loads/stores
  266. some superfluous data }
  267. { 1) the first part is 32 bit while there is still a second part }
  268. if (classes[1]<>X86_64_NO_CLASS) then
  269. case classes[0] of
  270. X86_64_INTEGERSI_CLASS:
  271. classes[0]:=X86_64_INTEGER_CLASS;
  272. X86_64_SSESF_CLASS:
  273. classes[0]:=X86_64_SSE_CLASS;
  274. end;
  275. { 2) the second part is 32 bit, but the total size is > 12 bytes }
  276. if (def.size>12) then
  277. case classes[1] of
  278. X86_64_INTEGERSI_CLASS:
  279. classes[1]:=X86_64_INTEGER_CLASS;
  280. X86_64_SSESF_CLASS:
  281. classes[1]:=X86_64_SSE_CLASS;
  282. end;
  283. result:=words;
  284. end;
  285. function classify_record(def: tdef; varspez: tvarspez; var classes: tx64paraclasses; byte_offset: aint): longint;
  286. var
  287. vs: tfieldvarsym;
  288. size,
  289. new_byte_offset: aint;
  290. i,
  291. words,
  292. num: longint;
  293. begin
  294. result:=init_aggregate_classification(def,varspez,words,classes);
  295. if (words=0) then
  296. exit;
  297. (* Merge the fields of the structure. *)
  298. for i:=0 to tabstractrecorddef(def).symtable.symlist.count-1 do
  299. begin
  300. if tsym(tabstractrecorddef(def).symtable.symlist[i]).typ<>fieldvarsym then
  301. continue;
  302. vs:=tfieldvarsym(tabstractrecorddef(def).symtable.symlist[i]);
  303. num:=-1;
  304. if not tabstractrecordsymtable(tabstractrecorddef(def).symtable).is_packed then
  305. begin
  306. new_byte_offset:=byte_offset+vs.fieldoffset;
  307. size:=vs.vardef.size;
  308. end
  309. else
  310. begin
  311. new_byte_offset:=byte_offset+vs.fieldoffset div 8;
  312. if (vs.vardef.typ in [orddef,enumdef]) then
  313. { calculate the number of bytes spanned by
  314. this bitpacked field }
  315. size:=((vs.fieldoffset+vs.vardef.packedbitsize+7) div 8)-(vs.fieldoffset div 8)
  316. else
  317. size:=vs.vardef.size
  318. end;
  319. num:=classify_aggregate_element(vs.vardef,varspez,size,classes,new_byte_offset);
  320. if (num=0) then
  321. exit(0);
  322. end;
  323. result:=finalize_aggregate_classification(def,words,classes);
  324. end;
  325. function classify_normal_array(def: tarraydef; varspez: tvarspez; var classes: tx64paraclasses; byte_offset: aint): longint;
  326. var
  327. i, elecount: aword;
  328. size,
  329. elesize,
  330. new_byte_offset,
  331. bitoffset: aint;
  332. words,
  333. num: longint;
  334. isbitpacked: boolean;
  335. begin
  336. result:=init_aggregate_classification(def,varspez,words,classes);
  337. if (words=0) then
  338. exit;
  339. isbitpacked:=is_packed_array(def);
  340. if not isbitpacked then
  341. begin
  342. elesize:=def.elesize;
  343. size:=elesize;
  344. end
  345. else
  346. begin
  347. elesize:=def.elepackedbitsize;
  348. bitoffset:=0;
  349. end;
  350. (* Merge the elements of the array. *)
  351. i:=0;
  352. elecount:=def.elecount;
  353. repeat
  354. if not isbitpacked then
  355. begin
  356. { size does not change }
  357. new_byte_offset:=byte_offset+i*elesize;
  358. end
  359. else
  360. begin
  361. { calculate the number of bytes spanned by this bitpacked
  362. element }
  363. size:=((bitoffset+elesize+7) div 8)-(bitoffset div 8);
  364. new_byte_offset:=byte_offset+(elesize*i) div 8;
  365. { bit offset of next element }
  366. inc(bitoffset,elesize);
  367. end;
  368. num:=classify_aggregate_element(def.elementdef,varspez,size,classes,new_byte_offset);
  369. if (num=0) then
  370. exit(0);
  371. inc(i);
  372. until (i=elecount);
  373. result:=finalize_aggregate_classification(def,words,classes);
  374. end;
  375. function classify_argument(def: tdef; varspez: tvarspez; real_size: aint; var classes: tx64paraclasses; byte_offset: aint): longint;
  376. begin
  377. case def.typ of
  378. orddef,
  379. enumdef,
  380. pointerdef,
  381. classrefdef:
  382. result:=classify_as_integer_argument(real_size,classes,byte_offset);
  383. formaldef:
  384. result:=classify_as_integer_argument(voidpointertype.size,classes,byte_offset);
  385. floatdef:
  386. begin
  387. case tfloatdef(def).floattype of
  388. s32real:
  389. begin
  390. if byte_offset=0 then
  391. classes[0]:=X86_64_SSESF_CLASS
  392. else
  393. { if we have e.g. a record with two successive "single"
  394. fields, we need a 64 bit rather than a 32 bit load }
  395. classes[0]:=X86_64_SSE_CLASS;
  396. result:=1;
  397. end;
  398. s64real:
  399. begin
  400. classes[0]:=X86_64_SSEDF_CLASS;
  401. result:=1;
  402. end;
  403. s80real,
  404. sc80real:
  405. begin
  406. classes[0]:=X86_64_X87_CLASS;
  407. classes[1]:=X86_64_X87UP_CLASS;
  408. result:=2;
  409. end;
  410. s64comp,
  411. s64currency:
  412. begin
  413. classes[0]:=X86_64_INTEGER_CLASS;
  414. result:=1;
  415. end;
  416. s128real:
  417. begin
  418. classes[0]:=X86_64_SSE_CLASS;
  419. classes[1]:=X86_64_SSEUP_CLASS;
  420. result:=2;
  421. end;
  422. else
  423. internalerror(2010060301);
  424. end;
  425. end;
  426. recorddef:
  427. result:=classify_record(def,varspez,classes,byte_offset);
  428. objectdef:
  429. begin
  430. if is_object(def) then
  431. { pass by reference, like ppc and i386 }
  432. result:=0
  433. else
  434. { all kinds of pointer types: class, objcclass, interface, ... }
  435. result:=classify_as_integer_argument(voidpointertype.size,classes,byte_offset);
  436. end;
  437. setdef:
  438. begin
  439. if is_smallset(def) then
  440. result:=classify_as_integer_argument(def.size,classes,byte_offset)
  441. else
  442. result:=0;
  443. end;
  444. stringdef:
  445. begin
  446. if (tstringdef(def).stringtype in [st_shortstring,st_longstring]) then
  447. result:=0
  448. else
  449. result:=classify_as_integer_argument(def.size,classes,byte_offset);
  450. end;
  451. arraydef:
  452. begin
  453. { a dynamic array is treated like a pointer }
  454. if is_dynamic_array(def) then
  455. result:=classify_as_integer_argument(voidpointertype.size,classes,byte_offset)
  456. { other special arrays are passed on the stack }
  457. else if is_open_array(def) or
  458. is_array_of_const(def) then
  459. result:=0
  460. else
  461. { normal array }
  462. result:=classify_normal_array(tarraydef(def),varspez,classes,byte_offset);
  463. end;
  464. { the file record is definitely too big }
  465. filedef:
  466. result:=0;
  467. procvardef:
  468. begin
  469. if (po_methodpointer in tprocvardef(def).procoptions) then
  470. begin
  471. { treat as TMethod record }
  472. def:=search_system_type('TMETHOD').typedef;
  473. result:=classify_argument(def,varspez,def.size,classes,byte_offset);
  474. end
  475. else
  476. { pointer }
  477. result:=classify_as_integer_argument(def.size,classes,byte_offset);
  478. end;
  479. variantdef:
  480. begin
  481. { same as tvardata record }
  482. def:=search_system_type('TVARDATA').typedef;
  483. result:=classify_argument(def,varspez,def.size,classes,byte_offset);
  484. end;
  485. else
  486. internalerror(2010021405);
  487. end;
  488. end;
  489. procedure getvalueparaloc(varspez:tvarspez;def:tdef;var loc1,loc2:tx64paraclass);
  490. var
  491. size: aint;
  492. i: longint;
  493. classes: tx64paraclasses;
  494. numclasses: longint;
  495. begin
  496. { init the classes array, because even if classify_argument inits only
  497. one element we copy both to loc1/loc2 in case "1" is returned }
  498. for i:=low(classes) to high(classes) do
  499. classes[i]:=X86_64_NO_CLASS;
  500. { def.size internalerrors for open arrays and dynamic arrays, since
  501. their size cannot be determined at compile-time.
  502. classify_argument does not look at the realsize argument for arrays
  503. cases, but we obviously do have to pass something... }
  504. if is_special_array(def) then
  505. size:=-1
  506. else
  507. size:=def.size;
  508. numclasses:=classify_argument(def,varspez,size,classes,0);
  509. case numclasses of
  510. 0:
  511. begin
  512. loc1:=X86_64_MEMORY_CLASS;
  513. loc2:=X86_64_NO_CLASS;
  514. end;
  515. 1,2:
  516. begin
  517. { If the class is X87, X87UP or COMPLEX_X87, it is passed in memory }
  518. if classes[0] in [X86_64_X87_CLASS,X86_64_X87UP_CLASS,X86_64_COMPLEX_X87_CLASS] then
  519. classes[0]:=X86_64_MEMORY_CLASS;
  520. if classes[1] in [X86_64_X87_CLASS,X86_64_X87UP_CLASS,X86_64_COMPLEX_X87_CLASS] then
  521. classes[1]:=X86_64_MEMORY_CLASS;
  522. loc1:=classes[0];
  523. loc2:=classes[1];
  524. end
  525. else
  526. { 4 can only happen for _m256 vectors, not yet supported }
  527. internalerror(2010021501);
  528. end;
  529. end;
  530. function tx86_64paramanager.ret_in_param(def : tdef;calloption : tproccalloption) : boolean;
  531. var
  532. classes: tx64paraclasses;
  533. numclasses: longint;
  534. begin
  535. if (tf_safecall_exceptions in target_info.flags) and
  536. (calloption=pocall_safecall) then
  537. begin
  538. result := true;
  539. exit;
  540. end;
  541. case def.typ of
  542. { for records it depends on their contents and size }
  543. recorddef,
  544. { make sure we handle 'procedure of object' correctly }
  545. procvardef:
  546. begin
  547. numclasses:=classify_argument(def,vs_value,def.size,classes,0);
  548. result:=(numclasses=0);
  549. end;
  550. else
  551. result:=inherited ret_in_param(def,calloption);
  552. end;
  553. end;
  554. function tx86_64paramanager.param_use_paraloc(const cgpara:tcgpara):boolean;
  555. var
  556. paraloc : pcgparalocation;
  557. begin
  558. if not assigned(cgpara.location) then
  559. internalerror(200410102);
  560. result:=true;
  561. { All locations are LOC_REFERENCE }
  562. paraloc:=cgpara.location;
  563. while assigned(paraloc) do
  564. begin
  565. if (paraloc^.loc<>LOC_REFERENCE) then
  566. begin
  567. result:=false;
  568. exit;
  569. end;
  570. paraloc:=paraloc^.next;
  571. end;
  572. end;
  573. { true if a parameter is too large to copy and only the address is pushed }
  574. function tx86_64paramanager.push_addr_param(varspez:tvarspez;def : tdef;calloption : tproccalloption) : boolean;
  575. var
  576. classes: tx64paraclasses;
  577. numclasses: longint;
  578. begin
  579. result:=false;
  580. { var,out,constref always require address }
  581. if varspez in [vs_var,vs_out,vs_constref] then
  582. begin
  583. result:=true;
  584. exit;
  585. end;
  586. { Only vs_const, vs_value here }
  587. case def.typ of
  588. formaldef :
  589. result:=true;
  590. recorddef :
  591. begin
  592. { MetroWerks Pascal: const records always passed by reference
  593. (for Mac OS X interfaces) }
  594. if (calloption=pocall_mwpascal) and
  595. (varspez=vs_const) then
  596. result:=true
  597. { Win ABI depends on size to pass it in a register or not }
  598. else if (target_info.system=system_x86_64_win64) then
  599. result:=not aggregate_in_registers_win64(varspez,def.size)
  600. { pass constant parameters that would be passed via memory by
  601. reference for non-cdecl/cppdecl, and make sure that the tmethod
  602. record (size=16) is passed the same way as a complex procvar }
  603. else if ((varspez=vs_const) and
  604. not(calloption in cdecl_pocalls)) or
  605. (def.size=16) then
  606. begin
  607. numclasses:=classify_argument(def,vs_value,def.size,classes,0);
  608. result:=numclasses=0;
  609. end
  610. else
  611. { SysV ABI always passes it as value parameter }
  612. result:=false;
  613. end;
  614. arraydef :
  615. begin
  616. { cdecl array of const need to be ignored and therefor be puhsed
  617. as value parameter with length 0 }
  618. if ((calloption in cdecl_pocalls) and
  619. is_array_of_const(def)) or
  620. is_dynamic_array(def) then
  621. result:=false
  622. else
  623. { pass all arrays by reference to be compatible with C (passing
  624. an array by value (= copying it on the stack) does not exist,
  625. because an array is the same as a pointer there }
  626. result:=true
  627. end;
  628. objectdef :
  629. begin
  630. { don't treat objects like records, because we only know wheter
  631. or not they'll have a VMT after the entire object is parsed
  632. -> if they are used as function result from one of their own
  633. methods, their size can still change after we've determined
  634. whether this function result should be returned by reference or
  635. by value }
  636. if is_object(def) then
  637. result:=true;
  638. end;
  639. variantdef,
  640. stringdef,
  641. procvardef,
  642. setdef :
  643. begin
  644. numclasses:=classify_argument(def,vs_value,def.size,classes,0);
  645. result:=numclasses=0;
  646. end;
  647. end;
  648. end;
  649. function tx86_64paramanager.get_volatile_registers_int(calloption : tproccalloption):tcpuregisterset;
  650. begin
  651. if target_info.system=system_x86_64_win64 then
  652. result:=[RS_RAX,RS_RCX,RS_RDX,RS_R8,RS_R9,RS_R10,RS_R11]
  653. else
  654. result:=[RS_RAX,RS_RCX,RS_RDX,RS_RSI,RS_RDI,RS_R8,RS_R9,RS_R10,RS_R11];
  655. end;
  656. function tx86_64paramanager.get_volatile_registers_mm(calloption : tproccalloption):tcpuregisterset;
  657. begin
  658. if target_info.system=system_x86_64_win64 then
  659. result:=[RS_XMM0..RS_XMM5]
  660. else
  661. result:=[RS_XMM0..RS_XMM15];
  662. end;
  663. function tx86_64paramanager.get_volatile_registers_fpu(calloption : tproccalloption):tcpuregisterset;
  664. begin
  665. result:=[RS_ST0..RS_ST7];
  666. end;
  667. procedure tx86_64paramanager.getintparaloc(calloption : tproccalloption; nr : longint; def : tdef; var cgpara : tcgpara);
  668. var
  669. paraloc : pcgparalocation;
  670. begin
  671. cgpara.reset;
  672. cgpara.size:=def_cgsize(def);
  673. cgpara.intsize:=tcgsize2size[cgpara.size];
  674. cgpara.alignment:=get_para_align(calloption);
  675. cgpara.def:=def;
  676. paraloc:=cgpara.add_location;
  677. with paraloc^ do
  678. begin
  679. size:=OS_INT;
  680. if target_info.system=system_x86_64_win64 then
  681. begin
  682. if nr<1 then
  683. internalerror(200304303)
  684. else if nr<=high(paraintsupregs_winx64)+1 then
  685. begin
  686. loc:=LOC_REGISTER;
  687. register:=newreg(R_INTREGISTER,paraintsupregs_winx64[nr-1],R_SUBWHOLE);
  688. end
  689. else
  690. begin
  691. loc:=LOC_REFERENCE;
  692. reference.index:=NR_STACK_POINTER_REG;
  693. reference.offset:=(nr-6)*sizeof(aint);
  694. end;
  695. end
  696. else
  697. begin
  698. if nr<1 then
  699. internalerror(200304303)
  700. else if nr<=high(paraintsupregs)+1 then
  701. begin
  702. loc:=LOC_REGISTER;
  703. register:=newreg(R_INTREGISTER,paraintsupregs[nr-1],R_SUBWHOLE);
  704. end
  705. else
  706. begin
  707. loc:=LOC_REFERENCE;
  708. reference.index:=NR_STACK_POINTER_REG;
  709. reference.offset:=(nr-6)*sizeof(aint);
  710. end;
  711. end;
  712. end;
  713. end;
  714. function tx86_64paramanager.get_funcretloc(p : tabstractprocdef; side: tcallercallee; forcetempdef: tdef): tcgpara;
  715. const
  716. intretregs: array[0..1] of tregister = (NR_FUNCTION_RETURN_REG,NR_FUNCTION_RETURN_REG_HIGH);
  717. mmretregs: array[0..1] of tregister = (NR_MM_RESULT_REG,NR_MM_RESULT_REG_HIGH);
  718. var
  719. classes: tx64paraclasses;
  720. i,
  721. numclasses: longint;
  722. intretregidx,
  723. mmretregidx: longint;
  724. retcgsize : tcgsize;
  725. paraloc : pcgparalocation;
  726. begin
  727. if set_common_funcretloc_info(p,forcetempdef,retcgsize,result) then
  728. exit;
  729. { integer sizes < 32 bit have to be sign/zero extended to 32 bit on
  730. the callee side (caller can expect those bits are valid) }
  731. if (side=calleeside) and
  732. (retcgsize in [OS_8,OS_S8,OS_16,OS_S16]) then
  733. begin
  734. retcgsize:=OS_S32;
  735. result.def:=s32inttype;
  736. result.intsize:=4;
  737. result.size:=retcgsize;
  738. end;
  739. { Return in FPU register? -> don't use classify_argument(), because
  740. currency and comp need special treatment here (they are integer class
  741. when passing as parameter, but LOC_FPUREGISTER as function result) }
  742. if result.def.typ=floatdef then
  743. begin
  744. paraloc:=result.add_location;
  745. case tfloatdef(result.def).floattype of
  746. s32real:
  747. begin
  748. paraloc^.loc:=LOC_MMREGISTER;
  749. paraloc^.register:=newreg(R_MMREGISTER,RS_MM_RESULT_REG,R_SUBMMS);
  750. paraloc^.size:=OS_F32;
  751. end;
  752. s64real:
  753. begin
  754. paraloc^.loc:=LOC_MMREGISTER;
  755. paraloc^.register:=newreg(R_MMREGISTER,RS_MM_RESULT_REG,R_SUBMMD);
  756. paraloc^.size:=OS_F64;
  757. end;
  758. { the first two only exist on targets with an x87, on others
  759. they are replace by int64 }
  760. s64currency,
  761. s64comp,
  762. s80real,
  763. sc80real:
  764. begin
  765. paraloc^.loc:=LOC_FPUREGISTER;
  766. paraloc^.register:=NR_FPU_RESULT_REG;
  767. paraloc^.size:=retcgsize;
  768. end;
  769. else
  770. internalerror(200405034);
  771. end;
  772. end
  773. else
  774. { Return in register }
  775. begin
  776. numclasses:=classify_argument(result.def,vs_value,result.def.size,classes,0);
  777. { this would mean a memory return }
  778. if (numclasses=0) then
  779. internalerror(2010021502);
  780. { this would mean an _m256 vector (valid, but not yet supported) }
  781. if (numclasses>2) then
  782. internalerror(2010021503);
  783. intretregidx:=0;
  784. mmretregidx:=0;
  785. for i:=0 to numclasses-1 do
  786. begin
  787. paraloc:=result.add_location;
  788. case classes[i] of
  789. X86_64_INTEGERSI_CLASS,
  790. X86_64_INTEGER_CLASS:
  791. begin
  792. paraloc^.loc:=LOC_REGISTER;
  793. paraloc^.register:=intretregs[intretregidx];
  794. if classes[i]=X86_64_INTEGER_CLASS then
  795. paraloc^.size:=OS_64
  796. else if result.intsize in [1,2,4] then
  797. paraloc^.size:=retcgsize
  798. else
  799. paraloc^.size:=OS_32;
  800. setsubreg(paraloc^.register,cgsize2subreg(R_INTREGISTER,paraloc^.size));
  801. inc(intretregidx);
  802. end;
  803. X86_64_SSE_CLASS,
  804. X86_64_SSEUP_CLASS,
  805. X86_64_SSESF_CLASS,
  806. X86_64_SSEDF_CLASS:
  807. begin
  808. paraloc^.loc:=LOC_MMREGISTER;
  809. paraloc^.register:=mmretregs[mmretregidx];
  810. case classes[i] of
  811. X86_64_SSESF_CLASS:
  812. begin
  813. setsubreg(paraloc^.register,R_SUBMMS);
  814. paraloc^.size:=OS_F32;
  815. end;
  816. X86_64_SSEDF_CLASS:
  817. begin
  818. setsubreg(paraloc^.register,R_SUBMMD);
  819. paraloc^.size:=OS_F64;
  820. end;
  821. else
  822. begin
  823. setsubreg(paraloc^.register,R_SUBMMWHOLE);
  824. paraloc^.size:=OS_M64;
  825. end;
  826. end;
  827. inc(mmretregidx);
  828. end;
  829. X86_64_NO_CLASS:
  830. begin
  831. { empty record/array }
  832. if (i<>0) or
  833. (numclasses<>1) then
  834. internalerror(2010060302);
  835. paraloc^.loc:=LOC_VOID;
  836. end;
  837. else
  838. internalerror(2010021504);
  839. end;
  840. end;
  841. end;
  842. end;
  843. procedure tx86_64paramanager.create_paraloc_info_intern(p : tabstractprocdef; side: tcallercallee;paras:tparalist;
  844. var intparareg,mmparareg,parasize:longint;varargsparas: boolean);
  845. var
  846. hp : tparavarsym;
  847. paradef : tdef;
  848. paraloc : pcgparalocation;
  849. subreg : tsubregister;
  850. pushaddr : boolean;
  851. paracgsize : tcgsize;
  852. loc : array[1..2] of tx64paraclass;
  853. needintloc,
  854. needmmloc,
  855. paralen,
  856. locidx,
  857. i,
  858. varalign,
  859. paraalign : longint;
  860. begin
  861. paraalign:=get_para_align(p.proccalloption);
  862. { Register parameters are assigned from left to right }
  863. for i:=0 to paras.count-1 do
  864. begin
  865. hp:=tparavarsym(paras[i]);
  866. paradef:=hp.vardef;
  867. pushaddr:=push_addr_param(hp.varspez,paradef,p.proccalloption);
  868. if pushaddr then
  869. begin
  870. loc[1]:=X86_64_INTEGER_CLASS;
  871. loc[2]:=X86_64_NO_CLASS;
  872. paracgsize:=OS_ADDR;
  873. paralen:=sizeof(pint);
  874. paradef:=getpointerdef(paradef);
  875. end
  876. else
  877. begin
  878. getvalueparaloc(hp.varspez,paradef,loc[1],loc[2]);
  879. paralen:=push_size(hp.varspez,paradef,p.proccalloption);
  880. paracgsize:=def_cgsize(paradef);
  881. { integer sizes < 32 bit have to be sign/zero extended to 32 bit
  882. on the caller side }
  883. if (side=callerside) and
  884. (paracgsize in [OS_8,OS_S8,OS_16,OS_S16]) then
  885. begin
  886. paracgsize:=OS_S32;
  887. paralen:=4;
  888. paradef:=s32inttype;
  889. end;
  890. end;
  891. { cheat for now, we should copy the value to an mm reg as well (FK) }
  892. if varargsparas and
  893. (target_info.system = system_x86_64_win64) and
  894. (paradef.typ = floatdef) then
  895. begin
  896. loc[2]:=X86_64_NO_CLASS;
  897. if paracgsize=OS_F64 then
  898. begin
  899. loc[1]:=X86_64_INTEGER_CLASS;
  900. paracgsize:=OS_64;
  901. paradef:=u64inttype;
  902. end
  903. else
  904. begin
  905. loc[1]:=X86_64_INTEGERSI_CLASS;
  906. paracgsize:=OS_32;
  907. paradef:=u32inttype;
  908. end;
  909. end;
  910. hp.paraloc[side].reset;
  911. hp.paraloc[side].size:=paracgsize;
  912. hp.paraloc[side].intsize:=paralen;
  913. hp.paraloc[side].Alignment:=paraalign;
  914. hp.paraloc[side].def:=paradef;
  915. if paralen>0 then
  916. begin
  917. { Enough registers free? }
  918. needintloc:=0;
  919. needmmloc:=0;
  920. for locidx:=low(loc) to high(loc) do
  921. case loc[locidx] of
  922. X86_64_INTEGER_CLASS,
  923. X86_64_INTEGERSI_CLASS:
  924. inc(needintloc);
  925. X86_64_SSE_CLASS,
  926. X86_64_SSESF_CLASS,
  927. X86_64_SSEDF_CLASS,
  928. X86_64_SSEUP_CLASS:
  929. inc(needmmloc);
  930. end;
  931. { the "-1" is because we can also use the current register }
  932. if ((target_info.system=system_x86_64_win64) and
  933. ((intparareg+needintloc-1 > high(paraintsupregs_winx64)) or
  934. (mmparareg+needmmloc-1 > high(parammsupregs_winx64)))) or
  935. ((target_info.system<>system_x86_64_win64) and
  936. ((intparareg+needintloc-1 > high(paraintsupregs)) or
  937. (mmparareg+needmmloc-1 > high(parammsupregs)))) then
  938. begin
  939. { If there are no registers available for any
  940. eightbyte of an argument, the whole argument is
  941. passed on the stack. }
  942. loc[low(loc)]:=X86_64_MEMORY_CLASS;
  943. for locidx:=succ(low(loc)) to high(loc) do
  944. loc[locidx]:=X86_64_NO_CLASS;
  945. end;
  946. locidx:=1;
  947. while (paralen>0) do
  948. begin
  949. if locidx>2 then
  950. internalerror(200501283);
  951. { Allocate }
  952. case loc[locidx] of
  953. X86_64_INTEGER_CLASS,
  954. X86_64_INTEGERSI_CLASS:
  955. begin
  956. paraloc:=hp.paraloc[side].add_location;
  957. paraloc^.loc:=LOC_REGISTER;
  958. if (paracgsize=OS_NO) or (loc[2]<>X86_64_NO_CLASS) then
  959. begin
  960. if loc[locidx]=X86_64_INTEGER_CLASS then
  961. begin
  962. paraloc^.size:=OS_INT;
  963. subreg:=R_SUBWHOLE;
  964. end
  965. else
  966. begin
  967. paraloc^.size:=OS_32;
  968. subreg:=R_SUBD;
  969. end;
  970. end
  971. else
  972. begin
  973. paraloc^.size:=paracgsize;
  974. { s64comp is pushed in an int register }
  975. if paraloc^.size=OS_C64 then
  976. paraloc^.size:=OS_64;
  977. subreg:=cgsize2subreg(R_INTREGISTER,paraloc^.size);
  978. end;
  979. { winx64 uses different registers }
  980. if target_info.system=system_x86_64_win64 then
  981. paraloc^.register:=newreg(R_INTREGISTER,paraintsupregs_winx64[intparareg],subreg)
  982. else
  983. paraloc^.register:=newreg(R_INTREGISTER,paraintsupregs[intparareg],subreg);
  984. { matching mm register must be skipped }
  985. if target_info.system=system_x86_64_win64 then
  986. inc(mmparareg);
  987. inc(intparareg);
  988. dec(paralen,tcgsize2size[paraloc^.size]);
  989. end;
  990. X86_64_SSE_CLASS,
  991. X86_64_SSESF_CLASS,
  992. X86_64_SSEDF_CLASS,
  993. X86_64_SSEUP_CLASS:
  994. begin
  995. paraloc:=hp.paraloc[side].add_location;
  996. paraloc^.loc:=LOC_MMREGISTER;
  997. case loc[locidx] of
  998. X86_64_SSESF_CLASS:
  999. begin
  1000. subreg:=R_SUBMMS;
  1001. paraloc^.size:=OS_F32;
  1002. end;
  1003. X86_64_SSEDF_CLASS:
  1004. begin
  1005. subreg:=R_SUBMMD;
  1006. paraloc^.size:=OS_F64;
  1007. end;
  1008. else
  1009. begin
  1010. subreg:=R_SUBMMWHOLE;
  1011. paraloc^.size:=OS_M64;
  1012. end;
  1013. end;
  1014. { winx64 uses different registers }
  1015. if target_info.system=system_x86_64_win64 then
  1016. paraloc^.register:=newreg(R_MMREGISTER,parammsupregs_winx64[mmparareg],subreg)
  1017. else
  1018. paraloc^.register:=newreg(R_MMREGISTER,parammsupregs[mmparareg],subreg);
  1019. { matching int register must be skipped }
  1020. if target_info.system=system_x86_64_win64 then
  1021. inc(intparareg);
  1022. inc(mmparareg);
  1023. dec(paralen,tcgsize2size[paraloc^.size]);
  1024. end;
  1025. X86_64_MEMORY_CLASS :
  1026. begin
  1027. paraloc:=hp.paraloc[side].add_location;
  1028. paraloc^.loc:=LOC_REFERENCE;
  1029. {Hack alert!!! We should modify int_cgsize to handle OS_128,
  1030. however, since int_cgsize is called in many places in the
  1031. compiler where only a few can already handle OS_128, fixing it
  1032. properly is out of the question to release 2.2.0 in time. (DM)}
  1033. if paracgsize=OS_128 then
  1034. if paralen=8 then
  1035. paraloc^.size:=OS_64
  1036. else if paralen=16 then
  1037. paraloc^.size:=OS_128
  1038. else
  1039. internalerror(200707143)
  1040. else if paracgsize in [OS_F32,OS_F64,OS_F80,OS_F128] then
  1041. paraloc^.size:=int_float_cgsize(paralen)
  1042. else
  1043. paraloc^.size:=int_cgsize(paralen);
  1044. if side=callerside then
  1045. paraloc^.reference.index:=NR_STACK_POINTER_REG
  1046. else
  1047. paraloc^.reference.index:=NR_FRAME_POINTER_REG;
  1048. varalign:=used_align(size_2_align(paralen),paraalign,paraalign);
  1049. paraloc^.reference.offset:=parasize;
  1050. parasize:=align(parasize+paralen,varalign);
  1051. paralen:=0;
  1052. end;
  1053. else
  1054. internalerror(2010053113);
  1055. end;
  1056. if (locidx<2) and
  1057. (loc[locidx+1]<>X86_64_NO_CLASS) then
  1058. inc(locidx);
  1059. end;
  1060. end
  1061. else
  1062. begin
  1063. paraloc:=hp.paraloc[side].add_location;
  1064. paraloc^.loc:=LOC_VOID;
  1065. end;
  1066. end;
  1067. { Register parameters are assigned from left-to-right, but the
  1068. offsets on the stack are right-to-left. There is no need
  1069. to reverse the offset, only adapt the calleeside with the
  1070. start offset of the first param on the stack }
  1071. if side=calleeside then
  1072. begin
  1073. for i:=0 to paras.count-1 do
  1074. begin
  1075. hp:=tparavarsym(paras[i]);
  1076. paraloc:=hp.paraloc[side].location;
  1077. while paraloc<>nil do
  1078. begin
  1079. with paraloc^ do
  1080. if (loc=LOC_REFERENCE) then
  1081. inc(reference.offset,target_info.first_parm_offset);
  1082. paraloc:=paraloc^.next;
  1083. end;
  1084. end;
  1085. end;
  1086. end;
  1087. function tx86_64paramanager.create_varargs_paraloc_info(p : tabstractprocdef; varargspara:tvarargsparalist):longint;
  1088. var
  1089. intparareg,mmparareg,
  1090. parasize : longint;
  1091. begin
  1092. intparareg:=0;
  1093. mmparareg:=0;
  1094. if target_info.system=system_x86_64_win64 then
  1095. parasize:=4*8
  1096. else
  1097. parasize:=0;
  1098. { calculate the registers for the normal parameters }
  1099. create_paraloc_info_intern(p,callerside,p.paras,intparareg,mmparareg,parasize,false);
  1100. { append the varargs }
  1101. create_paraloc_info_intern(p,callerside,varargspara,intparareg,mmparareg,parasize,true);
  1102. { store used no. of SSE registers, that needs to be passed in %AL }
  1103. varargspara.mmregsused:=mmparareg;
  1104. result:=parasize;
  1105. end;
  1106. function tx86_64paramanager.create_paraloc_info(p : tabstractprocdef; side: tcallercallee):longint;
  1107. var
  1108. intparareg,mmparareg,
  1109. parasize : longint;
  1110. begin
  1111. intparareg:=0;
  1112. mmparareg:=0;
  1113. if target_info.system=system_x86_64_win64 then
  1114. parasize:=4*8
  1115. else
  1116. parasize:=0;
  1117. create_paraloc_info_intern(p,side,p.paras,intparareg,mmparareg,parasize,false);
  1118. { Create Function result paraloc }
  1119. create_funcretloc_info(p,side);
  1120. { We need to return the size allocated on the stack }
  1121. result:=parasize;
  1122. end;
  1123. begin
  1124. paramanager:=tx86_64paramanager.create;
  1125. end.