diff options
| -rw-r--r-- | src/buildvm_arm.dasc | 866 |
1 files changed, 866 insertions, 0 deletions
diff --git a/src/buildvm_arm.dasc b/src/buildvm_arm.dasc new file mode 100644 index 00000000..c52cfc6c --- /dev/null +++ b/src/buildvm_arm.dasc | |||
| @@ -0,0 +1,866 @@ | |||
| 1 | |// Low-level VM code for ARM CPUs. | ||
| 2 | |// Bytecode interpreter, fast functions and helper functions. | ||
| 3 | |// Copyright (C) 2005-2011 Mike Pall. See Copyright Notice in luajit.h | ||
| 4 | | | ||
| 5 | |.arch arm | ||
| 6 | |.section code_op, code_sub | ||
| 7 | | | ||
| 8 | |.actionlist build_actionlist | ||
| 9 | |.globals GLOB_ | ||
| 10 | |.globalnames globnames | ||
| 11 | |.externnames extnames | ||
| 12 | | | ||
| 13 | |// Note: The ragged indentation of the instructions is intentional. | ||
| 14 | |// The starting columns indicate data dependencies. | ||
| 15 | | | ||
| 16 | |//----------------------------------------------------------------------- | ||
| 17 | | | ||
| 18 | |// Trap for not-yet-implemented parts. | ||
| 19 | |.macro NYI; ud; .endmacro | ||
| 20 | | | ||
| 21 | |//----------------------------------------------------------------------- | ||
| 22 | | | ||
| 23 | |// Assumes DISPATCH is relative to GL. | ||
| 24 | #define DISPATCH_GL(field) (GG_DISP2G + (int)offsetof(global_State, field)) | ||
| 25 | #define DISPATCH_J(field) (GG_DISP2J + (int)offsetof(jit_State, field)) | ||
| 26 | | | ||
| 27 | #define PC2PROTO(field) ((int)offsetof(GCproto, field)-(int)sizeof(GCproto)) | ||
| 28 | | | ||
| 29 | |.macro hotloop | ||
| 30 | | NYI | ||
| 31 | |.endmacro | ||
| 32 | | | ||
| 33 | |.macro hotcall | ||
| 34 | | NYI | ||
| 35 | |.endmacro | ||
| 36 | | | ||
| 37 | |//----------------------------------------------------------------------- | ||
| 38 | |||
| 39 | /* Generate subroutines used by opcodes and other parts of the VM. */ | ||
| 40 | /* The .code_sub section should be last to help static branch prediction. */ | ||
| 41 | static void build_subroutines(BuildCtx *ctx) | ||
| 42 | { | ||
| 43 | |.code_sub | ||
| 44 | | | ||
| 45 | |//----------------------------------------------------------------------- | ||
| 46 | |//-- Return handling ---------------------------------------------------- | ||
| 47 | |//----------------------------------------------------------------------- | ||
| 48 | | | ||
| 49 | |->vm_returnp: | ||
| 50 | | NYI | ||
| 51 | | | ||
| 52 | |->vm_returnc: | ||
| 53 | | NYI | ||
| 54 | | | ||
| 55 | |->vm_return: | ||
| 56 | | NYI | ||
| 57 | | | ||
| 58 | |->vm_leave_cp: | ||
| 59 | | NYI | ||
| 60 | | | ||
| 61 | |->vm_leave_unw: | ||
| 62 | | NYI | ||
| 63 | | | ||
| 64 | |->vm_unwind_c: // Unwind C stack, return from vm_pcall. | ||
| 65 | | NYI | ||
| 66 | |->vm_unwind_c_eh: // Landing pad for external unwinder. | ||
| 67 | | NYI | ||
| 68 | | | ||
| 69 | |->vm_unwind_ff: // Unwind C stack, return from ff pcall. | ||
| 70 | | NYI | ||
| 71 | |->vm_unwind_ff_eh: // Landing pad for external unwinder. | ||
| 72 | | NYI | ||
| 73 | | | ||
| 74 | |//----------------------------------------------------------------------- | ||
| 75 | |//-- Grow stack for calls ----------------------------------------------- | ||
| 76 | |//----------------------------------------------------------------------- | ||
| 77 | | | ||
| 78 | |->vm_growstack_c: // Grow stack for C function. | ||
| 79 | | NYI | ||
| 80 | | | ||
| 81 | |->vm_growstack_l: // Grow stack for Lua function. | ||
| 82 | | NYI | ||
| 83 | | | ||
| 84 | |//----------------------------------------------------------------------- | ||
| 85 | |//-- Entry points into the assembler VM --------------------------------- | ||
| 86 | |//----------------------------------------------------------------------- | ||
| 87 | | | ||
| 88 | |->vm_resume: // Setup C frame and resume thread. | ||
| 89 | | NYI | ||
| 90 | | | ||
| 91 | |->vm_pcall: // Setup protected C frame and enter VM. | ||
| 92 | | NYI | ||
| 93 | | | ||
| 94 | |->vm_call: // Setup C frame and enter VM. | ||
| 95 | | NYI | ||
| 96 | | | ||
| 97 | |->vm_call_dispatch: | ||
| 98 | | NYI | ||
| 99 | | | ||
| 100 | |->vm_call_dispatch_f: | ||
| 101 | | NYI | ||
| 102 | | | ||
| 103 | |->vm_cpcall: // Setup protected C frame, call C. | ||
| 104 | | NYI | ||
| 105 | | | ||
| 106 | |//----------------------------------------------------------------------- | ||
| 107 | |//-- Metamethod handling ------------------------------------------------ | ||
| 108 | |//----------------------------------------------------------------------- | ||
| 109 | | | ||
| 110 | |//-- Continuation dispatch ---------------------------------------------- | ||
| 111 | | | ||
| 112 | |->cont_dispatch: | ||
| 113 | | NYI | ||
| 114 | | | ||
| 115 | |->cont_cat: | ||
| 116 | | NYI | ||
| 117 | | | ||
| 118 | |//-- Table indexing metamethods ----------------------------------------- | ||
| 119 | | | ||
| 120 | |->vmeta_tgets: | ||
| 121 | | NYI | ||
| 122 | | | ||
| 123 | |->vmeta_tgetb: | ||
| 124 | | NYI | ||
| 125 | | | ||
| 126 | |->vmeta_tgetv: | ||
| 127 | | NYI | ||
| 128 | | | ||
| 129 | |//----------------------------------------------------------------------- | ||
| 130 | | | ||
| 131 | |->vmeta_tsets: | ||
| 132 | | NYI | ||
| 133 | | | ||
| 134 | |->vmeta_tsetb: | ||
| 135 | | NYI | ||
| 136 | | | ||
| 137 | |->vmeta_tsetv: | ||
| 138 | | NYI | ||
| 139 | | | ||
| 140 | |//-- Comparison metamethods --------------------------------------------- | ||
| 141 | | | ||
| 142 | |->vmeta_comp: | ||
| 143 | | NYI | ||
| 144 | | | ||
| 145 | |->cont_nop: | ||
| 146 | | NYI | ||
| 147 | | | ||
| 148 | |->cont_ra: // RA = resultptr | ||
| 149 | | NYI | ||
| 150 | | | ||
| 151 | |->cont_condt: // RA = resultptr | ||
| 152 | | NYI | ||
| 153 | | | ||
| 154 | |->cont_condf: // RA = resultptr | ||
| 155 | | NYI | ||
| 156 | | | ||
| 157 | |->vmeta_equal: | ||
| 158 | | NYI | ||
| 159 | | | ||
| 160 | |//-- Arithmetic metamethods --------------------------------------------- | ||
| 161 | | | ||
| 162 | |->vmeta_arith_vn: | ||
| 163 | | NYI | ||
| 164 | | | ||
| 165 | |->vmeta_arith_nv: | ||
| 166 | | NYI | ||
| 167 | | | ||
| 168 | |->vmeta_unm: | ||
| 169 | | NYI | ||
| 170 | | | ||
| 171 | |->vmeta_arith_vv: | ||
| 172 | | NYI | ||
| 173 | | | ||
| 174 | |->vmeta_binop: | ||
| 175 | | NYI | ||
| 176 | | | ||
| 177 | |->vmeta_len: | ||
| 178 | | NYI | ||
| 179 | | | ||
| 180 | |//-- Call metamethod ---------------------------------------------------- | ||
| 181 | | | ||
| 182 | |->vmeta_call: // Resolve and call __call metamethod. | ||
| 183 | | NYI | ||
| 184 | | | ||
| 185 | |->vmeta_callt: // Resolve __call for BC_CALLT. | ||
| 186 | | NYI | ||
| 187 | | | ||
| 188 | |//-- Argument coercion for 'for' statement ------------------------------ | ||
| 189 | | | ||
| 190 | |->vmeta_for: | ||
| 191 | | NYI | ||
| 192 | | | ||
| 193 | |//----------------------------------------------------------------------- | ||
| 194 | |//-- Fast functions ----------------------------------------------------- | ||
| 195 | |//----------------------------------------------------------------------- | ||
| 196 | | | ||
| 197 | |.macro .ffunc, name | ||
| 198 | |->ff_ .. name: | ||
| 199 | |.endmacro | ||
| 200 | | | ||
| 201 | |.macro .ffunc_1, name | ||
| 202 | |->ff_ .. name: | ||
| 203 | | NYI | ||
| 204 | |.endmacro | ||
| 205 | | | ||
| 206 | |.macro .ffunc_2, name | ||
| 207 | |->ff_ .. name: | ||
| 208 | | NYI | ||
| 209 | |.endmacro | ||
| 210 | | | ||
| 211 | |.macro .ffunc_n, name | ||
| 212 | | .ffunc_1 name | ||
| 213 | | NYI | ||
| 214 | |.endmacro | ||
| 215 | | | ||
| 216 | |.macro .ffunc_nn, name | ||
| 217 | | .ffunc_2 name | ||
| 218 | | NYI | ||
| 219 | |.endmacro | ||
| 220 | | | ||
| 221 | |.macro ffgccheck | ||
| 222 | | NYI | ||
| 223 | |.endmacro | ||
| 224 | | | ||
| 225 | |//-- Base library: checks ----------------------------------------------- | ||
| 226 | | | ||
| 227 | |.ffunc assert | ||
| 228 | | NYI | ||
| 229 | | | ||
| 230 | |.ffunc type | ||
| 231 | | NYI | ||
| 232 | | | ||
| 233 | |//-- Base library: getters and setters --------------------------------- | ||
| 234 | | | ||
| 235 | |.ffunc_1 getmetatable | ||
| 236 | | NYI | ||
| 237 | | | ||
| 238 | |.ffunc_2 setmetatable | ||
| 239 | | NYI | ||
| 240 | | | ||
| 241 | |.ffunc rawget | ||
| 242 | | NYI | ||
| 243 | | | ||
| 244 | |//-- Base library: conversions ------------------------------------------ | ||
| 245 | | | ||
| 246 | |.ffunc tonumber | ||
| 247 | | NYI | ||
| 248 | | | ||
| 249 | |.ffunc_1 tostring | ||
| 250 | | NYI | ||
| 251 | | | ||
| 252 | |//-- Base library: iterators ------------------------------------------- | ||
| 253 | | | ||
| 254 | |.ffunc next | ||
| 255 | | NYI | ||
| 256 | | | ||
| 257 | |.ffunc_1 pairs | ||
| 258 | | NYI | ||
| 259 | | | ||
| 260 | |.ffunc_2 ipairs_aux | ||
| 261 | | NYI | ||
| 262 | | | ||
| 263 | |.ffunc_1 ipairs | ||
| 264 | | NYI | ||
| 265 | | | ||
| 266 | |//-- Base library: catch errors ---------------------------------------- | ||
| 267 | | | ||
| 268 | |.ffunc pcall | ||
| 269 | | NYI | ||
| 270 | | | ||
| 271 | |.ffunc_2 xpcall | ||
| 272 | | NYI | ||
| 273 | | | ||
| 274 | |//-- Coroutine library -------------------------------------------------- | ||
| 275 | | | ||
| 276 | |.macro coroutine_resume_wrap, resume | ||
| 277 | |.if resume | ||
| 278 | |.ffunc_1 coroutine_resume | ||
| 279 | |.else | ||
| 280 | |.ffunc coroutine_wrap_aux | ||
| 281 | |.endif | ||
| 282 | | NYI | ||
| 283 | |.endmacro | ||
| 284 | | | ||
| 285 | | coroutine_resume_wrap 1 // coroutine.resume | ||
| 286 | | coroutine_resume_wrap 0 // coroutine.wrap | ||
| 287 | | | ||
| 288 | |.ffunc coroutine_yield | ||
| 289 | | NYI | ||
| 290 | | | ||
| 291 | |//-- Math library ------------------------------------------------------- | ||
| 292 | | | ||
| 293 | |.ffunc_n math_abs | ||
| 294 | | NYI | ||
| 295 | | | ||
| 296 | |->fff_restv: | ||
| 297 | | NYI | ||
| 298 | | | ||
| 299 | |->fff_res1: | ||
| 300 | | NYI | ||
| 301 | | | ||
| 302 | |->fff_res: | ||
| 303 | | NYI | ||
| 304 | | | ||
| 305 | |.macro math_extern, func | ||
| 306 | | .ffunc math_ .. func | ||
| 307 | | NYI | ||
| 308 | |.endmacro | ||
| 309 | | | ||
| 310 | |.macro math_extern2, func | ||
| 311 | | .ffunc math_ .. func | ||
| 312 | | NYI | ||
| 313 | |.endmacro | ||
| 314 | | | ||
| 315 | |.macro math_round, func | ||
| 316 | | .ffunc math_ .. func | ||
| 317 | | NYI | ||
| 318 | |.endmacro | ||
| 319 | | | ||
| 320 | | math_round floor | ||
| 321 | | math_round ceil | ||
| 322 | | | ||
| 323 | | math_extern sqrt | ||
| 324 | | math_extern log | ||
| 325 | | math_extern log10 | ||
| 326 | | math_extern exp | ||
| 327 | | math_extern sin | ||
| 328 | | math_extern cos | ||
| 329 | | math_extern tan | ||
| 330 | | math_extern asin | ||
| 331 | | math_extern acos | ||
| 332 | | math_extern atan | ||
| 333 | | math_extern sinh | ||
| 334 | | math_extern cosh | ||
| 335 | | math_extern tanh | ||
| 336 | | math_extern2 pow | ||
| 337 | | math_extern2 atan2 | ||
| 338 | | math_extern2 fmod | ||
| 339 | | | ||
| 340 | |->ff_math_deg: | ||
| 341 | |.ffunc_n math_rad | ||
| 342 | | NYI | ||
| 343 | | | ||
| 344 | |.ffunc math_ldexp | ||
| 345 | | NYI | ||
| 346 | | | ||
| 347 | |.ffunc math_frexp | ||
| 348 | | NYI | ||
| 349 | | | ||
| 350 | |.ffunc math_modf | ||
| 351 | | NYI | ||
| 352 | | | ||
| 353 | |.macro math_minmax, name, cmpop | ||
| 354 | | .ffunc_1 name | ||
| 355 | | NYI | ||
| 356 | |.endmacro | ||
| 357 | | | ||
| 358 | | math_minmax math_min, NYI | ||
| 359 | | math_minmax math_max, NYI | ||
| 360 | | | ||
| 361 | |//-- String library ----------------------------------------------------- | ||
| 362 | | | ||
| 363 | |.ffunc_1 string_len | ||
| 364 | | NYI | ||
| 365 | | | ||
| 366 | |.ffunc string_byte // Only handle the 1-arg case here. | ||
| 367 | | NYI | ||
| 368 | | | ||
| 369 | |.ffunc string_char // Only handle the 1-arg case here. | ||
| 370 | | NYI | ||
| 371 | | | ||
| 372 | |.ffunc string_sub | ||
| 373 | | NYI | ||
| 374 | | | ||
| 375 | |.ffunc string_rep // Only handle the 1-char case inline. | ||
| 376 | | NYI | ||
| 377 | | | ||
| 378 | |.ffunc string_reverse | ||
| 379 | | NYI | ||
| 380 | | | ||
| 381 | |.macro ffstring_case, name, lo | ||
| 382 | | .ffunc name | ||
| 383 | | NYI | ||
| 384 | |.endmacro | ||
| 385 | | | ||
| 386 | |ffstring_case string_lower, 65 | ||
| 387 | |ffstring_case string_upper, 97 | ||
| 388 | | | ||
| 389 | |//-- Table library ------------------------------------------------------ | ||
| 390 | | | ||
| 391 | |.ffunc_1 table_getn | ||
| 392 | | NYI | ||
| 393 | | | ||
| 394 | |//-- Bit library -------------------------------------------------------- | ||
| 395 | | | ||
| 396 | |.macro .ffunc_bit, name | ||
| 397 | | .ffunc_n bit_..name | ||
| 398 | | NYI | ||
| 399 | |.endmacro | ||
| 400 | | | ||
| 401 | |.ffunc_bit tobit | ||
| 402 | | NYI | ||
| 403 | |->fff_resbit: | ||
| 404 | | NYI | ||
| 405 | | | ||
| 406 | |.macro .ffunc_bit_op, name, ins | ||
| 407 | | .ffunc_bit name | ||
| 408 | | NYI | ||
| 409 | |.endmacro | ||
| 410 | | | ||
| 411 | |.ffunc_bit_op band, and | ||
| 412 | |.ffunc_bit_op bor, or | ||
| 413 | |.ffunc_bit_op bxor, xor | ||
| 414 | | | ||
| 415 | |.ffunc_bit bswap | ||
| 416 | | NYI | ||
| 417 | | | ||
| 418 | |.ffunc_bit bnot | ||
| 419 | | NYI | ||
| 420 | | | ||
| 421 | |.macro .ffunc_bit_sh, name, ins, shmod | ||
| 422 | | .ffunc_nn bit_..name | ||
| 423 | | NYI | ||
| 424 | |.endmacro | ||
| 425 | | | ||
| 426 | |.ffunc_bit_sh lshift, NYI, 1 | ||
| 427 | |.ffunc_bit_sh rshift, NYI, 1 | ||
| 428 | |.ffunc_bit_sh arshift, NYI, 1 | ||
| 429 | |.ffunc_bit_sh rol, NYI, 2 | ||
| 430 | |.ffunc_bit_sh ror, NYI, 0 | ||
| 431 | | | ||
| 432 | |//----------------------------------------------------------------------- | ||
| 433 | | | ||
| 434 | |->fff_fallback: // Call fast function fallback handler. | ||
| 435 | | NYI | ||
| 436 | | | ||
| 437 | |->fff_gcstep: // Call GC step function. | ||
| 438 | | NYI | ||
| 439 | | | ||
| 440 | |//----------------------------------------------------------------------- | ||
| 441 | |//-- Special dispatch targets ------------------------------------------- | ||
| 442 | |//----------------------------------------------------------------------- | ||
| 443 | | | ||
| 444 | |->vm_record: // Dispatch target for recording phase. | ||
| 445 | #if LJ_HASJIT | ||
| 446 | | NYI | ||
| 447 | #endif | ||
| 448 | | | ||
| 449 | |->vm_rethook: // Dispatch target for return hooks. | ||
| 450 | | NYI | ||
| 451 | | | ||
| 452 | |->vm_inshook: // Dispatch target for instr/line hooks. | ||
| 453 | | NYI | ||
| 454 | | | ||
| 455 | |->cont_hook: // Continue from hook yield. | ||
| 456 | | NYI | ||
| 457 | | | ||
| 458 | |->vm_hotloop: // Hot loop counter underflow. | ||
| 459 | #if LJ_HASJIT | ||
| 460 | | NYI | ||
| 461 | #endif | ||
| 462 | | | ||
| 463 | |->vm_callhook: // Dispatch target for call hooks. | ||
| 464 | | NYI | ||
| 465 | | | ||
| 466 | |->vm_hotcall: // Hot call counter underflow. | ||
| 467 | | NYI | ||
| 468 | | | ||
| 469 | |//----------------------------------------------------------------------- | ||
| 470 | |//-- Trace exit handler ------------------------------------------------- | ||
| 471 | |//----------------------------------------------------------------------- | ||
| 472 | | | ||
| 473 | |->vm_exit_handler: | ||
| 474 | #if LJ_HASJIT | ||
| 475 | | NYI | ||
| 476 | #endif | ||
| 477 | |->vm_exit_interp: | ||
| 478 | #if LJ_HASJIT | ||
| 479 | | NYI | ||
| 480 | #endif | ||
| 481 | | | ||
| 482 | |//----------------------------------------------------------------------- | ||
| 483 | |//-- Math helper functions ---------------------------------------------- | ||
| 484 | |//----------------------------------------------------------------------- | ||
| 485 | | | ||
| 486 | |// FP value rounding. Called by math.floor/math.ceil fast functions | ||
| 487 | |// and from JIT code. | ||
| 488 | |// | ||
| 489 | |.macro vm_round, name, mode | ||
| 490 | |->name: | ||
| 491 | | NYI | ||
| 492 | |.endmacro | ||
| 493 | | | ||
| 494 | | vm_round vm_floor, 0 | ||
| 495 | | vm_round vm_ceil, 1 | ||
| 496 | #if LJ_HASJIT | ||
| 497 | | vm_round vm_trunc, 2 | ||
| 498 | #else | ||
| 499 | |->vm_trunc: | ||
| 500 | #endif | ||
| 501 | | | ||
| 502 | |->vm_powi: | ||
| 503 | #if LJ_HASJIT | ||
| 504 | | NYI | ||
| 505 | #endif | ||
| 506 | | | ||
| 507 | |->vm_foldfpm: | ||
| 508 | #if LJ_HASJIT | ||
| 509 | | NYI | ||
| 510 | #endif | ||
| 511 | | | ||
| 512 | |// Callable from C: double lj_vm_foldarith(double x, double y, int op) | ||
| 513 | |// Compute x op y for basic arithmetic operators (+ - * / % ^ and unary -) | ||
| 514 | |// and basic math functions. ORDER ARITH | ||
| 515 | |->vm_foldarith: | ||
| 516 | | NYI | ||
| 517 | | | ||
| 518 | |//----------------------------------------------------------------------- | ||
| 519 | |//-- Miscellaneous functions -------------------------------------------- | ||
| 520 | |//----------------------------------------------------------------------- | ||
| 521 | | | ||
| 522 | |//----------------------------------------------------------------------- | ||
| 523 | |//-- FFI helper functions ----------------------------------------------- | ||
| 524 | |//----------------------------------------------------------------------- | ||
| 525 | | | ||
| 526 | |->vm_ffi_call: | ||
| 527 | #if LJ_HASFFI | ||
| 528 | | NYI | ||
| 529 | #endif | ||
| 530 | | | ||
| 531 | |//----------------------------------------------------------------------- | ||
| 532 | } | ||
| 533 | |||
| 534 | /* Generate the code for a single instruction. */ | ||
| 535 | static void build_ins(BuildCtx *ctx, BCOp op, int defop) | ||
| 536 | { | ||
| 537 | int vk = 0; | ||
| 538 | |=>defop: | ||
| 539 | |||
| 540 | switch (op) { | ||
| 541 | |||
| 542 | /* -- Comparison ops ---------------------------------------------------- */ | ||
| 543 | |||
| 544 | /* Remember: all ops branch for a true comparison, fall through otherwise. */ | ||
| 545 | |||
| 546 | case BC_ISLT: case BC_ISGE: case BC_ISLE: case BC_ISGT: | ||
| 547 | | NYI | ||
| 548 | break; | ||
| 549 | |||
| 550 | case BC_ISEQV: case BC_ISNEV: | ||
| 551 | vk = op == BC_ISEQV; | ||
| 552 | | NYI | ||
| 553 | break; | ||
| 554 | |||
| 555 | case BC_ISEQS: case BC_ISNES: | ||
| 556 | vk = op == BC_ISEQS; | ||
| 557 | | NYI | ||
| 558 | break; | ||
| 559 | |||
| 560 | case BC_ISEQN: case BC_ISNEN: | ||
| 561 | vk = op == BC_ISEQN; | ||
| 562 | | NYI | ||
| 563 | break; | ||
| 564 | |||
| 565 | case BC_ISEQP: case BC_ISNEP: | ||
| 566 | vk = op == BC_ISEQP; | ||
| 567 | | NYI | ||
| 568 | break; | ||
| 569 | |||
| 570 | /* -- Unary test and copy ops ------------------------------------------- */ | ||
| 571 | |||
| 572 | case BC_ISTC: case BC_ISFC: case BC_IST: case BC_ISF: | ||
| 573 | | NYI | ||
| 574 | break; | ||
| 575 | |||
| 576 | /* -- Unary ops --------------------------------------------------------- */ | ||
| 577 | |||
| 578 | case BC_MOV: | ||
| 579 | | NYI | ||
| 580 | break; | ||
| 581 | case BC_NOT: | ||
| 582 | | NYI | ||
| 583 | break; | ||
| 584 | case BC_UNM: | ||
| 585 | | NYI | ||
| 586 | break; | ||
| 587 | case BC_LEN: | ||
| 588 | | NYI | ||
| 589 | break; | ||
| 590 | |||
| 591 | /* -- Binary ops -------------------------------------------------------- */ | ||
| 592 | |||
| 593 | case BC_ADDVN: case BC_ADDNV: case BC_ADDVV: | ||
| 594 | | NYI | ||
| 595 | break; | ||
| 596 | case BC_SUBVN: case BC_SUBNV: case BC_SUBVV: | ||
| 597 | | NYI | ||
| 598 | break; | ||
| 599 | case BC_MULVN: case BC_MULNV: case BC_MULVV: | ||
| 600 | | NYI | ||
| 601 | break; | ||
| 602 | case BC_DIVVN: case BC_DIVNV: case BC_DIVVV: | ||
| 603 | | NYI | ||
| 604 | break; | ||
| 605 | case BC_MODVN: | ||
| 606 | | NYI | ||
| 607 | break; | ||
| 608 | case BC_MODNV: case BC_MODVV: | ||
| 609 | | NYI | ||
| 610 | break; | ||
| 611 | case BC_POW: | ||
| 612 | | NYI | ||
| 613 | break; | ||
| 614 | |||
| 615 | case BC_CAT: | ||
| 616 | | NYI | ||
| 617 | break; | ||
| 618 | |||
| 619 | /* -- Constant ops ------------------------------------------------------ */ | ||
| 620 | |||
| 621 | case BC_KSTR: | ||
| 622 | | NYI | ||
| 623 | break; | ||
| 624 | case BC_KCDATA: | ||
| 625 | #if LJ_HASFFI | ||
| 626 | | NYI | ||
| 627 | #endif | ||
| 628 | break; | ||
| 629 | case BC_KSHORT: | ||
| 630 | | NYI | ||
| 631 | break; | ||
| 632 | case BC_KNUM: | ||
| 633 | | NYI | ||
| 634 | break; | ||
| 635 | case BC_KPRI: | ||
| 636 | | NYI | ||
| 637 | break; | ||
| 638 | case BC_KNIL: | ||
| 639 | | NYI | ||
| 640 | break; | ||
| 641 | |||
| 642 | /* -- Upvalue and function ops ------------------------------------------ */ | ||
| 643 | |||
| 644 | case BC_UGET: | ||
| 645 | | NYI | ||
| 646 | break; | ||
| 647 | case BC_USETV: | ||
| 648 | | NYI | ||
| 649 | break; | ||
| 650 | case BC_USETS: | ||
| 651 | | NYI | ||
| 652 | break; | ||
| 653 | case BC_USETN: | ||
| 654 | | NYI | ||
| 655 | break; | ||
| 656 | case BC_USETP: | ||
| 657 | | NYI | ||
| 658 | break; | ||
| 659 | |||
| 660 | case BC_UCLO: | ||
| 661 | | NYI | ||
| 662 | break; | ||
| 663 | |||
| 664 | case BC_FNEW: | ||
| 665 | | NYI | ||
| 666 | break; | ||
| 667 | |||
| 668 | /* -- Table ops --------------------------------------------------------- */ | ||
| 669 | |||
| 670 | case BC_TNEW: | ||
| 671 | case BC_TDUP: | ||
| 672 | | NYI | ||
| 673 | break; | ||
| 674 | |||
| 675 | case BC_GGET: | ||
| 676 | case BC_GSET: | ||
| 677 | | NYI | ||
| 678 | break; | ||
| 679 | |||
| 680 | case BC_TGETV: | ||
| 681 | | NYI | ||
| 682 | break; | ||
| 683 | case BC_TGETS: | ||
| 684 | | NYI | ||
| 685 | break; | ||
| 686 | case BC_TGETB: | ||
| 687 | | NYI | ||
| 688 | break; | ||
| 689 | |||
| 690 | case BC_TSETV: | ||
| 691 | | NYI | ||
| 692 | break; | ||
| 693 | case BC_TSETS: | ||
| 694 | | NYI | ||
| 695 | break; | ||
| 696 | case BC_TSETB: | ||
| 697 | | NYI | ||
| 698 | break; | ||
| 699 | |||
| 700 | case BC_TSETM: | ||
| 701 | | NYI | ||
| 702 | break; | ||
| 703 | |||
| 704 | /* -- Calls and vararg handling ----------------------------------------- */ | ||
| 705 | |||
| 706 | case BC_CALLM: | ||
| 707 | | NYI | ||
| 708 | break; | ||
| 709 | case BC_CALL: | ||
| 710 | | NYI | ||
| 711 | break; | ||
| 712 | |||
| 713 | case BC_CALLMT: | ||
| 714 | | NYI | ||
| 715 | break; | ||
| 716 | case BC_CALLT: | ||
| 717 | | NYI | ||
| 718 | break; | ||
| 719 | |||
| 720 | case BC_ITERC: | ||
| 721 | | NYI | ||
| 722 | break; | ||
| 723 | |||
| 724 | case BC_ITERN: | ||
| 725 | | NYI | ||
| 726 | break; | ||
| 727 | |||
| 728 | case BC_ISNEXT: | ||
| 729 | | NYI | ||
| 730 | break; | ||
| 731 | |||
| 732 | case BC_VARG: | ||
| 733 | | NYI | ||
| 734 | break; | ||
| 735 | |||
| 736 | /* -- Returns ----------------------------------------------------------- */ | ||
| 737 | |||
| 738 | case BC_RETM: | ||
| 739 | | NYI | ||
| 740 | break; | ||
| 741 | |||
| 742 | case BC_RET: | ||
| 743 | | NYI | ||
| 744 | break; | ||
| 745 | |||
| 746 | case BC_RET0: case BC_RET1: | ||
| 747 | | NYI | ||
| 748 | break; | ||
| 749 | |||
| 750 | /* -- Loops and branches ------------------------------------------------ */ | ||
| 751 | |||
| 752 | case BC_FORL: | ||
| 753 | #if LJ_HASJIT | ||
| 754 | | hotloop | ||
| 755 | #endif | ||
| 756 | | // Fall through. Assumes BC_IFORL follows. | ||
| 757 | break; | ||
| 758 | |||
| 759 | case BC_JFORI: | ||
| 760 | case BC_JFORL: | ||
| 761 | #if !LJ_HASJIT | ||
| 762 | break; | ||
| 763 | #endif | ||
| 764 | case BC_FORI: | ||
| 765 | case BC_IFORL: | ||
| 766 | vk = (op == BC_IFORL || op == BC_JFORL); | ||
| 767 | | NYI | ||
| 768 | break; | ||
| 769 | |||
| 770 | case BC_ITERL: | ||
| 771 | #if LJ_HASJIT | ||
| 772 | | hotloop | ||
| 773 | #endif | ||
| 774 | | // Fall through. Assumes BC_IITERL follows. | ||
| 775 | break; | ||
| 776 | |||
| 777 | case BC_JITERL: | ||
| 778 | #if !LJ_HASJIT | ||
| 779 | break; | ||
| 780 | #endif | ||
| 781 | case BC_IITERL: | ||
| 782 | | NYI | ||
| 783 | break; | ||
| 784 | |||
| 785 | case BC_LOOP: | ||
| 786 | | NYI | ||
| 787 | break; | ||
| 788 | |||
| 789 | case BC_ILOOP: | ||
| 790 | | NYI | ||
| 791 | break; | ||
| 792 | |||
| 793 | case BC_JLOOP: | ||
| 794 | #if LJ_HASJIT | ||
| 795 | | NYI | ||
| 796 | #endif | ||
| 797 | break; | ||
| 798 | |||
| 799 | case BC_JMP: | ||
| 800 | | NYI | ||
| 801 | break; | ||
| 802 | |||
| 803 | /* -- Function headers -------------------------------------------------- */ | ||
| 804 | |||
| 805 | case BC_FUNCF: | ||
| 806 | #if LJ_HASJIT | ||
| 807 | | hotcall | ||
| 808 | #endif | ||
| 809 | case BC_FUNCV: /* NYI: compiled vararg functions. */ | ||
| 810 | | // Fall through. Assumes BC_IFUNCF/BC_IFUNCV follow. | ||
| 811 | break; | ||
| 812 | |||
| 813 | case BC_JFUNCF: | ||
| 814 | #if !LJ_HASJIT | ||
| 815 | break; | ||
| 816 | #endif | ||
| 817 | case BC_IFUNCF: | ||
| 818 | | NYI | ||
| 819 | break; | ||
| 820 | |||
| 821 | case BC_JFUNCV: | ||
| 822 | #if !LJ_HASJIT | ||
| 823 | break; | ||
| 824 | #endif | ||
| 825 | | NYI // NYI: compiled vararg functions | ||
| 826 | break; /* NYI: compiled vararg functions. */ | ||
| 827 | |||
| 828 | case BC_IFUNCV: | ||
| 829 | | NYI | ||
| 830 | break; | ||
| 831 | |||
| 832 | case BC_FUNCC: | ||
| 833 | case BC_FUNCCW: | ||
| 834 | | NYI | ||
| 835 | break; | ||
| 836 | |||
| 837 | /* ---------------------------------------------------------------------- */ | ||
| 838 | |||
| 839 | default: | ||
| 840 | fprintf(stderr, "Error: undefined opcode BC_%s\n", bc_names[op]); | ||
| 841 | exit(2); | ||
| 842 | break; | ||
| 843 | } | ||
| 844 | } | ||
| 845 | |||
| 846 | static int build_backend(BuildCtx *ctx) | ||
| 847 | { | ||
| 848 | int op; | ||
| 849 | |||
| 850 | dasm_growpc(Dst, BC__MAX); | ||
| 851 | |||
| 852 | build_subroutines(ctx); | ||
| 853 | |||
| 854 | |.code_op | ||
| 855 | for (op = 0; op < BC__MAX; op++) | ||
| 856 | build_ins(ctx, (BCOp)op, op); | ||
| 857 | |||
| 858 | return BC__MAX; | ||
| 859 | } | ||
| 860 | |||
| 861 | /* Emit pseudo frame-info for all assembler functions. */ | ||
| 862 | static void emit_asm_debug(BuildCtx *ctx) | ||
| 863 | { | ||
| 864 | UNUSED(ctx); /* NYI */ | ||
| 865 | } | ||
| 866 | |||
