|
9 | 9 | #include <ruby.h>
|
10 | 10 | #define RB_FUNC(f) reinterpret_cast<VALUE (*)(...)>(f)
|
11 | 11 |
|
| 12 | +#define RXBYAK_GENERATOR(s, x) RXbyakGenerator* x;Data_Get_Struct(s, RXbyakGenerator, x) |
12 | 13 |
|
13 | 14 |
|
14 | 15 | /**
|
@@ -146,9 +147,51 @@ class RXbyakGenerator : public Xbyak::CodeGenerator {
|
146 | 147 | mulsd(dest, src);
|
147 | 148 | }
|
148 | 149 |
|
149 |
| - void _ret() { |
150 |
| - ret(); |
151 |
| - } |
| 150 | + void _ret(int imm = 0) { ret(imm); } |
| 151 | + void _aaa() { aaa(); } |
| 152 | + void _aad() { aad(); } |
| 153 | + void _aam() { aam(); } |
| 154 | + void _aas() { aas(); } |
| 155 | + void _daa() { daa(); } |
| 156 | + void _das() { das(); } |
| 157 | + void _popad() { popad(); } |
| 158 | + void _popfd() { popfd(); } |
| 159 | + void _pusha() { pusha(); } |
| 160 | + void _pushad() { pushad(); } |
| 161 | + void _pushfd() { pushfd(); } |
| 162 | + void _popa() { popa(); } |
| 163 | + void _cbw() { cbw(); } |
| 164 | + void _cdq() { cdq(); } |
| 165 | + void _clc() { clc(); } |
| 166 | + void _cld() { cld(); } |
| 167 | + void _cli() { cli(); } |
| 168 | + void _cmc() { cmc(); } |
| 169 | + void _cpuid() { cpuid(); } |
| 170 | + void _cwd() { cwd(); } |
| 171 | + void _cwde() { cwde(); } |
| 172 | + void _lahf() { lahf(); } |
| 173 | + void _lock() { lock(); } |
| 174 | + void _nop() { nop(); } |
| 175 | + void _sahf() { sahf(); } |
| 176 | + void _stc() { stc(); } |
| 177 | + void _std() { std(); } |
| 178 | + void _sti() { sti(); } |
| 179 | + void _emms() { emms(); } |
| 180 | + void _pause() { pause(); } |
| 181 | + void _sfence() { sfence(); } |
| 182 | + void _lfence() { lfence(); } |
| 183 | + void _mfence() { mfence(); } |
| 184 | + void _monitor() { monitor(); } |
| 185 | + void _mwait() { mwait(); } |
| 186 | + void _rdmsr() { rdmsr(); } |
| 187 | + void _rdpmc() { rdpmc(); } |
| 188 | + void _rdtsc() { rdtsc(); } |
| 189 | + void _wait() { wait(); } |
| 190 | + void _wbinvd() { wbinvd(); } |
| 191 | + void _wrmsr() { wrmsr(); } |
| 192 | + void _xlatb() { xlatb(); } |
| 193 | + void _popf() { popf(); } |
| 194 | + void _pushf() { pushf(); } |
152 | 195 | };
|
153 | 196 |
|
154 | 197 |
|
@@ -248,14 +291,233 @@ VALUE RXbyak_mulsd(VALUE self, VALUE a1, VALUE a2) {
|
248 | 291 | return Qnil;
|
249 | 292 | }
|
250 | 293 |
|
251 |
| -extern "C" |
252 |
| -VALUE RXbyak_ret(VALUE self) { |
253 |
| - RXbyakGenerator* rx; |
254 |
| - Data_Get_Struct(self, RXbyakGenerator, rx); |
| 294 | +extern "C" VALUE RXbyak_ret(VALUE self) { |
| 295 | + RXBYAK_GENERATOR(self, rx); |
255 | 296 | rx->_ret();
|
256 | 297 | return Qnil;
|
257 | 298 | }
|
258 | 299 |
|
| 300 | +extern "C" VALUE RXbyak_aaa(VALUE self) { |
| 301 | + RXBYAK_GENERATOR(self, rx); |
| 302 | + rx->_aaa(); |
| 303 | + return Qnil; |
| 304 | +} |
| 305 | +extern "C" VALUE RXbyak_aad(VALUE self) { |
| 306 | + RXBYAK_GENERATOR(self, rx); |
| 307 | + rx->_aad(); |
| 308 | + return Qnil; |
| 309 | +} |
| 310 | +extern "C" VALUE RXbyak_aam(VALUE self) { |
| 311 | + RXBYAK_GENERATOR(self, rx); |
| 312 | + rx->_aam(); |
| 313 | + return Qnil; |
| 314 | +} |
| 315 | +extern "C" VALUE RXbyak_aas(VALUE self) { |
| 316 | + RXBYAK_GENERATOR(self, rx); |
| 317 | + rx->_aas(); |
| 318 | + return Qnil; |
| 319 | +} |
| 320 | +extern "C" VALUE RXbyak_daa(VALUE self) { |
| 321 | + RXBYAK_GENERATOR(self, rx); |
| 322 | + rx->_daa(); |
| 323 | + return Qnil; |
| 324 | +} |
| 325 | +extern "C" VALUE RXbyak_das(VALUE self) { |
| 326 | + RXBYAK_GENERATOR(self, rx); |
| 327 | + rx->_das(); |
| 328 | + return Qnil; |
| 329 | +} |
| 330 | +extern "C" VALUE RXbyak_popad(VALUE self) { |
| 331 | + RXBYAK_GENERATOR(self, rx); |
| 332 | + rx->_popad(); |
| 333 | + return Qnil; |
| 334 | +} |
| 335 | +extern "C" VALUE RXbyak_popfd(VALUE self) { |
| 336 | + RXBYAK_GENERATOR(self, rx); |
| 337 | + rx->_popfd(); |
| 338 | + return Qnil; |
| 339 | +} |
| 340 | +extern "C" VALUE RXbyak_pusha(VALUE self) { |
| 341 | + RXBYAK_GENERATOR(self, rx); |
| 342 | + rx->_pusha(); |
| 343 | + return Qnil; |
| 344 | +} |
| 345 | +extern "C" VALUE RXbyak_pushad(VALUE self) { |
| 346 | + RXBYAK_GENERATOR(self, rx); |
| 347 | + rx->_pushad(); |
| 348 | + return Qnil; |
| 349 | +} |
| 350 | +extern "C" VALUE RXbyak_pushfd(VALUE self) { |
| 351 | + RXBYAK_GENERATOR(self, rx); |
| 352 | + rx->_pushfd(); |
| 353 | + return Qnil; |
| 354 | +} |
| 355 | +extern "C" VALUE RXbyak_popa(VALUE self) { |
| 356 | + RXBYAK_GENERATOR(self, rx); |
| 357 | + rx->_popa(); |
| 358 | + return Qnil; |
| 359 | +} |
| 360 | +extern "C" VALUE RXbyak_cbw(VALUE self) { |
| 361 | + RXBYAK_GENERATOR(self, rx); |
| 362 | + rx->_cbw(); |
| 363 | + return Qnil; |
| 364 | +} |
| 365 | +extern "C" VALUE RXbyak_cdq(VALUE self) { |
| 366 | + RXBYAK_GENERATOR(self, rx); |
| 367 | + rx->_cdq(); |
| 368 | + return Qnil; |
| 369 | +} |
| 370 | +extern "C" VALUE RXbyak_clc(VALUE self) { |
| 371 | + RXBYAK_GENERATOR(self, rx); |
| 372 | + rx->_clc(); |
| 373 | + return Qnil; |
| 374 | +} |
| 375 | +extern "C" VALUE RXbyak_cld(VALUE self) { |
| 376 | + RXBYAK_GENERATOR(self, rx); |
| 377 | + rx->_cld(); |
| 378 | + return Qnil; |
| 379 | +} |
| 380 | +extern "C" VALUE RXbyak_cli(VALUE self) { |
| 381 | + RXBYAK_GENERATOR(self, rx); |
| 382 | + rx->_cli(); |
| 383 | + return Qnil; |
| 384 | +} |
| 385 | +extern "C" VALUE RXbyak_cmc(VALUE self) { |
| 386 | + RXBYAK_GENERATOR(self, rx); |
| 387 | + rx->_cmc(); |
| 388 | + return Qnil; |
| 389 | +} |
| 390 | +extern "C" VALUE RXbyak_cpuid(VALUE self) { |
| 391 | + RXBYAK_GENERATOR(self, rx); |
| 392 | + rx->_cpuid(); |
| 393 | + return Qnil; |
| 394 | +} |
| 395 | +extern "C" VALUE RXbyak_cwd(VALUE self) { |
| 396 | + RXBYAK_GENERATOR(self, rx); |
| 397 | + rx->_cwd(); |
| 398 | + return Qnil; |
| 399 | +} |
| 400 | +extern "C" VALUE RXbyak_cwde(VALUE self) { |
| 401 | + RXBYAK_GENERATOR(self, rx); |
| 402 | + rx->_cwde(); |
| 403 | + return Qnil; |
| 404 | +} |
| 405 | +extern "C" VALUE RXbyak_lahf(VALUE self) { |
| 406 | + RXBYAK_GENERATOR(self, rx); |
| 407 | + rx->_lahf(); |
| 408 | + return Qnil; |
| 409 | +} |
| 410 | +extern "C" VALUE RXbyak_lock(VALUE self) { |
| 411 | + RXBYAK_GENERATOR(self, rx); |
| 412 | + rx->_lock(); |
| 413 | + return Qnil; |
| 414 | +} |
| 415 | +extern "C" VALUE RXbyak_nop(VALUE self) { |
| 416 | + RXBYAK_GENERATOR(self, rx); |
| 417 | + rx->_nop(); |
| 418 | + return Qnil; |
| 419 | +} |
| 420 | +extern "C" VALUE RXbyak_sahf(VALUE self) { |
| 421 | + RXBYAK_GENERATOR(self, rx); |
| 422 | + rx->_sahf(); |
| 423 | + return Qnil; |
| 424 | +} |
| 425 | +extern "C" VALUE RXbyak_stc(VALUE self) { |
| 426 | + RXBYAK_GENERATOR(self, rx); |
| 427 | + rx->_stc(); |
| 428 | + return Qnil; |
| 429 | +} |
| 430 | +extern "C" VALUE RXbyak_std(VALUE self) { |
| 431 | + RXBYAK_GENERATOR(self, rx); |
| 432 | + rx->_std(); |
| 433 | + return Qnil; |
| 434 | +} |
| 435 | +extern "C" VALUE RXbyak_sti(VALUE self) { |
| 436 | + RXBYAK_GENERATOR(self, rx); |
| 437 | + rx->_sti(); |
| 438 | + return Qnil; |
| 439 | +} |
| 440 | +extern "C" VALUE RXbyak_emms(VALUE self) { |
| 441 | + RXBYAK_GENERATOR(self, rx); |
| 442 | + rx->_emms(); |
| 443 | + return Qnil; |
| 444 | +} |
| 445 | +extern "C" VALUE RXbyak_pause(VALUE self) { |
| 446 | + RXBYAK_GENERATOR(self, rx); |
| 447 | + rx->_pause(); |
| 448 | + return Qnil; |
| 449 | +} |
| 450 | +extern "C" VALUE RXbyak_sfence(VALUE self) { |
| 451 | + RXBYAK_GENERATOR(self, rx); |
| 452 | + rx->_sfence(); |
| 453 | + return Qnil; |
| 454 | +} |
| 455 | +extern "C" VALUE RXbyak_lfence(VALUE self) { |
| 456 | + RXBYAK_GENERATOR(self, rx); |
| 457 | + rx->_lfence(); |
| 458 | + return Qnil; |
| 459 | +} |
| 460 | +extern "C" VALUE RXbyak_mfence(VALUE self) { |
| 461 | + RXBYAK_GENERATOR(self, rx); |
| 462 | + rx->_mfence(); |
| 463 | + return Qnil; |
| 464 | +} |
| 465 | +extern "C" VALUE RXbyak_monitor(VALUE self) { |
| 466 | + RXBYAK_GENERATOR(self, rx); |
| 467 | + rx->_monitor(); |
| 468 | + return Qnil; |
| 469 | +} |
| 470 | +extern "C" VALUE RXbyak_mwait(VALUE self) { |
| 471 | + RXBYAK_GENERATOR(self, rx); |
| 472 | + rx->_mwait(); |
| 473 | + return Qnil; |
| 474 | +} |
| 475 | +extern "C" VALUE RXbyak_rdmsr(VALUE self) { |
| 476 | + RXBYAK_GENERATOR(self, rx); |
| 477 | + rx->_rdmsr(); |
| 478 | + return Qnil; |
| 479 | +} |
| 480 | +extern "C" VALUE RXbyak_rdpmc(VALUE self) { |
| 481 | + RXBYAK_GENERATOR(self, rx); |
| 482 | + rx->_rdpmc(); |
| 483 | + return Qnil; |
| 484 | +} |
| 485 | +extern "C" VALUE RXbyak_rdtsc(VALUE self) { |
| 486 | + RXBYAK_GENERATOR(self, rx); |
| 487 | + rx->_rdtsc(); |
| 488 | + return Qnil; |
| 489 | +} |
| 490 | +extern "C" VALUE RXbyak_wait(VALUE self) { |
| 491 | + RXBYAK_GENERATOR(self, rx); |
| 492 | + rx->_wait(); |
| 493 | + return Qnil; |
| 494 | +} |
| 495 | +extern "C" VALUE RXbyak_wbinvd(VALUE self) { |
| 496 | + RXBYAK_GENERATOR(self, rx); |
| 497 | + rx->_wbinvd(); |
| 498 | + return Qnil; |
| 499 | +} |
| 500 | +extern "C" VALUE RXbyak_wrmsr(VALUE self) { |
| 501 | + RXBYAK_GENERATOR(self, rx); |
| 502 | + rx->_wrmsr(); |
| 503 | + return Qnil; |
| 504 | +} |
| 505 | +extern "C" VALUE RXbyak_xlatb(VALUE self) { |
| 506 | + RXBYAK_GENERATOR(self, rx); |
| 507 | + rx->_xlatb(); |
| 508 | + return Qnil; |
| 509 | +} |
| 510 | +extern "C" VALUE RXbyak_popf(VALUE self) { |
| 511 | + RXBYAK_GENERATOR(self, rx); |
| 512 | + rx->_popf(); |
| 513 | + return Qnil; |
| 514 | +} |
| 515 | +extern "C" VALUE RXbyak_pushf(VALUE self) { |
| 516 | + RXBYAK_GENERATOR(self, rx); |
| 517 | + rx->_pushf(); |
| 518 | + return Qnil; |
| 519 | +} |
| 520 | + |
259 | 521 |
|
260 | 522 | // call the generated code
|
261 | 523 |
|
@@ -308,6 +570,51 @@ void Init_RXbyak(void) {
|
308 | 570 | rb_define_method(rb_cRXbyak, "mulsd", RB_FUNC(RXbyak_mulsd), 2);
|
309 | 571 | rb_define_method(rb_cRXbyak, "ret", RB_FUNC(RXbyak_ret), 0);
|
310 | 572 |
|
| 573 | + rb_define_method(rb_cRXbyak, "aaa", RB_FUNC(RXbyak_aaa), 0); |
| 574 | + rb_define_method(rb_cRXbyak, "aad", RB_FUNC(RXbyak_aad), 0); |
| 575 | + rb_define_method(rb_cRXbyak, "aam", RB_FUNC(RXbyak_aam), 0); |
| 576 | + rb_define_method(rb_cRXbyak, "aas", RB_FUNC(RXbyak_aas), 0); |
| 577 | + rb_define_method(rb_cRXbyak, "daa", RB_FUNC(RXbyak_daa), 0); |
| 578 | + rb_define_method(rb_cRXbyak, "das", RB_FUNC(RXbyak_das), 0); |
| 579 | + rb_define_method(rb_cRXbyak, "popad", RB_FUNC(RXbyak_popad), 0); |
| 580 | + rb_define_method(rb_cRXbyak, "popfd", RB_FUNC(RXbyak_popfd), 0); |
| 581 | + rb_define_method(rb_cRXbyak, "pusha", RB_FUNC(RXbyak_pusha), 0); |
| 582 | + rb_define_method(rb_cRXbyak, "pushad", RB_FUNC(RXbyak_pushad), 0); |
| 583 | + rb_define_method(rb_cRXbyak, "pushfd", RB_FUNC(RXbyak_pushfd), 0); |
| 584 | + rb_define_method(rb_cRXbyak, "popa", RB_FUNC(RXbyak_popa), 0); |
| 585 | + rb_define_method(rb_cRXbyak, "cbw", RB_FUNC(RXbyak_cbw), 0); |
| 586 | + rb_define_method(rb_cRXbyak, "cdq", RB_FUNC(RXbyak_cdq), 0); |
| 587 | + rb_define_method(rb_cRXbyak, "clc", RB_FUNC(RXbyak_clc), 0); |
| 588 | + rb_define_method(rb_cRXbyak, "cld", RB_FUNC(RXbyak_cld), 0); |
| 589 | + rb_define_method(rb_cRXbyak, "cli", RB_FUNC(RXbyak_cli), 0); |
| 590 | + rb_define_method(rb_cRXbyak, "cmc", RB_FUNC(RXbyak_cmc), 0); |
| 591 | + rb_define_method(rb_cRXbyak, "cpuid", RB_FUNC(RXbyak_cpuid), 0); |
| 592 | + rb_define_method(rb_cRXbyak, "cwd", RB_FUNC(RXbyak_cwd), 0); |
| 593 | + rb_define_method(rb_cRXbyak, "cwde", RB_FUNC(RXbyak_cwde), 0); |
| 594 | + rb_define_method(rb_cRXbyak, "lahf", RB_FUNC(RXbyak_lahf), 0); |
| 595 | + rb_define_method(rb_cRXbyak, "lock", RB_FUNC(RXbyak_lock), 0); |
| 596 | + rb_define_method(rb_cRXbyak, "nop", RB_FUNC(RXbyak_nop), 0); |
| 597 | + rb_define_method(rb_cRXbyak, "sahf", RB_FUNC(RXbyak_sahf), 0); |
| 598 | + rb_define_method(rb_cRXbyak, "stc", RB_FUNC(RXbyak_stc), 0); |
| 599 | + rb_define_method(rb_cRXbyak, "std", RB_FUNC(RXbyak_std), 0); |
| 600 | + rb_define_method(rb_cRXbyak, "sti", RB_FUNC(RXbyak_sti), 0); |
| 601 | + rb_define_method(rb_cRXbyak, "emms", RB_FUNC(RXbyak_emms), 0); |
| 602 | + rb_define_method(rb_cRXbyak, "pause", RB_FUNC(RXbyak_pause), 0); |
| 603 | + rb_define_method(rb_cRXbyak, "sfence", RB_FUNC(RXbyak_sfence), 0); |
| 604 | + rb_define_method(rb_cRXbyak, "lfence", RB_FUNC(RXbyak_lfence), 0); |
| 605 | + rb_define_method(rb_cRXbyak, "mfence", RB_FUNC(RXbyak_mfence), 0); |
| 606 | + rb_define_method(rb_cRXbyak, "monitor", RB_FUNC(RXbyak_monitor), 0); |
| 607 | + rb_define_method(rb_cRXbyak, "mwait", RB_FUNC(RXbyak_mwait), 0); |
| 608 | + rb_define_method(rb_cRXbyak, "rdmsr", RB_FUNC(RXbyak_rdmsr), 0); |
| 609 | + rb_define_method(rb_cRXbyak, "rdpmc", RB_FUNC(RXbyak_rdpmc), 0); |
| 610 | + rb_define_method(rb_cRXbyak, "rdtsc", RB_FUNC(RXbyak_rdtsc), 0); |
| 611 | + rb_define_method(rb_cRXbyak, "wait", RB_FUNC(RXbyak_wait), 0); |
| 612 | + rb_define_method(rb_cRXbyak, "wbinvd", RB_FUNC(RXbyak_wbinvd), 0); |
| 613 | + rb_define_method(rb_cRXbyak, "wrmsr", RB_FUNC(RXbyak_wrmsr), 0); |
| 614 | + rb_define_method(rb_cRXbyak, "xlatb", RB_FUNC(RXbyak_xlatb), 0); |
| 615 | + rb_define_method(rb_cRXbyak, "popf", RB_FUNC(RXbyak_popf), 0); |
| 616 | + rb_define_method(rb_cRXbyak, "pushf", RB_FUNC(RXbyak_pushf), 0); |
| 617 | + |
311 | 618 | rb_define_method(rb_cRXbyak, "call", RB_FUNC(RXbyak_call), -1);
|
312 | 619 | }
|
313 | 620 |
|
0 commit comments