paramgr.pas 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653
  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 get_para_regoff(proccalloption: tproccalloption; paraloc: pcgparalocation; out reg: Byte; out off: LongInt);virtual;
  70. procedure getintparaloc(list: TAsmList; pd: tabstractprocdef; nr : longint; var cgpara: tcgpara);virtual;
  71. {# allocate an individual pcgparalocation that's part of a tcgpara
  72. @param(list Current assembler list)
  73. @param(loc Parameter location element)
  74. }
  75. procedure allocparaloc(list: TAsmList; const paraloc: pcgparalocation);
  76. {# allocate a parameter location created with create_paraloc_info
  77. @param(list Current assembler list)
  78. @param(loc Parameter location)
  79. }
  80. procedure alloccgpara(list: TAsmList; const cgpara: TCGPara); virtual;
  81. {# free a parameter location allocated with alloccgpara
  82. @param(list Current assembler list)
  83. @param(loc Parameter location)
  84. }
  85. procedure freecgpara(list: TAsmList; const cgpara: TCGPara); virtual;
  86. { This is used to populate the location information on all parameters
  87. for the routine as seen in either the caller or the callee. It returns
  88. the size allocated on the stack
  89. }
  90. function create_paraloc_info(p : tabstractprocdef; side: tcallercallee):longint;virtual;abstract;
  91. { Returns the location of the function result if p had def as
  92. function result instead of its actual result. Used if the compiler
  93. forces the function result to something different than the real
  94. result. }
  95. function get_funcretloc(p : tabstractprocdef; side: tcallercallee; forcetempdef: tdef): tcgpara;virtual;abstract;
  96. procedure create_funcretloc_info(p : tabstractprocdef; side: tcallercallee);
  97. { This is used to populate the location information on all parameters
  98. for the routine when it is being inlined. It returns
  99. the size allocated on the stack
  100. }
  101. function create_inline_paraloc_info(p : tabstractprocdef):longint;virtual;
  102. { This is used to populate the location information on all parameters
  103. for the routine that are passed as varargs. It returns
  104. the size allocated on the stack (including the normal parameters)
  105. }
  106. function create_varargs_paraloc_info(p : tabstractprocdef; varargspara:tvarargsparalist):longint;virtual;abstract;
  107. function is_stack_paraloc(paraloc: pcgparalocation): boolean;virtual;
  108. procedure createtempparaloc(list: TAsmList;calloption : tproccalloption;parasym : tparavarsym;can_use_final_stack_loc : boolean;var cgpara:TCGPara);virtual;
  109. procedure duplicatecgparaloc(const orgparaloc: pcgparalocation; intonewparaloc: pcgparalocation);
  110. procedure duplicateparaloc(list: TAsmList;calloption : tproccalloption;parasym : tparavarsym;var cgpara:TCGPara);
  111. function parseparaloc(parasym : tparavarsym;const s : string) : boolean;virtual;
  112. function parsefuncretloc(p : tabstractprocdef; const s : string) : boolean;virtual;
  113. { allocate room for parameters on the stack in the entry code? }
  114. function use_fixed_stack: boolean;
  115. { whether stack pointer can be changed in the middle of procedure }
  116. function use_stackalloc: boolean;
  117. strict protected
  118. { common part of get_funcretloc; returns true if retloc is completely
  119. initialized afterwards }
  120. function set_common_funcretloc_info(p : tabstractprocdef; forcetempdef: tdef; out retcgsize: tcgsize; out retloc: tcgpara): boolean;
  121. { common part of ret_in_param; is called by ret_in_param at the
  122. beginning and every tparamanager descendant can decide to call it
  123. itself as well; parameter retinparam is only valid if function
  124. returns true }
  125. function handle_common_ret_in_param(def:tdef;pd:tabstractprocdef;out retinparam:boolean):boolean;
  126. { returns the def to use for a tparalocation part of a cgpara for paradef,
  127. for which the def is paradef and the integer length is restlen.
  128. fullsize is true if restlen equals the full paradef size }
  129. function get_paraloc_def(paradef: tdef; restlen: aint; fullsize: boolean): tdef;
  130. end;
  131. var
  132. paramanager : tparamanager;
  133. implementation
  134. uses
  135. systems,
  136. cgobj,tgobj,
  137. defutil,verbose;
  138. { true if the location in paraloc can be reused as localloc }
  139. function tparamanager.param_use_paraloc(const cgpara:tcgpara):boolean;
  140. begin
  141. result:=false;
  142. end;
  143. { true if uses a parameter as return value }
  144. function tparamanager.ret_in_param(def:tdef;pd:tabstractprocdef):boolean;
  145. begin
  146. { This handles all managed types, including COM interfaces and Variants }
  147. if handle_common_ret_in_param(def,pd,result) then
  148. exit;
  149. ret_in_param:=(def.typ=arraydef) or
  150. (def.typ=recorddef) or
  151. (def.typ=stringdef) or
  152. ((def.typ=procvardef) and not tprocvardef(def).is_addressonly) or
  153. ((def.typ=objectdef) and (is_object(def))) 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:=voidpointertype.size;
  182. vs_value,
  183. vs_const :
  184. begin
  185. if push_addr_param(varspez,def,calloption) then
  186. push_size:=voidpointertype.size
  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. procedure tparamanager.get_para_regoff(proccalloption: tproccalloption; paraloc: pcgparalocation; out reg: Byte; out off: LongInt);
  225. begin
  226. reg:=0;
  227. off:=0;
  228. end;
  229. {$if first_mm_imreg = 0}
  230. {$WARN 4044 OFF} { Comparison might be always false ... }
  231. {$endif}
  232. procedure tparamanager.allocparaloc(list: TAsmList; const paraloc: pcgparalocation);
  233. begin
  234. case paraloc^.loc of
  235. LOC_REGISTER,
  236. LOC_CREGISTER:
  237. begin
  238. if getsupreg(paraloc^.register)<first_int_imreg then
  239. cg.getcpuregister(list,paraloc^.register);
  240. end;
  241. {$ifndef x86}
  242. { don't allocate ST(x), they're not handled by the register allocator }
  243. LOC_FPUREGISTER,
  244. LOC_CFPUREGISTER:
  245. begin
  246. if getsupreg(paraloc^.register)<first_fpu_imreg then
  247. cg.getcpuregister(list,paraloc^.register);
  248. end;
  249. {$endif not x86}
  250. LOC_MMREGISTER,
  251. LOC_CMMREGISTER :
  252. begin
  253. if getsupreg(paraloc^.register)<first_mm_imreg then
  254. cg.getcpuregister(list,paraloc^.register);
  255. end;
  256. end;
  257. end;
  258. procedure tparamanager.alloccgpara(list: TAsmList; const cgpara: TCGPara);
  259. var
  260. paraloc : pcgparalocation;
  261. begin
  262. paraloc:=cgpara.location;
  263. while assigned(paraloc) do
  264. begin
  265. allocparaloc(list,paraloc);
  266. paraloc:=paraloc^.next;
  267. end;
  268. end;
  269. procedure tparamanager.freecgpara(list: TAsmList; const cgpara: TCGPara);
  270. var
  271. paraloc : Pcgparalocation;
  272. href : treference;
  273. begin
  274. paraloc:=cgpara.location;
  275. while assigned(paraloc) do
  276. begin
  277. case paraloc^.loc of
  278. LOC_VOID:
  279. ;
  280. LOC_REGISTER,
  281. LOC_CREGISTER:
  282. begin
  283. if getsupreg(paraloc^.register)<first_int_imreg then
  284. cg.ungetcpuregister(list,paraloc^.register);
  285. end;
  286. LOC_FPUREGISTER,
  287. LOC_CFPUREGISTER:
  288. begin
  289. if getsupreg(paraloc^.register)<first_fpu_imreg then
  290. cg.ungetcpuregister(list,paraloc^.register);
  291. end;
  292. LOC_MMREGISTER,
  293. LOC_CMMREGISTER :
  294. begin
  295. if getsupreg(paraloc^.register)<first_mm_imreg then
  296. cg.ungetcpuregister(list,paraloc^.register);
  297. end;
  298. LOC_REFERENCE,
  299. LOC_CREFERENCE :
  300. begin
  301. if use_fixed_stack then
  302. begin
  303. { don't use reference_reset_base, because that will depend on cgobj }
  304. fillchar(href,sizeof(href),0);
  305. href.base:=paraloc^.reference.index;
  306. href.offset:=paraloc^.reference.offset;
  307. tg.ungetiftemp(list,href);
  308. end;
  309. end;
  310. else
  311. internalerror(2004110212);
  312. end;
  313. paraloc:=paraloc^.next;
  314. end;
  315. end;
  316. function tparamanager.is_stack_paraloc(paraloc: pcgparalocation): boolean;
  317. begin
  318. result:=
  319. assigned(paraloc) and
  320. (paraloc^.loc=LOC_REFERENCE) and
  321. (paraloc^.reference.index=NR_STACK_POINTER_REG);
  322. end;
  323. procedure tparamanager.createtempparaloc(list: TAsmList;calloption : tproccalloption;parasym : tparavarsym;can_use_final_stack_loc : boolean;var cgpara:TCGPara);
  324. var
  325. href : treference;
  326. len : aint;
  327. paraloc,
  328. newparaloc : pcgparalocation;
  329. begin
  330. paraloc:=parasym.paraloc[callerside].location;
  331. cgpara.reset;
  332. cgpara.size:=parasym.paraloc[callerside].size;
  333. cgpara.intsize:=parasym.paraloc[callerside].intsize;
  334. cgpara.alignment:=parasym.paraloc[callerside].alignment;
  335. cgpara.def:=parasym.paraloc[callerside].def;
  336. while assigned(paraloc) do
  337. begin
  338. if paraloc^.size=OS_NO then
  339. len:=push_size(parasym.varspez,parasym.vardef,calloption)
  340. else
  341. len:=tcgsize2size[paraloc^.size];
  342. newparaloc:=cgpara.add_location;
  343. newparaloc^.size:=paraloc^.size;
  344. newparaloc^.def:=paraloc^.def;
  345. { shiftval overlaps with part of the reference, so it may be
  346. different from 0 and if wr then force the newparaloc to a register
  347. in the optimization below, shiftval will remain <> 0 }
  348. if not(paraloc^.loc in [LOC_REFERENCE,LOC_CREFERENCE]) then
  349. newparaloc^.shiftval:=paraloc^.shiftval;
  350. { $warning maybe release this optimization for all targets? }
  351. { released for all CPUs:
  352. i386 isn't affected anyways because it uses the stack to push parameters
  353. on arm it reduces executable size of the compiler by 2.1 per cent (FK) }
  354. { Does it fit a register? }
  355. if ((not can_use_final_stack_loc and
  356. use_fixed_stack) or
  357. not is_stack_paraloc(paraloc)) and
  358. (len<=sizeof(pint)) and
  359. (paraloc^.size in [OS_8,OS_16,OS_32,OS_64,OS_128,OS_S8,OS_S16,OS_S32,OS_S64,OS_S128]) then
  360. newparaloc^.loc:=LOC_REGISTER
  361. else
  362. newparaloc^.loc:=paraloc^.loc;
  363. case newparaloc^.loc of
  364. LOC_REGISTER :
  365. begin
  366. if (vo_has_explicit_paraloc in parasym.varoptions) and (paraloc^.loc = LOC_REGISTER) then
  367. newparaloc^.register:=paraloc^.register
  368. else
  369. newparaloc^.register:=cg.getintregister(list,paraloc^.size);
  370. end;
  371. LOC_FPUREGISTER :
  372. newparaloc^.register:=cg.getfpuregister(list,paraloc^.size);
  373. LOC_MMREGISTER :
  374. newparaloc^.register:=cg.getmmregister(list,paraloc^.size);
  375. LOC_REFERENCE :
  376. begin
  377. if (can_use_final_stack_loc or
  378. not use_fixed_stack) and
  379. is_stack_paraloc(paraloc) then
  380. duplicatecgparaloc(paraloc,newparaloc)
  381. else
  382. begin
  383. if assigned(cgpara.def) then
  384. tg.gethltemp(list,cgpara.def,len,tt_persistent,href)
  385. else
  386. tg.gettemp(list,len,cgpara.alignment,tt_persistent,href);
  387. newparaloc^.reference.index:=href.base;
  388. newparaloc^.reference.offset:=href.offset;
  389. end;
  390. end;
  391. end;
  392. paraloc:=paraloc^.next;
  393. end;
  394. end;
  395. procedure tparamanager.duplicatecgparaloc(const orgparaloc: pcgparalocation; intonewparaloc: pcgparalocation);
  396. begin
  397. move(orgparaloc^,intonewparaloc^,sizeof(intonewparaloc^));
  398. intonewparaloc^.next:=nil;
  399. end;
  400. procedure tparamanager.duplicateparaloc(list: TAsmList;calloption : tproccalloption;parasym : tparavarsym;var cgpara:TCGPara);
  401. var
  402. paraloc,
  403. newparaloc : pcgparalocation;
  404. begin
  405. cgpara.reset;
  406. cgpara.size:=parasym.paraloc[callerside].size;
  407. cgpara.intsize:=parasym.paraloc[callerside].intsize;
  408. cgpara.alignment:=parasym.paraloc[callerside].alignment;
  409. paraloc:=parasym.paraloc[callerside].location;
  410. while assigned(paraloc) do
  411. begin
  412. newparaloc:=cgpara.add_location;
  413. duplicatecgparaloc(paraloc,newparaloc);
  414. paraloc:=paraloc^.next;
  415. end;
  416. end;
  417. procedure tparamanager.create_funcretloc_info(p : tabstractprocdef; side: tcallercallee);
  418. begin
  419. if not assigned(p.funcretloc[side].Location) then
  420. p.funcretloc[side]:=get_funcretloc(p,side,nil);
  421. end;
  422. function tparamanager.create_inline_paraloc_info(p : tabstractprocdef):longint;
  423. begin
  424. { We need to return the size allocated }
  425. p.init_paraloc_info(callbothsides);
  426. result:=p.calleeargareasize;
  427. end;
  428. function tparamanager.parseparaloc(parasym: tparavarsym; const s: string): boolean;
  429. begin
  430. Result:=False;
  431. internalerror(200807235);
  432. end;
  433. function tparamanager.parsefuncretloc(p: tabstractprocdef; const s: string): boolean;
  434. begin
  435. Result:=False;
  436. internalerror(200807236);
  437. end;
  438. function tparamanager.use_fixed_stack: boolean;
  439. begin
  440. {$ifdef i386}
  441. result := target_info.stackalign > 4;
  442. {$else i386}
  443. {$ifdef cputargethasfixedstack}
  444. result := true;
  445. {$else cputargethasfixedstack}
  446. result := false;
  447. {$endif cputargethasfixedstack}
  448. {$endif i386}
  449. end;
  450. { This is a separate function because at least win64 allows stack allocations
  451. despite of fixed stack semantics (actually supporting it requires generating
  452. a compliant stack frame, not yet possible) }
  453. function tparamanager.use_stackalloc: boolean;
  454. begin
  455. result:=not use_fixed_stack;
  456. end;
  457. function tparamanager.set_common_funcretloc_info(p : tabstractprocdef; forcetempdef: tdef; out retcgsize: tcgsize; out retloc: tcgpara): boolean;
  458. var
  459. paraloc : pcgparalocation;
  460. begin
  461. result:=true;
  462. retloc.init;
  463. if not assigned(forcetempdef) then
  464. retloc.def:=p.returndef
  465. else
  466. begin
  467. retloc.def:=forcetempdef;
  468. retloc.temporary:=true;
  469. end;
  470. retloc.alignment:=get_para_align(p.proccalloption);
  471. { void has no location }
  472. if is_void(retloc.def) then
  473. begin
  474. paraloc:=retloc.add_location;
  475. retloc.size:=OS_NO;
  476. retcgsize:=OS_NO;
  477. retloc.intsize:=0;
  478. paraloc^.def:=retloc.def;
  479. paraloc^.size:=OS_NO;
  480. paraloc^.loc:=LOC_VOID;
  481. exit;
  482. end;
  483. { Constructors return self instead of a boolean }
  484. if p.proctypeoption=potype_constructor then
  485. begin
  486. retloc.def:=tdef(p.owner.defowner);
  487. if not (is_implicit_pointer_object_type(retloc.def) or
  488. (retloc.def.typ<>objectdef)) then
  489. retloc.def:=cpointerdef.getreusable_no_free(retloc.def);
  490. end;
  491. retcgsize:=def_cgsize(retloc.def);
  492. retloc.intsize:=retloc.def.size;
  493. retloc.size:=retcgsize;
  494. { Return is passed as var parameter }
  495. if ret_in_param(retloc.def,p) then
  496. begin
  497. retloc.def:=cpointerdef.getreusable_no_free(retloc.def);
  498. paraloc:=retloc.add_location;
  499. paraloc^.loc:=LOC_REFERENCE;
  500. paraloc^.size:=retcgsize;
  501. paraloc^.def:=retloc.def;
  502. exit;
  503. end;
  504. result:=false;
  505. end;
  506. function tparamanager.handle_common_ret_in_param(def: tdef;
  507. pd: tabstractprocdef; out retinparam: boolean): boolean;
  508. begin
  509. { This must be system independent: safecall and record constructor result
  510. is always returned in param.
  511. Furthermore, any managed type is returned in param, in order to avoid
  512. its finalization on exception at callee side. }
  513. if (tf_safecall_exceptions in target_info.flags) and
  514. (pd.proccalloption=pocall_safecall) or
  515. (
  516. (pd.proctypeoption=potype_constructor)and
  517. (
  518. is_record(def) or
  519. (
  520. (def.typ<>objectdef) and
  521. (pd.owner.symtabletype=objectsymtable) and
  522. is_objectpascal_helper(tdef(pd.owner.defowner))
  523. )
  524. )
  525. ) or is_managed_type(def) then
  526. begin
  527. retinparam:=true;
  528. exit(true);
  529. end;
  530. if pd.proctypeoption=potype_constructor then
  531. begin
  532. retinparam:=false;
  533. exit(true);
  534. end;
  535. result:=false;
  536. end;
  537. function tparamanager.get_paraloc_def(paradef: tdef; restlen: aint; fullsize: boolean): tdef;
  538. begin
  539. if fullsize then
  540. result:=paradef
  541. { no support for 128 bit ints -> tcgsize2orddef can't handle
  542. OS_(S)128 }
  543. else if restlen in [1,2,4,8] then
  544. result:=cgsize_orddef(int_cgsize(restlen))
  545. else
  546. result:=carraydef.getreusable_no_free(u8inttype,restlen);
  547. end;
  548. procedure tparamanager.getintparaloc(list: TAsmList; pd: tabstractprocdef; nr : longint; var cgpara: tcgpara);
  549. begin
  550. if (nr<1) or (nr>pd.paras.count) then
  551. InternalError(2013060101);
  552. pd.init_paraloc_info(callerside);
  553. cgpara:=tparavarsym(pd.paras[nr-1]).paraloc[callerside].getcopy;
  554. end;
  555. initialization
  556. ;
  557. finalization
  558. paramanager.free;
  559. end.