aasmcpu.pas 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863
  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. // the actual use is defined by the assembly section used
  64. { timpexp_ai }
  65. tai_impexp = class(tai)
  66. extname : ansistring; // external name
  67. intname : ansistring; // internal name
  68. extmodule : ansistring; // external unit name
  69. symstype: TImpExpType;
  70. constructor create(const aextname, aintname: ansistring; asymtype: timpexptype); overload;
  71. constructor create(const aextmodule, aextname, aintname: ansistring; asymtype: timpexptype); overload;
  72. end;
  73. // local variable declaration
  74. { tai_local }
  75. tai_local = class(tai)
  76. bastyp: TWasmBasicType;
  77. name : string;
  78. first: boolean;
  79. last: boolean;
  80. constructor create(abasictype: TWasmBasicType; const aname: string = '');
  81. end;
  82. { tai_functype }
  83. tai_functype = class(tai)
  84. funcname: string;
  85. functype: TWasmFuncType;
  86. constructor create(const afuncname: string; afunctype: TWasmFuncType);
  87. destructor destroy;override;
  88. end;
  89. { tai_tagtype }
  90. tai_tagtype = class(tai)
  91. tagname: string;
  92. params: TWasmResultType;
  93. constructor create(const atagname: string; aparams: TWasmResultType);
  94. end;
  95. procedure InitAsm;
  96. procedure DoneAsm;
  97. function spilling_create_load(const ref:treference;r:tregister):Taicpu;
  98. function spilling_create_store(r:tregister; const ref:treference):Taicpu;
  99. implementation
  100. { tai_functype }
  101. constructor tai_functype.create(const afuncname: string; afunctype: TWasmFuncType);
  102. begin
  103. inherited Create;
  104. typ:=ait_functype;
  105. funcname:=afuncname;
  106. functype:=afunctype;
  107. end;
  108. destructor tai_functype.destroy;
  109. begin
  110. functype.free;
  111. inherited;
  112. end;
  113. { tai_tagtype }
  114. constructor tai_tagtype.create(const atagname: string; aparams: TWasmResultType);
  115. begin
  116. typ:=ait_tagtype;
  117. tagname:=atagname;
  118. params:=aparams;
  119. end;
  120. { tai_local }
  121. constructor tai_local.create(abasictype: TWasmBasicType; const aname: string);
  122. begin
  123. inherited Create;
  124. bastyp := abasictype;
  125. typ := ait_local;
  126. name := aname;
  127. end;
  128. { timpexp_ai }
  129. constructor tai_impexp.create(const aextname, aintname: ansistring;
  130. asymtype: timpexptype);
  131. begin
  132. create('', aextname, aintname, asymtype);;
  133. end;
  134. constructor tai_impexp.create(const aextmodule, aextname, aintname: ansistring; asymtype: timpexptype);
  135. begin
  136. inherited create;
  137. typ := ait_importexport;
  138. extmodule := aextmodule;
  139. extname := aextname;
  140. intname := aintname;
  141. symstype:= asymtype;
  142. end;
  143. {*****************************************************************************
  144. taicpu Constructors
  145. *****************************************************************************}
  146. constructor taicpu.op_none(op : tasmop);
  147. begin
  148. inherited create(op);
  149. end;
  150. constructor taicpu.op_reg(op : tasmop;_op1 : tregister);
  151. begin
  152. inherited create(op);
  153. ops:=1;
  154. {$ifdef EXTDEBUG}
  155. if getregtype(_op1)=R_INVALIDREGISTER then
  156. InternalError(2021011901);
  157. {$endif EXTDEBUG}
  158. loadreg(0,_op1);
  159. end;
  160. constructor taicpu.op_ref(op : tasmop;const _op1 : treference);
  161. begin
  162. inherited create(op);
  163. ops:=1;
  164. loadref(0,_op1);
  165. if op in [a_local_get,a_local_set,a_local_tee] then
  166. begin
  167. if (_op1.base<>NR_LOCAL_STACK_POINTER_REG) or (_op1.index<>NR_NO) then
  168. internalerror(2021010201);
  169. end
  170. else
  171. begin
  172. if (_op1.base<>NR_NO) or (_op1.index<>NR_NO) then
  173. internalerror(2021010202);
  174. end;
  175. end;
  176. constructor taicpu.op_const(op : tasmop;_op1 : aint);
  177. begin
  178. inherited create(op);
  179. ops:=1;
  180. loadconst(0,_op1);
  181. end;
  182. constructor taicpu.op_sym(op : tasmop;_op1 : tasmsymbol);
  183. begin
  184. inherited create(op);
  185. ops:=1;
  186. loadsymbol(0,_op1,0);
  187. end;
  188. constructor taicpu.op_sym_const(op: tasmop; _op1: tasmsymbol; _op2: aint);
  189. begin
  190. inherited create(op);
  191. ops:=2;
  192. loadsymbol(0,_op1,0);
  193. loadconst(1,_op2);
  194. end;
  195. constructor taicpu.op_single(op: tasmop; _op1: single);
  196. begin
  197. inherited create(op);
  198. ops:=1;
  199. loadsingle(0,_op1);
  200. end;
  201. constructor taicpu.op_double(op: tasmop; _op1: double);
  202. begin
  203. inherited create(op);
  204. ops:=1;
  205. loaddouble(0,_op1);
  206. end;
  207. constructor taicpu.op_functype(op: tasmop; _op1: TWasmFuncType);
  208. begin
  209. inherited create(op);
  210. ops:=1;
  211. loadfunctype(0,_op1);
  212. end;
  213. procedure taicpu.loadfunctype(opidx: longint; ft: TWasmFuncType);
  214. begin
  215. allocate_oper(opidx+1);
  216. with oper[opidx]^ do
  217. begin
  218. if typ<>top_functype then
  219. clearop(opidx);
  220. functype:=ft;
  221. typ:=top_functype;
  222. end;
  223. end;
  224. procedure taicpu.loadsingle(opidx:longint;f:single);
  225. begin
  226. allocate_oper(opidx+1);
  227. with oper[opidx]^ do
  228. begin
  229. if typ<>top_single then
  230. clearop(opidx);
  231. sval:=f;
  232. typ:=top_single;
  233. end;
  234. end;
  235. procedure taicpu.loaddouble(opidx: longint; d: double);
  236. begin
  237. allocate_oper(opidx+1);
  238. with oper[opidx]^ do
  239. begin
  240. if typ<>top_double then
  241. clearop(opidx);
  242. dval:=d;
  243. typ:=top_double;
  244. end;
  245. end;
  246. function taicpu.is_same_reg_move(regtype: Tregistertype):boolean;
  247. begin
  248. result:=false;
  249. end;
  250. function taicpu.spilling_get_operation_type(opnr: longint): topertype;
  251. begin
  252. if opcode in AsmOp_Store then
  253. result:=operand_write
  254. else
  255. result:=operand_read;
  256. end;
  257. function taicpu.Pass1(objdata: TObjData): longint;
  258. function SlebSize(v: tcgint): longint;
  259. begin
  260. result:=0;
  261. repeat
  262. v:=SarInt64(v,7);
  263. Inc(result);
  264. until ((v=0) and ((byte(v) and 64)=0)) or ((v=-1) and ((byte(v) and 64)<>0));
  265. end;
  266. begin
  267. result:=0;
  268. case opcode of
  269. a_unreachable,
  270. a_nop,
  271. a_return,
  272. a_drop,
  273. a_i32_eqz,
  274. a_i32_eq,
  275. a_i32_ne,
  276. a_i32_lt_s,
  277. a_i32_lt_u,
  278. a_i32_gt_s,
  279. a_i32_gt_u,
  280. a_i32_le_s,
  281. a_i32_le_u,
  282. a_i32_ge_s,
  283. a_i32_ge_u,
  284. a_i64_eqz,
  285. a_i64_eq,
  286. a_i64_ne,
  287. a_i64_lt_s,
  288. a_i64_lt_u,
  289. a_i64_gt_s,
  290. a_i64_gt_u,
  291. a_i64_le_s,
  292. a_i64_le_u,
  293. a_i64_ge_s,
  294. a_i64_ge_u,
  295. a_f32_eq,
  296. a_f32_ne,
  297. a_f32_lt,
  298. a_f32_gt,
  299. a_f32_le,
  300. a_f32_ge,
  301. a_f64_eq,
  302. a_f64_ne,
  303. a_f64_lt,
  304. a_f64_gt,
  305. a_f64_le,
  306. a_f64_ge,
  307. a_i32_clz,
  308. a_i32_ctz,
  309. a_i32_popcnt,
  310. a_i32_add,
  311. a_i32_sub,
  312. a_i32_mul,
  313. a_i32_div_s,
  314. a_i32_div_u,
  315. a_i32_rem_s,
  316. a_i32_rem_u,
  317. a_i32_and,
  318. a_i32_or,
  319. a_i32_xor,
  320. a_i32_shl,
  321. a_i32_shr_s,
  322. a_i32_shr_u,
  323. a_i32_rotl,
  324. a_i32_rotr,
  325. a_i64_clz,
  326. a_i64_ctz,
  327. a_i64_popcnt,
  328. a_i64_add,
  329. a_i64_sub,
  330. a_i64_mul,
  331. a_i64_div_s,
  332. a_i64_div_u,
  333. a_i64_rem_s,
  334. a_i64_rem_u,
  335. a_i64_and,
  336. a_i64_or,
  337. a_i64_xor,
  338. a_i64_shl,
  339. a_i64_shr_s,
  340. a_i64_shr_u,
  341. a_i64_rotl,
  342. a_i64_rotr,
  343. a_f32_abs,
  344. a_f32_neg,
  345. a_f32_ceil,
  346. a_f32_floor,
  347. a_f32_trunc,
  348. a_f32_nearest,
  349. a_f32_sqrt,
  350. a_f32_add,
  351. a_f32_sub,
  352. a_f32_mul,
  353. a_f32_div,
  354. a_f32_min,
  355. a_f32_max,
  356. a_f32_copysign,
  357. a_f64_abs,
  358. a_f64_neg,
  359. a_f64_ceil,
  360. a_f64_floor,
  361. a_f64_trunc,
  362. a_f64_nearest,
  363. a_f64_sqrt,
  364. a_f64_add,
  365. a_f64_sub,
  366. a_f64_mul,
  367. a_f64_div,
  368. a_f64_min,
  369. a_f64_max,
  370. a_f64_copysign,
  371. a_i32_wrap_i64,
  372. a_i32_trunc_f32_s,
  373. a_i32_trunc_f32_u,
  374. a_i32_trunc_f64_s,
  375. a_i32_trunc_f64_u,
  376. a_i64_extend_i32_s,
  377. a_i64_extend_i32_u,
  378. a_i64_trunc_f32_s,
  379. a_i64_trunc_f32_u,
  380. a_i64_trunc_f64_s,
  381. a_i64_trunc_f64_u,
  382. a_f32_convert_i32_s,
  383. a_f32_convert_i32_u,
  384. a_f32_convert_i64_s,
  385. a_f32_convert_i64_u,
  386. a_f32_demote_f64,
  387. a_f64_convert_i32_s,
  388. a_f64_convert_i32_u,
  389. a_f64_convert_i64_s,
  390. a_f64_convert_i64_u,
  391. a_f64_promote_f32,
  392. a_i32_reinterpret_f32,
  393. a_i64_reinterpret_f64,
  394. a_f32_reinterpret_i32,
  395. a_f64_reinterpret_i64,
  396. a_i32_extend8_s,
  397. a_i32_extend16_s,
  398. a_i64_extend8_s,
  399. a_i64_extend16_s,
  400. a_i64_extend32_s,
  401. a_end_block,
  402. a_end_if,
  403. a_end_loop,
  404. a_end_try,
  405. a_catch_all:
  406. result:=1;
  407. a_memory_size,
  408. a_memory_grow:
  409. result:=2;
  410. a_i32_const,
  411. a_i64_const:
  412. begin
  413. if ops<>1 then
  414. internalerror(2021092001);
  415. case oper[0]^.typ of
  416. top_const:
  417. result:=1+SlebSize(oper[0]^.val);
  418. else
  419. Writeln('Warning! Not implemented opcode, pass1: ', opcode, ' ', oper[0]^.typ);
  420. end;
  421. end;
  422. else
  423. Writeln('Warning! Not implemented opcode, pass1: ', opcode);
  424. end;
  425. end;
  426. procedure taicpu.Pass2(objdata: TObjData);
  427. procedure WriteByte(b: byte);
  428. begin
  429. objdata.writebytes(b,1);
  430. end;
  431. procedure WriteSleb(v: tcgint);
  432. var
  433. b: byte;
  434. Done: Boolean=false;
  435. begin
  436. repeat
  437. b:=byte(v) and 127;
  438. v:=SarInt64(v,7);
  439. if ((v=0) and ((b and 64)=0)) or ((v=-1) and ((b and 64)<>0)) then
  440. Done:=true
  441. else
  442. b:=b or 128;
  443. objdata.writebytes(b,1);
  444. until Done;
  445. end;
  446. begin
  447. case opcode of
  448. a_unreachable:
  449. WriteByte($00);
  450. a_nop:
  451. WriteByte($01);
  452. a_return:
  453. WriteByte($0F);
  454. a_drop:
  455. WriteByte($1A);
  456. a_memory_size:
  457. begin
  458. WriteByte($3F);
  459. WriteByte($00);
  460. end;
  461. a_memory_grow:
  462. begin
  463. WriteByte($40);
  464. WriteByte($00);
  465. end;
  466. a_i32_eqz:
  467. WriteByte($45);
  468. a_i32_eq:
  469. WriteByte($46);
  470. a_i32_ne:
  471. WriteByte($47);
  472. a_i32_lt_s:
  473. WriteByte($48);
  474. a_i32_lt_u:
  475. WriteByte($49);
  476. a_i32_gt_s:
  477. WriteByte($4A);
  478. a_i32_gt_u:
  479. WriteByte($4B);
  480. a_i32_le_s:
  481. WriteByte($4C);
  482. a_i32_le_u:
  483. WriteByte($4D);
  484. a_i32_ge_s:
  485. WriteByte($4E);
  486. a_i32_ge_u:
  487. WriteByte($4F);
  488. a_i64_eqz:
  489. WriteByte($50);
  490. a_i64_eq:
  491. WriteByte($51);
  492. a_i64_ne:
  493. WriteByte($52);
  494. a_i64_lt_s:
  495. WriteByte($53);
  496. a_i64_lt_u:
  497. WriteByte($54);
  498. a_i64_gt_s:
  499. WriteByte($55);
  500. a_i64_gt_u:
  501. WriteByte($56);
  502. a_i64_le_s:
  503. WriteByte($57);
  504. a_i64_le_u:
  505. WriteByte($58);
  506. a_i64_ge_s:
  507. WriteByte($59);
  508. a_i64_ge_u:
  509. WriteByte($5A);
  510. a_f32_eq:
  511. WriteByte($5B);
  512. a_f32_ne:
  513. WriteByte($5C);
  514. a_f32_lt:
  515. WriteByte($5D);
  516. a_f32_gt:
  517. WriteByte($5E);
  518. a_f32_le:
  519. WriteByte($5F);
  520. a_f32_ge:
  521. WriteByte($60);
  522. a_f64_eq:
  523. WriteByte($61);
  524. a_f64_ne:
  525. WriteByte($62);
  526. a_f64_lt:
  527. WriteByte($63);
  528. a_f64_gt:
  529. WriteByte($64);
  530. a_f64_le:
  531. WriteByte($65);
  532. a_f64_ge:
  533. WriteByte($66);
  534. a_i32_clz:
  535. WriteByte($67);
  536. a_i32_ctz:
  537. WriteByte($68);
  538. a_i32_popcnt:
  539. WriteByte($69);
  540. a_i32_add:
  541. WriteByte($6A);
  542. a_i32_sub:
  543. WriteByte($6B);
  544. a_i32_mul:
  545. WriteByte($6C);
  546. a_i32_div_s:
  547. WriteByte($6D);
  548. a_i32_div_u:
  549. WriteByte($6E);
  550. a_i32_rem_s:
  551. WriteByte($6F);
  552. a_i32_rem_u:
  553. WriteByte($70);
  554. a_i32_and:
  555. WriteByte($71);
  556. a_i32_or:
  557. WriteByte($72);
  558. a_i32_xor:
  559. WriteByte($73);
  560. a_i32_shl:
  561. WriteByte($74);
  562. a_i32_shr_s:
  563. WriteByte($75);
  564. a_i32_shr_u:
  565. WriteByte($76);
  566. a_i32_rotl:
  567. WriteByte($77);
  568. a_i32_rotr:
  569. WriteByte($78);
  570. a_i64_clz:
  571. WriteByte($79);
  572. a_i64_ctz:
  573. WriteByte($7A);
  574. a_i64_popcnt:
  575. WriteByte($7B);
  576. a_i64_add:
  577. WriteByte($7C);
  578. a_i64_sub:
  579. WriteByte($7D);
  580. a_i64_mul:
  581. WriteByte($7E);
  582. a_i64_div_s:
  583. WriteByte($7F);
  584. a_i64_div_u:
  585. WriteByte($80);
  586. a_i64_rem_s:
  587. WriteByte($81);
  588. a_i64_rem_u:
  589. WriteByte($82);
  590. a_i64_and:
  591. WriteByte($83);
  592. a_i64_or:
  593. WriteByte($84);
  594. a_i64_xor:
  595. WriteByte($85);
  596. a_i64_shl:
  597. WriteByte($86);
  598. a_i64_shr_s:
  599. WriteByte($87);
  600. a_i64_shr_u:
  601. WriteByte($88);
  602. a_i64_rotl:
  603. WriteByte($89);
  604. a_i64_rotr:
  605. WriteByte($8A);
  606. a_f32_abs:
  607. WriteByte($8B);
  608. a_f32_neg:
  609. WriteByte($8C);
  610. a_f32_ceil:
  611. WriteByte($8D);
  612. a_f32_floor:
  613. WriteByte($8E);
  614. a_f32_trunc:
  615. WriteByte($8F);
  616. a_f32_nearest:
  617. WriteByte($90);
  618. a_f32_sqrt:
  619. WriteByte($91);
  620. a_f32_add:
  621. WriteByte($92);
  622. a_f32_sub:
  623. WriteByte($93);
  624. a_f32_mul:
  625. WriteByte($94);
  626. a_f32_div:
  627. WriteByte($95);
  628. a_f32_min:
  629. WriteByte($96);
  630. a_f32_max:
  631. WriteByte($97);
  632. a_f32_copysign:
  633. WriteByte($98);
  634. a_f64_abs:
  635. WriteByte($99);
  636. a_f64_neg:
  637. WriteByte($9A);
  638. a_f64_ceil:
  639. WriteByte($9B);
  640. a_f64_floor:
  641. WriteByte($9C);
  642. a_f64_trunc:
  643. WriteByte($9D);
  644. a_f64_nearest:
  645. WriteByte($9E);
  646. a_f64_sqrt:
  647. WriteByte($9F);
  648. a_f64_add:
  649. WriteByte($A0);
  650. a_f64_sub:
  651. WriteByte($A1);
  652. a_f64_mul:
  653. WriteByte($A2);
  654. a_f64_div:
  655. WriteByte($A3);
  656. a_f64_min:
  657. WriteByte($A4);
  658. a_f64_max:
  659. WriteByte($A5);
  660. a_f64_copysign:
  661. WriteByte($A6);
  662. a_i32_wrap_i64:
  663. WriteByte($A7);
  664. a_i32_trunc_f32_s:
  665. WriteByte($A8);
  666. a_i32_trunc_f32_u:
  667. WriteByte($A9);
  668. a_i32_trunc_f64_s:
  669. WriteByte($AA);
  670. a_i32_trunc_f64_u:
  671. WriteByte($AB);
  672. a_i64_extend_i32_s:
  673. WriteByte($AC);
  674. a_i64_extend_i32_u:
  675. WriteByte($AD);
  676. a_i64_trunc_f32_s:
  677. WriteByte($AE);
  678. a_i64_trunc_f32_u:
  679. WriteByte($AF);
  680. a_i64_trunc_f64_s:
  681. WriteByte($B0);
  682. a_i64_trunc_f64_u:
  683. WriteByte($B1);
  684. a_f32_convert_i32_s:
  685. WriteByte($B2);
  686. a_f32_convert_i32_u:
  687. WriteByte($B3);
  688. a_f32_convert_i64_s:
  689. WriteByte($B4);
  690. a_f32_convert_i64_u:
  691. WriteByte($B5);
  692. a_f32_demote_f64:
  693. WriteByte($B6);
  694. a_f64_convert_i32_s:
  695. WriteByte($B7);
  696. a_f64_convert_i32_u:
  697. WriteByte($B8);
  698. a_f64_convert_i64_s:
  699. WriteByte($B9);
  700. a_f64_convert_i64_u:
  701. WriteByte($BA);
  702. a_f64_promote_f32:
  703. WriteByte($BB);
  704. a_i32_reinterpret_f32:
  705. WriteByte($BC);
  706. a_i64_reinterpret_f64:
  707. WriteByte($BD);
  708. a_f32_reinterpret_i32:
  709. WriteByte($BE);
  710. a_f64_reinterpret_i64:
  711. WriteByte($BF);
  712. a_i32_extend8_s:
  713. WriteByte($C0);
  714. a_i32_extend16_s:
  715. WriteByte($C1);
  716. a_i64_extend8_s:
  717. WriteByte($C2);
  718. a_i64_extend16_s:
  719. WriteByte($C3);
  720. a_i64_extend32_s:
  721. WriteByte($C4);
  722. a_end_block,
  723. a_end_if,
  724. a_end_loop,
  725. a_end_try:
  726. WriteByte($0B);
  727. a_catch_all:
  728. WriteByte($19);
  729. a_i32_const,
  730. a_i64_const:
  731. begin
  732. case opcode of
  733. a_i32_const:
  734. WriteByte($41);
  735. a_i64_const:
  736. WriteByte($42);
  737. else
  738. internalerror(2021092002);
  739. end;
  740. if ops<>1 then
  741. internalerror(2021092001);
  742. case oper[0]^.typ of
  743. top_const:
  744. WriteSleb(oper[0]^.val);
  745. else
  746. Writeln('Warning! Not implemented opcode, pass2: ', opcode, ' ', oper[0]^.typ);
  747. end;
  748. end;
  749. else
  750. Writeln('Warning! Not implemented opcode, pass2: ', opcode);
  751. end;
  752. end;
  753. function spilling_create_load(const ref:treference;r:tregister):Taicpu;
  754. begin
  755. internalerror(2010122614);
  756. result:=nil;
  757. end;
  758. function spilling_create_store(r:tregister; const ref:treference):Taicpu;
  759. begin
  760. internalerror(2010122615);
  761. result:=nil;
  762. end;
  763. procedure InitAsm;
  764. begin
  765. end;
  766. procedure DoneAsm;
  767. begin
  768. end;
  769. initialization
  770. cai_cpu:=taicpu;
  771. cai_align:=tai_align;
  772. casmdata:=TAsmData;
  773. end.