aasmcpu.pas 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539
  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_i32_const:
  458. begin
  459. if ops<>1 then
  460. internalerror(2021092001);
  461. with oper[0]^ do
  462. case typ of
  463. top_ref:
  464. begin
  465. if assigned(ref^.symbol) then
  466. result:=6
  467. else
  468. begin
  469. if assigned(ref^.symbol) or (ref^.base<>NR_NO) or (ref^.index<>NR_NO) then
  470. internalerror(2021092018);
  471. result:=1+SlebSize(longint(ref^.offset));
  472. end;
  473. end;
  474. top_const:
  475. result:=1+SlebSize(longint(val));
  476. else
  477. internalerror(2021092615);
  478. end;
  479. end;
  480. a_i64_const:
  481. begin
  482. if ops<>1 then
  483. internalerror(2021092001);
  484. with oper[0]^ do
  485. case typ of
  486. top_ref:
  487. begin
  488. if assigned(ref^.symbol) then
  489. result:=6
  490. else
  491. begin
  492. if assigned(ref^.symbol) or (ref^.base<>NR_NO) or (ref^.index<>NR_NO) then
  493. internalerror(2021092018);
  494. result:=1+SlebSize(int64(ref^.offset));
  495. end;
  496. end;
  497. top_const:
  498. result:=1+SlebSize(int64(val));
  499. else
  500. internalerror(2021092615);
  501. end;
  502. end;
  503. a_f32_const:
  504. result:=5;
  505. a_f64_const:
  506. result:=9;
  507. a_local_get,
  508. a_local_set,
  509. a_local_tee:
  510. begin
  511. if ops<>1 then
  512. internalerror(2021092001);
  513. with oper[0]^ do
  514. case typ of
  515. top_ref:
  516. begin
  517. if assigned(ref^.symbol) then
  518. internalerror(2021092005);
  519. if ref^.base<>NR_STACK_POINTER_REG then
  520. internalerror(2021092006);
  521. if ref^.index<>NR_NO then
  522. internalerror(2021092007);
  523. result:=1+UlebSize(ref^.offset);
  524. end;
  525. else
  526. internalerror(2021092008);
  527. end;
  528. end;
  529. a_global_get,
  530. a_global_set:
  531. begin
  532. if ops<>1 then
  533. internalerror(2021092010);
  534. with oper[0]^ do
  535. case typ of
  536. top_ref:
  537. begin
  538. if not assigned(ref^.symbol) then
  539. internalerror(2021092012);
  540. if (ref^.base<>NR_NO) or (ref^.index<>NR_NO) or (ref^.offset<>0) then
  541. internalerror(2021092013);
  542. result:=6;
  543. end;
  544. else
  545. internalerror(2021092011);
  546. end;
  547. end;
  548. a_end_function:
  549. result:=0;
  550. a_block,
  551. a_loop,
  552. a_if,
  553. a_try:
  554. begin
  555. if ops=0 then
  556. result:=2
  557. else
  558. begin
  559. if ops<>1 then
  560. internalerror(2021092015);
  561. with oper[0]^ do
  562. case typ of
  563. top_functype:
  564. begin
  565. if (length(functype.params)=0) and (length(functype.results)<=1) then
  566. result:=2
  567. else
  568. { more complex blocktypes are not yet implemented }
  569. internalerror(2021092621);
  570. end;
  571. else
  572. internalerror(2021092620);
  573. end;
  574. end;
  575. end;
  576. a_i32_load,
  577. a_i64_load,
  578. a_f32_load,
  579. a_f64_load,
  580. a_i32_load8_s,
  581. a_i32_load8_u,
  582. a_i32_load16_s,
  583. a_i32_load16_u,
  584. a_i64_load8_s,
  585. a_i64_load8_u,
  586. a_i64_load16_s,
  587. a_i64_load16_u,
  588. a_i64_load32_s,
  589. a_i64_load32_u,
  590. a_i32_store,
  591. a_i64_store,
  592. a_f32_store,
  593. a_f64_store,
  594. a_i32_store8,
  595. a_i32_store16,
  596. a_i64_store8,
  597. a_i64_store16,
  598. a_i64_store32:
  599. begin
  600. if ops<>1 then
  601. internalerror(2021092016);
  602. with oper[0]^ do
  603. case typ of
  604. top_ref:
  605. begin
  606. if assigned(ref^.symbol) then
  607. begin
  608. Result:=1+
  609. UlebSize(natural_alignment_for_load_store(opcode))+
  610. 5; { relocation, fixed size = 5 bytes }
  611. end
  612. else
  613. begin
  614. if assigned(ref^.symbol) or (ref^.base<>NR_NO) or (ref^.index<>NR_NO) then
  615. internalerror(2021092018);
  616. Result:=1+
  617. UlebSize(natural_alignment_for_load_store(opcode))+
  618. UlebSize(ref^.offset);
  619. end;
  620. end;
  621. top_const:
  622. begin
  623. Result:=1+
  624. UlebSize(natural_alignment_for_load_store(opcode))+
  625. UlebSize(val);
  626. end;
  627. else
  628. internalerror(2021092017);
  629. end;
  630. end;
  631. a_call:
  632. begin
  633. if ops<>1 then
  634. internalerror(2021092021);
  635. with oper[0]^ do
  636. case typ of
  637. top_ref:
  638. begin
  639. if not assigned(ref^.symbol) or (ref^.base<>NR_NO) or (ref^.index<>NR_NO) or (ref^.offset<>0) then
  640. internalerror(2021092023);
  641. result:=6;
  642. end;
  643. else
  644. internalerror(2021092022);
  645. end;
  646. end;
  647. a_call_indirect:
  648. begin
  649. if ops<>1 then
  650. internalerror(2021092610);
  651. with oper[0]^ do
  652. case typ of
  653. top_functype:
  654. begin
  655. TWasmObjData(objdata).AddFuncType(functype);
  656. result:=6+
  657. UlebSize(0);
  658. end;
  659. else
  660. internalerror(2021092611);
  661. end;
  662. end;
  663. a_br,
  664. a_br_if,
  665. a_rethrow,
  666. a_delegate:
  667. begin
  668. if ops<>1 then
  669. internalerror(2021092610);
  670. with oper[0]^ do
  671. case typ of
  672. top_const:
  673. result:=1+
  674. UlebSize(val);
  675. else
  676. internalerror(2021092625);
  677. end;
  678. end;
  679. a_catch,
  680. a_throw:
  681. begin
  682. if ops<>1 then
  683. internalerror(2021092709);
  684. with oper[0]^ do
  685. case typ of
  686. top_ref:
  687. begin
  688. if not assigned(ref^.symbol) or (ref^.base<>NR_NO) or (ref^.index<>NR_NO) or (ref^.offset<>0) then
  689. internalerror(2021092711);
  690. result:=6;
  691. end;
  692. else
  693. internalerror(2021092710);
  694. end;
  695. end;
  696. else
  697. internalerror(2021092623);
  698. end;
  699. end;
  700. procedure taicpu.Pass2(objdata: TObjData);
  701. procedure WriteByte(b: byte);
  702. begin
  703. objdata.writebytes(b,1);
  704. end;
  705. {$ifdef FPC_LITTLE_ENDIAN}
  706. procedure WriteSingle(s: single);
  707. begin
  708. objdata.writebytes(s,4);
  709. end;
  710. procedure WriteDouble(d: double);
  711. begin
  712. objdata.writebytes(d,8);
  713. end;
  714. {$else FPC_LITTLE_ENDIAN}
  715. procedure WriteSingle(s: single);
  716. var
  717. l: longword;
  718. begin
  719. Move(s,l,4);
  720. l:=SwapEndian(l);
  721. objdata.writebytes(l,4);
  722. end;
  723. procedure WriteDouble(d: double);
  724. var
  725. q: qword;
  726. begin
  727. Move(d,q,8);
  728. q:=SwapEndian(q);
  729. objdata.writebytes(q,8);
  730. end;
  731. {$endif FPC_LITTLE_ENDIAN}
  732. procedure WriteSleb(v: tcgint);
  733. var
  734. b: byte;
  735. Done: Boolean=false;
  736. begin
  737. repeat
  738. b:=byte(v) and 127;
  739. v:=SarInt64(v,7);
  740. if ((v=0) and ((b and 64)=0)) or ((v=-1) and ((b and 64)<>0)) then
  741. Done:=true
  742. else
  743. b:=b or 128;
  744. objdata.writebytes(b,1);
  745. until Done;
  746. end;
  747. procedure WriteUleb(v: tcgint);
  748. var
  749. b: byte;
  750. begin
  751. repeat
  752. b:=byte(v) and 127;
  753. v:=v shr 7;
  754. if v<>0 then
  755. b:=b or 128;
  756. objdata.writebytes(b,1);
  757. until v=0;
  758. end;
  759. begin
  760. case opcode of
  761. a_unreachable:
  762. WriteByte($00);
  763. a_nop:
  764. WriteByte($01);
  765. a_return:
  766. WriteByte($0F);
  767. a_drop:
  768. WriteByte($1A);
  769. a_memory_size:
  770. begin
  771. WriteByte($3F);
  772. WriteByte($00);
  773. end;
  774. a_memory_grow:
  775. begin
  776. WriteByte($40);
  777. WriteByte($00);
  778. end;
  779. a_i32_eqz:
  780. WriteByte($45);
  781. a_i32_eq:
  782. WriteByte($46);
  783. a_i32_ne:
  784. WriteByte($47);
  785. a_i32_lt_s:
  786. WriteByte($48);
  787. a_i32_lt_u:
  788. WriteByte($49);
  789. a_i32_gt_s:
  790. WriteByte($4A);
  791. a_i32_gt_u:
  792. WriteByte($4B);
  793. a_i32_le_s:
  794. WriteByte($4C);
  795. a_i32_le_u:
  796. WriteByte($4D);
  797. a_i32_ge_s:
  798. WriteByte($4E);
  799. a_i32_ge_u:
  800. WriteByte($4F);
  801. a_i64_eqz:
  802. WriteByte($50);
  803. a_i64_eq:
  804. WriteByte($51);
  805. a_i64_ne:
  806. WriteByte($52);
  807. a_i64_lt_s:
  808. WriteByte($53);
  809. a_i64_lt_u:
  810. WriteByte($54);
  811. a_i64_gt_s:
  812. WriteByte($55);
  813. a_i64_gt_u:
  814. WriteByte($56);
  815. a_i64_le_s:
  816. WriteByte($57);
  817. a_i64_le_u:
  818. WriteByte($58);
  819. a_i64_ge_s:
  820. WriteByte($59);
  821. a_i64_ge_u:
  822. WriteByte($5A);
  823. a_f32_eq:
  824. WriteByte($5B);
  825. a_f32_ne:
  826. WriteByte($5C);
  827. a_f32_lt:
  828. WriteByte($5D);
  829. a_f32_gt:
  830. WriteByte($5E);
  831. a_f32_le:
  832. WriteByte($5F);
  833. a_f32_ge:
  834. WriteByte($60);
  835. a_f64_eq:
  836. WriteByte($61);
  837. a_f64_ne:
  838. WriteByte($62);
  839. a_f64_lt:
  840. WriteByte($63);
  841. a_f64_gt:
  842. WriteByte($64);
  843. a_f64_le:
  844. WriteByte($65);
  845. a_f64_ge:
  846. WriteByte($66);
  847. a_i32_clz:
  848. WriteByte($67);
  849. a_i32_ctz:
  850. WriteByte($68);
  851. a_i32_popcnt:
  852. WriteByte($69);
  853. a_i32_add:
  854. WriteByte($6A);
  855. a_i32_sub:
  856. WriteByte($6B);
  857. a_i32_mul:
  858. WriteByte($6C);
  859. a_i32_div_s:
  860. WriteByte($6D);
  861. a_i32_div_u:
  862. WriteByte($6E);
  863. a_i32_rem_s:
  864. WriteByte($6F);
  865. a_i32_rem_u:
  866. WriteByte($70);
  867. a_i32_and:
  868. WriteByte($71);
  869. a_i32_or:
  870. WriteByte($72);
  871. a_i32_xor:
  872. WriteByte($73);
  873. a_i32_shl:
  874. WriteByte($74);
  875. a_i32_shr_s:
  876. WriteByte($75);
  877. a_i32_shr_u:
  878. WriteByte($76);
  879. a_i32_rotl:
  880. WriteByte($77);
  881. a_i32_rotr:
  882. WriteByte($78);
  883. a_i64_clz:
  884. WriteByte($79);
  885. a_i64_ctz:
  886. WriteByte($7A);
  887. a_i64_popcnt:
  888. WriteByte($7B);
  889. a_i64_add:
  890. WriteByte($7C);
  891. a_i64_sub:
  892. WriteByte($7D);
  893. a_i64_mul:
  894. WriteByte($7E);
  895. a_i64_div_s:
  896. WriteByte($7F);
  897. a_i64_div_u:
  898. WriteByte($80);
  899. a_i64_rem_s:
  900. WriteByte($81);
  901. a_i64_rem_u:
  902. WriteByte($82);
  903. a_i64_and:
  904. WriteByte($83);
  905. a_i64_or:
  906. WriteByte($84);
  907. a_i64_xor:
  908. WriteByte($85);
  909. a_i64_shl:
  910. WriteByte($86);
  911. a_i64_shr_s:
  912. WriteByte($87);
  913. a_i64_shr_u:
  914. WriteByte($88);
  915. a_i64_rotl:
  916. WriteByte($89);
  917. a_i64_rotr:
  918. WriteByte($8A);
  919. a_f32_abs:
  920. WriteByte($8B);
  921. a_f32_neg:
  922. WriteByte($8C);
  923. a_f32_ceil:
  924. WriteByte($8D);
  925. a_f32_floor:
  926. WriteByte($8E);
  927. a_f32_trunc:
  928. WriteByte($8F);
  929. a_f32_nearest:
  930. WriteByte($90);
  931. a_f32_sqrt:
  932. WriteByte($91);
  933. a_f32_add:
  934. WriteByte($92);
  935. a_f32_sub:
  936. WriteByte($93);
  937. a_f32_mul:
  938. WriteByte($94);
  939. a_f32_div:
  940. WriteByte($95);
  941. a_f32_min:
  942. WriteByte($96);
  943. a_f32_max:
  944. WriteByte($97);
  945. a_f32_copysign:
  946. WriteByte($98);
  947. a_f64_abs:
  948. WriteByte($99);
  949. a_f64_neg:
  950. WriteByte($9A);
  951. a_f64_ceil:
  952. WriteByte($9B);
  953. a_f64_floor:
  954. WriteByte($9C);
  955. a_f64_trunc:
  956. WriteByte($9D);
  957. a_f64_nearest:
  958. WriteByte($9E);
  959. a_f64_sqrt:
  960. WriteByte($9F);
  961. a_f64_add:
  962. WriteByte($A0);
  963. a_f64_sub:
  964. WriteByte($A1);
  965. a_f64_mul:
  966. WriteByte($A2);
  967. a_f64_div:
  968. WriteByte($A3);
  969. a_f64_min:
  970. WriteByte($A4);
  971. a_f64_max:
  972. WriteByte($A5);
  973. a_f64_copysign:
  974. WriteByte($A6);
  975. a_i32_wrap_i64:
  976. WriteByte($A7);
  977. a_i32_trunc_f32_s:
  978. WriteByte($A8);
  979. a_i32_trunc_f32_u:
  980. WriteByte($A9);
  981. a_i32_trunc_f64_s:
  982. WriteByte($AA);
  983. a_i32_trunc_f64_u:
  984. WriteByte($AB);
  985. a_i64_extend_i32_s:
  986. WriteByte($AC);
  987. a_i64_extend_i32_u:
  988. WriteByte($AD);
  989. a_i64_trunc_f32_s:
  990. WriteByte($AE);
  991. a_i64_trunc_f32_u:
  992. WriteByte($AF);
  993. a_i64_trunc_f64_s:
  994. WriteByte($B0);
  995. a_i64_trunc_f64_u:
  996. WriteByte($B1);
  997. a_f32_convert_i32_s:
  998. WriteByte($B2);
  999. a_f32_convert_i32_u:
  1000. WriteByte($B3);
  1001. a_f32_convert_i64_s:
  1002. WriteByte($B4);
  1003. a_f32_convert_i64_u:
  1004. WriteByte($B5);
  1005. a_f32_demote_f64:
  1006. WriteByte($B6);
  1007. a_f64_convert_i32_s:
  1008. WriteByte($B7);
  1009. a_f64_convert_i32_u:
  1010. WriteByte($B8);
  1011. a_f64_convert_i64_s:
  1012. WriteByte($B9);
  1013. a_f64_convert_i64_u:
  1014. WriteByte($BA);
  1015. a_f64_promote_f32:
  1016. WriteByte($BB);
  1017. a_i32_reinterpret_f32:
  1018. WriteByte($BC);
  1019. a_i64_reinterpret_f64:
  1020. WriteByte($BD);
  1021. a_f32_reinterpret_i32:
  1022. WriteByte($BE);
  1023. a_f64_reinterpret_i64:
  1024. WriteByte($BF);
  1025. a_i32_extend8_s:
  1026. WriteByte($C0);
  1027. a_i32_extend16_s:
  1028. WriteByte($C1);
  1029. a_i64_extend8_s:
  1030. WriteByte($C2);
  1031. a_i64_extend16_s:
  1032. WriteByte($C3);
  1033. a_i64_extend32_s:
  1034. WriteByte($C4);
  1035. a_end_block,
  1036. a_end_if,
  1037. a_end_loop,
  1038. a_end_try:
  1039. WriteByte($0B);
  1040. a_catch_all:
  1041. WriteByte($19);
  1042. a_i32_const:
  1043. begin
  1044. WriteByte($41);
  1045. if ops<>1 then
  1046. internalerror(2021092001);
  1047. with oper[0]^ do
  1048. case typ of
  1049. top_ref:
  1050. begin
  1051. if assigned(ref^.symbol) then
  1052. objdata.writeReloc(ref^.offset,5,ObjData.symbolref(ref^.symbol),RELOC_MEMORY_ADDR_OR_TABLE_INDEX_SLEB)
  1053. else
  1054. begin
  1055. if assigned(ref^.symbol) or (ref^.base<>NR_NO) or (ref^.index<>NR_NO) then
  1056. internalerror(2021092018);
  1057. WriteSleb(longint(ref^.offset));
  1058. end;
  1059. end;
  1060. top_const:
  1061. WriteSleb(longint(val));
  1062. else
  1063. internalerror(2021092615);
  1064. end;
  1065. end;
  1066. a_i64_const:
  1067. begin
  1068. WriteByte($42);
  1069. if ops<>1 then
  1070. internalerror(2021092001);
  1071. with oper[0]^ do
  1072. case typ of
  1073. top_ref:
  1074. begin
  1075. if assigned(ref^.symbol) then
  1076. objdata.writeReloc(ref^.offset,5,ObjData.symbolref(ref^.symbol),RELOC_MEMORY_ADDR_OR_TABLE_INDEX_SLEB)
  1077. else
  1078. begin
  1079. if assigned(ref^.symbol) or (ref^.base<>NR_NO) or (ref^.index<>NR_NO) then
  1080. internalerror(2021092018);
  1081. WriteSleb(int64(ref^.offset));
  1082. end;
  1083. end;
  1084. top_const:
  1085. WriteSleb(int64(val));
  1086. else
  1087. internalerror(2021092615);
  1088. end;
  1089. end;
  1090. a_f32_const:
  1091. begin
  1092. if ops<>1 then
  1093. internalerror(2021092619);
  1094. WriteByte($43);
  1095. with oper[0]^ do
  1096. case typ of
  1097. top_single:
  1098. WriteSingle(sval);
  1099. else
  1100. internalerror(2021092618);
  1101. end;
  1102. end;
  1103. a_f64_const:
  1104. begin
  1105. if ops<>1 then
  1106. internalerror(2021092616);
  1107. WriteByte($44);
  1108. with oper[0]^ do
  1109. case typ of
  1110. top_double:
  1111. WriteDouble(dval);
  1112. else
  1113. internalerror(2021092617);
  1114. end;
  1115. end;
  1116. a_local_get,
  1117. a_local_set,
  1118. a_local_tee:
  1119. begin
  1120. case opcode of
  1121. a_local_get:
  1122. WriteByte($20);
  1123. a_local_set:
  1124. WriteByte($21);
  1125. a_local_tee:
  1126. WriteByte($22);
  1127. else
  1128. internalerror(2021092003);
  1129. end;
  1130. if ops<>1 then
  1131. internalerror(2021092004);
  1132. with oper[0]^ do
  1133. case typ of
  1134. top_ref:
  1135. begin
  1136. if assigned(ref^.symbol) then
  1137. internalerror(2021092005);
  1138. if ref^.base<>NR_STACK_POINTER_REG then
  1139. internalerror(2021092006);
  1140. if ref^.index<>NR_NO then
  1141. internalerror(2021092007);
  1142. WriteUleb(ref^.offset);
  1143. end;
  1144. else
  1145. internalerror(2021092008);
  1146. end;
  1147. end;
  1148. a_global_get,
  1149. a_global_set:
  1150. begin
  1151. case opcode of
  1152. a_global_get:
  1153. WriteByte($23);
  1154. a_global_set:
  1155. WriteByte($24);
  1156. else
  1157. internalerror(2021092009);
  1158. end;
  1159. if ops<>1 then
  1160. internalerror(2021092010);
  1161. with oper[0]^ do
  1162. case typ of
  1163. top_ref:
  1164. begin
  1165. if not assigned(ref^.symbol) then
  1166. internalerror(2021092012);
  1167. if (ref^.base<>NR_NO) or (ref^.index<>NR_NO) or (ref^.offset<>0) then
  1168. internalerror(2021092013);
  1169. objdata.writeReloc(0,5,TWasmObjData(ObjData).globalref(ref^.symbol),RELOC_GLOBAL_INDEX_LEB);
  1170. end;
  1171. else
  1172. internalerror(2021092011);
  1173. end;
  1174. end;
  1175. a_end_function:
  1176. ;
  1177. a_block,
  1178. a_loop,
  1179. a_if,
  1180. a_try:
  1181. begin
  1182. case opcode of
  1183. a_block:
  1184. WriteByte($02);
  1185. a_loop:
  1186. WriteByte($03);
  1187. a_if:
  1188. WriteByte($04);
  1189. a_try:
  1190. WriteByte($06);
  1191. else
  1192. internalerror(2021092626);
  1193. end;
  1194. if ops=0 then
  1195. WriteByte($40)
  1196. else
  1197. begin
  1198. if ops<>1 then
  1199. internalerror(2021092015);
  1200. with oper[0]^ do
  1201. case typ of
  1202. top_functype:
  1203. begin
  1204. if (length(functype.params)=0) and (length(functype.results)<=1) then
  1205. begin
  1206. if length(functype.results)=1 then
  1207. WriteByte(encode_wasm_basic_type(functype.results[0]))
  1208. else
  1209. WriteByte($40);
  1210. end
  1211. else
  1212. { more complex blocktypes are not yet implemented }
  1213. internalerror(2021092621);
  1214. end;
  1215. else
  1216. internalerror(2021092620);
  1217. end;
  1218. end;
  1219. end;
  1220. a_else:
  1221. WriteByte($05);
  1222. a_i32_load,
  1223. a_i64_load,
  1224. a_f32_load,
  1225. a_f64_load,
  1226. a_i32_load8_s,
  1227. a_i32_load8_u,
  1228. a_i32_load16_s,
  1229. a_i32_load16_u,
  1230. a_i64_load8_s,
  1231. a_i64_load8_u,
  1232. a_i64_load16_s,
  1233. a_i64_load16_u,
  1234. a_i64_load32_s,
  1235. a_i64_load32_u,
  1236. a_i32_store,
  1237. a_i64_store,
  1238. a_f32_store,
  1239. a_f64_store,
  1240. a_i32_store8,
  1241. a_i32_store16,
  1242. a_i64_store8,
  1243. a_i64_store16,
  1244. a_i64_store32:
  1245. begin
  1246. case opcode of
  1247. a_i32_load:
  1248. WriteByte($28);
  1249. a_i64_load:
  1250. WriteByte($29);
  1251. a_f32_load:
  1252. WriteByte($2A);
  1253. a_f64_load:
  1254. WriteByte($2B);
  1255. a_i32_load8_s:
  1256. WriteByte($2C);
  1257. a_i32_load8_u:
  1258. WriteByte($2D);
  1259. a_i32_load16_s:
  1260. WriteByte($2E);
  1261. a_i32_load16_u:
  1262. WriteByte($2F);
  1263. a_i64_load8_s:
  1264. WriteByte($30);
  1265. a_i64_load8_u:
  1266. WriteByte($31);
  1267. a_i64_load16_s:
  1268. WriteByte($32);
  1269. a_i64_load16_u:
  1270. WriteByte($33);
  1271. a_i64_load32_s:
  1272. WriteByte($34);
  1273. a_i64_load32_u:
  1274. WriteByte($35);
  1275. a_i32_store:
  1276. WriteByte($36);
  1277. a_i64_store:
  1278. WriteByte($37);
  1279. a_f32_store:
  1280. WriteByte($38);
  1281. a_f64_store:
  1282. WriteByte($39);
  1283. a_i32_store8:
  1284. WriteByte($3A);
  1285. a_i32_store16:
  1286. WriteByte($3B);
  1287. a_i64_store8:
  1288. WriteByte($3C);
  1289. a_i64_store16:
  1290. WriteByte($3D);
  1291. a_i64_store32:
  1292. WriteByte($3E);
  1293. else
  1294. internalerror(2021092019);
  1295. end;
  1296. if ops<>1 then
  1297. internalerror(2021092016);
  1298. with oper[0]^ do
  1299. case typ of
  1300. top_ref:
  1301. begin
  1302. if assigned(ref^.symbol) then
  1303. begin
  1304. WriteUleb(natural_alignment_for_load_store(opcode));
  1305. objdata.writeReloc(ref^.offset,5,ObjData.symbolref(ref^.symbol),RELOC_MEMORY_ADDR_LEB);
  1306. end
  1307. else
  1308. begin
  1309. if assigned(ref^.symbol) or (ref^.base<>NR_NO) or (ref^.index<>NR_NO) then
  1310. internalerror(2021092018);
  1311. WriteUleb(natural_alignment_for_load_store(opcode));
  1312. WriteUleb(ref^.offset);
  1313. end;
  1314. end;
  1315. top_const:
  1316. begin
  1317. WriteUleb(natural_alignment_for_load_store(opcode));
  1318. WriteUleb(val);
  1319. end;
  1320. else
  1321. internalerror(2021092017);
  1322. end;
  1323. end;
  1324. a_call:
  1325. begin
  1326. if ops<>1 then
  1327. internalerror(2021092021);
  1328. with oper[0]^ do
  1329. case typ of
  1330. top_ref:
  1331. begin
  1332. if not assigned(ref^.symbol) or (ref^.base<>NR_NO) or (ref^.index<>NR_NO) or (ref^.offset<>0) then
  1333. internalerror(2021092023);
  1334. WriteByte($10);
  1335. objdata.writeReloc(0,5,ObjData.symbolref(ref^.symbol),RELOC_FUNCTION_INDEX_LEB);
  1336. end;
  1337. else
  1338. internalerror(2021092022);
  1339. end;
  1340. end;
  1341. a_call_indirect:
  1342. begin
  1343. if ops<>1 then
  1344. internalerror(2021092610);
  1345. with oper[0]^ do
  1346. case typ of
  1347. top_functype:
  1348. begin
  1349. WriteByte($11);
  1350. objdata.writeReloc(TWasmObjData(objdata).AddFuncType(functype),5,nil,RELOC_TYPE_INDEX_LEB);
  1351. WriteUleb(0);
  1352. end;
  1353. else
  1354. internalerror(2021092611);
  1355. end;
  1356. end;
  1357. a_br,
  1358. a_br_if,
  1359. a_rethrow,
  1360. a_delegate:
  1361. begin
  1362. case opcode of
  1363. a_br:
  1364. WriteByte($0C);
  1365. a_br_if:
  1366. WriteByte($0D);
  1367. a_rethrow:
  1368. WriteByte($09);
  1369. a_delegate:
  1370. WriteByte($18);
  1371. else
  1372. internalerror(2021092622);
  1373. end;
  1374. if ops<>1 then
  1375. internalerror(2021092610);
  1376. with oper[0]^ do
  1377. case typ of
  1378. top_const:
  1379. WriteUleb(val);
  1380. else
  1381. internalerror(2021092625);
  1382. end;
  1383. end;
  1384. a_catch,
  1385. a_throw:
  1386. begin
  1387. case opcode of
  1388. a_catch:
  1389. WriteByte($07);
  1390. a_throw:
  1391. WriteByte($08);
  1392. else
  1393. internalerror(2021092708);
  1394. end;
  1395. if ops<>1 then
  1396. internalerror(2021092709);
  1397. with oper[0]^ do
  1398. case typ of
  1399. top_ref:
  1400. begin
  1401. if not assigned(ref^.symbol) or (ref^.base<>NR_NO) or (ref^.index<>NR_NO) or (ref^.offset<>0) then
  1402. internalerror(2021092711);
  1403. objdata.writeReloc(0,5,TWasmObjData(ObjData).ExceptionTagRef(ref^.symbol),RELOC_TAG_INDEX_LEB);
  1404. end;
  1405. else
  1406. internalerror(2021092710);
  1407. end;
  1408. end;
  1409. else
  1410. internalerror(2021092624);
  1411. end;
  1412. end;
  1413. function spilling_create_load(const ref:treference;r:tregister):Taicpu;
  1414. begin
  1415. internalerror(2010122614);
  1416. result:=nil;
  1417. end;
  1418. function spilling_create_store(r:tregister; const ref:treference):Taicpu;
  1419. begin
  1420. internalerror(2010122615);
  1421. result:=nil;
  1422. end;
  1423. procedure InitAsm;
  1424. begin
  1425. end;
  1426. procedure DoneAsm;
  1427. begin
  1428. end;
  1429. initialization
  1430. cai_cpu:=taicpu;
  1431. cai_align:=tai_align;
  1432. casmdata:=TAsmData;
  1433. end.