aasmcpu.pas 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555
  1. {
  2. Copyright (c) 2019 by Free Pascal and Lazarus foundation
  3. Contains the assembler object for the WebAssembly
  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 aasmcpu;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. cclasses,
  22. globtype,globals,verbose,
  23. aasmbase,aasmtai,aasmdata,aasmsym,
  24. cgbase,cgutils,cpubase,cpuinfo,ogbase,
  25. widestr;
  26. { fake, there are no "mov reg,reg" instructions here }
  27. const
  28. { "mov reg,reg" source operand number }
  29. O_MOV_SOURCE = 0;
  30. { "mov reg,reg" source operand number }
  31. O_MOV_DEST = 0;
  32. type
  33. { taicpu }
  34. taicpu = class(tai_cpu_abstract_sym)
  35. constructor op_none(op : tasmop);
  36. constructor op_reg(op : tasmop;_op1 : tregister);
  37. constructor op_const(op : tasmop;_op1 : aint);
  38. constructor op_ref(op : tasmop;const _op1 : treference);
  39. constructor op_sym(op : tasmop;_op1 : tasmsymbol);
  40. constructor op_sym_const(op : tasmop;_op1 : tasmsymbol;_op2 : aint);
  41. constructor op_single(op : tasmop;_op1 : single);
  42. constructor op_double(op : tasmop;_op1 : double);
  43. constructor op_functype(op : tasmop; _op1: TWasmFuncType);
  44. procedure loadfunctype(opidx:longint;ft:TWasmFuncType);
  45. procedure loadsingle(opidx:longint;f:single);
  46. procedure loaddouble(opidx:longint;d:double);
  47. { register allocation }
  48. function is_same_reg_move(regtype: Tregistertype):boolean; override;
  49. { register spilling code }
  50. function spilling_get_operation_type(opnr: longint): topertype;override;
  51. function Pass1(objdata:TObjData):longint;override;
  52. procedure Pass2(objdata:TObjData);override;
  53. end;
  54. tai_align = class(tai_align_abstract)
  55. { nothing to add }
  56. end;
  57. TImpExpType= (
  58. ie_Func, // functions
  59. ie_Table, // tables (arrays of methods)
  60. ie_Memory, // memory reference
  61. ie_Global // global variables
  62. );
  63. { tai_export_name }
  64. tai_export_name = class(tai)
  65. extname : ansistring; // external name
  66. intname : ansistring; // internal name
  67. symstype: TImpExpType;
  68. constructor create(const aextname, aintname: ansistring; asymtype: timpexptype);
  69. end;
  70. // local variable declaration
  71. { tai_local }
  72. tai_local = class(tai)
  73. bastyp: TWasmBasicType;
  74. name : string;
  75. first: boolean;
  76. last: boolean;
  77. constructor create(abasictype: TWasmBasicType; const aname: string = '');
  78. end;
  79. { tai_globaltype }
  80. tai_globaltype = class(tai)
  81. globalname: string;
  82. gtype: TWasmBasicType;
  83. immutable: boolean;
  84. constructor create(const aglobalname:string; atype: TWasmBasicType; aimmutable: boolean);
  85. end;
  86. { tai_functype }
  87. tai_functype = class(tai)
  88. funcname: string;
  89. functype: TWasmFuncType;
  90. constructor create(const afuncname: string; afunctype: TWasmFuncType);
  91. destructor destroy;override;
  92. end;
  93. { tai_tagtype }
  94. tai_tagtype = class(tai)
  95. tagname: string;
  96. params: TWasmResultType;
  97. constructor create(const atagname: string; aparams: TWasmResultType);
  98. end;
  99. { tai_import_module }
  100. tai_import_module = class(tai)
  101. symname: string;
  102. importmodule: string;
  103. constructor create(const asymname, aimportmodule: string);
  104. end;
  105. { tai_import_name }
  106. tai_import_name = class(tai)
  107. symname: string;
  108. importname: string;
  109. constructor create(const asymname, aimportname: string);
  110. end;
  111. procedure InitAsm;
  112. procedure DoneAsm;
  113. function spilling_create_load(const ref:treference;r:tregister):Taicpu;
  114. function spilling_create_store(r:tregister; const ref:treference):Taicpu;
  115. implementation
  116. uses
  117. ogwasm;
  118. { tai_globaltype }
  119. constructor tai_globaltype.create(const aglobalname: string; atype: TWasmBasicType; aimmutable: boolean);
  120. begin
  121. inherited Create;
  122. typ:=ait_globaltype;
  123. globalname:=aglobalname;
  124. gtype:=atype;
  125. immutable:=aimmutable;
  126. end;
  127. { tai_import_name }
  128. constructor tai_import_name.create(const asymname, aimportname: string);
  129. begin
  130. inherited Create;
  131. typ:=ait_import_name;
  132. symname:=asymname;
  133. importname:=aimportname;
  134. end;
  135. { tai_import_module }
  136. constructor tai_import_module.create(const asymname, aimportmodule: string);
  137. begin
  138. inherited Create;
  139. typ:=ait_import_module;
  140. symname:=asymname;
  141. importmodule:=aimportmodule;
  142. end;
  143. { tai_functype }
  144. constructor tai_functype.create(const afuncname: string; afunctype: TWasmFuncType);
  145. begin
  146. inherited Create;
  147. typ:=ait_functype;
  148. funcname:=afuncname;
  149. functype:=afunctype;
  150. end;
  151. destructor tai_functype.destroy;
  152. begin
  153. functype.free;
  154. inherited;
  155. end;
  156. { tai_tagtype }
  157. constructor tai_tagtype.create(const atagname: string; aparams: TWasmResultType);
  158. begin
  159. typ:=ait_tagtype;
  160. tagname:=atagname;
  161. params:=aparams;
  162. end;
  163. { tai_local }
  164. constructor tai_local.create(abasictype: TWasmBasicType; const aname: string);
  165. begin
  166. inherited Create;
  167. bastyp := abasictype;
  168. typ := ait_local;
  169. name := aname;
  170. end;
  171. { timpexp_ai }
  172. constructor tai_export_name.create(const aextname, aintname: ansistring;
  173. asymtype: timpexptype);
  174. begin
  175. inherited create;
  176. typ := ait_export_name;
  177. extname := aextname;
  178. intname := aintname;
  179. symstype:= asymtype;
  180. end;
  181. {*****************************************************************************
  182. taicpu Constructors
  183. *****************************************************************************}
  184. constructor taicpu.op_none(op : tasmop);
  185. begin
  186. inherited create(op);
  187. end;
  188. constructor taicpu.op_reg(op : tasmop;_op1 : tregister);
  189. begin
  190. inherited create(op);
  191. ops:=1;
  192. {$ifdef EXTDEBUG}
  193. if getregtype(_op1)=R_INVALIDREGISTER then
  194. InternalError(2021011901);
  195. {$endif EXTDEBUG}
  196. loadreg(0,_op1);
  197. end;
  198. constructor taicpu.op_ref(op : tasmop;const _op1 : treference);
  199. begin
  200. inherited create(op);
  201. ops:=1;
  202. loadref(0,_op1);
  203. if op in [a_local_get,a_local_set,a_local_tee] then
  204. begin
  205. if (_op1.base<>NR_LOCAL_STACK_POINTER_REG) or (_op1.index<>NR_NO) then
  206. internalerror(2021010201);
  207. end
  208. else
  209. begin
  210. if (_op1.base<>NR_NO) or (_op1.index<>NR_NO) then
  211. internalerror(2021010202);
  212. end;
  213. end;
  214. constructor taicpu.op_const(op : tasmop;_op1 : aint);
  215. begin
  216. inherited create(op);
  217. ops:=1;
  218. loadconst(0,_op1);
  219. end;
  220. constructor taicpu.op_sym(op : tasmop;_op1 : tasmsymbol);
  221. begin
  222. inherited create(op);
  223. ops:=1;
  224. loadsymbol(0,_op1,0);
  225. end;
  226. constructor taicpu.op_sym_const(op: tasmop; _op1: tasmsymbol; _op2: aint);
  227. begin
  228. inherited create(op);
  229. ops:=2;
  230. loadsymbol(0,_op1,0);
  231. loadconst(1,_op2);
  232. end;
  233. constructor taicpu.op_single(op: tasmop; _op1: single);
  234. begin
  235. inherited create(op);
  236. ops:=1;
  237. loadsingle(0,_op1);
  238. end;
  239. constructor taicpu.op_double(op: tasmop; _op1: double);
  240. begin
  241. inherited create(op);
  242. ops:=1;
  243. loaddouble(0,_op1);
  244. end;
  245. constructor taicpu.op_functype(op: tasmop; _op1: TWasmFuncType);
  246. begin
  247. inherited create(op);
  248. ops:=1;
  249. loadfunctype(0,_op1);
  250. end;
  251. procedure taicpu.loadfunctype(opidx: longint; ft: TWasmFuncType);
  252. begin
  253. allocate_oper(opidx+1);
  254. with oper[opidx]^ do
  255. begin
  256. if typ<>top_functype then
  257. clearop(opidx);
  258. functype:=ft;
  259. typ:=top_functype;
  260. end;
  261. end;
  262. procedure taicpu.loadsingle(opidx:longint;f:single);
  263. begin
  264. allocate_oper(opidx+1);
  265. with oper[opidx]^ do
  266. begin
  267. if typ<>top_single then
  268. clearop(opidx);
  269. sval:=f;
  270. typ:=top_single;
  271. end;
  272. end;
  273. procedure taicpu.loaddouble(opidx: longint; d: double);
  274. begin
  275. allocate_oper(opidx+1);
  276. with oper[opidx]^ do
  277. begin
  278. if typ<>top_double then
  279. clearop(opidx);
  280. dval:=d;
  281. typ:=top_double;
  282. end;
  283. end;
  284. function taicpu.is_same_reg_move(regtype: Tregistertype):boolean;
  285. begin
  286. result:=false;
  287. end;
  288. function taicpu.spilling_get_operation_type(opnr: longint): topertype;
  289. begin
  290. if opcode in AsmOp_Store then
  291. result:=operand_write
  292. else
  293. result:=operand_read;
  294. end;
  295. function taicpu.Pass1(objdata: TObjData): longint;
  296. function SlebSize(v: tcgint): longint;
  297. begin
  298. result:=0;
  299. repeat
  300. v:=SarInt64(v,7);
  301. Inc(result);
  302. until ((v=0) and ((byte(v) and 64)=0)) or ((v=-1) and ((byte(v) and 64)<>0));
  303. end;
  304. function UlebSize(v: tcgint): longint;
  305. begin
  306. result:=0;
  307. repeat
  308. v:=v shr 7;
  309. Inc(result);
  310. until v=0;
  311. end;
  312. begin
  313. result:=0;
  314. case opcode of
  315. a_unreachable,
  316. a_nop,
  317. a_return,
  318. a_drop,
  319. a_i32_eqz,
  320. a_i32_eq,
  321. a_i32_ne,
  322. a_i32_lt_s,
  323. a_i32_lt_u,
  324. a_i32_gt_s,
  325. a_i32_gt_u,
  326. a_i32_le_s,
  327. a_i32_le_u,
  328. a_i32_ge_s,
  329. a_i32_ge_u,
  330. a_i64_eqz,
  331. a_i64_eq,
  332. a_i64_ne,
  333. a_i64_lt_s,
  334. a_i64_lt_u,
  335. a_i64_gt_s,
  336. a_i64_gt_u,
  337. a_i64_le_s,
  338. a_i64_le_u,
  339. a_i64_ge_s,
  340. a_i64_ge_u,
  341. a_f32_eq,
  342. a_f32_ne,
  343. a_f32_lt,
  344. a_f32_gt,
  345. a_f32_le,
  346. a_f32_ge,
  347. a_f64_eq,
  348. a_f64_ne,
  349. a_f64_lt,
  350. a_f64_gt,
  351. a_f64_le,
  352. a_f64_ge,
  353. a_i32_clz,
  354. a_i32_ctz,
  355. a_i32_popcnt,
  356. a_i32_add,
  357. a_i32_sub,
  358. a_i32_mul,
  359. a_i32_div_s,
  360. a_i32_div_u,
  361. a_i32_rem_s,
  362. a_i32_rem_u,
  363. a_i32_and,
  364. a_i32_or,
  365. a_i32_xor,
  366. a_i32_shl,
  367. a_i32_shr_s,
  368. a_i32_shr_u,
  369. a_i32_rotl,
  370. a_i32_rotr,
  371. a_i64_clz,
  372. a_i64_ctz,
  373. a_i64_popcnt,
  374. a_i64_add,
  375. a_i64_sub,
  376. a_i64_mul,
  377. a_i64_div_s,
  378. a_i64_div_u,
  379. a_i64_rem_s,
  380. a_i64_rem_u,
  381. a_i64_and,
  382. a_i64_or,
  383. a_i64_xor,
  384. a_i64_shl,
  385. a_i64_shr_s,
  386. a_i64_shr_u,
  387. a_i64_rotl,
  388. a_i64_rotr,
  389. a_f32_abs,
  390. a_f32_neg,
  391. a_f32_ceil,
  392. a_f32_floor,
  393. a_f32_trunc,
  394. a_f32_nearest,
  395. a_f32_sqrt,
  396. a_f32_add,
  397. a_f32_sub,
  398. a_f32_mul,
  399. a_f32_div,
  400. a_f32_min,
  401. a_f32_max,
  402. a_f32_copysign,
  403. a_f64_abs,
  404. a_f64_neg,
  405. a_f64_ceil,
  406. a_f64_floor,
  407. a_f64_trunc,
  408. a_f64_nearest,
  409. a_f64_sqrt,
  410. a_f64_add,
  411. a_f64_sub,
  412. a_f64_mul,
  413. a_f64_div,
  414. a_f64_min,
  415. a_f64_max,
  416. a_f64_copysign,
  417. a_i32_wrap_i64,
  418. a_i32_trunc_f32_s,
  419. a_i32_trunc_f32_u,
  420. a_i32_trunc_f64_s,
  421. a_i32_trunc_f64_u,
  422. a_i64_extend_i32_s,
  423. a_i64_extend_i32_u,
  424. a_i64_trunc_f32_s,
  425. a_i64_trunc_f32_u,
  426. a_i64_trunc_f64_s,
  427. a_i64_trunc_f64_u,
  428. a_f32_convert_i32_s,
  429. a_f32_convert_i32_u,
  430. a_f32_convert_i64_s,
  431. a_f32_convert_i64_u,
  432. a_f32_demote_f64,
  433. a_f64_convert_i32_s,
  434. a_f64_convert_i32_u,
  435. a_f64_convert_i64_s,
  436. a_f64_convert_i64_u,
  437. a_f64_promote_f32,
  438. a_i32_reinterpret_f32,
  439. a_i64_reinterpret_f64,
  440. a_f32_reinterpret_i32,
  441. a_f64_reinterpret_i64,
  442. a_i32_extend8_s,
  443. a_i32_extend16_s,
  444. a_i64_extend8_s,
  445. a_i64_extend16_s,
  446. a_i64_extend32_s,
  447. a_else,
  448. a_end_block,
  449. a_end_if,
  450. a_end_loop,
  451. a_end_try,
  452. a_catch_all:
  453. result:=1;
  454. a_memory_size,
  455. a_memory_grow:
  456. result:=2;
  457. a_memory_copy:
  458. result:=4;
  459. a_memory_fill:
  460. result:=3;
  461. a_i32_const:
  462. begin
  463. if ops<>1 then
  464. internalerror(2021092001);
  465. with oper[0]^ do
  466. case typ of
  467. top_ref:
  468. begin
  469. if assigned(ref^.symbol) then
  470. result:=6
  471. else
  472. begin
  473. if assigned(ref^.symbol) or (ref^.base<>NR_NO) or (ref^.index<>NR_NO) then
  474. internalerror(2021092018);
  475. result:=1+SlebSize(longint(ref^.offset));
  476. end;
  477. end;
  478. top_const:
  479. result:=1+SlebSize(longint(val));
  480. else
  481. internalerror(2021092615);
  482. end;
  483. end;
  484. a_i64_const:
  485. begin
  486. if ops<>1 then
  487. internalerror(2021092001);
  488. with oper[0]^ do
  489. case typ of
  490. top_ref:
  491. begin
  492. if assigned(ref^.symbol) then
  493. result:=6
  494. else
  495. begin
  496. if assigned(ref^.symbol) or (ref^.base<>NR_NO) or (ref^.index<>NR_NO) then
  497. internalerror(2021092018);
  498. result:=1+SlebSize(int64(ref^.offset));
  499. end;
  500. end;
  501. top_const:
  502. result:=1+SlebSize(int64(val));
  503. else
  504. internalerror(2021092615);
  505. end;
  506. end;
  507. a_f32_const:
  508. result:=5;
  509. a_f64_const:
  510. result:=9;
  511. a_local_get,
  512. a_local_set,
  513. a_local_tee:
  514. begin
  515. if ops<>1 then
  516. internalerror(2021092001);
  517. with oper[0]^ do
  518. case typ of
  519. top_ref:
  520. begin
  521. if assigned(ref^.symbol) then
  522. internalerror(2021092005);
  523. if ref^.base<>NR_STACK_POINTER_REG then
  524. internalerror(2021092006);
  525. if ref^.index<>NR_NO then
  526. internalerror(2021092007);
  527. result:=1+UlebSize(ref^.offset);
  528. end;
  529. else
  530. internalerror(2021092008);
  531. end;
  532. end;
  533. a_global_get,
  534. a_global_set:
  535. begin
  536. if ops<>1 then
  537. internalerror(2021092010);
  538. with oper[0]^ do
  539. case typ of
  540. top_ref:
  541. begin
  542. if not assigned(ref^.symbol) then
  543. internalerror(2021092012);
  544. if (ref^.base<>NR_NO) or (ref^.index<>NR_NO) or (ref^.offset<>0) then
  545. internalerror(2021092013);
  546. result:=6;
  547. end;
  548. else
  549. internalerror(2021092011);
  550. end;
  551. end;
  552. a_end_function:
  553. result:=0;
  554. a_block,
  555. a_loop,
  556. a_if,
  557. a_try:
  558. begin
  559. if ops=0 then
  560. result:=2
  561. else
  562. begin
  563. if ops<>1 then
  564. internalerror(2021092015);
  565. with oper[0]^ do
  566. case typ of
  567. top_functype:
  568. begin
  569. if (length(functype.params)=0) and (length(functype.results)<=1) then
  570. result:=2
  571. else
  572. { more complex blocktypes are not yet implemented }
  573. internalerror(2021092621);
  574. end;
  575. else
  576. internalerror(2021092620);
  577. end;
  578. end;
  579. end;
  580. a_i32_load,
  581. a_i64_load,
  582. a_f32_load,
  583. a_f64_load,
  584. a_i32_load8_s,
  585. a_i32_load8_u,
  586. a_i32_load16_s,
  587. a_i32_load16_u,
  588. a_i64_load8_s,
  589. a_i64_load8_u,
  590. a_i64_load16_s,
  591. a_i64_load16_u,
  592. a_i64_load32_s,
  593. a_i64_load32_u,
  594. a_i32_store,
  595. a_i64_store,
  596. a_f32_store,
  597. a_f64_store,
  598. a_i32_store8,
  599. a_i32_store16,
  600. a_i64_store8,
  601. a_i64_store16,
  602. a_i64_store32:
  603. begin
  604. if ops<>1 then
  605. internalerror(2021092016);
  606. with oper[0]^ do
  607. case typ of
  608. top_ref:
  609. begin
  610. if assigned(ref^.symbol) then
  611. begin
  612. Result:=1+
  613. UlebSize(natural_alignment_for_load_store(opcode))+
  614. 5; { relocation, fixed size = 5 bytes }
  615. end
  616. else
  617. begin
  618. if assigned(ref^.symbol) or (ref^.base<>NR_NO) or (ref^.index<>NR_NO) then
  619. internalerror(2021092018);
  620. Result:=1+
  621. UlebSize(natural_alignment_for_load_store(opcode))+
  622. UlebSize(ref^.offset);
  623. end;
  624. end;
  625. top_const:
  626. begin
  627. Result:=1+
  628. UlebSize(natural_alignment_for_load_store(opcode))+
  629. UlebSize(val);
  630. end;
  631. else
  632. internalerror(2021092017);
  633. end;
  634. end;
  635. a_call:
  636. begin
  637. if ops<>1 then
  638. internalerror(2021092021);
  639. with oper[0]^ do
  640. case typ of
  641. top_ref:
  642. begin
  643. if not assigned(ref^.symbol) or (ref^.base<>NR_NO) or (ref^.index<>NR_NO) or (ref^.offset<>0) then
  644. internalerror(2021092023);
  645. result:=6;
  646. end;
  647. else
  648. internalerror(2021092022);
  649. end;
  650. end;
  651. a_call_indirect:
  652. begin
  653. if ops<>1 then
  654. internalerror(2021092610);
  655. with oper[0]^ do
  656. case typ of
  657. top_functype:
  658. begin
  659. TWasmObjData(objdata).AddFuncType(functype);
  660. result:=6+
  661. UlebSize(0);
  662. end;
  663. else
  664. internalerror(2021092611);
  665. end;
  666. end;
  667. a_br,
  668. a_br_if,
  669. a_rethrow,
  670. a_delegate:
  671. begin
  672. if ops<>1 then
  673. internalerror(2021092610);
  674. with oper[0]^ do
  675. case typ of
  676. top_const:
  677. result:=1+
  678. UlebSize(val);
  679. else
  680. internalerror(2021092625);
  681. end;
  682. end;
  683. a_catch,
  684. a_throw:
  685. begin
  686. if ops<>1 then
  687. internalerror(2021092709);
  688. with oper[0]^ do
  689. case typ of
  690. top_ref:
  691. begin
  692. if not assigned(ref^.symbol) or (ref^.base<>NR_NO) or (ref^.index<>NR_NO) or (ref^.offset<>0) then
  693. internalerror(2021092711);
  694. result:=6;
  695. end;
  696. else
  697. internalerror(2021092710);
  698. end;
  699. end;
  700. else
  701. internalerror(2021092623);
  702. end;
  703. end;
  704. procedure taicpu.Pass2(objdata: TObjData);
  705. procedure WriteByte(b: byte);
  706. begin
  707. objdata.writebytes(b,1);
  708. end;
  709. {$ifdef FPC_LITTLE_ENDIAN}
  710. procedure WriteSingle(s: single);
  711. begin
  712. objdata.writebytes(s,4);
  713. end;
  714. procedure WriteDouble(d: double);
  715. begin
  716. objdata.writebytes(d,8);
  717. end;
  718. {$else FPC_LITTLE_ENDIAN}
  719. procedure WriteSingle(s: single);
  720. var
  721. l: longword;
  722. begin
  723. Move(s,l,4);
  724. l:=SwapEndian(l);
  725. objdata.writebytes(l,4);
  726. end;
  727. procedure WriteDouble(d: double);
  728. var
  729. q: qword;
  730. begin
  731. Move(d,q,8);
  732. q:=SwapEndian(q);
  733. objdata.writebytes(q,8);
  734. end;
  735. {$endif FPC_LITTLE_ENDIAN}
  736. procedure WriteSleb(v: tcgint);
  737. var
  738. b: byte;
  739. Done: Boolean=false;
  740. begin
  741. repeat
  742. b:=byte(v) and 127;
  743. v:=SarInt64(v,7);
  744. if ((v=0) and ((b and 64)=0)) or ((v=-1) and ((b and 64)<>0)) then
  745. Done:=true
  746. else
  747. b:=b or 128;
  748. objdata.writebytes(b,1);
  749. until Done;
  750. end;
  751. procedure WriteUleb(v: tcgint);
  752. var
  753. b: byte;
  754. begin
  755. repeat
  756. b:=byte(v) and 127;
  757. v:=v shr 7;
  758. if v<>0 then
  759. b:=b or 128;
  760. objdata.writebytes(b,1);
  761. until v=0;
  762. end;
  763. begin
  764. case opcode of
  765. a_unreachable:
  766. WriteByte($00);
  767. a_nop:
  768. WriteByte($01);
  769. a_return:
  770. WriteByte($0F);
  771. a_drop:
  772. WriteByte($1A);
  773. a_memory_size:
  774. begin
  775. WriteByte($3F);
  776. WriteByte($00);
  777. end;
  778. a_memory_grow:
  779. begin
  780. WriteByte($40);
  781. WriteByte($00);
  782. end;
  783. a_memory_copy:
  784. begin
  785. WriteByte($FC);
  786. WriteUleb(10);
  787. WriteByte($00);
  788. WriteByte($00);
  789. end;
  790. a_memory_fill:
  791. begin
  792. WriteByte($FC);
  793. WriteUleb(11);
  794. WriteByte($00);
  795. end;
  796. a_i32_eqz:
  797. WriteByte($45);
  798. a_i32_eq:
  799. WriteByte($46);
  800. a_i32_ne:
  801. WriteByte($47);
  802. a_i32_lt_s:
  803. WriteByte($48);
  804. a_i32_lt_u:
  805. WriteByte($49);
  806. a_i32_gt_s:
  807. WriteByte($4A);
  808. a_i32_gt_u:
  809. WriteByte($4B);
  810. a_i32_le_s:
  811. WriteByte($4C);
  812. a_i32_le_u:
  813. WriteByte($4D);
  814. a_i32_ge_s:
  815. WriteByte($4E);
  816. a_i32_ge_u:
  817. WriteByte($4F);
  818. a_i64_eqz:
  819. WriteByte($50);
  820. a_i64_eq:
  821. WriteByte($51);
  822. a_i64_ne:
  823. WriteByte($52);
  824. a_i64_lt_s:
  825. WriteByte($53);
  826. a_i64_lt_u:
  827. WriteByte($54);
  828. a_i64_gt_s:
  829. WriteByte($55);
  830. a_i64_gt_u:
  831. WriteByte($56);
  832. a_i64_le_s:
  833. WriteByte($57);
  834. a_i64_le_u:
  835. WriteByte($58);
  836. a_i64_ge_s:
  837. WriteByte($59);
  838. a_i64_ge_u:
  839. WriteByte($5A);
  840. a_f32_eq:
  841. WriteByte($5B);
  842. a_f32_ne:
  843. WriteByte($5C);
  844. a_f32_lt:
  845. WriteByte($5D);
  846. a_f32_gt:
  847. WriteByte($5E);
  848. a_f32_le:
  849. WriteByte($5F);
  850. a_f32_ge:
  851. WriteByte($60);
  852. a_f64_eq:
  853. WriteByte($61);
  854. a_f64_ne:
  855. WriteByte($62);
  856. a_f64_lt:
  857. WriteByte($63);
  858. a_f64_gt:
  859. WriteByte($64);
  860. a_f64_le:
  861. WriteByte($65);
  862. a_f64_ge:
  863. WriteByte($66);
  864. a_i32_clz:
  865. WriteByte($67);
  866. a_i32_ctz:
  867. WriteByte($68);
  868. a_i32_popcnt:
  869. WriteByte($69);
  870. a_i32_add:
  871. WriteByte($6A);
  872. a_i32_sub:
  873. WriteByte($6B);
  874. a_i32_mul:
  875. WriteByte($6C);
  876. a_i32_div_s:
  877. WriteByte($6D);
  878. a_i32_div_u:
  879. WriteByte($6E);
  880. a_i32_rem_s:
  881. WriteByte($6F);
  882. a_i32_rem_u:
  883. WriteByte($70);
  884. a_i32_and:
  885. WriteByte($71);
  886. a_i32_or:
  887. WriteByte($72);
  888. a_i32_xor:
  889. WriteByte($73);
  890. a_i32_shl:
  891. WriteByte($74);
  892. a_i32_shr_s:
  893. WriteByte($75);
  894. a_i32_shr_u:
  895. WriteByte($76);
  896. a_i32_rotl:
  897. WriteByte($77);
  898. a_i32_rotr:
  899. WriteByte($78);
  900. a_i64_clz:
  901. WriteByte($79);
  902. a_i64_ctz:
  903. WriteByte($7A);
  904. a_i64_popcnt:
  905. WriteByte($7B);
  906. a_i64_add:
  907. WriteByte($7C);
  908. a_i64_sub:
  909. WriteByte($7D);
  910. a_i64_mul:
  911. WriteByte($7E);
  912. a_i64_div_s:
  913. WriteByte($7F);
  914. a_i64_div_u:
  915. WriteByte($80);
  916. a_i64_rem_s:
  917. WriteByte($81);
  918. a_i64_rem_u:
  919. WriteByte($82);
  920. a_i64_and:
  921. WriteByte($83);
  922. a_i64_or:
  923. WriteByte($84);
  924. a_i64_xor:
  925. WriteByte($85);
  926. a_i64_shl:
  927. WriteByte($86);
  928. a_i64_shr_s:
  929. WriteByte($87);
  930. a_i64_shr_u:
  931. WriteByte($88);
  932. a_i64_rotl:
  933. WriteByte($89);
  934. a_i64_rotr:
  935. WriteByte($8A);
  936. a_f32_abs:
  937. WriteByte($8B);
  938. a_f32_neg:
  939. WriteByte($8C);
  940. a_f32_ceil:
  941. WriteByte($8D);
  942. a_f32_floor:
  943. WriteByte($8E);
  944. a_f32_trunc:
  945. WriteByte($8F);
  946. a_f32_nearest:
  947. WriteByte($90);
  948. a_f32_sqrt:
  949. WriteByte($91);
  950. a_f32_add:
  951. WriteByte($92);
  952. a_f32_sub:
  953. WriteByte($93);
  954. a_f32_mul:
  955. WriteByte($94);
  956. a_f32_div:
  957. WriteByte($95);
  958. a_f32_min:
  959. WriteByte($96);
  960. a_f32_max:
  961. WriteByte($97);
  962. a_f32_copysign:
  963. WriteByte($98);
  964. a_f64_abs:
  965. WriteByte($99);
  966. a_f64_neg:
  967. WriteByte($9A);
  968. a_f64_ceil:
  969. WriteByte($9B);
  970. a_f64_floor:
  971. WriteByte($9C);
  972. a_f64_trunc:
  973. WriteByte($9D);
  974. a_f64_nearest:
  975. WriteByte($9E);
  976. a_f64_sqrt:
  977. WriteByte($9F);
  978. a_f64_add:
  979. WriteByte($A0);
  980. a_f64_sub:
  981. WriteByte($A1);
  982. a_f64_mul:
  983. WriteByte($A2);
  984. a_f64_div:
  985. WriteByte($A3);
  986. a_f64_min:
  987. WriteByte($A4);
  988. a_f64_max:
  989. WriteByte($A5);
  990. a_f64_copysign:
  991. WriteByte($A6);
  992. a_i32_wrap_i64:
  993. WriteByte($A7);
  994. a_i32_trunc_f32_s:
  995. WriteByte($A8);
  996. a_i32_trunc_f32_u:
  997. WriteByte($A9);
  998. a_i32_trunc_f64_s:
  999. WriteByte($AA);
  1000. a_i32_trunc_f64_u:
  1001. WriteByte($AB);
  1002. a_i64_extend_i32_s:
  1003. WriteByte($AC);
  1004. a_i64_extend_i32_u:
  1005. WriteByte($AD);
  1006. a_i64_trunc_f32_s:
  1007. WriteByte($AE);
  1008. a_i64_trunc_f32_u:
  1009. WriteByte($AF);
  1010. a_i64_trunc_f64_s:
  1011. WriteByte($B0);
  1012. a_i64_trunc_f64_u:
  1013. WriteByte($B1);
  1014. a_f32_convert_i32_s:
  1015. WriteByte($B2);
  1016. a_f32_convert_i32_u:
  1017. WriteByte($B3);
  1018. a_f32_convert_i64_s:
  1019. WriteByte($B4);
  1020. a_f32_convert_i64_u:
  1021. WriteByte($B5);
  1022. a_f32_demote_f64:
  1023. WriteByte($B6);
  1024. a_f64_convert_i32_s:
  1025. WriteByte($B7);
  1026. a_f64_convert_i32_u:
  1027. WriteByte($B8);
  1028. a_f64_convert_i64_s:
  1029. WriteByte($B9);
  1030. a_f64_convert_i64_u:
  1031. WriteByte($BA);
  1032. a_f64_promote_f32:
  1033. WriteByte($BB);
  1034. a_i32_reinterpret_f32:
  1035. WriteByte($BC);
  1036. a_i64_reinterpret_f64:
  1037. WriteByte($BD);
  1038. a_f32_reinterpret_i32:
  1039. WriteByte($BE);
  1040. a_f64_reinterpret_i64:
  1041. WriteByte($BF);
  1042. a_i32_extend8_s:
  1043. WriteByte($C0);
  1044. a_i32_extend16_s:
  1045. WriteByte($C1);
  1046. a_i64_extend8_s:
  1047. WriteByte($C2);
  1048. a_i64_extend16_s:
  1049. WriteByte($C3);
  1050. a_i64_extend32_s:
  1051. WriteByte($C4);
  1052. a_end_block,
  1053. a_end_if,
  1054. a_end_loop,
  1055. a_end_try:
  1056. WriteByte($0B);
  1057. a_catch_all:
  1058. WriteByte($19);
  1059. a_i32_const:
  1060. begin
  1061. WriteByte($41);
  1062. if ops<>1 then
  1063. internalerror(2021092001);
  1064. with oper[0]^ do
  1065. case typ of
  1066. top_ref:
  1067. begin
  1068. if assigned(ref^.symbol) then
  1069. objdata.writeReloc(ref^.offset,5,ObjData.symbolref(ref^.symbol),RELOC_MEMORY_ADDR_OR_TABLE_INDEX_SLEB)
  1070. else
  1071. begin
  1072. if assigned(ref^.symbol) or (ref^.base<>NR_NO) or (ref^.index<>NR_NO) then
  1073. internalerror(2021092018);
  1074. WriteSleb(longint(ref^.offset));
  1075. end;
  1076. end;
  1077. top_const:
  1078. WriteSleb(longint(val));
  1079. else
  1080. internalerror(2021092615);
  1081. end;
  1082. end;
  1083. a_i64_const:
  1084. begin
  1085. WriteByte($42);
  1086. if ops<>1 then
  1087. internalerror(2021092001);
  1088. with oper[0]^ do
  1089. case typ of
  1090. top_ref:
  1091. begin
  1092. if assigned(ref^.symbol) then
  1093. objdata.writeReloc(ref^.offset,5,ObjData.symbolref(ref^.symbol),RELOC_MEMORY_ADDR_OR_TABLE_INDEX_SLEB)
  1094. else
  1095. begin
  1096. if assigned(ref^.symbol) or (ref^.base<>NR_NO) or (ref^.index<>NR_NO) then
  1097. internalerror(2021092018);
  1098. WriteSleb(int64(ref^.offset));
  1099. end;
  1100. end;
  1101. top_const:
  1102. WriteSleb(int64(val));
  1103. else
  1104. internalerror(2021092615);
  1105. end;
  1106. end;
  1107. a_f32_const:
  1108. begin
  1109. if ops<>1 then
  1110. internalerror(2021092619);
  1111. WriteByte($43);
  1112. with oper[0]^ do
  1113. case typ of
  1114. top_single:
  1115. WriteSingle(sval);
  1116. else
  1117. internalerror(2021092618);
  1118. end;
  1119. end;
  1120. a_f64_const:
  1121. begin
  1122. if ops<>1 then
  1123. internalerror(2021092616);
  1124. WriteByte($44);
  1125. with oper[0]^ do
  1126. case typ of
  1127. top_double:
  1128. WriteDouble(dval);
  1129. else
  1130. internalerror(2021092617);
  1131. end;
  1132. end;
  1133. a_local_get,
  1134. a_local_set,
  1135. a_local_tee:
  1136. begin
  1137. case opcode of
  1138. a_local_get:
  1139. WriteByte($20);
  1140. a_local_set:
  1141. WriteByte($21);
  1142. a_local_tee:
  1143. WriteByte($22);
  1144. else
  1145. internalerror(2021092003);
  1146. end;
  1147. if ops<>1 then
  1148. internalerror(2021092004);
  1149. with oper[0]^ do
  1150. case typ of
  1151. top_ref:
  1152. begin
  1153. if assigned(ref^.symbol) then
  1154. internalerror(2021092005);
  1155. if ref^.base<>NR_STACK_POINTER_REG then
  1156. internalerror(2021092006);
  1157. if ref^.index<>NR_NO then
  1158. internalerror(2021092007);
  1159. WriteUleb(ref^.offset);
  1160. end;
  1161. else
  1162. internalerror(2021092008);
  1163. end;
  1164. end;
  1165. a_global_get,
  1166. a_global_set:
  1167. begin
  1168. case opcode of
  1169. a_global_get:
  1170. WriteByte($23);
  1171. a_global_set:
  1172. WriteByte($24);
  1173. else
  1174. internalerror(2021092009);
  1175. end;
  1176. if ops<>1 then
  1177. internalerror(2021092010);
  1178. with oper[0]^ do
  1179. case typ of
  1180. top_ref:
  1181. begin
  1182. if not assigned(ref^.symbol) then
  1183. internalerror(2021092012);
  1184. if (ref^.base<>NR_NO) or (ref^.index<>NR_NO) or (ref^.offset<>0) then
  1185. internalerror(2021092013);
  1186. objdata.writeReloc(0,5,TWasmObjData(ObjData).globalref(ref^.symbol),RELOC_GLOBAL_INDEX_LEB);
  1187. end;
  1188. else
  1189. internalerror(2021092011);
  1190. end;
  1191. end;
  1192. a_end_function:
  1193. ;
  1194. a_block,
  1195. a_loop,
  1196. a_if,
  1197. a_try:
  1198. begin
  1199. case opcode of
  1200. a_block:
  1201. WriteByte($02);
  1202. a_loop:
  1203. WriteByte($03);
  1204. a_if:
  1205. WriteByte($04);
  1206. a_try:
  1207. WriteByte($06);
  1208. else
  1209. internalerror(2021092626);
  1210. end;
  1211. if ops=0 then
  1212. WriteByte($40)
  1213. else
  1214. begin
  1215. if ops<>1 then
  1216. internalerror(2021092015);
  1217. with oper[0]^ do
  1218. case typ of
  1219. top_functype:
  1220. begin
  1221. if (length(functype.params)=0) and (length(functype.results)<=1) then
  1222. begin
  1223. if length(functype.results)=1 then
  1224. WriteByte(encode_wasm_basic_type(functype.results[0]))
  1225. else
  1226. WriteByte($40);
  1227. end
  1228. else
  1229. { more complex blocktypes are not yet implemented }
  1230. internalerror(2021092621);
  1231. end;
  1232. else
  1233. internalerror(2021092620);
  1234. end;
  1235. end;
  1236. end;
  1237. a_else:
  1238. WriteByte($05);
  1239. a_i32_load,
  1240. a_i64_load,
  1241. a_f32_load,
  1242. a_f64_load,
  1243. a_i32_load8_s,
  1244. a_i32_load8_u,
  1245. a_i32_load16_s,
  1246. a_i32_load16_u,
  1247. a_i64_load8_s,
  1248. a_i64_load8_u,
  1249. a_i64_load16_s,
  1250. a_i64_load16_u,
  1251. a_i64_load32_s,
  1252. a_i64_load32_u,
  1253. a_i32_store,
  1254. a_i64_store,
  1255. a_f32_store,
  1256. a_f64_store,
  1257. a_i32_store8,
  1258. a_i32_store16,
  1259. a_i64_store8,
  1260. a_i64_store16,
  1261. a_i64_store32:
  1262. begin
  1263. case opcode of
  1264. a_i32_load:
  1265. WriteByte($28);
  1266. a_i64_load:
  1267. WriteByte($29);
  1268. a_f32_load:
  1269. WriteByte($2A);
  1270. a_f64_load:
  1271. WriteByte($2B);
  1272. a_i32_load8_s:
  1273. WriteByte($2C);
  1274. a_i32_load8_u:
  1275. WriteByte($2D);
  1276. a_i32_load16_s:
  1277. WriteByte($2E);
  1278. a_i32_load16_u:
  1279. WriteByte($2F);
  1280. a_i64_load8_s:
  1281. WriteByte($30);
  1282. a_i64_load8_u:
  1283. WriteByte($31);
  1284. a_i64_load16_s:
  1285. WriteByte($32);
  1286. a_i64_load16_u:
  1287. WriteByte($33);
  1288. a_i64_load32_s:
  1289. WriteByte($34);
  1290. a_i64_load32_u:
  1291. WriteByte($35);
  1292. a_i32_store:
  1293. WriteByte($36);
  1294. a_i64_store:
  1295. WriteByte($37);
  1296. a_f32_store:
  1297. WriteByte($38);
  1298. a_f64_store:
  1299. WriteByte($39);
  1300. a_i32_store8:
  1301. WriteByte($3A);
  1302. a_i32_store16:
  1303. WriteByte($3B);
  1304. a_i64_store8:
  1305. WriteByte($3C);
  1306. a_i64_store16:
  1307. WriteByte($3D);
  1308. a_i64_store32:
  1309. WriteByte($3E);
  1310. else
  1311. internalerror(2021092019);
  1312. end;
  1313. if ops<>1 then
  1314. internalerror(2021092016);
  1315. with oper[0]^ do
  1316. case typ of
  1317. top_ref:
  1318. begin
  1319. if assigned(ref^.symbol) then
  1320. begin
  1321. WriteUleb(natural_alignment_for_load_store(opcode));
  1322. objdata.writeReloc(ref^.offset,5,ObjData.symbolref(ref^.symbol),RELOC_MEMORY_ADDR_LEB);
  1323. end
  1324. else
  1325. begin
  1326. if assigned(ref^.symbol) or (ref^.base<>NR_NO) or (ref^.index<>NR_NO) then
  1327. internalerror(2021092018);
  1328. WriteUleb(natural_alignment_for_load_store(opcode));
  1329. WriteUleb(ref^.offset);
  1330. end;
  1331. end;
  1332. top_const:
  1333. begin
  1334. WriteUleb(natural_alignment_for_load_store(opcode));
  1335. WriteUleb(val);
  1336. end;
  1337. else
  1338. internalerror(2021092017);
  1339. end;
  1340. end;
  1341. a_call:
  1342. begin
  1343. if ops<>1 then
  1344. internalerror(2021092021);
  1345. with oper[0]^ do
  1346. case typ of
  1347. top_ref:
  1348. begin
  1349. if not assigned(ref^.symbol) or (ref^.base<>NR_NO) or (ref^.index<>NR_NO) or (ref^.offset<>0) then
  1350. internalerror(2021092023);
  1351. WriteByte($10);
  1352. objdata.writeReloc(0,5,ObjData.symbolref(ref^.symbol),RELOC_FUNCTION_INDEX_LEB);
  1353. end;
  1354. else
  1355. internalerror(2021092022);
  1356. end;
  1357. end;
  1358. a_call_indirect:
  1359. begin
  1360. if ops<>1 then
  1361. internalerror(2021092610);
  1362. with oper[0]^ do
  1363. case typ of
  1364. top_functype:
  1365. begin
  1366. WriteByte($11);
  1367. objdata.writeReloc(TWasmObjData(objdata).AddFuncType(functype),5,nil,RELOC_TYPE_INDEX_LEB);
  1368. WriteUleb(0);
  1369. end;
  1370. else
  1371. internalerror(2021092611);
  1372. end;
  1373. end;
  1374. a_br,
  1375. a_br_if,
  1376. a_rethrow,
  1377. a_delegate:
  1378. begin
  1379. case opcode of
  1380. a_br:
  1381. WriteByte($0C);
  1382. a_br_if:
  1383. WriteByte($0D);
  1384. a_rethrow:
  1385. WriteByte($09);
  1386. a_delegate:
  1387. WriteByte($18);
  1388. else
  1389. internalerror(2021092622);
  1390. end;
  1391. if ops<>1 then
  1392. internalerror(2021092610);
  1393. with oper[0]^ do
  1394. case typ of
  1395. top_const:
  1396. WriteUleb(val);
  1397. else
  1398. internalerror(2021092625);
  1399. end;
  1400. end;
  1401. a_catch,
  1402. a_throw:
  1403. begin
  1404. case opcode of
  1405. a_catch:
  1406. WriteByte($07);
  1407. a_throw:
  1408. WriteByte($08);
  1409. else
  1410. internalerror(2021092708);
  1411. end;
  1412. if ops<>1 then
  1413. internalerror(2021092709);
  1414. with oper[0]^ do
  1415. case typ of
  1416. top_ref:
  1417. begin
  1418. if not assigned(ref^.symbol) or (ref^.base<>NR_NO) or (ref^.index<>NR_NO) or (ref^.offset<>0) then
  1419. internalerror(2021092711);
  1420. objdata.writeReloc(0,5,TWasmObjData(ObjData).ExceptionTagRef(ref^.symbol),RELOC_TAG_INDEX_LEB);
  1421. end;
  1422. else
  1423. internalerror(2021092710);
  1424. end;
  1425. end;
  1426. else
  1427. internalerror(2021092624);
  1428. end;
  1429. end;
  1430. function spilling_create_load(const ref:treference;r:tregister):Taicpu;
  1431. begin
  1432. internalerror(2010122614);
  1433. result:=nil;
  1434. end;
  1435. function spilling_create_store(r:tregister; const ref:treference):Taicpu;
  1436. begin
  1437. internalerror(2010122615);
  1438. result:=nil;
  1439. end;
  1440. procedure InitAsm;
  1441. begin
  1442. end;
  1443. procedure DoneAsm;
  1444. begin
  1445. end;
  1446. initialization
  1447. cai_cpu:=taicpu;
  1448. cai_align:=tai_align;
  1449. end.