aasmcpu.pas 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556
  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. casmdata:=TAsmData;
  1450. end.