a.out.go (12613B)
1 // Based on cmd/internal/obj/ppc64/a.out.go. 2 // 3 // Copyright © 1994-1999 Lucent Technologies Inc. All rights reserved. 4 // Portions Copyright © 1995-1997 C H Forsyth (forsyth@terzarima.net) 5 // Portions Copyright © 1997-1999 Vita Nuova Limited 6 // Portions Copyright © 2000-2008 Vita Nuova Holdings Limited (www.vitanuova.com) 7 // Portions Copyright © 2004,2006 Bruce Ellis 8 // Portions Copyright © 2005-2007 C H Forsyth (forsyth@terzarima.net) 9 // Revisions Copyright © 2000-2008 Lucent Technologies Inc. and others 10 // Portions Copyright © 2009 The Go Authors. All rights reserved. 11 // 12 // Permission is hereby granted, free of charge, to any person obtaining a copy 13 // of this software and associated documentation files (the "Software"), to deal 14 // in the Software without restriction, including without limitation the rights 15 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 // copies of the Software, and to permit persons to whom the Software is 17 // furnished to do so, subject to the following conditions: 18 // 19 // The above copyright notice and this permission notice shall be included in 20 // all copies or substantial portions of the Software. 21 // 22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 28 // THE SOFTWARE. 29 30 package s390x 31 32 import "github.com/twitchyliquid64/golang-asm/obj" 33 34 //go:generate go run ../stringer.go -i $GOFILE -o anames.go -p s390x 35 36 const ( 37 NSNAME = 8 38 NSYM = 50 39 NREG = 16 // number of general purpose registers 40 NFREG = 16 // number of floating point registers 41 ) 42 43 const ( 44 // General purpose registers (GPRs). 45 REG_R0 = obj.RBaseS390X + iota 46 REG_R1 47 REG_R2 48 REG_R3 49 REG_R4 50 REG_R5 51 REG_R6 52 REG_R7 53 REG_R8 54 REG_R9 55 REG_R10 56 REG_R11 57 REG_R12 58 REG_R13 59 REG_R14 60 REG_R15 61 62 // Floating point registers (FPRs). 63 REG_F0 64 REG_F1 65 REG_F2 66 REG_F3 67 REG_F4 68 REG_F5 69 REG_F6 70 REG_F7 71 REG_F8 72 REG_F9 73 REG_F10 74 REG_F11 75 REG_F12 76 REG_F13 77 REG_F14 78 REG_F15 79 80 // Vector registers (VRs) - only available when the vector 81 // facility is installed. 82 // V0-V15 are aliases for F0-F15. 83 // We keep them in a separate space to make printing etc. easier 84 // If the code generator ever emits vector instructions it will 85 // need to take into account the aliasing. 86 REG_V0 87 REG_V1 88 REG_V2 89 REG_V3 90 REG_V4 91 REG_V5 92 REG_V6 93 REG_V7 94 REG_V8 95 REG_V9 96 REG_V10 97 REG_V11 98 REG_V12 99 REG_V13 100 REG_V14 101 REG_V15 102 REG_V16 103 REG_V17 104 REG_V18 105 REG_V19 106 REG_V20 107 REG_V21 108 REG_V22 109 REG_V23 110 REG_V24 111 REG_V25 112 REG_V26 113 REG_V27 114 REG_V28 115 REG_V29 116 REG_V30 117 REG_V31 118 119 // Access registers (ARs). 120 // The thread pointer is typically stored in the register pair 121 // AR0 and AR1. 122 REG_AR0 123 REG_AR1 124 REG_AR2 125 REG_AR3 126 REG_AR4 127 REG_AR5 128 REG_AR6 129 REG_AR7 130 REG_AR8 131 REG_AR9 132 REG_AR10 133 REG_AR11 134 REG_AR12 135 REG_AR13 136 REG_AR14 137 REG_AR15 138 139 REG_RESERVED // end of allocated registers 140 141 REGARG = -1 // -1 disables passing the first argument in register 142 REGRT1 = REG_R3 // used during zeroing of the stack - not reserved 143 REGRT2 = REG_R4 // used during zeroing of the stack - not reserved 144 REGTMP = REG_R10 // scratch register used in the assembler and linker 145 REGTMP2 = REG_R11 // scratch register used in the assembler and linker 146 REGCTXT = REG_R12 // context for closures 147 REGG = REG_R13 // G 148 REG_LR = REG_R14 // link register 149 REGSP = REG_R15 // stack pointer 150 ) 151 152 // LINUX for zSeries ELF Application Binary Interface Supplement 153 // https://refspecs.linuxfoundation.org/ELF/zSeries/lzsabi0_zSeries/x1472.html 154 var S390XDWARFRegisters = map[int16]int16{} 155 156 func init() { 157 // f assigns dwarfregisters[from:to by step] = (base):((to-from)/step+base) 158 f := func(from, step, to, base int16) { 159 for r := int16(from); r <= to; r += step { 160 S390XDWARFRegisters[r] = (r-from)/step + base 161 } 162 } 163 f(REG_R0, 1, REG_R15, 0) 164 165 f(REG_F0, 2, REG_F6, 16) 166 f(REG_F1, 2, REG_F7, 20) 167 f(REG_F8, 2, REG_F14, 24) 168 f(REG_F9, 2, REG_F15, 28) 169 170 f(REG_V0, 2, REG_V6, 16) // V0:15 aliased to F0:15 171 f(REG_V1, 2, REG_V7, 20) // TODO what about V16:31? 172 f(REG_V8, 2, REG_V14, 24) 173 f(REG_V9, 2, REG_V15, 28) 174 175 f(REG_AR0, 1, REG_AR15, 48) 176 } 177 178 const ( 179 BIG = 32768 - 8 180 DISP12 = 4096 181 DISP16 = 65536 182 DISP20 = 1048576 183 ) 184 185 const ( 186 // mark flags 187 LEAF = 1 << iota 188 BRANCH 189 USETMP // generated code of this Prog uses REGTMP 190 ) 191 192 const ( // comments from func aclass in asmz.go 193 C_NONE = iota 194 C_REG // general-purpose register (64-bit) 195 C_FREG // floating-point register (64-bit) 196 C_VREG // vector register (128-bit) 197 C_AREG // access register (32-bit) 198 C_ZCON // constant == 0 199 C_SCON // 0 <= constant <= 0x7fff (positive int16) 200 C_UCON // constant & 0xffff == 0 (int16 or uint16) 201 C_ADDCON // 0 > constant >= -0x8000 (negative int16) 202 C_ANDCON // constant <= 0xffff 203 C_LCON // constant (int32 or uint32) 204 C_DCON // constant (int64 or uint64) 205 C_SACON // computed address, 16-bit displacement, possibly SP-relative 206 C_LACON // computed address, 32-bit displacement, possibly SP-relative 207 C_DACON // computed address, 64-bit displacment? 208 C_SBRA // short branch 209 C_LBRA // long branch 210 C_SAUTO // short auto 211 C_LAUTO // long auto 212 C_ZOREG // heap address, register-based, displacement == 0 213 C_SOREG // heap address, register-based, int16 displacement 214 C_LOREG // heap address, register-based, int32 displacement 215 C_TLS_LE // TLS - local exec model (for executables) 216 C_TLS_IE // TLS - initial exec model (for shared libraries loaded at program startup) 217 C_GOK // general address 218 C_ADDR // relocation for extern or static symbols (loads and stores) 219 C_SYMADDR // relocation for extern or static symbols (address taking) 220 C_GOTADDR // GOT slot for a symbol in -dynlink mode 221 C_TEXTSIZE // text size 222 C_ANY 223 C_NCLASS // must be the last 224 ) 225 226 const ( 227 // integer arithmetic 228 AADD = obj.ABaseS390X + obj.A_ARCHSPECIFIC + iota 229 AADDC 230 AADDE 231 AADDW 232 ADIVW 233 ADIVWU 234 ADIVD 235 ADIVDU 236 AMODW 237 AMODWU 238 AMODD 239 AMODDU 240 AMULLW 241 AMULLD 242 AMULHD 243 AMULHDU 244 AMLGR 245 ASUB 246 ASUBC 247 ASUBV 248 ASUBE 249 ASUBW 250 ANEG 251 ANEGW 252 253 // integer moves 254 AMOVWBR 255 AMOVB 256 AMOVBZ 257 AMOVH 258 AMOVHBR 259 AMOVHZ 260 AMOVW 261 AMOVWZ 262 AMOVD 263 AMOVDBR 264 265 // conditional moves 266 AMOVDEQ 267 AMOVDGE 268 AMOVDGT 269 AMOVDLE 270 AMOVDLT 271 AMOVDNE 272 ALOCR 273 ALOCGR 274 275 // find leftmost one 276 AFLOGR 277 278 // population count 279 APOPCNT 280 281 // integer bitwise 282 AAND 283 AANDW 284 AOR 285 AORW 286 AXOR 287 AXORW 288 ASLW 289 ASLD 290 ASRW 291 ASRAW 292 ASRD 293 ASRAD 294 ARLL 295 ARLLG 296 ARNSBG 297 ARXSBG 298 AROSBG 299 ARNSBGT 300 ARXSBGT 301 AROSBGT 302 ARISBG 303 ARISBGN 304 ARISBGZ 305 ARISBGNZ 306 ARISBHG 307 ARISBLG 308 ARISBHGZ 309 ARISBLGZ 310 311 // floating point 312 AFABS 313 AFADD 314 AFADDS 315 AFCMPO 316 AFCMPU 317 ACEBR 318 AFDIV 319 AFDIVS 320 AFMADD 321 AFMADDS 322 AFMOVD 323 AFMOVS 324 AFMSUB 325 AFMSUBS 326 AFMUL 327 AFMULS 328 AFNABS 329 AFNEG 330 AFNEGS 331 ALEDBR 332 ALDEBR 333 ALPDFR 334 ALNDFR 335 AFSUB 336 AFSUBS 337 AFSQRT 338 AFSQRTS 339 AFIEBR 340 AFIDBR 341 ACPSDR 342 ALTEBR 343 ALTDBR 344 ATCEB 345 ATCDB 346 347 // move from GPR to FPR and vice versa 348 ALDGR 349 ALGDR 350 351 // convert from int32/int64 to float/float64 352 ACEFBRA 353 ACDFBRA 354 ACEGBRA 355 ACDGBRA 356 357 // convert from float/float64 to int32/int64 358 ACFEBRA 359 ACFDBRA 360 ACGEBRA 361 ACGDBRA 362 363 // convert from uint32/uint64 to float/float64 364 ACELFBR 365 ACDLFBR 366 ACELGBR 367 ACDLGBR 368 369 // convert from float/float64 to uint32/uint64 370 ACLFEBR 371 ACLFDBR 372 ACLGEBR 373 ACLGDBR 374 375 // compare 376 ACMP 377 ACMPU 378 ACMPW 379 ACMPWU 380 381 // test under mask 382 ATMHH 383 ATMHL 384 ATMLH 385 ATMLL 386 387 // insert program mask 388 AIPM 389 390 // set program mask 391 ASPM 392 393 // compare and swap 394 ACS 395 ACSG 396 397 // serialize 398 ASYNC 399 400 // branch 401 ABC 402 ABCL 403 ABRC 404 ABEQ 405 ABGE 406 ABGT 407 ABLE 408 ABLT 409 ABLEU 410 ABLTU 411 ABNE 412 ABVC 413 ABVS 414 ASYSCALL 415 416 // branch on count 417 ABRCT 418 ABRCTG 419 420 // compare and branch 421 ACRJ 422 ACGRJ 423 ACLRJ 424 ACLGRJ 425 ACIJ 426 ACGIJ 427 ACLIJ 428 ACLGIJ 429 ACMPBEQ 430 ACMPBGE 431 ACMPBGT 432 ACMPBLE 433 ACMPBLT 434 ACMPBNE 435 ACMPUBEQ 436 ACMPUBGE 437 ACMPUBGT 438 ACMPUBLE 439 ACMPUBLT 440 ACMPUBNE 441 442 // storage-and-storage 443 AMVC 444 AMVCIN 445 ACLC 446 AXC 447 AOC 448 ANC 449 450 // load 451 AEXRL 452 ALARL 453 ALA 454 ALAY 455 456 // interlocked load and op 457 ALAA 458 ALAAG 459 ALAAL 460 ALAALG 461 ALAN 462 ALANG 463 ALAX 464 ALAXG 465 ALAO 466 ALAOG 467 468 // load/store multiple 469 ALMY 470 ALMG 471 ASTMY 472 ASTMG 473 474 // store clock 475 ASTCK 476 ASTCKC 477 ASTCKE 478 ASTCKF 479 480 // macros 481 ACLEAR 482 483 // vector 484 AVA 485 AVAB 486 AVAH 487 AVAF 488 AVAG 489 AVAQ 490 AVACC 491 AVACCB 492 AVACCH 493 AVACCF 494 AVACCG 495 AVACCQ 496 AVAC 497 AVACQ 498 AVACCC 499 AVACCCQ 500 AVN 501 AVNC 502 AVAVG 503 AVAVGB 504 AVAVGH 505 AVAVGF 506 AVAVGG 507 AVAVGL 508 AVAVGLB 509 AVAVGLH 510 AVAVGLF 511 AVAVGLG 512 AVCKSM 513 AVCEQ 514 AVCEQB 515 AVCEQH 516 AVCEQF 517 AVCEQG 518 AVCEQBS 519 AVCEQHS 520 AVCEQFS 521 AVCEQGS 522 AVCH 523 AVCHB 524 AVCHH 525 AVCHF 526 AVCHG 527 AVCHBS 528 AVCHHS 529 AVCHFS 530 AVCHGS 531 AVCHL 532 AVCHLB 533 AVCHLH 534 AVCHLF 535 AVCHLG 536 AVCHLBS 537 AVCHLHS 538 AVCHLFS 539 AVCHLGS 540 AVCLZ 541 AVCLZB 542 AVCLZH 543 AVCLZF 544 AVCLZG 545 AVCTZ 546 AVCTZB 547 AVCTZH 548 AVCTZF 549 AVCTZG 550 AVEC 551 AVECB 552 AVECH 553 AVECF 554 AVECG 555 AVECL 556 AVECLB 557 AVECLH 558 AVECLF 559 AVECLG 560 AVERIM 561 AVERIMB 562 AVERIMH 563 AVERIMF 564 AVERIMG 565 AVERLL 566 AVERLLB 567 AVERLLH 568 AVERLLF 569 AVERLLG 570 AVERLLV 571 AVERLLVB 572 AVERLLVH 573 AVERLLVF 574 AVERLLVG 575 AVESLV 576 AVESLVB 577 AVESLVH 578 AVESLVF 579 AVESLVG 580 AVESL 581 AVESLB 582 AVESLH 583 AVESLF 584 AVESLG 585 AVESRA 586 AVESRAB 587 AVESRAH 588 AVESRAF 589 AVESRAG 590 AVESRAV 591 AVESRAVB 592 AVESRAVH 593 AVESRAVF 594 AVESRAVG 595 AVESRL 596 AVESRLB 597 AVESRLH 598 AVESRLF 599 AVESRLG 600 AVESRLV 601 AVESRLVB 602 AVESRLVH 603 AVESRLVF 604 AVESRLVG 605 AVX 606 AVFAE 607 AVFAEB 608 AVFAEH 609 AVFAEF 610 AVFAEBS 611 AVFAEHS 612 AVFAEFS 613 AVFAEZB 614 AVFAEZH 615 AVFAEZF 616 AVFAEZBS 617 AVFAEZHS 618 AVFAEZFS 619 AVFEE 620 AVFEEB 621 AVFEEH 622 AVFEEF 623 AVFEEBS 624 AVFEEHS 625 AVFEEFS 626 AVFEEZB 627 AVFEEZH 628 AVFEEZF 629 AVFEEZBS 630 AVFEEZHS 631 AVFEEZFS 632 AVFENE 633 AVFENEB 634 AVFENEH 635 AVFENEF 636 AVFENEBS 637 AVFENEHS 638 AVFENEFS 639 AVFENEZB 640 AVFENEZH 641 AVFENEZF 642 AVFENEZBS 643 AVFENEZHS 644 AVFENEZFS 645 AVFA 646 AVFADB 647 AWFADB 648 AWFK 649 AWFKDB 650 AVFCE 651 AVFCEDB 652 AVFCEDBS 653 AWFCEDB 654 AWFCEDBS 655 AVFCH 656 AVFCHDB 657 AVFCHDBS 658 AWFCHDB 659 AWFCHDBS 660 AVFCHE 661 AVFCHEDB 662 AVFCHEDBS 663 AWFCHEDB 664 AWFCHEDBS 665 AWFC 666 AWFCDB 667 AVCDG 668 AVCDGB 669 AWCDGB 670 AVCDLG 671 AVCDLGB 672 AWCDLGB 673 AVCGD 674 AVCGDB 675 AWCGDB 676 AVCLGD 677 AVCLGDB 678 AWCLGDB 679 AVFD 680 AVFDDB 681 AWFDDB 682 AVLDE 683 AVLDEB 684 AWLDEB 685 AVLED 686 AVLEDB 687 AWLEDB 688 AVFM 689 AVFMDB 690 AWFMDB 691 AVFMA 692 AVFMADB 693 AWFMADB 694 AVFMS 695 AVFMSDB 696 AWFMSDB 697 AVFPSO 698 AVFPSODB 699 AWFPSODB 700 AVFLCDB 701 AWFLCDB 702 AVFLNDB 703 AWFLNDB 704 AVFLPDB 705 AWFLPDB 706 AVFSQ 707 AVFSQDB 708 AWFSQDB 709 AVFS 710 AVFSDB 711 AWFSDB 712 AVFTCI 713 AVFTCIDB 714 AWFTCIDB 715 AVGFM 716 AVGFMB 717 AVGFMH 718 AVGFMF 719 AVGFMG 720 AVGFMA 721 AVGFMAB 722 AVGFMAH 723 AVGFMAF 724 AVGFMAG 725 AVGEF 726 AVGEG 727 AVGBM 728 AVZERO 729 AVONE 730 AVGM 731 AVGMB 732 AVGMH 733 AVGMF 734 AVGMG 735 AVISTR 736 AVISTRB 737 AVISTRH 738 AVISTRF 739 AVISTRBS 740 AVISTRHS 741 AVISTRFS 742 AVL 743 AVLR 744 AVLREP 745 AVLREPB 746 AVLREPH 747 AVLREPF 748 AVLREPG 749 AVLC 750 AVLCB 751 AVLCH 752 AVLCF 753 AVLCG 754 AVLEH 755 AVLEF 756 AVLEG 757 AVLEB 758 AVLEIH 759 AVLEIF 760 AVLEIG 761 AVLEIB 762 AVFI 763 AVFIDB 764 AWFIDB 765 AVLGV 766 AVLGVB 767 AVLGVH 768 AVLGVF 769 AVLGVG 770 AVLLEZ 771 AVLLEZB 772 AVLLEZH 773 AVLLEZF 774 AVLLEZG 775 AVLM 776 AVLP 777 AVLPB 778 AVLPH 779 AVLPF 780 AVLPG 781 AVLBB 782 AVLVG 783 AVLVGB 784 AVLVGH 785 AVLVGF 786 AVLVGG 787 AVLVGP 788 AVLL 789 AVMX 790 AVMXB 791 AVMXH 792 AVMXF 793 AVMXG 794 AVMXL 795 AVMXLB 796 AVMXLH 797 AVMXLF 798 AVMXLG 799 AVMRH 800 AVMRHB 801 AVMRHH 802 AVMRHF 803 AVMRHG 804 AVMRL 805 AVMRLB 806 AVMRLH 807 AVMRLF 808 AVMRLG 809 AVMN 810 AVMNB 811 AVMNH 812 AVMNF 813 AVMNG 814 AVMNL 815 AVMNLB 816 AVMNLH 817 AVMNLF 818 AVMNLG 819 AVMAE 820 AVMAEB 821 AVMAEH 822 AVMAEF 823 AVMAH 824 AVMAHB 825 AVMAHH 826 AVMAHF 827 AVMALE 828 AVMALEB 829 AVMALEH 830 AVMALEF 831 AVMALH 832 AVMALHB 833 AVMALHH 834 AVMALHF 835 AVMALO 836 AVMALOB 837 AVMALOH 838 AVMALOF 839 AVMAL 840 AVMALB 841 AVMALHW 842 AVMALF 843 AVMAO 844 AVMAOB 845 AVMAOH 846 AVMAOF 847 AVME 848 AVMEB 849 AVMEH 850 AVMEF 851 AVMH 852 AVMHB 853 AVMHH 854 AVMHF 855 AVMLE 856 AVMLEB 857 AVMLEH 858 AVMLEF 859 AVMLH 860 AVMLHB 861 AVMLHH 862 AVMLHF 863 AVMLO 864 AVMLOB 865 AVMLOH 866 AVMLOF 867 AVML 868 AVMLB 869 AVMLHW 870 AVMLF 871 AVMO 872 AVMOB 873 AVMOH 874 AVMOF 875 AVNO 876 AVNOT 877 AVO 878 AVPK 879 AVPKH 880 AVPKF 881 AVPKG 882 AVPKLS 883 AVPKLSH 884 AVPKLSF 885 AVPKLSG 886 AVPKLSHS 887 AVPKLSFS 888 AVPKLSGS 889 AVPKS 890 AVPKSH 891 AVPKSF 892 AVPKSG 893 AVPKSHS 894 AVPKSFS 895 AVPKSGS 896 AVPERM 897 AVPDI 898 AVPOPCT 899 AVREP 900 AVREPB 901 AVREPH 902 AVREPF 903 AVREPG 904 AVREPI 905 AVREPIB 906 AVREPIH 907 AVREPIF 908 AVREPIG 909 AVSCEF 910 AVSCEG 911 AVSEL 912 AVSL 913 AVSLB 914 AVSLDB 915 AVSRA 916 AVSRAB 917 AVSRL 918 AVSRLB 919 AVSEG 920 AVSEGB 921 AVSEGH 922 AVSEGF 923 AVST 924 AVSTEH 925 AVSTEF 926 AVSTEG 927 AVSTEB 928 AVSTM 929 AVSTL 930 AVSTRC 931 AVSTRCB 932 AVSTRCH 933 AVSTRCF 934 AVSTRCBS 935 AVSTRCHS 936 AVSTRCFS 937 AVSTRCZB 938 AVSTRCZH 939 AVSTRCZF 940 AVSTRCZBS 941 AVSTRCZHS 942 AVSTRCZFS 943 AVS 944 AVSB 945 AVSH 946 AVSF 947 AVSG 948 AVSQ 949 AVSCBI 950 AVSCBIB 951 AVSCBIH 952 AVSCBIF 953 AVSCBIG 954 AVSCBIQ 955 AVSBCBI 956 AVSBCBIQ 957 AVSBI 958 AVSBIQ 959 AVSUMG 960 AVSUMGH 961 AVSUMGF 962 AVSUMQ 963 AVSUMQF 964 AVSUMQG 965 AVSUM 966 AVSUMB 967 AVSUMH 968 AVTM 969 AVUPH 970 AVUPHB 971 AVUPHH 972 AVUPHF 973 AVUPLH 974 AVUPLHB 975 AVUPLHH 976 AVUPLHF 977 AVUPLL 978 AVUPLLB 979 AVUPLLH 980 AVUPLLF 981 AVUPL 982 AVUPLB 983 AVUPLHW 984 AVUPLF 985 AVMSLG 986 AVMSLEG 987 AVMSLOG 988 AVMSLEOG 989 990 ANOPH // NOP 991 992 // binary 993 ABYTE 994 AWORD 995 ADWORD 996 997 // end marker 998 ALAST 999 1000 // aliases 1001 ABR = obj.AJMP 1002 ABL = obj.ACALL 1003 )