2
0

paramgr.pas 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646
  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. if handle_common_ret_in_param(def,pd,result) then
  146. exit;
  147. ret_in_param:=((def.typ=arraydef) and not(is_dynamic_array(def))) or
  148. (def.typ=recorddef) or
  149. (def.typ=stringdef) or
  150. ((def.typ=procvardef) and not tprocvardef(def).is_addressonly) or
  151. { interfaces are also passed by reference to be compatible with delphi and COM }
  152. ((def.typ=objectdef) and (is_object(def) or is_interface(def) or is_dispinterface(def))) or
  153. (def.typ=variantdef) or
  154. ((def.typ=setdef) and not is_smallset(def));
  155. end;
  156. function tparamanager.push_high_param(varspez:tvarspez;def : tdef;calloption : tproccalloption) : boolean;
  157. begin
  158. push_high_param:=not(calloption in cdecl_pocalls) and
  159. (
  160. is_open_array(def) or
  161. is_open_string(def) or
  162. is_array_of_const(def)
  163. );
  164. end;
  165. function tparamanager.keep_para_array_range(varspez: tvarspez; def: tdef; calloption: tproccalloption): boolean;
  166. begin
  167. result:=push_high_param(varspez,def,calloption);
  168. end;
  169. function tparamanager.push_copyout_param(varspez: tvarspez; def: tdef; calloption: tproccalloption): boolean;
  170. begin
  171. push_copyout_param:=false;
  172. end;
  173. { return the size of a push }
  174. function tparamanager.push_size(varspez:tvarspez;def : tdef;calloption : tproccalloption) : longint;
  175. begin
  176. push_size:=-1;
  177. case varspez of
  178. vs_constref,
  179. vs_out,
  180. vs_var :
  181. push_size:=sizeof(pint);
  182. vs_value,
  183. vs_const :
  184. begin
  185. if push_addr_param(varspez,def,calloption) then
  186. push_size:=sizeof(pint)
  187. else
  188. begin
  189. { special array are normally pushed by addr, only for
  190. cdecl array of const it comes here and the pushsize
  191. is unknown }
  192. if is_array_of_const(def) then
  193. push_size:=0
  194. else
  195. push_size:=def.size;
  196. end;
  197. end;
  198. end;
  199. end;
  200. function tparamanager.get_para_align(calloption : tproccalloption):byte;
  201. begin
  202. result:=std_param_align;
  203. end;
  204. function tparamanager.get_volatile_registers_int(calloption : tproccalloption):tcpuregisterset;
  205. begin
  206. result:=[];
  207. end;
  208. function tparamanager.get_volatile_registers_address(calloption : tproccalloption):tcpuregisterset;
  209. begin
  210. result:=[];
  211. end;
  212. function tparamanager.get_volatile_registers_fpu(calloption : tproccalloption):tcpuregisterset;
  213. begin
  214. result:=[];
  215. end;
  216. function tparamanager.get_volatile_registers_flags(calloption : tproccalloption):tcpuregisterset;
  217. begin
  218. result:=[];
  219. end;
  220. function tparamanager.get_volatile_registers_mm(calloption : tproccalloption):tcpuregisterset;
  221. begin
  222. result:=[];
  223. end;
  224. {$if first_mm_imreg = 0}
  225. {$WARN 4044 OFF} { Comparison might be always false ... }
  226. {$endif}
  227. procedure tparamanager.allocparaloc(list: TAsmList; const paraloc: pcgparalocation);
  228. begin
  229. case paraloc^.loc of
  230. LOC_REGISTER,
  231. LOC_CREGISTER:
  232. begin
  233. if getsupreg(paraloc^.register)<first_int_imreg then
  234. begin
  235. cg.getcpuregister(list,paraloc^.register);
  236. {$ifdef cpu16bitalu}
  237. if paraloc^.Size in [OS_32, OS_S32] then
  238. cg.getcpuregister(list,GetNextReg(paraloc^.register));
  239. {$endif cpu16bitalu}
  240. end;
  241. end;
  242. {$ifndef x86}
  243. { don't allocate ST(x), they're not handled by the register allocator }
  244. LOC_FPUREGISTER,
  245. LOC_CFPUREGISTER:
  246. begin
  247. if getsupreg(paraloc^.register)<first_fpu_imreg then
  248. cg.getcpuregister(list,paraloc^.register);
  249. end;
  250. {$endif not x86}
  251. LOC_MMREGISTER,
  252. LOC_CMMREGISTER :
  253. begin
  254. if getsupreg(paraloc^.register)<first_mm_imreg then
  255. cg.getcpuregister(list,paraloc^.register);
  256. end;
  257. end;
  258. end;
  259. procedure tparamanager.alloccgpara(list: TAsmList; const cgpara: TCGPara);
  260. var
  261. paraloc : pcgparalocation;
  262. begin
  263. paraloc:=cgpara.location;
  264. while assigned(paraloc) do
  265. begin
  266. allocparaloc(list,paraloc);
  267. paraloc:=paraloc^.next;
  268. end;
  269. end;
  270. procedure tparamanager.freecgpara(list: TAsmList; const cgpara: TCGPara);
  271. var
  272. paraloc : Pcgparalocation;
  273. href : treference;
  274. begin
  275. paraloc:=cgpara.location;
  276. while assigned(paraloc) do
  277. begin
  278. case paraloc^.loc of
  279. LOC_VOID:
  280. ;
  281. LOC_REGISTER,
  282. LOC_CREGISTER:
  283. begin
  284. if getsupreg(paraloc^.register)<first_int_imreg then
  285. begin
  286. cg.ungetcpuregister(list,paraloc^.register);
  287. {$ifdef cpu16bitalu}
  288. if paraloc^.Size in [OS_32, OS_S32] then
  289. cg.ungetcpuregister(list,GetNextReg(paraloc^.register));
  290. {$endif cpu16bitalu}
  291. end;
  292. end;
  293. LOC_FPUREGISTER,
  294. LOC_CFPUREGISTER:
  295. begin
  296. if getsupreg(paraloc^.register)<first_fpu_imreg then
  297. cg.ungetcpuregister(list,paraloc^.register);
  298. end;
  299. LOC_MMREGISTER,
  300. LOC_CMMREGISTER :
  301. begin
  302. if getsupreg(paraloc^.register)<first_mm_imreg then
  303. cg.ungetcpuregister(list,paraloc^.register);
  304. end;
  305. LOC_REFERENCE,
  306. LOC_CREFERENCE :
  307. begin
  308. if use_fixed_stack then
  309. begin
  310. { don't use reference_reset_base, because that will depend on cgobj }
  311. fillchar(href,sizeof(href),0);
  312. href.base:=paraloc^.reference.index;
  313. href.offset:=paraloc^.reference.offset;
  314. tg.ungetiftemp(list,href);
  315. end;
  316. end;
  317. else
  318. internalerror(2004110212);
  319. end;
  320. paraloc:=paraloc^.next;
  321. end;
  322. end;
  323. function tparamanager.is_stack_paraloc(paraloc: pcgparalocation): boolean;
  324. begin
  325. result:=
  326. assigned(paraloc) and
  327. (paraloc^.loc=LOC_REFERENCE) and
  328. (paraloc^.reference.index=NR_STACK_POINTER_REG);
  329. end;
  330. procedure tparamanager.createtempparaloc(list: TAsmList;calloption : tproccalloption;parasym : tparavarsym;can_use_final_stack_loc : boolean;var cgpara:TCGPara);
  331. var
  332. href : treference;
  333. len : aint;
  334. paraloc,
  335. newparaloc : pcgparalocation;
  336. begin
  337. paraloc:=parasym.paraloc[callerside].location;
  338. cgpara.reset;
  339. cgpara.size:=parasym.paraloc[callerside].size;
  340. cgpara.intsize:=parasym.paraloc[callerside].intsize;
  341. cgpara.alignment:=parasym.paraloc[callerside].alignment;
  342. cgpara.def:=parasym.paraloc[callerside].def;
  343. while assigned(paraloc) do
  344. begin
  345. if paraloc^.size=OS_NO then
  346. len:=push_size(parasym.varspez,parasym.vardef,calloption)
  347. else
  348. len:=tcgsize2size[paraloc^.size];
  349. newparaloc:=cgpara.add_location;
  350. newparaloc^.size:=paraloc^.size;
  351. newparaloc^.def:=paraloc^.def;
  352. newparaloc^.shiftval:=paraloc^.shiftval;
  353. { $warning maybe release this optimization for all targets? }
  354. { released for all CPUs:
  355. i386 isn't affected anyways because it uses the stack to push parameters
  356. on arm it reduces executable size of the compiler by 2.1 per cent (FK) }
  357. { Does it fit a register? }
  358. if ((not can_use_final_stack_loc and
  359. use_fixed_stack) or
  360. not is_stack_paraloc(paraloc)) and
  361. (len<=sizeof(pint)) and
  362. (paraloc^.size in [OS_8,OS_16,OS_32,OS_64,OS_128,OS_S8,OS_S16,OS_S32,OS_S64,OS_S128]) then
  363. newparaloc^.loc:=LOC_REGISTER
  364. else
  365. newparaloc^.loc:=paraloc^.loc;
  366. case newparaloc^.loc of
  367. LOC_REGISTER :
  368. newparaloc^.register:=cg.getintregister(list,paraloc^.size);
  369. LOC_FPUREGISTER :
  370. newparaloc^.register:=cg.getfpuregister(list,paraloc^.size);
  371. LOC_MMREGISTER :
  372. newparaloc^.register:=cg.getmmregister(list,paraloc^.size);
  373. LOC_REFERENCE :
  374. begin
  375. if (can_use_final_stack_loc or
  376. not use_fixed_stack) and
  377. is_stack_paraloc(paraloc) then
  378. duplicatecgparaloc(paraloc,newparaloc)
  379. else
  380. begin
  381. if assigned(cgpara.def) then
  382. tg.gethltemp(list,cgpara.def,len,tt_persistent,href)
  383. else
  384. tg.gettemp(list,len,cgpara.alignment,tt_persistent,href);
  385. newparaloc^.reference.index:=href.base;
  386. newparaloc^.reference.offset:=href.offset;
  387. end;
  388. end;
  389. end;
  390. paraloc:=paraloc^.next;
  391. end;
  392. end;
  393. procedure tparamanager.duplicatecgparaloc(const orgparaloc: pcgparalocation; intonewparaloc: pcgparalocation);
  394. begin
  395. move(orgparaloc^,intonewparaloc^,sizeof(intonewparaloc^));
  396. intonewparaloc^.next:=nil;
  397. end;
  398. procedure tparamanager.duplicateparaloc(list: TAsmList;calloption : tproccalloption;parasym : tparavarsym;var cgpara:TCGPara);
  399. var
  400. paraloc,
  401. newparaloc : pcgparalocation;
  402. begin
  403. cgpara.reset;
  404. cgpara.size:=parasym.paraloc[callerside].size;
  405. cgpara.intsize:=parasym.paraloc[callerside].intsize;
  406. cgpara.alignment:=parasym.paraloc[callerside].alignment;
  407. paraloc:=parasym.paraloc[callerside].location;
  408. while assigned(paraloc) do
  409. begin
  410. newparaloc:=cgpara.add_location;
  411. duplicatecgparaloc(paraloc,newparaloc);
  412. paraloc:=paraloc^.next;
  413. end;
  414. end;
  415. procedure tparamanager.create_funcretloc_info(p : tabstractprocdef; side: tcallercallee);
  416. begin
  417. p.funcretloc[side]:=get_funcretloc(p,side,nil);
  418. end;
  419. function tparamanager.create_inline_paraloc_info(p : tabstractprocdef):longint;
  420. begin
  421. { We need to return the size allocated }
  422. p.init_paraloc_info(callbothsides);
  423. result:=p.calleeargareasize;
  424. end;
  425. function tparamanager.parseparaloc(parasym: tparavarsym; const s: string): boolean;
  426. begin
  427. Result:=False;
  428. internalerror(200807235);
  429. end;
  430. function tparamanager.parsefuncretloc(p: tabstractprocdef; const s: string): boolean;
  431. begin
  432. Result:=False;
  433. internalerror(200807236);
  434. end;
  435. function tparamanager.use_fixed_stack: boolean;
  436. begin
  437. {$ifdef i386}
  438. result := target_info.stackalign > 4;
  439. {$else i386}
  440. {$ifdef cputargethasfixedstack}
  441. result := true;
  442. {$else cputargethasfixedstack}
  443. result := false;
  444. {$endif cputargethasfixedstack}
  445. {$endif i386}
  446. end;
  447. { This is a separate function because at least win64 allows stack allocations
  448. despite of fixed stack semantics (actually supporting it requires generating
  449. a compliant stack frame, not yet possible) }
  450. function tparamanager.use_stackalloc: boolean;
  451. begin
  452. result:=not use_fixed_stack;
  453. end;
  454. function tparamanager.set_common_funcretloc_info(p : tabstractprocdef; forcetempdef: tdef; out retcgsize: tcgsize; out retloc: tcgpara): boolean;
  455. var
  456. paraloc : pcgparalocation;
  457. begin
  458. result:=true;
  459. retloc.init;
  460. if not assigned(forcetempdef) then
  461. retloc.def:=p.returndef
  462. else
  463. begin
  464. retloc.def:=forcetempdef;
  465. retloc.temporary:=true;
  466. end;
  467. retloc.alignment:=get_para_align(p.proccalloption);
  468. { void has no location }
  469. if is_void(retloc.def) then
  470. begin
  471. paraloc:=retloc.add_location;
  472. retloc.size:=OS_NO;
  473. retcgsize:=OS_NO;
  474. retloc.intsize:=0;
  475. paraloc^.def:=retloc.def;
  476. paraloc^.size:=OS_NO;
  477. paraloc^.loc:=LOC_VOID;
  478. exit;
  479. end;
  480. { Constructors return self instead of a boolean }
  481. if p.proctypeoption=potype_constructor then
  482. begin
  483. retloc.def:=tdef(p.owner.defowner);
  484. if not (is_implicit_pointer_object_type(retloc.def) or
  485. (retloc.def.typ<>objectdef)) then
  486. retloc.def:=getpointerdef(retloc.def);
  487. end;
  488. retcgsize:=def_cgsize(retloc.def);
  489. retloc.intsize:=retloc.def.size;
  490. retloc.size:=retcgsize;
  491. { Return is passed as var parameter }
  492. if ret_in_param(retloc.def,p) then
  493. begin
  494. retloc.def:=getpointerdef(retloc.def);
  495. paraloc:=retloc.add_location;
  496. paraloc^.loc:=LOC_REFERENCE;
  497. paraloc^.size:=retcgsize;
  498. paraloc^.def:=retloc.def;
  499. exit;
  500. end;
  501. result:=false;
  502. end;
  503. function tparamanager.handle_common_ret_in_param(def: tdef;
  504. pd: tabstractprocdef; out retinparam: boolean): boolean;
  505. begin
  506. { this must be system independent safecall and record constructor result
  507. is always return in param }
  508. if (tf_safecall_exceptions in target_info.flags) and
  509. (pd.proccalloption=pocall_safecall) or
  510. (
  511. (pd.proctypeoption=potype_constructor)and
  512. (
  513. is_record(def) or
  514. (
  515. (def.typ<>objectdef) and
  516. (pd.owner.symtabletype=objectsymtable) and
  517. is_objectpascal_helper(tdef(pd.owner.defowner))
  518. )
  519. )
  520. ) then
  521. begin
  522. retinparam:=true;
  523. exit(true);
  524. end;
  525. if pd.proctypeoption=potype_constructor then
  526. begin
  527. retinparam:=false;
  528. exit(true);
  529. end;
  530. result:=false;
  531. end;
  532. function tparamanager.get_paraloc_def(paradef: tdef; restlen: aint; fullsize: boolean): tdef;
  533. begin
  534. if fullsize then
  535. result:=paradef
  536. { no support for 128 bit ints -> tcgsize2orddef can't handle
  537. OS_(S)128 }
  538. else if restlen in [1,2,4,8] then
  539. result:=cgsize_orddef(int_cgsize(restlen))
  540. else
  541. result:=getarraydef(u8inttype,restlen);
  542. end;
  543. procedure tparamanager.getintparaloc(pd: tabstractprocdef; nr : longint; var cgpara: tcgpara);
  544. begin
  545. if (nr<1) or (nr>pd.paras.count) then
  546. InternalError(2013060101);
  547. pd.init_paraloc_info(callerside);
  548. cgpara:=tparavarsym(pd.paras[nr-1]).paraloc[callerside].getcopy;
  549. end;
  550. initialization
  551. ;
  552. finalization
  553. paramanager.free;
  554. end.