Changeset 242240 in webkit for trunk/Source/JavaScriptCore/offlineasm/cloop.rb
- Timestamp:
- Feb 28, 2019, 4:04:51 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/offlineasm/cloop.rb
r242215 r242240 34 34 def cloopMapType(type) 35 35 case type 36 when :int ;".i()"37 when :uint ;".u()"36 when :intptr; ".i()" 37 when :uintptr; ".u()" 38 38 when :int32; ".i32()" 39 39 when :uint32; ".u32()" … … 56 56 57 57 class SpecialRegister < NoChildren 58 def clLValue(type=:int )58 def clLValue(type=:intptr) 59 59 clDump 60 60 end … … 62 62 @name 63 63 end 64 def clValue(type=:int )64 def clValue(type=:intptr) 65 65 @name + cloopMapType(type) 66 66 end … … 104 104 end 105 105 end 106 def clLValue(type=:int )106 def clLValue(type=:intptr) 107 107 clDump 108 108 end 109 def clValue(type=:int )109 def clValue(type=:intptr) 110 110 clDump + cloopMapType(type) 111 111 end … … 131 131 end 132 132 end 133 def clLValue(type=:int )133 def clLValue(type=:intptr) 134 134 clDump 135 135 end 136 def clValue(type=:int )136 def clValue(type=:intptr) 137 137 clDump + cloopMapType(type) 138 138 end … … 143 143 "#{value}" 144 144 end 145 def clLValue(type=:int )145 def clLValue(type=:intptr) 146 146 raise "Immediate cannot be used as an LValue" 147 147 end 148 def clValue(type=:int )148 def clValue(type=:intptr) 149 149 # There is a case of a very large unsigned number (0x8000000000000000) 150 150 # which we wish to encode. Unfortunately, the C/C++ compiler … … 163 163 when :int32; "int32_t(#{valueStr})" 164 164 when :int64; "int64_t(#{valueStr})" 165 when :int ;"intptr_t(#{valueStr})"165 when :intptr; "intptr_t(#{valueStr})" 166 166 when :uint8; "uint8_t(#{valueStr})" 167 167 when :uint32; "uint32_t(#{valueStr})" 168 168 when :uint64; "uint64_t(#{valueStr})" 169 when :uint ;"uintptr_t(#{valueStr})"169 when :uintptr; "uintptr_t(#{valueStr})" 170 170 else 171 171 raise "Not implemented immediate of type: #{type}" … … 178 178 "[#{base.clDump}, #{offset.value}]" 179 179 end 180 def clLValue(type=:int )180 def clLValue(type=:intptr) 181 181 clValue(type) 182 182 end 183 def clValue(type=:int )183 def clValue(type=:intptr) 184 184 case type 185 185 when :int8; int8MemRef 186 186 when :int32; int32MemRef 187 187 when :int64; int64MemRef 188 when :int ; intMemRef188 when :intptr; intptrMemRef 189 189 when :uint8; uint8MemRef 190 190 when :uint32; uint32MemRef 191 191 when :uint64; uint64MemRef 192 when :uint ; uintMemRef192 when :uintptr; uintptrMemRef 193 193 when :opcode; opcodeMemRef 194 194 when :nativeFunc; nativeFuncMemRef … … 218 218 "*CAST<int64_t*>(#{pointerExpr})" 219 219 end 220 def int MemRef220 def intptrMemRef 221 221 "*CAST<intptr_t*>(#{pointerExpr})" 222 222 end … … 233 233 "*CAST<uint64_t*>(#{pointerExpr})" 234 234 end 235 def uint MemRef235 def uintptrMemRef 236 236 "*CAST<uintptr_t*>(#{pointerExpr})" 237 237 end … … 251 251 "[#{base.clDump}, #{offset.clDump}, #{index.clDump} << #{scaleShift}]" 252 252 end 253 def clLValue(type=:int )253 def clLValue(type=:intptr) 254 254 clValue(type) 255 255 end 256 def clValue(type=:int )256 def clValue(type=:intptr) 257 257 case type 258 258 when :int8; int8MemRef 259 259 when :int32; int32MemRef 260 260 when :int64; int64MemRef 261 when :int ; intMemRef261 when :intptr; intptrMemRef 262 262 when :uint8; uint8MemRef 263 263 when :uint32; uint32MemRef 264 264 when :uint64; uint64MemRef 265 when :uint ; uintMemRef265 when :uintptr; uintptrMemRef 266 266 when :opcode; opcodeMemRef 267 267 else … … 288 288 "*CAST<int64_t*>(#{pointerExpr})" 289 289 end 290 def int MemRef290 def intptrMemRef 291 291 "*CAST<intptr_t*>(#{pointerExpr})" 292 292 end … … 303 303 "*CAST<uint64_t*>(#{pointerExpr})" 304 304 end 305 def uint MemRef305 def uintptrMemRef 306 306 "*CAST<uintptr_t*>(#{pointerExpr})" 307 307 end … … 318 318 "#{codeOriginString}" 319 319 end 320 def clLValue(type=:int )320 def clLValue(type=:intptr) 321 321 clValue(type) 322 322 end … … 327 327 328 328 class LabelReference 329 def int MemRef329 def intptrMemRef 330 330 "*CAST<intptr_t*>(&#{cLabel})" 331 331 end … … 386 386 387 387 def cloopEmitOperation(operands, type, operator) 388 raise unless type == :int || type == :uint|| type == :int32 || type == :uint32 || \388 raise unless type == :intptr || type == :uintptr || type == :int32 || type == :uint32 || \ 389 389 type == :int64 || type == :uint64 || type == :double 390 390 if operands.size == 3 … … 410 410 411 411 def cloopEmitShiftOperation(operands, type, operator) 412 raise unless type == :int || type == :uint|| type == :int32 || type == :uint32 || type == :int64 || type == :uint64412 raise unless type == :intptr || type == :uintptr || type == :int32 || type == :uint32 || type == :int64 || type == :uint64 413 413 if operands.size == 3 414 414 op1 = operands[0] … … 427 427 truncationFooter = "" 428 428 end 429 # FIXME: rename :int to :intptr to be match their expected names from C++. Ditto for :uint. 430 # https://bugs.webkit.org/show_bug.cgi?id=195183 431 shiftMask = "((sizeof(uintptr_t) == 8) ? 0x3f : 0x1f)" if type == :int || type == :uint 429 shiftMask = "((sizeof(uintptr_t) == 8) ? 0x3f : 0x1f)" if type == :intptr || type == :uintptr 432 430 shiftMask = "0x3f" if type == :int64 || type == :uint64 433 431 shiftMask = "0x1f" if type == :int32 || type == :uint32 434 $asm.putc "#{dst.clLValue(type)} = #{truncationHeader}#{operands[1].clValue(type)} #{operator} (#{operands[0].clValue(:int )} & #{shiftMask})#{truncationFooter};"432 $asm.putc "#{dst.clLValue(type)} = #{truncationHeader}#{operands[1].clValue(type)} #{operator} (#{operands[0].clValue(:intptr)} & #{shiftMask})#{truncationFooter};" 435 433 end 436 434 437 435 def cloopEmitUnaryOperation(operands, type, operator) 438 raise unless type == :int || type == :uint|| type == :int32 || type == :uint32 || type == :int64 || type == :uint64436 raise unless type == :intptr || type == :uintptr || type == :int32 || type == :uint32 || type == :int64 || type == :uint64 439 437 raise unless operands.size == 1 440 438 raise unless not operands[0].is_a? Immediate … … 507 505 def cloopEmitOpAndBranch(operands, operator, type, conditionTest) 508 506 case type 509 when :int ;tempType = "intptr_t"507 when :intptr; tempType = "intptr_t" 510 508 when :int32; tempType = "int32_t" 511 509 when :int64; tempType = "int64_t" … … 573 571 cloopEmitOperation(operands, :int64, "+") 574 572 when "addp" 575 cloopEmitOperation(operands, :int , "+")573 cloopEmitOperation(operands, :intptr, "+") 576 574 577 575 when "andi" … … 580 578 cloopEmitOperation(operands, :int64, "&") 581 579 when "andp" 582 cloopEmitOperation(operands, :int , "&")580 cloopEmitOperation(operands, :intptr, "&") 583 581 584 582 when "ori" … … 587 585 cloopEmitOperation(operands, :int64, "|") 588 586 when "orp" 589 cloopEmitOperation(operands, :int , "|")587 cloopEmitOperation(operands, :intptr, "|") 590 588 591 589 when "xori" … … 594 592 cloopEmitOperation(operands, :int64, "^") 595 593 when "xorp" 596 cloopEmitOperation(operands, :int , "^")594 cloopEmitOperation(operands, :intptr, "^") 597 595 598 596 when "lshifti" … … 601 599 cloopEmitShiftOperation(operands, :int64, "<<") 602 600 when "lshiftp" 603 cloopEmitShiftOperation(operands, :int , "<<")601 cloopEmitShiftOperation(operands, :intptr, "<<") 604 602 605 603 when "rshifti" … … 608 606 cloopEmitShiftOperation(operands, :int64, ">>") 609 607 when "rshiftp" 610 cloopEmitShiftOperation(operands, :int , ">>")608 cloopEmitShiftOperation(operands, :intptr, ">>") 611 609 612 610 when "urshifti" … … 615 613 cloopEmitShiftOperation(operands, :uint64, ">>") 616 614 when "urshiftp" 617 cloopEmitShiftOperation(operands, :uint , ">>")615 cloopEmitShiftOperation(operands, :uintptr, ">>") 618 616 619 617 when "muli" … … 622 620 cloopEmitOperation(operands, :int64, "*") 623 621 when "mulp" 624 cloopEmitOperation(operands, :int , "*")622 cloopEmitOperation(operands, :intptr, "*") 625 623 626 624 when "subi" … … 629 627 cloopEmitOperation(operands, :int64, "-") 630 628 when "subp" 631 cloopEmitOperation(operands, :int , "-")629 cloopEmitOperation(operands, :intptr, "-") 632 630 633 631 when "negi" … … 636 634 cloopEmitUnaryOperation(operands, :int64, "-") 637 635 when "negp" 638 cloopEmitUnaryOperation(operands, :int , "-")636 cloopEmitUnaryOperation(operands, :intptr, "-") 639 637 640 638 when "noti" … … 650 648 $asm.putc "#{operands[1].clLValue(:int64)} = #{operands[0].int64MemRef};" 651 649 when "loadp" 652 $asm.putc "#{operands[1].clLValue} = #{operands[0].int MemRef};"650 $asm.putc "#{operands[1].clLValue} = #{operands[0].intptrMemRef};" 653 651 when "storei" 654 652 $asm.putc "#{operands[1].int32MemRef} = #{operands[0].clValue(:int32)};" … … 656 654 $asm.putc "#{operands[1].int64MemRef} = #{operands[0].clValue(:int64)};" 657 655 when "storep" 658 $asm.putc "#{operands[1].int MemRef} = #{operands[0].clValue(:int)};"656 $asm.putc "#{operands[1].intptrMemRef} = #{operands[0].clValue(:intptr)};" 659 657 when "loadb" 660 $asm.putc "#{operands[1].clLValue(:int )} = #{operands[0].uint8MemRef};"658 $asm.putc "#{operands[1].clLValue(:intptr)} = #{operands[0].uint8MemRef};" 661 659 when "loadbs" 662 $asm.putc "#{operands[1].clLValue(:int )} = (uint32_t)(#{operands[0].int8MemRef});"660 $asm.putc "#{operands[1].clLValue(:intptr)} = (uint32_t)(#{operands[0].int8MemRef});" 663 661 when "loadbsp" 664 $asm.putc "#{operands[1].clLValue(:int )} = #{operands[0].int8MemRef};"662 $asm.putc "#{operands[1].clLValue(:intptr)} = #{operands[0].int8MemRef};" 665 663 when "storeb" 666 664 $asm.putc "#{operands[1].uint8MemRef} = #{operands[0].clValue(:int8)};" 667 665 when "loadh" 668 $asm.putc "#{operands[1].clLValue(:int )} = #{operands[0].uint16MemRef};"666 $asm.putc "#{operands[1].clLValue(:intptr)} = #{operands[0].uint16MemRef};" 669 667 when "loadhs" 670 $asm.putc "#{operands[1].clLValue(:int )} = (uint32_t)(#{operands[0].int16MemRef});"668 $asm.putc "#{operands[1].clLValue(:intptr)} = (uint32_t)(#{operands[0].int16MemRef});" 671 669 when "storeh" 672 670 $asm.putc "*#{operands[1].uint16MemRef} = #{operands[0].clValue(:int16)};" … … 716 714 717 715 when "td2i" 718 $asm.putc "#{operands[1].clLValue(:int )} = (uint32_t)(intptr_t)#{operands[0].clValue(:double)}; // td2i"716 $asm.putc "#{operands[1].clLValue(:intptr)} = (uint32_t)(intptr_t)#{operands[0].clValue(:double)}; // td2i" 719 717 720 718 when "bcd2i" # operands: srcDbl dstInt slowPath … … 728 726 729 727 when "move" 730 $asm.putc "#{operands[1].clLValue(:int )} = #{operands[0].clValue(:int)};"728 $asm.putc "#{operands[1].clLValue(:intptr)} = #{operands[0].clValue(:intptr)};" 731 729 when "sxi2q" 732 730 $asm.putc "#{operands[1].clLValue(:int64)} = #{operands[0].clValue(:int32)};" … … 742 740 cloopEmitCompareAndBranch(operands, :int64, "==") 743 741 when "bpeq" 744 cloopEmitCompareAndBranch(operands, :int , "==")742 cloopEmitCompareAndBranch(operands, :intptr, "==") 745 743 746 744 when "bbneq" … … 751 749 cloopEmitCompareAndBranch(operands, :int64, "!=") 752 750 when "bpneq" 753 cloopEmitCompareAndBranch(operands, :int , "!=")751 cloopEmitCompareAndBranch(operands, :intptr, "!=") 754 752 755 753 when "bba" … … 760 758 cloopEmitCompareAndBranch(operands, :uint64, ">") 761 759 when "bpa" 762 cloopEmitCompareAndBranch(operands, :uint , ">")760 cloopEmitCompareAndBranch(operands, :uintptr, ">") 763 761 764 762 when "bbaeq" … … 769 767 cloopEmitCompareAndBranch(operands, :uint64, ">=") 770 768 when "bpaeq" 771 cloopEmitCompareAndBranch(operands, :uint , ">=")769 cloopEmitCompareAndBranch(operands, :uintptr, ">=") 772 770 773 771 when "bbb" … … 778 776 cloopEmitCompareAndBranch(operands, :uint64, "<") 779 777 when "bpb" 780 cloopEmitCompareAndBranch(operands, :uint , "<")778 cloopEmitCompareAndBranch(operands, :uintptr, "<") 781 779 782 780 when "bbbeq" … … 787 785 cloopEmitCompareAndBranch(operands, :uint64, "<=") 788 786 when "bpbeq" 789 cloopEmitCompareAndBranch(operands, :uint , "<=")787 cloopEmitCompareAndBranch(operands, :uintptr, "<=") 790 788 791 789 when "bbgt" … … 796 794 cloopEmitCompareAndBranch(operands, :int64, ">") 797 795 when "bpgt" 798 cloopEmitCompareAndBranch(operands, :int , ">")796 cloopEmitCompareAndBranch(operands, :intptr, ">") 799 797 800 798 when "bbgteq" … … 805 803 cloopEmitCompareAndBranch(operands, :int64, ">=") 806 804 when "bpgteq" 807 cloopEmitCompareAndBranch(operands, :int , ">=")805 cloopEmitCompareAndBranch(operands, :intptr, ">=") 808 806 809 807 when "bblt" … … 814 812 cloopEmitCompareAndBranch(operands, :int64, "<") 815 813 when "bplt" 816 cloopEmitCompareAndBranch(operands, :int , "<")814 cloopEmitCompareAndBranch(operands, :intptr, "<") 817 815 818 816 when "bblteq" … … 823 821 cloopEmitCompareAndBranch(operands, :int64, "<=") 824 822 when "bplteq" 825 cloopEmitCompareAndBranch(operands, :int , "<=")823 cloopEmitCompareAndBranch(operands, :intptr, "<=") 826 824 827 825 when "btbz" … … 832 830 cloopEmitTestAndBranchIf(operands, :int64, "== 0", operands[-1].cLabel) 833 831 when "btpz" 834 cloopEmitTestAndBranchIf(operands, :int , "== 0", operands[-1].cLabel)832 cloopEmitTestAndBranchIf(operands, :intptr, "== 0", operands[-1].cLabel) 835 833 836 834 when "btbnz" … … 841 839 cloopEmitTestAndBranchIf(operands, :int64, "!= 0", operands[-1].cLabel) 842 840 when "btpnz" 843 cloopEmitTestAndBranchIf(operands, :int , "!= 0", operands[-1].cLabel)841 cloopEmitTestAndBranchIf(operands, :intptr, "!= 0", operands[-1].cLabel) 844 842 845 843 when "btbs" … … 850 848 cloopEmitTestAndBranchIf(operands, :int64, "< 0", operands[-1].cLabel) 851 849 when "btps" 852 cloopEmitTestAndBranchIf(operands, :int , "< 0", operands[-1].cLabel)850 cloopEmitTestAndBranchIf(operands, :intptr, "< 0", operands[-1].cLabel) 853 851 854 852 # For jmp, we do not want to assume that we have COMPUTED_GOTO support. … … 886 884 cloopEmitCompareAndSet(operands, :uint64, "==") 887 885 when "cpeq" 888 cloopEmitCompareAndSet(operands, :uint , "==")886 cloopEmitCompareAndSet(operands, :uintptr, "==") 889 887 890 888 when "cbneq" … … 895 893 cloopEmitCompareAndSet(operands, :uint64, "!=") 896 894 when "cpneq" 897 cloopEmitCompareAndSet(operands, :uint , "!=")895 cloopEmitCompareAndSet(operands, :uintptr, "!=") 898 896 899 897 when "cba" … … 904 902 cloopEmitCompareAndSet(operands, :uint64, ">") 905 903 when "cpa" 906 cloopEmitCompareAndSet(operands, :uint , ">")904 cloopEmitCompareAndSet(operands, :uintptr, ">") 907 905 908 906 when "cbaeq" … … 913 911 cloopEmitCompareAndSet(operands, :uint64, ">=") 914 912 when "cpaeq" 915 cloopEmitCompareAndSet(operands, :uint , ">=")913 cloopEmitCompareAndSet(operands, :uintptr, ">=") 916 914 917 915 when "cbb" … … 922 920 cloopEmitCompareAndSet(operands, :uint64, "<") 923 921 when "cpb" 924 cloopEmitCompareAndSet(operands, :uint , "<")922 cloopEmitCompareAndSet(operands, :uintptr, "<") 925 923 926 924 when "cbbeq" … … 931 929 cloopEmitCompareAndSet(operands, :uint64, "<=") 932 930 when "cpbeq" 933 cloopEmitCompareAndSet(operands, :uint , "<=")931 cloopEmitCompareAndSet(operands, :uintptr, "<=") 934 932 935 933 when "cbgt" … … 940 938 cloopEmitCompareAndSet(operands, :int64, ">") 941 939 when "cpgt" 942 cloopEmitCompareAndSet(operands, :int , ">")940 cloopEmitCompareAndSet(operands, :intptr, ">") 943 941 944 942 when "cbgteq" … … 949 947 cloopEmitCompareAndSet(operands, :int64, ">=") 950 948 when "cpgteq" 951 cloopEmitCompareAndSet(operands, :int , ">=")949 cloopEmitCompareAndSet(operands, :intptr, ">=") 952 950 953 951 when "cblt" … … 958 956 cloopEmitCompareAndSet(operands, :int64, "<") 959 957 when "cplt" 960 cloopEmitCompareAndSet(operands, :int , "<")958 cloopEmitCompareAndSet(operands, :intptr, "<") 961 959 962 960 when "cblteq" … … 967 965 cloopEmitCompareAndSet(operands, :int64, "<=") 968 966 when "cplteq" 969 cloopEmitCompareAndSet(operands, :int , "<=")967 cloopEmitCompareAndSet(operands, :intptr, "<=") 970 968 971 969 when "tbs" … … 976 974 cloopEmitTestSet(operands, :int64, "< 0") 977 975 when "tps" 978 cloopEmitTestSet(operands, :int , "< 0")976 cloopEmitTestSet(operands, :intptr, "< 0") 979 977 980 978 when "tbz" … … 985 983 cloopEmitTestSet(operands, :int64, "== 0") 986 984 when "tpz" 987 cloopEmitTestSet(operands, :int , "== 0")985 cloopEmitTestSet(operands, :intptr, "== 0") 988 986 989 987 when "tbnz" … … 994 992 cloopEmitTestSet(operands, :int64, "!= 0") 995 993 when "tpnz" 996 cloopEmitTestSet(operands, :int , "!= 0")994 cloopEmitTestSet(operands, :intptr, "!= 0") 997 995 998 996 # 64-bit instruction: cdqi (based on X64) … … 1021 1019 $asm.putc "{ // idivi" 1022 1020 $asm.putc " int64_t dividend = (int64_t(t1.u32()) << 32) | t0.u32();" 1023 $asm.putc " int64_t divisor = #{operands[0].clValue(:int )};"1021 $asm.putc " int64_t divisor = #{operands[0].clValue(:intptr)};" 1024 1022 $asm.putc " t1 = (uint32_t)(dividend % divisor); // remainder" 1025 1023 $asm.putc " t0 = (uint32_t)(dividend / divisor); // quotient" … … 1049 1047 operands[0].cloopEmitLea(operands[1], :int32) 1050 1048 when "leap" 1051 operands[0].cloopEmitLea(operands[1], :int )1049 operands[0].cloopEmitLea(operands[1], :intptr) 1052 1050 1053 1051 when "baddio" … … 1073 1071 1074 1072 when "baddps" 1075 cloopEmitOpAndBranch(operands, "+", :int , "< 0")1073 cloopEmitOpAndBranch(operands, "+", :intptr, "< 0") 1076 1074 when "baddpz" 1077 cloopEmitOpAndBranch(operands, "+", :int , "== 0")1075 cloopEmitOpAndBranch(operands, "+", :intptr, "== 0") 1078 1076 when "baddpnz" 1079 cloopEmitOpAndBranch(operands, "+", :int , "!= 0")1077 cloopEmitOpAndBranch(operands, "+", :intptr, "!= 0") 1080 1078 1081 1079 when "bsubis"
Note:
See TracChangeset
for help on using the changeset viewer.