paramgr.pas 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644
  1. {
  2. Copyright (c) 2002 by Florian Klaempfl
  3. Generic calling convention handling
  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. {# Parameter passing manager. Used to manage how
  18. parameters are passed to routines.
  19. }
  20. unit paramgr;
  21. {$i fpcdefs.inc}
  22. interface
  23. uses
  24. cclasses,globtype,
  25. cpubase,cgbase,cgutils,
  26. parabase,
  27. aasmtai,aasmdata,
  28. symconst,symtype,symsym,symdef;
  29. type
  30. {# This class defines some methods to take care of routine
  31. parameters. It should be overridden for each new processor
  32. }
  33. { tparamanager }
  34. tparamanager = class
  35. { true if the location in paraloc can be reused as localloc }
  36. function param_use_paraloc(const cgpara:tcgpara):boolean;virtual;
  37. { Returns true if the return value is actually a parameter pointer }
  38. function ret_in_param(def:tdef;pd:tabstractprocdef):boolean;virtual;
  39. function push_high_param(varspez:tvarspez;def : tdef;calloption : tproccalloption) : boolean;virtual;
  40. function keep_para_array_range(varspez:tvarspez;def : tdef;calloption : tproccalloption) : boolean;virtual;
  41. { Returns true if a parameter is too large to copy and only
  42. the address is pushed
  43. }
  44. function push_addr_param(varspez:tvarspez;def : tdef;calloption : tproccalloption) : boolean;virtual;abstract;
  45. { returns true if a parameter must be handled via copy-out (construct
  46. a reference, copy the parameter's value there in case of copy-in/out, pass the reference)
  47. }
  48. function push_copyout_param(varspez:tvarspez;def : tdef;calloption : tproccalloption) : boolean;virtual;
  49. { return the size of a push }
  50. function push_size(varspez:tvarspez;def : tdef;calloption : tproccalloption) : longint;virtual;
  51. {# Returns a structure giving the information on
  52. the storage of the parameter (which must be
  53. an integer parameter). This is only used when calling
  54. internal routines directly, where all parameters must
  55. be 4-byte values.
  56. In case the location is a register, this register is allocated.
  57. Call freeintparaloc() after the call to free the locations again.
  58. Default implementation: don't do anything at all (in case you don't
  59. use register parameter passing)
  60. @param(list Current assembler list)
  61. @param(nr Parameter number of routine, starting from 1)
  62. }
  63. function get_para_align(calloption : tproccalloption):byte;virtual;
  64. function get_volatile_registers_int(calloption : tproccalloption):tcpuregisterset;virtual;
  65. function get_volatile_registers_address(calloption : tproccalloption):tcpuregisterset;virtual;
  66. function get_volatile_registers_fpu(calloption : tproccalloption):tcpuregisterset;virtual;
  67. function get_volatile_registers_flags(calloption : tproccalloption):tcpuregisterset;virtual;
  68. function get_volatile_registers_mm(calloption : tproccalloption):tcpuregisterset;virtual;
  69. procedure getintparaloc(pd: tabstractprocdef; nr : longint; var cgpara: tcgpara);virtual;
  70. {# allocate an individual pcgparalocation that's part of a tcgpara
  71. @param(list Current assembler list)
  72. @param(loc Parameter location element)
  73. }
  74. procedure allocparaloc(list: TAsmList; const paraloc: pcgparalocation);
  75. {# allocate a parameter location created with create_paraloc_info
  76. @param(list Current assembler list)
  77. @param(loc Parameter location)
  78. }
  79. procedure alloccgpara(list: TAsmList; const cgpara: TCGPara); virtual;
  80. {# free a parameter location allocated with alloccgpara
  81. @param(list Current assembler list)
  82. @param(loc Parameter location)
  83. }
  84. procedure freecgpara(list: TAsmList; const cgpara: TCGPara); virtual;
  85. { This is used to populate the location information on all parameters
  86. for the routine as seen in either the caller or the callee. It returns
  87. the size allocated on the stack
  88. }
  89. function create_paraloc_info(p : tabstractprocdef; side: tcallercallee):longint;virtual;abstract;
  90. { Returns the location of the function result if p had def as
  91. function result instead of its actual result. Used if the compiler
  92. forces the function result to something different than the real
  93. result. }
  94. function get_funcretloc(p : tabstractprocdef; side: tcallercallee; forcetempdef: tdef): tcgpara;virtual;abstract;
  95. procedure create_funcretloc_info(p : tabstractprocdef; side: tcallercallee);
  96. { This is used to populate the location information on all parameters
  97. for the routine when it is being inlined. It returns
  98. the size allocated on the stack
  99. }
  100. function create_inline_paraloc_info(p : tabstractprocdef):longint;virtual;
  101. { This is used to populate the location information on all parameters
  102. for the routine that are passed as varargs. It returns
  103. the size allocated on the stack (including the normal parameters)
  104. }
  105. function create_varargs_paraloc_info(p : tabstractprocdef; varargspara:tvarargsparalist):longint;virtual;abstract;
  106. function is_stack_paraloc(paraloc: pcgparalocation): boolean;virtual;
  107. procedure createtempparaloc(list: TAsmList;calloption : tproccalloption;parasym : tparavarsym;can_use_final_stack_loc : boolean;var cgpara:TCGPara);virtual;
  108. procedure duplicatecgparaloc(const orgparaloc: pcgparalocation; intonewparaloc: pcgparalocation);
  109. procedure duplicateparaloc(list: TAsmList;calloption : tproccalloption;parasym : tparavarsym;var cgpara:TCGPara);
  110. function parseparaloc(parasym : tparavarsym;const s : string) : boolean;virtual;
  111. function parsefuncretloc(p : tabstractprocdef; const s : string) : boolean;virtual;
  112. { allocate room for parameters on the stack in the entry code? }
  113. function use_fixed_stack: boolean;
  114. { whether stack pointer can be changed in the middle of procedure }
  115. function use_stackalloc: boolean;
  116. strict protected
  117. { common part of get_funcretloc; returns true if retloc is completely
  118. initialized afterwards }
  119. function set_common_funcretloc_info(p : tabstractprocdef; forcetempdef: tdef; out retcgsize: tcgsize; out retloc: tcgpara): boolean;
  120. { common part of ret_in_param; is called by ret_in_param at the
  121. beginning and every tparamanager descendant can decide to call it
  122. itself as well; parameter retinparam is only valid if function
  123. returns true }
  124. function handle_common_ret_in_param(def:tdef;pd:tabstractprocdef;out retinparam:boolean):boolean;
  125. { returns the def to use for a tparalocation part of a cgpara for paradef,
  126. for which the def is paradef and the integer length is restlen.
  127. fullsize is true if restlen equals the full paradef size }
  128. function get_paraloc_def(paradef: tdef; restlen: aint; fullsize: boolean): tdef;
  129. end;
  130. var
  131. paramanager : tparamanager;
  132. implementation
  133. uses
  134. systems,
  135. cgobj,tgobj,
  136. defutil,verbose;
  137. { true if the location in paraloc can be reused as localloc }
  138. function tparamanager.param_use_paraloc(const cgpara:tcgpara):boolean;
  139. begin
  140. result:=false;
  141. end;
  142. { true if uses a parameter as return value }
  143. function tparamanager.ret_in_param(def:tdef;pd:tabstractprocdef):boolean;
  144. begin
  145. { This handles all managed types, including COM interfaces and Variants }
  146. if handle_common_ret_in_param(def,pd,result) then
  147. exit;
  148. ret_in_param:=(def.typ=arraydef) or
  149. (def.typ=recorddef) or
  150. (def.typ=stringdef) or
  151. ((def.typ=procvardef) and not tprocvardef(def).is_addressonly) or
  152. ((def.typ=objectdef) and (is_object(def))) or
  153. ((def.typ=setdef) and not is_smallset(def));
  154. end;
  155. function tparamanager.push_high_param(varspez:tvarspez;def : tdef;calloption : tproccalloption) : boolean;
  156. begin
  157. push_high_param:=not(calloption in cdecl_pocalls) and
  158. (
  159. is_open_array(def) or
  160. is_open_string(def) or
  161. is_array_of_const(def)
  162. );
  163. end;
  164. function tparamanager.keep_para_array_range(varspez: tvarspez; def: tdef; calloption: tproccalloption): boolean;
  165. begin
  166. result:=push_high_param(varspez,def,calloption);
  167. end;
  168. function tparamanager.push_copyout_param(varspez: tvarspez; def: tdef; calloption: tproccalloption): boolean;
  169. begin
  170. push_copyout_param:=false;
  171. end;
  172. { return the size of a push }
  173. function tparamanager.push_size(varspez:tvarspez;def : tdef;calloption : tproccalloption) : longint;
  174. begin
  175. push_size:=-1;
  176. case varspez of
  177. vs_constref,
  178. vs_out,
  179. vs_var :
  180. push_size:=voidpointertype.size;
  181. vs_value,
  182. vs_const :
  183. begin
  184. if push_addr_param(varspez,def,calloption) then
  185. push_size:=voidpointertype.size
  186. else
  187. begin
  188. { special array are normally pushed by addr, only for
  189. cdecl array of const it comes here and the pushsize
  190. is unknown }
  191. if is_array_of_const(def) then
  192. push_size:=0
  193. else
  194. push_size:=def.size;
  195. end;
  196. end;
  197. end;
  198. end;
  199. function tparamanager.get_para_align(calloption : tproccalloption):byte;
  200. begin
  201. result:=std_param_align;
  202. end;
  203. function tparamanager.get_volatile_registers_int(calloption : tproccalloption):tcpuregisterset;
  204. begin
  205. result:=[];
  206. end;
  207. function tparamanager.get_volatile_registers_address(calloption : tproccalloption):tcpuregisterset;
  208. begin
  209. result:=[];
  210. end;
  211. function tparamanager.get_volatile_registers_fpu(calloption : tproccalloption):tcpuregisterset;
  212. begin
  213. result:=[];
  214. end;
  215. function tparamanager.get_volatile_registers_flags(calloption : tproccalloption):tcpuregisterset;
  216. begin
  217. result:=[];
  218. end;
  219. function tparamanager.get_volatile_registers_mm(calloption : tproccalloption):tcpuregisterset;
  220. begin
  221. result:=[];
  222. end;
  223. {$if first_mm_imreg = 0}
  224. {$WARN 4044 OFF} { Comparison might be always false ... }
  225. {$endif}
  226. procedure tparamanager.allocparaloc(list: TAsmList; const paraloc: pcgparalocation);
  227. begin
  228. case paraloc^.loc of
  229. LOC_REGISTER,
  230. LOC_CREGISTER:
  231. begin
  232. if getsupreg(paraloc^.register)<first_int_imreg then
  233. cg.getcpuregister(list,paraloc^.register);
  234. end;
  235. {$ifndef x86}
  236. { don't allocate ST(x), they're not handled by the register allocator }
  237. LOC_FPUREGISTER,
  238. LOC_CFPUREGISTER:
  239. begin
  240. if getsupreg(paraloc^.register)<first_fpu_imreg then
  241. cg.getcpuregister(list,paraloc^.register);
  242. end;
  243. {$endif not x86}
  244. LOC_MMREGISTER,
  245. LOC_CMMREGISTER :
  246. begin
  247. if getsupreg(paraloc^.register)<first_mm_imreg then
  248. cg.getcpuregister(list,paraloc^.register);
  249. end;
  250. end;
  251. end;
  252. procedure tparamanager.alloccgpara(list: TAsmList; const cgpara: TCGPara);
  253. var
  254. paraloc : pcgparalocation;
  255. begin
  256. paraloc:=cgpara.location;
  257. while assigned(paraloc) do
  258. begin
  259. allocparaloc(list,paraloc);
  260. paraloc:=paraloc^.next;
  261. end;
  262. end;
  263. procedure tparamanager.freecgpara(list: TAsmList; const cgpara: TCGPara);
  264. var
  265. paraloc : Pcgparalocation;
  266. href : treference;
  267. begin
  268. paraloc:=cgpara.location;
  269. while assigned(paraloc) do
  270. begin
  271. case paraloc^.loc of
  272. LOC_VOID:
  273. ;
  274. LOC_REGISTER,
  275. LOC_CREGISTER:
  276. begin
  277. if getsupreg(paraloc^.register)<first_int_imreg then
  278. cg.ungetcpuregister(list,paraloc^.register);
  279. end;
  280. LOC_FPUREGISTER,
  281. LOC_CFPUREGISTER:
  282. begin
  283. if getsupreg(paraloc^.register)<first_fpu_imreg then
  284. cg.ungetcpuregister(list,paraloc^.register);
  285. end;
  286. LOC_MMREGISTER,
  287. LOC_CMMREGISTER :
  288. begin
  289. if getsupreg(paraloc^.register)<first_mm_imreg then
  290. cg.ungetcpuregister(list,paraloc^.register);
  291. end;
  292. LOC_REFERENCE,
  293. LOC_CREFERENCE :
  294. begin
  295. if use_fixed_stack then
  296. begin
  297. { don't use reference_reset_base, because that will depend on cgobj }
  298. fillchar(href,sizeof(href),0);
  299. href.base:=paraloc^.reference.index;
  300. href.offset:=paraloc^.reference.offset;
  301. tg.ungetiftemp(list,href);
  302. end;
  303. end;
  304. else
  305. internalerror(2004110212);
  306. end;
  307. paraloc:=paraloc^.next;
  308. end;
  309. end;
  310. function tparamanager.is_stack_paraloc(paraloc: pcgparalocation): boolean;
  311. begin
  312. result:=
  313. assigned(paraloc) and
  314. (paraloc^.loc=LOC_REFERENCE) and
  315. (paraloc^.reference.index=NR_STACK_POINTER_REG);
  316. end;
  317. procedure tparamanager.createtempparaloc(list: TAsmList;calloption : tproccalloption;parasym : tparavarsym;can_use_final_stack_loc : boolean;var cgpara:TCGPara);
  318. var
  319. href : treference;
  320. len : aint;
  321. paraloc,
  322. newparaloc : pcgparalocation;
  323. begin
  324. paraloc:=parasym.paraloc[callerside].location;
  325. cgpara.reset;
  326. cgpara.size:=parasym.paraloc[callerside].size;
  327. cgpara.intsize:=parasym.paraloc[callerside].intsize;
  328. cgpara.alignment:=parasym.paraloc[callerside].alignment;
  329. cgpara.def:=parasym.paraloc[callerside].def;
  330. while assigned(paraloc) do
  331. begin
  332. if paraloc^.size=OS_NO then
  333. len:=push_size(parasym.varspez,parasym.vardef,calloption)
  334. else
  335. len:=tcgsize2size[paraloc^.size];
  336. newparaloc:=cgpara.add_location;
  337. newparaloc^.size:=paraloc^.size;
  338. newparaloc^.def:=paraloc^.def;
  339. { shiftval overlaps with part of the reference, so it may be
  340. different from 0 and if wr then force the newparaloc to a register
  341. in the optimization below, shiftval will remain <> 0 }
  342. if not(paraloc^.loc in [LOC_REFERENCE,LOC_CREFERENCE]) then
  343. newparaloc^.shiftval:=paraloc^.shiftval;
  344. { $warning maybe release this optimization for all targets? }
  345. { released for all CPUs:
  346. i386 isn't affected anyways because it uses the stack to push parameters
  347. on arm it reduces executable size of the compiler by 2.1 per cent (FK) }
  348. { Does it fit a register? }
  349. if ((not can_use_final_stack_loc and
  350. use_fixed_stack) or
  351. not is_stack_paraloc(paraloc)) and
  352. (len<=sizeof(pint)) and
  353. (paraloc^.size in [OS_8,OS_16,OS_32,OS_64,OS_128,OS_S8,OS_S16,OS_S32,OS_S64,OS_S128]) then
  354. newparaloc^.loc:=LOC_REGISTER
  355. else
  356. newparaloc^.loc:=paraloc^.loc;
  357. case newparaloc^.loc of
  358. LOC_REGISTER :
  359. begin
  360. if (vo_has_explicit_paraloc in parasym.varoptions) and (paraloc^.loc = LOC_REGISTER) then
  361. newparaloc^.register:=paraloc^.register
  362. else
  363. newparaloc^.register:=cg.getintregister(list,paraloc^.size);
  364. end;
  365. LOC_FPUREGISTER :
  366. newparaloc^.register:=cg.getfpuregister(list,paraloc^.size);
  367. LOC_MMREGISTER :
  368. newparaloc^.register:=cg.getmmregister(list,paraloc^.size);
  369. LOC_REFERENCE :
  370. begin
  371. if (can_use_final_stack_loc or
  372. not use_fixed_stack) and
  373. is_stack_paraloc(paraloc) then
  374. duplicatecgparaloc(paraloc,newparaloc)
  375. else
  376. begin
  377. if assigned(cgpara.def) then
  378. tg.gethltemp(list,cgpara.def,len,tt_persistent,href)
  379. else
  380. tg.gettemp(list,len,cgpara.alignment,tt_persistent,href);
  381. newparaloc^.reference.index:=href.base;
  382. newparaloc^.reference.offset:=href.offset;
  383. end;
  384. end;
  385. end;
  386. paraloc:=paraloc^.next;
  387. end;
  388. end;
  389. procedure tparamanager.duplicatecgparaloc(const orgparaloc: pcgparalocation; intonewparaloc: pcgparalocation);
  390. begin
  391. move(orgparaloc^,intonewparaloc^,sizeof(intonewparaloc^));
  392. intonewparaloc^.next:=nil;
  393. end;
  394. procedure tparamanager.duplicateparaloc(list: TAsmList;calloption : tproccalloption;parasym : tparavarsym;var cgpara:TCGPara);
  395. var
  396. paraloc,
  397. newparaloc : pcgparalocation;
  398. begin
  399. cgpara.reset;
  400. cgpara.size:=parasym.paraloc[callerside].size;
  401. cgpara.intsize:=parasym.paraloc[callerside].intsize;
  402. cgpara.alignment:=parasym.paraloc[callerside].alignment;
  403. paraloc:=parasym.paraloc[callerside].location;
  404. while assigned(paraloc) do
  405. begin
  406. newparaloc:=cgpara.add_location;
  407. duplicatecgparaloc(paraloc,newparaloc);
  408. paraloc:=paraloc^.next;
  409. end;
  410. end;
  411. procedure tparamanager.create_funcretloc_info(p : tabstractprocdef; side: tcallercallee);
  412. begin
  413. p.funcretloc[side]:=get_funcretloc(p,side,nil);
  414. end;
  415. function tparamanager.create_inline_paraloc_info(p : tabstractprocdef):longint;
  416. begin
  417. { We need to return the size allocated }
  418. p.init_paraloc_info(callbothsides);
  419. result:=p.calleeargareasize;
  420. end;
  421. function tparamanager.parseparaloc(parasym: tparavarsym; const s: string): boolean;
  422. begin
  423. Result:=False;
  424. internalerror(200807235);
  425. end;
  426. function tparamanager.parsefuncretloc(p: tabstractprocdef; const s: string): boolean;
  427. begin
  428. Result:=False;
  429. internalerror(200807236);
  430. end;
  431. function tparamanager.use_fixed_stack: boolean;
  432. begin
  433. {$ifdef i386}
  434. result := target_info.stackalign > 4;
  435. {$else i386}
  436. {$ifdef cputargethasfixedstack}
  437. result := true;
  438. {$else cputargethasfixedstack}
  439. result := false;
  440. {$endif cputargethasfixedstack}
  441. {$endif i386}
  442. end;
  443. { This is a separate function because at least win64 allows stack allocations
  444. despite of fixed stack semantics (actually supporting it requires generating
  445. a compliant stack frame, not yet possible) }
  446. function tparamanager.use_stackalloc: boolean;
  447. begin
  448. result:=not use_fixed_stack;
  449. end;
  450. function tparamanager.set_common_funcretloc_info(p : tabstractprocdef; forcetempdef: tdef; out retcgsize: tcgsize; out retloc: tcgpara): boolean;
  451. var
  452. paraloc : pcgparalocation;
  453. begin
  454. result:=true;
  455. retloc.init;
  456. if not assigned(forcetempdef) then
  457. retloc.def:=p.returndef
  458. else
  459. begin
  460. retloc.def:=forcetempdef;
  461. retloc.temporary:=true;
  462. end;
  463. retloc.alignment:=get_para_align(p.proccalloption);
  464. { void has no location }
  465. if is_void(retloc.def) then
  466. begin
  467. paraloc:=retloc.add_location;
  468. retloc.size:=OS_NO;
  469. retcgsize:=OS_NO;
  470. retloc.intsize:=0;
  471. paraloc^.def:=retloc.def;
  472. paraloc^.size:=OS_NO;
  473. paraloc^.loc:=LOC_VOID;
  474. exit;
  475. end;
  476. { Constructors return self instead of a boolean }
  477. if p.proctypeoption=potype_constructor then
  478. begin
  479. retloc.def:=tdef(p.owner.defowner);
  480. if not (is_implicit_pointer_object_type(retloc.def) or
  481. (retloc.def.typ<>objectdef)) then
  482. retloc.def:=getpointerdef(retloc.def);
  483. end;
  484. retcgsize:=def_cgsize(retloc.def);
  485. retloc.intsize:=retloc.def.size;
  486. retloc.size:=retcgsize;
  487. { Return is passed as var parameter }
  488. if ret_in_param(retloc.def,p) then
  489. begin
  490. retloc.def:=getpointerdef(retloc.def);
  491. paraloc:=retloc.add_location;
  492. paraloc^.loc:=LOC_REFERENCE;
  493. paraloc^.size:=retcgsize;
  494. paraloc^.def:=retloc.def;
  495. exit;
  496. end;
  497. result:=false;
  498. end;
  499. function tparamanager.handle_common_ret_in_param(def: tdef;
  500. pd: tabstractprocdef; out retinparam: boolean): boolean;
  501. begin
  502. { This must be system independent: safecall and record constructor result
  503. is always returned in param.
  504. Furthermore, any managed type is returned in param, in order to avoid
  505. its finalization on exception at callee side. }
  506. if (tf_safecall_exceptions in target_info.flags) and
  507. (pd.proccalloption=pocall_safecall) or
  508. (
  509. (pd.proctypeoption=potype_constructor)and
  510. (
  511. is_record(def) or
  512. (
  513. (def.typ<>objectdef) and
  514. (pd.owner.symtabletype=objectsymtable) and
  515. is_objectpascal_helper(tdef(pd.owner.defowner))
  516. )
  517. )
  518. ) or is_managed_type(def) then
  519. begin
  520. retinparam:=true;
  521. exit(true);
  522. end;
  523. if pd.proctypeoption=potype_constructor then
  524. begin
  525. retinparam:=false;
  526. exit(true);
  527. end;
  528. result:=false;
  529. end;
  530. function tparamanager.get_paraloc_def(paradef: tdef; restlen: aint; fullsize: boolean): tdef;
  531. begin
  532. if fullsize then
  533. result:=paradef
  534. { no support for 128 bit ints -> tcgsize2orddef can't handle
  535. OS_(S)128 }
  536. else if restlen in [1,2,4,8] then
  537. result:=cgsize_orddef(int_cgsize(restlen))
  538. else
  539. result:=getarraydef(u8inttype,restlen);
  540. end;
  541. procedure tparamanager.getintparaloc(pd: tabstractprocdef; nr : longint; var cgpara: tcgpara);
  542. begin
  543. if (nr<1) or (nr>pd.paras.count) then
  544. InternalError(2013060101);
  545. pd.init_paraloc_info(callerside);
  546. cgpara:=tparavarsym(pd.paras[nr-1]).paraloc[callerside].getcopy;
  547. end;
  548. initialization
  549. ;
  550. finalization
  551. paramanager.free;
  552. end.